Project import
diff --git a/CoreFoundation/APPLE_LICENSE b/CoreFoundation/APPLE_LICENSE
new file mode 100644
index 0000000..fe81a60
--- /dev/null
+++ b/CoreFoundation/APPLE_LICENSE
@@ -0,0 +1,367 @@
+APPLE PUBLIC SOURCE LICENSE
+Version 2.0 - August 6, 2003
+
+Please read this License carefully before downloading this software.
+By downloading or using this software, you are agreeing to be bound by
+the terms of this License. If you do not or cannot agree to the terms
+of this License, please do not download or use the software.
+
+1. General; Definitions. This License applies to any program or other
+work which Apple Computer, Inc. ("Apple") makes publicly available and
+which contains a notice placed by Apple identifying such program or
+work as "Original Code" and stating that it is subject to the terms of
+this Apple Public Source License version 2.0 ("License"). As used in
+this License:
+
+1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is
+the grantor of rights, (i) claims of patents that are now or hereafter
+acquired, owned by or assigned to Apple and (ii) that cover subject
+matter contained in the Original Code, but only to the extent
+necessary to use, reproduce and/or distribute the Original Code
+without infringement; and (b) in the case where You are the grantor of
+rights, (i) claims of patents that are now or hereafter acquired,
+owned by or assigned to You and (ii) that cover subject matter in Your
+Modifications, taken alone or in combination with Original Code.
+
+1.2 "Contributor" means any person or entity that creates or
+contributes to the creation of Modifications.
+
+1.3 "Covered Code" means the Original Code, Modifications, the
+combination of Original Code and any Modifications, and/or any
+respective portions thereof.
+
+1.4 "Externally Deploy" means: (a) to sublicense, distribute or
+otherwise make Covered Code available, directly or indirectly, to
+anyone other than You; and/or (b) to use Covered Code, alone or as
+part of a Larger Work, in any way to provide a service, including but
+not limited to delivery of content, through electronic communication
+with a client other than You.
+
+1.5 "Larger Work" means a work which combines Covered Code or portions
+thereof with code not governed by the terms of this License.
+
+1.6 "Modifications" mean any addition to, deletion from, and/or change
+to, the substance and/or structure of the Original Code, any previous
+Modifications, the combination of Original Code and any previous
+Modifications, and/or any respective portions thereof. When code is
+released as a series of files, a Modification is: (a) any addition to
+or deletion from the contents of a file containing Covered Code;
+and/or (b) any new file or other representation of computer program
+statements that contains any part of Covered Code.
+
+1.7 "Original Code" means (a) the Source Code of a program or other
+work as originally made available by Apple under this License,
+including the Source Code of any updates or upgrades to such programs
+or works made available by Apple under this License, and that has been
+expressly identified by Apple as such in the header file(s) of such
+work; and (b) the object code compiled from such Source Code and
+originally made available by Apple under this License.
+
+1.8 "Source Code" means the human readable form of a program or other
+work that is suitable for making modifications to it, including all
+modules it contains, plus any associated interface definition files,
+scripts used to control compilation and installation of an executable
+(object code).
+
+1.9 "You" or "Your" means an individual or a legal entity exercising
+rights under this License. For legal entities, "You" or "Your"
+includes any entity which controls, is controlled by, or is under
+common control with, You, where "control" means (a) the power, direct
+or indirect, to cause the direction or management of such entity,
+whether by contract or otherwise, or (b) ownership of fifty percent
+(50%) or more of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Permitted Uses; Conditions & Restrictions. Subject to the terms
+and conditions of this License, Apple hereby grants You, effective on
+the date You accept this License and download the Original Code, a
+world-wide, royalty-free, non-exclusive license, to the extent of
+Apple's Applicable Patent Rights and copyrights covering the Original
+Code, to do the following:
+
+2.1 Unmodified Code. You may use, reproduce, display, perform,
+internally distribute within Your organization, and Externally Deploy
+verbatim, unmodified copies of the Original Code, for commercial or
+non-commercial purposes, provided that in each instance:
+
+(a) You must retain and reproduce in all copies of Original Code the
+copyright and other proprietary notices and disclaimers of Apple as
+they appear in the Original Code, and keep intact all notices in the
+Original Code that refer to this License; and
+
+(b) You must include a copy of this License with every copy of Source
+Code of Covered Code and documentation You distribute or Externally
+Deploy, and You may not offer or impose any terms on such Source Code
+that alter or restrict this License or the recipients' rights
+hereunder, except as permitted under Section 6.
+
+2.2 Modified Code. You may modify Covered Code and use, reproduce,
+display, perform, internally distribute within Your organization, and
+Externally Deploy Your Modifications and Covered Code, for commercial
+or non-commercial purposes, provided that in each instance You also
+meet all of these conditions:
+
+(a) You must satisfy all the conditions of Section 2.1 with respect to
+the Source Code of the Covered Code;
+
+(b) You must duplicate, to the extent it does not already exist, the
+notice in Exhibit A in each file of the Source Code of all Your
+Modifications, and cause the modified files to carry prominent notices
+stating that You changed the files and the date of any change; and
+
+(c) If You Externally Deploy Your Modifications, You must make
+Source Code of all Your Externally Deployed Modifications either
+available to those to whom You have Externally Deployed Your
+Modifications, or publicly available. Source Code of Your Externally
+Deployed Modifications must be released under the terms set forth in
+this License, including the license grants set forth in Section 3
+below, for as long as you Externally Deploy the Covered Code or twelve
+(12) months from the date of initial External Deployment, whichever is
+longer. You should preferably distribute the Source Code of Your
+Externally Deployed Modifications electronically (e.g. download from a
+web site).
+
+2.3 Distribution of Executable Versions. In addition, if You
+Externally Deploy Covered Code (Original Code and/or Modifications) in
+object code, executable form only, You must include a prominent
+notice, in the code itself as well as in related documentation,
+stating that Source Code of the Covered Code is available under the
+terms of this License with information on how and where to obtain such
+Source Code.
+
+2.4 Third Party Rights. You expressly acknowledge and agree that
+although Apple and each Contributor grants the licenses to their
+respective portions of the Covered Code set forth herein, no
+assurances are provided by Apple or any Contributor that the Covered
+Code does not infringe the patent or other intellectual property
+rights of any other entity. Apple and each Contributor disclaim any
+liability to You for claims brought by any other entity based on
+infringement of intellectual property rights or otherwise. As a
+condition to exercising the rights and licenses granted hereunder, You
+hereby assume sole responsibility to secure any other intellectual
+property rights needed, if any. For example, if a third party patent
+license is required to allow You to distribute the Covered Code, it is
+Your responsibility to acquire that license before distributing the
+Covered Code.
+
+3. Your Grants. In consideration of, and as a condition to, the
+licenses granted to You under this License, You hereby grant to any
+person or entity receiving or distributing Covered Code under this
+License a non-exclusive, royalty-free, perpetual, irrevocable license,
+under Your Applicable Patent Rights and other intellectual property
+rights (other than patent) owned or controlled by You, to use,
+reproduce, display, perform, modify, sublicense, distribute and
+Externally Deploy Your Modifications of the same scope and extent as
+Apple's licenses under Sections 2.1 and 2.2 above.
+
+4. Larger Works. You may create a Larger Work by combining Covered
+Code with other code not governed by the terms of this License and
+distribute the Larger Work as a single product. In each such instance,
+You must make sure the requirements of this License are fulfilled for
+the Covered Code or any portion thereof.
+
+5. Limitations on Patent License. Except as expressly stated in
+Section 2, no other patent rights, express or implied, are granted by
+Apple herein. Modifications and/or Larger Works may require additional
+patent licenses from Apple which Apple may grant in its sole
+discretion.
+
+6. Additional Terms. You may choose to offer, and to charge a fee for,
+warranty, support, indemnity or liability obligations and/or other
+rights consistent with the scope of the license granted herein
+("Additional Terms") to one or more recipients of Covered Code.
+However, You may do so only on Your own behalf and as Your sole
+responsibility, and not on behalf of Apple or any Contributor. You
+must obtain the recipient's agreement that any such Additional Terms
+are offered by You alone, and You hereby agree to indemnify, defend
+and hold Apple and every Contributor harmless for any liability
+incurred by or claims asserted against Apple or such Contributor by
+reason of any such Additional Terms.
+
+7. Versions of the License. Apple may publish revised and/or new
+versions of this License from time to time. Each version will be given
+a distinguishing version number. Once Original Code has been published
+under a particular version of this License, You may continue to use it
+under the terms of that version. You may also choose to use such
+Original Code under the terms of any subsequent version of this
+License published by Apple. No one other than Apple has the right to
+modify the terms applicable to Covered Code created under this
+License.
+
+8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in
+part pre-release, untested, or not fully tested works. The Covered
+Code may contain errors that could cause failures or loss of data, and
+may be incomplete or contain inaccuracies. You expressly acknowledge
+and agree that use of the Covered Code, or any portion thereof, is at
+Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND
+WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND
+APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE
+PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM
+ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT
+NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
+MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR
+PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD
+PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST
+INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE
+FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS,
+THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR
+ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO
+ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE
+AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY.
+You acknowledge that the Covered Code is not intended for use in the
+operation of nuclear facilities, aircraft navigation, communication
+systems, or air traffic control machines in which case the failure of
+the Covered Code could lead to death, personal injury, or severe
+physical or environmental damage.
+
+9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
+EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL,
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING
+TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
+ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY,
+TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF
+APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY
+REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY
+TO YOU. In no event shall Apple's total liability to You for all
+damages (other than as may be required by applicable law) under this
+License exceed the amount of fifty dollars ($50.00).
+
+10. Trademarks. This License does not grant any rights to use the
+trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS",
+"QuickTime", "QuickTime Streaming Server" or any other trademarks,
+service marks, logos or trade names belonging to Apple (collectively
+"Apple Marks") or to any trademark, service mark, logo or trade name
+belonging to any Contributor. You agree not to use any Apple Marks in
+or as part of the name of products derived from the Original Code or
+to endorse or promote products derived from the Original Code other
+than as expressly permitted by and in strict compliance at all times
+with Apple's third party trademark usage guidelines which are posted
+at http://www.apple.com/legal/guidelinesfor3rdparties.html.
+
+11. Ownership. Subject to the licenses granted under this License,
+each Contributor retains all rights, title and interest in and to any
+Modifications made by such Contributor. Apple retains all rights,
+title and interest in and to the Original Code and any Modifications
+made by or on behalf of Apple ("Apple Modifications"), and such Apple
+Modifications will not be automatically subject to this License. Apple
+may, at its sole discretion, choose to license such Apple
+Modifications under this License, or on different terms from those
+contained in this License or may choose not to license them at all.
+
+12. Termination.
+
+12.1 Termination. This License and the rights granted hereunder will
+terminate:
+
+(a) automatically without notice from Apple if You fail to comply with
+any term(s) of this License and fail to cure such breach within 30
+days of becoming aware of such breach;
+
+(b) immediately in the event of the circumstances described in Section
+13.5(b); or
+
+(c) automatically without notice from Apple if You, at any time during
+the term of this License, commence an action for patent infringement
+against Apple; provided that Apple did not first commence
+an action for patent infringement against You in that instance.
+
+12.2 Effect of Termination. Upon termination, You agree to immediately
+stop any further use, reproduction, modification, sublicensing and
+distribution of the Covered Code. All sublicenses to the Covered Code
+which have been properly granted prior to termination shall survive
+any termination of this License. Provisions which, by their nature,
+should remain in effect beyond the termination of this License shall
+survive, including but not limited to Sections 3, 5, 8, 9, 10, 11,
+12.2 and 13. No party will be liable to any other for compensation,
+indemnity or damages of any sort solely as a result of terminating
+this License in accordance with its terms, and termination of this
+License will be without prejudice to any other right or remedy of
+any party.
+
+13. Miscellaneous.
+
+13.1 Government End Users. The Covered Code is a "commercial item" as
+defined in FAR 2.101. Government software and technical data rights in
+the Covered Code include only those rights customarily provided to the
+public as defined in this License. This customary commercial license
+in technical data and software is provided in accordance with FAR
+12.211 (Technical Data) and 12.212 (Computer Software) and, for
+Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
+Commercial Items) and 227.7202-3 (Rights in Commercial Computer
+Software or Computer Software Documentation). Accordingly, all U.S.
+Government End Users acquire Covered Code with only those rights set
+forth herein.
+
+13.2 Relationship of Parties. This License will not be construed as
+creating an agency, partnership, joint venture or any other form of
+legal association between or among You, Apple or any Contributor, and
+You will not represent to the contrary, whether expressly, by
+implication, appearance or otherwise.
+
+13.3 Independent Development. Nothing in this License will impair
+Apple's right to acquire, license, develop, have others develop for
+it, market and/or distribute technology or products that perform the
+same or similar functions as, or otherwise compete with,
+Modifications, Larger Works, technology or products that You may
+develop, produce, market or distribute.
+
+13.4 Waiver; Construction. Failure by Apple or any Contributor to
+enforce any provision of this License will not be deemed a waiver of
+future enforcement of that or any other provision. Any law or
+regulation which provides that the language of a contract shall be
+construed against the drafter will not apply to this License.
+
+13.5 Severability. (a) If for any reason a court of competent
+jurisdiction finds any provision of this License, or portion thereof,
+to be unenforceable, that provision of the License will be enforced to
+the maximum extent permissible so as to effect the economic benefits
+and intent of the parties, and the remainder of this License will
+continue in full force and effect. (b) Notwithstanding the foregoing,
+if applicable law prohibits or restricts You from fully and/or
+specifically complying with Sections 2 and/or 3 or prevents the
+enforceability of either of those Sections, this License will
+immediately terminate and You must immediately discontinue any use of
+the Covered Code and destroy all copies of it that are in your
+possession or control.
+
+13.6 Dispute Resolution. Any litigation or other dispute resolution
+between You and Apple relating to this License shall take place in the
+Northern District of California, and You and Apple hereby consent to
+the personal jurisdiction of, and venue in, the state and federal
+courts within that District with respect to this License. The
+application of the United Nations Convention on Contracts for the
+International Sale of Goods is expressly excluded.
+
+13.7 Entire Agreement; Governing Law. This License constitutes the
+entire agreement between the parties with respect to the subject
+matter hereof. This License shall be governed by the laws of the
+United States and the State of California, except that body of
+California law concerning conflicts of law.
+
+Where You are located in the province of Quebec, Canada, the following
+clause applies: The parties hereby confirm that they have requested
+that this License and all related documents be drafted in English. Les
+parties ont exige que le present contrat et tous les documents
+connexes soient rediges en anglais.
+
+EXHIBIT A.
+
+"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
+Reserved.
+
+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."
diff --git a/CoreFoundation/Android.mk b/CoreFoundation/Android.mk
new file mode 100644
index 0000000..124957f
--- /dev/null
+++ b/CoreFoundation/Android.mk
@@ -0,0 +1,131 @@
+LOCAL_PATH := $(call my-dir)
+
+opencflite_src_files := \
+CFApplicationPreferences.c \
+CFArray.c \
+CFBag.c \
+CFBase.c \
+CFBinaryHeap.c \
+CFBinaryPList.c \
+CFBitVector.c \
+CFBuiltinConverters.c \
+CFBundle.c \
+CFBundle_Resources.c \
+CFCalendar.c \
+CFCharacterSet.c \
+CFConcreteStreams.c \
+CFData.c \
+CFDate.c \
+CFDateFormatter.c \
+CFDictionary.c \
+CFError.c \
+CFFileUtilities.c \
+CFLocale.c \
+CFLocaleIdentifier.c \
+CFNumber.c \
+CFNumberFormatter.c \
+CFPlatform.c \
+CFPlugIn.c \
+CFPlugIn_Factory.c \
+CFPlugIn_PlugIn.c \
+CFPreferences.c \
+CFPropertyList.c \
+CFRunLoop.c \
+CFRuntime.c \
+CFSet.c \
+CFSocket.c \
+CFSocketStream.c \
+CFSortFunctions.c \
+CFStorage.c \
+CFStream.c \
+CFString.c \
+CFStringEncodingConverter.c \
+CFStringEncodings.c \
+CFStringScanner.c \
+CFStringUtilities.c \
+CFSystemDirectories.c \
+CFTimeZone.c \
+CFTree.c \
+CFUniChar.c \
+CFUnicodeDecomposition.c \
+CFUnicodePrecomposition.c \
+CFURLAccess.c \
+CFURL.c \
+CFUtilities.c \
+CFUUID.c \
+CFVersion.c \
+CFWindowsMessageQueue.c \
+CFXMLPreferencesDomain.c \
+compat/flsl.c
+
+# disabled for now
+#CFMachPort.c
+#CFMessagePort.c
+#CFPlugIn_Instance.c
+#CFUserNotification.c
+#CFXMLInputStream.c
+#CFXMLNode.c
+#CFXMLParser.c
+#CFXMLTree.c
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libopencflite
+LOCAL_SRC_FILES := $(opencflite_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/icu/icu4c/source/common/
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/icu/icu4c/source/i18n/
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/icu/icu4c/source/tools/tzcode/
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/opencflite/libBlocksRuntime/
+# todo: remove Linux case
+LOCAL_EXPORT_CFLAGS := -DDEPLOYMENT_TARGET_LINUX -DDEPLOYMENT_TARGET_ANDROID
+LOCAL_CFLAGS = -x c -fblocks -std=gnu99 -Wno-trigraphs -fexceptions -DCF_BUILDING_CF=1 -DDISABLE_GCD -nostdlibinc -D__kCFDataDir=\"/etc/opencflite\" $(LOCAL_EXPORT_CFLAGS) -Wno-infinite-recursion -Wno-unused-parameter -Wno-unsequenced -Wno-date-time -Wno-implicit -Wno-tautological-pointer-compare
+#note: not all flags from MakefileLinux have been ported over.
+LOCAL_LDFLAGS = -fpic
+LOCAL_SHARED_LIBRARIES += libicuuc libicui18n
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libopencflite
+LOCAL_SRC_FILES := $(opencflite_src_files)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/icu/icu4c/source/common/
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/icu/icu4c/source/i18n/
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/icu/icu4c/source/tools/tzcode/
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/opencflite/libBlocksRuntime/
+# todo: remove Linux case
+LOCAL_EXPORT_CFLAGS := -DDEPLOYMENT_TARGET_LINUX -DDEPLOYMENT_TARGET_ANDROID
+LOCAL_CFLAGS = -x c -fblocks -std=gnu99 -Wno-trigraphs -fexceptions -DCF_BUILDING_CF=1 -DDISABLE_GCD -nostdlibinc -D__kCFDataDir=\"/etc/opencflite\" $(LOCAL_EXPORT_CFLAGS) -Wno-infinite-recursion -Wno-unused-parameter -Wno-unsequenced -Wno-date-time -Wno-implicit -Wno-tautological-pointer-compare
+#note: not all flags from MakefileLinux have been ported over.
+LOCAL_LDFLAGS = -fpic
+LOCAL_STATIC_LIBRARIES += libicuuc_static libicui18n_static
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CFCharacterSetBitmaps.bitmap
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/opencflite/CoreFoundation/CharacterSets
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES := CFCharacterSetBitmaps.bitmap
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CFUnicodeData-B.mapping
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/opencflite/CoreFoundation/CharacterSets
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES := CFUnicodeData-B.mapping
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CFUniCharPropertyDatabase.data
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/opencflite/CoreFoundation/CharacterSets
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES := CFUniCharPropertyDatabase.data
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CFUnicodeData-L.mapping
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/opencflite/CoreFoundation/CharacterSets
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES := CFUnicodeData-L.mapping
+include $(BUILD_PREBUILT)
diff --git a/CoreFoundation/BuildCFLite b/CoreFoundation/BuildCFLite
new file mode 100644
index 0000000..bbde7dd
--- /dev/null
+++ b/CoreFoundation/BuildCFLite
@@ -0,0 +1,92 @@
+#/bin/sh
+
+echo "Setup ..."
+
+ALL_CFILES=`ls *.c`
+ALL_HFILES=`ls *.h`
+
+MACHINE_TYPE=`uname -p`
+UNICODE_DATA_FILE="UNKNOWN"
+
+if [ "$MACHINE_TYPE" == "i386" ]; then
+	UNICODE_DATA_FILE="CFUnicodeData-L.mapping"
+fi
+
+if [ "$MACHINE_TYPE" == "powerpc" ]; then
+	UNICODE_DATA_FILE="CFUnicodeData-B.mapping"
+fi
+
+
+
+PUBLIC_HEADERS="CFArray.h CFBag.h CFBase.h CFBinaryHeap.h CFBitVector.h CFBundle.h CFByteOrder.h CFCalendar.h CFCharacterSet.h CFData.h CFDate.h CFDateFormatter.h CFDictionary.h CFError.h CFLocale.h CFMachPort.h CFMessagePort.h CFNumber.h CFNumberFormatter.h CFPlugIn.h CFPlugInCOM.h CFPreferences.h CFPropertyList.h CFRunLoop.h CFSet.h CFSocket.h CFStream.h CFString.h CFStringEncodingExt.h CFTimeZone.h CFTree.h CFURL.h CFURLAccess.h CFUUID.h CFUserNotification.h CFXMLNode.h CFXMLParser.h CoreFoundation.h"
+PRIVATE_HEADERS="CFBundlePriv.h CFCharacterSetPriv.h CFError_Private.h CFLogUtilities.h CFPriv.h CFRuntime.h CFStorage.h CFStreamAbstract.h CFStreamPriv.h CFStreamInternal.h CFStringDefaultEncoding.h CFStringEncodingConverter.h CFStringEncodingConverterExt.h CFUniChar.h CFUnicodeDecomposition.h CFUnicodePrecomposition.h ForFoundationOnly.h"
+
+OBJBASE=../CF-Objects
+ARCHFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+CFLAGS="-c -pipe -std=gnu99 -g -Wmost -Wno-trigraphs -mmacosx-version-min=10.5 -fconstant-cfstrings -fexceptions -DCF_BUILDING_CF=1 -DDEPLOYMENT_TARGET_MACOSX=1 -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5 -DU_SHOW_DRAFT_API=1 -I$OBJBASE -I. -I./include/mach_support -DVERSION=476.17"
+LFLAGS="-dynamiclib -mmacosx-version-min=10.5 -twolevel_namespace -init ___CFInitialize -compatibility_version 150 -current_version 476 -sectcreate __UNICODE __csbitmaps CFCharacterSetBitmaps.bitmap -sectcreate __UNICODE __properties CFUniCharPropertyDatabase.data -sectcreate __UNICODE __data $UNICODE_DATA_FILE -segprot __UNICODE r r"
+
+/bin/rm -rf $OBJBASE
+/bin/mkdir -p $OBJBASE
+/bin/mkdir $OBJBASE/normal
+/bin/mkdir $OBJBASE/CoreFoundation
+/bin/cp $ALL_HFILES $OBJBASE/CoreFoundation
+if [ $? -ne 0 ]; then
+	echo "Setup failed"
+	exit 1
+fi
+
+Build () {
+	echo "Compiling $STYLE ..."
+	for F in $ALL_CFILES ; do
+		echo /usr/bin/gcc $STYLE_CFLAGS $ARCHFLAGS $CFLAGS $F -o $OBJBASE/$STYLE/`basename $F .c`.o
+		/usr/bin/gcc $STYLE_CFLAGS $ARCHFLAGS $CFLAGS $F -o $OBJBASE/$STYLE/`basename $F .c`.o
+		if [ $? -ne 0 ]; then
+			echo "*** Compiling $STYLE failed ***"
+			exit 1
+		fi
+	done
+	echo "Linking $STYLE ..."
+	echo /usr/bin/gcc $STYLE_LFLAGS -install_name /System/Library/Frameworks/CFLite.framework/Versions/A/CFLite_$STYLE $ARCHFLAGS $LFLAGS $OBJBASE/$STYLE/*.o -licucore.A -lobjc -o $OBJBASE/CFLite_$STYLE
+	/usr/bin/gcc $STYLE_LFLAGS -install_name /System/Library/Frameworks/CFLite.framework/Versions/A/CFLite_$STYLE $ARCHFLAGS $LFLAGS $OBJBASE/$STYLE/*.o -licucore.A -lobjc -o $OBJBASE/CFLite_$STYLE
+	if [ $? -ne 0 ]; then
+		echo "*** Linking $STYLE failed ***"
+		exit 1
+	fi
+}
+
+STYLE=normal
+STYLE_CFLAGS="-O0"
+STYLE_LFLAGS=
+Build
+
+echo "Building done."
+
+echo "Installing ..."
+if [ -z "$DSTBASE" ]; then DSTBASE=../CF-Root ; fi
+
+/bin/rm -rf $DSTBASE/CFLite.framework
+/bin/mkdir -p $DSTBASE/CFLite.framework/Versions/A/Resources
+/bin/mkdir -p $DSTBASE/CFLite.framework/Versions/A/Headers
+/bin/mkdir -p $DSTBASE/CFLite.framework/Versions/A/PrivateHeaders
+/bin/ln -sf A $DSTBASE/CFLite.framework/Versions/Current
+/bin/ln -sf Versions/Current/Resources $DSTBASE/CFLite.framework/Resources
+/bin/ln -sf Versions/Current/Headers $DSTBASE/CFLite.framework/Headers
+/bin/ln -sf Versions/Current/PrivateHeaders $DSTBASE/CFLite.framework/PrivateHeaders
+/bin/ln -sf Versions/Current/CFLite $DSTBASE/CFLite.framework/CFLite
+/bin/cp Info.plist $DSTBASE/CFLite.framework/Versions/A/Resources
+/bin/mkdir -p $DSTBASE/CFLite.framework/Versions/A/Resources/en.lproj
+/bin/cp $PUBLIC_HEADERS $DSTBASE/CFLite.framework/Versions/A/Headers
+/bin/cp $PRIVATE_HEADERS $DSTBASE/CFLite.framework/Versions/A/PrivateHeaders
+#/usr/bin/strip -S -o $DSTBASE/CFLite.framework/Versions/A/CFLite $OBJBASE/CFLite_normal
+/bin/cp $OBJBASE/CFLite_normal $DSTBASE/CFLite.framework/Versions/A/CFLite 
+/usr/sbin/chown -RH -f root:wheel $DSTBASE/CFLite.framework
+/bin/chmod -RH a-w,a+rX $DSTBASE/CFLite.framework
+/bin/chmod -RH u+w $DSTBASE
+
+install_name_tool -id /System/Library/Frameworks/CFLite.framework/Versions/A/CFLite $DSTBASE/CFLite.framework/Versions/A/CFLite
+
+echo "Installing done.  The framework is in $DSTBASE"
+
+exit 0
+
diff --git a/CoreFoundation/BuildCFLite.windows b/CoreFoundation/BuildCFLite.windows
new file mode 100644
index 0000000..ba0ab1e
--- /dev/null
+++ b/CoreFoundation/BuildCFLite.windows
@@ -0,0 +1,101 @@
+#/bin/sh
+
+echo "Setup ..."
+
+ALL_CFILES=`ls *.c`
+ALL_HFILES=`ls *.h`
+CC="/mingw/bin/gcc"
+AR="/mingw/bin/ar"
+
+MACHINE_TYPE=`uname -p`
+UNICODE_DATA_FILE="UNKNOWN"
+# DEPLOYMENT_TARGET="-DDEPLOYMENT_TARGET_MACOSX=1"
+DEPLOYMENT_TARGET="-DDEPLOYMENT_TARGET_WIN32=1"
+#MACOSVERS="-mmacosx-version-min=10.5 -fconstant-cfstrings"
+MACOSVERS=""
+#WARNINGS="-Wmost"
+WARNINGS=""
+
+if [ "$MACHINE_TYPE" == "i386" ]; then
+	UNICODE_DATA_FILE="CFUnicodeData-L.mapping"
+fi
+
+if [ "$MACHINE_TYPE" == "powerpc" ]; then
+	UNICODE_DATA_FILE="CFUnicodeData-B.mapping"
+fi
+
+
+
+PUBLIC_HEADERS="CFArray.h CFBag.h CFBase.h CFBinaryHeap.h CFBitVector.h CFBundle.h CFByteOrder.h CFCalendar.h CFCharacterSet.h CFData.h CFDate.h CFDateFormatter.h CFDictionary.h CFError.h CFLocale.h CFMachPort.h CFMessagePort.h CFNumber.h CFNumberFormatter.h CFPlugIn.h CFPlugInCOM.h CFPreferences.h CFPropertyList.h CFRunLoop.h CFSet.h CFSocket.h CFStream.h CFString.h CFStringEncodingExt.h CFTimeZone.h CFTree.h CFURL.h CFURLAccess.h CFUUID.h CFUserNotification.h CFXMLNode.h CFXMLParser.h CoreFoundation.h"
+PRIVATE_HEADERS="CFBundlePriv.h CFCharacterSetPriv.h CFError_Private.h CFLogUtilities.h CFPriv.h CFRuntime.h CFStorage.h CFStreamAbstract.h CFStreamPriv.h CFStreamInternal.h CFStringDefaultEncoding.h CFStringEncodingConverter.h CFStringEncodingConverterExt.h CFUniChar.h CFUnicodeDecomposition.h CFUnicodePrecomposition.h ForFoundationOnly.h"
+
+OBJBASE=../CF-Objects
+#ARCHFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+ARCHFLAGS=""
+CFLAGS="-c -pipe -std=gnu99 -g $WARNINGS -Wno-trigraphs $MACOSVERS -fexceptions -DCF_BUILDING_CF=1 $DEPLOYMENT_TARGET -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5 -DU_SHOW_DRAFT_API=1 -I. -I./Compatability -I$OBJBASE -DVERSION=476.17 -DWINVER=0x0500 -D_WIN32_WINNT=0x0501"
+# LFLAGS="-dynamiclib -mmacosx-version-min=10.5 -twolevel_namespace -init ___CFInitialize -compatibility_version 150 -current_version 476 -sectcreate __UNICODE __csbitmaps CFCharacterSetBitmaps.bitmap -sectcreate __UNICODE __properties CFUniCharPropertyDatabase.data -sectcreate __UNICODE __data $UNICODE_DATA_FILE -segprot __UNICODE r r"
+LFLAGS="-lmsvcrt -lnetapi32 -lobjc -lole32 -lws2_32 -lkernel32 -lrpcrt4"
+
+/bin/rm -rf $OBJBASE
+/bin/mkdir -p $OBJBASE
+/bin/mkdir $OBJBASE/normal
+/bin/mkdir $OBJBASE/CoreFoundation
+/bin/cp $ALL_HFILES $OBJBASE/CoreFoundation
+if [ $? -ne 0 ]; then
+	echo "Setup failed"
+	exit 1
+fi
+
+Build () {
+	echo "Compiling $STYLE ..."
+	for F in $ALL_CFILES ; do
+		echo $CC $STYLE_CFLAGS $ARCHFLAGS $CFLAGS $F -o $OBJBASE/$STYLE/`basename $F .c`.o
+		$CC $STYLE_CFLAGS $ARCHFLAGS $CFLAGS $F -o $OBJBASE/$STYLE/`basename $F .c`.o
+		if [ $? -ne 0 ]; then
+			echo "*** Compiling $STYLE failed ***"
+			exit 1
+		fi
+	done
+	echo "Linking $STYLE ..."
+	echo $CC $STYLE_LFLAGS $ARCHFLAGS $OBJBASE/$STYLE/*.o $LFLAGS -licuuc -licuin -lobjc -o $OBJBASE/CoreFoundation_$STYLE
+	$CC -shared $STYLE_LFLAGS $ARCHFLAGS $OBJBASE/$STYLE/*.o $LFLAGS lib/icuuc.lib lib/icuin.lib -lobjc -o $OBJBASE/libCFlite_476_17.dll
+	if [ $? -ne 0 ]; then
+		echo "*** Linking $STYLE failed ***"
+		exit 1
+	fi
+}
+
+STYLE=normal
+STYLE_CFLAGS="-O2"
+STYLE_LFLAGS=
+Build
+
+echo "Building done."
+
+echo "Installing ..."
+if [ -z "$DSTBASE" ]; then DSTBASE=../CF-Root ; fi
+
+/bin/rm -rf $DSTBASE/CoreFoundation.framework
+/bin/mkdir -p $DSTBASE/CoreFoundation.framework/Versions/A/Resources
+/bin/mkdir -p $DSTBASE/CoreFoundation.framework/Versions/A/Headers
+/bin/mkdir -p $DSTBASE/CoreFoundation.framework/Versions/A/PrivateHeaders
+/bin/ln -sf A $DSTBASE/CoreFoundation.framework/Versions/Current
+/bin/ln -sf Versions/Current/Resources $DSTBASE/CoreFoundation.framework/Resources
+/bin/ln -sf Versions/Current/Headers $DSTBASE/CoreFoundation.framework/Headers
+/bin/ln -sf Versions/Current/PrivateHeaders $DSTBASE/CoreFoundation.framework/PrivateHeaders
+/bin/ln -sf Versions/Current/CoreFoundation $DSTBASE/CoreFoundation.framework/CoreFoundation
+/bin/cp Info.plist $DSTBASE/CoreFoundation.framework/Versions/A/Resources
+/bin/mkdir -p $DSTBASE/CoreFoundation.framework/Versions/A/Resources/en.lproj
+/bin/cp $PUBLIC_HEADERS $DSTBASE/CoreFoundation.framework/Versions/A/Headers
+/bin/cp $PRIVATE_HEADERS $DSTBASE/CoreFoundation.framework/Versions/A/PrivateHeaders
+/usr/bin/strip -S -o $DSTBASE/CoreFoundation.framework/Versions/A/CoreFoundation $OBJBASE/CoreFoundation_normal
+/usr/sbin/chown -RH -f root:wheel $DSTBASE/CoreFoundation.framework
+/bin/chmod -RH a-w,a+rX $DSTBASE/CoreFoundation.framework
+/bin/chmod -RH u+w $DSTBASE
+
+install_name_tool -id /System/Library/Frameworks/CoreFoundation/Versions/A/CoreFoundation $DSTBASE/CoreFoundation.framework/Versions/A/CoreFoundation
+
+echo "Installing done.  The framework is in $DSTBASE"
+
+exit 0
+
diff --git a/CoreFoundation/CFApplicationPreferences.c b/CoreFoundation/CFApplicationPreferences.c
new file mode 100644
index 0000000..2f5c68f
--- /dev/null
+++ b/CoreFoundation/CFApplicationPreferences.c
@@ -0,0 +1,682 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFApplicationPreferences.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Chris Parker
+*/
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFPreferences.h>
+#include <CoreFoundation/CFUniChar.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFLocale.h>
+#include <CoreFoundation/CFNumberFormatter.h>
+#include <CoreFoundation/CFDateFormatter.h>
+#include <sys/types.h>
+#if __MACH__
+#include <unistd.h>
+#endif
+
+static Boolean _CFApplicationPreferencesSynchronizeNoLock(_CFApplicationPreferences *self);
+void _CFPreferencesDomainSetMultiple(CFPreferencesDomainRef domain, CFDictionaryRef dict);
+static void updateDictRep(_CFApplicationPreferences *self);
+static void _CFApplicationPreferencesSetSearchList(_CFApplicationPreferences *self, CFArrayRef newSearchList);
+Boolean _CFApplicationPreferencesContainsDomainNoLock(_CFApplicationPreferences *self, CFPreferencesDomainRef domain);
+static CFTypeRef _CFApplicationPreferencesCreateValueForKey2(_CFApplicationPreferences *self, CFStringRef defaultName);
+
+// Right now, nothing is getting destroyed pretty much ever.  We probably don't want this to be the case, but it's very tricky - domains live in the cache as well as a given application's preferences, and since they're not CFTypes, there's no reference count.  Also, it's not clear we ever want domains destroyed.  When they're synchronized, they clear their internal state (to force reading from the disk again), so they're not very big.... REW, 12/17/98
+
+CFPropertyListRef CFPreferencesCopyAppValue(CFStringRef key, CFStringRef appName) {
+    _CFApplicationPreferences *standardPrefs;
+    CFAssert1(appName != NULL, __kCFLogAssertion, "%s(): Cannot access application preferences with a NULL application name", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+    
+    standardPrefs = _CFStandardApplicationPreferences(appName);
+    return standardPrefs ? _CFApplicationPreferencesCreateValueForKey2(standardPrefs, key) : NULL;
+}
+
+CF_EXPORT Boolean CFPreferencesAppBooleanValue(CFStringRef key, CFStringRef appName, Boolean *keyExistsAndHasValidFormat) {
+    CFPropertyListRef value;
+    Boolean result, valid;
+    CFTypeID typeID = 0;
+    CFAssert1(appName != NULL, __kCFLogAssertion, "%s(): Cannot access application preferences with a NULL application name", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+
+    if (!keyExistsAndHasValidFormat) {
+        keyExistsAndHasValidFormat = &valid;
+    }
+    value = CFPreferencesCopyAppValue(key, appName);
+    if (!value) {
+        *keyExistsAndHasValidFormat = false;
+        return false;
+    }
+    typeID = CFGetTypeID(value);
+    if (typeID == CFStringGetTypeID()) {
+        if (CFStringCompare((CFStringRef)value, CFSTR("true"), kCFCompareCaseInsensitive) == kCFCompareEqualTo || CFStringCompare((CFStringRef)value, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            *keyExistsAndHasValidFormat = true;
+            result = true;
+        } else if (CFStringCompare((CFStringRef)value, CFSTR("false"), kCFCompareCaseInsensitive) == kCFCompareEqualTo || CFStringCompare((CFStringRef)value, CFSTR("NO"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            *keyExistsAndHasValidFormat = true;
+            result = false;
+        } else {
+            *keyExistsAndHasValidFormat = false;
+            result = false;
+        }
+    } else if (typeID == CFNumberGetTypeID()) {
+        if (CFNumberIsFloatType((CFNumberRef)value)) {
+            *keyExistsAndHasValidFormat = false;
+            result = false;
+        } else {
+            int i;
+            *keyExistsAndHasValidFormat = true;
+            CFNumberGetValue((CFNumberRef)value, kCFNumberIntType, &i);
+            result = (i == 0) ? false : true;
+        }
+    } else if (typeID == CFBooleanGetTypeID()) {
+        result = (value == kCFBooleanTrue);
+        *keyExistsAndHasValidFormat = true;
+    } else {
+        // Unknown type
+        result = false;
+        *keyExistsAndHasValidFormat = false;
+    }
+    CFRelease(value);
+    return result;
+}
+
+__private_extern__ CFIndex CFPreferencesAppIntegerValue(CFStringRef key, CFStringRef appName, Boolean *keyExistsAndHasValidFormat) {
+    CFPropertyListRef value;
+    CFIndex result;
+    CFTypeID typeID = 0;
+    Boolean valid;
+    CFAssert1(appName != NULL, __kCFLogAssertion, "%s(): Cannot access application preferences with a NULL application name", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+
+    value = CFPreferencesCopyAppValue(key, appName);
+    if (!keyExistsAndHasValidFormat) {
+        keyExistsAndHasValidFormat = &valid;
+    }
+    if (!value) {
+        *keyExistsAndHasValidFormat = false;
+        return 0;
+    }
+    typeID = CFGetTypeID(value);
+    if (typeID == CFStringGetTypeID()) {
+        SInt32 charIndex = 0;
+        SInt32 intVal;
+        CFStringInlineBuffer buf;
+        Boolean success;
+        CFStringInitInlineBuffer((CFStringRef)value, &buf, CFRangeMake(0, CFStringGetLength((CFStringRef)value)));
+        success = __CFStringScanInteger(&buf, NULL, &charIndex, false, &intVal);
+        *keyExistsAndHasValidFormat = (success && charIndex == CFStringGetLength((CFStringRef)value));
+        result = (*keyExistsAndHasValidFormat) ? intVal : 0;
+    } else if (typeID == CFNumberGetTypeID()) {
+        *keyExistsAndHasValidFormat = !CFNumberIsFloatType((CFNumberRef)value);
+        if (*keyExistsAndHasValidFormat) {
+            CFNumberGetValue((CFNumberRef)value, kCFNumberCFIndexType, &result);
+        } else {
+            result = 0;
+        }
+    } else {
+        // Unknown type
+        result = 0;
+        *keyExistsAndHasValidFormat = false;
+    }
+    CFRelease(value);
+    return result;
+}
+
+Boolean CFPreferencesGetAppBooleanValue(CFStringRef key, CFStringRef appName, Boolean *keyExistsAndHasValidFormat) {
+    CFAssert1(appName != NULL, __kCFLogAssertion, "%s(): Cannot access application preferences with a NULL application name", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+    return CFPreferencesAppBooleanValue(key, appName, keyExistsAndHasValidFormat);
+}
+
+CFIndex CFPreferencesGetAppIntegerValue(CFStringRef key, CFStringRef appName, Boolean *keyExistsAndHasValidFormat) {
+    CFAssert1(appName != NULL, __kCFLogAssertion, "%s(): Cannot access application preferences with a NULL application name", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+    return CFPreferencesAppIntegerValue(key, appName, keyExistsAndHasValidFormat);
+}
+
+void CFPreferencesSetAppValue(CFStringRef key, CFTypeRef value, CFStringRef appName) {
+    _CFApplicationPreferences *standardPrefs;
+    CFAssert1(appName != NULL, __kCFLogAssertion, "%s(): Cannot access application preferences with a NULL application name", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+
+    standardPrefs = _CFStandardApplicationPreferences(appName);
+    if (standardPrefs) {
+        if (value) _CFApplicationPreferencesSet(standardPrefs, key, value);
+        else _CFApplicationPreferencesRemove(standardPrefs, key);
+    }
+}
+
+
+static CFSpinLock_t __CFApplicationPreferencesLock = CFSpinLockInit; // Locks access to __CFStandardUserPreferences
+static CFMutableDictionaryRef __CFStandardUserPreferences = NULL; // Mutable dictionary; keys are app names, values are _CFApplicationPreferences 
+
+Boolean CFPreferencesAppSynchronize(CFStringRef appName) {
+    _CFApplicationPreferences *standardPrefs;
+    Boolean result;
+    CFAssert1(appName != NULL, __kCFLogAssertion, "%s(): Cannot access application preferences with a NULL application name", __PRETTY_FUNCTION__);
+    
+    // Do not call _CFStandardApplicationPreferences(), as we do not want to create the preferences only to synchronize
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if (__CFStandardUserPreferences)  {
+        standardPrefs = (_CFApplicationPreferences *)CFDictionaryGetValue(__CFStandardUserPreferences, appName);
+    } else {
+        standardPrefs = NULL;
+    }
+
+    result = standardPrefs ? _CFApplicationPreferencesSynchronizeNoLock(standardPrefs) : _CFSynchronizeDomainCache();
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    return result;
+}
+
+void CFPreferencesFlushCaches(void) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if (__CFStandardUserPreferences)  {
+        _CFApplicationPreferences **prefsArray, *prefsBuf[32];
+        CFIndex idx, count = CFDictionaryGetCount(__CFStandardUserPreferences);
+        if (count < 32) {
+            prefsArray = prefsBuf;
+        } else {
+            prefsArray = (_CFApplicationPreferences **)CFAllocatorAllocate(alloc, count * sizeof(_CFApplicationPreferences *), 0);
+        }
+        CFDictionaryGetKeysAndValues(__CFStandardUserPreferences, NULL, (const void **)prefsArray);
+
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+        // DeallocateApplicationPreferences needs the lock
+        for (idx = 0; idx < count; idx ++) {
+            _CFApplicationPreferences *appPrefs = prefsArray[idx];
+            _CFApplicationPreferencesSynchronize(appPrefs);
+            _CFDeallocateApplicationPreferences(appPrefs);
+        }
+        __CFSpinLock(&__CFApplicationPreferencesLock);
+
+        CFRelease(__CFStandardUserPreferences);
+        __CFStandardUserPreferences = NULL;
+        if(prefsArray != prefsBuf) CFAllocatorDeallocate(alloc, prefsArray);
+    }
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    _CFPreferencesPurgeDomainCache();
+}
+
+// quick message to indicate that the given domain has changed, and we should go through and invalidate any dictReps that involve this domain.
+void _CFApplicationPreferencesDomainHasChanged(CFPreferencesDomainRef changedDomain) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if(__CFStandardUserPreferences) {  // only grovel over the prefs if there's something there to grovel
+        _CFApplicationPreferences **prefsArray, *prefsBuf[32];
+        CFIndex idx, count = CFDictionaryGetCount(__CFStandardUserPreferences);
+        if(count < 32) {
+            prefsArray = prefsBuf;
+        } else {
+            prefsArray = (_CFApplicationPreferences **)CFAllocatorAllocate(alloc, count * sizeof(_CFApplicationPreferences *), 0);
+        }
+        CFDictionaryGetKeysAndValues(__CFStandardUserPreferences, NULL, (const void **)prefsArray);
+        // For this operation, giving up the lock is the last thing we want to do, so use the modified flavor of _CFApplicationPreferencesContainsDomain
+        for(idx = 0; idx < count; idx++) {
+            _CFApplicationPreferences *appPrefs = prefsArray[idx];
+            if(_CFApplicationPreferencesContainsDomainNoLock(appPrefs, changedDomain)) {
+                updateDictRep(appPrefs);
+            }
+        }
+        if(prefsArray != prefsBuf) _CFAllocatorDeallocateGC(alloc, prefsArray);
+    }
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+
+// Begin ported code from NSUserDefaults.m
+
+
+static void updateDictRep(_CFApplicationPreferences *self) {
+    if (self->_dictRep) {
+        CFRelease(self->_dictRep);
+        self->_dictRep = NULL;
+    }
+}
+
+static void __addKeysAndValues(const void *key, const void *value, void *context) {
+    CFDictionarySetValue((CFMutableDictionaryRef)context, key, value);
+}
+
+static CFMutableDictionaryRef computeDictRep(_CFApplicationPreferences *self, Boolean skipC0C0A) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    CFMutableArrayRef searchList = self->_search;
+    CFIndex idx;
+    CFIndex cnt = CFArrayGetCount(searchList);
+    CFDictionaryRef subdomainDict;
+    CFMutableDictionaryRef dictRep;
+    
+    dictRep = CFDictionaryCreateMutable(alloc, 0, &kCFTypeDictionaryKeyCallBacks, & kCFTypeDictionaryValueCallBacks);
+    _CFDictionarySetCapacity(dictRep, 260);	// avoid lots of rehashing
+    
+    // For each subdomain triplet in the domain, iterate over dictionaries, adding them if necessary to the dictRep
+    for (idx = cnt; idx--;) {
+        CFPreferencesDomainRef domain = (CFPreferencesDomainRef)CFArrayGetValueAtIndex(searchList, idx);
+
+        if (!domain) continue;
+
+        subdomainDict = _CFPreferencesDomainDeepCopyDictionary(domain);
+        if (subdomainDict) {
+            CFDictionaryApplyFunction(subdomainDict, __addKeysAndValues, dictRep);
+            CFRelease(subdomainDict);
+        }
+    }
+    return dictRep;
+}
+
+CFTypeRef _CFApplicationPreferencesSearchDownToDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef stopper, CFStringRef key) {
+    return NULL;
+}
+
+
+void _CFApplicationPreferencesUpdate(_CFApplicationPreferences *self) {
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    updateDictRep(self);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentation(_CFApplicationPreferences *self);
+
+__private_extern__ CFDictionaryRef __CFApplicationPreferencesCopyCurrentState(void) {
+    _CFApplicationPreferences *self = _CFStandardApplicationPreferences(kCFPreferencesCurrentApplication);
+    CFDictionaryRef result = _CFApplicationPreferencesCopyRepresentation(self);
+    return result;
+}
+
+// CACHING here - we will only return a value as current as the last time computeDictRep() was called
+static CFTypeRef _CFApplicationPreferencesCreateValueForKey2(_CFApplicationPreferences *self, CFStringRef defaultName) {
+    CFTypeRef result;
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if (!self->_dictRep) {
+        self->_dictRep = computeDictRep(self, true);
+    }
+    result = (self->_dictRep) ? (CFTypeRef )CFDictionaryGetValue(self->_dictRep, defaultName) : NULL;
+    if (result) {
+        CFRetain(result);
+    }
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    return result;
+}
+
+
+void _CFApplicationPreferencesSet(_CFApplicationPreferences *self, CFStringRef defaultName, CFTypeRef value) {
+    CFPreferencesDomainRef applicationDomain;
+
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    applicationDomain = _CFPreferencesStandardDomain(self->_appName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    if(applicationDomain) {
+        _CFPreferencesDomainSet(applicationDomain, defaultName, value);
+        if (CFArrayContainsValue(self->_search, CFRangeMake(0, CFArrayGetCount(self->_search)), applicationDomain)) {
+            // Expensive; can't we just check the relevant value throughout the appropriate sets of domains? -- REW, 7/19/99
+            updateDictRep(self);
+        }
+    }
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+void _CFApplicationPreferencesRemove(_CFApplicationPreferences *self, CFStringRef defaultName) {
+    CFPreferencesDomainRef appDomain;
+
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    appDomain = _CFPreferencesStandardDomain(self->_appName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    if(appDomain) {
+        _CFPreferencesDomainSet(appDomain, defaultName, NULL);
+        if (CFArrayContainsValue(self->_search, CFRangeMake(0, CFArrayGetCount(self->_search)), appDomain)) {
+            // If key exists, it will be in the _dictRep (but possibly overridden)
+            updateDictRep(self);
+        }
+    }
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+static Boolean _CFApplicationPreferencesSynchronizeNoLock(_CFApplicationPreferences *self) {
+    Boolean success = _CFSynchronizeDomainCache();
+    updateDictRep(self);
+    return success;
+}
+
+Boolean _CFApplicationPreferencesSynchronize(_CFApplicationPreferences *self) {
+    Boolean result;
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    result = _CFApplicationPreferencesSynchronizeNoLock(self);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    return result;
+}
+
+// appName should not be kCFPreferencesCurrentApplication going in to this call
+_CFApplicationPreferences *_CFApplicationPreferencesCreateWithUser(CFStringRef userName, CFStringRef appName) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    _CFApplicationPreferences *self = (_CFApplicationPreferences*)CFAllocatorAllocate(alloc, sizeof(_CFApplicationPreferences), 0);
+    if (self) {
+        self->_dictRep = NULL;
+        self->_appName = (CFStringRef)CFRetain(appName);
+        self->_search = CFArrayCreateMutable(alloc, 0, &kCFTypeArrayCallBacks);
+        if (!self->_search) {
+            CFAllocatorDeallocate(alloc, self);
+            CFRelease(appName);
+            self = NULL;
+        }
+    }
+    return self;
+}
+
+// Do NOT release the domain after adding it to the array; domain_expression should not return a retained object  -- REW, 8/26/99 
+#define ADD_DOMAIN(domain_expression) domain = domain_expression; if (domain) {CFArrayAppendValue(search, domain);}
+void _CFApplicationPreferencesSetStandardSearchList(_CFApplicationPreferences *appPreferences) {
+    /* Here is how the domains end up in priority order in a search list.  Only a subset of these are setup by default.
+	argument domain
+	this app, this user, managed
+	this app, any user, managed
+        this app, this user, this host
+        this app, this user, any host (AppDomain)
+	suiteN, this user, this host
+	suiteN, this user, any host
+        ...
+	suite0, this user, this host
+	suite0, this user, any host
+        any app, this user, this host
+        any app, this user, any host (GlobalDomain)
+        NSUserDefaults backwards-compat ICU domain
+        this app, any user, this host
+        this app, any user, any host
+	suiteN, any user, this host
+	suiteN, any user, any host
+        ...
+	suite0, any user, this host
+	suite0, any user, any host
+        any app, any user, this host
+        any app, any user, any host
+	registration domain
+    */
+    CFPreferencesDomainRef domain;
+    CFMutableArrayRef search = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    if (!search) {
+        // couldn't allocate memory!
+        return;
+    }
+
+    ADD_DOMAIN(_CFPreferencesStandardDomain(appPreferences->_appName, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost));
+    ADD_DOMAIN(_CFPreferencesStandardDomain(appPreferences->_appName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
+    ADD_DOMAIN(_CFPreferencesStandardDomain(kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost));
+    ADD_DOMAIN(_CFPreferencesStandardDomain(kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
+    ADD_DOMAIN(_CFPreferencesStandardDomain(appPreferences->_appName, kCFPreferencesAnyUser, kCFPreferencesCurrentHost));
+    ADD_DOMAIN(_CFPreferencesStandardDomain(appPreferences->_appName, kCFPreferencesAnyUser, kCFPreferencesAnyHost));
+    ADD_DOMAIN(_CFPreferencesStandardDomain(kCFPreferencesAnyApplication, kCFPreferencesAnyUser, kCFPreferencesCurrentHost));
+    ADD_DOMAIN(_CFPreferencesStandardDomain(kCFPreferencesAnyApplication, kCFPreferencesAnyUser, kCFPreferencesAnyHost));
+
+    _CFApplicationPreferencesSetSearchList(appPreferences, search);
+    CFRelease(search);
+}
+#undef ADD_DOMAIN
+
+
+__private_extern__ _CFApplicationPreferences *_CFStandardApplicationPreferences(CFStringRef appName) {
+    _CFApplicationPreferences *appPreferences;
+//    CFAssert(appName != kCFPreferencesAnyApplication, __kCFLogAssertion, "Cannot use any of the CFPreferences...App... functions with an appName of kCFPreferencesAnyApplication");
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if (!__CFStandardUserPreferences)  {
+        __CFStandardUserPreferences = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, & kCFTypeDictionaryKeyCallBacks, NULL);
+    }
+    if (!__CFStandardUserPreferences) {
+        // Couldn't create
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+        return NULL;
+    }
+    if ((appPreferences = (_CFApplicationPreferences *)CFDictionaryGetValue(__CFStandardUserPreferences, appName)) == NULL ) {
+        appPreferences = _CFApplicationPreferencesCreateWithUser(kCFPreferencesCurrentUser, appName);
+        CFDictionarySetValue(__CFStandardUserPreferences, appName, appPreferences);
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+        _CFApplicationPreferencesSetStandardSearchList(appPreferences);
+    } else {
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    }
+    return appPreferences;
+}
+
+// Exclusively for Foundation's use
+void _CFApplicationPreferencesSetCacheForApp(_CFApplicationPreferences *appPrefs, CFStringRef appName) {
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if (!__CFStandardUserPreferences) {
+        __CFStandardUserPreferences = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, NULL);
+        CFDictionarySetValue(__CFStandardUserPreferences, appName, appPrefs);
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    } else {
+        _CFApplicationPreferences *oldPrefs = (_CFApplicationPreferences *)CFDictionaryGetValue(__CFStandardUserPreferences, appName);
+        CFDictionarySetValue(__CFStandardUserPreferences, appName, appPrefs);
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+        if (oldPrefs) {
+            _CFDeallocateApplicationPreferences(oldPrefs);
+        }
+    }
+}
+
+
+void _CFDeallocateApplicationPreferences(_CFApplicationPreferences *self) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    _CFApplicationPreferences *cachedPrefs = NULL;
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+
+    // Get us out of the cache before destroying!
+    if (__CFStandardUserPreferences)  {
+        cachedPrefs = (_CFApplicationPreferences *)CFDictionaryGetValue(__CFStandardUserPreferences, self->_appName);
+    }
+    if (cachedPrefs == self) {
+        CFDictionaryRemoveValue(__CFStandardUserPreferences, self->_appName);
+    }
+    
+    if (self->_dictRep) CFRelease(self->_dictRep);
+    CFRelease(self->_search);
+    CFRelease(self->_appName);
+    CFAllocatorDeallocate(alloc, self);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+
+CF_EXPORT
+CFDictionaryRef _CFApplicationPreferencesCopyRepresentation(_CFApplicationPreferences *self) {
+    CFDictionaryRef dict;
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if (!self->_dictRep) {
+        self->_dictRep = computeDictRep(self, true);
+    }
+    if (self->_dictRep) {
+        CFRetain(self->_dictRep);
+    }
+    dict = self->_dictRep;
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    return dict;
+}
+
+static void _CFApplicationPreferencesSetSearchList(_CFApplicationPreferences *self, CFArrayRef newSearchList) {
+    CFIndex idx, count;
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    CFArrayRemoveAllValues(self->_search);
+    count = CFArrayGetCount(newSearchList);
+    for (idx = 0; idx < count; idx ++) {
+        CFArrayAppendValue(self->_search, CFArrayGetValueAtIndex(newSearchList, idx));
+    }
+    updateDictRep(self);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+void CFPreferencesAddSuitePreferencesToApp(CFStringRef appName, CFStringRef suiteName) {
+    _CFApplicationPreferences *appPrefs;
+    
+    appPrefs = _CFStandardApplicationPreferences(appName);
+    _CFApplicationPreferencesAddSuitePreferences(appPrefs, suiteName);
+}
+
+void _CFApplicationPreferencesAddSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName) {
+    CFPreferencesDomainRef domain; 
+    CFIndex idx;
+    CFRange range;
+
+    // Find where to insert the new suite
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    domain = _CFPreferencesStandardDomain(appPrefs->_appName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    range.location = 0;
+    range.length = CFArrayGetCount(appPrefs->_search);
+    idx = domain ? CFArrayGetFirstIndexOfValue(appPrefs->_search, range, domain) : kCFNotFound;
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    idx ++; // We want just below the app domain.  Coincidentally, this gives us the top of the list if the app domain has been removed.
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    if (domain) {
+        __CFSpinLock(&__CFApplicationPreferencesLock);
+        CFArrayInsertValueAtIndex(appPrefs->_search, idx, domain);
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+        range.length ++;
+    }
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
+    if (domain) {
+        __CFSpinLock(&__CFApplicationPreferencesLock);
+        CFArrayInsertValueAtIndex(appPrefs->_search, idx, domain);
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+        range.length ++;
+    }
+
+    // Now the AnyUser domains
+    domain = _CFPreferencesStandardDomain(appPrefs->_appName, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+    idx = domain ? CFArrayGetFirstIndexOfValue(appPrefs->_search, range, domain) : kCFNotFound;
+    if (idx == kCFNotFound) {
+        // Someone blew away the app domain. For the any user case, we look for right below the global domain
+        domain = _CFPreferencesStandardDomain(kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+        idx = domain ? CFArrayGetFirstIndexOfValue(appPrefs->_search, range, domain) : kCFNotFound;
+        if (idx == kCFNotFound) {
+            // Try the "any host" choice
+            domain = _CFPreferencesStandardDomain(kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
+            idx = domain ? CFArrayGetFirstIndexOfValue(appPrefs->_search, range, domain) : kCFNotFound;
+            if (idx == kCFNotFound) {
+                // We give up; put the new domains at the bottom
+                idx = CFArrayGetCount(appPrefs->_search) - 1;
+            }
+        }
+    }
+    idx ++;
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+    if (domain) {
+        __CFSpinLock(&__CFApplicationPreferencesLock);
+        CFArrayInsertValueAtIndex(appPrefs->_search, idx, domain);
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    }
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesAnyUser, kCFPreferencesCurrentHost);
+    if (domain) {
+        __CFSpinLock(&__CFApplicationPreferencesLock);
+        CFArrayInsertValueAtIndex(appPrefs->_search, idx, domain);
+        __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    }
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    updateDictRep(appPrefs);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+void CFPreferencesRemoveSuitePreferencesFromApp(CFStringRef appName, CFStringRef suiteName) {
+    _CFApplicationPreferences *appPrefs;
+
+    appPrefs = _CFStandardApplicationPreferences(appName);
+    
+    _CFApplicationPreferencesRemoveSuitePreferences(appPrefs, suiteName);
+}
+
+void _CFApplicationPreferencesRemoveSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName) {
+    CFPreferencesDomainRef domain;
+
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    if (domain) _CFApplicationPreferencesRemoveDomain(appPrefs, domain);
+
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    if (domain) _CFApplicationPreferencesRemoveDomain(appPrefs, domain);
+
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    if (domain) _CFApplicationPreferencesRemoveDomain(appPrefs, domain);
+
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    domain = _CFPreferencesStandardDomain(suiteName, kCFPreferencesAnyUser, kCFPreferencesCurrentHost);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    if (domain) _CFApplicationPreferencesRemoveDomain(appPrefs, domain);
+}
+
+void _CFApplicationPreferencesAddDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain, Boolean addAtTop) {
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    if (addAtTop) {
+        CFArrayInsertValueAtIndex(self->_search, 0, domain);
+    } else {
+        CFArrayAppendValue(self->_search, domain);
+    }
+    updateDictRep(self);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
+
+Boolean _CFApplicationPreferencesContainsDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain) {
+    Boolean result;
+
+    if (!domain) {
+        return false;
+    }
+
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    result = CFArrayContainsValue(self->_search, CFRangeMake(0, CFArrayGetCount(self->_search)), domain);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    return result;
+}
+
+Boolean _CFApplicationPreferencesContainsDomainNoLock(_CFApplicationPreferences *self, CFPreferencesDomainRef domain) {
+    Boolean result;
+    result = CFArrayContainsValue(self->_search, CFRangeMake(0, CFArrayGetCount(self->_search)), domain);
+    return result;
+}
+
+void _CFApplicationPreferencesRemoveDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain) {
+    CFIndex idx;
+    CFRange range;
+    __CFSpinLock(&__CFApplicationPreferencesLock);
+    range.location = 0;
+    range.length = CFArrayGetCount(self->_search);
+    while ((idx = CFArrayGetFirstIndexOfValue(self->_search, range, domain)) != kCFNotFound) {
+        CFArrayRemoveValueAtIndex(self->_search, idx);
+        range.location = idx;
+        range.length  = range.length - idx - 1;
+    }
+    updateDictRep(self);
+    __CFSpinUnlock(&__CFApplicationPreferencesLock);
+}
diff --git a/CoreFoundation/CFArray.c b/CoreFoundation/CFArray.c
new file mode 100644
index 0000000..6003c5e
--- /dev/null
+++ b/CoreFoundation/CFArray.c
@@ -0,0 +1,1201 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ *
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFArray.h>
+#include "CFStorage.h"
+#include "CFPriv.h"
+#include <string.h>
+#include "auto_stubs.h"
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#define bzero(buf, bytes)      ((void) memset ((buf), 0x00, (bytes)))
+CF_EXPORT bool _CFArrayIsMutable(CFArrayRef array);
+#endif
+
+__private_extern__ void _CFStorageSetWeak(CFStorageRef storage);
+
+const CFArrayCallBacks kCFTypeArrayCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual};
+static const CFArrayCallBacks __kCFNullArrayCallBacks = {0, NULL, NULL, NULL, NULL};
+
+struct __CFArrayBucket {
+    const void *_item;
+};
+
+enum {
+    __CF_MAX_BUCKETS_PER_DEQUE = 262140
+};
+
+CF_INLINE CFIndex __CFArrayDequeRoundUpCapacity(CFIndex capacity) {
+    if (capacity < 4) return 4;
+    return __CFMin((1 << flsl(capacity)), __CF_MAX_BUCKETS_PER_DEQUE);
+}
+
+struct __CFArrayDeque {
+    uint32_t _leftIdx;
+    uint32_t _capacity;
+    int32_t _bias;
+#if __LP64__
+    uint32_t _pad;   // GC:  pointers must be 8-byte aligned for the collector to find them.
+#endif
+    /* struct __CFArrayBucket buckets follow here */
+};
+
+struct __CFArray {
+    CFRuntimeBase _base;
+    CFIndex _count;		/* number of objects */
+    CFIndex _mutations;
+    void *_store;           /* can be NULL when MutableDeque */
+};
+
+/* Flag bits */
+enum {		/* Bits 0-1 */
+    __kCFArrayImmutable = 0,
+    __kCFArrayDeque = 2,
+    __kCFArrayStorage = 3
+};
+
+enum {		/* Bits 2-3 */
+    __kCFArrayHasNullCallBacks = 0,
+    __kCFArrayHasCFTypeCallBacks = 1,
+    __kCFArrayHasCustomCallBacks = 3	/* callbacks are at end of header */
+};
+
+/*
+    Bits 4 & 5 are reserved for GC use.
+    Bit 4, if set, indicates that the array is weak.
+    Bit 5 marks whether finalization has occured and, thus, whether to continue to do special retain/release processing of elements.
+ */
+
+CF_INLINE bool isStrongMemory(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)collection)->_cfinfo[CF_INFO_BITS], 4, 4) == 0;
+}
+
+CF_INLINE bool isWeakMemory(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)collection)->_cfinfo[CF_INFO_BITS], 4, 4) != 0;
+}
+
+CF_INLINE bool hasBeenFinalized(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)collection)->_cfinfo[CF_INFO_BITS], 5, 5) != 0;
+}
+
+CF_INLINE void markFinalized(CFTypeRef collection) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)collection)->_cfinfo[CF_INFO_BITS], 5, 5, 1);
+}
+
+CF_INLINE CFIndex __CFArrayGetType(CFArrayRef array) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)array)->_cfinfo[CF_INFO_BITS], 1, 0);
+}
+
+CF_INLINE CFIndex __CFArrayGetSizeOfType(CFIndex t) {
+    CFIndex size = 0;
+        size += sizeof(struct __CFArray);
+    if (__CFBitfieldGetValue(t, 3, 2) == __kCFArrayHasCustomCallBacks) {
+	size += sizeof(CFArrayCallBacks);
+    }
+    return size;
+}
+
+CF_INLINE CFIndex __CFArrayGetCount(CFArrayRef array) {
+    return array->_count;
+}
+
+CF_INLINE void __CFArraySetCount(CFArrayRef array, CFIndex v) {
+    ((struct __CFArray *)array)->_count = v;
+}
+
+/* Only applies to immutable and mutable-deque-using arrays;
+ * Returns the bucket holding the left-most real value in the latter case. */
+CF_INLINE struct __CFArrayBucket *__CFArrayGetBucketsPtr(CFArrayRef array) {
+    switch (__CFArrayGetType(array)) {
+    case __kCFArrayImmutable:
+	return (struct __CFArrayBucket *)((uint8_t *)array + __CFArrayGetSizeOfType(((CFRuntimeBase *)array)->_cfinfo[CF_INFO_BITS]));
+    case __kCFArrayDeque: {
+	struct __CFArrayDeque *deque = (struct __CFArrayDeque *)array->_store;
+        return (struct __CFArrayBucket *)((uint8_t *)deque + sizeof(struct __CFArrayDeque) + deque->_leftIdx * sizeof(struct __CFArrayBucket));
+    }
+    }
+    return NULL;
+}
+
+/* This shouldn't be called if the array count is 0. */
+CF_INLINE struct __CFArrayBucket *__CFArrayGetBucketAtIndex(CFArrayRef array, CFIndex idx) {
+    switch (__CFArrayGetType(array)) {
+    case __kCFArrayImmutable:
+    case __kCFArrayDeque:
+	return __CFArrayGetBucketsPtr(array) + idx;
+    case __kCFArrayStorage: {
+	CFStorageRef store = (CFStorageRef)array->_store;
+	return (struct __CFArrayBucket *)CFStorageGetValueAtIndex(store, idx, NULL);
+    }
+    }
+    return NULL;
+}
+
+CF_INLINE CFArrayCallBacks *__CFArrayGetCallBacks(CFArrayRef array) {
+    CFArrayCallBacks *result = NULL;
+    switch (__CFBitfieldGetValue(((const CFRuntimeBase *)array)->_cfinfo[CF_INFO_BITS], 3, 2)) {
+    case __kCFArrayHasNullCallBacks:
+	return (CFArrayCallBacks *)&__kCFNullArrayCallBacks;
+    case __kCFArrayHasCFTypeCallBacks:
+	return (CFArrayCallBacks *)&kCFTypeArrayCallBacks;
+    case __kCFArrayHasCustomCallBacks:
+	break;
+    }
+    switch (__CFArrayGetType(array)) {
+    case __kCFArrayImmutable:
+	result = (CFArrayCallBacks *)((uint8_t *)array + sizeof(struct __CFArray));
+	break;
+    case __kCFArrayDeque:
+    case __kCFArrayStorage:
+	result = (CFArrayCallBacks *)((uint8_t *)array + sizeof(struct __CFArray));
+	break;
+    }
+    return result;
+}
+
+CF_INLINE bool __CFArrayCallBacksMatchNull(const CFArrayCallBacks *c) {
+    return (NULL == c ||
+	(c->retain == __kCFNullArrayCallBacks.retain &&
+	 c->release == __kCFNullArrayCallBacks.release &&
+	 c->copyDescription == __kCFNullArrayCallBacks.copyDescription &&
+	 c->equal == __kCFNullArrayCallBacks.equal));
+}
+
+CF_INLINE bool __CFArrayCallBacksMatchCFType(const CFArrayCallBacks *c) {
+    return (&kCFTypeArrayCallBacks == c ||
+	(c->retain == kCFTypeArrayCallBacks.retain &&
+	 c->release == kCFTypeArrayCallBacks.release &&
+	 c->copyDescription == kCFTypeArrayCallBacks.copyDescription &&
+	 c->equal == kCFTypeArrayCallBacks.equal));
+}
+
+struct _releaseContext {
+    void (*release)(CFAllocatorRef, const void *);
+    CFAllocatorRef allocator; 
+};
+
+static void __CFArrayStorageRelease(const void *itemptr, void *context) {
+    struct _releaseContext *rc = (struct _releaseContext *)context;
+    INVOKE_CALLBACK2(rc->release, rc->allocator, *(const void **)itemptr);
+    *(const void **)itemptr = NULL; // GC:  clear item to break strong reference.
+}
+
+static void __CFArrayReleaseValues(CFArrayRef array, CFRange range, bool releaseStorageIfPossible) {
+    const CFArrayCallBacks *cb = __CFArrayGetCallBacks(array);
+    CFAllocatorRef allocator;
+    CFIndex idx;
+    switch (__CFArrayGetType(array)) {
+    case __kCFArrayImmutable:
+	if (NULL != cb->release && 0 < range.length && !hasBeenFinalized(array)) {
+            // if we've been finalized then we know that
+            //   1) we're using the standard callback on GC memory
+            //   2) the slots don't' need to be zeroed
+	    struct __CFArrayBucket *buckets = __CFArrayGetBucketsPtr(array);
+	    allocator = __CFGetAllocator(array);
+	    for (idx = 0; idx < range.length; idx++) {
+		INVOKE_CALLBACK2(cb->release, allocator, buckets[idx + range.location]._item);
+		buckets[idx + range.location]._item = NULL; // GC:  break strong reference.
+	    }
+	}
+	break;
+    case __kCFArrayDeque: {
+	struct __CFArrayDeque *deque = (struct __CFArrayDeque *)array->_store;
+	if (0 < range.length && NULL != deque && !hasBeenFinalized(array)) {
+	    struct __CFArrayBucket *buckets = __CFArrayGetBucketsPtr(array);
+	    if (NULL != cb->release) {
+		allocator = __CFGetAllocator(array);
+		for (idx = 0; idx < range.length; idx++) {
+		    INVOKE_CALLBACK2(cb->release, allocator, buckets[idx + range.location]._item);
+		    buckets[idx + range.location]._item = NULL; // GC:  break strong reference.
+		}
+            } else {
+		for (idx = 0; idx < range.length; idx++) {
+		    buckets[idx + range.location]._item = NULL; // GC:  break strong reference.
+		}
+	    }
+	}
+	if (releaseStorageIfPossible && 0 == range.location && __CFArrayGetCount(array) == range.length) {
+	    allocator = __CFGetAllocator(array);
+	    if (NULL != deque) _CFAllocatorDeallocateGC(allocator, deque);
+	    __CFArraySetCount(array, 0);  // GC: _count == 0 ==> _store == NULL.
+	    ((struct __CFArray *)array)->_store = NULL;
+	}
+	break;
+    }
+    case __kCFArrayStorage: {
+	CFStorageRef store = (CFStorageRef)array->_store;
+	if (NULL != cb->release && 0 < range.length && !hasBeenFinalized(array)) {
+	    struct _releaseContext context;
+	    allocator = __CFGetAllocator(array);
+	    context.release = cb->release;
+	    context.allocator = allocator;
+	    CFStorageApplyFunction(store, range, __CFArrayStorageRelease, &context);
+	}
+	if (releaseStorageIfPossible && 0 == range.location && __CFArrayGetCount(array) == range.length) {
+	    _CFReleaseGC(store);
+	    __CFArraySetCount(array, 0);  // GC: _count == 0 ==> _store == NULL.
+	    ((struct __CFArray *)array)->_store = NULL;
+	    __CFBitfieldSetValue(((CFRuntimeBase *)array)->_cfinfo[CF_INFO_BITS], 1, 0, __kCFArrayDeque);
+	}
+	break;
+    }
+    }
+}
+
+#if defined(DEBUG)
+CF_INLINE void __CFArrayValidateRange(CFArrayRef array, CFRange range, const char *func) {
+    CFAssert3(0 <= range.location && range.location <= CFArrayGetCount(array), __kCFLogAssertion, "%s(): range.location index (%d) out of bounds (0, %d)", func, range.location, CFArrayGetCount(array));
+    CFAssert2(0 <= range.length, __kCFLogAssertion, "%s(): range.length (%d) cannot be less than zero", func, range.length);
+    CFAssert3(range.location + range.length <= CFArrayGetCount(array), __kCFLogAssertion, "%s(): ending index (%d) out of bounds (0, %d)", func, range.location + range.length, CFArrayGetCount(array));
+}
+#else
+#define __CFArrayValidateRange(a,r,f)
+#endif
+
+static Boolean __CFArrayEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFArrayRef array1 = (CFArrayRef)cf1;
+    CFArrayRef array2 = (CFArrayRef)cf2;
+    const CFArrayCallBacks *cb1, *cb2;
+    CFIndex idx, cnt;
+    if (array1 == array2) return true;
+    cnt = __CFArrayGetCount(array1);
+    if (cnt != __CFArrayGetCount(array2)) return false;
+    cb1 = __CFArrayGetCallBacks(array1);
+    cb2 = __CFArrayGetCallBacks(array2);
+    if (cb1->equal != cb2->equal) return false;
+    if (0 == cnt) return true;	/* after function comparison! */
+    for (idx = 0; idx < cnt; idx++) {
+	const void *val1 = __CFArrayGetBucketAtIndex(array1, idx)->_item;
+	const void *val2 = __CFArrayGetBucketAtIndex(array2, idx)->_item;
+	if (val1 != val2) {
+	    if (NULL == cb1->equal) return false;
+	    if (!INVOKE_CALLBACK2(cb1->equal, val1, val2)) return false;
+	}
+    }
+    return true;
+}
+
+static CFHashCode __CFArrayHash(CFTypeRef cf) {
+    CFArrayRef array = (CFArrayRef)cf;
+    return __CFArrayGetCount(array);
+}
+
+static CFStringRef __CFArrayCopyDescription(CFTypeRef cf) {
+    CFArrayRef array = (CFArrayRef)cf;
+    CFMutableStringRef result;
+    const CFArrayCallBacks *cb;
+    CFAllocatorRef allocator;
+    CFIndex idx, cnt;
+    cnt = __CFArrayGetCount(array);
+    allocator = CFGetAllocator(array);
+    result = CFStringCreateMutable(allocator, 0);
+    switch (__CFArrayGetType(array)) {
+    case __kCFArrayImmutable:
+	CFStringAppendFormat(result, NULL, CFSTR("<CFArray %p [%p]>{type = immutable, count = %u, values = (\n"), cf, allocator, cnt);
+	break;
+    case __kCFArrayDeque:
+	CFStringAppendFormat(result, NULL, CFSTR("<CFArray %p [%p]>{type = mutable-small, count = %u, values = (\n"), cf, allocator, cnt);
+	break;
+    case __kCFArrayStorage:
+	CFStringAppendFormat(result, NULL, CFSTR("<CFArray %p [%p]>{type = mutable-large, count = %u, values = (\n"), cf, allocator, cnt);
+	break;
+    }
+    cb = __CFArrayGetCallBacks(array);
+    for (idx = 0; idx < cnt; idx++) {
+	CFStringRef desc = NULL;
+	const void *val = __CFArrayGetBucketAtIndex(array, idx)->_item;
+	if (NULL != cb->copyDescription) {
+	    desc = (CFStringRef)INVOKE_CALLBACK1(cb->copyDescription, val);
+	}
+	if (NULL != desc) {
+	    CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@\n"), idx, desc);
+	    CFRelease(desc);
+	} else {
+	    CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p>\n"), idx, val);
+	}
+    }
+    CFStringAppend(result, CFSTR(")}"));
+    return result;
+}
+
+
+static void __CFResourceRelease(CFTypeRef cf, const void *ignored) {
+    kCFTypeArrayCallBacks.release(kCFAllocatorSystemDefault, cf);
+}
+
+static void __CFArrayDeallocate(CFTypeRef cf) {
+    CFArrayRef array = (CFArrayRef)cf;
+    // Under GC, keep contents alive when we know we can, either standard callbacks or NULL
+    // if (__CFBitfieldGetValue(cf->info, 5, 4)) return; // bits only ever set under GC
+    CFAllocatorRef allocator = __CFGetAllocator(array);
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+	// XXX_PCB keep array intact during finalization.
+	const CFArrayCallBacks *cb = __CFArrayGetCallBacks(array);
+	if (cb->retain == NULL && cb->release == NULL)
+            return;
+        if (cb == &kCFTypeArrayCallBacks || cb->release == kCFTypeArrayCallBacks.release) {
+            markFinalized(cf);
+            CFArrayApplyFunction((CFArrayRef)cf, CFRangeMake(0, __CFArrayGetCount(array)), (CFArrayApplierFunction)__CFResourceRelease, 0);
+            return;
+        }
+    }
+    __CFArrayReleaseValues(array, CFRangeMake(0, __CFArrayGetCount(array)), true);
+}
+
+static CFTypeID __kCFArrayTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFArrayClass = {
+    _kCFRuntimeScannedObject,
+    "CFArray",
+    NULL,	// init
+    NULL,	// copy
+    __CFArrayDeallocate,
+    __CFArrayEqual,
+    __CFArrayHash,
+    NULL,	// 
+    __CFArrayCopyDescription
+};
+
+__private_extern__ void __CFArrayInitialize(void) {
+    __kCFArrayTypeID = _CFRuntimeRegisterClass(&__CFArrayClass);
+}
+
+CFTypeID CFArrayGetTypeID(void) {
+    return __kCFArrayTypeID;
+}
+
+static CFArrayRef __CFArrayInit(CFAllocatorRef allocator, UInt32 flags, CFIndex capacity, const CFArrayCallBacks *callBacks) {
+    struct __CFArray *memory;
+    UInt32 size;
+    __CFBitfieldSetValue(flags, 31, 2, 0);
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+	if (!callBacks || (callBacks->retain == NULL && callBacks->release == NULL)) {
+	    __CFBitfieldSetValue(flags, 4, 4, 1); // setWeak
+	}
+    }
+    if (__CFArrayCallBacksMatchNull(callBacks)) {
+	__CFBitfieldSetValue(flags, 3, 2, __kCFArrayHasNullCallBacks);
+    } else if (__CFArrayCallBacksMatchCFType(callBacks)) {
+	__CFBitfieldSetValue(flags, 3, 2, __kCFArrayHasCFTypeCallBacks);
+    } else {
+	__CFBitfieldSetValue(flags, 3, 2, __kCFArrayHasCustomCallBacks);
+    }
+    size = __CFArrayGetSizeOfType(flags) - sizeof(CFRuntimeBase);
+    switch (__CFBitfieldGetValue(flags, 1, 0)) {
+    case __kCFArrayImmutable:
+	size += capacity * sizeof(struct __CFArrayBucket);
+	break;
+    case __kCFArrayDeque:
+    case __kCFArrayStorage:
+	break;
+    }
+    memory = (struct __CFArray*)_CFRuntimeCreateInstance(allocator, __kCFArrayTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    __CFBitfieldSetValue(memory->_base._cfinfo[CF_INFO_BITS], 6, 0, flags);
+    __CFArraySetCount((CFArrayRef)memory, 0);
+    switch (__CFBitfieldGetValue(flags, 1, 0)) {
+    case __kCFArrayImmutable:
+        if (isWeakMemory(memory)) {  // if weak, don't scan
+            auto_zone_set_layout_type(__CFCollectableZone, memory, AUTO_OBJECT_UNSCANNED);
+        }
+	if (__CFOASafe) __CFSetLastAllocationEventName(memory, "CFArray (immutable)");
+	break;
+    case __kCFArrayDeque:
+    case __kCFArrayStorage:
+	if (__CFOASafe) __CFSetLastAllocationEventName(memory, "CFArray (mutable-variable)");
+	((struct __CFArray *)memory)->_mutations = 1;
+	((struct __CFArray*)memory)->_store = NULL;
+	break;
+    }
+    if (__kCFArrayHasCustomCallBacks == __CFBitfieldGetValue(flags, 3, 2)) {
+	CFArrayCallBacks *cb = (CFArrayCallBacks *)__CFArrayGetCallBacks((CFArrayRef)memory);
+	*cb = *callBacks;
+	FAULT_CALLBACK((void **)&(cb->retain));
+	FAULT_CALLBACK((void **)&(cb->release));
+	FAULT_CALLBACK((void **)&(cb->copyDescription));
+	FAULT_CALLBACK((void **)&(cb->equal));
+    }
+    return (CFArrayRef)memory;
+}
+
+CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks) {
+    CFArrayRef result;
+    const CFArrayCallBacks *cb;
+    struct __CFArrayBucket *buckets;
+    CFAllocatorRef bucketsAllocator;
+    void* bucketsBase;
+    CFIndex idx;
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%d) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+    result = __CFArrayInit(allocator, __kCFArrayImmutable, numValues, callBacks);
+    cb = __CFArrayGetCallBacks(result);
+    buckets = __CFArrayGetBucketsPtr(result);
+    bucketsAllocator = isStrongMemory(result) ? allocator : kCFAllocatorNull;
+    bucketsBase = CF_IS_COLLECTABLE_ALLOCATOR(bucketsAllocator) ? (void *)auto_zone_base_pointer(__CFCollectableZone, buckets) : NULL;
+    if (NULL != cb->retain) {
+        for (idx = 0; idx < numValues; idx++) {
+	    CF_WRITE_BARRIER_BASE_ASSIGN(bucketsAllocator, bucketsBase, buckets->_item, (void *)INVOKE_CALLBACK2(cb->retain, allocator, *values));
+            values++;
+            buckets++;
+        }
+    }
+    else {
+        for (idx = 0; idx < numValues; idx++) {
+            CF_WRITE_BARRIER_BASE_ASSIGN(bucketsAllocator, bucketsBase, buckets->_item, *values);
+            values++;
+            buckets++;
+        }
+    }
+    __CFArraySetCount(result, numValues);
+    return result;
+}
+
+CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks) {
+    CFAssert2(0 <= capacity, __kCFLogAssertion, "%s(): capacity (%d) cannot be less than zero", __PRETTY_FUNCTION__, capacity);
+    CFAssert2(capacity <= (CFIndex)(LONG_MAX / sizeof(void *)), __kCFLogAssertion, "%s(): capacity (%d) is too large for this architecture", __PRETTY_FUNCTION__, capacity);
+    return (CFMutableArrayRef)__CFArrayInit(allocator, __kCFArrayDeque, capacity, callBacks);
+}
+
+// This creates an array which is for CFTypes or NSObjects, with an ownership transfer --
+// the array does not take a retain, and the caller does not need to release the inserted objects.
+// The incoming objects must also be collectable if allocated out of a collectable allocator.
+CFArrayRef _CFArrayCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const void **values, CFIndex numValues) {
+    CFArrayRef result;
+    result = __CFArrayInit(allocator, isMutable ? __kCFArrayDeque : __kCFArrayImmutable, numValues, &kCFTypeArrayCallBacks);
+    if (!isMutable) {
+	struct __CFArrayBucket *buckets = __CFArrayGetBucketsPtr(result);
+	CF_WRITE_BARRIER_MEMMOVE(buckets, values, numValues * sizeof(struct __CFArrayBucket));
+    } else {
+	if (__CF_MAX_BUCKETS_PER_DEQUE <= numValues) {
+	    CFStorageRef store = (CFStorageRef)CFMakeCollectable(CFStorageCreate(allocator, sizeof(const void *)));
+	    if (__CFOASafe) __CFSetLastAllocationEventName(store, "CFArray (store-storage)");
+	    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, result, result->_store, store);
+	    CFStorageInsertValues(store, CFRangeMake(0, numValues));
+	    CFStorageReplaceValues(store, CFRangeMake(0, numValues), values);
+	    __CFBitfieldSetValue(((CFRuntimeBase *)result)->_cfinfo[CF_INFO_BITS], 1, 0, __kCFArrayStorage);
+	} else if (0 <= numValues) {
+	    struct __CFArrayDeque *deque;
+	    struct __CFArrayBucket *raw_buckets;
+	    CFIndex capacity = __CFArrayDequeRoundUpCapacity(numValues);
+	    CFIndex size = sizeof(struct __CFArrayDeque) + capacity * sizeof(struct __CFArrayBucket);
+	    deque = (struct __CFArrayDeque *)_CFAllocatorAllocateGC(allocator, size, isStrongMemory(result) ? __kCFAllocatorGCScannedMemory : 0);
+	    if (__CFOASafe) __CFSetLastAllocationEventName(deque, "CFArray (store-deque)");
+	    deque->_leftIdx = (capacity - numValues) / 2;
+	    deque->_capacity = capacity;
+	    deque->_bias = 0;
+	    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, result, result->_store, deque);
+	    raw_buckets = (struct __CFArrayBucket *)((uint8_t *)deque + sizeof(struct __CFArrayDeque));
+	    CF_WRITE_BARRIER_MEMMOVE(raw_buckets + deque->_leftIdx + 0, values, numValues * sizeof(struct __CFArrayBucket));
+	    __CFBitfieldSetValue(((CFRuntimeBase *)result)->_cfinfo[CF_INFO_BITS], 1, 0, __kCFArrayDeque);
+	}
+    }
+    __CFArraySetCount(result, numValues);
+    return result;
+}
+
+CFArrayRef CFArrayCreateCopy(CFAllocatorRef allocator, CFArrayRef array) {
+    CFArrayRef result;
+    const CFArrayCallBacks *cb;
+    struct __CFArrayBucket *buckets;
+    CFAllocatorRef bucketsAllocator;
+    void* bucketsBase;
+    CFIndex numValues = CFArrayGetCount(array);
+    CFIndex idx;
+    if (CF_IS_OBJC(__kCFArrayTypeID, array)) {
+	cb = &kCFTypeArrayCallBacks;
+    } else {
+	cb = __CFArrayGetCallBacks(array);
+	    }
+    result = __CFArrayInit(allocator, __kCFArrayImmutable, numValues, cb);
+    cb = __CFArrayGetCallBacks(result); // GC: use the new array's callbacks so we don't leak.
+    buckets = __CFArrayGetBucketsPtr(result);
+    bucketsAllocator = isStrongMemory(result) ? allocator : kCFAllocatorNull;
+	bucketsBase = CF_IS_COLLECTABLE_ALLOCATOR(bucketsAllocator) ? (void *)auto_zone_base_pointer(__CFCollectableZone, buckets) : NULL;
+    for (idx = 0; idx < numValues; idx++) {
+	const void *value = CFArrayGetValueAtIndex(array, idx);
+	if (NULL != cb->retain) {
+	    value = (void *)INVOKE_CALLBACK2(cb->retain, allocator, value);
+	}
+	CF_WRITE_BARRIER_BASE_ASSIGN(bucketsAllocator, bucketsBase, buckets->_item, value);
+	buckets++;
+    }
+    __CFArraySetCount(result, numValues);
+    return result;
+}
+
+CFMutableArrayRef CFArrayCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFArrayRef array) {
+    CFMutableArrayRef result;
+    const CFArrayCallBacks *cb;
+    CFIndex idx, numValues = CFArrayGetCount(array);
+    UInt32 flags;
+    if (CF_IS_OBJC(__kCFArrayTypeID, array)) {
+	cb = &kCFTypeArrayCallBacks;
+    }
+    else {
+	cb = __CFArrayGetCallBacks(array);
+    }
+    flags = __kCFArrayDeque;
+    result = (CFMutableArrayRef)__CFArrayInit(allocator, flags, capacity, cb);
+    if (0 == capacity) _CFArraySetCapacity(result, numValues);
+    for (idx = 0; idx < numValues; idx++) {
+	const void *value = CFArrayGetValueAtIndex(array, idx);
+	CFArrayAppendValue(result, value);
+    }
+    return result;
+}
+
+CFIndex CFArrayGetCount(CFArrayRef array) {
+    CF_OBJC_FUNCDISPATCH0(__kCFArrayTypeID, CFIndex, array, "count");
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    return __CFArrayGetCount(array);
+}
+
+
+CFIndex CFArrayGetCountOfValue(CFArrayRef array, CFRange range, const void *value) {
+    const CFArrayCallBacks *cb;
+    CFIndex idx, count = 0;
+// CF: this ignores range
+    CF_OBJC_FUNCDISPATCH1(__kCFArrayTypeID, CFIndex, array, "countOccurrences:", value);
+    __CFGenericValidateType(array, __kCFArrayTypeID);    
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    cb = __CFArrayGetCallBacks(array);
+    for (idx = 0; idx < range.length; idx++) {
+	const void *item = __CFArrayGetBucketAtIndex(array, range.location + idx)->_item;
+	if (value == item || (cb->equal && INVOKE_CALLBACK2(cb->equal, value, item))) {
+	    count++;
+	}
+    }
+    return count;
+}
+
+Boolean CFArrayContainsValue(CFArrayRef array, CFRange range, const void *value) {
+    CFIndex idx;
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, char, array, "containsObject:inRange:", value, range);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    for (idx = 0; idx < range.length; idx++) {
+        const void *item = __CFArrayGetBucketAtIndex(array, range.location + idx)->_item;
+        if (value == item) {
+            return true;
+        }
+    }
+    const CFArrayCallBacks *cb = __CFArrayGetCallBacks(array);
+    if (cb->equal) {
+        for (idx = 0; idx < range.length; idx++) {
+            const void *item = __CFArrayGetBucketAtIndex(array, range.location + idx)->_item;
+            if (INVOKE_CALLBACK2(cb->equal, value, item)) {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+const void *CFArrayGetValueAtIndex(CFArrayRef array, CFIndex idx) {
+    CF_OBJC_FUNCDISPATCH1(__kCFArrayTypeID, void *, array, "objectAtIndex:", idx);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert2(0 <= idx && idx < __CFArrayGetCount(array), __kCFLogAssertion, "%s(): index (%d) out of bounds", __PRETTY_FUNCTION__, idx);
+    return __CFArrayGetBucketAtIndex(array, idx)->_item;
+}
+
+// This is for use by NSCFArray; it avoids ObjC dispatch, and checks for out of bounds
+const void *_CFArrayCheckAndGetValueAtIndex(CFArrayRef array, CFIndex idx) {
+    if (0 <= idx && idx < __CFArrayGetCount(array)) return __CFArrayGetBucketAtIndex(array, idx)->_item;
+    return (void *)(-1);
+}
+
+
+void CFArrayGetValues(CFArrayRef array, CFRange range, const void **values) {
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, void, array, "getObjects:range:", values, range);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    CFAssert1(NULL != values, __kCFLogAssertion, "%s(): pointer to values may not be NULL", __PRETTY_FUNCTION__);
+    if (0 < range.length) {
+	switch (__CFArrayGetType(array)) {
+	case __kCFArrayImmutable:
+	case __kCFArrayDeque:
+	    CF_WRITE_BARRIER_MEMMOVE(values, __CFArrayGetBucketsPtr(array) + range.location, range.length * sizeof(struct __CFArrayBucket));
+	    break;
+	case __kCFArrayStorage: {
+	    CFStorageRef store = (CFStorageRef)array->_store;
+	    CFStorageGetValues(store, range, values);
+	    break;
+	}
+	}
+    }
+}
+
+
+unsigned long _CFArrayFastEnumeration(CFArrayRef array, struct __objcFastEnumerationStateEquivalent *state, void *stackbuffer, unsigned long count) {
+    if (array->_count == 0) return 0;
+    enum { ATSTART = 0, ATEND = 1 };
+    switch (__CFArrayGetType(array)) {
+    case __kCFArrayImmutable:
+        if (state->state == ATSTART) { /* first time */
+            static const unsigned long const_mu = 1;
+            state->state = ATEND;
+            state->mutationsPtr = (unsigned long *)&const_mu;
+            state->itemsPtr = (unsigned long *)__CFArrayGetBucketsPtr(array);
+            return array->_count;
+        }
+        return 0;			
+    case __kCFArrayDeque:
+        if (state->state == ATSTART) { /* first time */
+            state->state = ATEND;
+            state->mutationsPtr = (unsigned long *)&array->_mutations;
+            state->itemsPtr = (unsigned long *)__CFArrayGetBucketsPtr(array);
+            return array->_count;
+        }
+        return 0;
+    case __kCFArrayStorage:
+        state->mutationsPtr = (unsigned long *)&array->_mutations;
+        return _CFStorageFastEnumeration((CFStorageRef)array->_store, state, stackbuffer, count);
+    }
+    return 0;
+}
+
+
+void CFArrayApplyFunction(CFArrayRef array, CFRange range, CFArrayApplierFunction applier, void *context) {
+    CFIndex idx;
+    FAULT_CALLBACK((void **)&(applier));
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, void, array, "apply:context:", applier, context);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    CFAssert1(NULL != applier, __kCFLogAssertion, "%s(): pointer to applier function may not be NULL", __PRETTY_FUNCTION__);
+    for (idx = 0; idx < range.length; idx++) {
+	const void *item = __CFArrayGetBucketAtIndex(array, range.location + idx)->_item;
+	INVOKE_CALLBACK2(applier, item, context);
+    }
+}
+
+CFIndex CFArrayGetFirstIndexOfValue(CFArrayRef array, CFRange range, const void *value) {
+    const CFArrayCallBacks *cb;
+    CFIndex idx;
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, CFIndex, array, "_cfindexOfObject:inRange:", value, range);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    cb = __CFArrayGetCallBacks(array);
+    for (idx = 0; idx < range.length; idx++) {
+	const void *item = __CFArrayGetBucketAtIndex(array, range.location + idx)->_item;
+	if (value == item || (cb->equal && INVOKE_CALLBACK2(cb->equal, value, item)))
+	    return idx + range.location;
+    }
+    return kCFNotFound;
+}
+
+CFIndex CFArrayGetLastIndexOfValue(CFArrayRef array, CFRange range, const void *value) {
+    const CFArrayCallBacks *cb;
+    CFIndex idx;
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, CFIndex, array, "_cflastIndexOfObject:inRange:", value, range);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    cb = __CFArrayGetCallBacks(array);
+    for (idx = range.length; idx--;) {
+	const void *item = __CFArrayGetBucketAtIndex(array, range.location + idx)->_item;
+	if (value == item || (cb->equal && INVOKE_CALLBACK2(cb->equal, value, item)))
+	    return idx + range.location;
+    }
+    return kCFNotFound;
+}
+
+void CFArrayAppendValue(CFMutableArrayRef array, const void *value) {
+    CF_OBJC_FUNCDISPATCH1(__kCFArrayTypeID, void, array, "addObject:", value);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    _CFArrayReplaceValues(array, CFRangeMake(__CFArrayGetCount(array), 0), &value, 1);
+}
+
+void CFArraySetValueAtIndex(CFMutableArrayRef array, CFIndex idx, const void *value) {
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, void, array, "setObject:atIndex:", value, idx);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    CFAssert2(0 <= idx && idx <= __CFArrayGetCount(array), __kCFLogAssertion, "%s(): index (%d) out of bounds", __PRETTY_FUNCTION__, idx);
+    if (idx == __CFArrayGetCount(array)) {
+	_CFArrayReplaceValues(array, CFRangeMake(idx, 0), &value, 1);
+    } else {
+	const void *old_value;
+	const CFArrayCallBacks *cb = __CFArrayGetCallBacks(array);
+	CFAllocatorRef allocator = __CFGetAllocator(array);
+        CFAllocatorRef bucketsAllocator = isStrongMemory(array) ? allocator : kCFAllocatorNull;
+	struct __CFArrayBucket *bucket = __CFArrayGetBucketAtIndex(array, idx);
+	if (NULL != cb->retain && !hasBeenFinalized(array)) {
+	    value = (void *)INVOKE_CALLBACK2(cb->retain, allocator, value);
+	}
+	old_value = bucket->_item;
+	CF_WRITE_BARRIER_ASSIGN(bucketsAllocator, bucket->_item, value); // GC: handles deque/CFStorage cases.
+	if (NULL != cb->release && !hasBeenFinalized(array)) {
+	    INVOKE_CALLBACK2(cb->release, allocator, old_value);
+	}
+	array->_mutations++;
+    }
+}
+
+void CFArrayInsertValueAtIndex(CFMutableArrayRef array, CFIndex idx, const void *value) {
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, void, array, "insertObject:atIndex:", value, idx);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    CFAssert2(0 <= idx && idx <= __CFArrayGetCount(array), __kCFLogAssertion, "%s(): index (%d) out of bounds", __PRETTY_FUNCTION__, idx);
+    _CFArrayReplaceValues(array, CFRangeMake(idx, 0), &value, 1);
+}
+
+void CFArrayExchangeValuesAtIndices(CFMutableArrayRef array, CFIndex idx1, CFIndex idx2) {
+    const void *tmp;
+    struct __CFArrayBucket *bucket1, *bucket2;
+    CFAllocatorRef bucketsAllocator;
+    CF_OBJC_FUNCDISPATCH2(__kCFArrayTypeID, void, array, "exchange::", idx1, idx2);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert2(0 <= idx1 && idx1 < __CFArrayGetCount(array), __kCFLogAssertion, "%s(): index #1 (%d) out of bounds", __PRETTY_FUNCTION__, idx1);
+    CFAssert2(0 <= idx2 && idx2 < __CFArrayGetCount(array), __kCFLogAssertion, "%s(): index #2 (%d) out of bounds", __PRETTY_FUNCTION__, idx2);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    bucket1 = __CFArrayGetBucketAtIndex(array, idx1);
+    bucket2 = __CFArrayGetBucketAtIndex(array, idx2);
+    tmp = bucket1->_item;
+    bucketsAllocator = isStrongMemory(array) ? __CFGetAllocator(array) : kCFAllocatorNull;
+    // XXX these aren't needed.
+    CF_WRITE_BARRIER_ASSIGN(bucketsAllocator, bucket1->_item, bucket2->_item);
+    CF_WRITE_BARRIER_ASSIGN(bucketsAllocator, bucket2->_item, tmp);
+    array->_mutations++;
+
+}
+
+void CFArrayRemoveValueAtIndex(CFMutableArrayRef array, CFIndex idx) {
+    CF_OBJC_FUNCDISPATCH1(__kCFArrayTypeID, void, array, "removeObjectAtIndex:", idx);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    CFAssert2(0 <= idx && idx < __CFArrayGetCount(array), __kCFLogAssertion, "%s(): index (%d) out of bounds", __PRETTY_FUNCTION__, idx);
+    _CFArrayReplaceValues(array, CFRangeMake(idx, 1), NULL, 0);
+}
+
+void CFArrayRemoveAllValues(CFMutableArrayRef array) {
+    CF_OBJC_FUNCDISPATCH0(__kCFArrayTypeID, void, array, "removeAllObjects");
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    __CFArrayReleaseValues(array, CFRangeMake(0, __CFArrayGetCount(array)), true);
+    __CFArraySetCount(array, 0);
+    array->_mutations++;
+}
+
+static void __CFArrayConvertDequeToStore(CFMutableArrayRef array) {
+    struct __CFArrayDeque *deque = (struct __CFArrayDeque *)array->_store;
+    struct __CFArrayBucket *raw_buckets = (struct __CFArrayBucket *)((uint8_t *)deque + sizeof(struct __CFArrayDeque));
+    CFStorageRef store;
+    CFIndex count = CFArrayGetCount(array);
+    CFAllocatorRef allocator = __CFGetAllocator(array);
+    store = (CFStorageRef)CFMakeCollectable(CFStorageCreate(allocator, sizeof(const void *)));
+    if (__CFOASafe) __CFSetLastAllocationEventName(store, "CFArray (store-storage)");
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, array, array->_store, store);
+    CFStorageInsertValues(store, CFRangeMake(0, count));
+    CFStorageReplaceValues(store, CFRangeMake(0, count), raw_buckets + deque->_leftIdx);
+    _CFAllocatorDeallocateGC(__CFGetAllocator(array), deque);
+    __CFBitfieldSetValue(((CFRuntimeBase *)array)->_cfinfo[CF_INFO_BITS], 1, 0, __kCFArrayStorage);
+}
+
+static void __CFArrayConvertStoreToDeque(CFMutableArrayRef array) {
+    CFStorageRef store = (CFStorageRef)array->_store;
+    struct __CFArrayDeque *deque;
+    struct __CFArrayBucket *raw_buckets;
+    CFIndex count = CFStorageGetCount(store);// storage, not array, has correct count at this point
+    // do not resize down to a completely tight deque
+    CFIndex capacity = __CFArrayDequeRoundUpCapacity(count + 6);
+    CFIndex size = sizeof(struct __CFArrayDeque) + capacity * sizeof(struct __CFArrayBucket);
+    CFAllocatorRef allocator = __CFGetAllocator(array);
+    deque = (struct __CFArrayDeque *)_CFAllocatorAllocateGC(allocator, size, isStrongMemory(array) ? __kCFAllocatorGCScannedMemory : 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(deque, "CFArray (store-deque)");
+    deque->_leftIdx = (capacity - count) / 2;
+    deque->_capacity = capacity;
+    deque->_bias = 0;
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, array, array->_store, deque);
+    raw_buckets = (struct __CFArrayBucket *)((uint8_t *)deque + sizeof(struct __CFArrayDeque));
+    CFStorageGetValues(store, CFRangeMake(0, count), raw_buckets + deque->_leftIdx);
+    _CFReleaseGC(store); // GC:  balances CFMakeCollectable() above.
+    __CFBitfieldSetValue(((CFRuntimeBase *)array)->_cfinfo[CF_INFO_BITS], 1, 0, __kCFArrayDeque);
+}
+
+// may move deque storage, as it may need to grow deque
+static void __CFArrayRepositionDequeRegions(CFMutableArrayRef array, CFRange range, CFIndex newCount) {
+    // newCount elements are going to replace the range, and the result will fit in the deque
+    struct __CFArrayDeque *deque = (struct __CFArrayDeque *)array->_store;
+    struct __CFArrayBucket *buckets;
+    CFIndex cnt, futureCnt, numNewElems;
+    CFIndex L, A, B, C, R;
+
+    buckets = (struct __CFArrayBucket *)((uint8_t *)deque + sizeof(struct __CFArrayDeque));
+    cnt = __CFArrayGetCount(array);
+    futureCnt = cnt - range.length + newCount;
+
+    L = deque->_leftIdx;		// length of region to left of deque
+    A = range.location;			// length of region in deque to left of replaced range
+    B = range.length;			// length of replaced range
+    C = cnt - B - A;			// length of region in deque to right of replaced range
+    R = deque->_capacity - cnt - L;	// length of region to right of deque
+    numNewElems = newCount - B;
+
+    CFIndex wiggle = deque->_capacity >> 17;
+    if (wiggle < 4) wiggle = 4;
+    if (deque->_capacity < (uint32_t)futureCnt || (cnt < futureCnt && L + R < wiggle)) {
+	// must be inserting or space is tight, reallocate and re-center everything
+	CFIndex capacity = __CFArrayDequeRoundUpCapacity(futureCnt + wiggle);
+	CFIndex size = sizeof(struct __CFArrayDeque) + capacity * sizeof(struct __CFArrayBucket);
+	CFAllocatorRef allocator = __CFGetAllocator(array);
+	struct __CFArrayDeque *newDeque = (struct __CFArrayDeque *)_CFAllocatorAllocateGC(allocator, size, isStrongMemory(array) ? __kCFAllocatorGCScannedMemory : 0);
+	if (__CFOASafe) __CFSetLastAllocationEventName(newDeque, "CFArray (store-deque)");
+	struct __CFArrayBucket *newBuckets = (struct __CFArrayBucket *)((uint8_t *)newDeque + sizeof(struct __CFArrayDeque));
+	CFIndex oldL = L;
+	CFIndex newL = (capacity - futureCnt) / 2;
+	CFIndex oldC0 = oldL + A + B;
+	CFIndex newC0 = newL + A + newCount;
+	newDeque->_leftIdx = newL;
+	newDeque->_capacity = capacity;
+	newDeque->_bias = 0;
+	if (0 < A) CF_WRITE_BARRIER_MEMMOVE(newBuckets + newL, buckets + oldL, A * sizeof(struct __CFArrayBucket));
+	if (0 < C) CF_WRITE_BARRIER_MEMMOVE(newBuckets + newC0, buckets + oldC0, C * sizeof(struct __CFArrayBucket));
+	if (deque) _CFAllocatorDeallocateGC(allocator, deque);
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, array, array->_store, newDeque);
+	return;
+    }
+
+    if ((numNewElems < 0 && C < A) || (numNewElems <= R && C < A)) {	// move C
+	// deleting: C is smaller
+	// inserting: C is smaller and R has room
+	CFIndex oldC0 = L + A + B;
+	CFIndex newC0 = L + A + newCount;
+	if (0 < C) CF_WRITE_BARRIER_MEMMOVE(buckets + newC0, buckets + oldC0, C * sizeof(struct __CFArrayBucket));
+	// GrP GC: zero-out newly exposed space on the right, if any
+	if (oldC0 > newC0) memset(buckets + newC0 + C, 0x00, (oldC0 - newC0) * sizeof(struct __CFArrayBucket));
+    } else if ((numNewElems < 0) || (numNewElems <= L && A <= C)) {	// move A
+	// deleting: A is smaller or equal (covers remaining delete cases)
+	// inserting: A is smaller and L has room
+	CFIndex oldL = L;
+	CFIndex newL = L - numNewElems;
+	deque->_leftIdx = newL;
+	if (0 < A) CF_WRITE_BARRIER_MEMMOVE(buckets + newL, buckets + oldL, A * sizeof(struct __CFArrayBucket));
+	// GrP GC: zero-out newly exposed space on the left, if any
+	if (newL > oldL) memset(buckets + oldL, 0x00, (newL - oldL) * sizeof(struct __CFArrayBucket));
+    } else {
+	// now, must be inserting, and either:
+	//    A<=C, but L doesn't have room (R might have, but don't care)
+	//    C<A, but R doesn't have room (L might have, but don't care)
+	// re-center everything
+	CFIndex oldL = L;
+	CFIndex newL = (L + R - numNewElems) / 2;
+	CFIndex oldBias = deque->_bias;
+	deque->_bias = (newL < oldL) ? -1 : 1;
+	if (oldBias < 0) {
+	    newL = newL - newL / 2;
+	} else if (0 < oldBias) {
+	    newL = newL + newL / 2;
+	}
+	CFIndex oldC0 = oldL + A + B;
+	CFIndex newC0 = newL + A + newCount;
+	deque->_leftIdx = newL;
+	if (newL < oldL) {
+	    if (0 < A) CF_WRITE_BARRIER_MEMMOVE(buckets + newL, buckets + oldL, A * sizeof(struct __CFArrayBucket));
+	    if (0 < C) CF_WRITE_BARRIER_MEMMOVE(buckets + newC0, buckets + oldC0, C * sizeof(struct __CFArrayBucket));
+	    // GrP GC: zero-out newly exposed space on the right, if any
+	    if (oldC0 > newC0) memset(buckets + newC0 + C, 0x00, (oldC0 - newC0) * sizeof(struct __CFArrayBucket));
+	} else {
+	    if (0 < C) CF_WRITE_BARRIER_MEMMOVE(buckets + newC0, buckets + oldC0, C * sizeof(struct __CFArrayBucket));
+	    if (0 < A) CF_WRITE_BARRIER_MEMMOVE(buckets + newL, buckets + oldL, A * sizeof(struct __CFArrayBucket));
+	    // GrP GC: zero-out newly exposed space on the left, if any
+	    if (newL > oldL) memset(buckets + oldL, 0x00, (newL - oldL) * sizeof(struct __CFArrayBucket));
+	}
+    }
+}
+
+static void __CFArrayHandleOutOfMemory(CFTypeRef obj, CFIndex numBytes) {
+    CFStringRef msg = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("Attempt to allocate %ld bytes for CFArray failed"), numBytes);
+    CFBadErrorCallBack cb = _CFGetOutOfMemoryErrorCallBack();
+    if (NULL == cb || !cb(obj, CFSTR("NS/CFArray"), msg)) {
+        CFLog(kCFLogLevelCritical, CFSTR("%@"), msg);
+        HALT;
+    }
+    CFRelease(msg);
+}
+
+// This function is for Foundation's benefit; no one else should use it.
+void _CFArraySetCapacity(CFMutableArrayRef array, CFIndex cap) {
+    if (CF_IS_OBJC(__kCFArrayTypeID, array)) return;
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    CFAssert3(__CFArrayGetCount(array) <= cap, __kCFLogAssertion, "%s(): desired capacity (%d) is less than count (%d)", __PRETTY_FUNCTION__, cap, __CFArrayGetCount(array));
+    // Currently, attempting to set the capacity of an array which is the CFStorage
+    // variant, or set the capacity larger than __CF_MAX_BUCKETS_PER_DEQUE, has no
+    // effect.  The primary purpose of this API is to help avoid a bunch of the
+    // resizes at the small capacities 4, 8, 16, etc.
+    if (__CFArrayGetType(array) == __kCFArrayDeque) {
+	struct __CFArrayDeque *deque = (struct __CFArrayDeque *)array->_store;
+	CFIndex capacity = __CFArrayDequeRoundUpCapacity(cap);
+	CFIndex size = sizeof(struct __CFArrayDeque) + capacity * sizeof(struct __CFArrayBucket);
+	CFAllocatorRef allocator = __CFGetAllocator(array);
+	if (NULL == deque) {
+	    deque = (struct __CFArrayDeque *)_CFAllocatorAllocateGC(allocator, size, isStrongMemory(array) ? __kCFAllocatorGCScannedMemory : 0);
+	    if (NULL == deque) __CFArrayHandleOutOfMemory(array, size);
+	    if (__CFOASafe) __CFSetLastAllocationEventName(deque, "CFArray (store-deque)");
+	    deque->_leftIdx = capacity / 2; 
+	} else {
+	    struct __CFArrayDeque *olddeque = deque;
+	    CFIndex oldcap = deque->_capacity;
+	    deque = (struct __CFArrayDeque *)_CFAllocatorAllocateGC(allocator, size, isStrongMemory(array) ? __kCFAllocatorGCScannedMemory : 0);
+	    if (NULL == deque) __CFArrayHandleOutOfMemory(array, size);
+	    CF_WRITE_BARRIER_MEMMOVE(deque, olddeque, sizeof(struct __CFArrayDeque) + oldcap * sizeof(struct __CFArrayBucket));
+	    _CFAllocatorDeallocateGC(allocator, olddeque);
+	    if (__CFOASafe) __CFSetLastAllocationEventName(deque, "CFArray (store-deque)");
+	}
+	deque->_capacity = capacity;
+	deque->_bias = 0;
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, array, array->_store, deque);
+    }    
+}
+
+// This function is for Foundation's benefit; no one else should use it.
+bool _CFArrayIsMutable(CFArrayRef array) {
+    return (__CFArrayGetType(array) != __kCFArrayImmutable);
+}
+
+void CFArrayReplaceValues(CFMutableArrayRef array, CFRange range, const void **newValues, CFIndex newCount) {
+    CF_OBJC_FUNCDISPATCH3(__kCFArrayTypeID, void, array, "replaceObjectsInRange:withObjects:count:", range, (void **)newValues, newCount);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    CFAssert2(0 <= newCount, __kCFLogAssertion, "%s(): newCount (%d) cannot be less than zero", __PRETTY_FUNCTION__, newCount);
+    return _CFArrayReplaceValues(array, range, newValues, newCount);
+}
+
+// This function does no ObjC dispatch or argument checking;
+// It should only be called from places where that dispatch and check has already been done, or NSCFArray
+void _CFArrayReplaceValues(CFMutableArrayRef array, CFRange range, const void **newValues, CFIndex newCount) {
+    const CFArrayCallBacks *cb;
+    CFAllocatorRef allocator;
+    CFIndex idx, cnt, futureCnt;
+    const void **newv, *buffer[256];
+    cnt = __CFArrayGetCount(array);
+    futureCnt = cnt - range.length + newCount;
+    CFAssert1(newCount <= futureCnt, __kCFLogAssertion, "%s(): internal error 1", __PRETTY_FUNCTION__);
+    cb = __CFArrayGetCallBacks(array);
+    allocator = __CFGetAllocator(array);
+    /* Retain new values if needed, possibly allocating a temporary buffer for them */
+    if (NULL != cb->retain && !hasBeenFinalized(array)) {
+	newv = (newCount <= 256) ? (const void **)buffer : (const void **)CFAllocatorAllocate(allocator, newCount * sizeof(void *), 0); // GC OK
+	if (newv != buffer && __CFOASafe) __CFSetLastAllocationEventName(newv, "CFArray (temp)");
+	for (idx = 0; idx < newCount; idx++) {
+	    newv[idx] = (void *)INVOKE_CALLBACK2(cb->retain, allocator, (void *)newValues[idx]);
+	}
+    } else {
+	newv = newValues;
+    }
+    array->_mutations++;
+
+    /* Now, there are three regions of interest, each of which may be empty:
+     *   A: the region from index 0 to one less than the range.location
+     *   B: the region of the range
+     *   C: the region from range.location + range.length to the end
+     * Note that index 0 is not necessarily at the lowest-address edge
+     * of the available storage. The values in region B need to get
+     * released, and the values in regions A and C (depending) need
+     * to get shifted if the number of new values is different from
+     * the length of the range being replaced.
+     */
+    if (0 < range.length) {
+	__CFArrayReleaseValues(array, range, false);
+    }
+    // region B elements are now "dead"
+    if (__kCFArrayStorage == __CFArrayGetType(array)) {
+	CFStorageRef store = (CFStorageRef)array->_store;
+	// reposition regions A and C for new region B elements in gap
+	if (range.length < newCount) {
+	    CFStorageInsertValues(store, CFRangeMake(range.location + range.length, newCount - range.length));
+	} else if (newCount < range.length) {
+	    CFStorageDeleteValues(store, CFRangeMake(range.location + newCount, range.length - newCount));
+	}
+	if (futureCnt <= __CF_MAX_BUCKETS_PER_DEQUE / 2) {
+	    __CFArrayConvertStoreToDeque(array);
+	}
+    } else if (NULL == array->_store) {
+	if (__CF_MAX_BUCKETS_PER_DEQUE <= futureCnt) {
+	    CFStorageRef store = (CFStorageRef)CFMakeCollectable(CFStorageCreate(allocator, sizeof(const void *)));
+	    if (! isStrongMemory(array)) _CFStorageSetWeak(store);
+	    if (__CFOASafe) __CFSetLastAllocationEventName(store, "CFArray (store-storage)");
+	    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, array, array->_store, store);
+	    CFStorageInsertValues(store, CFRangeMake(0, newCount));
+	    __CFBitfieldSetValue(((CFRuntimeBase *)array)->_cfinfo[CF_INFO_BITS], 1, 0, __kCFArrayStorage);
+	} else if (0 <= futureCnt) {
+	    struct __CFArrayDeque *deque;
+	    CFIndex capacity = __CFArrayDequeRoundUpCapacity(futureCnt);
+	    CFIndex size = sizeof(struct __CFArrayDeque) + capacity * sizeof(struct __CFArrayBucket);
+	    deque = (struct __CFArrayDeque *)_CFAllocatorAllocateGC(allocator, size, isStrongMemory(array) ? __kCFAllocatorGCScannedMemory : 0);
+	    if (__CFOASafe) __CFSetLastAllocationEventName(deque, "CFArray (store-deque)");
+	    deque->_leftIdx = (capacity - newCount) / 2;
+	    deque->_capacity = capacity;
+	    deque->_bias = 0;
+	    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, array, array->_store, deque);
+	}
+    } else {		// Deque
+	// reposition regions A and C for new region B elements in gap
+	if (__CF_MAX_BUCKETS_PER_DEQUE <= futureCnt) {
+	    CFStorageRef store;
+	    __CFArrayConvertDequeToStore(array);
+	    store = (CFStorageRef)array->_store;
+	    if (range.length < newCount) {
+		CFStorageInsertValues(store, CFRangeMake(range.location + range.length, newCount - range.length));
+	    } else if (newCount < range.length) { // this won't happen, but is here for completeness
+		CFStorageDeleteValues(store, CFRangeMake(range.location + newCount, range.length - newCount));
+	    }
+	} else if (range.length != newCount) {
+	    __CFArrayRepositionDequeRegions(array, range, newCount);
+	}
+    }
+    // copy in new region B elements
+    if (0 < newCount) {
+	if (__kCFArrayStorage == __CFArrayGetType(array)) {
+	    CFStorageRef store = (CFStorageRef)array->_store;
+	    CFStorageReplaceValues(store, CFRangeMake(range.location, newCount), newv);
+	} else {	// Deque
+	    struct __CFArrayDeque *deque = (struct __CFArrayDeque *)array->_store;
+	    struct __CFArrayBucket *raw_buckets = (struct __CFArrayBucket *)((uint8_t *)deque + sizeof(struct __CFArrayDeque));
+            CFAllocatorRef bucketsAllocator = isStrongMemory(array) ? allocator : kCFAllocatorNull;
+	    if (newCount == 1)
+		CF_WRITE_BARRIER_ASSIGN(bucketsAllocator, *((const void **)raw_buckets + deque->_leftIdx + range.location), newv[0]);
+	    else
+		CF_WRITE_BARRIER_MEMMOVE(raw_buckets + deque->_leftIdx + range.location, newv, newCount * sizeof(struct __CFArrayBucket));
+	}
+    }
+    __CFArraySetCount(array, futureCnt);
+    if (newv != buffer && newv != newValues) CFAllocatorDeallocate(allocator, newv);
+}
+
+struct _acompareContext {
+    CFComparatorFunction func;
+    void *context;
+};
+
+static CFComparisonResult __CFArrayCompareValues(const void *v1, const void *v2, struct _acompareContext *context) {
+    const void **val1 = (const void **)v1;
+    const void **val2 = (const void **)v2;
+    return (CFComparisonResult)(INVOKE_CALLBACK3(context->func, *val1, *val2, context->context));
+}
+
+void CFArraySortValues(CFMutableArrayRef array, CFRange range, CFComparatorFunction comparator, void *context) {
+    FAULT_CALLBACK((void **)&(comparator));
+    CF_OBJC_FUNCDISPATCH3(__kCFArrayTypeID, void, array, "sortUsingFunction:context:range:", comparator, context, range);
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    CFAssert1(NULL != comparator, __kCFLogAssertion, "%s(): pointer to comparator function may not be NULL", __PRETTY_FUNCTION__);
+    array->_mutations++;
+
+    if (1 < range.length) {
+	struct _acompareContext ctx;
+	struct __CFArrayBucket *bucket;
+	ctx.func = comparator;
+	ctx.context = context;
+	switch (__CFArrayGetType(array)) {
+	case __kCFArrayDeque:
+	    bucket = __CFArrayGetBucketsPtr(array) + range.location;
+	    if (CF_USING_COLLECTABLE_MEMORY && isStrongMemory(array)) {
+                size_t size = range.length * sizeof(void*);
+                __CFObjCWriteBarrierRange(bucket, size);
+                CFQSortArray(bucket, range.length, sizeof(void *), (CFComparatorFunction)__CFArrayCompareValues, &ctx);
+            } else {
+                CFQSortArray(bucket, range.length, sizeof(void *), (CFComparatorFunction)__CFArrayCompareValues, &ctx);
+            }
+	    break;
+	case __kCFArrayStorage: {
+	    CFStorageRef store = (CFStorageRef)array->_store;
+	    CFAllocatorRef allocator = __CFGetAllocator(array);
+	    const void **values, *buffer[256];
+	    values = (range.length <= 256) ? (const void **)buffer : (const void **)CFAllocatorAllocate(allocator, range.length * sizeof(void *), 0); // GC OK
+	    if (values != buffer && __CFOASafe) __CFSetLastAllocationEventName(values, "CFArray (temp)");
+	    CFStorageGetValues(store, range, values);
+	    CFQSortArray(values, range.length, sizeof(void *), (CFComparatorFunction)__CFArrayCompareValues, &ctx);
+	    CFStorageReplaceValues(store, range, values);
+	    if (values != buffer) CFAllocatorDeallocate(allocator, values);  // GC OK
+	    break;
+	}
+	}
+    }
+}
+
+CFIndex CFArrayBSearchValues(CFArrayRef array, CFRange range, const void *value, CFComparatorFunction comparator, void *context) {
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFArrayValidateRange(array, range, __PRETTY_FUNCTION__);
+    CFAssert1(NULL != comparator, __kCFLogAssertion, "%s(): pointer to comparator function may not be NULL", __PRETTY_FUNCTION__);
+    bool isObjC = CF_IS_OBJC(__kCFArrayTypeID, array);
+    FAULT_CALLBACK((void **)&(comparator));
+    CFIndex idx = 0;
+    if (range.length <= 0) return range.location;
+    if (isObjC || __kCFArrayStorage == __CFArrayGetType(array)) {
+	const void *item;
+	SInt32 lg;
+	item = CFArrayGetValueAtIndex(array, range.location + range.length - 1);
+	if ((CFComparisonResult)(INVOKE_CALLBACK3(comparator, item, value, context)) < 0) {
+	    return range.location + range.length;
+	}
+	item = CFArrayGetValueAtIndex(array, range.location);
+	if ((CFComparisonResult)(INVOKE_CALLBACK3(comparator, value, item, context)) < 0) {
+	    return range.location;
+	}
+	lg = flsl(range.length) - 1;	// lg2(range.length)
+	item = CFArrayGetValueAtIndex(array, range.location + -1 + (1 << lg));
+	idx = range.location + ((CFComparisonResult)(INVOKE_CALLBACK3(comparator, item, value, context)) < 0) ? range.length - (1 << lg) : -1;
+        while (lg--) {
+	    item = CFArrayGetValueAtIndex(array, range.location + idx + (1 << lg));
+	    if ((CFComparisonResult)(INVOKE_CALLBACK3(comparator, item, value, context)) < 0) {
+		idx += (1 << lg);
+	    }
+	}
+	idx++;
+    } else {
+	struct _acompareContext ctx;
+	ctx.func = comparator;
+	ctx.context = context;
+	idx = CFBSearch(&value, sizeof(void *), __CFArrayGetBucketsPtr(array) + range.location, range.length, (CFComparatorFunction)__CFArrayCompareValues, &ctx);
+    }
+    return idx + range.location;
+}
+
+void CFArrayAppendArray(CFMutableArrayRef array, CFArrayRef otherArray, CFRange otherRange) {
+    CFIndex idx;
+    __CFGenericValidateType(array, __kCFArrayTypeID);
+    __CFGenericValidateType(otherArray, __kCFArrayTypeID);
+    CFAssert1(__CFArrayGetType(array) != __kCFArrayImmutable, __kCFLogAssertion, "%s(): array is immutable", __PRETTY_FUNCTION__);
+    __CFArrayValidateRange(otherArray, otherRange, __PRETTY_FUNCTION__);
+    for (idx = otherRange.location; idx < otherRange.location + otherRange.length; idx++) {
+	CFArrayAppendValue(array, CFArrayGetValueAtIndex(otherArray, idx));
+    }
+}
diff --git a/CoreFoundation/CFArray.h b/CoreFoundation/CFArray.h
new file mode 100644
index 0000000..5b84595
--- /dev/null
+++ b/CoreFoundation/CFArray.h
@@ -0,0 +1,703 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+
+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 __CFArray * CFArrayRef;
+
+/*!
+	@typedef CFMutableArrayRef
+	This is the type of a reference to mutable CFArrays.
+*/
+typedef struct __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
+
+#endif /* ! __COREFOUNDATION_CFARRAY__ */
+
diff --git a/CoreFoundation/CFBag.c b/CoreFoundation/CFBag.c
new file mode 100644
index 0000000..ee56261
--- /dev/null
+++ b/CoreFoundation/CFBag.c
@@ -0,0 +1,1479 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2006, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+        Machine generated from Notes/HashingCode.template
+*/
+
+
+
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFBag.h>
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach-o/dyld.h>
+#endif
+
+#define CFDictionary 0
+#define CFSet 0
+#define CFBag 0
+#undef CFBag
+#define CFBag 1
+
+#if CFDictionary
+const CFBagKeyCallBacks kCFTypeBagKeyCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFBagKeyCallBacks kCFCopyStringBagKeyCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFBagValueCallBacks kCFTypeBagValueCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual};
+static const CFBagKeyCallBacks __kCFNullBagKeyCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+static const CFBagValueCallBacks __kCFNullBagValueCallBacks = {0, NULL, NULL, NULL, NULL};
+
+#define CFHashRef CFDictionaryRef
+#define CFMutableHashRef CFMutableDictionaryRef
+#define __kCFHashTypeID __kCFDictionaryTypeID
+#endif
+
+#if CFSet
+const CFBagCallBacks kCFTypeBagCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFBagCallBacks kCFCopyStringBagCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+static const CFBagCallBacks __kCFNullBagCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+
+#define CFBagKeyCallBacks CFBagCallBacks
+#define CFBagValueCallBacks CFBagCallBacks
+#define kCFTypeBagKeyCallBacks kCFTypeBagCallBacks
+#define kCFTypeBagValueCallBacks kCFTypeBagCallBacks
+#define __kCFNullBagKeyCallBacks __kCFNullBagCallBacks
+#define __kCFNullBagValueCallBacks __kCFNullBagCallBacks
+
+#define CFHashRef CFSetRef
+#define CFMutableHashRef CFMutableSetRef
+#define __kCFHashTypeID __kCFSetTypeID
+#endif
+
+#if CFBag
+const CFBagCallBacks kCFTypeBagCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFBagCallBacks kCFCopyStringBagCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+static const CFBagCallBacks __kCFNullBagCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+
+#define CFBagKeyCallBacks CFBagCallBacks
+#define CFBagValueCallBacks CFBagCallBacks
+#define kCFTypeBagKeyCallBacks kCFTypeBagCallBacks
+#define kCFTypeBagValueCallBacks kCFTypeBagCallBacks
+#define __kCFNullBagKeyCallBacks __kCFNullBagCallBacks
+#define __kCFNullBagValueCallBacks __kCFNullBagCallBacks
+
+#define CFHashRef CFBagRef
+#define CFMutableHashRef CFMutableBagRef
+#define __kCFHashTypeID __kCFBagTypeID
+#endif
+
+#define GETNEWKEY(newKey, oldKey) \
+        any_t (*kretain)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))__CFBagGetKeyCallBacks(hc)->retain \
+            : (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        any_t newKey = kretain ? (any_t)INVOKE_CALLBACK3(kretain, allocator, (any_t)key, hc->_context) : (any_t)oldKey
+
+#define RELEASEKEY(oldKey) \
+        void (*krelease)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (void (*)(CFAllocatorRef,any_t,any_pointer_t))__CFBagGetKeyCallBacks(hc)->release \
+            : (void (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        if (krelease) INVOKE_CALLBACK3(krelease, allocator, oldKey, hc->_context)
+        
+#if CFDictionary
+#define GETNEWVALUE(newValue) \
+        any_t (*vretain)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))__CFBagGetValueCallBacks(hc)->retain \
+            : (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        any_t newValue = vretain ? (any_t)INVOKE_CALLBACK3(vretain, allocator, (any_t)value, hc->_context) : (any_t)value
+
+#define RELEASEVALUE(oldValue) \
+    void (*vrelease)(CFAllocatorRef, any_t, any_pointer_t) = \
+      !hasBeenFinalized(hc) \
+        ? (void (*)(CFAllocatorRef,any_t,any_pointer_t))__CFBagGetValueCallBacks(hc)->release \
+        : (void (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+    if (vrelease) INVOKE_CALLBACK3(vrelease, allocator, oldValue, hc->_context)
+
+#endif
+
+static void __CFBagHandleOutOfMemory(CFTypeRef obj, CFIndex numBytes) {
+    CFStringRef msg = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("Attempt to allocate %ld bytes for NS/CFBag failed"), numBytes);
+    CFBadErrorCallBack cb = _CFGetOutOfMemoryErrorCallBack();
+    if (NULL == cb || !cb(obj, CFSTR("NS/CFBag"), msg)) {
+        CFLog(kCFLogLevelCritical, CFSTR("%@"), msg);
+	HALT;
+    }
+    CFRelease(msg);
+}
+
+
+// Max load is 3/4 number of buckets
+CF_INLINE CFIndex __CFHashRoundUpCapacity(CFIndex capacity) {
+    return 3 * ((CFIndex)1 << (flsl((capacity - 1) / 3)));
+}
+
+// Returns next power of two higher than the capacity
+// threshold for the given input capacity.
+CF_INLINE CFIndex __CFHashNumBucketsForCapacity(CFIndex capacity) {
+    return 4 * ((CFIndex)1 << (flsl((capacity - 1) / 3)));
+}
+
+enum {                /* Bits 1-0 */
+    __kCFHashImmutable = 0,        /* unchangable and fixed capacity */
+    __kCFHashMutable = 1,                /* changeable and variable capacity */
+};
+
+enum {                /* Bits 5-4 (value), 3-2 (key) */
+    __kCFHashHasNullCallBacks = 0,
+    __kCFHashHasCFTypeCallBacks = 1,
+    __kCFHashHasCustomCallBacks = 3        /* callbacks are at end of header */
+};
+
+// Under GC, we fudge the key/value memory in two ways
+// First, if we had null callbacks or null for both retain/release, we use unscanned memory and get
+// standard 'dangling' references.
+// This means that if people were doing addValue:[xxx new] and never removing, well, that doesn't work
+//
+// Second, if we notice standard retain/release implementations we use scanned memory, and fudge the
+// standard callbacks to generally do nothing if the collection was allocated in GC memory. On special
+// CF objects, however, like those used for precious resources like video-card buffers, we do indeed
+// do CFRetain on input and CFRelease on output.  The tricky case is GC finalization; we need to remember
+// that we did the CFReleases so that subsequent collection operations, like removal, don't double CFRelease.
+// (In fact we don't really use CFRetain/CFRelease but go directly to the collector)
+//
+
+enum {
+    __kCFHashFinalized =         (1 << 7),
+    __kCFHashWeakKeys =          (1 << 8),
+    __kCFHashWeakValues =        (1 << 9)
+};
+
+typedef uintptr_t any_t;
+typedef const void * const_any_pointer_t;
+typedef void * any_pointer_t;
+
+struct __CFBag {
+    CFRuntimeBase _base;
+    CFIndex _count;             /* number of values */
+    CFIndex _bucketsNum;        /* number of buckets */
+    CFIndex _bucketsUsed;       /* number of used buckets */
+    CFIndex _bucketsCap;        /* maximum number of used buckets */
+    CFIndex _mutations;
+    CFIndex _deletes;
+    any_pointer_t _context;     /* private */
+    CFOptionFlags _xflags;
+    any_t _marker;
+    any_t *_keys;     /* can be NULL if not allocated yet */
+    any_t *_values;   /* can be NULL if not allocated yet */
+};
+
+/* Bits 1-0 of the _xflags are used for mutability variety */
+/* Bits 3-2 of the _xflags are used for key callback indicator bits */
+/* Bits 5-4 of the _xflags are used for value callback indicator bits */
+/* Bit 6 of the _xflags is special KVO actions bit */
+/* Bits 7,8,9 are GC use */
+
+CF_INLINE bool hasBeenFinalized(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const struct __CFBag *)collection)->_xflags, 7, 7) != 0;
+}
+
+CF_INLINE void markFinalized(CFTypeRef collection) {
+    __CFBitfieldSetValue(((struct __CFBag *)collection)->_xflags, 7, 7, 1);
+}
+
+
+CF_INLINE CFIndex __CFHashGetType(CFHashRef hc) {
+    return __CFBitfieldGetValue(hc->_xflags, 1, 0);
+}
+
+CF_INLINE CFIndex __CFBagGetSizeOfType(CFIndex t) {
+    CFIndex size = sizeof(struct __CFBag);
+    if (__CFBitfieldGetValue(t, 3, 2) == __kCFHashHasCustomCallBacks) {
+        size += sizeof(CFBagKeyCallBacks);
+    }
+    if (__CFBitfieldGetValue(t, 5, 4) == __kCFHashHasCustomCallBacks) {
+        size += sizeof(CFBagValueCallBacks);
+    }
+    return size;
+}
+
+CF_INLINE const CFBagKeyCallBacks *__CFBagGetKeyCallBacks(CFHashRef hc) {
+    CFBagKeyCallBacks *result = NULL;
+    switch (__CFBitfieldGetValue(hc->_xflags, 3, 2)) {
+    case __kCFHashHasNullCallBacks:
+        return &__kCFNullBagKeyCallBacks;
+    case __kCFHashHasCFTypeCallBacks:
+        return &kCFTypeBagKeyCallBacks;
+    case __kCFHashHasCustomCallBacks:
+        break;
+    }
+    result = (CFBagKeyCallBacks *)((uint8_t *)hc + sizeof(struct __CFBag));
+    return result;
+}
+
+CF_INLINE Boolean __CFBagKeyCallBacksMatchNull(const CFBagKeyCallBacks *c) {
+    return (NULL == c ||
+        (c->retain == __kCFNullBagKeyCallBacks.retain &&
+         c->release == __kCFNullBagKeyCallBacks.release &&
+         c->copyDescription == __kCFNullBagKeyCallBacks.copyDescription &&
+         c->equal == __kCFNullBagKeyCallBacks.equal &&
+         c->hash == __kCFNullBagKeyCallBacks.hash));
+}
+
+CF_INLINE Boolean __CFBagKeyCallBacksMatchCFType(const CFBagKeyCallBacks *c) {
+    return (&kCFTypeBagKeyCallBacks == c ||
+        (c->retain == kCFTypeBagKeyCallBacks.retain &&
+         c->release == kCFTypeBagKeyCallBacks.release &&
+         c->copyDescription == kCFTypeBagKeyCallBacks.copyDescription &&
+         c->equal == kCFTypeBagKeyCallBacks.equal &&
+         c->hash == kCFTypeBagKeyCallBacks.hash));
+}
+
+CF_INLINE const CFBagValueCallBacks *__CFBagGetValueCallBacks(CFHashRef hc) {
+    CFBagValueCallBacks *result = NULL;
+    switch (__CFBitfieldGetValue(hc->_xflags, 5, 4)) {
+    case __kCFHashHasNullCallBacks:
+        return &__kCFNullBagValueCallBacks;
+    case __kCFHashHasCFTypeCallBacks:
+        return &kCFTypeBagValueCallBacks;
+    case __kCFHashHasCustomCallBacks:
+        break;
+    }
+    if (__CFBitfieldGetValue(hc->_xflags, 3, 2) == __kCFHashHasCustomCallBacks) {
+        result = (CFBagValueCallBacks *)((uint8_t *)hc + sizeof(struct __CFBag) + sizeof(CFBagKeyCallBacks));
+    } else {
+        result = (CFBagValueCallBacks *)((uint8_t *)hc + sizeof(struct __CFBag));
+    }
+    return result;
+}
+
+CF_INLINE Boolean __CFBagValueCallBacksMatchNull(const CFBagValueCallBacks *c) {
+    return (NULL == c ||
+        (c->retain == __kCFNullBagValueCallBacks.retain &&
+         c->release == __kCFNullBagValueCallBacks.release &&
+         c->copyDescription == __kCFNullBagValueCallBacks.copyDescription &&
+         c->equal == __kCFNullBagValueCallBacks.equal));
+}
+
+CF_INLINE Boolean __CFBagValueCallBacksMatchCFType(const CFBagValueCallBacks *c) {
+    return (&kCFTypeBagValueCallBacks == c ||
+        (c->retain == kCFTypeBagValueCallBacks.retain &&
+         c->release == kCFTypeBagValueCallBacks.release &&
+         c->copyDescription == kCFTypeBagValueCallBacks.copyDescription &&
+         c->equal == kCFTypeBagValueCallBacks.equal));
+}
+
+CFIndex _CFBagGetKVOBit(CFHashRef hc) {
+    return __CFBitfieldGetValue(hc->_xflags, 6, 6);
+}
+
+void _CFBagSetKVOBit(CFHashRef hc, CFIndex bit) {
+    __CFBitfieldSetValue(((CFMutableHashRef)hc)->_xflags, 6, 6, ((uintptr_t)bit & 0x1));
+}
+
+CF_INLINE Boolean __CFBagShouldShrink(CFHashRef hc) {
+    return (__kCFHashMutable == __CFHashGetType(hc)) &&
+                !(CF_USING_COLLECTABLE_MEMORY && auto_zone_is_finalized(__CFCollectableZone, hc)) && /* GC:  don't shrink finalizing hcs! */
+                (hc->_bucketsNum < 4 * hc->_deletes || (256 <= hc->_bucketsCap && hc-> _bucketsUsed < 3 * hc->_bucketsCap / 16));
+}
+
+CF_INLINE CFIndex __CFHashGetOccurrenceCount(CFHashRef hc, CFIndex idx) {
+#if CFBag
+    return (CFIndex)hc->_values[idx];
+#endif
+    return 1;
+}
+
+CF_INLINE Boolean __CFHashKeyIsValue(CFHashRef hc, any_t key) {
+    return (hc->_marker != key && ~hc->_marker != key) ? true : false;
+}
+
+CF_INLINE Boolean __CFHashKeyIsMagic(CFHashRef hc, any_t key) {
+    return (hc->_marker == key || ~hc->_marker == key) ? true : false;
+}
+
+
+#if !defined(CF_OBJC_KVO_WILLCHANGE)
+#define CF_OBJC_KVO_WILLCHANGE(obj, key)
+#define CF_OBJC_KVO_DIDCHANGE(obj, key)
+#endif
+
+CF_INLINE uintptr_t __CFBagScrambleHash(uintptr_t k) {
+#if 0
+    return k;
+#else
+#if __LP64__
+    uintptr_t a = 0x4368726973746F70ULL;
+    uintptr_t b = 0x686572204B616E65ULL;
+#else
+    uintptr_t a = 0x4B616E65UL;
+    uintptr_t b = 0x4B616E65UL;
+#endif
+    uintptr_t c = 1;
+    a += k;
+#if __LP64__
+    a -= b; a -= c; a ^= (c >> 43);
+    b -= c; b -= a; b ^= (a << 9);
+    c -= a; c -= b; c ^= (b >> 8);
+    a -= b; a -= c; a ^= (c >> 38);
+    b -= c; b -= a; b ^= (a << 23);
+    c -= a; c -= b; c ^= (b >> 5);
+    a -= b; a -= c; a ^= (c >> 35);
+    b -= c; b -= a; b ^= (a << 49);
+    c -= a; c -= b; c ^= (b >> 11);
+    a -= b; a -= c; a ^= (c >> 12);
+    b -= c; b -= a; b ^= (a << 18);
+    c -= a; c -= b; c ^= (b >> 22);
+#else
+    a -= b; a -= c; a ^= (c >> 13);
+    b -= c; b -= a; b ^= (a << 8);
+    c -= a; c -= b; c ^= (b >> 13);
+    a -= b; a -= c; a ^= (c >> 12);
+    b -= c; b -= a; b ^= (a << 16);
+    c -= a; c -= b; c ^= (b >> 5);
+    a -= b; a -= c; a ^= (c >> 3);
+    b -= c; b -= a; b ^= (a << 10);
+    c -= a; c -= b; c ^= (b >> 15);
+#endif
+    return c;
+#endif
+}
+
+static CFIndex __CFBagFindBuckets1a(CFHashRef hc, any_t key) {
+    CFHashCode keyHash = (CFHashCode)key;
+    keyHash = (CFHashCode)__CFBagScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            return kCFNotFound;
+        } else if (~marker == currKey) {        /* deleted */
+            /* do nothing */
+        } else if (currKey == key) {
+            return probe;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return kCFNotFound;
+        }
+    }
+}
+
+static CFIndex __CFBagFindBuckets1b(CFHashRef hc, any_t key) {
+    const CFBagKeyCallBacks *cb = __CFBagGetKeyCallBacks(hc);
+    CFHashCode keyHash = cb->hash ? (CFHashCode)INVOKE_CALLBACK2(((CFHashCode (*)(any_t, any_pointer_t))cb->hash), key, hc->_context) : (CFHashCode)key;
+    keyHash = (CFHashCode)__CFBagScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            return kCFNotFound;
+        } else if (~marker == currKey) {        /* deleted */
+            /* do nothing */
+        } else if (currKey == key || (cb->equal && INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))cb->equal, currKey, key, hc->_context))) {
+            return probe;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return kCFNotFound;
+        }
+    }
+}
+
+CF_INLINE CFIndex __CFBagFindBuckets1(CFHashRef hc, any_t key) {
+    if (__kCFHashHasNullCallBacks == __CFBitfieldGetValue(hc->_xflags, 3, 2)) {
+        return __CFBagFindBuckets1a(hc, key);
+    }
+    return __CFBagFindBuckets1b(hc, key);
+}
+
+static void __CFBagFindBuckets2(CFHashRef hc, any_t key, CFIndex *match, CFIndex *nomatch) {
+    const CFBagKeyCallBacks *cb = __CFBagGetKeyCallBacks(hc);
+    CFHashCode keyHash = cb->hash ? (CFHashCode)INVOKE_CALLBACK2(((CFHashCode (*)(any_t, any_pointer_t))cb->hash), key, hc->_context) : (CFHashCode)key;
+    keyHash = (CFHashCode)__CFBagScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    *match = kCFNotFound;
+    *nomatch = kCFNotFound;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            if (nomatch) *nomatch = probe;
+            return;
+        } else if (~marker == currKey) {        /* deleted */
+            if (nomatch) {
+                *nomatch = probe;
+                nomatch = NULL;
+            }
+        } else if (currKey == key || (cb->equal && INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))cb->equal, currKey, key, hc->_context))) {
+            *match = probe;
+            return;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return;
+        }
+    }
+}
+
+static void __CFBagFindNewMarker(CFHashRef hc) {
+    any_t *keys = hc->_keys;
+    any_t newMarker;
+    CFIndex idx, nbuckets;
+    Boolean hit;
+
+    nbuckets = hc->_bucketsNum;
+    newMarker = hc->_marker;
+    do {
+        newMarker--;
+        hit = false;
+        for (idx = 0; idx < nbuckets; idx++) {
+            if (newMarker == keys[idx] || ~newMarker == keys[idx]) {
+                hit = true;
+                break;
+            }
+        }
+    } while (hit);
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (hc->_marker == keys[idx]) {
+            keys[idx] = newMarker;
+        } else if (~hc->_marker == keys[idx]) {
+            keys[idx] = ~newMarker;
+        }
+    }
+    ((struct __CFBag *)hc)->_marker = newMarker;
+}
+
+static Boolean __CFBagEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFHashRef hc1 = (CFHashRef)cf1;
+    CFHashRef hc2 = (CFHashRef)cf2;
+    const CFBagKeyCallBacks *cb1, *cb2;
+    const CFBagValueCallBacks *vcb1, *vcb2;
+    any_t *keys;
+    CFIndex idx, nbuckets;
+    if (hc1 == hc2) return true;
+    if (hc1->_count != hc2->_count) return false;
+    cb1 = __CFBagGetKeyCallBacks(hc1);
+    cb2 = __CFBagGetKeyCallBacks(hc2);
+    if (cb1->equal != cb2->equal) return false;
+    vcb1 = __CFBagGetValueCallBacks(hc1);
+    vcb2 = __CFBagGetValueCallBacks(hc2);
+    if (vcb1->equal != vcb2->equal) return false;
+    if (0 == hc1->_bucketsUsed) return true; /* after function comparison! */
+    keys = hc1->_keys;
+    nbuckets = hc1->_bucketsNum;
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (hc1->_marker != keys[idx] && ~hc1->_marker != keys[idx]) {
+#if CFDictionary
+            const_any_pointer_t value;
+            if (!CFBagGetValueIfPresent(hc2, (any_pointer_t)keys[idx], &value)) return false;
+	    if (hc1->_values[idx] != (any_t)value) {
+		if (NULL == vcb1->equal) return false;
+	        if (!INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))vcb1->equal, hc1->_values[idx], (any_t)value, hc1->_context)) return false;
+            }
+#endif
+#if  CFSet
+            const_any_pointer_t value;
+            if (!CFBagGetValueIfPresent(hc2, (any_pointer_t)keys[idx], &value)) return false;
+#endif
+#if CFBag
+            if (hc1->_values[idx] != CFBagGetCountOfValue(hc2, (any_pointer_t)keys[idx])) return false;
+#endif
+        }
+    }
+    return true;
+}
+
+static CFHashCode __CFBagHash(CFTypeRef cf) {
+    CFHashRef hc = (CFHashRef)cf;
+    return hc->_count;
+}
+
+static CFStringRef __CFBagCopyDescription(CFTypeRef cf) {
+    CFHashRef hc = (CFHashRef)cf;
+    CFAllocatorRef allocator;
+    const CFBagKeyCallBacks *cb;
+    const CFBagValueCallBacks *vcb;
+    any_t *keys;
+    CFIndex idx, nbuckets;
+    CFMutableStringRef result;
+    cb = __CFBagGetKeyCallBacks(hc);
+    vcb = __CFBagGetValueCallBacks(hc);
+    keys = hc->_keys;
+    nbuckets = hc->_bucketsNum;
+    allocator = CFGetAllocator(hc);
+    result = CFStringCreateMutable(allocator, 0);
+    const char *type = "?";
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashImmutable: type = "immutable"; break;
+    case __kCFHashMutable: type = "mutable"; break;
+    }
+    CFStringAppendFormat(result, NULL, CFSTR("<CFBag %p [%p]>{type = %s, count = %u, capacity = %u, pairs = (\n"), cf, allocator, type, hc->_count, hc->_bucketsCap);
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            CFStringRef kDesc = NULL, vDesc = NULL;
+            if (NULL != cb->copyDescription) {
+                kDesc = (CFStringRef)INVOKE_CALLBACK2(((CFStringRef (*)(any_t, any_pointer_t))cb->copyDescription), keys[idx], hc->_context);
+            }
+            if (NULL != vcb->copyDescription) {
+                vDesc = (CFStringRef)INVOKE_CALLBACK2(((CFStringRef (*)(any_t, any_pointer_t))vcb->copyDescription), hc->_values[idx], hc->_context);
+            }
+#if CFDictionary
+            if (NULL != kDesc && NULL != vDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ = %@\n"), idx, kDesc, vDesc);
+                CFRelease(kDesc);
+                CFRelease(vDesc);
+            } else if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ = <%p>\n"), idx, kDesc, hc->_values[idx]);
+                CFRelease(kDesc);
+            } else if (NULL != vDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> = %@\n"), idx, keys[idx], vDesc);
+                CFRelease(vDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> = <%p>\n"), idx, keys[idx], hc->_values[idx]);
+            }
+#endif
+#if CFSet
+            if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@\n"), idx, kDesc);
+                CFRelease(kDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p>\n"), idx, keys[idx]);
+            }
+#endif
+#if CFBag
+            if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ (%ld)\n"), idx, kDesc, hc->_values[idx]);
+                CFRelease(kDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> (%ld)\n"), idx, keys[idx], hc->_values[idx]);
+            }
+#endif
+        }
+    }
+    CFStringAppend(result, CFSTR(")}"));
+    return result;
+}
+
+static void __CFBagDeallocate(CFTypeRef cf) {
+    CFMutableHashRef hc = (CFMutableHashRef)cf;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    const CFBagKeyCallBacks *cb = __CFBagGetKeyCallBacks(hc);
+    const CFBagValueCallBacks *vcb = __CFBagGetValueCallBacks(hc);
+
+    // mark now in case any callout somehow tries to add an entry back in
+    markFinalized(cf);
+    if (vcb->release || cb->release) {
+        any_t *keys = hc->_keys;
+        CFIndex idx, nbuckets = hc->_bucketsNum;
+        for (idx = 0; idx < nbuckets; idx++) {
+            any_t oldkey = keys[idx];
+            if (hc->_marker != oldkey && ~hc->_marker != oldkey) {
+                if (vcb->release) {
+                    INVOKE_CALLBACK3(((void (*)(CFAllocatorRef, any_t, any_pointer_t))vcb->release), allocator, hc->_values[idx], hc->_context);
+                }
+                if (cb->release) {
+                    INVOKE_CALLBACK3(((void (*)(CFAllocatorRef, any_t, any_pointer_t))cb->release), allocator, oldkey, hc->_context);
+                }
+            }
+        }
+    }
+
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        // return early so that contents are preserved after finalization
+        return;
+    }
+    
+    _CFAllocatorDeallocateGC(allocator, hc->_keys);
+#if CFDictionary || CFBag
+    _CFAllocatorDeallocateGC(allocator, hc->_values);
+#endif
+    hc->_keys = NULL;
+    hc->_values = NULL;
+    hc->_count = 0;  // GC: also zero count, so the hc will appear empty.
+    hc->_bucketsUsed = 0;
+    hc->_bucketsNum = 0;
+}
+
+static CFTypeID __kCFBagTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFBagClass = {
+    _kCFRuntimeScannedObject,
+    "CFBag",
+    NULL,        // init
+    NULL,        // copy
+    __CFBagDeallocate,
+    __CFBagEqual,
+    __CFBagHash,
+    NULL,        //
+    __CFBagCopyDescription
+};
+
+__private_extern__ void __CFBagInitialize(void) {
+    __kCFHashTypeID = _CFRuntimeRegisterClass(&__CFBagClass);
+}
+
+CFTypeID CFBagGetTypeID(void) {
+    return __kCFHashTypeID;
+}
+
+static CFMutableHashRef __CFBagInit(CFAllocatorRef allocator, CFOptionFlags flags, CFIndex capacity, const CFBagKeyCallBacks *keyCallBacks
+#if CFDictionary
+, const CFBagValueCallBacks *valueCallBacks
+#endif
+) {
+    struct __CFBag *hc;
+    CFIndex size;
+    __CFBitfieldSetValue(flags, 31, 2, 0);
+    CFOptionFlags xflags = 0;
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        // preserve NULL for key or value CB, otherwise fix up.
+        if (!keyCallBacks || (keyCallBacks->retain == NULL && keyCallBacks->release == NULL)) {
+            xflags = __kCFHashWeakKeys;
+        }
+#if CFDictionary
+        if (!valueCallBacks || (valueCallBacks->retain == NULL && valueCallBacks->release == NULL)) {
+            xflags |= __kCFHashWeakValues;
+        }
+#endif
+#if CFBag
+        xflags |= __kCFHashWeakValues;
+#endif
+    }
+    if (__CFBagKeyCallBacksMatchNull(keyCallBacks)) {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasNullCallBacks);
+    } else if (__CFBagKeyCallBacksMatchCFType(keyCallBacks)) {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasCFTypeCallBacks);
+    } else {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasCustomCallBacks);
+    }
+#if CFDictionary
+    if (__CFBagValueCallBacksMatchNull(valueCallBacks)) {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasNullCallBacks);
+    } else if (__CFBagValueCallBacksMatchCFType(valueCallBacks)) {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasCFTypeCallBacks);
+    } else {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasCustomCallBacks);
+    }
+#endif
+    size = __CFBagGetSizeOfType(flags) - sizeof(CFRuntimeBase);
+    hc = (struct __CFBag *)_CFRuntimeCreateInstance(allocator, __kCFHashTypeID, size, NULL);
+    if (NULL == hc) {
+        return NULL;
+    }
+    hc->_count = 0;
+    hc->_bucketsUsed = 0;
+    hc->_marker = (any_t)0xa1b1c1d3;
+    hc->_context = NULL;
+    hc->_deletes = 0;
+    hc->_mutations = 1;
+    hc->_xflags = xflags | flags;
+    switch (__CFBitfieldGetValue(flags, 1, 0)) {
+    case __kCFHashImmutable:
+        if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFBag (immutable)");
+        break;
+    case __kCFHashMutable:
+        if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFBag (mutable-variable)");
+        break;
+    }
+    hc->_bucketsCap = __CFHashRoundUpCapacity(1);
+    hc->_bucketsNum = 0;
+    hc->_keys = NULL;
+    hc->_values = NULL;
+    if (__kCFHashHasCustomCallBacks == __CFBitfieldGetValue(flags, 3, 2)) {
+        CFBagKeyCallBacks *cb = (CFBagKeyCallBacks *)__CFBagGetKeyCallBacks((CFHashRef)hc);
+        *cb = *keyCallBacks;
+        FAULT_CALLBACK((void **)&(cb->retain));
+        FAULT_CALLBACK((void **)&(cb->release));
+        FAULT_CALLBACK((void **)&(cb->copyDescription));
+        FAULT_CALLBACK((void **)&(cb->equal));
+        FAULT_CALLBACK((void **)&(cb->hash));
+    }
+#if CFDictionary
+    if (__kCFHashHasCustomCallBacks == __CFBitfieldGetValue(flags, 5, 4)) {
+        CFBagValueCallBacks *vcb = (CFBagValueCallBacks *)__CFBagGetValueCallBacks((CFHashRef)hc);
+        *vcb = *valueCallBacks;
+        FAULT_CALLBACK((void **)&(vcb->retain));
+        FAULT_CALLBACK((void **)&(vcb->release));
+        FAULT_CALLBACK((void **)&(vcb->copyDescription));
+        FAULT_CALLBACK((void **)&(vcb->equal));
+    }
+#endif
+    return hc;
+}
+
+#if CFDictionary
+CFHashRef CFBagCreate(CFAllocatorRef allocator, const_any_pointer_t *keys, const_any_pointer_t *values, CFIndex numValues, const CFBagKeyCallBacks *keyCallBacks, const CFBagValueCallBacks *valueCallBacks) {
+#endif
+#if CFSet || CFBag
+CFHashRef CFBagCreate(CFAllocatorRef allocator, const_any_pointer_t *keys, CFIndex numValues, const CFBagKeyCallBacks *keyCallBacks) {
+#endif
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%ld) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+#if CFDictionary
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashImmutable, numValues, keyCallBacks, valueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashImmutable, numValues, keyCallBacks);
+#endif
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashMutable);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+#if CFDictionary
+        CFBagAddValue(hc, keys[idx], values[idx]);
+#endif
+#if CFSet || CFBag
+        CFBagAddValue(hc, keys[idx]);
+#endif
+    }
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    return (CFHashRef)hc;
+}
+
+#if CFDictionary
+CFMutableHashRef CFBagCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFBagKeyCallBacks *keyCallBacks, const CFBagValueCallBacks *valueCallBacks) {
+#endif
+#if CFSet || CFBag
+CFMutableHashRef CFBagCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFBagKeyCallBacks *keyCallBacks) {
+#endif
+    CFAssert2(0 <= capacity, __kCFLogAssertion, "%s(): capacity (%ld) cannot be less than zero", __PRETTY_FUNCTION__, capacity);
+#if CFDictionary
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashMutable, capacity, keyCallBacks, valueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashMutable, capacity, keyCallBacks);
+#endif
+    return hc;
+}
+
+#if CFDictionary || CFSet
+// does not have Add semantics for Bag; it has Set semantics ... is that best?
+static void __CFBagGrow(CFMutableHashRef hc, CFIndex numNewValues);
+
+// This creates a hc which is for CFTypes or NSObjects, with a CFRetain style ownership transfer;
+// the hc does not take a retain (since it claims 1), and the caller does not need to release the inserted objects (since we do it).
+// The incoming objects must also be collectable if allocated out of a collectable allocator - and are neither released nor retained.
+#if CFDictionary
+CFHashRef _CFBagCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const_any_pointer_t *keys, const_any_pointer_t *values, CFIndex numValues) {
+#endif
+#if CFSet || CFBag
+CFHashRef _CFBagCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const_any_pointer_t *keys, CFIndex numValues) {
+#endif
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%ld) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+#if CFDictionary
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashMutable, numValues, &kCFTypeBagKeyCallBacks, &kCFTypeBagValueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashMutable, numValues, &kCFTypeBagKeyCallBacks);
+#endif
+    __CFBagGrow(hc, numValues);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+        CFIndex match, nomatch;
+        __CFBagFindBuckets2(hc, (any_t)keys[idx], &match, &nomatch);
+        if (kCFNotFound == match) {
+            CFAllocatorRef allocator = __CFGetAllocator(hc);
+            any_t newKey = (any_t)keys[idx];
+            if (__CFHashKeyIsMagic(hc, newKey)) {
+                __CFBagFindNewMarker(hc);
+            }
+            if (hc->_keys[nomatch] == ~hc->_marker) {
+                hc->_deletes--;
+            }
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+            any_t newValue = (any_t)values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+            hc->_values[nomatch] = 1;
+#endif
+            hc->_bucketsUsed++;
+            hc->_count++;
+        } else {
+            CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+            any_t oldKey = hc->_keys[match];
+            any_t newKey = (any_t)keys[idx];
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+            if (__CFHashKeyIsMagic(hc, newKey)) {
+                __CFBagFindNewMarker(hc);
+            }
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+            RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+            any_t oldValue = hc->_values[match];
+            any_t newValue = (any_t)values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+            RELEASEVALUE(oldValue);
+#endif
+        }
+    }
+    if (!isMutable) __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    return (CFHashRef)hc;
+}
+#endif
+
+CFHashRef CFBagCreateCopy(CFAllocatorRef allocator, CFHashRef other) {
+    CFMutableHashRef hc = CFBagCreateMutableCopy(allocator, CFBagGetCount(other), other);
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFBag (immutable)");
+    return hc;
+}
+
+CFMutableHashRef CFBagCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFHashRef other) {
+    CFIndex numValues = CFBagGetCount(other);
+    const_any_pointer_t *list, buffer[256];
+    list = (numValues <= 256) ? buffer : (const_any_pointer_t *)CFAllocatorAllocate(allocator, numValues * sizeof(const_any_pointer_t), 0);
+    if (list != buffer && __CFOASafe) __CFSetLastAllocationEventName(list, "CFBag (temp)");
+#if CFDictionary
+    const_any_pointer_t *vlist, vbuffer[256];
+    vlist = (numValues <= 256) ? vbuffer : (const_any_pointer_t *)CFAllocatorAllocate(allocator, numValues * sizeof(const_any_pointer_t), 0);
+    if (vlist != vbuffer && __CFOASafe) __CFSetLastAllocationEventName(vlist, "CFBag (temp)");
+#endif
+#if CFSet || CFBag
+    CFBagGetValues(other, list);
+#endif
+#if CFDictionary
+    CFBagGetKeysAndValues(other, list, vlist);
+#endif
+    const CFBagKeyCallBacks *kcb;
+    const CFBagValueCallBacks *vcb;
+    if (CF_IS_OBJC(__kCFHashTypeID, other)) {
+        kcb = &kCFTypeBagKeyCallBacks;
+        vcb = &kCFTypeBagValueCallBacks;
+    } else {
+        kcb = __CFBagGetKeyCallBacks(other);
+        vcb = __CFBagGetValueCallBacks(other);
+    }
+#if CFDictionary
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashMutable, capacity, kcb, vcb);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFBagInit(allocator, __kCFHashMutable, capacity, kcb);
+#endif
+    if (0 == capacity) _CFBagSetCapacity(hc, numValues);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+#if CFDictionary
+        CFBagAddValue(hc, list[idx], vlist[idx]);
+#endif
+#if CFSet || CFBag
+        CFBagAddValue(hc, list[idx]);
+#endif
+    }
+    if (list != buffer) CFAllocatorDeallocate(allocator, list);
+#if CFDictionary
+    if (vlist != vbuffer) CFAllocatorDeallocate(allocator, vlist);
+#endif
+    return hc;
+}
+
+// Used by NSHashTables/NSMapTables and KVO
+void _CFBagSetContext(CFHashRef hc, any_pointer_t context) {
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    CF_WRITE_BARRIER_BASE_ASSIGN(__CFGetAllocator(hc), hc, hc->_context, context);
+}
+
+any_pointer_t _CFBagGetContext(CFHashRef hc) {
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    return hc->_context;
+}
+
+CFIndex CFBagGetCount(CFHashRef hc) {
+    if (CFDictionary || CFSet) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, CFIndex, hc, "count");
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    return hc->_count;
+}
+
+#if CFDictionary
+CFIndex CFBagGetCountOfKey(CFHashRef hc, const_any_pointer_t key) {
+#endif
+#if CFSet || CFBag
+CFIndex CFBagGetCountOfValue(CFHashRef hc, const_any_pointer_t key) {
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    CFIndex match = __CFBagFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? __CFHashGetOccurrenceCount(hc, match) : 0);
+}
+
+#if CFDictionary
+Boolean CFBagContainsKey(CFHashRef hc, const_any_pointer_t key) {
+#endif
+#if CFSet || CFBag
+Boolean CFBagContainsValue(CFHashRef hc, const_any_pointer_t key) {
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFBagFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? true : false);
+}
+
+#if CFDictionary
+CFIndex CFBagGetCountOfValue(CFHashRef hc, const_any_pointer_t value) {
+    CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForObject:", value);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    any_t *keys = hc->_keys;
+    Boolean (*equal)(any_t, any_t, any_pointer_t) = (Boolean (*)(any_t, any_t, any_pointer_t))__CFBagGetValueCallBacks(hc)->equal;
+    CFIndex cnt = 0;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            if ((hc->_values[idx] == (any_t)value) || (equal && INVOKE_CALLBACK3(equal, hc->_values[idx], (any_t)value, hc->_context))) {
+                cnt++;
+            }
+        }
+    }
+    return cnt;
+}
+
+Boolean CFBagContainsValue(CFHashRef hc, const_any_pointer_t value) {
+    CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsObject:", value);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    any_t *keys = hc->_keys;
+    Boolean (*equal)(any_t, any_t, any_pointer_t) = (Boolean (*)(any_t, any_t, any_pointer_t))__CFBagGetValueCallBacks(hc)->equal;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            if ((hc->_values[idx] == (any_t)value) || (equal && INVOKE_CALLBACK3(equal, hc->_values[idx], (any_t)value, hc->_context))) {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+#endif
+
+const_any_pointer_t CFBagGetValue(CFHashRef hc, const_any_pointer_t key) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, const_any_pointer_t, hc, "objectForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, const_any_pointer_t, hc, "member:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    CFIndex match = __CFBagFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? (const_any_pointer_t)(CFDictionary ? hc->_values[match] : hc->_keys[match]) : 0);
+}
+
+Boolean CFBagGetValueIfPresent(CFHashRef hc, const_any_pointer_t key, const_any_pointer_t *value) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "_getValue:forKey:", (any_t *)value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "_getValue:forObj:", (any_t *)value, key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFBagFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? ((value ? __CFObjCStrongAssign((const_any_pointer_t)(CFDictionary ? hc->_values[match] : hc->_keys[match]), value) : 0), true) : false);
+}
+
+#if CFDictionary
+Boolean CFBagGetKeyIfPresent(CFHashRef hc, const_any_pointer_t key, const_any_pointer_t *actualkey) {
+    CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "getActualKey:forKey:", actualkey, key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFBagFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? ((actualkey ? __CFObjCStrongAssign((const_any_pointer_t)hc->_keys[match], actualkey) : NULL), true) : false);
+}
+#endif
+
+#if CFDictionary
+void CFBagGetKeysAndValues(CFHashRef hc, const_any_pointer_t *keybuf, const_any_pointer_t *valuebuf) {
+#endif
+#if CFSet || CFBag
+void CFBagGetValues(CFHashRef hc, const_any_pointer_t *keybuf) {
+    const_any_pointer_t *valuebuf = 0;
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "getObjects:andKeys:", (any_t *)valuebuf, (any_t *)keybuf);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "getObjects:", (any_t *)keybuf);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (CF_USING_COLLECTABLE_MEMORY) {
+        // GC: speculatively issue a write-barrier on the copied to buffers
+        __CFObjCWriteBarrierRange(keybuf, hc->_count * sizeof(any_t));
+        __CFObjCWriteBarrierRange(valuebuf, hc->_count * sizeof(any_t));
+    }
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            for (CFIndex cnt = __CFHashGetOccurrenceCount(hc, idx); cnt--;) {
+                if (keybuf) *keybuf++ = (const_any_pointer_t)keys[idx];
+                if (valuebuf) *valuebuf++ = (const_any_pointer_t)hc->_values[idx];
+            }
+        }
+    }
+}
+
+#if CFDictionary || CFSet
+unsigned long _CFBagFastEnumeration(CFHashRef hc, struct __objcFastEnumerationStateEquivalent *state, void *stackbuffer, unsigned long count) {
+    /* copy as many as count items over */
+    if (0 == state->state) {        /* first time */
+        state->mutationsPtr = (unsigned long *)&hc->_mutations;
+    }
+    state->itemsPtr = (unsigned long *)stackbuffer;
+    CFIndex cnt = 0;
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = (CFIndex)state->state, nbuckets = hc->_bucketsNum; idx < nbuckets && cnt < (CFIndex)count; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            state->itemsPtr[cnt++] = (unsigned long)keys[idx];
+        }
+        state->state++;
+    }
+    return cnt;
+}
+#endif
+
+void CFBagApplyFunction(CFHashRef hc, CFBagApplierFunction applier, any_pointer_t context) {
+    FAULT_CALLBACK((void **)&(applier));
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_apply:context:", applier, context);
+    if (CFSet) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_applyValues:context:", applier, context);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            for (CFIndex cnt = __CFHashGetOccurrenceCount(hc, idx); cnt--;) {
+#if CFDictionary
+                INVOKE_CALLBACK3(applier, (const_any_pointer_t)keys[idx], (const_any_pointer_t)hc->_values[idx], context);
+#endif
+#if CFSet || CFBag
+                INVOKE_CALLBACK2(applier, (const_any_pointer_t)keys[idx], context);
+#endif
+            }
+        }
+    }
+}
+
+static void __CFBagGrow(CFMutableHashRef hc, CFIndex numNewValues) {
+    any_t *oldkeys = hc->_keys;
+    any_t *oldvalues = hc->_values;
+    CFIndex nbuckets = hc->_bucketsNum;
+    hc->_bucketsCap = __CFHashRoundUpCapacity(hc->_bucketsUsed + numNewValues);
+    hc->_bucketsNum = __CFHashNumBucketsForCapacity(hc->_bucketsCap);
+    hc->_deletes = 0;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    CFOptionFlags weakOrStrong = (hc->_xflags & __kCFHashWeakKeys) ? 0 : __kCFAllocatorGCScannedMemory;
+    any_t *mem = (any_t *)_CFAllocatorAllocateGC(allocator, hc->_bucketsNum * sizeof(any_t), weakOrStrong);
+    if (NULL == mem) __CFBagHandleOutOfMemory(hc, hc->_bucketsNum * sizeof(any_t));
+    if (__CFOASafe) __CFSetLastAllocationEventName(mem, "CFBag (key-store)");
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, hc, hc->_keys, mem);
+    CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;  // GC: avoids write-barrier in weak case.
+    any_t *keysBase = mem;
+#if CFDictionary || CFBag
+    weakOrStrong = (hc->_xflags & __kCFHashWeakValues) ? 0 : __kCFAllocatorGCScannedMemory;
+    mem = (any_t *)_CFAllocatorAllocateGC(allocator, hc->_bucketsNum * sizeof(any_t), weakOrStrong);
+    if (NULL == mem) __CFBagHandleOutOfMemory(hc, hc->_bucketsNum * sizeof(any_t));
+    if (__CFOASafe) __CFSetLastAllocationEventName(mem, "CFBag (value-store)");
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, hc, hc->_values, mem);
+#endif
+#if CFDictionary
+    CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator; // GC: avoids write-barrier in weak case.
+    any_t *valuesBase = mem;
+#endif
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        hc->_keys[idx] = hc->_marker;
+#if CFDictionary || CFBag
+        hc->_values[idx] = 0;
+#endif
+    }
+    if (NULL == oldkeys) return;
+    for (CFIndex idx = 0; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, oldkeys[idx])) {
+            CFIndex match, nomatch;
+            __CFBagFindBuckets2(hc, oldkeys[idx], &match, &nomatch);
+            CFAssert3(kCFNotFound == match, __kCFLogAssertion, "%s(): two values (%p, %p) now hash to the same slot; mutable value changed while in table or hash value is not immutable", __PRETTY_FUNCTION__, oldkeys[idx], hc->_keys[match]);
+            if (kCFNotFound != nomatch) {
+                CF_WRITE_BARRIER_BASE_ASSIGN(keysAllocator, keysBase, hc->_keys[nomatch], oldkeys[idx]);
+#if CFDictionary
+                CF_WRITE_BARRIER_BASE_ASSIGN(valuesAllocator, valuesBase, hc->_values[nomatch], oldvalues[idx]);
+#endif
+#if CFBag
+                hc->_values[nomatch] = oldvalues[idx];
+#endif
+            }
+        }
+    }
+    _CFAllocatorDeallocateGC(allocator, oldkeys);
+    _CFAllocatorDeallocateGC(allocator, oldvalues);
+}
+
+// This function is for Foundation's benefit; no one else should use it.
+void _CFBagSetCapacity(CFMutableHashRef hc, CFIndex cap) {
+    if (CF_IS_OBJC(__kCFHashTypeID, hc)) return;
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    CFAssert1(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): collection is immutable", __PRETTY_FUNCTION__);
+    CFAssert3(hc->_bucketsUsed <= cap, __kCFLogAssertion, "%s(): desired capacity (%ld) is less than bucket count (%ld)", __PRETTY_FUNCTION__, cap, hc->_bucketsUsed);
+    __CFBagGrow(hc, cap - hc->_bucketsUsed);
+}
+
+
+#if CFDictionary
+void CFBagAddValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFBagAddValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_addObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "addObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        if (hc->_bucketsUsed == hc->_bucketsCap || NULL == hc->_keys) {
+            __CFBagGrow(hc, 1);
+        }
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    CFIndex match, nomatch;
+    __CFBagFindBuckets2(hc, (any_t)key, &match, &nomatch);
+    if (kCFNotFound != match) {
+#if CFBag
+        CF_OBJC_KVO_WILLCHANGE(hc, hc->_keys[match]);
+        hc->_values[match]++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, hc->_keys[match]);
+#endif
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        GETNEWKEY(newKey, key);
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFBagFindNewMarker(hc);
+        }
+        if (hc->_keys[nomatch] == ~hc->_marker) {
+            hc->_deletes--;
+        }
+        CF_OBJC_KVO_WILLCHANGE(hc, key);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+        hc->_values[nomatch] = 1;
+#endif
+        hc->_bucketsUsed++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, key);
+    }
+}
+
+#if CFDictionary
+void CFBagReplaceValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFBagReplaceValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_replaceObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "_replaceObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFIndex match = __CFBagFindBuckets1(hc, (any_t)key);
+    if (kCFNotFound == match) return;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+    GETNEWKEY(newKey, key);
+#endif
+#if CFDictionary
+    GETNEWVALUE(newValue);
+#endif
+    any_t oldKey = hc->_keys[match];
+    CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFSet || CFBag
+    CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+    CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+    if (__CFHashKeyIsMagic(hc, newKey)) {
+        __CFBagFindNewMarker(hc);
+    }
+    CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+#endif
+#if CFDictionary
+    any_t oldValue = hc->_values[match];
+    CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+    CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+#endif
+    CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+#if CFSet || CFBag
+    RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+    RELEASEVALUE(oldValue);
+#endif
+}
+
+#if CFDictionary
+void CFBagSetValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFBagSetValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "setObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "_setObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        if (hc->_bucketsUsed == hc->_bucketsCap || NULL == hc->_keys) {
+            __CFBagGrow(hc, 1);
+        }
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    CFIndex match, nomatch;
+    __CFBagFindBuckets2(hc, (any_t)key, &match, &nomatch);
+    if (kCFNotFound == match) {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        GETNEWKEY(newKey, key);
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFBagFindNewMarker(hc);
+        }
+        if (hc->_keys[nomatch] == ~hc->_marker) {
+            hc->_deletes--;
+        }
+        CF_OBJC_KVO_WILLCHANGE(hc, key);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+        hc->_values[nomatch] = 1;
+#endif
+        hc->_bucketsUsed++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, key);
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+        GETNEWKEY(newKey, key);
+#endif
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        any_t oldKey = hc->_keys[match];
+        CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFSet || CFBag
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFBagFindNewMarker(hc);
+        }
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+#endif
+#if CFDictionary
+        any_t oldValue = hc->_values[match];
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+#endif
+        CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+#if CFSet || CFBag
+        RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+        RELEASEVALUE(oldValue);
+#endif
+    }
+}
+
+void CFBagRemoveValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "removeObjectForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "removeObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFIndex match = __CFBagFindBuckets1(hc, (any_t)key);
+    if (kCFNotFound == match) return;
+    if (1 < __CFHashGetOccurrenceCount(hc, match)) {
+#if CFBag
+        CF_OBJC_KVO_WILLCHANGE(hc, hc->_keys[match]);
+        hc->_values[match]--;
+        hc->_count--;
+        CF_OBJC_KVO_DIDCHANGE(hc, hc->_keys[match]);
+#endif
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        any_t oldKey = hc->_keys[match];
+        CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+#if CFDictionary
+        any_t oldValue = hc->_values[match];
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], 0);
+#endif
+#if CFBag
+        hc->_values[match] = 0;
+#endif
+        hc->_count--;
+        hc->_bucketsUsed--;
+        hc->_deletes++;
+        CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+        RELEASEKEY(oldKey);
+#if CFDictionary
+        RELEASEVALUE(oldValue);
+#endif
+        if (__CFBagShouldShrink(hc)) {
+            __CFBagGrow(hc, 0);
+        } else {
+            // When the probeskip == 1 always and only, a DELETED slot followed by an EMPTY slot
+            // can be converted to an EMPTY slot.  By extension, a chain of DELETED slots followed
+            // by an EMPTY slot can be converted to EMPTY slots, which is what we do here.
+            if (match < hc->_bucketsNum - 1 && hc->_keys[match + 1] == hc->_marker) {
+                while (0 <= match && hc->_keys[match] == ~hc->_marker) {
+                    hc->_keys[match] = hc->_marker;
+                    hc->_deletes--;
+                    match--;
+                }
+            }
+        }
+    }
+}
+
+void CFBagRemoveAllValues(CFMutableHashRef hc) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, void, hc, "removeAllObjects");
+    if (CFSet) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, void, hc, "removeAllObjects");
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            any_t oldKey = keys[idx];
+            CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFDictionary || CFSet
+            hc->_count--;
+#endif
+#if CFBag
+            hc->_count -= (CFIndex)hc->_values[idx];
+#endif
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[idx], ~hc->_marker);
+#if CFDictionary
+            any_t oldValue = hc->_values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[idx], 0);
+#endif
+#if CFBag
+            hc->_values[idx] = 0;
+#endif
+            hc->_bucketsUsed--;
+            hc->_deletes++;
+            CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+            RELEASEKEY(oldKey);
+#if CFDictionary
+            RELEASEVALUE(oldValue);
+#endif
+        }
+    }
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        keys[idx] = hc->_marker;
+    }
+    hc->_deletes = 0;
+    hc->_bucketsUsed = 0;
+    hc->_count = 0;
+    if (__CFBagShouldShrink(hc) && (256 <= hc->_bucketsCap)) {
+        __CFBagGrow(hc, 128);
+    }
+}
+
+#undef CF_OBJC_KVO_WILLCHANGE
+#undef CF_OBJC_KVO_DIDCHANGE
+
diff --git a/CoreFoundation/CFBag.h b/CoreFoundation/CFBag.h
new file mode 100644
index 0000000..e23cf84
--- /dev/null
+++ b/CoreFoundation/CFBag.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBAG__)
+#define __COREFOUNDATION_CFBAG__ 1
+
+#include <CoreFoundation/CFBase.h>
+
+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
+
+#endif /* ! __COREFOUNDATION_CFBAG__ */
+
diff --git a/CoreFoundation/CFBase.c b/CoreFoundation/CFBase.c
new file mode 100644
index 0000000..fcf42f6
--- /dev/null
+++ b/CoreFoundation/CFBase.c
@@ -0,0 +1,1110 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFBase.h>
+#include "CFInternal.h"
+#if DEPLOYMENT_TARGET_MACOSX
+#include <pthread.h>
+#include <malloc/malloc.h>
+#include <mach/mach.h>
+#include <dlfcn.h>
+#elif DEPLOYMENT_TARGET_LINUX
+#if defined(DEBUG)
+#include <mcheck.h>
+#endif
+#include <pthread.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <windows.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+
+extern size_t malloc_good_size(size_t size);
+
+#if defined(__CYGWIN32__) || defined (D__CYGWIN_)
+#error CoreFoundation is currently built with the Microsoft C Runtime, which is incompatible with the Cygwin DLL.  You must either use the -mno-cygwin flag, or complete a port of CF to the Cygwin environment.
+#endif
+
+// -------- -------- -------- -------- -------- -------- -------- --------
+
+// CFAllocator structure must match struct _malloc_zone_t!
+// The first two reserved fields in struct _malloc_zone_t are for us with CFRuntimeBase
+struct __CFAllocator {
+    CFRuntimeBase _base;
+#if DEPLOYMENT_TARGET_MACOSX
+    size_t (*size)(struct _malloc_zone_t *zone, const void *ptr); /* returns the size of a block or 0 if not in this zone; must be fast, especially for negative answers */
+    void *(*malloc)(struct _malloc_zone_t *zone, size_t size);
+    void *(*calloc)(struct _malloc_zone_t *zone, size_t num_items, size_t size); /* same as malloc, but block returned is set to zero */
+    void *(*valloc)(struct _malloc_zone_t *zone, size_t size); /* same as malloc, but block returned is set to zero and is guaranteed to be page aligned */
+    void (*free)(struct _malloc_zone_t *zone, void *ptr);
+    void *(*realloc)(struct _malloc_zone_t *zone, void *ptr, size_t size);
+    void (*destroy)(struct _malloc_zone_t *zone); /* zone is destroyed and all memory reclaimed */
+    const char	*zone_name;
+    unsigned (*batch_malloc)(struct _malloc_zone_t *zone, size_t size, void **results, unsigned num_requested); /* given a size, returns pointers capable of holding that size; returns the number of pointers allocated (maybe 0 or less than num_requested) */
+    void (*batch_free)(struct _malloc_zone_t *zone, void **to_be_freed, unsigned num_to_be_freed); /* frees all the pointers in to_be_freed; note that to_be_freed may be overwritten during the process */
+    struct malloc_introspection_t	*introspect;
+    void	*reserved5;
+#endif
+    CFAllocatorRef _allocator;
+    CFAllocatorContext _context;
+};
+
+CF_INLINE CFAllocatorRetainCallBack __CFAllocatorGetRetainFunction(const CFAllocatorContext *context) {
+    CFAllocatorRetainCallBack retval = NULL;
+	retval = context->retain;
+    return retval;
+}
+
+CF_INLINE CFAllocatorReleaseCallBack __CFAllocatorGetReleaseFunction(const CFAllocatorContext *context) {
+    CFAllocatorReleaseCallBack retval = NULL;
+	retval = context->release;
+    return retval;
+}
+
+CF_INLINE CFAllocatorCopyDescriptionCallBack __CFAllocatorGetCopyDescriptionFunction(const CFAllocatorContext *context) {
+    CFAllocatorCopyDescriptionCallBack retval = NULL;
+	retval = context->copyDescription;
+    return retval;
+}
+
+CF_INLINE CFAllocatorAllocateCallBack __CFAllocatorGetAllocateFunction(const CFAllocatorContext *context) {
+    CFAllocatorAllocateCallBack retval = NULL;
+	retval = context->allocate;
+    return retval;
+}
+
+CF_INLINE CFAllocatorReallocateCallBack __CFAllocatorGetReallocateFunction(const CFAllocatorContext *context) {
+    CFAllocatorReallocateCallBack retval = NULL;
+	retval = context->reallocate;
+    return retval;
+}
+
+CF_INLINE CFAllocatorDeallocateCallBack __CFAllocatorGetDeallocateFunction(const CFAllocatorContext *context) {
+    CFAllocatorDeallocateCallBack retval = NULL;
+	retval = context->deallocate;
+    return retval;
+}
+
+CF_INLINE CFAllocatorPreferredSizeCallBack __CFAllocatorGetPreferredSizeFunction(const CFAllocatorContext *context) {
+    CFAllocatorPreferredSizeCallBack retval = NULL;
+	retval = context->preferredSize;
+    return retval;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX
+
+__private_extern__ void __CFAllocatorDeallocate(CFTypeRef cf);
+
+static kern_return_t __CFAllocatorZoneIntrospectNoOp(void) {
+    return 0;
+}
+
+static boolean_t __CFAllocatorZoneIntrospectTrue(void) {
+    return 1;
+}
+
+static size_t __CFAllocatorCustomSize(malloc_zone_t *zone, const void *ptr) {
+    return 0;
+
+    // The only way to implement this with a version 0 allocator would be
+    // for CFAllocator to keep track of all blocks allocated itself, which
+    // could be done, but would be bad for performance, so we don't do it.
+    //    size_t (*size)(struct _malloc_zone_t *zone, const void *ptr);
+    /* returns the size of a block or 0 if not in this zone;
+     * must be fast, especially for negative answers */
+}
+
+static void *__CFAllocatorCustomMalloc(malloc_zone_t *zone, size_t size) {
+    CFAllocatorRef allocator = (CFAllocatorRef)zone;
+    return CFAllocatorAllocate(allocator, size, 0);
+}
+
+static void *__CFAllocatorCustomCalloc(malloc_zone_t *zone, size_t num_items, size_t size) {
+    CFAllocatorRef allocator = (CFAllocatorRef)zone;
+    void *newptr = CFAllocatorAllocate(allocator, size, 0);
+    if (newptr) memset(newptr, 0, size);
+    return newptr;
+}
+
+static void *__CFAllocatorCustomValloc(malloc_zone_t *zone, size_t size) {
+    CFAllocatorRef allocator = (CFAllocatorRef)zone;
+    void *newptr = CFAllocatorAllocate(allocator, size + vm_page_size, 0);
+    newptr = (void *)round_page((uintptr_t)newptr);
+    return newptr;
+}
+
+static void __CFAllocatorCustomFree(malloc_zone_t *zone, void *ptr) {
+    CFAllocatorRef allocator = (CFAllocatorRef)zone;
+    CFAllocatorDeallocate(allocator, ptr);
+}
+
+static void *__CFAllocatorCustomRealloc(malloc_zone_t *zone, void *ptr, size_t size) {
+    CFAllocatorRef allocator = (CFAllocatorRef)zone;
+    return CFAllocatorReallocate(allocator, ptr, size, 0);
+}
+
+static void __CFAllocatorCustomDestroy(malloc_zone_t *zone) {
+    CFAllocatorRef allocator = (CFAllocatorRef)zone;
+    // !!! we do it, and caller of malloc_destroy_zone() assumes
+    // COMPLETE responsibility for the result; NO Apple library
+    // code should be modified as a result of discovering that
+    // some activity results in inconveniences to developers
+    // trying to use malloc_destroy_zone() with a CFAllocatorRef;
+    // that's just too bad for them.
+    __CFAllocatorDeallocate(allocator);
+}
+
+static size_t __CFAllocatorCustomGoodSize(malloc_zone_t *zone, size_t size) {
+    CFAllocatorRef allocator = (CFAllocatorRef)zone;
+    return CFAllocatorGetPreferredSizeForSize(allocator, size, 0);
+}
+
+// These should live in the malloc.h heaer file
+typedef double (*Fx)(double);
+typedef kern_return_t (*mit_EnumType)(task_t task, void *, unsigned type_mask, vm_address_t zone_address, memory_reader_t reader, vm_range_recorder_t recorder);
+typedef size_t        (*mit_GoodSize)(malloc_zone_t *zone, size_t size);
+typedef boolean_t     (*mit_Check)(malloc_zone_t *zone);
+typedef void          (*mit_Print)(malloc_zone_t *zone, boolean_t verbose);
+typedef void          (*mit_Log)(malloc_zone_t *zone, void *address);
+typedef void          (*mit_ZoneAction)(malloc_zone_t *zone);
+typedef void          (*mit_Statistics)(malloc_zone_t *zone, malloc_statistics_t *stats);
+
+static struct malloc_introspection_t __CFAllocatorZoneIntrospect = {
+    (mit_EnumType)__CFAllocatorZoneIntrospectNoOp,
+    (mit_GoodSize)__CFAllocatorCustomGoodSize,
+    (mit_Check)__CFAllocatorZoneIntrospectTrue,
+    (mit_Print)__CFAllocatorZoneIntrospectNoOp,
+    (mit_Log)__CFAllocatorZoneIntrospectNoOp,
+    (mit_ZoneAction)__CFAllocatorZoneIntrospectNoOp,
+    (mit_ZoneAction)__CFAllocatorZoneIntrospectNoOp,
+    (mit_Statistics)__CFAllocatorZoneIntrospectNoOp
+};
+
+static size_t __CFAllocatorNullSize(malloc_zone_t *zone, const void *ptr) {
+    return 0;
+}
+
+static void * __CFAllocatorNullMalloc(malloc_zone_t *zone, size_t size) {
+    return NULL;
+}
+
+static void * __CFAllocatorNullCalloc(malloc_zone_t *zone, size_t num_items, size_t size) {
+    return NULL;
+}
+
+static void * __CFAllocatorNullValloc(malloc_zone_t *zone, size_t size) {
+    return NULL;
+}
+
+static void __CFAllocatorNullFree(malloc_zone_t *zone, void *ptr) {
+}
+
+static void * __CFAllocatorNullRealloc(malloc_zone_t *zone, void *ptr, size_t size) {
+    return NULL;
+}
+
+static void __CFAllocatorNullDestroy(malloc_zone_t *zone) {
+}
+
+static size_t __CFAllocatorNullGoodSize(malloc_zone_t *zone, size_t size) {
+    return size;
+}
+
+static struct malloc_introspection_t __CFAllocatorNullZoneIntrospect = {
+    (mit_EnumType)__CFAllocatorZoneIntrospectNoOp,
+    (mit_GoodSize)__CFAllocatorNullGoodSize,
+    (mit_Check)__CFAllocatorZoneIntrospectTrue,
+    (mit_Print)__CFAllocatorZoneIntrospectNoOp,
+    (mit_Log)__CFAllocatorZoneIntrospectNoOp,
+    (mit_ZoneAction)__CFAllocatorZoneIntrospectNoOp,
+    (mit_ZoneAction)__CFAllocatorZoneIntrospectNoOp,
+    (mit_Statistics)__CFAllocatorZoneIntrospectNoOp
+};
+
+static void *__CFAllocatorSystemAllocate(CFIndex size, CFOptionFlags hint, void *info) {
+    return malloc_zone_malloc((malloc_zone_t*)info, size);
+}
+
+static void *__CFAllocatorSystemReallocate(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info) {
+    return malloc_zone_realloc((malloc_zone_t*)info, ptr, newsize);
+}
+
+static void __CFAllocatorSystemDeallocate(void *ptr, void *info) {
+#if defined(DEBUG)
+    size_t size = malloc_size(ptr);
+    if (size) memset(ptr, 0xCC, size);
+#endif
+    malloc_zone_free((malloc_zone_t*)info, ptr);
+}
+
+#endif /* DEPLOYMENT_TARGET_MACOSX */
+
+#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+static void *__CFAllocatorSystemAllocate(CFIndex size, CFOptionFlags hint, void *info) {
+    return malloc(size);
+}
+
+static void *__CFAllocatorSystemReallocate(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info) {
+    return realloc(ptr, newsize);
+}
+
+static void __CFAllocatorSystemDeallocate(void *ptr, void *info) {
+#if defined(DEBUG)
+    const enum mcheck_status status = mprobe(ptr);
+
+    CFAssert3(status == MCHECK_OK || status == MCHECK_DISABLED,
+              __kCFLogAssertion, "%s: ptr %p status %d",
+              __PRETTY_FUNCTION__, ptr, status);
+#endif
+
+    free(ptr);
+}
+#endif
+
+static void *__CFAllocatorNullAllocate(CFIndex size, CFOptionFlags hint, void *info) {
+    return NULL;
+}
+
+static void *__CFAllocatorNullReallocate(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info) {
+    return NULL;
+}
+
+#if defined (__cplusplus)
+static void * __CFAllocatorCPPMalloc(CFIndex allocSize, CFOptionFlags hint, void *info)
+{
+	return malloc(allocSize);	
+}
+static void * __CFAllocatorCPPReAlloc(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info)
+{
+	return realloc(ptr, newsize);
+}
+static void __CFAllocatorCPPFree(void *ptr, void *info)
+{
+	free(ptr);
+}
+#endif // C++
+
+
+static struct __CFAllocator __kCFAllocatorMalloc = {
+    INIT_CFRUNTIME_BASE(),
+#if DEPLOYMENT_TARGET_MACOSX
+    __CFAllocatorCustomSize,
+    __CFAllocatorCustomMalloc,
+    __CFAllocatorCustomCalloc,
+    __CFAllocatorCustomValloc,
+    __CFAllocatorCustomFree,
+    __CFAllocatorCustomRealloc,
+    __CFAllocatorNullDestroy,
+    "kCFAllocatorMalloc",
+    NULL,
+    NULL,
+    &__CFAllocatorZoneIntrospect,
+    NULL,
+#endif
+    NULL,	// _allocator
+    // Using the malloc functions directly is a total cheat, but works (in C)
+    // because the function signatures match in their common prefix of arguments.
+    // This saves us one hop through an adaptor function.
+#if !defined (__cplusplus)
+	{0, NULL, NULL, NULL, NULL, (void *)malloc, (void *)realloc, (void *)free, NULL}
+#else
+	{0, NULL, NULL, NULL, NULL, __CFAllocatorCPPMalloc,__CFAllocatorCPPReAlloc, __CFAllocatorCPPFree, NULL}
+#endif // __cplusplus
+};
+
+static struct __CFAllocator __kCFAllocatorMallocZone = {
+    INIT_CFRUNTIME_BASE(),
+#if DEPLOYMENT_TARGET_MACOSX
+    __CFAllocatorCustomSize,
+    __CFAllocatorCustomMalloc,
+    __CFAllocatorCustomCalloc,
+    __CFAllocatorCustomValloc,
+    __CFAllocatorCustomFree,
+    __CFAllocatorCustomRealloc,
+    __CFAllocatorNullDestroy,
+    "kCFAllocatorMallocZone",
+    NULL,
+    NULL,
+    &__CFAllocatorZoneIntrospect,
+    NULL,
+#endif
+    NULL,	// _allocator
+    {0, NULL, NULL, NULL, NULL, __CFAllocatorSystemAllocate, __CFAllocatorSystemReallocate, __CFAllocatorSystemDeallocate, NULL}
+};
+
+static struct __CFAllocator __kCFAllocatorSystemDefault = {
+    INIT_CFRUNTIME_BASE(),
+#if DEPLOYMENT_TARGET_MACOSX
+    __CFAllocatorCustomSize,
+    __CFAllocatorCustomMalloc,
+    __CFAllocatorCustomCalloc,
+    __CFAllocatorCustomValloc,
+    __CFAllocatorCustomFree,
+    __CFAllocatorCustomRealloc,
+    __CFAllocatorNullDestroy,
+    "kCFAllocatorSystemDefault",
+    NULL,
+    NULL,
+    &__CFAllocatorZoneIntrospect,
+    NULL,
+#endif
+    NULL,	// _allocator
+    {0, NULL, NULL, NULL, NULL, __CFAllocatorSystemAllocate, __CFAllocatorSystemReallocate, __CFAllocatorSystemDeallocate, NULL}
+};
+
+static struct __CFAllocator __kCFAllocatorNull = {
+    INIT_CFRUNTIME_BASE(),
+#if DEPLOYMENT_TARGET_MACOSX
+    __CFAllocatorNullSize,
+    __CFAllocatorNullMalloc,
+    __CFAllocatorNullCalloc,
+    __CFAllocatorNullValloc,
+    __CFAllocatorNullFree,
+    __CFAllocatorNullRealloc,
+    __CFAllocatorNullDestroy,
+    "kCFAllocatorNull",
+    NULL,
+    NULL,
+    &__CFAllocatorNullZoneIntrospect,
+    NULL,
+#endif
+    NULL,	// _allocator
+    {0, NULL, NULL, NULL, NULL, __CFAllocatorNullAllocate, __CFAllocatorNullReallocate, NULL, NULL}
+};
+
+const CFAllocatorRef kCFAllocatorDefault = NULL;
+const CFAllocatorRef kCFAllocatorSystemDefault = &__kCFAllocatorSystemDefault;
+const CFAllocatorRef kCFAllocatorMalloc = &__kCFAllocatorMalloc;
+const CFAllocatorRef kCFAllocatorMallocZone = &__kCFAllocatorMallocZone;
+const CFAllocatorRef kCFAllocatorNull = &__kCFAllocatorNull;
+const CFAllocatorRef kCFAllocatorUseContext = (CFAllocatorRef)0x0257;
+
+static CFStringRef __CFAllocatorCopyDescription(CFTypeRef cf) {
+    CFAllocatorRef self = (CFAllocatorRef)cf;
+    CFAllocatorRef allocator = (kCFAllocatorUseContext == self->_allocator) ? self : self->_allocator;
+    return CFStringCreateWithFormat(allocator, NULL, CFSTR("<CFAllocator %p [%p]>{info = %p}"), cf, allocator, self->_context.info);
+// CF: should use copyDescription function here to describe info field
+// remember to release value returned from copydescr function when this happens
+}
+
+__private_extern__ CFAllocatorRef __CFAllocatorGetAllocator(CFTypeRef cf) {
+    CFAllocatorRef allocator = (CFAllocatorRef)cf;
+    return (kCFAllocatorUseContext == allocator->_allocator) ? allocator : allocator->_allocator;
+}
+
+__private_extern__ void __CFAllocatorDeallocate(CFTypeRef cf) {
+    CFAllocatorRef self = (CFAllocatorRef)cf;
+    CFAllocatorRef allocator = self->_allocator;
+    CFAllocatorReleaseCallBack releaseFunc = __CFAllocatorGetReleaseFunction(&self->_context);
+    if (kCFAllocatorUseContext == allocator) {
+	/* Rather a chicken and egg problem here, so we do things
+	   in the reverse order from what was done at create time. */
+	CFAllocatorDeallocateCallBack deallocateFunc = __CFAllocatorGetDeallocateFunction(&self->_context);
+	void *info = self->_context.info;
+	if (NULL != deallocateFunc) {
+	    INVOKE_CALLBACK2(deallocateFunc, (void *)self, info);
+	}
+	if (NULL != releaseFunc) {
+	    INVOKE_CALLBACK1(releaseFunc, info);
+	}
+    } else {
+	if (NULL != releaseFunc) {
+	    INVOKE_CALLBACK1(releaseFunc, self->_context.info);
+	}
+	_CFAllocatorDeallocateGC(allocator, (void *)self);
+    }
+}
+
+static CFTypeID __kCFAllocatorTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFAllocatorClass = {
+    0,
+    "CFAllocator",
+    NULL,	// init
+    NULL,	// copy
+    __CFAllocatorDeallocate,
+    NULL,	// equal
+    NULL,	// hash
+    NULL,	// 
+    __CFAllocatorCopyDescription
+};
+
+__private_extern__ void __CFAllocatorInitialize(void) {
+    __kCFAllocatorTypeID = _CFRuntimeRegisterClass(&__CFAllocatorClass);
+
+    _CFRuntimeSetInstanceTypeID(&__kCFAllocatorSystemDefault, __kCFAllocatorTypeID);
+    __kCFAllocatorSystemDefault._base._cfisa = __CFISAForTypeID(__kCFAllocatorTypeID);
+#if DEPLOYMENT_TARGET_MACOSX
+    __kCFAllocatorSystemDefault._context.info = (CF_USING_COLLECTABLE_MEMORY ? __CFCollectableZone : malloc_default_zone());
+    memset(malloc_default_zone(), 0, 2 * sizeof(void *));
+#endif
+    __kCFAllocatorSystemDefault._allocator = kCFAllocatorSystemDefault;
+#ifdef DEPLOYMENT_TARGET_WINDOWS
+    __kCFAllocatorSystemDefault._context.allocate = __CFAllocatorSystemAllocate;
+    __kCFAllocatorSystemDefault._context.reallocate = __CFAllocatorSystemReallocate;
+    __kCFAllocatorSystemDefault._context.deallocate = __CFAllocatorSystemDeallocate;
+#endif // DEPLOYMENT_TARGET_WINDOWS
+   
+    _CFRuntimeSetInstanceTypeID(&__kCFAllocatorMalloc, __kCFAllocatorTypeID);
+    __kCFAllocatorMalloc._base._cfisa = __CFISAForTypeID(__kCFAllocatorTypeID);
+    __kCFAllocatorMalloc._allocator = kCFAllocatorSystemDefault;
+
+#if DEPLOYMENT_TARGET_MACOSX
+	_CFRuntimeSetInstanceTypeID(&__kCFAllocatorMallocZone, __kCFAllocatorTypeID);
+    __kCFAllocatorMallocZone._base._cfisa = __CFISAForTypeID(__kCFAllocatorTypeID);
+    __kCFAllocatorMallocZone._allocator = kCFAllocatorSystemDefault;
+    __kCFAllocatorMallocZone._context.info = malloc_default_zone();
+#endif //__MACH__
+
+    _CFRuntimeSetInstanceTypeID(&__kCFAllocatorNull, __kCFAllocatorTypeID);
+    __kCFAllocatorNull._base._cfisa = __CFISAForTypeID(__kCFAllocatorTypeID);
+    __kCFAllocatorNull._allocator = kCFAllocatorSystemDefault;
+
+}
+
+CFTypeID CFAllocatorGetTypeID(void) {
+    return __kCFAllocatorTypeID;
+}
+
+CFAllocatorRef CFAllocatorGetDefault(void) {
+    CFAllocatorRef allocator = (CFAllocatorRef)__CFGetThreadSpecificData_inline()->_allocator;
+    if (NULL == allocator) {
+	allocator = kCFAllocatorSystemDefault;
+    }
+    return allocator;
+}
+
+void CFAllocatorSetDefault(CFAllocatorRef allocator) {
+    CFAllocatorRef current = (CFAllocatorRef)__CFGetThreadSpecificData_inline()->_allocator;
+#if defined(DEBUG) 
+    if (NULL != allocator) {
+	__CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+    }
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+    if (allocator && allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+	return;		// require allocator to this function to be an allocator
+    }
+#endif
+    if (NULL != allocator && allocator != current) {
+	if (current) CFRelease(current);
+	CFRetain(allocator);
+	// We retain an extra time so that anything set as the default
+	// allocator never goes away.
+	CFRetain(allocator);
+	__CFGetThreadSpecificData_inline()->_allocator = (void *)allocator;
+    }
+}
+
+static CFAllocatorRef __CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContext *context) {
+    struct __CFAllocator *memory = NULL;
+    CFAllocatorRetainCallBack retainFunc;
+    CFAllocatorAllocateCallBack allocateFunc;
+    void *retainedInfo;
+#if DEPLOYMENT_TARGET_MACOSX
+    if (allocator && kCFAllocatorUseContext != allocator && allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+	return NULL;	// require allocator to this function to be an allocator
+    }
+#endif
+    retainFunc = context->retain;
+    FAULT_CALLBACK((void **)&retainFunc);
+    allocateFunc = context->allocate;
+    FAULT_CALLBACK((void **)&allocateFunc);
+    if (NULL != retainFunc) {
+	retainedInfo = (void *)INVOKE_CALLBACK1(retainFunc, context->info);
+    } else {
+	retainedInfo = context->info;
+    }
+    // We don't use _CFRuntimeCreateInstance()
+    if (kCFAllocatorUseContext == allocator) {
+	memory = NULL;
+	if (allocateFunc) {
+		memory = (struct __CFAllocator *)INVOKE_CALLBACK3(allocateFunc, sizeof(struct __CFAllocator), 0, retainedInfo);
+	}
+	if (NULL == memory) {
+	    return NULL;
+	}
+    } else {
+	allocator = (NULL == allocator) ? __CFGetDefaultAllocator() : allocator;
+	memory = (struct __CFAllocator *)CFAllocatorAllocate(allocator, sizeof(struct __CFAllocator), __kCFAllocatorGCObjectMemory);
+	if (__CFOASafe) __CFSetLastAllocationEventName(memory, "CFAllocator");
+	if (NULL == memory) {
+	    return NULL;
+	}
+    }
+    memory->_base._cfisa = 0;
+#if __LP64__
+    memory->_base._rc = 1;
+#else
+    memory->_base._cfinfo[CF_RC_BITS] = 1;
+#endif
+    memory->_base._cfinfo[CF_INFO_BITS] = 0;
+    _CFRuntimeSetInstanceTypeID(memory, __kCFAllocatorTypeID);
+    memory->_base._cfisa = __CFISAForTypeID(__kCFAllocatorTypeID);
+#if DEPLOYMENT_TARGET_MACOSX
+    memory->size = __CFAllocatorCustomSize;
+    memory->malloc = __CFAllocatorCustomMalloc;
+    memory->calloc = __CFAllocatorCustomCalloc;
+    memory->valloc = __CFAllocatorCustomValloc;
+    memory->free = __CFAllocatorCustomFree;
+    memory->realloc = __CFAllocatorCustomRealloc;
+    memory->destroy = __CFAllocatorCustomDestroy;
+    memory->zone_name = "Custom CFAllocator";
+    memory->batch_malloc = NULL;
+    memory->batch_free = NULL;
+    memory->introspect = &__CFAllocatorZoneIntrospect;
+    memory->reserved5 = NULL;
+#endif
+    memory->_allocator = allocator;
+    memory->_context.version = context->version;
+    memory->_context.info = retainedInfo;
+    memory->_context.retain = retainFunc;
+    memory->_context.release = context->release;
+    FAULT_CALLBACK((void **)&(memory->_context.release));
+    memory->_context.copyDescription = context->copyDescription;
+    FAULT_CALLBACK((void **)&(memory->_context.copyDescription));
+    memory->_context.allocate = allocateFunc;
+    memory->_context.reallocate = context->reallocate;
+    FAULT_CALLBACK((void **)&(memory->_context.reallocate));
+    memory->_context.deallocate = context->deallocate;
+    FAULT_CALLBACK((void **)&(memory->_context.deallocate));
+    memory->_context.preferredSize = context->preferredSize;
+    FAULT_CALLBACK((void **)&(memory->_context.preferredSize));
+
+    return memory;
+}
+
+CFAllocatorRef CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContext *context) {
+    CFAssert1(!CF_USING_COLLECTABLE_MEMORY, __kCFLogAssertion, "%s(): Shouldn't be called when GC is enabled!", __PRETTY_FUNCTION__);
+#if defined(DEBUG)
+    if (CF_USING_COLLECTABLE_MEMORY)
+        HALT;
+#endif
+    return __CFAllocatorCreate(allocator, context);
+}
+
+CFAllocatorRef _CFAllocatorCreateGC(CFAllocatorRef allocator, CFAllocatorContext *context) {
+    return __CFAllocatorCreate(allocator, context);
+}
+
+void *CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) {
+    CFAllocatorAllocateCallBack allocateFunc;
+    void *newptr = NULL;
+    allocator = (NULL == allocator) ? __CFGetDefaultAllocator() : allocator;
+#if (DEPLOYMENT_TARGET_MACOSX) && defined(DEBUG)
+    if (allocator->_base._cfisa == __CFISAForTypeID(__kCFAllocatorTypeID)) {
+	__CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+    }
+#else
+    __CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+#endif
+    if (0 == size) return NULL;
+#if DEPLOYMENT_TARGET_MACOSX
+    if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+	return malloc_zone_malloc((malloc_zone_t *)allocator, size);
+    }
+#endif
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+	newptr = auto_zone_allocate_object((auto_zone_t*)allocator->_context.info, size, CF_GET_GC_MEMORY_TYPE(hint), true, false);
+    } else {
+	newptr = NULL;
+	allocateFunc = __CFAllocatorGetAllocateFunction(&allocator->_context);
+	if (allocateFunc) {
+		newptr = (void *)INVOKE_CALLBACK3(allocateFunc, size, hint, allocator->_context.info);
+	}
+    }
+    return newptr;
+}
+
+void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint) {
+    CFAllocatorAllocateCallBack allocateFunc;
+    CFAllocatorReallocateCallBack reallocateFunc;
+    CFAllocatorDeallocateCallBack deallocateFunc;
+    void *newptr;
+    allocator = (NULL == allocator) ? __CFGetDefaultAllocator() : allocator;
+#if (DEPLOYMENT_TARGET_MACOSX) && defined(DEBUG)
+    if (allocator->_base._cfisa == __CFISAForTypeID(__kCFAllocatorTypeID)) {
+	__CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+    }
+#else
+    __CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+#endif
+    if (NULL == ptr && 0 < newsize) {
+#if DEPLOYMENT_TARGET_MACOSX
+	if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+	    return malloc_zone_malloc((malloc_zone_t *)allocator, newsize);
+	}
+#endif
+	newptr = NULL;
+	allocateFunc = __CFAllocatorGetAllocateFunction(&allocator->_context);
+	if (allocateFunc) {
+		newptr = (void *)INVOKE_CALLBACK3(allocateFunc, newsize, hint, allocator->_context.info);
+	}
+	return newptr;
+    }
+    if (NULL != ptr && 0 == newsize) {
+#if DEPLOYMENT_TARGET_MACOSX
+	if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+#if defined(DEBUG)
+	    size_t size = malloc_size(ptr);
+	    if (size) memset(ptr, 0xCC, size);
+#endif
+	    malloc_zone_free((malloc_zone_t *)allocator, ptr);
+	    return NULL;
+	}
+#endif /* DEPLOYMENT_TARGET_MACOSX */
+	deallocateFunc = __CFAllocatorGetDeallocateFunction(&allocator->_context);
+	if (NULL != deallocateFunc) {
+	    INVOKE_CALLBACK2(deallocateFunc, ptr, allocator->_context.info);
+	}
+	return NULL;
+    }
+    if (NULL == ptr && 0 == newsize) return NULL;
+#if DEPLOYMENT_TARGET_MACOSX
+    if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+	return malloc_zone_realloc((malloc_zone_t *)allocator, ptr, newsize);
+    }
+#endif
+    reallocateFunc = __CFAllocatorGetReallocateFunction(&allocator->_context);
+    if (NULL == reallocateFunc) return NULL;
+    newptr = (void *)INVOKE_CALLBACK4(reallocateFunc, ptr, newsize, hint, allocator->_context.info);
+    return newptr;
+}
+
+void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr) {
+    CFAllocatorDeallocateCallBack deallocateFunc;
+    allocator = (NULL == allocator) ? __CFGetDefaultAllocator() : allocator;
+#if (DEPLOYMENT_TARGET_MACOSX) && defined(DEBUG)
+    if (allocator->_base._cfisa == __CFISAForTypeID(__kCFAllocatorTypeID)) {
+	__CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+    }
+#else
+    __CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+    if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+#if defined(DEBUG)
+	size_t size = malloc_size(ptr);
+	if (size) memset(ptr, 0xCC, size);
+#endif
+	return malloc_zone_free((malloc_zone_t *)allocator, ptr);
+    }
+#endif /* DEPLOYMENT_TARGET_MACOSX */
+    deallocateFunc = __CFAllocatorGetDeallocateFunction(&allocator->_context);
+    if (NULL != ptr && NULL != deallocateFunc) {
+	INVOKE_CALLBACK2(deallocateFunc, ptr, allocator->_context.info);
+    }
+}
+
+CFIndex CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) {
+    CFAllocatorPreferredSizeCallBack prefFunc;
+    CFIndex newsize = 0;
+    allocator = (NULL == allocator) ? __CFGetDefaultAllocator() : allocator;
+#if (DEPLOYMENT_TARGET_MACOSX) && defined(DEBUG)
+    if (allocator->_base._cfisa == __CFISAForTypeID(__kCFAllocatorTypeID)) {
+	__CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+    }
+#else
+    __CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+    if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+	return malloc_good_size(size);
+    }
+#endif
+    prefFunc = __CFAllocatorGetPreferredSizeFunction(&allocator->_context);
+    if (0 < size && NULL != prefFunc) {
+	newsize = (CFIndex)(INVOKE_CALLBACK3(prefFunc, size, hint, allocator->_context.info));
+    }
+    if (newsize < size) newsize = size;
+    return newsize;
+}
+
+void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context) {
+    allocator = (NULL == allocator) ? __CFGetDefaultAllocator() : allocator;
+#if (DEPLOYMENT_TARGET_MACOSX) && defined(DEBUG)
+    if (allocator->_base._cfisa == __CFISAForTypeID(__kCFAllocatorTypeID)) {
+	__CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+    }
+#else
+    __CFGenericValidateType(allocator, __kCFAllocatorTypeID);
+#endif
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+#if DEPLOYMENT_TARGET_MACOSX
+    if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) {	// malloc_zone_t *
+	return;
+    }
+#endif
+    context->version = 0;
+    context->info = allocator->_context.info;
+    context->retain = __CFAllocatorGetRetainFunction(&allocator->_context);
+    context->release = __CFAllocatorGetReleaseFunction(&allocator->_context);
+    context->copyDescription = __CFAllocatorGetCopyDescriptionFunction(&allocator->_context);
+    context->allocate = __CFAllocatorGetAllocateFunction(&allocator->_context);
+    context->reallocate = __CFAllocatorGetReallocateFunction(&allocator->_context);
+    context->deallocate = __CFAllocatorGetDeallocateFunction(&allocator->_context);
+    context->preferredSize = __CFAllocatorGetPreferredSizeFunction(&allocator->_context);
+#if (DEPLOYMENT_TARGET_MACOSX) && defined(__ppc__)
+    context->retain = (void *)((uintptr_t)context->retain & ~0x3);
+    context->release = (void *)((uintptr_t)context->release & ~0x3);
+    context->copyDescription = (void *)((uintptr_t)context->copyDescription & ~0x3);
+    context->allocate = (void *)((uintptr_t)context->allocate & ~0x3);
+    context->reallocate = (void *)((uintptr_t)context->reallocate & ~0x3);
+    context->deallocate = (void *)((uintptr_t)context->deallocate & ~0x3);
+    context->preferredSize = (void *)((uintptr_t)context->preferredSize & ~0x3);
+#endif
+}
+
+void *_CFAllocatorAllocateGC(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint)
+{
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator))
+        return auto_zone_allocate_object((auto_zone_t*)kCFAllocatorSystemDefault->_context.info, size, CF_GET_GC_MEMORY_TYPE(hint), false, false);
+    else
+        return CFAllocatorAllocate(allocator, size, hint);
+}
+
+void *_CFAllocatorReallocateGC(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint)
+{
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+	if (ptr && (newsize == 0)) {
+	    return NULL; // equivalent to _CFAllocatorDeallocateGC.
+	}
+	if (ptr == NULL) {
+	    return auto_zone_allocate_object((auto_zone_t*)kCFAllocatorSystemDefault->_context.info, newsize, CF_GET_GC_MEMORY_TYPE(hint), false, false); // eq. to _CFAllocator
+	}
+    }
+    // otherwise, auto_realloc() now preserves layout type and refCount.
+    return CFAllocatorReallocate(allocator, ptr, newsize, hint);
+}
+
+void _CFAllocatorDeallocateGC(CFAllocatorRef allocator, void *ptr)
+{
+    // when running GC, don't deallocate.
+    if (!CF_IS_COLLECTABLE_ALLOCATOR(allocator)) CFAllocatorDeallocate(allocator, ptr);
+}
+
+// -------- -------- -------- -------- -------- -------- -------- --------
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+__private_extern__ pthread_key_t __CFTSDKey = (pthread_key_t)NULL;
+#elif DEPLOYMENT_TARGET_WINDOWS
+__private_extern__ DWORD __CFTSDKey = 0xFFFFFFFF;
+#endif
+
+extern void _CFRunLoop1(void);
+
+// Called for each thread as it exits
+__private_extern__ void __CFFinalizeThreadData(void *arg) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    __CFThreadSpecificData *tsd = (__CFThreadSpecificData *)arg;
+#elif DEPLOYMENT_TARGET_WINDOWS
+    __CFThreadSpecificData *tsd = (__CFThreadSpecificData*)TlsGetValue(__CFTSDKey);
+    TlsSetValue(__CFTSDKey, NULL);
+#endif
+    if (NULL == tsd) return; 
+    if (tsd->_allocator) CFRelease(tsd->_allocator);
+#if DEPLOYMENT_TARGET_MACOSX
+    _CFRunLoop1();
+#endif
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+
+    if (tsd->_messageHook) UnhookWindowsHookEx(tsd->_messageHook);
+
+#endif
+
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, tsd);
+}
+
+__private_extern__ __CFThreadSpecificData *__CFGetThreadSpecificData(void) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    __CFThreadSpecificData *data;
+    data = (__CFThreadSpecificData*)pthread_getspecific(__CFTSDKey);
+    if (data) {
+        return data;
+    }
+    data =(__CFThreadSpecificData*)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(__CFThreadSpecificData), 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(data, "CFUtilities (thread-data)");
+    memset(data, 0, sizeof(__CFThreadSpecificData));
+    pthread_setspecific(__CFTSDKey, data);
+    return data;
+#elif DEPLOYMENT_TARGET_WINDOWS
+    __CFThreadSpecificData *data;
+    data = (__CFThreadSpecificData *)TlsGetValue(__CFTSDKey);
+    if (data) {
+        return data;
+    }
+    data = (__CFThreadSpecificData *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(__CFThreadSpecificData), 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(data, "CFUtilities (thread-data)");
+    memset(data, 0, sizeof(__CFThreadSpecificData));
+    TlsSetValue(__CFTSDKey, data);
+    return data;
+#endif
+}
+
+__private_extern__ void __CFBaseInitialize(void) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    pthread_key_create(&__CFTSDKey, __CFFinalizeThreadData);
+#elif DEPLOYMENT_TARGET_WINDOWS || 0
+    __CFTSDKey = TlsAlloc();
+#endif
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+__private_extern__ void __CFBaseCleanup(void) {
+    TlsFree(__CFTSDKey);
+}
+#endif
+
+
+static CFBadErrorCallBack __CFOutOfMemoryCallBack = NULL;
+
+CFBadErrorCallBack _CFGetOutOfMemoryErrorCallBack(void) {
+    return __CFOutOfMemoryCallBack;
+}
+
+void _CFSetOutOfMemoryErrorCallBack(CFBadErrorCallBack callBack) {
+    __CFOutOfMemoryCallBack = callBack;
+}
+
+
+CFRange __CFRangeMake(CFIndex loc, CFIndex len) {
+    CFRange range;
+    range.location = loc;
+    range.length = len;
+    return range;
+}
+
+
+struct __CFNull {
+    CFRuntimeBase _base;
+};
+
+static struct __CFNull __kCFNull = {
+    INIT_CFRUNTIME_BASE()
+};
+const CFNullRef kCFNull = &__kCFNull;
+
+static CFStringRef __CFNullCopyDescription(CFTypeRef cf) {
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFNull %p [%p]>"), cf, CFGetAllocator(cf));
+}
+
+static CFStringRef __CFNullCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    return (CFStringRef)CFRetain(CFSTR("null"));
+}
+
+static void __CFNullDeallocate(CFTypeRef cf) {
+    CFAssert(false, __kCFLogAssertion, "Deallocated CFNull!");
+}
+
+static CFTypeID __kCFNullTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFNullClass = {
+    0,
+    "CFNull",
+    NULL,      // init
+    NULL,      // copy
+    __CFNullDeallocate,
+    NULL,
+    NULL,
+    __CFNullCopyFormattingDescription,
+    __CFNullCopyDescription
+};
+
+__private_extern__ void __CFNullInitialize(void) {
+    __kCFNullTypeID = _CFRuntimeRegisterClass(&__CFNullClass);
+    _CFRuntimeSetInstanceTypeID(&__kCFNull, __kCFNullTypeID);
+    __kCFNull._base._cfisa = __CFISAForTypeID(__kCFNullTypeID);
+}
+
+CFTypeID CFNullGetTypeID(void) {
+    return __kCFNullTypeID;
+}
+
+void CFCollection_non_gc_storage_error(void) { }
+
+
+static int hasCFM = 0;
+
+void _CFRuntimeSetCFMPresent(void *addr) {
+    hasCFM = 1;
+}
+
+#if (DEPLOYMENT_TARGET_MACOSX) && defined(__ppc__)
+
+/* See comments below */
+__private_extern__ void __CF_FAULT_CALLBACK(void **ptr) {
+    uintptr_t p = (uintptr_t)*ptr;
+    if ((0 == p) || (p & 0x1)) return;
+    if (0 == hasCFM || (0x90000000 <= p && p < 0xA0000000)) {
+	*ptr = (void *)(p | 0x1);
+    } else {
+	static CFMutableDictionaryRef cache = NULL;
+	static CFSpinLock_t lock = CFSpinLockInit;
+	uintptr_t known = ~0;
+	__CFSpinLock(&lock);
+	if (!cache || !CFDictionaryGetValueIfPresent(cache, (const void *)p, (const void **)&known)) {
+	    if (!cache) {
+		cache = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);
+	    }
+	    Dl_info info;
+	    known = dladdr((void *)p, &info);
+	    CFDictionarySetValue(cache, (const void *)p, (const void *)known);
+	}
+	__CFSpinUnlock(&lock);
+	*ptr = (void *)(p | (known ? 0x1 : 0x3));
+    }
+}
+
+/*
+Jump to callback function.  r2 is not saved and restored
+in the jump-to-CFM case, since we assume that dyld code
+never uses that register and that CF is dyld.
+
+There are three states for (ptr & 0x3):
+	0b00:	check not yet done (or not going to be done, and is a dyld func ptr)
+	0b01:	check done, dyld function pointer
+	0b11:	check done, CFM tvector pointer
+(but a NULL callback just stays NULL)
+
+There may be up to 5 word-sized arguments. Floating point
+arguments can be done, but count as two word arguments.
+Return value can be integral or real.
+*/
+
+/* Keep this assembly at the bottom of the source file! */
+
+__asm__ (
+".text\n"
+"        .align 2\n"
+".private_extern ___CF_INVOKE_CALLBACK\n"
+"___CF_INVOKE_CALLBACK:\n"
+	"rlwinm r12,r3,0,0,29\n"
+	"andi. r0,r3,0x2\n"
+	"or r3,r4,r4\n"
+	"or r4,r5,r5\n"
+	"or r5,r6,r6\n"
+	"or r6,r7,r7\n"
+	"or r7,r8,r8\n"
+	"beq- Lcall\n"
+	"lwz r2,0x4(r12)\n"
+	"lwz r12,0x0(r12)\n"
+"Lcall:  mtspr ctr,r12\n"
+	"bctr\n");
+
+#endif
+
+
+// void __HALT(void);
+
+#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
+__asm__ (
+".text\n"
+"	.align 2\n"
+#if DEPLOYMENT_TARGET_MACOSX
+".private_extern ___HALT\n"
+"___HALT:\n"
+#elif DEPLOYMENT_TARGET_LINUX
+".globl __HALT\n"
+"__HALT:\n"
+#else
+".globl ___HALT\n"
+"___HALT:\n"
+#endif
+"	trap\n"
+);
+#endif
+
+#if defined(__i386__) || defined(__x86_64__)
+#if defined(_MSC_VER)
+void __HALT() {
+    __asm int 3;
+}
+#else
+__asm__ (
+".text\n"
+"	.align 2, 0x90\n"
+#if DEPLOYMENT_TARGET_MACOSX
+".private_extern ___HALT\n"
+"___HALT:\n"
+#elif DEPLOYMENT_TARGET_LINUX
+".globl __HALT\n"
+"__HALT:\n"
+#else
+".globl ___HALT\n"
+"___HALT:\n"
+#endif
+"	int3\n"
+);
+#endif
+#endif
+
+#if defined(__arm__)
+__asm__ (
+".text\n"
+"	.align 2\n"
+#if DEPLOYMENT_TARGET_MACOSX
+".private_extern ___HALT\n"
+"___HALT:\n"
+#elif DEPLOYMENT_TARGET_LINUX
+".globl __HALT\n"
+"__HALT:\n"
+#else
+".globl ___HALT\n"
+"___HALT:\n"
+#endif
+"	bkpt\n"
+);
+#endif /* defined(__arm__) */
+
+#if defined(__aarch64__)
+__asm__ (
+".text\n"
+"	.align 2\n"
+#if DEPLOYMENT_TARGET_MACOSX
+".private_extern ___HALT\n"
+"___HALT:\n"
+#elif DEPLOYMENT_TARGET_LINUX
+".globl __HALT\n"
+"__HALT:\n"
+#else
+".globl ___HALT\n"
+"___HALT:\n"
+#endif
+"	brk #0000\n"
+);
+#endif /* defined(__aarch64__) */
diff --git a/CoreFoundation/CFBase.h b/CoreFoundation/CFBase.h
new file mode 100644
index 0000000..55fe89b
--- /dev/null
+++ b/CoreFoundation/CFBase.h
@@ -0,0 +1,469 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBASE__)
+#define __COREFOUNDATION_CFBASE__ 1
+
+#if (defined(__CYGWIN32__) || defined(_WIN32) || defined(WIN32)) && !defined (__WIN32__)
+#define __WIN32__ 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(__ARMEL__) && !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
+
+#if defined(__WIN32__)
+#include <windows.h>
+#include <winsock2.h>
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#if !(defined(__APPLE__) || defined(__GNUC__))
+#define weak_import
+#define __private_extern__
+#elif defined(__GNUC__)
+#define weak_import
+#define __private_extern__ __attribute__((visibility("hidden")))
+#endif
+
+#include <AvailabilityMacros.h>
+
+#if defined(__MACH__)
+    #include <libkern/OSTypes.h>
+#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 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;
+#endif
+#if !defined(__MACTYPES__) || (defined(UNIVERSAL_INTERFACES_VERSION) && UNIVERSAL_INTERFACES_VERSION < 0x0340)
+    typedef UInt32                  UTF32Char;
+    typedef UInt16                  UTF16Char;
+    typedef UInt8                   UTF8Char;
+#endif
+
+// Select correct deployment type
+#if defined(__APPLE__) && !defined(DEPLOYMENT_TARGET_MACOSX)
+#define DEPLOYMENT_TARGET_MACOSX 1
+#elif (defined (_WIN32) || defined(__WIN32__)) && defined(_MSC_VER) && !defined(DEPLOYMENT_TARGET_WINDOWS)
+#define DEPLOYMENT_TARGET_WINDOWS 1
+#elif (defined(linux) || defined(__linux) || defined (__linux__)) && !defined(DEPLOYMENT_TARGET_LINUX)
+#define DEPLOYMENT_TARGET_LINUX 1
+#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
+
+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(__WIN32__)
+    #undef CF_EXPORT
+    #if defined(CF_BUILDING_CF)
+        #define CF_EXPORT __declspec(dllexport) extern
+    #else
+        #define CF_EXPORT __declspec(dllimport) extern
+    #endif
+    #ifdef __GNUC__
+        #define WIN_STDCALL __attribute__((stdcall))
+    #else
+        #define WIN_STDCALL __stdcall
+    #endif
+#elif defined(macintosh)
+    #if defined(__MWERKS__)
+        #define CF_EXPORT __declspec(export) extern
+    #endif
+#endif
+
+#if !defined(CF_EXPORT)
+    #define CF_EXPORT extern
+#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(__MWERKS__) || defined(__cplusplus)
+        #define CF_INLINE static inline
+    #elif defined(_MSC_VER)
+        #define CF_INLINE static __inline
+    #elif defined(__WIN32__)
+        #define CF_INLINE static __inline__
+    #endif
+#endif
+
+
+CF_EXPORT double                kCFCoreFoundationVersionNumber;
+CF_EXPORT const unsigned char   kCFCoreFoundationVersionString[];
+
+#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
+
+typedef unsigned long CFTypeID;
+typedef unsigned long CFOptionFlags;
+typedef unsigned long CFHashCode;
+typedef signed long CFIndex;
+
+/* Base "type" of all "CF objects", and polymorphic functions on them */
+typedef const void * CFTypeRef;
+
+typedef const struct __CFString * CFStringRef;
+typedef struct __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 */
+enum {
+    kCFCompareLessThan = -1,
+    kCFCompareEqualTo = 0,
+    kCFCompareGreaterThan = 1
+};
+typedef CFIndex CFComparisonResult;
+
+/* 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);
+
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/* Null representant */
+
+typedef const struct __CFNull * CFNullRef;
+
+CF_EXPORT
+CFTypeID CFNullGetTypeID(void);
+
+CF_EXPORT
+const CFNullRef kCFNull;	// the singleton null instance
+
+#endif
+
+
+/* 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.
+
+   You should rarely use kCFAllocatorSystemDefault, the default default allocator.
+*/
+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 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+/* 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_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
+CFIndex CFGetRetainCount(CFTypeRef cf);
+
+CF_EXPORT
+CFTypeRef CFMakeCollectable(CFTypeRef cf) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+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_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFBASE__ */
+
diff --git a/CoreFoundation/CFBinaryHeap.c b/CoreFoundation/CFBinaryHeap.c
new file mode 100644
index 0000000..885428d
--- /dev/null
+++ b/CoreFoundation/CFBinaryHeap.c
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFBinaryHeap.h>
+#include "CFPriv.h"
+#include "CFInternal.h"
+
+const CFBinaryHeapCallBacks kCFStringBinaryHeapCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, (CFComparisonResult (*)(const void *, const void *, void *))CFStringCompare};
+
+struct __CFBinaryHeapBucket {
+    void *_item;
+};
+
+CF_INLINE CFIndex __CFBinaryHeapRoundUpCapacity(CFIndex capacity) {
+    if (capacity < 4) return 4;
+    return (1 << flsl(capacity));
+}
+
+CF_INLINE CFIndex __CFBinaryHeapNumBucketsForCapacity(CFIndex capacity) {
+    return capacity;
+}
+
+struct __CFBinaryHeap {
+    CFRuntimeBase _base;
+    CFIndex _count;	/* number of objects */
+    CFIndex _capacity;	/* maximum number of objects */
+    CFBinaryHeapCallBacks _callbacks;
+    CFBinaryHeapCompareContext _context;
+    struct __CFBinaryHeapBucket *_buckets;
+};
+
+CF_INLINE CFIndex __CFBinaryHeapCount(CFBinaryHeapRef heap) {
+    return heap->_count;
+}
+
+CF_INLINE void __CFBinaryHeapSetCount(CFBinaryHeapRef heap, CFIndex v) {
+    /* for a CFBinaryHeap, _bucketsUsed == _count */
+}
+
+CF_INLINE CFIndex __CFBinaryHeapCapacity(CFBinaryHeapRef heap) {
+    return heap->_capacity;
+}
+
+CF_INLINE void __CFBinaryHeapSetCapacity(CFBinaryHeapRef heap, CFIndex v) {
+    /* for a CFBinaryHeap, _bucketsNum == _capacity */
+}
+
+CF_INLINE CFIndex __CFBinaryHeapNumBucketsUsed(CFBinaryHeapRef heap) {
+    return heap->_count;
+}
+
+CF_INLINE void __CFBinaryHeapSetNumBucketsUsed(CFBinaryHeapRef heap, CFIndex v) {
+    heap->_count = v;
+}
+
+CF_INLINE CFIndex __CFBinaryHeapNumBuckets(CFBinaryHeapRef heap) {
+    return heap->_capacity;
+}
+
+CF_INLINE void __CFBinaryHeapSetNumBuckets(CFBinaryHeapRef heap, CFIndex v) {
+    heap->_capacity = v;
+}
+
+enum {      /* bits 1-0 */
+    kCFBinaryHeapMutable = 0x1,		/* changeable and variable capacity */
+};
+
+/* Bits 4-5 are used by GC */
+
+CF_INLINE bool isStrongMemory_Heap(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)collection)->_cfinfo[CF_INFO_BITS], 4, 4) == 0;
+}
+
+CF_INLINE bool isWeakMemory_Heap(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)collection)->_cfinfo[CF_INFO_BITS], 4, 4) != 0;
+}
+
+CF_INLINE UInt32 __CFBinaryHeapMutableVariety(const void *cf) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 2);
+}
+
+CF_INLINE void __CFBinaryHeapSetMutableVariety(void *cf, UInt32 v) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 2, v);
+}
+
+CF_INLINE UInt32 __CFBinaryHeapMutableVarietyFromFlags(UInt32 flags) {
+    return __CFBitfieldGetValue(flags, 1, 0);
+}
+
+static Boolean __CFBinaryHeapEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFBinaryHeapRef heap1 = (CFBinaryHeapRef)cf1;
+    CFBinaryHeapRef heap2 = (CFBinaryHeapRef)cf2;
+    CFComparisonResult (*compare)(const void *, const void *, void *);
+    CFIndex idx;
+    CFIndex cnt;
+    const void **list1, **list2, *buffer[256];
+    cnt = __CFBinaryHeapCount(heap1);
+    if (cnt != __CFBinaryHeapCount(heap2)) return false;
+    compare = heap1->_callbacks.compare;
+    if (compare != heap2->_callbacks.compare) return false;
+    if (0 == cnt) return true;	/* after function comparison */
+    list1 = (cnt <= 128) ? (const void **)buffer : (const void **)CFAllocatorAllocate(kCFAllocatorSystemDefault, 2 * cnt * sizeof(void *), 0); // GC OK
+    if (__CFOASafe && list1 != buffer) __CFSetLastAllocationEventName(list1, "CFBinaryHeap (temp)");
+    list2 = (cnt <= 128) ? buffer + 128 : list1 + cnt;
+    CFBinaryHeapGetValues(heap1, list1);
+    CFBinaryHeapGetValues(heap2, list2);
+    for (idx = 0; idx < cnt; idx++) {
+	const void *val1 = list1[idx];
+	const void *val2 = list2[idx];
+// CF: which context info should be passed in? both?
+// CF: if the context infos are not equal, should the heaps not be equal?
+        if (val1 != val2) { 
+            if (NULL == compare) return false;
+            if (!compare(val1, val2, heap1->_context.info)) return false;
+        }
+    }
+    if (list1 != buffer) CFAllocatorDeallocate(CFGetAllocator(heap1), list1); // GC OK
+    return true;
+}
+
+static CFHashCode __CFBinaryHeapHash(CFTypeRef cf) {
+    CFBinaryHeapRef heap = (CFBinaryHeapRef)cf;
+    return __CFBinaryHeapCount(heap);
+}
+
+static CFStringRef __CFBinaryHeapCopyDescription(CFTypeRef cf) {
+    CFBinaryHeapRef heap = (CFBinaryHeapRef)cf;
+    CFMutableStringRef result;
+    CFIndex idx;
+    CFIndex cnt;
+    const void **list, *buffer[256];
+    cnt = __CFBinaryHeapCount(heap);
+    result = CFStringCreateMutable(CFGetAllocator(heap), 0);
+    CFStringAppendFormat(result, NULL, CFSTR("<CFBinaryHeap %p [%p]>{count = %u, capacity = %u, objects = (\n"), cf, CFGetAllocator(heap), cnt, __CFBinaryHeapCapacity(heap));
+    list = (cnt <= 128) ? (const void **)buffer : (const void **)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(void *), 0); // GC OK
+    if (__CFOASafe && list != buffer) __CFSetLastAllocationEventName(list, "CFBinaryHeap (temp)");
+    CFBinaryHeapGetValues(heap, list);
+    for (idx = 0; idx < cnt; idx++) {
+	CFStringRef desc = NULL;
+	const void *item = list[idx];
+	if (NULL != heap->_callbacks.copyDescription) {
+	    desc = heap->_callbacks.copyDescription(item);
+	}
+	if (NULL != desc) {
+	    CFStringAppendFormat(result, NULL, CFSTR("\t%u : %s\n"), idx, desc);
+	    CFRelease(desc);
+	} else {
+	    CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p>\n"), idx, item);
+	}
+    }
+    CFStringAppend(result, CFSTR(")}"));
+    if (list != buffer) CFAllocatorDeallocate(CFGetAllocator(heap), list); // GC OK
+    return result;
+}
+
+static void __CFBinaryHeapDeallocate(CFTypeRef cf) {
+    CFBinaryHeapRef heap = (CFBinaryHeapRef)cf;
+    CFAllocatorRef allocator = CFGetAllocator(heap);
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+	if (heap->_callbacks.retain == NULL && heap->_callbacks.release == NULL)
+	    return; // GC: keep heap intact during finalization.
+    }
+// CF: should make the heap mutable here first, a la CFArrayDeallocate
+    CFBinaryHeapRemoveAllValues(heap);
+// CF: does not release the context info
+    if (__CFBinaryHeapMutableVariety(heap) == kCFBinaryHeapMutable) {
+	_CFAllocatorDeallocateGC(allocator, heap->_buckets);
+    }
+}
+
+static CFTypeID __kCFBinaryHeapTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFBinaryHeapClass = {
+    _kCFRuntimeScannedObject,
+    "CFBinaryHeap",
+    NULL,	// init
+    NULL,	// copy
+    __CFBinaryHeapDeallocate,
+    __CFBinaryHeapEqual,
+    __CFBinaryHeapHash,
+    NULL,	// 
+    __CFBinaryHeapCopyDescription
+};
+
+__private_extern__ void __CFBinaryHeapInitialize(void) {
+    __kCFBinaryHeapTypeID = _CFRuntimeRegisterClass(&__CFBinaryHeapClass);
+}
+
+CFTypeID CFBinaryHeapGetTypeID(void) {
+    return __kCFBinaryHeapTypeID;
+}
+
+static CFBinaryHeapRef __CFBinaryHeapInit(CFAllocatorRef allocator, UInt32 flags, CFIndex capacity, const void **values, CFIndex numValues, const CFBinaryHeapCallBacks *callBacks, const CFBinaryHeapCompareContext *compareContext) {
+    CFBinaryHeapRef memory;
+    CFIndex idx;
+    CFIndex size;
+
+    CFAssert2(0 <= capacity, __kCFLogAssertion, "%s(): capacity (%d) cannot be less than zero", __PRETTY_FUNCTION__, capacity);
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%d) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+    size = sizeof(struct __CFBinaryHeap) - sizeof(CFRuntimeBase);
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+	if (!callBacks || (callBacks->retain == NULL && callBacks->release == NULL)) {
+	    __CFBitfieldSetValue(flags, 4, 4, 1); // setWeak
+	}
+    }
+
+    memory = (CFBinaryHeapRef)_CFRuntimeCreateInstance(allocator, __kCFBinaryHeapTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+	__CFBinaryHeapSetCapacity(memory, __CFBinaryHeapRoundUpCapacity(1));
+	__CFBinaryHeapSetNumBuckets(memory, __CFBinaryHeapNumBucketsForCapacity(__CFBinaryHeapRoundUpCapacity(1)));
+	void *buckets = _CFAllocatorAllocateGC(allocator, __CFBinaryHeapNumBuckets(memory) * sizeof(struct __CFBinaryHeapBucket), isStrongMemory_Heap(memory) ? __kCFAllocatorGCScannedMemory : 0);
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, memory, memory->_buckets, buckets);
+	if (__CFOASafe) __CFSetLastAllocationEventName(memory->_buckets, "CFBinaryHeap (store)");
+	if (NULL == memory->_buckets) {
+	    CFRelease(memory);
+	    return NULL;
+	}
+    __CFBinaryHeapSetNumBucketsUsed(memory, 0);
+    __CFBinaryHeapSetCount(memory, 0);
+    if (NULL != callBacks) {
+	memory->_callbacks.retain = callBacks->retain;
+	memory->_callbacks.release = callBacks->release;
+	memory->_callbacks.copyDescription = callBacks->copyDescription;
+	memory->_callbacks.compare = callBacks->compare;
+    } else {
+	memory->_callbacks.retain = 0;
+	memory->_callbacks.release = 0;
+	memory->_callbacks.copyDescription = 0;
+	memory->_callbacks.compare = 0;
+    }
+    __CFBinaryHeapSetMutableVariety(memory, kCFBinaryHeapMutable);
+    for (idx = 0; idx < numValues; idx++) {
+	CFBinaryHeapAddValue(memory, values[idx]);
+    }
+    __CFBinaryHeapSetMutableVariety(memory, __CFBinaryHeapMutableVarietyFromFlags(flags));
+    if (compareContext) memcpy(&memory->_context, compareContext, sizeof(CFBinaryHeapCompareContext));
+    return memory;
+}
+
+CFBinaryHeapRef CFBinaryHeapCreate(CFAllocatorRef allocator, CFIndex capacity, const CFBinaryHeapCallBacks *callBacks, const CFBinaryHeapCompareContext *compareContext) {
+   return __CFBinaryHeapInit(allocator, kCFBinaryHeapMutable, capacity, NULL, 0, callBacks, compareContext);
+}
+
+CFBinaryHeapRef CFBinaryHeapCreateCopy(CFAllocatorRef allocator, CFIndex capacity, CFBinaryHeapRef heap) {
+   __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    return __CFBinaryHeapInit(allocator, kCFBinaryHeapMutable, capacity, (const void **)heap->_buckets, __CFBinaryHeapCount(heap), &(heap->_callbacks), &(heap->_context));
+}
+
+CFIndex CFBinaryHeapGetCount(CFBinaryHeapRef heap) {
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    return __CFBinaryHeapCount(heap);
+}
+
+CFIndex CFBinaryHeapGetCountOfValue(CFBinaryHeapRef heap, const void *value) {
+    CFComparisonResult (*compare)(const void *, const void *, void *);
+    CFIndex idx;
+    CFIndex cnt = 0, length;
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    compare = heap->_callbacks.compare;
+    length = __CFBinaryHeapCount(heap);
+    for (idx = 0; idx < length; idx++) {
+	const void *item = heap->_buckets[idx]._item;
+	if (value == item || (compare && kCFCompareEqualTo == compare(value, item, heap->_context.info))) {
+	    cnt++;
+	}
+    }
+    return cnt;
+}
+
+Boolean CFBinaryHeapContainsValue(CFBinaryHeapRef heap, const void *value) {
+    CFComparisonResult (*compare)(const void *, const void *, void *);
+    CFIndex idx;
+    CFIndex length;
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    compare = heap->_callbacks.compare;
+    length = __CFBinaryHeapCount(heap);
+    for (idx = 0; idx < length; idx++) {
+	const void *item = heap->_buckets[idx]._item;
+	if (value == item || (compare && kCFCompareEqualTo == compare(value, item, heap->_context.info))) {
+	    return true;
+	}
+    }
+    return false;
+}
+
+const void *CFBinaryHeapGetMinimum(CFBinaryHeapRef heap) {
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    CFAssert1(0 < __CFBinaryHeapCount(heap), __kCFLogAssertion, "%s(): binary heap is empty", __PRETTY_FUNCTION__);
+    return (0 < __CFBinaryHeapCount(heap)) ? heap->_buckets[0]._item : NULL;
+}
+
+Boolean CFBinaryHeapGetMinimumIfPresent(CFBinaryHeapRef heap, const void **value) {
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    if (0 == __CFBinaryHeapCount(heap)) return false;
+    if (NULL != value) __CFObjCStrongAssign(heap->_buckets[0]._item, value);
+    return true;
+}
+
+void CFBinaryHeapGetValues(CFBinaryHeapRef heap, const void **values) {
+    CFBinaryHeapRef heapCopy;
+    CFIndex idx;
+    CFIndex cnt;
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    CFAssert1(NULL != values, __kCFLogAssertion, "%s(): pointer to values may not be NULL", __PRETTY_FUNCTION__);
+    cnt = __CFBinaryHeapCount(heap);
+    if (0 == cnt) return;
+    if (CF_USING_COLLECTABLE_MEMORY) {
+	// GC: speculatively issue a write-barrier on the copied to buffers (3743553).
+	__CFObjCWriteBarrierRange(values, cnt * sizeof(void *));
+    }
+    heapCopy = CFBinaryHeapCreateCopy(CFGetAllocator(heap), cnt, heap);
+    idx = 0;
+    while (0 < __CFBinaryHeapCount(heapCopy)) {
+	const void *value = CFBinaryHeapGetMinimum(heapCopy);
+	CFBinaryHeapRemoveMinimumValue(heapCopy);
+	values[idx++] = value;
+    }
+    CFRelease(heapCopy);
+}
+
+void CFBinaryHeapApplyFunction(CFBinaryHeapRef heap, CFBinaryHeapApplierFunction applier, void *context) {
+    CFBinaryHeapRef heapCopy;
+    CFIndex cnt;
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    CFAssert1(NULL != applier, __kCFLogAssertion, "%s(): pointer to applier function may not be NULL", __PRETTY_FUNCTION__);
+    cnt = __CFBinaryHeapCount(heap);
+    if (0 == cnt) return;
+    heapCopy = CFBinaryHeapCreateCopy(CFGetAllocator(heap), cnt, heap);
+    while (0 < __CFBinaryHeapCount(heapCopy)) {
+	const void *value = CFBinaryHeapGetMinimum(heapCopy);
+	CFBinaryHeapRemoveMinimumValue(heapCopy);
+	applier(value, context);
+    }
+    CFRelease(heapCopy);
+}
+
+static void __CFBinaryHeapGrow(CFBinaryHeapRef heap, CFIndex numNewValues) {
+    CFIndex oldCount = __CFBinaryHeapCount(heap);
+    CFIndex capacity = __CFBinaryHeapRoundUpCapacity(oldCount + numNewValues);
+    CFAllocatorRef allocator = CFGetAllocator(heap);
+    __CFBinaryHeapSetCapacity(heap, capacity);
+    __CFBinaryHeapSetNumBuckets(heap, __CFBinaryHeapNumBucketsForCapacity(capacity));
+    void *buckets = _CFAllocatorReallocateGC(allocator, heap->_buckets, __CFBinaryHeapNumBuckets(heap) * sizeof(struct __CFBinaryHeapBucket), isStrongMemory_Heap(heap) ? __kCFAllocatorGCScannedMemory : 0);
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, heap, heap->_buckets, buckets);
+    if (__CFOASafe) __CFSetLastAllocationEventName(heap->_buckets, "CFBinaryHeap (store)");
+    if (NULL == heap->_buckets) HALT;
+}
+
+void CFBinaryHeapAddValue(CFBinaryHeapRef heap, const void *value) {
+    CFIndex idx, pidx;
+    CFIndex cnt;
+    CFAllocatorRef allocator = CFGetAllocator(heap);
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    switch (__CFBinaryHeapMutableVariety(heap)) {
+    case kCFBinaryHeapMutable:
+	if (__CFBinaryHeapNumBucketsUsed(heap) == __CFBinaryHeapCapacity(heap))
+	    __CFBinaryHeapGrow(heap, 1);
+	break;
+    }
+    cnt = __CFBinaryHeapCount(heap);
+    idx = cnt;
+    __CFBinaryHeapSetNumBucketsUsed(heap, cnt + 1);
+    __CFBinaryHeapSetCount(heap, cnt + 1);
+    pidx = (idx - 1) >> 1;
+    while (0 < idx) {
+	void *item = heap->_buckets[pidx]._item;
+	if (kCFCompareGreaterThan != heap->_callbacks.compare(item, value, heap->_context.info)) break;
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, heap->_buckets, heap->_buckets[idx]._item, item);
+	idx = pidx;
+	pidx = (idx - 1) >> 1;
+    }
+    if (heap->_callbacks.retain) {
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, heap->_buckets, heap->_buckets[idx]._item, (void *)heap->_callbacks.retain(allocator, (void *)value));
+    } else {
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, heap->_buckets, heap->_buckets[idx]._item, (void *)value);
+    }
+}
+
+void CFBinaryHeapRemoveMinimumValue(CFBinaryHeapRef heap) {
+    void *val;
+    CFIndex idx, cidx;
+    CFIndex cnt;
+    CFAllocatorRef allocator;
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    cnt = __CFBinaryHeapCount(heap);
+    if (0 == cnt) return;
+    idx = 0;
+    __CFBinaryHeapSetNumBucketsUsed(heap, cnt - 1);
+    __CFBinaryHeapSetCount(heap, cnt - 1);
+    allocator = CFGetAllocator(heap);
+    if (heap->_callbacks.release)
+	heap->_callbacks.release(allocator, heap->_buckets[idx]._item);
+    val = heap->_buckets[cnt - 1]._item;
+    cidx = (idx << 1) + 1;
+    while (cidx < __CFBinaryHeapCount(heap)) {
+	void *item = heap->_buckets[cidx]._item;
+	if (cidx + 1 < __CFBinaryHeapCount(heap)) {
+	    void *item2 = heap->_buckets[cidx + 1]._item;
+	    if (kCFCompareGreaterThan == heap->_callbacks.compare(item, item2, heap->_context.info)) {
+		cidx++;
+		item = item2;
+	    }
+	}
+	if (kCFCompareGreaterThan == heap->_callbacks.compare(item, val, heap->_context.info)) break;
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, heap->_buckets, heap->_buckets[idx]._item, item);
+	idx = cidx;
+	cidx = (idx << 1) + 1;
+    }
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, heap->_buckets, heap->_buckets[idx]._item, val);
+}
+
+void CFBinaryHeapRemoveAllValues(CFBinaryHeapRef heap) {
+    CFIndex idx;
+    CFIndex cnt;
+    __CFGenericValidateType(heap, __kCFBinaryHeapTypeID);
+    cnt = __CFBinaryHeapCount(heap);
+    if (heap->_callbacks.release)
+	for (idx = 0; idx < cnt; idx++)
+	    heap->_callbacks.release(CFGetAllocator(heap), heap->_buckets[idx]._item);
+    __CFBinaryHeapSetNumBucketsUsed(heap, 0);
+    __CFBinaryHeapSetCount(heap, 0);
+}
+
diff --git a/CoreFoundation/CFBinaryHeap.h b/CoreFoundation/CFBinaryHeap.h
new file mode 100644
index 0000000..09cf438
--- /dev/null
+++ b/CoreFoundation/CFBinaryHeap.h
@@ -0,0 +1,319 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+
+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
+
+#endif /* ! __COREFOUNDATION_CFBINARYHEAP__ */
+
diff --git a/CoreFoundation/CFBinaryPList.c b/CoreFoundation/CFBinaryPList.c
new file mode 100644
index 0000000..e284ecb
--- /dev/null
+++ b/CoreFoundation/CFBinaryPList.c
@@ -0,0 +1,1296 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Stuart Crook <stuart@echus.demon.co.uk>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFBinaryPList.c
+	Copyright 2000-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFSet.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFByteOrder.h>
+#include <CoreFoundation/CFRuntime.h>
+#include <CoreFoundation/CFStream.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <limits.h>
+#include <string.h>
+#include "CFInternal.h"
+
+typedef struct {
+    int64_t high;
+    uint64_t low;
+} CFSInt128Struct;
+
+enum {
+    kCFNumberSInt128Type = 17
+};
+
+extern CFNumberType _CFNumberGetType2(CFNumberRef number);
+
+enum {
+	CF_NO_ERROR = 0,
+	CF_OVERFLOW_ERROR = (1 << 0),
+};
+
+CF_INLINE uint32_t __check_uint32_add_unsigned_unsigned(uint32_t x, uint32_t y, int32_t* err) {
+   if((UINT_MAX - y) < x)
+        *err = *err | CF_OVERFLOW_ERROR;
+   return x + y;
+};
+
+CF_INLINE uint64_t __check_uint64_add_unsigned_unsigned(uint64_t x, uint64_t y, int32_t* err) {
+   if((ULLONG_MAX - y) < x)
+        *err = *err | CF_OVERFLOW_ERROR;
+   return x + y;
+};
+
+CF_INLINE uint32_t __check_uint32_mul_unsigned_unsigned(uint32_t x, uint32_t y, int32_t* err) {
+   uint64_t tmp = (uint64_t) x * (uint64_t) y;
+   /* If any of the upper 32 bits touched, overflow */
+   if(tmp & 0xffffffff00000000ULL)
+        *err = *err | CF_OVERFLOW_ERROR;
+   return (uint32_t) tmp;
+};
+
+CF_INLINE uint64_t __check_uint64_mul_unsigned_unsigned(uint64_t x, uint64_t y, int32_t* err) {
+  if(x == 0) return 0;
+  if(ULLONG_MAX/x < y)
+     *err = *err | CF_OVERFLOW_ERROR;
+  return x * y;
+};
+
+#if __LP64__
+#define check_ptr_add(p, a, err)	(const uint8_t *)__check_uint64_add_unsigned_unsigned((uintptr_t)p, (uintptr_t)a, err)
+#define check_size_t_mul(b, a, err)	(size_t)__check_uint64_mul_unsigned_unsigned((size_t)b, (size_t)a, err)
+#else
+#define check_ptr_add(p, a, err)	(const uint8_t *)__check_uint32_add_unsigned_unsigned((uintptr_t)p, (uintptr_t)a, err)
+#define check_size_t_mul(b, a, err)	(size_t)__check_uint32_mul_unsigned_unsigned((size_t)b, (size_t)a, err)
+#endif
+
+
+CF_INLINE CFTypeID __CFGenericTypeID_genericobj_inline(const void *cf) {
+    CFTypeID typeID = (*(uint32_t *)(((CFRuntimeBase *)cf)->_cfinfo) >> 8) & 0xFFFF;
+    return CF_IS_OBJC(typeID, cf) ? CFGetTypeID(cf) : typeID;
+}
+
+struct __CFKeyedArchiverUID {
+    CFRuntimeBase _base;
+    uint32_t _value;
+};
+
+static CFStringRef __CFKeyedArchiverUIDCopyDescription(CFTypeRef cf) {
+    CFKeyedArchiverUIDRef uid = (CFKeyedArchiverUIDRef)cf;
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFKeyedArchiverUID %p [%p]>{value = %u}"), cf, CFGetAllocator(cf), uid->_value);
+}
+
+static CFStringRef __CFKeyedArchiverUIDCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    CFKeyedArchiverUIDRef uid = (CFKeyedArchiverUIDRef)cf;
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("@%u@"), uid->_value);
+}
+
+static CFTypeID __kCFKeyedArchiverUIDTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFKeyedArchiverUIDClass = {
+    0,
+    "CFKeyedArchiverUID",
+    NULL,	// init
+    NULL,	// copy
+    NULL,	// finalize
+    NULL,	// equal -- pointer equality only
+    NULL,	// hash -- pointer hashing only
+    __CFKeyedArchiverUIDCopyFormattingDescription,
+    __CFKeyedArchiverUIDCopyDescription
+};
+
+__private_extern__ void __CFKeyedArchiverUIDInitialize(void) {
+    __kCFKeyedArchiverUIDTypeID = _CFRuntimeRegisterClass(&__CFKeyedArchiverUIDClass);
+}
+
+CFTypeID _CFKeyedArchiverUIDGetTypeID(void) {
+    return __kCFKeyedArchiverUIDTypeID;
+}
+
+CFKeyedArchiverUIDRef _CFKeyedArchiverUIDCreate(CFAllocatorRef allocator, uint32_t value) {
+    CFKeyedArchiverUIDRef uid;
+    uid = (CFKeyedArchiverUIDRef)_CFRuntimeCreateInstance(allocator, __kCFKeyedArchiverUIDTypeID, sizeof(struct __CFKeyedArchiverUID) - sizeof(CFRuntimeBase), NULL);
+    if (NULL == uid) {
+	return NULL;
+    }
+    ((struct __CFKeyedArchiverUID *)uid)->_value = value;
+    return uid;
+}
+
+
+uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid) {
+    return uid->_value;
+}
+
+
+typedef struct {
+    CFTypeRef stream;
+    CFTypeRef error;
+    uint64_t written;
+    int32_t used;
+    bool streamIsData;
+    uint8_t buffer[8192 - 32];
+} __CFBinaryPlistWriteBuffer;
+
+static void writeBytes(__CFBinaryPlistWriteBuffer *buf, const UInt8 *bytes, CFIndex length) {
+    if (0 == length) return;
+    if (buf->error) return;
+    if (buf->streamIsData) {
+        CFDataAppendBytes((CFMutableDataRef)buf->stream, bytes, length);
+        buf->written += length;
+    } else {
+        /* SystemConfiguration relies on being able to serialize a plist to a write stream.
+         * There seems no reason why this isn't supported. The old code read:
+        CFAssert(false, __kCFLogAssertion, "Streams are not supported on this platform");
+         */
+        CFIndex lengthWritten = CFWriteStreamWrite((CFWriteStreamRef)buf->stream, bytes, length);
+        buf->written += lengthWritten;
+    }
+}
+
+static void bufferWrite(__CFBinaryPlistWriteBuffer *buf, const uint8_t *buffer, CFIndex count) {
+    if (0 == count) return;
+    if ((CFIndex)sizeof(buf->buffer) <= count) {
+	writeBytes(buf, buf->buffer, buf->used);
+	buf->used = 0;
+	writeBytes(buf, buffer, count);
+	return;
+    }
+    CFIndex copyLen = __CFMin(count, (CFIndex)sizeof(buf->buffer) - buf->used);
+    memmove(buf->buffer + buf->used, buffer, copyLen);
+    buf->used += copyLen;
+    if (sizeof(buf->buffer) == buf->used) {
+	writeBytes(buf, buf->buffer, sizeof(buf->buffer));
+	memmove(buf->buffer, buffer + copyLen, count - copyLen);
+	buf->used = count - copyLen;
+    }
+}
+
+static void bufferFlush(__CFBinaryPlistWriteBuffer *buf) {
+    writeBytes(buf, buf->buffer, buf->used);
+    buf->used = 0;
+}
+
+/*
+HEADER
+	magic number ("bplist")
+	file format version
+
+OBJECT TABLE
+	variable-sized objects
+
+	Object Formats (marker byte followed by additional info in some cases)
+	null	0000 0000
+	bool	0000 1000			// false
+	bool	0000 1001			// true
+	fill	0000 1111			// fill byte
+	int	0001 nnnn	...		// # of bytes is 2^nnnn, big-endian bytes
+	real	0010 nnnn	...		// # of bytes is 2^nnnn, big-endian bytes
+	date	0011 0011	...		// 8 byte float follows, big-endian bytes
+	data	0100 nnnn	[int]	...	// nnnn is number of bytes unless 1111 then int count follows, followed by bytes
+	string	0101 nnnn	[int]	...	// ASCII string, nnnn is # of chars, else 1111 then int count, then bytes
+	string	0110 nnnn	[int]	...	// Unicode string, nnnn is # of chars, else 1111 then int count, then big-endian 2-byte uint16_t
+		0111 xxxx			// unused
+	uid	1000 nnnn	...		// nnnn+1 is # of bytes
+		1001 xxxx			// unused
+	array	1010 nnnn	[int]	objref*	// nnnn is count, unless '1111', then int count follows
+		1011 xxxx			// unused
+	set	1100 nnnn	[int]	objref* // nnnn is count, unless '1111', then int count follows
+	dict	1101 nnnn	[int]	keyref* objref*	// nnnn is count, unless '1111', then int count follows
+		1110 xxxx			// unused
+		1111 xxxx			// unused
+
+OFFSET TABLE
+	list of ints, byte size of which is given in trailer
+	-- these are the byte offsets into the file
+	-- number of these is in the trailer
+
+TRAILER
+	byte size of offset ints in offset table
+	byte size of object refs in arrays and dicts
+	number of offsets in offset table (also is number of objects)
+	element # in offset table which is top level object
+	offset table offset
+
+*/
+
+
+static CFTypeID stringtype = -1, datatype = -1, numbertype = -1, datetype = -1;
+static CFTypeID booltype = -1, nulltype = -1, dicttype = -1, arraytype = -1, settype = -1;
+
+static void _appendInt(__CFBinaryPlistWriteBuffer *buf, uint64_t bigint) {
+    uint8_t marker;
+    uint8_t *bytes;
+    CFIndex nbytes;
+    if (bigint <= (uint64_t)0xff) {
+	nbytes = 1;
+	marker = kCFBinaryPlistMarkerInt | 0;
+    } else if (bigint <= (uint64_t)0xffff) {
+	nbytes = 2;
+	marker = kCFBinaryPlistMarkerInt | 1;
+    } else if (bigint <= (uint64_t)0xffffffff) {
+	nbytes = 4;
+	marker = kCFBinaryPlistMarkerInt | 2;
+    } else {
+	nbytes = 8;
+	marker = kCFBinaryPlistMarkerInt | 3;
+    }
+    bigint = CFSwapInt64HostToBig(bigint);
+    bytes = (uint8_t *)&bigint + sizeof(bigint) - nbytes;
+    bufferWrite(buf, &marker, 1);
+    bufferWrite(buf, bytes, nbytes);
+}
+
+static void _appendUID(__CFBinaryPlistWriteBuffer *buf, CFKeyedArchiverUIDRef uid) {
+    uint8_t marker;
+    uint8_t *bytes;
+    CFIndex nbytes;
+    uint64_t bigint = _CFKeyedArchiverUIDGetValue(uid);
+    if (bigint <= (uint64_t)0xff) {
+	nbytes = 1;
+    } else if (bigint <= (uint64_t)0xffff) {
+	nbytes = 2;
+    } else if (bigint <= (uint64_t)0xffffffff) {
+	nbytes = 4;
+    } else {
+	nbytes = 8;
+    }
+    marker = kCFBinaryPlistMarkerUID | (uint8_t)(nbytes - 1);
+    bigint = CFSwapInt64HostToBig(bigint);
+    bytes = (uint8_t *)&bigint + sizeof(bigint) - nbytes;
+    bufferWrite(buf, &marker, 1);
+    bufferWrite(buf, bytes, nbytes);
+}
+
+static Boolean __plistNumberEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    // As long as this equals function is more restrictive than the
+    // existing one, for any given type, the hash function need not
+    // also be provided for the uniquing set.
+    if (CFNumberIsFloatType((CFNumberRef)cf1) != CFNumberIsFloatType((CFNumberRef)cf2)) return false;
+    return CFEqual(cf1, cf2);
+}
+
+static CFHashCode __plistDataHash(CFTypeRef cf) {
+    CFDataRef data = (CFDataRef)cf;
+    return CFHashBytes((UInt8 *)CFDataGetBytePtr(data), __CFMin(CFDataGetLength(data), 1280));
+}
+
+static void _flattenPlist(CFPropertyListRef plist, CFMutableArrayRef objlist, CFMutableDictionaryRef objtable, CFMutableSetRef uniquingsets[]) {
+    CFPropertyListRef unique;
+    uint32_t refnum;
+    CFTypeID type = __CFGenericTypeID_genericobj_inline(plist);
+    CFIndex idx;
+    CFPropertyListRef *list, buffer[256];
+
+    // Do not unique dictionaries or arrays, because: they
+    // are slow to compare, and have poor hash codes.
+    // Uniquing bools is unnecessary.
+    int which = -1;
+    if (stringtype == type) {
+	which = 0;
+    } else if (numbertype == type) {
+	which = 1;
+    } else if (datetype == type) {
+	which = 2;
+    } else if (datatype == type) {
+	which = 3;
+    }
+    if (1 && -1 != which) {
+	CFMutableSetRef uniquingset = uniquingsets[which];
+	CFIndex before = CFSetGetCount(uniquingset);
+	CFSetAddValue(uniquingset, plist);
+	CFIndex after = CFSetGetCount(uniquingset);
+	if (after == before) {	// already in set
+	    unique = CFSetGetValue(uniquingset, plist);
+	    if (unique != plist) {
+		refnum = (uint32_t)(uintptr_t)CFDictionaryGetValue(objtable, unique);
+		CFDictionaryAddValue(objtable, plist, (const void *)(uintptr_t)refnum);
+	    }
+	    return;
+	}
+    }
+    refnum = CFArrayGetCount(objlist);
+    CFArrayAppendValue(objlist, plist);
+    CFDictionaryAddValue(objtable, plist, (const void *)(uintptr_t)refnum);
+    if (dicttype == type) {
+	CFIndex count = CFDictionaryGetCount((CFDictionaryRef)plist);
+	list = (count <= 128) ? buffer : (CFPropertyListRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, 2 * count * sizeof(CFTypeRef), 0);
+        CFDictionaryGetKeysAndValues((CFDictionaryRef)plist, list, list + count);
+        for (idx = 0; idx < 2 * count; idx++) {
+            _flattenPlist(list[idx], objlist, objtable, uniquingsets);
+        }
+        if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+    } else if (arraytype == type) {
+	CFIndex count = CFArrayGetCount((CFArrayRef)plist);
+	list = (count <= 256) ? buffer : (CFPropertyListRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, count * sizeof(CFTypeRef), 0);
+        CFArrayGetValues((CFArrayRef)plist, CFRangeMake(0, count), list);
+        for (idx = 0; idx < count; idx++) {
+            _flattenPlist(list[idx], objlist, objtable, uniquingsets);
+        }
+        if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+    }
+}
+
+// stream must be a CFMutableDataRef
+CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream) {
+    CFMutableDictionaryRef objtable;
+    CFMutableArrayRef objlist;
+    CFBinaryPlistTrailer trailer;
+    uint64_t *offsets, length_so_far;
+    uint64_t mask, refnum;
+    int64_t idx, idx2, cnt;
+    __CFBinaryPlistWriteBuffer *buf;
+
+    if ((CFTypeID)-1 == stringtype) {
+	stringtype = CFStringGetTypeID();
+    }
+    if ((CFTypeID)-1 == datatype) {
+	datatype = CFDataGetTypeID();
+    }
+    if ((CFTypeID)-1 == numbertype) {
+	numbertype = CFNumberGetTypeID();
+    }
+    if ((CFTypeID)-1 == booltype) {
+	booltype = CFBooleanGetTypeID();
+    }
+    if ((CFTypeID)-1 == datetype) {
+	datetype = CFDateGetTypeID();
+    }
+    if ((CFTypeID)-1 == dicttype) {
+	dicttype = CFDictionaryGetTypeID();
+    }
+    if ((CFTypeID)-1 == arraytype) {
+	arraytype = CFArrayGetTypeID();
+    }
+    if ((CFTypeID)-1 == settype) {
+	settype = CFSetGetTypeID();
+    }
+    if ((CFTypeID)-1 == nulltype) {
+	nulltype = CFNullGetTypeID();
+    }
+
+    objtable = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);
+    _CFDictionarySetCapacity(objtable, 640);
+    objlist = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+    _CFArraySetCapacity(objlist, 640);
+    CFSetCallBacks cb = kCFTypeSetCallBacks;
+    cb.retain = NULL;
+    cb.release = NULL;
+    CFMutableSetRef uniquingsets[4];
+    uniquingsets[0] = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &cb);
+    _CFSetSetCapacity(uniquingsets[0], 1000);
+    cb.equal = __plistNumberEqual;
+    uniquingsets[1] = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &cb);
+    _CFSetSetCapacity(uniquingsets[1], 500);
+    cb.equal = kCFTypeSetCallBacks.equal;
+    uniquingsets[2] = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &cb);
+    _CFSetSetCapacity(uniquingsets[2], 500);
+    cb.hash = __plistDataHash;
+    uniquingsets[3] = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &cb);
+    _CFSetSetCapacity(uniquingsets[3], 500);
+
+    _flattenPlist(plist, objlist, objtable, uniquingsets);
+
+    CFRelease(uniquingsets[0]);
+    CFRelease(uniquingsets[1]);
+    CFRelease(uniquingsets[2]);
+    CFRelease(uniquingsets[3]);
+
+    cnt = CFArrayGetCount(objlist);
+    offsets = (uint64_t *)CFAllocatorAllocate(kCFAllocatorSystemDefault, (CFIndex)(cnt * sizeof(*offsets)), 0);
+
+    buf = (__CFBinaryPlistWriteBuffer *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(__CFBinaryPlistWriteBuffer), 0);
+    buf->stream = stream;
+    buf->error = NULL;
+    buf->streamIsData = (CFGetTypeID(stream) == CFDataGetTypeID());
+    buf->written = 0;
+    buf->used = 0;
+    bufferWrite(buf, (uint8_t *)"bplist00", 8);	// header
+
+    memset(&trailer, 0, sizeof(trailer));
+    trailer._numObjects = CFSwapInt64HostToBig(cnt);
+    trailer._topObject = 0;	// true for this implementation
+    mask = ~(uint64_t)0;
+    while (cnt & mask) {
+	trailer._objectRefSize++;
+	mask = mask << 8;
+    }
+
+    for (idx = 0; idx < cnt; idx++) {
+	CFPropertyListRef obj = CFArrayGetValueAtIndex(objlist, (CFIndex)idx);
+	CFTypeID type = __CFGenericTypeID_genericobj_inline(obj);
+	offsets[idx] = buf->written + buf->used;
+	if (stringtype == type) {
+	    CFIndex ret, count = CFStringGetLength((CFStringRef)obj);
+	    CFIndex needed;
+	    uint8_t *bytes, buffer[1024];
+	    bytes = (count <= 1024) ? buffer : (uint8_t *)CFAllocatorAllocate(kCFAllocatorSystemDefault, count, 0);
+	    // presumption, believed to be true, is that ASCII encoding may need
+	    // less bytes, but will not need greater, than the # of unichars
+	    ret = CFStringGetBytes((CFStringRef)obj, CFRangeMake(0, count), kCFStringEncodingASCII, 0, false, bytes, count, &needed);
+	    if (ret == count) {
+		uint8_t marker = (uint8_t)(kCFBinaryPlistMarkerASCIIString | (needed < 15 ? needed : 0xf));
+		bufferWrite(buf, &marker, 1);
+		if (15 <= needed) {
+		    _appendInt(buf, (uint64_t)needed);
+		}
+		bufferWrite(buf, bytes, needed);
+	    } else {
+		UniChar *chars;
+		uint8_t marker = (uint8_t)(kCFBinaryPlistMarkerUnicode16String | (count < 15 ? count : 0xf));
+		bufferWrite(buf, &marker, 1);
+		if (15 <= count) {
+		    _appendInt(buf, (uint64_t)count);
+		}
+		chars = (UniChar *)CFAllocatorAllocate(kCFAllocatorSystemDefault, count * sizeof(UniChar), 0);
+		CFStringGetCharacters((CFStringRef)obj, CFRangeMake(0, count), chars);
+		for (idx2 = 0; idx2 < count; idx2++) {
+		    chars[idx2] = CFSwapInt16HostToBig(chars[idx2]);
+		}
+		bufferWrite(buf, (uint8_t *)chars, count * sizeof(UniChar));
+		CFAllocatorDeallocate(kCFAllocatorSystemDefault, chars);
+	    }
+	    if (bytes != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, bytes);
+	} else if (numbertype == type) {
+	    uint8_t marker;
+	    uint64_t bigint;
+	    uint8_t *bytes;
+	    CFIndex nbytes;
+	    if (CFNumberIsFloatType((CFNumberRef)obj)) {
+		CFSwappedFloat64 swapped64;
+		CFSwappedFloat32 swapped32;
+		if (CFNumberGetByteSize((CFNumberRef)obj) <= (CFIndex)sizeof(float)) {
+		    float v;
+		    CFNumberGetValue((CFNumberRef)obj, kCFNumberFloat32Type, &v);
+		    swapped32 = CFConvertFloat32HostToSwapped(v);
+		    bytes = (uint8_t *)&swapped32;
+		    nbytes = sizeof(float);
+		    marker = kCFBinaryPlistMarkerReal | 2;
+		} else {
+		    double v;
+		    CFNumberGetValue((CFNumberRef)obj, kCFNumberFloat64Type, &v);
+		    swapped64 = CFConvertFloat64HostToSwapped(v);
+		    bytes = (uint8_t *)&swapped64;
+		    nbytes = sizeof(double);
+		    marker = kCFBinaryPlistMarkerReal | 3;
+		}
+		bufferWrite(buf, &marker, 1);
+		bufferWrite(buf, bytes, nbytes);
+	    } else {
+		CFNumberType type = _CFNumberGetType2((CFNumberRef)obj);
+		if (kCFNumberSInt128Type == type) {
+		    CFSInt128Struct s;
+		    CFNumberGetValue((CFNumberRef)obj, kCFNumberSInt128Type, &s);
+		    struct {
+			int64_t high;
+			uint64_t low;
+		    } storage;
+		    storage.high = CFSwapInt64HostToBig(s.high);
+		    storage.low = CFSwapInt64HostToBig(s.low);
+		    uint8_t *bytes = (uint8_t *)&storage;
+		    uint8_t marker = kCFBinaryPlistMarkerInt | 4;
+		    CFIndex nbytes = 16;
+		    bufferWrite(buf, &marker, 1);
+		    bufferWrite(buf, bytes, nbytes);
+		} else {
+		    CFNumberGetValue((CFNumberRef)obj, kCFNumberSInt64Type, &bigint);
+		    _appendInt(buf, bigint);
+		}
+	    }
+	} else if (_CFKeyedArchiverUIDGetTypeID() == type) {
+	    _appendUID(buf, (CFKeyedArchiverUIDRef)obj);
+	} else if (booltype == type) {
+	    uint8_t marker = CFBooleanGetValue((CFBooleanRef)obj) ? kCFBinaryPlistMarkerTrue : kCFBinaryPlistMarkerFalse;
+	    bufferWrite(buf, &marker, 1);
+	} else if (datatype == type) {
+	    CFIndex count = CFDataGetLength((CFDataRef)obj);
+	    uint8_t marker = (uint8_t)(kCFBinaryPlistMarkerData | (count < 15 ? count : 0xf));
+	    bufferWrite(buf, &marker, 1);
+	    if (15 <= count) {
+		_appendInt(buf, (uint64_t)count);
+	    }
+	    bufferWrite(buf, CFDataGetBytePtr((CFDataRef)obj), count);
+	} else if (datetype == type) {
+	    CFSwappedFloat64 swapped;
+	    uint8_t marker = kCFBinaryPlistMarkerDate;
+	    bufferWrite(buf, &marker, 1);
+	    swapped = CFConvertFloat64HostToSwapped(CFDateGetAbsoluteTime((CFDateRef)obj));
+	    bufferWrite(buf, (uint8_t *)&swapped, sizeof(swapped));
+	} else if (dicttype == type) {
+	    CFIndex count = CFDictionaryGetCount((CFDictionaryRef)obj);
+	    CFPropertyListRef *list, buffer[512];
+	    uint8_t marker = (uint8_t)(kCFBinaryPlistMarkerDict | (count < 15 ? count : 0xf));
+	    bufferWrite(buf, &marker, 1);
+	    if (15 <= count) {
+		_appendInt(buf, (uint64_t)count);
+	    }
+	    list = (count <= 256) ? buffer : (CFPropertyListRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, 2 * count * sizeof(CFTypeRef), 0);
+	    CFDictionaryGetKeysAndValues((CFDictionaryRef)obj, list, list + count);
+	    for (idx2 = 0; idx2 < 2 * count; idx2++) {
+		CFPropertyListRef value = list[idx2];
+		uint32_t swapped = 0;
+		uint8_t *source = (uint8_t *)&swapped;
+                refnum = (uint32_t)(uintptr_t)CFDictionaryGetValue(objtable, value);
+                swapped = CFSwapInt32HostToBig((uint32_t)refnum);
+		bufferWrite(buf, source + sizeof(swapped) - trailer._objectRefSize, trailer._objectRefSize);
+	    }
+	    if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+	} else if (arraytype == type) {
+	    CFIndex count = CFArrayGetCount((CFArrayRef)obj);
+	    CFPropertyListRef *list, buffer[256];
+	    uint8_t marker = (uint8_t)(kCFBinaryPlistMarkerArray | (count < 15 ? count : 0xf));
+	    bufferWrite(buf, &marker, 1);
+	    if (15 <= count) {
+		_appendInt(buf, (uint64_t)count);
+	    }
+	    list = (count <= 256) ? buffer : (CFPropertyListRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, count * sizeof(CFTypeRef), 0);
+	    CFArrayGetValues((CFArrayRef)obj, CFRangeMake(0, count), list);
+	    for (idx2 = 0; idx2 < count; idx2++) {
+		CFPropertyListRef value = list[idx2];
+		uint32_t swapped = 0;
+		uint8_t *source = (uint8_t *)&swapped;
+                refnum = (uint32_t)(uintptr_t)CFDictionaryGetValue(objtable, value);
+                swapped = CFSwapInt32HostToBig((uint32_t)refnum);
+		bufferWrite(buf, source + sizeof(swapped) - trailer._objectRefSize, trailer._objectRefSize);
+	    }
+	    if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+	} else {
+	    CFRelease(objtable);
+	    CFRelease(objlist);
+	    if (buf->error) CFRelease(buf->error);
+	    CFAllocatorDeallocate(kCFAllocatorSystemDefault, buf);
+            CFAllocatorDeallocate(kCFAllocatorSystemDefault, offsets);
+	    return 0;
+	}
+    }
+    CFRelease(objtable);
+    CFRelease(objlist);
+
+    length_so_far = buf->written + buf->used;
+    trailer._offsetTableOffset = CFSwapInt64HostToBig(length_so_far);
+    trailer._offsetIntSize = 0;
+    mask = ~(uint64_t)0;
+    while (length_so_far & mask) {
+	trailer._offsetIntSize++;
+	mask = mask << 8;
+    }
+
+    for (idx = 0; idx < cnt; idx++) {
+	uint64_t swapped = CFSwapInt64HostToBig(offsets[idx]);
+	uint8_t *source = (uint8_t *)&swapped;
+	bufferWrite(buf, source + sizeof(*offsets) - trailer._offsetIntSize, trailer._offsetIntSize);
+    }
+    length_so_far += cnt * trailer._offsetIntSize;
+
+    bufferWrite(buf, (uint8_t *)&trailer, sizeof(trailer));
+    bufferFlush(buf);
+    length_so_far += sizeof(trailer);
+    if (buf->error) {
+	CFRelease(buf->error);
+	return 0;
+    }
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, buf);
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, offsets);
+    return (CFIndex)length_so_far;
+}
+
+
+#define FAIL_FALSE	do { return false; } while (0)
+#define FAIL_MAXOFFSET	do { return UINT64_MAX; } while (0)
+
+bool __CFBinaryPlistGetTopLevelInfo(const uint8_t *databytes, uint64_t datalen, uint8_t *marker, uint64_t *offset, CFBinaryPlistTrailer *trailer) {
+    CFBinaryPlistTrailer trail;
+
+    if ((CFTypeID)-1 == stringtype) {
+	stringtype = CFStringGetTypeID();
+    }
+    if ((CFTypeID)-1 == datatype) {
+	datatype = CFDataGetTypeID();
+    }
+    if ((CFTypeID)-1 == numbertype) {
+	numbertype = CFNumberGetTypeID();
+    }
+    if ((CFTypeID)-1 == booltype) {
+	booltype = CFBooleanGetTypeID();
+    }
+    if ((CFTypeID)-1 == datetype) {
+	datetype = CFDateGetTypeID();
+    }
+    if ((CFTypeID)-1 == dicttype) {
+	dicttype = CFDictionaryGetTypeID();
+    }
+    if ((CFTypeID)-1 == arraytype) {
+	arraytype = CFArrayGetTypeID();
+    }
+    if ((CFTypeID)-1 == settype) {
+	settype = CFSetGetTypeID();
+    }
+    if ((CFTypeID)-1 == nulltype) {
+	nulltype = CFNullGetTypeID();
+    }
+
+    if (!databytes || datalen < sizeof(trail) + 8 + 1) FAIL_FALSE;
+    if (0 != memcmp("bplist00", databytes, 8) && 0 != memcmp("bplist01", databytes, 8)) return false;
+    memmove(&trail, databytes + datalen - sizeof(trail), sizeof(trail));
+    if (trail._unused[0] != 0 || trail._unused[1] != 0 || trail._unused[2] != 0 || trail._unused[3] != 0 || trail._unused[4] != 0 || trail._unused[5] != 0) FAIL_FALSE;
+    trail._numObjects = CFSwapInt64BigToHost(trail._numObjects);
+    trail._topObject = CFSwapInt64BigToHost(trail._topObject);
+    trail._offsetTableOffset = CFSwapInt64BigToHost(trail._offsetTableOffset);
+    if (LONG_MAX < trail._numObjects) FAIL_FALSE;
+    if (LONG_MAX < trail._offsetTableOffset) FAIL_FALSE;
+    if (trail._numObjects < 1) FAIL_FALSE;
+    if (trail._numObjects <= trail._topObject) FAIL_FALSE;
+    if (trail._offsetTableOffset < 9) FAIL_FALSE;
+    if (datalen - sizeof(trail) <= trail._offsetTableOffset) FAIL_FALSE;
+    if (trail._offsetIntSize < 1) FAIL_FALSE;
+    if (trail._objectRefSize < 1) FAIL_FALSE;
+    int32_t err = CF_NO_ERROR;
+    uint64_t offsetIntSize = trail._offsetIntSize;
+    uint64_t offsetTableSize = __check_uint64_mul_unsigned_unsigned(trail._numObjects, offsetIntSize, &err);
+    if (CF_NO_ERROR!= err) FAIL_FALSE;
+    if (offsetTableSize < 1) FAIL_FALSE;
+    uint64_t objectDataSize = trail._offsetTableOffset - 8;
+    uint64_t tmpSum = __check_uint64_add_unsigned_unsigned(8, objectDataSize, &err);
+    tmpSum = __check_uint64_add_unsigned_unsigned(tmpSum, offsetTableSize, &err);
+    tmpSum = __check_uint64_add_unsigned_unsigned(tmpSum, sizeof(trail), &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    if (datalen != tmpSum) FAIL_FALSE;
+    if (trail._objectRefSize < 8 && (1ULL << (8 * trail._objectRefSize)) <= trail._numObjects) FAIL_FALSE;
+    if (trail._offsetIntSize < 8 && (1ULL << (8 * trail._offsetIntSize)) <= trail._offsetTableOffset) FAIL_FALSE;
+    const uint8_t *objectsFirstByte;
+    objectsFirstByte = check_ptr_add(databytes, 8, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    const uint8_t *offsetsFirstByte = check_ptr_add(databytes, trail._offsetTableOffset, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    const uint8_t *offsetsLastByte;
+    offsetsLastByte = check_ptr_add(offsetsFirstByte, offsetTableSize - 1, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+
+    const uint8_t *bytesptr = databytes + trail._offsetTableOffset;
+    uint64_t maxOffset = trail._offsetTableOffset - 1;
+    for (CFIndex idx = 0; idx < trail._numObjects; idx++) {
+	uint64_t off = 0;
+	for (CFIndex idx2 = 0; idx2 < trail._offsetIntSize; idx2++) {
+	    off = (off << 8) + bytesptr[idx2];
+	}
+	if (maxOffset < off) FAIL_FALSE;
+	bytesptr += trail._offsetIntSize;
+    }
+
+    bytesptr = databytes + trail._offsetTableOffset + trail._topObject * trail._offsetIntSize;
+    uint64_t off = 0;
+    for (CFIndex idx = 0; idx < trail._offsetIntSize; idx++) {
+	off = (off << 8) + bytesptr[idx];
+    }
+    if (off < 8 || trail._offsetTableOffset <= off) FAIL_FALSE;
+    if (trailer) *trailer = trail;
+    if (offset) *offset = off;
+    if (marker) *marker = *(databytes + off);
+    return true;
+}
+
+CF_INLINE Boolean _plistIsPrimitive(CFPropertyListRef pl) {
+    CFTypeID type = __CFGenericTypeID_genericobj_inline(pl);
+    if (dicttype == type || arraytype == type || settype == type) FAIL_FALSE;
+    return true;
+}
+
+CF_INLINE bool _readInt(const uint8_t *ptr, const uint8_t *end_byte_ptr, uint64_t *bigint, const uint8_t **newptr) {
+    if (end_byte_ptr < ptr) FAIL_FALSE;
+    uint8_t marker = *ptr++;
+    if ((marker & 0xf0) != kCFBinaryPlistMarkerInt) FAIL_FALSE;
+    uint64_t cnt = 1 << (marker & 0x0f);
+    int32_t err = CF_NO_ERROR;
+    const uint8_t *extent = check_ptr_add(ptr, cnt, &err) - 1;
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    if (end_byte_ptr < extent) FAIL_FALSE;
+    // integers are not required to be in the most compact possible representation, but only the last 64 bits are significant currently
+    *bigint = 0;
+    for (CFIndex idx = 0; idx < cnt; idx++) {
+        *bigint = (*bigint << 8) + *ptr++;
+    }
+    if (newptr) *newptr = ptr;
+    return true;
+}
+
+// bytesptr points at a ref
+CF_INLINE uint64_t _getOffsetOfRefAt(const uint8_t *databytes, const uint8_t *bytesptr, const CFBinaryPlistTrailer *trailer) {
+    // *trailer contents are trusted, even for overflows -- was checked when the trailer was parsed;
+    // this pointer arithmetic and the multiplication was also already done once and checked,
+    // and the offsetTable was already validated.
+    const uint8_t *objectsFirstByte = databytes + 8;
+    const uint8_t *offsetsFirstByte = databytes + trailer->_offsetTableOffset;
+    if (bytesptr < objectsFirstByte || offsetsFirstByte - trailer->_objectRefSize < bytesptr) FAIL_MAXOFFSET;
+
+    uint64_t ref = 0;
+    for (CFIndex idx = 0; idx < trailer->_objectRefSize; idx++) {
+	ref = (ref << 8) + bytesptr[idx];
+    }
+    if (trailer->_numObjects <= ref) FAIL_MAXOFFSET;
+
+    bytesptr = databytes + trailer->_offsetTableOffset + ref * trailer->_offsetIntSize;
+    uint64_t off = 0;
+    for (CFIndex idx = 0; idx < trailer->_offsetIntSize; idx++) {
+	off = (off << 8) + bytesptr[idx];
+    }
+    return off;
+}
+
+static bool __CFBinaryPlistCreateObject2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFMutableSetRef set, CFIndex curDepth, CFPropertyListRef *plist);
+
+bool __CFBinaryPlistGetOffsetForValueFromArray2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFIndex idx, uint64_t *offset, CFMutableDictionaryRef objects) {
+    uint64_t objectsRangeStart = 8, objectsRangeEnd = trailer->_offsetTableOffset - 1;
+    if (startOffset < objectsRangeStart || objectsRangeEnd < startOffset) FAIL_FALSE;
+    const uint8_t *ptr = databytes + startOffset;
+    uint8_t marker = *ptr;
+    if ((marker & 0xf0) != kCFBinaryPlistMarkerArray) FAIL_FALSE;
+    int32_t err = CF_NO_ERROR;
+    ptr = check_ptr_add(ptr, 1, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    uint64_t cnt = (marker & 0x0f);
+    if (0xf == cnt) {
+	uint64_t bigint;
+	if (!_readInt(ptr, databytes + objectsRangeEnd, &bigint, &ptr)) FAIL_FALSE;
+	if (LONG_MAX < bigint) FAIL_FALSE;
+	cnt = bigint;
+    }
+    if (cnt <= idx) FAIL_FALSE;
+    size_t byte_cnt = check_size_t_mul(cnt, trailer->_objectRefSize, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    const uint8_t *extent = check_ptr_add(ptr, byte_cnt, &err) - 1;
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+    uint64_t off = _getOffsetOfRefAt(databytes, ptr + idx * trailer->_objectRefSize, trailer);
+    if (offset) *offset = off;
+    return true;
+}
+
+bool __CFBinaryPlistGetOffsetForValueFromDictionary2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFTypeRef key, uint64_t *koffset, uint64_t *voffset, CFMutableDictionaryRef objects) {
+    if (!key || !_plistIsPrimitive(key)) FAIL_FALSE;
+    uint64_t objectsRangeStart = 8, objectsRangeEnd = trailer->_offsetTableOffset - 1;
+    if (startOffset < objectsRangeStart || objectsRangeEnd < startOffset) FAIL_FALSE;
+    const uint8_t *ptr = databytes + startOffset;
+    uint8_t marker = *ptr;
+    if ((marker & 0xf0) != kCFBinaryPlistMarkerDict) FAIL_FALSE;
+    int32_t err = CF_NO_ERROR;
+    ptr = check_ptr_add(ptr, 1, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    uint64_t cnt = (marker & 0x0f);
+    if (0xf == cnt) {
+	uint64_t bigint = 0;
+	if (!_readInt(ptr, databytes + objectsRangeEnd, &bigint, &ptr)) FAIL_FALSE;
+	if (LONG_MAX < bigint) FAIL_FALSE;
+	cnt = bigint;
+    }
+    cnt = check_size_t_mul(cnt, 2, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    size_t byte_cnt = check_size_t_mul(cnt, trailer->_objectRefSize, &err);
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    const uint8_t *extent = check_ptr_add(ptr, byte_cnt, &err) - 1;
+    if (CF_NO_ERROR != err) FAIL_FALSE;
+    if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+    CFIndex stringKeyLen = -1;
+    UniChar ubuffer[16];
+    if (__CFGenericTypeID_genericobj_inline(key) == stringtype) {
+	stringKeyLen = CFStringGetLength((CFStringRef)key);
+	if (stringKeyLen < 0xf) {
+	    CFStringGetCharacters((CFStringRef)key, CFRangeMake(0, stringKeyLen), ubuffer);
+	}
+    }
+    cnt = cnt / 2;
+    for (CFIndex idx = 0; idx < cnt; idx++) {
+	uint64_t off = _getOffsetOfRefAt(databytes, ptr, trailer);
+	uint8_t marker = *(databytes + off);
+	CFIndex len = marker & 0x0f;
+	// if it is a short ascii string in the data, and the key is a string
+	if ((marker & 0xf0) == kCFBinaryPlistMarkerASCIIString && len < 0xf && stringKeyLen != -1) {
+	    if (len != stringKeyLen) goto miss;
+	    err = CF_NO_ERROR;
+	    const uint8_t *ptr2 = databytes + off;
+	    extent = check_ptr_add(ptr2, len, &err);
+	    if (CF_NO_ERROR != err) FAIL_FALSE;
+	    if (databytes + trailer->_offsetTableOffset <= extent) FAIL_FALSE;
+            for (CFIndex idx2 = 0; idx2 < stringKeyLen; idx2++) {
+                if ((UniChar)ptr2[idx2 + 1] != ubuffer[idx2]) goto miss;
+            }
+	    if (koffset) *koffset = off;
+	    if (voffset) {
+		off = _getOffsetOfRefAt(databytes, ptr + cnt * trailer->_objectRefSize, trailer);
+		*voffset = off;
+	    }
+	    return true;
+	    miss:;
+	} else {
+	    CFPropertyListRef pl = NULL;
+	    if (!__CFBinaryPlistCreateObject2(databytes, datalen, off, trailer, kCFAllocatorSystemDefault, kCFPropertyListImmutable, objects, NULL, 0, &pl) || !_plistIsPrimitive(pl)) {
+		if (pl) CFRelease(pl);
+		FAIL_FALSE;
+	    }
+	    if (CFEqual(key, pl)) {
+		CFRelease(pl);
+		if (koffset) *koffset = off;
+		if (voffset) {
+		    off = _getOffsetOfRefAt(databytes, ptr + cnt * trailer->_objectRefSize, trailer);
+		    *voffset = off;
+		}
+		return true;
+	    }
+	    CFRelease(pl);
+	}
+	ptr += trailer->_objectRefSize;
+    }
+    return false;
+}
+
+extern CFArrayRef _CFArrayCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const void **values, CFIndex numValues);
+extern CFSetRef _CFSetCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const void **values, CFIndex numValues);
+extern CFDictionaryRef _CFDictionaryCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const void **keys, const void **values, CFIndex numValues);
+
+static bool __CFBinaryPlistCreateObject2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFMutableSetRef set, CFIndex curDepth, CFPropertyListRef *plist) {
+
+    if (objects) {
+	*plist = CFDictionaryGetValue(objects, (const void *)(uintptr_t)startOffset);
+	if (*plist) {
+	    CFRetain(*plist);
+	    return true;
+	}
+    }
+
+    // at any one invocation of this function, set should contain the offsets in the "path" down to this object
+    if (set && CFSetContainsValue(set, (const void *)(uintptr_t)startOffset)) return false;
+
+    // databytes is trusted to be at least datalen bytes long
+    // *trailer contents are trusted, even for overflows -- was checked when the trailer was parsed
+    uint64_t objectsRangeStart = 8, objectsRangeEnd = trailer->_offsetTableOffset - 1;
+    if (startOffset < objectsRangeStart || objectsRangeEnd < startOffset) FAIL_FALSE;
+
+    uint64_t off;
+    CFPropertyListRef *list, buffer[256];
+    CFAllocatorRef listAllocator;
+
+    uint8_t marker = *(databytes + startOffset);
+    switch (marker & 0xf0) {
+    case kCFBinaryPlistMarkerNull:
+	switch (marker) {
+	case kCFBinaryPlistMarkerNull:
+	    *plist = kCFNull;
+	    return true;
+	case kCFBinaryPlistMarkerFalse:
+	    *plist = CFRetain(kCFBooleanFalse);
+	    return true;
+	case kCFBinaryPlistMarkerTrue:
+	    *plist = CFRetain(kCFBooleanTrue);
+	    return true;
+	}
+	FAIL_FALSE;
+    case kCFBinaryPlistMarkerInt:
+    {
+	const uint8_t *ptr = (databytes + startOffset);
+	int32_t err = CF_NO_ERROR;
+	ptr = check_ptr_add(ptr, 1, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	uint64_t cnt = 1 << (marker & 0x0f);
+	const uint8_t *extent = check_ptr_add(ptr, cnt, &err) - 1;
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	if (16 < cnt) FAIL_FALSE;
+	// in format version '00', 1, 2, and 4-byte integers have to be interpreted as unsigned,
+	// whereas 8-byte integers are signed (and 16-byte when available)
+	// negative 1, 2, 4-byte integers are always emitted as 8 bytes in format '00'
+	uint64_t bigint = 0;
+	// integers are not required to be in the most compact possible representation, but only the last 64 bits are significant currently
+	for (CFIndex idx = 0; idx < cnt; idx++) {
+	    bigint = (bigint << 8) + *ptr++;
+	}
+	if (8 < cnt) {
+	    CFSInt128Struct val;
+	    val.high = 0;
+	    val.low = bigint;
+	    *plist = CFNumberCreate(allocator, kCFNumberSInt128Type, &val);
+	} else {
+	    *plist = CFNumberCreate(allocator, kCFNumberSInt64Type, &bigint);
+	}
+	// these are always immutable
+	if (objects && *plist) {
+	    CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	}
+	return (*plist) ? true : false;
+    }
+    case kCFBinaryPlistMarkerReal:
+	switch (marker & 0x0f) {
+	case 2: {
+	    const uint8_t *ptr = (databytes + startOffset);
+	    int32_t err = CF_NO_ERROR;
+	    ptr = check_ptr_add(ptr, 1, &err);
+	    if (CF_NO_ERROR != err) FAIL_FALSE;
+	    const uint8_t *extent = check_ptr_add(ptr, 4, &err) - 1;
+	    if (CF_NO_ERROR != err) FAIL_FALSE;
+	    if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	    CFSwappedFloat32 swapped32;
+	    memmove(&swapped32, ptr, 4);
+	    float f = CFConvertFloat32SwappedToHost(swapped32);
+	    *plist = CFNumberCreate(allocator, kCFNumberFloat32Type, &f);
+	    // these are always immutable
+	    if (objects && *plist) {
+		CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	    }
+	    return (*plist) ? true : false;
+	}
+	case 3: {
+	    const uint8_t *ptr = (databytes + startOffset);
+	    int32_t err = CF_NO_ERROR;
+	    ptr = check_ptr_add(ptr, 1, &err);
+	    if (CF_NO_ERROR != err) FAIL_FALSE;
+	    const uint8_t *extent = check_ptr_add(ptr, 8, &err) - 1;
+	    if (CF_NO_ERROR != err) FAIL_FALSE;
+	    if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	    CFSwappedFloat64 swapped64;
+	    memmove(&swapped64, ptr, 8);
+	    double d = CFConvertFloat64SwappedToHost(swapped64);
+	    *plist = CFNumberCreate(allocator, kCFNumberFloat64Type, &d);
+	    // these are always immutable
+	    if (objects && *plist) {
+		CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	    }
+	    return (*plist) ? true : false;
+	}
+	}
+	FAIL_FALSE;
+    case kCFBinaryPlistMarkerDate & 0xf0:
+	switch (marker) {
+	case kCFBinaryPlistMarkerDate: {
+	    const uint8_t *ptr = (databytes + startOffset);
+	    int32_t err = CF_NO_ERROR;
+	    ptr = check_ptr_add(ptr, 1, &err);
+	    if (CF_NO_ERROR != err) FAIL_FALSE;
+	    const uint8_t *extent = check_ptr_add(ptr, 8, &err) - 1;
+	    if (CF_NO_ERROR != err) FAIL_FALSE;
+	    if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	    CFSwappedFloat64 swapped64;
+	    memmove(&swapped64, ptr, 8);
+	    double d = CFConvertFloat64SwappedToHost(swapped64);
+	    *plist = CFDateCreate(allocator, d);
+	    // these are always immutable
+	    if (objects && *plist) {
+		CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	    }
+	    return (*plist) ? true : false;
+	}
+	}
+	FAIL_FALSE;
+    case kCFBinaryPlistMarkerData: {
+	const uint8_t *ptr = databytes + startOffset;
+	int32_t err = CF_NO_ERROR;
+	ptr = check_ptr_add(ptr, 1, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	CFIndex cnt = marker & 0x0f;
+	if (0xf == cnt) {
+	    uint64_t bigint = 0;
+	    if (!_readInt(ptr, databytes + objectsRangeEnd, &bigint, &ptr)) FAIL_FALSE;
+	    if (LONG_MAX < bigint) FAIL_FALSE;
+	    cnt = (CFIndex)bigint;
+	}
+	const uint8_t *extent = check_ptr_add(ptr, cnt, &err) - 1;
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	if (mutabilityOption == kCFPropertyListMutableContainersAndLeaves) {
+	    *plist = CFDataCreateMutable(allocator, 0);
+	    if (*plist) CFDataAppendBytes((CFMutableDataRef)*plist, ptr, cnt);
+	} else {
+	    *plist = CFDataCreate(allocator, ptr, cnt);
+	}
+        if (objects && *plist && (mutabilityOption != kCFPropertyListMutableContainersAndLeaves)) {
+	    CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	}
+	return (*plist) ? true : false;
+	}
+    case kCFBinaryPlistMarkerASCIIString: {
+	const uint8_t *ptr = databytes + startOffset;
+	int32_t err = CF_NO_ERROR;
+	ptr = check_ptr_add(ptr, 1, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	CFIndex cnt = marker & 0x0f;
+	if (0xf == cnt) {
+            uint64_t bigint = 0;
+	    if (!_readInt(ptr, databytes + objectsRangeEnd, &bigint, &ptr)) FAIL_FALSE;
+	    if (LONG_MAX < bigint) FAIL_FALSE;
+	    cnt = (CFIndex)bigint;
+	}
+	const uint8_t *extent = check_ptr_add(ptr, cnt, &err) - 1;
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	if (mutabilityOption == kCFPropertyListMutableContainersAndLeaves) {
+	    CFStringRef str = CFStringCreateWithBytes(allocator, ptr, cnt, kCFStringEncodingASCII, false);
+	    *plist = str ? CFStringCreateMutableCopy(allocator, 0, str) : NULL;
+	    if (str) CFRelease(str);
+	} else {
+	    *plist = CFStringCreateWithBytes(allocator, ptr, cnt, kCFStringEncodingASCII, false);
+	}
+        if (objects && *plist && (mutabilityOption != kCFPropertyListMutableContainersAndLeaves)) {
+	    CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	}
+	return (*plist) ? true : false;
+	}
+    case kCFBinaryPlistMarkerUnicode16String: {
+	const uint8_t *ptr = databytes + startOffset;
+	int32_t err = CF_NO_ERROR;
+	ptr = check_ptr_add(ptr, 1, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	CFIndex cnt = marker & 0x0f;
+	if (0xf == cnt) {
+            uint64_t bigint = 0;
+	    if (!_readInt(ptr, databytes + objectsRangeEnd, &bigint, &ptr)) FAIL_FALSE;
+	    if (LONG_MAX < bigint) FAIL_FALSE;
+	    cnt = (CFIndex)bigint;
+	}
+	const uint8_t *extent = check_ptr_add(ptr, cnt, &err) - 1;
+	extent = check_ptr_add(extent, cnt, &err);	// 2 bytes per character
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	size_t byte_cnt = check_size_t_mul(cnt, sizeof(UniChar), &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	UniChar *chars = (UniChar *)CFAllocatorAllocate(allocator, byte_cnt, 0);
+	if (!chars) FAIL_FALSE;
+	memmove(chars, ptr, byte_cnt);
+	for (CFIndex idx = 0; idx < cnt; idx++) {
+	    chars[idx] = CFSwapInt16BigToHost(chars[idx]);
+	}
+	if (mutabilityOption == kCFPropertyListMutableContainersAndLeaves) {
+	    CFStringRef str = CFStringCreateWithCharactersNoCopy(allocator, chars, cnt, allocator);
+	    *plist = str ? CFStringCreateMutableCopy(allocator, 0, str) : NULL;
+	    if (str) CFRelease(str);
+	} else {
+	    *plist = CFStringCreateWithCharactersNoCopy(allocator, chars, cnt, allocator);
+	}
+        if (objects && *plist && (mutabilityOption != kCFPropertyListMutableContainersAndLeaves)) {
+	    CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	}
+	return (*plist) ? true : false;
+	}
+    case kCFBinaryPlistMarkerUID: {
+	const uint8_t *ptr = databytes + startOffset;
+	int32_t err = CF_NO_ERROR;
+	ptr = check_ptr_add(ptr, 1, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	CFIndex cnt = (marker & 0x0f) + 1;
+	const uint8_t *extent = check_ptr_add(ptr, cnt, &err) - 1;
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	// uids are not required to be in the most compact possible representation, but only the last 64 bits are significant currently
+	uint64_t bigint = 0;
+	for (CFIndex idx = 0; idx < cnt; idx++) {
+	    bigint = (bigint << 8) + *ptr++;
+	}
+	if (UINT32_MAX < bigint) FAIL_FALSE;
+	*plist = _CFKeyedArchiverUIDCreate(allocator, (uint32_t)bigint);
+	// these are always immutable
+	if (objects && *plist) {
+	    CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	}
+	return (*plist) ? true : false;
+	}
+    case kCFBinaryPlistMarkerArray:
+    case kCFBinaryPlistMarkerSet: {
+	const uint8_t *ptr = databytes + startOffset;
+	int32_t err = CF_NO_ERROR;
+	ptr = check_ptr_add(ptr, 1, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	CFIndex cnt = marker & 0x0f;
+	if (0xf == cnt) {
+	    uint64_t bigint = 0;
+	    if (!_readInt(ptr, databytes + objectsRangeEnd, &bigint, &ptr)) FAIL_FALSE;
+	    if (LONG_MAX < bigint) FAIL_FALSE;
+	    cnt = (CFIndex)bigint;
+	}
+	size_t byte_cnt = check_size_t_mul(cnt, trailer->_objectRefSize, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	const uint8_t *extent = check_ptr_add(ptr, byte_cnt, &err) - 1;
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	byte_cnt = check_size_t_mul(cnt, sizeof(CFPropertyListRef), &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	list = (cnt <= 256) ? buffer : (CFPropertyListRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, byte_cnt, __kCFAllocatorGCScannedMemory);
+	listAllocator = (list == buffer ? kCFAllocatorNull : kCFAllocatorSystemDefault);
+	if (!list) FAIL_FALSE;
+	Boolean madeSet = false;
+	if (!set && 15 < curDepth) {
+	    set = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+	    madeSet = set ? true : false;
+	}
+	if (set) CFSetAddValue(set, (const void *)(uintptr_t)startOffset);
+	for (CFIndex idx = 0; idx < cnt; idx++) {
+	    CFPropertyListRef pl;
+	    off = _getOffsetOfRefAt(databytes, ptr, trailer);
+	    if (!__CFBinaryPlistCreateObject2(databytes, datalen, off, trailer, allocator, mutabilityOption, objects, set, curDepth + 1, &pl)) {
+		if (!CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+		    while (idx--) {
+			CFRelease(list[idx]);
+		    }
+		}
+		if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+		FAIL_FALSE;
+	    }
+	    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+		CF_WRITE_BARRIER_BASE_ASSIGN(listAllocator, list, list[idx], CFMakeCollectable(pl));
+	    } else {
+		list[idx] = pl;
+	    }
+	    ptr += trailer->_objectRefSize;
+	}
+	if (set) CFSetRemoveValue(set, (const void *)(uintptr_t)startOffset);
+	if (madeSet) {
+	    CFRelease(set);
+	    set = NULL;
+	}
+	if ((marker & 0xf0) == kCFBinaryPlistMarkerArray) {
+	    *plist = _CFArrayCreate_ex(allocator, (mutabilityOption != kCFPropertyListImmutable), list, cnt);
+	} else {
+	    *plist = _CFSetCreate_ex(allocator, (mutabilityOption != kCFPropertyListImmutable), list, cnt);
+	}
+	if (objects && *plist && (mutabilityOption == kCFPropertyListImmutable)) {
+	    CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	}
+	if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+	return (*plist) ? true : false;
+	}
+    case kCFBinaryPlistMarkerDict: {
+	const uint8_t *ptr = databytes + startOffset;
+	int32_t err = CF_NO_ERROR;
+	ptr = check_ptr_add(ptr, 1, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	CFIndex cnt = marker & 0x0f;
+	if (0xf == cnt) {
+	    uint64_t bigint = 0;
+	    if (!_readInt(ptr, databytes + objectsRangeEnd, &bigint, &ptr)) FAIL_FALSE;
+	    if (LONG_MAX < bigint) FAIL_FALSE;
+	    cnt = (CFIndex)bigint;
+	}
+	cnt = (CFIndex)check_size_t_mul(cnt, 2, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	size_t byte_cnt = check_size_t_mul(cnt, trailer->_objectRefSize, &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	const uint8_t *extent = check_ptr_add(ptr, byte_cnt, &err) - 1;
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	if (databytes + objectsRangeEnd < extent) FAIL_FALSE;
+	byte_cnt = check_size_t_mul(cnt, sizeof(CFPropertyListRef), &err);
+	if (CF_NO_ERROR != err) FAIL_FALSE;
+	list = (cnt <= 256) ? buffer : (CFPropertyListRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, byte_cnt, __kCFAllocatorGCScannedMemory);
+	listAllocator = (list == buffer ? kCFAllocatorNull : kCFAllocatorSystemDefault);
+	if (!list) FAIL_FALSE;
+	Boolean madeSet = false;
+	if (!set && 15 < curDepth) {
+	    set = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+	    madeSet = set ? true : false;
+	}
+	if (set) CFSetAddValue(set, (const void *)(uintptr_t)startOffset);
+	for (CFIndex idx = 0; idx < cnt; idx++) {
+	    CFPropertyListRef pl = NULL;
+	    off = _getOffsetOfRefAt(databytes, ptr, trailer);
+	    if (!__CFBinaryPlistCreateObject2(databytes, datalen, off, trailer, allocator, mutabilityOption, objects, set, curDepth + 1, &pl) || (idx < cnt / 2 && !_plistIsPrimitive(pl))) {
+		if (!CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+		    if (pl) CFRelease(pl);
+		    while (idx--) {
+			CFRelease(list[idx]);
+		    }
+		}
+		if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+		FAIL_FALSE;
+	    }
+	    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+		CF_WRITE_BARRIER_BASE_ASSIGN(listAllocator, list, list[idx], CFMakeCollectable(pl));
+	    } else {
+		list[idx] = pl;
+	    }
+	    ptr += trailer->_objectRefSize;
+	}
+	if (set) CFSetRemoveValue(set, (const void *)(uintptr_t)startOffset);
+	if (madeSet) {
+	    CFRelease(set);
+	    set = NULL;
+	}
+	*plist = _CFDictionaryCreate_ex(allocator, (mutabilityOption != kCFPropertyListImmutable), list, list + cnt / 2, cnt / 2);
+	if (objects && *plist && (mutabilityOption == kCFPropertyListImmutable)) {
+	    CFDictionarySetValue(objects, (const void *)(uintptr_t)startOffset, *plist);
+	}
+	if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+	return (*plist) ? true : false;
+	}
+    }
+    FAIL_FALSE;
+}
+
+bool __CFBinaryPlistCreateObject(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFPropertyListRef *plist) {
+	// for compatibility with Foundation's use, need to leave this here
+    return __CFBinaryPlistCreateObject2(databytes, datalen, startOffset, trailer, allocator, mutabilityOption, objects, NULL, 0, plist);
+}
+
+__private_extern__ bool __CFTryParseBinaryPlist(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFPropertyListRef *plist, CFStringRef *errorString) {
+    uint8_t marker;    
+    CFBinaryPlistTrailer trailer;
+    uint64_t offset;
+    const uint8_t *databytes = CFDataGetBytePtr(data);
+    uint64_t datalen = CFDataGetLength(data);
+
+    if (8 <= datalen && __CFBinaryPlistGetTopLevelInfo(databytes, datalen, &marker, &offset, &trailer)) {
+	// FALSE: We know for binary plist parsing that the result objects will be retained
+	// by their containing collections as the parsing proceeds, so we do not need
+	// to use retaining callbacks for the objects map in this case. WHY: the file might
+	// be malformed and contain hash-equal keys for the same dictionary (for example)
+	// and the later key will cause the previous one to be released when we set the second
+	// in the dictionary.
+	CFMutableDictionaryRef objects = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
+	_CFDictionarySetCapacity(objects, 4000);
+	CFPropertyListRef pl = NULL;
+        if (__CFBinaryPlistCreateObject2(databytes, datalen, offset, &trailer, allocator, option, objects, NULL, 0, &pl)) {
+	    if (plist) *plist = pl;
+        } else {
+	    if (plist) *plist = NULL;
+            if (errorString) *errorString = (CFStringRef)CFRetain(CFSTR("binary data is corrupt"));
+	}
+	CFRelease(objects);
+        return true;
+    }
+    return false;
+}
+
diff --git a/CoreFoundation/CFBitVector.c b/CoreFoundation/CFBitVector.c
new file mode 100644
index 0000000..56a477f
--- /dev/null
+++ b/CoreFoundation/CFBitVector.c
@@ -0,0 +1,556 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFBitVector.h>
+#include "CFInternal.h"
+#include <string.h>
+
+/* The bucket type must be unsigned, at least one byte in size, and
+   a power of 2 in number of bits; bits are numbered from 0 from left
+   to right (bit 0 is the most significant) */
+typedef uint8_t __CFBitVectorBucket;
+
+enum {
+    __CF_BITS_PER_BYTE = 8
+};
+
+enum {
+    __CF_BITS_PER_BUCKET = (__CF_BITS_PER_BYTE * sizeof(__CFBitVectorBucket))
+};
+
+CF_INLINE CFIndex __CFBitVectorRoundUpCapacity(CFIndex capacity) {
+    return ((capacity + 63) / 64) * 64;
+}
+
+CF_INLINE CFIndex __CFBitVectorNumBucketsForCapacity(CFIndex capacity) {
+    return (capacity + __CF_BITS_PER_BUCKET - 1) / __CF_BITS_PER_BUCKET;
+}
+
+struct __CFBitVector {
+    CFRuntimeBase _base;
+    CFIndex _count;	/* number of bits */
+    CFIndex _capacity;	/* maximum number of bits */
+    __CFBitVectorBucket *_buckets;
+};
+
+CF_INLINE UInt32 __CFBitVectorMutableVariety(const void *cf) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 2);
+}
+
+CF_INLINE void __CFBitVectorSetMutableVariety(void *cf, UInt32 v) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 2, v);
+}
+
+CF_INLINE UInt32 __CFBitVectorMutableVarietyFromFlags(UInt32 flags) {
+    return __CFBitfieldGetValue(flags, 1, 0);
+}
+
+// ensure that uses of these inlines are correct, bytes vs. buckets vs. bits
+CF_INLINE CFIndex __CFBitVectorCount(CFBitVectorRef bv) {
+    return bv->_count;
+}
+
+CF_INLINE void __CFBitVectorSetCount(CFMutableBitVectorRef bv, CFIndex v) {
+    bv->_count = v;
+}
+
+CF_INLINE CFIndex __CFBitVectorCapacity(CFBitVectorRef bv) {
+    return bv->_capacity;
+}
+
+CF_INLINE void __CFBitVectorSetCapacity(CFMutableBitVectorRef bv, CFIndex v) {
+    bv->_capacity = v;
+}
+
+CF_INLINE CFIndex __CFBitVectorNumBucketsUsed(CFBitVectorRef bv) {
+    return bv->_count / __CF_BITS_PER_BUCKET + 1;
+}
+
+CF_INLINE void __CFBitVectorSetNumBucketsUsed(CFMutableBitVectorRef bv, CFIndex v) {
+    /* for a CFBitVector, _bucketsUsed == _count / __CF_BITS_PER_BUCKET + 1 */
+}
+
+CF_INLINE CFIndex __CFBitVectorNumBuckets(CFBitVectorRef bv) {
+    return bv->_capacity / __CF_BITS_PER_BUCKET + 1;
+}
+
+CF_INLINE void __CFBitVectorSetNumBuckets(CFMutableBitVectorRef bv, CFIndex v) {
+    /* for a CFBitVector, _bucketsNum == _capacity / __CF_BITS_PER_BUCKET + 1 */
+}
+
+static __CFBitVectorBucket __CFBitBucketMask(CFIndex bottomBit, CFIndex topBit) {
+    CFIndex shiftL = __CF_BITS_PER_BUCKET - topBit + bottomBit - 1;
+    __CFBitVectorBucket result = ~(__CFBitVectorBucket)0;
+    result = (result << shiftL);
+    result = (result >> bottomBit);
+    return result;
+}
+
+CF_INLINE CFBit __CFBitVectorBit(__CFBitVectorBucket *buckets, CFIndex idx) {
+    CFIndex bucketIdx = idx / __CF_BITS_PER_BUCKET;
+    CFIndex bitOfBucket = idx & (__CF_BITS_PER_BUCKET - 1);
+    return (buckets[bucketIdx] >> (__CF_BITS_PER_BUCKET - 1 - bitOfBucket)) & 0x1;
+}
+
+CF_INLINE void __CFSetBitVectorBit(__CFBitVectorBucket *buckets, CFIndex idx, CFBit value) {
+    CFIndex bucketIdx = idx / __CF_BITS_PER_BUCKET;
+    CFIndex bitOfBucket = idx & (__CF_BITS_PER_BUCKET - 1);
+    if (value) {
+	buckets[bucketIdx] |= (1 << (__CF_BITS_PER_BUCKET - 1 - bitOfBucket));
+    } else {
+	buckets[bucketIdx] &= ~(1 << (__CF_BITS_PER_BUCKET - 1 - bitOfBucket));
+    }
+}
+
+CF_INLINE void __CFFlipBitVectorBit(__CFBitVectorBucket *buckets, CFIndex idx) {
+    CFIndex bucketIdx = idx / __CF_BITS_PER_BUCKET;
+    CFIndex bitOfBucket = idx & (__CF_BITS_PER_BUCKET - 1);
+    buckets[bucketIdx] ^= (1 << (__CF_BITS_PER_BUCKET - 1 - bitOfBucket));
+}
+
+#if defined(DEBUG)
+CF_INLINE void __CFBitVectorValidateRange(CFBitVectorRef bv, CFRange range, const char *func) {
+    CFAssert2(0 <= range.location && range.location < __CFBitVectorCount(bv), __kCFLogAssertion, "%s(): range.location index (%d) out of bounds", func, range.location);
+    CFAssert2(0 <= range.length, __kCFLogAssertion, "%s(): range.length (%d) cannot be less than zero", func, range.length);
+    CFAssert2(range.location + range.length <= __CFBitVectorCount(bv), __kCFLogAssertion, "%s(): ending index (%d) out of bounds", func, range.location + range.length);
+}
+#else
+#define __CFBitVectorValidateRange(bf,r,f)
+#endif
+
+static Boolean __CFBitVectorEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFBitVectorRef bv1 = (CFBitVectorRef)cf1;
+    CFBitVectorRef bv2 = (CFBitVectorRef)cf2;
+    CFIndex idx, cnt;
+    cnt = __CFBitVectorCount(bv1);
+    if (cnt != __CFBitVectorCount(bv2)) return false;
+    if (0 == cnt) return true;
+    for (idx = 0; idx < (cnt / __CF_BITS_PER_BUCKET) + 1; idx++) {
+	__CFBitVectorBucket val1 = bv1->_buckets[idx];
+	__CFBitVectorBucket val2 = bv2->_buckets[idx];
+	if (val1 != val2) return false;
+    }
+    return true;
+}
+
+static CFHashCode __CFBitVectorHash(CFTypeRef cf) {
+    CFBitVectorRef bv = (CFBitVectorRef)cf;
+    return __CFBitVectorCount(bv);
+}
+
+static CFStringRef __CFBitVectorCopyDescription(CFTypeRef cf) {
+    CFBitVectorRef bv = (CFBitVectorRef)cf;
+    CFMutableStringRef result;
+    CFIndex idx, cnt;
+    __CFBitVectorBucket *buckets;
+    cnt = __CFBitVectorCount(bv);
+    buckets = bv->_buckets;
+    result = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+    CFStringAppendFormat(result, NULL, CFSTR("<CFBitVector %p [%p]>{count = %u, capacity = %u, objects = (\n"), cf, CFGetAllocator(bv), cnt, __CFBitVectorCapacity(bv));
+    for (idx = 0; idx < (cnt / 64); idx++) {	/* Print groups of 64 */
+	CFIndex idx2;
+	CFStringAppendFormat(result, NULL, CFSTR("\t%u : "), (idx * 64));
+	for (idx2 = 0; idx2 < 64; idx2 += 4) {
+	    CFIndex bucketIdx = (idx << 6) + idx2;
+	    CFStringAppendFormat(result, NULL, CFSTR("%d%d%d%d"),
+		__CFBitVectorBit(buckets, bucketIdx + 0),
+		__CFBitVectorBit(buckets, bucketIdx + 1),
+		__CFBitVectorBit(buckets, bucketIdx + 2),
+		__CFBitVectorBit(buckets, bucketIdx + 3));
+	}
+	CFStringAppend(result, CFSTR("\n"));
+    }
+    if (idx * 64 < cnt) {
+	CFStringAppendFormat(result, NULL, CFSTR("\t%u : "), (idx * 64));
+	for (idx = (idx * 64); idx < cnt; idx++) {	/* Print remainder */
+	    CFStringAppendFormat(result, NULL, CFSTR("%d"), __CFBitVectorBit(buckets, idx));
+	}
+    }
+    CFStringAppend(result, CFSTR("\n)}"));
+    return result;
+}
+
+enum {
+    kCFBitVectorImmutable = 0x0,		/* unchangable and fixed capacity; default */
+    kCFBitVectorMutable = 0x1,		/* changeable and variable capacity */
+    kCFBitVectorFixedMutable = 0x3	/* changeable and fixed capacity */
+};
+
+static void __CFBitVectorDeallocate(CFTypeRef cf) {
+    CFMutableBitVectorRef bv = (CFMutableBitVectorRef)cf;
+    CFAllocatorRef allocator = CFGetAllocator(bv);
+    if (__CFBitVectorMutableVariety(bv) == kCFBitVectorMutable) {
+	_CFAllocatorDeallocateGC(allocator, bv->_buckets);
+    }
+}
+
+static CFTypeID __kCFBitVectorTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFBitVectorClass = {
+    _kCFRuntimeScannedObject,
+    "CFBitVector",
+    NULL,	// init
+    NULL,	// copy
+    __CFBitVectorDeallocate,
+    __CFBitVectorEqual,
+    __CFBitVectorHash,
+    NULL,	// 
+    __CFBitVectorCopyDescription
+};
+
+__private_extern__ void __CFBitVectorInitialize(void) {
+    __kCFBitVectorTypeID = _CFRuntimeRegisterClass(&__CFBitVectorClass);
+}
+
+CFTypeID CFBitVectorGetTypeID(void) {
+    return __kCFBitVectorTypeID;
+}
+
+static CFMutableBitVectorRef __CFBitVectorInit(CFAllocatorRef allocator, CFOptionFlags flags, CFIndex capacity, const uint8_t *bytes, CFIndex numBits) {
+    CFMutableBitVectorRef memory;
+    CFIndex size;
+    CFAssert2(0 <= capacity, __kCFLogAssertion, "%s(): capacity (%d) cannot be less than zero", __PRETTY_FUNCTION__, capacity);
+    CFAssert3(kCFBitVectorFixedMutable != __CFBitVectorMutableVarietyFromFlags(flags) || numBits <= capacity, __kCFLogAssertion, "%s(): for fixed mutable bit vectors, capacity (%d) must be greater than or equal to number of initial elements (%d)", __PRETTY_FUNCTION__, capacity, numBits);
+    CFAssert2(0 <= numBits, __kCFLogAssertion, "%s(): numValues (%d) cannot be less than zero", __PRETTY_FUNCTION__, numBits);
+    size = sizeof(struct __CFBitVector) - sizeof(CFRuntimeBase);
+    if (__CFBitVectorMutableVarietyFromFlags(flags) != kCFBitVectorMutable)
+	size += sizeof(__CFBitVectorBucket) * __CFBitVectorNumBucketsForCapacity(capacity);
+    memory = (CFMutableBitVectorRef)_CFRuntimeCreateInstance(allocator, __kCFBitVectorTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    switch (__CFBitVectorMutableVarietyFromFlags(flags)) {
+    case kCFBitVectorMutable:
+	__CFBitVectorSetCapacity(memory, __CFBitVectorRoundUpCapacity(1));
+	__CFBitVectorSetNumBuckets(memory, __CFBitVectorNumBucketsForCapacity(__CFBitVectorRoundUpCapacity(1)));
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, memory, memory->_buckets, _CFAllocatorAllocateGC(allocator, __CFBitVectorNumBuckets(memory) * sizeof(__CFBitVectorBucket), 0));
+	if (__CFOASafe) __CFSetLastAllocationEventName(memory->_buckets, "CFBitVector (store)");
+	if (NULL == memory->_buckets) {
+	    CFRelease(memory);
+	    return NULL;
+	}
+	break;
+    case kCFBitVectorFixedMutable:
+    case kCFBitVectorImmutable:
+	/* Don't round up capacity */
+	__CFBitVectorSetCapacity(memory, capacity);
+	__CFBitVectorSetNumBuckets(memory, __CFBitVectorNumBucketsForCapacity(capacity));
+	memory->_buckets = (__CFBitVectorBucket *)((int8_t *)memory + sizeof(struct __CFBitVector));
+	break;
+    }
+    __CFBitVectorSetNumBucketsUsed(memory, numBits / __CF_BITS_PER_BUCKET + 1);
+    __CFBitVectorSetCount(memory, numBits);
+    if (bytes) {
+	/* This move is possible because bits are numbered from 0 on the left */
+	memmove(memory->_buckets, bytes, (numBits + __CF_BITS_PER_BYTE - 1) / __CF_BITS_PER_BYTE);
+    }
+    __CFBitVectorSetMutableVariety(memory, __CFBitVectorMutableVarietyFromFlags(flags));
+    return memory;
+}
+
+CFBitVectorRef CFBitVectorCreate(CFAllocatorRef allocator, const uint8_t *bytes, CFIndex numBits) {
+   return __CFBitVectorInit(allocator, kCFBitVectorImmutable, numBits, bytes, numBits);
+}
+
+CFMutableBitVectorRef CFBitVectorCreateMutable(CFAllocatorRef allocator, CFIndex capacity) {
+   return __CFBitVectorInit(allocator, (0 == capacity) ? kCFBitVectorMutable : kCFBitVectorFixedMutable, capacity, NULL, 0);
+}
+
+CFBitVectorRef CFBitVectorCreateCopy(CFAllocatorRef allocator, CFBitVectorRef bv) {
+   __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    return __CFBitVectorInit(allocator, kCFBitVectorImmutable, __CFBitVectorCount(bv), (const uint8_t *)bv->_buckets, __CFBitVectorCount(bv));
+}
+
+CFMutableBitVectorRef CFBitVectorCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFBitVectorRef bv) {
+   __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    return __CFBitVectorInit(allocator, (0 == capacity) ? kCFBitVectorMutable : kCFBitVectorFixedMutable, capacity, (const uint8_t *)bv->_buckets, __CFBitVectorCount(bv));
+}
+
+CFIndex CFBitVectorGetCount(CFBitVectorRef bv) {
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    return __CFBitVectorCount(bv);
+}
+
+typedef __CFBitVectorBucket (*__CFInternalMapper)(__CFBitVectorBucket bucketValue, __CFBitVectorBucket bucketValueMask, void *context);
+
+static void __CFBitVectorInternalMap(CFMutableBitVectorRef bv, CFRange range, __CFInternalMapper mapper, void *context) {
+    CFIndex bucketIdx, bitOfBucket;
+    CFIndex nBuckets;
+    __CFBitVectorBucket bucketValMask, newBucketVal;
+    if (0 == range.length) return;
+    bucketIdx = range.location / __CF_BITS_PER_BUCKET;
+    bitOfBucket = range.location & (__CF_BITS_PER_BUCKET - 1);
+    /* Follow usual pattern of ramping up to a bit bucket boundary ...*/
+    if (bitOfBucket + range.length < __CF_BITS_PER_BUCKET) {
+	bucketValMask = __CFBitBucketMask(bitOfBucket, bitOfBucket + range.length - 1);
+	range.length = 0;
+    } else {
+	bucketValMask = __CFBitBucketMask(bitOfBucket, __CF_BITS_PER_BUCKET - 1);
+	range.length -= __CF_BITS_PER_BUCKET - bitOfBucket;
+    }
+    newBucketVal = mapper(bv->_buckets[bucketIdx], bucketValMask, context);
+    bv->_buckets[bucketIdx] = (bv->_buckets[bucketIdx] & ~bucketValMask) | (newBucketVal & bucketValMask);
+    bucketIdx++;
+    /* ... clipping along with entire bit buckets ... */
+    nBuckets = range.length / __CF_BITS_PER_BUCKET;
+    range.length -= nBuckets * __CF_BITS_PER_BUCKET;
+    while (nBuckets--) {
+	newBucketVal = mapper(bv->_buckets[bucketIdx], ~0, context);
+	bv->_buckets[bucketIdx] = newBucketVal;
+	bucketIdx++;
+    }
+    /* ... and ramping down with the last fragmentary bit bucket. */
+    if (0 != range.length) {
+	bucketValMask = __CFBitBucketMask(0, range.length - 1);
+	newBucketVal = mapper(bv->_buckets[bucketIdx], bucketValMask, context);
+	bv->_buckets[bucketIdx] = (bv->_buckets[bucketIdx] & ~bucketValMask) | (newBucketVal & bucketValMask);
+    }
+}
+
+struct _occursContext {
+    CFBit value;
+    CFIndex count;
+};
+
+static __CFBitVectorBucket __CFBitVectorCountBits(__CFBitVectorBucket bucketValue, __CFBitVectorBucket bucketValueMask, struct _occursContext *context) {
+    static const __CFBitVectorBucket __CFNibbleBitCount[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
+    __CFBitVectorBucket val;
+    CFIndex idx;
+    val = (context->value) ? (bucketValue & bucketValueMask) : (~bucketValue & bucketValueMask);
+    for (idx = 0; idx < (CFIndex)sizeof(__CFBitVectorBucket) * 2; idx++) {
+	context->count += __CFNibbleBitCount[val & 0xF];
+	val = val >> 4;
+    }
+    return bucketValue;
+}
+
+CFIndex CFBitVectorGetCountOfBit(CFBitVectorRef bv, CFRange range, CFBit value) {
+    struct _occursContext context;
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    __CFBitVectorValidateRange(bv, range, __PRETTY_FUNCTION__);
+    if (0 == range.length) return 0;
+    context.value = value;
+    context.count = 0;
+    __CFBitVectorInternalMap((CFMutableBitVectorRef)bv, range, (__CFInternalMapper)__CFBitVectorCountBits, &context);
+    return context.count;
+}
+
+Boolean CFBitVectorContainsBit(CFBitVectorRef bv, CFRange range, CFBit value) {
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    __CFBitVectorValidateRange(bv, range, __PRETTY_FUNCTION__);
+    return (CFBitVectorGetCountOfBit(bv, range, value) != 0) ? true : false;
+}
+
+CFBit CFBitVectorGetBitAtIndex(CFBitVectorRef bv, CFIndex idx) {
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    CFAssert2(0 <= idx && idx < __CFBitVectorCount(bv), __kCFLogAssertion, "%s(): index (%d) out of bounds", __PRETTY_FUNCTION__, idx);
+    return __CFBitVectorBit(bv->_buckets, idx);
+}
+
+struct _getBitsContext {
+    uint8_t *curByte;
+    CFIndex initBits;	/* Bits to extract off the front for the prev. byte */
+    CFIndex totalBits;	/* This is for stopping at the end */
+    bool ignoreFirstInitBits;
+};
+
+static __CFBitVectorBucket __CFBitVectorGetBits(__CFBitVectorBucket bucketValue, __CFBitVectorBucket bucketValueMask, void *ctx) {
+    struct _getBitsContext *context = (struct _getBitsContext *)ctx;
+    __CFBitVectorBucket val;
+    CFIndex nBits;
+    val = bucketValue & bucketValueMask;
+    nBits = __CFMin(__CF_BITS_PER_BUCKET - context->initBits, context->totalBits);
+    /* First initBits bits go in *curByte ... */
+    if (0 < context->initBits) {
+	if (!context->ignoreFirstInitBits) {
+	    *context->curByte |= (uint8_t)(val >> (__CF_BITS_PER_BUCKET - context->initBits));
+	    context->curByte++;
+	    context->totalBits -= context->initBits;
+	    context->ignoreFirstInitBits = false;
+	}
+	val <<= context->initBits;
+    }
+    /* ... then next groups of __CF_BITS_PER_BYTE go in *curByte ... */
+    while (__CF_BITS_PER_BYTE <= nBits) {
+	*context->curByte = (uint8_t)(val >> (__CF_BITS_PER_BUCKET - __CF_BITS_PER_BYTE));
+	context->curByte++;
+	context->totalBits -= context->initBits;
+	nBits -= __CF_BITS_PER_BYTE;
+	val <<= __CF_BITS_PER_BYTE;
+    }
+    /* ... then remaining bits go in *curByte */
+    if (0 < nBits) {
+	*context->curByte = (uint8_t)(val >> (__CF_BITS_PER_BUCKET - __CF_BITS_PER_BYTE));
+	context->totalBits -= nBits;
+    }
+    return bucketValue;
+}
+
+void CFBitVectorGetBits(CFBitVectorRef bv, CFRange range, uint8_t *bytes) {
+    struct _getBitsContext context;
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    __CFBitVectorValidateRange(bv, range, __PRETTY_FUNCTION__);
+    if (0 == range.length) return;
+    context.curByte = bytes;
+    context.initBits = range.location & (__CF_BITS_PER_BUCKET - 1);
+    context.totalBits = range.length;
+    context.ignoreFirstInitBits = true;
+    __CFBitVectorInternalMap((CFMutableBitVectorRef)bv, range, __CFBitVectorGetBits, &context);
+}
+
+CFIndex CFBitVectorGetFirstIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value) {
+    CFIndex idx;
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    __CFBitVectorValidateRange(bv, range, __PRETTY_FUNCTION__);
+    for (idx = 0; idx < range.length; idx++) {
+	if (value == CFBitVectorGetBitAtIndex(bv, range.location + idx)) {
+	    return range.location + idx;
+	}
+    }
+    return kCFNotFound;
+}
+
+CFIndex CFBitVectorGetLastIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value) {
+    CFIndex idx;
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    __CFBitVectorValidateRange(bv, range, __PRETTY_FUNCTION__);
+    for (idx = range.length; idx--;) {
+	if (value == CFBitVectorGetBitAtIndex(bv, range.location + idx)) {
+	    return range.location + idx;
+	}
+    }
+    return kCFNotFound;
+}
+
+static void __CFBitVectorGrow(CFMutableBitVectorRef bv, CFIndex numNewValues) {
+    CFIndex oldCount = __CFBitVectorCount(bv);
+    CFIndex capacity = __CFBitVectorRoundUpCapacity(oldCount + numNewValues);
+    CFAllocatorRef allocator = CFGetAllocator(bv);
+    __CFBitVectorSetCapacity(bv, capacity);
+    __CFBitVectorSetNumBuckets(bv, __CFBitVectorNumBucketsForCapacity(capacity));
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, bv, bv->_buckets, CFAllocatorReallocate(allocator, bv->_buckets, __CFBitVectorNumBuckets(bv) * sizeof(__CFBitVectorBucket), 0));
+    if (__CFOASafe) __CFSetLastAllocationEventName(bv->_buckets, "CFBitVector (store)");
+    if (NULL == bv->_buckets) HALT;
+}
+
+static __CFBitVectorBucket __CFBitVectorZeroBits(__CFBitVectorBucket bucketValue, __CFBitVectorBucket bucketValueMask, void *context) {
+    return 0;
+}
+
+static __CFBitVectorBucket __CFBitVectorOneBits(__CFBitVectorBucket bucketValue, __CFBitVectorBucket bucketValueMask, void *context) {
+    return ~(__CFBitVectorBucket)0;
+}
+
+void CFBitVectorSetCount(CFMutableBitVectorRef bv, CFIndex count) {
+    CFIndex cnt;
+    CFAssert1(__CFBitVectorMutableVariety(bv) == kCFBitVectorMutable || __CFBitVectorMutableVariety(bv) == kCFBitVectorFixedMutable, __kCFLogAssertion, "%s(): bit vector is immutable", __PRETTY_FUNCTION__);
+    cnt = __CFBitVectorCount(bv);
+    switch (__CFBitVectorMutableVariety(bv)) {
+    case kCFBitVectorMutable:
+	if (cnt < count) {
+	    __CFBitVectorGrow(bv, count - cnt);
+	}
+	break;
+    case kCFBitVectorFixedMutable:
+	CFAssert1(count <= __CFBitVectorCapacity(bv), __kCFLogAssertion, "%s(): fixed-capacity bit vector is full", __PRETTY_FUNCTION__);
+	break;
+    }
+    if (cnt < count) {
+	CFRange range = CFRangeMake(cnt, count - cnt);
+        __CFBitVectorInternalMap(bv, range, __CFBitVectorZeroBits, NULL);
+    }
+    __CFBitVectorSetNumBucketsUsed(bv, count / __CF_BITS_PER_BUCKET + 1);
+    __CFBitVectorSetCount(bv, count);
+}
+
+void CFBitVectorFlipBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx) {
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    CFAssert2(0 <= idx && idx < __CFBitVectorCount(bv), __kCFLogAssertion, "%s(): index (%d) out of bounds", __PRETTY_FUNCTION__, idx);
+    CFAssert1(__CFBitVectorMutableVariety(bv) == kCFBitVectorMutable || __CFBitVectorMutableVariety(bv) == kCFBitVectorFixedMutable, __kCFLogAssertion, "%s(): bit vector is immutable", __PRETTY_FUNCTION__);
+    __CFFlipBitVectorBit(bv->_buckets, idx);
+}
+
+static __CFBitVectorBucket __CFBitVectorFlipBits(__CFBitVectorBucket bucketValue, __CFBitVectorBucket bucketValueMask, void *context) {
+    return (~(__CFBitVectorBucket)0) ^ bucketValue;
+}
+
+void CFBitVectorFlipBits(CFMutableBitVectorRef bv, CFRange range) {
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    __CFBitVectorValidateRange(bv, range, __PRETTY_FUNCTION__);
+    CFAssert1(__CFBitVectorMutableVariety(bv) == kCFBitVectorMutable || __CFBitVectorMutableVariety(bv) == kCFBitVectorFixedMutable, __kCFLogAssertion, "%s(): bit vector is immutable", __PRETTY_FUNCTION__);
+    if (0 == range.length) return;
+    __CFBitVectorInternalMap(bv, range, __CFBitVectorFlipBits, NULL);
+}
+
+void CFBitVectorSetBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx, CFBit value) {
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    CFAssert2(0 <= idx && idx < __CFBitVectorCount(bv), __kCFLogAssertion, "%s(): index (%d) out of bounds", __PRETTY_FUNCTION__, idx);
+    CFAssert1(__CFBitVectorMutableVariety(bv) == kCFBitVectorMutable || __CFBitVectorMutableVariety(bv) == kCFBitVectorFixedMutable, __kCFLogAssertion, "%s(): bit vector is immutable", __PRETTY_FUNCTION__);
+    __CFSetBitVectorBit(bv->_buckets, idx, value);
+}
+
+void CFBitVectorSetBits(CFMutableBitVectorRef bv, CFRange range, CFBit value) {
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    __CFBitVectorValidateRange(bv, range, __PRETTY_FUNCTION__);
+    CFAssert1(__CFBitVectorMutableVariety(bv) == kCFBitVectorMutable || __CFBitVectorMutableVariety(bv) == kCFBitVectorFixedMutable, __kCFLogAssertion, "%s(): bit vector is immutable", __PRETTY_FUNCTION__);
+    if (0 == range.length) return;
+    if (value) {
+	__CFBitVectorInternalMap(bv, range, __CFBitVectorOneBits, NULL);
+    } else {
+	__CFBitVectorInternalMap(bv, range, __CFBitVectorZeroBits, NULL);
+    }
+}
+
+void CFBitVectorSetAllBits(CFMutableBitVectorRef bv, CFBit value) {
+    CFIndex nBuckets, leftover;
+    __CFGenericValidateType(bv, __kCFBitVectorTypeID);
+    CFAssert1(__CFBitVectorMutableVariety(bv) == kCFBitVectorMutable || __CFBitVectorMutableVariety(bv) == kCFBitVectorFixedMutable, __kCFLogAssertion, "%s(): bit vector is immutable", __PRETTY_FUNCTION__);
+    nBuckets = __CFBitVectorCount(bv) / __CF_BITS_PER_BUCKET;
+    leftover = __CFBitVectorCount(bv) - nBuckets * __CF_BITS_PER_BUCKET;
+    if (0 < leftover) {
+	CFRange range = CFRangeMake(nBuckets * __CF_BITS_PER_BUCKET, leftover);
+	if (value) {
+	    __CFBitVectorInternalMap(bv, range, __CFBitVectorOneBits, NULL);
+	} else {
+	    __CFBitVectorInternalMap(bv, range, __CFBitVectorZeroBits, NULL);
+	}
+    }
+    memset(bv->_buckets, (value ? ~0 : 0), nBuckets);
+}
+
+#undef __CFBitVectorValidateRange
+
diff --git a/CoreFoundation/CFBitVector.h b/CoreFoundation/CFBitVector.h
new file mode 100644
index 0000000..0cd0a74
--- /dev/null
+++ b/CoreFoundation/CFBitVector.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBITVECTOR__)
+#define __COREFOUNDATION_CFBITVECTOR__ 1
+
+#include <CoreFoundation/CFBase.h>
+
+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
+
+#endif /* ! __COREFOUNDATION_CFBITVECTOR__ */
+
diff --git a/CoreFoundation/CFBuiltinConverters.c b/CoreFoundation/CFBuiltinConverters.c
new file mode 100644
index 0000000..b6e55ae
--- /dev/null
+++ b/CoreFoundation/CFBuiltinConverters.c
@@ -0,0 +1,1206 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFBuiltinConverters.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Aki Inoue
+*/
+
+#include "CFStringEncodingConverterExt.h"
+#include "CFUniChar.h"
+#include "CFUnicodeDecomposition.h"
+#include "CFUnicodePrecomposition.h"
+#include "CFStringEncodingConverterPriv.h"
+#include "CFInternal.h"
+
+#define ParagraphSeparator 0x2029
+#define ASCIINewLine 0x0a
+static int8_t __CFMapsParagraphSeparator = -1;
+
+CF_INLINE bool __CFIsParagraphSeparator(UTF16Char character) {
+    if (-1 == __CFMapsParagraphSeparator) __CFMapsParagraphSeparator = (_CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard) ? false : true);
+
+    return ((__CFMapsParagraphSeparator && (ParagraphSeparator == character)) ? true : false);
+}
+
+/* Precomposition */
+static const uint32_t __CFLatin1CombiningCharBitmap[] = { // 0x300 ~ 0x35FF
+    0xFBB94010, 0x01800000, 0x0000000,
+};
+
+bool CFStringEncodingIsValidCombiningCharacterForLatin1(UniChar character) {
+    return ((character >= 0x300) && (character < 0x360) && (__CFLatin1CombiningCharBitmap[(character - 0x300) / 32] & (1 << (31 - ((character - 0x300) % 32)))) ? true : false);
+}
+
+UniChar CFStringEncodingPrecomposeLatinCharacter(const UniChar *character, CFIndex numChars, CFIndex *usedChars) {
+    if (numChars > 0) {
+        UTF32Char ch = *(character++), nextCh, composedChar;
+        CFIndex usedCharLen = 1;
+
+        if (CFUniCharIsSurrogateHighCharacter(ch) || CFUniCharIsSurrogateLowCharacter(ch)) {
+            if (usedChars) (*usedChars) = usedCharLen;
+            return ch;
+        }
+
+        while (usedCharLen < numChars) {
+            nextCh = *(character++);
+
+            if (CFUniCharIsSurrogateHighCharacter(nextCh) || CFUniCharIsSurrogateLowCharacter(nextCh)) break;
+
+            if (CFUniCharIsMemberOf(nextCh, kCFUniCharNonBaseCharacterSet) && ((composedChar = CFUniCharPrecomposeCharacter(ch, nextCh)) != 0xFFFD)) {
+                if (composedChar > 0xFFFF) { // Non-base
+                    break;
+                } else {
+                    ch = composedChar;
+                }
+            } else {
+                break;
+            }
+            ++usedCharLen;
+        }
+        if (usedChars) (*usedChars) = usedCharLen;
+        return ch;
+    }
+    return 0xFFFD;
+}
+
+/* ASCII */
+static bool __CFToASCII(uint32_t flags, UniChar character, uint8_t *byte) {
+    if (character < 0x80) {
+        *byte = (uint8_t)character;
+    } else if (__CFIsParagraphSeparator(character)) {
+        *byte = ASCIINewLine;
+    } else {
+        return false;
+    }
+    return true;
+}
+
+static bool __CFFromASCII(uint32_t flags, uint8_t byte, UniChar *character) {
+    if (byte < 0x80) {
+        *character = (UniChar)byte;
+        return true;
+    } else {
+        return false;
+    }
+}
+
+
+__private_extern__ const CFStringEncodingConverter __CFConverterASCII = {
+    (void*)__CFToASCII, (void*)__CFFromASCII, 1, 1, kCFStringEncodingConverterCheapEightBit,
+    NULL, NULL, NULL, NULL, NULL, NULL,
+};
+
+/* ISO Latin 1 (8859-1) */
+static bool __CFToISOLatin1(uint32_t flags, UniChar character, uint8_t *byte) {
+    if (character <= 0xFF) {
+        *byte = (uint8_t)character;
+    } else if (__CFIsParagraphSeparator(character)) {
+        *byte = ASCIINewLine;
+    } else {
+        return false;
+    }
+
+    return true;
+}
+
+static bool __CFFromISOLatin1(uint32_t flags, uint8_t byte, UniChar *character) {
+    *character = (UniChar)byte;
+    return true;
+}
+
+static CFIndex __CFToISOLatin1Precompose(uint32_t flags, const UniChar *character, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    uint8_t byte;
+    CFIndex usedCharLen;
+
+    if (__CFToISOLatin1(flags, CFStringEncodingPrecomposeLatinCharacter(character, numChars, &usedCharLen), &byte) && byte && (usedCharLen > 1)) {
+        if (maxByteLen) *bytes = byte;
+        *usedByteLen = 1;
+        return usedCharLen;
+    } else {
+        return 0;
+    }
+}
+
+__private_extern__ const CFStringEncodingConverter __CFConverterISOLatin1 = {
+    (void*)__CFToISOLatin1, (void*)__CFFromISOLatin1, 1, 1, kCFStringEncodingConverterCheapEightBit,
+    NULL, NULL, NULL, NULL, __CFToISOLatin1Precompose, CFStringEncodingIsValidCombiningCharacterForLatin1,
+};
+
+/* Mac Roman */
+#define NUM_MACROMAN_FROM_UNI 129
+static const CFStringEncodingUnicodeTo8BitCharMap macRoman_from_uni[NUM_MACROMAN_FROM_UNI] = {
+    { 0x00A0, 0xCA }, /* NO-BREAK SPACE */
+    { 0x00A1, 0xC1 }, /* INVERTED EXCLAMATION MARK */
+    { 0x00A2, 0xA2 }, /* CENT SIGN */
+    { 0x00A3, 0xA3 }, /* POUND SIGN */
+    { 0x00A5, 0xB4 }, /* YEN SIGN */
+    { 0x00A7, 0xA4 }, /* SECTION SIGN */
+    { 0x00A8, 0xAC }, /* DIAERESIS */
+    { 0x00A9, 0xA9 }, /* COPYRIGHT SIGN */
+    { 0x00AA, 0xBB }, /* FEMININE ORDINAL INDICATOR */
+    { 0x00AB, 0xC7 }, /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
+    { 0x00AC, 0xC2 }, /* NOT SIGN */
+    { 0x00AE, 0xA8 }, /* REGISTERED SIGN */
+    { 0x00AF, 0xF8 }, /* MACRON */
+    { 0x00B0, 0xA1 }, /* DEGREE SIGN */
+    { 0x00B1, 0xB1 }, /* PLUS-MINUS SIGN */
+    { 0x00B4, 0xAB }, /* ACUTE ACCENT */
+    { 0x00B5, 0xB5 }, /* MICRO SIGN */
+    { 0x00B6, 0xA6 }, /* PILCROW SIGN */
+    { 0x00B7, 0xE1 }, /* MIDDLE DOT */
+    { 0x00B8, 0xFC }, /* CEDILLA */
+    { 0x00BA, 0xBC }, /* MASCULINE ORDINAL INDICATOR */
+    { 0x00BB, 0xC8 }, /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
+    { 0x00BF, 0xC0 }, /* INVERTED QUESTION MARK */
+    { 0x00C0, 0xCB }, /* LATIN CAPITAL LETTER A WITH GRAVE */
+    { 0x00C1, 0xE7 }, /* LATIN CAPITAL LETTER A WITH ACUTE */
+    { 0x00C2, 0xE5 }, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
+    { 0x00C3, 0xCC }, /* LATIN CAPITAL LETTER A WITH TILDE */
+    { 0x00C4, 0x80 }, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
+    { 0x00C5, 0x81 }, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
+    { 0x00C6, 0xAE }, /* LATIN CAPITAL LIGATURE AE */
+    { 0x00C7, 0x82 }, /* LATIN CAPITAL LETTER C WITH CEDILLA */
+    { 0x00C8, 0xE9 }, /* LATIN CAPITAL LETTER E WITH GRAVE */
+    { 0x00C9, 0x83 }, /* LATIN CAPITAL LETTER E WITH ACUTE */
+    { 0x00CA, 0xE6 }, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
+    { 0x00CB, 0xE8 }, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
+    { 0x00CC, 0xED }, /* LATIN CAPITAL LETTER I WITH GRAVE */
+    { 0x00CD, 0xEA }, /* LATIN CAPITAL LETTER I WITH ACUTE */
+    { 0x00CE, 0xEB }, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
+    { 0x00CF, 0xEC }, /* LATIN CAPITAL LETTER I WITH DIAERESIS */
+    { 0x00D1, 0x84 }, /* LATIN CAPITAL LETTER N WITH TILDE */
+    { 0x00D2, 0xF1 }, /* LATIN CAPITAL LETTER O WITH GRAVE */
+    { 0x00D3, 0xEE }, /* LATIN CAPITAL LETTER O WITH ACUTE */
+    { 0x00D4, 0xEF }, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
+    { 0x00D5, 0xCD }, /* LATIN CAPITAL LETTER O WITH TILDE */
+    { 0x00D6, 0x85 }, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
+    { 0x00D8, 0xAF }, /* LATIN CAPITAL LETTER O WITH STROKE */
+    { 0x00D9, 0xF4 }, /* LATIN CAPITAL LETTER U WITH GRAVE */
+    { 0x00DA, 0xF2 }, /* LATIN CAPITAL LETTER U WITH ACUTE */
+    { 0x00DB, 0xF3 }, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
+    { 0x00DC, 0x86 }, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
+    { 0x00DF, 0xA7 }, /* LATIN SMALL LETTER SHARP S */
+    { 0x00E0, 0x88 }, /* LATIN SMALL LETTER A WITH GRAVE */
+    { 0x00E1, 0x87 }, /* LATIN SMALL LETTER A WITH ACUTE */
+    { 0x00E2, 0x89 }, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
+    { 0x00E3, 0x8B }, /* LATIN SMALL LETTER A WITH TILDE */
+    { 0x00E4, 0x8A }, /* LATIN SMALL LETTER A WITH DIAERESIS */
+    { 0x00E5, 0x8C }, /* LATIN SMALL LETTER A WITH RING ABOVE */
+    { 0x00E6, 0xBE }, /* LATIN SMALL LIGATURE AE */
+    { 0x00E7, 0x8D }, /* LATIN SMALL LETTER C WITH CEDILLA */
+    { 0x00E8, 0x8F }, /* LATIN SMALL LETTER E WITH GRAVE */
+    { 0x00E9, 0x8E }, /* LATIN SMALL LETTER E WITH ACUTE */
+    { 0x00EA, 0x90 }, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
+    { 0x00EB, 0x91 }, /* LATIN SMALL LETTER E WITH DIAERESIS */
+    { 0x00EC, 0x93 }, /* LATIN SMALL LETTER I WITH GRAVE */
+    { 0x00ED, 0x92 }, /* LATIN SMALL LETTER I WITH ACUTE */
+    { 0x00EE, 0x94 }, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
+    { 0x00EF, 0x95 }, /* LATIN SMALL LETTER I WITH DIAERESIS */
+    { 0x00F1, 0x96 }, /* LATIN SMALL LETTER N WITH TILDE */
+    { 0x00F2, 0x98 }, /* LATIN SMALL LETTER O WITH GRAVE */
+    { 0x00F3, 0x97 }, /* LATIN SMALL LETTER O WITH ACUTE */
+    { 0x00F4, 0x99 }, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
+    { 0x00F5, 0x9B }, /* LATIN SMALL LETTER O WITH TILDE */
+    { 0x00F6, 0x9A }, /* LATIN SMALL LETTER O WITH DIAERESIS */
+    { 0x00F7, 0xD6 }, /* DIVISION SIGN */
+    { 0x00F8, 0xBF }, /* LATIN SMALL LETTER O WITH STROKE */
+    { 0x00F9, 0x9D }, /* LATIN SMALL LETTER U WITH GRAVE */
+    { 0x00FA, 0x9C }, /* LATIN SMALL LETTER U WITH ACUTE */
+    { 0x00FB, 0x9E }, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */
+    { 0x00FC, 0x9F }, /* LATIN SMALL LETTER U WITH DIAERESIS */
+    { 0x00FF, 0xD8 }, /* LATIN SMALL LETTER Y WITH DIAERESIS */
+    { 0x0131, 0xF5 }, /* LATIN SMALL LETTER DOTLESS I */
+    { 0x0152, 0xCE }, /* LATIN CAPITAL LIGATURE OE */
+    { 0x0153, 0xCF }, /* LATIN SMALL LIGATURE OE */
+    { 0x0178, 0xD9 }, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */
+    { 0x0192, 0xC4 }, /* LATIN SMALL LETTER F WITH HOOK */
+    { 0x02C6, 0xF6 }, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+    { 0x02C7, 0xFF }, /* CARON */
+    { 0x02D8, 0xF9 }, /* BREVE */
+    { 0x02D9, 0xFA }, /* DOT ABOVE */
+    { 0x02DA, 0xFB }, /* RING ABOVE */
+    { 0x02DB, 0xFE }, /* OGONEK */
+    { 0x02DC, 0xF7 }, /* SMALL TILDE */
+    { 0x02DD, 0xFD }, /* DOUBLE ACUTE ACCENT */
+    { 0x03A9, 0xBD }, /* OHM SIGN (Canonical ?) */
+    { 0x03C0, 0xB9 }, /* GREEK SMALL LETTER PI */
+    { 0x2013, 0xD0 }, /* EN DASH */
+    { 0x2014, 0xD1 }, /* EM DASH */
+    { 0x2018, 0xD4 }, /* LEFT SINGLE QUOTATION MARK */
+    { 0x2019, 0xD5 }, /* RIGHT SINGLE QUOTATION MARK */
+    { 0x201A, 0xE2 }, /* SINGLE LOW-9 QUOTATION MARK */
+    { 0x201C, 0xD2 }, /* LEFT DOUBLE QUOTATION MARK */
+    { 0x201D, 0xD3 }, /* RIGHT DOUBLE QUOTATION MARK */
+    { 0x201E, 0xE3 }, /* DOUBLE LOW-9 QUOTATION MARK */
+    { 0x2020, 0xA0 }, /* DAGGER */
+    { 0x2021, 0xE0 }, /* DOUBLE DAGGER */
+    { 0x2022, 0xA5 }, /* BULLET */
+    { 0x2026, 0xC9 }, /* HORIZONTAL ELLIPSIS */
+    { 0x2030, 0xE4 }, /* PER MILLE SIGN */
+    { 0x2039, 0xDC }, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */
+    { 0x203A, 0xDD }, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
+    { 0x2044, 0xDA }, /* FRACTION SLASH */
+    { 0x20AC, 0xDB }, /* EURO SIGN */
+    { 0x2122, 0xAA }, /* TRADE MARK SIGN */
+    { 0x2126, 0xBD }, /* OHM SIGN */
+    { 0x2202, 0xB6 }, /* PARTIAL DIFFERENTIAL */
+    { 0x2206, 0xC6 }, /* INCREMENT */
+    { 0x220F, 0xB8 }, /* N-ARY PRODUCT */
+    { 0x2211, 0xB7 }, /* N-ARY SUMMATION */
+    { 0x221A, 0xC3 }, /* SQUARE ROOT */
+    { 0x221E, 0xB0 }, /* INFINITY */
+    { 0x222B, 0xBA }, /* INTEGRAL */
+    { 0x2248, 0xC5 }, /* ALMOST EQUAL TO */
+    { 0x2260, 0xAD }, /* NOT EQUAL TO */
+    { 0x2264, 0xB2 }, /* LESS-THAN OR EQUAL TO */
+    { 0x2265, 0xB3 }, /* GREATER-THAN OR EQUAL TO */
+    { 0x25CA, 0xD7 }, /* LOZENGE */
+    { 0xF8FF, 0xF0 }, /* Apple logo */
+    { 0xFB01, 0xDE }, /* LATIN SMALL LIGATURE FI */
+    { 0xFB02, 0xDF }, /* LATIN SMALL LIGATURE FL */
+};
+
+static bool __CFToMacRoman(uint32_t flags, UniChar character, uint8_t *byte) {
+    if (character < 0x80) {
+        *byte = (uint8_t)character;
+        return true;
+    } else {
+        return CFStringEncodingUnicodeTo8BitEncoding(macRoman_from_uni, NUM_MACROMAN_FROM_UNI, character, byte);
+    }
+}
+
+static const UniChar macRoman_to_uni[128] = {
+    0x00C4, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
+    0x00C5, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
+    0x00C7, /* LATIN CAPITAL LETTER C WITH CEDILLA */
+    0x00C9, /* LATIN CAPITAL LETTER E WITH ACUTE */
+    0x00D1, /* LATIN CAPITAL LETTER N WITH TILDE */
+    0x00D6, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
+    0x00DC, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
+    0x00E1, /* LATIN SMALL LETTER A WITH ACUTE */
+    0x00E0, /* LATIN SMALL LETTER A WITH GRAVE */
+    0x00E2, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
+    0x00E4, /* LATIN SMALL LETTER A WITH DIAERESIS */
+    0x00E3, /* LATIN SMALL LETTER A WITH TILDE */
+    0x00E5, /* LATIN SMALL LETTER A WITH RING ABOVE */
+    0x00E7, /* LATIN SMALL LETTER C WITH CEDILLA */
+    0x00E9, /* LATIN SMALL LETTER E WITH ACUTE */
+    0x00E8, /* LATIN SMALL LETTER E WITH GRAVE */
+    0x00EA, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
+    0x00EB, /* LATIN SMALL LETTER E WITH DIAERESIS */
+    0x00ED, /* LATIN SMALL LETTER I WITH ACUTE */
+    0x00EC, /* LATIN SMALL LETTER I WITH GRAVE */
+    0x00EE, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
+    0x00EF, /* LATIN SMALL LETTER I WITH DIAERESIS */
+    0x00F1, /* LATIN SMALL LETTER N WITH TILDE */
+    0x00F3, /* LATIN SMALL LETTER O WITH ACUTE */
+    0x00F2, /* LATIN SMALL LETTER O WITH GRAVE */
+    0x00F4, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
+    0x00F6, /* LATIN SMALL LETTER O WITH DIAERESIS */
+    0x00F5, /* LATIN SMALL LETTER O WITH TILDE */
+    0x00FA, /* LATIN SMALL LETTER U WITH ACUTE */
+    0x00F9, /* LATIN SMALL LETTER U WITH GRAVE */
+    0x00FB, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */
+    0x00FC, /* LATIN SMALL LETTER U WITH DIAERESIS */
+    0x2020, /* DAGGER */
+    0x00B0, /* DEGREE SIGN */
+    0x00A2, /* CENT SIGN */
+    0x00A3, /* POUND SIGN */
+    0x00A7, /* SECTION SIGN */
+    0x2022, /* BULLET */
+    0x00B6, /* PILCROW SIGN */
+    0x00DF, /* LATIN SMALL LETTER SHARP S */
+    0x00AE, /* REGISTERED SIGN */
+    0x00A9, /* COPYRIGHT SIGN */
+    0x2122, /* TRADE MARK SIGN */
+    0x00B4, /* ACUTE ACCENT */
+    0x00A8, /* DIAERESIS */
+    0x2260, /* NOT EQUAL TO */
+    0x00C6, /* LATIN CAPITAL LIGATURE AE */
+    0x00D8, /* LATIN CAPITAL LETTER O WITH STROKE */
+    0x221E, /* INFINITY */
+    0x00B1, /* PLUS-MINUS SIGN */
+    0x2264, /* LESS-THAN OR EQUAL TO */
+    0x2265, /* GREATER-THAN OR EQUAL TO */
+    0x00A5, /* YEN SIGN */
+    0x00B5, /* MICRO SIGN */
+    0x2202, /* PARTIAL DIFFERENTIAL */
+    0x2211, /* N-ARY SUMMATION */
+    0x220F, /* N-ARY PRODUCT */
+    0x03C0, /* GREEK SMALL LETTER PI */
+    0x222B, /* INTEGRAL */
+    0x00AA, /* FEMININE ORDINAL INDICATOR */
+    0x00BA, /* MASCULINE ORDINAL INDICATOR */
+    0x03A9, /* OHM SIGN (Canonical mapping) */
+    0x00E6, /* LATIN SMALL LIGATURE AE */
+    0x00F8, /* LATIN SMALL LETTER O WITH STROKE */
+    0x00BF, /* INVERTED QUESTION MARK */
+    0x00A1, /* INVERTED EXCLAMATION MARK */
+    0x00AC, /* NOT SIGN */
+    0x221A, /* SQUARE ROOT */
+    0x0192, /* LATIN SMALL LETTER F WITH HOOK */
+    0x2248, /* ALMOST EQUAL TO */
+    0x2206, /* INCREMENT */
+    0x00AB, /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
+    0x00BB, /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
+    0x2026, /* HORIZONTAL ELLIPSIS */
+    0x00A0, /* NO-BREAK SPACE */
+    0x00C0, /* LATIN CAPITAL LETTER A WITH GRAVE */
+    0x00C3, /* LATIN CAPITAL LETTER A WITH TILDE */
+    0x00D5, /* LATIN CAPITAL LETTER O WITH TILDE */
+    0x0152, /* LATIN CAPITAL LIGATURE OE */
+    0x0153, /* LATIN SMALL LIGATURE OE */
+    0x2013, /* EN DASH */
+    0x2014, /* EM DASH */
+    0x201C, /* LEFT DOUBLE QUOTATION MARK */
+    0x201D, /* RIGHT DOUBLE QUOTATION MARK */
+    0x2018, /* LEFT SINGLE QUOTATION MARK */
+    0x2019, /* RIGHT SINGLE QUOTATION MARK */
+    0x00F7, /* DIVISION SIGN */
+    0x25CA, /* LOZENGE */
+    0x00FF, /* LATIN SMALL LETTER Y WITH DIAERESIS */
+    0x0178, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */
+    0x2044, /* FRACTION SLASH */
+    0x20AC, /* EURO SIGN */
+    0x2039, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */
+    0x203A, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
+    0xFB01, /* LATIN SMALL LIGATURE FI */
+    0xFB02, /* LATIN SMALL LIGATURE FL */
+    0x2021, /* DOUBLE DAGGER */
+    0x00B7, /* MIDDLE DOT */
+    0x201A, /* SINGLE LOW-9 QUOTATION MARK */
+    0x201E, /* DOUBLE LOW-9 QUOTATION MARK */
+    0x2030, /* PER MILLE SIGN */
+    0x00C2, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
+    0x00CA, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
+    0x00C1, /* LATIN CAPITAL LETTER A WITH ACUTE */
+    0x00CB, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
+    0x00C8, /* LATIN CAPITAL LETTER E WITH GRAVE */
+    0x00CD, /* LATIN CAPITAL LETTER I WITH ACUTE */
+    0x00CE, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
+    0x00CF, /* LATIN CAPITAL LETTER I WITH DIAERESIS */
+    0x00CC, /* LATIN CAPITAL LETTER I WITH GRAVE */
+    0x00D3, /* LATIN CAPITAL LETTER O WITH ACUTE */
+    0x00D4, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
+    0xF8FF, /* Apple logo */
+    0x00D2, /* LATIN CAPITAL LETTER O WITH GRAVE */
+    0x00DA, /* LATIN CAPITAL LETTER U WITH ACUTE */
+    0x00DB, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
+    0x00D9, /* LATIN CAPITAL LETTER U WITH GRAVE */
+    0x0131, /* LATIN SMALL LETTER DOTLESS I */
+    0x02C6, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+    0x02DC, /* SMALL TILDE */
+    0x00AF, /* MACRON */
+    0x02D8, /* BREVE */
+    0x02D9, /* DOT ABOVE */
+    0x02DA, /* RING ABOVE */
+    0x00B8, /* CEDILLA */
+    0x02DD, /* DOUBLE ACUTE ACCENT */
+    0x02DB, /* OGONEK */
+    0x02C7, /* CARON */
+};
+
+static bool __CFFromMacRoman(uint32_t flags, uint8_t byte, UniChar *character) {
+    *character = (byte < 0x80 ? (UniChar)byte : macRoman_to_uni[byte - 0x80]);
+    return true;
+}
+
+static CFIndex __CFToMacRomanPrecompose(uint32_t flags, const UniChar *character, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    uint8_t byte;
+    CFIndex usedCharLen;
+
+    if (__CFToMacRoman(flags, CFStringEncodingPrecomposeLatinCharacter(character, numChars, &usedCharLen), &byte) && byte && (usedCharLen > 1)) {
+        if (maxByteLen) *bytes = byte;
+        *usedByteLen = 1;
+        return usedCharLen;
+    } else {
+        return 0;
+    }
+}
+
+__private_extern__ const CFStringEncodingConverter __CFConverterMacRoman = {
+    (void*)__CFToMacRoman, (void*)__CFFromMacRoman, 1, 1, kCFStringEncodingConverterCheapEightBit,
+    NULL, NULL, NULL, NULL, __CFToMacRomanPrecompose, CFStringEncodingIsValidCombiningCharacterForLatin1,
+};
+
+/* Win Latin1 (ANSI CodePage 1252) */
+#define NUM_1252_FROM_UNI 27
+static const CFStringEncodingUnicodeTo8BitCharMap cp1252_from_uni[NUM_1252_FROM_UNI] = {
+    {0x0152, 0x8C}, // LATIN CAPITAL LIGATURE OE
+    {0x0153, 0x9C}, // LATIN SMALL LIGATURE OE
+    {0x0160, 0x8A}, // LATIN CAPITAL LETTER S WITH CARON
+    {0x0161, 0x9A}, // LATIN SMALL LETTER S WITH CARON
+    {0x0178, 0x9F}, // LATIN CAPITAL LETTER Y WITH DIAERESIS
+    {0x017D, 0x8E}, // LATIN CAPITAL LETTER Z WITH CARON
+    {0x017E, 0x9E}, // LATIN SMALL LETTER Z WITH CARON
+    {0x0192, 0x83}, // LATIN SMALL LETTER F WITH HOOK
+    {0x02C6, 0x88}, // MODIFIER LETTER CIRCUMFLEX ACCENT
+    {0x02DC, 0x98}, // SMALL TILDE
+    {0x2013, 0x96}, // EN DASH
+    {0x2014, 0x97}, // EM DASH
+    {0x2018, 0x91}, // LEFT SINGLE QUOTATION MARK
+    {0x2019, 0x92}, // RIGHT SINGLE QUOTATION MARK
+    {0x201A, 0x82}, // SINGLE LOW-9 QUOTATION MARK
+    {0x201C, 0x93}, // LEFT DOUBLE QUOTATION MARK
+    {0x201D, 0x94}, // RIGHT DOUBLE QUOTATION MARK
+    {0x201E, 0x84}, // DOUBLE LOW-9 QUOTATION MARK
+    {0x2020, 0x86}, // DAGGER
+    {0x2021, 0x87}, // DOUBLE DAGGER
+    {0x2022, 0x95}, // BULLET
+    {0x2026, 0x85}, // HORIZONTAL ELLIPSIS
+    {0x2030, 0x89}, // PER MILLE SIGN
+    {0x2039, 0x8B}, // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+    {0x203A, 0x9B}, // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+    {0x20AC, 0x80}, // EURO SIGN
+    {0x2122, 0x99}, // TRADE MARK SIGN
+};
+
+static bool __CFToWinLatin1(uint32_t flags, UniChar character, uint8_t *byte) {
+    if ((character < 0x80) || ((character > 0x9F) && (character <= 0x00FF))) {
+        *byte = (uint8_t)character;
+        return true;
+    }
+    return CFStringEncodingUnicodeTo8BitEncoding(cp1252_from_uni, NUM_1252_FROM_UNI, character, byte);
+}
+
+static const uint16_t cp1252_to_uni[32] = {
+    0x20AC, //  EURO SIGN
+    0xFFFD, //  NOT USED
+    0x201A, //  SINGLE LOW-9 QUOTATION MARK
+    0x0192, //  LATIN SMALL LETTER F WITH HOOK
+    0x201E, //  DOUBLE LOW-9 QUOTATION MARK
+    0x2026, //  HORIZONTAL ELLIPSIS
+    0x2020, //  DAGGER
+    0x2021, //  DOUBLE DAGGER
+    0x02C6, //  MODIFIER LETTER CIRCUMFLEX ACCENT
+    0x2030, //  PER MILLE SIGN
+    0x0160, //  LATIN CAPITAL LETTER S WITH CARON
+    0x2039, //  SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+    0x0152, //  LATIN CAPITAL LIGATURE OE
+    0xFFFD, //  NOT USED
+    0x017D, //  LATIN CAPITAL LETTER Z WITH CARON
+    0xFFFD, //  NOT USED
+    0xFFFD, //  NOT USED
+    0x2018, //  LEFT SINGLE QUOTATION MARK
+    0x2019, //  RIGHT SINGLE QUOTATION MARK
+    0x201C, //  LEFT DOUBLE QUOTATION MARK
+    0x201D, //  RIGHT DOUBLE QUOTATION MARK
+    0x2022, //  BULLET
+    0x2013, //  EN DASH
+    0x2014, //  EM DASH
+    0x02DC, //  SMALL TILDE
+    0x2122, //  TRADE MARK SIGN
+    0x0161, //  LATIN SMALL LETTER S WITH CARON
+    0x203A, //  SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+    0x0153, //  LATIN SMALL LIGATURE OE
+    0xFFFD, //  NOT USED
+    0x017E, //  LATIN SMALL LETTER Z WITH CARON
+    0x0178, //  LATIN CAPITAL LETTER Y WITH DIAERESIS
+};
+
+static bool __CFFromWinLatin1(uint32_t flags, uint8_t byte, UniChar *character) {
+    *character = (byte < 0x80 || byte > 0x9F ? (UniChar)byte : cp1252_to_uni[byte - 0x80]);
+    return (*character != 0xFFFD);
+}
+
+static CFIndex __CFToWinLatin1Precompose(uint32_t flags, const UniChar *character, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    uint8_t byte;
+    CFIndex usedCharLen;
+
+    if (__CFToWinLatin1(flags, CFStringEncodingPrecomposeLatinCharacter(character, numChars, &usedCharLen), &byte) && byte && (usedCharLen > 1)) {
+        if (maxByteLen) *bytes = byte;
+        *usedByteLen = 1;
+        return usedCharLen;
+    } else {
+        return 0;
+    }
+}
+
+__private_extern__ const CFStringEncodingConverter __CFConverterWinLatin1 = {
+    (void*)__CFToWinLatin1, (void*)__CFFromWinLatin1, 1, 1, kCFStringEncodingConverterCheapEightBit,
+    NULL, NULL, NULL, NULL, __CFToWinLatin1Precompose, CFStringEncodingIsValidCombiningCharacterForLatin1,
+};
+
+/* NEXTSTEP Encoding */
+#define NUM_NEXTSTEP_FROM_UNI	127
+
+static const CFStringEncodingUnicodeTo8BitCharMap nextstep_from_tab[NUM_NEXTSTEP_FROM_UNI] = {
+        { 0x00a0, 0x80 },
+        { 0x00a1, 0xa1 },
+        { 0x00a2, 0xa2 },
+        { 0x00a3, 0xa3 },
+        { 0x00a4, 0xa8 },
+        { 0x00a5, 0xa5 },
+        { 0x00a6, 0xb5 },
+        { 0x00a7, 0xa7 },
+        { 0x00a8, 0xc8 },
+        { 0x00a9, 0xa0 },
+        { 0x00aa, 0xe3 },
+        { 0x00ab, 0xab },
+        { 0x00ac, 0xbe },
+/*	{ 0x00ad, 0x2d }, <= 96/10/25 rick removed; converts soft-hyphen to hyphen! */
+        { 0x00ae, 0xb0 },
+        { 0x00af, 0xc5 },
+        { 0x00b1, 0xd1 },
+        { 0x00b2, 0xc9 },
+        { 0x00b3, 0xcc },
+        { 0x00b4, 0xc2 },
+        { 0x00b5, 0x9d },
+        { 0x00b6, 0xb6 },
+        { 0x00b7, 0xb4 },
+        { 0x00b8, 0xcb },
+        { 0x00b9, 0xc0 },
+        { 0x00ba, 0xeb },
+        { 0x00bb, 0xbb },
+        { 0x00bc, 0xd2 },
+        { 0x00bd, 0xd3 },
+        { 0x00be, 0xd4 },
+        { 0x00bf, 0xbf },
+        { 0x00c0, 0x81 },
+        { 0x00c1, 0x82 },
+        { 0x00c2, 0x83 },
+        { 0x00c3, 0x84 },
+        { 0x00c4, 0x85 },
+        { 0x00c5, 0x86 },
+        { 0x00c6, 0xe1 },
+        { 0x00c7, 0x87 },
+        { 0x00c8, 0x88 },
+        { 0x00c9, 0x89 },
+        { 0x00ca, 0x8a },
+        { 0x00cb, 0x8b },
+        { 0x00cc, 0x8c },
+        { 0x00cd, 0x8d },
+        { 0x00ce, 0x8e },
+        { 0x00cf, 0x8f },
+        { 0x00d0, 0x90 },
+        { 0x00d1, 0x91 },
+        { 0x00d2, 0x92 },
+        { 0x00d3, 0x93 },
+        { 0x00d4, 0x94 },
+        { 0x00d5, 0x95 },
+        { 0x00d6, 0x96 },
+        { 0x00d7, 0x9e },
+        { 0x00d8, 0xe9 },
+        { 0x00d9, 0x97 },
+        { 0x00da, 0x98 },
+        { 0x00db, 0x99 },
+        { 0x00dc, 0x9a },
+        { 0x00dd, 0x9b },
+        { 0x00de, 0x9c },
+        { 0x00df, 0xfb },
+        { 0x00e0, 0xd5 },
+        { 0x00e1, 0xd6 },
+        { 0x00e2, 0xd7 },
+        { 0x00e3, 0xd8 },
+        { 0x00e4, 0xd9 },
+        { 0x00e5, 0xda },
+        { 0x00e6, 0xf1 },
+        { 0x00e7, 0xdb },
+        { 0x00e8, 0xdc },
+        { 0x00e9, 0xdd },
+        { 0x00ea, 0xde },
+        { 0x00eb, 0xdf },
+        { 0x00ec, 0xe0 },
+        { 0x00ed, 0xe2 },
+        { 0x00ee, 0xe4 },
+        { 0x00ef, 0xe5 },
+        { 0x00f0, 0xe6 },
+        { 0x00f1, 0xe7 },
+        { 0x00f2, 0xec },
+        { 0x00f3, 0xed },
+        { 0x00f4, 0xee },
+        { 0x00f5, 0xef },
+        { 0x00f6, 0xf0 },
+        { 0x00f7, 0x9f },
+        { 0x00f8, 0xf9 },
+        { 0x00f9, 0xf2 },
+        { 0x00fa, 0xf3 },
+        { 0x00fb, 0xf4 },
+        { 0x00fc, 0xf6 },
+        { 0x00fd, 0xf7 },
+        { 0x00fe, 0xfc },
+        { 0x00ff, 0xfd },
+        { 0x0131, 0xf5 },
+        { 0x0141, 0xe8 },
+        { 0x0142, 0xf8 },
+        { 0x0152, 0xea },
+        { 0x0153, 0xfa },
+        { 0x0192, 0xa6 },
+        { 0x02c6, 0xc3 },
+        { 0x02c7, 0xcf },
+        { 0x02cb, 0xc1 },
+        { 0x02d8, 0xc6 },
+        { 0x02d9, 0xc7 },
+        { 0x02da, 0xca },
+        { 0x02db, 0xce },
+        { 0x02dc, 0xc4 },
+        { 0x02dd, 0xcd },
+        { 0x2013, 0xb1 },
+        { 0x2014, 0xd0 },
+        { 0x2019, 0xa9 },
+        { 0x201a, 0xb8 },
+        { 0x201c, 0xaa },
+        { 0x201d, 0xba },
+        { 0x201e, 0xb9 },
+        { 0x2020, 0xb2 },
+        { 0x2021, 0xb3 },
+        { 0x2022, 0xb7 },
+        { 0x2026, 0xbc },
+        { 0x2030, 0xbd },
+        { 0x2039, 0xac },
+        { 0x203a, 0xad },
+        { 0x2044, 0xa4 },
+        { 0xfb01, 0xae },
+        { 0xfb02, 0xaf },
+        { 0xfffd, 0xff },
+};
+
+static bool __CFToNextStepLatin(uint32_t flags, UniChar character, uint8_t *byte) {
+    if (character < 0x80) {
+        *byte = (uint8_t)character;
+        return true;
+    } else if (__CFIsParagraphSeparator(character)) {
+        *byte = ASCIINewLine;
+        return true;
+    } else {
+        return CFStringEncodingUnicodeTo8BitEncoding(nextstep_from_tab, NUM_NEXTSTEP_FROM_UNI, character, byte);
+    }
+};
+
+static const UniChar NSToPrecompUnicodeTable[128] = {
+        /* NextStep Encoding	Unicode */
+        /*  128	figspace */	0x00a0,		/* 0x2007 is fig space */
+        /*  129	Agrave */	0x00c0,
+        /*  130	Aacute */	0x00c1,
+        /*  131	Acircumflex */	0x00c2,
+        /*  132	Atilde */	0x00c3,
+        /*  133	Adieresis */	0x00c4,
+        /*  134	Aring */	0x00c5,
+        /*  135	Ccedilla */	0x00c7,
+        /*  136	Egrave */	0x00c8,
+        /*  137	Eacute */	0x00c9,
+        /*  138	Ecircumflex */	0x00ca,
+        /*  139	Edieresis */	0x00cb,
+        /*  140	Igrave */	0x00cc,
+        /*  141	Iacute */	0x00cd,
+        /*  142	Icircumflex */	0x00ce,
+        /*  143	Idieresis */	0x00cf,
+        /*  144	Eth */		0x00d0,
+        /*  145	Ntilde */	0x00d1,
+        /*  146	Ograve */	0x00d2,
+        /*  147	Oacute */	0x00d3,
+        /*  148	Ocircumflex */	0x00d4,
+        /*  149	Otilde */	0x00d5,
+        /*  150	Odieresis */	0x00d6,
+        /*  151	Ugrave */	0x00d9,
+        /*  152	Uacute */	0x00da,
+        /*  153	Ucircumflex */	0x00db,
+        /*  154	Udieresis */	0x00dc,
+        /*  155	Yacute */	0x00dd,
+        /*  156	Thorn */	0x00de,
+        /*  157	mu */		0x00b5,
+        /*  158	multiply */	0x00d7,
+        /*  159	divide */	0x00f7,
+        /*  160	copyright */	0x00a9,
+        /*  161	exclamdown */	0x00a1,
+        /*  162	cent */		0x00a2,
+        /*  163	sterling */	0x00a3,
+        /*  164	fraction */	0x2044,
+        /*  165	yen */		0x00a5,
+        /*  166	florin */	0x0192,
+        /*  167	section */	0x00a7,
+        /*  168	currency */	0x00a4,
+        /*  169	quotesingle */	0x2019,
+        /*  170	quotedblleft */	0x201c,
+        /*  171	guillemotleft */ 0x00ab,
+        /*  172	guilsinglleft */ 0x2039,
+        /*  173	guilsinglright */ 0x203a,
+        /*  174	fi */		0xFB01,
+        /*  175	fl */		0xFB02,
+        /*  176	registered */	0x00ae,
+        /*  177	endash */	0x2013,
+        /*  178	dagger */	0x2020,
+        /*  179	daggerdbl */	0x2021,
+        /*  180	periodcentered */ 0x00b7,
+        /*  181	brokenbar */	0x00a6,
+        /*  182	paragraph */	0x00b6,
+        /*  183	bullet */	0x2022,
+        /*  184	quotesinglbase */ 0x201a,
+        /*  185	quotedblbase */	0x201e,
+        /*  186	quotedblright */ 0x201d,
+        /*  187	guillemotright */ 0x00bb,
+        /*  188	ellipsis */	0x2026,
+        /*  189	perthousand */	0x2030,
+        /*  190	logicalnot */	0x00ac,
+        /*  191	questiondown */	0x00bf,
+        /*  192	onesuperior */	0x00b9,
+        /*  193	grave */	0x02cb,
+        /*  194	acute */	0x00b4,
+        /*  195	circumflex */	0x02c6,
+        /*  196	tilde */	0x02dc,
+        /*  197	macron */	0x00af,
+        /*  198	breve */	0x02d8,
+        /*  199	dotaccent */	0x02d9,
+        /*  200	dieresis */	0x00a8,
+        /*  201	twosuperior */	0x00b2,
+        /*  202	ring */		0x02da,
+        /*  203	cedilla */	0x00b8,
+        /*  204	threesuperior */ 0x00b3,
+        /*  205	hungarumlaut */	0x02dd,
+        /*  206	ogonek */	0x02db,
+        /*  207	caron */	0x02c7,
+        /*  208	emdash */	0x2014,
+        /*  209	plusminus */	0x00b1,
+        /*  210	onequarter */	0x00bc,
+        /*  211	onehalf */	0x00bd,
+        /*  212	threequarters */ 0x00be,
+        /*  213	agrave */	0x00e0,
+        /*  214	aacute */	0x00e1,
+        /*  215	acircumflex */	0x00e2,
+        /*  216	atilde */	0x00e3,
+        /*  217	adieresis */	0x00e4,
+        /*  218	aring */	0x00e5,
+        /*  219	ccedilla */	0x00e7,
+        /*  220	egrave */	0x00e8,
+        /*  221	eacute */	0x00e9,
+        /*  222	ecircumflex */	0x00ea,
+        /*  223	edieresis */	0x00eb,
+        /*  224	igrave */	0x00ec,
+        /*  225	AE */		0x00c6,
+        /*  226	iacute */	0x00ed,
+        /*  227	ordfeminine */	0x00aa,
+        /*  228	icircumflex */	0x00ee,
+        /*  229	idieresis */	0x00ef,
+        /*  230	eth */		0x00f0,
+        /*  231	ntilde */	0x00f1,
+        /*  232	Lslash */	0x0141,
+        /*  233	Oslash */	0x00d8,
+        /*  234	OE */		0x0152,
+        /*  235	ordmasculine */	0x00ba,
+        /*  236	ograve */	0x00f2,
+        /*  237	oacute */	0x00f3,
+        /*  238	ocircumflex */	0x00f4,
+        /*  239	otilde */	0x00f5,
+        /*  240	odieresis */	0x00f6,
+        /*  241	ae */		0x00e6,
+        /*  242	ugrave */	0x00f9,
+        /*  243	uacute */	0x00fa,
+        /*  244	ucircumflex */	0x00fb,
+        /*  245	dotlessi */	0x0131,
+        /*  246	udieresis */	0x00fc,
+        /*  247	yacute */	0x00fd,
+        /*  248	lslash */	0x0142,
+        /*  249	oslash */	0x00f8,
+        /*  250	oe */		0x0153,
+        /*  251	germandbls */	0x00df,
+        /*  252	thorn */	0x00fe,
+        /*  253	ydieresis */	0x00ff,
+        /*  254	.notdef */	0xFFFD,
+        /*  255	.notdef */	0xFFFD
+};
+
+static bool __CFFromNextStepLatin(uint32_t flags, uint8_t byte, UniChar *character) {
+    return ((*character = (byte < 0x80 ? (UniChar)byte : NSToPrecompUnicodeTable[byte - 0x80])) != 0xFFFD);
+}
+
+static CFIndex __CFToNextStepLatinPrecompose(uint32_t flags, const UniChar *character, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    uint8_t byte;
+    CFIndex usedCharLen;
+
+    if (__CFToNextStepLatin(flags, CFStringEncodingPrecomposeLatinCharacter(character, numChars, &usedCharLen), &byte) && byte && (usedCharLen > 1)) {
+        if (maxByteLen) *bytes = byte;
+        *usedByteLen = 1;
+        return usedCharLen;
+    } else {
+        return 0;
+    }
+}
+
+__private_extern__ const CFStringEncodingConverter __CFConverterNextStepLatin = {
+    (void*)__CFToNextStepLatin, (void*)__CFFromNextStepLatin, 1, 1, kCFStringEncodingConverterCheapEightBit,
+    NULL, NULL, NULL, NULL, __CFToNextStepLatinPrecompose, CFStringEncodingIsValidCombiningCharacterForLatin1,
+};
+
+/* UTF8 */
+/*
+ * Copyright 2001 Unicode, Inc.
+ * 
+ * Disclaimer
+ * 
+ * This source code is provided as is by Unicode, Inc. No claims are
+ * made as to fitness for any particular purpose. No warranties of any
+ * kind are expressed or implied. The recipient agrees to determine
+ * applicability of information provided. If this file has been
+ * purchased on magnetic or optical media from Unicode, Inc., the
+ * sole remedy for any claim will be exchange of defective media
+ * within 90 days of receipt.
+ * 
+ * Limitations on Rights to Redistribute This Code
+ * 
+ * Unicode, Inc. hereby grants the right to freely use the information
+ * supplied in this file in the creation of products supporting the
+ * Unicode Standard, and to make copies of this file in any form
+ * for internal or external distribution as long as this notice
+ * remains attached.
+ */
+
+static const uint32_t kReplacementCharacter =   0x0000FFFDUL;
+static const uint32_t kMaximumUCS2 =		0x0000FFFFUL;
+static const uint32_t kMaximumUTF16 =		0x0010FFFFUL;
+static const uint32_t kMaximumUCS4 =		0x7FFFFFFFUL;
+
+static const int halfShift			= 10;
+static const uint32_t halfBase		= 0x0010000UL;
+static const uint32_t halfMask		= 0x3FFUL;
+static const uint32_t kSurrogateHighStart	= 0xD800UL;
+static const uint32_t kSurrogateHighEnd	= 0xDBFFUL;
+static const uint32_t kSurrogateLowStart	= 0xDC00UL;
+static const uint32_t kSurrogateLowEnd	= 0xDFFFUL;
+
+/*
+ * Index into the table below with the first byte of a UTF-8 sequence to
+ * get the number of trailing bytes that are supposed to follow it.
+ */
+static const char trailingBytesForUTF8[256] = {
+	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
+};
+
+/*
+ * Magic values subtracted from a buffer value during UTF8 conversion.
+ * This table contains as many values as there might be trailing bytes
+ * in a UTF-8 sequence.
+ */
+static const UTF32Char offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 
+					 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
+
+static const uint8_t firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+/* This code is similar in effect to making successive calls on the mbtowc and wctomb routines in FSS-UTF. However, it is considerably different in code:
+        * it is adapted to be consistent with UTF16,
+        * constants have been gathered.
+        * loops & conditionals have been removed as much as possible for
+        * efficiency, in favor of drop-through switch statements.
+*/
+
+CF_INLINE uint16_t __CFUTF8BytesToWriteForCharacter(uint32_t ch) {
+    if (ch < 0x80) return  1;
+    else if (ch < 0x800) return 2;
+    else if (ch < 0x10000) return 3;
+    else if (ch < 0x200000) return 4;
+    else if (ch < 0x4000000) return 5;
+    else if (ch <= kMaximumUCS4) return 6;
+    else return 0;
+}
+
+CF_INLINE uint16_t __CFToUTF8Core(uint32_t ch, uint8_t *bytes, uint32_t maxByteLen) {
+    uint16_t bytesToWrite = __CFUTF8BytesToWriteForCharacter(ch);
+    const uint32_t byteMask = 0xBF;
+    const uint32_t byteMark = 0x80;
+
+    if (!bytesToWrite) {
+        bytesToWrite = 2;
+        ch = kReplacementCharacter;
+    }
+
+    if (maxByteLen < bytesToWrite) return 0;
+
+    switch (bytesToWrite) {	/* note: code falls through cases! */
+        case 6: bytes[5] = (ch | byteMark) & byteMask; ch >>= 6;
+        case 5: bytes[4] = (ch | byteMark) & byteMask; ch >>= 6;
+        case 4: bytes[3] = (ch | byteMark) & byteMask; ch >>= 6;
+        case 3: bytes[2] = (ch | byteMark) & byteMask; ch >>= 6;
+        case 2: bytes[1] = (ch | byteMark) & byteMask; ch >>= 6;
+        case 1: bytes[0] =  ch | firstByteMark[bytesToWrite];
+    }
+    return bytesToWrite;
+}
+
+static CFIndex __CFToUTF8(uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    uint16_t bytesWritten;
+    uint32_t ch;
+    const UniChar *beginCharacter = characters;
+    const UniChar *endCharacter = characters + numChars;
+    const uint8_t *beginBytes = bytes;
+    const uint8_t *endBytes = bytes + maxByteLen;
+    bool isStrict = (flags & kCFStringEncodingUseHFSPlusCanonical ? false : true);
+
+    while ((characters < endCharacter) && (!maxByteLen || (bytes < endBytes))) {
+        ch = *(characters++);
+
+        if (ch < 0x80) { // ASCII
+            if (maxByteLen) *bytes = ch;
+            ++bytes;
+        } else {
+            if (ch >= kSurrogateHighStart) {
+                if (ch <= kSurrogateHighEnd) {
+                    if ((characters < endCharacter) && ((*characters >= kSurrogateLowStart) && (*characters <= kSurrogateLowEnd))) {
+                        ch = ((ch - kSurrogateHighStart) << halfShift) + (*(characters++) - kSurrogateLowStart) + halfBase;
+                    } else if (isStrict) {
+                        --characters;
+                        break;
+                    }
+                } else if (isStrict && (ch <= kSurrogateLowEnd)) {
+                    --characters;
+                    break;
+                }
+            }
+    
+            if (!(bytesWritten = (maxByteLen ? __CFToUTF8Core(ch, bytes, endBytes - bytes) : __CFUTF8BytesToWriteForCharacter(ch)))) {
+                characters -= (ch < 0x10000 ? 1 : 2);
+                break;
+            }
+            bytes += bytesWritten;
+        }
+    }
+
+    if (usedByteLen) *usedByteLen = bytes - beginBytes;
+    return characters - beginCharacter;
+}
+
+/*
+ * Utility routine to tell whether a sequence of bytes is legal UTF-8.
+ * This must be called with the length pre-determined by the first byte.
+ * If not calling this from ConvertUTF8to*, then the length can be set by:
+ *	length = trailingBytesForUTF8[*source]+1;
+ * and the sequence is illegal right away if there aren't that many bytes
+ * available.
+ * If presented with a length > 4, this returns false.  The Unicode
+ * definition of UTF-8 goes up to 4-byte sequences.
+ */
+
+CF_INLINE bool __CFIsLegalUTF8(const uint8_t *source, CFIndex length) {
+    if (length > 4) return false;
+
+    const uint8_t *srcptr = source+length;
+    uint8_t head = *source;
+
+    while (--srcptr > source) if ((*srcptr & 0xC0) != 0x80) return false;
+
+    if (((head >= 0x80) && (head < 0xC2)) || (head > 0xF4)) return false;
+
+    if (((head == 0xE0) && (*(source + 1) < 0xA0)) || ((head == 0xED) && (*(source + 1) > 0x9F)) || ((head == 0xF0) && (*(source + 1) < 0x90)) || ((head == 0xF4) && (*(source + 1) > 0x8F))) return false;
+    return true;
+}
+
+static CFIndex __CFFromUTF8(uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    const uint8_t *source = bytes;
+    uint16_t extraBytesToRead;
+    CFIndex theUsedCharLen = 0;
+    uint32_t ch;
+    bool isHFSPlus = (flags & kCFStringEncodingUseHFSPlusCanonical ? true : false);
+    bool needsToDecompose = (flags & kCFStringEncodingUseCanonical || isHFSPlus ? true : false);
+    bool strictUTF8 = (flags & kCFStringEncodingLenientUTF8Conversion ? false : true);
+    UTF32Char decomposed[MAX_DECOMPOSED_LENGTH];
+    CFIndex decompLength;
+    bool isStrict = !isHFSPlus;
+
+    while (numBytes && (!maxCharLen || (theUsedCharLen < maxCharLen))) {
+        extraBytesToRead = trailingBytesForUTF8[*source];
+
+        if (extraBytesToRead > --numBytes) break;
+        numBytes -= extraBytesToRead;
+
+        /* Do this check whether lenient or strict */
+        // We need to allow 0xA9 (copyright in MacRoman and Unicode) not to break existing apps
+        // Will use a flag passed in from upper layers to switch restriction mode for this case in the next release
+        if ((extraBytesToRead > 3) || (strictUTF8 && !__CFIsLegalUTF8(source, extraBytesToRead + 1))) {
+            if ((*source == 0xA9) || (flags & kCFStringEncodingAllowLossyConversion)) {
+                numBytes += extraBytesToRead;
+                ++source;
+                if (maxCharLen) *(characters++) = (UTF16Char)kReplacementCharacter;
+                ++theUsedCharLen;
+                continue;
+            } else {
+                break;
+            }
+        }
+
+        ch = 0;
+        /*
+         * The cases all fall through. See "Note A" below.
+         */
+        switch (extraBytesToRead) {
+            case 3:	ch += *source++; ch <<= 6;
+            case 2:	ch += *source++; ch <<= 6;
+            case 1:	ch += *source++; ch <<= 6;
+            case 0:	ch += *source++;
+        }
+        ch -= offsetsFromUTF8[extraBytesToRead];
+
+        if (ch <= kMaximumUCS2) {
+            if (isStrict && (ch >= kSurrogateHighStart && ch <= kSurrogateLowEnd)) {
+                source -= (extraBytesToRead + 1);
+                break;
+            }
+            if (needsToDecompose && CFUniCharIsDecomposableCharacter(ch, isHFSPlus)) {
+                decompLength = CFUniCharDecomposeCharacter(ch, decomposed, MAX_DECOMPOSED_LENGTH);
+
+                if (maxCharLen) {
+                    if (!CFUniCharFillDestinationBuffer(decomposed, decompLength, (void **)&characters, maxCharLen, &theUsedCharLen, kCFUniCharUTF16Format)) break;
+                } else {
+                    theUsedCharLen += decompLength;
+                }
+            } else {
+                if (maxCharLen) *(characters++) = (UTF16Char)ch;
+                ++theUsedCharLen;
+            }
+        } else if (ch > kMaximumUTF16) {
+            if (isStrict) {
+                source -= (extraBytesToRead + 1);
+                break;
+            }
+            if (maxCharLen) *(characters++) = (UTF16Char)kReplacementCharacter;
+            ++theUsedCharLen;
+        } else {
+            if (needsToDecompose && CFUniCharIsDecomposableCharacter(ch, isHFSPlus)) {
+                decompLength = CFUniCharDecomposeCharacter(ch, decomposed, MAX_DECOMPOSED_LENGTH);
+
+                if (maxCharLen) {
+                    if (!CFUniCharFillDestinationBuffer(decomposed, decompLength, (void **)&characters, maxCharLen, &theUsedCharLen, kCFUniCharUTF16Format)) break;
+                } else {
+                    while (--decompLength >= 0) theUsedCharLen += (decomposed[decompLength] < 0x10000 ? 1 : 2);
+                }
+            } else {
+                if (maxCharLen) {
+                    if ((theUsedCharLen + 2) > maxCharLen) break;
+                    ch -= halfBase;
+                    *(characters++) = (ch >> halfShift) + kSurrogateHighStart;
+                    *(characters++) = (ch & halfMask) + kSurrogateLowStart;
+                }
+                theUsedCharLen += 2;
+            }
+        }
+    }
+
+    if (usedCharLen) *usedCharLen = theUsedCharLen;
+
+    return source - bytes;
+}
+
+static CFIndex __CFToUTF8Len(uint32_t flags, const UniChar *characters, CFIndex numChars) {
+    uint32_t bytesToWrite = 0;
+    uint32_t ch;
+
+    while (numChars) {
+        ch = *characters++;
+        numChars--;
+        if ((ch >= kSurrogateHighStart && ch <= kSurrogateHighEnd) && numChars && (*characters >= kSurrogateLowStart && *characters <= kSurrogateLowEnd)) {
+            ch = ((ch - kSurrogateHighStart) << halfShift) + (*characters++ - kSurrogateLowStart) + halfBase;
+            numChars--;
+        }
+        bytesToWrite += __CFUTF8BytesToWriteForCharacter(ch);
+    }
+
+    return bytesToWrite;
+}
+
+static CFIndex __CFFromUTF8Len(uint32_t flags, const uint8_t *source, CFIndex numBytes) {
+    uint16_t extraBytesToRead;
+    CFIndex theUsedCharLen = 0;
+    uint32_t ch;
+    bool isHFSPlus = (flags & kCFStringEncodingUseHFSPlusCanonical ? true : false);
+    bool needsToDecompose = (flags & kCFStringEncodingUseCanonical || isHFSPlus ? true : false);
+    bool strictUTF8 = (flags & kCFStringEncodingLenientUTF8Conversion ? false : true);
+    UTF32Char decomposed[MAX_DECOMPOSED_LENGTH];
+    CFIndex decompLength;
+    bool isStrict = !isHFSPlus;
+
+    while (numBytes) {
+        extraBytesToRead = trailingBytesForUTF8[*source];
+
+        if (extraBytesToRead > --numBytes) break;
+        numBytes -= extraBytesToRead;
+
+        /* Do this check whether lenient or strict */
+        // We need to allow 0xA9 (copyright in MacRoman and Unicode) not to break existing apps
+        // Will use a flag passed in from upper layers to switch restriction mode for this case in the next release
+        if ((extraBytesToRead > 3) || (strictUTF8 && !__CFIsLegalUTF8(source, extraBytesToRead + 1))) {
+            if ((*source == 0xA9) || (flags & kCFStringEncodingAllowLossyConversion)) {
+                numBytes += extraBytesToRead;
+                ++source;
+                ++theUsedCharLen;
+                continue;
+            } else {
+                break;
+            }
+        }
+
+
+        ch = 0;
+        /*
+         * The cases all fall through. See "Note A" below.
+         */
+        switch (extraBytesToRead) {
+            case 3:	ch += *source++; ch <<= 6;
+            case 2:	ch += *source++; ch <<= 6;
+            case 1:	ch += *source++; ch <<= 6;
+            case 0:	ch += *source++;
+        }
+        ch -= offsetsFromUTF8[extraBytesToRead];
+
+        if (ch <= kMaximumUCS2) {
+            if (isStrict && (ch >= kSurrogateHighStart && ch <= kSurrogateLowEnd)) {
+                break;
+            }
+            if (needsToDecompose && CFUniCharIsDecomposableCharacter(ch, isHFSPlus)) {
+                decompLength = CFUniCharDecomposeCharacter(ch, decomposed, MAX_DECOMPOSED_LENGTH);
+                theUsedCharLen += decompLength;
+            } else {
+                ++theUsedCharLen;
+            }
+        } else if (ch > kMaximumUTF16) {
+            ++theUsedCharLen;
+        } else {
+            if (needsToDecompose && CFUniCharIsDecomposableCharacter(ch, isHFSPlus)) {
+                decompLength = CFUniCharDecomposeCharacter(ch, decomposed, MAX_DECOMPOSED_LENGTH);
+                while (--decompLength >= 0) theUsedCharLen += (decomposed[decompLength] < 0x10000 ? 1 : 2);
+            } else {
+                theUsedCharLen += 2;
+            }
+        }
+    }
+
+    return theUsedCharLen;
+}
+
+__private_extern__ const CFStringEncodingConverter __CFConverterUTF8 = {
+    (void*)__CFToUTF8, (void*)__CFFromUTF8, 3, 2, kCFStringEncodingConverterStandard,
+    __CFToUTF8Len, __CFFromUTF8Len, NULL, NULL, NULL, NULL,
+};
diff --git a/CoreFoundation/CFBundle.c b/CoreFoundation/CFBundle.c
new file mode 100644
index 0000000..e25bff0
--- /dev/null
+++ b/CoreFoundation/CFBundle.c
@@ -0,0 +1,4051 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#include "CFBundle_Internal.h"
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFSet.h>
+#include <CoreFoundation/CFURLAccess.h>
+#include <CoreFoundation/CFError.h>
+#include <string.h>
+#include "CFPriv.h"
+#include "CFInternal.h"
+#include <CoreFoundation/CFByteOrder.h>
+#include "CFBundle_BinaryTypes.h"
+#include <ctype.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+
+#if defined(BINARY_SUPPORT_DYLD)
+// Import the mach-o headers that define the macho magic numbers
+#include <mach-o/loader.h>
+#include <mach-o/fat.h>
+#include <mach-o/arch.h>
+#include <mach-o/dyld.h>
+#include <mach-o/getsect.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#endif /* BINARY_SUPPORT_DYLD */
+
+#if defined(BINARY_SUPPORT_DLFCN)
+#include <dlfcn.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_SOLARIS
+#define CF_RTLD_FIRST	RTLD_FIRST
+#else
+#define CF_RTLD_FIRST	0
+#endif /* DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_SOLARIS */
+#endif /* BINARY_SUPPORT_DLFCN */
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+#include <fcntl.h>
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#include <io.h>
+#include <stdio.h>
+#define lseek _lseek
+#define open _open
+#define read _read
+#define write _write
+#define close _close
+#endif
+
+#if DEPLOYMENT_TARGET_LINUX
+#include <unistd.h>
+#endif
+
+#define LOG_BUNDLE_LOAD 0
+
+// Public CFBundle Info plist keys
+CONST_STRING_DECL(kCFBundleInfoDictionaryVersionKey, "CFBundleInfoDictionaryVersion")
+CONST_STRING_DECL(kCFBundleExecutableKey, "CFBundleExecutable")
+CONST_STRING_DECL(kCFBundleIdentifierKey, "CFBundleIdentifier")
+CONST_STRING_DECL(kCFBundleVersionKey, "CFBundleVersion")
+CONST_STRING_DECL(kCFBundleDevelopmentRegionKey, "CFBundleDevelopmentRegion")
+CONST_STRING_DECL(kCFBundleLocalizationsKey, "CFBundleLocalizations")
+
+// Finder stuff
+CONST_STRING_DECL(_kCFBundlePackageTypeKey, "CFBundlePackageType")
+CONST_STRING_DECL(_kCFBundleSignatureKey, "CFBundleSignature")
+CONST_STRING_DECL(_kCFBundleIconFileKey, "CFBundleIconFile")
+CONST_STRING_DECL(_kCFBundleDocumentTypesKey, "CFBundleDocumentTypes")
+CONST_STRING_DECL(_kCFBundleURLTypesKey, "CFBundleURLTypes")
+
+// Keys that are usually localized in InfoPlist.strings
+CONST_STRING_DECL(kCFBundleNameKey, "CFBundleName")
+CONST_STRING_DECL(_kCFBundleDisplayNameKey, "CFBundleDisplayName")
+CONST_STRING_DECL(_kCFBundleShortVersionStringKey, "CFBundleShortVersionString")
+CONST_STRING_DECL(_kCFBundleGetInfoStringKey, "CFBundleGetInfoString")
+CONST_STRING_DECL(_kCFBundleGetInfoHTMLKey, "CFBundleGetInfoHTML")
+
+// Sub-keys for CFBundleDocumentTypes dictionaries
+CONST_STRING_DECL(_kCFBundleTypeNameKey, "CFBundleTypeName")
+CONST_STRING_DECL(_kCFBundleTypeRoleKey, "CFBundleTypeRole")
+CONST_STRING_DECL(_kCFBundleTypeIconFileKey, "CFBundleTypeIconFile")
+CONST_STRING_DECL(_kCFBundleTypeOSTypesKey, "CFBundleTypeOSTypes")
+CONST_STRING_DECL(_kCFBundleTypeExtensionsKey, "CFBundleTypeExtensions")
+CONST_STRING_DECL(_kCFBundleTypeMIMETypesKey, "CFBundleTypeMIMETypes")
+
+// Sub-keys for CFBundleURLTypes dictionaries
+CONST_STRING_DECL(_kCFBundleURLNameKey, "CFBundleURLName")
+CONST_STRING_DECL(_kCFBundleURLIconFileKey, "CFBundleURLIconFile")
+CONST_STRING_DECL(_kCFBundleURLSchemesKey, "CFBundleURLSchemes")
+
+// Compatibility key names
+CONST_STRING_DECL(_kCFBundleOldExecutableKey, "NSExecutable")
+CONST_STRING_DECL(_kCFBundleOldInfoDictionaryVersionKey, "NSInfoPlistVersion")
+CONST_STRING_DECL(_kCFBundleOldNameKey, "NSHumanReadableName")
+CONST_STRING_DECL(_kCFBundleOldIconFileKey, "NSIcon")
+CONST_STRING_DECL(_kCFBundleOldDocumentTypesKey, "NSTypes")
+CONST_STRING_DECL(_kCFBundleOldShortVersionStringKey, "NSAppVersion")
+
+// Compatibility CFBundleDocumentTypes key names
+CONST_STRING_DECL(_kCFBundleOldTypeNameKey, "NSName")
+CONST_STRING_DECL(_kCFBundleOldTypeRoleKey, "NSRole")
+CONST_STRING_DECL(_kCFBundleOldTypeIconFileKey, "NSIcon")
+CONST_STRING_DECL(_kCFBundleOldTypeExtensions1Key, "NSUnixExtensions")
+CONST_STRING_DECL(_kCFBundleOldTypeExtensions2Key, "NSDOSExtensions")
+CONST_STRING_DECL(_kCFBundleOldTypeOSTypesKey, "NSMacOSType")
+
+// Internally used keys for loaded Info plists.
+CONST_STRING_DECL(_kCFBundleInfoPlistURLKey, "CFBundleInfoPlistURL")
+CONST_STRING_DECL(_kCFBundleRawInfoPlistURLKey, "CFBundleRawInfoPlistURL")
+CONST_STRING_DECL(_kCFBundleNumericVersionKey, "CFBundleNumericVersion")
+CONST_STRING_DECL(_kCFBundleExecutablePathKey, "CFBundleExecutablePath")
+CONST_STRING_DECL(_kCFBundleResourcesFileMappedKey, "CSResourcesFileMapped")
+CONST_STRING_DECL(_kCFBundleCFMLoadAsBundleKey, "CFBundleCFMLoadAsBundle")
+CONST_STRING_DECL(_kCFBundleAllowMixedLocalizationsKey, "CFBundleAllowMixedLocalizations")
+
+// Keys used by NSBundle for loaded Info plists.
+CONST_STRING_DECL(_kCFBundleInitialPathKey, "NSBundleInitialPath")
+CONST_STRING_DECL(_kCFBundleResolvedPathKey, "NSBundleResolvedPath")
+CONST_STRING_DECL(_kCFBundlePrincipalClassKey, "NSPrincipalClass")
+
+static CFTypeID __kCFBundleTypeID = _kCFRuntimeNotATypeID;
+
+struct __CFBundle {
+    CFRuntimeBase _base;
+
+    CFURLRef _url;
+    CFDateRef _modDate;
+
+    CFDictionaryRef _infoDict;
+    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;
+
+#if defined(BINARY_SUPPORT_DLL)
+    HMODULE _hModule;
+#endif /* BINARY_SUPPORT_DLL */
+
+};
+
+static CFSpinLock_t CFBundleGlobalDataLock = CFSpinLockInit;
+
+static CFMutableDictionaryRef _bundlesByURL = NULL;
+static CFMutableDictionaryRef _bundlesByIdentifier = NULL;
+
+// For scheduled lazy unloading.  Used by CFPlugIn.
+static CFMutableSetRef _bundlesToUnload = NULL;
+static Boolean _scheduledBundlesAreUnloading = false;
+
+// Various lists of all bundles.
+static CFMutableArrayRef _allBundles = NULL;
+
+static Boolean _initedMainBundle = false;
+static CFBundleRef _mainBundle = NULL;
+static CFStringRef _defaultLocalization = NULL;
+
+static Boolean _useDlfcn = false;
+
+// Forward declares functions.
+static CFBundleRef _CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL, Boolean alreadyLocked, Boolean doFinalProcessing);
+static CFStringRef _CFBundleCopyExecutableName(CFAllocatorRef alloc, CFBundleRef bundle, CFURLRef url, CFDictionaryRef infoDict);
+static CFURLRef _CFBundleCopyExecutableURLIgnoringCache(CFBundleRef bundle);
+static void _CFBundleEnsureBundlesUpToDateWithHintAlreadyLocked(CFStringRef hint);
+static void _CFBundleEnsureAllBundlesUpToDateAlreadyLocked(void);
+static void _CFBundleCheckWorkarounds(CFBundleRef bundle);
+static void _CFBundleEnsureBundleExistsForImagePath(CFStringRef imagePath);
+static void _CFBundleEnsureBundlesExistForImagePaths(CFArrayRef imagePaths);
+#if defined(BINARY_SUPPORT_DYLD)
+static CFDictionaryRef _CFBundleGrokInfoDictFromMainExecutable(void);
+static Boolean _CFBundleGrokObjCImageInfoFromMainExecutable(uint32_t *objcVersion, uint32_t *objcFlags);
+static CFStringRef _CFBundleDYLDCopyLoadedImagePathForPointer(void *p);
+static void *_CFBundleDYLDGetSymbolByNameWithSearch(CFBundleRef bundle, CFStringRef symbolName, Boolean globalSearch);
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_DLFCN)
+static CFStringRef _CFBundleDlfcnCopyLoadedImagePathForPointer(void *p);
+static void *_CFBundleDlfcnGetSymbolByNameWithSearch(CFBundleRef bundle, CFStringRef symbolName, Boolean globalSearch);
+#endif /* BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DYLD) && defined(BINARY_SUPPORT_CFM)
+static void *_CFBundleFunctionPointerForTVector(CFAllocatorRef allocator, void *tvp);
+static void *_CFBundleTVectorForFunctionPointer(CFAllocatorRef allocator, void *fp);
+#endif /* BINARY_SUPPORT_DYLD && BINARY_SUPPORT_CFM */
+
+static void _CFBundleAddToTables(CFBundleRef bundle, Boolean alreadyLocked) {
+    CFStringRef bundleID = CFBundleGetIdentifier(bundle);
+
+    if (!alreadyLocked) __CFSpinLock(&CFBundleGlobalDataLock);
+    
+    // Add to the _allBundles list
+    if (!_allBundles) {
+        // Create this from the default allocator
+        CFArrayCallBacks nonRetainingArrayCallbacks = kCFTypeArrayCallBacks;
+        nonRetainingArrayCallbacks.retain = NULL;
+        nonRetainingArrayCallbacks.release = NULL;
+        _allBundles = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &nonRetainingArrayCallbacks);
+    }
+    CFArrayAppendValue(_allBundles, bundle);
+    
+    // Add to the table that maps urls to bundles
+    if (!_bundlesByURL) {
+        // Create this from the default allocator
+        CFDictionaryValueCallBacks nonRetainingDictionaryValueCallbacks = kCFTypeDictionaryValueCallBacks;
+        nonRetainingDictionaryValueCallbacks.retain = NULL;
+        nonRetainingDictionaryValueCallbacks.release = NULL;
+        _bundlesByURL = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &nonRetainingDictionaryValueCallbacks);
+    }
+    CFDictionarySetValue(_bundlesByURL, bundle->_url, bundle);
+
+    // Add to the table that maps identifiers to bundles
+    if (bundleID) {
+        CFMutableArrayRef bundlesWithThisID = NULL;
+        CFBundleRef existingBundle = NULL;
+        if (!_bundlesByIdentifier) {
+            // Create this from the default allocator
+            _bundlesByIdentifier = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        }
+        bundlesWithThisID = (CFMutableArrayRef)CFDictionaryGetValue(_bundlesByIdentifier, bundleID);
+        if (bundlesWithThisID) {
+            CFIndex i, count = CFArrayGetCount(bundlesWithThisID);
+            UInt32 existingVersion, newVersion = CFBundleGetVersionNumber(bundle);
+            for (i = 0; i < count; i++) {
+                existingBundle = (CFBundleRef)CFArrayGetValueAtIndex(bundlesWithThisID, i);
+                existingVersion = CFBundleGetVersionNumber(existingBundle);
+                // If you load two bundles with the same identifier and the same version, the last one wins.
+                if (newVersion >= existingVersion) break;
+            }
+            CFArrayInsertValueAtIndex(bundlesWithThisID, i, bundle);
+        } else {
+            // Create this from the default allocator
+            CFArrayCallBacks nonRetainingArrayCallbacks = kCFTypeArrayCallBacks;
+            nonRetainingArrayCallbacks.retain = NULL;
+            nonRetainingArrayCallbacks.release = NULL;
+            bundlesWithThisID = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &nonRetainingArrayCallbacks);
+            CFArrayAppendValue(bundlesWithThisID, bundle);
+            CFDictionarySetValue(_bundlesByIdentifier, bundleID, bundlesWithThisID);
+            CFRelease(bundlesWithThisID);
+        }
+    }
+    if (!alreadyLocked) __CFSpinUnlock(&CFBundleGlobalDataLock);
+}
+
+static void _CFBundleRemoveFromTables(CFBundleRef bundle) {
+    CFStringRef bundleID = CFBundleGetIdentifier(bundle);
+
+    __CFSpinLock(&CFBundleGlobalDataLock);
+
+    // Remove from the various lists
+    if (_allBundles) {
+        CFIndex i = CFArrayGetFirstIndexOfValue(_allBundles, CFRangeMake(0, CFArrayGetCount(_allBundles)), bundle);
+        if (i >= 0) CFArrayRemoveValueAtIndex(_allBundles, i);
+    }
+
+    // Remove from the table that maps urls to bundles
+    if (_bundlesByURL) CFDictionaryRemoveValue(_bundlesByURL, bundle->_url);
+    
+    // Remove from the table that maps identifiers to bundles
+    if (bundleID && _bundlesByIdentifier) {
+        CFMutableArrayRef bundlesWithThisID = (CFMutableArrayRef)CFDictionaryGetValue(_bundlesByIdentifier, bundleID);
+        if (bundlesWithThisID) {
+            CFIndex count = CFArrayGetCount(bundlesWithThisID);
+            while (count-- > 0) if (bundle == (CFBundleRef)CFArrayGetValueAtIndex(bundlesWithThisID, count)) CFArrayRemoveValueAtIndex(bundlesWithThisID, count);
+            if (0 == CFArrayGetCount(bundlesWithThisID)) CFDictionaryRemoveValue(_bundlesByIdentifier, bundleID);
+        }
+    }
+    
+    __CFSpinUnlock(&CFBundleGlobalDataLock);
+}
+
+__private_extern__ CFBundleRef _CFBundleFindByURL(CFURLRef url, Boolean alreadyLocked) {
+    CFBundleRef result = NULL;
+    if (!alreadyLocked) __CFSpinLock(&CFBundleGlobalDataLock);
+    if (_bundlesByURL) result = (CFBundleRef)CFDictionaryGetValue(_bundlesByURL, url);
+    if (!alreadyLocked) __CFSpinUnlock(&CFBundleGlobalDataLock);
+    return result;
+}
+
+static CFURLRef _CFBundleCopyBundleURLForExecutablePath(CFStringRef str) {
+    //!!! need to handle frameworks, NT; need to integrate with NSBundle - drd
+    UniChar buff[CFMaxPathSize];
+    CFIndex buffLen;
+    CFURLRef url = NULL;
+    CFStringRef outstr;
+    
+    buffLen = CFStringGetLength(str);
+    if (buffLen > CFMaxPathSize) buffLen = CFMaxPathSize;
+    CFStringGetCharacters(str, CFRangeMake(0, buffLen), buff);
+
+    if (!url) {
+        buffLen = _CFLengthAfterDeletingLastPathComponent(buff, buffLen);  // Remove exe name
+
+        if (buffLen > 0) {
+            // See if this is a new bundle.  If it is, we have to remove more path components.
+            CFIndex startOfLastDir = _CFStartOfLastPathComponent(buff, buffLen);
+            if ((startOfLastDir > 0) && (startOfLastDir < buffLen)) {
+                CFStringRef lastDirName = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, &(buff[startOfLastDir]), buffLen - startOfLastDir);
+
+                if (CFEqual(lastDirName, _CFBundleGetPlatformExecutablesSubdirectoryName()) || CFEqual(lastDirName, _CFBundleGetAlternatePlatformExecutablesSubdirectoryName()) || CFEqual(lastDirName, _CFBundleGetOtherPlatformExecutablesSubdirectoryName()) || CFEqual(lastDirName, _CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName())) {
+                    // This is a new bundle.  Back off a few more levels
+                    if (buffLen > 0) {
+                        // Remove platform folder
+                        buffLen = _CFLengthAfterDeletingLastPathComponent(buff, buffLen);
+                    }
+                    if (buffLen > 0) {
+                        // Remove executables folder (if present)
+                        CFIndex startOfNextDir = _CFStartOfLastPathComponent(buff, buffLen);
+                        if ((startOfNextDir > 0) && (startOfNextDir < buffLen)) {
+                            CFStringRef nextDirName = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, &(buff[startOfNextDir]), buffLen - startOfNextDir);
+                            if (CFEqual(nextDirName, _CFBundleExecutablesDirectoryName)) buffLen = _CFLengthAfterDeletingLastPathComponent(buff, buffLen);
+                            CFRelease(nextDirName);
+                        }
+                    }
+                    if (buffLen > 0) {
+                        // Remove support files folder
+                        buffLen = _CFLengthAfterDeletingLastPathComponent(buff, buffLen);
+                    }
+                }
+                CFRelease(lastDirName);
+            }
+        }
+
+        if (buffLen > 0) {
+            outstr = CFStringCreateWithCharactersNoCopy(kCFAllocatorSystemDefault, buff, buffLen, kCFAllocatorNull);
+            url = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, outstr, PLATFORM_PATH_STYLE, true);
+            CFRelease(outstr);
+        }
+    }
+    return url;
+}
+
+static CFURLRef _CFBundleCopyResolvedURLForExecutableURL(CFURLRef url) {
+    // this is necessary so that we match any sanitization CFURL may perform on the result of _CFBundleCopyBundleURLForExecutableURL()
+    CFURLRef absoluteURL, url1, url2, outURL = NULL;
+    CFStringRef str, str1, str2;
+    absoluteURL = CFURLCopyAbsoluteURL(url);
+    str = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+    if (str) {
+        UniChar buff[CFMaxPathSize];
+        CFIndex buffLen = CFStringGetLength(str), len1;
+        if (buffLen > CFMaxPathSize) buffLen = CFMaxPathSize;
+        CFStringGetCharacters(str, CFRangeMake(0, buffLen), buff);
+        len1 = _CFLengthAfterDeletingLastPathComponent(buff, buffLen);
+        if (len1 > 0 && len1 + 1 < buffLen) {
+            str1 = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, buff, len1);
+            str2 = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, buff + len1 + 1, buffLen - len1 - 1);
+            if (str1 && str2) {
+                url1 = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str1, PLATFORM_PATH_STYLE, true);
+                if (url1) {
+                    url2 = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, str2, PLATFORM_PATH_STYLE, false, url1);
+                    if (url2) {
+                        outURL = CFURLCopyAbsoluteURL(url2);
+                        CFRelease(url2);
+                    }
+                    CFRelease(url1);
+                }
+            }
+            if (str1) CFRelease(str1);
+            if (str2) CFRelease(str2);
+        }
+        CFRelease(str);
+    }
+    if (!outURL) {
+        outURL = absoluteURL;
+    } else {
+        CFRelease(absoluteURL);
+    }
+    return outURL;
+}
+
+CFURLRef _CFBundleCopyBundleURLForExecutableURL(CFURLRef url) {
+    CFURLRef resolvedURL, outurl = NULL;
+    CFStringRef str;
+    resolvedURL = _CFBundleCopyResolvedURLForExecutableURL(url);
+    str = CFURLCopyFileSystemPath(resolvedURL, PLATFORM_PATH_STYLE);
+    if (str) {
+        outurl = _CFBundleCopyBundleURLForExecutablePath(str);
+        CFRelease(str);
+    }
+    CFRelease(resolvedURL);
+    return outurl;
+}
+
+CFBundleRef _CFBundleCreateIfLooksLikeBundle(CFAllocatorRef allocator, CFURLRef url) {
+    CFBundleRef bundle = CFBundleCreate(allocator, url);
+    
+    // exclude type 0 bundles with no binary (or CFM binary) and no Info.plist, since they give too many false positives
+    if (bundle && 0 == bundle->_version) {
+        CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+        if (!infoDict || 0 == CFDictionaryGetCount(infoDict)) {
+#if defined(BINARY_SUPPORT_CFM) && defined(BINARY_SUPPORT_DYLD)
+            CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+            if (executableURL) {
+                if (bundle->_binaryType == __CFBundleUnknownBinary) bundle->_binaryType = _CFBundleGrokBinaryType(executableURL);
+                if (bundle->_binaryType == __CFBundleCFMBinary || bundle->_binaryType == __CFBundleUnreadableBinary) {
+                    bundle->_version = 4;
+                } else {
+                    bundle->_resourceData._executableLacksResourceFork = true;
+                }
+                CFRelease(executableURL);
+            } else {
+                bundle->_version = 4;
+            }
+#elif defined(BINARY_SUPPORT_CFM)
+            bundle->_version = 4;
+#else 
+            CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+            if (executableURL) {
+                CFRelease(executableURL);
+            } else {
+                bundle->_version = 4;
+            }
+#endif /* BINARY_SUPPORT_CFM && BINARY_SUPPORT_DYLD */
+        }
+    }
+    if (bundle && (3 == bundle->_version || 4 == bundle->_version)) {
+        CFRelease(bundle);
+        bundle = NULL;
+    }
+    return bundle;
+}
+
+CFBundleRef _CFBundleGetMainBundleIfLooksLikeBundle(void) {
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    if (mainBundle && (3 == mainBundle->_version || 4 == mainBundle->_version)) mainBundle = NULL;
+    return mainBundle;
+}
+
+Boolean _CFBundleMainBundleInfoDictionaryComesFromResourceFork(void) {
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    return (mainBundle && mainBundle->_resourceData._infoDictionaryFromResourceFork);
+}
+
+CFBundleRef _CFBundleCreateWithExecutableURLIfLooksLikeBundle(CFAllocatorRef allocator, CFURLRef url) {
+    CFBundleRef bundle = NULL;
+    CFURLRef bundleURL = _CFBundleCopyBundleURLForExecutableURL(url), resolvedURL = _CFBundleCopyResolvedURLForExecutableURL(url);
+    if (bundleURL && resolvedURL) {
+        bundle = _CFBundleCreateIfLooksLikeBundle(allocator, bundleURL);
+        if (bundle) {
+            CFURLRef executableURL = _CFBundleCopyExecutableURLIgnoringCache(bundle);
+            char buff1[CFMaxPathSize], buff2[CFMaxPathSize];
+            if (!executableURL || !CFURLGetFileSystemRepresentation(resolvedURL, true, (uint8_t *)buff1, CFMaxPathSize) || !CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff2, CFMaxPathSize) || 0 != strcmp(buff1, buff2)) {
+                CFRelease(bundle);
+                bundle = NULL;
+            }
+            if (executableURL) CFRelease(executableURL);
+        }
+    }
+    if (bundleURL) CFRelease(bundleURL);
+    if (resolvedURL) CFRelease(resolvedURL);
+    return bundle;
+}
+
+CFURLRef _CFBundleCopyMainBundleExecutableURL(Boolean *looksLikeBundle) {
+    // This function is for internal use only; _mainBundle is deliberately accessed outside of the lock to get around a reentrancy issue
+    const char *processPath;
+    CFStringRef str = NULL;
+    CFURLRef executableURL = NULL;
+    processPath = _CFProcessPath();
+    if (processPath) {
+        str = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, processPath);
+        if (str) {
+            executableURL = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str, PLATFORM_PATH_STYLE, false);
+            CFRelease(str);
+        }
+    }
+    if (looksLikeBundle) {
+        CFBundleRef mainBundle = _mainBundle;
+        if (mainBundle && (3 == mainBundle->_version || 4 == mainBundle->_version)) mainBundle = NULL;
+        *looksLikeBundle = (mainBundle ? true : false);
+    }
+    return executableURL;
+}
+
+static void _CFBundleInitializeMainBundleInfoDictionaryAlreadyLocked(CFStringRef executablePath) {
+#if defined(BINARY_SUPPORT_CFM)
+    Boolean versRegionOverrides = false;
+#endif /* BINARY_SUPPORT_CFM */
+    CFBundleGetInfoDictionary(_mainBundle);
+    if (!_mainBundle->_infoDict || CFDictionaryGetCount(_mainBundle->_infoDict) == 0) {
+        // if type 3 bundle and no Info.plist, treat as unbundled, since this gives too many false positives
+        if (_mainBundle->_version == 3) _mainBundle->_version = 4;
+        if (_mainBundle->_version == 0) {
+            // if type 0 bundle and no Info.plist and not main executable for bundle, treat as unbundled, since this gives too many false positives
+            CFStringRef executableName = _CFBundleCopyExecutableName(kCFAllocatorSystemDefault, _mainBundle, NULL, NULL);
+            if (!executableName || !executablePath || !CFStringHasSuffix(executablePath, executableName)) _mainBundle->_version = 4;
+            if (executableName) CFRelease(executableName);
+        }
+#if defined(BINARY_SUPPORT_DYLD)
+        if (_mainBundle->_binaryType == __CFBundleDYLDExecutableBinary) {
+            if (_mainBundle->_infoDict) CFRelease(_mainBundle->_infoDict);
+            _mainBundle->_infoDict = _CFBundleGrokInfoDictFromMainExecutable();
+        }
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_CFM)
+        if (_mainBundle->_binaryType == __CFBundleCFMBinary || _mainBundle->_binaryType == __CFBundleUnreadableBinary) {
+            // if type 0 bundle and CFM binary and no Info.plist, treat as unbundled, since this also gives too many false positives
+            if (_mainBundle->_version == 0) _mainBundle->_version = 4;
+            if (_mainBundle->_version != 4) {
+                // if CFM binary and no Info.plist and not main executable for bundle, treat as unbundled, since this also gives too many false positives
+                // except for Macromedia Director MX, which is unbundled but wants to be treated as bundled
+                CFStringRef executableName = _CFBundleCopyExecutableName(kCFAllocatorSystemDefault, _mainBundle, NULL, NULL);
+                Boolean treatAsBundled = false;
+                if (executablePath) {
+                    CFIndex strLength = CFStringGetLength(executablePath);
+                    if (strLength > 10) treatAsBundled = CFStringFindWithOptions(executablePath, CFSTR(" MX"), CFRangeMake(strLength - 10, 10), 0, NULL);
+                }
+                if (!treatAsBundled && (!executableName || !executablePath || !CFStringHasSuffix(executablePath, executableName))) _mainBundle->_version = 4;
+                if (executableName) CFRelease(executableName);
+            }
+            if (_mainBundle->_infoDict) CFRelease(_mainBundle->_infoDict);
+            if (executablePath) {
+                CFURLRef executableURL = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, executablePath, PLATFORM_PATH_STYLE, false);
+                if (executableURL) {
+                    _mainBundle->_infoDict = _CFBundleCopyInfoDictionaryInResourceForkWithAllocator(CFGetAllocator(_mainBundle), executableURL);
+                    if (_mainBundle->_infoDict) _mainBundle->_resourceData._infoDictionaryFromResourceFork = true;
+                    CFRelease(executableURL);
+                }
+            }
+            if (_mainBundle->_binaryType == __CFBundleUnreadableBinary && _mainBundle->_infoDict && CFDictionaryGetValue(_mainBundle->_infoDict, kCFBundleDevelopmentRegionKey)) versRegionOverrides = true;
+        }
+#endif /* BINARY_SUPPORT_CFM */
+    }
+    if (!_mainBundle->_infoDict) _mainBundle->_infoDict = CFDictionaryCreateMutable(CFGetAllocator(_mainBundle), 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    if (!CFDictionaryGetValue(_mainBundle->_infoDict, _kCFBundleExecutablePathKey)) CFDictionarySetValue((CFMutableDictionaryRef)(_mainBundle->_infoDict), _kCFBundleExecutablePathKey, executablePath);
+#if defined(BINARY_SUPPORT_CFM)
+    if (versRegionOverrides) {
+        // This is a hack to preserve backward compatibility for certain broken applications (2761067)
+        CFStringRef devLang = _CFBundleCopyBundleDevelopmentRegionFromVersResource(_mainBundle);
+        if (devLang) {
+            CFDictionarySetValue((CFMutableDictionaryRef)(_mainBundle->_infoDict), kCFBundleDevelopmentRegionKey, devLang);
+            CFRelease(devLang);
+        }
+    }
+#endif /* BINARY_SUPPORT_CFM */
+}
+
+CF_EXPORT void _CFBundleFlushBundleCaches(CFBundleRef bundle) {
+    CFDictionaryRef oldInfoDict = bundle->_infoDict;
+    CFTypeRef val;
+    
+    _CFBundleFlushCachesForURL(bundle->_url);
+    bundle->_infoDict = NULL;
+    if (bundle->_localInfoDict) {
+        CFRelease(bundle->_localInfoDict);
+        bundle->_localInfoDict = NULL;
+    }
+    if (bundle->_searchLanguages) {
+        CFRelease(bundle->_searchLanguages);
+        bundle->_searchLanguages = NULL;
+    }
+    if (bundle->_resourceData._stringTableCache) {
+        CFRelease(bundle->_resourceData._stringTableCache);
+        bundle->_resourceData._stringTableCache = NULL;
+    }
+    if (bundle == _mainBundle) {
+        CFStringRef executablePath = oldInfoDict ? (CFStringRef)CFDictionaryGetValue(oldInfoDict, _kCFBundleExecutablePathKey) : NULL;
+        __CFSpinLock(&CFBundleGlobalDataLock);
+        _CFBundleInitializeMainBundleInfoDictionaryAlreadyLocked(executablePath);
+        __CFSpinUnlock(&CFBundleGlobalDataLock);
+    } else {
+        CFBundleGetInfoDictionary(bundle);
+    }
+    if (oldInfoDict) {
+        if (!bundle->_infoDict) bundle->_infoDict = CFDictionaryCreateMutable(CFGetAllocator(bundle), 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        val = CFDictionaryGetValue(oldInfoDict, _kCFBundleInitialPathKey);
+        if (val) CFDictionarySetValue((CFMutableDictionaryRef)bundle->_infoDict, _kCFBundleInitialPathKey, val);
+        val = CFDictionaryGetValue(oldInfoDict, _kCFBundleResolvedPathKey);
+        if (val) CFDictionarySetValue((CFMutableDictionaryRef)bundle->_infoDict, _kCFBundleResolvedPathKey, val);
+        val = CFDictionaryGetValue(oldInfoDict, _kCFBundlePrincipalClassKey);
+        if (val) CFDictionarySetValue((CFMutableDictionaryRef)bundle->_infoDict, _kCFBundlePrincipalClassKey, val);
+        CFRelease(oldInfoDict);
+    }
+}
+
+static CFBundleRef _CFBundleGetMainBundleAlreadyLocked(void) {
+    if (!_initedMainBundle) {
+        const char *processPath;
+        CFStringRef str = NULL;
+        CFURLRef executableURL = NULL, bundleURL = NULL;
+        _initedMainBundle = true;
+        processPath = _CFProcessPath();
+        if (processPath) {
+            str = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, processPath);
+            if (!executableURL) executableURL = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str, PLATFORM_PATH_STYLE, false);
+        }
+        if (executableURL) bundleURL = _CFBundleCopyBundleURLForExecutableURL(executableURL);
+        if (bundleURL) {
+            // make sure that main bundle has executable path
+            //??? what if we are not the main executable in the bundle?
+            // NB doFinalProcessing must be false here, see below
+            _mainBundle = _CFBundleCreate(kCFAllocatorSystemDefault, bundleURL, true, false);
+            if (_mainBundle) {
+                // make sure that the main bundle is listed as loaded, and mark it as executable
+                _mainBundle->_isLoaded = true;
+#if defined(BINARY_SUPPORT_DYLD)
+                if (_mainBundle->_binaryType == __CFBundleUnknownBinary) {
+                    if (!executableURL) {
+                        _mainBundle->_binaryType = __CFBundleNoBinary;
+                    } else {
+                        _mainBundle->_binaryType = _CFBundleGrokBinaryType(executableURL);
+#if defined(BINARY_SUPPORT_CFM)
+                        if (_mainBundle->_binaryType != __CFBundleCFMBinary && _mainBundle->_binaryType != __CFBundleUnreadableBinary) _mainBundle->_resourceData._executableLacksResourceFork = true;
+#endif /* BINARY_SUPPORT_CFM */
+                    }
+                }                
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_DYLD)
+                // get cookie for already-loaded main bundle
+                if (_mainBundle->_binaryType == __CFBundleDYLDExecutableBinary && !_mainBundle->_imageCookie) {
+                    // ??? need better way to specify main executable image
+                    _mainBundle->_imageCookie = (void *)_dyld_get_image_header(0);
+#if LOG_BUNDLE_LOAD
+                    printf("main bundle %p getting image %p\n", _mainBundle, _mainBundle->_imageCookie);
+#endif /* LOG_BUNDLE_LOAD */
+                }
+#endif /* BINARY_SUPPORT_DYLD */
+                _CFBundleInitializeMainBundleInfoDictionaryAlreadyLocked(str);
+                // Perform delayed final processing steps.
+                // This must be done after _isLoaded has been set, for security reasons (3624341).
+                _CFBundleCheckWorkarounds(_mainBundle);
+                if (_CFBundleNeedsInitPlugIn(_mainBundle)) {
+                    __CFSpinUnlock(&CFBundleGlobalDataLock);
+                    _CFBundleInitPlugIn(_mainBundle);
+                    __CFSpinLock(&CFBundleGlobalDataLock);
+                }
+            }
+        }
+        if (bundleURL) CFRelease(bundleURL);
+        if (str) CFRelease(str);
+        if (executableURL) CFRelease(executableURL);
+    }
+    return _mainBundle;
+}
+
+CFBundleRef CFBundleGetMainBundle(void) {
+    CFBundleRef mainBundle;
+    __CFSpinLock(&CFBundleGlobalDataLock);
+    mainBundle = _CFBundleGetMainBundleAlreadyLocked();
+    __CFSpinUnlock(&CFBundleGlobalDataLock);
+    return mainBundle;
+}
+
+CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID) {
+    CFBundleRef result = NULL;
+    CFArrayRef bundlesWithThisID;
+    if (bundleID) {
+        __CFSpinLock(&CFBundleGlobalDataLock);
+        (void)_CFBundleGetMainBundleAlreadyLocked();
+        if (_bundlesByIdentifier) {
+            bundlesWithThisID = (CFArrayRef)CFDictionaryGetValue(_bundlesByIdentifier, bundleID);
+            if (bundlesWithThisID && CFArrayGetCount(bundlesWithThisID) > 0) result = (CFBundleRef)CFArrayGetValueAtIndex(bundlesWithThisID, 0);
+        }
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+        if (!result) {
+            // Try to create the bundle for the caller and try again
+            void *p = __builtin_return_address(0);
+            if (p) {
+                CFStringRef imagePath = NULL;
+#if defined(BINARY_SUPPORT_DLFCN)
+                if (!imagePath && _useDlfcn) imagePath = _CFBundleDlfcnCopyLoadedImagePathForPointer(p);
+#endif /* BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DYLD)
+                if (!imagePath) imagePath = _CFBundleDYLDCopyLoadedImagePathForPointer(p);
+#endif /* BINARY_SUPPORT_DYLD */
+                if (imagePath) {
+                    _CFBundleEnsureBundleExistsForImagePath(imagePath);
+                    CFRelease(imagePath);
+                }
+                if (_bundlesByIdentifier) {
+                    bundlesWithThisID = (CFArrayRef)CFDictionaryGetValue(_bundlesByIdentifier, bundleID);
+                    if (bundlesWithThisID && CFArrayGetCount(bundlesWithThisID) > 0) result = (CFBundleRef)CFArrayGetValueAtIndex(bundlesWithThisID, 0);
+                }
+            }
+        }
+#endif
+        if (!result) {
+            // Try to guess the bundle from the identifier and try again
+            _CFBundleEnsureBundlesUpToDateWithHintAlreadyLocked(bundleID);
+            if (_bundlesByIdentifier) {
+                bundlesWithThisID = (CFArrayRef)CFDictionaryGetValue(_bundlesByIdentifier, bundleID);
+                if (bundlesWithThisID && CFArrayGetCount(bundlesWithThisID) > 0) result = (CFBundleRef)CFArrayGetValueAtIndex(bundlesWithThisID, 0);
+            }
+        }
+        if (!result) {
+            // Make sure all bundles have been created and try again.
+            _CFBundleEnsureAllBundlesUpToDateAlreadyLocked();
+            if (_bundlesByIdentifier) {
+                bundlesWithThisID = (CFArrayRef)CFDictionaryGetValue(_bundlesByIdentifier, bundleID);
+                if (bundlesWithThisID && CFArrayGetCount(bundlesWithThisID) > 0) result = (CFBundleRef)CFArrayGetValueAtIndex(bundlesWithThisID, 0);
+            }
+        }
+        __CFSpinUnlock(&CFBundleGlobalDataLock);
+    }
+    return result;
+}
+
+static CFStringRef __CFBundleCopyDescription(CFTypeRef cf) {
+    char buff[CFMaxPathSize];
+    CFStringRef path = NULL, binaryType = NULL, retval = NULL;
+    if (((CFBundleRef)cf)->_url && CFURLGetFileSystemRepresentation(((CFBundleRef)cf)->_url, true, (uint8_t *)buff, CFMaxPathSize)) path = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, buff);
+    switch (((CFBundleRef)cf)->_binaryType) {
+        case __CFBundleCFMBinary:
+            binaryType = CFSTR("");
+            break;
+        case __CFBundleDYLDExecutableBinary:
+            binaryType = CFSTR("executable, ");
+            break;
+        case __CFBundleDYLDBundleBinary:
+            binaryType = CFSTR("bundle, ");
+            break;
+        case __CFBundleDYLDFrameworkBinary:
+            binaryType = CFSTR("framework, ");
+            break;
+        case __CFBundleDLLBinary:
+            binaryType = CFSTR("DLL, ");
+            break;
+        case __CFBundleUnreadableBinary:
+            binaryType = CFSTR("");
+            break;
+        default:
+            binaryType = CFSTR("");
+            break;
+    }
+    if (((CFBundleRef)cf)->_plugInData._isPlugIn) {
+        retval = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("CFBundle/CFPlugIn %p <%@> (%@%sloaded)"), cf, path, binaryType, ((CFBundleRef)cf)->_isLoaded ? "" : "not ");
+    } else {
+        retval = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("CFBundle %p <%@> (%@%sloaded)"), cf, path, binaryType, ((CFBundleRef)cf)->_isLoaded ? "" : "not ");
+    }
+    if (path) CFRelease(path);
+    return retval;
+}
+
+static void _CFBundleDeallocateGlue(const void *key, const void *value, void *context) {
+    CFAllocatorRef allocator = (CFAllocatorRef)context;
+    if (value) CFAllocatorDeallocate(allocator, (void *)value);
+}
+
+static void __CFBundleDeallocate(CFTypeRef cf) {
+    CFBundleRef bundle = (CFBundleRef)cf;
+    CFAllocatorRef allocator;
+    
+    __CFGenericValidateType(cf, __kCFBundleTypeID);
+
+    allocator = CFGetAllocator(bundle);
+
+    /* Unload it */
+    CFBundleUnloadExecutable(bundle);
+
+    // Clean up plugIn stuff
+    _CFBundleDeallocatePlugIn(bundle);
+    
+    _CFBundleRemoveFromTables(bundle);
+
+    if (bundle->_url) {
+        _CFBundleFlushCachesForURL(bundle->_url);
+        CFRelease(bundle->_url);
+    }
+    if (bundle->_infoDict) CFRelease(bundle->_infoDict);
+    if (bundle->_modDate) CFRelease(bundle->_modDate);
+    if (bundle->_localInfoDict) CFRelease(bundle->_localInfoDict);
+    if (bundle->_searchLanguages) CFRelease(bundle->_searchLanguages);
+    if (bundle->_glueDict) {
+        CFDictionaryApplyFunction(bundle->_glueDict, _CFBundleDeallocateGlue, (void *)allocator);
+        CFRelease(bundle->_glueDict);
+    }
+    if (bundle->_resourceData._stringTableCache) CFRelease(bundle->_resourceData._stringTableCache);
+}
+
+static const CFRuntimeClass __CFBundleClass = {
+    0,
+    "CFBundle",
+    NULL,      // init
+    NULL,      // copy
+    __CFBundleDeallocate,
+    NULL,      // equal
+    NULL,      // hash
+    NULL,      // 
+    __CFBundleCopyDescription
+};
+
+__private_extern__ void __CFBundleInitialize(void) {
+    __kCFBundleTypeID = _CFRuntimeRegisterClass(&__CFBundleClass);
+#if defined(BINARY_SUPPORT_DLFCN)
+    _useDlfcn = true;
+#if defined(BINARY_SUPPORT_DYLD)
+    if (getenv("CFBundleUseDYLD")) _useDlfcn = false;
+#endif /* BINARY_SUPPORT_DYLD */
+#endif /* BINARY_SUPPORT_DLFCN */
+}
+
+Boolean _CFBundleUseDlfcn(void) {
+    return _useDlfcn;
+}
+
+CFTypeID CFBundleGetTypeID(void) {
+    return __kCFBundleTypeID;
+}
+
+CFBundleRef _CFBundleGetExistingBundleWithBundleURL(CFURLRef bundleURL) {
+    CFBundleRef bundle = NULL;
+    char buff[CFMaxPathSize];
+    CFURLRef newURL = NULL;
+    
+    if (!CFURLGetFileSystemRepresentation(bundleURL, true, (uint8_t *)buff, CFMaxPathSize)) return NULL;
+    
+    newURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)buff, (CFIndex)strlen(buff), true);
+    if (!newURL) newURL = (CFURLRef)CFRetain(bundleURL);
+    bundle = _CFBundleFindByURL(newURL, false);
+    CFRelease(newURL);
+    return bundle;
+}
+
+static CFBundleRef _CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL, Boolean alreadyLocked, Boolean doFinalProcessing) {
+    CFBundleRef bundle = NULL;
+    char buff[CFMaxPathSize];
+    CFDateRef modDate = NULL;
+    Boolean exists = false;
+    SInt32 mode = 0;
+    CFURLRef newURL = NULL;
+    uint8_t localVersion = 0;
+    
+    if (!CFURLGetFileSystemRepresentation(bundleURL, true, (uint8_t *)buff, CFMaxPathSize)) return NULL;
+
+    newURL = CFURLCreateFromFileSystemRepresentation(allocator, (uint8_t *)buff, (CFIndex)strlen(buff), true);
+    if (!newURL) newURL = (CFURLRef)CFRetain(bundleURL);
+    bundle = _CFBundleFindByURL(newURL, alreadyLocked);
+    if (bundle) {
+        CFRetain(bundle);
+        CFRelease(newURL);
+        return bundle;
+    }
+    
+    if (!_CFBundleURLLooksLikeBundleVersion(newURL, &localVersion)) {
+        localVersion = 3;
+        if (_CFGetFileProperties(allocator, newURL, &exists, &mode, NULL, &modDate, NULL, NULL) == 0) {
+            if (!exists || ((mode & S_IFMT) != S_IFDIR)) {
+                if (modDate) CFRelease(modDate);
+                CFRelease(newURL);
+                return NULL;
+            }
+        } else {
+            CFRelease(newURL);
+            return NULL;
+        }
+    }
+
+    bundle = (CFBundleRef)_CFRuntimeCreateInstance(allocator, __kCFBundleTypeID, sizeof(struct __CFBundle) - sizeof(CFRuntimeBase), NULL);
+    if (!bundle) {
+        CFRelease(newURL);
+        return NULL;
+    }
+
+    bundle->_url = newURL;
+
+    bundle->_modDate = modDate;
+    bundle->_version = localVersion;
+    bundle->_infoDict = NULL;
+    bundle->_localInfoDict = NULL;
+    bundle->_searchLanguages = NULL;
+    
+#if defined(BINARY_SUPPORT_DYLD)
+    /* We'll have to figure it out later */
+    bundle->_binaryType = __CFBundleUnknownBinary;
+#elif defined(BINARY_SUPPORT_CFM)
+    /* We support CFM only */
+    bundle->_binaryType = __CFBundleCFMBinary;
+#elif defined(BINARY_SUPPORT_DLL)
+    /* We support DLL only */
+    bundle->_binaryType = __CFBundleDLLBinary;
+    bundle->_hModule = NULL;
+#else
+    /* We'll have to figure it out later */
+    bundle->_binaryType = __CFBundleUnknownBinary;
+#endif /* BINARY_SUPPORT_DYLD */
+
+    bundle->_isLoaded = false;
+    bundle->_sharesStringsFiles = false;
+    
+    if (!getenv("CFBundleDisableStringsSharing") && 
+#if DEPLOYMENT_TARGET_MACOSX
+        (strncmp(buff, "/System/Library/Frameworks", 26) == 0) && 
+#endif
+        (strncmp(buff + strlen(buff) - 10, ".framework", 10) == 0)) bundle->_sharesStringsFiles = true;
+
+    bundle->_connectionCookie = NULL;
+    bundle->_handleCookie = NULL;
+    bundle->_imageCookie = NULL;
+    bundle->_moduleCookie = NULL;
+
+    bundle->_glueDict = NULL;
+    
+#if defined(BINARY_SUPPORT_CFM)
+    bundle->_resourceData._executableLacksResourceFork = false;
+#else /* BINARY_SUPPORT_CFM */
+    bundle->_resourceData._executableLacksResourceFork = true;
+#endif /* BINARY_SUPPORT_CFM */
+    bundle->_resourceData._infoDictionaryFromResourceFork = false;
+    bundle->_resourceData._stringTableCache = NULL;
+
+    bundle->_plugInData._isPlugIn = false;
+    bundle->_plugInData._loadOnDemand = false;
+    bundle->_plugInData._isDoingDynamicRegistration = false;
+    bundle->_plugInData._instanceCount = 0;
+    bundle->_plugInData._factories = NULL;
+
+    CFBundleGetInfoDictionary(bundle);
+    
+    _CFBundleAddToTables(bundle, alreadyLocked);
+
+    if (doFinalProcessing) {
+        _CFBundleCheckWorkarounds(bundle);
+        if (_CFBundleNeedsInitPlugIn(bundle)) {
+            if (alreadyLocked) __CFSpinUnlock(&CFBundleGlobalDataLock);
+            _CFBundleInitPlugIn(bundle);
+            if (alreadyLocked) __CFSpinLock(&CFBundleGlobalDataLock);
+        }
+    }
+    
+    return bundle;
+}
+
+CFBundleRef CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL) {return _CFBundleCreate(allocator, bundleURL, false, true);}
+
+CFArrayRef CFBundleCreateBundlesFromDirectory(CFAllocatorRef alloc, CFURLRef directoryURL, CFStringRef bundleType) {
+    CFMutableArrayRef bundles = CFArrayCreateMutable(alloc, 0, &kCFTypeArrayCallBacks);
+    CFArrayRef URLs = _CFContentsOfDirectory(alloc, NULL, NULL, directoryURL, bundleType);
+    if (URLs) {
+        CFIndex i, c = CFArrayGetCount(URLs);
+        CFURLRef curURL;
+        CFBundleRef curBundle;
+
+        for (i = 0; i < c; i++) {
+            curURL = (CFURLRef)CFArrayGetValueAtIndex(URLs, i);
+            curBundle = CFBundleCreate(alloc, curURL);
+            if (curBundle) CFArrayAppendValue(bundles, curBundle);
+        }
+        CFRelease(URLs);
+    }
+
+    return bundles;
+}
+
+CFURLRef CFBundleCopyBundleURL(CFBundleRef bundle) {
+    if (bundle->_url) {
+        CFRetain(bundle->_url);
+    }
+    return bundle->_url;
+}
+
+void _CFBundleSetDefaultLocalization(CFStringRef localizationName) {
+    CFStringRef newLocalization = localizationName ? (CFStringRef)CFStringCreateCopy(kCFAllocatorSystemDefault, localizationName) : NULL;
+    if (_defaultLocalization) CFRelease(_defaultLocalization);
+    _defaultLocalization = newLocalization;
+}
+
+CFArrayRef _CFBundleGetLanguageSearchList(CFBundleRef bundle) {
+    if (!bundle->_searchLanguages) {
+        CFMutableArrayRef langs = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+        CFStringRef devLang = CFBundleGetDevelopmentRegion(bundle);
+        
+        _CFBundleAddPreferredLprojNamesInDirectory(CFGetAllocator(bundle), bundle->_url, bundle->_version, bundle->_infoDict, langs, devLang);
+
+        if (CFArrayGetCount(langs) == 0) {
+            // If the user does not prefer any of our languages, and devLang is not present, try English
+            _CFBundleAddPreferredLprojNamesInDirectory(CFGetAllocator(bundle), bundle->_url, bundle->_version, bundle->_infoDict, langs, CFSTR("en_US"));
+        }
+        if (CFArrayGetCount(langs) == 0) {
+            // if none of the preferred localizations are present, fall back on a random localization that is present
+            CFArrayRef localizations = CFBundleCopyBundleLocalizations(bundle);
+            if (localizations) {
+                if (CFArrayGetCount(localizations) > 0) {
+                    _CFBundleAddPreferredLprojNamesInDirectory(CFGetAllocator(bundle), bundle->_url, bundle->_version, bundle->_infoDict, langs, (CFStringRef)CFArrayGetValueAtIndex(localizations, 0));
+                }
+                CFRelease(localizations);
+            }
+        }
+        
+        if (devLang && !CFArrayContainsValue(langs, CFRangeMake(0, CFArrayGetCount(langs)), devLang)) {
+            // Make sure that devLang is on the list as a fallback for individual resources that are not present
+            CFArrayAppendValue(langs, devLang);
+        } else if (!devLang) {
+            // Or if there is no devLang, try some variation of English that is present
+            CFArrayRef localizations = CFBundleCopyBundleLocalizations(bundle);
+            if (localizations) {
+                CFStringRef en_US = CFSTR("en_US"), en = CFSTR("en"), English = CFSTR("English");
+                CFRange range = CFRangeMake(0, CFArrayGetCount(localizations));
+                if (CFArrayContainsValue(localizations, range, en)) {
+                    if (!CFArrayContainsValue(langs, CFRangeMake(0, CFArrayGetCount(langs)), en)) CFArrayAppendValue(langs, en);
+                } else if (CFArrayContainsValue(localizations, range, English)) {
+                    if (!CFArrayContainsValue(langs, CFRangeMake(0, CFArrayGetCount(langs)), English)) CFArrayAppendValue(langs, English);
+                } else if (CFArrayContainsValue(localizations, range, en_US)) {
+                    if (!CFArrayContainsValue(langs, CFRangeMake(0, CFArrayGetCount(langs)), en_US)) CFArrayAppendValue(langs, en_US);
+                }
+                CFRelease(localizations);
+            }
+        }
+        if (CFArrayGetCount(langs) == 0) {
+            // Total backstop behavior to avoid having an empty array.
+            if (_defaultLocalization) {
+                CFArrayAppendValue(langs, _defaultLocalization);
+            } else {
+                CFArrayAppendValue(langs, CFSTR("en"));
+            }
+        }
+        bundle->_searchLanguages = langs;
+    }
+    return bundle->_searchLanguages;
+}
+
+CFDictionaryRef CFBundleCopyInfoDictionaryInDirectory(CFURLRef url) {return _CFBundleCopyInfoDictionaryInDirectory(kCFAllocatorSystemDefault, url, NULL);}
+
+CFDictionaryRef CFBundleGetInfoDictionary(CFBundleRef bundle) {
+    if (!bundle->_infoDict) bundle->_infoDict = _CFBundleCopyInfoDictionaryInDirectoryWithVersion(CFGetAllocator(bundle), bundle->_url, bundle->_version);
+    return bundle->_infoDict;
+}
+
+CFDictionaryRef _CFBundleGetLocalInfoDictionary(CFBundleRef bundle) {return CFBundleGetLocalInfoDictionary(bundle);}
+
+CFDictionaryRef CFBundleGetLocalInfoDictionary(CFBundleRef bundle) {
+    if (!bundle->_localInfoDict) {
+        CFURLRef url = CFBundleCopyResourceURL(bundle, _CFBundleLocalInfoName, _CFBundleStringTableType, NULL);
+        if (url) {
+            CFDataRef data;
+            SInt32 errCode;
+            CFStringRef errStr = NULL;
+            
+            if (CFURLCreateDataAndPropertiesFromResource(CFGetAllocator(bundle), url, &data, NULL, NULL, &errCode)) {
+                bundle->_localInfoDict = (CFDictionaryRef)CFPropertyListCreateFromXMLData(CFGetAllocator(bundle), data, kCFPropertyListImmutable, &errStr);
+                if (errStr) CFRelease(errStr);
+                if (bundle->_localInfoDict && CFDictionaryGetTypeID() != CFGetTypeID(bundle->_localInfoDict)) {
+                    CFRelease(bundle->_localInfoDict);
+                    bundle->_localInfoDict = NULL;
+                }
+                CFRelease(data);
+            }
+            CFRelease(url);
+        }
+    }
+    return bundle->_localInfoDict;
+}
+
+CFPropertyListRef _CFBundleGetValueForInfoKey(CFBundleRef bundle, CFStringRef key) {return (CFPropertyListRef)CFBundleGetValueForInfoDictionaryKey(bundle, key);}
+
+CFTypeRef CFBundleGetValueForInfoDictionaryKey(CFBundleRef bundle, CFStringRef key) {
+    // Look in InfoPlist.strings first.  Then look in Info.plist
+    CFTypeRef result = NULL;
+    if (bundle && key) {
+        CFDictionaryRef dict = CFBundleGetLocalInfoDictionary(bundle);
+        if (dict) result = CFDictionaryGetValue(dict, key);
+        if (!result) {
+            dict = CFBundleGetInfoDictionary(bundle);
+            if (dict) result = CFDictionaryGetValue(dict, key);
+        }
+    }
+    return result;
+}
+
+CFStringRef CFBundleGetIdentifier(CFBundleRef bundle) {
+    CFStringRef bundleID = NULL;
+    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+    if (infoDict) bundleID = (CFStringRef)CFDictionaryGetValue(infoDict, kCFBundleIdentifierKey);
+    return bundleID;
+}
+
+#define DEVELOPMENT_STAGE 0x20
+#define ALPHA_STAGE 0x40
+#define BETA_STAGE 0x60
+#define RELEASE_STAGE 0x80
+
+#define MAX_VERS_LEN 10
+
+CF_INLINE Boolean _isDigit(UniChar aChar) {return (((aChar >= (UniChar)'0') && (aChar <= (UniChar)'9')) ? true : false);}
+
+__private_extern__ CFStringRef _CFCreateStringFromVersionNumber(CFAllocatorRef alloc, UInt32 vers) {
+    CFStringRef result = NULL;
+    uint8_t major1, major2, minor1, minor2, stage, build;
+
+    major1 = (vers & 0xF0000000) >> 28;
+    major2 = (vers & 0x0F000000) >> 24;
+    minor1 = (vers & 0x00F00000) >> 20;
+    minor2 = (vers & 0x000F0000) >> 16;
+    stage = (vers & 0x0000FF00) >> 8;
+    build = (vers & 0x000000FF);
+
+    if (stage == RELEASE_STAGE) {
+        if (major1 > 0) {
+            result = CFStringCreateWithFormat(alloc, NULL, CFSTR("%d%d.%d.%d"), major1, major2, minor1, minor2);
+        } else {
+            result = CFStringCreateWithFormat(alloc, NULL, CFSTR("%d.%d.%d"), major2, minor1, minor2);
+        }
+    } else {
+        if (major1 > 0) {
+            result = CFStringCreateWithFormat(alloc, NULL, CFSTR("%d%d.%d.%d%s%d"), major1, major2, minor1, minor2, ((stage == DEVELOPMENT_STAGE) ? "d" : ((stage == ALPHA_STAGE) ? "a" : "b")), build);
+        } else {
+            result = CFStringCreateWithFormat(alloc, NULL, CFSTR("%d.%d.%d%s%d"), major2, minor1, minor2, ((stage == DEVELOPMENT_STAGE) ? "d" : ((stage == ALPHA_STAGE) ? "a" : "b")), build);
+        }
+    }
+    return result;
+}
+
+__private_extern__ UInt32 _CFVersionNumberFromString(CFStringRef versStr) {
+    // Parse version number from string.
+    // String can begin with "." for major version number 0.  String can end at any point, but elements within the string cannot be skipped.
+    UInt32 major1 = 0, major2 = 0, minor1 = 0, minor2 = 0, stage = RELEASE_STAGE, build = 0;
+    UniChar versChars[MAX_VERS_LEN];
+    UniChar *chars = NULL;
+    CFIndex len;
+    UInt32 theVers;
+    Boolean digitsDone = false;
+
+    if (!versStr) return 0;
+
+    len = CFStringGetLength(versStr);
+
+    if ((len == 0) || (len > MAX_VERS_LEN)) return 0;
+
+    CFStringGetCharacters(versStr, CFRangeMake(0, len), versChars);
+    chars = versChars;
+    
+    // Get major version number.
+    major1 = major2 = 0;
+    if (_isDigit(*chars)) {
+        major2 = *chars - (UniChar)'0';
+        chars++;
+        len--;
+        if (len > 0) {
+            if (_isDigit(*chars)) {
+                major1 = major2;
+                major2 = *chars - (UniChar)'0';
+                chars++;
+                len--;
+                if (len > 0) {
+                    if (*chars == (UniChar)'.') {
+                        chars++;
+                        len--;
+                    } else {
+                        digitsDone = true;
+                    }
+                }
+            } else if (*chars == (UniChar)'.') {
+                chars++;
+                len--;
+            } else {
+                digitsDone = true;
+            }
+        }
+    } else if (*chars == (UniChar)'.') {
+        chars++;
+        len--;
+    } else {
+        digitsDone = true;
+    }
+
+    // Now major1 and major2 contain first and second digit of the major version number as ints.
+    // Now either len is 0 or chars points at the first char beyond the first decimal point.
+
+    // Get the first minor version number.  
+    if (len > 0 && !digitsDone) {
+        if (_isDigit(*chars)) {
+            minor1 = *chars - (UniChar)'0';
+            chars++;
+            len--;
+            if (len > 0) {
+                if (*chars == (UniChar)'.') {
+                    chars++;
+                    len--;
+                } else {
+                    digitsDone = true;
+                }
+            }
+        } else {
+            digitsDone = true;
+        }
+    }
+
+    // Now minor1 contains the first minor version number as an int.
+    // Now either len is 0 or chars points at the first char beyond the second decimal point.
+
+    // Get the second minor version number. 
+    if (len > 0 && !digitsDone) {
+        if (_isDigit(*chars)) {
+            minor2 = *chars - (UniChar)'0';
+            chars++;
+            len--;
+        } else {
+            digitsDone = true;
+        }
+    }
+
+    // Now minor2 contains the second minor version number as an int.
+    // Now either len is 0 or chars points at the build stage letter.
+
+    // Get the build stage letter.  We must find 'd', 'a', 'b', or 'f' next, if there is anything next.
+    if (len > 0) {
+        if (*chars == (UniChar)'d') {
+            stage = DEVELOPMENT_STAGE;
+        } else if (*chars == (UniChar)'a') {
+            stage = ALPHA_STAGE;
+        } else if (*chars == (UniChar)'b') {
+            stage = BETA_STAGE;
+        } else if (*chars == (UniChar)'f') {
+            stage = RELEASE_STAGE;
+        } else {
+            return 0;
+        }
+        chars++;
+        len--;
+    }
+
+    // Now stage contains the release stage.
+    // Now either len is 0 or chars points at the build number.
+
+    // Get the first digit of the build number.
+    if (len > 0) {
+        if (_isDigit(*chars)) {
+            build = *chars - (UniChar)'0';
+            chars++;
+            len--;
+        } else {
+            return 0;
+        }
+    }
+    // Get the second digit of the build number.
+    if (len > 0) {
+        if (_isDigit(*chars)) {
+            build *= 10;
+            build += *chars - (UniChar)'0';
+            chars++;
+            len--;
+        } else {
+            return 0;
+        }
+    }
+    // Get the third digit of the build number.
+    if (len > 0) {
+        if (_isDigit(*chars)) {
+            build *= 10;
+            build += *chars - (UniChar)'0';
+            chars++;
+            len--;
+        } else {
+            return 0;
+        }
+    }
+
+    // Range check the build number and make sure we exhausted the string.
+    if ((build > 0xFF) || (len > 0)) return 0;
+
+    // Build the number
+    theVers = major1 << 28;
+    theVers += major2 << 24;
+    theVers += minor1 << 20;
+    theVers += minor2 << 16;
+    theVers += stage << 8;
+    theVers += build;
+
+    return theVers;
+}
+
+UInt32 CFBundleGetVersionNumber(CFBundleRef bundle) {
+    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+    CFTypeRef unknownVersionValue = CFDictionaryGetValue(infoDict, _kCFBundleNumericVersionKey);
+    CFNumberRef versNum;
+    UInt32 vers = 0;
+
+    if (!unknownVersionValue) unknownVersionValue = CFDictionaryGetValue(infoDict, kCFBundleVersionKey);
+    if (unknownVersionValue) {
+        if (CFGetTypeID(unknownVersionValue) == CFStringGetTypeID()) {
+            // Convert a string version number into a numeric one.
+            vers = _CFVersionNumberFromString((CFStringRef)unknownVersionValue);
+
+            versNum = CFNumberCreate(CFGetAllocator(bundle), kCFNumberSInt32Type, &vers);
+            CFDictionarySetValue((CFMutableDictionaryRef)infoDict, _kCFBundleNumericVersionKey, versNum);
+            CFRelease(versNum);
+        } else if (CFGetTypeID(unknownVersionValue) == CFNumberGetTypeID()) {
+            CFNumberGetValue((CFNumberRef)unknownVersionValue, kCFNumberSInt32Type, &vers);
+        } else {
+            CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, _kCFBundleNumericVersionKey);
+        }
+    }
+    return vers;
+}
+
+CFStringRef CFBundleGetDevelopmentRegion(CFBundleRef bundle) {
+    CFStringRef devLang = NULL;
+    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+    if (infoDict) {
+        devLang = (CFStringRef)CFDictionaryGetValue(infoDict, kCFBundleDevelopmentRegionKey);
+        if (devLang && (CFGetTypeID(devLang) != CFStringGetTypeID() || CFStringGetLength(devLang) == 0)) {
+            devLang = NULL;
+            CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, kCFBundleDevelopmentRegionKey);
+        }
+    }
+
+    return devLang;
+}
+
+Boolean _CFBundleGetHasChanged(CFBundleRef bundle) {
+    CFDateRef modDate;
+    Boolean result = false;
+    Boolean exists = false;
+    SInt32 mode = 0;
+
+    if (_CFGetFileProperties(CFGetAllocator(bundle), bundle->_url, &exists, &mode, NULL, &modDate, NULL, NULL) == 0) {
+        // If the bundle no longer exists or is not a folder, it must have "changed"
+        if (!exists || ((mode & S_IFMT) != S_IFDIR)) result = true;
+    } else {
+        // Something is wrong.  The stat failed.
+        result = true;
+    }
+    if (bundle->_modDate && !CFEqual(bundle->_modDate, modDate)) {
+        // mod date is different from when we created.
+        result = true;
+    }
+    CFRelease(modDate);
+    return result;
+}
+
+void _CFBundleSetStringsFilesShared(CFBundleRef bundle, Boolean flag) {
+    bundle->_sharesStringsFiles = flag;
+}
+
+Boolean _CFBundleGetStringsFilesShared(CFBundleRef bundle) {
+    return bundle->_sharesStringsFiles;
+}
+
+static Boolean _urlExists(CFAllocatorRef alloc, CFURLRef url) {
+    Boolean exists;
+    return url && (0 == _CFGetFileProperties(alloc, url, &exists, NULL, NULL, NULL, NULL, NULL)) && exists;
+}
+
+__private_extern__ CFURLRef _CFBundleCopySupportFilesDirectoryURLInDirectory(CFAllocatorRef alloc, CFURLRef bundleURL, uint8_t version) {
+    CFURLRef result = NULL;
+    if (bundleURL) {
+        if (1 == version) {
+            result = CFURLCreateWithString(alloc, _CFBundleSupportFilesURLFromBase1, bundleURL);
+        } else if (2 == version) {
+            result = CFURLCreateWithString(alloc, _CFBundleSupportFilesURLFromBase2, bundleURL);
+        } else {
+            result = (CFURLRef)CFRetain(bundleURL);
+        }
+    }
+    return result;
+}
+
+CF_EXPORT CFURLRef CFBundleCopySupportFilesDirectoryURL(CFBundleRef bundle) {return _CFBundleCopySupportFilesDirectoryURLInDirectory(CFGetAllocator(bundle), bundle->_url, bundle->_version);}
+
+__private_extern__ CFURLRef _CFBundleCopyResourcesDirectoryURLInDirectory(CFAllocatorRef alloc, CFURLRef bundleURL, uint8_t version) {
+    CFURLRef result = NULL;
+    if (bundleURL) {
+        if (0 == version) {
+            result = CFURLCreateWithString(alloc, _CFBundleResourcesURLFromBase0, bundleURL);
+        } else if (1 == version) {
+            result = CFURLCreateWithString(alloc, _CFBundleResourcesURLFromBase1, bundleURL);
+        } else if (2 == version) {
+            result = CFURLCreateWithString(alloc, _CFBundleResourcesURLFromBase2, bundleURL);
+        } else {
+            result = (CFURLRef)CFRetain(bundleURL);
+        }
+    }
+    return result;
+}
+
+CFURLRef CFBundleCopyResourcesDirectoryURL(CFBundleRef bundle) {return _CFBundleCopyResourcesDirectoryURLInDirectory(CFGetAllocator(bundle), bundle->_url, bundle->_version);}
+
+static CFURLRef _CFBundleCopyExecutableURLRaw(CFAllocatorRef alloc, CFURLRef urlPath, CFStringRef exeName) {
+    // Given an url to a folder and a name, this returns the url to the executable in that folder with that name, if it exists, and NULL otherwise.  This function deals with appending the ".exe" or ".dll" on Windows.
+    CFURLRef executableURL = NULL;
+    if (!urlPath || !exeName) return NULL;
+    
+#if DEPLOYMENT_TARGET_MACOSX
+    const uint8_t *image_suffix = (uint8_t *)getenv("DYLD_IMAGE_SUFFIX");
+    if (image_suffix) {
+        CFStringRef newExeName, imageSuffix;
+        imageSuffix = CFStringCreateWithCString(kCFAllocatorSystemDefault, (char *)image_suffix, kCFStringEncodingUTF8);
+        if (CFStringHasSuffix(exeName, CFSTR(".dylib"))) {
+            CFStringRef bareExeName = CFStringCreateWithSubstring(alloc, exeName, CFRangeMake(0, CFStringGetLength(exeName)-6));
+            newExeName = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@%@.dylib"), exeName, imageSuffix);
+            CFRelease(bareExeName);
+        } else {
+            newExeName = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@%@"), exeName, imageSuffix);
+        }
+        executableURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, newExeName, kCFURLPOSIXPathStyle, false, urlPath);
+        if (executableURL && !_urlExists(alloc, executableURL)) {
+            CFRelease(executableURL);
+            executableURL = NULL;
+        }
+        CFRelease(newExeName);
+        CFRelease(imageSuffix);
+    }
+#endif
+    if (!executableURL) {
+        executableURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, exeName, kCFURLPOSIXPathStyle, false, urlPath);
+        if (executableURL && !_urlExists(alloc, executableURL)) {
+            CFRelease(executableURL);
+            executableURL = NULL;
+        }
+    }
+#if defined(DEPLOYMENT_TARGET_WINDOWS)
+    if (executableURL == NULL) {
+        if (!CFStringHasSuffix(exeName, CFSTR(".dll"))) {
+            CFStringRef newExeName = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@%@"), exeName, CFSTR(".dll"));
+            executableURL = CFURLCreateWithString(alloc, newExeName, urlPath);
+            if (executableURL != NULL && !_urlExists(alloc, executableURL)) {
+                CFRelease(executableURL);
+                executableURL = NULL;
+            }
+            CFRelease(newExeName);
+        }
+    }
+    if (executableURL == NULL) {
+        if (!CFStringHasSuffix(exeName, CFSTR(".exe"))) {
+            CFStringRef newExeName = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@%@"), exeName, CFSTR(".exe"));
+            executableURL = CFURLCreateWithString(alloc, newExeName, urlPath);
+            if (executableURL != NULL && !_urlExists(alloc, executableURL)) {
+                CFRelease(executableURL);
+                executableURL = NULL;
+            }
+            CFRelease(newExeName);
+        }
+    }
+#endif
+    return executableURL;
+}
+
+static CFStringRef _CFBundleCopyExecutableName(CFAllocatorRef alloc, CFBundleRef bundle, CFURLRef url, CFDictionaryRef infoDict) {
+    CFStringRef executableName = NULL;
+    
+    if (!alloc && bundle) alloc = CFGetAllocator(bundle);
+    if (!infoDict && bundle) infoDict = CFBundleGetInfoDictionary(bundle);
+    if (!url && bundle) url = bundle->_url;
+    
+    if (infoDict) {
+        // Figure out the name of the executable.
+        // First try for the new key in the plist.
+        executableName = (CFStringRef)CFDictionaryGetValue(infoDict, kCFBundleExecutableKey);
+        // Second try for the old key in the plist.
+        if (!executableName) executableName = (CFStringRef)CFDictionaryGetValue(infoDict, _kCFBundleOldExecutableKey);
+        if (executableName && CFGetTypeID(executableName) == CFStringGetTypeID() && CFStringGetLength(executableName) > 0) {
+            CFRetain(executableName);
+        } else {
+            executableName = NULL;
+        }
+    }
+    if (!executableName && url) {
+        // Third, take the name of the bundle itself (with path extension stripped)
+        CFURLRef absoluteURL = CFURLCopyAbsoluteURL(url);
+        CFStringRef bundlePath = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+        UniChar buff[CFMaxPathSize];
+        CFIndex len = CFStringGetLength(bundlePath);
+        CFIndex startOfBundleName, endOfBundleName;
+
+        CFRelease(absoluteURL);
+        if (len > CFMaxPathSize) len = CFMaxPathSize;
+        CFStringGetCharacters(bundlePath, CFRangeMake(0, len), buff);
+        startOfBundleName = _CFStartOfLastPathComponent(buff, len);
+        endOfBundleName = _CFLengthAfterDeletingPathExtension(buff, len);
+
+        if ((startOfBundleName <= len) && (endOfBundleName <= len) && (startOfBundleName < endOfBundleName)) {
+            executableName = CFStringCreateWithCharacters(alloc, &(buff[startOfBundleName]), (endOfBundleName - startOfBundleName));
+        }
+        CFRelease(bundlePath);
+    }
+    
+    return executableName;
+}
+
+__private_extern__ CFURLRef _CFBundleCopyResourceForkURLMayBeLocal(CFBundleRef bundle, Boolean mayBeLocal) {
+    CFStringRef executableName = _CFBundleCopyExecutableName(kCFAllocatorSystemDefault, bundle, NULL, NULL);
+    CFURLRef resourceForkURL = NULL;
+    if (executableName) {
+        if (mayBeLocal) {
+            resourceForkURL = CFBundleCopyResourceURL(bundle, executableName, CFSTR("rsrc"), NULL);
+        } else {
+            resourceForkURL = CFBundleCopyResourceURLForLocalization(bundle, executableName, CFSTR("rsrc"), NULL, NULL);
+        }
+        CFRelease(executableName);
+    }
+    
+    return resourceForkURL;
+}
+
+CFURLRef _CFBundleCopyResourceForkURL(CFBundleRef bundle) {return _CFBundleCopyResourceForkURLMayBeLocal(bundle, true);}
+
+static CFURLRef _CFBundleCopyExecutableURLInDirectoryWithAllocator(CFAllocatorRef alloc, CFBundleRef bundle, CFURLRef url, CFStringRef executableName, Boolean ignoreCache, Boolean useOtherPlatform) {
+    uint8_t version = 0;
+    CFDictionaryRef infoDict = NULL;
+    CFStringRef executablePath = NULL;
+    CFURLRef executableURL = NULL;
+    Boolean foundIt = false;
+    Boolean lookupMainExe = (executableName ? false : true);
+    
+    if (bundle) {
+        infoDict = CFBundleGetInfoDictionary(bundle);
+        version = bundle->_version;
+    } else {
+        infoDict = _CFBundleCopyInfoDictionaryInDirectory(alloc, url, &version);
+    }
+
+    // If we have a bundle instance and an info dict, see if we have already cached the path
+    if (lookupMainExe && !ignoreCache && !useOtherPlatform && bundle && infoDict) {
+        executablePath = (CFStringRef)CFDictionaryGetValue(infoDict, _kCFBundleExecutablePathKey);
+        if (executablePath) {
+#if DEPLOYMENT_TARGET_MACOSX
+            executableURL = CFURLCreateWithFileSystemPath(alloc, executablePath, kCFURLPOSIXPathStyle, false);
+#else
+            executableURL = CFURLCreateWithFileSystemPath(alloc, executablePath, kCFURLWindowsPathStyle, false);
+#endif
+            if (executableURL) foundIt = true;
+            if (!foundIt) {
+                executablePath = NULL;
+                CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, _kCFBundleExecutablePathKey);
+            }
+        }
+    }
+
+    if (!foundIt) {
+        if (lookupMainExe) {
+            executableName = _CFBundleCopyExecutableName(alloc, bundle, url, infoDict);
+        }
+        if (executableName) {
+            Boolean doExecSearch = true;
+            // Now, look for the executable inside the bundle.
+            if (doExecSearch && 0 != version) {
+                CFURLRef exeDirURL;
+                CFURLRef exeSubdirURL;
+
+                if (1 == version) {
+                    exeDirURL = CFURLCreateWithString(alloc, _CFBundleExecutablesURLFromBase1, url);
+                } else if (2 == version) {
+                    exeDirURL = CFURLCreateWithString(alloc, _CFBundleExecutablesURLFromBase2, url);
+                } else {
+                    exeDirURL = (CFURLRef)CFRetain(url);
+                }
+                CFStringRef platformSubDir = useOtherPlatform ? _CFBundleGetOtherPlatformExecutablesSubdirectoryName() : _CFBundleGetPlatformExecutablesSubdirectoryName();
+                exeSubdirURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, platformSubDir, kCFURLPOSIXPathStyle, true, exeDirURL);
+                executableURL = _CFBundleCopyExecutableURLRaw(alloc, exeSubdirURL, executableName);
+                if (!executableURL) {
+                    CFRelease(exeSubdirURL);
+                    platformSubDir = useOtherPlatform ? _CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName() : _CFBundleGetAlternatePlatformExecutablesSubdirectoryName();
+                    exeSubdirURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, platformSubDir, kCFURLPOSIXPathStyle, true, exeDirURL);
+                    executableURL = _CFBundleCopyExecutableURLRaw(alloc, exeSubdirURL, executableName);
+                }
+                if (!executableURL) {
+                    CFRelease(exeSubdirURL);
+                    platformSubDir = useOtherPlatform ? _CFBundleGetPlatformExecutablesSubdirectoryName() : _CFBundleGetOtherPlatformExecutablesSubdirectoryName();
+                    exeSubdirURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, platformSubDir, kCFURLPOSIXPathStyle, true, exeDirURL);
+                    executableURL = _CFBundleCopyExecutableURLRaw(alloc, exeSubdirURL, executableName);
+                }
+                if (!executableURL) {
+                    CFRelease(exeSubdirURL);
+                    platformSubDir = useOtherPlatform ? _CFBundleGetAlternatePlatformExecutablesSubdirectoryName() : _CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName();
+                    exeSubdirURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, platformSubDir, kCFURLPOSIXPathStyle, true, exeDirURL);
+                    executableURL = _CFBundleCopyExecutableURLRaw(alloc, exeSubdirURL, executableName);
+                }
+                if (!executableURL) {
+                    executableURL = _CFBundleCopyExecutableURLRaw(alloc, exeDirURL, executableName);
+                }
+
+                CFRelease(exeDirURL);
+                CFRelease(exeSubdirURL);
+            }
+
+#if defined(DEPLOYMENT_TARGET_WINDOWS)
+            // Windows only: If we still haven't found the exe, look in the Executables folder.
+            // But only for the main bundle exe
+            if (lookupMainExe && (executableURL == NULL)) {
+                CFURLRef exeDirURL;
+
+                exeDirURL = CFURLCreateWithString(alloc, CFSTR("../../Executables"), url);
+
+                executableURL = _CFBundleCopyExecutableURLRaw(alloc, exeDirURL, executableName);
+
+                CFRelease(exeDirURL);
+            }
+#endif
+
+            // If this was an old bundle, or we did not find the executable in the Excutables subdirectory, look directly in the bundle wrapper.
+            if (!executableURL) executableURL = _CFBundleCopyExecutableURLRaw(alloc, url, executableName);
+            if (lookupMainExe && !ignoreCache && !useOtherPlatform && bundle && infoDict && executableURL) {
+                // We found it.  Cache the path.
+                CFURLRef absURL = CFURLCopyAbsoluteURL(executableURL);
+#if DEPLOYMENT_TARGET_MACOSX
+                executablePath = CFURLCopyFileSystemPath(absURL, kCFURLPOSIXPathStyle);
+#else
+                executablePath = CFURLCopyFileSystemPath(absURL, kCFURLWindowsPathStyle);
+#endif
+                CFRelease(absURL);
+                CFDictionarySetValue((CFMutableDictionaryRef)infoDict, _kCFBundleExecutablePathKey, executablePath);
+                CFRelease(executablePath);
+            }
+            if (lookupMainExe && !useOtherPlatform && bundle && !executableURL) bundle->_binaryType = __CFBundleNoBinary;
+            if (lookupMainExe) CFRelease(executableName);
+        }
+    }
+
+    if (!bundle && infoDict) CFRelease(infoDict);
+
+    return executableURL;
+}
+
+CFURLRef _CFBundleCopyExecutableURLInDirectory(CFURLRef url) {return _CFBundleCopyExecutableURLInDirectoryWithAllocator(kCFAllocatorSystemDefault, NULL, url, NULL, true, false);}
+
+CFURLRef _CFBundleCopyOtherExecutableURLInDirectory(CFURLRef url) {return _CFBundleCopyExecutableURLInDirectoryWithAllocator(kCFAllocatorSystemDefault, NULL, url, NULL, true, true);}
+
+CFURLRef CFBundleCopyExecutableURL(CFBundleRef bundle) {return _CFBundleCopyExecutableURLInDirectoryWithAllocator(CFGetAllocator(bundle), bundle, bundle->_url, NULL, false, false);}
+
+static CFURLRef _CFBundleCopyExecutableURLIgnoringCache(CFBundleRef bundle) {return _CFBundleCopyExecutableURLInDirectoryWithAllocator(CFGetAllocator(bundle), bundle, bundle->_url, NULL, true, false);}
+
+CFURLRef CFBundleCopyAuxiliaryExecutableURL(CFBundleRef bundle, CFStringRef executableName) {return _CFBundleCopyExecutableURLInDirectoryWithAllocator(CFGetAllocator(bundle), bundle, bundle->_url, executableName, true, false);}
+
+Boolean CFBundleIsExecutableLoaded(CFBundleRef bundle) {return bundle->_isLoaded;}
+
+CFBundleExecutableType CFBundleGetExecutableType(CFBundleRef bundle) {
+    CFBundleExecutableType result = kCFBundleOtherExecutableType;
+    CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+
+    if (!executableURL) bundle->_binaryType = __CFBundleNoBinary;
+#if defined(BINARY_SUPPORT_DYLD)
+    if (bundle->_binaryType == __CFBundleUnknownBinary) {
+        bundle->_binaryType = _CFBundleGrokBinaryType(executableURL);
+#if defined(BINARY_SUPPORT_CFM)
+        if (bundle->_binaryType != __CFBundleCFMBinary && bundle->_binaryType != __CFBundleUnreadableBinary) bundle->_resourceData._executableLacksResourceFork = true;
+#endif /* BINARY_SUPPORT_CFM */
+    }
+#endif /* BINARY_SUPPORT_DYLD */
+    if (executableURL) CFRelease(executableURL);
+
+    if (bundle->_binaryType == __CFBundleCFMBinary) {
+        result = kCFBundlePEFExecutableType;
+    } else if (bundle->_binaryType == __CFBundleDYLDExecutableBinary || bundle->_binaryType == __CFBundleDYLDBundleBinary || bundle->_binaryType == __CFBundleDYLDFrameworkBinary) {
+        result = kCFBundleMachOExecutableType;
+    } else if (bundle->_binaryType == __CFBundleDLLBinary) {
+        result = kCFBundleDLLExecutableType;
+    } else if (bundle->_binaryType == __CFBundleELFBinary) {
+        result = kCFBundleELFExecutableType;    
+    }
+    return result;
+}
+
+#define UNKNOWN_FILETYPE 0x0
+#define PEF_FILETYPE 0x1000
+#define PEF_MAGIC 0x4a6f7921
+#define PEF_CIGAM 0x21796f4a
+#define TEXT_SEGMENT "__TEXT"
+#define PLIST_SECTION "__info_plist"
+#define OBJC_SEGMENT "__OBJC"
+#define IMAGE_INFO_SECTION "__image_info"
+#define LIB_X11 "/usr/X11R6/lib/libX"
+
+#define XLS_NAME "Book"
+#define XLS_NAME2 "Workbook"
+#define DOC_NAME "WordDocument"
+#define PPT_NAME "PowerPoint Document"
+
+#define ustrncmp(x, y, z) strncmp((char *)(x), (char *)(y), (z))
+#if DEPLOYMENT_TARGET_WINDOWS
+#if _MSC_VER
+#define ustrncasecmp(x, y, z) _strnicmp_l((char *)(x), (char *)(y), (z), NULL)
+#else
+#define ustrncasecmp(x, y, z) strncasecmp((char *)(x), (char *)(y), (z))
+#endif
+#elif DEPLOYMENT_TARGET_LINUX
+// When compiling with -Wall the GNU C library complains about passing
+// NULL to strncasecmp_l as the locale. Since a locale is never
+// passed, the C locale version should be a suitable replacement.
+#define ustrncasecmp(x, y, z) strncasecmp((char *)(x), (char *)(y), (z))
+#else
+#define ustrncasecmp(x, y, z) strncasecmp_l((char *)(x), (char *)(y), (z), NULL)
+#endif
+
+static const uint32_t __CFBundleMagicNumbersArray[] = {
+    0xcafebabe, 0xbebafeca, 0xfeedface, 0xcefaedfe, 0xfeedfacf, 0xcffaedfe, 0x4a6f7921, 0x21796f4a, 
+    0x7f454c46, 0xffd8ffe0, 0x4d4d002a, 0x49492a00, 0x47494638, 0x89504e47, 0x69636e73, 0x00000100, 
+    0x7b5c7274, 0x25504446, 0x2e7261fd, 0x2e524d46, 0x2e736e64, 0x2e736400, 0x464f524d, 0x52494646, 
+    0x38425053, 0x000001b3, 0x000001ba, 0x4d546864, 0x504b0304, 0x53495421, 0x53495432, 0x53495435, 
+    0x53495444, 0x53747566, 0x30373037, 0x3c212d2d, 0x25215053, 0xd0cf11e0, 0x62656769, 0x3d796265,
+    0x6b6f6c79, 0x3026b275, 0x0000000c, 0xfe370023, 0x09020600, 0x09040600, 0x4f676753, 0x664c6143, 
+    0x00010000, 0x74727565, 0x4f54544f, 0x41433130, 0xc809fe02, 0x0809fe02, 0x2356524d, 0x67696d70, 
+    0x3c435058, 0x28445746, 0x424f4d53, 0x49544f4c, 0x72746664
+};
+
+// string, with groups of 5 characters being 1 element in the array
+static const char * __CFBundleExtensionsArray =
+    "mach\0"  "mach\0"  "mach\0"  "mach\0"  "mach\0"  "mach\0"  "pef\0\0" "pef\0\0" 
+    "elf\0\0" "jpeg\0"  "tiff\0"  "tiff\0"  "gif\0\0" "png\0\0" "icns\0"  "ico\0\0" 
+    "rtf\0\0" "pdf\0\0" "ra\0\0\0""rm\0\0\0""au\0\0\0""au\0\0\0""iff\0\0" "riff\0"  
+    "psd\0\0" "mpeg\0"  "mpeg\0"  "mid\0\0" "zip\0\0" "sit\0\0" "sit\0\0" "sit\0\0" 
+    "sit\0\0" "sit\0\0" "cpio\0"  "html\0"  "ps\0\0\0""ole\0\0" "uu\0\0\0""ync\0\0"
+    "dmg\0\0" "wmv\0\0" "jp2\0\0" "doc\0\0" "xls\0\0" "xls\0\0" "ogg\0\0" "flac\0"
+    "ttf\0\0" "ttf\0\0" "otf\0\0" "dwg\0\0" "dgn\0\0" "dgn\0\0" "wrl\0\0" "xcf\0\0"
+    "cpx\0\0" "dwf\0\0" "bom\0\0" "lit\0\0" "rtfd\0";
+
+static const char * __CFBundleOOExtensionsArray = "sxc\0\0" "sxd\0\0" "sxg\0\0" "sxi\0\0" "sxm\0\0" "sxw\0\0";
+static const char * __CFBundleODExtensionsArray = "odc\0\0" "odf\0\0" "odg\0\0" "oth\0\0" "odi\0\0" "odm\0\0" "odp\0\0" "ods\0\0" "odt\0\0";
+
+#define EXTENSION_LENGTH                5
+#define NUM_EXTENSIONS                  61
+#define MAGIC_BYTES_TO_READ             512
+#define DMG_BYTES_TO_READ               512
+#define ZIP_BYTES_TO_READ               1024
+#define OLE_BYTES_TO_READ               512
+#define X11_BYTES_TO_READ               4096
+#define IMAGE_INFO_BYTES_TO_READ        4096
+
+#if defined(BINARY_SUPPORT_DYLD)
+
+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;}
+
+static CFDictionaryRef _CFBundleGrokInfoDictFromData(const char *bytes, uint32_t length) {
+    CFMutableDictionaryRef result = NULL;
+    CFDataRef infoData = NULL;
+    if (bytes && 0 < length) {
+        infoData = CFDataCreateWithBytesNoCopy(kCFAllocatorSystemDefault, (uint8_t *)bytes, length, kCFAllocatorNull);
+        if (infoData) {
+            result = (CFMutableDictionaryRef)CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, infoData, kCFPropertyListMutableContainers, NULL);
+            if (result && CFDictionaryGetTypeID() != CFGetTypeID(result)) {
+                CFRelease(result);
+                result = NULL;
+            }
+            CFRelease(infoData);
+        }
+        if (!result) result = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    }
+    return result;
+}
+
+static CFDictionaryRef _CFBundleGrokInfoDictFromMainExecutable() {
+    unsigned long length = 0;
+    char *bytes = getsectdata(TEXT_SEGMENT, PLIST_SECTION, &length);
+    return _CFBundleGrokInfoDictFromData(bytes, length);
+}
+
+static Boolean _CFBundleGrokObjCImageInfoFromMainExecutable(uint32_t *objcVersion, uint32_t *objcFlags) {
+    Boolean retval = false;
+    uint32_t localVersion = 0, localFlags = 0;
+    if (getsegbyname(OBJC_SEGMENT)) {
+        unsigned long length = 0;
+        char *bytes = getsectdata(OBJC_SEGMENT, IMAGE_INFO_SECTION, &length);
+        if (bytes && length >= 8) {
+            localVersion = *(uint32_t *)bytes;
+            localFlags = *(uint32_t *)(bytes + 4);
+        }
+        retval = true;
+    }
+    if (objcVersion) *objcVersion = localVersion;
+    if (objcFlags) *objcFlags = localFlags;
+    return retval;
+}
+
+static Boolean _CFBundleGrokX11FromFile(int fd, const void *bytes, CFIndex length, uint32_t offset, Boolean swapped, Boolean sixtyFour) {
+    static const char libX11name[] = LIB_X11;
+    char *buffer = NULL;
+    const char *loc = NULL;
+    unsigned i;
+    Boolean result = false;
+    
+    if (fd >= 0 && lseek(fd, offset, SEEK_SET) == (off_t)offset) {
+        buffer = (char*)malloc(X11_BYTES_TO_READ);
+        if (buffer && read(fd, buffer, X11_BYTES_TO_READ) >= X11_BYTES_TO_READ) loc = buffer;
+    } else if (bytes && length >= offset + X11_BYTES_TO_READ) {
+        loc = (const char*)bytes + offset;
+    }
+    if (loc) {
+        if (sixtyFour) {
+            uint32_t ncmds = _CFBundleSwapInt32Conditional(((struct mach_header_64 *)loc)->ncmds, swapped);
+            uint32_t sizeofcmds = _CFBundleSwapInt32Conditional(((struct mach_header_64 *)loc)->sizeofcmds, swapped);
+            const char *startofcmds = loc + sizeof(struct mach_header_64);
+            const char *endofcmds = startofcmds + sizeofcmds;
+            struct dylib_command *dlp = (struct dylib_command *)startofcmds;
+            if (endofcmds > loc + X11_BYTES_TO_READ) endofcmds = loc + X11_BYTES_TO_READ;
+            for (i = 0; !result && i < ncmds && startofcmds <= (char *)dlp && (char *)dlp < endofcmds; i++) {
+                if (LC_LOAD_DYLIB == _CFBundleSwapInt32Conditional(dlp->cmd, swapped)) {
+                    uint32_t nameoffset = _CFBundleSwapInt32Conditional(dlp->dylib.name.offset, swapped);
+                    const char *name = (const char *)dlp + nameoffset;
+                    if (startofcmds <= name && name + sizeof(libX11name) <= endofcmds && 0 == strncmp(name, libX11name, sizeof(libX11name) - 1)) result = true;
+                }
+                dlp = (struct dylib_command *)((char *)dlp + _CFBundleSwapInt32Conditional(dlp->cmdsize, swapped));
+            }
+        } else {
+            uint32_t ncmds = _CFBundleSwapInt32Conditional(((struct mach_header *)loc)->ncmds, swapped);
+            uint32_t sizeofcmds = _CFBundleSwapInt32Conditional(((struct mach_header *)loc)->sizeofcmds, swapped);
+            const char *startofcmds = loc + sizeof(struct mach_header);
+            const char *endofcmds = startofcmds + sizeofcmds;
+            struct dylib_command *dlp = (struct dylib_command *)startofcmds;
+            if (endofcmds > loc + X11_BYTES_TO_READ) endofcmds = loc + X11_BYTES_TO_READ;
+            for (i = 0; !result && i < ncmds && startofcmds <= (char *)dlp && (char *)dlp < endofcmds; i++) {
+                if (LC_LOAD_DYLIB == _CFBundleSwapInt32Conditional(dlp->cmd, swapped)) {
+                    uint32_t nameoffset = _CFBundleSwapInt32Conditional(dlp->dylib.name.offset, swapped);
+                    const char *name = (const char *)dlp + nameoffset;
+                    if (startofcmds <= name && name + sizeof(libX11name) <= endofcmds && 0 == strncmp(name, libX11name, sizeof(libX11name) - 1)) result = true;
+                }
+                dlp = (struct dylib_command *)((char *)dlp + _CFBundleSwapInt32Conditional(dlp->cmdsize, swapped));
+            }
+        }
+    }
+    
+    if (buffer) free(buffer);
+    
+    return result;
+}
+    
+static CFDictionaryRef _CFBundleGrokInfoDictFromFile(int fd, const void *bytes, CFIndex length, uint32_t offset, Boolean swapped, Boolean sixtyFour) {
+    struct stat statBuf;
+    off_t fileLength = 0;
+    char *maploc = NULL;
+    const char *loc;
+    unsigned i, j;
+    CFDictionaryRef result = NULL;
+    Boolean foundit = false;
+    if (fd >= 0 && fstat(fd, &statBuf) == 0 && (maploc = (char*)mmap(0, statBuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) != (void *)-1) {
+        loc = maploc;
+        fileLength = statBuf.st_size;
+    } else {
+        loc = (const char*)bytes;
+        fileLength = length;
+    }
+    if (fileLength > offset + sizeof(struct mach_header_64)) {
+        if (sixtyFour) {
+            uint32_t ncmds = _CFBundleSwapInt32Conditional(((struct mach_header_64 *)(loc + offset))->ncmds, swapped);
+            uint32_t sizeofcmds = _CFBundleSwapInt32Conditional(((struct mach_header_64 *)(loc + offset))->sizeofcmds, swapped);
+            const char *startofcmds = loc + offset + sizeof(struct mach_header_64);
+            const char *endofcmds = startofcmds + sizeofcmds;
+            struct segment_command_64 *sgp = (struct segment_command_64 *)startofcmds;
+            if (endofcmds > loc + fileLength) endofcmds = loc + fileLength;
+            for (i = 0; !foundit && i < ncmds && startofcmds <= (char *)sgp && (char *)sgp < endofcmds; i++) {
+                if (LC_SEGMENT_64 == _CFBundleSwapInt32Conditional(sgp->cmd, swapped)) {
+                    struct section_64 *sp = (struct section_64 *)((char *)sgp + sizeof(struct segment_command_64));
+                    uint32_t nsects = _CFBundleSwapInt32Conditional(sgp->nsects, swapped);
+                    for (j = 0; !foundit && j < nsects && startofcmds <= (char *)sp && (char *)sp < endofcmds; j++) {
+                        if (0 == strncmp(sp->sectname, PLIST_SECTION, sizeof(sp->sectname)) && 0 == strncmp(sp->segname, TEXT_SEGMENT, sizeof(sp->segname))) {
+                            uint64_t sectlength64 = _CFBundleSwapInt64Conditional(sp->size, swapped);
+                            uint32_t sectlength = (uint32_t)(sectlength64 & 0xffffffff);
+                            uint32_t sectoffset = _CFBundleSwapInt32Conditional(sp->offset, swapped);
+                            const char *sectbytes = loc + offset + sectoffset;
+                            // we don't support huge-sized plists
+                            if (sectlength64 <= 0xffffffff && loc <= sectbytes && sectbytes + sectlength <= loc + fileLength) result = _CFBundleGrokInfoDictFromData(sectbytes, sectlength);
+                            foundit = true;
+                        }
+                        sp = (struct section_64 *)((char *)sp + sizeof(struct section_64));
+                    }
+                }
+                sgp = (struct segment_command_64 *)((char *)sgp + _CFBundleSwapInt32Conditional(sgp->cmdsize, swapped));
+            }
+        } else {
+            uint32_t ncmds = _CFBundleSwapInt32Conditional(((struct mach_header *)(loc + offset))->ncmds, swapped);
+            uint32_t sizeofcmds = _CFBundleSwapInt32Conditional(((struct mach_header *)(loc + offset))->sizeofcmds, swapped);
+            const char *startofcmds = loc + offset + sizeof(struct mach_header);
+            const char *endofcmds = startofcmds + sizeofcmds;
+            struct segment_command *sgp = (struct segment_command *)startofcmds;
+            if (endofcmds > loc + fileLength) endofcmds = loc + fileLength;
+            for (i = 0; !foundit && i < ncmds && startofcmds <= (char *)sgp && (char *)sgp < endofcmds; i++) {
+                if (LC_SEGMENT == _CFBundleSwapInt32Conditional(sgp->cmd, swapped)) {
+                    struct section *sp = (struct section *)((char *)sgp + sizeof(struct segment_command));
+                    uint32_t nsects = _CFBundleSwapInt32Conditional(sgp->nsects, swapped);
+                    for (j = 0; !foundit && j < nsects && startofcmds <= (char *)sp && (char *)sp < endofcmds; j++) {
+                        if (0 == strncmp(sp->sectname, PLIST_SECTION, sizeof(sp->sectname)) && 0 == strncmp(sp->segname, TEXT_SEGMENT, sizeof(sp->segname))) {
+                            uint32_t sectlength = _CFBundleSwapInt32Conditional(sp->size, swapped);
+                            uint32_t sectoffset = _CFBundleSwapInt32Conditional(sp->offset, swapped);
+                            const char *sectbytes = loc + offset + sectoffset;
+                            if (loc <= sectbytes && sectbytes + sectlength <= loc + fileLength) result = _CFBundleGrokInfoDictFromData(sectbytes, sectlength);
+                            foundit = true;
+                        }
+                        sp = (struct section *)((char *)sp + sizeof(struct section));
+                    }
+                }
+                sgp = (struct segment_command *)((char *)sgp + _CFBundleSwapInt32Conditional(sgp->cmdsize, swapped));
+            }
+        }
+    }
+    if (maploc) munmap(maploc, statBuf.st_size);
+    return result;
+}
+
+static void _CFBundleGrokObjcImageInfoFromFile(int fd, const void *bytes, CFIndex length, uint32_t offset, Boolean swapped, Boolean sixtyFour, Boolean *hasObjc, uint32_t *objcVersion, uint32_t *objcFlags) {
+    uint32_t sectlength = 0, sectoffset = 0, localVersion = 0, localFlags = 0;
+    char *buffer = NULL;
+    char sectbuffer[8];
+    const char *loc = NULL;
+    unsigned i, j;
+    Boolean foundit = false, localHasObjc = false;
+    
+    if (fd >= 0 && lseek(fd, offset, SEEK_SET) == (off_t)offset) {
+        buffer = (char*)malloc(IMAGE_INFO_BYTES_TO_READ);
+        if (buffer && read(fd, buffer, IMAGE_INFO_BYTES_TO_READ) >= IMAGE_INFO_BYTES_TO_READ) loc = buffer;
+    } else if (bytes && length >= offset + IMAGE_INFO_BYTES_TO_READ) {
+        loc = (const char*)bytes + offset;
+    }
+    if (loc) {
+        if (sixtyFour) {
+            uint32_t ncmds = _CFBundleSwapInt32Conditional(((struct mach_header_64 *)loc)->ncmds, swapped);
+            uint32_t sizeofcmds = _CFBundleSwapInt32Conditional(((struct mach_header_64 *)loc)->sizeofcmds, swapped);
+            const char *startofcmds = loc + sizeof(struct mach_header_64);
+            const char *endofcmds = startofcmds + sizeofcmds;
+            struct segment_command_64 *sgp = (struct segment_command_64 *)startofcmds;
+            if (endofcmds > loc + IMAGE_INFO_BYTES_TO_READ) endofcmds = loc + IMAGE_INFO_BYTES_TO_READ;
+            for (i = 0; !foundit && i < ncmds && startofcmds <= (char *)sgp && (char *)sgp < endofcmds; i++) {
+                if (LC_SEGMENT_64 == _CFBundleSwapInt32Conditional(sgp->cmd, swapped)) {
+                    struct section_64 *sp = (struct section_64 *)((char *)sgp + sizeof(struct segment_command_64));
+                    uint32_t nsects = _CFBundleSwapInt32Conditional(sgp->nsects, swapped);
+                    for (j = 0; !foundit && j < nsects && startofcmds <= (char *)sp && (char *)sp < endofcmds; j++) {
+                        if (0 == strncmp(sp->segname, OBJC_SEGMENT, sizeof(sp->segname))) localHasObjc = true;
+                        if (0 == strncmp(sp->sectname, IMAGE_INFO_SECTION, sizeof(sp->sectname)) && 0 == strncmp(sp->segname, OBJC_SEGMENT, sizeof(sp->segname))) {
+                            uint64_t sectlength64 = _CFBundleSwapInt64Conditional(sp->size, swapped);
+                            sectlength = (uint32_t)(sectlength64 & 0xffffffff);
+                            sectoffset = _CFBundleSwapInt32Conditional(sp->offset, swapped);
+                            foundit = true;
+                        }
+                        sp = (struct section_64 *)((char *)sp + sizeof(struct section_64));
+                    }
+                }
+                sgp = (struct segment_command_64 *)((char *)sgp + _CFBundleSwapInt32Conditional(sgp->cmdsize, swapped));
+            }
+        } else {
+            uint32_t ncmds = _CFBundleSwapInt32Conditional(((struct mach_header *)loc)->ncmds, swapped);
+            uint32_t sizeofcmds = _CFBundleSwapInt32Conditional(((struct mach_header *)loc)->sizeofcmds, swapped);
+            const char *startofcmds = loc + sizeof(struct mach_header);
+            const char *endofcmds = startofcmds + sizeofcmds;
+            struct segment_command *sgp = (struct segment_command *)startofcmds;
+            if (endofcmds > loc + IMAGE_INFO_BYTES_TO_READ) endofcmds = loc + IMAGE_INFO_BYTES_TO_READ;
+            for (i = 0; !foundit && i < ncmds && startofcmds <= (char *)sgp && (char *)sgp < endofcmds; i++) {
+                if (LC_SEGMENT == _CFBundleSwapInt32Conditional(sgp->cmd, swapped)) {
+                    struct section *sp = (struct section *)((char *)sgp + sizeof(struct segment_command));
+                    uint32_t nsects = _CFBundleSwapInt32Conditional(sgp->nsects, swapped);
+                    for (j = 0; !foundit && j < nsects && startofcmds <= (char *)sp && (char *)sp < endofcmds; j++) {
+                        if (0 == strncmp(sp->segname, OBJC_SEGMENT, sizeof(sp->segname))) localHasObjc = true;
+                        if (0 == strncmp(sp->sectname, IMAGE_INFO_SECTION, sizeof(sp->sectname)) && 0 == strncmp(sp->segname, OBJC_SEGMENT, sizeof(sp->segname))) {
+                            sectlength = _CFBundleSwapInt32Conditional(sp->size, swapped);
+                            sectoffset = _CFBundleSwapInt32Conditional(sp->offset, swapped);
+                            foundit = true;
+                        }
+                        sp = (struct section *)((char *)sp + sizeof(struct section));
+                    }
+                }
+                sgp = (struct segment_command *)((char *)sgp + _CFBundleSwapInt32Conditional(sgp->cmdsize, swapped));
+            }
+        }
+        if (sectlength >= 8) {
+            if (fd >= 0 && lseek(fd, offset + sectoffset, SEEK_SET) == (off_t)(offset + sectoffset) && read(fd, sectbuffer, 8) >= 8) {
+                localVersion = _CFBundleSwapInt32Conditional(*(uint32_t *)sectbuffer, swapped);
+                localFlags = _CFBundleSwapInt32Conditional(*(uint32_t *)(sectbuffer + 4), swapped);
+            } else if (bytes && length >= offset + sectoffset + 8) {
+                localVersion = _CFBundleSwapInt32Conditional(*(uint32_t *)((uint32_t*)bytes + offset + sectoffset), swapped);
+                localFlags = _CFBundleSwapInt32Conditional(*(uint32_t *)((uint32_t*)bytes + offset + sectoffset + 4), swapped);
+            }
+        }
+    }
+    
+    if (buffer) free(buffer);
+    
+    if (hasObjc) *hasObjc = localHasObjc;
+    if (objcVersion) *objcVersion = localVersion;
+    if (objcFlags) *objcFlags = localFlags;
+}
+    
+static UInt32 _CFBundleGrokMachTypeForFatFile(int fd, const void *bytes, CFIndex length, Boolean *isX11, CFArrayRef *architectures, CFDictionaryRef *infodict, Boolean *hasObjc, uint32_t *objcVersion, uint32_t *objcFlags) {
+    UInt32 machtype = UNKNOWN_FILETYPE, magic, numFatHeaders = ((struct fat_header *)bytes)->nfat_arch, maxFatHeaders = (length - sizeof(struct fat_header)) / sizeof(struct fat_arch), i;
+    unsigned char buffer[sizeof(struct mach_header_64)];
+    const unsigned char *moreBytes = NULL;
+    const NXArchInfo *archInfo = NXGetLocalArchInfo();
+    struct fat_arch *fat = NULL;
+
+    if (isX11) *isX11 = false;
+    if (architectures) *architectures = NULL;
+    if (infodict) *infodict = NULL;
+    if (hasObjc) *hasObjc = false;
+    if (objcVersion) *objcVersion = 0;
+    if (objcFlags) *objcFlags = 0;
+    if (numFatHeaders > maxFatHeaders) numFatHeaders = maxFatHeaders;
+    if (numFatHeaders > 0) {
+        fat = NXFindBestFatArch(archInfo->cputype, archInfo->cpusubtype, (struct fat_arch *)((struct fat_arch*)bytes + sizeof(struct fat_header)), numFatHeaders);
+        if (!fat) fat = (struct fat_arch *)((struct fat_arch *)bytes + sizeof(struct fat_header));
+        if (architectures) {
+            CFMutableArrayRef mutableArchitectures = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+            for (i = 0; i < numFatHeaders; i++) {
+                CFNumberRef architecture = CFNumberCreate(kCFAllocatorSystemDefault, kCFNumberSInt32Type, (struct fat_header *)bytes + sizeof(struct fat_header) + i * sizeof(struct fat_arch));
+                if (CFArrayGetFirstIndexOfValue(mutableArchitectures, CFRangeMake(0, CFArrayGetCount(mutableArchitectures)), architecture) < 0) CFArrayAppendValue(mutableArchitectures, architecture);
+                CFRelease(architecture);
+            }
+            *architectures = (CFArrayRef)mutableArchitectures;
+        }
+    } 
+    if (fat) {
+        if (fd >= 0 && lseek(fd, fat->offset, SEEK_SET) == (off_t)fat->offset && read(fd, buffer, sizeof(struct mach_header_64)) >= (int)sizeof(struct mach_header_64)) {
+            moreBytes = buffer;
+        } else if (bytes && (uint32_t)length >= fat->offset + sizeof(struct mach_header_64)) {
+            moreBytes = (const unsigned char *)bytes + fat->offset;
+        }
+        if (moreBytes) {
+            magic = *((UInt32 *)moreBytes);
+            if (MH_MAGIC == magic) {
+                machtype = ((struct mach_header *)moreBytes)->filetype;
+                if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, fat->offset, false, false);
+                if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, fat->offset, false, false);
+                if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, fat->offset, false, false, hasObjc, objcVersion, objcFlags);
+            } else if (MH_CIGAM == magic) {
+                machtype = CFSwapInt32(((struct mach_header *)moreBytes)->filetype);
+                if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, fat->offset, true, false);
+                if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, fat->offset, true, false);
+                if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, fat->offset, true, false, hasObjc, objcVersion, objcFlags);
+            } else if (MH_MAGIC_64 == magic) {
+                machtype = ((struct mach_header_64 *)moreBytes)->filetype;
+                if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, fat->offset, false, true);
+                if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, fat->offset, false, true);
+                if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, fat->offset, false, true, hasObjc, objcVersion, objcFlags);
+            } else if (MH_CIGAM_64 == magic) {
+                machtype = CFSwapInt32(((struct mach_header_64 *)moreBytes)->filetype);
+                if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, fat->offset, true, true);
+                if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, fat->offset, true, true);
+                if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, fat->offset, true, true, hasObjc, objcVersion, objcFlags);
+            }
+        }
+    }
+    return machtype;
+}
+
+static UInt32 _CFBundleGrokMachType(int fd, const void *bytes, CFIndex length, Boolean *isX11, CFArrayRef *architectures, CFDictionaryRef *infodict, Boolean *hasObjc, uint32_t *objcVersion, uint32_t *objcFlags) {
+    unsigned int magic = *((UInt32 *)bytes), machtype = UNKNOWN_FILETYPE;
+    CFNumberRef architecture = NULL;
+    CFIndex i;
+
+    if (isX11) *isX11 = false;
+    if (architectures) *architectures = NULL;
+    if (infodict) *infodict = NULL;
+    if (hasObjc) *hasObjc = false;
+    if (objcVersion) *objcVersion = 0;
+    if (objcFlags) *objcFlags = 0;
+    if (MH_MAGIC == magic) {
+        machtype = ((struct mach_header *)bytes)->filetype;
+        if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, 0, false, false);
+        if (architectures) architecture = CFNumberCreate(kCFAllocatorSystemDefault, kCFNumberSInt32Type, (char*)bytes + 4);
+        if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, 0, false, false);
+        if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, 0, false, false, hasObjc, objcVersion, objcFlags);
+    } else if (MH_CIGAM == magic) {
+        for (i = 0; i < length; i += 4) *(UInt32 *)((char*)bytes + i) = CFSwapInt32(*(UInt32 *)((char*)bytes + i));
+        machtype = ((struct mach_header *)bytes)->filetype;
+        if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, 0, true, false);
+        if (architectures) architecture = CFNumberCreate(kCFAllocatorSystemDefault, kCFNumberSInt32Type, (char*)bytes + 4);
+        if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, 0, true, false);
+        if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, 0, true, false, hasObjc, objcVersion, objcFlags);
+    } else if (MH_MAGIC_64 == magic) {
+        machtype = ((struct mach_header_64 *)bytes)->filetype;
+        if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, 0, false, true);
+        if (architectures) architecture = CFNumberCreate(kCFAllocatorSystemDefault, kCFNumberSInt32Type, (char*)bytes + 4);
+        if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, 0, false, true);
+        if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, 0, false, true, hasObjc, objcVersion, objcFlags);
+    } else if (MH_CIGAM_64 == magic) {
+        for (i = 0; i < length; i += 4) *(UInt32 *)((char*)bytes + i) = CFSwapInt32(*(UInt32 *)((char*)bytes + i));
+        machtype = ((struct mach_header_64 *)bytes)->filetype;
+        if (isX11 && MH_EXECUTE == machtype) *isX11 = _CFBundleGrokX11FromFile(fd, bytes, length, 0, true, true);
+        if (architectures) architecture = CFNumberCreate(kCFAllocatorSystemDefault, kCFNumberSInt32Type, (char*)bytes + 4);
+        if (infodict) *infodict = _CFBundleGrokInfoDictFromFile(fd, bytes, length, 0, true, true);
+        if (hasObjc || objcVersion || objcFlags) _CFBundleGrokObjcImageInfoFromFile(fd, bytes, length, 0, true, true, hasObjc, objcVersion, objcFlags);
+    } else if (FAT_MAGIC == magic) {
+        machtype = _CFBundleGrokMachTypeForFatFile(fd, bytes, length, isX11, architectures, infodict, hasObjc, objcVersion, objcFlags);
+    } else if (FAT_CIGAM == magic) {
+        for (i = 0; i < length; i += 4) *(UInt32 *)((char*)bytes + i) = CFSwapInt32(*(UInt32 *)((char*)bytes + i));
+        machtype = _CFBundleGrokMachTypeForFatFile(fd, bytes, length, isX11, architectures, infodict, hasObjc, objcVersion, objcFlags);
+    } else if (PEF_MAGIC == magic || PEF_CIGAM == magic) {
+        machtype = PEF_FILETYPE;
+    }
+    if (architectures && architecture) *architectures = CFArrayCreate(kCFAllocatorSystemDefault, (const void **)&architecture, 1, &kCFTypeArrayCallBacks);
+    if (architecture) CFRelease(architecture);
+    return machtype;
+}
+
+#endif /* BINARY_SUPPORT_DYLD */
+
+static Boolean _CFBundleGrokFileTypeForZipMimeType(const unsigned char *bytes, CFIndex length, const char **ext) {
+    unsigned namelength = CFSwapInt16HostToLittle(*((UInt16 *)(bytes + 26))), extralength = CFSwapInt16HostToLittle(*((UInt16 *)(bytes + 28)));
+    const unsigned char *data = bytes + 30 + namelength + extralength;
+    int i = -1;
+    if (bytes < data && data + 56 <= bytes + length && 0 == CFSwapInt16HostToLittle(*((UInt16 *)(bytes + 8))) && (0 == ustrncasecmp(data, "application/vnd.", 16) || 0 == ustrncasecmp(data, "application/x-vnd.", 18))) {
+        data += ('.' == *(data + 15)) ? 16 : 18;
+        if (0 == ustrncasecmp(data, "sun.xml.", 8)) {
+            data += 8;
+            if (0 == ustrncasecmp(data, "calc", 4)) i = 0;
+            else if (0 == ustrncasecmp(data, "draw", 4)) i = 1;
+            else if (0 == ustrncasecmp(data, "writer.global", 13)) i = 2;
+            else if (0 == ustrncasecmp(data, "impress", 7)) i = 3;
+            else if (0 == ustrncasecmp(data, "math", 4)) i = 4;
+            else if (0 == ustrncasecmp(data, "writer", 6)) i = 5;
+            if (i >= 0 && ext) *ext = __CFBundleOOExtensionsArray + i * EXTENSION_LENGTH;
+        } else if (0 == ustrncasecmp(data, "oasis.opendocument.", 19)) {
+            data += 19;
+            if (0 == ustrncasecmp(data, "chart", 5)) i = 0;
+            else if (0 == ustrncasecmp(data, "formula", 7)) i = 1;
+            else if (0 == ustrncasecmp(data, "graphics", 8)) i = 2;
+            else if (0 == ustrncasecmp(data, "text-web", 8)) i = 3;
+            else if (0 == ustrncasecmp(data, "image", 5)) i = 4;
+            else if (0 == ustrncasecmp(data, "text-master", 11)) i = 5;
+            else if (0 == ustrncasecmp(data, "presentation", 12)) i = 6;
+            else if (0 == ustrncasecmp(data, "spreadsheet", 11)) i = 7;
+            else if (0 == ustrncasecmp(data, "text", 4)) i = 8;
+            if (i >= 0 && ext) *ext = __CFBundleODExtensionsArray + i * EXTENSION_LENGTH;
+        }
+    } else if (bytes < data && data + 41 <= bytes + length && 8 == CFSwapInt16HostToLittle(*((UInt16 *)(bytes + 8))) && 0x4b2c28c8 == CFSwapInt32HostToBig(*((UInt32 *)data)) && 0xc94c4e2c == CFSwapInt32HostToBig(*((UInt32 *)(data + 4)))) {
+        // AbiWord compressed mimetype odt
+        if (ext) *ext = "odt";
+    }
+    return (i >= 0);
+}
+
+static const char *_CFBundleGrokFileTypeForZipFile(int fd, const unsigned char *bytes, CFIndex length, off_t fileLength) {
+    const char *ext = "zip";
+    const unsigned char *moreBytes = NULL;
+    unsigned char *buffer = NULL;
+    CFIndex i;
+    Boolean foundMimetype = false, hasMetaInf = false, hasContentXML = false, hasManifestMF = false, hasManifestXML = false, hasRels = false, hasContentTypes = false, hasWordDocument = false, hasExcelDocument = false, hasPowerPointDocument = false, hasOPF = false, hasSMIL = false;
+
+    if (bytes) {
+        for (i = 0; !foundMimetype && i + 30 < length; i++) {
+            if (0x50 == bytes[i] && 0x4b == bytes[i + 1]) {
+                unsigned namelength = 0, offset = 0;
+                if (0x01 == bytes[i + 2] && 0x02 == bytes[i + 3]) {
+                    namelength = (unsigned)CFSwapInt16HostToLittle(*((UInt16 *)(bytes + i + 28)));
+                    offset = 46;
+                } else if (0x03 == bytes[i + 2] && 0x04 == bytes[i + 3]) {
+                    namelength = (unsigned)CFSwapInt16HostToLittle(*((UInt16 *)(bytes + i + 26)));
+                    offset = 30;
+                }
+                if (offset > 0 && (CFIndex)(i + offset + namelength) <= length) {
+                    //printf("%.*s\n", namelength, bytes + i + offset);
+                    if (8 == namelength && 30 == offset && 0 == ustrncasecmp(bytes + i + offset, "mimetype", 8)) foundMimetype = _CFBundleGrokFileTypeForZipMimeType(bytes + i, length - i, &ext);
+                    else if (9 == namelength && 0 == ustrncasecmp(bytes + i + offset, "META-INF/", 9)) hasMetaInf = true;
+                    else if (11 == namelength && 0 == ustrncasecmp(bytes + i + offset, "content.xml", 11)) hasContentXML = true;
+                    else if (11 == namelength && 0 == ustrncasecmp(bytes + i + offset, "_rels/.rels", 11)) hasRels = true;
+                    else if (19 == namelength && 0 == ustrncasecmp(bytes + i + offset, "[Content_Types].xml", 19)) hasContentTypes = true;
+                    else if (20 == namelength && 0 == ustrncasecmp(bytes + i + offset, "META-INF/MANIFEST.MF", 20)) hasManifestMF = true;
+                    else if (21 == namelength && 0 == ustrncasecmp(bytes + i + offset, "META-INF/manifest.xml", 21)) hasManifestXML = true;
+                    else if (4 < namelength && 0 == ustrncasecmp(bytes + i + offset + namelength - 4, ".opf", 4)) hasOPF = true;
+                    else if (4 < namelength && 0 == ustrncasecmp(bytes + i + offset + namelength - 4, ".sml", 4)) hasSMIL = true;
+                    else if (5 < namelength && 0 == ustrncasecmp(bytes + i + offset + namelength - 5, ".smil", 5)) hasSMIL = true;
+                    else if (9 < namelength && 0 == ustrncasecmp(bytes + i + offset, "word/", 5) && 0 == ustrncasecmp(bytes + i + offset + namelength - 4, ".xml", 4)) hasWordDocument = true;
+                    else if (10 < namelength && 0 == ustrncasecmp(bytes + i + offset, "excel/", 6) && 0 == ustrncasecmp(bytes + i + offset + namelength - 4, ".xml", 4)) hasExcelDocument = true;
+                    else if (15 < namelength && 0 == ustrncasecmp(bytes + i + offset, "powerpoint/", 11) && 0 == ustrncasecmp(bytes + i + offset + namelength - 4, ".xml", 4)) hasPowerPointDocument = true;
+                    i += offset + namelength - 1;
+                }
+            }
+        }
+    }
+    if (!foundMimetype) {
+        if (fileLength >= ZIP_BYTES_TO_READ) {
+            if (fd >= 0 && lseek(fd, fileLength - ZIP_BYTES_TO_READ, SEEK_SET) == fileLength - ZIP_BYTES_TO_READ) {
+                buffer = (unsigned char *)malloc(ZIP_BYTES_TO_READ);
+                if (buffer && read(fd, buffer, ZIP_BYTES_TO_READ) >= ZIP_BYTES_TO_READ) moreBytes = buffer;
+            } else if (bytes && length >= ZIP_BYTES_TO_READ) {
+                moreBytes = bytes + length - ZIP_BYTES_TO_READ;
+            }
+        }
+        if (moreBytes) {
+            for (i = 0; i + 30 < ZIP_BYTES_TO_READ; i++) {
+                if (0x50 == moreBytes[i] && 0x4b == moreBytes[i + 1]) {
+                    unsigned namelength = 0, offset = 0;
+                    if (0x01 == moreBytes[i + 2] && 0x02 == moreBytes[i + 3]) {
+                        namelength = CFSwapInt16HostToLittle(*((UInt16 *)(moreBytes + i + 28)));
+                        offset = 46;
+                    } else if (0x03 == moreBytes[i + 2] && 0x04 == moreBytes[i + 3]) {
+                        namelength = CFSwapInt16HostToLittle(*((UInt16 *)(moreBytes + i + 26)));
+                        offset = 30;
+                    }
+                    if (offset > 0 && i + offset + namelength <= ZIP_BYTES_TO_READ) {
+                        //printf("%.*s\n", namelength, moreBytes + i + offset);
+                        if (9 == namelength && 0 == ustrncasecmp(moreBytes + i + offset, "META-INF/", 9)) hasMetaInf = true;
+                        else if (11 == namelength && 0 == ustrncasecmp(moreBytes + i + offset, "content.xml", 11)) hasContentXML = true;
+                        else if (11 == namelength && 0 == ustrncasecmp(moreBytes + i + offset, "_rels/.rels", 11)) hasRels = true;
+                        else if (19 == namelength && 0 == ustrncasecmp(moreBytes + i + offset, "[Content_Types].xml", 19)) hasContentTypes = true;
+                        else if (20 == namelength && 0 == ustrncasecmp(moreBytes + i + offset, "META-INF/MANIFEST.MF", 20)) hasManifestMF = true;
+                        else if (21 == namelength && 0 == ustrncasecmp(moreBytes + i + offset, "META-INF/manifest.xml", 21)) hasManifestXML = true;
+                        else if (4 < namelength && 0 == ustrncasecmp(moreBytes + i + offset + namelength - 4, ".opf", 4)) hasOPF = true;
+                        else if (4 < namelength && 0 == ustrncasecmp(moreBytes + i + offset + namelength - 4, ".sml", 4)) hasSMIL = true;
+                        else if (5 < namelength && 0 == ustrncasecmp(moreBytes + i + offset + namelength - 5, ".smil", 5)) hasSMIL = true;
+                        else if (9 < namelength && 0 == ustrncasecmp(moreBytes + i + offset, "word/", 5) && 0 == ustrncasecmp(moreBytes + i + offset + namelength - 4, ".xml", 4)) hasWordDocument = true;
+                        else if (10 < namelength && 0 == ustrncasecmp(moreBytes + i + offset, "excel/", 6) && 0 == ustrncasecmp(moreBytes + i + offset + namelength - 4, ".xml", 4)) hasExcelDocument = true;
+                        else if (15 < namelength && 0 == ustrncasecmp(moreBytes + i + offset, "powerpoint/", 11) && 0 == ustrncasecmp(moreBytes + i + offset + namelength - 4, ".xml", 4)) hasPowerPointDocument = true;
+                        i += offset + namelength - 1;
+                    }
+                }
+            }
+        }
+        //printf("hasManifestMF %d hasManifestXML %d hasContentXML %d hasRels %d hasContentTypes %d hasWordDocument %d hasExcelDocument %d hasPowerPointDocument %d hasMetaInf %d hasOPF %d hasSMIL %d\n", hasManifestMF, hasManifestXML, hasContentXML, hasRels, hasContentTypes, hasWordDocument, hasExcelDocument, hasPowerPointDocument, hasMetaInf, hasOPF, hasSMIL);
+        if (hasManifestMF) ext = "jar";
+        else if ((hasRels || hasContentTypes) && hasWordDocument) ext = "docx";
+        else if ((hasRels || hasContentTypes) && hasExcelDocument) ext = "xlsx";
+        else if ((hasRels || hasContentTypes) && hasPowerPointDocument) ext = "pptx";
+        else if (hasManifestXML || hasContentXML) ext = "odt";
+        else if (hasMetaInf) ext = "jar";
+        else if (hasOPF && hasSMIL) ext = "dtb";
+        else if (hasOPF) ext = "oeb";
+
+        if (buffer) free(buffer);
+    }
+    return ext;
+}
+
+static Boolean _CFBundleCheckOLEName(const char *name, const char *bytes, unsigned length) {
+    Boolean retval = true;
+    unsigned j;
+    for (j = 0; retval && j < length; j++) if (bytes[2 * j] != name[j]) retval = false;
+    return retval;
+}
+
+static const char *_CFBundleGrokFileTypeForOLEFile(int fd, const void *bytes, CFIndex length, off_t offset) {
+    const char *ext = "ole", *moreBytes = NULL;
+    char *buffer = NULL;
+    
+    if (fd >= 0 && lseek(fd, offset, SEEK_SET) == (off_t)offset) {
+        buffer = (char *)malloc(OLE_BYTES_TO_READ);
+        if (buffer && read(fd, buffer, OLE_BYTES_TO_READ) >= OLE_BYTES_TO_READ) moreBytes = buffer;
+    } else if (bytes && length >= offset + OLE_BYTES_TO_READ) {
+        moreBytes = (char *)bytes + offset;
+    }
+    if (moreBytes) {
+        Boolean foundit = false;
+        unsigned i;
+        for (i = 0; !foundit && i < 4; i++) {
+            char namelength = moreBytes[128 * i + 64] / 2;
+            foundit = true;
+            if (sizeof(XLS_NAME) == namelength && _CFBundleCheckOLEName(XLS_NAME, moreBytes + 128 * i, namelength - 1)) ext = "xls";
+            else if (sizeof(XLS_NAME2) == namelength && _CFBundleCheckOLEName(XLS_NAME2, moreBytes + 128 * i, namelength - 1)) ext = "xls";
+            else if (sizeof(DOC_NAME) == namelength && _CFBundleCheckOLEName(DOC_NAME, moreBytes + 128 * i, namelength - 1)) ext = "doc";
+            else if (sizeof(PPT_NAME) == namelength && _CFBundleCheckOLEName(PPT_NAME, moreBytes + 128 * i, namelength - 1)) ext = "ppt";
+            else foundit = false;
+        }
+    }
+
+    if (buffer) free(buffer);
+
+    return ext;
+}
+
+static Boolean _CFBundleGrokFileType(CFURLRef url, CFDataRef data, CFStringRef *extension, UInt32 *machtype, CFArrayRef *architectures, CFDictionaryRef *infodict, Boolean *hasObjc, uint32_t *objcVersion, uint32_t *objcFlags) {
+    struct stat statBuf;
+    int fd = -1;
+    char path[CFMaxPathSize];
+    const unsigned char *bytes = NULL;
+    unsigned char buffer[MAGIC_BYTES_TO_READ];
+    CFIndex i, length = 0;
+    off_t fileLength = 0;
+    const char *ext = NULL;
+    UInt32 mt = UNKNOWN_FILETYPE;
+#if defined(BINARY_SUPPORT_DYLD)
+    Boolean isX11 = false;
+#endif /* BINARY_SUPPORT_DYLD */
+    Boolean isFile = false, isPlain = true, isZero = true, isHTML = false;
+    // extensions returned:  o, tool, x11app, pef, core, dylib, bundle, elf, jpeg, jp2, tiff, gif, png, pict, icns, ico, rtf, rtfd, pdf, ra, rm, au, aiff, aifc, wav, avi, wmv, ogg, flac, psd, mpeg, mid, zip, jar, sit, cpio, html, ps, mov, qtif, ttf, otf, sfont, bmp, hqx, bin, class, tar, txt, gz, Z, uu, ync, bz, bz2, sh, pl, py, rb, dvi, sgi, tga, mp3, xml, plist, xls, doc, ppt, mp4, m4a, m4b, m4p, dmg, cwk, webarchive, dwg, dgn, pfa, pfb, afm, tfm, xcf, cpx, dwf, swf, swc, abw, bom, lit, svg, rdf, x3d, oeb, dtb, docx, xlsx, pptx, sxc, sxd, sxg, sxi, sxm, sxw, odc, odf, odg, oth, odi, odm, odp, ods
+    // ??? we do not distinguish between different wm types, returning wmv for any of wmv, wma, or asf
+    // ??? we do not distinguish between ordinary documents and template versions (often there is no difference in file contents)
+    // ??? the distinctions between docx, xlsx, and pptx may not be entirely reliable
+    if (architectures) *architectures = NULL;
+    if (infodict) *infodict = NULL;
+    if (hasObjc) *hasObjc = false;
+    if (objcVersion) *objcVersion = 0;
+    if (objcFlags) *objcFlags = 0;
+    if (url && CFURLGetFileSystemRepresentation(url, true, (uint8_t *)path, CFMaxPathSize) && stat(path, &statBuf) == 0 && (statBuf.st_mode & S_IFMT) == S_IFREG && (fd = open(path, O_RDONLY, 0777)) >= 0) {
+        length = read(fd, buffer, MAGIC_BYTES_TO_READ);
+        fileLength = statBuf.st_size;
+        bytes = buffer;
+        isFile = true;
+    } else if (data) {
+        length = CFDataGetLength(data);
+        fileLength = (off_t)length;
+        bytes = CFDataGetBytePtr(data);
+        if (length == 0) ext = "txt";
+    }
+    if (bytes) {
+        if (length >= 4) {
+            UInt32 magic = CFSwapInt32HostToBig(*((UInt32 *)bytes));
+            for (i = 0; !ext && i < NUM_EXTENSIONS; i++) {
+                if (__CFBundleMagicNumbersArray[i] == magic) ext = __CFBundleExtensionsArray + i * EXTENSION_LENGTH;
+            }
+            if (ext) {
+                if (0xcafebabe == magic && 8 <= length && 0 != *((UInt16 *)(bytes + 4))) ext = "class";
+#if defined(BINARY_SUPPORT_DYLD)
+                else if ((int)sizeof(struct mach_header_64) <= length) mt = _CFBundleGrokMachType(fd, bytes, length, extension ? &isX11 : NULL, architectures, infodict, hasObjc, objcVersion, objcFlags);
+                
+                if (MH_OBJECT == mt) ext = "o";
+                else if (MH_EXECUTE == mt) ext = isX11 ? "x11app" : "tool";
+                else if (PEF_FILETYPE == mt) ext = "pef";
+                else if (MH_CORE == mt) ext = "core";
+                else if (MH_DYLIB == mt) ext = "dylib";
+                else if (MH_BUNDLE == mt) ext = "bundle";
+#endif /* BINARY_SUPPORT_DYLD */
+                else if (0x7b5c7274 == magic && (6 > length || 'f' != bytes[4])) ext = NULL;
+                else if (0x00010000 == magic && (6 > length || 0 != bytes[4])) ext = NULL;
+                else if (0x47494638 == magic && (6 > length || (0x3761 != CFSwapInt16HostToBig(*((UInt16 *)(bytes + 4))) && 0x3961 != CFSwapInt16HostToBig(*((UInt16 *)(bytes + 4))))))  ext = NULL;
+                else if (0x0000000c == magic && (6 > length || 0x6a50 != CFSwapInt16HostToBig(*((UInt16 *)(bytes + 4))))) ext = NULL;
+                else if (0x2356524d == magic && (6 > length || 0x4c20 != CFSwapInt16HostToBig(*((UInt16 *)(bytes + 4))))) ext = NULL;
+                else if (0x28445746 == magic && (6 > length || 0x2056 != CFSwapInt16HostToBig(*((UInt16 *)(bytes + 4))))) ext = NULL;
+                else if (0x30373037 == magic && (6 > length || 0x30 != bytes[4] || !isdigit(bytes[5]))) ext = NULL;
+                else if (0x41433130 == magic && (6 > length || 0x31 != bytes[4] || !isdigit(bytes[5]))) ext = NULL;
+                else if (0x89504e47 == magic && (8 > length || 0x0d0a1a0a != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = NULL;
+                else if (0x53747566 == magic && (8 > length || 0x66497420 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = NULL;
+                else if (0x3026b275 == magic && (8 > length || 0x8e66cf11 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = NULL;
+                else if (0x67696d70 == magic && (8 > length || 0x20786366 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = NULL;
+                else if (0x424f4d53 == magic && (8 > length || 0x746f7265 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = NULL;
+                else if (0x49544f4c == magic && (8 > length || 0x49544c53 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = NULL;
+                else if (0x72746664 == magic && (8 > length || 0x00000000 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = NULL;
+                else if (0x3d796265 == magic && (12 > length || 0x67696e20 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))) || (0x6c696e65 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8))) && 0x70617274 != CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8)))))) ext = NULL;
+                else if (0x25215053 == magic && 14 <= length && 0 == ustrncmp(bytes + 4, "-AdobeFont", 10)) ext = "pfa"; 
+                else if (0x504b0304 == magic) ext = _CFBundleGrokFileTypeForZipFile(fd, bytes, length, fileLength);
+                else if (0x464f524d == magic) {
+                    // IFF
+                    ext = NULL;
+                    if (12 <= length) {
+                        UInt32 iffMagic = CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8)));
+                        if (0x41494646 == iffMagic) ext = "aiff";
+                        else if (0x414946 == iffMagic) ext = "aifc";
+                    }
+                } else if (0x52494646 == magic) {
+                    // RIFF
+                    ext = NULL;
+                    if (12 <= length) {
+                        UInt32 riffMagic = CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8)));
+                        if (0x57415645 == riffMagic) ext = "wav";
+                        else if (0x41564920 == riffMagic) ext = "avi";
+                    }
+                } else if (0xd0cf11e0 == magic) {
+                    // OLE
+                    if (52 <= length) ext = _CFBundleGrokFileTypeForOLEFile(fd, bytes, length, 512 * (1 + CFSwapInt32HostToLittle(*((UInt32 *)(bytes + 48)))));
+                } else if (0x62656769 == magic) {
+                    // uu
+                    ext = NULL;
+                    if (76 <= length && 'n' == bytes[4] && ' ' == bytes[5] && isdigit(bytes[6]) && isdigit(bytes[7]) && isdigit(bytes[8]) && ' ' == bytes[9]) {
+                        CFIndex endOfLine = 0;
+                        for (i = 10; 0 == endOfLine && i < length; i++) if ('\n' == bytes[i]) endOfLine = i;
+                        if (10 <= endOfLine && endOfLine + 62 < length && 'M' == bytes[endOfLine + 1] && '\n' == bytes[endOfLine + 62]) {
+                            ext = "uu";
+                            for (i = endOfLine + 1; ext && i < endOfLine + 62; i++) if (!isprint(bytes[i])) ext = NULL;
+                        }
+                    }
+                }
+            }
+            if (extension && !ext) {
+                UInt16 shortMagic = CFSwapInt16HostToBig(*((UInt16 *)bytes));
+                if (5 <= length && 0 == bytes[3] && 0 == bytes[4] && ((1 == bytes[1] && 1 == (0xf7 & bytes[2])) || (0 == bytes[1] && (2 == (0xf7 & bytes[2]) || (3 == (0xf7 & bytes[2])))))) ext = "tga";
+                else if (8 <= length && (0x6d6f6f76 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))) || 0x6d646174 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))) || 0x77696465 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = "mov";
+                else if (8 <= length && (0x69647363 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))) || 0x69646174 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = "qtif";
+                else if (8 <= length && 0x424f424f == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4)))) ext = "cwk";
+                else if (8 <= length && 0x62706c69 == magic && 0x7374 == CFSwapInt16HostToBig(*((UInt16 *)(bytes + 4))) && isdigit(bytes[6]) && isdigit(bytes[7])) {
+                    for (i = 8; !ext && i < 128 && i + 16 <= length; i++) {
+                        if (0 == ustrncmp(bytes + i, "WebMainResource", 15)) ext = "webarchive";
+                    }
+                    if (!ext) ext = "plist";
+                } else if (12 <= length && 0x66747970 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4)))) {
+                    // ??? list of ftyp values needs to be checked
+                    if (0x6d703432 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8)))) ext = "mp4";
+                    else if (0x4d344120 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8)))) ext = "m4a";
+                    else if (0x4d344220 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8)))) ext = "m4b";
+                    else if (0x4d345020 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 8)))) ext = "m4p";
+                } else if (0x424d == shortMagic && 18 <= length && 40 == CFSwapInt32HostToLittle(*((UInt32 *)(bytes + 14)))) ext = "bmp";
+                else if (20 <= length && 0 == ustrncmp(bytes + 6, "%!PS-AdobeFont", 14)) ext = "pfb";
+                else if (40 <= length && 0x42696e48 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 34))) && 0x6578 == CFSwapInt16HostToBig(*((UInt16 *)(bytes + 38)))) ext = "hqx";
+                else if (128 <= length && 0x6d42494e == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 102)))) ext = "bin";
+                else if (128 <= length && 0 == bytes[0] && 0 < bytes[1] && bytes[1] < 64 && 0 == bytes[74] && 0 == bytes[82] && 0 == (fileLength % 128)) {
+                    unsigned df = CFSwapInt32HostToBig(*((UInt32 *)(bytes + 83))), rf = CFSwapInt32HostToBig(*((UInt32 *)(bytes + 87))), blocks = 1 + (df + 127) / 128 + (rf + 127) / 128;
+                    if (df < 0x00800000 && rf < 0x00800000 && 1 < blocks && (off_t)(128 * blocks) == fileLength) ext = "bin";
+                } else if (265 <= length && 0x75737461 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 257))) && (0x72202000 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 261))) || 0x7200 == CFSwapInt16HostToBig(*((UInt16 *)(bytes + 261))))) ext = "tar";
+                else if (0xfeff == shortMagic || 0xfffe == shortMagic) ext = "txt";
+                else if (0x1f9d == shortMagic) ext = "Z";
+                else if (0x1f8b == shortMagic) ext = "gz";
+                else if (0x71c7 == shortMagic || 0xc771 == shortMagic) ext = "cpio";
+                else if (0xf702 == shortMagic) ext = "dvi";
+                else if (0x01da == shortMagic && (0 == bytes[2] || 1 == bytes[2]) && (0 < bytes[3] && 16 > bytes[3])) ext = "sgi";
+                else if (0x2321 == shortMagic) {
+                    CFIndex endOfLine = 0, lastSlash = 0;
+                    for (i = 2; 0 == endOfLine && i < length; i++) if ('\n' == bytes[i]) endOfLine = i;
+                    if (endOfLine > 3) {
+                        for (i = endOfLine - 1; 0 == lastSlash && i > 1; i--) if ('/' == bytes[i]) lastSlash = i;
+                        if (lastSlash > 0) {
+                            if (0 == ustrncmp(bytes + lastSlash + 1, "perl", 4)) ext = "pl";
+                            else if (0 == ustrncmp(bytes + lastSlash + 1, "python", 6)) ext = "py";
+                            else if (0 == ustrncmp(bytes + lastSlash + 1, "ruby", 4)) ext = "rb";
+                            else ext = "sh";
+                        }
+                    } 
+                } else if (0xffd8 == shortMagic && 0xff == bytes[2]) ext = "jpeg";
+                else if (0x4657 == shortMagic && 0x53 == bytes[2]) ext = "swf";
+                else if (0x4357 == shortMagic && 0x53 == bytes[2]) ext = "swc";
+                else if (0x4944 == shortMagic && '3' == bytes[2] && 0x20 > bytes[3]) ext = "mp3";
+                else if (0x425a == shortMagic && isdigit(bytes[2]) && isdigit(bytes[3])) ext = "bz";
+                else if (0x425a == shortMagic && 'h' == bytes[2] && isdigit(bytes[3]) && 8 <= length && (0x31415926 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))) || 0x17724538 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 4))))) ext = "bz2";
+                else if (0x0011 == CFSwapInt16HostToBig(*((UInt16 *)(bytes + 2))) || 0x0012 == CFSwapInt16HostToBig(*((UInt16 *)(bytes + 2)))) ext = "tfm";
+                else if ('<' == bytes[0] && 14 <= length) {
+                    if (0 == ustrncasecmp(bytes + 1, "!doctype html", 13) || 0 == ustrncasecmp(bytes + 1, "head", 4) || 0 == ustrncasecmp(bytes + 1, "title", 5) || 0 == ustrncasecmp(bytes + 1, "html", 4)) {
+                        ext = "html";
+                    } else if (0 == ustrncasecmp(bytes + 1, "?xml", 4)) {
+                        for (i = 4; !ext && i < 128 && i + 20 <= length; i++) {
+                            if ('<' == bytes[i]) {
+                                if (0 == ustrncasecmp(bytes + i + 1, "abiword", 7)) ext = "abw";
+                                else if (0 == ustrncasecmp(bytes + i + 1, "!doctype svg", 12)) ext = "svg";
+                                else if (0 == ustrncasecmp(bytes + i + 1, "!doctype rdf", 12)) ext = "rdf";
+                                else if (0 == ustrncasecmp(bytes + i + 1, "!doctype x3d", 12)) ext = "x3d";
+                                else if (0 == ustrncasecmp(bytes + i + 1, "!doctype html", 13)) ext = "html";
+                                else if (0 == ustrncasecmp(bytes + i + 1, "!doctype plist", 14)) ext = "plist";
+                                else if (0 == ustrncasecmp(bytes + i + 1, "!doctype posingfont", 19)) ext = "sfont";
+                            }
+                        }
+                        if (!ext) ext = "xml";
+                    }
+                }
+            }
+        }
+        if (extension && !ext) {
+            //??? what about MacOSRoman?
+            for (i = 0; (isPlain || isZero) && !isHTML && i < length && i < 512; i++) {
+                char c = bytes[i];
+                if (0x7f <= c || (0x20 > c && !isspace(c))) isPlain = false;
+                if (0 != c) isZero = false;
+                if (isPlain && '<' == c && i + 14 <= length && 0 == ustrncasecmp(bytes + i + 1, "!doctype html", 13)) isHTML = true;
+            }
+            if (isHTML) {
+                ext = "html";
+            } else if (isPlain) {
+                if (16 <= length && 0 == ustrncmp(bytes, "StartFontMetrics", 16)) ext = "afm";
+                else ext = "txt";
+            } else if (isZero && length >= MAGIC_BYTES_TO_READ && fileLength >= 526) {
+                if (isFile) {
+                    if (lseek(fd, 512, SEEK_SET) == 512 && read(fd, buffer, MAGIC_BYTES_TO_READ) >= 14) {
+                        if (0x001102ff == CFSwapInt32HostToBig(*((UInt32 *)(buffer + 10)))) ext = "pict";
+                    }
+                } else {
+                    if (526 <= length && 0x001102ff == CFSwapInt32HostToBig(*((UInt32 *)(bytes + 522)))) ext = "pict";
+                }
+            }
+        }
+        if (extension && (!ext || 0 == strcmp(ext, "bz2")) && length >= MAGIC_BYTES_TO_READ && fileLength >= DMG_BYTES_TO_READ) {
+            if (isFile) {
+                if (lseek(fd, fileLength - DMG_BYTES_TO_READ, SEEK_SET) == fileLength - DMG_BYTES_TO_READ && read(fd, buffer, DMG_BYTES_TO_READ) >= DMG_BYTES_TO_READ) {
+                    if (0x6b6f6c79 == CFSwapInt32HostToBig(*((UInt32 *)buffer)) || (0x63647361 == CFSwapInt32HostToBig(*((UInt32 *)(buffer + DMG_BYTES_TO_READ - 8))) && 0x656e6372 == CFSwapInt32HostToBig(*((UInt32 *)(buffer + DMG_BYTES_TO_READ - 4))))) ext = "dmg";
+                }
+            } else {
+                if (DMG_BYTES_TO_READ <= length && (0x6b6f6c79 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + length - DMG_BYTES_TO_READ))) || (0x63647361 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + length - 8))) && 0x656e6372 == CFSwapInt32HostToBig(*((UInt32 *)(bytes + length - 4)))))) ext = "dmg";
+            }
+        }
+    }
+    if (extension) *extension = ext ? CFStringCreateWithCStringNoCopy(kCFAllocatorSystemDefault, ext, kCFStringEncodingUTF8, kCFAllocatorNull) : NULL;
+    if (machtype) *machtype = mt;
+    if (fd >= 0) close(fd);
+    return (ext ? true : false);
+}
+
+CFStringRef _CFBundleCopyFileTypeForFileURL(CFURLRef url) {
+    CFStringRef extension = NULL;
+    (void)_CFBundleGrokFileType(url, NULL, &extension, NULL, NULL, NULL, NULL, NULL, NULL);
+    return extension;
+}
+
+CFStringRef _CFBundleCopyFileTypeForFileData(CFDataRef data) {
+    CFStringRef extension = NULL;
+    (void)_CFBundleGrokFileType(NULL, data, &extension, NULL, NULL, NULL, NULL, NULL, NULL);
+    return extension;
+}
+
+__private_extern__ CFDictionaryRef _CFBundleCopyInfoDictionaryInExecutable(CFURLRef url) {
+    CFDictionaryRef result = NULL;
+    (void)_CFBundleGrokFileType(url, NULL, NULL, NULL, NULL, &result, NULL, NULL, NULL);
+    return result;
+}
+
+__private_extern__ CFArrayRef _CFBundleCopyArchitecturesForExecutable(CFURLRef url) {
+    CFArrayRef result = NULL;
+    (void)_CFBundleGrokFileType(url, NULL, NULL, NULL, &result, NULL, NULL, NULL, NULL);
+    return result;
+}
+
+static Boolean _CFBundleGetObjCImageInfoForExecutable(CFURLRef url, uint32_t *objcVersion, uint32_t *objcFlags) {
+    Boolean retval = false;
+    (void)_CFBundleGrokFileType(url, NULL, NULL, NULL, NULL, NULL, &retval, objcVersion, objcFlags);
+    return retval;
+}
+
+#if defined(BINARY_SUPPORT_DYLD)
+
+__private_extern__ __CFPBinaryType _CFBundleGrokBinaryType(CFURLRef executableURL) {
+    // Attempt to grok the type of the binary by looking for DYLD magic numbers.  If one of the DYLD magic numbers is found, find out what type of Mach-o file it is.  Otherwise, look for the PEF magic numbers to see if it is CFM (if we understand CFM).
+    __CFPBinaryType result = executableURL ? __CFBundleUnreadableBinary : __CFBundleNoBinary;
+    UInt32 machtype = UNKNOWN_FILETYPE;
+    if (_CFBundleGrokFileType(executableURL, NULL, NULL, &machtype, NULL, NULL, NULL, NULL, NULL)) {
+        switch (machtype) {
+            case MH_EXECUTE:
+                result = __CFBundleDYLDExecutableBinary;
+                break;
+            case MH_BUNDLE:
+                result = __CFBundleDYLDBundleBinary;
+                break;
+            case MH_DYLIB:
+                result = __CFBundleDYLDFrameworkBinary;
+                break;
+#if defined(BINARY_SUPPORT_CFM)
+            case PEF_FILETYPE:
+                result = __CFBundleCFMBinary;
+                break;
+#endif /* BINARY_SUPPORT_CFM */
+        }
+    }
+    return result;
+}
+
+#endif /* BINARY_SUPPORT_DYLD */
+
+void _CFBundleSetCFMConnectionID(CFBundleRef bundle, void *connectionID) {
+#if defined(BINARY_SUPPORT_CFM)
+    if (bundle->_binaryType == __CFBundleUnknownBinary || bundle->_binaryType == __CFBundleUnreadableBinary) {
+        bundle->_binaryType = __CFBundleCFMBinary;
+    }
+#endif /* BINARY_SUPPORT_CFM */
+    bundle->_connectionCookie = connectionID;
+    bundle->_isLoaded = true;
+}
+
+static CFStringRef _CFBundleCopyLastPathComponent(CFBundleRef bundle) {
+    CFURLRef bundleURL = CFBundleCopyBundleURL(bundle);
+    CFStringRef str = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
+    UniChar buff[CFMaxPathSize];
+    CFIndex buffLen = CFStringGetLength(str), startOfLastDir = 0;
+
+    CFRelease(bundleURL);
+    if (buffLen > CFMaxPathSize) buffLen = CFMaxPathSize;
+    CFStringGetCharacters(str, CFRangeMake(0, buffLen), buff);
+    CFRelease(str);
+    if (buffLen > 0) startOfLastDir = _CFStartOfLastPathComponent(buff, buffLen);
+    return CFStringCreateWithCharacters(kCFAllocatorSystemDefault, &(buff[startOfLastDir]), buffLen - startOfLastDir);
+}
+
+static CFErrorRef _CFBundleCreateErrorDebug(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code, CFStringRef debugString) {
+    const void *userInfoKeys[6], *userInfoValues[6];
+    CFIndex numKeys = 0;
+    CFURLRef bundleURL = CFBundleCopyBundleURL(bundle), absoluteURL = CFURLCopyAbsoluteURL(bundleURL), executableURL = CFBundleCopyExecutableURL(bundle);
+    CFBundleRef bdl = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreFoundation"));
+    CFStringRef bundlePath = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE), executablePath = executableURL ? CFURLCopyFileSystemPath(executableURL, PLATFORM_PATH_STYLE) : NULL, descFormat = NULL, desc = NULL, reason = NULL, suggestion = NULL;
+    CFErrorRef error;
+    if (bdl) {
+        CFStringRef name = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleNameKey);
+        name = name ? (CFStringRef)CFRetain(name) : _CFBundleCopyLastPathComponent(bundle);
+        if (CFBundleExecutableNotFoundError == code) {
+            descFormat = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr4"), CFSTR("Error"), bdl, CFSTR("The bundle \\U201c%@\\U201d could not be loaded because its executable could not be located."), "NSFileNoSuchFileError");
+            reason = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr4-C"), CFSTR("Error"), bdl, CFSTR("The bundle\\U2019s executable could not be located."), "NSFileNoSuchFileError");
+            suggestion = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr4-R"), CFSTR("Error"), bdl, CFSTR("Try reinstalling the bundle."), "NSFileNoSuchFileError");
+        } else if (CFBundleExecutableNotLoadableError == code) {
+            descFormat = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3584"), CFSTR("Error"), bdl, CFSTR("The bundle \\U201c%@\\U201d could not be loaded because its executable is not loadable."), "NSExecutableNotLoadableError");
+            reason = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3584-C"), CFSTR("Error"), bdl, CFSTR("The bundle\\U2019s executable is not loadable."), "NSExecutableNotLoadableError");
+            suggestion = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3584-R"), CFSTR("Error"), bdl, CFSTR("Try reinstalling the bundle."), "NSExecutableNotLoadableError");
+        } else if (CFBundleExecutableArchitectureMismatchError == code) {
+            descFormat = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3585"), CFSTR("Error"), bdl, CFSTR("The bundle \\U201c%@\\U201d could not be loaded because it does not contain a version for the current architecture."), "NSExecutableArchitectureMismatchError");
+            reason = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3585-C"), CFSTR("Error"), bdl, CFSTR("The bundle does not contain a version for the current architecture."), "NSExecutableArchitectureMismatchError");
+            suggestion = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3585-R"), CFSTR("Error"), bdl, CFSTR("Try installing a universal version of the bundle."), "NSExecutableArchitectureMismatchError");
+        } else if (CFBundleExecutableRuntimeMismatchError == code) {
+            descFormat = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3586"), CFSTR("Error"), bdl, CFSTR("The bundle \\U201c%@\\U201d could not be loaded because it is not compatible with the current application."), "NSExecutableRuntimeMismatchError");
+            reason = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3586-C"), CFSTR("Error"), bdl, CFSTR("The bundle is not compatible with this application."), "NSExecutableRuntimeMismatchError");
+            suggestion = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3586-R"), CFSTR("Error"), bdl, CFSTR("Try installing a newer version of the bundle."), "NSExecutableRuntimeMismatchError");
+        } else if (CFBundleExecutableLoadError == code) {
+            descFormat = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3587"), CFSTR("Error"), bdl, CFSTR("The bundle \\U201c%@\\U201d could not be loaded because it is damaged or missing necessary resources."), "NSExecutableLoadError");
+            reason = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3587-C"), CFSTR("Error"), bdl, CFSTR("The bundle is damaged or missing necessary resources."), "NSExecutableLoadError");
+            suggestion = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3587-R"), CFSTR("Error"), bdl, CFSTR("Try reinstalling the bundle."), "NSExecutableLoadError");
+        } else if (CFBundleExecutableLinkError == code) {
+            descFormat = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3588"), CFSTR("Error"), bdl, CFSTR("The bundle \\U201c%@\\U201d could not be loaded."), "NSExecutableLinkError");
+            reason = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3588-C"), CFSTR("Error"), bdl, CFSTR("The bundle could not be loaded."), "NSExecutableLinkError");
+            suggestion = CFCopyLocalizedStringWithDefaultValue(CFSTR("BundleErr3588-R"), CFSTR("Error"), bdl, CFSTR("Try reinstalling the bundle."), "NSExecutableLinkError");
+        }
+        if (descFormat) {
+            desc = CFStringCreateWithFormat(allocator, NULL, descFormat, name);
+            CFRelease(descFormat);
+        }
+        CFRelease(name);
+    }
+    if (bundlePath) {
+        userInfoKeys[numKeys] = CFSTR("NSBundlePath");
+        userInfoValues[numKeys] = bundlePath;
+        numKeys++;
+    }
+    if (executablePath) {
+        userInfoKeys[numKeys] = CFSTR("NSFilePath");
+        userInfoValues[numKeys] = executablePath;
+        numKeys++;
+    }
+    if (desc) {
+        userInfoKeys[numKeys] = kCFErrorLocalizedDescriptionKey;
+        userInfoValues[numKeys] = desc;
+        numKeys++;
+    }
+    if (reason) {
+        userInfoKeys[numKeys] = kCFErrorLocalizedFailureReasonKey;
+        userInfoValues[numKeys] = reason;
+        numKeys++;
+    }
+    if (suggestion) {
+        userInfoKeys[numKeys] = kCFErrorLocalizedRecoverySuggestionKey;
+        userInfoValues[numKeys] = suggestion;
+        numKeys++;
+    }
+    if (debugString) {
+        userInfoKeys[numKeys] = CFSTR("NSDebugDescription");
+        userInfoValues[numKeys] = debugString;
+        numKeys++;
+    }
+    error = CFErrorCreateWithUserInfoKeysAndValues(allocator, kCFErrorDomainCocoa, code, userInfoKeys, userInfoValues, numKeys);
+    if (bundleURL) CFRelease(bundleURL);
+    if (absoluteURL) CFRelease(absoluteURL);
+    if (executableURL) CFRelease(executableURL);
+    if (bundlePath) CFRelease(bundlePath);
+    if (executablePath) CFRelease(executablePath);
+    if (desc) CFRelease(desc);
+    if (reason) CFRelease(reason);
+    if (suggestion) CFRelease(suggestion);
+    return error;
+}
+
+CFErrorRef _CFBundleCreateError(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code) {
+    return _CFBundleCreateErrorDebug(allocator, bundle, code, NULL);
+}
+
+Boolean _CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error) {
+    Boolean result = false;
+    CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
+    CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+
+    if (!executableURL) bundle->_binaryType = __CFBundleNoBinary;
+    // make sure we know whether bundle is already loaded or not
+#if defined(BINARY_SUPPORT_DLFCN)
+    if (!bundle->_isLoaded && _useDlfcn) _CFBundleDlfcnCheckLoaded(bundle);
+#endif /* BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DYLD)
+    if (!bundle->_isLoaded) _CFBundleDYLDCheckLoaded(bundle);
+    // We might need to figure out what it is
+    if (bundle->_binaryType == __CFBundleUnknownBinary) {
+        bundle->_binaryType = _CFBundleGrokBinaryType(executableURL);
+#if defined(BINARY_SUPPORT_CFM)
+        if (bundle->_binaryType != __CFBundleCFMBinary && bundle->_binaryType != __CFBundleUnreadableBinary) bundle->_resourceData._executableLacksResourceFork = true;
+#endif /* BINARY_SUPPORT_CFM */
+    }
+#endif /* BINARY_SUPPORT_DYLD */
+    if (executableURL) CFRelease(executableURL);
+    
+    if (bundle->_isLoaded) {
+        // Remove from the scheduled unload set if we are there.
+        __CFSpinLock(&CFBundleGlobalDataLock);
+        if (_bundlesToUnload) CFSetRemoveValue(_bundlesToUnload, bundle);
+        __CFSpinUnlock(&CFBundleGlobalDataLock);
+        return true;
+    }
+
+    // Unload bundles scheduled for unloading
+    if (!_scheduledBundlesAreUnloading) _CFBundleUnloadScheduledBundles();
+    
+    switch (bundle->_binaryType) {
+#if defined(BINARY_SUPPORT_CFM)
+        case __CFBundleCFMBinary:
+        case __CFBundleUnreadableBinary:
+            result = _CFBundleCFMLoad(bundle, subError);
+            break;
+#elif defined(BINARY_SUPPORT_DLFCN)
+        case __CFBundleUnreadableBinary:
+            result = _CFBundleDlfcnLoadBundle(bundle, forceGlobal, subError);
+            break;
+#endif /* BINARY_SUPPORT_CFM */
+#if defined(BINARY_SUPPORT_DYLD)
+        case __CFBundleDYLDBundleBinary:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (_useDlfcn) result = _CFBundleDlfcnLoadBundle(bundle, forceGlobal, subError); else
+#endif /* BINARY_SUPPORT_DLFCN */
+            result = _CFBundleDYLDLoadBundle(bundle, forceGlobal, subError);
+            break;
+        case __CFBundleDYLDFrameworkBinary:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (_useDlfcn) result = _CFBundleDlfcnLoadFramework(bundle, subError); else
+#endif /* BINARY_SUPPORT_DLFCN */
+            result = _CFBundleDYLDLoadFramework(bundle, subError);
+            break;
+        case __CFBundleDYLDExecutableBinary:
+            CFLog(__kCFLogBundle, CFSTR("Attempt to load executable of a type that cannot be dynamically loaded for %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotLoadableError);
+            break;
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_DLFCN)
+        case __CFBundleUnknownBinary:
+        case __CFBundleELFBinary:
+            result = _CFBundleDlfcnLoadBundle(bundle, forceGlobal, subError);
+            break;
+#endif /* BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DLL)
+        case __CFBundleDLLBinary:
+            result = _CFBundleDLLLoad(bundle, subError);
+            break;
+#endif /* BINARY_SUPPORT_DLL */
+        case __CFBundleNoBinary:
+            CFLog(__kCFLogBundle, CFSTR("Cannot find executable for %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+            break;     
+        default:
+            CFLog(__kCFLogBundle, CFSTR("Cannot recognize type of executable for %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotLoadableError);
+            break;
+    }
+    if (result && bundle->_plugInData._isPlugIn) _CFBundlePlugInLoaded(bundle);
+
+    if (!result && error) *error = localError;
+    return result;
+}
+
+Boolean CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, CFErrorRef *error) {
+    return _CFBundleLoadExecutableAndReturnError(bundle, false, error);
+}
+
+Boolean CFBundleLoadExecutable(CFBundleRef bundle) {
+    return _CFBundleLoadExecutableAndReturnError(bundle, false, NULL);
+}
+
+Boolean CFBundlePreflightExecutable(CFBundleRef bundle, CFErrorRef *error) {
+    Boolean result = false;
+    CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
+    CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+
+    if (!executableURL) bundle->_binaryType = __CFBundleNoBinary;
+    // make sure we know whether bundle is already loaded or not
+#if defined(BINARY_SUPPORT_DLFCN)
+    if (!bundle->_isLoaded && _useDlfcn) _CFBundleDlfcnCheckLoaded(bundle);
+#endif /* BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DYLD)
+    if (!bundle->_isLoaded) _CFBundleDYLDCheckLoaded(bundle);
+    // We might need to figure out what it is
+    if (bundle->_binaryType == __CFBundleUnknownBinary) {
+        bundle->_binaryType = _CFBundleGrokBinaryType(executableURL);
+#if defined(BINARY_SUPPORT_CFM)
+        if (bundle->_binaryType != __CFBundleCFMBinary && bundle->_binaryType != __CFBundleUnreadableBinary) bundle->_resourceData._executableLacksResourceFork = true;
+#endif /* BINARY_SUPPORT_CFM */
+    }
+#endif /* BINARY_SUPPORT_DYLD */
+    if (executableURL) CFRelease(executableURL);
+    
+    if (bundle->_isLoaded) return true;
+    
+    switch (bundle->_binaryType) {
+#if defined(BINARY_SUPPORT_CFM)
+        case __CFBundleCFMBinary:
+        case __CFBundleUnreadableBinary:
+            result = true;
+            break;
+#elif defined(BINARY_SUPPORT_DLFCN)
+        case __CFBundleUnreadableBinary:
+            result = _CFBundleDlfcnPreflight(bundle, subError);
+            break;
+#endif /* BINARY_SUPPORT_CFM */
+#if defined(BINARY_SUPPORT_DYLD)
+        case __CFBundleDYLDBundleBinary:
+            result = true;
+#if defined(BINARY_SUPPORT_DLFCN)
+            result = _CFBundleDlfcnPreflight(bundle, subError);
+#endif /* BINARY_SUPPORT_DLFCN */
+            break;
+        case __CFBundleDYLDFrameworkBinary:
+            result = true;
+#if defined(BINARY_SUPPORT_DLFCN)
+            result = _CFBundleDlfcnPreflight(bundle, subError);
+#endif /* BINARY_SUPPORT_DLFCN */
+            break;
+        case __CFBundleDYLDExecutableBinary:
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotLoadableError);
+            break;
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_DLFCN)
+        case __CFBundleUnknownBinary:
+        case __CFBundleELFBinary:
+            result = _CFBundleDlfcnPreflight(bundle, subError);
+            break;
+#endif /* BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DLL)
+        case __CFBundleDLLBinary:
+            result = true;
+            break;
+#endif /* BINARY_SUPPORT_DLL */
+        case __CFBundleNoBinary:
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+            break;     
+        default:
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotLoadableError);
+            break;
+    }
+    if (!result && error) *error = localError;
+    return result;
+}
+
+CFArrayRef CFBundleCopyExecutableArchitectures(CFBundleRef bundle) {
+    CFArrayRef result = NULL;
+    CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+    if (executableURL) {
+        result = _CFBundleCopyArchitecturesForExecutable(executableURL);
+        CFRelease(executableURL);
+    }
+    return result;
+}
+
+static Boolean _CFBundleGetObjCImageInfo(CFBundleRef bundle, uint32_t *objcVersion, uint32_t *objcFlags) {
+    Boolean retval = false;
+    uint32_t localVersion = 0, localFlags = 0;
+    CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+    if (executableURL) {
+        retval = _CFBundleGetObjCImageInfoForExecutable(executableURL, &localVersion, &localFlags);
+        CFRelease(executableURL);
+    }
+    if (objcVersion) *objcVersion = localVersion;
+    if (objcFlags) *objcFlags = localFlags;
+    return retval;
+}
+
+void CFBundleUnloadExecutable(CFBundleRef bundle) {
+    // First unload bundles scheduled for unloading (if that's not what we are already doing.)
+    if (!_scheduledBundlesAreUnloading) _CFBundleUnloadScheduledBundles();
+    
+    if (!bundle->_isLoaded) return;
+    
+    // Remove from the scheduled unload set if we are there.
+    if (!_scheduledBundlesAreUnloading) __CFSpinLock(&CFBundleGlobalDataLock);
+    if (_bundlesToUnload) CFSetRemoveValue(_bundlesToUnload, bundle);
+    if (!_scheduledBundlesAreUnloading) __CFSpinUnlock(&CFBundleGlobalDataLock);
+    
+    // Give the plugIn code a chance to realize this...
+    _CFPlugInWillUnload(bundle);
+
+    switch (bundle->_binaryType) {
+#if defined(BINARY_SUPPORT_CFM)
+        case __CFBundleCFMBinary:
+             _CFBundleCFMUnload(bundle);
+            break;
+#endif /* BINARY_SUPPORT_CFM */
+#if defined(BINARY_SUPPORT_DYLD)
+        case __CFBundleDYLDBundleBinary:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) _CFBundleDlfcnUnload(bundle); else
+#endif /* BINARY_SUPPORT_DLFCN */
+            _CFBundleDYLDUnloadBundle(bundle);
+            break;
+        case __CFBundleDYLDFrameworkBinary:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie && _CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard)) _CFBundleDlfcnUnload(bundle);
+#endif /* BINARY_SUPPORT_DLFCN */
+            break;
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_DLL)
+        case __CFBundleDLLBinary:
+            _CFBundleDLLUnload(bundle);
+            break;
+#endif /* BINARY_SUPPORT_DLL */
+        default:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) _CFBundleDlfcnUnload(bundle);
+#endif /* BINARY_SUPPORT_DLFCN */
+            break;
+    }
+    if (!bundle->_isLoaded && bundle->_glueDict) {
+        CFDictionaryApplyFunction(bundle->_glueDict, _CFBundleDeallocateGlue, (void *)CFGetAllocator(bundle));
+        CFRelease(bundle->_glueDict);
+        bundle->_glueDict = NULL;
+    }
+}
+
+__private_extern__ void _CFBundleScheduleForUnloading(CFBundleRef bundle) {
+    __CFSpinLock(&CFBundleGlobalDataLock);
+    if (!_bundlesToUnload) {
+        // Create this from the default allocator
+        CFSetCallBacks nonRetainingCallbacks = kCFTypeSetCallBacks;
+        nonRetainingCallbacks.retain = NULL;
+        nonRetainingCallbacks.release = NULL;
+        _bundlesToUnload = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &nonRetainingCallbacks);
+    }
+    CFSetAddValue(_bundlesToUnload, bundle);
+    __CFSpinUnlock(&CFBundleGlobalDataLock);
+}
+
+__private_extern__ void _CFBundleUnscheduleForUnloading(CFBundleRef bundle) {
+    __CFSpinLock(&CFBundleGlobalDataLock);
+    if (_bundlesToUnload) {
+        CFSetRemoveValue(_bundlesToUnload, bundle);
+    }
+    __CFSpinUnlock(&CFBundleGlobalDataLock);
+}
+
+__private_extern__ void _CFBundleUnloadScheduledBundles(void) {
+    __CFSpinLock(&CFBundleGlobalDataLock);
+    if (_bundlesToUnload) {
+        CFIndex c = CFSetGetCount(_bundlesToUnload);
+        if (c > 0) {
+            CFIndex i;
+            CFBundleRef *unloadThese = (CFBundleRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(CFBundleRef) * c, 0);
+            CFSetGetValues(_bundlesToUnload, (const void **)unloadThese);
+            _scheduledBundlesAreUnloading = true;
+            for (i = 0; i < c; i++) {
+                // This will cause them to be removed from the set.  (Which is why we copied all the values out of the set up front.)
+                CFBundleUnloadExecutable(unloadThese[i]);
+            }
+            _scheduledBundlesAreUnloading = false;
+            CFAllocatorDeallocate(kCFAllocatorSystemDefault, unloadThese);
+        }
+    }
+    __CFSpinUnlock(&CFBundleGlobalDataLock);
+}
+
+void *CFBundleGetFunctionPointerForName(CFBundleRef bundle, CFStringRef funcName) {
+    void *tvp = NULL;
+    // Load if necessary
+    if (!bundle->_isLoaded) {
+        if (!CFBundleLoadExecutable(bundle)) return NULL;
+    }
+    
+    switch (bundle->_binaryType) {
+#if defined(BINARY_SUPPORT_CFM)
+        case __CFBundleCFMBinary:
+            tvp = _CFBundleCFMGetSymbolByName(bundle, funcName, kTVectorCFragSymbol);
+            break;
+#endif /* BINARY_SUPPORT_CFM */
+#if defined(BINARY_SUPPORT_DYLD)
+        case __CFBundleDYLDBundleBinary:
+        case __CFBundleDYLDFrameworkBinary:
+        case __CFBundleDYLDExecutableBinary:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) return _CFBundleDlfcnGetSymbolByName(bundle, funcName);
+#endif /* BINARY_SUPPORT_DLFCN */
+            return _CFBundleDYLDGetSymbolByName(bundle, funcName);
+            break;
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_DLL)
+        case __CFBundleDLLBinary:
+            tvp = _CFBundleDLLGetSymbolByName(bundle, funcName);
+            break;
+#endif /* BINARY_SUPPORT_DLL */
+        default:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) return _CFBundleDlfcnGetSymbolByName(bundle, funcName);
+#endif /* BINARY_SUPPORT_DLFCN */
+            break;
+    }
+#if defined(BINARY_SUPPORT_DYLD) && defined(BINARY_SUPPORT_CFM)
+    if (tvp) {
+        if (!bundle->_glueDict) bundle->_glueDict = CFDictionaryCreateMutable(CFGetAllocator(bundle), 0, NULL, NULL);
+        void *fp = (void *)CFDictionaryGetValue(bundle->_glueDict, tvp);
+        if (!fp) {
+            fp = _CFBundleFunctionPointerForTVector(CFGetAllocator(bundle), tvp);
+            CFDictionarySetValue(bundle->_glueDict, tvp, fp);
+        }
+        return fp;
+    }
+#endif /* BINARY_SUPPORT_DYLD && BINARY_SUPPORT_CFM */
+    return tvp;
+}
+
+void *_CFBundleGetCFMFunctionPointerForName(CFBundleRef bundle, CFStringRef funcName) {
+    void *fp = NULL;
+    // Load if necessary
+    if (!bundle->_isLoaded) {
+        if (!CFBundleLoadExecutable(bundle)) return NULL;
+    }
+#if defined (BINARY_SUPPORT_CFM) || defined (BINARY_SUPPORT_DYLD) || defined (BINARY_SUPPORT_DLFCN)
+    switch (bundle->_binaryType) {
+#if defined(BINARY_SUPPORT_CFM)
+        case __CFBundleCFMBinary:
+            return _CFBundleCFMGetSymbolByName(bundle, funcName, kTVectorCFragSymbol);
+            break;
+#endif /* BINARY_SUPPORT_CFM */
+#if defined(BINARY_SUPPORT_DYLD)
+        case __CFBundleDYLDBundleBinary:
+        case __CFBundleDYLDFrameworkBinary:
+        case __CFBundleDYLDExecutableBinary:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) fp = _CFBundleDlfcnGetSymbolByNameWithSearch(bundle, funcName, true); else
+#endif /* BINARY_SUPPORT_DLFCN */
+            fp = _CFBundleDYLDGetSymbolByNameWithSearch(bundle, funcName, true);
+            break;
+#endif /* BINARY_SUPPORT_DYLD */
+        default:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) fp = _CFBundleDlfcnGetSymbolByNameWithSearch(bundle, funcName, true);
+#endif /* BINARY_SUPPORT_DLFCN */
+            break;
+    }
+#endif /* BINARY_SUPPORT_CFM || BINARY_SUPPORT_DYLD || BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DYLD) && defined(BINARY_SUPPORT_CFM)
+    if (fp) {
+        if (!bundle->_glueDict) bundle->_glueDict = CFDictionaryCreateMutable(CFGetAllocator(bundle), 0, NULL, NULL);
+        void *tvp = (void *)CFDictionaryGetValue(bundle->_glueDict, fp);
+        if (!tvp) {
+            tvp = _CFBundleTVectorForFunctionPointer(CFGetAllocator(bundle), fp);
+            CFDictionarySetValue(bundle->_glueDict, fp, tvp);
+        }
+        return tvp;
+    }
+#endif /* BINARY_SUPPORT_DYLD && BINARY_SUPPORT_CFM */
+    return fp;
+}
+
+void CFBundleGetFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]) {
+    SInt32 i, c;
+
+    if (!ftbl) return;
+
+    c = CFArrayGetCount(functionNames);
+    for (i = 0; i < c; i++) {
+        ftbl[i] = CFBundleGetFunctionPointerForName(bundle, (CFStringRef)CFArrayGetValueAtIndex(functionNames, i));
+    }
+}
+
+void _CFBundleGetCFMFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]) {
+    SInt32 i, c;
+
+    if (!ftbl) return;
+
+    c = CFArrayGetCount(functionNames);
+    for (i = 0; i < c; i++) {
+        ftbl[i] = _CFBundleGetCFMFunctionPointerForName(bundle, (CFStringRef)CFArrayGetValueAtIndex(functionNames, i));
+    }
+}
+
+void *CFBundleGetDataPointerForName(CFBundleRef bundle, CFStringRef symbolName) {
+    void *dp = NULL;
+    // Load if necessary
+    if (!bundle->_isLoaded) {
+        if (!CFBundleLoadExecutable(bundle)) return NULL;
+    }
+    
+    switch (bundle->_binaryType) {
+#if defined(BINARY_SUPPORT_CFM)
+        case __CFBundleCFMBinary:
+            dp = _CFBundleCFMGetSymbolByName(bundle, symbolName, kDataCFragSymbol);
+            break;
+#endif /* BINARY_SUPPORT_CFM */
+#if defined(BINARY_SUPPORT_DYLD)
+        case __CFBundleDYLDBundleBinary:
+        case __CFBundleDYLDFrameworkBinary:
+        case __CFBundleDYLDExecutableBinary:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) dp = _CFBundleDlfcnGetSymbolByName(bundle, symbolName); else
+#endif /* BINARY_SUPPORT_DLFCN */
+            dp = _CFBundleDYLDGetSymbolByName(bundle, symbolName);
+            break;
+#endif /* BINARY_SUPPORT_DYLD */
+#if defined(BINARY_SUPPORT_DLL)
+        case __CFBundleDLLBinary:
+            /* MF:!!! Handle this someday */
+            break;
+#endif /* BINARY_SUPPORT_DLL */
+        default:
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (bundle->_handleCookie) dp = _CFBundleDlfcnGetSymbolByName(bundle, symbolName);
+#endif /* BINARY_SUPPORT_DLFCN */
+            break;
+    }
+    return dp;
+}
+
+void CFBundleGetDataPointersForNames(CFBundleRef bundle, CFArrayRef symbolNames, void *stbl[]) {
+    SInt32 i, c;
+
+    if (!stbl) return;
+
+    c = CFArrayGetCount(symbolNames);
+    for (i = 0; i < c; i++) {
+        stbl[i] = CFBundleGetDataPointerForName(bundle, (CFStringRef)CFArrayGetValueAtIndex(symbolNames, i));
+    }
+}
+
+__private_extern__ _CFResourceData *__CFBundleGetResourceData(CFBundleRef bundle) {
+    return &(bundle->_resourceData);
+}
+
+CFPlugInRef CFBundleGetPlugIn(CFBundleRef bundle) {
+    if (bundle->_plugInData._isPlugIn) {
+        return (CFPlugInRef)bundle;
+    } else {
+        return NULL;
+    }
+}
+
+__private_extern__ _CFPlugInData *__CFBundleGetPlugInData(CFBundleRef bundle) {
+    return &(bundle->_plugInData);
+}
+
+__private_extern__ Boolean _CFBundleCouldBeBundle(CFURLRef url) {
+    Boolean result = false;
+    Boolean exists;
+    SInt32 mode;
+
+    if (_CFGetFileProperties(kCFAllocatorSystemDefault, url, &exists, &mode, NULL, NULL, NULL, NULL) == 0) {
+        result = (exists && ((mode & S_IFMT) == S_IFDIR) && ((mode & 0444) != 0));
+    }
+    return result;
+}
+
+#define LENGTH_OF(A) (sizeof(A) / sizeof(A[0]))
+
+__private_extern__ CFURLRef _CFBundleCopyFrameworkURLForExecutablePath(CFAllocatorRef alloc, CFStringRef executablePath) {
+    // MF:!!! Implement me.  We need to be able to find the bundle from the exe, dealing with old vs. new as well as the Executables dir business on Windows.
+#if DEPLOYMENT_TARGET_WINDOWS
+    UniChar executablesToFrameworksPathBuff[] = {'.', '.', '\\', 'F', 'r', 'a', 'm', 'e', 'w', 'o', 'r', 'k', 's'};  // length 16
+    UniChar executablesToPrivateFrameworksPathBuff[] = {'.', '.', '\\', 'P', 'r', 'i', 'v', 'a', 't', 'e', 'F', 'r', 'a', 'm', 'e', 'w', 'o', 'r', 'k', 's'};  // length 23
+    UniChar frameworksExtension[] = {'f', 'r', 'a', 'm', 'e', 'w', 'o', 'r', 'k'};  // length 9
+#endif
+
+    UniChar pathBuff[CFMaxPathSize];
+    UniChar nameBuff[CFMaxPathSize];
+    CFIndex length, nameStart, nameLength, savedLength;
+    CFMutableStringRef cheapStr = CFStringCreateMutableWithExternalCharactersNoCopy(alloc, NULL, 0, 0, NULL);
+    CFURLRef bundleURL = NULL;
+
+    length = CFStringGetLength(executablePath);
+    if (length > CFMaxPathSize) length = CFMaxPathSize;
+    CFStringGetCharacters(executablePath, CFRangeMake(0, length), pathBuff);
+
+    // Save the name in nameBuff
+    length = _CFLengthAfterDeletingPathExtension(pathBuff, length);
+    nameStart = _CFStartOfLastPathComponent(pathBuff, length);
+    nameLength = length - nameStart;
+    memmove(nameBuff, &(pathBuff[nameStart]), nameLength * sizeof(UniChar));
+
+    // Strip the name from pathBuff
+    length = _CFLengthAfterDeletingLastPathComponent(pathBuff, length);
+    savedLength = length;
+
+#if DEPLOYMENT_TARGET_WINDOWS
+    // * (Windows-only) First check the "Executables" directory parallel to the "Frameworks" directory case.
+    if (_CFAppendPathComponent(pathBuff, &length, CFMaxPathSize, executablesToFrameworksPathBuff, 16) && _CFAppendPathComponent(pathBuff, &length, CFMaxPathSize, nameBuff, nameLength) && _CFAppendPathExtension(pathBuff, &length, CFMaxPathSize, frameworksExtension, 9)) {
+        CFStringSetExternalCharactersNoCopy(cheapStr, pathBuff, length, CFMaxPathSize);
+        bundleURL = CFURLCreateWithFileSystemPath(alloc, cheapStr, PLATFORM_PATH_STYLE, true);
+        if (!_CFBundleCouldBeBundle(bundleURL)) {
+            CFRelease(bundleURL);
+            bundleURL = NULL;
+        }
+    }
+    // * (Windows-only) Next check the "Executables" directory parallel to the "PrivateFrameworks" directory case.
+    if (bundleURL == NULL) {
+        length = savedLength;
+        if (_CFAppendPathComponent(pathBuff, &length, CFMaxPathSize, executablesToPrivateFrameworksPathBuff, 23) && _CFAppendPathComponent(pathBuff, &length, CFMaxPathSize, nameBuff, nameLength) && _CFAppendPathExtension(pathBuff, &length, CFMaxPathSize, frameworksExtension, 9)) {
+            CFStringSetExternalCharactersNoCopy(cheapStr, pathBuff, length, CFMaxPathSize);
+            bundleURL = CFURLCreateWithFileSystemPath(alloc, cheapStr, PLATFORM_PATH_STYLE, true);
+            if (!_CFBundleCouldBeBundle(bundleURL)) {
+                CFRelease(bundleURL);
+                bundleURL = NULL;
+            }
+        }
+    }
+#endif
+
+    // * Finally check the executable inside the framework case.
+    if (!bundleURL) {
+        // MF:!!! This should ensure the framework name is the same as the library name!
+        CFIndex curStart;
+        
+        length = savedLength;
+        // To catch all the cases, we just peel off level looking for one ending in .framework or one called "Supporting Files".
+
+        while (length > 0) {
+            curStart = _CFStartOfLastPathComponent(pathBuff, length);
+            if (curStart >= length) {
+                break;
+            }
+            CFStringSetExternalCharactersNoCopy(cheapStr, &(pathBuff[curStart]), length - curStart, CFMaxPathSize - curStart);
+            if (CFEqual(cheapStr, _CFBundleSupportFilesDirectoryName1) || CFEqual(cheapStr, _CFBundleSupportFilesDirectoryName2)) {
+                length = _CFLengthAfterDeletingLastPathComponent(pathBuff, length);
+                CFStringSetExternalCharactersNoCopy(cheapStr, pathBuff, length, CFMaxPathSize);
+                bundleURL = CFURLCreateWithFileSystemPath(alloc, cheapStr, PLATFORM_PATH_STYLE, true);
+                if (!_CFBundleCouldBeBundle(bundleURL)) {
+                    CFRelease(bundleURL);
+                    bundleURL = NULL;
+                }
+                break;
+            } else if (CFStringHasSuffix(cheapStr, CFSTR(".framework"))) {
+                CFStringSetExternalCharactersNoCopy(cheapStr, pathBuff, length, CFMaxPathSize);
+                bundleURL = CFURLCreateWithFileSystemPath(alloc, cheapStr, PLATFORM_PATH_STYLE, true);
+                if (!_CFBundleCouldBeBundle(bundleURL)) {
+                    CFRelease(bundleURL);
+                    bundleURL = NULL;
+                }
+                break;
+            }
+            length = _CFLengthAfterDeletingLastPathComponent(pathBuff, length);
+        }
+    }
+
+    CFStringSetExternalCharactersNoCopy(cheapStr, NULL, 0, 0);
+    CFRelease(cheapStr);
+
+    return bundleURL;
+}
+
+static void _CFBundleEnsureBundleExistsForImagePath(CFStringRef imagePath) {
+    // This finds the bundle for the given path.
+    // If an image path corresponds to a bundle, we see if there is already a bundle instance.  If there is and it is NOT in the _dynamicBundles array, it is added to the staticBundles.  Do not add the main bundle to the list here.
+    CFBundleRef bundle;
+    CFURLRef curURL = _CFBundleCopyFrameworkURLForExecutablePath(kCFAllocatorSystemDefault, imagePath);
+    Boolean doFinalProcessing = false;
+
+    if (curURL) {
+        bundle = _CFBundleFindByURL(curURL, true);
+        if (!bundle) {
+            bundle = _CFBundleCreate(kCFAllocatorSystemDefault, curURL, true, false);
+            doFinalProcessing = true;
+        }
+        if (bundle && !bundle->_isLoaded) {
+            // make sure that these bundles listed as loaded, and mark them frameworks (we probably can't see anything else here, and we cannot unload them)
+#if defined(BINARY_SUPPORT_DLFCN)
+            if (!bundle->_isLoaded && _useDlfcn) _CFBundleDlfcnCheckLoaded(bundle);
+#endif /* BINARY_SUPPORT_DLFCN */
+#if defined(BINARY_SUPPORT_DYLD)
+            if (bundle->_binaryType == __CFBundleUnknownBinary) bundle->_binaryType = __CFBundleDYLDFrameworkBinary;
+            if (bundle->_binaryType != __CFBundleCFMBinary && bundle->_binaryType != __CFBundleUnreadableBinary) bundle->_resourceData._executableLacksResourceFork = true;
+            if (!bundle->_isLoaded) _CFBundleDYLDCheckLoaded(bundle);
+#endif /* BINARY_SUPPORT_DYLD */
+#if LOG_BUNDLE_LOAD
+            if (!bundle->_isLoaded) printf("ensure bundle %p set loaded fallback, handle %p image %p conn %p\n", bundle, bundle->_handleCookie, bundle->_imageCookie, bundle->_connectionCookie);
+#endif /* LOG_BUNDLE_LOAD */
+            bundle->_isLoaded = true;
+        }
+        // Perform delayed final processing steps.
+        // This must be done after _isLoaded has been set.
+        if (bundle && doFinalProcessing) {
+            _CFBundleCheckWorkarounds(bundle);
+            if (_CFBundleNeedsInitPlugIn(bundle)) {
+                __CFSpinUnlock(&CFBundleGlobalDataLock);
+                _CFBundleInitPlugIn(bundle);
+                __CFSpinLock(&CFBundleGlobalDataLock);
+            }
+        }
+        CFRelease(curURL);
+    }
+}
+
+static void _CFBundleEnsureBundlesExistForImagePaths(CFArrayRef imagePaths) {
+    // This finds the bundles for the given paths.
+    // If an image path corresponds to a bundle, we see if there is already a bundle instance.  If there is and it is NOT in the _dynamicBundles array, it is added to the staticBundles.  Do not add the main bundle to the list here (even if it appears in imagePaths).
+    CFIndex i, imagePathCount = CFArrayGetCount(imagePaths);
+
+    for (i = 0; i < imagePathCount; i++) {
+        _CFBundleEnsureBundleExistsForImagePath((CFStringRef)CFArrayGetValueAtIndex(imagePaths, i));
+    }
+}
+
+static void _CFBundleEnsureBundlesUpToDateWithHintAlreadyLocked(CFStringRef hint) {
+    CFArrayRef imagePaths = NULL;
+    // Tickle the main bundle into existence
+    (void)_CFBundleGetMainBundleAlreadyLocked();
+#if defined(BINARY_SUPPORT_DYLD)
+    imagePaths = _CFBundleDYLDCopyLoadedImagePathsForHint(hint);
+#endif /* BINARY_SUPPORT_DYLD */
+    if (imagePaths) {
+        _CFBundleEnsureBundlesExistForImagePaths(imagePaths);
+        CFRelease(imagePaths);
+    }
+}
+
+static void _CFBundleEnsureAllBundlesUpToDateAlreadyLocked(void) {
+    // This method returns all the statically linked bundles.  This includes the main bundle as well as any frameworks that the process was linked against at launch time.  It does not include frameworks or opther bundles that were loaded dynamically.
+    CFArrayRef imagePaths = NULL;
+
+    // Tickle the main bundle into existence
+    (void)_CFBundleGetMainBundleAlreadyLocked();
+
+#if defined(BINARY_SUPPORT_DLL)
+// Dont know how to find static bundles for DLLs
+#endif /* BINARY_SUPPORT_DLL */
+
+#if defined(BINARY_SUPPORT_CFM)
+// CFM bundles are supplied to us by CFM, so we do not need to figure them out ourselves
+#endif /* BINARY_SUPPORT_CFM */
+
+#if defined(BINARY_SUPPORT_DYLD)
+    imagePaths = _CFBundleDYLDCopyLoadedImagePathsIfChanged();
+#endif /* BINARY_SUPPORT_DYLD */
+    if (imagePaths) {
+        _CFBundleEnsureBundlesExistForImagePaths(imagePaths);
+        CFRelease(imagePaths);
+    }
+}
+
+CFArrayRef CFBundleGetAllBundles(void) {
+    // To answer this properly, we have to have created the static bundles!
+    __CFSpinLock(&CFBundleGlobalDataLock);
+    _CFBundleEnsureAllBundlesUpToDateAlreadyLocked();
+    __CFSpinUnlock(&CFBundleGlobalDataLock);
+    return _allBundles;
+}
+
+uint8_t _CFBundleLayoutVersion(CFBundleRef bundle) {return bundle->_version;}
+
+CF_EXPORT CFURLRef _CFBundleCopyInfoPlistURL(CFBundleRef bundle) {
+    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+    CFURLRef url = (CFURLRef)CFDictionaryGetValue(infoDict, _kCFBundleInfoPlistURLKey);
+    if (!url) url = (CFURLRef)CFDictionaryGetValue(infoDict, _kCFBundleRawInfoPlistURLKey);
+    return (url ? (CFURLRef)CFRetain(url) : NULL);
+}
+
+CF_EXPORT CFURLRef _CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle) {return CFBundleCopyPrivateFrameworksURL(bundle);}
+
+CF_EXPORT CFURLRef CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle) {
+    CFURLRef result = NULL;
+
+    if (1 == bundle->_version) {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundlePrivateFrameworksURLFromBase1, bundle->_url);
+    } else if (2 == bundle->_version) {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundlePrivateFrameworksURLFromBase2, bundle->_url);
+    } else {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundlePrivateFrameworksURLFromBase0, bundle->_url);
+    }
+    return result;
+}
+
+CF_EXPORT CFURLRef _CFBundleCopySharedFrameworksURL(CFBundleRef bundle) {return CFBundleCopySharedFrameworksURL(bundle);}
+
+CF_EXPORT CFURLRef CFBundleCopySharedFrameworksURL(CFBundleRef bundle) {
+    CFURLRef result = NULL;
+
+    if (1 == bundle->_version) {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundleSharedFrameworksURLFromBase1, bundle->_url);
+    } else if (2 == bundle->_version) {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundleSharedFrameworksURLFromBase2, bundle->_url);
+    } else {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundleSharedFrameworksURLFromBase0, bundle->_url);
+    }
+    return result;
+}
+
+CF_EXPORT CFURLRef _CFBundleCopySharedSupportURL(CFBundleRef bundle) {return CFBundleCopySharedSupportURL(bundle);}
+
+CF_EXPORT CFURLRef CFBundleCopySharedSupportURL(CFBundleRef bundle) {
+    CFURLRef result = NULL;
+
+    if (1 == bundle->_version) {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundleSharedSupportURLFromBase1, bundle->_url);
+    } else if (2 == bundle->_version) {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundleSharedSupportURLFromBase2, bundle->_url);
+    } else {
+        result = CFURLCreateWithString(CFGetAllocator(bundle), _CFBundleSharedSupportURLFromBase0, bundle->_url);
+    }
+    return result;
+}
+
+__private_extern__ CFURLRef _CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle) {return CFBundleCopyBuiltInPlugInsURL(bundle);}
+
+CF_EXPORT CFURLRef CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle) {
+    CFURLRef result = NULL, alternateResult = NULL;
+
+    CFAllocatorRef alloc = CFGetAllocator(bundle);
+    if (1 == bundle->_version) {
+        result = CFURLCreateWithString(alloc, _CFBundleBuiltInPlugInsURLFromBase1, bundle->_url);
+    } else if (2 == bundle->_version) {
+        result = CFURLCreateWithString(alloc, _CFBundleBuiltInPlugInsURLFromBase2, bundle->_url);
+    } else {
+        result = CFURLCreateWithString(alloc, _CFBundleBuiltInPlugInsURLFromBase0, bundle->_url);
+    }
+    if (!result || !_urlExists(alloc, result)) {
+        if (1 == bundle->_version) {
+            alternateResult = CFURLCreateWithString(alloc, _CFBundleAlternateBuiltInPlugInsURLFromBase1, bundle->_url);
+        } else if (2 == bundle->_version) {
+            alternateResult = CFURLCreateWithString(alloc, _CFBundleAlternateBuiltInPlugInsURLFromBase2, bundle->_url);
+        } else {
+            alternateResult = CFURLCreateWithString(alloc, _CFBundleAlternateBuiltInPlugInsURLFromBase0, bundle->_url);
+        }
+        if (alternateResult && _urlExists(alloc, alternateResult)) {
+            if (result) CFRelease(result);
+            result = alternateResult;
+        } else {
+            if (alternateResult) CFRelease(alternateResult);
+        }
+    }
+    return result;
+}
+
+
+
+#if defined(BINARY_SUPPORT_DYLD)
+
+static const void *__CFBundleDYLDFindImage(char *buff) {
+    const void *header = NULL;
+    uint32_t i, numImages = _dyld_image_count(), numMatches = 0;
+    const char *curName, *p, *q;
+
+    for (i = 0; !header && i < numImages; i++) {
+        curName = _dyld_get_image_name(i);
+        if (curName && 0 == strncmp(curName, buff, CFMaxPathSize)) {
+            header = _dyld_get_image_header(i);
+            numMatches = 1;
+        }
+    }
+    if (!header) {
+        for (i = 0; i < numImages; i++) {
+            curName = _dyld_get_image_name(i);
+            if (curName) {
+                for (p = buff, q = curName; *p && *q && (q - curName < CFMaxPathSize); p++, q++) {
+                    if (*p != *q && (q - curName > 11) && 0 == strncmp(q - 11, ".framework/Versions/", 20) && *(q + 9) && '/' == *(q + 10)) q += 11;
+                    else if (*p != *q && (q - curName > 12) && 0 == strncmp(q - 12, ".framework/Versions/", 20) && *(q + 8) && '/' == *(q + 9)) q += 10;
+                    if (*p != *q) break;
+                }
+                if (*p == *q) {
+                    header = _dyld_get_image_header(i);
+                    numMatches++;
+                }
+            }
+        }
+    }
+    return (numMatches == 1) ? header : NULL;
+}
+
+__private_extern__ Boolean _CFBundleDYLDCheckLoaded(CFBundleRef bundle) {
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        char buff[CFMaxPathSize];
+
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+            const void *header = __CFBundleDYLDFindImage(buff);
+            if (header) {
+                if (bundle->_binaryType == __CFBundleUnknownBinary) bundle->_binaryType = __CFBundleDYLDFrameworkBinary;
+                if (!bundle->_imageCookie) {
+                    bundle->_imageCookie = header;
+#if LOG_BUNDLE_LOAD
+                    printf("dyld check load bundle %p, find %s getting image %p\n", bundle, buff, bundle->_imageCookie);
+#endif /* LOG_BUNDLE_LOAD */
+                }
+                bundle->_isLoaded = true;
+            } else {
+#if LOG_BUNDLE_LOAD
+                printf("dyld check load bundle %p, find %s no image\n", bundle, buff);
+#endif /* LOG_BUNDLE_LOAD */
+            }
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    return bundle->_isLoaded;
+}
+
+__private_extern__ Boolean _CFBundleDYLDLoadBundle(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error) {
+    CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
+    NSLinkEditErrors c = NSLinkEditUndefinedError;
+    int errorNumber = 0;
+    const char *fileName = NULL;
+    const char *errorString = NULL;
+
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        char buff[CFMaxPathSize];
+
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+            NSObjectFileImage image;
+            NSObjectFileImageReturnCode retCode = NSCreateObjectFileImageFromFile(buff, &image);
+#if LOG_BUNDLE_LOAD
+            printf("dyld load bundle %p, create image of %s returns image %p retcode %d\n", bundle, buff, image, retCode);
+#endif /* LOG_BUNDLE_LOAD */
+            if (retCode == NSObjectFileImageSuccess) {
+                uint32_t options = forceGlobal ? NSLINKMODULE_OPTION_RETURN_ON_ERROR : (NSLINKMODULE_OPTION_BINDNOW | NSLINKMODULE_OPTION_PRIVATE | NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+                NSModule module = NSLinkModule(image, buff, options);
+#if LOG_BUNDLE_LOAD
+                printf("dyld load bundle %p, link module of %s options 0x%x returns module %p image %p\n", bundle, buff, options, module, image);
+#endif /* LOG_BUNDLE_LOAD */
+                if (module) {
+                    bundle->_imageCookie = image;
+                    bundle->_moduleCookie = module;
+                    bundle->_isLoaded = true;
+                } else {
+                    NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
+                    CFLog(__kCFLogBundle, CFSTR("Error loading %s:  error code %d, error number %d (%s)"), fileName, c, errorNumber, errorString);
+                    if (error) {
+#if defined(BINARY_SUPPORT_DLFCN)
+                        _CFBundleDlfcnPreflight(bundle, subError);
+#endif /* BINARY_SUPPORT_DLFCN */
+                        if (!localError) {
+                            CFStringRef debugString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("error code %d, error number %d (%s)"), c, errorNumber, errorString);
+                            localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError, debugString);
+                            CFRelease(debugString);
+                        }
+                    }
+                    (void)NSDestroyObjectFileImage(image);
+                }
+            } else {
+                CFLog(__kCFLogBundle, CFSTR("dyld returns %d when trying to load %@"), retCode, executableURL);
+                if (error) {
+                    if (retCode == NSObjectFileImageArch) {
+                        localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableArchitectureMismatchError);
+                    } else if (retCode == NSObjectFileImageInappropriateFile) {
+                        Boolean hasRuntimeMismatch = false;
+                        uint32_t mainFlags = 0, bundleFlags = 0;
+                        if (_CFBundleGrokObjCImageInfoFromMainExecutable(NULL, &mainFlags) && (mainFlags & 0x2) != 0) {
+                            if (_CFBundleGetObjCImageInfo(bundle, NULL, &bundleFlags) && (bundleFlags & 0x2) == 0) hasRuntimeMismatch = true;
+                        }
+                        if (hasRuntimeMismatch) {
+                            localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableRuntimeMismatchError);
+                        } else {
+                            localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotLoadableError);
+                        }
+                    } else {
+#if defined(BINARY_SUPPORT_DLFCN)
+                        _CFBundleDlfcnPreflight(bundle, subError);
+#endif /* BINARY_SUPPORT_DLFCN */
+                        if (!localError) {
+                            CFStringRef debugString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("dyld returns %d"), retCode);
+                            localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError, debugString);
+                            CFRelease(debugString);
+                        }
+                    }
+                }
+            }
+        } else {
+            CFLog(__kCFLogBundle, CFSTR("Cannot find executable for bundle %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    if (!bundle->_isLoaded && error) *error = localError;
+    return bundle->_isLoaded;
+}
+
+__private_extern__ Boolean _CFBundleDYLDLoadFramework(CFBundleRef bundle, CFErrorRef *error) {
+    // !!! Framework loading should be better.  Can't unload frameworks.
+    CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
+    NSLinkEditErrors c = NSLinkEditUndefinedError;
+    int errorNumber = 0;
+    const char *fileName = NULL;
+    const char *errorString = NULL;
+
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        char buff[CFMaxPathSize];
+
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+            void *image = (void *)NSAddImage(buff, NSADDIMAGE_OPTION_RETURN_ON_ERROR);
+#if LOG_BUNDLE_LOAD
+            printf("dyld load framework %p, add image of %s returns image %p\n", bundle, buff, image);
+#endif /* LOG_BUNDLE_LOAD */
+            if (image) {
+                bundle->_imageCookie = image;
+                bundle->_isLoaded = true;
+            } else {
+                NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
+                CFLog(__kCFLogBundle, CFSTR("Error loading %s:  error code %d, error number %d (%s)"), fileName, c, errorNumber, errorString);
+                if (error) {
+#if defined(BINARY_SUPPORT_DLFCN)
+                    _CFBundleDlfcnPreflight(bundle, subError);
+#endif /* BINARY_SUPPORT_DLFCN */
+                    if (!localError) {
+                        CFStringRef debugString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("error code %d, error number %d (%s)"), c, errorNumber, errorString);
+                        localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError, debugString);
+                        CFRelease(debugString);
+                    }
+                }
+            }
+        } else {
+            CFLog(__kCFLogBundle, CFSTR("Cannot find executable for bundle %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    if (!bundle->_isLoaded && error) *error = localError;
+    return bundle->_isLoaded;
+}
+
+__private_extern__ void _CFBundleDYLDUnloadBundle(CFBundleRef bundle) {
+    if (bundle->_isLoaded) {
+#if LOG_BUNDLE_LOAD
+        printf("dyld unload bundle %p, handle %p module %p image %p\n", bundle, bundle->_handleCookie, bundle->_moduleCookie, bundle->_imageCookie);
+#endif /* LOG_BUNDLE_LOAD */
+        if (bundle->_moduleCookie && !NSUnLinkModule((NSModule)(bundle->_moduleCookie), NSUNLINKMODULE_OPTION_NONE)) {
+            CFLog(__kCFLogBundle, CFSTR("Internal error unloading bundle %@"), bundle);
+        } else {
+            if (bundle->_moduleCookie && bundle->_imageCookie) (void)NSDestroyObjectFileImage((NSObjectFileImage)(bundle->_imageCookie));
+            bundle->_connectionCookie = bundle->_handleCookie = NULL;
+            bundle->_imageCookie = bundle->_moduleCookie = NULL;
+            bundle->_isLoaded = false;
+        }
+    }
+}
+
+__private_extern__ void *_CFBundleDYLDGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName) {return _CFBundleDYLDGetSymbolByNameWithSearch(bundle, symbolName, false);}
+
+static void *_CFBundleDYLDGetSymbolByNameWithSearch(CFBundleRef bundle, CFStringRef symbolName, Boolean globalSearch) {
+    void *result = NULL;
+    char buff[1026];
+    NSSymbol symbol = NULL;
+    
+    buff[0] = '_';
+    if (CFStringGetCString(symbolName, &(buff[1]), 1024, kCFStringEncodingUTF8)) {
+        if (bundle->_moduleCookie) {
+            symbol = NSLookupSymbolInModule((NSModule)(bundle->_moduleCookie), buff);
+        } else if (bundle->_imageCookie) {
+            symbol = NSLookupSymbolInImage((const struct mach_header*)bundle->_imageCookie, buff, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND|NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+        } 
+        if (!symbol && !bundle->_moduleCookie && (!bundle->_imageCookie || globalSearch)) {
+            char hintBuff[1026];
+            CFStringRef executableName = _CFBundleCopyExecutableName(kCFAllocatorSystemDefault, bundle, NULL, NULL);
+            hintBuff[0] = '\0';
+            if (executableName) {
+                if (!CFStringGetCString(executableName, hintBuff, 1024, kCFStringEncodingUTF8)) hintBuff[0] = '\0';
+                CFRelease(executableName);
+            }
+	    // Nowdays, NSIsSymbolNameDefinedWithHint() and NSLookupAndBindSymbolWithHint()
+	    // are identical, except the first just returns a bool, so checking with the
+	    // Is function first just causes a redundant lookup.
+	    // This returns NULL on failure.
+            symbol = NSLookupAndBindSymbolWithHint(buff, hintBuff);
+        }
+        if (symbol) result = NSAddressOfSymbol(symbol);
+#if defined(DEBUG)
+        if (!result) CFLog(__kCFLogBundle, CFSTR("dyld cannot find symbol %s in %@"), buff, bundle);
+#endif /* DEBUG */
+#if LOG_BUNDLE_LOAD
+        printf("bundle %p handle %p module %p image %p dyld returns symbol %p for %s\n", bundle, bundle->_handleCookie, bundle->_moduleCookie, bundle->_imageCookie, result, buff + 1);
+#endif /* LOG_BUNDLE_LOAD */
+    }
+    return result;
+}
+
+static CFStringRef _CFBundleDYLDCopyLoadedImagePathForPointer(void *p) {
+    CFStringRef result = NULL;
+    if (!result) {
+        uint32_t i, j, n = _dyld_image_count();
+        Boolean foundit = false;
+        const char *name;
+#if __LP64__
+#define MACH_HEADER_TYPE struct mach_header_64
+#define MACH_SEGMENT_CMD_TYPE struct segment_command_64
+#define MACH_SEGMENT_FLAVOR LC_SEGMENT_64
+#else
+#define MACH_HEADER_TYPE struct mach_header
+#define MACH_SEGMENT_CMD_TYPE struct segment_command
+#define MACH_SEGMENT_FLAVOR LC_SEGMENT
+#endif
+        for (i = 0; !foundit && i < n; i++) {
+            const MACH_HEADER_TYPE *mh = (const MACH_HEADER_TYPE *)_dyld_get_image_header(i);
+            uintptr_t addr = (uintptr_t)p - _dyld_get_image_vmaddr_slide(i);
+            if (mh) {
+                struct load_command *lc = (struct load_command *)((char *)mh + sizeof(MACH_HEADER_TYPE));
+                for (j = 0; !foundit && j < mh->ncmds; j++, lc = (struct load_command *)((char *)lc + lc->cmdsize)) {
+                    if (MACH_SEGMENT_FLAVOR == lc->cmd && ((MACH_SEGMENT_CMD_TYPE *)lc)->vmaddr <= addr && addr < ((MACH_SEGMENT_CMD_TYPE *)lc)->vmaddr + ((MACH_SEGMENT_CMD_TYPE *)lc)->vmsize) {
+                        foundit = true;
+                        name = _dyld_get_image_name(i);
+                        if (name) result = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, name);
+                    }
+                }
+            }
+        }
+#undef MACH_HEADER_TYPE
+#undef MACH_SEGMENT_CMD_TYPE
+#undef MACH_SEGMENT_FLAVOR
+    }
+#if LOG_BUNDLE_LOAD
+    printf("dyld image path for pointer %p is %p\n", p, result);
+#endif /* LOG_BUNDLE_LOAD */
+    return result;
+}
+
+__private_extern__ CFArrayRef _CFBundleDYLDCopyLoadedImagePathsForHint(CFStringRef hint) {
+    uint32_t i, numImages = _dyld_image_count();
+    CFMutableArrayRef result = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    CFRange range = CFRangeMake(0, CFStringGetLength(hint));
+    const char *processPath = _CFProcessPath();
+    
+    for (i = 0; i < numImages; i++) {
+        const char *curName = _dyld_get_image_name(i), *lastComponent = NULL;
+        if (curName && (!processPath || 0 != strcmp(curName, processPath))) lastComponent = strrchr(curName, '/');
+        if (lastComponent) {
+            CFStringRef str = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, lastComponent + 1);
+            if (str) {
+                if (CFStringFindWithOptions(hint, str, range, kCFCompareAnchored|kCFCompareBackwards|kCFCompareCaseInsensitive, NULL)) {
+                    CFStringRef curStr = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, curName);
+                    if (curStr) {
+                        CFArrayAppendValue(result, curStr);
+                        CFRelease(curStr);
+                    }
+                }
+                CFRelease(str);
+            }
+        }
+    }
+    return result;
+}
+
+static char *_cleanedPathForPath(const char *curName) {
+    char *thePath = strdup(curName);
+    if (thePath) {
+        // We are going to process the buffer replacing all "/./" and "//" with "/"
+        CFIndex srcIndex = 0, dstIndex = 0;
+        CFIndex len = strlen(thePath);
+        for (srcIndex=0; srcIndex<len; srcIndex++) {
+            thePath[dstIndex] = thePath[srcIndex];
+            dstIndex++;
+            while (srcIndex < len-1 && thePath[srcIndex] == '/' && (thePath[srcIndex+1] == '/' || (thePath[srcIndex+1] == '.' && srcIndex < len-2 && thePath[srcIndex+2] == '/'))) srcIndex += (thePath[srcIndex+1] == '/' ? 1 : 2);
+        }
+        thePath[dstIndex] = 0;
+    }
+    return thePath;
+}
+
+__private_extern__ CFArrayRef _CFBundleDYLDCopyLoadedImagePathsIfChanged(void) {
+    // This returns an array of the paths of all the dyld images in the process.  These paths may not be absolute, they may point at things that are not bundles, they may be staticly linked bundles or dynamically loaded bundles, they may be NULL.
+    static uint32_t _cachedDYLDImageCount = -1;
+
+    uint32_t i, numImages = _dyld_image_count();
+    CFMutableArrayRef result = NULL;
+
+    if (numImages != _cachedDYLDImageCount) {
+        const char *curName;
+        char *cleanedCurName = NULL;
+        CFStringRef curStr;
+        const char *processPath = _CFProcessPath();
+
+        result = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+
+        for (i = 0; i < numImages; i++) {
+            curName = _dyld_get_image_name(i);
+            if (curName && i == 0) cleanedCurName = _cleanedPathForPath(curName);
+            if (curName && (!processPath || 0 != strcmp(curName, processPath)) && (!processPath || !cleanedCurName || 0 != strcmp(cleanedCurName, processPath))) {
+                curStr = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, curName);
+                if (curStr) {
+                    CFArrayAppendValue(result, curStr);
+                    CFRelease(curStr);
+                }
+            }
+            if (cleanedCurName) {
+                free(cleanedCurName);
+                cleanedCurName = NULL;
+            }
+        }
+        _cachedDYLDImageCount = numImages;
+    }
+    return result;
+}
+
+#endif /* BINARY_SUPPORT_DYLD */
+
+#if defined(BINARY_SUPPORT_DLFCN)
+
+__private_extern__ Boolean _CFBundleDlfcnCheckLoaded(CFBundleRef bundle) {
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        char buff[CFMaxPathSize];
+
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+            int mode = RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD | CF_RTLD_FIRST;
+            void *handle = dlopen(buff, mode);
+            if (handle) {
+                if (!bundle->_handleCookie) {
+                    bundle->_handleCookie = handle;
+#if LOG_BUNDLE_LOAD
+                    printf("dlfcn check load bundle %p, dlopen of %s mode 0x%x getting handle %p\n", bundle, buff, mode, bundle->_handleCookie);
+#endif /* LOG_BUNDLE_LOAD */
+                }
+                bundle->_isLoaded = true;
+            } else {
+#if LOG_BUNDLE_LOAD
+                printf("dlfcn check load bundle %p, dlopen of %s mode 0x%x no handle\n", bundle, buff, mode);
+#endif /* LOG_BUNDLE_LOAD */
+            }
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    return bundle->_isLoaded;
+}
+
+static SInt32 _CFBundleCurrentArchitecture(void) {
+    SInt32 arch = 0;
+#if defined(__ppc__) || defined(__powerpc__)
+    arch = kCFBundleExecutableArchitecturePPC;
+#elif defined(__ppc64__)
+    arch = kCFBundleExecutableArchitecturePPC64;
+#elif defined(__i386__)
+    arch = kCFBundleExecutableArchitectureI386;
+#elif defined(__x86_64__)
+    arch = kCFBundleExecutableArchitectureX86_64;
+#elif defined(BINARY_SUPPORT_DYLD)
+    const NXArchInfo *archInfo = NXGetLocalArchInfo();
+    if (archInfo) arch = archInfo->cputype;
+#endif
+    return arch;
+}
+
+extern Boolean _CFBundleDlfcnPreflight(CFBundleRef bundle, CFErrorRef *error) {
+    Boolean retval = true;
+    CFErrorRef localError = NULL;
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        char buff[CFMaxPathSize];
+        
+        retval = false;
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+#if DEPLOYMENT_TARGET_MACOSX && (MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED)
+            retval = dlopen_preflight(buff);
+#else
+			retval = false;
+#endif /* DEPLOYMENT_TARGET_MACOSX && (MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED) */
+            if (!retval && error) {
+                CFArrayRef archs = CFBundleCopyExecutableArchitectures(bundle);
+                CFStringRef debugString = NULL;
+                const char *errorString = dlerror();
+                if (errorString && strlen(errorString) > 0) debugString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString);
+                if (archs) {
+                    Boolean hasSuitableArch = false, hasRuntimeMismatch = false;
+                    CFIndex i, count = CFArrayGetCount(archs);
+                    SInt32 arch, curArch = _CFBundleCurrentArchitecture();
+                    for (i = 0; !hasSuitableArch && i < count; i++) {
+                        if (CFNumberGetValue((CFNumberRef)CFArrayGetValueAtIndex(archs, i), kCFNumberSInt32Type, (void *)&arch) && arch == curArch) hasSuitableArch = true;
+                    }
+#if defined(BINARY_SUPPORT_DYLD)
+                    if (hasSuitableArch) {
+                        uint32_t mainFlags = 0, bundleFlags = 0;
+                        if (_CFBundleGrokObjCImageInfoFromMainExecutable(NULL, &mainFlags) && (mainFlags & 0x2) != 0) {
+                            if (_CFBundleGetObjCImageInfo(bundle, NULL, &bundleFlags) && (bundleFlags & 0x2) == 0) hasRuntimeMismatch = true;
+                        }
+                    }
+#endif /* BINARY_SUPPORT_DYLD */
+                    if (hasRuntimeMismatch) {
+                        localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableRuntimeMismatchError, debugString);
+                    } else if (!hasSuitableArch) {
+                        localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableArchitectureMismatchError, debugString);
+                    } else {
+                        localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLoadError, debugString);
+                    }
+                    CFRelease(archs);
+                } else {
+                    localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLoadError, debugString);
+                }
+                if (debugString) CFRelease(debugString);
+            }
+        } else {
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    if (!retval && error) *error = localError;
+    return retval;
+}
+
+__private_extern__ Boolean _CFBundleDlfcnLoadBundle(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error) {
+    CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        char buff[CFMaxPathSize];
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+            int mode = forceGlobal ? (RTLD_LAZY | RTLD_GLOBAL | CF_RTLD_FIRST) : (RTLD_NOW | RTLD_LOCAL | CF_RTLD_FIRST);
+            bundle->_handleCookie = dlopen(buff, mode);
+#if LOG_BUNDLE_LOAD
+            printf("dlfcn load bundle %p, dlopen of %s mode 0x%x returns handle %p\n", bundle, buff, mode, bundle->_handleCookie);
+#endif /* LOG_BUNDLE_LOAD */
+            if (bundle->_handleCookie) {
+                bundle->_isLoaded = true;
+            } else {
+                CFStringRef debugString = NULL;
+                const char *errorString = dlerror();
+                if (errorString) {
+                    CFLog(__kCFLogBundle, CFSTR("Error loading %s:  %s"), buff, errorString);
+                    debugString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString);
+                } else {
+                    CFLog(__kCFLogBundle, CFSTR("Error loading %s"), buff);
+                }
+                if (error && _CFBundleDlfcnPreflight(bundle, subError)) localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError, debugString);
+                if (debugString) CFRelease(debugString);
+            }
+        } else {
+            CFLog(__kCFLogBundle, CFSTR("Cannot find executable for bundle %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    if (!bundle->_isLoaded && error) *error = localError;
+    return bundle->_isLoaded;
+}
+
+__private_extern__ Boolean _CFBundleDlfcnLoadFramework(CFBundleRef bundle, CFErrorRef *error) {
+    CFErrorRef localError = NULL, *subError = (error ? &localError : NULL);
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        char buff[CFMaxPathSize];
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+            int mode = RTLD_LAZY | RTLD_GLOBAL | CF_RTLD_FIRST;
+            bundle->_handleCookie = dlopen(buff, mode);
+#if LOG_BUNDLE_LOAD
+            printf("dlfcn load framework %p, dlopen of %s mode 0x%x returns handle %p\n", bundle, buff, mode, bundle->_handleCookie);
+#endif /* LOG_BUNDLE_LOAD */
+            if (bundle->_handleCookie) {
+                bundle->_isLoaded = true;
+            } else {
+                CFStringRef debugString = NULL;
+                const char *errorString = dlerror();
+                if (errorString) {
+                    CFLog(__kCFLogBundle, CFSTR("Error loading %s:  %s"), buff, errorString);
+                    debugString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString);
+                } else {
+                    CFLog(__kCFLogBundle, CFSTR("Error loading %s"), buff);
+                }
+                if (error && _CFBundleDlfcnPreflight(bundle, subError)) localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError, debugString);
+                if (debugString) CFRelease(debugString);
+            }
+        } else {
+            CFLog(__kCFLogBundle, CFSTR("Cannot find executable for bundle %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    if (!bundle->_isLoaded && error) *error = localError;
+    return bundle->_isLoaded;
+}
+
+__private_extern__ void _CFBundleDlfcnUnload(CFBundleRef bundle) {
+    if (bundle->_isLoaded) {
+#if LOG_BUNDLE_LOAD
+        printf("dlfcn unload bundle %p, handle %p module %p image %p\n", bundle, bundle->_handleCookie, bundle->_moduleCookie, bundle->_imageCookie);
+#endif /* LOG_BUNDLE_LOAD */
+        if (0 != dlclose(bundle->_handleCookie)) {
+            CFLog(__kCFLogBundle, CFSTR("Internal error unloading bundle %@"), bundle);
+        } else {
+            bundle->_connectionCookie = bundle->_handleCookie = NULL;
+            bundle->_imageCookie = bundle->_moduleCookie = NULL;
+            bundle->_isLoaded = false;
+        }
+    }
+}
+
+__private_extern__ void *_CFBundleDlfcnGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName) {return _CFBundleDlfcnGetSymbolByNameWithSearch(bundle, symbolName, false);}
+
+static void *_CFBundleDlfcnGetSymbolByNameWithSearch(CFBundleRef bundle, CFStringRef symbolName, Boolean globalSearch) {
+    void *result = NULL;
+    char buff[1026];
+    
+    if (CFStringGetCString(symbolName, buff, 1024, kCFStringEncodingUTF8)) {
+        result = dlsym(bundle->_handleCookie, buff);
+        if (!result && globalSearch) result = dlsym(RTLD_DEFAULT, buff);
+#if defined(DEBUG)
+        if (!result) CFLog(__kCFLogBundle, CFSTR("dlsym cannot find symbol %s in %@"), buff, bundle);
+#endif /* DEBUG */
+#if LOG_BUNDLE_LOAD
+        printf("bundle %p handle %p module %p image %p dlsym returns symbol %p for %s\n", bundle, bundle->_handleCookie, bundle->_moduleCookie, bundle->_imageCookie, result, buff);
+#endif /* LOG_BUNDLE_LOAD */
+    }
+    return result;
+}
+
+static CFStringRef _CFBundleDlfcnCopyLoadedImagePathForPointer(void *p) {
+    CFStringRef result = NULL;
+    Dl_info info;
+    if (0 != dladdr(p, &info) && info.dli_fname) result = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, info.dli_fname);
+#if LOG_BUNDLE_LOAD
+    printf("dlfcn image path for pointer %p is %p\n", p, result);
+#endif /* LOG_BUNDLE_LOAD */
+    return result;
+}
+
+#endif /* BINARY_SUPPORT_DLFCN */
+
+
+#if defined(BINARY_SUPPORT_DLL)
+
+__private_extern__ Boolean _CFBundleDLLLoad(CFBundleRef bundle, CFErrorRef *error) {
+    CFErrorRef localError = NULL;
+    if (!bundle->_isLoaded) {
+        CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
+        TCHAR buff[CFMaxPathSize];
+
+        if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
+            bundle->_hModule = LoadLibrary(buff);
+            if (bundle->_hModule) {
+                bundle->_isLoaded = true;
+            } else {
+                if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableLinkError);
+            }
+        } else {
+            CFLog(__kCFLogBundle, CFSTR("Cannot find executable for bundle %@"), bundle);
+            if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
+        }
+        if (executableURL) CFRelease(executableURL);
+    }
+    if (!bundle->_isLoaded && error) *error = localError;
+    return bundle->_isLoaded;
+}
+
+__private_extern__ void _CFBundleDLLUnload(CFBundleRef bundle) {
+    if (bundle->_isLoaded) {
+       FreeLibrary(bundle->_hModule);
+       bundle->_hModule = NULL;
+       bundle->_isLoaded = false;
+    }
+}
+
+__private_extern__ void *_CFBundleDLLGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName) {
+    void *result = NULL;
+    char buff[1024];
+    if (CFStringGetCString(symbolName, buff, 1024, kCFStringEncodingWindowsLatin1)) result = GetProcAddress(bundle->_hModule, buff);
+    return result;
+}
+
+#endif /* BINARY_SUPPORT_DLL */
+
+/* Workarounds to be applied in the presence of certain bundles can go here. This is called on every bundle creation.
+*/
+extern void _CFStringSetCompatibility(CFOptionFlags);
+
+static void _CFBundleCheckWorkarounds(CFBundleRef bundle) {
+}
+
diff --git a/CoreFoundation/CFBundle.h b/CoreFoundation/CFBundle.h
new file mode 100644
index 0000000..3814fb0
--- /dev/null
+++ b/CoreFoundation/CFBundle.h
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBUNDLE__)
+#define __COREFOUNDATION_CFBUNDLE__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFError.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFURL.h>
+
+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 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;
+    /* 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.  Use with care. */
+
+/* ===================== 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);
+
+#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) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;
+    /* 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) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;
+    /* 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) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;
+    /* 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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+    /* 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);
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+enum {
+    kCFBundleExecutableArchitectureI386     = 0x00000007,
+    kCFBundleExecutableArchitecturePPC      = 0x00000012,
+    kCFBundleExecutableArchitectureX86_64   = 0x01000007,
+    kCFBundleExecutableArchitecturePPC64    = 0x01000012
+};
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 */
+
+CF_EXPORT
+CFArrayRef CFBundleCopyExecutableArchitectures(CFBundleRef bundle) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+    /* 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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+    /* 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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+    /* 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
+
+#endif /* ! __COREFOUNDATION_CFBUNDLE__ */
+
diff --git a/CoreFoundation/CFBundlePriv.h b/CoreFoundation/CFBundlePriv.h
new file mode 100644
index 0000000..83e042f
--- /dev/null
+++ b/CoreFoundation/CFBundlePriv.h
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBUNDLEPRIV__)
+#define __COREFOUNDATION_CFBUNDLEPRIV__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFURL.h>
+
+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;
+
+
+/* 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);
+
+/* Functions for examining the structure of a bundle */
+
+CF_EXPORT
+CFURLRef _CFBundleCopyResourceForkURL(CFBundleRef bundle);
+
+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. */ 
+
+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_EXPORT
+void _CFBundleFlushCachesForURL(CFURLRef url);
+
+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
+void _CFBundleSetStringsFilesShared(CFBundleRef bundle, Boolean flag);
+
+CF_EXPORT
+Boolean _CFBundleGetStringsFilesShared(CFBundleRef bundle);
+
+
+/* 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
+CFArrayRef _CFBundleCopyBundleRegionsArray(CFBundleRef bundle);		// deprecated in favor of CFBundleCopyBundleLocalizations
+
+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/CoreFoundation/CFBundle_BinaryTypes.h b/CoreFoundation/CFBundle_BinaryTypes.h
new file mode 100644
index 0000000..67e0372
--- /dev/null
+++ b/CoreFoundation/CFBundle_BinaryTypes.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBUNDLE_BINARYTYPES__)
+#define __COREFOUNDATION_CFBUNDLE_BINARYTYPES__ 1
+
+CF_EXTERN_C_BEGIN
+
+
+#if DEPLOYMENT_TARGET_MACOSX
+#if !defined(DISABLE_DYLD_USAGE)
+#define BINARY_SUPPORT_DYLD 1
+#endif
+#if !defined(DISABLE_DLFCN_USAGE)
+#define BINARY_SUPPORT_DLFCN 1
+#endif
+#elif DEPLOYMENT_TARGET_WINDOWS
+#define BINARY_SUPPORT_DLL 1
+#elif DEPLOYMENT_TARGET_LINUX
+#define BINARY_SUPPORT_DLFCN 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/CoreFoundation/CFBundle_Internal.h b/CoreFoundation/CFBundle_Internal.h
new file mode 100644
index 0000000..c6518b0
--- /dev/null
+++ b/CoreFoundation/CFBundle_Internal.h
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBUNDLE_INTERNAL__)
+#define __COREFOUNDATION_CFBUNDLE_INTERNAL__ 1
+
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFPlugIn.h>
+#include <CoreFoundation/CFError.h>
+#include "CFInternal.h"
+#include "CFPlugIn_Factory.h"
+#include "CFBundle_BinaryTypes.h"
+
+CF_EXTERN_C_BEGIN
+
+#define __kCFLogBundle       3
+#define __kCFLogPlugIn       3
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || 0
+#define PLATFORM_PATH_STYLE kCFURLPOSIXPathStyle
+#elif DEPLOYMENT_TARGET_WINDOWS
+#define PLATFORM_PATH_STYLE kCFURLWindowsPathStyle
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+#define CFBundleExecutableNotFoundError             4
+#define CFBundleExecutableNotLoadableError          3584
+#define CFBundleExecutableArchitectureMismatchError 3585
+#define CFBundleExecutableRuntimeMismatchError      3586
+#define CFBundleExecutableLoadError                 3587
+#define CFBundleExecutableLinkError                 3588
+
+typedef struct __CFResourceData {
+    CFMutableDictionaryRef _stringTableCache;
+    Boolean _executableLacksResourceFork;
+    Boolean _infoDictionaryFromResourceFork;
+    char _padding[2];
+} _CFResourceData;
+
+extern _CFResourceData *__CFBundleGetResourceData(CFBundleRef bundle);
+
+typedef struct __CFPlugInData {
+    Boolean _isPlugIn;
+    Boolean _loadOnDemand;
+    Boolean _isDoingDynamicRegistration;
+    Boolean _unused1;
+    UInt32 _instanceCount;
+    CFMutableArrayRef _factories;
+} _CFPlugInData;
+
+extern _CFPlugInData *__CFBundleGetPlugInData(CFBundleRef bundle);
+
+/* Private CFBundle API */
+
+extern Boolean _CFIsResourceAtURL(CFURLRef url, Boolean *isDir);
+extern Boolean _CFIsResourceAtPath(CFStringRef path, Boolean *isDir);
+
+extern Boolean _CFBundleURLLooksLikeBundleVersion(CFURLRef url, UInt8 *version);
+extern CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt8 *version);
+extern CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectoryWithVersion(CFAllocatorRef alloc, CFURLRef url, UInt8 version);
+extern CFURLRef _CFBundleCopySupportFilesDirectoryURLInDirectory(CFAllocatorRef alloc, CFURLRef bundleURL, UInt8 version);
+extern CFURLRef _CFBundleCopyResourcesDirectoryURLInDirectory(CFAllocatorRef alloc, CFURLRef bundleURL, UInt8 version);
+
+extern Boolean _CFBundleCouldBeBundle(CFURLRef url);
+extern CFURLRef _CFBundleCopyFrameworkURLForExecutablePath(CFAllocatorRef alloc, CFStringRef executablePath);
+extern CFURLRef _CFBundleCopyResourceForkURLMayBeLocal(CFBundleRef bundle, Boolean mayBeLocal);
+extern CFDictionaryRef _CFBundleCopyInfoDictionaryInResourceForkWithAllocator(CFAllocatorRef alloc, CFURLRef url);
+extern CFStringRef _CFBundleCopyBundleDevelopmentRegionFromVersResource(CFBundleRef bundle);
+extern CFDictionaryRef _CFBundleCopyInfoDictionaryInExecutable(CFURLRef url);
+extern CFArrayRef _CFBundleCopyArchitecturesForExecutable(CFURLRef url);
+
+extern void _CFBundleAddPreferredLprojNamesInDirectory(CFAllocatorRef alloc, CFURLRef bundleURL, UInt8 version, CFDictionaryRef infoDict, CFMutableArrayRef lprojNames, CFStringRef devLang);
+
+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);
+
+
+#if defined(BINARY_SUPPORT_DYLD)
+// DYLD API
+extern __CFPBinaryType _CFBundleGrokBinaryType(CFURLRef executableURL);
+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);
+
+extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsIfChanged(void);
+extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsForHint(CFStringRef hint);
+#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, _CFPFactory *factory);
+extern void _CFPlugInRemoveFactory(CFPlugInRef plugIn, _CFPFactory *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")
+
+#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 _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 _CFBundleInfoFileName CFSTR("Info.plist")
+#define _CFBundleInfoURLFromBaseNoExtension0 CFSTR("Resources/Info")
+#define _CFBundleInfoURLFromBaseNoExtension1 CFSTR("Support%20Files/Info")
+#define _CFBundleInfoURLFromBaseNoExtension2 CFSTR("Contents/Info")
+#define _CFBundleInfoURLFromBaseNoExtension3 CFSTR("Info")
+#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 _CFBundleMacOSXPlatformName CFSTR("macos")
+#define _CFBundleAlternateMacOSXPlatformName CFSTR("macosx")
+#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 _CFBundleUserLanguagesPreferenceName CFSTR("AppleLanguages")
+#define _CFBundleOldUserLanguagesPreferenceName CFSTR("NSLanguages")
+
+#define _CFBundleLocalizedResourceForkFileName CFSTR("Localized")
+
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+#define _CFBundleWindowsResourceDirectoryExtension CFSTR("resources")
+#endif
+
+/* Old platform names (no longer used) */
+#define _CFBundleMacOSXPlatformName_OLD CFSTR("macintosh")
+#define _CFBundleAlternateMacOSXPlatformName_OLD CFSTR("nextstep")
+#define _CFBundleWindowsPlatformName_OLD CFSTR("windows")
+#define _CFBundleAlternateWindowsPlatformName_OLD CFSTR("winnt")
+
+#define _CFBundleMacOSXInfoPlistPlatformName_OLD CFSTR("macos")
+#define _CFBundleWindowsInfoPlistPlatformName_OLD CFSTR("win32")
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFBUNDLE_INTERNAL__ */
+
diff --git a/CoreFoundation/CFBundle_Resources.c b/CoreFoundation/CFBundle_Resources.c
new file mode 100644
index 0000000..fef002f
--- /dev/null
+++ b/CoreFoundation/CFBundle_Resources.c
@@ -0,0 +1,2212 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 David M. Cotter <me@davevcotter.com>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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_Resources.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#define READ_DIRECTORIES 1
+#endif
+
+#define READ_DIRECTORIES_CACHE_CAPACITY 128
+
+#include "CFBundle_Internal.h"
+#include <CoreFoundation/CFURLAccess.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFByteOrder.h>
+#include <CoreFoundation/CFNumber.h>
+#include <string.h>
+#include "CFInternal.h"
+#include "CFPriv.h"
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#if DEPLOYMENT_TARGET_MACOSX
+#include <CoreFoundation/CFPreferences.h>
+#include <unistd.h>
+#endif
+
+#if READ_DIRECTORIES
+#include <dirent.h>
+#endif /* READ_DIRECTORIES */
+
+#if DEPLOYMENT_TARGET_WINDOWS && !defined(__GNUC__)
+#include "compat/dirent.h"
+#define  READ_DIRECTORIES 1
+#endif
+
+
+
+// All new-style bundles will have these extensions.
+CF_INLINE CFStringRef _CFGetPlatformName(void) {
+#if DEPLOYMENT_TARGET_MACOSX
+    return _CFBundleMacOSXPlatformName;
+#elif DEPLOYMENT_TARGET_SOLARIS
+    return _CFBundleSolarisPlatformName;
+#elif DEPLOYMENT_TARGET_HPUX
+    return _CFBundleHPUXPlatformName;
+#elif DEPLOYMENT_TARGET_LINUX
+    return _CFBundleLinuxPlatformName;
+#elif DEPLOYMENT_TARGET_FREEBSD
+    return _CFBundleFreeBSDPlatformName;
+#elif DEPLOYMENT_TARGET_WINDOWS
+    return _CFBundleWindowsPlatformName;
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+}
+
+CF_INLINE CFStringRef _CFGetAlternatePlatformName(void) {
+#if DEPLOYMENT_TARGET_MACOSX
+    return _CFBundleAlternateMacOSXPlatformName;
+#else
+    return CFSTR("");
+#endif
+}
+
+static CFSpinLock_t CFBundleResourceGlobalDataLock = CFSpinLockInit;
+static UniChar *_AppSupportUniChars1 = NULL;
+static CFIndex _AppSupportLen1 = 0;
+static UniChar *_AppSupportUniChars2 = NULL;
+static CFIndex _AppSupportLen2 = 0;
+static UniChar *_ResourcesUniChars = NULL;
+static CFIndex _ResourcesLen = 0;
+static UniChar *_PlatformUniChars = NULL;
+static CFIndex _PlatformLen = 0;
+static UniChar *_AlternatePlatformUniChars = NULL;
+static CFIndex _AlternatePlatformLen = 0;
+static UniChar *_LprojUniChars = NULL;
+static CFIndex _LprojLen = 0;
+static UniChar *_GlobalResourcesUniChars = NULL;
+static CFIndex _GlobalResourcesLen = 0;
+static UniChar *_InfoExtensionUniChars = NULL;
+static CFIndex _InfoExtensionLen = 0;
+
+static void _CFBundleInitStaticUniCharBuffers(void) {
+    CFStringRef appSupportStr1 = _CFBundleSupportFilesDirectoryName1;
+    CFStringRef appSupportStr2 = _CFBundleSupportFilesDirectoryName2;
+    CFStringRef resourcesStr = _CFBundleResourcesDirectoryName;
+    CFStringRef platformStr = _CFGetPlatformName();
+    CFStringRef alternatePlatformStr = _CFGetAlternatePlatformName();
+    CFStringRef lprojStr = _CFBundleLprojExtension;
+    CFStringRef globalResourcesStr = _CFBundleNonLocalizedResourcesDirectoryName;
+    CFStringRef infoExtensionStr = _CFBundleInfoExtension;
+
+    CFAllocatorRef alloc = __CFGetDefaultAllocator();
+
+    _AppSupportLen1 = CFStringGetLength(appSupportStr1);
+    _AppSupportLen2 = CFStringGetLength(appSupportStr2);
+    _ResourcesLen = CFStringGetLength(resourcesStr);
+    _PlatformLen = CFStringGetLength(platformStr);
+    _AlternatePlatformLen = CFStringGetLength(alternatePlatformStr);
+    _LprojLen = CFStringGetLength(lprojStr);
+    _GlobalResourcesLen = CFStringGetLength(globalResourcesStr);
+    _InfoExtensionLen = CFStringGetLength(infoExtensionStr);
+
+    _AppSupportUniChars1 = (UniChar *)CFAllocatorAllocate(alloc, sizeof(UniChar) * (_AppSupportLen1 + _AppSupportLen2 + _ResourcesLen + _PlatformLen + _AlternatePlatformLen + _LprojLen + _GlobalResourcesLen + _InfoExtensionLen), 0);
+    _AppSupportUniChars2 = _AppSupportUniChars1 + _AppSupportLen1;
+    _ResourcesUniChars = _AppSupportUniChars2 + _AppSupportLen2;
+    _PlatformUniChars = _ResourcesUniChars + _ResourcesLen;
+    _AlternatePlatformUniChars = _PlatformUniChars + _PlatformLen;
+    _LprojUniChars = _AlternatePlatformUniChars + _AlternatePlatformLen;
+    _GlobalResourcesUniChars = _LprojUniChars + _LprojLen;
+    _InfoExtensionUniChars = _GlobalResourcesUniChars + _GlobalResourcesLen;
+
+    if (_AppSupportLen1 > 0) CFStringGetCharacters(appSupportStr1, CFRangeMake(0, _AppSupportLen1), _AppSupportUniChars1);
+    if (_AppSupportLen2 > 0) CFStringGetCharacters(appSupportStr2, CFRangeMake(0, _AppSupportLen2), _AppSupportUniChars2);
+    if (_ResourcesLen > 0) CFStringGetCharacters(resourcesStr, CFRangeMake(0, _ResourcesLen), _ResourcesUniChars);
+    if (_PlatformLen > 0) CFStringGetCharacters(platformStr, CFRangeMake(0, _PlatformLen), _PlatformUniChars);
+    if (_AlternatePlatformLen > 0) CFStringGetCharacters(alternatePlatformStr, CFRangeMake(0, _AlternatePlatformLen), _AlternatePlatformUniChars);
+    if (_LprojLen > 0) CFStringGetCharacters(lprojStr, CFRangeMake(0, _LprojLen), _LprojUniChars);
+    if (_GlobalResourcesLen > 0) CFStringGetCharacters(globalResourcesStr, CFRangeMake(0, _GlobalResourcesLen), _GlobalResourcesUniChars);
+    if (_InfoExtensionLen > 0) CFStringGetCharacters(infoExtensionStr, CFRangeMake(0, _InfoExtensionLen), _InfoExtensionUniChars);
+}
+
+CF_INLINE void _CFEnsureStaticBuffersInited(void) {
+    __CFSpinLock(&CFBundleResourceGlobalDataLock);
+    if (!_AppSupportUniChars1) _CFBundleInitStaticUniCharBuffers();
+    __CFSpinUnlock(&CFBundleResourceGlobalDataLock);
+}
+
+#if READ_DIRECTORIES
+
+static CFMutableDictionaryRef contentsCache = NULL;
+static CFMutableDictionaryRef directoryContentsCache = NULL;
+static CFMutableDictionaryRef unknownContentsCache = NULL;
+
+typedef enum {
+    _CFBundleAllContents = 0,
+    _CFBundleDirectoryContents = 1,
+    _CFBundleUnknownContents = 2
+} _CFBundleDirectoryContentsType;
+
+static CFArrayRef _CFBundleCopyDirectoryContentsAtPath(CFStringRef path, _CFBundleDirectoryContentsType contentsType) {
+    CFArrayRef result = NULL;
+    
+    __CFSpinLock(&CFBundleResourceGlobalDataLock);
+    if (contentsType == _CFBundleUnknownContents) {
+        if (unknownContentsCache) result = (CFMutableArrayRef)CFDictionaryGetValue(unknownContentsCache, path);
+    } else if (contentsType == _CFBundleDirectoryContents) {
+        if (directoryContentsCache) result = (CFMutableArrayRef)CFDictionaryGetValue(directoryContentsCache, path);
+    } else {
+        if (contentsCache) result = (CFMutableArrayRef)CFDictionaryGetValue(contentsCache, path);
+    }
+    if (result) CFRetain(result);
+    __CFSpinUnlock(&CFBundleResourceGlobalDataLock);
+
+    if (!result) {
+        Boolean tryToOpen = false, allDots = true;
+        char cpathBuff[CFMaxPathSize];
+        CFIndex cpathLen = 0, idx, lastSlashIdx = 0;
+        DIR *dirp = NULL;
+        struct dirent *dent;
+        CFMutableArrayRef contents = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks), directoryContents = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks), unknownContents = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+        CFStringRef dirName, name;
+        struct stat statBuf;
+        
+        cpathBuff[0] = '\0';
+        if (CFStringGetFileSystemRepresentation(path, cpathBuff, CFMaxPathSize)) {
+            tryToOpen = true;
+            cpathLen = (CFIndex)strlen(cpathBuff);
+            
+            // First see whether we already know that the directory doesn't exist
+            for (idx = cpathLen; lastSlashIdx == 0 && idx-- > 0;) {
+                if (cpathBuff[idx] == '/') lastSlashIdx = idx;
+                else if (cpathBuff[idx] != '.') allDots = false;
+            }
+            if (lastSlashIdx > 0 && lastSlashIdx + 1 < cpathLen && !allDots) {
+                cpathBuff[lastSlashIdx] = '\0';
+                dirName = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, cpathBuff);
+                if (dirName) {
+                    name = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, cpathBuff + lastSlashIdx + 1);
+                    if (name) {
+                        // ??? we might like to use directoryContentsCache rather than contentsCache here, but we cannot unless we resolve DT_LNKs below
+                        CFArrayRef dirDirContents = NULL;
+                        
+                        __CFSpinLock(&CFBundleResourceGlobalDataLock);
+                        if (contentsCache) dirDirContents = (CFArrayRef)CFDictionaryGetValue(contentsCache, dirName);
+                        if (dirDirContents) {
+                            Boolean foundIt = false;
+                            CFIndex dirDirIdx, dirDirLength = CFArrayGetCount(dirDirContents);
+                            for (dirDirIdx = 0; !foundIt && dirDirIdx < dirDirLength; dirDirIdx++) if (kCFCompareEqualTo == CFStringCompare(name, (CFStringRef)CFArrayGetValueAtIndex(dirDirContents, dirDirIdx), kCFCompareCaseInsensitive)) foundIt = true;
+                            if (!foundIt) tryToOpen = false;
+                        }
+                        __CFSpinUnlock(&CFBundleResourceGlobalDataLock);
+                        
+                        CFRelease(name);
+                    }
+                    CFRelease(dirName);
+                }
+                cpathBuff[lastSlashIdx] = '/';
+            }
+        }
+        if (tryToOpen && stat(cpathBuff, &statBuf) == 0 && (statBuf.st_mode & S_IFMT) == S_IFDIR && (dirp = opendir(cpathBuff))) {
+            while ((dent = readdir(dirp))) {
+                CFIndex nameLen = (CFIndex)strlen(dent->d_name);
+                if (0 == nameLen || 0 == dent->d_fileno || ('.' == dent->d_name[0] && (1 == nameLen || (2 == nameLen && '.' == dent->d_name[1]) || '_' == dent->d_name[1]))) continue;
+                name = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, dent->d_name);
+                if (name) {
+                    // ??? should we follow links for DT_LNK?  unless we do, results are approximate, but for performance reasons we do not
+                    // ??? likewise for DT_UNKNOWN
+                    // ??? the utility of distinguishing directories from other contents is somewhat doubtful anyway
+                    CFArrayAppendValue(contents, name);
+                    if (dent->d_type == DT_DIR) {
+                        CFArrayAppendValue(directoryContents, name);
+                    } else if (dent->d_type == DT_UNKNOWN) {
+                        CFArrayAppendValue(unknownContents, name);
+                    }
+                    CFRelease(name);
+                }
+            }
+            (void)closedir(dirp);
+        }
+        
+        __CFSpinLock(&CFBundleResourceGlobalDataLock);
+        if (!contentsCache) contentsCache = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, READ_DIRECTORIES_CACHE_CAPACITY, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        if (READ_DIRECTORIES_CACHE_CAPACITY <= CFDictionaryGetCount(contentsCache)) CFDictionaryRemoveAllValues(contentsCache);
+        CFDictionaryAddValue(contentsCache, path, contents);
+
+        if (!directoryContentsCache) directoryContentsCache = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, READ_DIRECTORIES_CACHE_CAPACITY, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        if (READ_DIRECTORIES_CACHE_CAPACITY <= CFDictionaryGetCount(directoryContentsCache)) CFDictionaryRemoveAllValues(directoryContentsCache);
+        CFDictionaryAddValue(directoryContentsCache, path, directoryContents);
+
+        if (!unknownContentsCache) unknownContentsCache = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, READ_DIRECTORIES_CACHE_CAPACITY, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        if (READ_DIRECTORIES_CACHE_CAPACITY <= CFDictionaryGetCount(unknownContentsCache)) CFDictionaryRemoveAllValues(unknownContentsCache);
+        CFDictionaryAddValue(unknownContentsCache, path, unknownContents);
+
+        if (contentsType == _CFBundleUnknownContents) {
+            result = (CFArrayRef)CFRetain(unknownContents);
+        } else if (contentsType == _CFBundleDirectoryContents) {
+            result = (CFArrayRef)CFRetain(directoryContents);
+        } else {
+            result = (CFArrayRef)CFRetain(contents);
+        }
+        
+        CFRelease(contents);
+        CFRelease(directoryContents);
+        CFRelease(unknownContents);
+        __CFSpinUnlock(&CFBundleResourceGlobalDataLock);
+    }
+    return result;
+}
+
+static void _CFBundleFlushContentsCaches(void) {
+    __CFSpinLock(&CFBundleResourceGlobalDataLock);
+    if (contentsCache) CFDictionaryRemoveAllValues(contentsCache);
+    if (directoryContentsCache) CFDictionaryRemoveAllValues(directoryContentsCache);
+    if (unknownContentsCache) CFDictionaryRemoveAllValues(unknownContentsCache);
+    __CFSpinUnlock(&CFBundleResourceGlobalDataLock);
+}
+
+static void _CFBundleFlushContentsCacheForPath(CFMutableDictionaryRef cache, CFStringRef path) {
+    CFStringRef keys[READ_DIRECTORIES_CACHE_CAPACITY];
+    unsigned i, count = CFDictionaryGetCount(cache);
+    if (count <= READ_DIRECTORIES_CACHE_CAPACITY) {
+        CFDictionaryGetKeysAndValues(cache, (const void **)keys, NULL);
+        for (i = 0; i < count; i++) {
+            if (CFStringFindWithOptions(keys[i], path, CFRangeMake(0, CFStringGetLength(keys[i])), kCFCompareAnchored|kCFCompareCaseInsensitive, NULL)) CFDictionaryRemoveValue(cache, keys[i]);
+        }
+    }
+}
+
+static void _CFBundleFlushContentsCachesForPath(CFStringRef path) {
+    __CFSpinLock(&CFBundleResourceGlobalDataLock);
+    if (contentsCache) _CFBundleFlushContentsCacheForPath(contentsCache, path);
+    if (directoryContentsCache) _CFBundleFlushContentsCacheForPath(directoryContentsCache, path);
+    if (unknownContentsCache) _CFBundleFlushContentsCacheForPath(unknownContentsCache, path);
+    __CFSpinUnlock(&CFBundleResourceGlobalDataLock);
+}
+
+#endif /* READ_DIRECTORIES */
+
+CF_EXPORT void _CFBundleFlushCachesForURL(CFURLRef url) {
+#if READ_DIRECTORIES
+    CFURLRef absoluteURL = CFURLCopyAbsoluteURL(url);
+    CFStringRef path = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+    _CFBundleFlushContentsCachesForPath(path);
+    CFRelease(path);
+    CFRelease(absoluteURL);
+#endif /* READ_DIRECTORIES */
+}
+
+CF_EXPORT void _CFBundleFlushCaches(void) {
+#if READ_DIRECTORIES
+    _CFBundleFlushContentsCaches();
+#endif /* READ_DIRECTORIES */
+}
+
+__private_extern__ Boolean _CFIsResourceAtURL(CFURLRef url, Boolean *isDir) {
+    Boolean exists;
+    SInt32 mode;
+    if (_CFGetFileProperties(kCFAllocatorSystemDefault, url, &exists, &mode, NULL, NULL, NULL, NULL) == 0) {
+        if (isDir) *isDir = ((exists && ((mode & S_IFMT) == S_IFDIR)) ? true : false);
+        return (exists && (mode & 0444));
+    } else {
+        return false;
+    }
+}
+
+__private_extern__ Boolean _CFIsResourceAtPath(CFStringRef path, Boolean *isDir) {
+    Boolean result = false;
+    CFURLRef url = CFURLCreateWithFileSystemPath(CFGetAllocator(path), path, PLATFORM_PATH_STYLE, false);
+    if (url) {
+        result = _CFIsResourceAtURL(url, isDir);
+        CFRelease(url);
+    }
+    return result;
+}
+
+#if READ_DIRECTORIES
+static CFArrayRef _CFCopyTypesForSearchBundleDirectory(CFAllocatorRef alloc, UniChar *pathUniChars, CFIndex pathLen, UniChar *nameUniChars, CFIndex nameLen, CFArrayRef resTypes, CFMutableStringRef cheapStr, CFMutableStringRef tmpString, uint8_t version) {
+    CFMutableArrayRef result = CFArrayCreateMutable(alloc, 0, &kCFTypeArrayCallBacks);
+    CFArrayRef contents;
+    CFRange contentsRange, resultRange = CFRangeMake(0, 0);
+    CFIndex dirPathLen = pathLen, numResTypes = CFArrayGetCount(resTypes), i, j;
+    
+    CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, dirPathLen, dirPathLen);
+    CFStringReplaceAll(cheapStr, tmpString);
+    //fprintf(stderr, "looking in ");CFShow(cheapStr);
+    contents = _CFBundleCopyDirectoryContentsAtPath(cheapStr, _CFBundleAllContents);
+    contentsRange = CFRangeMake(0, CFArrayGetCount(contents));
+    
+    CFStringSetExternalCharactersNoCopy(tmpString, nameUniChars, nameLen, nameLen);
+    CFStringReplaceAll(cheapStr, tmpString);
+    for (i = 0; i < contentsRange.length; i++) {
+        CFStringRef content = (CFStringRef)CFArrayGetValueAtIndex(contents, i);
+        if (CFStringHasPrefix(content, cheapStr)) {
+            //fprintf(stderr, "found ");CFShow(content);
+            for (j = 0; j < numResTypes; j++) {
+                CFStringRef resType = (CFStringRef)CFArrayGetValueAtIndex(resTypes, j);
+                if (!CFArrayContainsValue(result, resultRange, resType) && CFStringHasSuffix(content, resType)) {
+                    CFArrayAppendValue(result, resType);
+                    resultRange.length = CFArrayGetCount(result);
+                }
+            }
+        }
+    }
+    //fprintf(stderr, "result ");CFShow(result);
+    CFRelease(contents);
+    return result;
+}
+#endif /* READ_DIRECTORIES */
+
+static void _CFSearchBundleDirectory(CFAllocatorRef alloc, CFMutableArrayRef result, UniChar *pathUniChars, CFIndex pathLen, UniChar *nameUniChars, CFIndex nameLen, UniChar *typeUniChars, CFIndex typeLen, CFMutableStringRef cheapStr, CFMutableStringRef tmpString, uint8_t version) {
+    // pathUniChars is the full path to the directory we are searching.
+    // nameUniChars is what we are looking for.
+    // typeUniChars is the type we are looking for.
+    // platformUniChars is the platform name.
+    // cheapStr is available for our use for whatever we want.
+    // URLs for found resources get added to result.
+    CFIndex savedPathLen;
+    Boolean appendSucceeded = true, platformGenericFound = false, platformSpecificFound = false, platformGenericIsDir = false, platformSpecificIsDir = false, platformGenericIsUnknown = false, platformSpecificIsUnknown = false;
+    CFStringRef platformGenericStr = NULL;
+
+#if READ_DIRECTORIES
+    CFIndex dirPathLen = pathLen;
+    CFArrayRef contents, directoryContents, unknownContents;
+    CFRange contentsRange, directoryContentsRange, unknownContentsRange;
+    
+    CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, dirPathLen, dirPathLen);
+    CFStringReplaceAll(cheapStr, tmpString);
+    //fprintf(stderr, "looking in ");CFShow(cheapStr);
+    contents = _CFBundleCopyDirectoryContentsAtPath(cheapStr, _CFBundleAllContents);
+    contentsRange = CFRangeMake(0, CFArrayGetCount(contents));
+    directoryContents = _CFBundleCopyDirectoryContentsAtPath(cheapStr, _CFBundleDirectoryContents);
+    directoryContentsRange = CFRangeMake(0, CFArrayGetCount(directoryContents));
+    unknownContents = _CFBundleCopyDirectoryContentsAtPath(cheapStr, _CFBundleUnknownContents);
+    unknownContentsRange = CFRangeMake(0, CFArrayGetCount(unknownContents));
+#endif /* READ_DIRECTORIES */
+
+    if (nameLen > 0) appendSucceeded = _CFAppendPathComponent(pathUniChars, &pathLen, CFMaxPathSize, nameUniChars, nameLen);
+    savedPathLen = pathLen;
+    if (appendSucceeded && typeLen > 0) appendSucceeded = _CFAppendPathExtension(pathUniChars, &pathLen, CFMaxPathSize, typeUniChars, typeLen);
+    if (appendSucceeded) {
+#if READ_DIRECTORIES
+        CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars + dirPathLen + 1, pathLen - dirPathLen - 1, pathLen - dirPathLen - 1);
+        CFStringReplaceAll(cheapStr, tmpString);
+        platformGenericFound = CFArrayContainsValue(contents, contentsRange, cheapStr);
+        platformGenericIsDir = CFArrayContainsValue(directoryContents, directoryContentsRange, cheapStr);
+        platformGenericIsUnknown = CFArrayContainsValue(unknownContents, unknownContentsRange, cheapStr);
+        //fprintf(stderr, "looking for ");CFShow(cheapStr);if (platformGenericFound) fprintf(stderr, "found it\n"); if (platformGenericIsDir) fprintf(stderr, "a directory\n");
+        CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+        CFStringReplaceAll(cheapStr, tmpString);
+        if (platformGenericFound && platformGenericIsUnknown) {
+            (void)_CFIsResourceAtPath(cheapStr, &platformGenericIsDir);
+            //if (platformGenericIsDir) fprintf(stderr, "a directory after all\n"); else fprintf(stderr, "not a directory after all\n"); 
+        }
+#else /* READ_DIRECTORIES */
+        CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+        CFStringReplaceAll(cheapStr, tmpString);
+        platformGenericFound = _CFIsResourceAtPath(cheapStr, &platformGenericIsDir);
+#endif /* READ_DIRECTORIES */
+    }
+    
+    // Check for platform specific.
+    if (platformGenericFound) {
+        platformGenericStr = (CFStringRef)CFStringCreateCopy(alloc, cheapStr);
+        if (!platformSpecificFound && (_PlatformLen > 0)) {
+            pathLen = savedPathLen;
+            pathUniChars[pathLen++] = (UniChar)'-';
+            memmove(pathUniChars + pathLen, _PlatformUniChars, _PlatformLen * sizeof(UniChar));
+            pathLen += _PlatformLen;
+            if (appendSucceeded && typeLen > 0) appendSucceeded = _CFAppendPathExtension(pathUniChars, &pathLen, CFMaxPathSize, typeUniChars, typeLen);
+            if (appendSucceeded) {
+#if READ_DIRECTORIES
+                CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars + dirPathLen + 1, pathLen - dirPathLen - 1, pathLen - dirPathLen - 1);
+                CFStringReplaceAll(cheapStr, tmpString);
+                platformSpecificFound = CFArrayContainsValue(contents, contentsRange, cheapStr);
+                platformSpecificIsDir = CFArrayContainsValue(directoryContents, directoryContentsRange, cheapStr);
+                platformSpecificIsUnknown = CFArrayContainsValue(unknownContents, unknownContentsRange, cheapStr);
+                //fprintf(stderr, "looking for ");CFShow(cheapStr);if (platformSpecificFound) fprintf(stderr, "found it\n"); if (platformSpecificIsDir) fprintf(stderr, "a directory\n");
+                CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+                CFStringReplaceAll(cheapStr, tmpString);
+                if (platformSpecificFound && platformSpecificIsUnknown) {
+                    (void)_CFIsResourceAtPath(cheapStr, &platformSpecificIsDir);
+                    //if (platformSpecificIsDir) fprintf(stderr, "a directory after all\n"); else fprintf(stderr, "not a directory after all\n"); 
+                }
+#else /* READ_DIRECTORIES */
+                CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+                CFStringReplaceAll(cheapStr, tmpString);
+                platformSpecificFound = _CFIsResourceAtPath(cheapStr, &platformSpecificIsDir);
+#endif /* READ_DIRECTORIES */
+            }
+        }
+    }
+    if (platformSpecificFound) {
+        CFURLRef url = CFURLCreateWithFileSystemPath(alloc, cheapStr, PLATFORM_PATH_STYLE, platformSpecificIsDir);
+        CFArrayAppendValue(result, url);
+        CFRelease(url);
+    } else if (platformGenericFound) {
+        CFURLRef url = CFURLCreateWithFileSystemPath(alloc, platformGenericStr ? platformGenericStr : cheapStr, PLATFORM_PATH_STYLE, platformGenericIsDir);
+        CFArrayAppendValue(result, url);
+        CFRelease(url);
+    }
+    if (platformGenericStr) CFRelease(platformGenericStr);
+#if READ_DIRECTORIES
+    CFRelease(contents);
+    CFRelease(directoryContents);
+    CFRelease(unknownContents);
+#endif /* READ_DIRECTORIES */
+}
+
+static void _CFFindBundleResourcesInRawDir(CFAllocatorRef alloc, UniChar *workingUniChars, CFIndex workingLen, UniChar *nameUniChars, CFIndex nameLen, CFArrayRef resTypes, CFIndex limit, uint8_t version, CFMutableStringRef cheapStr, CFMutableStringRef tmpString, CFMutableArrayRef result) {
+    if (nameLen > 0) {
+        // If we have a resName, just call the search API.  We may have to loop over the resTypes.
+        if (!resTypes) {
+            _CFSearchBundleDirectory(alloc, result, workingUniChars, workingLen, nameUniChars, nameLen, NULL, 0, cheapStr, tmpString, version);
+        } else {
+            CFArrayRef subResTypes = resTypes;
+            Boolean releaseSubResTypes = false;
+            CFIndex i, c = CFArrayGetCount(resTypes);
+#if READ_DIRECTORIES
+            if (c > 2) {
+                // this is an optimization we employ when searching for large numbers of types, if the directory contents are available
+                // we scan the directory contents and restrict the list of resTypes to the types that might actually occur with the specified name
+                subResTypes = _CFCopyTypesForSearchBundleDirectory(alloc, workingUniChars, workingLen, nameUniChars, nameLen, resTypes, cheapStr, tmpString, version);
+                c = CFArrayGetCount(subResTypes);
+                releaseSubResTypes = true;
+            }
+#endif /* READ_DIRECTORIES */
+            for (i = 0; i < c; i++) {
+                CFStringRef curType = (CFStringRef)CFArrayGetValueAtIndex(subResTypes, i);
+                CFIndex typeLen = CFStringGetLength(curType);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+                STACK_BUFFER_DECL(UniChar, typeChars, typeLen);
+#else
+                UniChar *typeChars = (UniChar*)CFAllocatorAllocate(alloc, sizeof(UniChar) * typeLen, 0);
+                if (typeChars) {
+#endif
+                CFStringGetCharacters(curType, CFRangeMake(0, typeLen), typeChars);
+                _CFSearchBundleDirectory(alloc, result, workingUniChars, workingLen, nameUniChars, nameLen, typeChars, typeLen, cheapStr, tmpString, version);
+                if (limit <= CFArrayGetCount(result)) break;
+#if !DEPLOYMENT_TARGET_MACOSX && !DEPLOYMENT_TARGET_WINDOWS && !DEPLOYMENT_TARGET_LINUX
+                    CFAllocatorDeallocate(alloc, typeChars);
+                }
+#endif
+            }
+            if (releaseSubResTypes) CFRelease(subResTypes);
+        }
+    } else {
+        // If we have no resName, do it by hand. We may have to loop over the resTypes.
+        char cpathBuff[CFMaxPathSize];
+        CFIndex cpathLen;
+        CFMutableArrayRef children;
+
+        CFStringSetExternalCharactersNoCopy(tmpString, workingUniChars, workingLen, workingLen);
+        if (!CFStringGetFileSystemRepresentation(tmpString, cpathBuff, CFMaxPathSize)) return;
+        cpathLen = (CFIndex)strlen(cpathBuff);
+
+        if (!resTypes) {
+            // ??? should this use _CFBundleCopyDirectoryContentsAtPath?
+            children = _CFContentsOfDirectory(alloc, cpathBuff, NULL, NULL, NULL);
+            if (children) {
+                CFIndex childIndex, childCount = CFArrayGetCount(children);
+                for (childIndex = 0; childIndex < childCount; childIndex++) CFArrayAppendValue(result, CFArrayGetValueAtIndex(children, childIndex));
+                CFRelease(children);
+            }
+        } else {
+            CFIndex i, c = CFArrayGetCount(resTypes);
+            for (i = 0; i < c; i++) {
+                CFStringRef curType = (CFStringRef)CFArrayGetValueAtIndex(resTypes, i);
+
+                // ??? should this use _CFBundleCopyDirectoryContentsAtPath?
+                children = _CFContentsOfDirectory(alloc, cpathBuff, NULL, NULL, curType);
+                if (children) {
+                    CFIndex childIndex, childCount = CFArrayGetCount(children);
+                    for (childIndex = 0; childIndex < childCount; childIndex++) CFArrayAppendValue(result, CFArrayGetValueAtIndex(children, childIndex));
+                    CFRelease(children);
+                }
+                if (limit <= CFArrayGetCount(result)) break;
+            }
+        }
+    }
+}
+
+static void _CFFindBundleResourcesInResourcesDir(CFAllocatorRef alloc, UniChar *workingUniChars, CFIndex workingLen, UniChar *subDirUniChars, CFIndex subDirLen, CFArrayRef searchLanguages, UniChar *nameUniChars, CFIndex nameLen, CFArrayRef resTypes, CFIndex limit, uint8_t version, CFMutableStringRef cheapStr, CFMutableStringRef tmpString, CFMutableArrayRef result) {
+    CFIndex savedWorkingLen = workingLen;
+
+    // Look directly in the directory specified in workingUniChars. as if it is a Resources directory.
+    if (1 == version) {
+        // Add the non-localized resource directory.
+        Boolean appendSucceeded = _CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, _GlobalResourcesUniChars, _GlobalResourcesLen);
+        if (appendSucceeded && subDirLen > 0) appendSucceeded = _CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, subDirUniChars, subDirLen);
+        if (appendSucceeded) _CFFindBundleResourcesInRawDir(alloc, workingUniChars, workingLen, nameUniChars, nameLen, resTypes, limit, version, cheapStr, tmpString, result);
+        // Strip the non-localized resource directory.
+        workingLen = savedWorkingLen;
+    }
+    if (CFArrayGetCount(result) < limit) {
+        Boolean appendSucceeded = true;
+        if (subDirLen > 0) appendSucceeded = _CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, subDirUniChars, subDirLen);
+        if (appendSucceeded) _CFFindBundleResourcesInRawDir(alloc, workingUniChars, workingLen, nameUniChars, nameLen, resTypes, limit, version, cheapStr, tmpString, result);
+    }
+    
+    // Now search the local resources.
+    workingLen = savedWorkingLen;
+    if (CFArrayGetCount(result) < limit) {
+        CFIndex langIndex;
+        CFIndex langCount = (searchLanguages ? CFArrayGetCount(searchLanguages) : 0);
+        CFStringRef curLangStr;
+        CFIndex curLangLen;
+        // MF:??? OK to hard-wire this length?
+        UniChar curLangUniChars[255];
+        CFIndex numResults = CFArrayGetCount(result);
+
+        for (langIndex = 0; langIndex < langCount; langIndex++) {
+            curLangStr = (CFStringRef)CFArrayGetValueAtIndex(searchLanguages, langIndex);
+            curLangLen = CFStringGetLength(curLangStr);
+            if (curLangLen > 255) curLangLen = 255;
+            CFStringGetCharacters(curLangStr, CFRangeMake(0, curLangLen), curLangUniChars);
+            savedWorkingLen = workingLen;
+            if (!_CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, curLangUniChars, curLangLen)) {
+                workingLen = savedWorkingLen;
+                continue;
+            }
+            if (!_CFAppendPathExtension(workingUniChars, &workingLen, CFMaxPathSize, _LprojUniChars, _LprojLen)) {
+                workingLen = savedWorkingLen;
+                continue;
+            }
+            if (subDirLen > 0) {
+                if (!_CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, subDirUniChars, subDirLen)) {
+                    workingLen = savedWorkingLen;
+                    continue;
+                }
+            }
+            _CFFindBundleResourcesInRawDir(alloc, workingUniChars, workingLen, nameUniChars, nameLen, resTypes, limit, version, cheapStr, tmpString, result);
+            
+            // Back off this lproj component
+            workingLen = savedWorkingLen;
+            if (CFArrayGetCount(result) != numResults) {
+                // We found resources in a language we already searched.  Don't look any farther.
+                // We also don't need to check the limit, since if the count changed at all, we are bailing.
+                break;
+            }
+        }
+    }
+}
+
+extern void _CFStrSetDesiredCapacity(CFMutableStringRef str, CFIndex len);
+
+CFArrayRef _CFFindBundleResources(CFBundleRef bundle, CFURLRef bundleURL, CFStringRef subDirName, CFArrayRef searchLanguages, CFStringRef resName, CFArrayRef resTypes, CFIndex limit, uint8_t version) {
+    CFAllocatorRef alloc = (bundle ? CFGetAllocator(bundle) : (CFAllocatorRef)CFRetain(__CFGetDefaultAllocator()));
+    CFMutableArrayRef result;
+    UniChar *workingUniChars, *nameUniChars, *subDirUniChars;
+    CFIndex nameLen = (resName ? CFStringGetLength(resName) : 0);
+    CFIndex subDirLen = (subDirName ? CFStringGetLength(subDirName) : 0);
+    CFIndex workingLen, savedWorkingLen;
+    CFURLRef absoluteURL;
+    CFStringRef bundlePath;
+    CFMutableStringRef cheapStr, tmpString;
+
+    result = CFArrayCreateMutable(alloc, 0, &kCFTypeArrayCallBacks);
+    // Init the one-time-only unichar buffers.
+    _CFEnsureStaticBuffersInited();
+
+    // Build UniChar buffers for some of the string pieces we need.
+    // One malloc will do.
+    nameUniChars = (UniChar *)CFAllocatorAllocate(alloc, sizeof(UniChar) * (nameLen + subDirLen + CFMaxPathSize), 0);
+    subDirUniChars = nameUniChars + nameLen;
+    workingUniChars = subDirUniChars + subDirLen;
+
+    if (nameLen > 0) CFStringGetCharacters(resName, CFRangeMake(0, nameLen), nameUniChars);
+    if (subDirLen > 0) CFStringGetCharacters(subDirName, CFRangeMake(0, subDirLen), subDirUniChars);
+    // Build a UniChar buffer with the absolute path to the bundle's resources directory.
+    // If no URL was passed, we get it from the bundle.
+    bundleURL = (bundleURL ? (CFURLRef)CFRetain(bundleURL) : CFBundleCopyBundleURL(bundle));
+    absoluteURL = CFURLCopyAbsoluteURL(bundleURL);
+    bundlePath = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+    CFRelease(absoluteURL);
+    if ((workingLen = CFStringGetLength(bundlePath)) > 0) CFStringGetCharacters(bundlePath, CFRangeMake(0, workingLen), workingUniChars);
+    CFRelease(bundlePath);
+    CFRelease(bundleURL);
+    savedWorkingLen = workingLen;
+    if (1 == version) {
+        _CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, _AppSupportUniChars1, _AppSupportLen1);
+    } else if (2 == version) {
+        _CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, _AppSupportUniChars2, _AppSupportLen2);
+    }
+    if (0 == version || 1 == version || 2 == version) {
+        _CFAppendPathComponent(workingUniChars, &workingLen, CFMaxPathSize, _ResourcesUniChars, _ResourcesLen);
+    }
+
+    // both of these used for temp string operations, for slightly
+    // different purposes, where each type is appropriate
+    cheapStr = CFStringCreateMutable(alloc, 0);
+    _CFStrSetDesiredCapacity(cheapStr, CFMaxPathSize);
+    tmpString = CFStringCreateMutableWithExternalCharactersNoCopy(kCFAllocatorSystemDefault, NULL, 0, 0, kCFAllocatorNull);
+
+    _CFFindBundleResourcesInResourcesDir(alloc, workingUniChars, workingLen, subDirUniChars, subDirLen, searchLanguages, nameUniChars, nameLen, resTypes, limit, version, cheapStr, tmpString, result);
+    
+    // drd: This unfortunate hack is still necessary because of installer packages
+    if (0 == version && CFArrayGetCount(result) == 0) {
+        // Try looking directly in the bundle path
+        workingLen = savedWorkingLen;
+        _CFFindBundleResourcesInResourcesDir(alloc, workingUniChars, workingLen, subDirUniChars, subDirLen, searchLanguages, nameUniChars, nameLen, resTypes, limit, version, cheapStr, tmpString, result);
+    }
+
+    CFRelease(cheapStr);
+    CFRelease(tmpString);
+    CFAllocatorDeallocate(alloc, nameUniChars);
+    if (!bundle) CFRelease(alloc);
+
+    return result;
+}
+
+CF_EXPORT CFURLRef CFBundleCopyResourceURL(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName) {
+    CFURLRef result = NULL;
+    CFArrayRef languages = _CFBundleGetLanguageSearchList(bundle), types = NULL, array;
+    if (resourceType) types = CFArrayCreate(CFGetAllocator(bundle), (const void **)&resourceType, 1, &kCFTypeArrayCallBacks);
+    
+    array = _CFFindBundleResources(bundle, NULL, subDirName, languages, resourceName, types, 1, _CFBundleLayoutVersion(bundle));
+    
+    if (types) CFRelease(types);
+    
+    if (array) {
+        if (CFArrayGetCount(array) > 0) result = (CFURLRef)CFRetain(CFArrayGetValueAtIndex(array, 0));
+        CFRelease(array);
+    }
+    return result;
+}
+
+CF_EXPORT CFArrayRef CFBundleCopyResourceURLsOfType(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName) {
+    CFArrayRef languages = _CFBundleGetLanguageSearchList(bundle), types = NULL, array;
+    if (resourceType) types = CFArrayCreate(CFGetAllocator(bundle), (const void **)&resourceType, 1, &kCFTypeArrayCallBacks);
+
+    // MF:!!! Better "limit" than 1,000,000?
+    array = _CFFindBundleResources(bundle, NULL, subDirName, languages, NULL, types, 1000000, _CFBundleLayoutVersion(bundle));
+    
+    if (types) CFRelease(types);
+    
+    return array;
+}
+
+CF_EXPORT CFURLRef _CFBundleCopyResourceURLForLanguage(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName, CFStringRef language) {return CFBundleCopyResourceURLForLocalization(bundle, resourceName, resourceType, subDirName, language);}
+
+CF_EXPORT CFURLRef CFBundleCopyResourceURLForLocalization(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName) {
+    CFURLRef result = NULL;
+    CFArrayRef languages = NULL, types = NULL, array;
+
+    if (localizationName) languages = CFArrayCreate(CFGetAllocator(bundle), (const void **)&localizationName, 1, &kCFTypeArrayCallBacks);
+    if (resourceType) types = CFArrayCreate(CFGetAllocator(bundle), (const void **)&resourceType, 1, &kCFTypeArrayCallBacks);
+    
+    array = _CFFindBundleResources(bundle, NULL, subDirName, languages, resourceName, types, 1, _CFBundleLayoutVersion(bundle));
+    if (array) {
+        if (CFArrayGetCount(array) > 0) result = (CFURLRef)CFRetain(CFArrayGetValueAtIndex(array, 0));
+        CFRelease(array);
+    }
+
+    if (types) CFRelease(types);
+    if (languages) CFRelease(languages);
+    
+    return result;
+}
+
+CF_EXPORT CFArrayRef _CFBundleCopyResourceURLsOfTypeForLanguage(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName, CFStringRef language) {return CFBundleCopyResourceURLsOfTypeForLocalization(bundle, resourceType, subDirName, language);}
+
+CF_EXPORT CFArrayRef CFBundleCopyResourceURLsOfTypeForLocalization(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName) {
+    CFArrayRef languages = NULL, types = NULL, array;
+
+    if (localizationName) languages = CFArrayCreate(CFGetAllocator(bundle), (const void **)&localizationName, 1, &kCFTypeArrayCallBacks);
+    if (resourceType) types = CFArrayCreate(CFGetAllocator(bundle), (const void **)&resourceType, 1, &kCFTypeArrayCallBacks);
+    
+    // MF:!!! Better "limit" than 1,000,000?
+    array = _CFFindBundleResources(bundle, NULL, subDirName, languages, NULL, types, 1000000, _CFBundleLayoutVersion(bundle));
+
+    if (types) CFRelease(types);
+    if (languages) CFRelease(languages);
+
+    return array;
+}
+
+CF_EXPORT CFStringRef CFBundleCopyLocalizedString(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName) {
+    CFStringRef result = NULL;
+    CFDictionaryRef stringTable = NULL;
+
+    if (!key) return (value ? (CFStringRef)CFRetain(value) : (CFStringRef)CFRetain(CFSTR("")));
+
+    if (!tableName || CFEqual(tableName, CFSTR(""))) tableName = _CFBundleDefaultStringTableName;
+    if (__CFBundleGetResourceData(bundle)->_stringTableCache) stringTable = (CFDictionaryRef)CFDictionaryGetValue(__CFBundleGetResourceData(bundle)->_stringTableCache, tableName);
+    if (!stringTable) {
+        // Go load the table.
+        CFURLRef tableURL = CFBundleCopyResourceURL(bundle, tableName, _CFBundleStringTableType, NULL);
+        if (tableURL) {
+            CFStringRef nameForSharing = NULL;
+            if (!stringTable) {
+                CFDataRef tableData = NULL;
+                SInt32 errCode;
+                CFStringRef errStr;
+                if (CFURLCreateDataAndPropertiesFromResource(CFGetAllocator(bundle), tableURL, &tableData, NULL, NULL, &errCode)) {
+                    stringTable = (CFDictionaryRef)CFPropertyListCreateFromXMLData(CFGetAllocator(bundle), tableData, kCFPropertyListImmutable, &errStr);
+                    if (errStr) {
+                        CFRelease(errStr);
+                        errStr = NULL;
+                    }
+                    if (stringTable && CFDictionaryGetTypeID() != CFGetTypeID(stringTable)) {
+                        CFRelease(stringTable);
+                        stringTable = NULL;
+                    }
+                    CFRelease(tableData);
+                }
+            }
+            if (nameForSharing) CFRelease(nameForSharing);
+            CFRelease(tableURL);
+        }
+        if (!stringTable) stringTable = CFDictionaryCreate(CFGetAllocator(bundle), NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        if (!__CFBundleGetResourceData(bundle)->_stringTableCache) __CFBundleGetResourceData(bundle)->_stringTableCache = CFDictionaryCreateMutable(CFGetAllocator(bundle), 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        CFDictionarySetValue(__CFBundleGetResourceData(bundle)->_stringTableCache, tableName, stringTable);
+        CFRelease(stringTable);
+    }
+
+    result = (CFStringRef)CFDictionaryGetValue(stringTable, key);
+    if (!result) {
+        static int capitalize = -1;
+        if (!value) {
+            result = (CFStringRef)CFRetain(key);
+        } else if (CFEqual(value, CFSTR(""))) {
+            result = (CFStringRef)CFRetain(key);
+        } else {
+            result = (CFStringRef)CFRetain(value);
+        }
+        if (capitalize != 0) {
+            if (capitalize != 0) {
+                CFMutableStringRef capitalizedResult = CFStringCreateMutableCopy(CFGetAllocator(bundle), 0, result);
+                CFLog(__kCFLogBundle, CFSTR("Localizable string \"%@\" not found in strings table \"%@\" of bundle %@."), key, tableName, bundle);
+                CFStringUppercase(capitalizedResult, NULL);
+                CFRelease(result);
+                result = capitalizedResult;
+            }
+        }
+    } else {
+        CFRetain(result);
+    }
+    if (CFStringHasSuffix(tableName, CFSTR(".nocache")) && __CFBundleGetResourceData(bundle)->_stringTableCache && _CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard)) CFDictionaryRemoveValue(__CFBundleGetResourceData(bundle)->_stringTableCache, tableName);
+    
+    return result;
+}
+
+CF_EXPORT CFURLRef CFBundleCopyResourceURLInDirectory(CFURLRef bundleURL, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName) {
+    CFURLRef result = NULL;
+    unsigned char buff[CFMaxPathSize];
+    CFURLRef newURL = NULL;
+
+    if (!CFURLGetFileSystemRepresentation(bundleURL, true, buff, CFMaxPathSize)) return NULL;
+
+    newURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, buff, (CFIndex)strlen((char *)buff), true);
+    if (!newURL) newURL = (CFURLRef)CFRetain(bundleURL);
+    if (_CFBundleCouldBeBundle(newURL)) {
+        uint8_t version = 0;
+        CFArrayRef languages = _CFBundleCopyLanguageSearchListInDirectory(kCFAllocatorSystemDefault, newURL, &version), types = NULL, array;
+        if (resourceType) types = CFArrayCreate(kCFAllocatorSystemDefault, (const void **)&resourceType, 1, &kCFTypeArrayCallBacks);
+        
+        array = _CFFindBundleResources(NULL, newURL, subDirName, languages, resourceName, types, 1, version);
+
+        if (types) CFRelease(types);
+        if (languages) CFRelease(languages);
+
+        if (array) {
+            if (CFArrayGetCount(array) > 0) result = (CFURLRef)CFRetain(CFArrayGetValueAtIndex(array, 0));
+            CFRelease(array);
+        }
+    }
+    if (newURL) CFRelease(newURL);
+    return result;
+}
+
+CF_EXPORT CFArrayRef CFBundleCopyResourceURLsOfTypeInDirectory(CFURLRef bundleURL, CFStringRef resourceType, CFStringRef subDirName) {
+    CFArrayRef array = NULL;
+    unsigned char buff[CFMaxPathSize];
+    CFURLRef newURL = NULL;
+
+    if (!CFURLGetFileSystemRepresentation(bundleURL, true, buff, CFMaxPathSize)) return NULL;
+
+    newURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, buff, (CFIndex)strlen((char *)buff), true);
+    if (!newURL) newURL = (CFURLRef)CFRetain(bundleURL);
+    if (_CFBundleCouldBeBundle(newURL)) {
+        uint8_t version = 0;
+        CFArrayRef languages = _CFBundleCopyLanguageSearchListInDirectory(kCFAllocatorSystemDefault, newURL, &version), types = NULL;
+        if (resourceType) types = CFArrayCreate(kCFAllocatorSystemDefault, (const void **)&resourceType, 1, &kCFTypeArrayCallBacks);
+
+        // MF:!!! Better "limit" than 1,000,000?
+        array = _CFFindBundleResources(NULL, newURL, subDirName, languages, NULL, types, 1000000, version);
+
+        if (types) CFRelease(types);
+        if (languages) CFRelease(languages);
+    }
+    if (newURL) CFRelease(newURL);
+    return array;
+}
+
+// string, with groups of 6 characters being 1 element in the array of locale abbreviations
+const char * __CFBundleLocaleAbbreviationsArray =
+    "en_US\0"      "fr_FR\0"      "en_GB\0"      "de_DE\0"      "it_IT\0"      "nl_NL\0"      "nl_BE\0"      "sv_SE\0"
+    "es_ES\0"      "da_DK\0"      "pt_PT\0"      "fr_CA\0"      "nb_NO\0"      "he_IL\0"      "ja_JP\0"      "en_AU\0"
+    "ar\0\0\0\0"   "fi_FI\0"      "fr_CH\0"      "de_CH\0"      "el_GR\0"      "is_IS\0"      "mt_MT\0"      "el_CY\0"
+    "tr_TR\0"      "hr_HR\0"      "nl_NL\0"      "nl_BE\0"      "en_CA\0"      "en_CA\0"      "pt_PT\0"      "nb_NO\0"
+    "da_DK\0"      "hi_IN\0"      "ur_PK\0"      "tr_TR\0"      "it_CH\0"      "en\0\0\0\0"   "\0\0\0\0\0\0" "ro_RO\0"
+    "grc\0\0\0"    "lt_LT\0"      "pl_PL\0"      "hu_HU\0"      "et_EE\0"      "lv_LV\0"      "se\0\0\0\0"   "fo_FO\0"
+    "fa_IR\0"      "ru_RU\0"      "ga_IE\0"      "ko_KR\0"      "zh_CN\0"      "zh_TW\0"      "th_TH\0"      "\0\0\0\0\0\0"
+    "cs_CZ\0"      "sk_SK\0"      "\0\0\0\0\0\0" "hu_HU\0"      "bn\0\0\0\0"   "be_BY\0"      "uk_UA\0"      "\0\0\0\0\0\0"
+    "el_GR\0"      "sr_CS\0"      "sl_SI\0"      "mk_MK\0"      "hr_HR\0"      "\0\0\0\0\0\0" "de_DE\0"      "pt_BR\0"
+    "bg_BG\0"      "ca_ES\0"      "\0\0\0\0\0\0" "gd\0\0\0\0"   "gv\0\0\0\0"   "br\0\0\0\0"   "iu_CA\0"      "cy\0\0\0\0"
+    "en_CA\0"      "ga_IE\0"      "en_CA\0"      "dz_BT\0"      "hy_AM\0"      "ka_GE\0"      "es_XL\0"      "es_ES\0"
+    "to_TO\0"      "pl_PL\0"      "ca_ES\0"      "fr\0\0\0\0"   "de_AT\0"      "es_XL\0"      "gu_IN\0"      "pa\0\0\0\0"
+    "ur_IN\0"      "vi_VN\0"      "fr_BE\0"      "uz_UZ\0"      "en_SG\0"      "nn_NO\0"      "af_ZA\0"      "eo\0\0\0\0"
+    "mr_IN\0"      "bo\0\0\0\0"   "ne_NP\0"      "kl\0\0\0\0"   "en_IE\0";
+
+#define NUM_LOCALE_ABBREVIATIONS	109
+#define LOCALE_ABBREVIATION_LENGTH	6
+
+static const char * const __CFBundleLanguageNamesArray[] = {
+    "English",      "French",       "German",       "Italian",      "Dutch",        "Swedish",      "Spanish",      "Danish",
+    "Portuguese",   "Norwegian",    "Hebrew",       "Japanese",     "Arabic",       "Finnish",      "Greek",        "Icelandic",
+    "Maltese",      "Turkish",      "Croatian",     "Chinese",      "Urdu",         "Hindi",        "Thai",         "Korean",
+    "Lithuanian",   "Polish",       "Hungarian",    "Estonian",     "Latvian",      "Sami",         "Faroese",      "Farsi",
+    "Russian",      "Chinese",      "Dutch",        "Irish",        "Albanian",     "Romanian",     "Czech",        "Slovak",
+    "Slovenian",    "Yiddish",      "Serbian",      "Macedonian",   "Bulgarian",    "Ukrainian",    "Byelorussian", "Uzbek",
+    "Kazakh",       "Azerbaijani",  "Azerbaijani",  "Armenian",     "Georgian",     "Moldavian",    "Kirghiz",      "Tajiki",
+    "Turkmen",      "Mongolian",    "Mongolian",    "Pashto",       "Kurdish",      "Kashmiri",     "Sindhi",       "Tibetan",
+    "Nepali",       "Sanskrit",     "Marathi",      "Bengali",      "Assamese",     "Gujarati",     "Punjabi",      "Oriya",
+    "Malayalam",    "Kannada",      "Tamil",        "Telugu",       "Sinhalese",    "Burmese",      "Khmer",        "Lao",
+    "Vietnamese",   "Indonesian",   "Tagalog",      "Malay",        "Malay",        "Amharic",      "Tigrinya",     "Oromo",
+    "Somali",       "Swahili",      "Kinyarwanda",  "Rundi",        "Nyanja",       "Malagasy",     "Esperanto",    "",
+    "",             "",             "",             "",             "",             "",             "",             "",
+    "",             "",             "",             "",             "",             "",             "",             "",
+    "",             "",             "",             "",             "",             "",             "",             "",
+    "",             "",             "",             "",             "",             "",             "",             "",
+    "Welsh",        "Basque",       "Catalan",      "Latin",        "Quechua",      "Guarani",      "Aymara",       "Tatar",
+    "Uighur",       "Dzongkha",     "Javanese",     "Sundanese",    "Galician",     "Afrikaans",    "Breton",       "Inuktitut",
+    "Scottish",     "Manx",         "Irish",        "Tongan",       "Greek",        "Greenlandic",  "Azerbaijani",  "Nynorsk"
+};
+
+#define NUM_LANGUAGE_NAMES	152
+#define LANGUAGE_NAME_LENGTH	13
+
+// string, with groups of 3 characters being 1 element in the array of abbreviations
+const char * __CFBundleLanguageAbbreviationsArray =
+    "en\0"   "fr\0"   "de\0"   "it\0"   "nl\0"   "sv\0"   "es\0"   "da\0"
+    "pt\0"   "nb\0"   "he\0"   "ja\0"   "ar\0"   "fi\0"   "el\0"   "is\0"
+    "mt\0"   "tr\0"   "hr\0"   "zh\0"   "ur\0"   "hi\0"   "th\0"   "ko\0"
+    "lt\0"   "pl\0"   "hu\0"   "et\0"   "lv\0"   "se\0"   "fo\0"   "fa\0"
+    "ru\0"   "zh\0"   "nl\0"   "ga\0"   "sq\0"   "ro\0"   "cs\0"   "sk\0"
+    "sl\0"   "yi\0"   "sr\0"   "mk\0"   "bg\0"   "uk\0"   "be\0"   "uz\0"
+    "kk\0"   "az\0"   "az\0"   "hy\0"   "ka\0"   "mo\0"   "ky\0"   "tg\0"
+    "tk\0"   "mn\0"   "mn\0"   "ps\0"   "ku\0"   "ks\0"   "sd\0"   "bo\0"
+    "ne\0"   "sa\0"   "mr\0"   "bn\0"   "as\0"   "gu\0"   "pa\0"   "or\0"
+    "ml\0"   "kn\0"   "ta\0"   "te\0"   "si\0"   "my\0"   "km\0"   "lo\0"
+    "vi\0"   "id\0"   "tl\0"   "ms\0"   "ms\0"   "am\0"   "ti\0"   "om\0"
+    "so\0"   "sw\0"   "rw\0"   "rn\0"   "\0\0\0" "mg\0"   "eo\0"   "\0\0\0"
+    "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0"
+    "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0"
+    "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0"
+    "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0" "\0\0\0"
+    "cy\0"   "eu\0"   "ca\0"   "la\0"   "qu\0"   "gn\0"   "ay\0"   "tt\0"
+    "ug\0"   "dz\0"   "jv\0"   "su\0"   "gl\0"   "af\0"   "br\0"   "iu\0"
+    "gd\0"   "gv\0"   "ga\0"   "to\0"   "el\0"   "kl\0"   "az\0"   "nn\0";
+
+#define NUM_LANGUAGE_ABBREVIATIONS	152
+#define LANGUAGE_ABBREVIATION_LENGTH	3
+
+#if defined(__CONSTANT_CFSTRINGS__)
+
+// These are not necessarily common localizations per se, but localizations for which the full language name is still in common use.
+// These are used to provide a fast path for it (other localizations usually use the abbreviation, which is even faster).
+static CFStringRef const __CFBundleCommonLanguageNamesArray[] = {CFSTR("English"), CFSTR("French"), CFSTR("German"), CFSTR("Italian"), CFSTR("Dutch"), CFSTR("Spanish"), CFSTR("Japanese")};
+static CFStringRef const __CFBundleCommonLanguageAbbreviationsArray[] = {CFSTR("en"), CFSTR("fr"), CFSTR("de"), CFSTR("it"), CFSTR("nl"), CFSTR("es"), CFSTR("ja")};
+
+#define NUM_COMMON_LANGUAGE_NAMES 7
+
+#endif /* __CONSTANT_CFSTRINGS__ */
+
+static const SInt32 __CFBundleScriptCodesArray[] = {
+     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  5,  1,  4,  0,  6,  0,
+     0,  0,  0,  2,  4,  9, 21,  3, 29, 29, 29, 29, 29,  0,  0,  4,
+     7, 25,  0,  0,  0,  0, 29, 29,  0,  5,  7,  7,  7,  7,  7,  7,
+     7,  7,  4, 24, 23,  7,  7,  7,  7, 27,  7,  4,  4,  4,  4, 26,
+     9,  9,  9, 13, 13, 11, 10, 12, 17, 16, 14, 15, 18, 19, 20, 22,
+    30,  0,  0,  0,  4, 28, 28, 28,  0,  0,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  7,  4, 26,  0,  0,  0,  0,  0, 28,
+     0,  0,  0,  0,  6,  0,  0,  0
+};
+
+static const CFStringEncoding __CFBundleStringEncodingsArray[] = {
+     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  5,  1,  4,  0,  6, 37,
+     0, 35, 36,  2,  4,  9, 21,  3, 29, 29, 29, 29, 29,  0, 37, 0x8C,
+     7, 25,  0, 39,  0, 38, 29, 29, 36,  5,  7,  7,  7, 0x98,  7,  7,
+     7,  7,  4, 24, 23,  7,  7,  7,  7, 27,  7,  4,  4,  4,  4, 26,
+     9,  9,  9, 13, 13, 11, 10, 12, 17, 16, 14, 15, 18, 19, 20, 22,
+    30,  0,  0,  0,  4, 28, 28, 28,  0,  0,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+    39,  0,  0,  0,  0,  0,  0,  7,  4, 26,  0,  0,  0,  0, 39, 0xEC,
+    39, 39, 40,  0,  6,  0,  0,  0
+};
+
+static SInt32 _CFBundleGetLanguageCodeForLocalization(CFStringRef localizationName) {
+    SInt32 result = -1, i;
+    char buff[256];
+    CFIndex length = CFStringGetLength(localizationName);
+    if (length >= LANGUAGE_ABBREVIATION_LENGTH - 1 && length <= 255 && CFStringGetCString(localizationName, buff, 255, kCFStringEncodingASCII)) {
+        buff[255] = '\0';
+        for (i = 0; -1 == result && i < NUM_LANGUAGE_NAMES; i++) {
+            if (0 == strcmp(buff, __CFBundleLanguageNamesArray[i])) result = i;
+        }
+        if (0 == strcmp(buff, "zh_TW") || 0 == strcmp(buff, "zh-Hant")) result = 19; else if (0 == strcmp(buff, "zh_CN") || 0 == strcmp(buff, "zh-Hans")) result = 33; // hack for mixed-up Chinese language codes
+        if (-1 == result && (length == LANGUAGE_ABBREVIATION_LENGTH - 1 || !isalpha(buff[LANGUAGE_ABBREVIATION_LENGTH - 1]))) {
+            buff[LANGUAGE_ABBREVIATION_LENGTH - 1] = '\0';
+            if ('n' == buff[0] && 'o' == buff[1]) result = 9;  // hack for Norwegian
+            for (i = 0; -1 == result && i < NUM_LANGUAGE_ABBREVIATIONS * LANGUAGE_ABBREVIATION_LENGTH; i += LANGUAGE_ABBREVIATION_LENGTH) {
+                if (buff[0] == *(__CFBundleLanguageAbbreviationsArray + i + 0) && buff[1] == *(__CFBundleLanguageAbbreviationsArray + i + 1)) result = i / LANGUAGE_ABBREVIATION_LENGTH;
+            }
+        }
+    }
+    return result;
+}
+
+static CFStringRef _CFBundleCopyLanguageAbbreviationForLanguageCode(SInt32 languageCode) {
+    CFStringRef result = NULL;
+    if (0 <= languageCode && languageCode < NUM_LANGUAGE_ABBREVIATIONS) {
+        const char *languageAbbreviation = __CFBundleLanguageAbbreviationsArray + languageCode * LANGUAGE_ABBREVIATION_LENGTH;
+        if (languageAbbreviation && *languageAbbreviation != '\0') result = CFStringCreateWithCStringNoCopy(kCFAllocatorSystemDefault, languageAbbreviation, kCFStringEncodingASCII, kCFAllocatorNull);
+    }
+    return result;
+}
+
+CF_INLINE CFStringRef _CFBundleCopyLanguageNameForLanguageCode(SInt32 languageCode) {
+    CFStringRef result = NULL;
+    if (0 <= languageCode && languageCode < NUM_LANGUAGE_NAMES) {
+        const char *languageName = __CFBundleLanguageNamesArray[languageCode];
+        if (languageName && *languageName != '\0') result = CFStringCreateWithCStringNoCopy(kCFAllocatorSystemDefault, languageName, kCFStringEncodingASCII, kCFAllocatorNull);
+    }
+    return result;
+}
+
+CF_INLINE CFStringRef _CFBundleCopyLanguageAbbreviationForLocalization(CFStringRef localizationName) {
+    CFStringRef result = NULL;
+    SInt32 languageCode = _CFBundleGetLanguageCodeForLocalization(localizationName);
+    if (languageCode >= 0) {
+        result = _CFBundleCopyLanguageAbbreviationForLanguageCode(languageCode);
+    } else {
+        CFIndex length = CFStringGetLength(localizationName);
+        if (length == LANGUAGE_ABBREVIATION_LENGTH - 1 || (length > LANGUAGE_ABBREVIATION_LENGTH - 1 && CFStringGetCharacterAtIndex(localizationName, LANGUAGE_ABBREVIATION_LENGTH - 1) == '_')) {
+            result = CFStringCreateWithSubstring(kCFAllocatorSystemDefault, localizationName, CFRangeMake(0, LANGUAGE_ABBREVIATION_LENGTH - 1));
+        }
+    }
+    return result;
+}
+
+CF_INLINE CFStringRef _CFBundleCopyModifiedLocalization(CFStringRef localizationName) {
+    CFMutableStringRef result = NULL;
+    CFIndex length = CFStringGetLength(localizationName);
+    if (length >= 4) {
+        UniChar c = CFStringGetCharacterAtIndex(localizationName, 2);
+        if ('-' == c || '_' == c) {
+            result = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, length, localizationName);
+            CFStringReplace(result, CFRangeMake(2, 1), ('-' == c) ? CFSTR("_") : CFSTR("-"));
+        }
+    }
+    return result;
+}
+
+CF_INLINE CFStringRef _CFBundleCopyLanguageNameForLocalization(CFStringRef localizationName) {
+    CFStringRef result = NULL;
+    SInt32 languageCode = _CFBundleGetLanguageCodeForLocalization(localizationName);
+    if (languageCode >= 0) {
+        result = _CFBundleCopyLanguageNameForLanguageCode(languageCode);
+    } else {
+        result = (CFStringRef)CFStringCreateCopy(kCFAllocatorSystemDefault, localizationName);
+    }
+    return result;
+}
+
+static SInt32 _CFBundleGetLanguageCodeForRegionCode(SInt32 regionCode) {
+    SInt32 result = -1, i;
+    if (52 == regionCode) {	// hack for mixed-up Chinese language codes
+        result = 33;
+    } else if (0 <= regionCode && regionCode < NUM_LOCALE_ABBREVIATIONS) {
+        const char *localeAbbreviation = __CFBundleLocaleAbbreviationsArray + regionCode * LOCALE_ABBREVIATION_LENGTH;
+        if (localeAbbreviation && *localeAbbreviation != '\0') {
+            for (i = 0; -1 == result && i < NUM_LANGUAGE_ABBREVIATIONS * LANGUAGE_ABBREVIATION_LENGTH; i += LANGUAGE_ABBREVIATION_LENGTH) {
+                if (localeAbbreviation[0] == *(__CFBundleLanguageAbbreviationsArray + i + 0) && localeAbbreviation[1] == *(__CFBundleLanguageAbbreviationsArray + i + 1)) result = i / LANGUAGE_ABBREVIATION_LENGTH;
+            }
+        }
+    }
+    return result;
+}
+
+static SInt32 _CFBundleGetRegionCodeForLanguageCode(SInt32 languageCode) {
+    SInt32 result = -1, i;
+    if (19 == languageCode) {	// hack for mixed-up Chinese language codes
+        result = 53;
+    } else if (0 <= languageCode && languageCode < NUM_LANGUAGE_ABBREVIATIONS) {
+        const char *languageAbbreviation = __CFBundleLanguageAbbreviationsArray + languageCode * LANGUAGE_ABBREVIATION_LENGTH;
+        if (languageAbbreviation && *languageAbbreviation != '\0') {
+            for (i = 0; -1 == result && i < NUM_LOCALE_ABBREVIATIONS * LOCALE_ABBREVIATION_LENGTH; i += LOCALE_ABBREVIATION_LENGTH) {
+                if (*(__CFBundleLocaleAbbreviationsArray + i + 0) == languageAbbreviation[0] && *(__CFBundleLocaleAbbreviationsArray + i + 1) == languageAbbreviation[1]) result = i / LOCALE_ABBREVIATION_LENGTH;
+            }
+        }
+    }
+    if (25 == result) result = 68;
+    if (28 == result) result = 82;
+    return result;
+}
+
+static SInt32 _CFBundleGetRegionCodeForLocalization(CFStringRef localizationName) {
+    SInt32 result = -1, i;
+    char buff[LOCALE_ABBREVIATION_LENGTH];
+    CFIndex length = CFStringGetLength(localizationName);
+    if ((length >= LANGUAGE_ABBREVIATION_LENGTH - 1) && (length <= LOCALE_ABBREVIATION_LENGTH - 1) && CFStringGetCString(localizationName, buff, LOCALE_ABBREVIATION_LENGTH, kCFStringEncodingASCII)) {
+        buff[LOCALE_ABBREVIATION_LENGTH - 1] = '\0';
+        for (i = 0; -1 == result && i < NUM_LOCALE_ABBREVIATIONS * LOCALE_ABBREVIATION_LENGTH; i += LOCALE_ABBREVIATION_LENGTH) {
+            if (0 == strcmp(buff, __CFBundleLocaleAbbreviationsArray + i)) result = i / LOCALE_ABBREVIATION_LENGTH;
+        }
+    }
+    if (25 == result) result = 68;
+    if (28 == result) result = 82;
+    if (37 == result) result = 0;
+    if (-1 == result) {
+        SInt32 languageCode = _CFBundleGetLanguageCodeForLocalization(localizationName);
+        result = _CFBundleGetRegionCodeForLanguageCode(languageCode);
+    }
+    return result;
+}
+
+static CFStringRef _CFBundleCopyLocaleAbbreviationForRegionCode(SInt32 regionCode) {
+    CFStringRef result = NULL;
+    if (0 <= regionCode && regionCode < NUM_LOCALE_ABBREVIATIONS) {
+        const char *localeAbbreviation = __CFBundleLocaleAbbreviationsArray + regionCode * LOCALE_ABBREVIATION_LENGTH;
+        if (localeAbbreviation && *localeAbbreviation != '\0') {
+            result = CFStringCreateWithCStringNoCopy(kCFAllocatorSystemDefault, localeAbbreviation, kCFStringEncodingASCII, kCFAllocatorNull);
+        }
+    }
+    return result;
+}
+
+Boolean CFBundleGetLocalizationInfoForLocalization(CFStringRef localizationName, SInt32 *languageCode, SInt32 *regionCode, SInt32 *scriptCode, CFStringEncoding *stringEncoding) {
+    Boolean retval = false;
+    SInt32 language = -1, region = -1, script = 0;
+    CFStringEncoding encoding = kCFStringEncodingMacRoman;
+    if (!localizationName) {
+        CFBundleRef mainBundle = CFBundleGetMainBundle();
+        CFArrayRef languages = NULL;
+        if (mainBundle) {
+            languages = _CFBundleGetLanguageSearchList(mainBundle);
+            if (languages) CFRetain(languages);
+        }
+        if (!languages) languages = _CFBundleCopyUserLanguages(false);
+        if (languages && CFArrayGetCount(languages) > 0) localizationName = (CFStringRef)CFArrayGetValueAtIndex(languages, 0);
+    }
+    if (!retval) {
+        if (localizationName) {
+            language = _CFBundleGetLanguageCodeForLocalization(localizationName);
+            region = _CFBundleGetRegionCodeForLocalization(localizationName);
+        } else {
+            _CFBundleGetLanguageAndRegionCodes(&language, &region);
+        }
+        if ((language < 0 || language > (int)(sizeof(__CFBundleScriptCodesArray)/sizeof(SInt32))) && region != -1) language = _CFBundleGetLanguageCodeForRegionCode(region);
+        if (region == -1 && language != -1) region = _CFBundleGetRegionCodeForLanguageCode(language);
+        if (language >= 0 && language < (int)(sizeof(__CFBundleScriptCodesArray)/sizeof(SInt32))) {
+            script = __CFBundleScriptCodesArray[language];
+        }
+        if (language >= 0 && language < (int)(sizeof(__CFBundleStringEncodingsArray)/sizeof(CFStringEncoding))) {
+            encoding = __CFBundleStringEncodingsArray[language];
+        }
+        retval = (language != -1 || region != -1);
+    }
+    if (languageCode) *languageCode = language;
+    if (regionCode) *regionCode = region;
+    if (scriptCode) *scriptCode = script;
+    if (stringEncoding) *stringEncoding = encoding;
+    return retval;
+}
+
+CFStringRef CFBundleCopyLocalizationForLocalizationInfo(SInt32 languageCode, SInt32 regionCode, SInt32 scriptCode, CFStringEncoding stringEncoding) {
+    CFStringRef localizationName = NULL;
+    if (!localizationName) {
+        localizationName = _CFBundleCopyLocaleAbbreviationForRegionCode(regionCode);
+    }
+    if (!localizationName && 0 <= languageCode && languageCode < SHRT_MAX) {
+        localizationName = CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(kCFAllocatorSystemDefault, (LangCode)languageCode, (RegionCode)-1);
+    }
+    if (!localizationName) {
+        localizationName = _CFBundleCopyLanguageAbbreviationForLanguageCode(languageCode);
+    }
+    if (!localizationName) {
+        SInt32 language = -1, scriptLanguage = -1, encodingLanguage = -1;
+        unsigned int i;
+        for (i = 0; language == -1 && i < (sizeof(__CFBundleScriptCodesArray)/sizeof(SInt32)); i++) {
+            if (__CFBundleScriptCodesArray[i] == scriptCode && __CFBundleStringEncodingsArray[i] == stringEncoding) language = i;
+        }
+        for (i = 0; scriptLanguage == -1 && i < (sizeof(__CFBundleScriptCodesArray)/sizeof(SInt32)); i++) {
+            if (__CFBundleScriptCodesArray[i] == scriptCode) scriptLanguage = i;
+        }
+        for (i = 0; encodingLanguage == -1 && i < (sizeof(__CFBundleStringEncodingsArray)/sizeof(CFStringEncoding)); i++) {
+            if (__CFBundleStringEncodingsArray[i] == stringEncoding) encodingLanguage = i;
+        }
+        localizationName = _CFBundleCopyLanguageAbbreviationForLanguageCode(language);
+        if (!localizationName) localizationName = _CFBundleCopyLanguageAbbreviationForLanguageCode(encodingLanguage);
+        if (!localizationName) localizationName = _CFBundleCopyLanguageAbbreviationForLanguageCode(scriptLanguage);
+    }
+    return localizationName;
+}
+
+extern void *__CFAppleLanguages;
+
+__private_extern__ CFArrayRef _CFBundleCopyUserLanguages(Boolean useBackstops) {
+    CFArrayRef result = NULL;
+    static CFArrayRef userLanguages = NULL;
+    static Boolean didit = false;
+    CFArrayRef preferencesArray = CFLocaleCopyPreferredLanguages();
+    // This is a temporary solution, until the argument domain is moved down into CFPreferences
+    __CFSpinLock(&CFBundleResourceGlobalDataLock);
+    if (!didit) {
+        if (__CFAppleLanguages) {
+            CFDataRef data;
+            CFIndex length = (CFIndex)strlen((const char *)__CFAppleLanguages);
+            if (length > 0) {
+                data = CFDataCreateWithBytesNoCopy(kCFAllocatorSystemDefault, (const UInt8 *)__CFAppleLanguages, length, kCFAllocatorNull);
+                if (data) {
+                    userLanguages = (CFArrayRef)CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, data, kCFPropertyListImmutable, NULL);
+                    CFRelease(data);
+                }
+            }
+        }
+        if (!userLanguages && preferencesArray) userLanguages = (CFArrayRef)CFRetain(preferencesArray);
+        Boolean useEnglishAsBackstop = true;
+        // could perhaps read out of LANG environment variable
+        if (useEnglishAsBackstop && !userLanguages) {
+            CFStringRef english = CFSTR("en");
+            userLanguages = CFArrayCreate(kCFAllocatorSystemDefault, (const void **)&english, 1, &kCFTypeArrayCallBacks);
+        }
+        if (userLanguages && CFGetTypeID(userLanguages) != CFArrayGetTypeID()) {
+            CFRelease(userLanguages);
+            userLanguages = NULL;
+        }
+        didit = true;
+    }
+    __CFSpinUnlock(&CFBundleResourceGlobalDataLock);
+    if (preferencesArray) CFRelease(preferencesArray);
+    if (!result && userLanguages) result = (CFArrayRef)CFRetain(userLanguages);
+    return result;
+}
+
+CF_EXPORT void _CFBundleGetLanguageAndRegionCodes(SInt32 *languageCode, SInt32 *regionCode) {
+    // an attempt to answer the question, "what language are we running in?"
+    // note that the question cannot be answered fully since it may depend on the bundle
+    SInt32 language = -1, region = -1;
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    CFArrayRef languages = NULL;
+    if (mainBundle) {
+        languages = _CFBundleGetLanguageSearchList(mainBundle);
+        if (languages) CFRetain(languages);
+    }
+    if (!languages) languages = _CFBundleCopyUserLanguages(false);
+    if (languages && CFArrayGetCount(languages) > 0) {
+        CFStringRef localizationName = (CFStringRef)CFArrayGetValueAtIndex(languages, 0);
+        Boolean retval = false;
+        LangCode langCode = -1;
+        RegionCode regCode = -1;
+        if (!retval) {
+            language = _CFBundleGetLanguageCodeForLocalization(localizationName);
+            region = _CFBundleGetRegionCodeForLocalization(localizationName);
+        }
+    } else {
+        language = 0;
+        region = 0;
+    }
+    if (language == -1 && region != -1) language = _CFBundleGetLanguageCodeForRegionCode(region);
+    if (region == -1 && language != -1) region = _CFBundleGetRegionCodeForLanguageCode(language);
+    if (languages) CFRelease(languages);
+    if (languageCode) *languageCode = language;
+    if (regionCode) *regionCode = region;
+}
+
+
+static Boolean _CFBundleTryOnePreferredLprojNameInDirectory(CFAllocatorRef alloc, UniChar *pathUniChars, CFIndex pathLen, uint8_t version, CFDictionaryRef infoDict, CFStringRef curLangStr, CFMutableArrayRef lprojNames) {
+    CFIndex curLangLen = CFStringGetLength(curLangStr), savedPathLen;
+    UniChar curLangUniChars[255];
+    CFStringRef altLangStr = NULL, modifiedLangStr = NULL, languageAbbreviation = NULL, languageName = NULL, canonicalLanguageIdentifier = NULL;
+    CFMutableDictionaryRef canonicalLanguageIdentifiers = NULL, predefinedCanonicalLanguageIdentifiers = NULL;
+    Boolean foundOne = false;
+    CFArrayRef predefinedLocalizations = NULL;
+    CFRange predefinedLocalizationsRange;
+    CFMutableStringRef cheapStr, tmpString;
+#if READ_DIRECTORIES
+    CFArrayRef contents;
+    CFRange contentsRange;
+#else /* READ_DIRECTORIES */
+    Boolean isDir = false;
+#endif /* READ_DIRECTORIES */
+
+    // both of these used for temp string operations, for slightly
+    // different purposes, where each type is appropriate
+    cheapStr = CFStringCreateMutable(alloc, 0);
+    _CFStrSetDesiredCapacity(cheapStr, CFMaxPathSize);
+    tmpString = CFStringCreateMutableWithExternalCharactersNoCopy(kCFAllocatorSystemDefault, NULL, 0, 0, kCFAllocatorNull);    
+    
+#if READ_DIRECTORIES
+    CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+    CFStringReplaceAll(cheapStr, tmpString);
+    contents = _CFBundleCopyDirectoryContentsAtPath(cheapStr, _CFBundleAllContents);
+    contentsRange = CFRangeMake(0, CFArrayGetCount(contents));
+#endif /* READ_DIRECTORIES */
+    
+    if (infoDict) {
+        predefinedLocalizations = (CFArrayRef)CFDictionaryGetValue(infoDict, kCFBundleLocalizationsKey);
+        if (predefinedLocalizations && CFGetTypeID(predefinedLocalizations) != CFArrayGetTypeID()) {
+            predefinedLocalizations = NULL;
+            CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, kCFBundleLocalizationsKey);
+        }
+    }
+    predefinedLocalizationsRange = CFRangeMake(0, predefinedLocalizations ? CFArrayGetCount(predefinedLocalizations) : 0);
+    
+    if (curLangLen > 255) curLangLen = 255;
+    CFStringGetCharacters(curLangStr, CFRangeMake(0, curLangLen), curLangUniChars);
+    savedPathLen = pathLen;
+    if (_CFAppendPathComponent(pathUniChars, &pathLen, CFMaxPathSize, curLangUniChars, curLangLen) && _CFAppendPathExtension(pathUniChars, &pathLen, CFMaxPathSize, _LprojUniChars, _LprojLen)) {
+#if READ_DIRECTORIES
+        CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars + savedPathLen + 1, pathLen - savedPathLen - 1, pathLen - savedPathLen - 1);
+        CFStringReplaceAll(cheapStr, tmpString);
+        if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, curLangStr)) || (version != 4 && CFArrayContainsValue(contents, contentsRange, cheapStr))) {
+#else /* READ_DIRECTORIES */
+        CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+        CFStringReplaceAll(cheapStr, tmpString);
+        if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, curLangStr)) || (version != 4 && _CFIsResourceAtPath(cheapStr, &isDir) && isDir)) {
+#endif /* READ_DIRECTORIES */
+            if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), curLangStr)) CFArrayAppendValue(lprojNames, curLangStr);
+            foundOne = true;
+            if (CFStringGetLength(curLangStr) <= 2) {
+                CFRelease(cheapStr);
+                CFRelease(tmpString);
+#if READ_DIRECTORIES
+                CFRelease(contents);
+#endif /* READ_DIRECTORIES */
+                return foundOne;
+            }
+        }
+    }
+#if defined(__CONSTANT_CFSTRINGS__)
+    if (!altLangStr) {
+        CFIndex idx;
+        for (idx = 0; !altLangStr && idx < NUM_COMMON_LANGUAGE_NAMES; idx++) {
+            if (CFEqual(curLangStr, __CFBundleCommonLanguageAbbreviationsArray[idx])) altLangStr = __CFBundleCommonLanguageNamesArray[idx];
+            else if (CFEqual(curLangStr, __CFBundleCommonLanguageNamesArray[idx])) altLangStr = __CFBundleCommonLanguageAbbreviationsArray[idx];
+        }
+    }
+#endif /* __CONSTANT_CFSTRINGS__ */
+    if (foundOne && altLangStr) {
+        CFRelease(cheapStr);
+        CFRelease(tmpString);
+#if READ_DIRECTORIES
+        CFRelease(contents);
+#endif /* READ_DIRECTORIES */
+        return foundOne;
+    }
+    if (altLangStr) {
+        curLangLen = CFStringGetLength(altLangStr);
+        if (curLangLen > 255) curLangLen = 255;
+        CFStringGetCharacters(altLangStr, CFRangeMake(0, curLangLen), curLangUniChars);
+        pathLen = savedPathLen;
+        if (_CFAppendPathComponent(pathUniChars, &pathLen, CFMaxPathSize, curLangUniChars, curLangLen) && _CFAppendPathExtension(pathUniChars, &pathLen, CFMaxPathSize, _LprojUniChars, _LprojLen)) {
+#if READ_DIRECTORIES
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars + savedPathLen + 1, pathLen - savedPathLen - 1, pathLen - savedPathLen - 1);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, altLangStr)) || (version != 4 && CFArrayContainsValue(contents, contentsRange, cheapStr))) {
+#else /* READ_DIRECTORIES */
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, altLangStr)) || (version != 4 && _CFIsResourceAtPath(cheapStr, &isDir) && isDir)) {
+#endif /* READ_DIRECTORIES */
+                if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), altLangStr)) CFArrayAppendValue(lprojNames, altLangStr);
+                foundOne = true;
+                CFRelease(cheapStr);
+                CFRelease(tmpString);
+#if READ_DIRECTORIES
+                CFRelease(contents);
+#endif /* READ_DIRECTORIES */
+                return foundOne;
+            }
+        }
+    }
+#if READ_DIRECTORIES
+    if (!foundOne && (!predefinedLocalizations || CFArrayGetCount(predefinedLocalizations) == 0)) {
+        Boolean hasLocalizations = false;
+        CFIndex idx;
+        for (idx = 0; !hasLocalizations && idx < contentsRange.length; idx++) {
+            CFStringRef name = (CFStringRef)CFArrayGetValueAtIndex(contents, idx);
+            if (CFStringHasSuffix(name, _CFBundleLprojExtensionWithDot)) hasLocalizations = true;
+        }
+        if (!hasLocalizations) {
+            CFRelease(cheapStr);
+            CFRelease(tmpString);
+            CFRelease(contents);
+            return foundOne;
+        }
+    }
+#endif /* READ_DIRECTORIES */
+    if (!altLangStr && (modifiedLangStr = _CFBundleCopyModifiedLocalization(curLangStr))) {
+        curLangLen = CFStringGetLength(modifiedLangStr);
+        if (curLangLen > 255) curLangLen = 255;
+        CFStringGetCharacters(modifiedLangStr, CFRangeMake(0, curLangLen), curLangUniChars);
+        pathLen = savedPathLen;
+        if (_CFAppendPathComponent(pathUniChars, &pathLen, CFMaxPathSize, curLangUniChars, curLangLen) && _CFAppendPathExtension(pathUniChars, &pathLen, CFMaxPathSize, _LprojUniChars, _LprojLen)) {
+#if READ_DIRECTORIES
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars + savedPathLen + 1, pathLen - savedPathLen - 1, pathLen - savedPathLen - 1);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, modifiedLangStr)) || (version != 4 && CFArrayContainsValue(contents, contentsRange, cheapStr))) {
+#else /* READ_DIRECTORIES */
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, modifiedLangStr)) || (version != 4 && _CFIsResourceAtPath(cheapStr, &isDir) && isDir)) {
+#endif /* READ_DIRECTORIES */
+                if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), modifiedLangStr)) CFArrayAppendValue(lprojNames, modifiedLangStr);
+                foundOne = true;
+            }
+        }
+    }
+    if (!altLangStr && (languageAbbreviation = _CFBundleCopyLanguageAbbreviationForLocalization(curLangStr)) && !CFEqual(curLangStr, languageAbbreviation)) {
+        curLangLen = CFStringGetLength(languageAbbreviation);
+        if (curLangLen > 255) curLangLen = 255;
+        CFStringGetCharacters(languageAbbreviation, CFRangeMake(0, curLangLen), curLangUniChars);
+        pathLen = savedPathLen;
+        if (_CFAppendPathComponent(pathUniChars, &pathLen, CFMaxPathSize, curLangUniChars, curLangLen) && _CFAppendPathExtension(pathUniChars, &pathLen, CFMaxPathSize, _LprojUniChars, _LprojLen)) {
+#if READ_DIRECTORIES
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars + savedPathLen + 1, pathLen - savedPathLen - 1, pathLen - savedPathLen - 1);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, languageAbbreviation)) || (version != 4 && CFArrayContainsValue(contents, contentsRange, cheapStr))) {
+#else /* READ_DIRECTORIES */
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, languageAbbreviation)) || (version != 4 && _CFIsResourceAtPath(cheapStr, &isDir) && isDir)) {
+#endif /* READ_DIRECTORIES */
+                if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), languageAbbreviation)) CFArrayAppendValue(lprojNames, languageAbbreviation);
+                foundOne = true;
+            }
+        }
+    }
+    if (!altLangStr && (languageName = _CFBundleCopyLanguageNameForLocalization(curLangStr)) && !CFEqual(curLangStr, languageName)) {
+        curLangLen = CFStringGetLength(languageName);
+        if (curLangLen > 255) curLangLen = 255;
+        CFStringGetCharacters(languageName, CFRangeMake(0, curLangLen), curLangUniChars);
+        pathLen = savedPathLen;
+        if (_CFAppendPathComponent(pathUniChars, &pathLen, CFMaxPathSize, curLangUniChars, curLangLen) && _CFAppendPathExtension(pathUniChars, &pathLen, CFMaxPathSize, _LprojUniChars, _LprojLen)) {
+#if READ_DIRECTORIES
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars + savedPathLen + 1, pathLen - savedPathLen - 1, pathLen - savedPathLen - 1);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, languageName)) || (version != 4 && CFArrayContainsValue(contents, contentsRange, cheapStr))) {
+#else /* READ_DIRECTORIES */
+            CFStringSetExternalCharactersNoCopy(tmpString, pathUniChars, pathLen, pathLen);
+            CFStringReplaceAll(cheapStr, tmpString);
+            if ((predefinedLocalizations && CFArrayContainsValue(predefinedLocalizations, predefinedLocalizationsRange, languageName)) || (version != 4 && _CFIsResourceAtPath(cheapStr, &isDir) && isDir)) {
+#endif /* READ_DIRECTORIES */
+                if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), languageName)) CFArrayAppendValue(lprojNames, languageName);
+                foundOne = true;
+            }
+        }
+    }
+    if (modifiedLangStr) CFRelease(modifiedLangStr);
+    if (languageAbbreviation) CFRelease(languageAbbreviation);
+    if (languageName) CFRelease(languageName);
+    if (canonicalLanguageIdentifier) CFRelease(canonicalLanguageIdentifier);
+    if (canonicalLanguageIdentifiers) CFRelease(canonicalLanguageIdentifiers);
+    if (predefinedCanonicalLanguageIdentifiers) CFRelease(predefinedCanonicalLanguageIdentifiers);
+    CFRelease(cheapStr);
+    CFRelease(tmpString);
+#if READ_DIRECTORIES
+    CFRelease(contents);
+#endif /* READ_DIRECTORIES */
+
+    return foundOne;
+}
+
+static Boolean CFBundleAllowMixedLocalizations(void) {
+    static Boolean allowMixed = false, examinedMain = false;
+    if (!examinedMain) {
+        CFBundleRef mainBundle = CFBundleGetMainBundle();
+        CFDictionaryRef infoDict = mainBundle ? CFBundleGetInfoDictionary(mainBundle) : NULL;
+        CFTypeRef allowMixedValue = infoDict ? CFDictionaryGetValue(infoDict, _kCFBundleAllowMixedLocalizationsKey) : NULL;
+        if (allowMixedValue) {
+            CFTypeID typeID = CFGetTypeID(allowMixedValue);
+            if (typeID == CFBooleanGetTypeID()) {
+                allowMixed = CFBooleanGetValue((CFBooleanRef)allowMixedValue);
+            } else if (typeID == CFStringGetTypeID()) {
+                allowMixed = (CFStringCompare((CFStringRef)allowMixedValue, CFSTR("true"), kCFCompareCaseInsensitive) == kCFCompareEqualTo || CFStringCompare((CFStringRef)allowMixedValue, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo);
+            } else if (typeID == CFNumberGetTypeID()) {
+                SInt32 val = 0;
+                if (CFNumberGetValue((CFNumberRef)allowMixedValue, kCFNumberSInt32Type, &val)) allowMixed = (val != 0);
+            }
+        }
+        examinedMain = true;
+    }
+    return allowMixed;
+}
+
+__private_extern__ void _CFBundleAddPreferredLprojNamesInDirectory(CFAllocatorRef alloc, CFURLRef bundleURL, uint8_t version, CFDictionaryRef infoDict, CFMutableArrayRef lprojNames, CFStringRef devLang) {
+    // This function will add zero, one or two elements to the lprojNames array.
+    // It examines the users preferred language list and the lproj directories inside the bundle directory.  It picks the lproj directory that is highest on the users list.
+    // The users list can contain region names (like "en_US" for US English).  In this case, if the region lproj exists, it will be added, and, if the region's associated language lproj exists that will be added.
+    CFURLRef resourcesURL = _CFBundleCopyResourcesDirectoryURLInDirectory(alloc, bundleURL, version);
+    CFURLRef absoluteURL;
+    CFIndex idx;
+    CFIndex count;
+    CFStringRef resourcesPath;
+    UniChar pathUniChars[CFMaxPathSize];
+    CFIndex pathLen;
+    CFStringRef curLangStr;
+    Boolean foundOne = false;
+
+    CFArrayRef userLanguages;
+    
+    // Init the one-time-only unichar buffers.
+    _CFEnsureStaticBuffersInited();
+
+    // Get the path to the resources and extract into a buffer.
+    absoluteURL = CFURLCopyAbsoluteURL(resourcesURL);
+    resourcesPath = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+    CFRelease(absoluteURL);
+    pathLen = CFStringGetLength(resourcesPath);
+    if (pathLen > CFMaxPathSize) pathLen = CFMaxPathSize;
+    CFStringGetCharacters(resourcesPath, CFRangeMake(0, pathLen), pathUniChars);
+    CFRelease(resourcesURL);
+    CFRelease(resourcesPath);
+
+    // First check the main bundle.
+    if (!CFBundleAllowMixedLocalizations()) {
+        CFBundleRef mainBundle = CFBundleGetMainBundle();
+        if (mainBundle) {
+            CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+            if (!CFEqual(bundleURL, mainBundleURL)) {
+                // If there is a main bundle, and it isn't this one, try to use the language it prefers.
+                CFArrayRef mainBundleLangs = _CFBundleGetLanguageSearchList(mainBundle);
+                if (mainBundleLangs && (CFArrayGetCount(mainBundleLangs) > 0)) {
+                    curLangStr = (CFStringRef)CFArrayGetValueAtIndex(mainBundleLangs, 0);
+                    foundOne = _CFBundleTryOnePreferredLprojNameInDirectory(alloc, pathUniChars, pathLen, version, infoDict, curLangStr, lprojNames);
+                }
+            }
+            CFRelease(mainBundleURL);
+        }
+    }
+
+    if (!foundOne) {
+        // If we didn't find the main bundle's preferred language, look at the users' prefs again and find the best one.
+        userLanguages = _CFBundleCopyUserLanguages(true);
+        count = (userLanguages ? CFArrayGetCount(userLanguages) : 0);
+        for (idx = 0; !foundOne && idx < count; idx++) {
+            curLangStr = (CFStringRef)CFArrayGetValueAtIndex(userLanguages, idx);
+            foundOne = _CFBundleTryOnePreferredLprojNameInDirectory(alloc, pathUniChars, pathLen, version, infoDict, curLangStr, lprojNames);
+        }
+        // use development region and U.S. English as backstops
+        if (!foundOne && devLang) foundOne = _CFBundleTryOnePreferredLprojNameInDirectory(alloc, pathUniChars, pathLen, version, infoDict, devLang, lprojNames);
+        if (!foundOne) foundOne = _CFBundleTryOnePreferredLprojNameInDirectory(alloc, pathUniChars, pathLen, version, infoDict, CFSTR("en_US"), lprojNames);
+        if (userLanguages) CFRelease(userLanguages);
+    }
+}
+
+static Boolean _CFBundleTryOnePreferredLprojNameInArray(CFArrayRef array, CFStringRef curLangStr, CFMutableArrayRef lprojNames) {
+    Boolean foundOne = false;
+    CFRange range = CFRangeMake(0, CFArrayGetCount(array));
+    CFStringRef altLangStr = NULL, modifiedLangStr = NULL, languageAbbreviation = NULL, languageName = NULL, canonicalLanguageIdentifier = NULL;
+    CFMutableDictionaryRef canonicalLanguageIdentifiers = NULL;
+
+    if (range.length == 0) return foundOne;
+    if (CFArrayContainsValue(array, range, curLangStr)) {
+        if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), curLangStr)) CFArrayAppendValue(lprojNames, curLangStr);
+        foundOne = true;
+        if (range.length == 1 || CFStringGetLength(curLangStr) <= 2) return foundOne;
+    }
+    if (range.length == 1 && CFArrayContainsValue(array, range, CFSTR("default"))) return foundOne;
+#if defined(__CONSTANT_CFSTRINGS__)
+    if (!altLangStr) {
+        CFIndex idx;
+        for (idx = 0; !altLangStr && idx < NUM_COMMON_LANGUAGE_NAMES; idx++) {
+            if (CFEqual(curLangStr, __CFBundleCommonLanguageAbbreviationsArray[idx])) altLangStr = __CFBundleCommonLanguageNamesArray[idx];
+            else if (CFEqual(curLangStr, __CFBundleCommonLanguageNamesArray[idx])) altLangStr = __CFBundleCommonLanguageAbbreviationsArray[idx];
+        }
+    }
+#endif /* __CONSTANT_CFSTRINGS__ */
+    if (foundOne && altLangStr) return foundOne;
+    if (altLangStr && CFArrayContainsValue(array, range, altLangStr)) {
+        if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), altLangStr)) CFArrayAppendValue(lprojNames, altLangStr);
+        foundOne = true;
+        return foundOne;
+    }
+    if (!altLangStr && (modifiedLangStr = _CFBundleCopyModifiedLocalization(curLangStr))) {
+        if (CFArrayContainsValue(array, range, modifiedLangStr)) {
+            if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), modifiedLangStr)) CFArrayAppendValue(lprojNames, modifiedLangStr);
+            foundOne = true;
+        }
+    }
+    if (!altLangStr && (languageAbbreviation = _CFBundleCopyLanguageAbbreviationForLocalization(curLangStr)) && !CFEqual(curLangStr, languageAbbreviation)) {
+        if (CFArrayContainsValue(array, range, languageAbbreviation)) {
+            if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), languageAbbreviation)) CFArrayAppendValue(lprojNames, languageAbbreviation);
+            foundOne = true;
+        }
+    }
+    if (!altLangStr && (languageName = _CFBundleCopyLanguageNameForLocalization(curLangStr)) && !CFEqual(curLangStr, languageName)) {
+        if (CFArrayContainsValue(array, range, languageName)) {
+            if (!CFArrayContainsValue(lprojNames, CFRangeMake(0, CFArrayGetCount(lprojNames)), languageName)) CFArrayAppendValue(lprojNames, languageName);
+            foundOne = true;
+        }
+    }
+    if (modifiedLangStr) CFRelease(modifiedLangStr);
+    if (languageAbbreviation) CFRelease(languageAbbreviation);
+    if (languageName) CFRelease(languageName);
+    if (canonicalLanguageIdentifier) CFRelease(canonicalLanguageIdentifier);
+    if (canonicalLanguageIdentifiers) CFRelease(canonicalLanguageIdentifiers);
+
+    return foundOne;
+}
+
+static CFArrayRef _CFBundleCopyLocalizationsForPreferences(CFArrayRef locArray, CFArrayRef prefArray, Boolean considerMain) {
+    CFMutableArrayRef lprojNames = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    Boolean foundOne = false, releasePrefArray = false;
+    CFIndex idx, count;
+    
+    if (considerMain && !CFBundleAllowMixedLocalizations()) {
+        CFBundleRef mainBundle = CFBundleGetMainBundle();
+        if (mainBundle) {
+            // If there is a main bundle, try to use the language it prefers.
+            CFArrayRef mainBundleLangs = _CFBundleGetLanguageSearchList(mainBundle);
+            if (mainBundleLangs && (CFArrayGetCount(mainBundleLangs) > 0)) {
+                foundOne = _CFBundleTryOnePreferredLprojNameInArray(locArray, (CFStringRef)CFArrayGetValueAtIndex(mainBundleLangs, 0), lprojNames);
+            }
+        }
+    }
+    if (!foundOne) {
+        if (!prefArray) {
+            prefArray = _CFBundleCopyUserLanguages(true);
+            if (prefArray) releasePrefArray = true;
+        }
+        count = (prefArray ? CFArrayGetCount(prefArray) : 0);
+        for (idx = 0; !foundOne && idx < count; idx++) {
+            foundOne = _CFBundleTryOnePreferredLprojNameInArray(locArray, (CFStringRef)CFArrayGetValueAtIndex(prefArray, idx), lprojNames);
+        }
+        // use U.S. English as backstop
+        if (!foundOne) {
+            foundOne = _CFBundleTryOnePreferredLprojNameInArray(locArray, CFSTR("en_US"), lprojNames);
+        }
+        // use random entry as backstop
+        if (!foundOne && CFArrayGetCount(lprojNames) > 0) {
+            foundOne = _CFBundleTryOnePreferredLprojNameInArray(locArray, (CFStringRef)CFArrayGetValueAtIndex(locArray, 0), lprojNames);
+        }
+    }
+    if (CFArrayGetCount(lprojNames) == 0) {
+        // Total backstop behavior to avoid having an empty array. 
+        CFArrayAppendValue(lprojNames, CFSTR("en"));
+    }
+    if (releasePrefArray) {
+        CFRelease(prefArray);
+    }
+    return lprojNames;
+}
+
+CF_EXPORT CFArrayRef CFBundleCopyLocalizationsForPreferences(CFArrayRef locArray, CFArrayRef prefArray) {return _CFBundleCopyLocalizationsForPreferences(locArray, prefArray, false);}
+
+CF_EXPORT CFArrayRef CFBundleCopyPreferredLocalizationsFromArray(CFArrayRef locArray) {return _CFBundleCopyLocalizationsForPreferences(locArray, NULL, true);}
+
+__private_extern__ CFArrayRef _CFBundleCopyLanguageSearchListInDirectory(CFAllocatorRef alloc, CFURLRef url, uint8_t *version) {
+    CFMutableArrayRef langs = CFArrayCreateMutable(alloc, 0, &kCFTypeArrayCallBacks);
+    uint8_t localVersion = 0;
+    CFDictionaryRef infoDict = _CFBundleCopyInfoDictionaryInDirectory(alloc, url, &localVersion);
+    CFStringRef devLang = NULL;
+    if (infoDict) devLang = (CFStringRef)CFDictionaryGetValue(infoDict, kCFBundleDevelopmentRegionKey);
+    if (devLang && (CFGetTypeID(devLang) != CFStringGetTypeID() || CFStringGetLength(devLang) == 0)) devLang = NULL;
+
+    _CFBundleAddPreferredLprojNamesInDirectory(alloc, url, localVersion, infoDict, langs, devLang);
+    
+    if (devLang && CFArrayGetFirstIndexOfValue(langs, CFRangeMake(0, CFArrayGetCount(langs)), devLang) < 0) CFArrayAppendValue(langs, devLang);
+
+    // Total backstop behavior to avoid having an empty array. 
+    if (CFArrayGetCount(langs) == 0) CFArrayAppendValue(langs, CFSTR("en"));
+    
+    if (infoDict) CFRelease(infoDict);
+    if (version) *version = localVersion;
+    return langs;
+}
+
+CF_EXPORT Boolean _CFBundleURLLooksLikeBundle(CFURLRef url) {
+    Boolean result = false;
+    CFBundleRef bundle = _CFBundleCreateIfLooksLikeBundle(kCFAllocatorSystemDefault, url);
+    if (bundle) {
+        result = true;
+        CFRelease(bundle);
+    }
+    return result;
+}
+
+// Note that subDirName is expected to be the string for a URL
+CF_INLINE Boolean _CFBundleURLHasSubDir(CFURLRef url, CFStringRef subDirName) {
+    CFURLRef dirURL;
+    Boolean isDir = false, result = false;
+
+    dirURL = CFURLCreateWithString(kCFAllocatorSystemDefault, subDirName, url);
+    if (dirURL) {
+        if (_CFIsResourceAtURL(dirURL, &isDir) && isDir) result = true;
+        CFRelease(dirURL);
+    }
+    return result;
+}
+
+__private_extern__ Boolean _CFBundleURLLooksLikeBundleVersion(CFURLRef url, uint8_t *version) {
+    // check for existence of "Resources" or "Contents" or "Support Files"
+    // but check for the most likely one first
+    // version 0:  old-style "Resources" bundles
+    // version 1:  obsolete "Support Files" bundles
+    // version 2:  modern "Contents" bundles
+    // version 3:  none of the above (see below)
+    // version 4:  not a bundle (for main bundle only)
+    uint8_t localVersion = 3;
+#if READ_DIRECTORIES
+    CFURLRef absoluteURL = CFURLCopyAbsoluteURL(url);
+    CFStringRef directoryPath = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+    CFArrayRef contents = _CFBundleCopyDirectoryContentsAtPath(directoryPath, _CFBundleAllContents);
+    CFRange contentsRange = CFRangeMake(0, CFArrayGetCount(contents));
+    if (CFStringHasSuffix(CFURLGetString(url), CFSTR(".framework/"))) {
+        if (CFArrayContainsValue(contents, contentsRange, _CFBundleResourcesDirectoryName)) localVersion = 0;
+        else if (CFArrayContainsValue(contents, contentsRange, _CFBundleSupportFilesDirectoryName2)) localVersion = 2;
+        else if (CFArrayContainsValue(contents, contentsRange, _CFBundleSupportFilesDirectoryName1)) localVersion = 1;
+    } else {
+        if (CFArrayContainsValue(contents, contentsRange, _CFBundleSupportFilesDirectoryName2)) localVersion = 2;
+        else if (CFArrayContainsValue(contents, contentsRange, _CFBundleResourcesDirectoryName)) localVersion = 0;
+        else if (CFArrayContainsValue(contents, contentsRange, _CFBundleSupportFilesDirectoryName1)) localVersion = 1;
+    }
+    CFRelease(contents);
+    CFRelease(directoryPath);
+    CFRelease(absoluteURL);
+#endif /* READ_DIRECTORIES */
+    if (localVersion == 3) {
+#if DEPLOYMENT_TARGET_MACOSX
+        if (CFStringHasSuffix(CFURLGetString(url), CFSTR(".framework/"))) {
+            if (_CFBundleURLHasSubDir(url, _CFBundleResourcesURLFromBase0)) localVersion = 0;
+            else if (_CFBundleURLHasSubDir(url, _CFBundleSupportFilesURLFromBase2)) localVersion = 2;
+            else if (_CFBundleURLHasSubDir(url, _CFBundleSupportFilesURLFromBase1)) localVersion = 1;
+        } else {
+            if (_CFBundleURLHasSubDir(url, _CFBundleSupportFilesURLFromBase2)) localVersion = 2;
+            else if (_CFBundleURLHasSubDir(url, _CFBundleResourcesURLFromBase0)) localVersion = 0;
+            else if (_CFBundleURLHasSubDir(url, _CFBundleSupportFilesURLFromBase1)) localVersion = 1;
+        }
+#endif
+    }
+    if (version) *version = localVersion;
+    return !(localVersion == 3);
+}
+
+__private_extern__ CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectory(CFAllocatorRef alloc, CFURLRef url, uint8_t *version) {
+    CFDictionaryRef dict = NULL;
+    unsigned char buff[CFMaxPathSize];
+    uint8_t localVersion = 0;
+    
+    if (CFURLGetFileSystemRepresentation(url, true, buff, CFMaxPathSize)) {
+        CFURLRef newURL = CFURLCreateFromFileSystemRepresentation(alloc, buff, (CFIndex)strlen((char *)buff), true);
+        if (!newURL) newURL = (CFURLRef)CFRetain(url);
+
+        // version 3 is for flattened pseudo-bundles with no Contents, Support Files, or Resources directories
+        if (!_CFBundleURLLooksLikeBundleVersion(newURL, &localVersion)) localVersion = 3;
+        
+        dict = _CFBundleCopyInfoDictionaryInDirectoryWithVersion(alloc, newURL, localVersion);
+        CFRelease(newURL);
+    }
+    if (version) *version = localVersion;
+    return dict;
+}
+
+__private_extern__ CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectoryWithVersion(CFAllocatorRef alloc, CFURLRef url, uint8_t version) {
+    CFDictionaryRef result = NULL;
+    if (url) {
+        CFURLRef infoURL = NULL, rawInfoURL = NULL;
+        CFDataRef infoData = NULL;
+        UniChar buff[CFMaxPathSize];
+        CFIndex len;
+        CFMutableStringRef cheapStr;
+        CFStringRef infoURLFromBaseNoExtension = _CFBundleInfoURLFromBaseNoExtension0, infoURLFromBase = _CFBundleInfoURLFromBase0;
+        Boolean tryPlatformSpecific = true, tryGlobal = true;
+#if READ_DIRECTORIES
+        CFURLRef directoryURL = NULL, absoluteURL;
+        CFStringRef directoryPath;
+        CFArrayRef contents = NULL;
+        CFRange contentsRange = CFRangeMake(0, 0);
+#endif /* READ_DIRECTORIES */    
+
+        _CFEnsureStaticBuffersInited();
+
+        if (0 == version) {
+#if READ_DIRECTORIES
+            directoryURL = CFURLCreateWithString(alloc, _CFBundleResourcesURLFromBase0, url);
+#endif /* READ_DIRECTORIES */    
+            infoURLFromBaseNoExtension = _CFBundleInfoURLFromBaseNoExtension0;
+            infoURLFromBase = _CFBundleInfoURLFromBase0;
+        } else if (1 == version) {
+#if READ_DIRECTORIES
+            directoryURL = CFURLCreateWithString(alloc, _CFBundleSupportFilesURLFromBase1, url);
+#endif /* READ_DIRECTORIES */    
+            infoURLFromBaseNoExtension = _CFBundleInfoURLFromBaseNoExtension1;
+            infoURLFromBase = _CFBundleInfoURLFromBase1;
+        } else if (2 == version) {
+#if READ_DIRECTORIES
+            directoryURL = CFURLCreateWithString(alloc, _CFBundleSupportFilesURLFromBase2, url);
+#endif /* READ_DIRECTORIES */    
+            infoURLFromBaseNoExtension = _CFBundleInfoURLFromBaseNoExtension2;
+            infoURLFromBase = _CFBundleInfoURLFromBase2;
+        } else if (3 == version) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+            CFStringRef posixPath = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+            // this test is necessary to exclude the case where a bundle is spuriously created from the innards of another bundle
+            if (posixPath) {
+                if (!(CFStringHasSuffix(posixPath, _CFBundleSupportFilesDirectoryName1) || CFStringHasSuffix(posixPath, _CFBundleSupportFilesDirectoryName2) || CFStringHasSuffix(posixPath, _CFBundleResourcesDirectoryName))) {
+#if READ_DIRECTORIES
+                    directoryURL = (CFURLRef)CFRetain(url);
+#endif /* READ_DIRECTORIES */    
+                    infoURLFromBaseNoExtension = _CFBundleInfoURLFromBaseNoExtension3;
+                    infoURLFromBase = _CFBundleInfoURLFromBase3;
+                }
+                CFRelease(posixPath);
+            }
+#elif DEPLOYMENT_TARGET_WINDOWS
+            CFStringRef windowsPath = CFURLCopyFileSystemPath(url, kCFURLWindowsPathStyle);
+            // this test is necessary to exclude the case where a bundle is spuriously created from the innards of another bundle
+            if (windowsPath) {
+                if (!(CFStringHasSuffix(windowsPath, _CFBundleSupportFilesDirectoryName1) || CFStringHasSuffix(windowsPath, _CFBundleSupportFilesDirectoryName2) || CFStringHasSuffix(windowsPath, _CFBundleResourcesDirectoryName))) {
+#if READ_DIRECTORIES
+                    directoryURL = (CFURLRef)CFRetain(url);
+#endif /* READ_DIRECTORIES */    
+                    infoURLFromBaseNoExtension = _CFBundleInfoURLFromBaseNoExtension3;
+                    infoURLFromBase = _CFBundleInfoURLFromBase3;
+                }
+                CFRelease(windowsPath);
+            }
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+        }
+#if READ_DIRECTORIES
+        if (directoryURL) {
+            absoluteURL = CFURLCopyAbsoluteURL(directoryURL);
+            directoryPath = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+            contents = _CFBundleCopyDirectoryContentsAtPath(directoryPath, _CFBundleAllContents);
+            contentsRange = CFRangeMake(0, CFArrayGetCount(contents));
+            CFRelease(directoryPath);
+            CFRelease(absoluteURL);
+            CFRelease(directoryURL);
+        }
+#endif /* READ_DIRECTORIES */    
+
+        len = CFStringGetLength(infoURLFromBaseNoExtension);
+        CFStringGetCharacters(infoURLFromBaseNoExtension, CFRangeMake(0, len), buff);
+        buff[len++] = (UniChar)'-';
+        memmove(buff + len, _PlatformUniChars, _PlatformLen * sizeof(UniChar));
+        len += _PlatformLen;
+        _CFAppendPathExtension(buff, &len, CFMaxPathSize, _InfoExtensionUniChars, _InfoExtensionLen);
+        cheapStr = CFStringCreateMutable(alloc, 0);
+        CFStringAppendCharacters(cheapStr, buff, len);
+        infoURL = CFURLCreateWithString(alloc, cheapStr, url);
+#if READ_DIRECTORIES
+        if (contents) {
+            CFIndex resourcesLen, idx;
+            for (resourcesLen = len; resourcesLen > 0; resourcesLen--) if (buff[resourcesLen - 1] == '/') break;
+            CFStringDelete(cheapStr, CFRangeMake(0, CFStringGetLength(cheapStr)));
+            CFStringAppendCharacters(cheapStr, buff + resourcesLen, len - resourcesLen);
+            for (tryPlatformSpecific = false, idx = 0; !tryPlatformSpecific && idx < contentsRange.length; idx++) {
+                // Need to do this case-insensitive to accommodate Palm
+                if (kCFCompareEqualTo == CFStringCompare(cheapStr, (CFStringRef)CFArrayGetValueAtIndex(contents, idx), kCFCompareCaseInsensitive)) tryPlatformSpecific = true;
+            }
+        }
+#endif /* READ_DIRECTORIES */    
+        if (tryPlatformSpecific) CFURLCreateDataAndPropertiesFromResource(alloc, infoURL, &infoData, NULL, NULL, NULL);
+        //fprintf(stderr, "looking for ");CFShow(infoURL);fprintf(stderr, infoData ? "found it\n" : (tryPlatformSpecific ? "missed it\n" : "skipped it\n"));
+        CFRelease(cheapStr);
+        if (!infoData) {
+            // Check for global Info.plist
+            CFRelease(infoURL);
+            infoURL = CFURLCreateWithString(alloc, infoURLFromBase, url);
+#if READ_DIRECTORIES
+            if (contents) {
+                CFIndex idx;
+                for (tryGlobal = false, idx = 0; !tryGlobal && idx < contentsRange.length; idx++) {
+                    // Need to do this case-insensitive to accommodate Palm
+                    if (kCFCompareEqualTo == CFStringCompare(_CFBundleInfoFileName, (CFStringRef)CFArrayGetValueAtIndex(contents, idx), kCFCompareCaseInsensitive)) tryGlobal = true;
+                }
+            }
+#endif /* READ_DIRECTORIES */    
+            if (tryGlobal) CFURLCreateDataAndPropertiesFromResource(alloc, infoURL, &infoData, NULL, NULL, NULL);
+            //fprintf(stderr, "looking for ");CFShow(infoURL);fprintf(stderr, infoData ? "found it\n" : (tryGlobal ? "missed it\n" : "skipped it\n"));
+        }
+        
+        if (infoData) {
+            result = (CFDictionaryRef)CFPropertyListCreateFromXMLData(alloc, infoData, kCFPropertyListMutableContainers, NULL);
+            if (result) {
+                if (CFDictionaryGetTypeID() == CFGetTypeID(result)) {
+                    CFDictionarySetValue((CFMutableDictionaryRef)result, _kCFBundleInfoPlistURLKey, infoURL);
+                } else {
+                    CFRelease(result);
+                    result = NULL;
+                }
+            }
+            if (!result) rawInfoURL = infoURL;
+            CFRelease(infoData);
+        }
+        if (!result) {
+            result = CFDictionaryCreateMutable(alloc, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+            if (rawInfoURL) CFDictionarySetValue((CFMutableDictionaryRef)result, _kCFBundleRawInfoPlistURLKey, rawInfoURL);
+        }
+
+        CFRelease(infoURL);
+#if READ_DIRECTORIES
+        if (contents) CFRelease(contents);
+#endif /* READ_DIRECTORIES */    
+    }
+    return result;
+}
+
+static Boolean _CFBundleGetPackageInfoInDirectoryWithInfoDictionary(CFAllocatorRef alloc, CFURLRef url, CFDictionaryRef infoDict, UInt32 *packageType, UInt32 *packageCreator) {
+    Boolean retVal = false, hasType = false, hasCreator = false, releaseInfoDict = false;
+    CFURLRef tempURL;
+    CFDataRef pkgInfoData = NULL;
+
+    // Check for a "real" new bundle
+    tempURL = CFURLCreateWithString(alloc, _CFBundlePkgInfoURLFromBase2, url);
+    CFURLCreateDataAndPropertiesFromResource(alloc, tempURL, &pkgInfoData, NULL, NULL, NULL);
+    CFRelease(tempURL);
+    if (!pkgInfoData) {
+        tempURL = CFURLCreateWithString(alloc, _CFBundlePkgInfoURLFromBase1, url);
+        CFURLCreateDataAndPropertiesFromResource(alloc, tempURL, &pkgInfoData, NULL, NULL, NULL);
+        CFRelease(tempURL);
+    }
+    if (!pkgInfoData) {
+        // Check for a "pseudo" new bundle
+        tempURL = CFURLCreateWithString(alloc, _CFBundlePseudoPkgInfoURLFromBase, url);
+        CFURLCreateDataAndPropertiesFromResource(alloc, tempURL, &pkgInfoData, NULL, NULL, NULL);
+        CFRelease(tempURL);
+    }
+
+    // Now, either we have a pkgInfoData or not.  If not, then is it because this is a new bundle without one (do we allow this?), or is it dbecause it is an old bundle.
+    // If we allow new bundles to not have a PkgInfo (because they already have the same data in the Info.plist), then we have to go read the info plist which makes failure expensive.
+    // drd: So we assume that a new bundle _must_ have a PkgInfo if they have this data at all, otherwise we manufacture it from the extension.
+    
+    if (pkgInfoData && CFDataGetLength(pkgInfoData) >= (int)(sizeof(UInt32) * 2)) {
+        UInt32 *pkgInfo = (UInt32 *)CFDataGetBytePtr(pkgInfoData);
+        if (packageType) *packageType = CFSwapInt32BigToHost(pkgInfo[0]);
+        if (packageCreator) *packageCreator = CFSwapInt32BigToHost(pkgInfo[1]);
+        retVal = hasType = hasCreator = true;
+    }
+    if (pkgInfoData) CFRelease(pkgInfoData);
+    if (!retVal) {
+        if (!infoDict) {
+            infoDict = _CFBundleCopyInfoDictionaryInDirectory(alloc, url, NULL);
+            releaseInfoDict = true;
+        }
+        if (infoDict) {
+            CFStringRef typeString = (CFStringRef)CFDictionaryGetValue(infoDict, _kCFBundlePackageTypeKey), creatorString = (CFStringRef)CFDictionaryGetValue(infoDict, _kCFBundleSignatureKey);
+            UInt32 tmp;
+            CFIndex usedBufLen = 0;
+            if (typeString && CFGetTypeID(typeString) == CFStringGetTypeID() && CFStringGetLength(typeString) == 4 && 4 == CFStringGetBytes(typeString, CFRangeMake(0, 4), kCFStringEncodingMacRoman, 0, false, (UInt8 *)&tmp, 4, &usedBufLen) && 4 == usedBufLen) {
+                if (packageType) *packageType = CFSwapInt32BigToHost(tmp);
+                retVal = hasType = true;
+            }
+            if (creatorString && CFGetTypeID(creatorString) == CFStringGetTypeID() && CFStringGetLength(creatorString) == 4 && 4 == CFStringGetBytes(creatorString, CFRangeMake(0, 4), kCFStringEncodingMacRoman, 0, false, (UInt8 *)&tmp, 4, &usedBufLen) && 4 == usedBufLen) {
+                if (packageCreator) *packageCreator = CFSwapInt32BigToHost(tmp);
+                retVal = hasCreator = true;
+            }
+            if (releaseInfoDict) CFRelease(infoDict);
+        }
+    }
+    if (!hasType || !hasCreator) {
+        // If this looks like a bundle then manufacture the type and creator.
+        if (retVal || _CFBundleURLLooksLikeBundle(url)) {
+            if (packageCreator && !hasCreator) *packageCreator = 0x3f3f3f3f;  // '????'
+            if (packageType && !hasType) {
+                CFStringRef urlStr;
+                UniChar buff[CFMaxPathSize];
+                CFIndex strLen, startOfExtension;
+                CFURLRef absoluteURL;
+                
+                // Detect "app", "debug", "profile", or "framework" extensions
+                absoluteURL = CFURLCopyAbsoluteURL(url);
+                urlStr = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+                CFRelease(absoluteURL);
+                strLen = CFStringGetLength(urlStr);
+                if (strLen > CFMaxPathSize) strLen = CFMaxPathSize;
+                CFStringGetCharacters(urlStr, CFRangeMake(0, strLen), buff);
+                CFRelease(urlStr);
+                startOfExtension = _CFStartOfPathExtension(buff, strLen);
+                if (((strLen - startOfExtension == 4) || (strLen - startOfExtension == 5)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'a') && (buff[startOfExtension+2] == (UniChar)'p') && (buff[startOfExtension+3] == (UniChar)'p') && ((strLen - startOfExtension == 4) || (buff[startOfExtension+4] == (UniChar)'/'))) {
+                    // This is an app
+                    *packageType = 0x4150504c;  // 'APPL'
+                } else if (((strLen - startOfExtension == 6) || (strLen - startOfExtension == 7)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'d') && (buff[startOfExtension+2] == (UniChar)'e') && (buff[startOfExtension+3] == (UniChar)'b') && (buff[startOfExtension+4] == (UniChar)'u') && (buff[startOfExtension+5] == (UniChar)'g') && ((strLen - startOfExtension == 6) || (buff[startOfExtension+6] == (UniChar)'/'))) {
+                    // This is an app (debug version)
+                    *packageType = 0x4150504c;  // 'APPL'
+                } else if (((strLen - startOfExtension == 8) || (strLen - startOfExtension == 9)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'p') && (buff[startOfExtension+2] == (UniChar)'r') && (buff[startOfExtension+3] == (UniChar)'o') && (buff[startOfExtension+4] == (UniChar)'f') && (buff[startOfExtension+5] == (UniChar)'i') && (buff[startOfExtension+6] == (UniChar)'l') && (buff[startOfExtension+7] == (UniChar)'e') && ((strLen - startOfExtension == 8) || (buff[startOfExtension+8] == (UniChar)'/'))) {
+                    // This is an app (profile version)
+                    *packageType = 0x4150504c;  // 'APPL'
+                } else if (((strLen - startOfExtension == 8) || (strLen - startOfExtension == 9)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'s') && (buff[startOfExtension+2] == (UniChar)'e') && (buff[startOfExtension+3] == (UniChar)'r') && (buff[startOfExtension+4] == (UniChar)'v') && (buff[startOfExtension+5] == (UniChar)'i') && (buff[startOfExtension+6] == (UniChar)'c') && (buff[startOfExtension+7] == (UniChar)'e') && ((strLen - startOfExtension == 8) || (buff[startOfExtension+8] == (UniChar)'/'))) {
+                    // This is a service
+                    *packageType = 0x4150504c;  // 'APPL'
+                } else if (((strLen - startOfExtension == 10) || (strLen - startOfExtension == 11)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'f') && (buff[startOfExtension+2] == (UniChar)'r') && (buff[startOfExtension+3] == (UniChar)'a') && (buff[startOfExtension+4] == (UniChar)'m') && (buff[startOfExtension+5] == (UniChar)'e') && (buff[startOfExtension+6] == (UniChar)'w') && (buff[startOfExtension+7] == (UniChar)'o') && (buff[startOfExtension+8] == (UniChar)'r') && (buff[startOfExtension+9] == (UniChar)'k') && ((strLen - startOfExtension == 10) || (buff[startOfExtension+10] == (UniChar)'/'))) {
+                    // This is a framework
+                    *packageType = 0x464d574b;  // 'FMWK'
+                } else {
+                    // Default to BNDL for generic bundle
+                    *packageType = 0x424e444c;  // 'BNDL'
+                }
+            }
+            retVal = true;
+        }
+    }
+    return retVal;
+}
+
+CF_EXPORT Boolean _CFBundleGetPackageInfoInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt32 *packageType, UInt32 *packageCreator) {return _CFBundleGetPackageInfoInDirectoryWithInfoDictionary(alloc, url, NULL, packageType, packageCreator);}
+
+CF_EXPORT void CFBundleGetPackageInfo(CFBundleRef bundle, UInt32 *packageType, UInt32 *packageCreator) {
+    CFURLRef bundleURL = CFBundleCopyBundleURL(bundle);
+    if (!_CFBundleGetPackageInfoInDirectoryWithInfoDictionary(CFGetAllocator(bundle), bundleURL, CFBundleGetInfoDictionary(bundle), packageType, packageCreator)) {
+        if (packageType) *packageType = 0x424e444c;  // 'BNDL'
+        if (packageCreator) *packageCreator = 0x3f3f3f3f;  // '????'
+    }
+    if (bundleURL) CFRelease(bundleURL);
+}
+
+CF_EXPORT Boolean CFBundleGetPackageInfoInDirectory(CFURLRef url, UInt32 *packageType, UInt32 *packageCreator) {return _CFBundleGetPackageInfoInDirectory(kCFAllocatorSystemDefault, url, packageType, packageCreator);}
+
+__private_extern__ CFStringRef _CFBundleGetPlatformExecutablesSubdirectoryName(void) {
+#if DEPLOYMENT_TARGET_MACOSX
+    return CFSTR("MacOS");
+#elif DEPLOYMENT_TARGET_SOLARIS
+    return CFSTR("Solaris");
+#elif DEPLOYMENT_TARGET_HPUX
+    return CFSTR("HPUX");
+#elif DEPLOYMENT_TARGET_LINUX
+    return CFSTR("Linux");
+#elif DEPLOYMENT_TARGET_FREEBSD
+    return CFSTR("FreeBSD");
+#elif DEPLOYMENT_TARGET_WINDOWS
+    return CFSTR("Windows");
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+}
+
+__private_extern__ CFStringRef _CFBundleGetAlternatePlatformExecutablesSubdirectoryName(void) {
+#if DEPLOYMENT_TARGET_MACOSX
+    return CFSTR("Mac OS X");
+#elif DEPLOYMENT_TARGET_SOLARIS
+    return CFSTR("Solaris");
+#elif DEPLOYMENT_TARGET_HPUX
+    return CFSTR("HP-UX");
+#elif DEPLOYMENT_TARGET_LINUX
+    return CFSTR("Linux");
+#elif DEPLOYMENT_TARGET_FREEBSD
+    return CFSTR("FreeBSD");
+#elif DEPLOYMENT_TARGET_WINDOWS
+    return CFSTR("Windows");
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+}
+
+__private_extern__ CFStringRef _CFBundleGetOtherPlatformExecutablesSubdirectoryName(void) {
+#if DEPLOYMENT_TARGET_MACOSX
+    return CFSTR("MacOSClassic");
+#elif DEPLOYMENT_TARGET_HPUX
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_SOLARIS
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_LINUX
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_FREEBSD
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_WINDOWS
+    return CFSTR("Other");
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+}
+
+__private_extern__ CFStringRef _CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName(void) {
+#if DEPLOYMENT_TARGET_MACOSX
+    return CFSTR("Mac OS 8");
+#elif DEPLOYMENT_TARGET_HPUX
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_SOLARIS
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_LINUX
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_FREEBSD
+    return CFSTR("Other");
+#elif DEPLOYMENT_TARGET_WINDOWS
+    return CFSTR("Other");
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+}
+
+__private_extern__ CFArrayRef _CFBundleCopyBundleRegionsArray(CFBundleRef bundle) {return CFBundleCopyBundleLocalizations(bundle);}
+
+CF_EXPORT CFArrayRef CFBundleCopyBundleLocalizations(CFBundleRef bundle) {
+    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
+#if READ_DIRECTORIES
+    CFURLRef absoluteURL;
+    CFStringRef directoryPath;
+    CFArrayRef contents;
+    CFRange contentsRange;
+    CFIndex idx;
+#else /* READ_DIRECTORIES */
+    CFArrayRef urls = ((_CFBundleLayoutVersion(bundle) != 4) ? _CFContentsOfDirectory(CFGetAllocator(bundle), NULL, NULL, resourcesURL, _CFBundleLprojExtension) : NULL);
+#endif /* READ_DIRECTORIES */
+    CFArrayRef predefinedLocalizations = NULL;
+    CFMutableArrayRef result = NULL;
+
+    if (infoDict) {
+        predefinedLocalizations = (CFArrayRef)CFDictionaryGetValue(infoDict, kCFBundleLocalizationsKey);
+        if (predefinedLocalizations && CFGetTypeID(predefinedLocalizations) != CFArrayGetTypeID()) {
+            predefinedLocalizations = NULL;
+            CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, kCFBundleLocalizationsKey);
+        }
+        if (predefinedLocalizations) {
+            CFIndex i, c = CFArrayGetCount(predefinedLocalizations);
+            if (c > 0 && !result) result = CFArrayCreateMutable(CFGetAllocator(bundle), 0, &kCFTypeArrayCallBacks);
+            for (i = 0; i < c; i++) CFArrayAppendValue(result, CFArrayGetValueAtIndex(predefinedLocalizations, i));
+        }
+    }
+
+#if READ_DIRECTORIES
+    if (resourcesURL) {
+        absoluteURL = CFURLCopyAbsoluteURL(resourcesURL);
+        directoryPath = CFURLCopyFileSystemPath(absoluteURL, PLATFORM_PATH_STYLE);
+        contents = _CFBundleCopyDirectoryContentsAtPath(directoryPath, _CFBundleAllContents);
+        contentsRange = CFRangeMake(0, CFArrayGetCount(contents));
+        for (idx = 0; idx < contentsRange.length; idx++) {
+            CFStringRef name = (CFStringRef)CFArrayGetValueAtIndex(contents, idx);
+            if (CFStringHasSuffix(name, _CFBundleLprojExtensionWithDot)) {
+                CFStringRef localization = CFStringCreateWithSubstring(kCFAllocatorSystemDefault, name, CFRangeMake(0, CFStringGetLength(name) - 6));
+                if (!result) result = CFArrayCreateMutable(CFGetAllocator(bundle), 0, &kCFTypeArrayCallBacks);
+                CFArrayAppendValue(result, localization);
+                CFRelease(localization);
+            }
+        }
+        CFRelease(contents);
+        CFRelease(directoryPath);
+        CFRelease(absoluteURL);
+    }
+#else /* READ_DIRECTORIES */
+    if (urls) {
+        CFIndex i, c = CFArrayGetCount(urls);
+        CFURLRef curURL, curAbsoluteURL;
+        CFStringRef curStr, regionStr;
+        UniChar buff[CFMaxPathSize];
+        CFIndex strLen, startOfLastPathComponent, regionLen;
+
+        if (c > 0 && !result) result = CFArrayCreateMutable(CFGetAllocator(bundle), 0, &kCFTypeArrayCallBacks);
+        for (i = 0; i < c; i++) {
+            curURL = (CFURLRef)CFArrayGetValueAtIndex(urls, i);
+            curAbsoluteURL = CFURLCopyAbsoluteURL(curURL);
+            curStr = CFURLCopyFileSystemPath(curAbsoluteURL, PLATFORM_PATH_STYLE);
+            CFRelease(curAbsoluteURL);
+            strLen = CFStringGetLength(curStr);
+            if (strLen > CFMaxPathSize) strLen = CFMaxPathSize;
+            CFStringGetCharacters(curStr, CFRangeMake(0, strLen), buff);
+
+            startOfLastPathComponent = _CFStartOfLastPathComponent(buff, strLen);
+            regionLen = _CFLengthAfterDeletingPathExtension(&(buff[startOfLastPathComponent]), strLen - startOfLastPathComponent);
+            regionStr = CFStringCreateWithCharacters(CFGetAllocator(bundle), &(buff[startOfLastPathComponent]), regionLen);
+            CFArrayAppendValue(result, regionStr);
+            CFRelease(regionStr);
+            CFRelease(curStr);
+        }
+        CFRelease(urls);
+    }
+#endif /* READ_DIRECTORIES */
+    
+    if (!result) {
+        CFStringRef developmentLocalization = CFBundleGetDevelopmentRegion(bundle);
+        if (developmentLocalization) {
+            result = CFArrayCreateMutable(CFGetAllocator(bundle), 0, &kCFTypeArrayCallBacks);
+            CFArrayAppendValue(result, developmentLocalization);
+        }
+    }
+    if (resourcesURL) CFRelease(resourcesURL);
+
+    return result;
+}
+
+
+CF_EXPORT CFDictionaryRef CFBundleCopyInfoDictionaryForURL(CFURLRef url) {
+    CFDictionaryRef result = NULL;
+    Boolean isDir = false;
+    if (_CFIsResourceAtURL(url, &isDir)) {
+        if (isDir) {
+            result = _CFBundleCopyInfoDictionaryInDirectory(kCFAllocatorSystemDefault, url, NULL);
+        } else {
+            result = _CFBundleCopyInfoDictionaryInExecutable(url);
+        }
+    }
+    return result;
+}
+
+CFArrayRef CFBundleCopyExecutableArchitecturesForURL(CFURLRef url) {
+    CFArrayRef result = NULL;
+    CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, url);
+    if (bundle) {
+        result = CFBundleCopyExecutableArchitectures(bundle);
+        CFRelease(bundle);
+    } else {
+        result = _CFBundleCopyArchitecturesForExecutable(url);
+    }
+    return result;
+}
+
+CFArrayRef CFBundleCopyLocalizationsForURL(CFURLRef url) {
+    CFArrayRef result = NULL;
+    CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, url);
+    CFStringRef devLang = NULL;
+    if (bundle) {
+        result = CFBundleCopyBundleLocalizations(bundle);
+        CFRelease(bundle);
+    } else {
+        CFDictionaryRef infoDict = _CFBundleCopyInfoDictionaryInExecutable(url);
+        if (infoDict) {
+            CFArrayRef predefinedLocalizations = (CFArrayRef)CFDictionaryGetValue(infoDict, kCFBundleLocalizationsKey);
+            if (predefinedLocalizations && CFGetTypeID(predefinedLocalizations) == CFArrayGetTypeID()) result = (CFArrayRef)CFRetain(predefinedLocalizations);
+            if (!result) {
+                devLang = (CFStringRef)CFDictionaryGetValue(infoDict, kCFBundleDevelopmentRegionKey);
+                if (devLang && (CFGetTypeID(devLang) == CFStringGetTypeID() && CFStringGetLength(devLang) > 0)) result = CFArrayCreate(kCFAllocatorSystemDefault, (const void **)&devLang, 1, &kCFTypeArrayCallBacks);
+            }
+            CFRelease(infoDict);
+        }
+    }
+    return result;
+}
diff --git a/CoreFoundation/CFByteOrder.h b/CoreFoundation/CFByteOrder.h
new file mode 100644
index 0000000..7172cbb
--- /dev/null
+++ b/CoreFoundation/CFByteOrder.h
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFBYTEORDER__)
+#define __COREFOUNDATION_CFBYTEORDER__ 1
+
+#include <CoreFoundation/CFBase.h>
+#if defined(__MACH__) && !defined(CF_USE_OSBYTEORDER_H)
+#include <libkern/OSByteOrder.h>
+#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/CoreFoundation/CFCalendar.c b/CoreFoundation/CFCalendar.c
new file mode 100644
index 0000000..796200b
--- /dev/null
+++ b/CoreFoundation/CFCalendar.c
@@ -0,0 +1,1079 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 2004-2004, Apple Computer, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFCalendar.h>
+#include <CoreFoundation/CFRuntime.h>
+#include "CFInternal.h"
+#include "CFPriv.h"
+#include <unicode/ucal.h>
+
+#define BUFFER_SIZE 512
+
+struct __CFCalendar {
+    CFRuntimeBase _base;
+    CFStringRef _identifier;	// canonical identifier, never NULL
+    CFLocaleRef _locale;
+    CFStringRef _localeID;
+    CFTimeZoneRef _tz;
+    UCalendar *_cal;
+};
+
+static Boolean __CFCalendarEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFCalendarRef calendar1 = (CFCalendarRef)cf1;
+    CFCalendarRef calendar2 = (CFCalendarRef)cf2;
+    return CFEqual(calendar1->_identifier, calendar2->_identifier);
+}
+
+static CFHashCode __CFCalendarHash(CFTypeRef cf) {
+    CFCalendarRef calendar = (CFCalendarRef)cf;
+    return CFHash(calendar->_identifier);
+}
+
+static CFStringRef __CFCalendarCopyDescription(CFTypeRef cf) {
+    CFCalendarRef calendar = (CFCalendarRef)cf;
+    return CFStringCreateWithFormat(CFGetAllocator(calendar), NULL, CFSTR("<CFCalendar %p [%p]>{identifier = '%@'}"), cf, CFGetAllocator(calendar), calendar->_identifier);
+}
+
+static void __CFCalendarDeallocate(CFTypeRef cf) {
+    CFCalendarRef calendar = (CFCalendarRef)cf;
+    CFRelease(calendar->_identifier);
+    if (calendar->_locale) CFRelease(calendar->_locale);
+    if (calendar->_localeID) CFRelease(calendar->_localeID);
+    CFRelease(calendar->_tz);
+    if (calendar->_cal) ucal_close(calendar->_cal);
+}
+
+static CFTypeID __kCFCalendarTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFCalendarClass = {
+    0,
+    "CFCalendar",
+    NULL,	// init
+    NULL,	// copy
+    __CFCalendarDeallocate,
+    __CFCalendarEqual,
+    __CFCalendarHash,
+    NULL,	// 
+    __CFCalendarCopyDescription
+};
+
+static void __CFCalendarInitialize(void) {
+    __kCFCalendarTypeID = _CFRuntimeRegisterClass(&__CFCalendarClass);
+}
+
+CFTypeID CFCalendarGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFCalendarTypeID) __CFCalendarInitialize();
+    return __kCFCalendarTypeID;
+}
+
+__private_extern__ UCalendar *__CFCalendarCreateUCalendar(CFStringRef calendarID, CFStringRef localeID, CFTimeZoneRef tz) {
+    if (calendarID) {
+	CFDictionaryRef components = CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorSystemDefault, localeID);
+	CFMutableDictionaryRef mcomponents = CFDictionaryCreateMutableCopy(kCFAllocatorSystemDefault, 0, components);
+	CFDictionarySetValue(mcomponents, kCFLocaleCalendarIdentifier, calendarID);
+	localeID = CFLocaleCreateLocaleIdentifierFromComponents(kCFAllocatorSystemDefault, mcomponents);
+	CFRelease(mcomponents);
+	CFRelease(components);
+    }
+
+    char buffer[BUFFER_SIZE];
+    const char *cstr = CFStringGetCStringPtr(localeID, kCFStringEncodingASCII);
+    if (NULL == cstr) {
+	if (CFStringGetCString(localeID, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;
+    }
+    if (NULL == cstr) {
+	if (calendarID) CFRelease(localeID);
+	return NULL;
+    }
+    
+    UChar ubuffer[BUFFER_SIZE];
+    CFStringRef tznam = CFTimeZoneGetName(tz);
+    CFIndex cnt = CFStringGetLength(tznam);
+    if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+    CFStringGetCharacters(tznam, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+
+    UErrorCode status = U_ZERO_ERROR;
+    UCalendar *cal = ucal_open(ubuffer, cnt, cstr, UCAL_TRADITIONAL, &status);
+    if (calendarID) CFRelease(localeID);
+    return cal;
+}
+
+static void __CFCalendarSetupCal(CFCalendarRef calendar) {
+    calendar->_cal = __CFCalendarCreateUCalendar(calendar->_identifier, calendar->_localeID, calendar->_tz);
+}
+
+static void __CFCalendarZapCal(CFCalendarRef calendar) {
+    ucal_close(calendar->_cal);
+    calendar->_cal = NULL;
+}
+
+CFCalendarRef CFCalendarCopyCurrent(void) {
+    CFLocaleRef locale = CFLocaleCopyCurrent();
+    CFCalendarRef calID = (CFCalendarRef)CFLocaleGetValue(locale, kCFLocaleCalendarIdentifier);
+    if (calID) {
+        CFCalendarRef calendar = CFCalendarCreateWithIdentifier(kCFAllocatorSystemDefault, (CFStringRef)calID);
+        CFCalendarSetLocale(calendar, locale);
+	CFRelease(locale);
+        return calendar;
+    }
+    return NULL;
+}
+
+CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringRef identifier) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(identifier, CFStringGetTypeID());
+    // return NULL until Chinese calendar is available
+    if (identifier != kCFGregorianCalendar && identifier != kCFBuddhistCalendar && identifier != kCFJapaneseCalendar && identifier != kCFIslamicCalendar && identifier != kCFIslamicCivilCalendar && identifier != kCFHebrewCalendar) {
+//    if (identifier != kCFGregorianCalendar && identifier != kCFBuddhistCalendar && identifier != kCFJapaneseCalendar && identifier != kCFIslamicCalendar && identifier != kCFIslamicCivilCalendar && identifier != kCFHebrewCalendar && identifier != kCFChineseCalendar) {
+	if (CFEqual(kCFGregorianCalendar, identifier)) identifier = kCFGregorianCalendar;
+	else if (CFEqual(kCFBuddhistCalendar, identifier)) identifier = kCFBuddhistCalendar;
+	else if (CFEqual(kCFJapaneseCalendar, identifier)) identifier = kCFJapaneseCalendar;
+	else if (CFEqual(kCFIslamicCalendar, identifier)) identifier = kCFIslamicCalendar;
+	else if (CFEqual(kCFIslamicCivilCalendar, identifier)) identifier = kCFIslamicCivilCalendar;
+	else if (CFEqual(kCFHebrewCalendar, identifier)) identifier = kCFHebrewCalendar;
+//	else if (CFEqual(kCFChineseCalendar, identifier)) identifier = kCFChineseCalendar;
+	else return NULL;
+    }
+    struct __CFCalendar *calendar = NULL;
+    uint32_t size = sizeof(struct __CFCalendar) - sizeof(CFRuntimeBase);
+    calendar = (struct __CFCalendar *)_CFRuntimeCreateInstance(allocator, CFCalendarGetTypeID(), size, NULL);
+    if (NULL == calendar) {
+	return NULL;
+    }
+    calendar->_identifier = (CFStringRef)CFRetain(identifier);
+    calendar->_locale = NULL;
+    calendar->_localeID = CFLocaleGetIdentifier(CFLocaleGetSystem());
+    calendar->_tz = CFTimeZoneCopyDefault();
+    calendar->_cal = NULL;
+    return (CFCalendarRef)calendar;
+}
+
+CFStringRef CFCalendarGetIdentifier(CFCalendarRef calendar) {
+    CF_OBJC_FUNCDISPATCH0(CFCalendarGetTypeID(), CFStringRef, calendar, "calendarIdentifier");
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    return calendar->_identifier;
+}
+
+CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar) {
+    CF_OBJC_FUNCDISPATCH0(CFCalendarGetTypeID(), CFLocaleRef, calendar, "_copyLocale");
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    return (CFLocaleRef)CFLocaleCreate(kCFAllocatorSystemDefault, calendar->_localeID);
+}
+
+void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale) {
+    CF_OBJC_FUNCDISPATCH1(CFCalendarGetTypeID(), void, calendar, "setLocale:", locale);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    __CFGenericValidateType(locale, CFLocaleGetTypeID());
+    CFStringRef localeID = CFLocaleGetIdentifier(locale);
+    if (localeID != calendar->_localeID) {
+	CFRelease(calendar->_localeID);
+	CFRetain(localeID);
+	calendar->_localeID = localeID;
+        if (calendar->_cal) __CFCalendarZapCal(calendar);
+    }
+}
+
+CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar) {
+    CF_OBJC_FUNCDISPATCH0(CFCalendarGetTypeID(), CFTimeZoneRef, calendar, "_copyTimeZone");
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    return (CFTimeZoneRef)CFRetain(calendar->_tz);
+}
+
+void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz) {
+    CF_OBJC_FUNCDISPATCH1(CFCalendarGetTypeID(), void, calendar, "setTimeZone:", tz);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (tz) __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    if (tz != calendar->_tz) {
+	CFRelease(calendar->_tz);
+	calendar->_tz = tz ? (CFTimeZoneRef)CFRetain(tz) : CFTimeZoneCopyDefault();
+        if (calendar->_cal) __CFCalendarZapCal(calendar);
+    }
+}
+
+CFIndex CFCalendarGetFirstWeekday(CFCalendarRef calendar) {
+    CF_OBJC_FUNCDISPATCH0(CFCalendarGetTypeID(), CFIndex, calendar, "firstWeekday");
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	return ucal_getAttribute(calendar->_cal, UCAL_FIRST_DAY_OF_WEEK);
+    }
+    return -1;
+}
+
+void CFCalendarSetFirstWeekday(CFCalendarRef calendar, CFIndex wkdy) {
+    CF_OBJC_FUNCDISPATCH1(CFCalendarGetTypeID(), void, calendar, "setFirstWeekday:", wkdy);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	ucal_setAttribute(calendar->_cal, UCAL_FIRST_DAY_OF_WEEK, wkdy);
+    }
+}
+
+CFIndex CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar) {
+    CF_OBJC_FUNCDISPATCH0(CFCalendarGetTypeID(), CFIndex, calendar, "minimumDaysInFirstWeek");
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    return calendar->_cal ? ucal_getAttribute(calendar->_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK) : -1;
+}
+
+void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, CFIndex mwd) {
+    CF_OBJC_FUNCDISPATCH1(CFCalendarGetTypeID(), void, calendar, "setMinimumDaysInFirstWeek:", mwd);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) ucal_setAttribute(calendar->_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, mwd);
+}
+
+CFDateRef CFCalendarCopyGregorianStartDate(CFCalendarRef calendar) {
+    CF_OBJC_FUNCDISPATCH0(CFCalendarGetTypeID(), CFDateRef, calendar, "_gregorianStartDate");
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    UErrorCode status = U_ZERO_ERROR;
+    UDate udate = calendar->_cal ? ucal_getGregorianChange(calendar->_cal, &status) : 0;
+    if (calendar->_cal && U_SUCCESS(status)) {
+	CFAbsoluteTime at = (double)udate / 1000.0 - kCFAbsoluteTimeIntervalSince1970;
+	return CFDateCreate(CFGetAllocator(calendar), at);
+    }
+    return NULL;
+}
+
+void CFCalendarSetGregorianStartDate(CFCalendarRef calendar, CFDateRef date) {
+    CF_OBJC_FUNCDISPATCH1(CFCalendarGetTypeID(), void, calendar, "_setGregorianStartDate:", date);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (date) __CFGenericValidateType(date, CFDateGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (!calendar->_cal) return;
+    if (!date) {
+	UErrorCode status = U_ZERO_ERROR;
+	UCalendar *cal = __CFCalendarCreateUCalendar(calendar->_identifier, calendar->_localeID, calendar->_tz);
+	UDate udate = cal ? ucal_getGregorianChange(cal, &status) : 0;
+	if (cal && U_SUCCESS(status)) {
+	    status = U_ZERO_ERROR;
+	    if (calendar->_cal) ucal_setGregorianChange(calendar->_cal, udate, &status);
+	}
+	if (cal) ucal_close(cal);
+    } else {
+	CFAbsoluteTime at = CFDateGetAbsoluteTime(date);
+	UDate udate = (at + kCFAbsoluteTimeIntervalSince1970) * 1000.0;
+	UErrorCode status = U_ZERO_ERROR;
+	if (calendar->_cal) ucal_setGregorianChange(calendar->_cal, udate, &status);
+    }
+}
+
+
+static UCalendarDateFields __CFCalendarGetICUFieldCode(CFCalendarUnit unit) {
+    switch (unit) {
+    case kCFCalendarUnitEra: return UCAL_ERA;
+    case kCFCalendarUnitYear: return UCAL_YEAR;
+    case kCFCalendarUnitMonth: return UCAL_MONTH;
+    case kCFCalendarUnitDay: return UCAL_DAY_OF_MONTH;
+    case kCFCalendarUnitHour: return UCAL_HOUR_OF_DAY;
+    case kCFCalendarUnitMinute: return UCAL_MINUTE;
+    case kCFCalendarUnitSecond: return UCAL_SECOND;
+    case kCFCalendarUnitWeek: return UCAL_WEEK_OF_YEAR;
+    case kCFCalendarUnitWeekday: return UCAL_DAY_OF_WEEK;
+    case kCFCalendarUnitWeekdayOrdinal: return UCAL_DAY_OF_WEEK_IN_MONTH;
+    }
+    return (UCalendarDateFields)-1;
+}
+
+static UCalendarDateFields __CFCalendarGetICUFieldCodeFromChar(char ch) {
+    switch (ch) {
+    case 'G': return UCAL_ERA;
+    case 'y': return UCAL_YEAR;
+    case 'M': return UCAL_MONTH;
+    case 'd': return UCAL_DAY_OF_MONTH;
+    case 'h': return UCAL_HOUR;
+    case 'H': return UCAL_HOUR_OF_DAY;
+    case 'm': return UCAL_MINUTE;
+    case 's': return UCAL_SECOND;
+    case 'S': return UCAL_MILLISECOND;
+    case 'w': return UCAL_WEEK_OF_YEAR;
+    case 'W': return UCAL_WEEK_OF_MONTH;
+    case 'E': return UCAL_DAY_OF_WEEK;
+    case 'D': return UCAL_DAY_OF_YEAR;
+    case 'F': return UCAL_DAY_OF_WEEK_IN_MONTH;
+    case 'a': return UCAL_AM_PM;
+    case 'g': return UCAL_JULIAN_DAY;
+    }
+    return (UCalendarDateFields)-1;
+}
+
+static UCalendarDateFields __CFCalendarGetCalendarUnitFromChar(char ch) {
+    switch (ch) {
+    case 'G': return (UCalendarDateFields)kCFCalendarUnitEra;
+    case 'y': return (UCalendarDateFields)kCFCalendarUnitYear;
+    case 'M': return (UCalendarDateFields)kCFCalendarUnitMonth;
+    case 'd': return (UCalendarDateFields)kCFCalendarUnitDay;
+    case 'H': return (UCalendarDateFields)kCFCalendarUnitHour;
+    case 'm': return (UCalendarDateFields)kCFCalendarUnitMinute;
+    case 's': return (UCalendarDateFields)kCFCalendarUnitSecond;
+    case 'w': return (UCalendarDateFields)kCFCalendarUnitWeek;
+    case 'E': return (UCalendarDateFields)kCFCalendarUnitWeekday;
+    case 'F': return (UCalendarDateFields)kCFCalendarUnitWeekdayOrdinal;
+    }
+    return (UCalendarDateFields)-1;
+}
+
+CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit) {
+    CF_OBJC_FUNCDISPATCH1(CFCalendarGetTypeID(), CFRange, calendar, "_minimumRangeOfUnit:", unit);
+    CFRange range = {kCFNotFound, kCFNotFound};
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	ucal_clear(calendar->_cal);
+	UCalendarDateFields field = __CFCalendarGetICUFieldCode(unit);
+	UErrorCode status = U_ZERO_ERROR;
+	range.location = ucal_getLimit(calendar->_cal, field, UCAL_GREATEST_MINIMUM, &status);
+	range.length = ucal_getLimit(calendar->_cal, field, UCAL_LEAST_MAXIMUM, &status) - range.location + 1;
+	if (UCAL_MONTH == field) range.location++;
+	if (100000 < range.length) range.length = 100000;
+    }
+    return range;
+}
+
+CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit) {
+    CF_OBJC_FUNCDISPATCH1(CFCalendarGetTypeID(), CFRange, calendar, "_maximumRangeOfUnit:", unit);
+    CFRange range = {kCFNotFound, kCFNotFound};
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	ucal_clear(calendar->_cal);
+	UCalendarDateFields field = __CFCalendarGetICUFieldCode(unit);
+	UErrorCode status = U_ZERO_ERROR;
+	range.location = ucal_getLimit(calendar->_cal, field, UCAL_MINIMUM, &status);
+	range.length = ucal_getLimit(calendar->_cal, field, UCAL_MAXIMUM, &status) - range.location + 1;
+	if (UCAL_MONTH == field) range.location++;
+	if (100000 < range.length) range.length = 100000;
+    }
+    return range;
+}
+
+static void __CFCalendarSetToFirstInstant(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at) {
+    // Set UCalendar to first instant of unit prior to 'at'
+    UErrorCode status = U_ZERO_ERROR;
+    UDate udate = floor((at + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+    ucal_setMillis(calendar->_cal, udate, &status);
+    int target_era = INT_MIN;
+    switch (unit) { // largest to smallest, we set the fields to their minimum value
+    case kCFCalendarUnitWeek:
+	{
+	// reduce to first day of week, then reduce the rest of the day
+        int32_t goal = ucal_getAttribute(calendar->_cal, UCAL_FIRST_DAY_OF_WEEK);
+	int32_t dow = ucal_get(calendar->_cal, UCAL_DAY_OF_WEEK, &status);
+	while (dow != goal) {
+	    ucal_add(calendar->_cal, UCAL_DAY_OF_MONTH, -1, &status);
+	    dow = ucal_get(calendar->_cal, UCAL_DAY_OF_WEEK, &status);
+	}
+	goto day;
+	}
+    case kCFCalendarUnitEra:
+	{
+	target_era = ucal_get(calendar->_cal, UCAL_ERA, &status);
+	ucal_set(calendar->_cal, UCAL_YEAR, ucal_getLimit(calendar->_cal, UCAL_YEAR, UCAL_ACTUAL_MINIMUM, &status));
+	}
+    case kCFCalendarUnitYear:
+	ucal_set(calendar->_cal, UCAL_MONTH, ucal_getLimit(calendar->_cal, UCAL_MONTH, UCAL_ACTUAL_MINIMUM, &status));
+    case kCFCalendarUnitMonth:
+	ucal_set(calendar->_cal, UCAL_DAY_OF_MONTH, ucal_getLimit(calendar->_cal, UCAL_DAY_OF_MONTH, UCAL_ACTUAL_MINIMUM, &status));
+    case kCFCalendarUnitWeekday:
+    case kCFCalendarUnitDay:
+    day:;
+	ucal_set(calendar->_cal, UCAL_HOUR_OF_DAY, ucal_getLimit(calendar->_cal, UCAL_HOUR_OF_DAY, UCAL_ACTUAL_MINIMUM, &status));
+    case kCFCalendarUnitHour:
+	ucal_set(calendar->_cal, UCAL_MINUTE, ucal_getLimit(calendar->_cal, UCAL_MINUTE, UCAL_ACTUAL_MINIMUM, &status));
+    case kCFCalendarUnitMinute:
+	ucal_set(calendar->_cal, UCAL_SECOND, ucal_getLimit(calendar->_cal, UCAL_SECOND, UCAL_ACTUAL_MINIMUM, &status));
+    case kCFCalendarUnitSecond:
+	ucal_set(calendar->_cal, UCAL_MILLISECOND, 0);
+    }
+    if (INT_MIN != target_era && ucal_get(calendar->_cal, UCAL_ERA, &status) < target_era) {
+	// In the Japanese calendar, and possibly others, eras don't necessarily
+	// start on the first day of a year, so the previous code may have backed
+	// up into the previous era, and we have to correct forward.
+	UDate bad_udate = ucal_getMillis(calendar->_cal, &status);
+	ucal_add(calendar->_cal, UCAL_MONTH, 1, &status);
+	while (ucal_get(calendar->_cal, UCAL_ERA, &status) < target_era) {
+	    bad_udate = ucal_getMillis(calendar->_cal, &status);
+	    ucal_add(calendar->_cal, UCAL_MONTH, 1, &status);
+	}
+	udate = ucal_getMillis(calendar->_cal, &status);
+	// target date is between bad_udate and udate
+	for (;;) {
+	    UDate test_udate = (udate + bad_udate) / 2;
+	    ucal_setMillis(calendar->_cal, test_udate, &status);
+	    if (ucal_get(calendar->_cal, UCAL_ERA, &status) < target_era) {
+		bad_udate = test_udate;
+	    } else {
+		udate = test_udate;
+	    }
+	    if (fabs(udate - bad_udate) < 1000) break;
+	}
+	do {
+	    bad_udate = floor((bad_udate + 1000) / 1000) * 1000;
+	    ucal_setMillis(calendar->_cal, bad_udate, &status);
+	} while (ucal_get(calendar->_cal, UCAL_ERA, &status) < target_era);
+    }
+}
+
+static Boolean __validUnits(CFCalendarUnit smaller, CFCalendarUnit bigger) {
+    switch (bigger) {
+    case kCFCalendarUnitEra:
+	if (kCFCalendarUnitEra == smaller) return false;
+	if (kCFCalendarUnitWeekday == smaller) return false;
+	if (kCFCalendarUnitMinute == smaller) return false;	// this causes CFIndex overflow in range.length
+	if (kCFCalendarUnitSecond == smaller) return false;	// this causes CFIndex overflow in range.length
+	return true;
+    case kCFCalendarUnitYear:
+	if (kCFCalendarUnitEra == smaller) return false;
+	if (kCFCalendarUnitYear == smaller) return false;
+	if (kCFCalendarUnitWeekday == smaller) return false;
+	return true;
+    case kCFCalendarUnitMonth:
+	if (kCFCalendarUnitEra == smaller) return false;
+	if (kCFCalendarUnitYear == smaller) return false;
+	if (kCFCalendarUnitMonth == smaller) return false;
+	if (kCFCalendarUnitWeekday == smaller) return false;
+	return true;
+    case kCFCalendarUnitDay:
+	if (kCFCalendarUnitHour == smaller) return true;
+	if (kCFCalendarUnitMinute == smaller) return true;
+	if (kCFCalendarUnitSecond == smaller) return true;
+	return false;
+    case kCFCalendarUnitHour:
+	if (kCFCalendarUnitMinute == smaller) return true;
+	if (kCFCalendarUnitSecond == smaller) return true;
+	return false;
+    case kCFCalendarUnitMinute:
+	if (kCFCalendarUnitSecond == smaller) return true;
+	return false;
+    case kCFCalendarUnitWeek:
+	if (kCFCalendarUnitWeekday == smaller) return true;
+	if (kCFCalendarUnitDay == smaller) return true;
+	if (kCFCalendarUnitHour == smaller) return true;
+	if (kCFCalendarUnitMinute == smaller) return true;
+	if (kCFCalendarUnitSecond == smaller) return true;
+	return false;
+    case kCFCalendarUnitSecond:
+    case kCFCalendarUnitWeekday:
+    case kCFCalendarUnitWeekdayOrdinal:
+	return false;
+    }
+    return false;
+};
+
+static CFRange __CFCalendarGetRangeOfUnit1(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at) {
+    CFRange range = {kCFNotFound, kCFNotFound};
+    if (!__validUnits(smallerUnit, biggerUnit)) return range;
+    CF_OBJC_FUNCDISPATCH3(CFCalendarGetTypeID(), CFRange, calendar, "_rangeOfUnit:inUnit:forAT:", smallerUnit, biggerUnit, at);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	int32_t dow = -1;
+	ucal_clear(calendar->_cal);
+	UCalendarDateFields smallField = __CFCalendarGetICUFieldCode(smallerUnit);
+	UCalendarDateFields bigField = __CFCalendarGetICUFieldCode(biggerUnit);
+	if (kCFCalendarUnitWeekdayOrdinal == smallerUnit) {
+	    UErrorCode status = U_ZERO_ERROR;
+	    UDate udate = floor((at + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	    ucal_setMillis(calendar->_cal, udate, &status);
+	    dow = ucal_get(calendar->_cal, UCAL_DAY_OF_WEEK, &status);
+	}
+	// Set calendar to first instant of big unit
+	__CFCalendarSetToFirstInstant(calendar, biggerUnit, at);
+	UErrorCode status = U_ZERO_ERROR;
+	UDate start = ucal_getMillis(calendar->_cal, &status);
+	if (kCFCalendarUnitWeek == biggerUnit) {
+	    range.location = ucal_get(calendar->_cal, smallField, &status);
+	    if (kCFCalendarUnitMonth == smallerUnit) range.location++;
+	} else {
+	    range.location = (kCFCalendarUnitHour == smallerUnit || kCFCalendarUnitMinute == smallerUnit || kCFCalendarUnitSecond == smallerUnit) ? 0 : 1;
+	}
+	// Set calendar to first instant of next value of big unit
+	if (UCAL_ERA == bigField) {
+	    // ICU refuses to do the addition, probably because we are
+	    // at the limit of UCAL_ERA.  Use alternate strategy.
+	    CFIndex limit = ucal_getLimit(calendar->_cal, UCAL_YEAR, UCAL_MAXIMUM, &status);
+	    if (100000 < limit) limit = 100000;
+	    ucal_add(calendar->_cal, UCAL_YEAR, limit, &status);
+	} else {
+	    ucal_add(calendar->_cal, bigField, 1, &status);
+	}
+	if (kCFCalendarUnitWeek == smallerUnit && kCFCalendarUnitYear == biggerUnit) {
+	    ucal_add(calendar->_cal, UCAL_SECOND, -1, &status);
+	    range.length = ucal_get(calendar->_cal, UCAL_WEEK_OF_YEAR, &status);
+	    while (1 == range.length) {
+		ucal_add(calendar->_cal, UCAL_DAY_OF_MONTH, -1, &status);
+		range.length = ucal_get(calendar->_cal, UCAL_WEEK_OF_YEAR, &status);
+	    }
+	    range.location = 1;
+	    return range;
+	} else if (kCFCalendarUnitWeek == smallerUnit && kCFCalendarUnitMonth == biggerUnit) {
+	    ucal_add(calendar->_cal, UCAL_SECOND, -1, &status);
+	    range.length = ucal_get(calendar->_cal, UCAL_WEEK_OF_YEAR, &status);
+	    range.location = 1;
+	    return range;
+	}
+	UDate goal = ucal_getMillis(calendar->_cal, &status);
+	// Set calendar back to first instant of big unit
+	ucal_setMillis(calendar->_cal, start, &status);
+	if (kCFCalendarUnitWeekdayOrdinal == smallerUnit) {
+	    // roll day forward to first 'dow'
+	    while (ucal_get(calendar->_cal, (kCFCalendarUnitMonth == biggerUnit) ? UCAL_WEEK_OF_MONTH : UCAL_WEEK_OF_YEAR, &status) != 1) {
+		ucal_add(calendar->_cal, UCAL_DAY_OF_MONTH, 1, &status);
+	    }
+	    while (ucal_get(calendar->_cal, UCAL_DAY_OF_WEEK, &status) != dow) {
+		ucal_add(calendar->_cal, UCAL_DAY_OF_MONTH, 1, &status);
+	    }
+	    start = ucal_getMillis(calendar->_cal, &status);
+	    goal -= 1000;
+	    range.location = 1;  // constant here works around ICU -- see 3948293
+	}
+	UDate curr = start;
+	range.length = 	(kCFCalendarUnitWeekdayOrdinal == smallerUnit) ? 1 : 0;
+	const int multiple_table[] = {0, 0, 16, 19, 24, 26, 24, 28, 14, 14, 14};
+	int multiple = (1 << multiple_table[flsl(smallerUnit) - 1]);
+	Boolean divide = false, alwaysDivide = false;
+	while (curr < goal) {
+	    ucal_add(calendar->_cal, smallField, multiple, &status);
+	    UDate newcurr = ucal_getMillis(calendar->_cal, &status);
+	    if (curr < newcurr && newcurr <= goal) {
+		range.length += multiple;
+		curr = newcurr;
+	    } else {
+		// Either newcurr is going backwards, or not making
+		// progress, or has overshot the goal; reset date
+		// and try smaller multiples.
+		ucal_setMillis(calendar->_cal, curr, &status);
+		divide = true;
+		// once we start overshooting the goal, the add at
+		// smaller multiples will succeed at most once for
+		// each multiple, so we reduce it every time through
+		// the loop.
+		if (goal < newcurr) alwaysDivide = true;
+	    }
+	    if (divide) {
+		multiple = multiple / 2;
+		if (0 == multiple) break;
+		divide = alwaysDivide;
+	    }
+	}
+    }
+    return range;
+}
+
+#if __GNUC__
+static CFRange __CFCalendarGetRangeOfUnit2(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at) __attribute__((noinline));
+#endif
+static CFRange __CFCalendarGetRangeOfUnit2(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at) {
+    CF_OBJC_FUNCDISPATCH3(CFCalendarGetTypeID(), CFRange, calendar, "_rangeOfUnit:inUnit:forAT:", smallerUnit, biggerUnit, at);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    CFRange range = {kCFNotFound, kCFNotFound};
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	switch (smallerUnit) {
+	case kCFCalendarUnitSecond:
+            switch (biggerUnit) {
+            case kCFCalendarUnitMinute:
+            case kCFCalendarUnitHour:
+            case kCFCalendarUnitDay:
+            case kCFCalendarUnitWeekday:
+            case kCFCalendarUnitWeek:
+            case kCFCalendarUnitMonth:
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		// goto calculate;
+                range.location = 0;
+                range.length = 60;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitMinute:
+            switch (biggerUnit) {
+            case kCFCalendarUnitHour:
+            case kCFCalendarUnitDay:
+            case kCFCalendarUnitWeekday:
+            case kCFCalendarUnitWeek:
+            case kCFCalendarUnitMonth:
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		// goto calculate;
+                range.location = 0;
+                range.length = 60;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitHour:
+            switch (biggerUnit) {
+            case kCFCalendarUnitDay:
+            case kCFCalendarUnitWeekday:
+            case kCFCalendarUnitWeek:
+            case kCFCalendarUnitMonth:
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		// goto calculate;
+                range.location = 0;
+                range.length = 24;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitDay:
+            switch (biggerUnit) {
+            case kCFCalendarUnitWeek:
+            case kCFCalendarUnitMonth:
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		goto calculate;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitWeekday:
+            switch (biggerUnit) {
+            case kCFCalendarUnitWeek:
+            case kCFCalendarUnitMonth:
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		goto calculate;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitWeekdayOrdinal:
+            switch (biggerUnit) {
+            case kCFCalendarUnitMonth:
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		goto calculate;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitWeek:
+            switch (biggerUnit) {
+            case kCFCalendarUnitMonth:
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		goto calculate;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitMonth:
+            switch (biggerUnit) {
+            case kCFCalendarUnitYear:
+            case kCFCalendarUnitEra:
+		goto calculate;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitYear:
+            switch (biggerUnit) {
+            case kCFCalendarUnitEra:
+		goto calculate;
+		break;
+            }
+	    break;
+	case kCFCalendarUnitEra:
+	    break;
+	}
+    }
+    return range;
+
+    calculate:;
+    ucal_clear(calendar->_cal);
+    UCalendarDateFields smallField = __CFCalendarGetICUFieldCode(smallerUnit);
+    UCalendarDateFields bigField = __CFCalendarGetICUFieldCode(biggerUnit);
+    UCalendarDateFields yearField = __CFCalendarGetICUFieldCode(kCFCalendarUnitYear);
+    UCalendarDateFields fieldToAdd = smallField;
+    if (kCFCalendarUnitWeekday == smallerUnit) {
+        fieldToAdd = __CFCalendarGetICUFieldCode(kCFCalendarUnitDay);
+    }
+    int32_t dow = -1;
+    if (kCFCalendarUnitWeekdayOrdinal == smallerUnit) {
+        UErrorCode status = U_ZERO_ERROR;
+        UDate udate = floor((at + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+        ucal_setMillis(calendar->_cal, udate, &status);
+        dow = ucal_get(calendar->_cal, UCAL_DAY_OF_WEEK, &status);
+        fieldToAdd = __CFCalendarGetICUFieldCode(kCFCalendarUnitWeek);
+    }
+    // Set calendar to first instant of big unit
+    __CFCalendarSetToFirstInstant(calendar, biggerUnit, at);
+    if (kCFCalendarUnitWeekdayOrdinal == smallerUnit) {
+        UErrorCode status = U_ZERO_ERROR;
+        // roll day forward to first 'dow'
+        while (ucal_get(calendar->_cal, (kCFCalendarUnitMonth == biggerUnit) ? UCAL_WEEK_OF_MONTH : UCAL_WEEK_OF_YEAR, &status) != 1) {
+	    ucal_add(calendar->_cal, UCAL_DAY_OF_MONTH, 1, &status);
+        }
+        while (ucal_get(calendar->_cal, UCAL_DAY_OF_WEEK, &status) != dow) {
+	    ucal_add(calendar->_cal, UCAL_DAY_OF_MONTH, 1, &status);
+        }
+    }
+    int32_t minSmallValue = INT32_MAX;
+    int32_t maxSmallValue = INT32_MIN;
+    UErrorCode status = U_ZERO_ERROR;
+    int32_t bigValue = ucal_get(calendar->_cal, bigField, &status);
+    for (;;) {
+        int32_t smallValue = ucal_get(calendar->_cal, smallField, &status);
+        if (smallValue < minSmallValue) minSmallValue = smallValue;
+        if (smallValue > maxSmallValue) maxSmallValue = smallValue;
+        ucal_add(calendar->_cal, fieldToAdd, 1, &status);
+        if (bigValue != ucal_get(calendar->_cal, bigField, &status)) break;
+        if (biggerUnit == kCFCalendarUnitEra && ucal_get(calendar->_cal, yearField, &status) > 10000) break;
+	// we assume an answer for 10000 years can be extrapolated to 100000 years, to save time
+    }
+    status = U_ZERO_ERROR;
+    range.location = minSmallValue;
+    if (smallerUnit == kCFCalendarUnitMonth) range.location = 1;
+    range.length = maxSmallValue - minSmallValue + 1;
+    if (biggerUnit == kCFCalendarUnitEra && ucal_get(calendar->_cal, yearField, &status) > 10000) range.length = 100000;
+
+    return range;
+}
+
+CFRange CFCalendarGetRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at) {
+    if (_CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard)) {
+	return __CFCalendarGetRangeOfUnit2(calendar, smallerUnit, biggerUnit, at);
+    } else {
+	return __CFCalendarGetRangeOfUnit1(calendar, smallerUnit, biggerUnit, at);
+    }
+}
+
+CFIndex CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at) {
+    CFIndex result = kCFNotFound;
+    if (!__validUnits(smallerUnit, biggerUnit)) return result;
+    CF_OBJC_FUNCDISPATCH3(CFCalendarGetTypeID(), CFIndex, calendar, "_ordinalityOfUnit:inUnit:forAT:", smallerUnit, biggerUnit, at);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	UErrorCode status = U_ZERO_ERROR;
+	ucal_clear(calendar->_cal);
+	if (kCFCalendarUnitWeek == smallerUnit && kCFCalendarUnitYear == biggerUnit) {
+	    UDate udate = floor((at + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	    ucal_setMillis(calendar->_cal, udate, &status);
+	    int32_t val = ucal_get(calendar->_cal, UCAL_WEEK_OF_YEAR, &status);
+	    return val;
+	} else if (kCFCalendarUnitWeek == smallerUnit && kCFCalendarUnitMonth == biggerUnit) {
+	    UDate udate = floor((at + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	    ucal_setMillis(calendar->_cal, udate, &status);
+	    int32_t val = ucal_get(calendar->_cal, UCAL_WEEK_OF_MONTH, &status);
+	    return val;
+	}
+	UCalendarDateFields smallField = __CFCalendarGetICUFieldCode(smallerUnit);
+	// Set calendar to first instant of big unit
+	__CFCalendarSetToFirstInstant(calendar, biggerUnit, at);
+	UDate curr = ucal_getMillis(calendar->_cal, &status);
+        UDate goal = floor((at + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	result = 1;
+	const int multiple_table[] = {0, 0, 16, 19, 24, 26, 24, 28, 14, 14, 14};
+	int multiple = (1 << multiple_table[flsl(smallerUnit) - 1]);
+	Boolean divide = false, alwaysDivide = false;
+	while (curr < goal) {
+	    ucal_add(calendar->_cal, smallField, multiple, &status);
+	    UDate newcurr = ucal_getMillis(calendar->_cal, &status);
+	    if (curr < newcurr && newcurr <= goal) {
+		result += multiple;
+		curr = newcurr;
+	    } else {
+		// Either newcurr is going backwards, or not making
+		// progress, or has overshot the goal; reset date
+		// and try smaller multiples.
+		ucal_setMillis(calendar->_cal, curr, &status);
+		divide = true;
+		// once we start overshooting the goal, the add at
+		// smaller multiples will succeed at most once for
+		// each multiple, so we reduce it every time through
+		// the loop.
+		if (goal < newcurr) alwaysDivide = true;
+	    }
+	    if (divide) {
+		multiple = multiple / 2;
+		if (0 == multiple) break;
+		divide = alwaysDivide;
+	    }
+	}
+    }
+    return result;
+}
+
+Boolean _CFCalendarComposeAbsoluteTimeV(CFCalendarRef calendar, /* out */ CFAbsoluteTime *atp, const char *componentDesc, int *vector, int count) {
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	UErrorCode status = U_ZERO_ERROR;
+	ucal_clear(calendar->_cal);
+	ucal_set(calendar->_cal, UCAL_YEAR, 1);
+	ucal_set(calendar->_cal, UCAL_MONTH, 0);
+	ucal_set(calendar->_cal, UCAL_DAY_OF_MONTH, 1);
+	ucal_set(calendar->_cal, UCAL_HOUR_OF_DAY, 0);
+	ucal_set(calendar->_cal, UCAL_MINUTE, 0);
+	ucal_set(calendar->_cal, UCAL_SECOND, 0);
+	const char *desc = componentDesc;
+	Boolean doWOY = false;
+	char ch = *desc;
+	while (ch) {
+	    UCalendarDateFields field = __CFCalendarGetICUFieldCodeFromChar(ch);
+	    if (UCAL_WEEK_OF_YEAR == field) {
+		doWOY = true;
+	    }
+	    desc++;
+	    ch = *desc;
+	}
+	desc = componentDesc;
+	ch = *desc;
+	while (ch) {
+	    UCalendarDateFields field = __CFCalendarGetICUFieldCodeFromChar(ch);
+	    int value = *vector;
+	    if (UCAL_YEAR == field && doWOY) field = UCAL_YEAR_WOY;
+	    if (UCAL_MONTH == field) value--;
+	    ucal_set(calendar->_cal, field, value);
+	    vector++;
+	    desc++;
+	    ch = *desc;
+	}
+	UDate udate = ucal_getMillis(calendar->_cal, &status);
+	CFAbsoluteTime at = (udate / 1000.0) - kCFAbsoluteTimeIntervalSince1970;
+        if (atp) *atp = at;
+	return U_SUCCESS(status) ? true : false;
+    }
+    return false;
+}
+
+Boolean _CFCalendarDecomposeAbsoluteTimeV(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, int **vector, int count) {
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	UErrorCode status = U_ZERO_ERROR;
+	ucal_clear(calendar->_cal);
+	UDate udate = floor((at + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	ucal_setMillis(calendar->_cal, udate, &status);
+	char ch = *componentDesc;
+	while (ch) {
+	    UCalendarDateFields field = __CFCalendarGetICUFieldCodeFromChar(ch);
+	    int value = ucal_get(calendar->_cal, field, &status);
+	    if (UCAL_MONTH == field) value++;
+	    *(*vector) = value;
+	    vector++;
+	    componentDesc++;
+	    ch = *componentDesc;
+	}
+	return U_SUCCESS(status) ? true : false;
+    }
+    return false;
+}
+
+Boolean _CFCalendarAddComponentsV(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *atp, CFOptionFlags options, const char *componentDesc, int *vector, int count) {
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	UErrorCode status = U_ZERO_ERROR;
+	ucal_clear(calendar->_cal);
+	UDate udate = floor((*atp + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	ucal_setMillis(calendar->_cal, udate, &status);
+	char ch = *componentDesc;
+	while (ch) {
+	    UCalendarDateFields field = __CFCalendarGetICUFieldCodeFromChar(ch);
+            int amount = *vector;
+	    if (options & kCFCalendarComponentsWrap) {
+		ucal_roll(calendar->_cal, field, amount, &status);
+	    } else {
+		ucal_add(calendar->_cal, field, amount, &status);
+	    }
+	    vector++;
+	    componentDesc++;
+	    ch = *componentDesc;
+	}
+	udate = ucal_getMillis(calendar->_cal, &status);
+	*atp = (udate / 1000.0) - kCFAbsoluteTimeIntervalSince1970;
+	return U_SUCCESS(status) ? true : false;
+    }
+    return false;
+}
+
+Boolean _CFCalendarGetComponentDifferenceV(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, int **vector, int count) {
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+	UErrorCode status = U_ZERO_ERROR;
+	ucal_clear(calendar->_cal);
+	UDate curr = floor((startingAT + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	UDate goal = floor((resultAT + kCFAbsoluteTimeIntervalSince1970) * 1000.0);
+	ucal_setMillis(calendar->_cal, curr, &status);
+	int direction = (startingAT <= resultAT) ? 1 : -1;
+	char ch = *componentDesc;
+	while (ch) {
+	    UCalendarDateFields field = __CFCalendarGetICUFieldCodeFromChar(ch);
+	    const int multiple_table[] = {0, 0, 16, 19, 24, 26, 24, 28, 14, 14, 14};
+	    int multiple = direction * (1 << multiple_table[flsl(__CFCalendarGetCalendarUnitFromChar(ch)) - 1]);
+	    Boolean divide = false, alwaysDivide = false;
+	    int result = 0;
+	    while ((direction > 0 && curr < goal) || (direction < 0 && goal < curr)) {
+		ucal_add(calendar->_cal, field, multiple, &status);
+		UDate newcurr = ucal_getMillis(calendar->_cal, &status);
+		if ((direction > 0 && curr < newcurr && newcurr <= goal) || (direction < 0 && newcurr < curr && goal <= newcurr)) {
+		    result += multiple;
+		    curr = newcurr;
+		} else {
+		    // Either newcurr is going backwards, or not making
+		    // progress, or has overshot the goal; reset date
+		    // and try smaller multiples.
+		    ucal_setMillis(calendar->_cal, curr, &status);
+		    divide = true;
+		    // once we start overshooting the goal, the add at
+		    // smaller multiples will succeed at most once for
+		    // each multiple, so we reduce it every time through
+		    // the loop.
+		    if ((direction > 0 && goal < newcurr) || (direction < 0 && newcurr < goal)) alwaysDivide = true;
+		}
+		if (divide) {
+		    multiple = multiple / 2;
+		    if (0 == multiple) break;
+		    divide = alwaysDivide;
+		}
+	    }
+	    *(*vector) = result;
+	    vector++;
+	    componentDesc++;
+	    ch = *componentDesc;
+	}
+	return U_SUCCESS(status) ? true : false;
+    }
+    return false;
+}
+
+Boolean CFCalendarComposeAbsoluteTime(CFCalendarRef calendar, /* out */ CFAbsoluteTime *atp, const char *componentDesc, ...) {
+    va_list args;
+    va_start(args, componentDesc);
+    CF_OBJC_FUNCDISPATCH3(CFCalendarGetTypeID(), Boolean, calendar, "_composeAbsoluteTime:::", atp, componentDesc, args);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    int idx, cnt = (int)strlen((char *)componentDesc);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(int, vector, cnt);
+#else
+    int vector[256]; // Dynamic stack allocation is GNU specific
+#endif
+    for (idx = 0; idx < cnt; idx++) {
+	int arg = va_arg(args, int);
+	vector[idx] = arg;
+    }
+    va_end(args);
+    return _CFCalendarComposeAbsoluteTimeV(calendar, atp, componentDesc, vector, cnt);
+}
+
+Boolean CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ...) {
+    va_list args;
+    va_start(args, componentDesc);
+    CF_OBJC_FUNCDISPATCH3(CFCalendarGetTypeID(), Boolean, calendar, "_decomposeAbsoluteTime:::", at, componentDesc, args);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    int idx, cnt = (int)strlen((char *)componentDesc);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(int *, vector, cnt);
+#else
+    int* vector[256]; // Dynamic stack allocation is GNU specific
+#endif
+    for (idx = 0; idx < cnt; idx++) {
+        int *arg = va_arg(args, int *);
+        vector[idx] = arg;
+    }
+    va_end(args);
+    return _CFCalendarDecomposeAbsoluteTimeV(calendar, at, componentDesc, vector, cnt);
+}
+
+Boolean CFCalendarAddComponents(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *atp, CFOptionFlags options, const char *componentDesc, ...) {
+    va_list args;
+    va_start(args, componentDesc);
+    CF_OBJC_FUNCDISPATCH4(CFCalendarGetTypeID(), Boolean, calendar, "_addComponents::::", atp, options, componentDesc, args);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    int idx, cnt = (int)strlen((char *)componentDesc);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(int, vector, cnt);
+#else
+    int vector[256]; // Dynamic stack allocation is GNU specific
+#endif
+    for (idx = 0; idx < cnt; idx++) {
+        int arg = va_arg(args, int);
+        vector[idx] = arg;
+    }
+    va_end(args);
+    return _CFCalendarAddComponentsV(calendar, atp, options, componentDesc, vector, cnt);    
+}
+
+Boolean CFCalendarGetComponentDifference(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ...) {
+    va_list args;
+    va_start(args, componentDesc);
+    CF_OBJC_FUNCDISPATCH5(CFCalendarGetTypeID(), Boolean, calendar, "_diffComponents:::::", startingAT, resultAT, options, componentDesc, args);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    int idx, cnt = (int)strlen((char *)componentDesc);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(int *, vector, cnt);
+#else
+    int* vector[256]; // Dynamic stack allocation is GNU specific
+#endif
+    for (idx = 0; idx < cnt; idx++) {
+        int *arg = va_arg(args, int *);
+        vector[idx] = arg;
+    }
+    va_end(args);
+    Boolean ret = _CFCalendarGetComponentDifferenceV(calendar, startingAT, resultAT, options, componentDesc, vector, cnt);
+    return ret;
+}
+
+Boolean CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip) {
+    CF_OBJC_FUNCDISPATCH4(CFCalendarGetTypeID(), Boolean, calendar, "_rangeOfUnit:startTime:interval:forAT:", unit, startp, tip, at);
+    __CFGenericValidateType(calendar, CFCalendarGetTypeID());
+    if (kCFCalendarUnitWeekdayOrdinal == unit) return false;
+    if (kCFCalendarUnitWeekday == unit) unit = kCFCalendarUnitDay;
+    if (!calendar->_cal) __CFCalendarSetupCal(calendar);
+    if (calendar->_cal) {
+        ucal_clear(calendar->_cal);
+        __CFCalendarSetToFirstInstant(calendar, unit, at);
+        UErrorCode status = U_ZERO_ERROR;
+        UDate start = ucal_getMillis(calendar->_cal, &status);
+	UCalendarDateFields field = __CFCalendarGetICUFieldCode(unit);
+	ucal_add(calendar->_cal, field, 1, &status);
+        UDate end = ucal_getMillis(calendar->_cal, &status);
+	if (end == start && kCFCalendarUnitEra == unit) {
+            // ICU refuses to do the addition, probably because we are
+            // at the limit of UCAL_ERA.  Use alternate strategy.
+            CFIndex limit = ucal_getLimit(calendar->_cal, UCAL_YEAR, UCAL_MAXIMUM, &status);
+            if (100000 < limit) limit = 100000;
+            ucal_add(calendar->_cal, UCAL_YEAR, limit, &status);
+	    end = ucal_getMillis(calendar->_cal, &status);
+	}
+	if (U_SUCCESS(status)) {
+	    if (startp) *startp = (double)start / 1000.0 - kCFAbsoluteTimeIntervalSince1970;
+	    if (tip) *tip = (double)(end - start) / 1000.0;
+	    return true;
+	}
+    }
+    return false;
+}
+
+#undef BUFFER_SIZE
+
diff --git a/CoreFoundation/CFCalendar.h b/CoreFoundation/CFCalendar.h
new file mode 100644
index 0000000..31b28c8
--- /dev/null
+++ b/CoreFoundation/CFCalendar.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFCALENDAR__)
+#define __COREFOUNDATION_CFCALENDAR__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFLocale.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFTimeZone.h>
+
+#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
+
+CF_EXTERN_C_BEGIN
+
+typedef struct __CFCalendar * CFCalendarRef;
+
+CF_EXPORT
+CFTypeID CFCalendarGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFCalendarRef CFCalendarCopyCurrent(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringRef identifier) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// Create a calendar.  The identifiers are the kCF*Calendar
+	// constants in CFLocale.h.
+
+CF_EXPORT
+CFStringRef CFCalendarGetIdentifier(CFCalendarRef calendar) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// Returns the calendar's identifier.
+
+CF_EXPORT
+CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFIndex CFCalendarGetFirstWeekday(CFCalendarRef calendar) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+void CFCalendarSetFirstWeekday(CFCalendarRef calendar, CFIndex wkdy) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFIndex CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, CFIndex mwd) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+
+enum {
+	kCFCalendarUnitEra = (1 << 1),
+	kCFCalendarUnitYear = (1 << 2),
+	kCFCalendarUnitMonth = (1 << 3),
+	kCFCalendarUnitDay = (1 << 4),
+	kCFCalendarUnitHour = (1 << 5),
+	kCFCalendarUnitMinute = (1 << 6),
+	kCFCalendarUnitSecond = (1 << 7),
+	kCFCalendarUnitWeek = (1 << 8),
+	kCFCalendarUnitWeekday = (1 << 9),
+	kCFCalendarUnitWeekdayOrdinal = (1 << 10)
+};
+typedef CFOptionFlags CFCalendarUnit;
+
+CF_EXPORT
+CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFRange CFCalendarGetRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+CFIndex CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+Boolean CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+CF_EXPORT
+Boolean CFCalendarComposeAbsoluteTime(CFCalendarRef calendar, /* out */ CFAbsoluteTime *at, const char *componentDesc, ...) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+Boolean CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ...) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+
+enum {
+    kCFCalendarComponentsWrap = (1 << 0)  // option for adding
+};
+
+CF_EXPORT
+Boolean CFCalendarAddComponents(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *at, CFOptionFlags options, const char *componentDesc, ...) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT
+Boolean CFCalendarGetComponentDifference(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ...) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+
+CF_EXTERN_C_END
+
+#endif
+
+#endif /* ! __COREFOUNDATION_CFCALENDAR__ */
+
diff --git a/CoreFoundation/CFCharacterSet.c b/CoreFoundation/CFCharacterSet.c
new file mode 100644
index 0000000..67b3f73
--- /dev/null
+++ b/CoreFoundation/CFCharacterSet.c
@@ -0,0 +1,2742 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Aki Inoue
+*/
+
+#include <CoreFoundation/CFCharacterSet.h>
+#include <CoreFoundation/CFByteOrder.h>
+#include "CFCharacterSetPriv.h"
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFString.h>
+#include "CFInternal.h"
+#include "CFUniChar.h"
+#include "CFUniCharPriv.h"
+#include <stdlib.h>
+#include <string.h>
+
+
+#define BITSPERBYTE	8	/* (CHAR_BIT * sizeof(unsigned char)) */
+#define LOG_BPB		3
+#define LOG_BPLW	5
+#define NUMCHARACTERS	65536
+
+#define MAX_ANNEX_PLANE	(16)
+
+/* Number of things in the array keeping the bits.
+*/
+#define __kCFBitmapSize		(NUMCHARACTERS / BITSPERBYTE)
+
+/* How many elements max can be in an __kCFCharSetClassString CFCharacterSet
+*/
+#define __kCFStringCharSetMax 64
+
+/* The last builtin set ID number
+*/
+#define __kCFLastBuiltinSetID kCFCharacterSetNewline
+
+/* How many elements in the "singles" array before we use binary search.
+*/
+#define __kCFSetBreakeven 10
+
+/* This tells us, within 1k or so, whether a thing is POTENTIALLY in the set (in the bitmap blob of the private structure) before we bother to do specific checking.
+*/
+#define __CFCSetBitsInRange(n, i)	(i[n>>15] & (1L << ((n>>10) % 32)))
+
+/* Compact bitmap params
+*/
+#define __kCFCompactBitmapNumPages (256)
+
+#define __kCFCompactBitmapMaxPages (128) // the max pages allocated
+
+#define __kCFCompactBitmapPageSize (__kCFBitmapSize / __kCFCompactBitmapNumPages)
+
+typedef struct {
+    CFCharacterSetRef *_nonBMPPlanes;
+    unsigned int _validEntriesBitmap;
+    unsigned char _numOfAllocEntries;
+    unsigned char _isAnnexInverted;
+    uint16_t _padding;
+} CFCharSetAnnexStruct;
+
+struct __CFCharacterSet {
+    CFRuntimeBase _base;
+    CFHashCode _hashValue;
+    union {
+        struct {
+            CFIndex _type;
+        } _builtin;
+        struct {
+            UInt32 _firstChar;
+            CFIndex _length;
+        } _range;
+        struct {
+            UniChar *_buffer;
+            CFIndex _length;
+        } _string;
+        struct {
+            uint8_t *_bits;
+        } _bitmap;
+        struct {
+            uint8_t *_cBits;
+        } _compactBitmap;
+   } _variants;
+   CFCharSetAnnexStruct *_annex;
+};
+
+/* _base._info values interesting for CFCharacterSet
+*/
+enum {
+    __kCFCharSetClassTypeMask = 0x0070,
+      __kCFCharSetClassBuiltin = 0x0000,
+      __kCFCharSetClassRange = 0x0010,
+      __kCFCharSetClassString = 0x0020,
+      __kCFCharSetClassBitmap = 0x0030,
+      __kCFCharSetClassSet = 0x0040,
+      __kCFCharSetClassCompactBitmap = 0x0040,
+
+    __kCFCharSetIsInvertedMask = 0x0008,
+      __kCFCharSetIsInverted = 0x0008,
+
+    __kCFCharSetHasHashValueMask = 0x00004,
+      __kCFCharSetHasHashValue = 0x0004,
+
+    /* Generic CFBase values */
+    __kCFCharSetIsMutableMask = 0x0001,
+      __kCFCharSetIsMutable = 0x0001,
+};
+
+/* Inline accessor macros for _base._info
+*/
+CF_INLINE Boolean __CFCSetIsMutable(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetIsMutableMask) == __kCFCharSetIsMutable;}
+CF_INLINE Boolean __CFCSetIsBuiltin(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetClassTypeMask) == __kCFCharSetClassBuiltin;}
+CF_INLINE Boolean __CFCSetIsRange(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetClassTypeMask) == __kCFCharSetClassRange;}
+CF_INLINE Boolean __CFCSetIsString(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetClassTypeMask) == __kCFCharSetClassString;}
+CF_INLINE Boolean __CFCSetIsBitmap(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetClassTypeMask) == __kCFCharSetClassBitmap;}
+CF_INLINE Boolean __CFCSetIsCompactBitmap(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetClassTypeMask) == __kCFCharSetClassCompactBitmap;}
+CF_INLINE Boolean __CFCSetIsInverted(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetIsInvertedMask) == __kCFCharSetIsInverted;}
+CF_INLINE Boolean __CFCSetHasHashValue(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetHasHashValueMask) == __kCFCharSetHasHashValue;}
+CF_INLINE UInt32 __CFCSetClassType(CFCharacterSetRef cset) {return (cset->_base._cfinfo[CF_INFO_BITS] & __kCFCharSetClassTypeMask);}
+
+CF_INLINE void __CFCSetPutIsMutable(CFMutableCharacterSetRef cset, Boolean isMutable) {(isMutable ? (cset->_base._cfinfo[CF_INFO_BITS] |= __kCFCharSetIsMutable) : (cset->_base._cfinfo[CF_INFO_BITS] &= ~ __kCFCharSetIsMutable));}
+CF_INLINE void __CFCSetPutIsInverted(CFMutableCharacterSetRef cset, Boolean isInverted) {(isInverted ? (cset->_base._cfinfo[CF_INFO_BITS] |= __kCFCharSetIsInverted) : (cset->_base._cfinfo[CF_INFO_BITS] &= ~__kCFCharSetIsInverted));}
+CF_INLINE void __CFCSetPutHasHashValue(CFMutableCharacterSetRef cset, Boolean hasHash) {(hasHash ? (cset->_base._cfinfo[CF_INFO_BITS] |= __kCFCharSetHasHashValue) : (cset->_base._cfinfo[CF_INFO_BITS] &= ~__kCFCharSetHasHashValue));}
+CF_INLINE void __CFCSetPutClassType(CFMutableCharacterSetRef cset, UInt32 classType) {cset->_base._cfinfo[CF_INFO_BITS] &= ~__kCFCharSetClassTypeMask;  cset->_base._cfinfo[CF_INFO_BITS] |= classType;}
+
+
+/* Inline contents accessor macros
+*/
+CF_INLINE CFCharacterSetPredefinedSet __CFCSetBuiltinType(CFCharacterSetRef cset) {return cset->_variants._builtin._type;}
+CF_INLINE UInt32 __CFCSetRangeFirstChar(CFCharacterSetRef cset) {return cset->_variants._range._firstChar;}
+CF_INLINE CFIndex __CFCSetRangeLength(CFCharacterSetRef cset) {return cset->_variants._range._length;}
+CF_INLINE UniChar *__CFCSetStringBuffer(CFCharacterSetRef cset) {return (UniChar*)(cset->_variants._string._buffer);}
+CF_INLINE CFIndex __CFCSetStringLength(CFCharacterSetRef cset) {return cset->_variants._string._length;}
+CF_INLINE uint8_t *__CFCSetBitmapBits(CFCharacterSetRef cset) {return cset->_variants._bitmap._bits;}
+CF_INLINE uint8_t *__CFCSetCompactBitmapBits(CFCharacterSetRef cset) {return cset->_variants._compactBitmap._cBits;}
+
+CF_INLINE void __CFCSetPutBuiltinType(CFMutableCharacterSetRef cset, CFCharacterSetPredefinedSet type) {cset->_variants._builtin._type = type;}
+CF_INLINE void __CFCSetPutRangeFirstChar(CFMutableCharacterSetRef cset, UInt32 first) {cset->_variants._range._firstChar = first;}
+CF_INLINE void __CFCSetPutRangeLength(CFMutableCharacterSetRef cset, CFIndex length) {cset->_variants._range._length = length;}
+CF_INLINE void __CFCSetPutStringBuffer(CFMutableCharacterSetRef cset, UniChar *theBuffer) {cset->_variants._string._buffer = theBuffer;}
+CF_INLINE void __CFCSetPutStringLength(CFMutableCharacterSetRef cset, CFIndex length) {cset->_variants._string._length = length;}
+CF_INLINE void __CFCSetPutBitmapBits(CFMutableCharacterSetRef cset, uint8_t *bits) {cset->_variants._bitmap._bits = bits;}
+CF_INLINE void __CFCSetPutCompactBitmapBits(CFMutableCharacterSetRef cset, uint8_t *bits) {cset->_variants._compactBitmap._cBits = bits;}
+
+/* Validation funcs
+*/
+#if defined(CF_ENABLE_ASSERTIONS)
+CF_INLINE void __CFCSetValidateBuiltinType(CFCharacterSetPredefinedSet type, const char *func) {
+    CFAssert2(type > 0 && type <= __kCFLastBuiltinSetID, __kCFLogAssertion, "%s: Unknowen builtin type %d", func, type);
+}
+CF_INLINE void __CFCSetValidateRange(CFRange theRange, const char *func) {
+    CFAssert3(theRange.location >= 0 && theRange.location + theRange.length <= 0x1FFFFF, __kCFLogAssertion, "%s: Range out of Unicode range (location -> %d length -> %d)", func, theRange.location, theRange.length);
+}
+CF_INLINE void __CFCSetValidateTypeAndMutability(CFCharacterSetRef cset, const char *func) {
+    __CFGenericValidateType(cset, __kCFCharacterSetTypeID);
+    CFAssert1(__CFCSetIsMutable(cset), __kCFLogAssertion, "%s: Immutable character set passed to mutable function", func);
+}
+#else
+#define __CFCSetValidateBuiltinType(t,f)
+#define __CFCSetValidateRange(r,f)
+#define __CFCSetValidateTypeAndMutability(r,f)
+#endif
+
+/* Inline utility funcs
+*/
+static Boolean __CFCSetIsEqualBitmap(const UInt32 *bits1, const UInt32 *bits2) {
+    CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+
+    if (bits1 == bits2) {
+        return true;
+    } else if (bits1 && bits2) {
+        if (bits1 == (const UInt32 *)-1) {
+            while (length--) if ((UInt32)-1 != *bits2++) return false;
+        } else if (bits2 == (const UInt32 *)-1) {
+            while (length--) if ((UInt32)-1 != *bits1++) return false;
+        } else {
+            while (length--) if (*bits1++ != *bits2++) return false;
+        }
+        return true;
+    } else if (!bits1 && !bits2) { // empty set
+        return true;
+    } else {
+        if (bits2) bits1 = bits2;
+        if (bits1 == (const UInt32 *)-1) return false;
+        while (length--) if (*bits1++) return false;
+        return true;
+    }
+}
+
+CF_INLINE Boolean __CFCSetIsEqualBitmapInverted(const UInt32 *bits1, const UInt32 *bits2) {
+    CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+
+    while (length--) if (*bits1++ != ~(*(bits2++))) return false;
+    return true;
+}
+
+static Boolean __CFCSetIsBitmapEqualToRange(const UInt32 *bits, UniChar firstChar, UniChar lastChar, Boolean isInverted) {
+    CFIndex firstCharIndex = firstChar >> LOG_BPB;
+    CFIndex lastCharIndex = lastChar >> LOG_BPB;
+    CFIndex length;
+    UInt32 value;
+
+    if (firstCharIndex == lastCharIndex) {
+        value = ((((UInt32)0xFF) << (firstChar & (BITSPERBYTE - 1))) & (((UInt32)0xFF) >> ((BITSPERBYTE - 1) - (lastChar & (BITSPERBYTE - 1))))) << (((sizeof(UInt32) - 1) - (firstCharIndex % sizeof(UInt32))) * BITSPERBYTE);
+        value = CFSwapInt32HostToBig(value);
+        firstCharIndex = lastCharIndex = firstChar >> LOG_BPLW;
+        if (*(bits + firstCharIndex) != (isInverted ? ~value : value)) return FALSE;
+    } else {
+        UInt32 firstCharMask;
+        UInt32 lastCharMask;
+
+        length = firstCharIndex % sizeof(UInt32);
+        firstCharMask = (((((UInt32)0xFF) << (firstChar & (BITSPERBYTE - 1))) & 0xFF) << (((sizeof(UInt32) - 1) - length) * BITSPERBYTE)) | (((UInt32)0xFFFFFFFF) >> ((length + 1) * BITSPERBYTE));
+        
+        length = lastCharIndex % sizeof(UInt32);
+        lastCharMask = ((((UInt32)0xFF) >> ((BITSPERBYTE - 1) - (lastChar & (BITSPERBYTE - 1)))) << (((sizeof(UInt32) - 1) - length) * BITSPERBYTE)) | (((UInt32)0xFFFFFFFF) << ((sizeof(UInt32) - length) * BITSPERBYTE));
+
+        firstCharIndex = firstChar >> LOG_BPLW;
+        lastCharIndex = lastChar >> LOG_BPLW;
+        
+        if (firstCharIndex == lastCharIndex) {
+            firstCharMask &= lastCharMask;
+            value = CFSwapInt32HostToBig(firstCharMask & lastCharMask);
+            if (*(bits + firstCharIndex) != (isInverted ? ~value : value)) return FALSE;
+        } else {
+            value = CFSwapInt32HostToBig(firstCharMask);
+            if (*(bits + firstCharIndex) != (isInverted ? ~value : value)) return FALSE;
+
+            value = CFSwapInt32HostToBig(lastCharMask);
+            if (*(bits + lastCharIndex) != (isInverted ? ~value : value)) return FALSE;
+        }
+    }
+
+    length = firstCharIndex;
+    value = (isInverted ? ((UInt32)0xFFFFFFFF) : 0);
+    while (length--) {
+        if (*(bits++) != value) return FALSE;
+    }
+
+    ++bits; // Skip firstCharIndex
+    length = (lastCharIndex - (firstCharIndex + 1));
+    value = (isInverted ? 0 : ((UInt32)0xFFFFFFFF));
+    while (length-- > 0) {
+        if (*(bits++) != value) return FALSE;
+    }
+    if (firstCharIndex != lastCharIndex) ++bits;
+
+    length = (0xFFFF >> LOG_BPLW) - lastCharIndex;
+    value = (isInverted ? ((UInt32)0xFFFFFFFF) : 0);
+    while (length--) {
+        if (*(bits++) != value) return FALSE;
+    }
+
+    return TRUE;
+}
+
+CF_INLINE Boolean __CFCSetIsBitmapSupersetOfBitmap(const UInt32 *bits1, const UInt32 *bits2, Boolean isInverted1, Boolean isInverted2) {
+    CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+    UInt32 val1, val2;
+
+    while (length--) {
+        val2 = (isInverted2 ? ~(*(bits2++)) : *(bits2++));
+        val1 = (isInverted1 ? ~(*(bits1++)) : *(bits1++)) & val2;
+        if (val1 != val2) return false;
+    }
+
+    return true;
+}
+
+CF_INLINE Boolean __CFCSetHasNonBMPPlane(CFCharacterSetRef cset) { return ((cset)->_annex && (cset)->_annex->_validEntriesBitmap ? true : false); }
+CF_INLINE Boolean __CFCSetAnnexIsInverted (CFCharacterSetRef cset) { return ((cset)->_annex && (cset)->_annex->_isAnnexInverted ? true : false); }
+CF_INLINE UInt32 __CFCSetAnnexValidEntriesBitmap(CFCharacterSetRef cset) { return ((cset)->_annex ? (cset)->_annex->_validEntriesBitmap : 0); }
+
+CF_INLINE Boolean __CFCSetIsEmpty(CFCharacterSetRef cset) {
+    if (__CFCSetHasNonBMPPlane(cset) || __CFCSetAnnexIsInverted(cset)) return false;
+
+    switch (__CFCSetClassType(cset)) {
+        case __kCFCharSetClassRange: if (!__CFCSetRangeLength(cset)) return true; break;
+        case __kCFCharSetClassString: if (!__CFCSetStringLength(cset)) return true; break;
+        case __kCFCharSetClassBitmap: if (!__CFCSetBitmapBits(cset)) return true; break;
+        case __kCFCharSetClassCompactBitmap: if (!__CFCSetCompactBitmapBits(cset)) return true; break;
+    }
+    return false;
+}
+
+CF_INLINE void __CFCSetBitmapAddCharacter(uint8_t *bitmap, UniChar theChar) {
+    bitmap[(theChar) >> LOG_BPB] |= (((unsigned)1) << (theChar & (BITSPERBYTE - 1)));
+}
+
+CF_INLINE void __CFCSetBitmapRemoveCharacter(uint8_t *bitmap, UniChar theChar) {
+    bitmap[(theChar) >> LOG_BPB] &= ~(((unsigned)1) << (theChar & (BITSPERBYTE - 1)));
+}
+
+CF_INLINE Boolean __CFCSetIsMemberBitmap(const uint8_t *bitmap, UniChar theChar) {
+    return ((bitmap[(theChar) >> LOG_BPB] & (((unsigned)1) << (theChar & (BITSPERBYTE - 1)))) ? true : false);
+}
+
+#define NUM_32BIT_SLOTS	(NUMCHARACTERS / 32)
+
+CF_INLINE void __CFCSetBitmapFastFillWithValue(UInt32 *bitmap, uint8_t value) {
+    UInt32 mask = (value << 24) | (value << 16) | (value << 8) | value;
+    UInt32 numSlots = NUMCHARACTERS / 32;
+
+    while (numSlots--) *(bitmap++) = mask;
+}
+
+CF_INLINE void __CFCSetBitmapAddCharactersInRange(uint8_t *bitmap, UniChar firstChar, UniChar lastChar) {
+    if (firstChar == lastChar) {
+        bitmap[firstChar >> LOG_BPB] |= (((unsigned)1) << (firstChar & (BITSPERBYTE - 1)));
+    } else {
+        UInt32 idx = firstChar >> LOG_BPB;
+        UInt32 max = lastChar >> LOG_BPB;
+
+        if (idx == max) {
+            bitmap[idx] |= (((unsigned)0xFF) << (firstChar & (BITSPERBYTE - 1))) & (((unsigned)0xFF) >> ((BITSPERBYTE - 1) - (lastChar & (BITSPERBYTE - 1))));
+        } else {
+            bitmap[idx] |= (((unsigned)0xFF) << (firstChar & (BITSPERBYTE - 1)));
+            bitmap[max] |= (((unsigned)0xFF) >> ((BITSPERBYTE - 1) - (lastChar & (BITSPERBYTE - 1))));
+
+            ++idx;
+            while (idx < max) bitmap[idx++] = 0xFF;
+        }
+    }
+}
+
+CF_INLINE void __CFCSetBitmapRemoveCharactersInRange(uint8_t *bitmap, UniChar firstChar, UniChar lastChar) {
+    UInt32 idx = firstChar >> LOG_BPB;
+    UInt32 max = lastChar >> LOG_BPB;
+
+    if (idx == max) {
+        bitmap[idx] &= ~((((unsigned)0xFF) << (firstChar & (BITSPERBYTE - 1))) & (((unsigned)0xFF) >> ((BITSPERBYTE - 1) - (lastChar & (BITSPERBYTE - 1)))));
+    } else {
+        bitmap[idx] &= ~(((unsigned)0xFF) << (firstChar & (BITSPERBYTE - 1)));
+        bitmap[max] &= ~(((unsigned)0xFF) >> ((BITSPERBYTE - 1) - (lastChar & (BITSPERBYTE - 1))));
+
+        ++idx;
+        while (idx < max) bitmap[idx++] = 0;
+    }
+}
+
+#define __CFCSetAnnexBitmapSetPlane(bitmap,plane)	((bitmap) |= (1 << (plane)))
+#define __CFCSetAnnexBitmapClearPlane(bitmap,plane)	((bitmap) &= (~(1 << (plane))))
+#define __CFCSetAnnexBitmapGetPlane(bitmap,plane)	((bitmap) & (1 << (plane)))
+
+CF_INLINE void __CFCSetAllocateAnnexForPlane(CFCharacterSetRef cset, int plane) {
+    if (cset->_annex == NULL) {
+        ((CFMutableCharacterSetRef)cset)->_annex = (CFCharSetAnnexStruct *)CFAllocatorAllocate(CFGetAllocator(cset), sizeof(CFCharSetAnnexStruct), 0);
+        cset->_annex->_numOfAllocEntries = plane;
+        cset->_annex->_isAnnexInverted = false;
+        cset->_annex->_validEntriesBitmap = 0;
+        cset->_annex->_nonBMPPlanes = ((plane > 0) ? (CFCharacterSetRef*)CFAllocatorAllocate(CFGetAllocator(cset), sizeof(CFCharacterSetRef) * plane, 0) : NULL);
+    } else if (cset->_annex->_numOfAllocEntries < plane) {
+        cset->_annex->_numOfAllocEntries = plane;
+        if (NULL == cset->_annex->_nonBMPPlanes) {
+            cset->_annex->_nonBMPPlanes = (CFCharacterSetRef*)CFAllocatorAllocate(CFGetAllocator(cset), sizeof(CFCharacterSetRef) * plane, 0);
+        } else {
+            cset->_annex->_nonBMPPlanes = (CFCharacterSetRef*)CFAllocatorReallocate(CFGetAllocator(cset), (void *)cset->_annex->_nonBMPPlanes, sizeof(CFCharacterSetRef) * plane, 0);
+        }
+    }
+}
+
+CF_INLINE void __CFCSetAnnexSetIsInverted(CFCharacterSetRef cset, Boolean flag) {
+    if (flag) __CFCSetAllocateAnnexForPlane(cset, 0);
+    if (cset->_annex) ((CFMutableCharacterSetRef)cset)->_annex->_isAnnexInverted = flag;
+}
+                                      
+CF_INLINE void __CFCSetPutCharacterSetToAnnexPlane(CFCharacterSetRef cset, CFCharacterSetRef annexCSet, int plane) {
+    __CFCSetAllocateAnnexForPlane(cset, plane);
+    if (__CFCSetAnnexBitmapGetPlane(cset->_annex->_validEntriesBitmap, plane)) CFRelease(cset->_annex->_nonBMPPlanes[plane - 1]);
+    if (annexCSet) {
+        cset->_annex->_nonBMPPlanes[plane - 1] = (CFCharacterSetRef)CFRetain(annexCSet);
+        __CFCSetAnnexBitmapSetPlane(cset->_annex->_validEntriesBitmap, plane);
+    } else {
+        __CFCSetAnnexBitmapClearPlane(cset->_annex->_validEntriesBitmap, plane);
+    }
+}
+
+CF_INLINE CFCharacterSetRef __CFCSetGetAnnexPlaneCharacterSet(CFCharacterSetRef cset, int plane) {
+    __CFCSetAllocateAnnexForPlane(cset, plane);
+    if (!__CFCSetAnnexBitmapGetPlane(cset->_annex->_validEntriesBitmap, plane)) {
+        cset->_annex->_nonBMPPlanes[plane - 1] = (CFCharacterSetRef)CFCharacterSetCreateMutable(CFGetAllocator(cset));
+        __CFCSetAnnexBitmapSetPlane(cset->_annex->_validEntriesBitmap, plane);
+    }
+    return cset->_annex->_nonBMPPlanes[plane - 1];
+}
+
+CF_INLINE CFCharacterSetRef __CFCSetGetAnnexPlaneCharacterSetNoAlloc(CFCharacterSetRef cset, int plane) {
+    return (cset->_annex && __CFCSetAnnexBitmapGetPlane(cset->_annex->_validEntriesBitmap, plane) ? cset->_annex->_nonBMPPlanes[plane - 1] : NULL);
+}
+
+CF_INLINE void __CFCSetDeallocateAnnexPlane(CFCharacterSetRef cset) {
+    if (cset->_annex) {
+        int idx;
+        
+        for (idx = 0;idx < MAX_ANNEX_PLANE;idx++) {
+            if (__CFCSetAnnexBitmapGetPlane(cset->_annex->_validEntriesBitmap, idx + 1)) {
+                CFRelease(cset->_annex->_nonBMPPlanes[idx]);
+            }
+        }
+        CFAllocatorDeallocate(CFGetAllocator(cset), cset->_annex->_nonBMPPlanes);
+        CFAllocatorDeallocate(CFGetAllocator(cset), cset->_annex);
+        ((CFMutableCharacterSetRef)cset)->_annex = NULL;
+    }
+}
+
+CF_INLINE uint8_t __CFCSetGetHeaderValue(const uint8_t *bitmap, int *numPages) {
+    uint8_t value = *bitmap;
+
+    if ((value == 0) || (value == UINT8_MAX)) {
+        int numBytes = __kCFCompactBitmapPageSize - 1;
+
+        while (numBytes > 0) {
+            if (*(++bitmap) != value) break;
+            --numBytes;
+        }
+        if (numBytes == 0) return value;
+    }
+    return (uint8_t)(++(*numPages));
+}
+
+CF_INLINE bool __CFCSetIsMemberInCompactBitmap(const uint8_t *compactBitmap, UTF16Char character) {
+    uint8_t value = compactBitmap[(character >> 8)]; // Assuming __kCFCompactBitmapNumPages == 256
+
+    if (value == 0) {
+        return false;
+    } else if (value == UINT8_MAX) {
+        return true;
+    } else {
+        compactBitmap += (__kCFCompactBitmapNumPages + (__kCFCompactBitmapPageSize * (value - 1)));
+        character &= 0xFF; // Assuming __kCFCompactBitmapNumPages == 256
+        return ((compactBitmap[(character / BITSPERBYTE)] & (1 << (character % BITSPERBYTE))) ? true : false);
+    }
+}
+
+CF_INLINE uint32_t __CFCSetGetCompactBitmapSize(const uint8_t *compactBitmap) {
+    uint32_t length = __kCFCompactBitmapNumPages;
+    uint32_t size = __kCFCompactBitmapNumPages;
+    uint8_t value;
+
+    while (length-- > 0) {
+        value = *(compactBitmap++);
+        if ((value != 0) && (value != UINT8_MAX)) size += __kCFCompactBitmapPageSize;
+    }
+    return size;
+}
+
+/* Take a private "set" structure and make a bitmap from it.  Return the bitmap.  THE CALLER MUST RELEASE THE RETURNED MEMORY as necessary.
+*/
+
+CF_INLINE void __CFCSetBitmapProcessManyCharacters(unsigned char *map, unsigned n, unsigned m, Boolean isInverted) {
+    if (isInverted) {
+        __CFCSetBitmapRemoveCharactersInRange(map, n, m);
+    } else {
+        __CFCSetBitmapAddCharactersInRange(map, n, m);
+    }
+}
+
+CF_INLINE void __CFExpandCompactBitmap(const uint8_t *src, uint8_t *dst) {
+    const uint8_t *srcBody = src + __kCFCompactBitmapNumPages;
+    int i;
+    uint8_t value;
+
+    for (i = 0;i < __kCFCompactBitmapNumPages;i++) {
+        value = *(src++);
+        if ((value == 0) || (value == UINT8_MAX)) {
+            memset(dst, value, __kCFCompactBitmapPageSize);
+        } else {
+            memmove(dst, srcBody, __kCFCompactBitmapPageSize);
+            srcBody += __kCFCompactBitmapPageSize;
+        }
+        dst += __kCFCompactBitmapPageSize;
+    }
+}
+
+
+static void __CFCheckForExpandedSet(CFCharacterSetRef cset) {
+    static int8_t __CFNumberOfPlanesForLogging = -1;
+    static bool warnedOnce = false;
+
+    if (0 > __CFNumberOfPlanesForLogging) {
+        const char *envVar = getenv("CFCharacterSetCheckForExpandedSet");
+#if DEPLOYMENT_TARGET_MACOSX
+        long value = (envVar ? strtol_l(envVar, NULL, 0, NULL) : 0);
+#else
+        long value = (envVar ? strtol(envVar, NULL, 0) : 0);
+#endif
+        __CFNumberOfPlanesForLogging = (int8_t)(((value > 0) && (value <= 16)) ? value : 0);
+    }
+
+    if (__CFNumberOfPlanesForLogging) {
+        uint32_t entries = __CFCSetAnnexValidEntriesBitmap(cset);
+        int count = 0;
+
+        while (entries) {
+            if ((entries & 1) && (++count >= __CFNumberOfPlanesForLogging)) {
+                if (!warnedOnce) {
+                    CFLog(kCFLogLevelWarning, CFSTR("An expanded CFMutableCharacter has been detected.  Recommend to compact with CFCharacterSetCreateCopy"));
+		    warnedOnce = true;
+		}
+                break;
+            }
+            entries >>= 1;
+        }
+    }
+}
+
+static void __CFCSetGetBitmap(CFCharacterSetRef cset, uint8_t *bits) {
+    uint8_t *bitmap;
+    CFIndex length = __kCFBitmapSize;
+
+    if (__CFCSetIsBitmap(cset) && (bitmap = __CFCSetBitmapBits(cset))) {
+        memmove(bits, bitmap, __kCFBitmapSize);
+    } else {
+        Boolean isInverted = __CFCSetIsInverted(cset);
+        uint8_t value = (isInverted ? (uint8_t)-1 : 0);
+
+        bitmap = bits;
+        while (length--) *bitmap++ = value; // Initialize the buffer
+
+        if (!__CFCSetIsEmpty(cset)) {
+            switch (__CFCSetClassType(cset)) {
+                case __kCFCharSetClassBuiltin: {
+                    UInt8 result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(cset), 0, bits, (isInverted != 0));
+                    if (result == kCFUniCharBitmapEmpty && isInverted) {
+                        length = __kCFBitmapSize;
+                        bitmap = bits;
+                        while (length--) *bitmap++ = 0;
+                    } else if (result == kCFUniCharBitmapAll && !isInverted) {
+                        length = __kCFBitmapSize;
+                        bitmap = bits;
+                        while (length--) *bitmap++ = (UInt8)0xFF;
+                    }
+                }
+                    break;
+
+                case __kCFCharSetClassRange: {
+                    UInt32 theChar = __CFCSetRangeFirstChar(cset);
+                    if (theChar < NUMCHARACTERS) { // the range starts in BMP
+                        length = __CFCSetRangeLength(cset);
+                        if (theChar + length >= NUMCHARACTERS) length = NUMCHARACTERS - theChar;
+                        if (isInverted) {
+                            __CFCSetBitmapRemoveCharactersInRange(bits, theChar, (UniChar)(theChar + length) - 1);
+                        } else {
+                            __CFCSetBitmapAddCharactersInRange(bits, theChar, (UniChar)(theChar + length) - 1);
+                        }
+                    }
+                }
+                    break;
+
+                case __kCFCharSetClassString: {
+                    const UniChar *buffer = __CFCSetStringBuffer(cset);
+                    length = __CFCSetStringLength(cset);
+                    while (length--) (isInverted ? __CFCSetBitmapRemoveCharacter(bits, *buffer++) : __CFCSetBitmapAddCharacter(bits, *buffer++));
+                }
+                    break;
+
+                case __kCFCharSetClassCompactBitmap:
+                    __CFExpandCompactBitmap(__CFCSetCompactBitmapBits(cset), bits);
+                    break;
+            }
+        }
+    }
+}
+
+static Boolean __CFCharacterSetEqual(CFTypeRef cf1, CFTypeRef cf2);
+
+static Boolean __CFCSetIsEqualAnnex(CFCharacterSetRef cf1, CFCharacterSetRef cf2) {
+    CFCharacterSetRef subSet1;
+    CFCharacterSetRef subSet2;
+    Boolean isAnnexInvertStateIdentical = (__CFCSetAnnexIsInverted(cf1) == __CFCSetAnnexIsInverted(cf2) ? true: false);
+    int idx;
+
+    if (isAnnexInvertStateIdentical) {
+        if (__CFCSetAnnexValidEntriesBitmap(cf1) != __CFCSetAnnexValidEntriesBitmap(cf2)) return false;
+        for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+            subSet1 = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(cf1, idx);
+            subSet2 = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(cf2, idx);
+
+            if (subSet1 && !__CFCharacterSetEqual(subSet1, subSet2)) return false;
+        }
+    } else {
+        uint8_t bitsBuf[__kCFBitmapSize];
+        uint8_t bitsBuf2[__kCFBitmapSize];
+
+        for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+            subSet1 = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(cf1, idx);
+            subSet2 = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(cf2, idx);
+
+            if (subSet1 == NULL && subSet2 == NULL) {
+                return false;
+            } else if (subSet1 == NULL) {
+                if (__CFCSetIsBitmap(subSet2)) {
+                    if (!__CFCSetIsEqualBitmap((const UInt32 *)__CFCSetBitmapBits(subSet2), (const UInt32 *)-1)) {
+                        return false;
+                    }
+                } else {
+                    __CFCSetGetBitmap(subSet2, bitsBuf);
+                    if (!__CFCSetIsEqualBitmap((const UInt32 *)bitsBuf, (const UInt32 *)-1)) {
+                        return false;
+                    }
+                }
+            } else if (subSet2 == NULL) {
+                if (__CFCSetIsBitmap(subSet1)) {
+                    if (!__CFCSetIsEqualBitmap((const UInt32 *)__CFCSetBitmapBits(subSet1), (const UInt32 *)-1)) {
+                        return false;
+                    }
+                } else {
+                    __CFCSetGetBitmap(subSet1, bitsBuf);
+                    if (!__CFCSetIsEqualBitmap((const UInt32 *)bitsBuf, (const UInt32 *)-1)) {
+                        return false;
+                    }
+                }
+            } else {
+                Boolean isBitmap1 = __CFCSetIsBitmap(subSet1);
+                Boolean isBitmap2 = __CFCSetIsBitmap(subSet2);
+
+                if (isBitmap1 && isBitmap2) {
+                    if (!__CFCSetIsEqualBitmapInverted((const UInt32 *)__CFCSetBitmapBits(subSet1), (const UInt32 *)__CFCSetBitmapBits(subSet2))) {
+                        return false;
+                    }
+                } else if (!isBitmap1 && !isBitmap2) {
+                    __CFCSetGetBitmap(subSet1, bitsBuf);
+                    __CFCSetGetBitmap(subSet2, bitsBuf2);
+                    if (!__CFCSetIsEqualBitmapInverted((const UInt32 *)bitsBuf, (const UInt32 *)bitsBuf2)) {
+                        return false;
+                    }
+                } else {
+                    if (isBitmap2) {
+                        CFCharacterSetRef tmp = subSet2;
+                        subSet2 = subSet1;
+                        subSet1 = tmp;
+                    }
+                    __CFCSetGetBitmap(subSet2, bitsBuf);
+                    if (!__CFCSetIsEqualBitmapInverted((const UInt32 *)__CFCSetBitmapBits(subSet1), (const UInt32 *)bitsBuf)) {
+                        return false;
+                    }
+                }
+            }
+        }
+    }
+    return true;
+}
+
+/* Compact bitmap
+*/
+static uint8_t *__CFCreateCompactBitmap(CFAllocatorRef allocator, const uint8_t *bitmap) {
+    const uint8_t *src;
+    uint8_t *dst;
+    int i;
+    int numPages = 0;
+    uint8_t header[__kCFCompactBitmapNumPages];
+
+    src = bitmap;
+    for (i = 0;i < __kCFCompactBitmapNumPages;i++) {
+        header[i] = __CFCSetGetHeaderValue(src, &numPages);
+
+        // Allocating more pages is probably not interesting enough to be compact
+        if (numPages > __kCFCompactBitmapMaxPages) return NULL;
+        src += __kCFCompactBitmapPageSize;
+    }
+
+    dst = (uint8_t *)CFAllocatorAllocate(allocator, __kCFCompactBitmapNumPages + (__kCFCompactBitmapPageSize * numPages), 0);
+
+    if (numPages > 0) {
+        uint8_t *dstBody = dst + __kCFCompactBitmapNumPages;
+
+        src = bitmap;
+        for (i = 0;i < __kCFCompactBitmapNumPages;i++) {
+            dst[i] = header[i];
+    
+            if ((dst[i] != 0) && (dst[i] != UINT8_MAX)) {
+                memmove(dstBody, src, __kCFCompactBitmapPageSize);
+                dstBody += __kCFCompactBitmapPageSize;
+            }
+            src += __kCFCompactBitmapPageSize;
+        }
+    } else {
+        memmove(dst, header, __kCFCompactBitmapNumPages);
+    }
+
+    return dst;
+}
+
+static void __CFCSetMakeCompact(CFMutableCharacterSetRef cset) {
+    if (__CFCSetIsBitmap(cset) && __CFCSetBitmapBits(cset)) {
+        uint8_t *bitmap = __CFCSetBitmapBits(cset);
+        uint8_t *cBitmap = __CFCreateCompactBitmap(CFGetAllocator(cset), bitmap);
+
+        if (cBitmap) {
+            CFAllocatorDeallocate(CFGetAllocator(cset), bitmap);
+            __CFCSetPutClassType(cset, __kCFCharSetClassCompactBitmap);
+            __CFCSetPutCompactBitmapBits(cset, cBitmap);
+        }
+    }
+}
+
+static void __CFCSetAddNonBMPPlanesInRange(CFMutableCharacterSetRef cset, CFRange range) {
+    int firstChar = (range.location & 0xFFFF);
+    int maxChar = range.location + range.length;
+    int idx = range.location >> 16; // first plane
+    int maxPlane = (maxChar - 1) >> 16; // last plane
+    CFRange planeRange;
+    CFMutableCharacterSetRef annexPlane;
+
+    maxChar &= 0xFFFF;
+
+    for (idx = (idx ? idx : 1);idx <= maxPlane;idx++) {
+        planeRange.location = __CFMax(firstChar, 0);
+        planeRange.length = (idx == maxPlane && maxChar ? maxChar : 0x10000) - planeRange.location;
+        if (__CFCSetAnnexIsInverted(cset)) {
+            if ((annexPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(cset, idx))) {
+                CFCharacterSetRemoveCharactersInRange(annexPlane, planeRange);
+                if (__CFCSetIsEmpty(annexPlane) && !__CFCSetIsInverted(annexPlane)) {
+                    CFRelease(annexPlane);
+                    __CFCSetAnnexBitmapClearPlane(cset->_annex->_validEntriesBitmap, idx);
+                }
+            }
+        } else {
+            CFCharacterSetAddCharactersInRange((CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(cset, idx), planeRange);
+        }
+    }
+    if (!__CFCSetHasNonBMPPlane(cset) && !__CFCSetAnnexIsInverted(cset)) __CFCSetDeallocateAnnexPlane(cset);
+}
+
+static void __CFCSetRemoveNonBMPPlanesInRange(CFMutableCharacterSetRef cset, CFRange range) {
+    int firstChar = (range.location & 0xFFFF);
+    int maxChar = range.location + range.length;
+    int idx = range.location >> 16; // first plane
+    int maxPlane = (maxChar - 1) >> 16; // last plane
+    CFRange planeRange;
+    CFMutableCharacterSetRef annexPlane;
+
+    maxChar &= 0xFFFF;
+
+    for (idx = (idx ? idx : 1);idx <= maxPlane;idx++) {
+        planeRange.location = __CFMax(firstChar, 0);
+        planeRange.length = (idx == maxPlane && maxChar ? maxChar : 0x10000) - planeRange.location;
+        if (__CFCSetAnnexIsInverted(cset)) {
+            CFCharacterSetAddCharactersInRange((CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(cset, idx), planeRange);
+        } else {
+            if ((annexPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(cset, idx))) {
+                CFCharacterSetRemoveCharactersInRange(annexPlane, planeRange);
+                if(__CFCSetIsEmpty(annexPlane) && !__CFCSetIsInverted(annexPlane)) {
+                    CFRelease(annexPlane);
+                    __CFCSetAnnexBitmapClearPlane(cset->_annex->_validEntriesBitmap, idx);
+                }
+            }
+        }
+    }
+    if (!__CFCSetHasNonBMPPlane(cset) && !__CFCSetAnnexIsInverted(cset)) __CFCSetDeallocateAnnexPlane(cset);
+}
+
+static void __CFCSetMakeBitmap(CFMutableCharacterSetRef cset) {
+    if (!__CFCSetIsBitmap(cset) || !__CFCSetBitmapBits(cset)) {
+        CFAllocatorRef allocator = CFGetAllocator(cset);
+        uint8_t *bitmap = (uint8_t *)CFAllocatorAllocate(allocator, __kCFBitmapSize, 0);
+        __CFCSetGetBitmap(cset, bitmap);
+        
+        if (__CFCSetIsBuiltin(cset)) {
+            CFIndex numPlanes = CFUniCharGetNumberOfPlanes(__CFCSetBuiltinType(cset));
+
+            if (numPlanes > 1) {
+                CFMutableCharacterSetRef annexSet;
+                uint8_t *annexBitmap = NULL;
+                int idx;
+                UInt8 result;
+
+                __CFCSetAllocateAnnexForPlane(cset, numPlanes - 1);
+                for (idx = 1;idx < numPlanes;idx++) {
+                    if (NULL == annexBitmap) {
+                        annexBitmap = (uint8_t *)CFAllocatorAllocate(allocator, __kCFBitmapSize, 0);
+                    }
+                    result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(cset), idx, annexBitmap, false);
+                    if (result == kCFUniCharBitmapEmpty) continue;
+                    if (result == kCFUniCharBitmapAll) {
+                        CFIndex bitmapLength = __kCFBitmapSize;
+                        uint8_t *bytes = annexBitmap;
+                        while (bitmapLength-- > 0) *(bytes++) = (uint8_t)0xFF;
+                    }
+                    annexSet = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(cset, idx);
+                    __CFCSetPutClassType(annexSet, __kCFCharSetClassBitmap);
+                    __CFCSetPutBitmapBits(annexSet, annexBitmap);
+                    __CFCSetPutIsInverted(annexSet, false);
+                    __CFCSetPutHasHashValue(annexSet, false);
+                    annexBitmap = NULL;
+                }
+                if (annexBitmap) CFAllocatorDeallocate(allocator, annexBitmap);
+            }
+        } else if (__CFCSetIsCompactBitmap(cset) && __CFCSetCompactBitmapBits(cset)) {
+            CFAllocatorDeallocate(allocator, __CFCSetCompactBitmapBits(cset));
+            __CFCSetPutCompactBitmapBits(cset, NULL);
+        } else if (__CFCSetIsString(cset) && __CFCSetStringBuffer(cset)) {
+            CFAllocatorDeallocate(allocator, __CFCSetStringBuffer(cset));
+            __CFCSetPutStringBuffer(cset, NULL);
+        } else if (__CFCSetIsRange(cset)) { // We may have to allocate annex here
+            Boolean needsToInvert = (!__CFCSetHasNonBMPPlane(cset) && __CFCSetIsInverted(cset) ? true : false);
+            __CFCSetAddNonBMPPlanesInRange(cset, CFRangeMake(__CFCSetRangeFirstChar(cset), __CFCSetRangeLength(cset)));
+            if (needsToInvert) __CFCSetAnnexSetIsInverted(cset, true);
+        }
+        __CFCSetPutClassType(cset, __kCFCharSetClassBitmap);
+        __CFCSetPutBitmapBits(cset, bitmap);
+        __CFCSetPutIsInverted(cset, false);
+    }    
+}
+
+CF_INLINE CFMutableCharacterSetRef __CFCSetGenericCreate(CFAllocatorRef allocator, UInt32 flags) {
+    CFMutableCharacterSetRef cset;
+    CFIndex size = sizeof(struct __CFCharacterSet) - sizeof(CFRuntimeBase);
+
+    cset = (CFMutableCharacterSetRef)_CFRuntimeCreateInstance(allocator, CFCharacterSetGetTypeID(), size, NULL);
+    if (NULL == cset) return NULL;
+
+    cset->_base._cfinfo[CF_INFO_BITS] |= flags;
+    cset->_hashValue = 0;
+    cset->_annex = NULL;
+
+    return cset;
+}
+
+/* Bsearch theChar for __kCFCharSetClassString
+*/
+CF_INLINE Boolean __CFCSetBsearchUniChar(const UniChar *theTable, CFIndex length, UniChar theChar) {
+    const UniChar *p, *q, *divider;
+
+    if ((theChar < theTable[0]) || (theChar > theTable[length - 1])) return false;
+
+    p = theTable;
+    q = p + (length - 1);
+    while (p <= q) {
+        divider = p + ((q - p) >> 1);	/* divide by 2 */
+        if (theChar < *divider) q = divider - 1;
+        else if (theChar > *divider) p = divider + 1;
+        else return true;
+    }
+    return false;
+}
+
+/* Predefined cset names
+ Need to add entry here for new builtin types
+*/
+CONST_STRING_DECL(__kCFCSetNameControl, "<CFCharacterSet Predefined Control Set>")
+CONST_STRING_DECL(__kCFCSetNameWhitespace, "<CFCharacterSet Predefined Whitespace Set>")
+CONST_STRING_DECL(__kCFCSetNameWhitespaceAndNewline, "<CFCharacterSet Predefined WhitespaceAndNewline Set>")
+CONST_STRING_DECL(__kCFCSetNameDecimalDigit, "<CFCharacterSet Predefined DecimalDigit Set>")
+CONST_STRING_DECL(__kCFCSetNameLetter, "<CFCharacterSet Predefined Letter Set>")
+CONST_STRING_DECL(__kCFCSetNameLowercaseLetter, "<CFCharacterSet Predefined LowercaseLetter Set>")
+CONST_STRING_DECL(__kCFCSetNameUppercaseLetter, "<CFCharacterSet Predefined UppercaseLetter Set>")
+CONST_STRING_DECL(__kCFCSetNameNonBase, "<CFCharacterSet Predefined NonBase Set>")
+CONST_STRING_DECL(__kCFCSetNameDecomposable, "<CFCharacterSet Predefined Decomposable Set>")
+CONST_STRING_DECL(__kCFCSetNameAlphaNumeric, "<CFCharacterSet Predefined AlphaNumeric Set>")
+CONST_STRING_DECL(__kCFCSetNamePunctuation, "<CFCharacterSet Predefined Punctuation Set>")
+CONST_STRING_DECL(__kCFCSetNameIllegal, "<CFCharacterSet Predefined Illegal Set>")
+CONST_STRING_DECL(__kCFCSetNameCapitalizedLetter, "<CFCharacterSet Predefined CapitalizedLetter Set>")
+CONST_STRING_DECL(__kCFCSetNameSymbol, "<CFCharacterSet Predefined Symbol Set>")
+CONST_STRING_DECL(__kCFCSetNameNewline, "<CFCharacterSet Predefined Newline Set>")
+
+CONST_STRING_DECL(__kCFCSetNameStringTypeFormat, "<CFCharacterSet Items(")
+
+/* Array of instantiated builtin set. Note builtin set ID starts with 1 so the array index is ID - 1
+*/
+static CFCharacterSetRef *__CFBuiltinSets = NULL;
+
+/* Global lock for character set
+*/
+static CFSpinLock_t __CFCharacterSetLock = CFSpinLockInit;
+
+/* CFBase API functions
+*/
+static Boolean __CFCharacterSetEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    Boolean isInvertStateIdentical = (__CFCSetIsInverted((CFCharacterSetRef)cf1) == __CFCSetIsInverted((CFCharacterSetRef)cf2) ? true: false);
+    Boolean isAnnexInvertStateIdentical = (__CFCSetAnnexIsInverted((CFCharacterSetRef)cf1) == __CFCSetAnnexIsInverted((CFCharacterSetRef)cf2) ? true: false);
+    CFIndex idx;
+    CFCharacterSetRef subSet1;
+    uint8_t bitsBuf[__kCFBitmapSize];
+    uint8_t *bits;
+    Boolean isBitmap1;
+    Boolean isBitmap2;
+
+    if (__CFCSetHasHashValue((CFCharacterSetRef)cf1) && __CFCSetHasHashValue((CFCharacterSetRef)cf2) && ((CFCharacterSetRef)cf1)->_hashValue != ((CFCharacterSetRef)cf2)->_hashValue) return false;
+    if (__CFCSetIsEmpty((CFCharacterSetRef)cf1) && __CFCSetIsEmpty((CFCharacterSetRef)cf2) && !isInvertStateIdentical) return false;
+
+    if (__CFCSetClassType((CFCharacterSetRef)cf1) == __CFCSetClassType((CFCharacterSetRef)cf2)) { // Types are identical, we can do it fast
+        switch (__CFCSetClassType((CFCharacterSetRef)cf1)) {
+            case __kCFCharSetClassBuiltin:
+                return (__CFCSetBuiltinType((CFCharacterSetRef)cf1) == __CFCSetBuiltinType((CFCharacterSetRef)cf2) && isInvertStateIdentical ? true : false);
+
+            case __kCFCharSetClassRange:
+                return (__CFCSetRangeFirstChar((CFCharacterSetRef)cf1) == __CFCSetRangeFirstChar((CFCharacterSetRef)cf2) && __CFCSetRangeLength((CFCharacterSetRef)cf1) && __CFCSetRangeLength((CFCharacterSetRef)cf2) && isInvertStateIdentical ? true : false);
+
+            case __kCFCharSetClassString:
+                if (__CFCSetStringLength((CFCharacterSetRef)cf1) == __CFCSetStringLength((CFCharacterSetRef)cf2) && isInvertStateIdentical) {
+                    const UniChar *buf1 = __CFCSetStringBuffer((CFCharacterSetRef)cf1);
+                    const UniChar *buf2 = __CFCSetStringBuffer((CFCharacterSetRef)cf2);
+                    CFIndex length = __CFCSetStringLength((CFCharacterSetRef)cf1);
+
+                    while (length--) if (*buf1++ != *buf2++) return false;
+                } else {
+                    return false;
+                }
+                break;
+
+            case __kCFCharSetClassBitmap:
+                if (!__CFCSetIsEqualBitmap((const UInt32 *)__CFCSetBitmapBits((CFCharacterSetRef)cf1), (const UInt32 *)__CFCSetBitmapBits((CFCharacterSetRef)cf2))) return false;
+                break;
+        }
+        return __CFCSetIsEqualAnnex((CFCharacterSetRef)cf1, (CFCharacterSetRef)cf2);
+    }
+
+    // Check for easy empty cases
+    if (__CFCSetIsEmpty((CFCharacterSetRef)cf1) || __CFCSetIsEmpty((CFCharacterSetRef)cf2)) {
+        CFCharacterSetRef emptySet = (__CFCSetIsEmpty((CFCharacterSetRef)cf1) ? (CFCharacterSetRef)cf1 : (CFCharacterSetRef)cf2);
+        CFCharacterSetRef nonEmptySet = (emptySet == cf1 ? (CFCharacterSetRef)cf2 : (CFCharacterSetRef)cf1);
+
+        if (__CFCSetIsBuiltin(nonEmptySet)) {
+            return false;
+        } else if (__CFCSetIsRange(nonEmptySet)) {
+            if (isInvertStateIdentical) {
+                return (__CFCSetRangeLength(nonEmptySet) ? false : true);
+            } else {
+                return (__CFCSetRangeLength(nonEmptySet) == 0x110000 ? true : false);
+            }
+        } else {
+            if (__CFCSetAnnexIsInverted(nonEmptySet)) {
+                if (__CFCSetAnnexValidEntriesBitmap(nonEmptySet) != 0x1FFFE) return false;
+            } else {
+                if (__CFCSetAnnexValidEntriesBitmap(nonEmptySet)) return false;
+            }
+
+            if (__CFCSetIsBitmap(nonEmptySet)) {
+                bits = __CFCSetBitmapBits(nonEmptySet);
+            } else {
+                bits = bitsBuf;
+                __CFCSetGetBitmap(nonEmptySet, bitsBuf);
+            }
+
+            if (__CFCSetIsEqualBitmap(NULL, (const UInt32 *)bits)) {
+                if (!__CFCSetAnnexIsInverted(nonEmptySet)) return true;
+            } else {
+                return false;
+            }
+
+            // Annex set has to be CFRangeMake(0x10000, 0xfffff)
+            for (idx = 1;idx < MAX_ANNEX_PLANE;idx++) {
+                if (__CFCSetIsBitmap(nonEmptySet)) {
+                    if (!__CFCSetIsEqualBitmap((__CFCSetAnnexIsInverted(nonEmptySet) ? NULL : (const UInt32 *)-1), (const UInt32 *)bitsBuf)) return false;
+                } else {
+                    __CFCSetGetBitmap(__CFCSetGetAnnexPlaneCharacterSetNoAlloc(nonEmptySet, idx), bitsBuf);
+                    if (!__CFCSetIsEqualBitmap((const UInt32 *)-1, (const UInt32 *)bitsBuf)) return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    if (__CFCSetIsBuiltin((CFCharacterSetRef)cf1) || __CFCSetIsBuiltin((CFCharacterSetRef)cf2)) {
+        CFCharacterSetRef builtinSet = (__CFCSetIsBuiltin((CFCharacterSetRef)cf1) ? (CFCharacterSetRef)cf1 : (CFCharacterSetRef)cf2);
+        CFCharacterSetRef nonBuiltinSet = (builtinSet == cf1 ? (CFCharacterSetRef)cf2 : (CFCharacterSetRef)cf1);
+        
+
+        if (__CFCSetIsRange(nonBuiltinSet)) {
+            UTF32Char firstChar = __CFCSetRangeFirstChar(nonBuiltinSet);
+            UTF32Char lastChar = (firstChar + __CFCSetRangeLength(nonBuiltinSet) - 1);
+            uint8_t firstPlane = (firstChar >> 16) & 0xFF;
+            uint8_t lastPlane = (lastChar >> 16) & 0xFF;
+            uint8_t result;
+
+            for (idx = 0;idx < MAX_ANNEX_PLANE;idx++) {
+                result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(builtinSet), idx, bitsBuf, (isInvertStateIdentical != 0));
+
+                if (idx < firstPlane || idx > lastPlane) {
+                    if (result == kCFUniCharBitmapAll) {
+                        return false;
+                    } else if (result == kCFUniCharBitmapFilled) {
+                        if (!__CFCSetIsEqualBitmap(NULL, (const UInt32 *)bitsBuf)) return false;
+                    }
+                } else if (idx > firstPlane && idx < lastPlane) {
+                    if (result == kCFUniCharBitmapEmpty) {
+                        return false;
+                    } else if (result == kCFUniCharBitmapFilled) {
+                        if (!__CFCSetIsEqualBitmap((const UInt32 *)-1, (const UInt32 *)bitsBuf)) return false;
+                    }
+                } else {
+                    if (result == kCFUniCharBitmapEmpty) {
+                        return false;
+                    } else if (result == kCFUniCharBitmapAll) {
+                        if (idx == firstPlane) {
+                            if (((firstChar & 0xFFFF) != 0) || (firstPlane == lastPlane && ((lastChar & 0xFFFF) != 0xFFFF))) return false;
+                        } else {
+                            if (((lastChar & 0xFFFF) != 0xFFFF) || (firstPlane == lastPlane && ((firstChar & 0xFFFF) != 0))) return false;
+                        }
+                    } else {
+                        if (idx == firstPlane) {
+                            if (!__CFCSetIsBitmapEqualToRange((const UInt32 *)bitsBuf, firstChar & 0xFFFF, (firstPlane == lastPlane ? lastChar & 0xFFFF : 0xFFFF), false)) return false;
+                        } else {
+                            if (!__CFCSetIsBitmapEqualToRange((const UInt32 *)bitsBuf, (firstPlane == lastPlane ? firstChar & 0xFFFF : 0), lastChar & 0xFFFF, false)) return false;
+                        }
+                    }
+                }
+            }
+            return true;
+        } else  {
+            uint8_t bitsBuf2[__kCFBitmapSize];
+            uint8_t result;
+
+            result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(builtinSet), 0, bitsBuf, (__CFCSetIsInverted(builtinSet) != 0));
+            if (result == kCFUniCharBitmapFilled) {
+                if (__CFCSetIsBitmap(nonBuiltinSet)) {
+                    if (!__CFCSetIsEqualBitmap((const UInt32 *)bitsBuf, (const UInt32 *)__CFCSetBitmapBits(nonBuiltinSet))) return false;
+                } else {
+
+                    __CFCSetGetBitmap(nonBuiltinSet, bitsBuf2);
+                    if (!__CFCSetIsEqualBitmap((const UInt32 *)bitsBuf, (const UInt32 *)bitsBuf2)) {
+                        return false;
+                    }
+                }
+            } else {
+                if (__CFCSetIsBitmap(nonBuiltinSet)) {
+                    if (!__CFCSetIsEqualBitmap((result == kCFUniCharBitmapAll ? (const UInt32*)-1 : NULL), (const UInt32 *)__CFCSetBitmapBits(nonBuiltinSet))) return false;
+                } else {
+                    __CFCSetGetBitmap(nonBuiltinSet, bitsBuf);
+                    if (!__CFCSetIsEqualBitmap((result == kCFUniCharBitmapAll ? (const UInt32*)-1: NULL), (const UInt32 *)bitsBuf)) return false;
+                }
+            }
+
+            isInvertStateIdentical = (__CFCSetIsInverted(builtinSet) == __CFCSetAnnexIsInverted(nonBuiltinSet) ? true : false);
+
+            for (idx = 1;idx < MAX_ANNEX_PLANE;idx++) {
+                result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(builtinSet), idx, bitsBuf, !isInvertStateIdentical);
+                subSet1 = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(nonBuiltinSet, idx);
+
+                if (result == kCFUniCharBitmapFilled) {
+                    if (NULL == subSet1) {
+                        return false;
+                    } else if (__CFCSetIsBitmap(subSet1)) {
+                        if (!__CFCSetIsEqualBitmap((const UInt32*)bitsBuf, (const UInt32*)__CFCSetBitmapBits(subSet1))) {
+                            return false;
+                        }
+                    } else {
+
+                        __CFCSetGetBitmap(subSet1, bitsBuf2);
+                        if (!__CFCSetIsEqualBitmap((const UInt32*)bitsBuf, (const UInt32*)bitsBuf2)) {
+                            return false;
+                        }
+                    }
+                } else {
+                    if (NULL == subSet1) {
+                        if (result == kCFUniCharBitmapAll) {
+                            return false;
+                        }
+                    } else if (__CFCSetIsBitmap(subSet1)) {
+                        if (!__CFCSetIsEqualBitmap((result == kCFUniCharBitmapAll ? (const UInt32*)-1: NULL), (const UInt32*)__CFCSetBitmapBits(subSet1))) {
+                            return false;
+                        }
+                    } else {
+                        __CFCSetGetBitmap(subSet1, bitsBuf);
+                        if (!__CFCSetIsEqualBitmap((result == kCFUniCharBitmapAll ? (const UInt32*)-1: NULL), (const UInt32*)bitsBuf)) {
+                            return false;
+                        }
+                    }
+                }
+            }
+            return true;
+        }
+    }
+
+    if (__CFCSetIsRange((CFCharacterSetRef)cf1) || __CFCSetIsRange((CFCharacterSetRef)cf2)) {
+        CFCharacterSetRef rangeSet = (__CFCSetIsRange((CFCharacterSetRef)cf1) ? (CFCharacterSetRef)cf1 : (CFCharacterSetRef)cf2);
+        CFCharacterSetRef nonRangeSet = (rangeSet == cf1 ? (CFCharacterSetRef)cf2 : (CFCharacterSetRef)cf1);
+        UTF32Char firstChar = __CFCSetRangeFirstChar(rangeSet);
+        UTF32Char lastChar = (firstChar + __CFCSetRangeLength(rangeSet) - 1);
+        uint8_t firstPlane = (firstChar >> 16) & 0xFF;
+        uint8_t lastPlane = (lastChar >> 16) & 0xFF;
+        Boolean isRangeSetInverted = __CFCSetIsInverted(rangeSet);
+
+        if (__CFCSetIsBitmap(nonRangeSet)) {
+            bits = __CFCSetBitmapBits(nonRangeSet);
+        } else {
+            bits = bitsBuf;
+            __CFCSetGetBitmap(nonRangeSet, bitsBuf);
+        }
+        if (firstPlane == 0) {
+            if (!__CFCSetIsBitmapEqualToRange((const UInt32*)bits, firstChar, (lastPlane == 0 ? lastChar : 0xFFFF), isRangeSetInverted)) return false;
+	    firstPlane = 1;
+	    firstChar = 0;
+        } else {
+            if (!__CFCSetIsEqualBitmap((const UInt32*)bits, (isRangeSetInverted ? (const UInt32 *)-1 : NULL))) return false;
+	    firstChar &= 0xFFFF;
+        }
+
+	lastChar &= 0xFFFF;
+
+        isAnnexInvertStateIdentical = (isRangeSetInverted == __CFCSetAnnexIsInverted(nonRangeSet) ? true : false);
+
+        for (idx = 1;idx < MAX_ANNEX_PLANE;idx++) {
+            subSet1 = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(nonRangeSet, idx);
+            if (NULL == subSet1) {
+                if (idx < firstPlane || idx > lastPlane) {
+                    if (!isAnnexInvertStateIdentical) return false;
+                } else if (idx > firstPlane && idx < lastPlane) {
+                    if (isAnnexInvertStateIdentical) return false;
+                } else if (idx == firstPlane) {
+                    if (isAnnexInvertStateIdentical || firstChar || (idx == lastPlane && lastChar != 0xFFFF)) return false;
+                } else if (idx == lastPlane) {
+                    if (isAnnexInvertStateIdentical || (idx == firstPlane && firstChar) || (lastChar != 0xFFFF)) return false;
+                }
+            } else {
+                if (__CFCSetIsBitmap(subSet1)) {
+                    bits = __CFCSetBitmapBits(subSet1);
+                } else {
+                    __CFCSetGetBitmap(subSet1, bitsBuf);
+                    bits = bitsBuf;
+                }
+
+                if (idx < firstPlane || idx > lastPlane) {
+                    if (!__CFCSetIsEqualBitmap((const UInt32*)bits, (isAnnexInvertStateIdentical ? NULL : (const UInt32 *)-1))) return false;
+                } else if (idx > firstPlane && idx < lastPlane) {
+                    if (!__CFCSetIsEqualBitmap((const UInt32*)bits, (isAnnexInvertStateIdentical ? (const UInt32 *)-1 : NULL))) return false;
+                } else if (idx == firstPlane) {
+                    if (!__CFCSetIsBitmapEqualToRange((const UInt32*)bits, firstChar, (idx == lastPlane ? lastChar : 0xFFFF), !isAnnexInvertStateIdentical)) return false;
+                } else if (idx == lastPlane) {
+                    if (!__CFCSetIsBitmapEqualToRange((const UInt32*)bits, (idx == firstPlane ? firstChar : 0), lastChar, !isAnnexInvertStateIdentical)) return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    isBitmap1 = __CFCSetIsBitmap((CFCharacterSetRef)cf1);
+    isBitmap2 = __CFCSetIsBitmap((CFCharacterSetRef)cf2);
+
+    if (isBitmap1 && isBitmap2) {
+        if (!__CFCSetIsEqualBitmap((const UInt32 *)__CFCSetBitmapBits((CFCharacterSetRef)cf1), (const UInt32 *)__CFCSetBitmapBits((CFCharacterSetRef)cf2))) return false;
+    } else if (!isBitmap1 && !isBitmap2) {
+        uint8_t bitsBuf2[__kCFBitmapSize];
+
+        __CFCSetGetBitmap((CFCharacterSetRef)cf1, bitsBuf);
+        __CFCSetGetBitmap((CFCharacterSetRef)cf2, bitsBuf2);
+
+        if (!__CFCSetIsEqualBitmap((const UInt32*)bitsBuf, (const UInt32*)bitsBuf2)) {
+            return false;
+        }
+    } else {
+        if (isBitmap2) {
+            CFCharacterSetRef tmp = (CFCharacterSetRef)cf2;
+            cf2 = cf1;
+            cf1 = tmp;
+        }
+
+        __CFCSetGetBitmap((CFCharacterSetRef)cf2, bitsBuf);
+
+        if (!__CFCSetIsEqualBitmap((const UInt32 *)__CFCSetBitmapBits((CFCharacterSetRef)cf1), (const UInt32 *)bitsBuf)) return false;
+    }
+    return __CFCSetIsEqualAnnex((CFCharacterSetRef)cf1, (CFCharacterSetRef)cf2);
+}
+
+static CFHashCode __CFCharacterSetHash(CFTypeRef cf) {
+    if (!__CFCSetHasHashValue((CFCharacterSetRef)cf)) {
+        if (__CFCSetIsEmpty((CFCharacterSetRef)cf)) {
+            ((CFMutableCharacterSetRef)cf)->_hashValue = (__CFCSetIsInverted((CFCharacterSetRef)cf) ? ((UInt32)0xFFFFFFFF) : 0);
+        } else if (__CFCSetIsBitmap( (CFCharacterSetRef) cf  )) {
+            ((CFMutableCharacterSetRef)cf)->_hashValue = CFHashBytes(__CFCSetBitmapBits((CFCharacterSetRef)cf), __kCFBitmapSize);
+        } else {
+            uint8_t bitsBuf[__kCFBitmapSize];
+            __CFCSetGetBitmap((CFCharacterSetRef)cf, bitsBuf);
+            ((CFMutableCharacterSetRef)cf)->_hashValue = CFHashBytes(bitsBuf, __kCFBitmapSize);
+        }
+        __CFCSetPutHasHashValue((CFMutableCharacterSetRef)cf, true);
+    }
+    return ((CFCharacterSetRef)cf)->_hashValue;
+}
+
+static CFStringRef  __CFCharacterSetCopyDescription(CFTypeRef cf) {
+    CFMutableStringRef string;
+    CFIndex idx;
+    CFIndex length;
+
+    if (__CFCSetIsEmpty((CFCharacterSetRef)cf)) {
+	return (CFStringRef)(__CFCSetIsInverted((CFCharacterSetRef)cf) ? CFRetain(CFSTR("<CFCharacterSet All>")) : CFRetain(CFSTR("<CFCharacterSet Empty>")));
+    }
+
+    switch (__CFCSetClassType((CFCharacterSetRef)cf)) {
+        case __kCFCharSetClassBuiltin:
+            switch (__CFCSetBuiltinType((CFCharacterSetRef)cf)) {
+                case kCFCharacterSetControl: return (CFStringRef)CFRetain(__kCFCSetNameControl);
+                case kCFCharacterSetWhitespace : return (CFStringRef)CFRetain(__kCFCSetNameWhitespace);
+                case kCFCharacterSetWhitespaceAndNewline: return (CFStringRef)CFRetain(__kCFCSetNameWhitespaceAndNewline);
+                case kCFCharacterSetDecimalDigit: return (CFStringRef)CFRetain(__kCFCSetNameDecimalDigit);
+                case kCFCharacterSetLetter: return (CFStringRef)CFRetain(__kCFCSetNameLetter);
+                case kCFCharacterSetLowercaseLetter: return (CFStringRef)CFRetain(__kCFCSetNameLowercaseLetter);
+                case kCFCharacterSetUppercaseLetter: return (CFStringRef)CFRetain(__kCFCSetNameUppercaseLetter);
+                case kCFCharacterSetNonBase: return (CFStringRef)CFRetain(__kCFCSetNameNonBase);
+                case kCFCharacterSetDecomposable: return (CFStringRef)CFRetain(__kCFCSetNameDecomposable);
+                case kCFCharacterSetAlphaNumeric: return (CFStringRef)CFRetain(__kCFCSetNameAlphaNumeric);
+                case kCFCharacterSetPunctuation: return (CFStringRef)CFRetain(__kCFCSetNamePunctuation);
+                case kCFCharacterSetIllegal: return (CFStringRef)CFRetain(__kCFCSetNameIllegal);
+                case kCFCharacterSetCapitalizedLetter: return (CFStringRef)CFRetain(__kCFCSetNameCapitalizedLetter);
+                case kCFCharacterSetSymbol: return (CFStringRef)CFRetain(__kCFCSetNameSymbol);
+                case kCFCharacterSetNewline: return (CFStringRef)CFRetain(__kCFCSetNameNewline);
+            }
+            break;
+
+        case __kCFCharSetClassRange:
+            return CFStringCreateWithFormat(CFGetAllocator((CFCharacterSetRef)cf), NULL, CFSTR("<CFCharacterSet Range(%d, %d)>"), __CFCSetRangeFirstChar((CFCharacterSetRef)cf), __CFCSetRangeLength((CFCharacterSetRef)cf));
+
+        case __kCFCharSetClassString:
+            length = __CFCSetStringLength((CFCharacterSetRef)cf);
+            string = CFStringCreateMutable(CFGetAllocator(cf), CFStringGetLength(__kCFCSetNameStringTypeFormat) + 7 * length + 2); // length of__kCFCSetNameStringTypeFormat + "U+XXXX "(7) * length + ")>"(2)
+            CFStringAppend(string, __kCFCSetNameStringTypeFormat);
+            for (idx = 0;idx < length;idx++) {
+                CFStringAppendFormat(string, NULL, CFSTR("%sU+%04X"), (idx > 0 ? " " : ""), (UInt32)((__CFCSetStringBuffer((CFCharacterSetRef)cf))[idx]));
+            }
+            CFStringAppend(string, CFSTR(")>"));
+            return string;
+
+        case __kCFCharSetClassBitmap:
+        case __kCFCharSetClassCompactBitmap:
+            return (CFStringRef)CFRetain(CFSTR("<CFCharacterSet Bitmap>")); // ??? Should generate description for 8k bitmap ?
+    }
+    CFAssert1(0, __kCFLogAssertion, "%s: Internal inconsistency error: unknown character set type", __PRETTY_FUNCTION__); // We should never come here
+    return NULL;
+}
+
+static void __CFCharacterSetDeallocate(CFTypeRef cf) {
+    CFAllocatorRef allocator = CFGetAllocator(cf);
+
+    if (__CFCSetIsBuiltin((CFCharacterSetRef)cf) && !__CFCSetIsMutable((CFCharacterSetRef)cf) && !__CFCSetIsInverted((CFCharacterSetRef)cf)) {
+        CFCharacterSetRef sharedSet = CFCharacterSetGetPredefined(__CFCSetBuiltinType((CFCharacterSetRef)cf));
+        if (sharedSet == cf) { // We're trying to dealloc the builtin set
+            CFAssert1(0, __kCFLogAssertion, "%s: Trying to deallocate predefined set. The process is likely to crash.", __PRETTY_FUNCTION__);
+            return; // We never deallocate builtin set
+        }
+    }
+
+    if (__CFCSetIsString((CFCharacterSetRef)cf) && __CFCSetStringBuffer((CFCharacterSetRef)cf)) CFAllocatorDeallocate(allocator, __CFCSetStringBuffer((CFCharacterSetRef)cf));
+    else if (__CFCSetIsBitmap((CFCharacterSetRef)cf) && __CFCSetBitmapBits((CFCharacterSetRef)cf)) CFAllocatorDeallocate(allocator, __CFCSetBitmapBits((CFCharacterSetRef)cf));
+    else if (__CFCSetIsCompactBitmap((CFCharacterSetRef)cf) && __CFCSetCompactBitmapBits((CFCharacterSetRef)cf)) CFAllocatorDeallocate(allocator, __CFCSetCompactBitmapBits((CFCharacterSetRef)cf));
+    __CFCSetDeallocateAnnexPlane((CFCharacterSetRef)cf);
+}
+
+static CFTypeID __kCFCharacterSetTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFCharacterSetClass = {
+    0,
+    "CFCharacterSet",
+    NULL,      // init
+    NULL,      // copy
+    __CFCharacterSetDeallocate,
+    __CFCharacterSetEqual,
+    __CFCharacterSetHash,
+    NULL,      // 
+    __CFCharacterSetCopyDescription
+};
+
+static bool __CFCheckForExapendedSet = false;
+
+__private_extern__ void __CFCharacterSetInitialize(void) {
+    const char *checkForExpandedSet = getenv("__CF_DEBUG_EXPANDED_SET");
+
+    __kCFCharacterSetTypeID = _CFRuntimeRegisterClass(&__CFCharacterSetClass);
+
+    if (checkForExpandedSet && (*checkForExpandedSet == 'Y')) __CFCheckForExapendedSet = true;
+}
+
+/* Public functions
+*/
+
+CFTypeID CFCharacterSetGetTypeID(void) {
+    return __kCFCharacterSetTypeID;
+}
+
+/*** CharacterSet creation ***/
+/* Functions to create basic immutable characterset.
+*/
+CFCharacterSetRef CFCharacterSetGetPredefined(CFCharacterSetPredefinedSet theSetIdentifier) {
+    CFCharacterSetRef cset;
+
+    __CFCSetValidateBuiltinType(theSetIdentifier, __PRETTY_FUNCTION__);
+
+    __CFSpinLock(&__CFCharacterSetLock);
+    cset = ((NULL != __CFBuiltinSets) ? __CFBuiltinSets[theSetIdentifier - 1] : NULL);
+    __CFSpinUnlock(&__CFCharacterSetLock);
+
+    if (NULL != cset) return cset;
+
+    if (!(cset = __CFCSetGenericCreate(kCFAllocatorSystemDefault, __kCFCharSetClassBuiltin))) return NULL;
+    __CFCSetPutBuiltinType((CFMutableCharacterSetRef)cset, theSetIdentifier);
+
+    __CFSpinLock(&__CFCharacterSetLock);
+    if (!__CFBuiltinSets) {
+	__CFBuiltinSets = (CFCharacterSetRef *)CFAllocatorAllocate((CFAllocatorRef)CFRetain(__CFGetDefaultAllocator()), sizeof(CFCharacterSetRef) * __kCFLastBuiltinSetID, 0);
+	memset(__CFBuiltinSets, 0, sizeof(CFCharacterSetRef) * __kCFLastBuiltinSetID);
+    }
+
+    __CFBuiltinSets[theSetIdentifier - 1] = cset;
+    __CFSpinUnlock(&__CFCharacterSetLock);
+
+    return cset;
+}
+
+CFCharacterSetRef CFCharacterSetCreateWithCharactersInRange(CFAllocatorRef allocator, CFRange theRange) {
+    CFMutableCharacterSetRef cset;
+
+    __CFCSetValidateRange(theRange, __PRETTY_FUNCTION__);
+
+    if (theRange.length) {
+        if (!(cset = __CFCSetGenericCreate(allocator, __kCFCharSetClassRange))) return NULL;
+        __CFCSetPutRangeFirstChar(cset, theRange.location);
+        __CFCSetPutRangeLength(cset, theRange.length);
+    } else {
+        if (!(cset = __CFCSetGenericCreate(allocator, __kCFCharSetClassBitmap))) return NULL;
+        __CFCSetPutBitmapBits(cset, NULL);
+        __CFCSetPutHasHashValue(cset, true); // _hashValue is 0
+    }
+
+    return cset;
+}
+
+static int chcompar(const void *a, const void *b) {
+    return -(int)(*(UniChar *)b - *(UniChar *)a);
+}
+
+CFCharacterSetRef CFCharacterSetCreateWithCharactersInString(CFAllocatorRef allocator, CFStringRef theString) {
+    CFIndex length;
+
+    length = CFStringGetLength(theString);
+    if (length < __kCFStringCharSetMax) {
+        CFMutableCharacterSetRef cset;
+
+        if (!(cset = __CFCSetGenericCreate(allocator, __kCFCharSetClassString))) return NULL;
+        __CFCSetPutStringBuffer(cset, (UniChar *)CFAllocatorAllocate(CFGetAllocator(cset), __kCFStringCharSetMax * sizeof(UniChar), 0));
+        __CFCSetPutStringLength(cset, length);
+        CFStringGetCharacters(theString, CFRangeMake(0, length), __CFCSetStringBuffer(cset));
+        qsort(__CFCSetStringBuffer(cset), length, sizeof(UniChar), chcompar);
+        if (!length) __CFCSetPutHasHashValue(cset, true); // _hashValue is 0
+        return cset;
+    } else {
+        CFMutableCharacterSetRef mcset = CFCharacterSetCreateMutable(allocator);
+        CFCharacterSetAddCharactersInString(mcset, theString);
+        __CFCSetMakeCompact(mcset);
+        __CFCSetPutIsMutable(mcset, false);
+        return mcset;
+    }
+}
+
+CFCharacterSetRef CFCharacterSetCreateWithBitmapRepresentation(CFAllocatorRef allocator, CFDataRef theData) {
+    CFMutableCharacterSetRef cset;
+    CFIndex length;
+
+    if (!(cset = __CFCSetGenericCreate(allocator, __kCFCharSetClassBitmap))) return NULL;
+
+    if (theData && (length = CFDataGetLength(theData)) > 0) {
+        uint8_t *bitmap;
+        uint8_t *cBitmap;
+
+        if (length < __kCFBitmapSize) {
+            bitmap = (uint8_t *)CFAllocatorAllocate(allocator, __kCFBitmapSize, 0);
+            memmove(bitmap, CFDataGetBytePtr(theData), length);
+            memset(bitmap + length, 0, __kCFBitmapSize - length);
+
+            cBitmap = __CFCreateCompactBitmap(allocator, bitmap);
+
+            if (cBitmap == NULL) {
+                __CFCSetPutBitmapBits(cset, bitmap);
+            } else {
+                CFAllocatorDeallocate(allocator, bitmap);
+                __CFCSetPutCompactBitmapBits(cset, cBitmap);
+                __CFCSetPutClassType(cset, __kCFCharSetClassCompactBitmap);
+            }
+        } else {
+            cBitmap = __CFCreateCompactBitmap(allocator, CFDataGetBytePtr(theData));
+
+            if (cBitmap == NULL) {
+                bitmap = (uint8_t *)CFAllocatorAllocate(allocator, __kCFBitmapSize, 0);
+                memmove(bitmap, CFDataGetBytePtr(theData), __kCFBitmapSize);
+
+                __CFCSetPutBitmapBits(cset, bitmap);
+            } else {
+                __CFCSetPutCompactBitmapBits(cset, cBitmap);
+                __CFCSetPutClassType(cset, __kCFCharSetClassCompactBitmap);
+            }
+
+            if (length > __kCFBitmapSize) {
+                CFMutableCharacterSetRef annexSet;
+                const uint8_t *bytes = CFDataGetBytePtr(theData) + __kCFBitmapSize;
+    
+                length -= __kCFBitmapSize;
+    
+                while (length > 1) {
+                    annexSet = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(cset, *(bytes++));
+                    --length; // Decrement the plane no byte
+
+                    if (length < __kCFBitmapSize) {
+                        bitmap = (uint8_t *)CFAllocatorAllocate(allocator, __kCFBitmapSize, 0);
+                        memmove(bitmap, bytes, length);
+                        memset(bitmap + length, 0, __kCFBitmapSize - length);
+            
+                        cBitmap = __CFCreateCompactBitmap(allocator, bitmap);
+            
+                        if (cBitmap == NULL) {
+                            __CFCSetPutBitmapBits(annexSet, bitmap);
+                        } else {
+                            CFAllocatorDeallocate(allocator, bitmap);
+                            __CFCSetPutCompactBitmapBits(annexSet, cBitmap);
+                            __CFCSetPutClassType(annexSet, __kCFCharSetClassCompactBitmap);
+                        }
+                    } else {
+                        cBitmap = __CFCreateCompactBitmap(allocator, bytes);
+            
+                        if (cBitmap == NULL) {
+                            bitmap = (uint8_t *)CFAllocatorAllocate(allocator, __kCFBitmapSize, 0);
+                            memmove(bitmap, bytes, __kCFBitmapSize);
+            
+                            __CFCSetPutBitmapBits(annexSet, bitmap);
+                        } else {
+                            __CFCSetPutCompactBitmapBits(annexSet, cBitmap);
+                            __CFCSetPutClassType(annexSet, __kCFCharSetClassCompactBitmap);
+                        }
+                    }
+                    length -= __kCFBitmapSize;
+                    bytes += __kCFBitmapSize;
+                }
+            }
+        }
+    } else {
+        __CFCSetPutBitmapBits(cset, NULL);
+        __CFCSetPutHasHashValue(cset, true); // Hash value is 0
+    }
+
+    return cset;
+}
+
+CFCharacterSetRef CFCharacterSetCreateInvertedSet(CFAllocatorRef alloc, CFCharacterSetRef theSet) {
+    CFMutableCharacterSetRef cset;
+    
+    CF_OBJC_FUNCDISPATCH0(__kCFCharacterSetTypeID, CFCharacterSetRef , theSet, "invertedSet");
+
+    cset = CFCharacterSetCreateMutableCopy(alloc, theSet);
+    CFCharacterSetInvert(cset);
+    __CFCSetPutIsMutable(cset, false);
+
+    return cset;
+}
+
+/* Functions to create mutable characterset.
+*/
+CFMutableCharacterSetRef CFCharacterSetCreateMutable(CFAllocatorRef allocator) {
+    CFMutableCharacterSetRef cset;
+
+    if (!(cset = __CFCSetGenericCreate(allocator, __kCFCharSetClassBitmap| __kCFCharSetIsMutable))) return NULL;
+    __CFCSetPutBitmapBits(cset, NULL);
+    __CFCSetPutHasHashValue(cset, true); // Hash value is 0
+
+    return cset;
+}
+
+CFMutableCharacterSetRef __CFCharacterSetCreateCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet, bool isMutable) {
+    CFMutableCharacterSetRef cset;
+
+    CF_OBJC_FUNCDISPATCH0(__kCFCharacterSetTypeID, CFMutableCharacterSetRef , theSet, "mutableCopy");
+
+    __CFGenericValidateType(theSet, __kCFCharacterSetTypeID);
+
+    if (!isMutable && !__CFCSetIsMutable(theSet)) {
+        return (CFMutableCharacterSetRef)CFRetain(theSet);
+    }
+
+    cset = CFCharacterSetCreateMutable(alloc);
+
+    __CFCSetPutClassType(cset, __CFCSetClassType(theSet));
+    __CFCSetPutHasHashValue(cset, __CFCSetHasHashValue(theSet));
+    __CFCSetPutIsInverted(cset, __CFCSetIsInverted(theSet));
+    cset->_hashValue = theSet->_hashValue;
+
+    switch (__CFCSetClassType(theSet)) {
+        case __kCFCharSetClassBuiltin:
+            __CFCSetPutBuiltinType(cset, __CFCSetBuiltinType(theSet));
+            break;
+
+        case __kCFCharSetClassRange:
+            __CFCSetPutRangeFirstChar(cset, __CFCSetRangeFirstChar(theSet));
+            __CFCSetPutRangeLength(cset, __CFCSetRangeLength(theSet));
+            break;
+
+        case __kCFCharSetClassString:
+			__CFCSetPutStringBuffer(cset, (UniChar *)CFAllocatorAllocate(alloc, __kCFStringCharSetMax * sizeof(UniChar), 0));
+
+            __CFCSetPutStringLength(cset, __CFCSetStringLength(theSet));
+            memmove(__CFCSetStringBuffer(cset), __CFCSetStringBuffer(theSet), __CFCSetStringLength(theSet) * sizeof(UniChar));
+            break;
+
+        case __kCFCharSetClassBitmap:
+            if (__CFCSetBitmapBits(theSet)) {
+                uint8_t * bitmap = (isMutable ? NULL : __CFCreateCompactBitmap(alloc, __CFCSetBitmapBits(theSet)));
+
+                if (bitmap == NULL) {
+                    bitmap = (uint8_t *)CFAllocatorAllocate(alloc, sizeof(uint8_t) * __kCFBitmapSize, 0);
+                    memmove(bitmap, __CFCSetBitmapBits(theSet), __kCFBitmapSize);
+                    __CFCSetPutBitmapBits(cset, bitmap);
+                } else {
+                    __CFCSetPutCompactBitmapBits(cset, bitmap);
+                    __CFCSetPutClassType(cset, __kCFCharSetClassCompactBitmap);
+                }
+            } else {
+                __CFCSetPutBitmapBits(cset, NULL);
+            }
+            break;
+
+        case __kCFCharSetClassCompactBitmap: {
+            const uint8_t *compactBitmap = __CFCSetCompactBitmapBits(theSet);
+
+            if (compactBitmap) {
+                uint32_t size = __CFCSetGetCompactBitmapSize(compactBitmap);
+                uint8_t *newBitmap = (uint8_t *)CFAllocatorAllocate(alloc, size, 0);
+
+                memmove(newBitmap, compactBitmap, size);
+                __CFCSetPutCompactBitmapBits(cset, newBitmap);
+            }
+        }
+            break;
+
+        default:
+            CFAssert1(0, __kCFLogAssertion, "%s: Internal inconsistency error: unknown character set type", __PRETTY_FUNCTION__); // We should never come here
+    }
+    if (__CFCSetHasNonBMPPlane(theSet)) {
+        CFMutableCharacterSetRef annexPlane;
+        int idx;
+
+        for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+            if ((annexPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, idx))) {
+                annexPlane = __CFCharacterSetCreateCopy(alloc, annexPlane, isMutable);
+                __CFCSetPutCharacterSetToAnnexPlane(cset, annexPlane, idx);
+                CFRelease(annexPlane);
+            }
+        }
+        __CFCSetAnnexSetIsInverted(cset, __CFCSetAnnexIsInverted(theSet));
+    } else if (__CFCSetAnnexIsInverted(theSet)) {
+        __CFCSetAllocateAnnexForPlane(cset, 0); // We need to alloc annex to invert
+        __CFCSetAnnexSetIsInverted(cset, true);
+    }
+    
+    return cset;
+}
+
+CFCharacterSetRef CFCharacterSetCreateCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet) {
+    return __CFCharacterSetCreateCopy(alloc, theSet, false);
+}
+
+CFMutableCharacterSetRef CFCharacterSetCreateMutableCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet) {
+    return __CFCharacterSetCreateCopy(alloc, theSet, true);
+}
+
+/*** Basic accessors ***/
+Boolean CFCharacterSetIsCharacterMember(CFCharacterSetRef theSet, UniChar theChar) {
+    CFIndex length;
+    Boolean isInverted;
+    Boolean result = false;
+    
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, Boolean, theSet, "longCharacterIsMember:", theChar);
+    
+    __CFGenericValidateType(theSet, __kCFCharacterSetTypeID);
+    
+    isInverted = __CFCSetIsInverted(theSet);
+    
+    switch (__CFCSetClassType(theSet)) {
+        case __kCFCharSetClassBuiltin:
+            result = (CFUniCharIsMemberOf(theChar, __CFCSetBuiltinType(theSet)) ? !isInverted : isInverted);
+            break;
+            
+        case __kCFCharSetClassRange:
+            length = __CFCSetRangeLength(theSet);
+            result = (length && __CFCSetRangeFirstChar(theSet) <= theChar && theChar < __CFCSetRangeFirstChar(theSet) + length ? !isInverted : isInverted);
+            break;
+            
+        case __kCFCharSetClassString:
+            result = ((length = __CFCSetStringLength(theSet)) ? (__CFCSetBsearchUniChar(__CFCSetStringBuffer(theSet), length, theChar) ? !isInverted : isInverted) : isInverted);
+            break;
+            
+        case __kCFCharSetClassBitmap:
+            result = (__CFCSetCompactBitmapBits(theSet) ? (__CFCSetIsMemberBitmap(__CFCSetBitmapBits(theSet), theChar) ? true : false) : isInverted);
+            break;
+            
+        case __kCFCharSetClassCompactBitmap:
+            result = (__CFCSetCompactBitmapBits(theSet) ? (__CFCSetIsMemberInCompactBitmap(__CFCSetCompactBitmapBits(theSet), theChar) ? true : false) : isInverted);
+            break;
+            
+        default:
+            CFAssert1(0, __kCFLogAssertion, "%s: Internal inconsistency error: unknown character set type", __PRETTY_FUNCTION__); // We should never come here
+            break;
+    }
+    
+    return result;
+}
+
+Boolean CFCharacterSetIsLongCharacterMember(CFCharacterSetRef theSet, UTF32Char theChar) {
+    CFIndex length;
+    UInt32 plane = (theChar >> 16);
+    Boolean isAnnexInverted = false;
+    Boolean isInverted;
+    Boolean result = false;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, Boolean, theSet, "longCharacterIsMember:", theChar);
+
+    __CFGenericValidateType(theSet, __kCFCharacterSetTypeID);
+
+    if (plane) {
+        CFCharacterSetRef annexPlane;
+
+        if (__CFCSetIsBuiltin(theSet)) {
+            isInverted = __CFCSetIsInverted(theSet);
+            return (CFUniCharIsMemberOf(theChar, __CFCSetBuiltinType(theSet)) ? !isInverted : isInverted); 
+        }
+
+        isAnnexInverted = __CFCSetAnnexIsInverted(theSet);
+
+        if ((annexPlane = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, plane)) == NULL) {
+            if (!__CFCSetHasNonBMPPlane(theSet) && __CFCSetIsRange(theSet)) {
+                isInverted = __CFCSetIsInverted(theSet);
+                length = __CFCSetRangeLength(theSet);
+                return (length && __CFCSetRangeFirstChar(theSet) <= theChar && theChar < __CFCSetRangeFirstChar(theSet) + length ? !isInverted : isInverted);
+            } else {
+                return (isAnnexInverted ? true : false);
+            }
+        } else {
+            theSet = annexPlane;
+            theChar &= 0xFFFF;
+        }
+    }
+
+    isInverted = __CFCSetIsInverted(theSet);
+
+    switch (__CFCSetClassType(theSet)) {
+        case __kCFCharSetClassBuiltin:
+            result = (CFUniCharIsMemberOf(theChar, __CFCSetBuiltinType(theSet)) ? !isInverted : isInverted);
+            break;
+
+        case __kCFCharSetClassRange:
+            length = __CFCSetRangeLength(theSet);
+            result = (length && __CFCSetRangeFirstChar(theSet) <= theChar && theChar < __CFCSetRangeFirstChar(theSet) + length ? !isInverted : isInverted);
+            break;
+
+        case __kCFCharSetClassString:
+            result = ((length = __CFCSetStringLength(theSet)) ? (__CFCSetBsearchUniChar(__CFCSetStringBuffer(theSet), length, theChar) ? !isInverted : isInverted) : isInverted);
+            break;
+
+        case __kCFCharSetClassBitmap:
+            result = (__CFCSetCompactBitmapBits(theSet) ? (__CFCSetIsMemberBitmap(__CFCSetBitmapBits(theSet), theChar) ? true : false) : isInverted);
+            break;
+
+        case __kCFCharSetClassCompactBitmap:
+            result = (__CFCSetCompactBitmapBits(theSet) ? (__CFCSetIsMemberInCompactBitmap(__CFCSetCompactBitmapBits(theSet), theChar) ? true : false) : isInverted);
+            break;
+
+        default:
+            CFAssert1(0, __kCFLogAssertion, "%s: Internal inconsistency error: unknown character set type", __PRETTY_FUNCTION__); // We should never come here
+            return false; // To make compiler happy
+    }
+
+    return (result ? !isAnnexInverted : isAnnexInverted);
+}
+
+Boolean CFCharacterSetIsSurrogatePairMember(CFCharacterSetRef theSet, UniChar surrogateHigh, UniChar surrogateLow) {
+    return CFCharacterSetIsLongCharacterMember(theSet, CFCharacterSetGetLongCharacterForSurrogatePair(surrogateHigh, surrogateLow));
+}
+
+
+static inline CFCharacterSetRef __CFCharacterSetGetExpandedSetForNSCharacterSet(const void *characterSet) {
+    CF_OBJC_FUNCDISPATCH0(__kCFCharacterSetTypeID, CFCharacterSetRef , characterSet, "_expandedCFCharacterSet");
+    return NULL;
+}
+
+Boolean CFCharacterSetIsSupersetOfSet(CFCharacterSetRef theSet, CFCharacterSetRef theOtherSet) {
+    CFMutableCharacterSetRef copy;
+    CFCharacterSetRef expandedSet = NULL;
+    CFCharacterSetRef expandedOtherSet = NULL;
+    Boolean result;
+
+    if ((!CF_IS_OBJC(__kCFCharacterSetTypeID, theSet) || (expandedSet = __CFCharacterSetGetExpandedSetForNSCharacterSet(theSet))) && (!CF_IS_OBJC(__kCFCharacterSetTypeID, theOtherSet) || (expandedOtherSet = __CFCharacterSetGetExpandedSetForNSCharacterSet(theOtherSet)))) { // Really CF, we can do some trick here
+        if (expandedSet) theSet = expandedSet;
+        if (expandedOtherSet) theOtherSet = expandedOtherSet;
+    
+        __CFGenericValidateType(theSet, __kCFCharacterSetTypeID);
+        __CFGenericValidateType(theOtherSet, __kCFCharacterSetTypeID);
+
+        if (__CFCSetIsEmpty(theSet)) {
+            if (__CFCSetIsInverted(theSet)) {
+                return TRUE; // Inverted empty set covers all range
+            } else if (!__CFCSetIsEmpty(theOtherSet) || __CFCSetIsInverted(theOtherSet)) {
+                return FALSE;
+            }
+        } else if (__CFCSetIsEmpty(theOtherSet) && !__CFCSetIsInverted(theOtherSet)) {
+            return TRUE;
+        } else {
+            if (__CFCSetIsBuiltin(theSet) || __CFCSetIsBuiltin(theOtherSet)) {
+                if (__CFCSetClassType(theSet) == __CFCSetClassType(theOtherSet) && __CFCSetBuiltinType(theSet) == __CFCSetBuiltinType(theOtherSet) && !__CFCSetIsInverted(theSet) && !__CFCSetIsInverted(theOtherSet)) return TRUE;
+            } else if (__CFCSetIsRange(theSet) || __CFCSetIsRange(theOtherSet)) {
+                if (__CFCSetClassType(theSet) == __CFCSetClassType(theOtherSet)) {
+                    if (__CFCSetIsInverted(theSet)) {
+                        if (__CFCSetIsInverted(theOtherSet)) {
+                            return (__CFCSetRangeFirstChar(theOtherSet) > __CFCSetRangeFirstChar(theSet) || (__CFCSetRangeFirstChar(theSet) + __CFCSetRangeLength(theSet)) > (__CFCSetRangeFirstChar(theOtherSet) + __CFCSetRangeLength(theOtherSet)) ? FALSE : TRUE);
+                        } else {
+                            return ((__CFCSetRangeFirstChar(theOtherSet) + __CFCSetRangeLength(theOtherSet)) <= __CFCSetRangeFirstChar(theSet) || (__CFCSetRangeFirstChar(theSet) + __CFCSetRangeLength(theSet)) <= __CFCSetRangeFirstChar(theOtherSet) ? TRUE : FALSE);
+                        }
+                    } else {
+                        if (__CFCSetIsInverted(theOtherSet)) {
+                            return ((__CFCSetRangeFirstChar(theSet) == 0 && __CFCSetRangeLength(theSet) == 0x110000) || (__CFCSetRangeFirstChar(theOtherSet) == 0 && (UInt32)__CFCSetRangeLength(theOtherSet) <= __CFCSetRangeFirstChar(theSet)) || ((__CFCSetRangeFirstChar(theSet) + __CFCSetRangeLength(theSet)) <= __CFCSetRangeFirstChar(theOtherSet) && (__CFCSetRangeFirstChar(theOtherSet) + __CFCSetRangeLength(theOtherSet)) == 0x110000) ? TRUE : FALSE);
+                        } else {
+                            return (__CFCSetRangeFirstChar(theOtherSet) < __CFCSetRangeFirstChar(theSet) || (__CFCSetRangeFirstChar(theSet) + __CFCSetRangeLength(theSet)) < (__CFCSetRangeFirstChar(theOtherSet) + __CFCSetRangeLength(theOtherSet)) ? FALSE : TRUE);
+                        }
+                    }
+                }
+            } else {
+                UInt32 theSetAnnexMask = __CFCSetAnnexValidEntriesBitmap(theSet);
+                UInt32 theOtherSetAnnexMask = __CFCSetAnnexValidEntriesBitmap(theOtherSet);
+                Boolean isTheSetAnnexInverted = __CFCSetAnnexIsInverted(theSet);
+                Boolean isTheOtherSetAnnexInverted = __CFCSetAnnexIsInverted(theOtherSet);
+                uint8_t theSetBuffer[__kCFBitmapSize];
+                uint8_t theOtherSetBuffer[__kCFBitmapSize];
+
+                // We mask plane 1 to plane 16
+                if (isTheSetAnnexInverted) theSetAnnexMask = (~theSetAnnexMask) & (0xFFFF < 1);
+                if (isTheOtherSetAnnexInverted) theOtherSetAnnexMask = (~theOtherSetAnnexMask) & (0xFFFF < 1);
+
+                __CFCSetGetBitmap(theSet, theSetBuffer);
+                __CFCSetGetBitmap(theOtherSet, theOtherSetBuffer);
+
+                if (!__CFCSetIsBitmapSupersetOfBitmap((const UInt32 *)theSetBuffer, (const UInt32 *)theOtherSetBuffer, FALSE, FALSE)) return FALSE;
+
+                if (theOtherSetAnnexMask) {
+                    CFCharacterSetRef theSetAnnex;
+                    CFCharacterSetRef theOtherSetAnnex;
+                    uint32_t idx;
+
+                    if ((theSetAnnexMask & theOtherSetAnnexMask) != theOtherSetAnnexMask) return FALSE;
+
+                    for (idx = 1;idx <= 16;idx++) {
+                        theSetAnnex = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, idx);
+                        if (NULL == theSetAnnex) continue; // This case is already handled by the mask above
+
+                        theOtherSetAnnex = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(theOtherSet, idx);
+
+                        if (NULL == theOtherSetAnnex) {
+                            if (isTheOtherSetAnnexInverted) {
+                                __CFCSetGetBitmap(theSetAnnex, theSetBuffer);
+                                if (!__CFCSetIsEqualBitmap((const UInt32 *)theSetBuffer, (isTheSetAnnexInverted ? NULL : (const UInt32 *)-1))) return FALSE;
+                            }
+                        } else {
+                            __CFCSetGetBitmap(theSetAnnex, theSetBuffer);
+                            __CFCSetGetBitmap(theOtherSetAnnex, theOtherSetBuffer);
+                            if (!__CFCSetIsBitmapSupersetOfBitmap((const UInt32 *)theSetBuffer, (const UInt32 *)theOtherSetBuffer, isTheSetAnnexInverted, isTheOtherSetAnnexInverted)) return FALSE;
+                        }
+                    }
+                }
+
+                return TRUE;
+            }
+        }
+    }
+
+    copy = CFCharacterSetCreateMutableCopy(kCFAllocatorSystemDefault, theSet);
+    CFCharacterSetIntersect(copy, theOtherSet);
+    result = __CFCharacterSetEqual(copy, theOtherSet);
+    CFRelease(copy);
+
+    return result;
+}
+
+Boolean CFCharacterSetHasMemberInPlane(CFCharacterSetRef theSet, CFIndex thePlane) {
+    Boolean isInverted = __CFCSetIsInverted(theSet);
+
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, Boolean, theSet, "hasMemberInPlane:", thePlane);
+
+    if (__CFCSetIsEmpty(theSet)) {
+        return (isInverted ? TRUE : FALSE);
+    } else if (__CFCSetIsBuiltin(theSet)) {
+        CFCharacterSetPredefinedSet type = __CFCSetBuiltinType(theSet);
+
+        if (type == kCFCharacterSetControl) {
+            if (isInverted || (thePlane == 14)) {
+                return TRUE; // There is no plane that covers all values || Plane 14 has language tags
+            } else {
+                return (CFUniCharGetBitmapPtrForPlane(type, thePlane) ? TRUE : FALSE);
+            }
+        } else if ((type < kCFCharacterSetDecimalDigit) || (type == kCFCharacterSetNewline)) {
+            return (thePlane && !isInverted ? FALSE : TRUE);
+        } else if (__CFCSetBuiltinType(theSet) == kCFCharacterSetIllegal) {
+            return (isInverted ? (thePlane < 3 || thePlane > 13 ? TRUE : FALSE) : TRUE); // This is according to Unicode 3.1
+        } else {
+            if (isInverted) {
+                return TRUE; // There is no plane that covers all values
+            } else {
+                return (CFUniCharGetBitmapPtrForPlane(type, thePlane) ? TRUE : FALSE);
+            }
+        }
+    } else if (__CFCSetIsRange(theSet)) {
+        UTF32Char firstChar = __CFCSetRangeFirstChar(theSet);
+        UTF32Char lastChar = (firstChar + __CFCSetRangeLength(theSet) - 1);
+        CFIndex firstPlane = firstChar >> 16;
+        CFIndex lastPlane = lastChar >> 16;
+
+        if (isInverted) {
+            if (thePlane < firstPlane || thePlane > lastPlane) {
+                return TRUE;
+            } else if (thePlane > firstPlane && thePlane < lastPlane) {
+                return FALSE;
+            } else {
+                firstChar &= 0xFFFF;
+                lastChar &= 0xFFFF;
+                if (thePlane == firstPlane) {
+                    return (firstChar || (firstPlane == lastPlane && lastChar != 0xFFFF) ? TRUE : FALSE);
+                } else {
+                    return (lastChar != 0xFFFF || (firstPlane == lastPlane && firstChar) ? TRUE : FALSE);
+                }
+            }
+        } else {
+            return (thePlane < firstPlane || thePlane > lastPlane ? FALSE : TRUE);
+        }
+    } else {
+        if (thePlane == 0) {
+            switch (__CFCSetClassType(theSet)) {
+                case __kCFCharSetClassString: if (!__CFCSetStringLength(theSet)) return isInverted; break;
+                case __kCFCharSetClassCompactBitmap: return (__CFCSetCompactBitmapBits(theSet) ? TRUE : FALSE); break;
+                case __kCFCharSetClassBitmap: return (__CFCSetBitmapBits(theSet) ? TRUE : FALSE); break;
+            }
+            return TRUE;
+        } else {
+            CFCharacterSetRef annex = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, thePlane);
+            if (annex) {
+                if (__CFCSetIsRange(annex)) {
+                    return (__CFCSetAnnexIsInverted(theSet) && (__CFCSetRangeFirstChar(annex) == 0) && (__CFCSetRangeLength(annex) == 0x10000) ? FALSE : TRUE);
+                } else if (__CFCSetIsBitmap(annex)) {
+                    return (__CFCSetAnnexIsInverted(theSet) && __CFCSetIsEqualBitmap((const UInt32 *)__CFCSetBitmapBits(annex), (const UInt32 *)-1) ? FALSE : TRUE);
+                } else {
+                    uint8_t bitsBuf[__kCFBitmapSize];
+                    __CFCSetGetBitmap(annex, bitsBuf);
+                    return (__CFCSetAnnexIsInverted(theSet) && __CFCSetIsEqualBitmap((const UInt32 *)bitsBuf, (const UInt32 *)-1) ? FALSE : TRUE);
+                }
+            } else {
+                return __CFCSetAnnexIsInverted(theSet);
+            }
+        }
+    }
+ 
+    return FALSE;
+}
+
+
+CFDataRef CFCharacterSetCreateBitmapRepresentation(CFAllocatorRef alloc, CFCharacterSetRef theSet) {
+    CFMutableDataRef data;
+    int numNonBMPPlanes = 0;
+    int planeIndices[MAX_ANNEX_PLANE];
+    int idx;
+    int length;
+    bool isAnnexInverted;
+
+    CF_OBJC_FUNCDISPATCH0(__kCFCharacterSetTypeID, CFDataRef , theSet, "_retainedBitmapRepresentation");
+
+    __CFGenericValidateType(theSet, __kCFCharacterSetTypeID);
+
+    isAnnexInverted = (__CFCSetAnnexIsInverted(theSet) != 0);
+
+    if (__CFCSetHasNonBMPPlane(theSet)) {
+        for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+            if (isAnnexInverted || __CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, idx)) {
+                planeIndices[numNonBMPPlanes++] = idx;
+            }
+        }
+    } else if (__CFCSetIsBuiltin(theSet)) {
+        numNonBMPPlanes = (__CFCSetIsInverted(theSet) ? MAX_ANNEX_PLANE : CFUniCharGetNumberOfPlanes(__CFCSetBuiltinType(theSet)) - 1);
+    } else if (__CFCSetIsRange(theSet)) {
+        UInt32 firstChar = __CFCSetRangeFirstChar(theSet);
+        UInt32 lastChar = __CFCSetRangeFirstChar(theSet) + __CFCSetRangeLength(theSet) - 1;
+        int firstPlane = (firstChar >> 16);
+        int lastPlane = (lastChar >> 16);
+        bool isInverted = (__CFCSetIsInverted(theSet) != 0);
+
+        if (lastPlane > 0) {
+            if (firstPlane == 0) {
+                firstPlane = 1;
+                firstChar = 0x10000;
+            }
+            numNonBMPPlanes = (lastPlane - firstPlane) + 1;
+            if (isInverted) {
+                numNonBMPPlanes = MAX_ANNEX_PLANE - numNonBMPPlanes;
+                if (firstPlane == lastPlane) {
+                    if (((firstChar & 0xFFFF) > 0) || ((lastChar & 0xFFFF) < 0xFFFF)) ++numNonBMPPlanes;
+                } else {
+                    if ((firstChar & 0xFFFF) > 0) ++numNonBMPPlanes;
+                    if ((lastChar & 0xFFFF) < 0xFFFF) ++numNonBMPPlanes;
+                }
+            }
+        } else if (isInverted) {
+	    numNonBMPPlanes = MAX_ANNEX_PLANE;
+	}
+    } else if (isAnnexInverted) {
+        numNonBMPPlanes = MAX_ANNEX_PLANE;
+    }
+
+    length = __kCFBitmapSize + ((__kCFBitmapSize + 1) * numNonBMPPlanes);
+    data = CFDataCreateMutable(alloc, length);
+    CFDataSetLength(data, length);
+    __CFCSetGetBitmap(theSet, CFDataGetMutableBytePtr(data));
+
+    if (numNonBMPPlanes > 0) {
+        uint8_t *bytes = CFDataGetMutableBytePtr(data) + __kCFBitmapSize;
+
+        if (__CFCSetHasNonBMPPlane(theSet)) {
+            CFCharacterSetRef subset;
+
+            for (idx = 0;idx < numNonBMPPlanes;idx++) {
+                *(bytes++) = planeIndices[idx];
+                if ((subset = __CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, planeIndices[idx])) == NULL) {
+                    __CFCSetBitmapFastFillWithValue((UInt32 *)bytes, (isAnnexInverted ? 0xFF : 0));
+                } else {
+                    __CFCSetGetBitmap(subset, bytes);
+		    if (isAnnexInverted) {
+			uint32_t count = __kCFBitmapSize / sizeof(uint32_t);
+			uint32_t *bits = (uint32_t *)bytes;
+
+			while (count-- > 0) {
+			    *bits = ~(*bits);
+			    ++bits;
+			}
+		    }
+                }
+                bytes += __kCFBitmapSize;
+            }
+        } else if (__CFCSetIsBuiltin(theSet)) {
+            UInt8 result;
+            CFIndex delta;
+            Boolean isInverted = __CFCSetIsInverted(theSet);
+
+            for (idx = 0;idx < numNonBMPPlanes;idx++) {
+                if ((result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(theSet), idx + 1, bytes + 1,  (isInverted != 0))) == kCFUniCharBitmapEmpty) continue;
+                *(bytes++) = idx + 1;
+                if (result == kCFUniCharBitmapAll) {
+                    CFIndex bitmapLength = __kCFBitmapSize;
+                    while (bitmapLength-- > 0) *(bytes++) = (uint8_t)0xFF;
+                } else {
+                    bytes += __kCFBitmapSize;
+                }
+            }
+            delta = bytes - (const uint8_t *)CFDataGetBytePtr(data);
+            if (delta < length) CFDataSetLength(data, delta);
+        } else if (__CFCSetIsRange(theSet)) {
+            UInt32 firstChar = __CFCSetRangeFirstChar(theSet);
+            UInt32 lastChar = __CFCSetRangeFirstChar(theSet) + __CFCSetRangeLength(theSet) - 1;
+            int firstPlane = (firstChar >> 16);
+            int lastPlane = (lastChar >> 16);
+
+            if (firstPlane == 0) {
+                firstPlane = 1;
+                firstChar = 0x10000;
+            }
+            if (__CFCSetIsInverted(theSet)) {
+                // Mask out the plane byte
+                firstChar &= 0xFFFF;
+                lastChar &= 0xFFFF;
+
+                for (idx = 1;idx < firstPlane;idx++) { // Fill up until the first plane
+                    *(bytes++) = idx;
+                    __CFCSetBitmapFastFillWithValue((UInt32 *)bytes, 0xFF);
+                    bytes += __kCFBitmapSize;
+                }
+                if (firstPlane == lastPlane) {
+                    if ((firstChar > 0) || (lastChar < 0xFFFF)) {
+                        *(bytes++) = idx;
+                   	__CFCSetBitmapFastFillWithValue((UInt32 *)bytes, 0xFF);
+                        __CFCSetBitmapRemoveCharactersInRange(bytes, firstChar, lastChar);
+                        bytes += __kCFBitmapSize;
+                    }
+                } else if (firstPlane < lastPlane) {
+                    if (firstChar > 0) {
+                        *(bytes++) = idx;
+                   	__CFCSetBitmapFastFillWithValue((UInt32 *)bytes, 0);
+                        __CFCSetBitmapAddCharactersInRange(bytes, 0, firstChar - 1);
+                        bytes += __kCFBitmapSize;
+                    }
+                    if (lastChar < 0xFFFF) {
+                        *(bytes++) = idx;
+                   	__CFCSetBitmapFastFillWithValue((UInt32 *)bytes, 0);
+                        __CFCSetBitmapAddCharactersInRange(bytes, lastChar, 0xFFFF);
+                        bytes += __kCFBitmapSize;
+                    }
+                }
+                for (idx = lastPlane + 1;idx <= MAX_ANNEX_PLANE;idx++) {
+                    *(bytes++) = idx;
+                    __CFCSetBitmapFastFillWithValue((UInt32 *)bytes, 0xFF);
+                    bytes += __kCFBitmapSize;
+                }
+            } else {
+                for (idx = firstPlane;idx <= lastPlane;idx++) {
+                    *(bytes++) = idx;
+                    __CFCSetBitmapAddCharactersInRange(bytes, (idx == firstPlane ? firstChar : 0), (idx == lastPlane ? lastChar : 0xFFFF));
+		    bytes += __kCFBitmapSize;
+                }
+            }
+        } else if (isAnnexInverted) {
+            for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+                *(bytes++) = idx;
+                __CFCSetBitmapFastFillWithValue((UInt32 *)bytes, 0xFF);
+                bytes += __kCFBitmapSize;
+            }
+        }
+    }
+
+    return data;
+}
+
+/*** MutableCharacterSet functions ***/
+void CFCharacterSetAddCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange) {
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, void, theSet, "addCharactersInRange:", theRange);
+
+    __CFCSetValidateTypeAndMutability(theSet, __PRETTY_FUNCTION__);
+    __CFCSetValidateRange(theRange, __PRETTY_FUNCTION__);
+
+    if (!theRange.length || (__CFCSetIsInverted(theSet) && __CFCSetIsEmpty(theSet))) return; // Inverted && empty set contains all char
+
+    if (!__CFCSetIsInverted(theSet)) {
+        if (__CFCSetIsEmpty(theSet)) {
+            __CFCSetPutClassType(theSet, __kCFCharSetClassRange);
+            __CFCSetPutRangeFirstChar(theSet, theRange.location);
+            __CFCSetPutRangeLength(theSet, theRange.length);
+            __CFCSetPutHasHashValue(theSet, false);
+            return;
+       } else if (__CFCSetIsRange(theSet)) {
+            CFIndex firstChar = __CFCSetRangeFirstChar(theSet);
+            CFIndex length = __CFCSetRangeLength(theSet);
+
+            if (firstChar == theRange.location) {
+                __CFCSetPutRangeLength(theSet, __CFMin(length, theRange.length));
+                __CFCSetPutHasHashValue(theSet, false);
+                return;
+            } else if (firstChar < theRange.location && theRange.location <= firstChar + length) {
+                if (firstChar + length < theRange.location + theRange.length) __CFCSetPutRangeLength(theSet, theRange.length + (theRange.location - firstChar));
+                __CFCSetPutHasHashValue(theSet, false);
+                return;
+            } else if (theRange.location < firstChar && firstChar <= theRange.location + theRange.length) {
+                __CFCSetPutRangeFirstChar(theSet, theRange.location);
+                __CFCSetPutRangeLength(theSet, length + (firstChar - theRange.location));
+                __CFCSetPutHasHashValue(theSet, false);
+                return;
+            }
+        } else if (__CFCSetIsString(theSet) && __CFCSetStringLength(theSet) + theRange.length < __kCFStringCharSetMax) {
+            UniChar *buffer;
+            if (!__CFCSetStringBuffer(theSet))
+				__CFCSetPutStringBuffer(theSet, (UniChar *)CFAllocatorAllocate(CFGetAllocator(theSet), __kCFStringCharSetMax * sizeof(UniChar), 0));
+            buffer = __CFCSetStringBuffer(theSet) + __CFCSetStringLength(theSet);
+            __CFCSetPutStringLength(theSet, __CFCSetStringLength(theSet) + theRange.length);
+            while (theRange.length--) *buffer++ = (UniChar)theRange.location++;
+            qsort(__CFCSetStringBuffer(theSet), __CFCSetStringLength(theSet), sizeof(UniChar), chcompar);
+            __CFCSetPutHasHashValue(theSet, false);
+            return;
+        }
+    }
+
+    // OK, I have to be a bitmap
+    __CFCSetMakeBitmap(theSet);
+    __CFCSetAddNonBMPPlanesInRange(theSet, theRange);
+    if (theRange.location < 0x10000) { // theRange is in BMP
+        if (theRange.location + theRange.length >= NUMCHARACTERS) theRange.length = NUMCHARACTERS - theRange.location;
+        __CFCSetBitmapAddCharactersInRange(__CFCSetBitmapBits(theSet), (UniChar)theRange.location, (UniChar)(theRange.location + theRange.length - 1));
+    }
+    __CFCSetPutHasHashValue(theSet, false);
+
+    if (__CFCheckForExapendedSet) __CFCheckForExpandedSet(theSet);
+}
+
+void CFCharacterSetRemoveCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange) {
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, void, theSet, "removeCharactersInRange:", theRange);
+
+    __CFCSetValidateTypeAndMutability(theSet, __PRETTY_FUNCTION__);
+    __CFCSetValidateRange(theRange, __PRETTY_FUNCTION__);
+
+    if (!theRange.length || (!__CFCSetIsInverted(theSet) && __CFCSetIsEmpty(theSet))) return; // empty set
+
+    if (__CFCSetIsInverted(theSet)) {
+        if (__CFCSetIsEmpty(theSet)) {
+            __CFCSetPutClassType(theSet, __kCFCharSetClassRange);
+            __CFCSetPutRangeFirstChar(theSet, theRange.location);
+            __CFCSetPutRangeLength(theSet, theRange.length);
+            __CFCSetPutHasHashValue(theSet, false);
+            return;
+       } else if (__CFCSetIsRange(theSet)) {
+            CFIndex firstChar = __CFCSetRangeFirstChar(theSet);
+            CFIndex length = __CFCSetRangeLength(theSet);
+
+            if (firstChar == theRange.location) {
+                __CFCSetPutRangeLength(theSet, __CFMin(length, theRange.length));
+                __CFCSetPutHasHashValue(theSet, false);
+                return;
+            } else if (firstChar < theRange.location && theRange.location <= firstChar + length) {
+                if (firstChar + length < theRange.location + theRange.length) __CFCSetPutRangeLength(theSet, theRange.length + (theRange.location - firstChar));
+                __CFCSetPutHasHashValue(theSet, false);
+                return;
+            } else if (theRange.location < firstChar && firstChar <= theRange.location + theRange.length) {
+                __CFCSetPutRangeFirstChar(theSet, theRange.location);
+                __CFCSetPutRangeLength(theSet, length + (firstChar - theRange.location));
+                __CFCSetPutHasHashValue(theSet, false);
+                return;
+            }
+        } else if (__CFCSetIsString(theSet) && __CFCSetStringLength(theSet) + theRange.length < __kCFStringCharSetMax) {
+            UniChar *buffer;
+            if (!__CFCSetStringBuffer(theSet))
+				__CFCSetPutStringBuffer(theSet, (UniChar *)CFAllocatorAllocate(CFGetAllocator(theSet), __kCFStringCharSetMax * sizeof(UniChar), 0));
+            buffer = __CFCSetStringBuffer(theSet) + __CFCSetStringLength(theSet);
+            __CFCSetPutStringLength(theSet, __CFCSetStringLength(theSet) + theRange.length);
+            while (theRange.length--) *buffer++ = (UniChar)theRange.location++;
+            qsort(__CFCSetStringBuffer(theSet), __CFCSetStringLength(theSet), sizeof(UniChar), chcompar);
+            __CFCSetPutHasHashValue(theSet, false);
+            return;
+        }
+    }
+
+    // OK, I have to be a bitmap
+    __CFCSetMakeBitmap(theSet);
+    __CFCSetRemoveNonBMPPlanesInRange(theSet, theRange);
+    if (theRange.location < 0x10000) { // theRange is in BMP
+        if (theRange.location + theRange.length > NUMCHARACTERS) theRange.length = NUMCHARACTERS - theRange.location;
+        if (theRange.location == 0 && theRange.length == NUMCHARACTERS) { // Remove all
+            CFAllocatorDeallocate(CFGetAllocator(theSet), __CFCSetBitmapBits(theSet));
+            __CFCSetPutBitmapBits(theSet, NULL);
+        } else {
+            __CFCSetBitmapRemoveCharactersInRange(__CFCSetBitmapBits(theSet), (UniChar)theRange.location, (UniChar)(theRange.location + theRange.length - 1));
+        }
+    }
+
+    __CFCSetPutHasHashValue(theSet, false);
+    if (__CFCheckForExapendedSet) __CFCheckForExpandedSet(theSet);
+}
+
+void CFCharacterSetAddCharactersInString(CFMutableCharacterSetRef theSet,  CFStringRef theString) {
+    const UniChar *buffer;
+    CFIndex length;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, void, theSet, "addCharactersInString:", theString);
+
+    __CFCSetValidateTypeAndMutability(theSet, __PRETTY_FUNCTION__);
+
+    if ((__CFCSetIsEmpty(theSet) && __CFCSetIsInverted(theSet)) || !(length = CFStringGetLength(theString))) return;
+
+    if (!__CFCSetIsInverted(theSet)) {
+        CFIndex newLength = length + (__CFCSetIsEmpty(theSet) ? 0 : (__CFCSetIsString(theSet) ? __CFCSetStringLength(theSet) : __kCFStringCharSetMax));
+
+        if (newLength < __kCFStringCharSetMax) {
+            if (__CFCSetIsEmpty(theSet)) {
+                __CFCSetPutClassType(theSet, __kCFCharSetClassString);
+                __CFCSetPutStringLength(theSet, 0); // Make sure to reset this
+            }
+            
+            if (!__CFCSetStringBuffer(theSet))
+				__CFCSetPutStringBuffer(theSet, (UniChar *)CFAllocatorAllocate(CFGetAllocator(theSet), __kCFStringCharSetMax * sizeof(UniChar), 0));
+            buffer = __CFCSetStringBuffer(theSet) + __CFCSetStringLength(theSet);
+
+            __CFCSetPutClassType(theSet, __kCFCharSetClassString);
+            __CFCSetPutStringLength(theSet, newLength);
+            CFStringGetCharacters(theString, CFRangeMake(0, length), (UniChar*)buffer);
+            qsort(__CFCSetStringBuffer(theSet), newLength, sizeof(UniChar), chcompar);
+            __CFCSetPutHasHashValue(theSet, false);
+            return;
+        }
+    }
+
+    // OK, I have to be a bitmap
+    __CFCSetMakeBitmap(theSet);
+    if ((buffer = CFStringGetCharactersPtr(theString))) {
+        while (length--) __CFCSetBitmapAddCharacter(__CFCSetBitmapBits(theSet), *buffer++);
+    } else {
+        CFStringInlineBuffer inlineBuffer;
+        CFIndex idx;
+
+        CFStringInitInlineBuffer(theString, &inlineBuffer, CFRangeMake(0, length));
+        for (idx = 0;idx < length;idx++) __CFCSetBitmapAddCharacter(__CFCSetBitmapBits(theSet), __CFStringGetCharacterFromInlineBufferQuick(&inlineBuffer, idx));
+    }
+    __CFCSetPutHasHashValue(theSet, false);
+    if (__CFCheckForExapendedSet) __CFCheckForExpandedSet(theSet);
+}
+
+void CFCharacterSetRemoveCharactersInString(CFMutableCharacterSetRef theSet, CFStringRef theString) {
+    const UniChar *buffer;
+    CFIndex length;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, void, theSet, "removeCharactersInString:", theString);
+
+    __CFCSetValidateTypeAndMutability(theSet, __PRETTY_FUNCTION__);
+
+    if ((__CFCSetIsEmpty(theSet) && !__CFCSetIsInverted(theSet)) || !(length = CFStringGetLength(theString))) return;
+
+    if (__CFCSetIsInverted(theSet)) {
+        CFIndex newLength = length + (__CFCSetIsEmpty(theSet) ? 0 : (__CFCSetIsString(theSet) ? __CFCSetStringLength(theSet) : __kCFStringCharSetMax));
+
+        if (newLength < __kCFStringCharSetMax) {
+            if (__CFCSetIsEmpty(theSet)) {
+                __CFCSetPutClassType(theSet, __kCFCharSetClassString);
+                __CFCSetPutStringLength(theSet, 0); // Make sure to reset this
+            }
+
+            if (!__CFCSetStringBuffer(theSet))
+				__CFCSetPutStringBuffer(theSet, (UniChar *)CFAllocatorAllocate(CFGetAllocator(theSet), __kCFStringCharSetMax * sizeof(UniChar), 0));
+            buffer = __CFCSetStringBuffer(theSet) + __CFCSetStringLength(theSet);
+
+            __CFCSetPutClassType(theSet, __kCFCharSetClassString);
+            __CFCSetPutStringLength(theSet, newLength);
+            CFStringGetCharacters(theString, CFRangeMake(0, length), (UniChar *)buffer);
+            qsort(__CFCSetStringBuffer(theSet), newLength, sizeof(UniChar), chcompar);
+            __CFCSetPutHasHashValue(theSet, false);
+            return;
+        }
+    }
+
+    // OK, I have to be a bitmap
+    __CFCSetMakeBitmap(theSet);
+    if ((buffer = CFStringGetCharactersPtr(theString))) {
+        while (length--) __CFCSetBitmapRemoveCharacter(__CFCSetBitmapBits(theSet), *buffer++);
+    } else {
+        CFStringInlineBuffer inlineBuffer;
+        CFIndex idx;
+
+        CFStringInitInlineBuffer(theString, &inlineBuffer, CFRangeMake(0, length));
+        for (idx = 0;idx < length;idx++) __CFCSetBitmapRemoveCharacter(__CFCSetBitmapBits(theSet), __CFStringGetCharacterFromInlineBufferQuick(&inlineBuffer, idx));
+    }
+    __CFCSetPutHasHashValue(theSet, false);
+    if (__CFCheckForExapendedSet) __CFCheckForExpandedSet(theSet);
+}
+
+void CFCharacterSetUnion(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet) {
+    CFCharacterSetRef expandedSet = NULL;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, void, theSet, "formUnionWithCharacterSet:", theOtherSet);
+
+    __CFCSetValidateTypeAndMutability(theSet, __PRETTY_FUNCTION__);
+
+    if (__CFCSetIsEmpty(theSet) && __CFCSetIsInverted(theSet)) return; // Inverted empty set contains all char
+
+    if (!CF_IS_OBJC(__kCFCharacterSetTypeID, theOtherSet) || (expandedSet = __CFCharacterSetGetExpandedSetForNSCharacterSet(theOtherSet))) { // Really CF, we can do some trick here
+        if (expandedSet) theOtherSet = expandedSet;
+
+        if (__CFCSetIsEmpty(theOtherSet)) {
+            if (__CFCSetIsInverted(theOtherSet)) {
+                if (__CFCSetIsString(theSet) && __CFCSetStringBuffer(theSet)) {
+                    CFAllocatorDeallocate(CFGetAllocator(theSet), __CFCSetStringBuffer(theSet));
+                } else if (__CFCSetIsBitmap(theSet) && __CFCSetBitmapBits(theSet)) {
+                    CFAllocatorDeallocate(CFGetAllocator(theSet), __CFCSetBitmapBits(theSet));
+                } else if (__CFCSetIsCompactBitmap(theSet) && __CFCSetCompactBitmapBits(theSet)) {
+                    CFAllocatorDeallocate(CFGetAllocator(theSet), __CFCSetCompactBitmapBits(theSet));
+                }
+                __CFCSetPutClassType(theSet, __kCFCharSetClassRange);
+                __CFCSetPutRangeLength(theSet, 0);
+                __CFCSetPutIsInverted(theSet, true);
+                __CFCSetPutHasHashValue(theSet, false);
+                __CFCSetDeallocateAnnexPlane(theSet);
+            }
+        } else if (__CFCSetIsBuiltin(theOtherSet) && __CFCSetIsEmpty(theSet)) { // theSet can be builtin set
+            __CFCSetPutClassType(theSet, __kCFCharSetClassBuiltin);
+            __CFCSetPutBuiltinType(theSet, __CFCSetBuiltinType(theOtherSet));
+            __CFCSetPutHasHashValue(theSet, false);
+        } else {
+            if (__CFCSetIsRange(theOtherSet)) {
+                if (__CFCSetIsInverted(theOtherSet)) {
+                    UTF32Char firstChar = __CFCSetRangeFirstChar(theOtherSet);
+                    CFIndex length = __CFCSetRangeLength(theOtherSet);
+
+                    if (firstChar > 0) CFCharacterSetAddCharactersInRange(theSet, CFRangeMake(0, firstChar));
+                    firstChar += length;
+                    length = 0x110000 - firstChar;
+                    CFCharacterSetAddCharactersInRange(theSet, CFRangeMake(firstChar, length));
+                } else {
+                    CFCharacterSetAddCharactersInRange(theSet, CFRangeMake(__CFCSetRangeFirstChar(theOtherSet), __CFCSetRangeLength(theOtherSet)));
+                }
+            } else if (__CFCSetIsString(theOtherSet)) {
+                CFStringRef string = CFStringCreateWithCharactersNoCopy(CFGetAllocator(theSet), __CFCSetStringBuffer(theOtherSet), __CFCSetStringLength(theOtherSet), kCFAllocatorNull);
+                CFCharacterSetAddCharactersInString(theSet, string);
+                CFRelease(string);
+            } else {
+                __CFCSetMakeBitmap(theSet);
+                if (__CFCSetIsBitmap(theOtherSet)) {
+                    UInt32 *bitmap1 = (UInt32*)__CFCSetBitmapBits(theSet);
+                    UInt32 *bitmap2 = (UInt32*)__CFCSetBitmapBits(theOtherSet);
+                    CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+                    while (length--) *bitmap1++ |= *bitmap2++;
+                } else {
+                    UInt32 *bitmap1 = (UInt32*)__CFCSetBitmapBits(theSet);
+                    UInt32 *bitmap2;
+                    CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+                    uint8_t bitmapBuffer[__kCFBitmapSize];
+                    __CFCSetGetBitmap(theOtherSet, bitmapBuffer);
+                    bitmap2 = (UInt32*)bitmapBuffer;
+                    while (length--) *bitmap1++ |= *bitmap2++;
+                }
+                __CFCSetPutHasHashValue(theSet, false);
+            }
+            if (__CFCSetHasNonBMPPlane(theOtherSet)) {
+                CFMutableCharacterSetRef otherSetPlane;
+                int idx;
+
+                for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+                    if ((otherSetPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theOtherSet, idx))) {
+                        CFCharacterSetUnion((CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(theSet, idx), otherSetPlane);
+                    }
+                }
+            } else if (__CFCSetIsBuiltin(theOtherSet)) {
+                CFMutableCharacterSetRef annexPlane;
+                uint8_t bitmapBuffer[__kCFBitmapSize];
+                uint8_t result;
+                int planeIndex;
+                Boolean isOtherAnnexPlaneInverted = __CFCSetAnnexIsInverted(theOtherSet);
+                UInt32 *bitmap1;
+                UInt32 *bitmap2;
+                CFIndex length;
+
+                for (planeIndex = 1;planeIndex <= MAX_ANNEX_PLANE;planeIndex++) {
+                    result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(theOtherSet), planeIndex, bitmapBuffer, (isOtherAnnexPlaneInverted != 0));
+                    if (result != kCFUniCharBitmapEmpty) {
+                        annexPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(theSet, planeIndex);
+                        if (result == kCFUniCharBitmapAll) {
+                            CFCharacterSetAddCharactersInRange(annexPlane, CFRangeMake(0x0000, 0x10000));
+                        } else {
+                            __CFCSetMakeBitmap(annexPlane);
+                            bitmap1 = (UInt32 *)__CFCSetBitmapBits(annexPlane);
+                            length = __kCFBitmapSize / sizeof(UInt32);
+                            bitmap2 = (UInt32*)bitmapBuffer;
+                            while (length--) *bitmap1++ |= *bitmap2++;
+                        }
+                    }
+                }
+            }
+        }
+        if (__CFCheckForExapendedSet) __CFCheckForExpandedSet(theSet);
+    } else { // It's NSCharacterSet
+        CFDataRef bitmapRep = CFCharacterSetCreateBitmapRepresentation(kCFAllocatorSystemDefault, theOtherSet);
+        const UInt32 *bitmap2 = (bitmapRep && CFDataGetLength(bitmapRep) ? (const UInt32 *)CFDataGetBytePtr(bitmapRep) : NULL);
+        if (bitmap2) {
+            UInt32 *bitmap1;
+            CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+            __CFCSetMakeBitmap(theSet);
+            bitmap1 = (UInt32*)__CFCSetBitmapBits(theSet);
+            while (length--) *bitmap1++ |= *bitmap2++;
+            __CFCSetPutHasHashValue(theSet, false);
+        }
+        CFRelease(bitmapRep);
+    }
+}
+
+void CFCharacterSetIntersect(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet) {
+    CFCharacterSetRef expandedSet = NULL;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFCharacterSetTypeID, void, theSet, "formIntersectionWithCharacterSet:", theOtherSet);
+
+    __CFCSetValidateTypeAndMutability(theSet, __PRETTY_FUNCTION__);
+
+    if (__CFCSetIsEmpty(theSet) && !__CFCSetIsInverted(theSet)) return; // empty set
+
+    if (!CF_IS_OBJC(__kCFCharacterSetTypeID, theOtherSet) || (expandedSet = __CFCharacterSetGetExpandedSetForNSCharacterSet(theOtherSet))) { // Really CF, we can do some trick here
+        if (expandedSet) theOtherSet = expandedSet;
+
+        if (__CFCSetIsEmpty(theOtherSet)) {
+           if (!__CFCSetIsInverted(theOtherSet)) {
+                if (__CFCSetIsString(theSet) && __CFCSetStringBuffer(theSet)) {
+                    CFAllocatorDeallocate(CFGetAllocator(theSet), __CFCSetStringBuffer(theSet));
+                } else if (__CFCSetIsBitmap(theSet) && __CFCSetBitmapBits(theSet)) {
+                    CFAllocatorDeallocate(CFGetAllocator(theSet), __CFCSetBitmapBits(theSet));
+                } else if (__CFCSetIsCompactBitmap(theSet) && __CFCSetCompactBitmapBits(theSet)) {
+                    CFAllocatorDeallocate(CFGetAllocator(theSet), __CFCSetCompactBitmapBits(theSet));
+                }
+                __CFCSetPutClassType(theSet, __kCFCharSetClassBitmap);
+                __CFCSetPutBitmapBits(theSet, NULL);
+                __CFCSetPutIsInverted(theSet, false);
+                theSet->_hashValue = 0;
+                __CFCSetPutHasHashValue(theSet, true);
+                __CFCSetDeallocateAnnexPlane(theSet);
+            }
+        } else if (__CFCSetIsEmpty(theSet)) { // non inverted empty set contains all character
+            __CFCSetPutClassType(theSet, __CFCSetClassType(theOtherSet));
+            __CFCSetPutHasHashValue(theSet, __CFCSetHasHashValue(theOtherSet));
+            __CFCSetPutIsInverted(theSet, __CFCSetIsInverted(theOtherSet));
+            theSet->_hashValue = theOtherSet->_hashValue;
+            if (__CFCSetHasNonBMPPlane(theOtherSet)) {
+                CFMutableCharacterSetRef otherSetPlane;
+                int idx;
+                for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+                    if ((otherSetPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theOtherSet, idx))) {
+                        otherSetPlane = (CFMutableCharacterSetRef)CFCharacterSetCreateMutableCopy(CFGetAllocator(theSet), otherSetPlane);
+                        __CFCSetPutCharacterSetToAnnexPlane(theSet, otherSetPlane, idx);
+                        CFRelease(otherSetPlane);
+                    }
+                }
+                __CFCSetAnnexSetIsInverted(theSet, __CFCSetAnnexIsInverted(theOtherSet));
+            }
+
+            switch (__CFCSetClassType(theOtherSet)) {
+                case __kCFCharSetClassBuiltin:
+                    __CFCSetPutBuiltinType(theSet, __CFCSetBuiltinType(theOtherSet));
+                    break;
+
+                case __kCFCharSetClassRange:
+                    __CFCSetPutRangeFirstChar(theSet, __CFCSetRangeFirstChar(theOtherSet));
+                    __CFCSetPutRangeLength(theSet, __CFCSetRangeLength(theOtherSet));
+                    break;
+
+                case __kCFCharSetClassString:
+                    __CFCSetPutStringLength(theSet, __CFCSetStringLength(theOtherSet));
+                    if (!__CFCSetStringBuffer(theSet))
+						__CFCSetPutStringBuffer(theSet, (UniChar *)CFAllocatorAllocate(CFGetAllocator(theSet), __kCFStringCharSetMax * sizeof(UniChar), 0));
+                   memmove(__CFCSetStringBuffer(theSet), __CFCSetStringBuffer(theOtherSet), __CFCSetStringLength(theSet) * sizeof(UniChar));
+                    break;
+
+                case __kCFCharSetClassBitmap:
+					__CFCSetPutBitmapBits(theSet, (uint8_t *)CFAllocatorAllocate(CFGetAllocator(theSet), sizeof(uint8_t) * __kCFBitmapSize, 0));
+                    memmove(__CFCSetBitmapBits(theSet), __CFCSetBitmapBits(theOtherSet), __kCFBitmapSize);
+                    break;
+
+                case __kCFCharSetClassCompactBitmap: {
+                    const uint8_t *cBitmap = __CFCSetCompactBitmapBits(theOtherSet);
+                    uint8_t *newBitmap;
+                    uint32_t size = __CFCSetGetCompactBitmapSize(cBitmap);
+                    newBitmap = (uint8_t *)CFAllocatorAllocate(CFGetAllocator(theSet), sizeof(uint8_t) * size, 0);
+                    __CFCSetPutBitmapBits(theSet, newBitmap);
+                    memmove(newBitmap, cBitmap, size);
+                    }
+                    break;
+
+                default:
+                    CFAssert1(0, __kCFLogAssertion, "%s: Internal inconsistency error: unknown character set type", __PRETTY_FUNCTION__); // We should never come here
+            }
+        } else {
+            __CFCSetMakeBitmap(theSet);
+            if (__CFCSetIsBitmap(theOtherSet)) {
+                UInt32 *bitmap1 = (UInt32*)__CFCSetBitmapBits(theSet);
+                UInt32 *bitmap2 = (UInt32*)__CFCSetBitmapBits(theOtherSet);
+                CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+                while (length--) *bitmap1++ &= *bitmap2++;
+            } else {
+                UInt32 *bitmap1 = (UInt32*)__CFCSetBitmapBits(theSet);
+                UInt32 *bitmap2;
+                CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+                uint8_t bitmapBuffer[__kCFBitmapSize];
+                __CFCSetGetBitmap(theOtherSet, bitmapBuffer);
+                bitmap2 = (UInt32*)bitmapBuffer;
+                while (length--) *bitmap1++ &= *bitmap2++;
+            }
+            __CFCSetPutHasHashValue(theSet, false);
+            if (__CFCSetHasNonBMPPlane(theOtherSet)) {
+                CFMutableCharacterSetRef annexPlane;
+                CFMutableCharacterSetRef otherSetPlane;
+                int idx;
+                for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+                    if ((otherSetPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theOtherSet, idx))) {
+                        annexPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(theSet, idx);
+                        CFCharacterSetIntersect(annexPlane, otherSetPlane);
+                        if (__CFCSetIsEmpty(annexPlane) && !__CFCSetIsInverted(annexPlane)) __CFCSetPutCharacterSetToAnnexPlane(theSet, NULL, idx);
+                    } else if (__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, idx)) {
+                        __CFCSetPutCharacterSetToAnnexPlane(theSet, NULL, idx);
+                    }
+                }
+                if (!__CFCSetHasNonBMPPlane(theSet)) __CFCSetDeallocateAnnexPlane(theSet);
+            } else if (__CFCSetIsBuiltin(theOtherSet)) {
+                CFMutableCharacterSetRef annexPlane;
+                uint8_t bitmapBuffer[__kCFBitmapSize];
+                uint8_t result;
+                int planeIndex;
+                Boolean isOtherAnnexPlaneInverted = __CFCSetAnnexIsInverted(theOtherSet);
+                UInt32 *bitmap1;
+                UInt32 *bitmap2;
+                CFIndex length;
+
+                for (planeIndex = 1;planeIndex <= MAX_ANNEX_PLANE;planeIndex++) {
+                    annexPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, planeIndex);
+                    if (annexPlane) {
+                        result = CFUniCharGetBitmapForPlane(__CFCSetBuiltinType(theOtherSet), planeIndex, bitmapBuffer, (isOtherAnnexPlaneInverted != 0));
+                        if (result == kCFUniCharBitmapEmpty) {
+                            __CFCSetPutCharacterSetToAnnexPlane(theSet, NULL, planeIndex);
+                        } else if (result == kCFUniCharBitmapFilled) {
+                            Boolean isEmpty = true;
+
+                            __CFCSetMakeBitmap(annexPlane);
+                            bitmap1 = (UInt32 *)__CFCSetBitmapBits(annexPlane);
+                            length = __kCFBitmapSize / sizeof(UInt32);
+                            bitmap2 = (UInt32*)bitmapBuffer;
+
+                            while (length--) {
+                                if ((*bitmap1++ &= *bitmap2++)) isEmpty = false;
+                            }
+                            if (isEmpty) __CFCSetPutCharacterSetToAnnexPlane(theSet, NULL, planeIndex);
+                        }
+                    }
+                }
+                if (!__CFCSetHasNonBMPPlane(theSet)) __CFCSetDeallocateAnnexPlane(theSet);
+            } else if (__CFCSetIsRange(theOtherSet)) {
+                CFMutableCharacterSetRef tempOtherSet = CFCharacterSetCreateMutable(CFGetAllocator(theSet));
+                CFMutableCharacterSetRef annexPlane;
+                CFMutableCharacterSetRef otherSetPlane;
+                int idx;
+
+                __CFCSetAddNonBMPPlanesInRange(tempOtherSet, CFRangeMake(__CFCSetRangeFirstChar(theOtherSet), __CFCSetRangeLength(theOtherSet)));
+                
+                for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+                    if ((otherSetPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(tempOtherSet, idx))) {
+                        annexPlane = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSet(theSet, idx);
+                        CFCharacterSetIntersect(annexPlane, otherSetPlane);
+                        if (__CFCSetIsEmpty(annexPlane) && !__CFCSetIsInverted(annexPlane)) __CFCSetPutCharacterSetToAnnexPlane(theSet, NULL, idx);
+                    } else if (__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, idx)) {
+                        __CFCSetPutCharacterSetToAnnexPlane(theSet, NULL, idx);
+                    }
+                }
+                if (!__CFCSetHasNonBMPPlane(theSet)) __CFCSetDeallocateAnnexPlane(theSet);
+                CFRelease(tempOtherSet);
+            } else if (__CFCSetHasNonBMPPlane(theSet)) {
+                __CFCSetDeallocateAnnexPlane(theSet);
+            }
+        }
+        if (__CFCheckForExapendedSet) __CFCheckForExpandedSet(theSet);
+    } else { // It's NSCharacterSet
+        CFDataRef bitmapRep = CFCharacterSetCreateBitmapRepresentation(kCFAllocatorSystemDefault, theOtherSet);
+        const UInt32 *bitmap2 = (bitmapRep && CFDataGetLength(bitmapRep) ? (const UInt32 *)CFDataGetBytePtr(bitmapRep) : NULL);
+        if (bitmap2) {
+            UInt32 *bitmap1;
+            CFIndex length = __kCFBitmapSize / sizeof(UInt32);
+            __CFCSetMakeBitmap(theSet);
+            bitmap1 = (UInt32*)__CFCSetBitmapBits(theSet);
+            while (length--) *bitmap1++ &= *bitmap2++;
+            __CFCSetPutHasHashValue(theSet, false);
+        }
+        CFRelease(bitmapRep);
+    }
+}
+
+void CFCharacterSetInvert(CFMutableCharacterSetRef theSet) {
+
+    CF_OBJC_FUNCDISPATCH0(__kCFCharacterSetTypeID, void, theSet, "invert");
+
+    __CFCSetValidateTypeAndMutability(theSet, __PRETTY_FUNCTION__);
+
+    __CFCSetPutHasHashValue(theSet, false);
+
+    if (__CFCSetClassType(theSet) == __kCFCharSetClassBitmap) {
+        CFIndex idx;
+        CFIndex count = __kCFBitmapSize / sizeof(UInt32);
+        UInt32 *bitmap = (UInt32*) __CFCSetBitmapBits(theSet);
+
+        if (NULL == bitmap) {
+            bitmap =  (UInt32 *)CFAllocatorAllocate(CFGetAllocator(theSet), __kCFBitmapSize, 0);
+            __CFCSetPutBitmapBits(theSet, (uint8_t *)bitmap);
+            for (idx = 0;idx < count;idx++) bitmap[idx] = ((UInt32)0xFFFFFFFF);
+        } else {
+            for (idx = 0;idx < count;idx++) bitmap[idx] = ~(bitmap[idx]);
+        }
+        __CFCSetAllocateAnnexForPlane(theSet, 0); // We need to alloc annex to invert
+    } else if (__CFCSetClassType(theSet) == __kCFCharSetClassCompactBitmap) {
+        uint8_t *bitmap = __CFCSetCompactBitmapBits(theSet);
+        int idx;
+        int length = 0;
+        uint8_t value;
+
+        for (idx = 0;idx < __kCFCompactBitmapNumPages;idx++) {
+            value = bitmap[idx];
+
+            if (value == 0) {
+                bitmap[idx] = UINT8_MAX;
+            } else if (value == UINT8_MAX) {
+                bitmap[idx] = 0;
+            } else {
+                length += __kCFCompactBitmapPageSize;
+            }
+        }
+        bitmap += __kCFCompactBitmapNumPages;
+        for (idx = 0;idx < length;idx++) bitmap[idx] = ~(bitmap[idx]);
+        __CFCSetAllocateAnnexForPlane(theSet, 0); // We need to alloc annex to invert
+    } else {
+        __CFCSetPutIsInverted(theSet, !__CFCSetIsInverted(theSet));
+    }
+    __CFCSetAnnexSetIsInverted(theSet, !__CFCSetAnnexIsInverted(theSet));
+}
+
+void CFCharacterSetCompact(CFMutableCharacterSetRef theSet) {
+    if (__CFCSetIsBitmap(theSet) && __CFCSetBitmapBits(theSet)) __CFCSetMakeCompact(theSet);
+    if (__CFCSetHasNonBMPPlane(theSet)) {
+        CFMutableCharacterSetRef annex;
+        int idx;
+
+        for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+            if ((annex = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, idx)) && __CFCSetIsBitmap(annex) && __CFCSetBitmapBits(annex)) {
+                __CFCSetMakeCompact(annex);
+            }
+        }
+    }
+}
+
+void CFCharacterSetFast(CFMutableCharacterSetRef theSet) {
+    if (__CFCSetIsCompactBitmap(theSet) && __CFCSetCompactBitmapBits(theSet)) __CFCSetMakeBitmap(theSet);
+    if (__CFCSetHasNonBMPPlane(theSet)) {
+        CFMutableCharacterSetRef annex;
+        int idx;
+
+        for (idx = 1;idx <= MAX_ANNEX_PLANE;idx++) {
+            if ((annex = (CFMutableCharacterSetRef)__CFCSetGetAnnexPlaneCharacterSetNoAlloc(theSet, idx)) && __CFCSetIsCompactBitmap(annex) && __CFCSetCompactBitmapBits(annex)) {
+                __CFCSetMakeBitmap(annex);
+            }
+        }
+    }
+}
+
+/* Keyed-coding support
+*/
+CFCharacterSetKeyedCodingType _CFCharacterSetGetKeyedCodingType(CFCharacterSetRef cset) {
+    switch (__CFCSetClassType(cset)) {
+        case __kCFCharSetClassBuiltin: return ((__CFCSetBuiltinType(cset) < kCFCharacterSetSymbol) ? kCFCharacterSetKeyedCodingTypeBuiltin : kCFCharacterSetKeyedCodingTypeBuiltinAndBitmap);
+        case __kCFCharSetClassRange: return kCFCharacterSetKeyedCodingTypeRange;
+
+        case __kCFCharSetClassString: // We have to check if we have non-BMP here
+            if (!__CFCSetHasNonBMPPlane(cset) && !__CFCSetAnnexIsInverted(cset)) return kCFCharacterSetKeyedCodingTypeString; // BMP only. we can archive the string
+        /* fallthrough */
+
+        default:
+            return kCFCharacterSetKeyedCodingTypeBitmap;
+    }
+}
+
+bool _CFCharacterSetIsMutable(CFCharacterSetRef cset) { return __CFCSetIsMutable(cset); }
+CFCharacterSetPredefinedSet _CFCharacterSetGetKeyedCodingBuiltinType(CFCharacterSetRef cset) { return __CFCSetBuiltinType(cset); }
+CFRange _CFCharacterSetGetKeyedCodingRange(CFCharacterSetRef cset) { return CFRangeMake(__CFCSetRangeFirstChar(cset), __CFCSetRangeLength(cset)); }
+CFStringRef _CFCharacterSetCreateKeyedCodingString(CFCharacterSetRef cset) { return CFStringCreateWithCharacters(kCFAllocatorSystemDefault, __CFCSetStringBuffer(cset), __CFCSetStringLength(cset)); }
+
+bool _CFCharacterSetIsInverted(CFCharacterSetRef cset) { return (__CFCSetIsInverted(cset) != 0); }
+void _CFCharacterSetSetIsInverted(CFCharacterSetRef cset, bool flag) { __CFCSetPutIsInverted((CFMutableCharacterSetRef)cset, flag); }
+
+/* Inline buffer support
+*/
+void CFCharacterSetInitInlineBuffer(CFCharacterSetRef cset, CFCharacterSetInlineBuffer *buffer) {
+    memset(buffer, 0, sizeof(CFCharacterSetInlineBuffer));
+    buffer->cset = cset;
+    buffer->rangeLimit = 0x10000;
+
+    if (CF_IS_OBJC(__kCFCharacterSetTypeID, cset)) {
+        CFCharacterSetRef expandedSet = __CFCharacterSetGetExpandedSetForNSCharacterSet(cset);
+
+        if (NULL == expandedSet) {
+            buffer->flags = kCFCharacterSetNoBitmapAvailable;
+            buffer->rangeLimit = 0x110000;
+
+            return;
+        } else {
+            cset = expandedSet;
+        }
+    }
+
+    switch (__CFCSetClassType(cset)) {
+        case __kCFCharSetClassBuiltin:
+            buffer->bitmap = CFUniCharGetBitmapPtrForPlane(__CFCSetBuiltinType(cset), 0);
+            buffer->rangeLimit = 0x110000;
+            if (NULL == buffer->bitmap) {
+                buffer->flags = kCFCharacterSetNoBitmapAvailable;
+            } else {
+                if (__CFCSetIsInverted(cset)) buffer->flags = kCFCharacterSetIsInverted;
+            }
+            break;
+            
+        case __kCFCharSetClassRange:
+            buffer->rangeStart = __CFCSetRangeFirstChar(cset);
+            buffer->rangeLimit = __CFCSetRangeFirstChar(cset) + __CFCSetRangeLength(cset);
+            if (__CFCSetIsInverted(cset)) buffer->flags = kCFCharacterSetIsInverted;
+            return;
+            
+        case __kCFCharSetClassString:
+            buffer->flags = kCFCharacterSetNoBitmapAvailable;
+            if (__CFCSetStringLength(cset) > 0) {
+                buffer->rangeStart = *__CFCSetStringBuffer(cset);
+                buffer->rangeLimit = *(__CFCSetStringBuffer(cset) + __CFCSetStringLength(cset) - 1) + 1;
+
+                if (__CFCSetIsInverted(cset)) {
+                    if (0 == buffer->rangeStart) {
+                        buffer->rangeStart = buffer->rangeLimit;
+                        buffer->rangeLimit = 0x10000;
+                    } else if (0x10000 == buffer->rangeLimit) {
+                        buffer->rangeLimit = buffer->rangeStart;
+                        buffer->rangeStart = 0;
+                    } else {
+                        buffer->rangeStart = 0;
+                        buffer->rangeLimit = 0x10000;
+                    }
+                }
+            }
+            break;
+            
+        case __kCFCharSetClassBitmap:
+        case __kCFCharSetClassCompactBitmap:
+            buffer->bitmap = __CFCSetCompactBitmapBits(cset);
+            if (NULL == buffer->bitmap) {
+                buffer->flags = kCFCharacterSetIsCompactBitmap;
+                if (__CFCSetIsInverted(cset)) buffer->flags |= kCFCharacterSetIsInverted;
+            } else {
+                if (__kCFCharSetClassCompactBitmap == __CFCSetClassType(cset)) buffer->flags = kCFCharacterSetIsCompactBitmap;
+            }
+            break;
+            
+        default:
+            CFAssert1(0, __kCFLogAssertion, "%s: Internal inconsistency error: unknown character set type", __PRETTY_FUNCTION__); // We should never come here
+            return;
+    }
+
+    if (__CFCSetAnnexIsInverted(cset)) {
+        buffer->rangeLimit = 0x110000;
+    } else if (__CFCSetHasNonBMPPlane(cset)) {
+        CFIndex index;
+
+        for (index = MAX_ANNEX_PLANE;index > 0;index--) {
+            if (NULL != __CFCSetGetAnnexPlaneCharacterSetNoAlloc(cset, index)) {
+                buffer->rangeLimit = (index + 1) << 16;
+                break;
+            }
+        }
+    }
+}
diff --git a/CoreFoundation/CFCharacterSet.h b/CoreFoundation/CFCharacterSet.h
new file mode 100644
index 0000000..9360965
--- /dev/null
+++ b/CoreFoundation/CFCharacterSet.h
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFData.h>
+
+CF_EXTERN_C_BEGIN
+
+/*!
+	@typedef CFCharacterSetRef
+	This is the type of a reference to immutable CFCharacterSets.
+*/
+typedef const struct __CFCharacterSet * CFCharacterSetRef;
+
+/*!
+	@typedef CFMutableCharacterSetRef
+	This is the type of a reference to mutable CFMutableCharacterSets.
+*/
+typedef struct __CFCharacterSet * CFMutableCharacterSetRef;
+
+/*!
+	@typedef CFCharacterSetPredefinedSet
+        Type of the predefined CFCharacterSet selector values.
+*/
+   
+enum {
+    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*) */
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFCharacterSetCapitalizedLetter = 13, /* Titlecase character set (Unicode General Category Lt) */
+#endif
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFCharacterSetSymbol = 14, /* Symbol character set (Unicode General Category S*) */
+#endif
+#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFCharacterSetNewline = 15, /* Newline character set (U000A ~ U000D, U0085, U2028, and U2029) */
+#endif
+    kCFCharacterSetIllegal = 12/* Illegal character set */
+};
+typedef CFIndex CFCharacterSetPredefinedSet;
+
+/*!
+	@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);
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/*!
+	@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);
+#endif
+
+/*!
+	@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);
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+#endif
+
+/*!
+	@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);
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/*!
+	@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);
+#endif
+
+/*!
+	@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
+
+#endif /* ! __COREFOUNDATION_CFCHARACTERSET__ */
+
diff --git a/CoreFoundation/CFCharacterSetBitmaps.bitmap b/CoreFoundation/CFCharacterSetBitmaps.bitmap
new file mode 100644
index 0000000..b0874f9
--- /dev/null
+++ b/CoreFoundation/CFCharacterSetBitmaps.bitmap
Binary files differ
diff --git a/CoreFoundation/CFCharacterSetPriv.h b/CoreFoundation/CFCharacterSetPriv.h
new file mode 100644
index 0000000..6d65653
--- /dev/null
+++ b/CoreFoundation/CFCharacterSetPriv.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFCHARACTERSETPRIV__)
+#define __COREFOUNDATION_CFCHARACTERSETPRIV__ 1
+
+#include <CoreFoundation/CFCharacterSet.h>
+
+CF_EXTERN_C_BEGIN
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/*!
+	@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 ((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL;
+}
+#endif
+
+/* 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
+*/
+enum {
+    kCFCharacterSetKeyedCodingTypeBitmap = 1,
+    kCFCharacterSetKeyedCodingTypeBuiltin = 2,
+    kCFCharacterSetKeyedCodingTypeRange = 3,
+    kCFCharacterSetKeyedCodingTypeString = 4,
+    kCFCharacterSetKeyedCodingTypeBuiltinAndBitmap = 5
+};
+typedef CFIndex CFCharacterSetKeyedCodingType;
+
+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/CoreFoundation/CFConcreteStreams.c b/CoreFoundation/CFConcreteStreams.c
new file mode 100644
index 0000000..6218446
--- /dev/null
+++ b/CoreFoundation/CFConcreteStreams.c
@@ -0,0 +1,870 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFConcreteStreams.c
+	Copyright 2000-2002, Apple, Inc. All rights reserved.
+	Responsibility: Becky Willrich
+*/
+
+#define _DARWIN_UNLIMITED_SELECT 1
+
+#include "CFStreamInternal.h"
+#include "CFInternal.h"
+#include "CFPriv.h"
+#include <CoreFoundation/CFNumber.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdio.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#include <sys/time.h>
+#include <unistd.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <io.h>
+#define lseek _lseek
+#define open _open
+#define read _read
+#define write _write
+#define close _close
+#endif
+
+// On Unix, you can schedule an fd with the RunLoop by creating a CFSocket around it.  On Win32
+// files and sockets are not interchangeable, and we do cheapo scheduling, where the file is
+// always readable and writable until we hit EOF (similar to the way CFData streams are scheduled).
+#if DEPLOYMENT_TARGET_MACOSX
+#define REAL_FILE_SCHEDULING (1)
+#endif
+
+#define SCHEDULE_AFTER_WRITE  (0)
+#define SCHEDULE_AFTER_READ   (1)
+#define APPEND                (3)
+#define AT_EOF                (4)
+#define USE_RUNLOOP_ARRAY     (5)
+
+
+/* File callbacks */
+typedef struct {
+    CFURLRef url;
+    int fd;
+#ifdef REAL_FILE_SCHEDULING
+    union {
+        CFSocketRef sock;		// socket created once we open and have an fd
+        CFMutableArrayRef rlArray;	// scheduling information prior to open
+    } rlInfo; // If fd > 0, sock exists.  Otherwise, rlArray.
+#else
+    uint16_t scheduled;	// ref count of how many times we've been scheduled
+#endif
+    CFOptionFlags flags;    
+    off_t offset;
+} _CFFileStreamContext;
+
+
+CONST_STRING_DECL(kCFStreamPropertyFileCurrentOffset, "kCFStreamPropertyFileCurrentOffset");
+
+
+#ifdef REAL_FILE_SCHEDULING
+static void fileCallBack(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info);
+
+static void constructCFSocket(_CFFileStreamContext *fileStream, Boolean forRead, struct _CFStream *stream) {
+    CFSocketContext context = {0, stream, NULL, NULL, CFCopyDescription};
+    CFSocketRef sock = CFSocketCreateWithNative(CFGetAllocator(stream), fileStream->fd, forRead ? kCFSocketReadCallBack : kCFSocketWriteCallBack, fileCallBack, &context);
+    CFSocketSetSocketFlags(sock, 0);
+    if (fileStream->rlInfo.rlArray) {
+        CFIndex i, c = CFArrayGetCount(fileStream->rlInfo.rlArray);
+        CFRunLoopSourceRef src = CFSocketCreateRunLoopSource(CFGetAllocator(stream), sock, 0);
+        for (i = 0; i+1 < c; i += 2) {
+            CFRunLoopRef rl = (CFRunLoopRef)CFArrayGetValueAtIndex(fileStream->rlInfo.rlArray, i);
+            CFStringRef mode = (CFStringRef)CFArrayGetValueAtIndex(fileStream->rlInfo.rlArray, i+1);
+            CFRunLoopAddSource(rl, src, mode);
+        }
+        CFRelease(fileStream->rlInfo.rlArray);
+        CFRelease(src);
+    }    
+    fileStream->rlInfo.sock = sock;
+}
+#endif
+
+static Boolean constructFD(_CFFileStreamContext *fileStream, CFStreamError *error, Boolean forRead, struct _CFStream *stream) {
+    UInt8 path[1024];
+    int flags = forRead ? O_RDONLY : (O_CREAT | O_TRUNC | O_WRONLY);
+
+    if (CFURLGetFileSystemRepresentation(fileStream->url, TRUE, path, 1024) == FALSE) {
+        error->error = ENOENT;
+        error->domain = kCFStreamErrorDomainPOSIX;
+        return FALSE;
+    }
+    if (__CFBitIsSet(fileStream->flags, APPEND)) {
+        flags |= O_APPEND;
+        if(_CFExecutableLinkedOnOrAfter(CFSystemVersionPanther)) flags &= ~O_TRUNC;
+    }
+    
+    do {
+        fileStream->fd = open((const char *)path, flags, 0666);
+        
+        if (fileStream->fd < 0)
+            break;
+        
+        if ((fileStream->offset != -1) && (lseek(fileStream->fd, fileStream->offset, SEEK_SET) == -1))
+            break;
+
+#ifdef REAL_FILE_SCHEDULING
+        if (fileStream->rlInfo.rlArray != NULL) {
+            constructCFSocket(fileStream, forRead, stream);
+        }
+#endif
+
+        return TRUE;
+    } while (1);
+
+    __CFBitSet(fileStream->flags, USE_RUNLOOP_ARRAY);
+    error->error = errno;
+    error->domain = kCFStreamErrorDomainPOSIX;
+
+    return FALSE;
+}
+
+static Boolean fileOpen(struct _CFStream *stream, CFStreamError *errorCode, Boolean *openComplete, void *info) {
+    _CFFileStreamContext *ctxt = (_CFFileStreamContext *)info;
+    Boolean forRead = (CFGetTypeID(stream) == CFReadStreamGetTypeID());
+    *openComplete = TRUE;
+    if (ctxt->url) {
+        if (constructFD(ctxt, errorCode, forRead, stream)) {
+#ifndef REAL_FILE_SCHEDULING
+            if (ctxt->scheduled > 0) {
+                if (forRead)
+                    CFReadStreamSignalEvent((CFReadStreamRef)stream, kCFStreamEventHasBytesAvailable, NULL);
+                else
+                    CFWriteStreamSignalEvent((CFWriteStreamRef)stream, kCFStreamEventCanAcceptBytes, NULL);
+            }
+#endif
+            return TRUE;
+        } else {
+            return FALSE;
+        }
+#ifdef REAL_FILE_SCHEDULING
+    } else if (ctxt->rlInfo.rlArray != NULL) {
+        constructCFSocket(ctxt, forRead, stream);
+#endif
+    }
+    return TRUE;
+}
+
+__private_extern__ CFIndex fdRead(int fd, UInt8 *buffer, CFIndex bufferLength, CFStreamError *errorCode, Boolean *atEOF) {
+    CFIndex bytesRead = read(fd, buffer, bufferLength);
+    if (bytesRead < 0) {
+        errorCode->error = errno;
+        errorCode->domain = kCFStreamErrorDomainPOSIX;
+        return -1;
+    } else {
+        *atEOF = (bytesRead == 0) ? TRUE : FALSE;
+        errorCode->error = 0;
+        return bytesRead;
+    }
+}
+
+static CFIndex fileRead(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *errorCode, Boolean *atEOF, void *info) {
+    _CFFileStreamContext *ctxt = (_CFFileStreamContext *)info;
+    CFIndex result;
+    result = fdRead(ctxt->fd, buffer, bufferLength, errorCode, atEOF);
+#ifdef REAL_FILE_SCHEDULING
+    if (__CFBitIsSet(ctxt->flags, SCHEDULE_AFTER_READ)) {
+        __CFBitClear(ctxt->flags, SCHEDULE_AFTER_READ);
+        if (ctxt->rlInfo.sock) {
+            CFSocketEnableCallBacks(ctxt->rlInfo.sock, kCFSocketReadCallBack);
+        }
+    }
+#else
+    if (*atEOF)
+        __CFBitSet(ctxt->flags, AT_EOF);
+    if (ctxt->scheduled > 0 && !*atEOF) {
+        CFReadStreamSignalEvent(stream, kCFStreamEventHasBytesAvailable, NULL);
+    }
+#endif
+    return result;
+}
+
+#ifdef REAL_FILE_SCHEDULING
+__private_extern__ Boolean fdCanRead(int fd) {
+    struct timeval timeout = {0, 0};
+    fd_set *readSetPtr;
+    fd_set readSet;
+    Boolean result;
+// fd_set is not a mask in Win32, so checking for an fd that's too big is not relevant
+    if (fd < FD_SETSIZE) {
+        FD_ZERO(&readSet);
+        readSetPtr = &readSet;
+    } else {
+        int size = howmany(fd+1, NFDBITS) * sizeof(uint32_t);
+        uint32_t *fds_bits = (uint32_t *)malloc(size);
+        memset(fds_bits, 0, size);
+        readSetPtr = (fd_set *)fds_bits;
+    }
+    FD_SET(fd, readSetPtr);
+    result = (select(fd + 1, readSetPtr, NULL, NULL, &timeout) == 1) ? TRUE : FALSE;
+    if (readSetPtr != &readSet) {
+        free(readSetPtr);
+    }
+    return result;
+}
+#endif
+
+static Boolean fileCanRead(CFReadStreamRef stream, void *info) {
+    _CFFileStreamContext *ctxt = (_CFFileStreamContext *)info;
+#ifdef REAL_FILE_SCHEDULING
+    return fdCanRead(ctxt->fd);
+#else
+    return !__CFBitIsSet(ctxt->flags, AT_EOF);
+#endif
+}
+
+__private_extern__ CFIndex fdWrite(int fd, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *errorCode) {
+    CFIndex bytesWritten = write(fd, buffer, bufferLength);
+    if (bytesWritten < 0) {
+        errorCode->error = errno;
+        errorCode->domain = kCFStreamErrorDomainPOSIX;
+        return -1;
+    } else {
+        errorCode->error = 0;
+        return bytesWritten;
+    }
+}
+
+static CFIndex fileWrite(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *errorCode, void *info) {
+    _CFFileStreamContext *fileStream = ((_CFFileStreamContext *)info);
+    CFIndex result = fdWrite(fileStream->fd, buffer, bufferLength, errorCode);
+#ifdef REAL_FILE_SCHEDULING
+    if (__CFBitIsSet(fileStream->flags, SCHEDULE_AFTER_WRITE)) {
+        __CFBitClear(fileStream->flags, SCHEDULE_AFTER_WRITE);
+        if (fileStream->rlInfo.sock) {
+            CFSocketEnableCallBacks(fileStream->rlInfo.sock, kCFSocketWriteCallBack);
+        }
+    }
+#else
+    if (fileStream->scheduled > 0) {
+        CFWriteStreamSignalEvent(stream, kCFStreamEventCanAcceptBytes, NULL);
+    }
+#endif
+    return result;
+}
+
+#ifdef REAL_FILE_SCHEDULING
+__private_extern__ Boolean fdCanWrite(int fd) {
+    struct timeval timeout = {0, 0};
+    fd_set *writeSetPtr;
+    fd_set writeSet;
+    Boolean result;
+    if (fd < FD_SETSIZE) {
+        FD_ZERO(&writeSet);
+        writeSetPtr = &writeSet;
+    } else {
+        int size = howmany(fd+1, NFDBITS) * sizeof(uint32_t);
+        uint32_t *fds_bits = (uint32_t *)malloc(size);
+        memset(fds_bits, 0, size);
+        writeSetPtr = (fd_set *)fds_bits;
+    }
+    FD_SET(fd, writeSetPtr);
+    result = (select(fd + 1, NULL, writeSetPtr, NULL, &timeout) == 1) ? TRUE : FALSE;
+    if (writeSetPtr != &writeSet) {
+        free(writeSetPtr);
+    }
+    return result;
+}
+#endif
+
+static Boolean fileCanWrite(CFWriteStreamRef stream, void *info) {
+#ifdef REAL_FILE_SCHEDULING
+    return fdCanWrite(((_CFFileStreamContext *)info)->fd);
+#else
+    return TRUE;
+#endif
+}
+
+static void fileClose(struct _CFStream *stream, void *info) {
+    _CFFileStreamContext *ctxt = (_CFFileStreamContext *)info;
+    if (ctxt->fd >= 0) {
+        close(ctxt->fd);
+        ctxt->fd = -1;
+#ifdef REAL_FILE_SCHEDULING
+        if (ctxt->rlInfo.sock) {
+            CFSocketInvalidate(ctxt->rlInfo.sock);
+            CFRelease(ctxt->rlInfo.sock);
+            ctxt->rlInfo.sock = NULL;
+        }
+    } else if (ctxt->rlInfo.rlArray) {
+        CFRelease(ctxt->rlInfo.rlArray);
+        ctxt->rlInfo.rlArray = NULL;
+#endif
+    }
+}
+
+#ifdef REAL_FILE_SCHEDULING
+static void fileCallBack(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) {
+    struct _CFStream *stream = (struct _CFStream *)info;
+    Boolean isReadStream = (CFGetTypeID(stream) == CFReadStreamGetTypeID());
+    _CFFileStreamContext *fileStream = (_CFFileStreamContext *)((isReadStream) ? CFReadStreamGetInfoPointer((CFReadStreamRef)stream) : CFWriteStreamGetInfoPointer((CFWriteStreamRef)stream));
+    if (type == kCFSocketWriteCallBack) {
+        __CFBitSet(fileStream->flags, SCHEDULE_AFTER_WRITE);
+        CFWriteStreamSignalEvent((CFWriteStreamRef)stream, kCFStreamEventCanAcceptBytes, NULL);
+    } else {
+        // type == kCFSocketReadCallBack
+        __CFBitSet(fileStream->flags, SCHEDULE_AFTER_READ);
+        CFReadStreamSignalEvent((CFReadStreamRef)stream, kCFStreamEventHasBytesAvailable, NULL);
+    }
+}
+#endif
+
+static void fileSchedule(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info) {
+    _CFFileStreamContext *fileStream = (_CFFileStreamContext *)info;
+    Boolean isReadStream = (CFGetTypeID(stream) == CFReadStreamGetTypeID());
+    CFStreamStatus status = isReadStream ? CFReadStreamGetStatus((CFReadStreamRef)stream) : CFWriteStreamGetStatus((CFWriteStreamRef)stream);
+    if (fileStream->fd < 0 && status != kCFStreamStatusNotOpen) {
+        // Stream's already closed or error-ed out 
+        return;
+    }
+#ifdef REAL_FILE_SCHEDULING
+    if (status == kCFStreamStatusNotOpen) {
+        if (!fileStream->rlInfo.rlArray) {
+            fileStream->rlInfo.rlArray = CFArrayCreateMutable(CFGetAllocator(stream), 0, &kCFTypeArrayCallBacks);
+        }
+        CFArrayAppendValue(fileStream->rlInfo.rlArray, runLoop);
+        CFArrayAppendValue(fileStream->rlInfo.rlArray, runLoopMode);
+    } else {
+        CFRunLoopSourceRef rlSrc;
+        if (!fileStream->rlInfo.sock) {
+            constructCFSocket(fileStream, isReadStream, stream);
+        }
+        rlSrc = CFSocketCreateRunLoopSource(CFGetAllocator(stream), fileStream->rlInfo.sock, 0);
+        CFRunLoopAddSource(runLoop, rlSrc, runLoopMode);
+        CFRelease(rlSrc);
+    }
+#else
+    fileStream->scheduled++;
+    if (fileStream->scheduled == 1 && fileStream->fd > 0 && status == kCFStreamStatusOpen) {
+        if (isReadStream)
+            CFReadStreamSignalEvent((CFReadStreamRef)stream, kCFStreamEventHasBytesAvailable, NULL);
+        else
+            CFWriteStreamSignalEvent((CFWriteStreamRef)stream, kCFStreamEventCanAcceptBytes, NULL);
+    }
+#endif
+}
+
+static void fileUnschedule(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info) {
+    _CFFileStreamContext *fileStream = (_CFFileStreamContext *)info;
+#ifdef REAL_FILE_SCHEDULING
+    Boolean isReadStream = (CFGetTypeID(stream) == CFReadStreamGetTypeID());
+    CFStreamStatus status = isReadStream ? CFReadStreamGetStatus((CFReadStreamRef)stream) : CFWriteStreamGetStatus((CFWriteStreamRef)stream);
+    if (status == kCFStreamStatusNotOpen) {
+        // Not opened yet
+        if (fileStream->rlInfo.rlArray) {
+            CFMutableArrayRef runloops = fileStream->rlInfo.rlArray;
+            CFIndex i, c;
+            for (i = 0, c = CFArrayGetCount(runloops); i+1 < c; i += 2) {
+                if (CFEqual(CFArrayGetValueAtIndex(runloops, i), runLoop) && CFEqual(CFArrayGetValueAtIndex(runloops, i+1), runLoopMode)) {
+                    CFArrayRemoveValueAtIndex(runloops, i);
+                    CFArrayRemoveValueAtIndex(runloops, i);
+                    break;
+                }
+            }
+        }
+    } else if (fileStream->rlInfo.sock) {
+		if (__CFBitIsSet(fileStream->flags, USE_RUNLOOP_ARRAY)) {
+			// we know that fileStream->rlInfo.rlArray is non-NULL because it is in a union with fileStream->rlInfo.sock
+            CFMutableArrayRef runloops = fileStream->rlInfo.rlArray;
+            CFIndex i, c;
+            for (i = 0, c = CFArrayGetCount(runloops); i+1 < c; i += 2) {
+                if (CFEqual(CFArrayGetValueAtIndex(runloops, i), runLoop) && CFEqual(CFArrayGetValueAtIndex(runloops, i+1), runLoopMode)) {
+                    CFArrayRemoveValueAtIndex(runloops, i);
+                    CFArrayRemoveValueAtIndex(runloops, i);
+                    break;
+                }
+            }
+        } else {
+			CFRunLoopSourceRef sockSource = CFSocketCreateRunLoopSource(CFGetAllocator(stream), fileStream->rlInfo.sock, 0);
+			CFRunLoopRemoveSource(runLoop, sockSource, runLoopMode);
+			CFRelease(sockSource);
+		}
+    }
+#else
+    if (fileStream->scheduled > 0)
+        fileStream->scheduled--;
+#endif
+}
+
+static CFTypeRef fileCopyProperty(struct _CFStream *stream, CFStringRef propertyName, void *info) {
+    
+    CFTypeRef result = NULL;
+    _CFFileStreamContext *fileStream = (_CFFileStreamContext *)info;
+
+    if (CFEqual(propertyName, kCFStreamPropertyFileCurrentOffset)) {
+        
+        // NOTE that this does a lseek of 0 from the current location in
+        // order to populate the offset field which will then be used to
+        // create the resulting value.
+        if (!__CFBitIsSet(fileStream->flags, APPEND) && fileStream->fd != -1) {
+            fileStream->offset = lseek(fileStream->fd, 0, SEEK_CUR);
+        }
+        
+        if (fileStream->offset != -1) {
+            result = CFNumberCreate(CFGetAllocator((CFTypeRef)stream), kCFNumberSInt64Type, &(fileStream->offset));
+        }
+    }
+
+    return result;
+}
+
+static Boolean fileSetProperty(struct _CFStream *stream, CFStringRef prop, CFTypeRef val, void *info) {
+    
+    Boolean result = FALSE;
+    _CFFileStreamContext *fileStream = (_CFFileStreamContext *)info;
+
+    if (CFEqual(prop, kCFStreamPropertyAppendToFile) && CFGetTypeID(stream) == CFWriteStreamGetTypeID() &&
+        CFWriteStreamGetStatus((CFWriteStreamRef)stream) == kCFStreamStatusNotOpen)
+    {
+        if (val == kCFBooleanTrue) {
+            __CFBitSet(fileStream->flags, APPEND);
+            fileStream->offset = -1;				// Can't offset and append on the stream
+        } else {
+            __CFBitClear(fileStream->flags, APPEND);
+        }
+        result = TRUE;
+    }
+    
+    else if (CFEqual(prop, kCFStreamPropertyFileCurrentOffset)) {
+        
+        if (!__CFBitIsSet(fileStream->flags, APPEND))
+        {
+            result = CFNumberGetValue((CFNumberRef)val, kCFNumberSInt64Type, &(fileStream->offset));
+        }
+        
+        if ((fileStream->fd != -1) && (lseek(fileStream->fd, fileStream->offset, SEEK_SET) == -1)) {
+            result = FALSE;
+        }
+    }
+    
+    return result;
+}
+
+static void *fileCreate(struct _CFStream *stream, void *info) {
+    _CFFileStreamContext *ctxt = (_CFFileStreamContext *)info;
+    _CFFileStreamContext *newCtxt = (_CFFileStreamContext *)CFAllocatorAllocate(CFGetAllocator(stream), sizeof(_CFFileStreamContext), 0);
+    if (!newCtxt) return NULL;
+    newCtxt->url = ctxt->url;
+    if (newCtxt->url) {
+        CFRetain(newCtxt->url);
+    }
+    newCtxt->fd = ctxt->fd;
+#ifdef REAL_FILE_SCHEDULING
+    newCtxt->rlInfo.sock = NULL;
+#else
+    newCtxt->scheduled = 0;
+#endif
+    newCtxt->flags = 0;
+    newCtxt->offset = -1;
+    return newCtxt;
+}
+
+static void	fileFinalize(struct _CFStream *stream, void *info) {
+    _CFFileStreamContext *ctxt = (_CFFileStreamContext *)info;
+    if (ctxt->fd > 0) {
+#ifdef REAL_FILE_SCHEDULING
+        if (ctxt->rlInfo.sock) {
+            CFSocketInvalidate(ctxt->rlInfo.sock); 
+            CFRelease(ctxt->rlInfo.sock);
+        }
+#endif
+        close(ctxt->fd);
+#ifdef REAL_FILE_SCHEDULING
+    } else if (ctxt->rlInfo.rlArray) {
+        CFRelease(ctxt->rlInfo.rlArray);
+#endif
+    }
+    if (ctxt->url) {
+        CFRelease(ctxt->url);
+    }
+    CFAllocatorDeallocate(CFGetAllocator(stream), ctxt);
+}
+
+static CFStringRef fileCopyDescription(struct _CFStream *stream, void *info) {
+    // This needs work
+    _CFFileStreamContext *ctxt = (_CFFileStreamContext *)info;
+    if (ctxt->url) {
+        return CFCopyDescription(ctxt->url);
+    } else {
+        return CFStringCreateWithFormat(CFGetAllocator(stream), NULL, CFSTR("fd = %d"), ctxt->fd);
+    }
+}
+
+/* CFData stream callbacks */
+typedef struct {
+    CFDataRef data; // Mutable if the stream was constructed writable
+    const UInt8 *loc; // Current location in the file
+    Boolean scheduled;
+    char _padding[3];
+} _CFReadDataStreamContext;
+
+#define BUF_SIZE 1024
+typedef struct _CFStreamByteBuffer {
+    UInt8 *bytes;
+    CFIndex capacity, length;
+    struct _CFStreamByteBuffer *next;
+} _CFStreamByteBuffer;
+
+typedef struct {
+    _CFStreamByteBuffer *firstBuf, *currentBuf;
+    CFAllocatorRef bufferAllocator;
+    Boolean scheduled;
+    char _padding[3];
+} _CFWriteDataStreamContext;
+
+static Boolean readDataOpen(struct _CFStream *stream, CFStreamError *errorCode, Boolean *openComplete, void *info) {
+    _CFReadDataStreamContext *dataStream = (_CFReadDataStreamContext *)info;
+    if (dataStream->scheduled) {
+        if (CFDataGetLength(dataStream->data) != 0) {
+            CFReadStreamSignalEvent((CFReadStreamRef)stream, kCFStreamEventHasBytesAvailable, NULL);
+        } else {
+            CFReadStreamSignalEvent((CFReadStreamRef)stream, kCFStreamEventEndEncountered, NULL);
+        }
+    }
+    errorCode->error = 0;
+    *openComplete = TRUE;
+    return TRUE;
+}
+
+static void readDataSchedule(struct _CFStream *stream, CFRunLoopRef rl, CFStringRef rlMode, void *info) {
+    _CFReadDataStreamContext *dataStream = (_CFReadDataStreamContext *)info;
+    if (dataStream->scheduled == FALSE) {
+        dataStream->scheduled = TRUE;
+		if (CFReadStreamGetStatus((CFReadStreamRef)stream) != kCFStreamStatusOpen)
+			return;
+        if (CFDataGetBytePtr(dataStream->data) + CFDataGetLength(dataStream->data) > dataStream->loc) {
+            CFReadStreamSignalEvent((CFReadStreamRef)stream, kCFStreamEventHasBytesAvailable, NULL);
+        } else {
+            CFReadStreamSignalEvent((CFReadStreamRef)stream, kCFStreamEventEndEncountered, NULL);
+        }
+    }
+}
+
+static CFIndex dataRead(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info) {
+    _CFReadDataStreamContext *dataCtxt = (_CFReadDataStreamContext *)info;
+    const UInt8 *bytePtr = CFDataGetBytePtr(dataCtxt->data);
+    CFIndex length = CFDataGetLength(dataCtxt->data);
+    CFIndex bytesToCopy = bytePtr + length - dataCtxt->loc;
+    if (bytesToCopy > bufferLength) {
+        bytesToCopy = bufferLength;
+    }
+    if (bytesToCopy < 0) {
+        bytesToCopy = 0;
+    }
+    if (bytesToCopy != 0) {
+        memmove(buffer, dataCtxt->loc, bytesToCopy);
+        dataCtxt->loc += bytesToCopy;
+    }
+    error->error = 0;
+    *atEOF = (dataCtxt->loc < bytePtr + length) ? FALSE : TRUE;
+    if (dataCtxt->scheduled && !*atEOF) {
+        CFReadStreamSignalEvent(stream, kCFStreamEventHasBytesAvailable, NULL);
+    }
+    return bytesToCopy;
+}
+
+static const UInt8 *dataGetBuffer(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info) {
+    _CFReadDataStreamContext *dataCtxt = (_CFReadDataStreamContext *)info;
+    const UInt8 *bytes = CFDataGetBytePtr(dataCtxt->data);
+    if (dataCtxt->loc - bytes > maxBytesToRead) {
+        *numBytesRead = maxBytesToRead;
+        *atEOF = FALSE;
+    } else {
+        *numBytesRead = dataCtxt->loc - bytes;
+        *atEOF = TRUE;
+    }
+    error->error = 0;
+    bytes = dataCtxt->loc;
+    dataCtxt->loc += *numBytesRead;
+    if (dataCtxt->scheduled && !*atEOF) {
+        CFReadStreamSignalEvent(stream, kCFStreamEventHasBytesAvailable, NULL);
+    }
+    return bytes;
+}
+
+static Boolean dataCanRead(CFReadStreamRef stream, void *info) {
+    _CFReadDataStreamContext *dataCtxt = (_CFReadDataStreamContext *)info;
+    return (CFDataGetBytePtr(dataCtxt->data) + CFDataGetLength(dataCtxt->data) > dataCtxt->loc) ? TRUE : FALSE;
+}
+
+static Boolean writeDataOpen(struct _CFStream *stream, CFStreamError *errorCode, Boolean *openComplete, void *info) {
+    _CFWriteDataStreamContext *dataStream = (_CFWriteDataStreamContext *)info;
+    if (dataStream->scheduled) {
+        if (dataStream->bufferAllocator != kCFAllocatorNull || dataStream->currentBuf->capacity > dataStream->currentBuf->length) {
+            CFWriteStreamSignalEvent((CFWriteStreamRef)stream, kCFStreamEventCanAcceptBytes, NULL);
+        } else {
+            CFWriteStreamSignalEvent((CFWriteStreamRef)stream, kCFStreamEventEndEncountered, NULL);
+        }
+    }
+    errorCode->error = 0;
+    *openComplete = TRUE;
+    return TRUE;
+}
+
+static void writeDataSchedule(struct _CFStream *stream, CFRunLoopRef rl, CFStringRef rlMode, void *info) {
+    _CFWriteDataStreamContext *dataStream = (_CFWriteDataStreamContext *)info;
+    if (dataStream->scheduled == FALSE) {
+        dataStream->scheduled = TRUE;
+		if (CFWriteStreamGetStatus((CFWriteStreamRef)stream) != kCFStreamStatusOpen)
+			return;
+        if (dataStream->bufferAllocator != kCFAllocatorNull || dataStream->currentBuf->capacity > dataStream->currentBuf->length) {
+            CFWriteStreamSignalEvent((CFWriteStreamRef)stream, kCFStreamEventCanAcceptBytes, NULL);
+        } else {
+            CFWriteStreamSignalEvent((CFWriteStreamRef)stream, kCFStreamEventEndEncountered, NULL);
+        }
+    }
+}
+
+static CFIndex dataWrite(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *errorCode, void *info) {
+    _CFWriteDataStreamContext *dataStream = (_CFWriteDataStreamContext *)info;
+    CFIndex result;
+    CFIndex freeSpace = dataStream->currentBuf->capacity - dataStream->currentBuf->length;
+    if (dataStream->bufferAllocator == kCFAllocatorNull && bufferLength > freeSpace) {
+        errorCode->error = ENOMEM;
+        errorCode->domain = kCFStreamErrorDomainPOSIX;
+        return -1;
+    } else {
+        result = bufferLength;
+        while (bufferLength > 0) {
+            CFIndex amountToCopy = (bufferLength > freeSpace) ? freeSpace : bufferLength;
+            if (freeSpace > 0) {
+                memmove(dataStream->currentBuf->bytes + dataStream->currentBuf->length, buffer, amountToCopy);
+                buffer += amountToCopy;
+                bufferLength -= amountToCopy;
+                dataStream->currentBuf->length += amountToCopy;
+            }
+            if (bufferLength > 0) {
+                CFIndex bufSize = BUF_SIZE > bufferLength ? BUF_SIZE : bufferLength;
+                _CFStreamByteBuffer *newBuf = (_CFStreamByteBuffer *)CFAllocatorAllocate(dataStream->bufferAllocator, sizeof(_CFStreamByteBuffer) + bufSize, 0);
+                newBuf->bytes = (UInt8 *)(newBuf + 1);
+                newBuf->capacity = bufSize;
+                newBuf->length = 0;
+                newBuf->next = NULL;
+                dataStream->currentBuf->next = newBuf;
+                dataStream->currentBuf = newBuf;
+                freeSpace = bufSize;
+            }
+        }
+        errorCode->error = 0;
+    }
+    if (dataStream->scheduled && (dataStream->bufferAllocator != kCFAllocatorNull || dataStream->currentBuf->capacity > dataStream->currentBuf->length)) {
+        CFWriteStreamSignalEvent(stream, kCFStreamEventCanAcceptBytes, NULL);
+    }
+    return result;
+}
+
+static  Boolean dataCanWrite(CFWriteStreamRef stream, void *info) {
+    _CFWriteDataStreamContext *dataStream = (_CFWriteDataStreamContext *)info;
+    if (dataStream->bufferAllocator != kCFAllocatorNull) return TRUE;
+    if (dataStream->currentBuf->capacity  > dataStream->currentBuf->length) return TRUE;
+    return FALSE;
+}
+
+static CFPropertyListRef dataCopyProperty(struct _CFStream *stream, CFStringRef propertyName, void *info) {
+    _CFWriteDataStreamContext *dataStream = (_CFWriteDataStreamContext *)info;
+    CFIndex size = 0;
+    _CFStreamByteBuffer *buf;
+    CFAllocatorRef alloc;
+    UInt8 *bytes, *currByte;
+    if (!CFEqual(propertyName, kCFStreamPropertyDataWritten)) return NULL;
+    if (dataStream->bufferAllocator == kCFAllocatorNull)  return NULL;
+    alloc = dataStream->bufferAllocator;
+    for (buf = dataStream->firstBuf; buf != NULL; buf = buf->next) {
+        size += buf->length;
+    }
+    if (size == 0) return NULL;
+    bytes = (UInt8 *)CFAllocatorAllocate(alloc, size, 0);
+    currByte = bytes;
+    for (buf = dataStream->firstBuf; buf != NULL; buf = buf->next) {
+        memmove(currByte, buf->bytes, buf->length);
+        currByte += buf->length;
+    }
+    return CFDataCreateWithBytesNoCopy(alloc, bytes, size, alloc);
+}
+
+static void *readDataCreate(struct _CFStream *stream, void *info) {
+    _CFReadDataStreamContext *ctxt = (_CFReadDataStreamContext *)info;
+    _CFReadDataStreamContext *newCtxt = (_CFReadDataStreamContext *)CFAllocatorAllocate(CFGetAllocator(stream), sizeof(_CFReadDataStreamContext), 0);
+    if (!newCtxt) return NULL;
+    newCtxt->data = (CFDataRef)CFRetain(ctxt->data);
+    newCtxt->loc = CFDataGetBytePtr(newCtxt->data);
+    newCtxt->scheduled = FALSE;
+    return (void *)newCtxt;
+}
+
+static void readDataFinalize(struct _CFStream *stream, void *info) {
+    _CFReadDataStreamContext *ctxt = (_CFReadDataStreamContext *)info;
+    CFRelease(ctxt->data);
+    CFAllocatorDeallocate(CFGetAllocator(stream), ctxt);
+}
+
+static CFStringRef readDataCopyDescription(struct _CFStream *stream, void *info) {
+    return CFCopyDescription(((_CFReadDataStreamContext *)info)->data);
+}
+
+static void *writeDataCreate(struct _CFStream *stream, void *info) {
+    _CFWriteDataStreamContext *ctxt = (_CFWriteDataStreamContext *)info;
+    _CFWriteDataStreamContext *newCtxt;
+    if (ctxt->bufferAllocator != kCFAllocatorNull) {
+        if (ctxt->bufferAllocator == NULL) ctxt->bufferAllocator = CFAllocatorGetDefault();
+        CFRetain(ctxt->bufferAllocator);
+        newCtxt = (_CFWriteDataStreamContext *)CFAllocatorAllocate(CFGetAllocator(stream), sizeof(_CFWriteDataStreamContext) + sizeof(_CFStreamByteBuffer) + BUF_SIZE, 0);
+        newCtxt->firstBuf = (_CFStreamByteBuffer *)(newCtxt + 1);
+        newCtxt->firstBuf->bytes = (UInt8 *)(newCtxt->firstBuf + 1);
+        newCtxt->firstBuf->capacity = BUF_SIZE;
+        newCtxt->firstBuf->length = 0;
+        newCtxt->firstBuf->next = NULL;
+        newCtxt->currentBuf = newCtxt->firstBuf;
+        newCtxt->bufferAllocator = ctxt->bufferAllocator;
+        newCtxt->scheduled = FALSE;
+    } else {
+        newCtxt = (_CFWriteDataStreamContext *)CFAllocatorAllocate(CFGetAllocator(stream), sizeof(_CFWriteDataStreamContext) + sizeof(_CFStreamByteBuffer), 0);
+        newCtxt->firstBuf = (_CFStreamByteBuffer *)(newCtxt+1);
+        newCtxt->firstBuf->bytes = ctxt->firstBuf->bytes;
+        newCtxt->firstBuf->capacity = ctxt->firstBuf->capacity;
+        newCtxt->firstBuf->length = 0;
+        newCtxt->firstBuf->next = NULL;
+        newCtxt->currentBuf = newCtxt->firstBuf;
+        newCtxt->bufferAllocator = kCFAllocatorNull;
+        newCtxt->scheduled = FALSE;
+    }
+    return (void *)newCtxt;
+}
+
+static void writeDataFinalize(struct _CFStream *stream, void *info) {
+    _CFWriteDataStreamContext *ctxt = (_CFWriteDataStreamContext *)info;
+    if (ctxt->bufferAllocator != kCFAllocatorNull) {
+        _CFStreamByteBuffer *buf = ctxt->firstBuf->next, *next;
+        while (buf != NULL) {
+            next = buf->next;
+            CFAllocatorDeallocate(ctxt->bufferAllocator, buf);
+            buf = next;
+        }
+        CFRelease(ctxt->bufferAllocator);
+    }
+    CFAllocatorDeallocate(CFGetAllocator(stream), ctxt);
+}
+
+static CFStringRef writeDataCopyDescription(struct _CFStream *stream, void *info) {
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFWriteDataContext %p>"), info);
+}
+
+static const struct _CFStreamCallBacksV1 fileCallBacks = {1, fileCreate, fileFinalize, fileCopyDescription, fileOpen, NULL, fileRead, NULL, fileCanRead, fileWrite, fileCanWrite, fileClose, fileCopyProperty, fileSetProperty, NULL, fileSchedule, fileUnschedule};
+
+static struct _CFStream *_CFStreamCreateWithFile(CFAllocatorRef alloc, CFURLRef fileURL, Boolean forReading) {
+    _CFFileStreamContext fileContext;
+    CFStringRef scheme = fileURL ? CFURLCopyScheme(fileURL) : NULL;
+    if (!scheme || !CFEqual(scheme, CFSTR("file"))) {
+        if (scheme) CFRelease(scheme);
+        return NULL;
+    }
+    CFRelease(scheme);
+    fileContext.url = fileURL;
+    fileContext.fd = -1;
+    return _CFStreamCreateWithConstantCallbacks(alloc, &fileContext, (struct _CFStreamCallBacks *)(&fileCallBacks), forReading);
+}
+
+CF_EXPORT CFReadStreamRef CFReadStreamCreateWithFile(CFAllocatorRef alloc, CFURLRef fileURL) {
+    return (CFReadStreamRef)_CFStreamCreateWithFile(alloc, fileURL, TRUE);
+}
+
+CF_EXPORT CFWriteStreamRef CFWriteStreamCreateWithFile(CFAllocatorRef alloc, CFURLRef fileURL) {
+    return (CFWriteStreamRef)_CFStreamCreateWithFile(alloc, fileURL, FALSE);
+}
+
+CFReadStreamRef _CFReadStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd) {
+    _CFFileStreamContext fileContext;
+    fileContext.url = NULL;
+    fileContext.fd = fd;
+    return (CFReadStreamRef)_CFStreamCreateWithConstantCallbacks(alloc, &fileContext, (struct _CFStreamCallBacks *)(&fileCallBacks), TRUE);
+}
+
+CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd) {
+    _CFFileStreamContext fileContext;
+    fileContext.url = NULL;
+    fileContext.fd = fd;
+    return (CFWriteStreamRef)_CFStreamCreateWithConstantCallbacks(alloc, &fileContext, (struct _CFStreamCallBacks *)(&fileCallBacks), FALSE);
+}
+
+
+
+static const struct _CFStreamCallBacksV1 readDataCallBacks = {1, readDataCreate, readDataFinalize, readDataCopyDescription, readDataOpen, NULL, dataRead, dataGetBuffer, dataCanRead, NULL, NULL, NULL, NULL, NULL, NULL, readDataSchedule, NULL};
+static const struct _CFStreamCallBacksV1 writeDataCallBacks = {1, writeDataCreate, writeDataFinalize, writeDataCopyDescription, writeDataOpen, NULL, NULL, NULL, NULL, dataWrite, dataCanWrite, NULL, dataCopyProperty, NULL, NULL, writeDataSchedule, NULL};
+
+CF_EXPORT CFReadStreamRef CFReadStreamCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator) {
+    _CFReadDataStreamContext ctxt;
+    CFReadStreamRef result;
+    ctxt.data = CFDataCreateWithBytesNoCopy(alloc, bytes, length, bytesDeallocator);
+    result = (CFReadStreamRef)_CFStreamCreateWithConstantCallbacks(alloc, &ctxt, (struct _CFStreamCallBacks *)(&readDataCallBacks), TRUE);
+    CFRelease(ctxt.data);
+    return result;
+}
+
+/* This needs to be exported to make it callable from Foundation. */
+CF_EXPORT CFReadStreamRef CFReadStreamCreateWithData(CFAllocatorRef alloc, CFDataRef data) {
+    _CFReadDataStreamContext ctxt;
+    CFReadStreamRef result = NULL;
+    
+    ctxt.data = (CFDataRef)CFRetain(data);
+    result = (CFReadStreamRef)_CFStreamCreateWithConstantCallbacks(alloc, &ctxt, (struct _CFStreamCallBacks *)(&readDataCallBacks), TRUE);
+    CFRelease(data);
+    return result;
+}
+
+CFWriteStreamRef CFWriteStreamCreateWithBuffer(CFAllocatorRef alloc, UInt8 *buffer, CFIndex bufferCapacity) {
+    _CFStreamByteBuffer buf;
+    _CFWriteDataStreamContext ctxt;
+    buf.bytes = buffer;
+    buf.capacity = bufferCapacity;
+    buf.length = 0;
+    buf.next = NULL;
+    ctxt.firstBuf = &buf;
+    ctxt.currentBuf = ctxt.firstBuf;
+    ctxt.bufferAllocator = kCFAllocatorNull;
+    return (CFWriteStreamRef)_CFStreamCreateWithConstantCallbacks(alloc, &ctxt, (struct _CFStreamCallBacks *)(&writeDataCallBacks), FALSE);
+}
+
+CF_EXPORT CFWriteStreamRef CFWriteStreamCreateWithAllocatedBuffers(CFAllocatorRef alloc, CFAllocatorRef bufferAllocator) {
+    _CFWriteDataStreamContext ctxt;
+    ctxt.firstBuf = NULL;
+    ctxt.currentBuf = NULL;
+    ctxt.bufferAllocator = bufferAllocator;
+    return (CFWriteStreamRef)_CFStreamCreateWithConstantCallbacks(alloc, &ctxt, (struct _CFStreamCallBacks *)(&writeDataCallBacks), FALSE);
+}
+
+#undef BUF_SIZE
+
diff --git a/CoreFoundation/CFData.c b/CoreFoundation/CFData.c
new file mode 100644
index 0000000..d74655f
--- /dev/null
+++ b/CoreFoundation/CFData.c
@@ -0,0 +1,426 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFData.h>
+#include "CFPriv.h"
+#include "CFInternal.h"
+#include <string.h>
+
+struct __CFData {
+    CFRuntimeBase _base;
+    CFIndex _length;	/* number of bytes */
+    CFIndex _capacity;	/* maximum number of bytes */
+    CFAllocatorRef _bytesDeallocator;	/* used only for immutable; if NULL, no deallocation */
+    uint8_t *_bytes;
+};
+
+/* Bits 3-2 are used for mutability variation */
+
+CF_INLINE UInt32 __CFMutableVariety(const void *cf) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 2);
+}
+
+CF_INLINE void __CFSetMutableVariety(void *cf, UInt32 v) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 2, v);
+}
+
+CF_INLINE UInt32 __CFMutableVarietyFromFlags(UInt32 flags) {
+    return __CFBitfieldGetValue(flags, 1, 0);
+}
+
+#define __CFGenericValidateMutabilityFlags(flags) \
+    CFAssert2(__CFMutableVarietyFromFlags(flags) != 0x2, __kCFLogAssertion, "%s(): flags 0x%x do not correctly specify the mutable variety", __PRETTY_FUNCTION__, flags);
+
+CF_INLINE CFIndex __CFDataLength(CFDataRef data) {
+    return data->_length;
+}
+
+CF_INLINE void __CFDataSetLength(CFMutableDataRef data, CFIndex v) {
+    /* for a CFData, _bytesUsed == _length */
+}
+
+CF_INLINE CFIndex __CFDataCapacity(CFDataRef data) {
+    return data->_capacity;
+}
+
+CF_INLINE void __CFDataSetCapacity(CFMutableDataRef data, CFIndex v) {
+    /* for a CFData, _bytesNum == _capacity */
+}
+
+CF_INLINE CFIndex __CFDataNumBytesUsed(CFDataRef data) {
+    return data->_length;
+}
+
+CF_INLINE void __CFDataSetNumBytesUsed(CFMutableDataRef data, CFIndex v) {
+    data->_length = v;
+}
+
+CF_INLINE CFIndex __CFDataNumBytes(CFDataRef data) {
+    return data->_capacity;
+}
+
+CF_INLINE void __CFDataSetNumBytes(CFMutableDataRef data, CFIndex v) {
+    data->_capacity = v;
+}
+
+CF_INLINE CFIndex __CFDataRoundUpCapacity(CFIndex capacity) {
+    if (capacity < 16) return 16;
+// CF: quite probably, this doubling should slow as the data gets larger and larger; should not use strict doubling
+    return (1 << flsl(capacity));
+}
+
+CF_INLINE CFIndex __CFDataNumBytesForCapacity(CFIndex capacity) {
+    return capacity;
+}
+
+static void __CFDataHandleOutOfMemory(CFTypeRef obj, CFIndex numBytes) {
+    CFStringRef msg = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("Attempt to allocate %ld bytes for NS/CFData failed"), numBytes);
+    CFBadErrorCallBack cb = _CFGetOutOfMemoryErrorCallBack();
+    if (NULL == cb || !cb(obj, CFSTR("NS/CFData"), msg)) {
+        CFLog(kCFLogLevelCritical, CFSTR("%@"), msg);
+        HALT;
+    }
+    CFRelease(msg);
+}
+
+#if defined(DEBUG)
+CF_INLINE void __CFDataValidateRange(CFDataRef data, CFRange range, const char *func) {
+    CFAssert2(0 <= range.location && range.location <= __CFDataLength(data), __kCFLogAssertion, "%s(): range.location index (%d) out of bounds", func, range.location);
+    CFAssert2(0 <= range.length, __kCFLogAssertion, "%s(): length (%d) cannot be less than zero", func, range.length);
+    CFAssert2(range.location + range.length <= __CFDataLength(data), __kCFLogAssertion, "%s(): ending index (%d) out of bounds", func, range.location + range.length);
+}
+#else
+#define __CFDataValidateRange(a,r,f)
+#endif
+
+static Boolean __CFDataEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFDataRef data1 = (CFDataRef)cf1;
+    CFDataRef data2 = (CFDataRef)cf2;
+    CFIndex length;
+    length = __CFDataLength(data1);
+    if (length != __CFDataLength(data2)) return false;
+    return 0 == memcmp(data1->_bytes, data2->_bytes, length);
+}
+
+static CFHashCode __CFDataHash(CFTypeRef cf) {
+    CFDataRef data = (CFDataRef)cf;
+    return CFHashBytes(data->_bytes, __CFMin(__CFDataLength(data), 80));
+}
+
+static CFStringRef __CFDataCopyDescription(CFTypeRef cf) {
+    CFDataRef data = (CFDataRef)cf;
+    CFMutableStringRef result;
+    CFIndex idx;
+    CFIndex len;
+    const uint8_t *bytes;
+    len = __CFDataLength(data);
+    bytes = data->_bytes;
+    result = CFStringCreateMutable(CFGetAllocator(data), 0);
+    CFStringAppendFormat(result, NULL, CFSTR("<CFData %p [%p]>{length = %u, capacity = %u, bytes = 0x"), cf, CFGetAllocator(data), len, __CFDataCapacity(data));
+    if (24 < len) {
+        for (idx = 0; idx < 16; idx += 4) {
+	    CFStringAppendFormat(result, NULL, CFSTR("%02x%02x%02x%02x"), bytes[idx], bytes[idx + 1], bytes[idx + 2], bytes[idx + 3]);
+	}
+        CFStringAppend(result, CFSTR(" ... "));
+        for (idx = len - 8; idx < len; idx += 4) {
+	    CFStringAppendFormat(result, NULL, CFSTR("%02x%02x%02x%02x"), bytes[idx], bytes[idx + 1], bytes[idx + 2], bytes[idx + 3]);
+	}
+    } else {
+        for (idx = 0; idx < len; idx++) {
+	    CFStringAppendFormat(result, NULL, CFSTR("%02x"), bytes[idx]);
+	}
+    }
+    CFStringAppend(result, CFSTR("}"));
+    return result;
+}
+
+enum {
+    kCFImmutable = 0x0,		/* unchangable and fixed capacity; default */
+    kCFMutable = 0x1,		/* changeable and variable capacity */
+    kCFFixedMutable = 0x3	/* changeable and fixed capacity */
+};
+
+static void __CFDataDeallocate(CFTypeRef cf) {
+    CFMutableDataRef data = (CFMutableDataRef)cf;
+    CFAllocatorRef allocator = __CFGetAllocator(data);
+    switch (__CFMutableVariety(data)) {
+    case kCFMutable:
+	_CFAllocatorDeallocateGC(allocator, data->_bytes);
+	data->_bytes = NULL;
+	break;
+    case kCFFixedMutable:
+	break;
+    case kCFImmutable:
+	if (NULL != data->_bytesDeallocator) {
+	    if (CF_IS_COLLECTABLE_ALLOCATOR(data->_bytesDeallocator)) {
+		// GC:  for finalization safety, let collector reclaim the buffer in the next GC cycle.
+		auto_zone_release(__CFCollectableZone, data->_bytes);
+            } else {
+		CFAllocatorDeallocate(data->_bytesDeallocator, data->_bytes);
+		CFRelease(data->_bytesDeallocator);
+		data->_bytes = NULL;
+	    }
+	}
+	break;
+    }
+}
+
+static CFTypeID __kCFDataTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFDataClass = {
+    0,
+    "CFData",
+    NULL,	// init
+    NULL,	// copy
+    __CFDataDeallocate,
+    __CFDataEqual,
+    __CFDataHash,
+    NULL,	// 
+    __CFDataCopyDescription
+};
+
+__private_extern__ void __CFDataInitialize(void) {
+    __kCFDataTypeID = _CFRuntimeRegisterClass(&__CFDataClass);
+}
+
+CFTypeID CFDataGetTypeID(void) {
+    return __kCFDataTypeID;
+}
+
+// NULL bytesDeallocator to this function does not mean the default allocator, it means
+// that there should be no deallocator, and the bytes should be copied.
+static CFMutableDataRef __CFDataInit(CFAllocatorRef allocator, CFOptionFlags flags, CFIndex capacity, const uint8_t *bytes, CFIndex length, CFAllocatorRef bytesDeallocator) {
+    CFMutableDataRef memory;
+    CFIndex size;
+    __CFGenericValidateMutabilityFlags(flags);
+    CFAssert2(0 <= capacity, __kCFLogAssertion, "%s(): capacity (%d) cannot be less than zero", __PRETTY_FUNCTION__, capacity);
+    CFAssert3(kCFFixedMutable != __CFMutableVarietyFromFlags(flags) || length <= capacity, __kCFLogAssertion, "%s(): for kCFFixedMutable type, capacity (%d) must be greater than or equal to number of initial elements (%d)", __PRETTY_FUNCTION__, capacity, length);
+    CFAssert2(0 <= length, __kCFLogAssertion, "%s(): length (%d) cannot be less than zero", __PRETTY_FUNCTION__, length);
+    size = sizeof(struct __CFData) - sizeof(CFRuntimeBase);
+    if (__CFMutableVarietyFromFlags(flags) != kCFMutable && (bytesDeallocator == NULL)) {
+	size += sizeof(uint8_t) * __CFDataNumBytesForCapacity(capacity);
+    }
+    if (__CFMutableVarietyFromFlags(flags) != kCFMutable) {
+	size += sizeof(uint8_t) * 15;	// for 16-byte alignment fixup
+    }
+    memory = (CFMutableDataRef)_CFRuntimeCreateInstance(allocator, __kCFDataTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    __CFDataSetNumBytesUsed(memory, 0);
+    __CFDataSetLength(memory, 0);
+    switch (__CFMutableVarietyFromFlags(flags)) {
+    case kCFMutable:
+	__CFDataSetCapacity(memory, __CFDataRoundUpCapacity(1));
+	__CFDataSetNumBytes(memory, __CFDataNumBytesForCapacity(__CFDataRoundUpCapacity(1)));
+	// GC: if allocated in the collectable zone, mark the object as needing to be scanned.
+	if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) auto_zone_set_layout_type(__CFCollectableZone, memory, AUTO_MEMORY_SCANNED);
+	// assume that allocators give 16-byte aligned memory back -- it is their responsibility
+	CF_WRITE_BARRIER_BASE_ASSIGN(allocator, memory, memory->_bytes, _CFAllocatorAllocateGC(allocator, __CFDataNumBytes(memory) * sizeof(uint8_t), 0));
+	if (__CFOASafe) __CFSetLastAllocationEventName(memory->_bytes, "CFData (store)");
+	if (NULL == memory->_bytes) {
+	    CFRelease(memory);
+	    return NULL;
+	}
+	memory->_bytesDeallocator = NULL;
+	__CFSetMutableVariety(memory, kCFMutable);
+	CFDataReplaceBytes(memory, CFRangeMake(0, 0), bytes, length);
+	break;
+    case kCFFixedMutable:
+	/* Don't round up capacity */
+	__CFDataSetCapacity(memory, capacity);
+	__CFDataSetNumBytes(memory, __CFDataNumBytesForCapacity(capacity));
+	memory->_bytes = (uint8_t *)((uintptr_t)((int8_t *)memory + sizeof(struct __CFData) + 15) & ~0xF);	// 16-byte align
+	memory->_bytesDeallocator = NULL;
+	__CFSetMutableVariety(memory, kCFFixedMutable);
+	CFDataReplaceBytes(memory, CFRangeMake(0, 0), bytes, length);
+	break;
+    case kCFImmutable:
+	/* Don't round up capacity */
+	__CFDataSetCapacity(memory, capacity);
+	__CFDataSetNumBytes(memory, __CFDataNumBytesForCapacity(capacity));
+	if (bytesDeallocator != NULL) {
+            CF_WRITE_BARRIER_BASE_ASSIGN(allocator, memory, memory->_bytes, (uint8_t *)bytes);
+	    memory->_bytesDeallocator = (CFAllocatorRef)CFRetain(bytesDeallocator);
+	    __CFDataSetNumBytesUsed(memory, length);
+	    __CFDataSetLength(memory, length);
+	} else {
+	    memory->_bytes = (uint8_t *)((uintptr_t)((int8_t *)memory + sizeof(struct __CFData) + 15) & ~0xF);	// 16-byte align
+	    memory->_bytesDeallocator = NULL;
+	    __CFSetMutableVariety(memory, kCFFixedMutable);
+	    CFDataReplaceBytes(memory, CFRangeMake(0, 0), bytes, length);
+	}
+	break;
+    }
+    __CFSetMutableVariety(memory, __CFMutableVarietyFromFlags(flags));
+    return memory;
+}
+
+CFDataRef CFDataCreate(CFAllocatorRef allocator, const uint8_t *bytes, CFIndex length) {
+    return __CFDataInit(allocator, kCFImmutable, length, bytes, length, NULL);
+}
+
+CFDataRef CFDataCreateWithBytesNoCopy(CFAllocatorRef allocator, const uint8_t *bytes, CFIndex length, CFAllocatorRef bytesDeallocator) {
+    CFAssert1((0 == length || bytes != NULL), __kCFLogAssertion, "%s(): bytes pointer cannot be NULL if length is non-zero", __PRETTY_FUNCTION__);
+    if (NULL == bytesDeallocator) bytesDeallocator = __CFGetDefaultAllocator();
+    return __CFDataInit(allocator, kCFImmutable, length, bytes, length, bytesDeallocator);
+}
+
+CFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef data) {
+    CFIndex length = CFDataGetLength(data);
+    return __CFDataInit(allocator, kCFImmutable, length, CFDataGetBytePtr(data), length, NULL);
+}
+
+CFMutableDataRef CFDataCreateMutable(CFAllocatorRef allocator, CFIndex capacity) {
+    return __CFDataInit(allocator, (0 == capacity) ? kCFMutable : kCFFixedMutable, capacity, NULL, 0, NULL);
+}
+
+CFMutableDataRef CFDataCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDataRef data) {
+    return __CFDataInit(allocator, (0 == capacity) ? kCFMutable : kCFFixedMutable, capacity, CFDataGetBytePtr(data), CFDataGetLength(data), NULL);
+}
+
+CFIndex CFDataGetLength(CFDataRef data) {
+    CF_OBJC_FUNCDISPATCH0(__kCFDataTypeID, CFIndex, data, "length");
+    __CFGenericValidateType(data, __kCFDataTypeID);
+    return __CFDataLength(data);
+}
+
+const uint8_t *CFDataGetBytePtr(CFDataRef data) {
+    CF_OBJC_FUNCDISPATCH0(__kCFDataTypeID, const uint8_t *, data, "bytes");
+    __CFGenericValidateType(data, __kCFDataTypeID);
+    return data->_bytes;
+}
+
+uint8_t *CFDataGetMutableBytePtr(CFMutableDataRef data) {
+    CF_OBJC_FUNCDISPATCH0(__kCFDataTypeID, uint8_t *, data, "mutableBytes");
+    CFAssert1(__CFMutableVariety(data) == kCFMutable || __CFMutableVariety(data) == kCFFixedMutable, __kCFLogAssertion, "%s(): data is immutable", __PRETTY_FUNCTION__);
+    return data->_bytes;
+}
+
+void CFDataGetBytes(CFDataRef data, CFRange range, uint8_t *buffer) {
+    CF_OBJC_FUNCDISPATCH2(__kCFDataTypeID, void, data, "getBytes:range:", buffer, range);
+    memmove(buffer, data->_bytes + range.location, range.length);
+}
+
+static void __CFDataGrow(CFMutableDataRef data, CFIndex numNewValues) {
+    CFIndex oldLength = __CFDataLength(data);
+    CFIndex capacity = __CFDataRoundUpCapacity(oldLength + numNewValues);
+    CFAllocatorRef allocator = CFGetAllocator(data);
+    __CFDataSetCapacity(data, capacity);
+    __CFDataSetNumBytes(data, __CFDataNumBytesForCapacity(capacity));
+    void *bytes = _CFAllocatorReallocateGC(allocator, data->_bytes, __CFDataNumBytes(data) * sizeof(uint8_t), 0);
+    if (NULL == bytes) __CFDataHandleOutOfMemory(data, __CFDataNumBytes(data) * sizeof(uint8_t));
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, data, data->_bytes, bytes);
+    if (__CFOASafe) __CFSetLastAllocationEventName(data->_bytes, "CFData (store)");
+}
+
+void CFDataSetLength(CFMutableDataRef data, CFIndex length) {
+    CFIndex len;
+    CF_OBJC_FUNCDISPATCH1(__kCFDataTypeID, void, data, "setLength:", length);
+    CFAssert1(__CFMutableVariety(data) == kCFMutable || __CFMutableVariety(data) == kCFFixedMutable, __kCFLogAssertion, "%s(): data is immutable", __PRETTY_FUNCTION__);
+    len = __CFDataLength(data);
+    switch (__CFMutableVariety(data)) {
+    case kCFMutable:
+	if (len < length) {
+// CF: should only grow when new length exceeds current capacity, not whenever it exceeds the current length
+	    __CFDataGrow(data, length - len);
+	}
+	break;
+    case kCFFixedMutable:
+	CFAssert1(length <= __CFDataCapacity(data), __kCFLogAssertion, "%s(): fixed-capacity data is full", __PRETTY_FUNCTION__);
+	break;
+    }
+    if (len < length) {
+	memset(data->_bytes + len, 0, length - len);
+    }
+    __CFDataSetLength(data, length);
+    __CFDataSetNumBytesUsed(data, length);
+}
+
+void CFDataIncreaseLength(CFMutableDataRef data, CFIndex extraLength) {
+    CF_OBJC_FUNCDISPATCH1(__kCFDataTypeID, void, data, "increaseLengthBy:", extraLength);
+    CFAssert1(__CFMutableVariety(data) == kCFMutable || __CFMutableVariety(data) == kCFFixedMutable, __kCFLogAssertion, "%s(): data is immutable", __PRETTY_FUNCTION__);
+    CFDataSetLength(data, __CFDataLength(data) + extraLength);
+}
+
+void CFDataAppendBytes(CFMutableDataRef data, const uint8_t *bytes, CFIndex length) {
+    CF_OBJC_FUNCDISPATCH2(__kCFDataTypeID, void, data, "appendBytes:length:", bytes, length);
+    CFAssert1(__CFMutableVariety(data) == kCFMutable || __CFMutableVariety(data) == kCFFixedMutable, __kCFLogAssertion, "%s(): data is immutable", __PRETTY_FUNCTION__);
+    CFDataReplaceBytes(data, CFRangeMake(__CFDataLength(data), 0), bytes, length); 
+}
+
+void CFDataDeleteBytes(CFMutableDataRef data, CFRange range) {
+    CF_OBJC_FUNCDISPATCH3(__kCFDataTypeID, void, data, "replaceBytesInRange:withBytes:length:", range, NULL, 0);
+    CFAssert1(__CFMutableVariety(data) == kCFMutable || __CFMutableVariety(data) == kCFFixedMutable, __kCFLogAssertion, "%s(): data is immutable", __PRETTY_FUNCTION__);
+    CFDataReplaceBytes(data, range, NULL, 0); 
+}
+
+void CFDataReplaceBytes(CFMutableDataRef data, CFRange range, const uint8_t *newBytes, CFIndex newLength) {
+    CF_OBJC_FUNCDISPATCH3(__kCFDataTypeID, void, data, "replaceBytesInRange:withBytes:length:", range, newBytes, newLength);
+    __CFGenericValidateType(data, __kCFDataTypeID);
+    __CFDataValidateRange(data, range, __PRETTY_FUNCTION__);
+    CFAssert1(__CFMutableVariety(data) == kCFMutable || __CFMutableVariety(data) == kCFFixedMutable, __kCFLogAssertion, "%s(): data is immutable", __PRETTY_FUNCTION__);
+    CFAssert2(0 <= newLength, __kCFLogAssertion, "%s(): newLength (%d) cannot be less than zero", __PRETTY_FUNCTION__, newLength);
+
+    CFIndex len = __CFDataLength(data);
+    if (len < 0 || range.length < 0 || newLength < 0) HALT;
+    CFIndex newCount = len - range.length + newLength;
+    if (newCount < 0) HALT;
+
+    switch (__CFMutableVariety(data)) {
+    case kCFMutable:
+	if (__CFDataNumBytes(data) < newCount) {
+	    __CFDataGrow(data, newLength - range.length);
+	}
+	break;
+    case kCFFixedMutable:
+	CFAssert1(newCount <= __CFDataCapacity(data), __kCFLogAssertion, "%s(): fixed-capacity data is full", __PRETTY_FUNCTION__);
+	break;
+    }
+    if (newLength != range.length && range.location + range.length < len) {
+        memmove(data->_bytes + range.location + newLength, data->_bytes + range.location + range.length, (len - range.location - range.length) * sizeof(uint8_t));
+    }
+    if (0 < newLength) {
+        memmove(data->_bytes + range.location, newBytes, newLength * sizeof(uint8_t));
+    }
+    __CFDataSetNumBytesUsed(data, newCount);
+    __CFDataSetLength(data, newCount);
+}
+
+#undef __CFDataValidateRange
+#undef __CFGenericValidateMutabilityFlags
+
diff --git a/CoreFoundation/CFData.h b/CoreFoundation/CFData.h
new file mode 100644
index 0000000..379af56
--- /dev/null
+++ b/CoreFoundation/CFData.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFDATA__)
+#define __COREFOUNDATION_CFDATA__ 1
+
+#include <CoreFoundation/CFBase.h>
+
+CF_EXTERN_C_BEGIN
+    
+typedef const struct __CFData * CFDataRef;
+typedef struct __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);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFDATA__ */
+
diff --git a/CoreFoundation/CFDate.c b/CoreFoundation/CFDate.c
new file mode 100644
index 0000000..0ce697b
--- /dev/null
+++ b/CoreFoundation/CFDate.c
@@ -0,0 +1,538 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFTimeZone.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFNumber.h>
+#include "CFInternal.h"
+#include <math.h>
+#if DEPLOYMENT_TARGET_LINUX
+#include <time.h>
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+#include <sys/time.h>
+#endif
+
+#if defined(_MSC_VER)
+extern void gettimeofday(struct timeval *tv, void *dummy);
+#endif
+
+const CFTimeInterval kCFAbsoluteTimeIntervalSince1970 = 978307200.0L;
+const CFTimeInterval kCFAbsoluteTimeIntervalSince1904 = 3061152000.0L;
+
+/* cjk: The Julian Date for the reference date is 2451910.5,
+        I think, in case that's ever useful. */
+
+__private_extern__ double __CFTSRRate = 0.0;
+static double __CF1_TSRRate = 0.0;
+
+#if DEPLOYMENT_TARGET_WINDOWS
+// We should export this as SPI or API to clients - 3514284
+CFAbsoluteTime _CFAbsoluteTimeFromFileTime(const FILETIME *ft) {
+    CFAbsoluteTime ret = (CFTimeInterval)ft->dwHighDateTime * 429.49672960;
+    ret += (CFTimeInterval)ft->dwLowDateTime / 10000000.0;
+    ret -= (11644473600.0 + kCFAbsoluteTimeIntervalSince1970);
+    /* seconds between 1601 and 1970, 1970 and 2001 */
+    return ret;
+}
+#endif
+
+__private_extern__ int64_t __CFTimeIntervalToTSR(CFTimeInterval ti) {
+    if ((ti * __CFTSRRate) > INT64_MAX / 2) return (INT64_MAX / 2);
+    return (int64_t)(ti * __CFTSRRate);
+}
+
+__private_extern__ CFTimeInterval __CFTSRToTimeInterval(int64_t tsr) {
+    return (CFTimeInterval)((double)tsr * __CF1_TSRRate);
+}
+
+#ifdef DEPLOYMENT_TARGET_WINDOWS
+__private_extern__ CFAbsoluteTime __CFDateWindowsSystemTimeToAbsoluteTime(SYSTEMTIME *the_time) {
+   // this song and dance seems to be required to get enough precision
+   // and date offset that the OSX version returns - steps were culled
+   // from the remarks section of RtlTimeToSecondsSince1970 in the
+   // msdn documentation
+
+   SYSTEMTIME darwin_epoch;
+   FILETIME also_the_time, also_epoch;
+   ULARGE_INTEGER also_also_the_time, also_also_epoch;
+
+   memset(&darwin_epoch, 0, sizeof(SYSTEMTIME));
+   SystemTimeToFileTime(the_time, &also_the_time);
+
+   // MSDN says casting a pointer from FILETIME to ULARGE_INTEGER* or __int64* can cause alignment faults on WIN64
+   also_also_the_time.LowPart = also_the_time.dwLowDateTime;
+   also_also_the_time.HighPart = also_the_time.dwHighDateTime;
+
+   darwin_epoch.wYear = 2001;
+   darwin_epoch.wMonth = 1;
+   darwin_epoch.wDay = 1;
+   SystemTimeToFileTime(&darwin_epoch, &also_epoch);
+   also_also_epoch.LowPart = also_epoch.dwLowDateTime;
+   also_also_epoch.HighPart = also_epoch.dwHighDateTime;
+
+   return((double)(also_also_the_time.QuadPart - also_also_epoch.QuadPart) / 10000000.0);
+}
+#endif // DEPLOYMENT_TARGET_WINDOWS
+
+CFAbsoluteTime CFAbsoluteTimeGetCurrent(void) {
+    CFAbsoluteTime ret;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    ret = (CFTimeInterval)tv.tv_sec - kCFAbsoluteTimeIntervalSince1970;
+    ret += (1.0E-6 * (CFTimeInterval)tv.tv_usec);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    FILETIME ft;
+    GetSystemTimeAsFileTime(&ft);
+    ret = _CFAbsoluteTimeFromFileTime(&ft);
+#else
+#error CFAbsoluteTimeGetCurrent unimplemented for this platform
+#endif
+   return ret;
+}
+
+__private_extern__ void __CFDateInitialize(void) {
+#if DEPLOYMENT_TARGET_MACOSX
+    struct mach_timebase_info info;
+    mach_timebase_info(&info);
+    __CFTSRRate = (1.0E9 / (double)info.numer) * (double)info.denom;
+#elif DEPLOYMENT_TARGET_WINDOWS
+    LARGE_INTEGER freq;
+    if (!QueryPerformanceFrequency(&freq)) {
+        HALT;
+    }
+    __CFTSRRate = (double)freq.QuadPart;
+#elif DEPLOYMENT_TARGET_LINUX
+	// On Linux, __CFReadTSR (see ForFoundation.h) is implemented on
+	// the POSIX RT clock_* APIs which work at nanosecond granularity
+	// (though not necessarily nanosecond resolution). Simply set the
+	// TSRRate to 1 ns.
+	__CFTSRRate = 1.0E9;
+#else
+#warning "__CFTSRRate not initialized for this platform!"
+#endif
+	__CF1_TSRRate = 1.0 / __CFTSRRate;
+    CFDateGetTypeID(); // cause side-effects
+}
+
+#if 1
+struct __CFDate {
+    CFRuntimeBase _base;
+    CFAbsoluteTime _time;       /* immutable */
+};
+
+static Boolean __CFDateEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFDateRef date1 = (CFDateRef)cf1;
+    CFDateRef date2 = (CFDateRef)cf2;
+    if (date1->_time != date2->_time) return false;
+    return true;
+}
+
+static CFHashCode __CFDateHash(CFTypeRef cf) {
+    CFDateRef date = (CFDateRef)cf;
+    return (CFHashCode)(float)floor(date->_time);
+}
+
+static CFStringRef __CFDateCopyDescription(CFTypeRef cf) {
+    CFDateRef date = (CFDateRef)cf;
+    return CFStringCreateWithFormat(CFGetAllocator(date), NULL, CFSTR("<CFDate %p [%p]>{time = %0.09g}"), cf, CFGetAllocator(date), date->_time);
+}
+
+static CFTypeID __kCFDateTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFDateClass = {
+    0,
+    "CFDate",
+    NULL,       // init
+    NULL,       // copy
+    NULL,       // dealloc
+    __CFDateEqual,
+    __CFDateHash,
+    NULL,       //
+    __CFDateCopyDescription
+};
+
+CFTypeID CFDateGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFDateTypeID) __kCFDateTypeID = _CFRuntimeRegisterClass(&__CFDateClass);
+    return __kCFDateTypeID;
+}
+
+CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at) {
+    CFDateRef memory; 
+    uint32_t size;
+    size = sizeof(struct __CFDate) - sizeof(CFRuntimeBase);
+    memory = (CFDateRef)_CFRuntimeCreateInstance(allocator, CFDateGetTypeID(), size, NULL);
+    if (NULL == memory) {
+        return NULL;
+    }
+    ((struct __CFDate *)memory)->_time = at;
+    return memory;
+}
+
+CFTimeInterval CFDateGetAbsoluteTime(CFDateRef date) {
+    CF_OBJC_FUNCDISPATCH0(CFDateGetTypeID(), CFTimeInterval, date, "timeIntervalSinceReferenceDate");
+    __CFGenericValidateType(date, CFDateGetTypeID());
+    return date->_time;
+}
+
+CFTimeInterval CFDateGetTimeIntervalSinceDate(CFDateRef date, CFDateRef otherDate) {
+    CF_OBJC_FUNCDISPATCH1(CFDateGetTypeID(), CFTimeInterval, date, "timeIntervalSinceDate:", otherDate);
+    __CFGenericValidateType(date, CFDateGetTypeID());
+    __CFGenericValidateType(otherDate, CFDateGetTypeID());
+    return date->_time - otherDate->_time;
+}   
+    
+CFComparisonResult CFDateCompare(CFDateRef date, CFDateRef otherDate, void *context) {
+    CF_OBJC_FUNCDISPATCH1(CFDateGetTypeID(), CFComparisonResult, date, "compare:", otherDate);
+    __CFGenericValidateType(date, CFDateGetTypeID());
+    __CFGenericValidateType(otherDate, CFDateGetTypeID());
+    if (date->_time < otherDate->_time) return kCFCompareLessThan;
+    if (date->_time > otherDate->_time) return kCFCompareGreaterThan;
+    return kCFCompareEqualTo;
+}
+#endif
+
+CF_INLINE int32_t __CFDoubleModToInt(double d, int32_t modulus) {
+    int32_t result = (int32_t)(float)floor(d - floor(d / modulus) * modulus);
+    if (result < 0) result += modulus;
+    return result;
+}
+
+CF_INLINE double __CFDoubleMod(double d, int32_t modulus) {
+    double result = d - floor(d / modulus) * modulus;
+    if (result < 0.0) result += (double)modulus;
+    return result;
+}
+
+static const uint8_t daysInMonth[16] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0, 0, 0};
+static const uint16_t daysBeforeMonth[16] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 0, 0};
+static const uint16_t daysAfterMonth[16] = {365, 334, 306, 275, 245, 214, 184, 153, 122, 92, 61, 31, 0, 0, 0, 0};
+
+CF_INLINE bool isleap(int64_t year) {
+    int64_t y = (year + 1) % 400;	/* correct to nearest multiple-of-400 year, then find the remainder */
+    if (y < 0) y = -y;
+    return (0 == (y & 3) && 100 != y && 200 != y && 300 != y);
+}
+
+/* year arg is absolute year; Gregorian 2001 == year 0; 2001/1/1 = absolute date 0 */
+CF_INLINE uint8_t __CFDaysInMonth(int8_t month, int64_t year, bool leap) {
+    return daysInMonth[month] + (2 == month && leap);
+}
+
+/* year arg is absolute year; Gregorian 2001 == year 0; 2001/1/1 = absolute date 0 */
+CF_INLINE uint16_t __CFDaysBeforeMonth(int8_t month, int64_t year, bool leap) {
+    return daysBeforeMonth[month] + (2 < month && leap);
+}
+
+/* year arg is absolute year; Gregorian 2001 == year 0; 2001/1/1 = absolute date 0 */
+CF_INLINE uint16_t __CFDaysAfterMonth(int8_t month, int64_t year, bool leap) {
+    return daysAfterMonth[month] + (month < 2 && leap);
+}
+
+/* year arg is absolute year; Gregorian 2001 == year 0; 2001/1/1 = absolute date 0 */
+static void __CFYMDFromAbsolute(int64_t absolute, int64_t *year, int8_t *month, int8_t *day) {
+    int64_t b = absolute / 146097; // take care of as many multiples of 400 years as possible
+    int64_t y = b * 400;
+    uint16_t ydays;
+    absolute -= b * 146097;
+    while (absolute < 0) {
+	y -= 1;
+	absolute += __CFDaysAfterMonth(0, y, isleap(y));
+    }
+    /* Now absolute is non-negative days to add to year */
+    ydays = __CFDaysAfterMonth(0, y, isleap(y));
+    while (ydays <= absolute) {
+	y += 1;
+	absolute -= ydays;
+	ydays = __CFDaysAfterMonth(0, y, isleap(y));
+    }
+    /* Now we have year and days-into-year */
+    if (year) *year = y;
+    if (month || day) {
+	int8_t m = absolute / 33 + 1; /* search from the approximation */
+	bool leap = isleap(y);
+	while (__CFDaysBeforeMonth(m + 1, y, leap) <= absolute) m++;
+	if (month) *month = m;
+	if (day) *day = absolute - __CFDaysBeforeMonth(m, y, leap) + 1;
+    }
+}
+
+/* year arg is absolute year; Gregorian 2001 == year 0; 2001/1/1 = absolute date 0 */
+static double __CFAbsoluteFromYMD(int64_t year, int8_t month, int8_t day) {
+    double absolute = 0.0;
+    int64_t idx;
+    int64_t b = year / 400; // take care of as many multiples of 400 years as possible
+    absolute += b * 146097.0;
+    year -= b * 400;
+    if (year < 0) {
+	for (idx = year; idx < 0; idx++)
+	    absolute -= __CFDaysAfterMonth(0, idx, isleap(idx));
+    } else {
+	for (idx = 0; idx < year; idx++)
+	    absolute += __CFDaysAfterMonth(0, idx, isleap(idx));
+    }
+    /* Now add the days into the original year */
+    absolute += __CFDaysBeforeMonth(month, year, isleap(year)) + day - 1;
+    return absolute;
+}
+
+Boolean CFGregorianDateIsValid(CFGregorianDate gdate, CFOptionFlags unitFlags) {
+    if ((unitFlags & kCFGregorianUnitsYears) && (gdate.year <= 0)) return false;
+    if ((unitFlags & kCFGregorianUnitsMonths) && (gdate.month < 1 || 12 < gdate.month)) return false;
+    if ((unitFlags & kCFGregorianUnitsDays) && (gdate.day < 1 || 31 < gdate.day)) return false;
+    if ((unitFlags & kCFGregorianUnitsHours) && (gdate.hour < 0 || 23 < gdate.hour)) return false;
+    if ((unitFlags & kCFGregorianUnitsMinutes) && (gdate.minute < 0 || 59 < gdate.minute)) return false;
+    if ((unitFlags & kCFGregorianUnitsSeconds) && (gdate.second < 0.0 || 60.0 <= gdate.second)) return false;
+    if ((unitFlags & kCFGregorianUnitsDays) && (unitFlags & kCFGregorianUnitsMonths) && (unitFlags & kCFGregorianUnitsYears) && (__CFDaysInMonth(gdate.month, gdate.year - 2001, isleap(gdate.year - 2001)) < gdate.day)) return false;
+    return true;
+}
+
+CFAbsoluteTime CFGregorianDateGetAbsoluteTime(CFGregorianDate gdate, CFTimeZoneRef tz) {
+    CFAbsoluteTime at;
+    CFTimeInterval offset0, offset1;
+    if (NULL != tz) {
+	__CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    }
+    at = 86400.0 * __CFAbsoluteFromYMD(gdate.year - 2001, gdate.month, gdate.day);
+    at += 3600.0 * gdate.hour + 60.0 * gdate.minute + gdate.second;
+    if (NULL != tz) {
+	offset0 = CFTimeZoneGetSecondsFromGMT(tz, at);
+	offset1 = CFTimeZoneGetSecondsFromGMT(tz, at - offset0);
+	at -= offset1;
+    }
+    return at;
+}
+
+CFGregorianDate CFAbsoluteTimeGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz) {
+    CFGregorianDate gdate;
+    int64_t absolute, year;
+    int8_t month, day;
+    CFAbsoluteTime fixedat;
+    if (NULL != tz) {
+	__CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    }
+    fixedat = at + (NULL != tz ? CFTimeZoneGetSecondsFromGMT(tz, at) : 0.0);
+    absolute = (int64_t)floor(fixedat / 86400.0);
+    __CFYMDFromAbsolute(absolute, &year, &month, &day);
+    if (INT32_MAX - 2001 < year) year = INT32_MAX - 2001;
+    gdate.year = year + 2001;
+    gdate.month = month;
+    gdate.day = day;
+    gdate.hour = __CFDoubleModToInt(floor(fixedat / 3600.0), 24);
+    gdate.minute = __CFDoubleModToInt(floor(fixedat / 60.0), 60);
+    gdate.second = __CFDoubleMod(fixedat, 60);
+    if (0.0 == gdate.second) gdate.second = 0.0;	// stomp out possible -0.0
+    return gdate;
+}
+
+/* Note that the units of years and months are not equal length, but are treated as such. */
+CFAbsoluteTime CFAbsoluteTimeAddGregorianUnits(CFAbsoluteTime at, CFTimeZoneRef tz, CFGregorianUnits units) {
+    CFGregorianDate gdate;
+    CFGregorianUnits working;
+    CFAbsoluteTime candidate_at0, candidate_at1;
+    uint8_t monthdays;
+
+    if (NULL != tz) {
+	__CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    }
+
+    /* Most people seem to expect years, then months, then days, etc.
+	to be added in that order.  Thus, 27 April + (4 days, 1 month)
+	= 31 May, and not 1 June. This is also relatively predictable.
+
+	On another issue, months not being equal length, people also
+	seem to expect late day-of-month clamping (don't clamp as you
+	go through months), but clamp before adding in the days. Late
+	clamping is also more predictable given random starting points
+	and random numbers of months added (ie Jan 31 + 2 months could
+	be March 28 or March 29 in different years with aggressive
+	clamping). Proportionality (28 Feb + 1 month = 31 March) is
+	also not expected.
+
+	Also, people don't expect time zone transitions to have any
+	effect when adding years and/or months and/or days, only.
+	Hours, minutes, and seconds, though, are added in as humans
+	would experience the passing of that time. What this means
+	is that if the date, after adding years, months, and days
+	lands on some date, and then adding hours, minutes, and
+	seconds crosses a time zone transition, the time zone
+	transition is accounted for. If adding years, months, and
+	days gets the date into a different time zone offset period,
+	that transition is not taken into account.
+    */
+    gdate = CFAbsoluteTimeGetGregorianDate(at, tz);
+    /* We must work in a CFGregorianUnits, because the fields in the CFGregorianDate can easily overflow */
+    working.years = gdate.year;
+    working.months = gdate.month;
+    working.days = gdate.day;
+    working.years += units.years;
+    working.months += units.months;
+    while (12 < working.months) {
+	working.months -= 12;
+	working.years += 1;
+    }
+    while (working.months < 1) {
+	working.months += 12;
+	working.years -= 1;
+    }
+    monthdays = __CFDaysInMonth(working.months, working.years - 2001, isleap(working.years - 2001));
+    if (monthdays < working.days) {	/* Clamp day to new month */
+	working.days = monthdays;
+    }
+    working.days += units.days;
+    while (monthdays < working.days) {
+	working.months += 1;
+	if (12 < working.months) {
+	    working.months -= 12;
+	    working.years += 1;
+	}
+	working.days -= monthdays;
+	monthdays = __CFDaysInMonth(working.months, working.years - 2001, isleap(working.years - 2001));
+    }
+    while (working.days < 1) {
+	working.months -= 1;
+	if (working.months < 1) {
+	    working.months += 12;
+	    working.years -= 1;
+	}
+	monthdays = __CFDaysInMonth(working.months, working.years - 2001, isleap(working.years - 2001));
+	working.days += monthdays;
+    }
+    gdate.year = working.years;
+    gdate.month = working.months;
+    gdate.day = working.days;
+    /* Roll in hours, minutes, and seconds */
+    candidate_at0 = CFGregorianDateGetAbsoluteTime(gdate, tz);
+    candidate_at1 = candidate_at0 + 3600.0 * units.hours + 60.0 * units.minutes + units.seconds;
+    /* If summing in the hours, minutes, and seconds delta pushes us
+     * into a new time zone offset, that will automatically be taken
+     * care of by the fact that we just add the raw time above. To
+     * undo that effect, we'd have to get the time zone offsets for
+     * candidate_at0 and candidate_at1 here, and subtract the
+     * difference (offset1 - offset0) from candidate_at1. */
+    return candidate_at1;
+}
+
+/* at1 - at2.  The only constraint here is that this needs to be the inverse
+of CFAbsoluteTimeByAddingGregorianUnits(), but that's a very rigid constraint.
+Unfortunately, due to the nonuniformity of the year and month units, this
+inversion essentially has to approximate until it finds the answer. */
+CFGregorianUnits CFAbsoluteTimeGetDifferenceAsGregorianUnits(CFAbsoluteTime at1, CFAbsoluteTime at2, CFTimeZoneRef tz, CFOptionFlags unitFlags) {
+    const int32_t seconds[5] = {366 * 24 * 3600, 31 * 24 * 3600, 24 * 3600, 3600, 60};
+    CFGregorianUnits units = {0, 0, 0, 0, 0, 0.0};
+    CFAbsoluteTime atold, atnew = at2;
+    int32_t idx, incr;
+    incr = (at2 < at1) ? 1 : -1;
+    /* Successive approximation: years, then months, then days, then hours, then minutes. */
+    for (idx = 0; idx < 5; idx++) {
+	if (unitFlags & (1 << idx)) {
+	    ((int32_t *)&units)[idx] = -3 * incr + (int32_t)((at1 - atnew) / seconds[idx]);
+	    do {
+		atold = atnew;
+		((int32_t *)&units)[idx] += incr;
+		atnew = CFAbsoluteTimeAddGregorianUnits(at2, tz, units);
+	    } while ((1 == incr && atnew <= at1) || (-1 == incr && at1 <= atnew));
+	    ((int32_t *)&units)[idx] -= incr;
+	    atnew = atold;
+	}
+    }
+    if (unitFlags & kCFGregorianUnitsSeconds) {
+	units.seconds = at1 - atnew;
+    }
+    if (0.0 == units.seconds) units.seconds = 0.0;	// stomp out possible -0.0
+    return units;
+}
+
+SInt32 CFAbsoluteTimeGetDayOfWeek(CFAbsoluteTime at, CFTimeZoneRef tz) {
+    int64_t absolute;
+    CFAbsoluteTime fixedat;
+    if (NULL != tz) {
+	__CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    }
+    fixedat = at + (NULL != tz ? CFTimeZoneGetSecondsFromGMT(tz, at) : 0.0);
+    absolute = (int64_t)floor(fixedat / 86400.0);
+    return (absolute < 0) ? ((absolute + 1) % 7 + 7) : (absolute % 7 + 1); /* Monday = 1, etc. */
+}
+
+SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) {
+    CFAbsoluteTime fixedat;
+    int64_t absolute, year;
+    int8_t month, day;
+    if (NULL != tz) {
+	__CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    }
+    fixedat = at + (NULL != tz ? CFTimeZoneGetSecondsFromGMT(tz, at) : 0.0);
+    absolute = (int64_t)floor(fixedat / 86400.0);
+    __CFYMDFromAbsolute(absolute, &year, &month, &day);
+    return __CFDaysBeforeMonth(month, year, isleap(year)) + day;
+}
+
+/* "the first week of a year is the one which includes the first Thursday" (ISO 8601) */
+SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) {
+    int64_t absolute, year;
+    int8_t month, day;
+    CFAbsoluteTime fixedat;
+    if (NULL != tz) {
+	__CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    }
+    fixedat = at + (NULL != tz ? CFTimeZoneGetSecondsFromGMT(tz, at) : 0.0);
+    absolute = (int64_t)floor(fixedat / 86400.0);
+    __CFYMDFromAbsolute(absolute, &year, &month, &day);
+    double absolute0101 = __CFAbsoluteFromYMD(year, 1, 1);
+    int64_t dow0101 = __CFDoubleModToInt(absolute0101, 7) + 1;
+    /* First three and last three days of a year can end up in a week of a different year */
+    if (1 == month && day < 4) {
+	if ((day < 4 && 5 == dow0101) || (day < 3 && 6 == dow0101) || (day < 2 && 7 == dow0101)) {
+	    return 53;
+	}
+    }
+    if (12 == month && 28 < day) {
+	double absolute20101 = __CFAbsoluteFromYMD(year + 1, 1, 1);
+	int64_t dow20101 = __CFDoubleModToInt(absolute20101, 7) + 1;
+	if ((28 < day && 4 == dow20101) || (29 < day && 3 == dow20101) || (30 < day && 2 == dow20101)) {
+	    return 1;
+	}
+    }
+    /* Days into year, plus a week-shifting correction, divided by 7. First week is 1. */
+    return (__CFDaysBeforeMonth(month, year, isleap(year)) + day + (dow0101 - 11) % 7 + 2) / 7 + 1;
+}
+
+
diff --git a/CoreFoundation/CFDate.h b/CoreFoundation/CFDate.h
new file mode 100644
index 0000000..9503e58
--- /dev/null
+++ b/CoreFoundation/CFDate.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFDATE__)
+#define __COREFOUNDATION_CFDATE__ 1
+
+#include <CoreFoundation/CFBase.h>
+
+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 __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);
+
+typedef const struct __CFTimeZone * CFTimeZoneRef;
+
+typedef struct _CFGregorianDate {
+    SInt32 year;
+    SInt8 month;
+    SInt8 day;
+    SInt8 hour;
+    SInt8 minute;
+    double second;
+} CFGregorianDate;
+
+typedef struct {
+    SInt32 years;
+    SInt32 months;
+    SInt32 days;
+    SInt32 hours;
+    SInt32 minutes;
+    double seconds;
+} CFGregorianUnits;
+
+enum {
+    kCFGregorianUnitsYears = (1 << 0),
+    kCFGregorianUnitsMonths = (1 << 1),
+    kCFGregorianUnitsDays = (1 << 2),
+    kCFGregorianUnitsHours = (1 << 3),
+    kCFGregorianUnitsMinutes = (1 << 4),
+    kCFGregorianUnitsSeconds = (1 << 5),
+#if 0
+    kCFGregorianUnitsTimeZone = (1 << 8),
+    kCFGregorianUnitsDayOfWeek = (1 << 9),
+#endif
+    kCFGregorianAllUnits = 0x00FFFFFF
+};
+typedef CFOptionFlags CFGregorianUnitFlags;
+
+CF_EXPORT
+Boolean CFGregorianDateIsValid(CFGregorianDate gdate, CFOptionFlags unitFlags);
+
+CF_EXPORT
+CFAbsoluteTime CFGregorianDateGetAbsoluteTime(CFGregorianDate gdate, CFTimeZoneRef tz);
+
+CF_EXPORT
+CFGregorianDate CFAbsoluteTimeGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz);
+
+CF_EXPORT
+CFAbsoluteTime CFAbsoluteTimeAddGregorianUnits(CFAbsoluteTime at, CFTimeZoneRef tz, CFGregorianUnits units);
+
+CF_EXPORT
+CFGregorianUnits CFAbsoluteTimeGetDifferenceAsGregorianUnits(CFAbsoluteTime at1, CFAbsoluteTime at2, CFTimeZoneRef tz, CFOptionFlags unitFlags);
+
+CF_EXPORT
+SInt32 CFAbsoluteTimeGetDayOfWeek(CFAbsoluteTime at, CFTimeZoneRef tz);
+
+CF_EXPORT
+SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz);
+
+CF_EXPORT
+SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFDATE__ */
+
diff --git a/CoreFoundation/CFDateFormatter.c b/CoreFoundation/CFDateFormatter.c
new file mode 100644
index 0000000..64871de
--- /dev/null
+++ b/CoreFoundation/CFDateFormatter.c
@@ -0,0 +1,802 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 2002-2003, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFDateFormatter.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFTimeZone.h>
+#include <CoreFoundation/CFCalendar.h>
+#include <CoreFoundation/CFNumber.h>
+#include "CFInternal.h"
+#include <unicode/udat.h>
+#include <math.h>
+#include <float.h>
+
+extern UCalendar *__CFCalendarCreateUCalendar(CFStringRef calendarID, CFStringRef localeID, CFTimeZoneRef tz);
+#ifdef DEPLOYMENT_TARGET_WINDOWS
+extern CFAbsoluteTime __CFDateWindowsSystemTimeToAbsoluteTime(SYSTEMTIME *time);
+#endif
+static void __CFDateFormatterCustomize(CFDateFormatterRef formatter);
+
+CF_EXPORT const CFStringRef kCFDateFormatterCalendarIdentifier;
+
+#define BUFFER_SIZE 768
+
+struct __CFDateFormatter {
+    CFRuntimeBase _base;
+    UDateFormat *_df;
+    CFLocaleRef _locale;
+    CFDateFormatterStyle _timeStyle;
+    CFDateFormatterStyle _dateStyle;
+    CFStringRef _format;
+    CFStringRef _defformat;
+    CFStringRef _calendarName;
+    CFTimeZoneRef _tz;
+    CFDateRef _defaultDate;
+};
+
+static CFStringRef __CFDateFormatterCopyDescription(CFTypeRef cf) {
+    CFDateFormatterRef formatter = (CFDateFormatterRef)cf;
+    return CFStringCreateWithFormat(CFGetAllocator(formatter), NULL, CFSTR("<CFDateFormatter %p [%p]>"), cf, CFGetAllocator(formatter));
+}
+
+static void __CFDateFormatterDeallocate(CFTypeRef cf) {
+    CFDateFormatterRef formatter = (CFDateFormatterRef)cf;
+    if (formatter->_df) udat_close(formatter->_df);
+    if (formatter->_locale) CFRelease(formatter->_locale);
+    if (formatter->_format) CFRelease(formatter->_format);
+    if (formatter->_defformat) CFRelease(formatter->_defformat);
+    if (formatter->_calendarName) CFRelease(formatter->_calendarName);
+    if (formatter->_tz) CFRelease(formatter->_tz);
+    if (formatter->_defaultDate) CFRelease(formatter->_defaultDate);
+}
+
+static CFTypeID __kCFDateFormatterTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFDateFormatterClass = {
+    0,
+    "CFDateFormatter",
+    NULL,	// init
+    NULL,	// copy
+    __CFDateFormatterDeallocate,
+    NULL,
+    NULL,
+    NULL,	// 
+    __CFDateFormatterCopyDescription
+};
+
+static void __CFDateFormatterInitialize(void) {
+    __kCFDateFormatterTypeID = _CFRuntimeRegisterClass(&__CFDateFormatterClass);
+}
+
+CFTypeID CFDateFormatterGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFDateFormatterTypeID) __CFDateFormatterInitialize();
+    return __kCFDateFormatterTypeID;
+}
+
+CFDateFormatterRef CFDateFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFDateFormatterStyle dateStyle, CFDateFormatterStyle timeStyle) {
+    struct __CFDateFormatter *memory;
+    uint32_t size = sizeof(struct __CFDateFormatter) - sizeof(CFRuntimeBase);
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    if (locale) __CFGenericValidateType(locale, CFLocaleGetTypeID());
+    memory = (struct __CFDateFormatter *)_CFRuntimeCreateInstance(allocator, CFDateFormatterGetTypeID(), size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    memory->_df = NULL;
+    memory->_locale = NULL;
+    memory->_format = NULL;
+    memory->_defformat = NULL;
+    memory->_calendarName = NULL;
+    memory->_tz = NULL;
+    memory->_defaultDate = NULL;
+    if (NULL == locale) locale = CFLocaleGetSystem();
+    memory->_dateStyle = dateStyle;
+    memory->_timeStyle = timeStyle;
+    int32_t udstyle, utstyle;
+    switch (dateStyle) {
+    case kCFDateFormatterNoStyle: udstyle = UDAT_NONE; break;
+    case kCFDateFormatterShortStyle: udstyle = UDAT_SHORT; break;
+    case kCFDateFormatterMediumStyle: udstyle = UDAT_MEDIUM; break;
+    case kCFDateFormatterLongStyle: udstyle = UDAT_LONG; break;
+    case kCFDateFormatterFullStyle: udstyle = UDAT_FULL; break;
+    default:
+	CFAssert2(0, __kCFLogAssertion, "%s(): unknown date style %d", __PRETTY_FUNCTION__, dateStyle);
+	udstyle = UDAT_MEDIUM;
+	memory->_dateStyle = kCFDateFormatterMediumStyle;
+	break;
+    }
+    switch (timeStyle) {
+    case kCFDateFormatterNoStyle: utstyle = UDAT_NONE; break;
+    case kCFDateFormatterShortStyle: utstyle = UDAT_SHORT; break;
+    case kCFDateFormatterMediumStyle: utstyle = UDAT_MEDIUM; break;
+    case kCFDateFormatterLongStyle: utstyle = UDAT_LONG; break;
+    case kCFDateFormatterFullStyle: utstyle = UDAT_FULL; break;
+    default:
+	CFAssert2(0, __kCFLogAssertion, "%s(): unknown time style %d", __PRETTY_FUNCTION__, timeStyle);
+	utstyle = UDAT_MEDIUM;
+	memory->_timeStyle = kCFDateFormatterMediumStyle;
+	break;
+    }
+    CFStringRef localeName = locale ? CFLocaleGetIdentifier(locale) : CFSTR("");
+    char buffer[BUFFER_SIZE];
+    const char *cstr = CFStringGetCStringPtr(localeName, kCFStringEncodingASCII);
+    if (NULL == cstr) {
+        if (CFStringGetCString(localeName, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;
+    }
+    if (NULL == cstr) {
+        CFRelease(memory);
+        return NULL;
+    }
+    UChar ubuffer[BUFFER_SIZE];
+    memset(ubuffer, 0x00, sizeof(UChar) * BUFFER_SIZE);
+    memory->_tz = CFTimeZoneCopyDefault();
+#ifdef DEPLOYMENT_TARGET_WINDOWS
+    // ICU doesn't know about Windows Time Zone names.  It'll understand the abbreviation for the non-daylight saving time, though
+    TIME_ZONE_INFORMATION *tzi = (TIME_ZONE_INFORMATION *)CFDataGetBytePtr(CFTimeZoneGetData(memory->_tz));
+    CFAbsoluteTime at = __CFDateWindowsSystemTimeToAbsoluteTime(&tzi->DaylightDate);
+    // subtract a day to get us off the time change boundary
+    at -= (60 * 60 * 24);
+    CFStringRef tznam = CFTimeZoneCopyAbbreviation(memory->_tz, at);
+#else
+    CFStringRef tznam = CFTimeZoneGetName(memory->_tz);
+#endif
+    CFIndex cnt = CFStringGetLength(tznam);
+    if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+    CFStringGetCharacters(tznam, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+    UErrorCode status = U_ZERO_ERROR;
+    memory->_df = udat_open((UDateFormatStyle)utstyle, (UDateFormatStyle)udstyle, cstr, ubuffer, cnt, NULL, 0, &status);
+    CFAssert2(memory->_df, __kCFLogAssertion, "%s(): error (%d) creating date formatter", __PRETTY_FUNCTION__, status);
+    if (NULL == memory->_df) {
+	CFRelease(memory->_tz);
+	CFRelease(memory);
+	return NULL;
+    }
+    udat_setLenient(memory->_df, 0);
+    if (kCFDateFormatterNoStyle == dateStyle && kCFDateFormatterNoStyle == timeStyle) {
+	udat_applyPattern(memory->_df, false, NULL, 0);
+    }
+    CFTypeRef calident = CFLocaleGetValue(locale, kCFLocaleCalendarIdentifier);
+    if (calident && CFEqual(calident, kCFGregorianCalendar)) {
+	status = U_ZERO_ERROR;
+	udat_set2DigitYearStart(memory->_df, -631152000000.0, &status); // 1950-01-01 00:00:00 GMT
+    }
+    memory->_locale = locale ? CFLocaleCreateCopy(allocator, locale) : CFLocaleGetSystem();
+    __CFDateFormatterCustomize(memory);
+    status = U_ZERO_ERROR;
+    int32_t ret = udat_toPattern(memory->_df, false, ubuffer, BUFFER_SIZE, &status);
+    if (U_SUCCESS(status) && ret <= BUFFER_SIZE) {
+	memory->_format = CFStringCreateWithCharacters(allocator, (const UniChar *)ubuffer, ret);
+    }
+    memory->_defformat = memory->_format ? (CFStringRef)CFRetain(memory->_format) : NULL;
+    return (CFDateFormatterRef)memory;
+}
+
+extern CFDictionaryRef __CFLocaleGetPrefs(CFLocaleRef locale);
+
+static void __substituteFormatStringFromPrefsDF(CFDateFormatterRef formatter, bool doTime) {
+    CFIndex formatStyle = doTime ? formatter->_timeStyle : formatter->_dateStyle;
+    CFStringRef prefName = doTime ? CFSTR("AppleICUTimeFormatStrings") : CFSTR("AppleICUDateFormatStrings");
+    if (kCFDateFormatterNoStyle != formatStyle) {
+        CFStringRef pref = NULL;
+        CFDictionaryRef prefs = __CFLocaleGetPrefs(formatter->_locale);
+        CFPropertyListRef metapref = prefs ? CFDictionaryGetValue(prefs, prefName) : NULL;
+        if (NULL != metapref && CFGetTypeID(metapref) == CFDictionaryGetTypeID()) {
+            CFStringRef key;
+            switch (formatStyle) {
+                case kCFDateFormatterShortStyle: key = CFSTR("1"); break;
+                case kCFDateFormatterMediumStyle: key = CFSTR("2"); break;
+                case kCFDateFormatterLongStyle: key = CFSTR("3"); break;
+                case kCFDateFormatterFullStyle: key = CFSTR("4"); break;
+                default: key = CFSTR("0"); break;
+            }
+            pref = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)metapref, key);
+        }
+        if (NULL != pref && CFGetTypeID(pref) == CFStringGetTypeID()) {
+            int32_t icustyle = UDAT_NONE;
+            switch (formatStyle) {
+                case kCFDateFormatterShortStyle: icustyle = UDAT_SHORT; break;
+                case kCFDateFormatterMediumStyle: icustyle = UDAT_MEDIUM; break;
+                case kCFDateFormatterLongStyle: icustyle = UDAT_LONG; break;
+                case kCFDateFormatterFullStyle: icustyle = UDAT_FULL; break;
+            }
+            CFStringRef localeName = CFLocaleGetIdentifier(formatter->_locale);
+            char buffer[BUFFER_SIZE];
+            const char *cstr = CFStringGetCStringPtr(localeName, kCFStringEncodingASCII);
+            if (NULL == cstr) {
+                if (CFStringGetCString(localeName, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;
+            }
+            UErrorCode status = U_ZERO_ERROR;
+            UDateFormat *df = udat_open((UDateFormatStyle)(doTime ? icustyle : UDAT_NONE), (UDateFormatStyle)(doTime ? UDAT_NONE : icustyle), cstr, NULL, 0, NULL, 0, &status);
+            if (NULL != df) {
+                UChar ubuffer[BUFFER_SIZE];
+                status = U_ZERO_ERROR;
+                int32_t date_len = udat_toPattern(df, false, ubuffer, BUFFER_SIZE, &status);
+                if (U_SUCCESS(status) && date_len <= BUFFER_SIZE) {
+                    CFStringRef dateString = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (UniChar *)ubuffer, date_len);
+                    status = U_ZERO_ERROR;
+                    int32_t formatter_len = udat_toPattern(formatter->_df, false, ubuffer, BUFFER_SIZE, &status);
+                    if (U_SUCCESS(status) && formatter_len <= BUFFER_SIZE) {
+                        CFMutableStringRef formatString = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+                        CFStringAppendCharacters(formatString, (UniChar *)ubuffer, formatter_len);
+                        // find dateString inside formatString, substitute the pref in that range
+                        CFRange result;
+                        if (CFStringFindWithOptions(formatString, dateString, CFRangeMake(0, formatter_len), 0, &result)) {
+                            CFStringReplace(formatString, result, pref);
+                            int32_t new_len = CFStringGetLength(formatString);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+                            STACK_BUFFER_DECL(UChar, new_buffer, new_len);
+#else
+                            UChar new_buffer[BUFFER_SIZE]; // Dynamic stack allocation is GNU specific
+#endif
+                            const UChar *new_ustr = (UChar *)CFStringGetCharactersPtr(formatString);
+                            if (NULL == new_ustr) {
+                                CFStringGetCharacters(formatString, CFRangeMake(0, new_len), (UniChar *)new_buffer);
+                                new_ustr = new_buffer;
+                            }
+                            status = U_ZERO_ERROR;
+//	                         udat_applyPattern(formatter->_df, false, new_ustr, new_len, &status);
+                            udat_applyPattern(formatter->_df, false, new_ustr, new_len);
+                        }
+                        CFRelease(formatString);
+                    }
+                    CFRelease(dateString);
+                }
+                udat_close(df);
+            }
+        }
+    }
+}
+
+static void __CFDateFormatterApplySymbolPrefs(const void *key, const void *value, void *context) {
+    if (CFGetTypeID(key) == CFStringGetTypeID() && CFGetTypeID(value) == CFArrayGetTypeID()) {
+        CFDateFormatterRef formatter = (CFDateFormatterRef)context;
+        UDateFormatSymbolType sym = (UDateFormatSymbolType)CFStringGetIntValue((CFStringRef)key);
+        CFArrayRef array = (CFArrayRef)value;
+        CFIndex idx, cnt = CFArrayGetCount(array);
+        for (idx = 0; idx < cnt; idx++) {
+            CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(array, idx);
+            if (CFGetTypeID(item) != CFStringGetTypeID()) continue;
+            CFIndex item_cnt = CFStringGetLength(item);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+	         STACK_BUFFER_DECL(UChar, item_buffer, __CFMin(BUFFER_SIZE, item_cnt));
+#else
+            UChar item_buffer[BUFFER_SIZE]; // Dynamic stack allocation is GNU specific
+#endif
+            UChar *item_ustr = (UChar *)CFStringGetCharactersPtr(item);
+            if (NULL == item_ustr) {
+                item_cnt = __CFMin(BUFFER_SIZE, item_cnt);
+                CFStringGetCharacters(item, CFRangeMake(0, item_cnt), (UniChar *)item_buffer);
+                item_ustr = item_buffer;
+            }
+            UErrorCode status = U_ZERO_ERROR;
+            udat_setSymbols(formatter->_df, sym, idx, item_ustr, item_cnt, &status);
+        }
+    }
+}
+
+static void __CFDateFormatterCustomize(CFDateFormatterRef formatter) {
+    __substituteFormatStringFromPrefsDF(formatter, false);
+    __substituteFormatStringFromPrefsDF(formatter, true);
+    CFDictionaryRef prefs = __CFLocaleGetPrefs(formatter->_locale);
+    CFPropertyListRef metapref = prefs ? CFDictionaryGetValue(prefs, CFSTR("AppleICUDateTimeSymbols")) : NULL;
+    if (NULL != metapref && CFGetTypeID(metapref) == CFDictionaryGetTypeID()) {
+	CFDictionaryApplyFunction((CFDictionaryRef)metapref, __CFDateFormatterApplySymbolPrefs, formatter);
+    }
+}
+
+CFLocaleRef CFDateFormatterGetLocale(CFDateFormatterRef formatter) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    return formatter->_locale;
+}
+
+CFDateFormatterStyle CFDateFormatterGetDateStyle(CFDateFormatterRef formatter) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    return formatter->_dateStyle;
+}
+
+CFDateFormatterStyle CFDateFormatterGetTimeStyle(CFDateFormatterRef formatter) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    return formatter->_timeStyle;
+}
+
+CFStringRef CFDateFormatterGetFormat(CFDateFormatterRef formatter) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    return formatter->_format;
+}
+
+void CFDateFormatterSetFormat(CFDateFormatterRef formatter, CFStringRef formatString) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    __CFGenericValidateType(formatString, CFStringGetTypeID());
+    CFIndex cnt = CFStringGetLength(formatString);
+    CFAssert1(cnt <= 1024, __kCFLogAssertion, "%s(): format string too long", __PRETTY_FUNCTION__);
+    if (formatter->_format != formatString && cnt <= 1024) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+        STACK_BUFFER_DECL(UChar, ubuffer, cnt);
+#else
+        UChar ubuffer[BUFFER_SIZE]; // Dynamic stack allocation is GNU specific
+#endif
+        const UChar *ustr = (UChar *)CFStringGetCharactersPtr((CFStringRef)formatString);
+        if (NULL == ustr) {
+            CFStringGetCharacters(formatString, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+            ustr = ubuffer;
+        }
+        UErrorCode status = U_ZERO_ERROR;
+//	     udat_applyPattern(formatter->_df, false, ustr, cnt, &status);
+        udat_applyPattern(formatter->_df, false, ustr, cnt);
+        if (U_SUCCESS(status)) {
+            if (formatter->_format) CFRelease(formatter->_format);
+            formatter->_format = (CFStringRef)CFStringCreateCopy(CFGetAllocator(formatter), formatString);
+        }
+    }
+}
+
+CFStringRef CFDateFormatterCreateStringWithDate(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFDateRef date) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    __CFGenericValidateType(date, CFDateGetTypeID());
+    return CFDateFormatterCreateStringWithAbsoluteTime(allocator, formatter, CFDateGetAbsoluteTime(date));
+}
+
+CFStringRef CFDateFormatterCreateStringWithAbsoluteTime(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFAbsoluteTime at) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    UChar *ustr = NULL, ubuffer[BUFFER_SIZE];
+    UErrorCode status = U_ZERO_ERROR;
+    CFIndex used, cnt = BUFFER_SIZE;
+    UDate ud = (at + kCFAbsoluteTimeIntervalSince1970) * 1000.0 + 0.5;
+    used = udat_format(formatter->_df, ud, ubuffer, cnt, NULL, &status);
+    if (status == U_BUFFER_OVERFLOW_ERROR || cnt < used) {
+	cnt = used + 1;
+	ustr = (UChar *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(UChar) * cnt, 0);
+	status = U_ZERO_ERROR;
+	used = udat_format(formatter->_df, ud, ustr, cnt, NULL, &status);
+    }
+    CFStringRef string = NULL;
+    if (U_SUCCESS(status)) {
+	string = CFStringCreateWithCharacters(allocator, (const UniChar *)(ustr ? ustr : ubuffer), used);
+    }
+    if (ustr) CFAllocatorDeallocate(kCFAllocatorSystemDefault, ustr);
+    return string;
+}
+
+CFDateRef CFDateFormatterCreateDateFromString(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    __CFGenericValidateType(string, CFStringGetTypeID());
+    CFAbsoluteTime at;
+    if (CFDateFormatterGetAbsoluteTimeFromString(formatter, string, rangep, &at)) {
+	return CFDateCreate(allocator, at);
+    }
+    return NULL;
+}
+
+Boolean CFDateFormatterGetAbsoluteTimeFromString(CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep, CFAbsoluteTime *atp) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    __CFGenericValidateType(string, CFStringGetTypeID());
+    CFRange range = {0, 0};
+    if (rangep) {
+       range = *rangep;
+    } else {
+        range.length = CFStringGetLength(string);
+    }
+    if (1024 < range.length) range.length = 1024;
+    const UChar *ustr = (UChar *)CFStringGetCharactersPtr(string);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(UChar, ubuffer, (NULL == ustr) ? range.length : 1);
+#else
+    UChar ubuffer[BUFFER_SIZE]; // Dynamic stack allocation is GNU specific
+#endif
+    if (NULL == ustr) {
+        CFStringGetCharacters(string, range, (UniChar *)ubuffer);
+        ustr = ubuffer;
+    } else {
+        ustr += range.location;
+    }
+    UDate udate;
+    int32_t dpos = 0;
+    UErrorCode status = U_ZERO_ERROR;
+    if (formatter->_defaultDate) {
+        CFAbsoluteTime at = CFDateGetAbsoluteTime(formatter->_defaultDate);
+        udate = (at + kCFAbsoluteTimeIntervalSince1970) * 1000.0;
+        UDateFormat *df2 = udat_clone(formatter->_df, &status);
+        UCalendar *cal2 = (UCalendar *)udat_getCalendar(df2);
+        ucal_setMillis(cal2, udate, &status);
+        udat_parseCalendar(formatter->_df, cal2, ustr, range.length, &dpos, &status);
+        udate = ucal_getMillis(cal2, &status);
+        udat_close(df2);
+    } else {
+        udate = udat_parse(formatter->_df, ustr, range.length, &dpos, &status);
+    }
+    if (rangep) rangep->length = dpos;
+    if (U_FAILURE(status)) {
+        return false;
+    }
+    if (atp) {
+        *atp = (double)udate / 1000.0 - kCFAbsoluteTimeIntervalSince1970;
+    }
+    return true;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+#define SET_SYMBOLS_ARRAY(ICU_CODE, INDEX_BASE) \
+        __CFGenericValidateType(value, CFArrayGetTypeID()); \
+	CFArrayRef array = (CFArrayRef)value; \
+	CFIndex idx, cnt = CFArrayGetCount(array); \
+	for (idx = 0; idx < cnt; idx++) { \
+	    CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(array, idx); \
+	    __CFGenericValidateType(item, CFStringGetTypeID()); \
+	    CFIndex item_cnt = CFStringGetLength(item); \
+	    STACK_BUFFER_DECL(UChar, item_buffer, __CFMin(BUFFER_SIZE, item_cnt)); \
+	    UChar *item_ustr = (UChar *)CFStringGetCharactersPtr(item); \
+	    if (NULL == item_ustr) { \
+		item_cnt = __CFMin(BUFFER_SIZE, item_cnt); \
+	        CFStringGetCharacters(item, CFRangeMake(0, item_cnt), (UniChar *)item_buffer); \
+		item_ustr = item_buffer; \
+	    } \
+	    status = U_ZERO_ERROR; \
+	    udat_setSymbols(formatter->_df, ICU_CODE, idx + INDEX_BASE, item_ustr, item_cnt, &status); \
+	}
+#else
+#define SET_SYMBOLS_ARRAY(ICU_CODE, INDEX_BASE) \
+        __CFGenericValidateType(value, CFArrayGetTypeID()); \
+	CFArrayRef array = (CFArrayRef)value; \
+	CFIndex idx, cnt = CFArrayGetCount(array); \
+	for (idx = 0; idx < cnt; idx++) { \
+	    CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(array, idx); \
+	    __CFGenericValidateType(item, CFStringGetTypeID()); \
+	    CFIndex item_cnt = CFStringGetLength(item); \
+       UChar item_buffer[BUFFER_SIZE]; \
+	    UChar *item_ustr = (UChar *)CFStringGetCharactersPtr(item); \
+	    if (NULL == item_ustr) { \
+		item_cnt = __CFMin(BUFFER_SIZE, item_cnt); \
+	        CFStringGetCharacters(item, CFRangeMake(0, item_cnt), (UniChar *)item_buffer); \
+		item_ustr = item_buffer; \
+	    } \
+	    status = U_ZERO_ERROR; \
+	    udat_setSymbols(formatter->_df, ICU_CODE, idx + INDEX_BASE, item_ustr, item_cnt, &status); \
+	}
+#endif
+
+
+void CFDateFormatterSetProperty(CFDateFormatterRef formatter, CFStringRef key, CFTypeRef value) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    __CFGenericValidateType(key, CFStringGetTypeID());
+    UErrorCode status = U_ZERO_ERROR;
+    UChar ubuffer[BUFFER_SIZE];
+
+    if (kCFDateFormatterIsLenient == key) {
+	__CFGenericValidateType(value, CFBooleanGetTypeID());
+	udat_setLenient(formatter->_df, (kCFBooleanTrue == value));
+    } else if (kCFDateFormatterCalendar == key) {
+	__CFGenericValidateType(value, CFCalendarGetTypeID());
+	CFStringRef localeName = CFLocaleGetIdentifier(formatter->_locale);
+	CFDictionaryRef components = CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorSystemDefault, localeName);
+	CFMutableDictionaryRef mcomponents = CFDictionaryCreateMutableCopy(kCFAllocatorSystemDefault, 0, components);
+	CFDictionarySetValue(mcomponents, kCFLocaleCalendarIdentifier, CFCalendarGetIdentifier((CFCalendarRef)value));
+	localeName = CFLocaleCreateLocaleIdentifierFromComponents(kCFAllocatorSystemDefault, mcomponents);
+	CFRelease(mcomponents);
+	CFRelease(components);
+	CFLocaleRef newLocale = CFLocaleCreate(CFGetAllocator(formatter->_locale), localeName);
+	CFRelease(localeName);
+	CFRelease(formatter->_locale);
+	formatter->_locale = newLocale;
+	UCalendar *cal = __CFCalendarCreateUCalendar(NULL, CFLocaleGetIdentifier(formatter->_locale), formatter->_tz);
+	if (cal) udat_setCalendar(formatter->_df, cal);
+	if (cal) ucal_close(cal);
+    } else if (kCFDateFormatterCalendarIdentifier == key || kCFDateFormatterCalendarName == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	CFStringRef localeName = CFLocaleGetIdentifier(formatter->_locale);
+	CFDictionaryRef components = CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorSystemDefault, localeName);
+	CFMutableDictionaryRef mcomponents = CFDictionaryCreateMutableCopy(kCFAllocatorSystemDefault, 0, components);
+	CFDictionarySetValue(mcomponents, kCFLocaleCalendarIdentifier, value);
+	localeName = CFLocaleCreateLocaleIdentifierFromComponents(kCFAllocatorSystemDefault, mcomponents);
+	CFRelease(mcomponents);
+	CFRelease(components);
+	CFLocaleRef newLocale = CFLocaleCreate(CFGetAllocator(formatter->_locale), localeName);
+	CFRelease(localeName);
+	CFRelease(formatter->_locale);
+	formatter->_locale = newLocale;
+	UCalendar *cal = __CFCalendarCreateUCalendar(NULL, CFLocaleGetIdentifier(formatter->_locale), formatter->_tz);
+	if (cal) udat_setCalendar(formatter->_df, cal);
+	if (cal) ucal_close(cal);
+    } else if (kCFDateFormatterTimeZone == key) {
+	__CFGenericValidateType(value, CFTimeZoneGetTypeID());
+	CFTimeZoneRef old = formatter->_tz;
+	formatter->_tz = value ? (CFTimeZoneRef)CFRetain(value) : CFTimeZoneCopyDefault();
+	if (old) CFRelease(old);
+	CFStringRef tznam = CFTimeZoneGetName(formatter->_tz);
+	UCalendar *cal = (UCalendar *)udat_getCalendar(formatter->_df);
+	CFIndex ucnt = CFStringGetLength(tznam);
+	if (BUFFER_SIZE < ucnt) ucnt = BUFFER_SIZE;
+	CFStringGetCharacters(tznam, CFRangeMake(0, ucnt), (UniChar *)ubuffer);
+	ucal_setTimeZone(cal, ubuffer, ucnt, &status);
+    } else if (kCFDateFormatterDefaultFormat == key) {
+	// read-only attribute
+    } else if (kCFDateFormatterTwoDigitStartDate == key) {
+        __CFGenericValidateType(value, CFDateGetTypeID());
+	CFAbsoluteTime at = CFDateGetAbsoluteTime((CFDateRef)value);
+	UDate udate = (at + kCFAbsoluteTimeIntervalSince1970) * 1000.0;
+	udat_set2DigitYearStart(formatter->_df, udate, &status);
+    } else if (kCFDateFormatterDefaultDate == key) {
+        __CFGenericValidateType(value, CFDateGetTypeID());
+	CFDateRef old = formatter->_defaultDate;
+	formatter->_defaultDate = value ? (CFDateRef)CFRetain(value) : NULL;
+	if (old) CFRelease(old);
+    } else if (kCFDateFormatterEraSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_ERAS, 0)
+    } else if (kCFDateFormatterMonthSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_MONTHS, 0)
+    } else if (kCFDateFormatterShortMonthSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_SHORT_MONTHS, 0)
+    } else if (kCFDateFormatterWeekdaySymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_WEEKDAYS, 1)
+    } else if (kCFDateFormatterShortWeekdaySymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_SHORT_WEEKDAYS, 1)
+    } else if (kCFDateFormatterAMSymbol == key) {
+        __CFGenericValidateType(value, CFStringGetTypeID());
+	CFIndex item_cnt = CFStringGetLength((CFStringRef)value);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+	STACK_BUFFER_DECL(UChar, item_buffer, __CFMin(BUFFER_SIZE, item_cnt));
+#else
+   UChar item_buffer[BUFFER_SIZE];
+#endif
+	UChar *item_ustr = (UChar *)CFStringGetCharactersPtr((CFStringRef)value);
+	if (NULL == item_ustr) {
+	    item_cnt = __CFMin(BUFFER_SIZE, item_cnt);
+	    CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, item_cnt), (UniChar *)item_buffer);
+	    item_ustr = item_buffer;
+	}
+	udat_setSymbols(formatter->_df, UDAT_AM_PMS, 0, item_ustr, item_cnt, &status);
+    } else if (kCFDateFormatterPMSymbol == key) {
+        __CFGenericValidateType(value, CFStringGetTypeID());
+	CFIndex item_cnt = CFStringGetLength((CFStringRef)value);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+	STACK_BUFFER_DECL(UChar, item_buffer, __CFMin(BUFFER_SIZE, item_cnt));
+#else
+   UChar item_buffer[BUFFER_SIZE];
+#endif
+	UChar *item_ustr = (UChar *)CFStringGetCharactersPtr((CFStringRef)value);
+	if (NULL == item_ustr) {
+	    item_cnt = __CFMin(BUFFER_SIZE, item_cnt);
+	    CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, item_cnt), (UniChar *)item_buffer);
+	    item_ustr = item_buffer;
+	}
+	udat_setSymbols(formatter->_df, UDAT_AM_PMS, 1, item_ustr, item_cnt, &status);
+    } else if (kCFDateFormatterGregorianStartDate == key) {
+	__CFGenericValidateType(value, CFDateGetTypeID());
+	CFAbsoluteTime at = CFDateGetAbsoluteTime((CFDateRef)value);
+	UDate udate = (at + kCFAbsoluteTimeIntervalSince1970) * 1000.0;
+	UCalendar *cal = (UCalendar *)udat_getCalendar(formatter->_df);
+	ucal_setGregorianChange(cal, udate, &status);
+    } else if (kCFDateFormatterLongEraSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_ERA_NAMES, 0)
+    } else if (kCFDateFormatterVeryShortMonthSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_NARROW_MONTHS, 0)
+    } else if (kCFDateFormatterStandaloneMonthSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_MONTHS, 0)
+    } else if (kCFDateFormatterShortStandaloneMonthSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_SHORT_MONTHS, 0)
+    } else if (kCFDateFormatterVeryShortStandaloneMonthSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_NARROW_MONTHS, 0)
+    } else if (kCFDateFormatterVeryShortWeekdaySymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_NARROW_WEEKDAYS, 1)
+    } else if (kCFDateFormatterStandaloneWeekdaySymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_WEEKDAYS, 1)
+    } else if (kCFDateFormatterShortStandaloneWeekdaySymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_SHORT_WEEKDAYS, 1)
+    } else if (kCFDateFormatterVeryShortStandaloneWeekdaySymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_NARROW_WEEKDAYS, 1)
+    } else if (kCFDateFormatterQuarterSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_QUARTERS, 1)
+    } else if (kCFDateFormatterShortQuarterSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_SHORT_QUARTERS, 1)
+    } else if (kCFDateFormatterStandaloneQuarterSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_QUARTERS, 1)
+    } else if (kCFDateFormatterShortStandaloneQuarterSymbols == key) {
+	SET_SYMBOLS_ARRAY(UDAT_STANDALONE_SHORT_QUARTERS, 1)
+    } else {
+	CFAssert3(0, __kCFLogAssertion, "%s(): unknown key %p (%@)", __PRETTY_FUNCTION__, key, key);
+    }
+}
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+#define GET_SYMBOLS_ARRAY(ICU_CODE, INDEX_BASE) \
+	CFIndex idx, cnt = udat_countSymbols(formatter->_df, ICU_CODE) - INDEX_BASE; \
+	STACK_BUFFER_DECL(CFStringRef, strings, cnt); \
+	for (idx = 0; idx < cnt; idx++) { \
+	    CFStringRef str = NULL; \
+	    status = U_ZERO_ERROR; \
+	    CFIndex ucnt = udat_getSymbols(formatter->_df, ICU_CODE, idx + INDEX_BASE, ubuffer, BUFFER_SIZE, &status); \
+	    if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) { \
+		str = CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, ucnt); \
+	    } \
+	    strings[idx] = !str ? (CFStringRef)CFRetain(CFSTR("<error>")) : str; \
+	} \
+	CFArrayRef array = CFArrayCreate(CFGetAllocator(formatter), (const void **)strings, cnt, &kCFTypeArrayCallBacks); \
+	while (cnt--) { \
+	    CFRelease(strings[cnt]); \
+	} \
+	return array;
+#else
+#define GET_SYMBOLS_ARRAY(ICU_CODE, INDEX_BASE) \
+	CFIndex idx, cnt = udat_countSymbols(formatter->_df, ICU_CODE) - INDEX_BASE; \
+	CFStringRef strings[BUFFER_SIZE]; \
+	for (idx = 0; idx < cnt; idx++) { \
+	    CFStringRef str = NULL; \
+	    status = U_ZERO_ERROR; \
+	    CFIndex ucnt = udat_getSymbols(formatter->_df, ICU_CODE, idx + INDEX_BASE, ubuffer, BUFFER_SIZE, &status); \
+	    if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) { \
+		str = CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, ucnt); \
+	    } \
+	    strings[idx] = !str ? (CFStringRef)CFRetain(CFSTR("<error>")) : str; \
+	} \
+	CFArrayRef array = CFArrayCreate(CFGetAllocator(formatter), (const void **)strings, cnt, &kCFTypeArrayCallBacks); \
+	while (cnt--) { \
+	    CFRelease(strings[cnt]); \
+	} \
+	return array;
+#endif
+
+CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef key) {
+    __CFGenericValidateType(formatter, CFDateFormatterGetTypeID());
+    __CFGenericValidateType(key, CFStringGetTypeID());
+    UErrorCode status = U_ZERO_ERROR;
+    UChar ubuffer[BUFFER_SIZE];
+
+    if (kCFDateFormatterIsLenient == key) {
+	return CFRetain(udat_isLenient(formatter->_df) ? kCFBooleanTrue : kCFBooleanFalse);
+    } else if (kCFDateFormatterCalendar == key) {
+	CFCalendarRef calendar = (CFCalendarRef)CFLocaleGetValue(formatter->_locale, kCFLocaleCalendar);
+	return calendar ? CFRetain(calendar) : NULL;
+    } else if (kCFDateFormatterCalendarIdentifier == key || kCFDateFormatterCalendarName == key) {
+	CFStringRef ident = (CFStringRef)CFLocaleGetValue(formatter->_locale, kCFLocaleCalendarIdentifier);
+	return ident ? CFRetain(ident) : NULL;
+    } else if (kCFDateFormatterTimeZone == key) {
+	return CFRetain(formatter->_tz);
+    } else if (kCFDateFormatterDefaultFormat == key) {
+	return formatter->_defformat ? CFRetain(formatter->_defformat) : NULL;
+    } else if (kCFDateFormatterTwoDigitStartDate == key) {
+	UDate udate = udat_get2DigitYearStart(formatter->_df, &status);
+        if (U_SUCCESS(status)) {
+	    CFAbsoluteTime at = (double)udate / 1000.0 - kCFAbsoluteTimeIntervalSince1970;
+            return CFDateCreate(CFGetAllocator(formatter), at);
+        }
+    } else if (kCFDateFormatterDefaultDate == key) {
+	return formatter->_defaultDate ? CFRetain(formatter->_defaultDate) : NULL;
+    } else if (kCFDateFormatterEraSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_ERAS, 0)
+    } else if (kCFDateFormatterMonthSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_MONTHS, 0)
+    } else if (kCFDateFormatterShortMonthSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_SHORT_MONTHS, 0)
+    } else if (kCFDateFormatterWeekdaySymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_WEEKDAYS, 1)
+    } else if (kCFDateFormatterShortWeekdaySymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_SHORT_WEEKDAYS, 1)
+    } else if (kCFDateFormatterAMSymbol == key) {
+	CFIndex cnt = udat_countSymbols(formatter->_df, UDAT_AM_PMS);
+	if (2 <= cnt) {
+	    CFIndex ucnt = udat_getSymbols(formatter->_df, UDAT_AM_PMS, 0, ubuffer, BUFFER_SIZE, &status);
+	    if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+		return CFStringCreateWithCharacters(CFGetAllocator(formatter), (UniChar *)ubuffer, ucnt);
+	    }
+	}	
+    } else if (kCFDateFormatterPMSymbol == key) {
+	CFIndex cnt = udat_countSymbols(formatter->_df, UDAT_AM_PMS);
+	if (2 <= cnt) {
+	    CFIndex ucnt = udat_getSymbols(formatter->_df, UDAT_AM_PMS, 1, ubuffer, BUFFER_SIZE, &status);
+	    if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+		return CFStringCreateWithCharacters(CFGetAllocator(formatter), (UniChar *)ubuffer, ucnt);
+	    }
+	}	
+    } else if (kCFDateFormatterGregorianStartDate == key) {
+	UCalendar *cal = (UCalendar *)udat_getCalendar(formatter->_df);
+	UDate udate = ucal_getGregorianChange(cal, &status);
+        if (U_SUCCESS(status)) {
+	    CFAbsoluteTime at = (double)udate / 1000.0 - kCFAbsoluteTimeIntervalSince1970;
+            return CFDateCreate(CFGetAllocator(formatter), at);
+        }
+    } else if (kCFDateFormatterLongEraSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_ERA_NAMES, 0)
+    } else if (kCFDateFormatterVeryShortMonthSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_NARROW_MONTHS, 0)
+    } else if (kCFDateFormatterStandaloneMonthSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_MONTHS, 0)
+    } else if (kCFDateFormatterShortStandaloneMonthSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_SHORT_MONTHS, 0)
+    } else if (kCFDateFormatterVeryShortStandaloneMonthSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_NARROW_MONTHS, 0)
+    } else if (kCFDateFormatterVeryShortWeekdaySymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_NARROW_WEEKDAYS, 1)
+    } else if (kCFDateFormatterStandaloneWeekdaySymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_WEEKDAYS, 1)
+    } else if (kCFDateFormatterShortStandaloneWeekdaySymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_SHORT_WEEKDAYS, 1)
+    } else if (kCFDateFormatterVeryShortStandaloneWeekdaySymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_NARROW_WEEKDAYS, 1)
+    } else if (kCFDateFormatterQuarterSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_QUARTERS, 1)
+    } else if (kCFDateFormatterShortQuarterSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_SHORT_QUARTERS, 1)
+    } else if (kCFDateFormatterStandaloneQuarterSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_QUARTERS, 1)
+    } else if (kCFDateFormatterShortStandaloneQuarterSymbols == key) {
+	GET_SYMBOLS_ARRAY(UDAT_STANDALONE_SHORT_QUARTERS, 1)
+    } else {
+	CFAssert3(0, __kCFLogAssertion, "%s(): unknown key %p (%@)", __PRETTY_FUNCTION__, key, key);
+    }
+    return NULL;
+}
+
+CONST_STRING_DECL(kCFDateFormatterIsLenient, "kCFDateFormatterIsLenient")
+CONST_STRING_DECL(kCFDateFormatterTimeZone, "kCFDateFormatterTimeZone")
+CONST_STRING_DECL(kCFDateFormatterCalendarName, "kCFDateFormatterCalendarName")
+CONST_STRING_DECL(kCFDateFormatterCalendarIdentifier, "kCFDateFormatterCalendarIdentifier")
+CONST_STRING_DECL(kCFDateFormatterCalendar, "kCFDateFormatterCalendar")
+CONST_STRING_DECL(kCFDateFormatterDefaultFormat, "kCFDateFormatterDefaultFormat")
+
+CONST_STRING_DECL(kCFDateFormatterTwoDigitStartDate, "kCFDateFormatterTwoDigitStartDate")
+CONST_STRING_DECL(kCFDateFormatterDefaultDate, "kCFDateFormatterDefaultDate")
+CONST_STRING_DECL(kCFDateFormatterEraSymbols, "kCFDateFormatterEraSymbols")
+CONST_STRING_DECL(kCFDateFormatterMonthSymbols, "kCFDateFormatterMonthSymbols")
+CONST_STRING_DECL(kCFDateFormatterShortMonthSymbols, "kCFDateFormatterShortMonthSymbols")
+CONST_STRING_DECL(kCFDateFormatterWeekdaySymbols, "kCFDateFormatterWeekdaySymbols")
+CONST_STRING_DECL(kCFDateFormatterShortWeekdaySymbols, "kCFDateFormatterShortWeekdaySymbols")
+CONST_STRING_DECL(kCFDateFormatterAMSymbol, "kCFDateFormatterAMSymbol")
+CONST_STRING_DECL(kCFDateFormatterPMSymbol, "kCFDateFormatterPMSymbol")
+
+CONST_STRING_DECL(kCFDateFormatterLongEraSymbols, "kCFDateFormatterLongEraSymbols")
+CONST_STRING_DECL(kCFDateFormatterVeryShortMonthSymbols, "kCFDateFormatterVeryShortMonthSymbols")
+CONST_STRING_DECL(kCFDateFormatterStandaloneMonthSymbols, "kCFDateFormatterStandaloneMonthSymbols")
+CONST_STRING_DECL(kCFDateFormatterShortStandaloneMonthSymbols, "kCFDateFormatterShortStandaloneMonthSymbols")
+CONST_STRING_DECL(kCFDateFormatterVeryShortStandaloneMonthSymbols, "kCFDateFormatterVeryShortStandaloneMonthSymbols")
+CONST_STRING_DECL(kCFDateFormatterVeryShortWeekdaySymbols, "kCFDateFormatterVeryShortWeekdaySymbols")
+CONST_STRING_DECL(kCFDateFormatterStandaloneWeekdaySymbols, "kCFDateFormatterStandaloneWeekdaySymbols")
+CONST_STRING_DECL(kCFDateFormatterShortStandaloneWeekdaySymbols, "kCFDateFormatterShortStandaloneWeekdaySymbols")
+CONST_STRING_DECL(kCFDateFormatterVeryShortStandaloneWeekdaySymbols, "kCFDateFormatterVeryShortStandaloneWeekdaySymbols")
+CONST_STRING_DECL(kCFDateFormatterQuarterSymbols, "kCFDateFormatterQuarterSymbols")
+CONST_STRING_DECL(kCFDateFormatterShortQuarterSymbols, "kCFDateFormatterShortQuarterSymbols")
+CONST_STRING_DECL(kCFDateFormatterStandaloneQuarterSymbols, "kCFDateFormatterStandaloneQuarterSymbols")
+CONST_STRING_DECL(kCFDateFormatterShortStandaloneQuarterSymbols, "kCFDateFormatterShortStandaloneQuarterSymbols")
+CONST_STRING_DECL(kCFDateFormatterGregorianStartDate, "kCFDateFormatterGregorianStartDate")
+
+#undef BUFFER_SIZE
+
diff --git a/CoreFoundation/CFDateFormatter.h b/CoreFoundation/CFDateFormatter.h
new file mode 100644
index 0000000..d9ae72c
--- /dev/null
+++ b/CoreFoundation/CFDateFormatter.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFDATEFORMATTER__)
+#define __COREFOUNDATION_CFDATEFORMATTER__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFLocale.h>
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+
+CF_EXTERN_C_BEGIN
+
+typedef struct __CFDateFormatter *CFDateFormatterRef;
+
+// CFDateFormatters are not thread-safe.  Do not use one from multiple threads!
+
+CF_EXPORT
+CFTypeID CFDateFormatterGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+enum {	// date and time format styles
+	kCFDateFormatterNoStyle = 0,
+	kCFDateFormatterShortStyle = 1,
+	kCFDateFormatterMediumStyle = 2,
+	kCFDateFormatterLongStyle = 3,
+	kCFDateFormatterFullStyle = 4
+};
+typedef CFIndex CFDateFormatterStyle;
+
+// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFDateFormatterStyle CFDateFormatterGetDateStyle(CFDateFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFDateFormatterStyle CFDateFormatterGetTimeStyle(CFDateFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Get the properties with which the date formatter was created.
+
+CF_EXPORT
+CFStringRef CFDateFormatterGetFormat(CFDateFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+void CFDateFormatterSetFormat(CFDateFormatterRef formatter, CFStringRef formatString) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFStringRef CFDateFormatterCreateStringWithAbsoluteTime(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFAbsoluteTime at) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+Boolean CFDateFormatterGetAbsoluteTimeFromString(CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep, CFAbsoluteTime *atp) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef key) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Set and get various properties of the date formatter, the set of
+	// which may be expanded in the future.
+
+CF_EXPORT const CFStringRef kCFDateFormatterIsLenient AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFBoolean
+CF_EXPORT const CFStringRef kCFDateFormatterTimeZone AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFTimeZone
+CF_EXPORT const CFStringRef kCFDateFormatterCalendarName AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFString
+CF_EXPORT const CFStringRef kCFDateFormatterDefaultFormat AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFString
+CF_EXPORT const CFStringRef kCFDateFormatterTwoDigitStartDate AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFDate
+CF_EXPORT const CFStringRef kCFDateFormatterDefaultDate AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;	// CFDate
+CF_EXPORT const CFStringRef kCFDateFormatterCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFCalendar
+CF_EXPORT const CFStringRef kCFDateFormatterEraSymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;	// CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;	// CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterShortMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;	// CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterShortWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterAMSymbol AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFDateFormatterPMSymbol AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFDateFormatterLongEraSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;   // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterVeryShortMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterStandaloneMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterVeryShortWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterStandaloneWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; 	// CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterShortQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterStandaloneQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
+CF_EXPORT const CFStringRef kCFDateFormatterGregorianStartDate AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFDate
+
+// 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;
+
+CF_EXTERN_C_END
+
+#endif
+
+#endif /* ! __COREFOUNDATION_CFDATEFORMATTER__ */
+
diff --git a/CoreFoundation/CFDictionary.c b/CoreFoundation/CFDictionary.c
new file mode 100644
index 0000000..daaf6d7
--- /dev/null
+++ b/CoreFoundation/CFDictionary.c
@@ -0,0 +1,1483 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2006, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+        Machine generated from Notes/HashingCode.template
+*/
+
+
+
+
+#include <CoreFoundation/CFDictionary.h>
+#include "CFInternal.h"
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach-o/dyld.h>
+#endif
+
+#define CFDictionary 0
+#define CFSet 0
+#define CFBag 0
+#undef CFDictionary
+#define CFDictionary 1
+
+#if CFDictionary
+const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual};
+static const CFDictionaryKeyCallBacks __kCFNullDictionaryKeyCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+static const CFDictionaryValueCallBacks __kCFNullDictionaryValueCallBacks = {0, NULL, NULL, NULL, NULL};
+
+#define CFHashRef CFDictionaryRef
+#define CFMutableHashRef CFMutableDictionaryRef
+#define __kCFHashTypeID __kCFDictionaryTypeID
+#endif
+
+#if CFSet
+const CFDictionaryCallBacks kCFTypeDictionaryCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFDictionaryCallBacks kCFCopyStringDictionaryCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+static const CFDictionaryCallBacks __kCFNullDictionaryCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+
+#define CFDictionaryKeyCallBacks CFDictionaryCallBacks
+#define CFDictionaryValueCallBacks CFDictionaryCallBacks
+#define kCFTypeDictionaryKeyCallBacks kCFTypeDictionaryCallBacks
+#define kCFTypeDictionaryValueCallBacks kCFTypeDictionaryCallBacks
+#define __kCFNullDictionaryKeyCallBacks __kCFNullDictionaryCallBacks
+#define __kCFNullDictionaryValueCallBacks __kCFNullDictionaryCallBacks
+
+#define CFHashRef CFSetRef
+#define CFMutableHashRef CFMutableSetRef
+#define __kCFHashTypeID __kCFSetTypeID
+#endif
+
+#if CFBag
+const CFDictionaryCallBacks kCFTypeDictionaryCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFDictionaryCallBacks kCFCopyStringDictionaryCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+static const CFDictionaryCallBacks __kCFNullDictionaryCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+
+#define CFDictionaryKeyCallBacks CFDictionaryCallBacks
+#define CFDictionaryValueCallBacks CFDictionaryCallBacks
+#define kCFTypeDictionaryKeyCallBacks kCFTypeDictionaryCallBacks
+#define kCFTypeDictionaryValueCallBacks kCFTypeDictionaryCallBacks
+#define __kCFNullDictionaryKeyCallBacks __kCFNullDictionaryCallBacks
+#define __kCFNullDictionaryValueCallBacks __kCFNullDictionaryCallBacks
+
+#define CFHashRef CFBagRef
+#define CFMutableHashRef CFMutableBagRef
+#define __kCFHashTypeID __kCFBagTypeID
+#endif
+
+#define GETNEWKEY(newKey, oldKey) \
+        any_t (*kretain)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))__CFDictionaryGetKeyCallBacks(hc)->retain \
+            : (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        any_t newKey = kretain ? (any_t)INVOKE_CALLBACK3(kretain, allocator, (any_t)key, hc->_context) : (any_t)oldKey
+
+#define RELEASEKEY(oldKey) \
+        void (*krelease)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (void (*)(CFAllocatorRef,any_t,any_pointer_t))__CFDictionaryGetKeyCallBacks(hc)->release \
+            : (void (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        if (krelease) INVOKE_CALLBACK3(krelease, allocator, oldKey, hc->_context)
+        
+#if CFDictionary
+#define GETNEWVALUE(newValue) \
+        any_t (*vretain)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))__CFDictionaryGetValueCallBacks(hc)->retain \
+            : (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        any_t newValue = vretain ? (any_t)INVOKE_CALLBACK3(vretain, allocator, (any_t)value, hc->_context) : (any_t)value
+
+#define RELEASEVALUE(oldValue) \
+    void (*vrelease)(CFAllocatorRef, any_t, any_pointer_t) = \
+      !hasBeenFinalized(hc) \
+        ? (void (*)(CFAllocatorRef,any_t,any_pointer_t))__CFDictionaryGetValueCallBacks(hc)->release \
+        : (void (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+    if (vrelease) INVOKE_CALLBACK3(vrelease, allocator, oldValue, hc->_context)
+
+#endif
+
+static void __CFDictionaryHandleOutOfMemory(CFTypeRef obj, CFIndex numBytes) {
+    CFStringRef msg = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("Attempt to allocate %ld bytes for NS/CFDictionary failed"), numBytes);
+    CFBadErrorCallBack cb = _CFGetOutOfMemoryErrorCallBack();
+    if (NULL == cb || !cb(obj, CFSTR("NS/CFDictionary"), msg)) {
+        CFLog(kCFLogLevelCritical, CFSTR("%@"), msg);
+	HALT;
+    }
+    CFRelease(msg);
+}
+
+
+// Max load is 3/4 number of buckets
+CF_INLINE CFIndex __CFHashRoundUpCapacity(CFIndex capacity) {
+    return 3 * ((CFIndex)1 << (flsl((capacity - 1) / 3)));
+}
+
+// Returns next power of two higher than the capacity
+// threshold for the given input capacity.
+CF_INLINE CFIndex __CFHashNumBucketsForCapacity(CFIndex capacity) {
+    return 4 * ((CFIndex)1 << (flsl((capacity - 1) / 3)));
+}
+
+enum {                /* Bits 1-0 */
+    __kCFHashImmutable = 0,        /* unchangable and fixed capacity */
+    __kCFHashMutable = 1,                /* changeable and variable capacity */
+};
+
+enum {                /* Bits 5-4 (value), 3-2 (key) */
+    __kCFHashHasNullCallBacks = 0,
+    __kCFHashHasCFTypeCallBacks = 1,
+    __kCFHashHasCustomCallBacks = 3        /* callbacks are at end of header */
+};
+
+// Under GC, we fudge the key/value memory in two ways
+// First, if we had null callbacks or null for both retain/release, we use unscanned memory and get
+// standard 'dangling' references.
+// This means that if people were doing addValue:[xxx new] and never removing, well, that doesn't work
+//
+// Second, if we notice standard retain/release implementations we use scanned memory, and fudge the
+// standard callbacks to generally do nothing if the collection was allocated in GC memory. On special
+// CF objects, however, like those used for precious resources like video-card buffers, we do indeed
+// do CFRetain on input and CFRelease on output.  The tricky case is GC finalization; we need to remember
+// that we did the CFReleases so that subsequent collection operations, like removal, don't double CFRelease.
+// (In fact we don't really use CFRetain/CFRelease but go directly to the collector)
+//
+
+enum {
+    __kCFHashFinalized =         (1 << 7),
+    __kCFHashWeakKeys =          (1 << 8),
+    __kCFHashWeakValues =        (1 << 9)
+};
+
+typedef uintptr_t any_t;
+typedef const void * const_any_pointer_t;
+typedef void * any_pointer_t;
+
+struct __CFDictionary {
+    CFRuntimeBase _base;
+    CFIndex _count;             /* number of values */
+    CFIndex _bucketsNum;        /* number of buckets */
+    CFIndex _bucketsUsed;       /* number of used buckets */
+    CFIndex _bucketsCap;        /* maximum number of used buckets */
+    CFIndex _mutations;
+    CFIndex _deletes;
+    any_pointer_t _context;     /* private */
+    CFOptionFlags _xflags;
+    any_t _marker;
+    any_t *_keys;     /* can be NULL if not allocated yet */
+    any_t *_values;   /* can be NULL if not allocated yet */
+};
+
+/* Bits 1-0 of the _xflags are used for mutability variety */
+/* Bits 3-2 of the _xflags are used for key callback indicator bits */
+/* Bits 5-4 of the _xflags are used for value callback indicator bits */
+/* Bit 6 of the _xflags is special KVO actions bit */
+/* Bits 7,8,9 are GC use */
+
+CF_INLINE bool hasBeenFinalized(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const struct __CFDictionary *)collection)->_xflags, 7, 7) != 0;
+}
+
+CF_INLINE void markFinalized(CFTypeRef collection) {
+    __CFBitfieldSetValue(((struct __CFDictionary *)collection)->_xflags, 7, 7, 1);
+}
+
+
+CF_INLINE CFIndex __CFHashGetType(CFHashRef hc) {
+    return __CFBitfieldGetValue(hc->_xflags, 1, 0);
+}
+
+CF_INLINE CFIndex __CFDictionaryGetSizeOfType(CFIndex t) {
+    CFIndex size = sizeof(struct __CFDictionary);
+    if (__CFBitfieldGetValue(t, 3, 2) == __kCFHashHasCustomCallBacks) {
+        size += sizeof(CFDictionaryKeyCallBacks);
+    }
+    if (__CFBitfieldGetValue(t, 5, 4) == __kCFHashHasCustomCallBacks) {
+        size += sizeof(CFDictionaryValueCallBacks);
+    }
+    return size;
+}
+
+CF_INLINE const CFDictionaryKeyCallBacks *__CFDictionaryGetKeyCallBacks(CFHashRef hc) {
+    CFDictionaryKeyCallBacks *result = NULL;
+    switch (__CFBitfieldGetValue(hc->_xflags, 3, 2)) {
+    case __kCFHashHasNullCallBacks:
+        return &__kCFNullDictionaryKeyCallBacks;
+    case __kCFHashHasCFTypeCallBacks:
+        return &kCFTypeDictionaryKeyCallBacks;
+    case __kCFHashHasCustomCallBacks:
+        break;
+    }
+    result = (CFDictionaryKeyCallBacks *)((uint8_t *)hc + sizeof(struct __CFDictionary));
+    return result;
+}
+
+CF_INLINE Boolean __CFDictionaryKeyCallBacksMatchNull(const CFDictionaryKeyCallBacks *c) {
+    return (NULL == c ||
+        (c->retain == __kCFNullDictionaryKeyCallBacks.retain &&
+         c->release == __kCFNullDictionaryKeyCallBacks.release &&
+         c->copyDescription == __kCFNullDictionaryKeyCallBacks.copyDescription &&
+         c->equal == __kCFNullDictionaryKeyCallBacks.equal &&
+         c->hash == __kCFNullDictionaryKeyCallBacks.hash));
+}
+
+CF_INLINE Boolean __CFDictionaryKeyCallBacksMatchCFType(const CFDictionaryKeyCallBacks *c) {
+    return (&kCFTypeDictionaryKeyCallBacks == c ||
+        (c->retain == kCFTypeDictionaryKeyCallBacks.retain &&
+         c->release == kCFTypeDictionaryKeyCallBacks.release &&
+         c->copyDescription == kCFTypeDictionaryKeyCallBacks.copyDescription &&
+         c->equal == kCFTypeDictionaryKeyCallBacks.equal &&
+         c->hash == kCFTypeDictionaryKeyCallBacks.hash));
+}
+
+CF_INLINE const CFDictionaryValueCallBacks *__CFDictionaryGetValueCallBacks(CFHashRef hc) {
+    CFDictionaryValueCallBacks *result = NULL;
+    switch (__CFBitfieldGetValue(hc->_xflags, 5, 4)) {
+    case __kCFHashHasNullCallBacks:
+        return &__kCFNullDictionaryValueCallBacks;
+    case __kCFHashHasCFTypeCallBacks:
+        return &kCFTypeDictionaryValueCallBacks;
+    case __kCFHashHasCustomCallBacks:
+        break;
+    }
+    if (__CFBitfieldGetValue(hc->_xflags, 3, 2) == __kCFHashHasCustomCallBacks) {
+        result = (CFDictionaryValueCallBacks *)((uint8_t *)hc + sizeof(struct __CFDictionary) + sizeof(CFDictionaryKeyCallBacks));
+    } else {
+        result = (CFDictionaryValueCallBacks *)((uint8_t *)hc + sizeof(struct __CFDictionary));
+    }
+    return result;
+}
+
+CF_INLINE Boolean __CFDictionaryValueCallBacksMatchNull(const CFDictionaryValueCallBacks *c) {
+    return (NULL == c ||
+        (c->retain == __kCFNullDictionaryValueCallBacks.retain &&
+         c->release == __kCFNullDictionaryValueCallBacks.release &&
+         c->copyDescription == __kCFNullDictionaryValueCallBacks.copyDescription &&
+         c->equal == __kCFNullDictionaryValueCallBacks.equal));
+}
+
+CF_INLINE Boolean __CFDictionaryValueCallBacksMatchCFType(const CFDictionaryValueCallBacks *c) {
+    return (&kCFTypeDictionaryValueCallBacks == c ||
+        (c->retain == kCFTypeDictionaryValueCallBacks.retain &&
+         c->release == kCFTypeDictionaryValueCallBacks.release &&
+         c->copyDescription == kCFTypeDictionaryValueCallBacks.copyDescription &&
+         c->equal == kCFTypeDictionaryValueCallBacks.equal));
+}
+
+CFIndex _CFDictionaryGetKVOBit(CFHashRef hc) {
+    return __CFBitfieldGetValue(hc->_xflags, 6, 6);
+}
+
+void _CFDictionarySetKVOBit(CFHashRef hc, CFIndex bit) {
+    __CFBitfieldSetValue(((CFMutableHashRef)hc)->_xflags, 6, 6, ((uintptr_t)bit & 0x1));
+}
+
+CF_INLINE Boolean __CFDictionaryShouldShrink(CFHashRef hc) {
+    return (__kCFHashMutable == __CFHashGetType(hc)) &&
+                !(CF_USING_COLLECTABLE_MEMORY && auto_zone_is_finalized(__CFCollectableZone, hc)) && /* GC:  don't shrink finalizing hcs! */
+                (hc->_bucketsNum < 4 * hc->_deletes || (256 <= hc->_bucketsCap && hc-> _bucketsUsed < 3 * hc->_bucketsCap / 16));
+}
+
+CF_INLINE CFIndex __CFHashGetOccurrenceCount(CFHashRef hc, CFIndex idx) {
+#if CFBag
+    return hc->_values[idx];
+#endif
+    return 1;
+}
+
+CF_INLINE Boolean __CFHashKeyIsValue(CFHashRef hc, any_t key) {
+    return (hc->_marker != key && ~hc->_marker != key) ? true : false;
+}
+
+CF_INLINE Boolean __CFHashKeyIsMagic(CFHashRef hc, any_t key) {
+    return (hc->_marker == key || ~hc->_marker == key) ? true : false;
+}
+
+
+#if !defined(CF_OBJC_KVO_WILLCHANGE)
+#define CF_OBJC_KVO_WILLCHANGE(obj, key)
+#define CF_OBJC_KVO_DIDCHANGE(obj, key)
+#endif
+
+CF_INLINE uintptr_t __CFDictionaryScrambleHash(uintptr_t k) {
+#if 0
+    return k;
+#else
+#if __LP64__
+    uintptr_t a = 0x4368726973746F70ULL;
+    uintptr_t b = 0x686572204B616E65ULL;
+#else
+    uintptr_t a = 0x4B616E65UL;
+    uintptr_t b = 0x4B616E65UL;
+#endif
+    uintptr_t c = 1;
+    a += k;
+#if __LP64__
+    a -= b; a -= c; a ^= (c >> 43);
+    b -= c; b -= a; b ^= (a << 9);
+    c -= a; c -= b; c ^= (b >> 8);
+    a -= b; a -= c; a ^= (c >> 38);
+    b -= c; b -= a; b ^= (a << 23);
+    c -= a; c -= b; c ^= (b >> 5);
+    a -= b; a -= c; a ^= (c >> 35);
+    b -= c; b -= a; b ^= (a << 49);
+    c -= a; c -= b; c ^= (b >> 11);
+    a -= b; a -= c; a ^= (c >> 12);
+    b -= c; b -= a; b ^= (a << 18);
+    c -= a; c -= b; c ^= (b >> 22);
+#else
+    a -= b; a -= c; a ^= (c >> 13);
+    b -= c; b -= a; b ^= (a << 8);
+    c -= a; c -= b; c ^= (b >> 13);
+    a -= b; a -= c; a ^= (c >> 12);
+    b -= c; b -= a; b ^= (a << 16);
+    c -= a; c -= b; c ^= (b >> 5);
+    a -= b; a -= c; a ^= (c >> 3);
+    b -= c; b -= a; b ^= (a << 10);
+    c -= a; c -= b; c ^= (b >> 15);
+#endif
+    return c;
+#endif
+}
+
+static CFIndex __CFDictionaryFindBuckets1a(CFHashRef hc, any_t key) {
+    CFHashCode keyHash = (CFHashCode)key;
+    keyHash = (CFHashCode)__CFDictionaryScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            return kCFNotFound;
+        } else if (~marker == currKey) {        /* deleted */
+            /* do nothing */
+        } else if (currKey == key) {
+            return probe;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return kCFNotFound;
+        }
+    }
+}
+
+static CFIndex __CFDictionaryFindBuckets1b(CFHashRef hc, any_t key) {
+    const CFDictionaryKeyCallBacks *cb = __CFDictionaryGetKeyCallBacks(hc);
+    CFHashCode keyHash = cb->hash ? (CFHashCode)INVOKE_CALLBACK2(((CFHashCode (*)(any_t, any_pointer_t))cb->hash), key, hc->_context) : (CFHashCode)key;
+    keyHash = (CFHashCode)__CFDictionaryScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            return kCFNotFound;
+        } else if (~marker == currKey) {        /* deleted */
+            /* do nothing */
+        } else if (currKey == key || (cb->equal && INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))cb->equal, currKey, key, hc->_context))) {
+            return probe;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return kCFNotFound;
+        }
+    }
+}
+
+CF_INLINE CFIndex __CFDictionaryFindBuckets1(CFHashRef hc, any_t key) {
+    if (__kCFHashHasNullCallBacks == __CFBitfieldGetValue(hc->_xflags, 3, 2)) {
+        return __CFDictionaryFindBuckets1a(hc, key);
+    }
+    return __CFDictionaryFindBuckets1b(hc, key);
+}
+
+static void __CFDictionaryFindBuckets2(CFHashRef hc, any_t key, CFIndex *match, CFIndex *nomatch) {
+    const CFDictionaryKeyCallBacks *cb = __CFDictionaryGetKeyCallBacks(hc);
+    CFHashCode keyHash = cb->hash ? (CFHashCode)INVOKE_CALLBACK2(((CFHashCode (*)(any_t, any_pointer_t))cb->hash), key, hc->_context) : (CFHashCode)key;
+    keyHash = (CFHashCode)__CFDictionaryScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    *match = kCFNotFound;
+    *nomatch = kCFNotFound;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            if (nomatch) *nomatch = probe;
+            return;
+        } else if (~marker == currKey) {        /* deleted */
+            if (nomatch) {
+                *nomatch = probe;
+                nomatch = NULL;
+            }
+        } else if (currKey == key || (cb->equal && INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))cb->equal, currKey, key, hc->_context))) {
+            *match = probe;
+            return;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return;
+        }
+    }
+}
+
+static void __CFDictionaryFindNewMarker(CFHashRef hc) {
+    any_t *keys = hc->_keys;
+    any_t newMarker;
+    CFIndex idx, nbuckets;
+    Boolean hit;
+
+    nbuckets = hc->_bucketsNum;
+    newMarker = hc->_marker;
+    do {
+        newMarker--;
+        hit = false;
+        for (idx = 0; idx < nbuckets; idx++) {
+            if (newMarker == keys[idx] || ~newMarker == keys[idx]) {
+                hit = true;
+                break;
+            }
+        }
+    } while (hit);
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (hc->_marker == keys[idx]) {
+            keys[idx] = newMarker;
+        } else if (~hc->_marker == keys[idx]) {
+            keys[idx] = ~newMarker;
+        }
+    }
+    ((struct __CFDictionary *)hc)->_marker = newMarker;
+}
+
+static Boolean __CFDictionaryEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFHashRef hc1 = (CFHashRef)cf1;
+    CFHashRef hc2 = (CFHashRef)cf2;
+    const CFDictionaryKeyCallBacks *cb1, *cb2;
+    const CFDictionaryValueCallBacks *vcb1, *vcb2;
+    any_t *keys;
+    CFIndex idx, nbuckets;
+    if (hc1 == hc2) return true;
+    if (hc1->_count != hc2->_count) return false;
+    cb1 = __CFDictionaryGetKeyCallBacks(hc1);
+    cb2 = __CFDictionaryGetKeyCallBacks(hc2);
+    if (cb1->equal != cb2->equal) return false;
+    vcb1 = __CFDictionaryGetValueCallBacks(hc1);
+    vcb2 = __CFDictionaryGetValueCallBacks(hc2);
+    if (vcb1->equal != vcb2->equal) return false;
+    if (0 == hc1->_bucketsUsed) return true; /* after function comparison! */
+    keys = hc1->_keys;
+    nbuckets = hc1->_bucketsNum;
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (hc1->_marker != keys[idx] && ~hc1->_marker != keys[idx]) {
+#if CFDictionary
+            const_any_pointer_t value;
+            if (!CFDictionaryGetValueIfPresent(hc2, (any_pointer_t)keys[idx], &value)) return false;
+	    if (hc1->_values[idx] != (any_t)value) {
+		if (NULL == vcb1->equal) return false;
+	        if (!INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))vcb1->equal, hc1->_values[idx], (any_t)value, hc1->_context)) return false;
+            }
+#endif
+#if  CFSet
+            const_any_pointer_t value;
+            if (!CFDictionaryGetValueIfPresent(hc2, (any_pointer_t)keys[idx], &value)) return false;
+#endif
+#if CFBag
+            if (hc1->_values[idx] != CFDictionaryGetCountOfValue(hc2, (any_pointer_t)keys[idx])) return false;
+#endif
+        }
+    }
+    return true;
+}
+
+static CFHashCode __CFDictionaryHash(CFTypeRef cf) {
+    CFHashRef hc = (CFHashRef)cf;
+    return hc->_count;
+}
+
+static CFStringRef __CFDictionaryCopyDescription(CFTypeRef cf) {
+    CFHashRef hc = (CFHashRef)cf;
+    CFAllocatorRef allocator;
+    const CFDictionaryKeyCallBacks *cb;
+    const CFDictionaryValueCallBacks *vcb;
+    any_t *keys;
+    CFIndex idx, nbuckets;
+    CFMutableStringRef result;
+    cb = __CFDictionaryGetKeyCallBacks(hc);
+    vcb = __CFDictionaryGetValueCallBacks(hc);
+    keys = hc->_keys;
+    nbuckets = hc->_bucketsNum;
+    allocator = CFGetAllocator(hc);
+    result = CFStringCreateMutable(allocator, 0);
+    const char *type = "?";
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashImmutable: type = "immutable"; break;
+    case __kCFHashMutable: type = "mutable"; break;
+    }
+    CFStringAppendFormat(result, NULL, CFSTR("<CFDictionary %p [%p]>{type = %s, count = %u, capacity = %u, pairs = (\n"), cf, allocator, type, hc->_count, hc->_bucketsCap);
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            CFStringRef kDesc = NULL, vDesc = NULL;
+            if (NULL != cb->copyDescription) {
+                kDesc = (CFStringRef)INVOKE_CALLBACK2(((CFStringRef (*)(any_t, any_pointer_t))cb->copyDescription), keys[idx], hc->_context);
+            }
+            if (NULL != vcb->copyDescription) {
+                vDesc = (CFStringRef)INVOKE_CALLBACK2(((CFStringRef (*)(any_t, any_pointer_t))vcb->copyDescription), hc->_values[idx], hc->_context);
+            }
+#if CFDictionary
+            if (NULL != kDesc && NULL != vDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ = %@\n"), idx, kDesc, vDesc);
+                CFRelease(kDesc);
+                CFRelease(vDesc);
+            } else if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ = <%p>\n"), idx, kDesc, hc->_values[idx]);
+                CFRelease(kDesc);
+            } else if (NULL != vDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> = %@\n"), idx, keys[idx], vDesc);
+                CFRelease(vDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> = <%p>\n"), idx, keys[idx], hc->_values[idx]);
+            }
+#endif
+#if CFSet
+            if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@\n"), idx, kDesc);
+                CFRelease(kDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p>\n"), idx, keys[idx]);
+            }
+#endif
+#if CFBag
+            if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ (%ld)\n"), idx, kDesc, hc->_values[idx]);
+                CFRelease(kDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> (%ld)\n"), idx, keys[idx], hc->_values[idx]);
+            }
+#endif
+        }
+    }
+    CFStringAppend(result, CFSTR(")}"));
+    return result;
+}
+
+static void __CFDictionaryDeallocate(CFTypeRef cf) {
+    CFMutableHashRef hc = (CFMutableHashRef)cf;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    const CFDictionaryKeyCallBacks *cb = __CFDictionaryGetKeyCallBacks(hc);
+    const CFDictionaryValueCallBacks *vcb = __CFDictionaryGetValueCallBacks(hc);
+
+    // mark now in case any callout somehow tries to add an entry back in
+    markFinalized(cf);
+    if (vcb->release || cb->release) {
+        any_t *keys = hc->_keys;
+        CFIndex idx, nbuckets = hc->_bucketsNum;
+        for (idx = 0; idx < nbuckets; idx++) {
+            any_t oldkey = keys[idx];
+            if (hc->_marker != oldkey && ~hc->_marker != oldkey) {
+                if (vcb->release) {
+                    INVOKE_CALLBACK3(((void (*)(CFAllocatorRef, any_t, any_pointer_t))vcb->release), allocator, hc->_values[idx], hc->_context);
+                }
+                if (cb->release) {
+                    INVOKE_CALLBACK3(((void (*)(CFAllocatorRef, any_t, any_pointer_t))cb->release), allocator, oldkey, hc->_context);
+                }
+            }
+        }
+    }
+
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        // return early so that contents are preserved after finalization
+        return;
+    }
+    
+    _CFAllocatorDeallocateGC(allocator, hc->_keys);
+#if CFDictionary || CFBag
+    _CFAllocatorDeallocateGC(allocator, hc->_values);
+#endif
+    hc->_keys = NULL;
+    hc->_values = NULL;
+    hc->_count = 0;  // GC: also zero count, so the hc will appear empty.
+    hc->_bucketsUsed = 0;
+    hc->_bucketsNum = 0;
+}
+
+static CFTypeID __kCFDictionaryTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFDictionaryClass = {
+    _kCFRuntimeScannedObject,
+    "CFDictionary",
+    NULL,        // init
+    NULL,        // copy
+    __CFDictionaryDeallocate,
+    __CFDictionaryEqual,
+    __CFDictionaryHash,
+    NULL,        //
+    __CFDictionaryCopyDescription
+};
+
+__private_extern__ void __CFDictionaryInitialize(void) {
+    __kCFHashTypeID = _CFRuntimeRegisterClass(&__CFDictionaryClass);
+}
+
+CFTypeID CFDictionaryGetTypeID(void) {
+    return __kCFHashTypeID;
+}
+
+static CFMutableHashRef __CFDictionaryInit(CFAllocatorRef allocator, CFOptionFlags flags, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks
+#if CFDictionary
+, const CFDictionaryValueCallBacks *valueCallBacks
+#endif
+) {
+    struct __CFDictionary *hc;
+    CFIndex size;
+    __CFBitfieldSetValue(flags, 31, 2, 0);
+    CFOptionFlags xflags = 0;
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        // preserve NULL for key or value CB, otherwise fix up.
+        if (!keyCallBacks || (keyCallBacks->retain == NULL && keyCallBacks->release == NULL)) {
+            xflags = __kCFHashWeakKeys;
+        }
+#if CFDictionary
+        if (!valueCallBacks || (valueCallBacks->retain == NULL && valueCallBacks->release == NULL)) {
+            xflags |= __kCFHashWeakValues;
+        }
+#endif
+#if CFBag
+        xflags |= __kCFHashWeakValues;
+#endif
+    }
+    if (__CFDictionaryKeyCallBacksMatchNull(keyCallBacks)) {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasNullCallBacks);
+    } else if (__CFDictionaryKeyCallBacksMatchCFType(keyCallBacks)) {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasCFTypeCallBacks);
+    } else {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasCustomCallBacks);
+    }
+#if CFDictionary
+    if (__CFDictionaryValueCallBacksMatchNull(valueCallBacks)) {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasNullCallBacks);
+    } else if (__CFDictionaryValueCallBacksMatchCFType(valueCallBacks)) {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasCFTypeCallBacks);
+    } else {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasCustomCallBacks);
+    }
+#endif
+    size = __CFDictionaryGetSizeOfType(flags) - sizeof(CFRuntimeBase);
+    hc = (struct __CFDictionary *)_CFRuntimeCreateInstance(allocator, __kCFHashTypeID, size, NULL);
+    if (NULL == hc) {
+        return NULL;
+    }
+    hc->_count = 0;
+    hc->_bucketsUsed = 0;
+    hc->_marker = (any_t)0xa1b1c1d3;
+    hc->_context = NULL;
+    hc->_deletes = 0;
+    hc->_mutations = 1;
+    hc->_xflags = xflags | flags;
+    switch (__CFBitfieldGetValue(flags, 1, 0)) {
+    case __kCFHashImmutable:
+        if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFDictionary (immutable)");
+        break;
+    case __kCFHashMutable:
+        if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFDictionary (mutable-variable)");
+        break;
+    }
+    hc->_bucketsCap = __CFHashRoundUpCapacity(1);
+    hc->_bucketsNum = 0;
+    hc->_keys = NULL;
+    hc->_values = NULL;
+    if (__kCFHashHasCustomCallBacks == __CFBitfieldGetValue(flags, 3, 2)) {
+        CFDictionaryKeyCallBacks *cb = (CFDictionaryKeyCallBacks *)__CFDictionaryGetKeyCallBacks((CFHashRef)hc);
+        *cb = *keyCallBacks;
+        FAULT_CALLBACK((void **)&(cb->retain));
+        FAULT_CALLBACK((void **)&(cb->release));
+        FAULT_CALLBACK((void **)&(cb->copyDescription));
+        FAULT_CALLBACK((void **)&(cb->equal));
+        FAULT_CALLBACK((void **)&(cb->hash));
+    }
+#if CFDictionary
+    if (__kCFHashHasCustomCallBacks == __CFBitfieldGetValue(flags, 5, 4)) {
+        CFDictionaryValueCallBacks *vcb = (CFDictionaryValueCallBacks *)__CFDictionaryGetValueCallBacks((CFHashRef)hc);
+        *vcb = *valueCallBacks;
+        FAULT_CALLBACK((void **)&(vcb->retain));
+        FAULT_CALLBACK((void **)&(vcb->release));
+        FAULT_CALLBACK((void **)&(vcb->copyDescription));
+        FAULT_CALLBACK((void **)&(vcb->equal));
+    }
+#endif
+    return hc;
+}
+
+#if CFDictionary
+CFHashRef CFDictionaryCreate(CFAllocatorRef allocator, const_any_pointer_t *keys, const_any_pointer_t *values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks) {
+#endif
+#if CFSet || CFBag
+CFHashRef CFDictionaryCreate(CFAllocatorRef allocator, const_any_pointer_t *keys, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks) {
+#endif
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%ld) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+#if CFDictionary
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashImmutable, numValues, keyCallBacks, valueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashImmutable, numValues, keyCallBacks);
+#endif
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashMutable);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+#if CFDictionary
+        CFDictionaryAddValue(hc, keys[idx], values[idx]);
+#endif
+#if CFSet || CFBag
+        CFDictionaryAddValue(hc, keys[idx]);
+#endif
+    }
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    return (CFHashRef)hc;
+}
+
+#if CFDictionary
+CFMutableHashRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks) {
+#endif
+#if CFSet || CFBag
+CFMutableHashRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks) {
+#endif
+    CFAssert2(0 <= capacity, __kCFLogAssertion, "%s(): capacity (%ld) cannot be less than zero", __PRETTY_FUNCTION__, capacity);
+#if CFDictionary
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashMutable, capacity, keyCallBacks, valueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashMutable, capacity, keyCallBacks);
+#endif
+    return hc;
+}
+
+#if CFDictionary || CFSet
+// does not have Add semantics for Bag; it has Set semantics ... is that best?
+static void __CFDictionaryGrow(CFMutableHashRef hc, CFIndex numNewValues);
+
+// This creates a hc which is for CFTypes or NSObjects, with a CFRetain style ownership transfer;
+// the hc does not take a retain (since it claims 1), and the caller does not need to release the inserted objects (since we do it).
+// The incoming objects must also be collectable if allocated out of a collectable allocator - and are neither released nor retained.
+#if CFDictionary
+CFHashRef _CFDictionaryCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const_any_pointer_t *keys, const_any_pointer_t *values, CFIndex numValues) {
+#endif
+#if CFSet || CFBag
+CFHashRef _CFDictionaryCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const_any_pointer_t *keys, CFIndex numValues) {
+#endif
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%ld) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+#if CFDictionary
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashMutable, numValues, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashMutable, numValues, &kCFTypeDictionaryKeyCallBacks);
+#endif
+    __CFDictionaryGrow(hc, numValues);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+        CFIndex match, nomatch;
+        __CFDictionaryFindBuckets2(hc, (any_t)keys[idx], &match, &nomatch);
+        if (kCFNotFound == match) {
+            CFAllocatorRef allocator = __CFGetAllocator(hc);
+            any_t newKey = (any_t)keys[idx];
+            if (__CFHashKeyIsMagic(hc, newKey)) {
+                __CFDictionaryFindNewMarker(hc);
+            }
+            if (hc->_keys[nomatch] == ~hc->_marker) {
+                hc->_deletes--;
+            }
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+            any_t newValue = (any_t)values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+            hc->_values[nomatch] = 1;
+#endif
+            hc->_bucketsUsed++;
+            hc->_count++;
+        } else {
+            CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+            any_t oldKey = hc->_keys[match];
+            any_t newKey = (any_t)keys[idx];
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+            if (__CFHashKeyIsMagic(hc, newKey)) {
+                __CFDictionaryFindNewMarker(hc);
+            }
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+            RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+            any_t oldValue = hc->_values[match];
+            any_t newValue = (any_t)values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+            RELEASEVALUE(oldValue);
+#endif
+        }
+    }
+    if (!isMutable) __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    return (CFHashRef)hc;
+}
+#endif
+
+CFHashRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFHashRef other) {
+    CFMutableHashRef hc = CFDictionaryCreateMutableCopy(allocator, CFDictionaryGetCount(other), other);
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFDictionary (immutable)");
+    return hc;
+}
+
+CFMutableHashRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFHashRef other) {
+    CFIndex numValues = CFDictionaryGetCount(other);
+    const_any_pointer_t *list, buffer[256];
+    list = (numValues <= 256) ? buffer : (const_any_pointer_t *)CFAllocatorAllocate(allocator, numValues * sizeof(const_any_pointer_t), 0);
+    if (list != buffer && __CFOASafe) __CFSetLastAllocationEventName(list, "CFDictionary (temp)");
+#if CFDictionary
+    const_any_pointer_t *vlist, vbuffer[256];
+    vlist = (numValues <= 256) ? vbuffer : (const_any_pointer_t *)CFAllocatorAllocate(allocator, numValues * sizeof(const_any_pointer_t), 0);
+    if (vlist != vbuffer && __CFOASafe) __CFSetLastAllocationEventName(vlist, "CFDictionary (temp)");
+#endif
+#if CFSet || CFBag
+    CFDictionaryGetValues(other, list);
+#endif
+#if CFDictionary
+    CFDictionaryGetKeysAndValues(other, list, vlist);
+#endif
+    const CFDictionaryKeyCallBacks *kcb;
+    const CFDictionaryValueCallBacks *vcb;
+    if (CF_IS_OBJC(__kCFHashTypeID, other)) {
+        kcb = &kCFTypeDictionaryKeyCallBacks;
+        vcb = &kCFTypeDictionaryValueCallBacks;
+    } else {
+        kcb = __CFDictionaryGetKeyCallBacks(other);
+        vcb = __CFDictionaryGetValueCallBacks(other);
+    }
+#if CFDictionary
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashMutable, capacity, kcb, vcb);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFDictionaryInit(allocator, __kCFHashMutable, capacity, kcb);
+#endif
+    if (0 == capacity) _CFDictionarySetCapacity(hc, numValues);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+#if CFDictionary
+        CFDictionaryAddValue(hc, list[idx], vlist[idx]);
+#endif
+#if CFSet || CFBag
+        CFDictionaryAddValue(hc, list[idx]);
+#endif
+    }
+    if (list != buffer) CFAllocatorDeallocate(allocator, list);
+#if CFDictionary
+    if (vlist != vbuffer) CFAllocatorDeallocate(allocator, vlist);
+#endif
+    return hc;
+}
+
+// Used by NSHashTables/NSMapTables and KVO
+void _CFDictionarySetContext(CFHashRef hc, any_pointer_t context) {
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    CF_WRITE_BARRIER_BASE_ASSIGN(__CFGetAllocator(hc), hc, hc->_context, context);
+}
+
+any_pointer_t _CFDictionaryGetContext(CFHashRef hc) {
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    return hc->_context;
+}
+
+CFIndex CFDictionaryGetCount(CFHashRef hc) {
+    if (CFDictionary || CFSet) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, CFIndex, hc, "count");
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    return hc->_count;
+}
+
+#if CFDictionary
+CFIndex CFDictionaryGetCountOfKey(CFHashRef hc, const_any_pointer_t key) {
+#endif
+#if CFSet || CFBag
+CFIndex CFDictionaryGetCountOfValue(CFHashRef hc, const_any_pointer_t key) {
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    CFIndex match = __CFDictionaryFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? __CFHashGetOccurrenceCount(hc, match) : 0);
+}
+
+#if CFDictionary
+Boolean CFDictionaryContainsKey(CFHashRef hc, const_any_pointer_t key) {
+#endif
+#if CFSet || CFBag
+Boolean CFDictionaryContainsValue(CFHashRef hc, const_any_pointer_t key) {
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFDictionaryFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? true : false);
+}
+
+#if CFDictionary
+CFIndex CFDictionaryGetCountOfValue(CFHashRef hc, const_any_pointer_t value) {
+    CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForObject:", value);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    any_t *keys = hc->_keys;
+    Boolean (*equal)(any_t, any_t, any_pointer_t) = (Boolean (*)(any_t, any_t, any_pointer_t))__CFDictionaryGetValueCallBacks(hc)->equal;
+    CFIndex cnt = 0;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            if ((hc->_values[idx] == (any_t)value) || (equal && INVOKE_CALLBACK3(equal, hc->_values[idx], (any_t)value, hc->_context))) {
+                cnt++;
+            }
+        }
+    }
+    return cnt;
+}
+
+Boolean CFDictionaryContainsValue(CFHashRef hc, const_any_pointer_t value) {
+    CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsObject:", value);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    any_t *keys = hc->_keys;
+    Boolean (*equal)(any_t, any_t, any_pointer_t) = (Boolean (*)(any_t, any_t, any_pointer_t))__CFDictionaryGetValueCallBacks(hc)->equal;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            if ((hc->_values[idx] == (any_t)value) || (equal && INVOKE_CALLBACK3(equal, hc->_values[idx], (any_t)value, hc->_context))) {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+#endif
+
+const_any_pointer_t CFDictionaryGetValue(CFHashRef hc, const_any_pointer_t key) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, const_any_pointer_t, hc, "objectForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, const_any_pointer_t, hc, "member:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    CFIndex match = __CFDictionaryFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? (const_any_pointer_t)(CFDictionary ? hc->_values[match] : hc->_keys[match]) : 0);
+}
+
+Boolean CFDictionaryGetValueIfPresent(CFHashRef hc, const_any_pointer_t key, const_any_pointer_t *value) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "_getValue:forKey:", (any_t *)value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "_getValue:forObj:", (any_t *)value, key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFDictionaryFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? ((value ? __CFObjCStrongAssign((const_any_pointer_t)(CFDictionary ? hc->_values[match] : hc->_keys[match]), value) : 0), true) : false);
+}
+
+#if CFDictionary
+Boolean CFDictionaryGetKeyIfPresent(CFHashRef hc, const_any_pointer_t key, const_any_pointer_t *actualkey) {
+    CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "getActualKey:forKey:", actualkey, key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFDictionaryFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? ((actualkey ? __CFObjCStrongAssign((const_any_pointer_t)hc->_keys[match], actualkey) : NULL), true) : false);
+}
+#endif
+
+#if CFDictionary
+void CFDictionaryGetKeysAndValues(CFHashRef hc, const_any_pointer_t *keybuf, const_any_pointer_t *valuebuf) {
+#endif
+#if CFSet || CFBag
+void CFDictionaryGetValues(CFHashRef hc, const_any_pointer_t *keybuf) {
+    const_any_pointer_t *valuebuf = 0;
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "getObjects:andKeys:", (any_t *)valuebuf, (any_t *)keybuf);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "getObjects:", (any_t *)keybuf);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (CF_USING_COLLECTABLE_MEMORY) {
+        // GC: speculatively issue a write-barrier on the copied to buffers
+        __CFObjCWriteBarrierRange(keybuf, hc->_count * sizeof(any_t));
+        __CFObjCWriteBarrierRange(valuebuf, hc->_count * sizeof(any_t));
+    }
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            for (CFIndex cnt = __CFHashGetOccurrenceCount(hc, idx); cnt--;) {
+                if (keybuf) *keybuf++ = (const_any_pointer_t)keys[idx];
+                if (valuebuf) *valuebuf++ = (const_any_pointer_t)hc->_values[idx];
+            }
+        }
+    }
+}
+
+#if CFDictionary || CFSet
+unsigned long _CFDictionaryFastEnumeration(CFHashRef hc, struct __objcFastEnumerationStateEquivalent *state, void *stackbuffer, unsigned long count) {
+    /* copy as many as count items over */
+    if (0 == state->state) {        /* first time */
+        state->mutationsPtr = (unsigned long *)&hc->_mutations;
+    }
+    state->itemsPtr = (unsigned long *)stackbuffer;
+    CFIndex cnt = 0;
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = (CFIndex)state->state, nbuckets = hc->_bucketsNum; idx < nbuckets && cnt < (CFIndex)count; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            state->itemsPtr[cnt++] = (unsigned long)keys[idx];
+        }
+        state->state++;
+    }
+    return cnt;
+}
+#endif
+
+void CFDictionaryApplyFunction(CFHashRef hc, CFDictionaryApplierFunction applier, any_pointer_t context) {
+    FAULT_CALLBACK((void **)&(applier));
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_apply:context:", applier, context);
+    if (CFSet) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_applyValues:context:", applier, context);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            for (CFIndex cnt = __CFHashGetOccurrenceCount(hc, idx); cnt--;) {
+#if CFDictionary
+                INVOKE_CALLBACK3(applier, (const_any_pointer_t)keys[idx], (const_any_pointer_t)hc->_values[idx], context);
+#endif
+#if CFSet || CFBag
+                INVOKE_CALLBACK2(applier, (const_any_pointer_t)keys[idx], context);
+#endif
+            }
+        }
+    }
+}
+
+static void __CFDictionaryGrow(CFMutableHashRef hc, CFIndex numNewValues) {
+    any_t *oldkeys = hc->_keys;
+    any_t *oldvalues = hc->_values;
+    CFIndex nbuckets = hc->_bucketsNum;
+    hc->_bucketsCap = __CFHashRoundUpCapacity(hc->_bucketsUsed + numNewValues);
+    hc->_bucketsNum = __CFHashNumBucketsForCapacity(hc->_bucketsCap);
+    hc->_deletes = 0;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    CFOptionFlags weakOrStrong = (hc->_xflags & __kCFHashWeakKeys) ? 0 : __kCFAllocatorGCScannedMemory;
+    any_t *mem = (any_t *)_CFAllocatorAllocateGC(allocator, hc->_bucketsNum * sizeof(any_t), weakOrStrong);
+    if (NULL == mem) __CFDictionaryHandleOutOfMemory(hc, hc->_bucketsNum * sizeof(any_t));
+    if (__CFOASafe) __CFSetLastAllocationEventName(mem, "CFDictionary (key-store)");
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, hc, hc->_keys, mem);
+    CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;  // GC: avoids write-barrier in weak case.
+    any_t *keysBase = mem;
+#if CFDictionary || CFBag
+    weakOrStrong = (hc->_xflags & __kCFHashWeakValues) ? 0 : __kCFAllocatorGCScannedMemory;
+    mem = (any_t *)_CFAllocatorAllocateGC(allocator, hc->_bucketsNum * sizeof(any_t), weakOrStrong);
+    if (NULL == mem) __CFDictionaryHandleOutOfMemory(hc, hc->_bucketsNum * sizeof(any_t));
+    if (__CFOASafe) __CFSetLastAllocationEventName(mem, "CFDictionary (value-store)");
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, hc, hc->_values, mem);
+#endif
+#if CFDictionary
+    CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator; // GC: avoids write-barrier in weak case.
+    any_t *valuesBase = mem;
+#endif
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        hc->_keys[idx] = hc->_marker;
+#if CFDictionary || CFBag
+        hc->_values[idx] = 0;
+#endif
+    }
+    if (NULL == oldkeys) return;
+    for (CFIndex idx = 0; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, oldkeys[idx])) {
+            CFIndex match, nomatch;
+            __CFDictionaryFindBuckets2(hc, oldkeys[idx], &match, &nomatch);
+            CFAssert3(kCFNotFound == match, __kCFLogAssertion, "%s(): two values (%p, %p) now hash to the same slot; mutable value changed while in table or hash value is not immutable", __PRETTY_FUNCTION__, oldkeys[idx], hc->_keys[match]);
+            if (kCFNotFound != nomatch) {
+                CF_WRITE_BARRIER_BASE_ASSIGN(keysAllocator, keysBase, hc->_keys[nomatch], oldkeys[idx]);
+#if CFDictionary
+                CF_WRITE_BARRIER_BASE_ASSIGN(valuesAllocator, valuesBase, hc->_values[nomatch], oldvalues[idx]);
+#endif
+#if CFBag
+                hc->_values[nomatch] = oldvalues[idx];
+#endif
+            }
+        }
+    }
+    _CFAllocatorDeallocateGC(allocator, oldkeys);
+    _CFAllocatorDeallocateGC(allocator, oldvalues);
+}
+
+// This function is for Foundation's benefit; no one else should use it.
+void _CFDictionarySetCapacity(CFMutableHashRef hc, CFIndex cap) {
+    if (CF_IS_OBJC(__kCFHashTypeID, hc)) return;
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    CFAssert1(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): collection is immutable", __PRETTY_FUNCTION__);
+    CFAssert3(hc->_bucketsUsed <= cap, __kCFLogAssertion, "%s(): desired capacity (%ld) is less than bucket count (%ld)", __PRETTY_FUNCTION__, cap, hc->_bucketsUsed);
+    __CFDictionaryGrow(hc, cap - hc->_bucketsUsed);
+}
+
+// This function is for Foundation's benefit; no one else should use it.
+bool _CFDictionaryIsMutable(CFDictionaryRef dict) {
+    return (__CFHashGetType(dict) != __kCFHashImmutable);
+}
+
+#if CFDictionary
+void CFDictionaryAddValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFDictionaryAddValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_addObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "addObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        if (hc->_bucketsUsed == hc->_bucketsCap || NULL == hc->_keys) {
+            __CFDictionaryGrow(hc, 1);
+        }
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    CFIndex match, nomatch;
+    __CFDictionaryFindBuckets2(hc, (any_t)key, &match, &nomatch);
+    if (kCFNotFound != match) {
+#if CFBag
+        CF_OBJC_KVO_WILLCHANGE(hc, hc->_keys[match]);
+        hc->_values[match]++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, hc->_keys[match]);
+#endif
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        GETNEWKEY(newKey, key);
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFDictionaryFindNewMarker(hc);
+        }
+        if (hc->_keys[nomatch] == ~hc->_marker) {
+            hc->_deletes--;
+        }
+        CF_OBJC_KVO_WILLCHANGE(hc, key);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+        hc->_values[nomatch] = 1;
+#endif
+        hc->_bucketsUsed++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, key);
+    }
+}
+
+#if CFDictionary
+void CFDictionaryReplaceValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFDictionaryReplaceValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_replaceObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "_replaceObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFIndex match = __CFDictionaryFindBuckets1(hc, (any_t)key);
+    if (kCFNotFound == match) return;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+    GETNEWKEY(newKey, key);
+#endif
+#if CFDictionary
+    GETNEWVALUE(newValue);
+#endif
+    any_t oldKey = hc->_keys[match];
+    CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFSet || CFBag
+    CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+    CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+    if (__CFHashKeyIsMagic(hc, newKey)) {
+        __CFDictionaryFindNewMarker(hc);
+    }
+    CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+#endif
+#if CFDictionary
+    any_t oldValue = hc->_values[match];
+    CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+    CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+#endif
+    CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+#if CFSet || CFBag
+    RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+    RELEASEVALUE(oldValue);
+#endif
+}
+
+#if CFDictionary
+void CFDictionarySetValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFDictionarySetValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "setObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "_setObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        if (hc->_bucketsUsed == hc->_bucketsCap || NULL == hc->_keys) {
+            __CFDictionaryGrow(hc, 1);
+        }
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    CFIndex match, nomatch;
+    __CFDictionaryFindBuckets2(hc, (any_t)key, &match, &nomatch);
+    if (kCFNotFound == match) {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        GETNEWKEY(newKey, key);
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFDictionaryFindNewMarker(hc);
+        }
+        if (hc->_keys[nomatch] == ~hc->_marker) {
+            hc->_deletes--;
+        }
+        CF_OBJC_KVO_WILLCHANGE(hc, key);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+        hc->_values[nomatch] = 1;
+#endif
+        hc->_bucketsUsed++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, key);
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+        GETNEWKEY(newKey, key);
+#endif
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        any_t oldKey = hc->_keys[match];
+        CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFSet || CFBag
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFDictionaryFindNewMarker(hc);
+        }
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+#endif
+#if CFDictionary
+        any_t oldValue = hc->_values[match];
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+#endif
+        CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+#if CFSet || CFBag
+        RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+        RELEASEVALUE(oldValue);
+#endif
+    }
+}
+
+void CFDictionaryRemoveValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "removeObjectForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "removeObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFIndex match = __CFDictionaryFindBuckets1(hc, (any_t)key);
+    if (kCFNotFound == match) return;
+    if (1 < __CFHashGetOccurrenceCount(hc, match)) {
+#if CFBag
+        CF_OBJC_KVO_WILLCHANGE(hc, hc->_keys[match]);
+        hc->_values[match]--;
+        hc->_count--;
+        CF_OBJC_KVO_DIDCHANGE(hc, hc->_keys[match]);
+#endif
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        any_t oldKey = hc->_keys[match];
+        CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+#if CFDictionary
+        any_t oldValue = hc->_values[match];
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], 0);
+#endif
+#if CFBag
+        hc->_values[match] = 0;
+#endif
+        hc->_count--;
+        hc->_bucketsUsed--;
+        hc->_deletes++;
+        CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+        RELEASEKEY(oldKey);
+#if CFDictionary
+        RELEASEVALUE(oldValue);
+#endif
+        if (__CFDictionaryShouldShrink(hc)) {
+            __CFDictionaryGrow(hc, 0);
+        } else {
+            // When the probeskip == 1 always and only, a DELETED slot followed by an EMPTY slot
+            // can be converted to an EMPTY slot.  By extension, a chain of DELETED slots followed
+            // by an EMPTY slot can be converted to EMPTY slots, which is what we do here.
+            if (match < hc->_bucketsNum - 1 && hc->_keys[match + 1] == hc->_marker) {
+                while (0 <= match && hc->_keys[match] == ~hc->_marker) {
+                    hc->_keys[match] = hc->_marker;
+                    hc->_deletes--;
+                    match--;
+                }
+            }
+        }
+    }
+}
+
+void CFDictionaryRemoveAllValues(CFMutableHashRef hc) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, void, hc, "removeAllObjects");
+    if (CFSet) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, void, hc, "removeAllObjects");
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            any_t oldKey = keys[idx];
+            CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFDictionary || CFSet
+            hc->_count--;
+#endif
+#if CFBag
+            hc->_count -= hc->_values[idx];
+#endif
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[idx], ~hc->_marker);
+#if CFDictionary
+            any_t oldValue = hc->_values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[idx], 0);
+#endif
+#if CFBag
+            hc->_values[idx] = 0;
+#endif
+            hc->_bucketsUsed--;
+            hc->_deletes++;
+            CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+            RELEASEKEY(oldKey);
+#if CFDictionary
+            RELEASEVALUE(oldValue);
+#endif
+        }
+    }
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        keys[idx] = hc->_marker;
+    }
+    hc->_deletes = 0;
+    hc->_bucketsUsed = 0;
+    hc->_count = 0;
+    if (__CFDictionaryShouldShrink(hc) && (256 <= hc->_bucketsCap)) {
+        __CFDictionaryGrow(hc, 128);
+    }
+}
+
+#undef CF_OBJC_KVO_WILLCHANGE
+#undef CF_OBJC_KVO_DIDCHANGE
+
diff --git a/CoreFoundation/CFDictionary.h b/CoreFoundation/CFDictionary.h
new file mode 100644
index 0000000..071871b
--- /dev/null
+++ b/CoreFoundation/CFDictionary.h
@@ -0,0 +1,699 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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(lg 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*lg 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 <CoreFoundation/CFBase.h>
+
+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 __CFDictionary * CFDictionaryRef;
+
+/*!
+	@typedef CFMutableDictionaryRef
+	This is the type of a reference to mutable CFDictionarys.
+*/
+typedef struct __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
+
+#endif /* ! __COREFOUNDATION_CFDICTIONARY__ */
+
diff --git a/CoreFoundation/CFError.c b/CoreFoundation/CFError.c
new file mode 100644
index 0000000..fec7c16
--- /dev/null
+++ b/CoreFoundation/CFError.c
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 2006, Apple, Inc. All rights reserved.
+	Responsibility: Ali Ozer
+*/
+
+#include <CoreFoundation/CFError.h>
+#include <CoreFoundation/CFError_Private.h>
+#include "CFInternal.h"
+#include "CFPriv.h"
+#if DEPLOYMENT_TARGET_MACOSX
+#include <objc/runtime.h>
+#include <mach/mach_error.h>
+#endif
+
+/* Pre-defined userInfo keys
+*/
+CONST_STRING_DECL(kCFErrorLocalizedDescriptionKey,          "NSLocalizedDescription");
+CONST_STRING_DECL(kCFErrorLocalizedFailureReasonKey,        "NSLocalizedFailureReason");
+CONST_STRING_DECL(kCFErrorLocalizedRecoverySuggestionKey,   "NSLocalizedRecoverySuggestion");
+CONST_STRING_DECL(kCFErrorDescriptionKey,                   "NSDescription");
+CONST_STRING_DECL(kCFErrorDebugDescriptionKey,              "NSDebugDescription");
+CONST_STRING_DECL(kCFErrorUnderlyingErrorKey,               "NSUnderlyingError");
+
+/* Pre-defined error domains
+*/
+CONST_STRING_DECL(kCFErrorDomainPOSIX,              "NSPOSIXErrorDomain");
+CONST_STRING_DECL(kCFErrorDomainOSStatus,           "NSOSStatusErrorDomain");
+CONST_STRING_DECL(kCFErrorDomainMach,               "NSMachErrorDomain");
+CONST_STRING_DECL(kCFErrorDomainCocoa,              "NSCocoaErrorDomain");
+
+/* We put the localized names of domain names here so genstrings can pick them out.  Any additional domains that are added should be listed here if we'd like them localized.
+
+CFCopyLocalizedStringWithDefaultValue(CFSTR("NSMachErrorDomain"), CFSTR("Error"), NULL, CFSTR("Mach"), "Name of the 'Mach' error domain when showing to user. This probably will not get localized, unless there is a generally recognized phrase for 'Mach' in the language.")
+CFCopyLocalizedStringWithDefaultValue(CFSTR("NSCoreFoundationErrorDomain"), CFSTR("Error"), NULL, CFSTR("Core Foundation"), "Name of the 'Core Foundation' error domain when showing to user. Very likely this will not get localized differently in other languages.")
+CFCopyLocalizedStringWithDefaultValue(CFSTR("NSPOSIXErrorDomain"), CFSTR("Error"), NULL, CFSTR("POSIX"), "Name of the 'POSIX' error domain when showing to user. This probably will not get localized, unless there is a generally recognized phrase for 'POSIX' in the language.")
+CFCopyLocalizedStringWithDefaultValue(CFSTR("NSOSStatusErrorDomain"), CFSTR("Error"), NULL, CFSTR("OSStatus"), "Name of the 'OSStatus' error domain when showing to user. Very likely this will not get localized.")
+CFCopyLocalizedStringWithDefaultValue(CFSTR("NSCocoaErrorDomain"), CFSTR("Error"), NULL, CFSTR("Cocoa"), "Name of the 'Cocoa' error domain when showing to user. Very likely this will not get localized.")
+*/
+
+
+
+/* Forward declarations
+*/
+static CFDictionaryRef _CFErrorGetUserInfo(CFErrorRef err);
+static CFStringRef _CFErrorCopyUserInfoKey(CFErrorRef err, CFStringRef key);
+static CFDictionaryRef _CFErrorCreateEmptyDictionary(CFAllocatorRef allocator);
+
+/* Assertions and other macros/inlines
+*/
+#define __CFAssertIsError(cf) __CFGenericValidateType(cf, __kCFErrorTypeID)
+
+/* This lock is used in the few places in CFError where we create and access shared static objects. Should only be around tiny snippets of code; no recursion
+*/
+static CFSpinLock_t _CFErrorSpinlock = CFSpinLockInit;
+
+
+
+
+/**** CFError CF runtime stuff ****/
+
+struct __CFError {		// Potentially interesting to keep layout same as NSError (but currently not a requirement)
+    CFRuntimeBase _base;
+    CFIndex code;
+    CFStringRef domain;		// !!! Could compress well-known domains down to few bits, but probably not worth its weight in code since CFErrors are rare
+    CFDictionaryRef userInfo;	// !!! Could avoid allocating this slot if userInfo is NULL, but probably not worth its weight in code since CFErrors are rare
+};
+
+/* CFError equal checks for equality of domain, code, and userInfo. 
+*/
+static Boolean __CFErrorEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFErrorRef err1 = (CFErrorRef)cf1;
+    CFErrorRef err2 = (CFErrorRef)cf2;
+    
+    // First do quick checks of code and domain (in that order for performance)
+    if (CFErrorGetCode(err1) != CFErrorGetCode(err2)) return false;
+    if (!CFEqual(CFErrorGetDomain(err1), CFErrorGetDomain(err2))) return false;
+
+    // If those are equal, then check the dictionaries
+    CFDictionaryRef dict1 = CFErrorCopyUserInfo(err1);
+    CFDictionaryRef dict2 = CFErrorCopyUserInfo(err2);
+
+    Boolean result = false;
+    
+    if (dict1 == dict2) {
+        result = true;
+    } else if (dict1 && dict2 && CFEqual(dict1, dict2)) {
+        result = true;
+    }
+    
+    if (dict1) CFRelease(dict1);
+    if (dict2) CFRelease(dict2);
+    
+    return result;
+}
+
+/* CFError hash code is hash(domain) + code
+*/
+static CFHashCode __CFErrorHash(CFTypeRef cf) {
+    CFErrorRef err = (CFErrorRef)cf;
+    /* !!! We do not need an assertion here, as this is called by the CFBase runtime only */
+    return CFHash(err->domain) + err->code;
+}
+
+/* This is the full debug description. Shows the description (possibly localized), plus the domain, code, and userInfo explicitly. If there is a debug description, shows that as well. 
+*/
+static CFStringRef __CFErrorCopyDescription(CFTypeRef cf) {
+    return _CFErrorCreateDebugDescription((CFErrorRef)cf);
+}
+
+/* This is the description you get for %@; we tone it down a bit from what you get in __CFErrorCopyDescription().
+*/
+static CFStringRef __CFErrorCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    CFErrorRef err = (CFErrorRef)cf;
+    return CFErrorCopyDescription(err);     // No need to release, since we are returning from a Copy function
+}
+
+static void __CFErrorDeallocate(CFTypeRef cf) {
+    CFErrorRef err = (CFErrorRef)cf;
+    CFRelease(err->domain);
+    CFRelease(err->userInfo);
+}
+
+
+static CFTypeID __kCFErrorTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFErrorClass = {
+    0,
+    "CFError",
+    NULL,      // init
+    NULL,      // copy
+    __CFErrorDeallocate,
+    __CFErrorEqual,
+    __CFErrorHash,
+    __CFErrorCopyFormattingDescription,
+    __CFErrorCopyDescription
+};
+
+__private_extern__ void __CFErrorInitialize(void) {
+    __kCFErrorTypeID = _CFRuntimeRegisterClass(&__CFErrorClass);
+}
+
+CFTypeID CFErrorGetTypeID(void) {
+    return __kCFErrorTypeID;
+}
+
+
+
+
+/**** CFError support functions ****/
+
+/* Returns a shared empty dictionary (unless the allocator is not kCFAllocatorSystemDefault, in which case returns a newly allocated one).
+*/
+static CFDictionaryRef _CFErrorCreateEmptyDictionary(CFAllocatorRef allocator) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    if (allocator == kCFAllocatorSystemDefault) {
+        static CFDictionaryRef emptyErrorDictionary = NULL;
+        if (emptyErrorDictionary == NULL) {
+            CFDictionaryRef tmp = CFDictionaryCreate(allocator, NULL, NULL, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+            __CFSpinLock(&_CFErrorSpinlock);
+            if (emptyErrorDictionary == NULL) {
+                emptyErrorDictionary = tmp;
+                __CFSpinUnlock(&_CFErrorSpinlock);
+            } else {
+                __CFSpinUnlock(&_CFErrorSpinlock);
+                CFRelease(tmp);
+            }
+        }
+        return (CFDictionaryRef)CFRetain(emptyErrorDictionary);
+    } else {
+        return CFDictionaryCreate(allocator, NULL, NULL, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    }
+}
+
+/* A non-retained accessor for the userInfo. Might return NULL in some cases, if the subclass of NSError returned nil for some reason. It works with a CF or NSError.
+*/
+static CFDictionaryRef _CFErrorGetUserInfo(CFErrorRef err) {
+    CF_OBJC_FUNCDISPATCH0(__kCFErrorTypeID, CFDictionaryRef, err, "userInfo");
+    __CFAssertIsError(err);
+    return err->userInfo;
+}
+
+/* This function retrieves the value of the specified key from the userInfo, or from the callback. It works with a CF or NSError.
+*/
+static CFStringRef _CFErrorCopyUserInfoKey(CFErrorRef err, CFStringRef key) {
+    CFStringRef result = NULL;
+    // First consult the userInfo dictionary   
+    CFDictionaryRef userInfo = _CFErrorGetUserInfo(err);
+    if (userInfo) result = (CFStringRef)CFDictionaryGetValue(userInfo, key);
+    // If that doesn't work, consult the callback
+    if (result) {
+        CFRetain(result);
+    } else {
+        CFErrorUserInfoKeyCallBack callBack = CFErrorGetCallBackForDomain(CFErrorGetDomain(err));
+        if (callBack) result = (CFStringRef)callBack(err, key);
+    }
+    return result;
+}
+
+/* The real guts of the description creation functionality. See the header file for the steps this function goes through to compute the description. This function can take a CF or NSError. It's called by NSError for the localizedDescription computation.
+*/
+CFStringRef _CFErrorCreateLocalizedDescription(CFErrorRef err) {
+    // First look for kCFErrorLocalizedDescriptionKey; if non-NULL, return that as-is.
+    CFStringRef localizedDesc = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedDescriptionKey);
+    if (localizedDesc) return localizedDesc;
+
+    // Cache the CF bundle since we will be using it for localized strings. !!! Might be good to check for NULL, although that indicates some serious problem.
+    CFBundleRef cfBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreFoundation"));
+
+    // Then look for kCFErrorLocalizedFailureReasonKey; if there, create a full sentence from that.
+    CFStringRef reason = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedFailureReasonKey);
+    if (reason) {
+	CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("Operation could not be completed. %@"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem. The %@ will be replaced by a second sentence which indicates why the operation failed.");
+        CFStringRef result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, reason);
+	CFRelease(operationFailedStr);
+        CFRelease(reason);
+	return result;
+    }
+
+    // Otherwise, generate a semi-user presentable string from the domain, code, and if available, the presumably non-localized kCFErrorDescriptionKey.
+    CFStringRef result;
+    CFStringRef desc = _CFErrorCopyUserInfoKey(err, kCFErrorDescriptionKey);
+    CFStringRef localizedDomain = CFCopyLocalizedStringFromTableInBundle(CFErrorGetDomain(err), CFSTR("Error"), cfBundle, "These are localized in the comment above");
+    if (desc) {     // We have kCFErrorDescriptionKey, so include that with the error domain and code
+	CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("Operation could not be completed. (%@ error %ld - %@)"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem, followed by a parenthetical sentence which indicates error domain, code, and a description when there is no other way to present an error to the user. The first %@ indicates the error domain, %ld indicates the error code, and the second %@ indicates the description; so this might become '(Mach error 42 - Server error.)' for instance.");
+	result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, localizedDomain, (long)CFErrorGetCode(err), desc);
+	CFRelease(operationFailedStr);
+        CFRelease(desc);
+    } else {        // We don't have kCFErrorDescriptionKey, so just use error domain and code
+	CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("Operation could not be completed. (%@ error %ld.)"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem, followed by a parenthetical sentence which indicates error domain and code when there is no other way to present an error to the user. The %@ indicates the error domain while %ld indicates the error code; so this might become '(Mach error 42.)' for instance.");
+	result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, localizedDomain, (long)CFErrorGetCode(err));
+	CFRelease(operationFailedStr);
+    }
+    CFRelease(localizedDomain);
+    return result;
+}
+
+/* The real guts of the failure reason creation functionality. This function can take a CF or NSError. It's called by NSError for the localizedFailureReason computation.
+*/
+CFStringRef _CFErrorCreateLocalizedFailureReason(CFErrorRef err) {
+    // We simply return the value of kCFErrorLocalizedFailureReasonKey; no other searching takes place
+    return _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedFailureReasonKey);
+}
+
+/* The real guts of the recovery suggestion functionality. This function can take a CF or NSError. It's called by NSError for the localizedRecoverySuggestion computation.
+*/
+CFStringRef _CFErrorCreateLocalizedRecoverySuggestion(CFErrorRef err) {
+    // We simply return the value of kCFErrorLocalizedRecoverySuggestionKey; no other searching takes place
+    return _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedRecoverySuggestionKey);
+}
+
+/* The "debug" description, used by CFCopyDescription and -[NSObject description].
+*/
+CFStringRef _CFErrorCreateDebugDescription(CFErrorRef err) {
+    CFStringRef desc = CFErrorCopyDescription(err);
+    CFStringRef debugDesc = _CFErrorCopyUserInfoKey(err, kCFErrorDebugDescriptionKey);
+    CFDictionaryRef userInfo = _CFErrorGetUserInfo(err);
+    CFMutableStringRef result = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+    CFStringAppendFormat(result, NULL, CFSTR("Error Domain=%@ Code=%d"), CFErrorGetDomain(err), (long)CFErrorGetCode(err));
+    if (userInfo) CFStringAppendFormat(result, NULL, CFSTR(" UserInfo=%p"), userInfo);
+    CFStringAppendFormat(result, NULL, CFSTR(" \"%@\""), desc);
+    if (debugDesc && CFStringGetLength(debugDesc) > 0) CFStringAppendFormat(result, NULL, CFSTR(" (%@)"), debugDesc);
+    if (debugDesc) CFRelease(debugDesc);
+    if (desc) CFRelease(desc);
+    return result;
+}
+
+
+
+
+/**** CFError API/SPI ****/
+
+/* Note that there are two entry points for creating CFErrors. This one does it with a presupplied userInfo dictionary.
+*/
+CFErrorRef CFErrorCreate(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, CFDictionaryRef userInfo) {
+    __CFGenericValidateType(domain, CFStringGetTypeID());
+    if (userInfo) __CFGenericValidateType(userInfo, CFDictionaryGetTypeID());
+
+    CFErrorRef err = (CFErrorRef)_CFRuntimeCreateInstance(allocator, __kCFErrorTypeID, sizeof(struct __CFError) - sizeof(CFRuntimeBase), NULL);
+    if (NULL == err) return NULL;
+
+    err->domain = CFStringCreateCopy(allocator, domain);
+    err->code = code;
+    err->userInfo = userInfo ? CFDictionaryCreateCopy(allocator, userInfo) : _CFErrorCreateEmptyDictionary(allocator);
+
+    return err;
+}
+
+/* Note that there are two entry points for creating CFErrors. This one does it with individual keys and values which are used to create the userInfo dictionary.
+*/
+CFErrorRef CFErrorCreateWithUserInfoKeysAndValues(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, const void *const *userInfoKeys, const void *const *userInfoValues, CFIndex numUserInfoValues) {
+    __CFGenericValidateType(domain, CFStringGetTypeID());
+
+    CFErrorRef err = (CFErrorRef)_CFRuntimeCreateInstance(allocator, __kCFErrorTypeID, sizeof(struct __CFError) - sizeof(CFRuntimeBase), NULL);
+    if (NULL == err) return NULL;
+
+    err->domain = CFStringCreateCopy(allocator, domain);
+    err->code = code;
+    err->userInfo = CFDictionaryCreate(allocator, (const void **)userInfoKeys, (const void **)userInfoValues, numUserInfoValues, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+    return err;
+}
+
+CFStringRef CFErrorGetDomain(CFErrorRef err) {
+    CF_OBJC_FUNCDISPATCH0(__kCFErrorTypeID, CFStringRef, err, "domain");
+    __CFAssertIsError(err);
+    return err->domain;
+}
+
+CFIndex CFErrorGetCode(CFErrorRef err) {
+    CF_OBJC_FUNCDISPATCH0(__kCFErrorTypeID, CFIndex, err, "code");
+    __CFAssertIsError(err);
+    return err->code;
+}
+
+/* This accessor never returns NULL. For usage inside this file, consider __CFErrorGetUserInfo().
+*/
+CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) {
+    CFDictionaryRef userInfo = _CFErrorGetUserInfo(err);
+    return userInfo ? (CFDictionaryRef)CFRetain(userInfo) : _CFErrorCreateEmptyDictionary(CFGetAllocator(err));
+}
+
+CFStringRef CFErrorCopyDescription(CFErrorRef err) {
+    if (CF_IS_OBJC(__kCFErrorTypeID, err)) {  // Since we have to return a retained result, we need to treat the toll-free bridging specially
+        CFStringRef desc;
+        CF_OBJC_CALL0(CFStringRef, desc, err, "localizedDescription");
+        return desc ? (CFStringRef)CFRetain(desc) : NULL;    // !!! It really should never return nil.
+    }
+    __CFAssertIsError(err);
+    return _CFErrorCreateLocalizedDescription(err);
+}
+
+CFStringRef CFErrorCopyFailureReason(CFErrorRef err) {
+    if (CF_IS_OBJC(__kCFErrorTypeID, err)) {  // Since we have to return a retained result, we need to treat the toll-free bridging specially
+        CFStringRef str;
+        CF_OBJC_CALL0(CFStringRef, str, err, "localizedFailureReason");
+        return str ? (CFStringRef)CFRetain(str) : NULL;    // It's possible for localizedFailureReason to return nil
+    }
+    __CFAssertIsError(err);
+    return _CFErrorCreateLocalizedFailureReason(err);
+}
+
+CFStringRef CFErrorCopyRecoverySuggestion(CFErrorRef err) {
+    if (CF_IS_OBJC(__kCFErrorTypeID, err)) {  // Since we have to return a retained result, we need to treat the toll-free bridging specially
+        CFStringRef str;
+        CF_OBJC_CALL0(CFStringRef, str, err, "localizedRecoverySuggestion");
+        return str ? (CFStringRef)CFRetain(str) : NULL;    // It's possible for localizedRecoverySuggestion to return nil
+    }
+    __CFAssertIsError(err);
+    return _CFErrorCreateLocalizedRecoverySuggestion(err);
+}
+
+
+/**** CFError CallBack management ****/
+
+/* Domain-to-callback mapping dictionary
+*/
+static CFMutableDictionaryRef _CFErrorCallBackTable = NULL;
+
+
+/* Built-in callback for POSIX domain. Note that we will pick up localizations from ErrnoErrors.strings in /System/Library/CoreServices/CoreTypes.bundle, if the file happens to be there.
+*/
+static CFTypeRef _CFErrorPOSIXCallBack(CFErrorRef err, CFStringRef key) {
+    if (!CFEqual(key, kCFErrorDescriptionKey) && !CFEqual(key, kCFErrorLocalizedFailureReasonKey)) return NULL;
+    
+    const char *errCStr = strerror(CFErrorGetCode(err));
+    CFStringRef errStr = (errCStr && strlen(errCStr)) ? CFStringCreateWithCString(kCFAllocatorSystemDefault, errCStr, kCFStringEncodingUTF8) : NULL;
+    
+    if (!errStr) return NULL;
+    if (CFEqual(key, kCFErrorDescriptionKey)) return errStr;	// If all we wanted was the non-localized description, we're done
+    
+    // We need a kCFErrorLocalizedFailureReasonKey, so look up a possible localization for the error message
+    // Look for the bundle in /System/Library/CoreServices/CoreTypes.bundle
+    CFArrayRef paths = CFCopySearchPathForDirectoriesInDomains(kCFLibraryDirectory, kCFSystemDomainMask, false);
+    if (paths) {
+	if (CFArrayGetCount(paths) > 0) {
+	    CFStringRef path = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%@/CoreServices/CoreTypes.bundle"), CFArrayGetValueAtIndex(paths, 0));
+	    CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, path, kCFURLPOSIXPathStyle, false /* not a directory */);
+	    if (url) {
+		CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, url);
+		if (bundle) {
+		    // We only want to return a result if there was a localization
+		    CFStringRef localizedErrStr = CFBundleCopyLocalizedString(bundle, errStr, errStr, CFSTR("ErrnoErrors"));
+		    if (localizedErrStr == errStr) {
+			CFRelease(localizedErrStr);
+			CFRelease(errStr);
+			errStr = NULL;
+		    } else {
+			CFRelease(errStr);
+			errStr = localizedErrStr;
+		    }
+		    CFRelease(bundle);
+		}
+		CFRelease(url);
+	    }
+	    CFRelease(path);
+	}
+	CFRelease(paths);
+    }
+    
+    return errStr;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX
+/* Built-in callback for Mach domain.
+*/
+static CFTypeRef _CFErrorMachCallBack(CFErrorRef err, CFStringRef key) {
+    if (CFEqual(key, kCFErrorDescriptionKey)) {
+        const char *errStr = mach_error_string(CFErrorGetCode(err));
+        if (errStr && strlen(errStr)) return CFStringCreateWithCString(kCFAllocatorSystemDefault, errStr, kCFStringEncodingUTF8);
+    }
+    return NULL;
+}
+#endif
+
+
+/* This initialize function is meant to be called lazily, the first time a callback is registered or requested. It creates the table and registers the built-in callbacks. Clearly doing this non-lazily in _CFErrorInitialize() would be simpler, but this is a fine example of something that should not have to happen at launch time.
+*/
+static void _CFErrorInitializeCallBackTable(void) {
+    // Create the table outside the lock
+    CFMutableDictionaryRef table = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFCopyStringDictionaryKeyCallBacks, NULL);
+    __CFSpinLock(&_CFErrorSpinlock);
+    if (!_CFErrorCallBackTable) {
+        _CFErrorCallBackTable = table;
+        __CFSpinUnlock(&_CFErrorSpinlock);
+    } else {
+        __CFSpinUnlock(&_CFErrorSpinlock);
+        CFRelease(table);
+        // Note, even though the table looks like it was initialized, we go on to register the items on this thread as well, since otherwise we might consult the table before the items are actually registered.
+    }
+    CFErrorSetCallBackForDomain(kCFErrorDomainPOSIX, _CFErrorPOSIXCallBack);
+#if DEPLOYMENT_TARGET_MACOSX
+    CFErrorSetCallBackForDomain(kCFErrorDomainMach, _CFErrorMachCallBack);
+#endif
+}
+
+void CFErrorSetCallBackForDomain(CFStringRef domainName, CFErrorUserInfoKeyCallBack callBack) {
+    if (!_CFErrorCallBackTable) _CFErrorInitializeCallBackTable();
+    __CFSpinLock(&_CFErrorSpinlock);
+    if (callBack) {
+        CFDictionarySetValue(_CFErrorCallBackTable, domainName, (void*)callBack);
+    } else {
+        CFDictionaryRemoveValue(_CFErrorCallBackTable, domainName);
+    }
+    __CFSpinUnlock(&_CFErrorSpinlock);
+}
+
+CFErrorUserInfoKeyCallBack CFErrorGetCallBackForDomain(CFStringRef domainName) {
+    if (!_CFErrorCallBackTable) _CFErrorInitializeCallBackTable();
+    __CFSpinLock(&_CFErrorSpinlock);
+    CFErrorUserInfoKeyCallBack callBack = (CFErrorUserInfoKeyCallBack)CFDictionaryGetValue(_CFErrorCallBackTable, domainName);
+    __CFSpinUnlock(&_CFErrorSpinlock);
+    return callBack;
+}
+
+
+
diff --git a/CoreFoundation/CFError.h b/CoreFoundation/CFError.h
new file mode 100644
index 0000000..c494d91
--- /dev/null
+++ b/CoreFoundation/CFError.h
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFDictionary.h>
+
+CF_EXTERN_C_BEGIN
+
+/*!
+	@typedef CFErrorRef
+	    This is the type of a reference to CFErrors.  CFErrorRef is toll-free bridged with NSError.
+*/
+typedef struct __CFError * CFErrorRef;
+
+/*!
+	@function CFErrorGetTypeID
+	    Returns the type identifier of all CFError instances.
+*/
+CF_EXPORT
+CFTypeID CFErrorGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+
+// Predefined domains; value of "code" will correspond to preexisting values in these domains.
+CF_EXPORT const CFStringRef kCFErrorDomainPOSIX		    AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+CF_EXPORT const CFStringRef kCFErrorDomainOSStatus	    AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+CF_EXPORT const CFStringRef kCFErrorDomainMach		    AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+CF_EXPORT const CFStringRef kCFErrorDomainCocoa		    AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+// 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         AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;   // Key to identify the end user-presentable description in userInfo.
+CF_EXPORT const CFStringRef kCFErrorLocalizedFailureReasonKey       AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;   // Key to identify the end user-presentable failure reason in userInfo.
+CF_EXPORT const CFStringRef kCFErrorLocalizedRecoverySuggestionKey  AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;   // 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                  AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;   // 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              AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;   // Key to identify the underlying error in userInfo.
+
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*!
+	@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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFERROR__ */
+
diff --git a/CoreFoundation/CFError_Private.h b/CoreFoundation/CFError_Private.h
new file mode 100644
index 0000000..0454ad5
--- /dev/null
+++ b/CoreFoundation/CFError_Private.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+	
+	This is Apple-internal SPI for CFError.
+*/
+
+#if !defined(__COREFOUNDATION_CFERRORPRIVATE__)
+#define __COREFOUNDATION_CFERRORPRIVATE__ 1
+
+#include <CoreFoundation/CFError.h>
+
+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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+CF_EXPORT CFErrorUserInfoKeyCallBack CFErrorGetCallBackForDomain(CFStringRef domainName) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/* 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 kCFErrorDebugDescription AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFERRORPRIVATE__ */
+
diff --git a/CoreFoundation/CFFileUtilities.c b/CoreFoundation/CFFileUtilities.c
new file mode 100644
index 0000000..ae4bb62
--- /dev/null
+++ b/CoreFoundation/CFFileUtilities.c
@@ -0,0 +1,783 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFFileUtilities.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include "CFInternal.h"
+#include "CFPriv.h"
+#include <string.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <fcntl.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+/* In typical fragile fashion, order of include on Windows is important */
+#include <io.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <windows.h>
+#define lseek _lseek
+#define open _open
+#define read _read
+#define write _write
+#define close _close
+#endif
+#include <errno.h>
+#include <stdio.h>
+
+#if DEPLOYMENT_TARGET_WINDOWS
+    #define CF_OPENFLGS	(_O_BINARY|_O_NOINHERIT)
+#else
+    #define CF_OPENFLGS	(0)
+#endif
+
+
+__private_extern__ CFStringRef _CFCopyExtensionForAbstractType(CFStringRef abstractType) {
+    return (abstractType ? (CFStringRef)CFRetain(abstractType) : NULL);
+}
+
+
+__private_extern__ Boolean _CFCreateDirectory(const char *path) {
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+    return CreateDirectoryA(path, (LPSECURITY_ATTRIBUTES)NULL);
+#else
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+    int ret = ((mkdir(path, 0777) == 0) ? true : false);
+    close(no_hang_fd);
+    return ret;
+#endif
+}
+
+__private_extern__ Boolean _CFRemoveDirectory(const char *path) {
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+    return RemoveDirectoryA(path);
+#else
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+    int ret = ((rmdir(path) == 0) ? true : false);
+    close(no_hang_fd);
+    return ret;
+#endif
+}
+
+__private_extern__ Boolean _CFDeleteFile(const char *path) {
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+    return DeleteFileA(path);
+#else
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+    int ret = unlink(path) == 0;
+    close(no_hang_fd);
+    return ret;
+#endif
+}
+
+__private_extern__ Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef url, void **bytes, CFIndex *length, CFIndex maxLength) {
+    // maxLength is the number of bytes desired, or 0 if the whole file is desired regardless of length.
+    struct stat statBuf;
+    int fd = -1;
+    char path[CFMaxPathSize];
+    if (!CFURLGetFileSystemRepresentation(url, true, (uint8_t *)path, CFMaxPathSize)) {
+        return false;
+    }
+
+    *bytes = NULL;
+    
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+    fd = open(path, O_RDONLY|CF_OPENFLGS, 0666|_S_IREAD);
+#else
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+    fd = open(path, O_RDONLY|CF_OPENFLGS, 0666);
+#endif
+    if (fd < 0) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+        close(no_hang_fd);
+#endif
+        return false;
+    }
+    if (fstat(fd, &statBuf) < 0) {
+        int saveerr = thread_errno();
+        close(fd);
+#if !DEPLOYMENT_TARGET_WINDOWS
+        close(no_hang_fd);
+#endif
+        thread_set_errno(saveerr);
+        return false;
+    }
+    if ((statBuf.st_mode & S_IFMT) != S_IFREG) {
+        close(fd);
+#if !DEPLOYMENT_TARGET_WINDOWS
+        close(no_hang_fd);
+#endif
+        thread_set_errno(EACCES);
+        return false;
+    }
+    if (statBuf.st_size == 0) {
+        *bytes = CFAllocatorAllocate(alloc, 4, 0); // don't return constant string -- it's freed!
+	if (__CFOASafe) __CFSetLastAllocationEventName(*bytes, "CFUtilities (file-bytes)");
+        *length = 0;
+    } else {
+        CFIndex desiredLength;
+        if ((maxLength >= statBuf.st_size) || (maxLength == 0)) {
+            desiredLength = statBuf.st_size;
+        } else {
+            desiredLength = maxLength;
+        }
+        *bytes = CFAllocatorAllocate(alloc, desiredLength, 0);
+	if (__CFOASafe) __CFSetLastAllocationEventName(*bytes, "CFUtilities (file-bytes)");
+//	fcntl(fd, F_NOCACHE, 1);
+        if (read(fd, *bytes, desiredLength) < 0) {
+            CFAllocatorDeallocate(alloc, *bytes);
+            close(fd);
+#if !DEPLOYMENT_TARGET_WINDOWS
+            close(no_hang_fd);
+#endif
+            return false;
+        }
+        *length = desiredLength;
+    }
+    close(fd);
+#if !DEPLOYMENT_TARGET_WINDOWS
+    close(no_hang_fd);
+#endif
+    return true;
+}
+
+__private_extern__ Boolean _CFWriteBytesToFile(CFURLRef url, const void *bytes, CFIndex length) {
+    struct stat statBuf;
+    int fd = -1;
+    int mode;
+    char path[CFMaxPathSize];
+    if (!CFURLGetFileSystemRepresentation(url, true, (uint8_t *)path, CFMaxPathSize)) {
+        return false;
+    }
+
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+    mode = 0666;
+    if (0 == stat(path, &statBuf)) {
+        mode = statBuf.st_mode;
+    } else if (thread_errno() != ENOENT) {
+        return false;
+    }
+    fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, 0666|_S_IWRITE);
+    if (fd < 0) {
+        return false;
+    }
+    if (length && write(fd, bytes, length) != length) {
+        int saveerr = thread_errno();
+        close(fd);
+        thread_set_errno(saveerr);
+        return false;
+    }
+    FlushFileBuffers((HANDLE)_get_osfhandle(fd));
+    close(fd);
+#else
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+    mode = 0666;
+    if (0 == stat(path, &statBuf)) {
+        mode = statBuf.st_mode;
+    } else if (thread_errno() != ENOENT) {
+	close(no_hang_fd);
+        return false;
+    }
+    fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, 0666);
+    if (fd < 0) {
+	close(no_hang_fd);
+        return false;
+    }
+    if (length && write(fd, bytes, length) != length) {
+        int saveerr = thread_errno();
+        close(fd);
+	close(no_hang_fd);
+        thread_set_errno(saveerr);
+        return false;
+    }
+    fsync(fd);
+    close(fd);
+    close(no_hang_fd);
+#endif
+    return true;
+}
+
+
+/* On Mac OS 8/9, one of dirSpec 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.  */
+/* Lately, dirSpec appears to be (rightfully) unused. */
+__private_extern__ CFMutableArrayRef _CFContentsOfDirectory(CFAllocatorRef alloc, char *dirPath, void *dirSpec, CFURLRef dirURL, CFStringRef matchingAbstractType) {
+    CFMutableArrayRef files = NULL;
+    Boolean releaseBase = false;
+    CFIndex pathLength = dirPath ? (CFIndex)strlen(dirPath) : 0;
+    // MF:!!! Need to use four-letter type codes where appropriate.
+    CFStringRef extension = (matchingAbstractType ? _CFCopyExtensionForAbstractType(matchingAbstractType) : NULL);
+    CFIndex extLen = (extension ? CFStringGetLength(extension) : 0);
+    uint8_t extBuff[CFMaxPathSize];
+    
+    if (extLen > 0) {
+        CFStringGetBytes(extension, CFRangeMake(0, extLen), CFStringFileSystemEncoding(), 0, false, extBuff, CFMaxPathLength, &extLen);
+        extBuff[extLen] = '\0';
+    }
+
+    uint8_t pathBuf[CFMaxPathSize];
+
+    if (!dirPath) {
+        if (!CFURLGetFileSystemRepresentation(dirURL, true, pathBuf, CFMaxPathLength)) {
+            if (extension) CFRelease(extension);
+            return NULL;
+        } else {
+            dirPath = (char *)pathBuf;
+            pathLength = (CFIndex)strlen(dirPath);
+        }
+    }
+    
+#if (DEPLOYMENT_TARGET_MACOSX) || defined(__svr4__) || defined(__hpux__) || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    struct dirent buffer;
+    struct dirent *dp;
+    int err;
+   
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+ 
+    DIR *dirp = opendir(dirPath);
+    if (!dirp) {
+        if (extension) {
+            CFRelease(extension);
+        }
+        close(no_hang_fd);
+        return NULL;
+        // raiseErrno("opendir", path);
+    }
+    files = CFArrayCreateMutable(alloc, 0, & kCFTypeArrayCallBacks);
+
+    while((0 == readdir_r(dirp, &buffer, &dp)) && dp) {
+        CFURLRef fileURL;
+        unsigned namelen = strlen(dp->d_name);
+
+        // skip . & ..; they cause descenders to go berserk
+        if (dp->d_name[0] == '.' && (namelen == 1 || (namelen == 2 && dp->d_name[1] == '.'))) {
+            continue;
+        }
+        
+        if (extLen > namelen) continue;    // if the extension is the same length or longer than the name, it can't possibly match.
+        
+        if (extLen > 0) {
+            // Check to see if it matches the extension we're looking for.
+            if (strncmp(&(dp->d_name[namelen - extLen]), (char *)extBuff, extLen) != 0) {
+                continue;
+            }
+        }
+        if (dirURL == NULL) {
+            dirURL = CFURLCreateFromFileSystemRepresentation(alloc, (uint8_t *)dirPath, pathLength, true);
+            releaseBase = true;
+        }
+        if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) {
+            Boolean isDir = (dp->d_type == DT_DIR);
+            if (!isDir) {
+                // Ugh; must stat.
+                char subdirPath[CFMaxPathLength];
+                struct stat statBuf;
+                strlcpy(subdirPath, dirPath, sizeof(subdirPath));
+                strlcat(subdirPath, "/", sizeof(subdirPath));
+                strlcat(subdirPath, dp->d_name, sizeof(subdirPath));
+                if (stat(subdirPath, &statBuf) == 0) {
+                    isDir = ((statBuf.st_mode & S_IFMT) == S_IFDIR);
+                }
+            }
+            fileURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(alloc, (uint8_t *)dp->d_name, namelen, isDir, dirURL);
+        } else {
+            fileURL = CFURLCreateFromFileSystemRepresentationRelativeToBase (alloc, (uint8_t *)dp->d_name, namelen, false, dirURL);
+        }
+        CFArrayAppendValue(files, fileURL);
+        CFRelease(fileURL);
+    }
+    err = closedir(dirp);
+    close(no_hang_fd);
+    if (err != 0) {
+        CFRelease(files);
+        if (releaseBase) {
+            CFRelease(dirURL);
+        }
+        if (extension) {
+            CFRelease(extension);
+        }
+        return NULL;
+    }
+
+#elif DEPLOYMENT_TARGET_WINDOWS
+
+    WIN32_FIND_DATAA file;
+    HANDLE handle;
+
+    if (pathLength + 2 >= CFMaxPathLength) {
+        if (extension) {
+            CFRelease(extension);
+        }
+        return NULL;
+    }
+    if (NULL != dirPath) {
+        dirPath[pathLength] = '\'';
+        dirPath[pathLength + 1] = '*';
+        dirPath[pathLength + 2] = '\0';
+        handle = FindFirstFileA(dirPath, &file);
+        if (INVALID_HANDLE_VALUE == handle) {
+            dirPath[pathLength] = '\0';
+            if (extension) {
+                CFRelease(extension);
+            }
+            return NULL;
+        }
+    } else {
+        pathLength = 0;
+    }
+    files = CFArrayCreateMutable(alloc, 0, &kCFTypeArrayCallBacks);
+
+    do {
+        CFURLRef fileURL;
+        CFIndex namelen = (CFIndex)strlen(file.cFileName);
+        if (file.cFileName[0] == '.' && (namelen == 1 || (namelen == 2  && file.cFileName[1] == '.'))) {
+            continue;
+        }
+        if (extLen > 0) {
+            // Check to see if it matches the extension we're looking for.
+            if (_stricmp((char*)&(file.cFileName[namelen - extLen]), (char*)extBuff) != 0) {
+                continue;
+            }
+        }
+	if (dirURL == NULL) {
+	    dirURL = CFURLCreateFromFileSystemRepresentation(alloc, (UInt8*)dirPath, pathLength, true);
+            releaseBase = true;
+        }
+        // MF:!!! What about the trailing slash?
+        fileURL = CFURLCreateFromFileSystemRepresentationRelativeToBase(alloc, (UInt8*)file.cFileName, namelen, false, dirURL);
+        CFArrayAppendValue(files, fileURL);
+        CFRelease(fileURL);
+    } while (FindNextFileA(handle, &file));
+    FindClose(handle);
+    dirPath[pathLength] = '\0';
+
+#else
+
+#error _CFContentsOfDirectory() unknown architechture, not implemented
+    
+#endif
+
+    if (extension) {
+        CFRelease(extension);
+    }
+    if (releaseBase) {
+        CFRelease(dirURL);
+    }
+    return files;
+}
+
+__private_extern__ SInt32 _CFGetFileProperties(CFAllocatorRef alloc, CFURLRef pathURL, Boolean *exists, SInt32 *posixMode, int64_t *size, CFDateRef *modTime, SInt32 *ownerID, CFArrayRef *dirContents) {
+    Boolean fileExists;
+    Boolean isDirectory = false;
+
+#if DEPLOYMENT_TARGET_WINDOWS
+    struct _stati64 statBuf;
+    int fd = -1;
+#else
+    struct stat64 statBuf;
+#endif
+    char path[CFMaxPathSize];
+
+    if ((exists == NULL) && (posixMode == NULL) && (size == NULL) && (modTime == NULL) && (ownerID == NULL) && (dirContents == NULL)) {
+        // Nothing to do.
+        return 0;
+    }
+
+    if (!CFURLGetFileSystemRepresentation(pathURL, true, (uint8_t *)path, CFMaxPathLength)) {
+        return -1;
+    }
+
+#if DEPLOYMENT_TARGET_WINDOWS
+    HANDLE hFile = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+    if (INVALID_HANDLE_VALUE == hFile)
+       return -1;
+
+    fd = _open_osfhandle((intptr_t)hFile, _O_RDONLY|CF_OPENFLGS);
+    if (fd < 0) {
+        if (thread_errno() == ENOENT) {
+            fileExists = false;
+        } else {
+            CloseHandle (hFile);
+            return thread_errno();
+        }
+    }
+    else
+    {
+        if (_fstati64(fd, &statBuf) != 0) {
+            close(fd);
+            CloseHandle (hFile);
+            // stat failed, but why?
+            if (thread_errno() == ENOENT) {
+                fileExists = false;
+            } else {
+                return thread_errno();
+            }
+       } else {
+            close(fd);
+            CloseHandle (hFile);
+            fileExists = true;
+            isDirectory = ((statBuf.st_mode & S_IFMT) == S_IFDIR);
+       }
+    }
+#else
+    if (stat64(path, &statBuf) != 0) {
+        // stat failed, but why?
+        if (thread_errno() == ENOENT) {
+            fileExists = false;
+        } else {
+            return thread_errno();
+        }
+    } else {
+        fileExists = true;
+        isDirectory = ((statBuf.st_mode & S_IFMT) == S_IFDIR);
+    }    
+#endif
+
+    if (exists != NULL) {
+        *exists = fileExists;
+    }
+
+    if (posixMode != NULL) {
+        if (fileExists) {
+
+            *posixMode = statBuf.st_mode;
+
+        } else {
+            *posixMode = 0;
+        }
+    }
+
+    if (size != NULL) {
+        if (fileExists) {
+
+            *size = statBuf.st_size;
+
+        } else {
+            *size = 0;
+        }
+    }
+
+    if (modTime != NULL) {
+        if (fileExists) {
+#if DEPLOYMENT_TARGET_WINDOWS
+            CFAbsoluteTime theTime = (CFAbsoluteTime)statBuf.st_mtime;
+#elif DEPLOYMENT_TARGET_LINUX
+#if defined _BSD_SOURCE || defined _SVID_SOURCE
+            CFAbsoluteTime theTime = (CFAbsoluteTime)statBuf.st_mtim.tv_sec - kCFAbsoluteTimeIntervalSince1970;
+            theTime += (CFAbsoluteTime)statBuf.st_mtim.tv_nsec / 1000000000.0;
+#else
+            CFAbsoluteTime theTime = (CFAbsoluteTime)statBuf.st_mtime - kCFAbsoluteTimeIntervalSince1970;
+            theTime += (CFAbsoluteTime)statBuf.st_mtimensec / 1000000000.0;
+#endif /* defined _BSD_SOURCE || defined _SVID_SOURCE */
+#else
+            CFAbsoluteTime theTime = (CFAbsoluteTime)statBuf.st_mtimespec.tv_sec - kCFAbsoluteTimeIntervalSince1970;
+            theTime += (CFAbsoluteTime)statBuf.st_mtimespec.tv_nsec / 1000000000.0;
+#endif
+            *modTime = CFDateCreate(alloc, theTime);
+        } else {
+            *modTime = NULL;
+        }
+    }
+
+    if (ownerID != NULL) {
+        if (fileExists) {
+
+            *ownerID = statBuf.st_uid;
+
+        } else {
+            *ownerID = -1;
+        }
+    }
+    
+    if (dirContents != NULL) {
+        if (fileExists && isDirectory) {
+
+            CFMutableArrayRef contents = _CFContentsOfDirectory(alloc, path, NULL, pathURL, NULL);
+
+            if (contents) {
+                *dirContents = contents;
+            } else {
+                *dirContents = NULL;
+            }
+        } else {
+            *dirContents = NULL;
+        }
+    }
+    return 0;
+}
+
+
+// MF:!!! Should pull in the rest of the UniChar based path utils from Foundation.
+#if (DEPLOYMENT_TARGET_MACOSX) || defined(__svr4__) || defined(__hpux__) || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    #define UNIX_PATH_SEMANTICS
+#elif DEPLOYMENT_TARGET_WINDOWS
+    #define WINDOWS_PATH_SEMANTICS
+#else
+#error Unknown platform
+#endif
+
+#if defined(WINDOWS_PATH_SEMANTICS)
+    #define CFPreferredSlash	((UniChar)'\\')
+#elif defined(UNIX_PATH_SEMANTICS)
+    #define CFPreferredSlash	((UniChar)'/')
+#elif defined(HFS_PATH_SEMANTICS)
+    #define CFPreferredSlash	((UniChar)':')
+#else
+    #error Cannot define NSPreferredSlash on this platform
+#endif
+
+#if defined(HFS_PATH_SEMANTICS)
+#define HAS_DRIVE(S) (false)
+#define HAS_NET(S) (false)
+#else
+#define HAS_DRIVE(S) ((S)[1] == ':' && (('A' <= (S)[0] && (S)[0] <= 'Z') || ('a' <= (S)[0] && (S)[0] <= 'z')))
+#define HAS_NET(S) ((S)[0] == '\\' && (S)[1] == '\\')
+#endif
+
+#if defined(WINDOWS_PATH_SEMANTICS)
+    #define IS_SLASH(C)	((C) == '\\' || (C) == '/')
+#elif defined(UNIX_PATH_SEMANTICS)
+    #define IS_SLASH(C)	((C) == '/')
+#elif defined(HFS_PATH_SEMANTICS)
+    #define IS_SLASH(C)	((C) == ':')
+#endif
+
+__private_extern__ Boolean _CFIsAbsolutePath(UniChar *unichars, CFIndex length) {
+    if (length < 1) {
+        return false;
+    }
+#if defined(WINDOWS_PATH_SEMANTICS)
+    if (unichars[0] == '~') {
+        return true;
+    }
+    if (length < 2) {
+        return false;
+    }
+    if (HAS_NET(unichars)) {
+        return true;
+    }
+    if (length < 3) {
+        return false;
+    }
+    if (IS_SLASH(unichars[2]) && HAS_DRIVE(unichars)) {
+        return true;
+    }
+#elif defined(HFS_PATH_SEMANTICS)
+    return !IS_SLASH(unichars[0]);
+#else
+    if (unichars[0] == '~') {
+        return true;
+    }
+    if (IS_SLASH(unichars[0])) {
+        return true;
+    }
+#endif
+    return false;
+}
+
+__private_extern__ Boolean _CFStripTrailingPathSlashes(UniChar *unichars, CFIndex *length) {
+    Boolean destHasDrive = (1 < *length) && HAS_DRIVE(unichars);
+    CFIndex oldLength = *length;
+    while (((destHasDrive && 3 < *length) || (!destHasDrive && 1 < *length)) && IS_SLASH(unichars[*length - 1])) {
+        (*length)--;
+    }
+    return (oldLength != *length);
+}
+
+__private_extern__ Boolean _CFAppendPathComponent(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *component, CFIndex componentLength) {
+    if (0 == componentLength) {
+        return true;
+    }
+    if (maxLength < *length + 1 + componentLength) {
+        return false;
+    }
+    switch (*length) {
+    case 0:
+        break;
+    case 1:
+        if (!IS_SLASH(unichars[0])) {
+            unichars[(*length)++] = CFPreferredSlash;
+        }
+        break;
+    case 2:
+        if (!HAS_DRIVE(unichars) && !HAS_NET(unichars)) {
+            unichars[(*length)++] = CFPreferredSlash;
+        }
+        break;
+    default:
+        unichars[(*length)++] = CFPreferredSlash;
+        break;
+    }
+    memmove(unichars + *length, component, componentLength * sizeof(UniChar));
+    *length += componentLength;
+    return true;
+}
+
+__private_extern__ Boolean _CFAppendPathExtension(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *extension, CFIndex extensionLength) {
+    if (maxLength < *length + 1 + extensionLength) {
+        return false;
+    }
+    if ((0 < extensionLength && IS_SLASH(extension[0])) || (1 < extensionLength && HAS_DRIVE(extension))) {
+        return false;
+    }
+    _CFStripTrailingPathSlashes(unichars, length);
+    switch (*length) {
+    case 0:
+        return false;
+    case 1:
+        if (IS_SLASH(unichars[0]) || unichars[0] == '~') {
+            return false;
+        }
+        break;
+    case 2:
+        if (HAS_DRIVE(unichars) || HAS_NET(unichars)) {
+            return false;
+        }
+        break;
+    case 3:
+        if (IS_SLASH(unichars[2]) && HAS_DRIVE(unichars)) {
+            return false;
+        }
+        break;
+    }
+    if (0 < *length && unichars[0] == '~') {
+        CFIndex idx;
+        Boolean hasSlash = false;
+        for (idx = 1; idx < *length; idx++) {
+            if (IS_SLASH(unichars[idx])) {
+                hasSlash = true;
+                break;
+            }
+        }
+        if (!hasSlash) {
+            return false;
+        }
+    }
+    unichars[(*length)++] = '.';
+    memmove(unichars + *length, extension, extensionLength * sizeof(UniChar));
+    *length += extensionLength;
+    return true;
+}
+
+__private_extern__ Boolean _CFTransmutePathSlashes(UniChar *unichars, CFIndex *length, UniChar replSlash) {
+    CFIndex didx, sidx, scnt = *length;
+    sidx = (1 < *length && HAS_NET(unichars)) ? 2 : 0;
+    didx = sidx;
+    while (sidx < scnt) {
+        if (IS_SLASH(unichars[sidx])) {
+            unichars[didx++] = replSlash;
+            for (sidx++; sidx < scnt && IS_SLASH(unichars[sidx]); sidx++);
+        } else {
+            unichars[didx++] = unichars[sidx++];
+        }
+    }
+    *length = didx;
+    return (scnt != didx);
+}
+
+__private_extern__ CFIndex _CFStartOfLastPathComponent(UniChar *unichars, CFIndex length) {
+    CFIndex idx;
+    if (length < 2) {
+        return 0;
+    }
+    for (idx = length - 1; idx; idx--) {
+        if (IS_SLASH(unichars[idx - 1])) {
+            return idx;
+        }
+    }
+    if ((2 < length) && HAS_DRIVE(unichars)) {
+        return 2;
+    }
+    return 0;
+}
+
+__private_extern__ CFIndex _CFLengthAfterDeletingLastPathComponent(UniChar *unichars, CFIndex length) {
+    CFIndex idx;
+    if (length < 2) {
+        return 0;
+    }
+    for (idx = length - 1; idx; idx--) {
+        if (IS_SLASH(unichars[idx - 1])) {
+            if ((idx != 1) && (!HAS_DRIVE(unichars) || idx != 3)) {
+                return idx - 1;
+            }
+            return idx;
+        }
+    }
+    if ((2 < length) && HAS_DRIVE(unichars)) {
+        return 2;
+    }
+    return 0;
+}
+
+__private_extern__ CFIndex _CFStartOfPathExtension(UniChar *unichars, CFIndex length) {
+    CFIndex idx;
+    if (length < 2) {
+        return 0;
+    }
+    for (idx = length - 1; idx; idx--) {
+        if (IS_SLASH(unichars[idx - 1])) {
+            return 0;
+        }
+        if (unichars[idx] != '.') {
+            continue;
+        }
+        if (idx == 2 && HAS_DRIVE(unichars)) {
+            return 0;
+        }
+        return idx;
+    }
+    return 0;
+}
+
+__private_extern__ CFIndex _CFLengthAfterDeletingPathExtension(UniChar *unichars, CFIndex length) {
+    CFIndex start = _CFStartOfPathExtension(unichars, length);
+    return ((0 < start) ? start : length);
+}
+
+#undef CF_OPENFLGS
+#undef UNIX_PATH_SEMANTICS
+#undef WINDOWS_PATH_SEMANTICS
+#undef HFS_PATH_SEMANTICS
+#undef CFPreferredSlash
+#undef HAS_DRIVE
+#undef HAS_NET
+#undef IS_SLASH
+
diff --git a/CoreFoundation/CFInternal.h b/CoreFoundation/CFInternal.h
new file mode 100644
index 0000000..0c9f709
--- /dev/null
+++ b/CoreFoundation/CFInternal.h
@@ -0,0 +1,780 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFStorage.h>
+#include "CFLogUtilities.h"
+#include "CFRuntime.h"
+#if defined(__MACH__)
+#include <xlocale.h>
+#include <mach/mach_time.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <windows.h>
+#include <malloc.h>
+#endif
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+#include <sys/time.h>
+#include <pthread.h>
+#endif
+#include <limits.h>
+#include "auto_stubs.h"
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#include <libkern/OSAtomic.h>
+#endif //DEPLOYMENT_TARGET_MACOSX
+
+#if !(DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_FREEBSD)
+extern int flsl(long mask);
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#define __PRETTY_FUNCTION__ __FUNCTION__
+#define __builtin_expect(expr, val) (expr)
+#endif
+
+#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 "ForFoundationOnly.h"
+
+CF_EXPORT const char *_CFProcessName(void);
+CF_EXPORT CFStringRef _CFProcessNameString(void);
+
+CF_EXPORT Boolean _CFIsCFM(void);
+
+CF_EXPORT Boolean _CFGetCurrentDirectory(char *path, int maxlen);
+
+CF_EXPORT CFStringRef _CFGetUserName(void);
+
+CF_EXPORT CFArrayRef _CFGetWindowsBinaryDirectories(void);
+
+CF_EXPORT CFStringRef _CFStringCreateHostName(void);
+
+#if DEPLOYMENT_TARGET_MACOSX
+CF_EXPORT void _CFMachPortInstallNotifyPort(CFRunLoopRef rl, CFStringRef mode);
+#endif
+
+#if defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
+    #define HALT asm __volatile__("trap")
+#elif defined(__i386__) || defined(__x86_64__)
+    #if defined(__GNUC__)
+        #define HALT __asm__ __volatile__("int3")
+    #elif defined(_MSC_VER)
+        #define HALT __asm int 3;
+    #else
+        #error Compiler not supported
+    #endif
+#elif defined(__arm__)
+	#define HALT asm __volatile__("bkpt")
+#elif defined(__aarch64__)
+	#define HALT asm __volatile__("brk #0000")
+#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
+
+#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)))
+
+#if DEPLOYMENT_TARGET_WINDOWS
+CF_INLINE bool _CFAtomicCompareAndSwap32Barrier(int32_t oldValue, int32_t newValue, volatile int32_t *theValue) {
+    int32_t actualOldValue = InterlockedCompareExchange((volatile LONG *)theValue, newValue, oldValue);
+    return actualOldValue == oldValue ? true : false;
+}
+CF_INLINE bool _CFAtomicCompareAndSwapPtrBarrier(void* oldValue, void* newValue, void* volatile *theValue) {
+	void *actualOldValue = InterlockedCompareExchangePointer((volatile PVOID*)theValue, newValue, (PVOID)oldValue);
+	return actualOldValue == oldValue ? true : false;
+}
+CF_INLINE int32_t _CFAtomicIncrement32(volatile int32_t *theValue) {
+	return (unsigned int)InterlockedIncrement((volatile LONG*)theValue);
+}
+CF_INLINE void _CFMemoryBarrier(void) {
+	MemoryBarrier();
+}
+#elif DEPLOYMENT_TARGET_MACOSX
+CF_INLINE bool _CFAtomicCompareAndSwap32Barrier(int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue) {
+	return OSAtomicCompareAndSwap32Barrier(__oldValue, __newValue, __theValue);
+}
+CF_INLINE bool _CFAtomicCompareAndSwapPtrBarrier(void* __oldValue, void* __newValue, void* volatile *__theValue) {
+	return OSAtomicCompareAndSwapPtrBarrier(__oldValue, __newValue, __theValue);
+}
+CF_INLINE int32_t _CFAtomicIncrement32(volatile int32_t *theValue) {
+	return OSAtomicIncrement32(theValue);
+}
+CF_INLINE void _CFMemoryBarrier(void) {
+	OSMemoryBarrier();
+}
+#elif DEPLOYMENT_TARGET_LINUX
+// Simply leverage GCC's atomic built-ins (see http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html)
+CF_INLINE bool _CFAtomicCompareAndSwap32Barrier(int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue) {
+	return __sync_bool_compare_and_swap(__theValue, __oldValue, __newValue);
+}
+CF_INLINE bool _CFAtomicCompareAndSwapPtrBarrier(void* __oldValue, void* __newValue, void* volatile *__theValue) {
+	return __sync_bool_compare_and_swap(__theValue, __oldValue, __newValue);
+}
+CF_INLINE int32_t _CFAtomicIncrement32(volatile int32_t *theValue) {
+	return __sync_fetch_and_add(theValue, 1);
+}
+CF_INLINE void _CFMemoryBarrier(void) {
+	__sync_synchronize();
+}
+#else
+#error "Don't know how to perform atomic operations."
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_FREEBSD
+#define	_CFIsSetUgid()	issetugid()
+#elif DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_SOLARIS
+#include <unistd.h>
+CF_INLINE bool _CFIsSetUgid(void) {
+	return (getuid() != geteuid() || getgid() != getegid());
+}
+#elif DEPLOYMENT_TARGET_WINDOWS
+#define	_CFIsSetUgid()	0
+#else
+#error "Don't know how to determine a setuid or setgid executable."
+#endif /* DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_FREEBSD */
+
+
+typedef struct ___CFThreadSpecificData {
+    void *_unused1;
+    void *_allocator;
+#if DEPLOYMENT_TARGET_WINDOWS
+    HHOOK _messageHook;
+#endif
+// If you add things to this struct, add cleanup to __CFFinalizeThreadData()
+} __CFThreadSpecificData;
+
+extern __CFThreadSpecificData *__CFGetThreadSpecificData(void);
+__private_extern__ void __CFFinalizeThreadData(void *arg);
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+extern pthread_key_t __CFTSDKey;
+#elif DEPLOYMENT_TARGET_WINDOWS
+extern DWORD __CFTSDKey;
+#endif
+
+//extern void *pthread_getspecific(pthread_key_t key);
+
+CF_INLINE __CFThreadSpecificData *__CFGetThreadSpecificData_inline(void) {
+#if DEPLOYMENT_TARGET_MACOSX|| DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    __CFThreadSpecificData *data = (__CFThreadSpecificData *)pthread_getspecific(__CFTSDKey);
+    return data ? data : __CFGetThreadSpecificData();
+#elif DEPLOYMENT_TARGET_WINDOWS
+    __CFThreadSpecificData *data = (__CFThreadSpecificData *)TlsGetValue(__CFTSDKey);
+    return data ? data : __CFGetThreadSpecificData();
+#endif
+}
+
+#define __kCFAllocatorTypeID_CONST	2
+
+CF_INLINE CFAllocatorRef __CFGetDefaultAllocator(void) {
+    CFAllocatorRef allocator = (CFAllocatorRef)__CFGetThreadSpecificData_inline()->_allocator;
+    if (NULL == allocator) {
+	allocator = kCFAllocatorSystemDefault;
+    }
+    return allocator;
+}
+
+extern CFTypeID __CFGenericTypeID(const void *cf);
+
+// 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!
+    CFAssert1(__kCFAllocatorTypeID_CONST != __CFGenericTypeID(cf), __kCFLogAssertion, "__CFGetAllocator(): CFAllocator argument", cf);
+    if (__builtin_expect(__CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 7, 7), 1)) {
+	return kCFAllocatorSystemDefault;
+    }
+    return *(CFAllocatorRef *)((char *)cf - sizeof(CFAllocatorRef));
+}
+
+// Don't define a __CFGetCurrentRunLoop(), because even internal clients should go through the real one
+
+
+#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_EXPORT CFAllocatorRef _CFTemporaryMemoryAllocator(void);
+
+extern SInt64 __CFTimeIntervalToTSR(CFTimeInterval ti);
+extern CFTimeInterval __CFTSRToTimeInterval(SInt64 tsr);
+
+extern CFStringRef __CFCopyFormattingDescription(CFTypeRef cf, 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);
+
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || (DEPLOYMENT_TARGET_WINDOWS && __GNUC__)
+
+#define STACK_BUFFER_DECL(T, N, C) T N[C];
+
+#elif DEPLOYMENT_TARGET_WINDOWS && _MSC_VER
+
+#define STACK_BUFFER_DECL(T, N, C) T* N = (T*)_alloca((C + 1) * sizeof(T));
+
+#endif
+
+
+#ifdef __CONSTANT_CFSTRINGS__
+#define CONST_STRING_DECL(S, V) const CFStringRef S = (const CFStringRef)__builtin___CFStringMakeConstantString("" V "");
+#else
+
+struct CF_CONST_STRING {
+    CFRuntimeBase _base;
+    uint8_t *_ptr;
+    uint32_t _length;
+};
+
+extern 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 DEPLOYMENT_TARGET_WINDOWS
+#define ___WindowsConstantStringClassReference (uintptr_t)&__CFConstantStringClassReference
+#else
+#define ___WindowsConstantStringClassReference NULL
+#endif
+
+#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 ## __;
+#elif !DEPLOYMENT_TARGET_WINDOWS || (DEPLOYMENT_TARGET_WINDOWS && defined(__GNUC__))
+#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 ## __;
+#elif DEPLOYMENT_TARGET_WINDOWS
+#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}; \
+CF_EXPORT const CFStringRef S = (CFStringRef) & __ ## S ## __;
+
+#define CONST_STRING_DECL_EXPORT(S, V)			\
+struct CF_CONST_STRING __ ## S ## __ = {{___WindowsConstantStringClassReference, {0xc8, 0x07, 0x00, 0x00}}, (uint8_t *)V, sizeof(V) - 1}; \
+CF_EXPORT const CFStringRef S = (CFStringRef) & __ ## S ## __;
+
+#else
+#define CONST_STRING_DECL(S, V)			\
+static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)NULL, {0xc8, 0x07, 0x00, 0x00}},(uint8_t *) V, sizeof(V) - 1}; \
+const CFStringRef S = (CFStringRef) & __ ## S ## __;
+
+#define CONST_STRING_DECL_EXPORT(S, V)			\
+struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)NULL, {0xc8, 0x07, 0x00, 0x00}}, (uint8_t *)V, sizeof(V) - 1}; \
+CF_EXPORT const CFStringRef S = (CFStringRef) & __ ## S ## __;
+
+#endif // __WIN32__
+#endif // __BIG_ENDIAN__
+
+#undef ___WindowsConstantStringClassReference
+
+/* Buffer size for file pathname */
+#if DEPLOYMENT_TARGET_WINDOWS
+    #define CFMaxPathSize ((CFIndex)262)
+    #define CFMaxPathLength ((CFIndex)260)
+#else
+    #define CFMaxPathSize ((CFIndex)1026)
+    #define CFMaxPathLength ((CFIndex)1024)
+#endif
+
+#define __CFOASafe 0
+#define __CFSetLastAllocationEventName(a, b) ((void) 0)
+
+CF_EXPORT CFStringRef _CFCreateLimitedUniqueString(void);
+
+/* 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);
+
+__private_extern__ 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);
+
+
+#if DEPLOYMENT_TARGET_MACOSX
+
+typedef OSSpinLock CFSpinLock_t;
+
+#define CFSpinLockInit OS_SPINLOCK_INIT
+#define CF_SPINLOCK_INIT_FOR_STRUCTS(X) (X = CFSpinLockInit)
+
+CF_INLINE void __CFSpinLock(CFSpinLock_t *lockp) {
+    OSSpinLockLock(lockp);
+}
+
+CF_INLINE void __CFSpinUnlock(CFSpinLock_t *lockp) {
+    OSSpinLockUnlock(lockp);
+}
+
+#elif DEPLOYMENT_TARGET_WINDOWS
+
+typedef CRITICAL_SECTION CFSpinLock_t;
+
+#define CFSpinLockInit {0}
+
+// For some reason, the {0} initializer does not work when the spinlock is a member of a structure; hence this macro
+#define CF_SPINLOCK_INIT_FOR_STRUCTS(X) InitializeCriticalSection(&X)
+extern CFSpinLock_t *theLock;
+CF_INLINE void __CFSpinLock(CFSpinLock_t *slock) {
+    if (NULL == slock->DebugInfo) {
+        InitializeCriticalSection(slock);
+    }
+    EnterCriticalSection(slock);
+}
+
+CF_INLINE void __CFSpinUnlock(CFSpinLock_t *lock) {
+    LeaveCriticalSection(lock);
+}
+
+#elif DEPLOYMENT_TARGET_LINUX
+
+typedef struct __CFSpinLock {
+	int init;
+	pthread_spinlock_t lock;
+} CFSpinLock_t;
+
+#define CFSpinLockInit {0}
+#define CF_SPINLOCK_INIT_FOR_STRUCTS(X) do { pthread_spin_init(&X.lock, PTHREAD_PROCESS_PRIVATE); X.init = 1; } while (0)
+
+CF_INLINE void __CFSpinLock(CFSpinLock_t *lockp) {
+	if (lockp->init == 0) {
+		!pthread_spin_init(&lockp->lock, PTHREAD_PROCESS_PRIVATE) &&
+		(lockp->init = 1);
+	}
+	pthread_spin_lock(&lockp->lock);
+}
+
+CF_INLINE void __CFSpinUnlock(CFSpinLock_t *lockp) {
+	pthread_spin_unlock(&lockp->lock);
+}
+
+#else
+
+#warning CF spin locks not defined for this platform -- CF is not thread-safe
+#define __CFSpinLock(A)		do {} while (0)
+#define __CFSpinUnlock(A)	do {} while (0)
+
+#endif
+
+#if !defined(CHECK_FOR_FORK)
+#define CHECK_FOR_FORK() do { } while (0)
+#endif
+
+#if !defined(HAS_FORKED)
+#define HAS_FORKED() 0
+#endif
+
+#if defined(__svr4__) || defined(__hpux__) || DEPLOYMENT_TARGET_WINDOWS
+#include <errno.h>
+#elif DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+#include <sys/errno.h>
+#endif
+
+#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_EXPORT Boolean _CFCreateDirectory(const char *path);
+CF_EXPORT Boolean _CFRemoveDirectory(const char *path);
+CF_EXPORT Boolean _CFDeleteFile(const char *path);
+
+CF_EXPORT Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef url, void **bytes, CFIndex *length, CFIndex maxLength);
+    /* 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);
+#if DEPLOYMENT_TARGET_MACOSX
+CF_EXPORT Boolean _CFWriteBytesToFileWithAtomicity(CFURLRef url, const void *bytes, unsigned int length, SInt32 mode, Boolean atomic);
+#endif
+
+CF_EXPORT CFMutableArrayRef _CFContentsOfDirectory(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_EXPORT 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 ==================== */
+/* These functions all act on a UniChar buffers. */
+
+CF_EXPORT Boolean _CFIsAbsolutePath(UniChar *unichars, CFIndex length);
+CF_EXPORT Boolean _CFStripTrailingPathSlashes(UniChar *unichars, CFIndex *length);
+CF_EXPORT Boolean _CFAppendPathComponent(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *component, CFIndex componentLength);
+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_EXPORT CFIndex _CFStartOfLastPathComponent(UniChar *unichars, CFIndex length);
+CF_EXPORT CFIndex _CFLengthAfterDeletingLastPathComponent(UniChar *unichars, CFIndex length);
+CF_EXPORT CFIndex _CFStartOfPathExtension(UniChar *unichars, CFIndex length);
+CF_EXPORT CFIndex _CFLengthAfterDeletingPathExtension(UniChar *unichars, CFIndex length);
+
+#ifdef COCOTRON 
+
+extern SEL (*__CFGetObjCSelector)(const char *);
+extern void* (*__CFSendObjCMsg)(const void*, SEL, ...);
+extern void* __CFISAForTypeID(CFTypeID typeid);
+
+#define CF_IS_OBJC(typeID, obj)	(((CFRuntimeBase *)(obj))->_cfisa != NULL && ((CFRuntimeBase *)(obj))->_cfisa != __CFISAForTypeID(typeID))
+
+#define CF_OBJC_VOIDCALL0(obj, sel) \
+        {void (*func)(const void *, SEL) = (void *)__CFSendObjCMsg; \
+        static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+        func((const void *)obj, s);}
+#define CF_OBJC_VOIDCALL1(obj, sel, a1) \
+        {void (*func)(const void *, SEL, ...) = (void *)__CFSendObjCMsg; \
+        static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+        func((const void *)obj, s, (a1));}
+#define CF_OBJC_VOIDCALL2(obj, sel, a1, a2) \
+        {void (*func)(const void *, SEL, ...) = (void *)__CFSendObjCMsg; \
+        static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+        func((const void *)obj, s, (a1), (a2));}
+
+// Invoke an ObjC method, leaving the result in "retvar".
+// Assumes CF_IS_OBJC has already been checked.
+#define CF_OBJC_CALL0(rettype, retvar, obj, sel) \
+        {rettype (*func)(const void *, SEL) = (void *)__CFSendObjCMsg; \
+        static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+        retvar = func((const void *)obj, s);}
+#define CF_OBJC_CALL1(rettype, retvar, obj, sel, a1) \
+        {rettype (*func)(const void *, SEL, ...) = (void *)__CFSendObjCMsg; \
+        static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+        retvar = func((const void *)obj, s, (a1));}
+#define CF_OBJC_CALL2(rettype, retvar, obj, sel, a1, a2) \
+        {rettype (*func)(const void *, SEL, ...) = (void *)__CFSendObjCMsg; \
+        static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+        retvar = func((const void *)obj, s, (a1), (a2));}
+
+#define CF_OBJC_FUNCDISPATCH0(typeID, rettype, obj, sel) \
+	if (CF_IS_OBJC(typeID, obj)) \
+	{rettype (*func)(id, SEL) = (void *)__CFSendObjCMsg; \
+	static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+	return func((id)obj, s);}
+#define CF_OBJC_FUNCDISPATCH1(typeID, rettype, obj, sel, a1) \
+	if (CF_IS_OBJC(typeID, obj)) \
+	{rettype (*func)(id, SEL, ...) = (void *)__CFSendObjCMsg; \
+	static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+	return func((id)obj, s, (a1));}
+#define CF_OBJC_FUNCDISPATCH2(typeID, rettype, obj, sel, a1, a2) \
+	if (CF_IS_OBJC(typeID, obj)) \
+	{rettype (*func)(id, SEL, ...) = (void *)__CFSendObjCMsg; \
+	static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+	return func((id)obj, s, (a1), (a2));}
+#define CF_OBJC_FUNCDISPATCH3(typeID, rettype, obj, sel, a1, a2, a3) \
+	if (CF_IS_OBJC(typeID, obj)) \
+	{rettype (*func)(id, SEL, ...) = (void *)__CFSendObjCMsg; \
+	static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+	return func((id)obj, s, (a1), (a2), (a3));}
+#define CF_OBJC_FUNCDISPATCH4(typeID, rettype, obj, sel, a1, a2, a3, a4) \
+	if (CF_IS_OBJC(typeID, obj)) \
+	{rettype (*func)(id, SEL, ...) = (void *)__CFSendObjCMsg; \
+	static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+	return func((id)obj, s, (a1), (a2), (a3), (a4));}
+#define CF_OBJC_FUNCDISPATCH5(typeID, rettype, obj, sel, a1, a2, a3, a4, a5) \
+	if (CF_IS_OBJC(typeID, obj)) \
+	{rettype (*func)(id, SEL, ...) = (void *)__CFSendObjCMsg; \
+	static SEL s = NULL; if (!s) s = __CFGetObjCSelector(sel); \
+	return func((id)obj, s, (a1), (a2), (a3), (a4), (a5));}
+
+#else
+
+#define CF_IS_OBJC(typeID, obj)	(false)
+
+#define CF_OBJC_VOIDCALL0(obj, sel)
+#define CF_OBJC_VOIDCALL1(obj, sel, a1)
+#define CF_OBJC_VOIDCALL2(obj, sel, a1, a2)
+
+#define CF_OBJC_CALL0(rettype, retvar, obj, sel)
+#define CF_OBJC_CALL1(rettype, retvar, obj, sel, a1)
+#define CF_OBJC_CALL2(rettype, retvar, obj, sel, a1, a2)
+
+#if defined DEPLOYMENT_TARGET_WINDOWS
+#define CF_OBJC_FUNCDISPATCH0(typeID, rettype, obj, sel) ((void)0)
+#define CF_OBJC_FUNCDISPATCH1(typeID, rettype, obj, sel, a1) ((void)0)
+#define CF_OBJC_FUNCDISPATCH2(typeID, rettype, obj, sel, a1, a2) ((void)0)
+#define CF_OBJC_FUNCDISPATCH3(typeID, rettype, obj, sel, a1, a2, a3) ((void)0)
+#define CF_OBJC_FUNCDISPATCH4(typeID, rettype, obj, sel, a1, a2, a3, a4) ((void)0)
+#define CF_OBJC_FUNCDISPATCH5(typeID, rettype, obj, sel, a1, a2, a3, a4, a5) ((void)0)
+#else
+#define CF_OBJC_FUNCDISPATCH0(typeID, rettype, obj, sel)
+#define CF_OBJC_FUNCDISPATCH1(typeID, rettype, obj, sel, a1)
+#define CF_OBJC_FUNCDISPATCH2(typeID, rettype, obj, sel, a1, a2)
+#define CF_OBJC_FUNCDISPATCH3(typeID, rettype, obj, sel, a1, a2, a3)
+#define CF_OBJC_FUNCDISPATCH4(typeID, rettype, obj, sel, a1, a2, a3, a4)
+#define CF_OBJC_FUNCDISPATCH5(typeID, rettype, obj, sel, a1, a2, a3, a4, a5)
+#endif
+
+#define __CFISAForTypeID(x) (0)
+
+#endif
+
+#define __CFMaxRuntimeTypes	65535
+
+/* See comments in CFBase.c
+*/
+#if DEPLOYMENT_TARGET_MACOSX && defined(__ppc__)
+extern void __CF_FAULT_CALLBACK(void **ptr);
+extern void *__CF_INVOKE_CALLBACK(void *, ...);
+#define FAULT_CALLBACK(V) __CF_FAULT_CALLBACK(V)
+#define INVOKE_CALLBACK1(P, A) (__CF_INVOKE_CALLBACK(P, A))
+#define INVOKE_CALLBACK2(P, A, B) (__CF_INVOKE_CALLBACK(P, A, B))
+#define INVOKE_CALLBACK3(P, A, B, C) (__CF_INVOKE_CALLBACK(P, A, B, C))
+#define INVOKE_CALLBACK4(P, A, B, C, D) (__CF_INVOKE_CALLBACK(P, A, B, C, D))
+#define INVOKE_CALLBACK5(P, A, B, C, D, E) (__CF_INVOKE_CALLBACK(P, A, B, C, D, E))
+#define UNFAULT_CALLBACK(V) do { V = (void *)((uintptr_t)V & ~0x3); } while (0)
+#else
+#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)
+#endif
+
+/* 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
+//  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
+
+extern void *__CFLookupCFNetworkFunction(const char *name);
+
+#define DEFINE_WEAK_CFNETWORK_FUNC(R, N, P, A, ...)	\
+ static R __CFNetwork_ ## N P {				\
+ typedef R (*CALL_FUN_TYPE ## N) P;    \
+ static CALL_FUN_TYPE ## N dyfunc = (CALL_FUN_TYPE ## N)(~(uintptr_t)0);	\
+ if (((CALL_FUN_TYPE ## N)(~(uintptr_t)0)) == dyfunc) {		\
+ dyfunc = (CALL_FUN_TYPE ## N)__CFLookupCFNetworkFunction(#N); }	\
+ if (dyfunc) { return dyfunc A ; }			\
+ return __VA_ARGS__ ;				\
+ }
+ 
+#else
+
+#define DEFINE_WEAK_CFNETWORK_FUNC(R, N, P, A, ...)
+
+#endif
+
+
+#if !defined(DEFINE_WEAK_CARBONCORE_FUNC)
+#define DEFINE_WEAK_CARBONCORE_FUNC(R, N, P, A, ...)
+#endif
+
+
+__private_extern__ CFArrayRef _CFBundleCopyUserLanguages(Boolean useBackstops);
+
+/* GC related internal SPIs. */
+extern malloc_zone_t *__CFCollectableZone;
+
+/* !!! 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];
+};
+
+unsigned long _CFStorageFastEnumeration(CFStorageRef storage, struct __objcFastEnumerationStateEquivalent *state, void *stackbuffer, unsigned long count);
+
+#if DEPLOYMENT_TARGET_MACOSX
+// Allocate an id[count], new slots are nil
+extern void *__CFAllocateObjectArray(unsigned long count);
+extern void *__CFReallocateObjectArray(id *array, unsigned long count);
+extern void __CFFreeObjectArray(id *array);
+
+// check against LONG_MAX to catch negative numbers
+#define new_id_array(N, C) \
+        size_t N ## _count__ = (C); \
+        if (N ## _count__ > LONG_MAX) { \
+	    id rr = [objc_lookUpClass("NSString") stringWithFormat:@"*** attempt to create a temporary id buffer which is too large or with a negative count (%lu) -- possibly data is corrupt", N ## _count__]; \
+	    @throw [NSException exceptionWithName:NSGenericException reason:rr userInfo:nil]; \
+	} \
+        NSInteger N ## _is_stack__ = (N ## _count__ <= 256); \
+        id N ## _buffer__[N ## _is_stack__ ? N ## _count__ : 0]; \
+        if (N ## _is_stack__) memset(N ## _buffer__, 0, sizeof(N ## _buffer__)); \
+        id * N = N ## _is_stack__ ? N ## _buffer__ : __CFAllocateObjectArray(N ## _count__); \
+        if (! N) { \
+	    id rr = [objc_lookUpClass("NSString") stringWithFormat:@"*** attempt to create a temporary id buffer of length (%lu) failed", N ## _count__]; \
+	    @throw [NSException exceptionWithName:NSMallocException reason:rr userInfo:nil]; \
+	} \
+        do {} while (0)
+
+#define free_id_array(N) \
+        if (! N ## _is_stack__) __CFFreeObjectArray(N)
+
+extern void *__CFFullMethodName(Class cls, id obj, SEL sel);
+extern void *__CFExceptionProem(id obj, SEL sel);
+extern void __CFRequireConcreteImplementation(Class absClass, id obj, SEL sel);
+#endif
+
+#endif /* ! __COREFOUNDATION_CFINTERNAL__ */
+
diff --git a/CoreFoundation/CFLite.sln b/CoreFoundation/CFLite.sln
new file mode 100644
index 0000000..e687de1
--- /dev/null
+++ b/CoreFoundation/CFLite.sln
@@ -0,0 +1,130 @@
+

+Microsoft Visual Studio Solution File, Format Version 9.00

+# Visual Studio 2005

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WritePListExample", "examples\WritePListExample\WritePListExample.vcproj", "{AD525151-D756-44E6-AEA7-12052F4F43E2}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+	ProjectSection(ProjectDependencies) = postProject

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372} = {EC99198F-4CDD-4D85-AE6F-F837FF6CC372}

+	EndProjectSection

+EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadPListExample", "examples\ReadPListExample\ReadPListExample.vcproj", "{CDF7218C-AE33-4367-B6F9-5728AE3C7F6E}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+	ProjectSection(ProjectDependencies) = postProject

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372} = {EC99198F-4CDD-4D85-AE6F-F837FF6CC372}

+	EndProjectSection

+EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StringExample", "examples\StringExample\StringExample.vcproj", "{4E98FDA7-54AE-4A8E-847A-8665DEF6BBE1}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+	ProjectSection(ProjectDependencies) = postProject

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372} = {EC99198F-4CDD-4D85-AE6F-F837FF6CC372}

+	EndProjectSection

+EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllocatorExample", "examples\Allocator\Allocator.vcproj", "{2A4D3906-539D-4D1E-9C97-47ABD83FD999}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+	ProjectSection(ProjectDependencies) = postProject

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372} = {EC99198F-4CDD-4D85-AE6F-F837FF6CC372}

+	EndProjectSection

+EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CFLite", "windows\CFLiteLib.vcproj", "{EC99198F-4CDD-4D85-AE6F-F837FF6CC372}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DisplayURL", "examples\DisplayURL\DisplayURL.vcproj", "{6816B34F-DE8C-48EC-8F31-11176DA5FE11}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+	ProjectSection(ProjectDependencies) = postProject

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372} = {EC99198F-4CDD-4D85-AE6F-F837FF6CC372}

+	EndProjectSection

+EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DNSServiceMetaQuery", "examples\DNSServiceMetaQuery\DNSServiceMetaQuery.vcproj", "{B5F7F4D9-DCA9-4CCD-8776-D2EAF45E4BE9}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+	ProjectSection(ProjectDependencies) = postProject

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372} = {EC99198F-4CDD-4D85-AE6F-F837FF6CC372}

+	EndProjectSection

+EndProject

+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{60C062B2-DAC0-4361-9D92-9654183AFD72}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+EndProject

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CFRunLoopTimerExample", "examples\CFRunLoopTimerExample\CFRunLoopTimerExample.vcproj", "{6EC2C74D-B79D-4B8D-B14B-94ED3F08EB28}"

+	ProjectSection(WebsiteProperties) = preProject

+		Debug.AspNetCompiler.Debug = "True"

+		Release.AspNetCompiler.Debug = "False"

+	EndProjectSection

+	ProjectSection(ProjectDependencies) = postProject

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372} = {EC99198F-4CDD-4D85-AE6F-F837FF6CC372}

+	EndProjectSection

+EndProject

+Global

+	GlobalSection(SolutionConfigurationPlatforms) = preSolution

+		Debug|Win32 = Debug|Win32

+		Release|Win32 = Release|Win32

+	EndGlobalSection

+	GlobalSection(ProjectConfigurationPlatforms) = postSolution

+		{AD525151-D756-44E6-AEA7-12052F4F43E2}.Debug|Win32.ActiveCfg = Debug|Win32

+		{AD525151-D756-44E6-AEA7-12052F4F43E2}.Debug|Win32.Build.0 = Debug|Win32

+		{AD525151-D756-44E6-AEA7-12052F4F43E2}.Release|Win32.ActiveCfg = Release|Win32

+		{AD525151-D756-44E6-AEA7-12052F4F43E2}.Release|Win32.Build.0 = Release|Win32

+		{CDF7218C-AE33-4367-B6F9-5728AE3C7F6E}.Debug|Win32.ActiveCfg = Debug|Win32

+		{CDF7218C-AE33-4367-B6F9-5728AE3C7F6E}.Debug|Win32.Build.0 = Debug|Win32

+		{CDF7218C-AE33-4367-B6F9-5728AE3C7F6E}.Release|Win32.ActiveCfg = Release|Win32

+		{CDF7218C-AE33-4367-B6F9-5728AE3C7F6E}.Release|Win32.Build.0 = Release|Win32

+		{4E98FDA7-54AE-4A8E-847A-8665DEF6BBE1}.Debug|Win32.ActiveCfg = Debug|Win32

+		{4E98FDA7-54AE-4A8E-847A-8665DEF6BBE1}.Debug|Win32.Build.0 = Debug|Win32

+		{4E98FDA7-54AE-4A8E-847A-8665DEF6BBE1}.Release|Win32.ActiveCfg = Release|Win32

+		{4E98FDA7-54AE-4A8E-847A-8665DEF6BBE1}.Release|Win32.Build.0 = Release|Win32

+		{2A4D3906-539D-4D1E-9C97-47ABD83FD999}.Debug|Win32.ActiveCfg = Debug|Win32

+		{2A4D3906-539D-4D1E-9C97-47ABD83FD999}.Debug|Win32.Build.0 = Debug|Win32

+		{2A4D3906-539D-4D1E-9C97-47ABD83FD999}.Release|Win32.ActiveCfg = Release|Win32

+		{2A4D3906-539D-4D1E-9C97-47ABD83FD999}.Release|Win32.Build.0 = Release|Win32

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372}.Debug|Win32.ActiveCfg = Debug|Win32

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372}.Debug|Win32.Build.0 = Debug|Win32

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372}.Release|Win32.ActiveCfg = Release|Win32

+		{EC99198F-4CDD-4D85-AE6F-F837FF6CC372}.Release|Win32.Build.0 = Release|Win32

+		{6816B34F-DE8C-48EC-8F31-11176DA5FE11}.Debug|Win32.ActiveCfg = Debug|Win32

+		{6816B34F-DE8C-48EC-8F31-11176DA5FE11}.Debug|Win32.Build.0 = Debug|Win32

+		{6816B34F-DE8C-48EC-8F31-11176DA5FE11}.Release|Win32.ActiveCfg = Release|Win32

+		{6816B34F-DE8C-48EC-8F31-11176DA5FE11}.Release|Win32.Build.0 = Release|Win32

+		{B5F7F4D9-DCA9-4CCD-8776-D2EAF45E4BE9}.Debug|Win32.ActiveCfg = Debug|Win32

+		{B5F7F4D9-DCA9-4CCD-8776-D2EAF45E4BE9}.Debug|Win32.Build.0 = Debug|Win32

+		{B5F7F4D9-DCA9-4CCD-8776-D2EAF45E4BE9}.Release|Win32.ActiveCfg = Release|Win32

+		{B5F7F4D9-DCA9-4CCD-8776-D2EAF45E4BE9}.Release|Win32.Build.0 = Release|Win32

+		{6EC2C74D-B79D-4B8D-B14B-94ED3F08EB28}.Debug|Win32.ActiveCfg = Debug|Win32

+		{6EC2C74D-B79D-4B8D-B14B-94ED3F08EB28}.Debug|Win32.Build.0 = Debug|Win32

+		{6EC2C74D-B79D-4B8D-B14B-94ED3F08EB28}.Release|Win32.ActiveCfg = Release|Win32

+		{6EC2C74D-B79D-4B8D-B14B-94ED3F08EB28}.Release|Win32.Build.0 = Release|Win32

+	EndGlobalSection

+	GlobalSection(SolutionProperties) = preSolution

+		HideSolutionNode = FALSE

+	EndGlobalSection

+	GlobalSection(NestedProjects) = preSolution

+		{CDF7218C-AE33-4367-B6F9-5728AE3C7F6E} = {60C062B2-DAC0-4361-9D92-9654183AFD72}

+		{4E98FDA7-54AE-4A8E-847A-8665DEF6BBE1} = {60C062B2-DAC0-4361-9D92-9654183AFD72}

+		{2A4D3906-539D-4D1E-9C97-47ABD83FD999} = {60C062B2-DAC0-4361-9D92-9654183AFD72}

+		{6816B34F-DE8C-48EC-8F31-11176DA5FE11} = {60C062B2-DAC0-4361-9D92-9654183AFD72}

+		{B5F7F4D9-DCA9-4CCD-8776-D2EAF45E4BE9} = {60C062B2-DAC0-4361-9D92-9654183AFD72}

+		{AD525151-D756-44E6-AEA7-12052F4F43E2} = {60C062B2-DAC0-4361-9D92-9654183AFD72}

+		{6EC2C74D-B79D-4B8D-B14B-94ED3F08EB28} = {60C062B2-DAC0-4361-9D92-9654183AFD72}

+	EndGlobalSection

+EndGlobal

diff --git a/CoreFoundation/CFLocale.c b/CoreFoundation/CFLocale.c
new file mode 100644
index 0000000..872e2dd
--- /dev/null
+++ b/CoreFoundation/CFLocale.c
@@ -0,0 +1,1073 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+    Copyright 2002-2003, Apple Computer, Inc. All rights reserved.
+    Responsibility: Christopher Kane
+*/
+
+// Note the header file is in the OpenSource set (stripped to almost nothing), but not the .c file
+
+#include <CoreFoundation/CFLocale.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFPreferences.h>
+#include <CoreFoundation/CFCalendar.h>
+#include <CoreFoundation/CFNumber.h>
+#include "CFInternal.h"
+#include <unicode/uloc.h>           // ICU locales
+#include <unicode/ulocdata.h>       // ICU locale data
+#include <unicode/ucurr.h>          // ICU currency functions
+#include <unicode/uset.h>           // ICU Unicode sets
+#include <unicode/putil.h>          // ICU low-level utilities
+#include <unicode/umsg.h>           // ICU message formatting
+#include <CoreFoundation/CFNumberFormatter.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unicode/ucol.h>
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#include <windows.h> // for GetLocaleInfo
+#include <winnls.h>
+#include <locale.h>
+#endif
+
+#if _MSC_VER
+#define snprintf _snprintf
+#define BUFFER_SIZE 512
+#endif
+
+CONST_STRING_DECL(kCFLocaleCurrentLocaleDidChangeNotification, "kCFLocaleCurrentLocaleDidChangeNotification")
+
+static const char *kCalendarKeyword = "calendar";
+static const char *kCollationKeyword = "collation";
+#define kMaxICUNameSize 1024
+
+typedef struct __CFLocale *CFMutableLocaleRef;
+
+__private_extern__ CONST_STRING_DECL(__kCFLocaleCollatorID, "locale:collator id")
+
+enum {
+    __kCFLocaleKeyTableCount = 16
+};
+
+struct key_table {
+    CFStringRef key;
+    bool (*get)(CFLocaleRef, bool user, CFTypeRef *, CFStringRef context);  // returns an immutable copy & reference
+    bool (*set)(CFMutableLocaleRef, CFTypeRef, CFStringRef context);
+    bool (*name)(const char *, const char *, CFStringRef *); 
+    CFStringRef context;
+};
+
+
+// Must forward decl. these functions:
+static bool __CFLocaleCopyLocaleID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleSetNOP(CFMutableLocaleRef locale, CFTypeRef cf, CFStringRef context);
+static bool __CFLocaleFullName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleCopyCodes(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCountryName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleScriptName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleLanguageName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleCurrencyShortName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleCopyExemplarCharSet(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleVariantName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleNoName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleCopyCalendarID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCalendarName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleCollationName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleCopyUsesMetric(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCopyCalendar(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCopyCollationID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCopyMeasurementSystem(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCopyNumberFormat(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCopyNumberFormat2(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+static bool __CFLocaleCurrencyFullName(const char *locale, const char *value, CFStringRef *out);
+static bool __CFLocaleCopyCollatorID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context);
+
+// Note string members start with an extra &, and are fixed up at init time
+static struct key_table __CFLocaleKeyTable[__kCFLocaleKeyTableCount] = {
+    {(CFStringRef)&kCFLocaleIdentifier, __CFLocaleCopyLocaleID, __CFLocaleSetNOP, __CFLocaleFullName, NULL},
+    {(CFStringRef)&kCFLocaleLanguageCode, __CFLocaleCopyCodes, __CFLocaleSetNOP, __CFLocaleLanguageName, (CFStringRef)&kCFLocaleLanguageCode},
+    {(CFStringRef)&kCFLocaleCountryCode, __CFLocaleCopyCodes, __CFLocaleSetNOP, __CFLocaleCountryName, (CFStringRef)&kCFLocaleCountryCode},
+    {(CFStringRef)&kCFLocaleScriptCode, __CFLocaleCopyCodes, __CFLocaleSetNOP, __CFLocaleScriptName, (CFStringRef)&kCFLocaleScriptCode},
+    {(CFStringRef)&kCFLocaleVariantCode, __CFLocaleCopyCodes, __CFLocaleSetNOP, __CFLocaleVariantName, (CFStringRef)&kCFLocaleVariantCode},
+    {(CFStringRef)&kCFLocaleExemplarCharacterSet, __CFLocaleCopyExemplarCharSet, __CFLocaleSetNOP, __CFLocaleNoName, NULL},
+    {(CFStringRef)&kCFLocaleCalendarIdentifier, __CFLocaleCopyCalendarID, __CFLocaleSetNOP, __CFLocaleCalendarName, NULL},
+    {(CFStringRef)&kCFLocaleCalendar, __CFLocaleCopyCalendar, __CFLocaleSetNOP, __CFLocaleNoName, NULL},
+    {(CFStringRef)&kCFLocaleCollationIdentifier, __CFLocaleCopyCollationID, __CFLocaleSetNOP, __CFLocaleCollationName, NULL},
+    {(CFStringRef)&kCFLocaleUsesMetricSystem, __CFLocaleCopyUsesMetric, __CFLocaleSetNOP, __CFLocaleNoName, NULL},
+    {(CFStringRef)&kCFLocaleMeasurementSystem, __CFLocaleCopyMeasurementSystem, __CFLocaleSetNOP, __CFLocaleNoName, NULL},
+    {(CFStringRef)&kCFLocaleDecimalSeparator, __CFLocaleCopyNumberFormat, __CFLocaleSetNOP, __CFLocaleNoName, (CFStringRef)&kCFNumberFormatterDecimalSeparator},
+    {(CFStringRef)&kCFLocaleGroupingSeparator, __CFLocaleCopyNumberFormat, __CFLocaleSetNOP, __CFLocaleNoName, (CFStringRef)&kCFNumberFormatterGroupingSeparator},
+    {(CFStringRef)&kCFLocaleCurrencySymbol, __CFLocaleCopyNumberFormat2, __CFLocaleSetNOP, __CFLocaleCurrencyShortName, (CFStringRef)&kCFNumberFormatterCurrencySymbol},
+    {(CFStringRef)&kCFLocaleCurrencyCode, __CFLocaleCopyNumberFormat2, __CFLocaleSetNOP, __CFLocaleCurrencyFullName, (CFStringRef)&kCFNumberFormatterCurrencyCode},
+    {(CFStringRef)&__kCFLocaleCollatorID, __CFLocaleCopyCollatorID, __CFLocaleSetNOP, __CFLocaleNoName, NULL},
+};
+
+
+static CFLocaleRef __CFLocaleSystem = NULL;
+static CFMutableDictionaryRef __CFLocaleCache = NULL;
+static CFSpinLock_t __CFLocaleGlobalLock = CFSpinLockInit;
+
+struct __CFLocale {
+    CFRuntimeBase _base;
+    CFStringRef _identifier;    // canonical identifier, never NULL
+    CFMutableDictionaryRef _cache;
+    CFMutableDictionaryRef _overrides;
+    CFDictionaryRef _prefs;
+    CFSpinLock_t _lock;
+};
+
+/* Flag bits */
+enum {      /* Bits 0-1 */
+    __kCFLocaleOrdinary = 0,
+    __kCFLocaleSystem = 1,
+    __kCFLocaleUser = 2,
+    __kCFLocaleCustom = 3
+};
+
+CF_INLINE CFIndex __CFLocaleGetType(CFLocaleRef locale) {
+    return __CFBitfieldGetValue(((const CFRuntimeBase *)locale)->_cfinfo[CF_INFO_BITS], 1, 0);
+}
+
+CF_INLINE void __CFLocaleSetType(CFLocaleRef locale, CFIndex type) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)locale)->_cfinfo[CF_INFO_BITS], 1, 0, (uint8_t)type);
+}
+
+CF_INLINE void __CFLocaleLockGlobal(void) {
+    __CFSpinLock(&__CFLocaleGlobalLock);
+}
+
+CF_INLINE void __CFLocaleUnlockGlobal(void) {
+    __CFSpinUnlock(&__CFLocaleGlobalLock);
+}
+
+CF_INLINE void __CFLocaleLock(CFLocaleRef locale) {
+    __CFSpinLock((CFSpinLock_t *)(&locale->_lock));
+}
+
+CF_INLINE void __CFLocaleUnlock(CFLocaleRef locale) {
+    __CFSpinUnlock((CFSpinLock_t *)(&locale->_lock));
+}
+
+#ifdef DEPLOYMENT_TARGET_WINDOWS
+__private_extern__ CFStringRef __CFLocaleWindowsLCIDToISOLocaleName(LCID id)
+{
+    //XXXBS Windows Vista should use LCIDToLocaleName instead of this
+    char iso_localename[18], iso_lang_name[9], iso_region_name[9];
+    GetLocaleInfoA(id, LOCALE_SISO639LANGNAME, iso_lang_name, 9);
+    GetLocaleInfoA(id, LOCALE_SISO3166CTRYNAME,iso_region_name, 9);
+    // implicitly protected from overflow because of guaranteed maximum size returned by GetLocaleInfoA/W
+    strcpy(iso_localename, iso_lang_name);
+    strcat(iso_localename, "_");
+    strcat(iso_localename, iso_region_name);
+    return(CFStringCreateWithCString(kCFAllocatorSystemDefault, iso_localename, kCFStringEncodingASCII));
+}
+
+__private_extern__ CFStringRef __CFLocaleWindowsLCIDToISOLocaleNameUsingHyphen(LCID id)
+{
+    char iso_localename[18], iso_lang_name[9], iso_region_name[9];
+    GetLocaleInfoA(id, LOCALE_SISO639LANGNAME, iso_lang_name, 9);
+    GetLocaleInfoA(id, LOCALE_SISO3166CTRYNAME,iso_region_name, 9);
+    // implicitly protected from overflow because of guaranteed maximum size returned by GetLocaleInfoA/W
+    strcpy(iso_localename, iso_lang_name);
+    strcat(iso_localename, "-");
+    strcat(iso_localename, iso_region_name);
+    return(CFStringCreateWithCString(kCFAllocatorSystemDefault, iso_localename, kCFStringEncodingASCII));
+}
+
+CFStringRef		s_WindowsInstalledLocales[255];
+int				s_num_installed_localesI = 0;
+
+static BOOL CALLBACK WindowsLocaleEnumProc(char *localeName)
+{
+	s_WindowsInstalledLocales[s_num_installed_localesI] = CFStringCreateWithCString(kCFAllocatorDefault, localeName, kCFStringEncodingASCII);
+	s_num_installed_localesI++;
+    return (TRUE);
+}
+
+__private_extern__ CFArrayRef CFLocaleWindowsGetInstalledLocales(void)
+{
+    CFArrayRef WindowsLocales;
+    EnumSystemLocales((LOCALE_ENUMPROC)WindowsLocaleEnumProc, LCID_INSTALLED);
+    WindowsLocales = CFArrayCreate(kCFAllocatorSystemDefault, (const void**)s_WindowsInstalledLocales, s_num_installed_localesI, &kCFTypeArrayCallBacks);
+    return (WindowsLocales);
+}
+#elif DEPLOYMENT_TARGET_LINUX
+static CFStringRef __CFLocaleCopyPOSIXLocaleName(void)
+{
+    const char *p = NULL;
+    CFStringRef identifier = NULL;
+
+    p = getenv("LC_ALL");
+
+    if (NULL == p) p = getenv("LANG");
+    if (NULL != p) identifier = CFStringCreateWithCString(kCFAllocatorDefault, p, kCFStringEncodingASCII);
+
+    return (identifier);
+}
+#endif // DEPLOYMENT_TARGET_WINDOWS
+
+static Boolean __CFLocaleEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFLocaleRef locale1 = (CFLocaleRef)cf1;
+    CFLocaleRef locale2 = (CFLocaleRef)cf2;
+    // a user locale and a locale created with an ident are not the same even if their contents are
+    if (__CFLocaleGetType(locale1) != __CFLocaleGetType(locale2)) return false;
+    if (!CFEqual(locale1->_identifier, locale2->_identifier)) return false;
+    if (NULL == locale1->_overrides && NULL != locale2->_overrides) return false;
+    if (NULL != locale1->_overrides && NULL == locale2->_overrides) return false;
+    if (NULL != locale1->_overrides && !CFEqual(locale1->_overrides, locale2->_overrides)) return false;
+    if (__kCFLocaleUser == __CFLocaleGetType(locale1)) {
+    return CFEqual(locale1->_prefs, locale2->_prefs);
+    }
+    return true;
+}
+
+static CFHashCode __CFLocaleHash(CFTypeRef cf) {
+    CFLocaleRef locale = (CFLocaleRef)cf;
+    return CFHash(locale->_identifier);
+}
+
+static CFStringRef __CFLocaleCopyDescription(CFTypeRef cf) {
+    CFLocaleRef locale = (CFLocaleRef)cf;
+    const char *type = NULL;
+    switch (__CFLocaleGetType(locale)) {
+    case __kCFLocaleOrdinary: type = "ordinary"; break;
+    case __kCFLocaleSystem: type = "system"; break;
+    case __kCFLocaleUser: type = "user"; break;
+    case __kCFLocaleCustom: type = "custom"; break;
+    }
+    return CFStringCreateWithFormat(CFGetAllocator(locale), NULL, CFSTR("<CFLocale %p [%p]>{type = %s, identifier = '%@'}"), cf, CFGetAllocator(locale), type, locale->_identifier);
+}
+
+static void __CFLocaleDeallocate(CFTypeRef cf) {
+    CFLocaleRef locale = (CFLocaleRef)cf;
+    CFRelease(locale->_identifier);
+    if (NULL != locale->_cache) CFRelease(locale->_cache);
+    if (NULL != locale->_overrides) CFRelease(locale->_overrides);
+    if (NULL != locale->_prefs) CFRelease(locale->_prefs);
+}
+
+static CFTypeID __kCFLocaleTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFLocaleClass = {
+    0,
+    "CFLocale",
+    NULL,   // init
+    NULL,   // copy
+    __CFLocaleDeallocate,
+    __CFLocaleEqual,
+    __CFLocaleHash,
+    NULL,   // 
+    __CFLocaleCopyDescription
+};
+
+__private_extern__ void __CFLocaleInitialize(void) {
+    CFIndex idx;
+    __kCFLocaleTypeID = _CFRuntimeRegisterClass(&__CFLocaleClass);
+    for (idx = 0; idx < __kCFLocaleKeyTableCount; idx++) {
+	// table fixup to workaround compiler/language limitations
+        __CFLocaleKeyTable[idx].key = *((CFStringRef *)__CFLocaleKeyTable[idx].key);
+        if (NULL != __CFLocaleKeyTable[idx].context) {
+            __CFLocaleKeyTable[idx].context = *((CFStringRef *)__CFLocaleKeyTable[idx].context);
+        }
+    }
+}
+
+CFTypeID CFLocaleGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFLocaleTypeID) __CFLocaleInitialize();
+    return __kCFLocaleTypeID;
+}
+
+CFLocaleRef CFLocaleGetSystem(void) {
+    CFLocaleRef locale;
+    __CFLocaleLockGlobal();
+    if (NULL == __CFLocaleSystem) {
+	__CFLocaleUnlockGlobal();
+	locale = CFLocaleCreate(kCFAllocatorSystemDefault, CFSTR(""));
+	if (!locale) return NULL;
+	__CFLocaleSetType(locale, __kCFLocaleSystem);
+	__CFLocaleLockGlobal();
+	if (NULL == __CFLocaleSystem) {
+	    __CFLocaleSystem = locale;
+	} else {
+	    if (locale) CFRelease(locale);
+	}
+    }
+    locale = __CFLocaleSystem ? (CFLocaleRef)CFRetain(__CFLocaleSystem) : NULL;
+    __CFLocaleUnlockGlobal();
+    return locale;
+}
+
+static CFLocaleRef __CFLocaleCurrent = NULL;
+
+#define FALLBACK_LOCALE_NAME CFSTR("")
+
+CFLocaleRef CFLocaleCopyCurrent(void) {
+
+    __CFLocaleLockGlobal();
+    if (__CFLocaleCurrent) {
+        CFRetain(__CFLocaleCurrent);
+        __CFLocaleUnlockGlobal();
+        return __CFLocaleCurrent;
+    }
+    __CFLocaleUnlockGlobal();
+
+    CFDictionaryRef prefs = NULL;
+    CFStringRef identifier = NULL;
+
+#ifdef DEPLOYMENT_TARGET_WINDOWS
+    identifier = __CFLocaleWindowsLCIDToISOLocaleName(LOCALE_USER_DEFAULT);
+#elif DEPLOYMENT_TARGET_LINUX
+    identifier = __CFLocaleCopyPOSIXLocaleName();
+#endif 
+
+    struct __CFLocale *locale;
+    uint32_t size = sizeof(struct __CFLocale) - sizeof(CFRuntimeBase);
+    locale = (struct __CFLocale *)_CFRuntimeCreateInstance(kCFAllocatorSystemDefault, CFLocaleGetTypeID(), size, NULL);
+    if (NULL == locale) {
+        return NULL;
+    }
+    __CFLocaleSetType(locale, __kCFLocaleUser);
+    if (NULL == identifier) identifier = (CFStringRef)CFRetain(FALLBACK_LOCALE_NAME);
+    locale->_identifier = identifier;
+    locale->_cache = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
+    locale->_overrides = NULL;
+    locale->_prefs = prefs;
+
+    CF_SPINLOCK_INIT_FOR_STRUCTS(locale->_lock);
+
+    __CFLocaleLockGlobal();
+    if (NULL == __CFLocaleCurrent) {
+        __CFLocaleCurrent = locale;
+    } else {
+        CFRelease(locale);
+    }
+    locale = (struct __CFLocale *)CFRetain(__CFLocaleCurrent);
+    __CFLocaleUnlockGlobal();
+    return locale;
+}
+
+__private_extern__ CFDictionaryRef __CFLocaleGetPrefs(CFLocaleRef locale) {
+    return locale->_prefs;
+}
+
+CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef identifier) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(identifier, CFStringGetTypeID());
+    CFStringRef localeIdentifier = NULL;
+    if (identifier) {
+         localeIdentifier = CFLocaleCreateCanonicalLocaleIdentifierFromString(allocator, identifier);
+    }
+    if (NULL == localeIdentifier) return NULL;
+    CFStringRef old = localeIdentifier;
+    localeIdentifier = (CFStringRef)CFStringCreateCopy(allocator, localeIdentifier);
+    CFRelease(old);
+    __CFLocaleLockGlobal();
+    // Look for cases where we can return a cached instance.
+    // We only use cached objects if the allocator is the system
+    // default allocator.
+    if (!allocator) allocator = __CFGetDefaultAllocator();
+    Boolean canCache = (kCFAllocatorSystemDefault == allocator);
+    if (canCache && __CFLocaleCache) {
+        CFLocaleRef locale = (CFLocaleRef)CFDictionaryGetValue(__CFLocaleCache, localeIdentifier);
+        if (locale) {
+             CFRetain(locale);
+             __CFLocaleUnlockGlobal();
+             CFRelease(localeIdentifier);
+             return locale;
+         }
+     }
+    struct __CFLocale *locale = NULL;
+    uint32_t size = sizeof(struct __CFLocale) - sizeof(CFRuntimeBase);
+    locale = (struct __CFLocale *)_CFRuntimeCreateInstance(allocator, CFLocaleGetTypeID(), size, NULL);
+    if (NULL == locale) {
+         return NULL;
+    }
+    __CFLocaleSetType(locale, __kCFLocaleOrdinary);
+    locale->_identifier = localeIdentifier;
+    locale->_cache = CFDictionaryCreateMutable(allocator, 0, NULL, &kCFTypeDictionaryValueCallBacks);
+    locale->_overrides = NULL;
+    locale->_prefs = NULL;
+
+    CF_SPINLOCK_INIT_FOR_STRUCTS(locale->_lock);
+
+    if (canCache) {
+        if (NULL == __CFLocaleCache) {
+            __CFLocaleCache = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        }
+        CFDictionarySetValue(__CFLocaleCache, localeIdentifier, locale);
+    }
+    __CFLocaleUnlockGlobal();
+    return (CFLocaleRef)locale;
+}
+
+CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale) {
+    return (CFLocaleRef)CFRetain(locale);
+}
+
+CFStringRef CFLocaleGetIdentifier(CFLocaleRef locale) {
+    CF_OBJC_FUNCDISPATCH0(CFLocaleGetTypeID(), CFStringRef, locale, "localeIdentifier");
+    return locale->_identifier;
+}
+
+CFTypeRef CFLocaleGetValue(CFLocaleRef locale, CFStringRef key) {
+    CF_OBJC_FUNCDISPATCH1(CFLocaleGetTypeID(), CFTypeRef, locale, "objectForKey:", key);
+    CFIndex idx, slot = -1;
+    for (idx = 0; idx < __kCFLocaleKeyTableCount; idx++) {
+	if (__CFLocaleKeyTable[idx].key == key) {
+	    slot = idx;
+	    break;
+	}
+    }
+    if (-1 == slot && NULL != key) {
+	for (idx = 0; idx < __kCFLocaleKeyTableCount; idx++) {
+	    if (CFEqual(__CFLocaleKeyTable[idx].key, key)) {
+		slot = idx;
+		break;
+	    }
+	}
+    }
+    if (-1 == slot) {
+	return NULL;
+    }
+    CFTypeRef value;
+    if (NULL != locale->_overrides && CFDictionaryGetValueIfPresent(locale->_overrides, __CFLocaleKeyTable[slot].key, &value)) {
+	return value;
+    }
+    __CFLocaleLock(locale);
+    if (CFDictionaryGetValueIfPresent(locale->_cache, __CFLocaleKeyTable[slot].key, &value)) {
+	__CFLocaleUnlock(locale);
+	return value;
+    }
+    if (__kCFLocaleUser == __CFLocaleGetType(locale) && __CFLocaleKeyTable[slot].get(locale, true, &value, __CFLocaleKeyTable[slot].context)) {
+	if (value) CFDictionarySetValue(locale->_cache, __CFLocaleKeyTable[idx].key, value);
+	if (value) CFRelease(value);
+	__CFLocaleUnlock(locale);
+	return value;
+    }
+    if (__CFLocaleKeyTable[slot].get(locale, false, &value, __CFLocaleKeyTable[slot].context)) {
+	if (value) CFDictionarySetValue(locale->_cache, __CFLocaleKeyTable[idx].key, value);
+	if (value) CFRelease(value);
+	__CFLocaleUnlock(locale);
+	return value;
+    }
+    __CFLocaleUnlock(locale);
+    return NULL;
+}
+
+CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, CFStringRef key, CFStringRef value) {
+    CF_OBJC_FUNCDISPATCH2(CFLocaleGetTypeID(), CFStringRef, displayLocale, "_copyDisplayNameForKey:value:", key, value);
+    CFIndex idx, slot = -1;
+    for (idx = 0; idx < __kCFLocaleKeyTableCount; idx++) {
+	if (__CFLocaleKeyTable[idx].key == key) {
+	    slot = idx;
+	    break;
+	}
+    }
+    if (-1 == slot && NULL != key) {
+	for (idx = 0; idx < __kCFLocaleKeyTableCount; idx++) {
+	    if (CFEqual(__CFLocaleKeyTable[idx].key, key)) {
+		slot = idx;
+		break;
+	    }
+	}
+    }
+    if (-1 == slot || !value) {
+	return NULL;
+    }
+    // Get the locale ID as a C string
+    char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    char cValue[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    if (CFStringGetCString(displayLocale->_identifier, localeID, sizeof(localeID)/sizeof(localeID[0]), kCFStringEncodingASCII) && CFStringGetCString(value, cValue, sizeof(cValue)/sizeof(char), kCFStringEncodingASCII)) {
+        CFStringRef result;
+        if ((NULL == displayLocale->_prefs) && __CFLocaleKeyTable[slot].name(localeID, cValue, &result)) {
+            return result;
+        }
+
+        // We could not find a result using the requested language. Fall back through all preferred languages.
+        CFArrayRef langPref;
+	if (displayLocale->_prefs) {
+	    langPref = (CFArrayRef)CFDictionaryGetValue(displayLocale->_prefs, CFSTR("AppleLanguages"));
+	    if (langPref) CFRetain(langPref);
+	} else {
+	    langPref = (CFArrayRef)CFPreferencesCopyAppValue(CFSTR("AppleLanguages"), kCFPreferencesCurrentApplication);
+	}
+        if (langPref != NULL) {
+            CFIndex count = CFArrayGetCount(langPref);
+            CFIndex i;
+            bool success = false;
+            for (i = 0; i < count && !success; ++i) {
+                CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(langPref, i);
+                CFStringRef cleanLanguage = CFLocaleCreateCanonicalLanguageIdentifierFromString(kCFAllocatorSystemDefault, language);
+                if (CFStringGetCString(cleanLanguage, localeID, sizeof(localeID)/sizeof(localeID[0]), kCFStringEncodingASCII)) {
+                    success = __CFLocaleKeyTable[slot].name(localeID, cValue, &result);
+		}
+                CFRelease(cleanLanguage);
+            }
+	    CFRelease(langPref);
+            if (success)
+                return result;
+        }
+    }
+    return NULL;
+}
+
+CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void) {
+    int32_t locale, localeCount = uloc_countAvailable();
+    CFMutableSetRef working = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeSetCallBacks);
+    for (locale = 0; locale < localeCount; ++locale) {
+        const char *localeID = uloc_getAvailable(locale);
+        CFStringRef string1 = CFStringCreateWithCString(kCFAllocatorSystemDefault, localeID, kCFStringEncodingASCII);
+	CFStringRef string2 = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorSystemDefault, string1);
+	CFSetAddValue(working, string1);
+	// do not include canonicalized version as IntlFormats cannot cope with that in its popup
+        CFRelease(string1);
+        CFRelease(string2);
+    }
+    CFIndex cnt = CFSetGetCount(working);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || (DEPLOYMENT_TARGET_WINDOWS && __GNUC__)
+    STACK_BUFFER_DECL(const void *, buffer, cnt);
+#else
+    const void* buffer[BUFFER_SIZE];
+#endif
+    CFSetGetValues(working, buffer);
+    CFArrayRef result = CFArrayCreate(kCFAllocatorSystemDefault, buffer, cnt, &kCFTypeArrayCallBacks);
+    CFRelease(working);
+    return result;
+}
+
+static CFArrayRef __CFLocaleCopyCStringsAsArray(const char* const* p) {
+    CFMutableArrayRef working = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    for (; *p; ++p) {
+        CFStringRef string = CFStringCreateWithCString(kCFAllocatorSystemDefault, *p, kCFStringEncodingASCII);
+        CFArrayAppendValue(working, string);
+        CFRelease(string);
+    }
+    CFArrayRef result = CFArrayCreateCopy(kCFAllocatorSystemDefault, working);
+    CFRelease(working);
+    return result;
+}
+
+static CFArrayRef __CFLocaleCopyUEnumerationAsArray(UEnumeration *enumer, UErrorCode *icuErr) {
+    const UChar *next = NULL;
+    int32_t len = 0;
+    CFMutableArrayRef working = NULL;
+    if (U_SUCCESS(*icuErr)) {
+        working = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    }
+    while ((next = uenum_unext(enumer, &len, icuErr)) && U_SUCCESS(*icuErr)) {
+        CFStringRef string = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (const UniChar *)next, (CFIndex) len);
+        CFArrayAppendValue(working, string);
+        CFRelease(string);
+    }
+    if (*icuErr == U_INDEX_OUTOFBOUNDS_ERROR) {
+        *icuErr = U_ZERO_ERROR;      // Temp: Work around bug (ICU 5220) in ucurr enumerator
+    }
+    CFArrayRef result = NULL;
+    if (U_SUCCESS(*icuErr)) {
+        result = CFArrayCreateCopy(kCFAllocatorSystemDefault, working);
+    }
+    if (working != NULL) {
+        CFRelease(working);
+    }
+    return result;
+}
+
+CFArrayRef CFLocaleCopyISOLanguageCodes(void) {
+    const char* const* p = uloc_getISOLanguages();
+    return __CFLocaleCopyCStringsAsArray(p);
+}
+
+CFArrayRef CFLocaleCopyISOCountryCodes(void) {
+    const char* const* p = uloc_getISOCountries();
+    return __CFLocaleCopyCStringsAsArray(p);
+}
+
+CFArrayRef CFLocaleCopyISOCurrencyCodes(void) {
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    UEnumeration *enumer = ucurr_openISOCurrencies(UCURR_ALL, &icuStatus);
+    CFArrayRef result = __CFLocaleCopyUEnumerationAsArray(enumer, &icuStatus);
+    uenum_close(enumer);
+    return result;
+}
+
+CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) {
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    UEnumeration *enumer = ucurr_openISOCurrencies(UCURR_COMMON|UCURR_NON_DEPRECATED, &icuStatus);
+    CFArrayRef result = __CFLocaleCopyUEnumerationAsArray(enumer, &icuStatus);
+    uenum_close(enumer);
+    return result;
+}
+
+CFArrayRef CFLocaleCopyPreferredLanguages(void) {
+    CFMutableArrayRef newArray = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+   
+#if DEPLOYMENT_TARGET_WINDOWS
+    LANGID langId = GetUserDefaultLangID();
+    CFStringRef lang_name = __CFLocaleWindowsLCIDToISOLocaleName(langId);
+    CFArrayAppendValue(newArray, lang_name);
+#else
+    CFArrayRef languagesArray = (CFArrayRef)CFPreferencesCopyAppValue(CFSTR("AppleLanguages"), kCFPreferencesCurrentApplication);
+    if (languagesArray && (CFArrayGetTypeID() == CFGetTypeID(languagesArray))) {
+        for (CFIndex idx = 0, cnt = CFArrayGetCount(languagesArray); idx < cnt; idx++) {
+            CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(languagesArray, idx);
+            if (str && (CFStringGetTypeID() == CFGetTypeID(str))) {
+                CFStringRef ident = CFLocaleCreateCanonicalLanguageIdentifierFromString(kCFAllocatorSystemDefault, str);
+                CFArrayAppendValue(newArray, ident);
+                CFRelease(ident);
+            }
+        }
+    }
+    if (languagesArray)	CFRelease(languagesArray);
+#endif
+    return newArray;
+}
+
+// -------- -------- -------- -------- -------- --------
+
+// These functions return true or false depending on the success or failure of the function.
+// In the Copy case, this is failure to fill the *cf out parameter, and that out parameter is
+// returned by reference WITH a retain on it.
+static bool __CFLocaleSetNOP(CFMutableLocaleRef locale, CFTypeRef cf, CFStringRef context) {
+    return false;
+}
+
+static bool __CFLocaleCopyLocaleID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    *cf = CFRetain(locale->_identifier);
+    return true;
+}
+
+
+static bool __CFLocaleCopyCodes(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    CFDictionaryRef codes = NULL;
+    // this access of _cache is protected by the lock in CFLocaleGetValue()
+    if (!CFDictionaryGetValueIfPresent(locale->_cache, CFSTR("__kCFLocaleCodes"), (const void **)&codes)) {
+        codes = CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorSystemDefault, locale->_identifier);
+	if (codes) CFDictionarySetValue(locale->_cache, CFSTR("__kCFLocaleCodes"), codes);
+	if (codes) CFRelease(codes);
+    }
+    if (codes) {
+	CFStringRef value = (CFStringRef)CFDictionaryGetValue(codes, context); // context is one of kCFLocale*Code constants
+	if (value) CFRetain(value);
+	*cf = value;
+	return true;
+    }
+    return false;
+}
+
+CFCharacterSetRef _CFCreateCharacterSetFromUSet(USet *set) {
+    UErrorCode icuErr = U_ZERO_ERROR;
+    CFMutableCharacterSetRef working = CFCharacterSetCreateMutable(NULL);
+    UChar   buffer[2048];   // Suitable for most small sets
+    int32_t stringLen;
+
+    if (working == NULL)
+        return NULL;
+
+    int32_t itemCount = uset_getItemCount(set);
+    int32_t i;
+    for (i = 0; i < itemCount; ++i)
+    {
+        UChar32   start, end;
+        UChar * string;
+
+        string = buffer;
+        stringLen = uset_getItem(set, i, &start, &end, buffer, sizeof(buffer)/sizeof(UChar), &icuErr);
+        if (icuErr == U_BUFFER_OVERFLOW_ERROR)
+        {
+            string = (UChar *) malloc(sizeof(UChar)*(stringLen+1));
+            if (!string)
+            {
+                CFRelease(working);
+                return NULL;
+            }
+            icuErr = U_ZERO_ERROR;
+            (void) uset_getItem(set, i, &start, &end, string, stringLen+1, &icuErr);
+        }
+        if (U_FAILURE(icuErr))
+        {
+            if (string != buffer)
+                free(string);
+            CFRelease(working);
+            return NULL;
+        }
+        if (stringLen <= 0)
+            CFCharacterSetAddCharactersInRange(working, CFRangeMake(start, end-start+1));
+        else
+        {
+            CFStringRef cfString = CFStringCreateWithCharactersNoCopy(kCFAllocatorSystemDefault, (UniChar *)string, stringLen, kCFAllocatorNull);
+            CFCharacterSetAddCharactersInString(working, cfString);
+            CFRelease(cfString);
+        }
+        if (string != buffer)
+            free(string);
+    }
+    
+    CFCharacterSetRef   result = CFCharacterSetCreateCopy(kCFAllocatorSystemDefault, working);
+    CFRelease(working);
+    return result;
+}
+
+
+static bool __CFLocaleCopyExemplarCharSet(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII)) {
+        UErrorCode icuStatus = U_ZERO_ERROR;
+	ULocaleData* uld = ulocdata_open(localeID, &icuStatus);
+        USet *set = ulocdata_getExemplarSet(uld, NULL, USET_ADD_CASE_MAPPINGS, ULOCDATA_ES_STANDARD, &icuStatus);
+	ulocdata_close(uld);
+        if (U_FAILURE(icuStatus))
+            return false;
+        if (icuStatus == U_USING_DEFAULT_WARNING)   // If default locale used, force to empty set
+            uset_clear(set);
+        *cf = (CFTypeRef) _CFCreateCharacterSetFromUSet(set);
+        uset_close(set);
+        return (*cf != NULL);
+    }
+    return false;
+}
+
+static bool __CFLocaleCopyICUKeyword(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context, const char *keyword)
+{
+    char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII))
+    {
+        char value[ULOC_KEYWORD_AND_VALUES_CAPACITY];
+        UErrorCode icuStatus = U_ZERO_ERROR;
+        if (uloc_getKeywordValue(localeID, keyword, value, sizeof(value)/sizeof(char), &icuStatus) > 0 && U_SUCCESS(icuStatus))
+        {
+            *cf = (CFTypeRef) CFStringCreateWithCString(kCFAllocatorSystemDefault, value, kCFStringEncodingASCII);
+            return true;
+        }
+    }
+    *cf = NULL;
+    return false;
+}
+
+static bool __CFLocaleCopyCalendarID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    bool succeeded = __CFLocaleCopyICUKeyword(locale, user, cf, context, kCalendarKeyword);
+    if (succeeded) {
+	if (CFEqual(*cf, kCFGregorianCalendar)) {
+	    CFRelease(*cf);
+	    *cf = CFRetain(kCFGregorianCalendar);
+	} else if (CFEqual(*cf, kCFBuddhistCalendar)) {
+	    CFRelease(*cf);
+	    *cf = CFRetain(kCFBuddhistCalendar);
+	} else if (CFEqual(*cf, kCFJapaneseCalendar)) {
+	    CFRelease(*cf);
+	    *cf = CFRetain(kCFJapaneseCalendar);
+	} else if (CFEqual(*cf, kCFIslamicCalendar)) {
+	    CFRelease(*cf);
+	    *cf = CFRetain(kCFIslamicCalendar);
+	} else if (CFEqual(*cf, kCFIslamicCivilCalendar)) {
+	    CFRelease(*cf);
+	    *cf = CFRetain(kCFIslamicCivilCalendar);
+	} else if (CFEqual(*cf, kCFHebrewCalendar)) {
+	    CFRelease(*cf);
+	    *cf = CFRetain(kCFHebrewCalendar);
+	} else if (CFEqual(*cf, kCFChineseCalendar)) {
+	    CFRelease(*cf);
+	    *cf = CFRetain(kCFChineseCalendar);
+	}
+    } else {
+	*cf = CFRetain(kCFGregorianCalendar);
+    }
+    return true;
+}
+
+static bool __CFLocaleCopyCalendar(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    if (__CFLocaleCopyCalendarID(locale, user, cf, context)) {
+	CFCalendarRef calendar = CFCalendarCreateWithIdentifier(kCFAllocatorSystemDefault, (CFStringRef)*cf);
+	CFCalendarSetLocale(calendar, locale);
+	CFRelease(*cf);
+	*cf = calendar;
+	return true;
+    }
+    return false;
+}
+
+static bool __CFLocaleCopyCollationID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    return __CFLocaleCopyICUKeyword(locale, user, cf, context, kCollationKeyword);
+}
+
+static bool __CFLocaleCopyCollatorID(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    CFStringRef canonLocaleCFStr = NULL;
+    if (!canonLocaleCFStr) {
+	canonLocaleCFStr = CFLocaleGetIdentifier(locale);
+	CFRetain(canonLocaleCFStr);
+    }
+    *cf = canonLocaleCFStr;
+    return canonLocaleCFStr ? true : false;
+}
+
+static bool __CFLocaleCopyUsesMetric(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    bool us = false;    // Default is Metric
+    bool done = false;
+
+    if (!done) {
+        char localeID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+        if (CFStringGetCString(locale->_identifier, localeID, sizeof(localeID)/sizeof(char), kCFStringEncodingASCII)) {
+            UErrorCode  icuStatus = U_ZERO_ERROR;
+            UMeasurementSystem ms = UMS_SI;
+            ms = ulocdata_getMeasurementSystem(localeID, &icuStatus);
+            if (U_SUCCESS(icuStatus)) {
+                us = (ms == UMS_US);
+                done = true;
+            }
+        }
+    }
+    if (!done)
+        us = false;
+    *cf = us ? CFRetain(kCFBooleanFalse) : CFRetain(kCFBooleanTrue);
+    return true;
+}
+
+static bool __CFLocaleCopyMeasurementSystem(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    if (__CFLocaleCopyUsesMetric(locale, user, cf, context)) {
+	bool us = (*cf == kCFBooleanFalse);
+	CFRelease(*cf);
+	*cf = us ? CFRetain(CFSTR("U.S.")) : CFRetain(CFSTR("Metric"));
+	return true;
+    }
+    return false;
+}
+
+static bool __CFLocaleCopyNumberFormat(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    CFStringRef str = NULL;
+    CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorSystemDefault, locale, kCFNumberFormatterDecimalStyle);
+    str = nf ? (CFStringRef)CFNumberFormatterCopyProperty(nf, context) : NULL;
+    if (nf) CFRelease(nf);
+    if (str) {
+        *cf = str;
+        return true;
+    }
+    return false;
+}
+
+// ICU does not reliably set up currency info for other than Currency-type formatters,
+// so we have to have another routine here which creates a Currency number formatter.
+static bool __CFLocaleCopyNumberFormat2(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
+    CFStringRef str = NULL;
+    CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorSystemDefault, locale, kCFNumberFormatterCurrencyStyle);
+    str = nf ? (CFStringRef)CFNumberFormatterCopyProperty(nf, context) : NULL;
+    if (nf) CFRelease(nf);
+    if (str) {
+	*cf = str;
+	return true;
+    }
+    return false;
+}
+
+typedef int32_t (*__CFICUFunction)(const char *, const char *, UChar *, int32_t, UErrorCode *);
+
+static bool __CFLocaleICUName(const char *locale, const char *valLocale, CFStringRef *out, __CFICUFunction icu) {
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    int32_t size;
+    UChar name[kMaxICUNameSize];
+
+    size = (*icu)(valLocale, locale, name, kMaxICUNameSize, &icuStatus);
+    if (U_SUCCESS(icuStatus) && size > 0 && icuStatus != U_USING_DEFAULT_WARNING) {
+        *out = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (UniChar *)name, size);
+        return (*out != NULL);
+    }
+    return false;
+}
+
+static bool __CFLocaleICUKeywordValueName(const char *locale, const char *value, const char *keyword, CFStringRef *out) {
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    int32_t size = 0;
+    UChar name[kMaxICUNameSize];
+    // Need to make a fake locale ID
+    char lid[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    if (strlen(value) < ULOC_KEYWORD_AND_VALUES_CAPACITY) {
+        snprintf(lid, sizeof(lid), "en_US@%s=%s", keyword, value);
+        size = uloc_getDisplayKeywordValue(lid, keyword, locale, name, kMaxICUNameSize, &icuStatus);
+        if (U_SUCCESS(icuStatus) && size > 0 && icuStatus != U_USING_DEFAULT_WARNING) {
+            *out = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (UniChar *)name, size);
+            return (*out != NULL);
+        }
+    }
+    return false;
+}
+
+static bool __CFLocaleICUCurrencyName(const char *locale, const char *value, UCurrNameStyle style, CFStringRef *out) {
+    size_t valLen = strlen(value);
+    if (valLen != 3) // not a valid ISO code
+        return false;
+    UChar curr[4];
+    UBool isChoice = FALSE;
+    int32_t size = 0;
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    u_charsToUChars(value, curr, (int32_t)valLen);
+    curr[valLen] = '\0';
+    const UChar *name;
+    name = ucurr_getName(curr, locale, style, &isChoice, &size, &icuStatus);
+    if (U_FAILURE(icuStatus) || icuStatus == U_USING_DEFAULT_WARNING)
+        return false;
+    UChar result[kMaxICUNameSize];
+    if (isChoice)
+    {
+        UChar pattern[kMaxICUNameSize];
+        CFStringRef patternRef = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("{0,choice,%S}"), name);
+        CFIndex pattlen = CFStringGetLength(patternRef);
+        CFStringGetCharacters(patternRef, CFRangeMake(0, pattlen), (UniChar *)pattern);
+        CFRelease(patternRef);
+        pattern[pattlen] = '\0';        // null terminate the pattern
+        // Format the message assuming a large amount of the currency
+        size = u_formatMessage("en_US", pattern, pattlen, result, kMaxICUNameSize, &icuStatus, 10.0);
+        if (U_FAILURE(icuStatus))
+            return false;
+        name = result;
+        
+    }
+    *out = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (UniChar *)name, size);
+    return (*out != NULL);
+}
+
+static bool __CFLocaleFullName(const char *locale, const char *value, CFStringRef *out) {
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    int32_t size;
+    UChar name[kMaxICUNameSize];
+    
+    // First, try to get the full locale.
+    size = uloc_getDisplayName(value, locale, name, kMaxICUNameSize, &icuStatus);
+    if (U_FAILURE(icuStatus) || size <= 0)
+        return false;
+
+    // Did we wind up using a default somewhere?
+    if (icuStatus == U_USING_DEFAULT_WARNING) {
+        // For some locale IDs, there may be no language which has a translation for every
+        // piece. Rather than return nothing, see if we can at least handle
+        // the language part of the locale.
+        UErrorCode localStatus = U_ZERO_ERROR;
+        int32_t localSize;
+        UChar localName[kMaxICUNameSize];
+        localSize = uloc_getDisplayLanguage(value, locale, localName, kMaxICUNameSize, &localStatus);
+        if (U_FAILURE(localStatus) || size <= 0 || localStatus == U_USING_DEFAULT_WARNING)
+            return false;
+    }
+
+    // This locale is OK, so use the result.
+    *out = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (UniChar *)name, size);
+    return (*out != NULL);
+}
+
+static bool __CFLocaleLanguageName(const char *locale, const char *value, CFStringRef *out) {
+    size_t len = strlen(value);
+    if (len >= 2 && len <= 3)
+        return __CFLocaleICUName(locale, value, out, uloc_getDisplayLanguage);
+    return false;
+}
+
+static bool __CFLocaleCountryName(const char *locale, const char *value, CFStringRef *out) {
+    // Need to make a fake locale ID
+    char lid[ULOC_FULLNAME_CAPACITY];
+    if (strlen(value) == 2) {
+        snprintf(lid, sizeof(lid), "en_%s", value);
+        return __CFLocaleICUName(locale, lid, out, uloc_getDisplayCountry);
+    }
+    return false;
+}
+
+static bool __CFLocaleScriptName(const char *locale, const char *value, CFStringRef *out) {
+    // Need to make a fake locale ID
+    char lid[ULOC_FULLNAME_CAPACITY];
+    if (strlen(value) == 4) {
+        snprintf(lid, sizeof(lid), "en_%s_US", value);
+        return __CFLocaleICUName(locale, lid, out, uloc_getDisplayScript);
+    }
+    return false;
+}
+
+static bool __CFLocaleVariantName(const char *locale, const char *value, CFStringRef *out) {
+    // Need to make a fake locale ID
+    char lid[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    if (strlen(value) < ULOC_FULLNAME_CAPACITY) {
+        snprintf(lid, sizeof(lid), "en_US_%s", value);
+        return __CFLocaleICUName(locale, lid, out, uloc_getDisplayVariant);
+    }
+    return false;
+}
+
+static bool __CFLocaleCalendarName(const char *locale, const char *value, CFStringRef *out) {
+    return __CFLocaleICUKeywordValueName(locale, value, kCalendarKeyword, out);
+}
+
+static bool __CFLocaleCollationName(const char *locale, const char *value, CFStringRef *out) {
+    return __CFLocaleICUKeywordValueName(locale, value, kCollationKeyword, out);
+}
+
+static bool __CFLocaleCurrencyShortName(const char *locale, const char *value, CFStringRef *out) {
+    return __CFLocaleICUCurrencyName(locale, value, UCURR_SYMBOL_NAME, out);
+}
+
+static bool __CFLocaleCurrencyFullName(const char *locale, const char *value, CFStringRef *out) {
+    return __CFLocaleICUCurrencyName(locale, value, UCURR_LONG_NAME, out);
+}
+
+static bool __CFLocaleNoName(const char *locale, const char *value, CFStringRef *out) {
+    return false;
+}
+
+// Remember to keep the names such that they would make sense for the user locale,
+// in addition to the others; for example, it is "Currency", not "DefaultCurrency".
+// (And besides, "Default" is almost always implied.)  Words like "Default" and
+// "Preferred" and so on should be left out of the names.
+CONST_STRING_DECL(kCFLocaleIdentifier, "locale:id")
+CONST_STRING_DECL(kCFLocaleLanguageCode, "locale:language code")
+CONST_STRING_DECL(kCFLocaleCountryCode, "locale:country code")
+CONST_STRING_DECL(kCFLocaleScriptCode, "locale:script code")
+CONST_STRING_DECL(kCFLocaleVariantCode, "locale:variant code")
+CONST_STRING_DECL(kCFLocaleExemplarCharacterSet, "locale:exemplar characters")
+CONST_STRING_DECL(kCFLocaleCalendarIdentifier, "calendar")
+CONST_STRING_DECL(kCFLocaleCalendar, "locale:calendarref")
+CONST_STRING_DECL(kCFLocaleCollationIdentifier, "collation")
+CONST_STRING_DECL(kCFLocaleUsesMetricSystem, "locale:uses metric")
+CONST_STRING_DECL(kCFLocaleMeasurementSystem, "locale:measurement system")
+CONST_STRING_DECL(kCFLocaleDecimalSeparator, "locale:decimal separator")
+CONST_STRING_DECL(kCFLocaleGroupingSeparator, "locale:grouping separator")
+CONST_STRING_DECL(kCFLocaleCurrencySymbol, "locale:currency symbol")
+CONST_STRING_DECL(kCFLocaleCurrencyCode, "currency")
+
+CONST_STRING_DECL(kCFGregorianCalendar, "gregorian")
+CONST_STRING_DECL(kCFBuddhistCalendar, "buddhist")
+CONST_STRING_DECL(kCFJapaneseCalendar, "japanese")
+CONST_STRING_DECL(kCFIslamicCalendar, "islamic")
+CONST_STRING_DECL(kCFIslamicCivilCalendar, "islamic-civil")
+CONST_STRING_DECL(kCFHebrewCalendar, "hebrew")
+CONST_STRING_DECL(kCFChineseCalendar, "chinese")
+
+#undef kMaxICUNameSize
+
diff --git a/CoreFoundation/CFLocale.h b/CoreFoundation/CFLocale.h
new file mode 100644
index 0000000..7302a55
--- /dev/null
+++ b/CoreFoundation/CFLocale.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFLOCALE__)
+#define __COREFOUNDATION_CFLOCALE__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDictionary.h>
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+
+CF_EXTERN_C_BEGIN
+
+typedef const struct __CFLocale *CFLocaleRef;
+
+CF_EXPORT
+CFTypeID CFLocaleGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFLocaleRef CFLocaleGetSystem(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Returns the "root", canonical locale.  Contains fixed "backstop" settings.
+
+CF_EXPORT
+CFLocaleRef CFLocaleCopyCurrent(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// Returns an array of CFStrings that represents all locales for
+	// which locale data is available.
+
+CF_EXPORT
+CFArrayRef CFLocaleCopyISOLanguageCodes(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+	// Returns an array of CFStrings that represents ISO currency codes for
+	// currencies in common use.
+
+CF_EXPORT
+CFArrayRef CFLocaleCopyPreferredLanguages(void) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+	// Returns the array of canonicalized CFString locale IDs that the user prefers.
+
+CF_EXPORT
+CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// Map an arbitrary language identification string (something close at
+	// least) to a canonical language identifier.
+
+CF_EXPORT
+CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Map an arbitrary locale identification string (something close at
+	// least) to the canonical identifier.
+
+CF_EXPORT
+CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Map a Mac OS LangCode and RegionCode to the canonical locale identifier.
+
+CF_EXPORT
+CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier.
+
+CF_EXPORT
+CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+	// 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 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+
+// Locale Keys
+CF_EXPORT const CFStringRef kCFLocaleIdentifier AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleLanguageCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleCountryCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleScriptCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleVariantCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // "Metric" or "U.S."
+CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+CF_EXPORT const CFStringRef kCFLocaleCurrencyCode AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // ISO 3-letter currency code
+
+// Values for kCFLocaleCalendarIdentifier
+CF_EXPORT const CFStringRef kCFGregorianCalendar AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+CF_EXPORT const CFStringRef kCFBuddhistCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFChineseCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFHebrewCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFIslamicCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFIslamicCivilCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFJapaneseCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+
+CF_EXTERN_C_END
+
+#endif
+
+#endif /* ! __COREFOUNDATION_CFLOCALE__ */
+
diff --git a/CoreFoundation/CFLocaleIdentifier.c b/CoreFoundation/CFLocaleIdentifier.c
new file mode 100644
index 0000000..b380a89
--- /dev/null
+++ b/CoreFoundation/CFLocaleIdentifier.c
@@ -0,0 +1,1911 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*
+    CFLocaleIdentifier.c
+	Copyright (c) 2002-2007, Apple Inc. All rights reserved.
+    Responsibility: Christopher Kane
+    
+    CFLocaleIdentifier.c defines
+    - enum value kLocaleIdentifierCStringMax
+    - structs KeyStringToResultString, SpecialCaseUpdates
+    and provides the following data for the functions
+    CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes,
+    CFLocaleCreateCanonicalLocaleIdentifierFromString
+    CFLocaleCreateCanonicalLanguageIdentifierFromString
+
+    1. static const char * regionCodeToLocaleString[]; enum kNumRegionCodeToLocaleString;
+        map RegionCode 0..kNumRegionCodeToLocaleString-1 to canonical locale string
+
+    2. static const char * langCodeToLocaleString[]; enum kNumLangCodeToLocaleString;
+        map LangCode 0..kNumLangCodeToLocaleString-1 to canonical locale string
+
+    3. static const KeyStringToResultString oldAppleLocaleToCanonical[]; enum kNumOldAppleLocaleToCanonical;
+        map old Apple string        oldAppleLocaleToCanonical[n].key
+        to canonical locale string  oldAppleLocaleToCanonical[n].result
+        for n = 0..kNumOldAppleLocaleToCanonical-1
+
+    4. static const KeyStringToResultString localeStringPrefixToCanonical[]; enum kNumLocaleStringPrefixToCanonical;
+        map non-canonical language prefix (3-letter, obsolete)  localeStringPrefixToCanonical[].key
+        to updated replacement                                  localeStringPrefixToCanonical[].result
+        for n = 0..kNumLocaleStringPrefixToCanonical-1
+
+    5. static const SpecialCaseUpdates specialCases[];
+        various special cases for updating region codes, or for updating language codes based on region codes
+
+    6. static const KeyStringToResultString localeStringRegionToDefaults[]; enum kNumLocaleStringRegionToDefaults;
+        map locale string region tag    localeStringRegionToDefaults[n].key
+        to default substrings to delete localeStringRegionToDefaults[n].result
+        for n = 0..kNumLocaleStringRegionToDefaults-1
+
+    7. static const KeyStringToResultString localeStringPrefixToDefaults[]; enum kNumLocaleStringPrefixToDefaults;
+        map locale string initial part  localeStringPrefixToDefaults[n].key
+        to default substrings to delete localeStringPrefixToDefaults[n].result
+        for n = 0..kNumLocaleStringPrefixToDefaults-1
+    
+    8. static const KeyStringToResultString appleLocaleToLanguageString[]; enum kNumAppleLocaleToLanguageString;
+        map Apple locale string         appleLocaleToLanguageString[].key
+        to equivalent language string   appleLocaleToLanguageString[].result
+        for n = 0..kNumAppleLocaleToLanguageString-1
+    
+*/
+
+#include <CoreFoundation/CFString.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unicode/uloc.h>
+
+#if DEPLOYMENT_TARGET_WINDOWS
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+extern size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+// Max byte length of locale identifier (ASCII) as C string, including terminating null byte
+enum {
+    kLocaleIdentifierCStringMax = ULOC_FULLNAME_CAPACITY + ULOC_KEYWORD_AND_VALUES_CAPACITY	// currently 56 + 100
+};
+
+// KeyStringToResultString struct used in data tables for CFLocaleCreateCanonicalLocaleIdentifierFromString
+struct KeyStringToResultString {
+    const char *    key;
+    const char *    result;
+};
+typedef struct KeyStringToResultString KeyStringToResultString;
+
+// SpecialCaseUpdates struct used in data tables for CFLocaleCreateCanonicalLocaleIdentifierFromString
+struct SpecialCaseUpdates {
+    const char *    lang;
+    const char *    reg1;
+    const char *    update1;
+    const char *    reg2;
+    const char *    update2;
+};
+typedef struct SpecialCaseUpdates SpecialCaseUpdates;
+
+
+static const char * const regionCodeToLocaleString[] = {
+// map RegionCode (array index) to canonical locale string
+//
+//  canon. string      region code;             language code;      [comment]       [   # __CFBundleLocaleAbbreviationsArray
+//  --------           ------------             ------------------  ------------        --------     string, if different ]
+    "en_US",        //   0 verUS;                 0 langEnglish;
+    "fr_FR",        //   1 verFrance;             1 langFrench;
+    "en_GB",        //   2 verBritain;            0 langEnglish;
+    "de_DE",        //   3 verGermany;            2 langGerman;
+    "it_IT",        //   4 verItaly;              3 langItalian;
+    "nl_NL",        //   5 verNetherlands;        4 langDutch;
+    "nl_BE",        //   6 verFlemish;           34 langFlemish (redundant, =Dutch);
+    "sv_SE",        //   7 verSweden;             5 langSwedish;
+    "es_ES",        //   8 verSpain;              6 langSpanish;
+    "da_DK",        //   9 verDenmark;            7 langDanish;
+    "pt_PT",        //  10 verPortugal;           8 langPortuguese;
+    "fr_CA",        //  11 verFrCanada;           1 langFrench;
+    "nb_NO",        //  12 verNorway;             9 langNorwegian (Bokmal);             # "no_NO"
+    "he_IL",        //  13 verIsrael;            10 langHebrew;
+    "ja_JP",        //  14 verJapan;             11 langJapanese;
+    "en_AU",        //  15 verAustralia;          0 langEnglish;
+    "ar",           //  16 verArabic;            12 langArabic;
+    "fi_FI",        //  17 verFinland;           13 langFinnish;
+    "fr_CH",        //  18 verFrSwiss;            1 langFrench;
+    "de_CH",        //  19 verGrSwiss;            2 langGerman;
+    "el_GR",        //  20 verGreece;            14 langGreek (modern)-Grek-mono;
+    "is_IS",        //  21 verIceland;           15 langIcelandic;
+    "mt_MT",        //  22 verMalta;             16 langMaltese;
+    "el_CY",        //  23 verCyprus;            14 langGreek?;     el or tr? guess el  # ""
+    "tr_TR",        //  24 verTurkey;            17 langTurkish;
+    "hr_HR",        //  25 verYugoCroatian;      18 langCroatian;   * one-way mapping -> verCroatia
+    "nl_NL",        //  26 KCHR, Netherlands;     4 langDutch;      * one-way mapping
+    "nl_BE",        //  27 KCHR, verFlemish;     34 langFlemish;    * one-way mapping
+    "_CA",          //  28 KCHR, Canada-en/fr?;  -1 none;           * one-way mapping   # "en_CA"
+    "_CA",          //  29 KCHR, Canada-en/fr?;  -1 none;           * one-way mapping   # "en_CA"
+    "pt_PT",        //  30 KCHR, Portugal;        8 langPortuguese; * one-way mapping
+    "nb_NO",        //  31 KCHR, Norway;          9 langNorwegian (Bokmal); * one-way mapping   # "no_NO"
+    "da_DK",        //  32 KCHR, Denmark;         7 langDanish;     * one-way mapping
+    "hi_IN",        //  33 verIndiaHindi;        21 langHindi;
+    "ur_PK",        //  34 verPakistanUrdu;      20 langUrdu;
+    "tr_TR",        //  35 verTurkishModified;   17 langTurkish;    * one-way mapping
+    "it_CH",        //  36 verItalianSwiss;       3 langItalian;
+    "en_001",       //  37 verInternational;      0 langEnglish; ASCII only             # "en"
+    NULL,           //  38 *unassigned;          -1 none;           * one-way mapping   # ""
+    "ro_RO",        //  39 verRomania;           37 langRomanian;
+    "grc",          //  40 verGreekAncient;     148 langGreekAncient -Grek-poly;        # "el_GR"
+    "lt_LT",        //  41 verLithuania;         24 langLithuanian;
+    "pl_PL",        //  42 verPoland;            25 langPolish;
+    "hu_HU",        //  43 verHungary;           26 langHungarian;
+    "et_EE",        //  44 verEstonia;           27 langEstonian;
+    "lv_LV",        //  45 verLatvia;            28 langLatvian;
+    "se",           //  46 verSami;              29 langSami;
+    "fo_FO",        //  47 verFaroeIsl;          30 langFaroese;
+    "fa_IR",        //  48 verIran;              31 langFarsi/Persian;
+    "ru_RU",        //  49 verRussia;            32 langRussian;
+    "ga_IE",        //  50 verIreland;           35 langIrishGaelic (no dots);
+    "ko_KR",        //  51 verKorea;             23 langKorean;
+    "zh_CN",        //  52 verChina;             33 langSimpChinese;
+    "zh_TW",        //  53 verTaiwan;            19 langTradChinese;
+    "th_TH",        //  54 verThailand;          22 langThai;
+    "und",          //  55 verScriptGeneric;     -1 none;                               # ""        // <1.9>
+    "cs_CZ",        //  56 verCzech;             38 langCzech;
+    "sk_SK",        //  57 verSlovak;            39 langSlovak;
+    "und",          //  58 verEastAsiaGeneric;   -1 none;           * one-way mapping   # ""        // <1.9>
+    "hu_HU",        //  59 verMagyar;            26 langHungarian;  * one-way mapping -> verHungary
+    "bn",           //  60 verBengali;           67 langBengali;    _IN or _BD? guess generic
+    "be_BY",        //  61 verBelarus;           46 langBelorussian;
+    "uk_UA",        //  62 verUkraine;           45 langUkrainian;
+    NULL,           //  63 *unused;              -1 none;           * one-way mapping   # ""
+    "el_GR",        //  64 verGreeceAlt;         14 langGreek (modern)-Grek-mono;   * one-way mapping
+    "sr_CS",        //  65 verSerbian;           42 langSerbian -Cyrl;								// <1.18>
+    "sl_SI",        //  66 verSlovenian;         40 langSlovenian;
+    "mk_MK",        //  67 verMacedonian;        43 langMacedonian;
+    "hr_HR",        //  68 verCroatia;           18 langCroatian;
+    NULL,           //  69 *unused;              -1 none;           * one-way mapping   # ""
+    "de-1996",      //  70 verGermanReformed;     2 langGerman;     1996 orthogr.       # "de_DE"
+    "pt_BR",        //  71 verBrazil;             8 langPortuguese;
+    "bg_BG",        //  72 verBulgaria;          44 langBulgarian;
+    "ca_ES",        //  73 verCatalonia;        130 langCatalan;
+    "mul",          //  74 verMultilingual;      -1 none;                               # ""
+    "gd",           //  75 verScottishGaelic;   144 langScottishGaelic;
+    "gv",           //  76 verManxGaelic;       145 langManxGaelic;
+    "br",           //  77 verBreton;           142 langBreton;
+    "iu_CA",        //  78 verNunavut;          143 langInuktitut -Cans;
+    "cy",           //  79 verWelsh;            128 langWelsh;
+    "_CA",          //  80 KCHR, Canada-en/fr?;  -1 none;           * one-way mapping   # "en_CA"
+    "ga-Latg_IE",   //  81 verIrishGaelicScrip; 146 langIrishGaelicScript -dots;        # "ga_IE"   // <xx>
+    "en_CA",        //  82 verEngCanada;          0 langEnglish;
+    "dz_BT",        //  83 verBhutan;           137 langDzongkha;
+    "hy_AM",        //  84 verArmenian;          51 langArmenian;
+    "ka_GE",        //  85 verGeorgian;          52 langGeorgian;
+    "es_419",       //  86 verSpLatinAmerica;     6 langSpanish;                        # "es"
+    "es_ES",        //  87 KCHR, Spain;           6 langSpanish;    * one-way mapping
+    "to_TO",        //  88 verTonga;            147 langTongan;
+    "pl_PL",        //  89 KCHR, Poland;         25 langPolish;     * one-way mapping
+    "ca_ES",        //  90 KCHR, Catalonia;     130 langCatalan;    * one-way mapping
+    "fr_001",       //  91 verFrenchUniversal;    1 langFrench;
+    "de_AT",        //  92 verAustria;            2 langGerman;
+    "es_419",       //  93 > verSpLatinAmerica;   6 langSpanish;    * one-way mapping   # "es"
+    "gu_IN",        //  94 verGujarati;          69 langGujarati;
+    "pa",           //  95 verPunjabi;           70 langPunjabi;    _IN or _PK? guess generic
+    "ur_IN",        //  96 verIndiaUrdu;         20 langUrdu;
+    "vi_VN",        //  97 verVietnam;           80 langVietnamese;
+    "fr_BE",        //  98 verFrBelgium;          1 langFrench;
+    "uz_UZ",        //  99 verUzbek;             47 langUzbek;
+    "en_SG",        // 100 verSingapore;          0 langEnglish?; en, zh, or ms? guess en   # ""
+    "nn_NO",        // 101 verNynorsk;          151 langNynorsk;                        # ""
+    "af_ZA",        // 102 verAfrikaans;        141 langAfrikaans;
+    "eo",           // 103 verEsperanto;         94 langEsperanto;
+    "mr_IN",        // 104 verMarathi;           66 langMarathi;
+    "bo",           // 105 verTibetan;           63 langTibetan;
+    "ne_NP",        // 106 verNepal;             64 langNepali;
+    "kl",           // 107 verGreenland;        149 langGreenlandic;
+    "en_IE",        // 108 verIrelandEnglish;     0 langEnglish;                        # (no entry)
+};
+enum {
+    kNumRegionCodeToLocaleString = sizeof(regionCodeToLocaleString)/sizeof(char *)
+};
+
+static const char * const langCodeToLocaleString[] = {
+// map LangCode (array index) to canonical locale string
+//
+//  canon. string   language code;                  [ comment]  [   # __CFBundleLanguageAbbreviationsArray
+//  --------        --------------                  ----------      --------    string, if different ]
+    "en",       //   0 langEnglish;
+    "fr",       //   1 langFrench;
+    "de",       //   2 langGerman;
+    "it",       //   3 langItalian;
+    "nl",       //   4 langDutch;
+    "sv",       //   5 langSwedish;
+    "es",       //   6 langSpanish;
+    "da",       //   7 langDanish;
+    "pt",       //   8 langPortuguese;
+    "nb",       //   9 langNorwegian (Bokmal);                      # "no"
+    "he",       //  10 langHebrew -Hebr;
+    "ja",       //  11 langJapanese -Jpan;
+    "ar",       //  12 langArabic -Arab;
+    "fi",       //  13 langFinnish;
+    "el",       //  14 langGreek (modern)-Grek-mono;
+    "is",       //  15 langIcelandic;
+    "mt",       //  16 langMaltese -Latn;
+    "tr",       //  17 langTurkish -Latn;
+    "hr",       //  18 langCroatian;
+    "zh-Hant",  //  19 langTradChinese;                             # "zh"
+    "ur",       //  20 langUrdu -Arab;
+    "hi",       //  21 langHindi -Deva;
+    "th",       //  22 langThai -Thai;
+    "ko",       //  23 langKorean -Hang;
+    "lt",       //  24 langLithuanian;
+    "pl",       //  25 langPolish;
+    "hu",       //  26 langHungarian;
+    "et",       //  27 langEstonian;
+    "lv",       //  28 langLatvian;
+    "se",       //  29 langSami;
+    "fo",       //  30 langFaroese;
+    "fa",       //  31 langFarsi/Persian -Arab;
+    "ru",       //  32 langRussian -Cyrl;
+    "zh-Hans",  //  33 langSimpChinese;                             # "zh"
+    "nl-BE",    //  34 langFlemish (redundant, =Dutch);             # "nl"
+    "ga",       //  35 langIrishGaelic (no dots);
+    "sq",       //  36 langAlbanian;                no region codes
+    "ro",       //  37 langRomanian;
+    "cs",       //  38 langCzech;
+    "sk",       //  39 langSlovak;
+    "sl",       //  40 langSlovenian;
+    "yi",       //  41 langYiddish -Hebr;           no region codes
+    "sr",       //  42 langSerbian -Cyrl;
+    "mk",       //  43 langMacedonian -Cyrl;
+    "bg",       //  44 langBulgarian -Cyrl;
+    "uk",       //  45 langUkrainian -Cyrl;
+    "be",       //  46 langBelorussian -Cyrl;
+    "uz-Cyrl",  //  47 langUzbek -Cyrl;             also -Latn, -Arab
+    "kk",       //  48 langKazakh -Cyrl;            no region codes; also -Latn, -Arab
+    "az-Cyrl",  //  49 langAzerbaijani -Cyrl;       no region codes # "az"
+    "az-Arab",  //  50 langAzerbaijanAr -Arab;      no region codes # "az"
+    "hy",       //  51 langArmenian -Armn;
+    "ka",       //  52 langGeorgian -Geor;
+    "mo",       //  53 langMoldavian -Cyrl;         no region codes
+    "ky",       //  54 langKirghiz -Cyrl;           no region codes; also -Latn, -Arab
+    "tg-Cyrl",  //  55 langTajiki -Cyrl;            no region codes; also -Latn, -Arab
+    "tk-Cyrl",  //  56 langTurkmen -Cyrl;           no region codes; also -Latn, -Arab
+    "mn-Mong",  //  57 langMongolian -Mong;         no region codes # "mn"
+    "mn-Cyrl",  //  58 langMongolianCyr -Cyrl;      no region codes # "mn"
+    "ps",       //  59 langPashto -Arab;            no region codes
+    "ku",       //  60 langKurdish -Arab;           no region codes
+    "ks",       //  61 langKashmiri -Arab;          no region codes
+    "sd",       //  62 langSindhi -Arab;            no region codes
+    "bo",       //  63 langTibetan -Tibt;
+    "ne",       //  64 langNepali -Deva;
+    "sa",       //  65 langSanskrit -Deva;          no region codes
+    "mr",       //  66 langMarathi -Deva;
+    "bn",       //  67 langBengali -Beng;
+    "as",       //  68 langAssamese -Beng;          no region codes
+    "gu",       //  69 langGujarati -Gujr;
+    "pa",       //  70 langPunjabi -Guru;
+    "or",       //  71 langOriya -Orya;             no region codes
+    "ml",       //  72 langMalayalam -Mlym;         no region codes
+    "kn",       //  73 langKannada -Knda;           no region codes
+    "ta",       //  74 langTamil -Taml;             no region codes
+    "te",       //  75 langTelugu -Telu;            no region codes
+    "si",       //  76 langSinhalese -Sinh;         no region codes
+    "my",       //  77 langBurmese -Mymr;           no region codes
+    "km",       //  78 langKhmer -Khmr;             no region codes
+    "lo",       //  79 langLao -Laoo;               no region codes
+    "vi",       //  80 langVietnamese -Latn;
+    "id",       //  81 langIndonesian -Latn;        no region codes
+    "tl",       //  82 langTagalog -Latn;           no region codes
+    "ms",       //  83 langMalayRoman -Latn;        no region codes # "ms"
+    "ms-Arab",  //  84 langMalayArabic -Arab;       no region codes # "ms"
+    "am",       //  85 langAmharic -Ethi;           no region codes
+    "ti",       //  86 langTigrinya -Ethi;          no region codes
+    "om",       //  87 langOromo -Ethi;             no region codes
+    "so",       //  88 langSomali -Latn;            no region codes
+    "sw",       //  89 langSwahili -Latn;           no region codes
+    "rw",       //  90 langKinyarwanda -Latn;       no region codes
+    "rn",       //  91 langRundi -Latn;             no region codes
+    "ny",       //  92 langNyanja/Chewa -Latn;      no region codes # ""
+    "mg",       //  93 langMalagasy -Latn;          no region codes
+    "eo",       //  94 langEsperanto -Latn;
+    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, //  95 to 105 (gap)
+    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, // 106 to 116 (gap)
+    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, // 107 to 117 (gap)
+    "cy",       // 128 langWelsh -Latn;
+    "eu",       // 129 langBasque -Latn;            no region codes
+    "ca",       // 130 langCatalan -Latn;
+    "la",       // 131 langLatin -Latn;             no region codes
+    "qu",       // 132 langQuechua -Latn;           no region codes
+    "gn",       // 133 langGuarani -Latn;           no region codes
+    "ay",       // 134 langAymara -Latn;            no region codes
+    "tt-Cyrl",  // 135 langTatar -Cyrl;             no region codes
+    "ug",       // 136 langUighur -Arab;            no region codes
+    "dz",       // 137 langDzongkha -Tibt;
+    "jv",       // 138 langJavaneseRom -Latn;       no region codes
+    "su",       // 139 langSundaneseRom -Latn;      no region codes
+    "gl",       // 140 langGalician -Latn;          no region codes
+    "af",       // 141 langAfrikaans -Latn;
+    "br",       // 142 langBreton -Latn;
+    "iu",       // 143 langInuktitut -Cans;
+    "gd",       // 144 langScottishGaelic;
+    "gv",       // 145 langManxGaelic -Latn;
+    "ga-Latg",  // 146 langIrishGaelicScript  -Latn-dots;           # "ga"                                      // <xx>
+    "to",       // 147 langTongan -Latn;
+    "grc",      // 148 langGreekAncient -Grek-poly;                 # "el"
+    "kl",       // 149 langGreenlandic -Latn;
+    "az-Latn",  // 150 langAzerbaijanRoman -Latn;   no region codes # "az"
+    "nn",       // 151 langNynorsk -Latn;                           # (no entry)
+};
+enum {
+    kNumLangCodeToLocaleString = sizeof(langCodeToLocaleString)/sizeof(char *)
+};
+
+static const KeyStringToResultString oldAppleLocaleToCanonical[] = {
+// Map obsolete/old-style Apple strings to canonical
+// Must be sorted according to how strcmp compares the strings in the first column
+//
+//    non-canonical             canonical       [  comment ]            # source/reason for non-canonical string
+//    string                    string
+//    -------------             ---------
+    { "Afrikaans",              "af"        },  //                      # __CFBundleLanguageNamesArray
+    { "Albanian",               "sq"        },  //                      # __CFBundleLanguageNamesArray
+    { "Amharic",                "am"        },  //                      # __CFBundleLanguageNamesArray
+    { "Arabic",                 "ar"        },  //                      # __CFBundleLanguageNamesArray
+    { "Armenian",               "hy"        },  //                      # __CFBundleLanguageNamesArray
+    { "Assamese",               "as"        },  //                      # __CFBundleLanguageNamesArray
+    { "Aymara",                 "ay"        },  //                      # __CFBundleLanguageNamesArray
+    { "Azerbaijani",            "az"        },  // -Arab,-Cyrl,-Latn?   # __CFBundleLanguageNamesArray (had 3 entries "Azerbaijani" for "az-Arab", "az-Cyrl", "az-Latn")
+    { "Basque",                 "eu"        },  //                      # __CFBundleLanguageNamesArray
+    { "Belarusian",             "be"        },  //                      # handle other names
+    { "Belorussian",            "be"        },  //                      # handle other names
+    { "Bengali",                "bn"        },  //                      # __CFBundleLanguageNamesArray
+    { "Brazilian Portugese",    "pt-BR"     },  //                      # from Installer.app Info.plist IFLanguages key, misspelled
+    { "Brazilian Portuguese",   "pt-BR"     },  //                      # correct spelling for above
+    { "Breton",                 "br"        },  //                      # __CFBundleLanguageNamesArray
+    { "Bulgarian",              "bg"        },  //                      # __CFBundleLanguageNamesArray
+    { "Burmese",                "my"        },  //                      # __CFBundleLanguageNamesArray
+    { "Byelorussian",           "be"        },  //                      # __CFBundleLanguageNamesArray
+    { "Catalan",                "ca"        },  //                      # __CFBundleLanguageNamesArray
+    { "Chewa",                  "ny"        },  //                      # handle other names
+    { "Chichewa",               "ny"        },  //                      # handle other names
+    { "Chinese",                "zh"        },  // -Hans,-Hant?         # __CFBundleLanguageNamesArray (had 2 entries "Chinese" for "zh-Hant", "zh-Hans")
+    { "Chinese, Simplified",    "zh-Hans"   },  //                      # from Installer.app Info.plist IFLanguages key
+    { "Chinese, Traditional",   "zh-Hant"   },  //                      # correct spelling for below
+    { "Chinese, Tradtional",    "zh-Hant"   },  //                      # from Installer.app Info.plist IFLanguages key, misspelled
+    { "Croatian",               "hr"        },  //                      # __CFBundleLanguageNamesArray
+    { "Czech",                  "cs"        },  //                      # __CFBundleLanguageNamesArray
+    { "Danish",                 "da"        },  //                      # __CFBundleLanguageNamesArray
+    { "Dutch",                  "nl"        },  //                      # __CFBundleLanguageNamesArray (had 2 entries "Dutch" for "nl", "nl-BE")
+    { "Dzongkha",               "dz"        },  //                      # __CFBundleLanguageNamesArray
+    { "English",                "en"        },  //                      # __CFBundleLanguageNamesArray
+    { "Esperanto",              "eo"        },  //                      # __CFBundleLanguageNamesArray
+    { "Estonian",               "et"        },  //                      # __CFBundleLanguageNamesArray
+    { "Faroese",                "fo"        },  //                      # __CFBundleLanguageNamesArray
+    { "Farsi",                  "fa"        },  //                      # __CFBundleLanguageNamesArray
+    { "Finnish",                "fi"        },  //                      # __CFBundleLanguageNamesArray
+    { "Flemish",                "nl-BE"     },  //                      # handle other names
+    { "French",                 "fr"        },  //                      # __CFBundleLanguageNamesArray
+    { "Galician",               "gl"        },  //                      # __CFBundleLanguageNamesArray
+    { "Gallegan",               "gl"        },  //                      # handle other names
+    { "Georgian",               "ka"        },  //                      # __CFBundleLanguageNamesArray
+    { "German",                 "de"        },  //                      # __CFBundleLanguageNamesArray
+    { "Greek",                  "el"        },  //                      # __CFBundleLanguageNamesArray (had 2 entries "Greek" for "el", "grc")
+    { "Greenlandic",            "kl"        },  //                      # __CFBundleLanguageNamesArray
+    { "Guarani",                "gn"        },  //                      # __CFBundleLanguageNamesArray
+    { "Gujarati",               "gu"        },  //                      # __CFBundleLanguageNamesArray
+    { "Hawaiian",               "haw"       },  //                      # handle new languages
+    { "Hebrew",                 "he"        },  //                      # __CFBundleLanguageNamesArray
+    { "Hindi",                  "hi"        },  //                      # __CFBundleLanguageNamesArray
+    { "Hungarian",              "hu"        },  //                      # __CFBundleLanguageNamesArray
+    { "Icelandic",              "is"        },  //                      # __CFBundleLanguageNamesArray
+    { "Indonesian",             "id"        },  //                      # __CFBundleLanguageNamesArray
+    { "Inuktitut",              "iu"        },  //                      # __CFBundleLanguageNamesArray
+    { "Irish",                  "ga"        },  //                      # __CFBundleLanguageNamesArray (had 2 entries "Irish" for "ga", "ga-dots")
+    { "Italian",                "it"        },  //                      # __CFBundleLanguageNamesArray
+    { "Japanese",               "ja"        },  //                      # __CFBundleLanguageNamesArray
+    { "Javanese",               "jv"        },  //                      # __CFBundleLanguageNamesArray
+    { "Kalaallisut",            "kl"        },  //                      # handle other names
+    { "Kannada",                "kn"        },  //                      # __CFBundleLanguageNamesArray
+    { "Kashmiri",               "ks"        },  //                      # __CFBundleLanguageNamesArray
+    { "Kazakh",                 "kk"        },  //                      # __CFBundleLanguageNamesArray
+    { "Khmer",                  "km"        },  //                      # __CFBundleLanguageNamesArray
+    { "Kinyarwanda",            "rw"        },  //                      # __CFBundleLanguageNamesArray
+    { "Kirghiz",                "ky"        },  //                      # __CFBundleLanguageNamesArray
+    { "Korean",                 "ko"        },  //                      # __CFBundleLanguageNamesArray
+    { "Kurdish",                "ku"        },  //                      # __CFBundleLanguageNamesArray
+    { "Lao",                    "lo"        },  //                      # __CFBundleLanguageNamesArray
+    { "Latin",                  "la"        },  //                      # __CFBundleLanguageNamesArray
+    { "Latvian",                "lv"        },  //                      # __CFBundleLanguageNamesArray
+    { "Lithuanian",             "lt"        },  //                      # __CFBundleLanguageNamesArray
+    { "Macedonian",             "mk"        },  //                      # __CFBundleLanguageNamesArray
+    { "Malagasy",               "mg"        },  //                      # __CFBundleLanguageNamesArray
+    { "Malay",                  "ms"        },  // -Latn,-Arab?         # __CFBundleLanguageNamesArray (had 2 entries "Malay" for "ms-Latn", "ms-Arab")
+    { "Malayalam",              "ml"        },  //                      # __CFBundleLanguageNamesArray
+    { "Maltese",                "mt"        },  //                      # __CFBundleLanguageNamesArray
+    { "Manx",                   "gv"        },  //                      # __CFBundleLanguageNamesArray
+    { "Marathi",                "mr"        },  //                      # __CFBundleLanguageNamesArray
+    { "Moldavian",              "mo"        },  //                      # __CFBundleLanguageNamesArray
+    { "Mongolian",              "mn"        },  // -Mong,-Cyrl?         # __CFBundleLanguageNamesArray (had 2 entries "Mongolian" for "mn-Mong", "mn-Cyrl")
+    { "Nepali",                 "ne"        },  //                      # __CFBundleLanguageNamesArray
+    { "Norwegian",              "nb"        },  //                      # __CFBundleLanguageNamesArray (had "Norwegian" mapping to "no")
+    { "Nyanja",                 "ny"        },  //                      # __CFBundleLanguageNamesArray
+    { "Nynorsk",                "nn"        },  //                      # handle other names (no entry in __CFBundleLanguageNamesArray)
+    { "Oriya",                  "or"        },  //                      # __CFBundleLanguageNamesArray
+    { "Oromo",                  "om"        },  //                      # __CFBundleLanguageNamesArray
+    { "Panjabi",                "pa"        },  //                      # handle other names
+    { "Pashto",                 "ps"        },  //                      # __CFBundleLanguageNamesArray
+    { "Persian",                "fa"        },  //                      # handle other names
+    { "Polish",                 "pl"        },  //                      # __CFBundleLanguageNamesArray
+    { "Portuguese",             "pt"        },  //                      # __CFBundleLanguageNamesArray
+    { "Portuguese, Brazilian",  "pt-BR"     },  //                      # handle other names
+    { "Punjabi",                "pa"        },  //                      # __CFBundleLanguageNamesArray
+    { "Pushto",                 "ps"        },  //                      # handle other names
+    { "Quechua",                "qu"        },  //                      # __CFBundleLanguageNamesArray
+    { "Romanian",               "ro"        },  //                      # __CFBundleLanguageNamesArray
+    { "Ruanda",                 "rw"        },  //                      # handle other names
+    { "Rundi",                  "rn"        },  //                      # __CFBundleLanguageNamesArray
+    { "Russian",                "ru"        },  //                      # __CFBundleLanguageNamesArray
+    { "Sami",                   "se"        },  //                      # __CFBundleLanguageNamesArray
+    { "Sanskrit",               "sa"        },  //                      # __CFBundleLanguageNamesArray
+    { "Scottish",               "gd"        },  //                      # __CFBundleLanguageNamesArray
+    { "Serbian",                "sr"        },  //                      # __CFBundleLanguageNamesArray
+    { "Simplified Chinese",     "zh-Hans"   },  //                      # handle other names
+    { "Sindhi",                 "sd"        },  //                      # __CFBundleLanguageNamesArray
+    { "Sinhalese",              "si"        },  //                      # __CFBundleLanguageNamesArray
+    { "Slovak",                 "sk"        },  //                      # __CFBundleLanguageNamesArray
+    { "Slovenian",              "sl"        },  //                      # __CFBundleLanguageNamesArray
+    { "Somali",                 "so"        },  //                      # __CFBundleLanguageNamesArray
+    { "Spanish",                "es"        },  //                      # __CFBundleLanguageNamesArray
+    { "Sundanese",              "su"        },  //                      # __CFBundleLanguageNamesArray
+    { "Swahili",                "sw"        },  //                      # __CFBundleLanguageNamesArray
+    { "Swedish",                "sv"        },  //                      # __CFBundleLanguageNamesArray
+    { "Tagalog",                "tl"        },  //                      # __CFBundleLanguageNamesArray
+    { "Tajik",                  "tg"        },  //                      # handle other names
+    { "Tajiki",                 "tg"        },  //                      # __CFBundleLanguageNamesArray
+    { "Tamil",                  "ta"        },  //                      # __CFBundleLanguageNamesArray
+    { "Tatar",                  "tt"        },  //                      # __CFBundleLanguageNamesArray
+    { "Telugu",                 "te"        },  //                      # __CFBundleLanguageNamesArray
+    { "Thai",                   "th"        },  //                      # __CFBundleLanguageNamesArray
+    { "Tibetan",                "bo"        },  //                      # __CFBundleLanguageNamesArray
+    { "Tigrinya",               "ti"        },  //                      # __CFBundleLanguageNamesArray
+    { "Tongan",                 "to"        },  //                      # __CFBundleLanguageNamesArray
+    { "Traditional Chinese",    "zh-Hant"   },  //                      # handle other names
+    { "Turkish",                "tr"        },  //                      # __CFBundleLanguageNamesArray
+    { "Turkmen",                "tk"        },  //                      # __CFBundleLanguageNamesArray
+    { "Uighur",                 "ug"        },  //                      # __CFBundleLanguageNamesArray
+    { "Ukrainian",              "uk"        },  //                      # __CFBundleLanguageNamesArray
+    { "Urdu",                   "ur"        },  //                      # __CFBundleLanguageNamesArray
+    { "Uzbek",                  "uz"        },  //                      # __CFBundleLanguageNamesArray
+    { "Vietnamese",             "vi"        },  //                      # __CFBundleLanguageNamesArray
+    { "Welsh",                  "cy"        },  //                      # __CFBundleLanguageNamesArray
+    { "Yiddish",                "yi"        },  //                      # __CFBundleLanguageNamesArray
+    { "ar_??",                  "ar"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "az.Ar",                  "az-Arab"   },  //                      # from old LocaleRefGetPartString
+    { "az.Cy",                  "az-Cyrl"   },  //                      # from old LocaleRefGetPartString
+    { "az.La",                  "az-Latn"   },  //                      # from old LocaleRefGetPartString
+    { "be_??",                  "be_BY"     },  //                      # from old MapScriptInfoAndISOCodes
+    { "bn_??",                  "bn"        },  //                      # from old LocaleRefGetPartString
+    { "bo_??",                  "bo"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "br_??",                  "br"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "cy_??",                  "cy"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "de-96",                  "de-1996"   },  //                      # from old MapScriptInfoAndISOCodes                     // <1.9>
+    { "de_96",                  "de-1996"   },  //                      # from old MapScriptInfoAndISOCodes                     // <1.9>
+    { "de_??",                  "de-1996"   },  //                      # from old MapScriptInfoAndISOCodes
+    { "el.El-P",                "grc"       },  //                      # from old LocaleRefGetPartString
+    { "en-ascii",               "en_001"    },  //                      # from earlier version of tables in this file!
+    { "en_??",                  "en_001"    },  //                      # from old MapScriptInfoAndISOCodes
+    { "eo_??",                  "eo"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "es_??",                  "es_419"    },  //                      # from old MapScriptInfoAndISOCodes
+    { "es_XL",                  "es_419"    },  //                      # from earlier version of tables in this file!
+    { "fr_??",                  "fr_001"    },  //                      # from old MapScriptInfoAndISOCodes
+    { "ga-dots",                "ga-Latg"   },  //                      # from earlier version of tables in this file!          // <1.8>
+    { "ga-dots_IE",             "ga-Latg_IE" }, //                      # from earlier version of tables in this file!          // <1.8>
+    { "ga.Lg",                  "ga-Latg"   },  //                      # from old LocaleRefGetPartString                       // <1.8>
+    { "ga.Lg_IE",               "ga-Latg_IE" }, //                      # from old LocaleRefGetPartString                       // <1.8>
+    { "gd_??",                  "gd"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "gv_??",                  "gv"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "jv.La",                  "jv"        },  //                      # logical extension                                     // <1.9>
+    { "jw.La",                  "jv"        },  //                      # from old LocaleRefGetPartString
+    { "kk.Cy",                  "kk"        },  //                      # from old LocaleRefGetPartString
+    { "kl.La",                  "kl"        },  //                      # from old LocaleRefGetPartString
+    { "kl.La_GL",               "kl_GL"     },  //                      # from old LocaleRefGetPartString                       // <1.9>
+    { "lp_??",                  "se"        },  //                      # from old MapScriptInfoAndISOCodes
+    { "mk_??",                  "mk_MK"     },  //                      # from old MapScriptInfoAndISOCodes
+    { "mn.Cy",                  "mn-Cyrl"   },  //                      # from old LocaleRefGetPartString
+    { "mn.Mn",                  "mn-Mong"   },  //                      # from old LocaleRefGetPartString
+    { "ms.Ar",                  "ms-Arab"   },  //                      # from old LocaleRefGetPartString
+    { "ms.La",                  "ms"        },  //                      # from old LocaleRefGetPartString
+    { "nl-be",                  "nl-BE"     },  //                      # from old LocaleRefGetPartString
+    { "nl-be_BE",               "nl_BE"     },  //                      # from old LocaleRefGetPartString
+//  { "no-bok_NO",              "nb_NO"     },  //                      # from old LocaleRefGetPartString - handled by localeStringPrefixToCanonical
+//  { "no-nyn_NO",              "nn_NO"     },  //                      # from old LocaleRefGetPartString - handled by localeStringPrefixToCanonical
+//  { "nya",                    "ny"        },  //                      # from old LocaleRefGetPartString - handled by localeStringPrefixToCanonical
+    { "pa_??",                  "pa"        },  //                      # from old LocaleRefGetPartString
+    { "sa.Dv",                  "sa"        },  //                      # from old LocaleRefGetPartString
+    { "sl_??",                  "sl_SI"     },  //                      # from old MapScriptInfoAndISOCodes
+    { "sr_??",                  "sr_CS"     },  //                      # from old MapScriptInfoAndISOCodes						// <1.18>
+    { "su.La",                  "su"        },  //                      # from old LocaleRefGetPartString
+    { "yi.He",                  "yi"        },  //                      # from old LocaleRefGetPartString
+    { "zh-simp",                "zh-Hans"   },  //                      # from earlier version of tables in this file!
+    { "zh-trad",                "zh-Hant"   },  //                      # from earlier version of tables in this file!
+    { "zh.Ha-S",                "zh-Hans"   },  //                      # from old LocaleRefGetPartString
+    { "zh.Ha-S_CN",             "zh_CN"     },  //                      # from old LocaleRefGetPartString
+    { "zh.Ha-T",                "zh-Hant"   },  //                      # from old LocaleRefGetPartString
+    { "zh.Ha-T_TW",             "zh_TW"     },  //                      # from old LocaleRefGetPartString
+};
+enum {
+    kNumOldAppleLocaleToCanonical = sizeof(oldAppleLocaleToCanonical)/sizeof(KeyStringToResultString)
+};
+
+static const KeyStringToResultString localeStringPrefixToCanonical[] = {
+// Map 3-letter & obsolete ISO 639 codes, plus obsolete RFC 3066 codes, to 2-letter ISO 639 code.
+// (special cases for 'sh' handled separately)
+// First column must be all lowercase; must be sorted according to how strcmp compares the strings in the first column.
+//
+//    non-canonical canonical       [  comment ]                # source/reason for non-canonical string
+//    prefix        prefix
+//    ------------- ---------
+
+    { "afr",        "af"        },  // Afrikaans
+    { "alb",        "sq"        },  // Albanian
+    { "amh",        "am"        },  // Amharic
+    { "ara",        "ar"        },  // Arabic
+    { "arm",        "hy"        },  // Armenian
+    { "asm",        "as"        },  // Assamese
+    { "aym",        "ay"        },  // Aymara
+    { "aze",        "az"        },  // Azerbaijani
+    { "baq",        "eu"        },  // Basque
+    { "bel",        "be"        },  // Belarusian
+    { "ben",        "bn"        },  // Bengali
+    { "bih",        "bh"        },  // Bihari
+    { "bod",        "bo"        },  // Tibetan
+    { "bos",        "bs"        },  // Bosnian
+    { "bre",        "br"        },  // Breton
+    { "bul",        "bg"        },  // Bulgarian
+    { "bur",        "my"        },  // Burmese
+    { "cat",        "ca"        },  // Catalan
+    { "ces",        "cs"        },  // Czech
+    { "che",        "ce"        },  // Chechen
+    { "chi",        "zh"        },  // Chinese
+    { "cor",        "kw"        },  // Cornish
+    { "cos",        "co"        },  // Corsican
+    { "cym",        "cy"        },  // Welsh
+    { "cze",        "cs"        },  // Czech
+    { "dan",        "da"        },  // Danish
+    { "deu",        "de"        },  // German
+    { "dut",        "nl"        },  // Dutch
+    { "dzo",        "dz"        },  // Dzongkha
+    { "ell",        "el"        },  // Greek, Modern (1453-)
+    { "eng",        "en"        },  // English
+    { "epo",        "eo"        },  // Esperanto
+    { "est",        "et"        },  // Estonian
+    { "eus",        "eu"        },  // Basque
+    { "fao",        "fo"        },  // Faroese
+    { "fas",        "fa"        },  // Persian
+    { "fin",        "fi"        },  // Finnish
+    { "fra",        "fr"        },  // French
+    { "fre",        "fr"        },  // French
+    { "geo",        "ka"        },  // Georgian
+    { "ger",        "de"        },  // German
+    { "gla",        "gd"        },  // Gaelic,Scottish
+    { "gle",        "ga"        },  // Irish
+    { "glg",        "gl"        },  // Gallegan
+    { "glv",        "gv"        },  // Manx
+    { "gre",        "el"        },  // Greek, Modern (1453-)
+    { "grn",        "gn"        },  // Guarani
+    { "guj",        "gu"        },  // Gujarati
+    { "heb",        "he"        },  // Hebrew
+    { "hin",        "hi"        },  // Hindi
+    { "hrv",        "hr"        },  // Croatian
+    { "hun",        "hu"        },  // Hungarian
+    { "hye",        "hy"        },  // Armenian
+    { "i-hak",      "zh-hakka"  },  // Hakka                    # deprecated RFC 3066
+    { "i-lux",      "lb"        },  // Luxembourgish            # deprecated RFC 3066
+    { "i-navajo",   "nv"        },  // Navajo                   # deprecated RFC 3066
+    { "ice",        "is"        },  // Icelandic
+    { "iku",        "iu"        },  // Inuktitut
+    { "ile",        "ie"        },  // Interlingue
+    { "in",         "id"        },  // Indonesian               # deprecated 639 code in -> id (1989)
+    { "ina",        "ia"        },  // Interlingua
+    { "ind",        "id"        },  // Indonesian
+    { "isl",        "is"        },  // Icelandic
+    { "ita",        "it"        },  // Italian
+    { "iw",         "he"        },  // Hebrew                   # deprecated 639 code iw -> he (1989)
+    { "jav",        "jv"        },  // Javanese
+    { "jaw",        "jv"        },  // Javanese                 # deprecated 639 code jaw -> jv (2001)
+    { "ji",         "yi"        },  // Yiddish                  # deprecated 639 code ji -> yi (1989)
+    { "jpn",        "ja"        },  // Japanese
+    { "kal",        "kl"        },  // Kalaallisut
+    { "kan",        "kn"        },  // Kannada
+    { "kas",        "ks"        },  // Kashmiri
+    { "kat",        "ka"        },  // Georgian
+    { "kaz",        "kk"        },  // Kazakh
+    { "khm",        "km"        },  // Khmer
+    { "kin",        "rw"        },  // Kinyarwanda
+    { "kir",        "ky"        },  // Kirghiz
+    { "kor",        "ko"        },  // Korean
+    { "kur",        "ku"        },  // Kurdish
+    { "lao",        "lo"        },  // Lao
+    { "lat",        "la"        },  // Latin
+    { "lav",        "lv"        },  // Latvian
+    { "lit",        "lt"        },  // Lithuanian
+    { "ltz",        "lb"        },  // Letzeburgesch
+    { "mac",        "mk"        },  // Macedonian
+    { "mal",        "ml"        },  // Malayalam
+    { "mar",        "mr"        },  // Marathi
+    { "may",        "ms"        },  // Malay
+    { "mkd",        "mk"        },  // Macedonian
+    { "mlg",        "mg"        },  // Malagasy
+    { "mlt",        "mt"        },  // Maltese
+    { "mol",        "mo"        },  // Moldavian
+    { "mon",        "mn"        },  // Mongolian
+    { "msa",        "ms"        },  // Malay
+    { "mya",        "my"        },  // Burmese
+    { "nep",        "ne"        },  // Nepali
+    { "nld",        "nl"        },  // Dutch
+    { "nno",        "nn"        },  // Norwegian Nynorsk
+    { "no",         "nb"        },  // Norwegian generic        # ambiguous 639 code no -> nb
+    { "no-bok",     "nb"        },  // Norwegian Bokmal         # deprecated RFC 3066 tag - used in old LocaleRefGetPartString
+    { "no-nyn",     "nn"        },  // Norwegian Nynorsk        # deprecated RFC 3066 tag - used in old LocaleRefGetPartString
+    { "nob",        "nb"        },  // Norwegian Bokmal
+    { "nor",        "nb"        },  // Norwegian generic        # ambiguous 639 code nor -> nb
+    { "nya",        "ny"        },  // Nyanja/Chewa/Chichewa    # 3-letter code used in old LocaleRefGetPartString
+    { "oci",        "oc"        },  // Occitan/Provencal
+    { "ori",        "or"        },  // Oriya
+    { "orm",        "om"        },  // Oromo,Galla
+    { "pan",        "pa"        },  // Panjabi
+    { "per",        "fa"        },  // Persian
+    { "pol",        "pl"        },  // Polish
+    { "por",        "pt"        },  // Portuguese
+    { "pus",        "ps"        },  // Pushto
+    { "que",        "qu"        },  // Quechua
+    { "roh",        "rm"        },  // Raeto-Romance
+    { "ron",        "ro"        },  // Romanian
+    { "rum",        "ro"        },  // Romanian
+    { "run",        "rn"        },  // Rundi
+    { "rus",        "ru"        },  // Russian
+    { "san",        "sa"        },  // Sanskrit
+    { "scc",        "sr"        },  // Serbian
+    { "scr",        "hr"        },  // Croatian
+    { "sin",        "si"        },  // Sinhalese
+    { "slk",        "sk"        },  // Slovak
+    { "slo",        "sk"        },  // Slovak
+    { "slv",        "sl"        },  // Slovenian
+    { "sme",        "se"        },  // Sami,Northern
+    { "snd",        "sd"        },  // Sindhi
+    { "som",        "so"        },  // Somali
+    { "spa",        "es"        },  // Spanish
+    { "sqi",        "sq"        },  // Albanian
+    { "srp",        "sr"        },  // Serbian
+    { "sun",        "su"        },  // Sundanese
+    { "swa",        "sw"        },  // Swahili
+    { "swe",        "sv"        },  // Swedish
+    { "tam",        "ta"        },  // Tamil
+    { "tat",        "tt"        },  // Tatar
+    { "tel",        "te"        },  // Telugu
+    { "tgk",        "tg"        },  // Tajik
+    { "tgl",        "tl"        },  // Tagalog
+    { "tha",        "th"        },  // Thai
+    { "tib",        "bo"        },  // Tibetan
+    { "tir",        "ti"        },  // Tigrinya
+    { "ton",        "to"        },  // Tongan
+    { "tuk",        "tk"        },  // Turkmen
+    { "tur",        "tr"        },  // Turkish
+    { "uig",        "ug"        },  // Uighur
+    { "ukr",        "uk"        },  // Ukrainian
+    { "urd",        "ur"        },  // Urdu
+    { "uzb",        "uz"        },  // Uzbek
+    { "vie",        "vi"        },  // Vietnamese
+    { "wel",        "cy"        },  // Welsh
+    { "yid",        "yi"        },  // Yiddish
+    { "zho",        "zh"        },  // Chinese
+};
+enum {
+    kNumLocaleStringPrefixToCanonical = sizeof(localeStringPrefixToCanonical)/sizeof(KeyStringToResultString)
+};
+
+
+static const SpecialCaseUpdates specialCases[] = {
+// Data for special cases
+// a) The 3166 code CS was used for Czechoslovakia until 1993, when that country split and the code was
+// replaced by CZ and SK. Then in 2003-07, the code YU (formerly designating all of Yugoslavia, then after
+// the 1990s breakup just designating what is now Serbia and Montenegro) was changed to CS! However, ICU
+// and RFC 3066bis will continue to use YU for this. So now CS is ambiguous. We guess as follows: If we
+// see CS but a language of cs or sk, we change CS to CZ or SK. Otherwise, we change CS to YU.
+// b) The 639 code sh for Serbo-Croatian was also replaced in the 1990s by separate codes hr and sr, and
+// deprecated in 2000. We guess which one to map it to as follows: If there is a region tag of HR we use
+// hr; if there is a region tag of (now) YU we use sr; else we do not change it (not enough info).
+// c) There are other codes that have been updated without these issues (eg. TP to TL), plus among the
+// "exceptionally reserved" codes some are just alternates for standard codes (eg. UK for GB).
+    {   NULL,   "-UK",  "GB",   NULL,   NULL    },  // always change UK to GB (UK is "exceptionally reserved" to mean GB)
+    {   NULL,   "-TP",  "TL",   NULL,   NULL    },  // always change TP to TL (East Timor, code changed 2002-05)
+    {   "cs",   "-CS",  "CZ",   NULL,   NULL    },  // if language is cs, change CS (pre-1993 Czechoslovakia) to CZ (Czech Republic)
+    {   "sk",   "-CS",  "SK",   NULL,   NULL    },  // if language is sk, change CS (pre-1993 Czechoslovakia) to SK (Slovakia)
+    {   NULL,   "-YU",  "CS",   NULL,   NULL    },  // then always change YU to CS (map old Yugoslavia code to new 2003-07 ISO code
+    												// for Serbia & Montenegro per RFC3066bis & ICU)								// <1.18>
+                                                    // Note: do this after fixing CS for cs/sk as above.
+    {   "sh",   "-HR",  "hr",   "-CS",  "sr"    },  // if language is old 'sh' (SerboCroatian), change it to 'hr' (Croatian) if we find
+                                                    // HR (Croatia) or to 'sr' (Serbian) if we find CS (Serbia & Montenegro, Yugoslavia).	// <1.18>
+                                                    // Note: Do this after changing YU to CS as above.
+    {   NULL,   NULL,   NULL,   NULL,   NULL    }   // terminator
+};
+
+
+static const KeyStringToResultString localeStringRegionToDefaults[] = {
+// For some region-code suffixes, there are default substrings to strip off for canonical string.
+// Must be sorted according to how strcmp compares the strings in the first column
+//
+//  region      default writing
+//  suffix      system tags, strip     comment
+//  --------    -------------          ---------
+    { "_CN",    "-Hans"         },  // mainland China, default is simplified
+    { "_HK",    "-Hant"         },  // Hong Kong, default is traditional
+    { "_MO",    "-Hant"         },  // Macao, default is traditional
+    { "_SG",    "-Hans"         },  // Singapore, default is simplified
+    { "_TW",    "-Hant"         },  // Taiwan, default is traditional
+};
+enum {
+    kNumLocaleStringRegionToDefaults = sizeof(localeStringRegionToDefaults)/sizeof(KeyStringToResultString)
+};
+
+static const KeyStringToResultString localeStringPrefixToDefaults[] = {
+// For some initial portions of language tag, there are default substrings to strip off for canonical string.
+// Must be sorted according to how strcmp compares the strings in the first column
+//
+//  language    default writing
+//  tag prefix  system tags, strip     comment
+//  --------    -------------          ---------
+    { "ab-",    "-Cyrl"         },  // Abkhazian
+    { "af-",    "-Latn"         },  // Afrikaans
+    { "am-",    "-Ethi"         },  // Amharic
+    { "ar-",    "-Arab"         },  // Arabic
+    { "as-",    "-Beng"         },  // Assamese
+    { "ay-",    "-Latn"         },  // Aymara
+    { "be-",    "-Cyrl"         },  // Belarusian
+    { "bg-",    "-Cyrl"         },  // Bulgarian
+    { "bn-",    "-Beng"         },  // Bengali
+    { "bo-",    "-Tibt"         },  // Tibetan (? not Suppress-Script)
+    { "br-",    "-Latn"         },  // Breton (? not Suppress-Script)
+    { "bs-",    "-Latn"         },  // Bosnian
+    { "ca-",    "-Latn"         },  // Catalan
+    { "cs-",    "-Latn"         },  // Czech
+    { "cy-",    "-Latn"         },  // Welsh
+    { "da-",    "-Latn"         },  // Danish
+    { "de-",    "-Latn -1901"   },  // German, traditional orthography
+    { "dv-",    "-Thaa"         },  // Divehi/Maldivian
+    { "dz-",    "-Tibt"         },  // Dzongkha
+    { "el-",    "-Grek"         },  // Greek (modern, monotonic)
+    { "en-",    "-Latn"         },  // English
+    { "eo-",    "-Latn"         },  // Esperanto
+    { "es-",    "-Latn"         },  // Spanish
+    { "et-",    "-Latn"         },  // Estonian
+    { "eu-",    "-Latn"         },  // Basque
+    { "fa-",    "-Arab"         },  // Farsi
+    { "fi-",    "-Latn"         },  // Finnish
+    { "fo-",    "-Latn"         },  // Faroese
+    { "fr-",    "-Latn"         },  // French
+    { "ga-",    "-Latn"         },  // Irish
+    { "gd-",    "-Latn"         },  // Scottish Gaelic (? not Suppress-Script)
+    { "gl-",    "-Latn"         },  // Galician
+    { "gn-",    "-Latn"         },  // Guarani
+    { "gu-",    "-Gujr"         },  // Gujarati
+    { "gv-",    "-Latn"         },  // Manx
+    { "haw-",   "-Latn"         },  // Hawaiian (? not Suppress-Script)
+    { "he-",    "-Hebr"         },  // Hebrew
+    { "hi-",    "-Deva"         },  // Hindi
+    { "hr-",    "-Latn"         },  // Croatian
+    { "hu-",    "-Latn"         },  // Hungarian
+    { "hy-",    "-Armn"         },  // Armenian
+    { "id-",    "-Latn"         },  // Indonesian
+    { "is-",    "-Latn"         },  // Icelandic
+    { "it-",    "-Latn"         },  // Italian
+    { "ja-",    "-Jpan"         },  // Japanese
+    { "ka-",    "-Geor"         },  // Georgian
+    { "kk-",    "-Cyrl"         },  // Kazakh
+    { "kl-",    "-Latn"         },  // Kalaallisut/Greenlandic
+    { "km-",    "-Khmr"         },  // Central Khmer
+    { "kn-",    "-Knda"         },  // Kannada
+    { "ko-",    "-Hang"         },  // Korean (? not Suppress-Script)
+    { "kok-",   "-Deva"         },  // Konkani
+    { "la-",    "-Latn"         },  // Latin
+    { "lb-",    "-Latn"         },  // Luxembourgish
+    { "lo-",    "-Laoo"         },  // Lao
+    { "lt-",    "-Latn"         },  // Lithuanian
+    { "lv-",    "-Latn"         },  // Latvian
+    { "mg-",    "-Latn"         },  // Malagasy
+    { "mk-",    "-Cyrl"         },  // Macedonian
+    { "ml-",    "-Mlym"         },  // Malayalam
+    { "mo-",    "-Latn"         },  // Moldavian
+    { "mr-",    "-Deva"         },  // Marathi
+    { "ms-",    "-Latn"         },  // Malay
+    { "mt-",    "-Latn"         },  // Maltese
+    { "my-",    "-Mymr"         },  // Burmese/Myanmar
+    { "nb-",    "-Latn"         },  // Norwegian Bokmal
+    { "ne-",    "-Deva"         },  // Nepali
+    { "nl-",    "-Latn"         },  // Dutch
+    { "nn-",    "-Latn"         },  // Norwegian Nynorsk
+    { "ny-",    "-Latn"         },  // Chichewa/Nyanja
+    { "om-",    "-Latn"         },  // Oromo
+    { "or-",    "-Orya"         },  // Oriya
+    { "pa-",    "-Guru"         },  // Punjabi
+    { "pl-",    "-Latn"         },  // Polish
+    { "ps-",    "-Arab"         },  // Pushto
+    { "pt-",    "-Latn"         },  // Portuguese
+    { "qu-",    "-Latn"         },  // Quechua
+    { "rn-",    "-Latn"         },  // Rundi
+    { "ro-",    "-Latn"         },  // Romanian
+    { "ru-",    "-Cyrl"         },  // Russian
+    { "rw-",    "-Latn"         },  // Kinyarwanda
+    { "sa-",    "-Deva"         },  // Sanskrit (? not Suppress-Script)
+    { "se-",    "-Latn"         },  // Sami (? not Suppress-Script)
+    { "si-",    "-Sinh"         },  // Sinhala
+    { "sk-",    "-Latn"         },  // Slovak
+    { "sl-",    "-Latn"         },  // Slovenian
+    { "so-",    "-Latn"         },  // Somali
+    { "sq-",    "-Latn"         },  // Albanian
+    { "sv-",    "-Latn"         },  // Swedish
+    { "sw-",    "-Latn"         },  // Swahili
+    { "ta-",    "-Taml"         },  // Tamil
+    { "te-",    "-Telu"         },  // Telugu
+    { "th-",    "-Thai"         },  // Thai
+    { "ti-",    "-Ethi"         },  // Tigrinya
+    { "tl-",    "-Latn"         },  // Tagalog
+    { "tn-",    "-Latn"         },  // Tswana
+    { "to-",    "-Latn"         },  // Tonga of Tonga Islands
+    { "tr-",    "-Latn"         },  // Turkish
+    { "uk-",    "-Cyrl"         },  // Ukrainian
+    { "ur-",    "-Arab"         },  // Urdu
+    { "vi-",    "-Latn"         },  // Vietnamese
+    { "wo-",    "-Latn"         },  // Wolof
+    { "xh-",    "-Latn"         },  // Xhosa
+    { "yi-",    "-Hebr"         },  // Yiddish
+    { "zh-",    "-Hani"         },  // Chinese (? not Suppress-Script)
+    { "zu-",    "-Latn"         },  // Zulu
+};
+enum {
+    kNumLocaleStringPrefixToDefaults = sizeof(localeStringPrefixToDefaults)/sizeof(KeyStringToResultString)
+};
+
+static const KeyStringToResultString appleLocaleToLanguageString[] = {
+// Map locale strings that Apple uses as language IDs to real language strings.
+// Must be sorted according to how strcmp compares the strings in the first column.
+// Note: Now we remove all transforms of the form ll_RR -> ll-RR, they are now
+// handled in the code. <1.19>
+//
+//    locale 			lang			[  comment ]
+//    string			string
+//    -------			-------
+    { "en_US_POSIX",	"en-US-POSIX"	},  // POSIX locale, need as language string			// <1.17> [3840752]
+    { "zh_CN",  		"zh-Hans"		},  // mainland China => simplified
+    { "zh_HK",  		"zh-Hant"		},  // Hong Kong => traditional, not currently used
+    { "zh_MO",  		"zh-Hant"		},  // Macao => traditional, not currently used
+    { "zh_SG",  		"zh-Hans"		},  // Singapore => simplified, not currently used
+    { "zh_TW",  		"zh-Hant"		},  // Taiwan => traditional
+};
+enum {
+    kNumAppleLocaleToLanguageString = sizeof(appleLocaleToLanguageString)/sizeof(KeyStringToResultString)
+};
+
+static const KeyStringToResultString appleLocaleToLanguageStringForCFBundle[] = {
+// Map locale strings that Apple uses as language IDs to real language strings.
+// Must be sorted according to how strcmp compares the strings in the first column.
+//
+//    locale 			lang			[  comment ]
+//    string			string
+//    -------			-------
+    { "de_AT",  		"de-AT"			},  // Austrian German
+    { "de_CH",  		"de-CH"			},  // Swiss German
+//  { "de_DE",  		"de-DE"			},  // German for Germany (default), not currently used
+    { "en_AU", 			"en-AU"			},  // Australian English
+    { "en_CA",  		"en-CA"			},  // Canadian English
+    { "en_GB",  		"en-GB"			},  // British English
+//  { "en_IE",  		"en-IE"			},  // Irish English, not currently used
+    { "en_US",  		"en-US"			},  // U.S. English
+    { "en_US_POSIX",	"en-US-POSIX"	},  // POSIX locale, need as language string			// <1.17> [3840752]
+//  { "fr_BE",  		"fr-BE"			},  // Belgian French, not currently used
+    { "fr_CA",  		"fr-CA"			},  // Canadian French
+    { "fr_CH",  		"fr-CH"			},  // Swiss French
+//  { "fr_FR",  		"fr-FR"			},  // French for France (default), not currently used
+    { "nl_BE",  		"nl-BE"			},  // Flemish = Vlaams, Dutch for Belgium
+//  { "nl_NL",  		"nl-NL"			},  // Dutch for Netherlands (default), not currently used
+    { "pt_BR",  		"pt-BR"			},  // Brazilian Portuguese
+    { "pt_PT",  		"pt-PT"     	},  // Portuguese for Portugal
+    { "zh_CN",  		"zh-Hans"		},  // mainland China => simplified
+    { "zh_HK",  		"zh-Hant"		},  // Hong Kong => traditional, not currently used
+    { "zh_MO",  		"zh-Hant"		},  // Macao => traditional, not currently used
+    { "zh_SG",  		"zh-Hans"		},  // Singapore => simplified, not currently used
+    { "zh_TW",  		"zh-Hant"		},  // Taiwan => traditional
+};
+enum {
+    kNumAppleLocaleToLanguageStringForCFBundle = sizeof(appleLocaleToLanguageStringForCFBundle)/sizeof(KeyStringToResultString)
+};
+
+
+struct LocaleToLegacyCodes {
+    const char *        locale;	// reduced to language plus one other component (script, region, variant), separators normalized to'_'
+    RegionCode		    regCode;
+    LangCode		    langCode;
+    CFStringEncoding    encoding;
+};
+typedef struct LocaleToLegacyCodes LocaleToLegacyCodes;
+
+static const LocaleToLegacyCodes localeToLegacyCodes[] = {
+	//	locale			RegionCode					LangCode						CFStringEncoding
+    {   "af"/*ZA*/,     102/*verAfrikaans*/,        141/*langAfrikaans*/,            0/*Roman*/              },  // Latn
+    {   "am",            -1,                         85/*langAmharic*/,             28/*Ethiopic*/           },  // Ethi
+    {   "ar",            16/*verArabic*/,            12/*langArabic*/,               4/*Arabic*/             },  // Arab;
+    {   "as",            -1,                         68/*langAssamese*/,            13/*Bengali*/            },  // Beng;
+    {   "ay",            -1,                        134/*langAymara*/,               0/*Roman*/              },  // Latn;
+    {   "az",            -1,                         49/*langAzerbaijani*/,          7/*Cyrillic*/           },  // assume "az" defaults to -Cyrl
+    {   "az_Arab",       -1,                         50/*langAzerbaijanAr*/,         4/*Arabic*/             },  // Arab;
+    {   "az_Cyrl",       -1,                         49/*langAzerbaijani*/,          7/*Cyrillic*/           },  // Cyrl;
+    {   "az_Latn",       -1,                        150/*langAzerbaijanRoman*/,      0/*Roman*/              },  // Latn;
+    {   "be"/*BY*/,      61/*verBelarus*/,           46/*langBelorussian*/,          7/*Cyrillic*/           },  // Cyrl;
+    {   "bg"/*BG*/,      72/*verBulgaria*/,          44/*langBulgarian*/,            7/*Cyrillic*/           },  // Cyrl;
+    {   "bn",            60/*verBengali*/,           67/*langBengali*/,             13/*Bengali*/            },  // Beng;
+    {   "bo",           105/*verTibetan*/,           63/*langTibetan*/,             26/*Tibetan*/            },  // Tibt;
+    {   "br",            77/*verBreton*/,           142/*langBreton*/,              39/*Celtic*/             },  // Latn;
+    {   "ca"/*ES*/,      73/*verCatalonia*/,        130/*langCatalan*/,              0/*Roman*/              },  // Latn;
+    {   "cs"/*CZ*/,      56/*verCzech*/,             38/*langCzech*/,               29/*CentralEurRoman*/    },  // Latn;
+    {   "cy",            79/*verWelsh*/,            128/*langWelsh*/,               39/*Celtic*/             },  // Latn;
+    {   "da"/*DK*/,       9/*verDenmark*/,            7/*langDanish*/,               0/*Roman*/              },  // Latn;
+    {   "de",             3/*verGermany*/,            2/*langGerman*/,               0/*Roman*/              },  // assume "de" defaults to verGermany
+    {   "de_1996",       70/*verGermanReformed*/,     2/*langGerman*/,               0/*Roman*/              },
+    {   "de_AT",         92/*verAustria*/,            2/*langGerman*/,               0/*Roman*/              },
+    {   "de_CH",         19/*verGrSwiss*/,            2/*langGerman*/,               0/*Roman*/              },
+    {   "de_DE",          3/*verGermany*/,            2/*langGerman*/,               0/*Roman*/              },
+    {   "dz"/*BT*/,      83/*verBhutan*/,           137/*langDzongkha*/,            26/*Tibetan*/            },  // Tibt;
+    {   "el",            20/*verGreece*/,            14/*langGreek*/,                6/*Greek*/              },  // assume "el" defaults to verGreece
+    {   "el_CY",         23/*verCyprus*/,            14/*langGreek*/,                6/*Greek*/              },
+    {   "el_GR",         20/*verGreece*/,            14/*langGreek*/,                6/*Greek*/              },  // modern monotonic
+    {   "en",             0/*verUS*/,                 0/*langEnglish*/,              0/*Roman*/              },  // "en" defaults to verUS (per Chris Hansten)
+    {   "en_001",        37/*verInternational*/,      0/*langEnglish*/,              0/*Roman*/              },
+    {   "en_AU",         15/*verAustralia*/,          0/*langEnglish*/,              0/*Roman*/              },
+    {   "en_CA",         82/*verEngCanada*/,          0/*langEnglish*/,              0/*Roman*/              },
+    {   "en_GB",          2/*verBritain*/,            0/*langEnglish*/,              0/*Roman*/              },
+    {   "en_IE",        108/*verIrelandEnglish*/,     0/*langEnglish*/,              0/*Roman*/              },
+    {   "en_SG",        100/*verSingapore*/,          0/*langEnglish*/,              0/*Roman*/              },
+    {   "en_US",          0/*verUS*/,                 0/*langEnglish*/,              0/*Roman*/              },
+    {   "eo",           103/*verEsperanto*/,         94/*langEsperanto*/,            0/*Roman*/              },  // Latn;
+    {   "es",             8/*verSpain*/,              6/*langSpanish*/,              0/*Roman*/              },  // "es" defaults to verSpain (per Chris Hansten)
+    {   "es_419",        86/*verSpLatinAmerica*/,     6/*langSpanish*/,              0/*Roman*/              },  // new BCP 47 tag
+    {   "es_ES",          8/*verSpain*/,              6/*langSpanish*/,              0/*Roman*/              },
+    {   "es_MX",         86/*verSpLatinAmerica*/,     6/*langSpanish*/,              0/*Roman*/              },
+    {   "es_US",         86/*verSpLatinAmerica*/,     6/*langSpanish*/,              0/*Roman*/              },
+    {   "et"/*EE*/,      44/*verEstonia*/,           27/*langEstonian*/,            29/*CentralEurRoman*/    },
+    {   "eu",            -1,                        129/*langBasque*/,               0/*Roman*/              },  // Latn;
+    {   "fa"/*IR*/,      48/*verIran*/,              31/*langFarsi/Persian*/,       0x8C/*Farsi*/            },  // Arab;
+    {   "fi"/*FI*/,      17/*verFinland*/,           13/*langFinnish*/,              0/*Roman*/              },
+    {   "fo"/*FO*/,      47/*verFaroeIsl*/,          30/*langFaroese*/,             37/*Icelandic*/          },
+    {   "fr",             1/*verFrance*/,             1/*langFrench*/,               0/*Roman*/              },  // "fr" defaults to verFrance (per Chris Hansten)
+    {   "fr_001",        91/*verFrenchUniversal*/,    1/*langFrench*/,               0/*Roman*/              },
+    {   "fr_BE",         98/*verFrBelgium*/,          1/*langFrench*/,               0/*Roman*/              },
+    {   "fr_CA",         11/*verFrCanada*/,           1/*langFrench*/,               0/*Roman*/              },
+    {   "fr_CH",         18/*verFrSwiss*/,            1/*langFrench*/,               0/*Roman*/              },
+    {   "fr_FR",          1/*verFrance*/,             1/*langFrench*/,               0/*Roman*/              },
+    {   "ga"/*IE*/,      50/*verIreland*/,           35/*langIrishGaelic*/,          0/*Roman*/              },  // no dots (h after)
+    {   "ga_Latg"/*IE*/, 81/*verIrishGaelicScrip*/, 146/*langIrishGaelicScript*/,   40/*Gaelic*/             },  // using dots
+    {   "gd",            75/*verScottishGaelic*/,   144/*langScottishGaelic*/,      39/*Celtic*/             },
+    {   "gl",            -1,                        140/*langGalician*/,             0/*Roman*/              },  // Latn;
+    {   "gn",            -1,                        133/*langGuarani*/,              0/*Roman*/              },  // Latn;
+    {   "grc",           40/*verGreekAncient*/,     148/*langGreekAncient*/,         6/*Greek*/              },  // polytonic (MacGreek doesn't actually support it)
+    {   "gu"/*IN*/,      94/*verGujarati*/,          69/*langGujarati*/,            11/*Gujarati*/           },  // Gujr;
+    {   "gv",            76/*verManxGaelic*/,       145/*langManxGaelic*/,          39/*Celtic*/             },  // Latn;
+    {   "he"/*IL*/,      13/*verIsrael*/,            10/*langHebrew*/,               5/*Hebrew*/             },  // Hebr;
+    {   "hi"/*IN*/,      33/*verIndiaHindi*/,        21/*langHindi*/,                9/*Devanagari*/         },  // Deva;
+    {   "hr"/*HR*/,      68/*verCroatia*/,           18/*langCroatian*/,            36/*Croatian*/           },
+    {   "hu"/*HU*/,      43/*verHungary*/,           26/*langHungarian*/,           29/*CentralEurRoman*/    },
+    {   "hy"/*AM*/,      84/*verArmenian*/,          51/*langArmenian*/,            24/*Armenian*/           },  // Armn;
+    {   "id",            -1,                         81/*langIndonesian*/,           0/*Roman*/              },  // Latn;
+    {   "is"/*IS*/,      21/*verIceland*/,           15/*langIcelandic*/,           37/*Icelandic*/          },
+    {   "it",             4/*verItaly*/,              3/*langItalian*/,              0/*Roman*/              },  // "it" defaults to verItaly
+    {   "it_CH",         36/*verItalianSwiss*/,       3/*langItalian*/,              0/*Roman*/              },
+    {   "it_IT",          4/*verItaly*/,              3/*langItalian*/,              0/*Roman*/              },
+    {   "iu"/*CA*/,      78/*verNunavut*/,          143/*langInuktitut*/,           0xEC/*Inuit*/            },  // Cans;
+    {   "ja"/*JP*/,      14/*verJapan*/,             11/*langJapanese*/,             1/*Japanese*/           },  // Jpan;
+    {   "jv",            -1,                        138/*langJavaneseRom*/,          0/*Roman*/              },  // Latn;
+    {   "ka"/*GE*/,      85/*verGeorgian*/,          52/*langGeorgian*/,            23/*Georgian*/           },  // Geor;
+    {   "kk",            -1,                         48/*langKazakh*/,               7/*Cyrillic*/           },  // "kk" defaults to -Cyrl; also have -Latn, -Arab
+    {   "kl",           107/*verGreenland*/,        149/*langGreenlandic*/,          0/*Roman*/              },  // Latn;
+    {   "km",            -1,                         78/*langKhmer*/,               20/*Khmer*/              },  // Khmr;
+    {   "kn",            -1,                         73/*langKannada*/,             16/*Kannada*/            },  // Knda;
+    {   "ko"/*KR*/,      51/*verKorea*/,             23/*langKorean*/,               3/*Korean*/             },  // Hang;
+    {   "ks",            -1,                         61/*langKashmiri*/,             4/*Arabic*/             },  // Arab;
+    {   "ku",            -1,                         60/*langKurdish*/,              4/*Arabic*/             },  // Arab;
+    {   "ky",            -1,                         54/*langKirghiz*/,              7/*Cyrillic*/           },  // Cyrl; also -Latn, -Arab
+    {   "la",            -1,                        131/*langLatin*/,                0/*Roman*/              },  // Latn;
+    {   "lo",            -1,                         79/*langLao*/,                 22/*Laotian*/            },  // Laoo;
+    {   "lt"/*LT*/,      41/*verLithuania*/,         24/*langLithuanian*/,          29/*CentralEurRoman*/    },
+    {   "lv"/*LV*/,      45/*verLatvia*/,            28/*langLatvian*/,             29/*CentralEurRoman*/    },
+    {   "mg",            -1,                         93/*langMalagasy*/,             0/*Roman*/              },  // Latn;
+    {   "mk"/*MK*/,      67/*verMacedonian*/,        43/*langMacedonian*/,           7/*Cyrillic*/           },  // Cyrl;
+    {   "ml",            -1,                         72/*langMalayalam*/,           17/*Malayalam*/          },  // Mlym;
+    {   "mn",            -1,                         57/*langMongolian*/,           27/*Mongolian*/          },  // "mn" defaults to -Mong
+    {   "mn_Cyrl",       -1,                         58/*langMongolianCyr*/,         7/*Cyrillic*/           },  // Cyrl;
+    {   "mn_Mong",       -1,                         57/*langMongolian*/,           27/*Mongolian*/          },  // Mong;
+    {   "mo",            -1,                         53/*langMoldavian*/,            7/*Cyrillic*/           },  // Cyrl;
+    {   "mr"/*IN*/,     104/*verMarathi*/,           66/*langMarathi*/,              9/*Devanagari*/         },  // Deva;
+    {   "ms",            -1,                         83/*langMalayRoman*/,           0/*Roman*/              },  // "ms" defaults to -Latn;
+    {   "ms_Arab",       -1,                         84/*langMalayArabic*/,          4/*Arabic*/             },  // Arab;
+    {   "mt"/*MT*/,      22/*verMalta*/,             16/*langMaltese*/,              0/*Roman*/              },  // Latn;
+    {   "mul",           74/*verMultilingual*/,      -1,                             0                       },
+    {   "my",            -1,                         77/*langBurmese*/,             19/*Burmese*/            },  // Mymr;
+    {   "nb"/*NO*/,      12/*verNorway*/,             9/*langNorwegian*/,            0/*Roman*/              },
+    {   "ne"/*NP*/,     106/*verNepal*/,             64/*langNepali*/,               9/*Devanagari*/         },  // Deva;
+    {   "nl",             5/*verNetherlands*/,        4/*langDutch*/,                0/*Roman*/              },  // "nl" defaults to verNetherlands
+    {   "nl_BE",          6/*verFlemish*/,           34/*langFlemish*/,              0/*Roman*/              },
+    {   "nl_NL",          5/*verNetherlands*/,        4/*langDutch*/,                0/*Roman*/              },
+    {   "nn"/*NO*/,     101/*verNynorsk*/,          151/*langNynorsk*/,              0/*Roman*/              },
+    {   "ny",            -1,                         92/*langNyanja/Chewa*/,         0/*Roman*/              },  // Latn;
+    {   "om",            -1,                         87/*langOromo*/,               28/*Ethiopic*/           },  // Ethi;
+    {   "or",            -1,                         71/*langOriya*/,               12/*Oriya*/              },  // Orya;
+    {   "pa",            95/*verPunjabi*/,           70/*langPunjabi*/,             10/*Gurmukhi*/           },  // Guru;
+    {   "pl"/*PL*/,      42/*verPoland*/,            25/*langPolish*/,              29/*CentralEurRoman*/    },
+    {   "ps",            -1,                         59/*langPashto*/,              0x8C/*Farsi*/            },  // Arab;
+    {   "pt",            71/*verBrazil*/,             8/*langPortuguese*/,           0/*Roman*/              },  // "pt" defaults to verBrazil (per Chris Hansten)
+    {   "pt_BR",         71/*verBrazil*/,             8/*langPortuguese*/,           0/*Roman*/              },
+    {   "pt_PT",         10/*verPortugal*/,           8/*langPortuguese*/,           0/*Roman*/              },
+    {   "qu",            -1,                        132/*langQuechua*/,              0/*Roman*/              },  // Latn;
+    {   "rn",            -1,                         91/*langRundi*/,                0/*Roman*/              },  // Latn;
+    {   "ro"/*RO*/,      39/*verRomania*/,           37/*langRomanian*/,            38/*Romanian*/           },
+    {   "ru"/*RU*/,      49/*verRussia*/,            32/*langRussian*/,              7/*Cyrillic*/           },  // Cyrl;
+    {   "rw",            -1,                         90/*langKinyarwanda*/,          0/*Roman*/              },  // Latn;
+    {   "sa",            -1,                         65/*langSanskrit*/,             9/*Devanagari*/         },  // Deva;
+    {   "sd",            -1,                         62/*langSindhi*/,              0x8C/*Farsi*/            },  // Arab;
+    {   "se",            46/*verSami*/,              29/*langSami*/,                 0/*Roman*/              },
+    {   "si",            -1,                         76/*langSinhalese*/,           18/*Sinhalese*/          },  // Sinh;
+    {   "sk"/*SK*/,      57/*verSlovak*/,            39/*langSlovak*/,              29/*CentralEurRoman*/    },
+    {   "sl"/*SI*/,      66/*verSlovenian*/,         40/*langSlovenian*/,           36/*Croatian*/           },
+    {   "so",            -1,                         88/*langSomali*/,               0/*Roman*/              },  // Latn;
+    {   "sq",            -1,                         36/*langAlbanian*/,             0/*Roman*/              },
+    {   "sr"/*CS,RS*/,   65/*verSerbian*/,           42/*langSerbian*/,              7/*Cyrillic*/           },  // Cyrl;
+    {   "su",            -1,                        139/*langSundaneseRom*/,         0/*Roman*/              },  // Latn;
+    {   "sv"/*SE*/,       7/*verSweden*/,             5/*langSwedish*/,              0/*Roman*/              },
+    {   "sw",            -1,                         89/*langSwahili*/,              0/*Roman*/              },  // Latn;
+    {   "ta",            -1,                         74/*langTamil*/,               14/*Tamil*/              },  // Taml;
+    {   "te",            -1,                         75/*langTelugu*/,              15/*Telugu*/             },  // Telu
+    {   "tg",            -1,                         55/*langTajiki*/,               7/*Cyrillic*/           },  // "tg" defaults to "Cyrl"
+    {   "tg_Cyrl",       -1,                         55/*langTajiki*/,               7/*Cyrillic*/           },  // Cyrl; also -Latn, -Arab
+    {   "th"/*TH*/,      54/*verThailand*/,          22/*langThai*/,                21/*Thai*/               },  // Thai;
+    {   "ti",            -1,                         86/*langTigrinya*/,            28/*Ethiopic*/           },  // Ethi;
+    {   "tk",            -1,                         56/*langTurkmen*/,              7/*Cyrillic*/           },  // "tk" defaults to Cyrl
+    {   "tk_Cyrl",       -1,                         56/*langTurkmen*/,              7/*Cyrillic*/           },  // Cyrl; also -Latn, -Arab
+    {   "tl",            -1,                         82/*langTagalog*/,              0/*Roman*/              },  // Latn;
+    {   "to"/*TO*/,      88/*verTonga*/,            147/*langTongan*/,               0/*Roman*/              },  // Latn;
+    {   "tr"/*TR*/,      24/*verTurkey*/,            17/*langTurkish*/,             35/*Turkish*/            },  // Latn;
+    {   "tt",            -1,                        135/*langTatar*/,                7/*Cyrillic*/           },  // Cyrl;
+    {   "tt_Cyrl",       -1,                        135/*langTatar*/,                7/*Cyrillic*/           },  // Cyrl;
+    {   "ug",            -1,                        136/*langUighur*/,               4/*Arabic*/             },  // Arab;
+    {   "uk"/*UA*/,      62/*verUkraine*/,           45/*langUkrainian*/,            7/*Cyrillic*/           },  // Cyrl;
+    {   "und",           55/*verScriptGeneric*/,     -1,                             0                       },
+    {   "ur",            34/*verPakistanUrdu*/,      20/*langUrdu*/,                0x8C/*Farsi*/            },  // "ur" defaults to verPakistanUrdu
+    {   "ur_IN",         96/*verIndiaUrdu*/,         20/*langUrdu*/,                0x8C/*Farsi*/            },  // Arab
+    {   "ur_PK",         34/*verPakistanUrdu*/,      20/*langUrdu*/,                0x8C/*Farsi*/            },  // Arab
+    {   "uz"/*UZ*/,      99/*verUzbek*/,             47/*langUzbek*/,                7/*Cyrillic*/           },  // Cyrl; also -Latn, -Arab
+    {   "uz_Cyrl",       99/*verUzbek*/,             47/*langUzbek*/,                7/*Cyrillic*/           },
+    {   "vi"/*VN*/,      97/*verVietnam*/,           80/*langVietnamese*/,          30/*Vietnamese*/         },  // Latn
+    {   "yi",            -1,                         41/*langYiddish*/,              5/*Hebrew*/             },  // Hebr;
+    {   "zh",            52/*verChina*/,             33/*langSimpChinese*/,         25/*ChineseSimp*/        },  // "zh" defaults to verChina, langSimpChinese
+    {   "zh_CN",         52/*verChina*/,             33/*langSimpChinese*/,         25/*ChineseSimp*/        },
+    {   "zh_HK",         53/*verTaiwan*/,            19/*langTradChinese*/,          2/*ChineseTrad*/        },
+    {   "zh_Hans",       52/*verChina*/,             33/*langSimpChinese*/,         25/*ChineseSimp*/        },
+    {   "zh_Hant",       53/*verTaiwan*/,            19/*langTradChinese*/,          2/*ChineseTrad*/        },
+    {   "zh_MO",         53/*verTaiwan*/,            19/*langTradChinese*/,          2/*ChineseTrad*/        },
+    {   "zh_SG",         52/*verChina*/,             33/*langSimpChinese*/,         25/*ChineseSimp*/        },
+    {   "zh_TW",         53/*verTaiwan*/,            19/*langTradChinese*/,          2/*ChineseTrad*/        },
+};
+enum {
+    kNumLocaleToLegacyCodes = sizeof(localeToLegacyCodes)/sizeof(localeToLegacyCodes[0])
+};
+
+/*
+	For reference here is a list of ICU locales with variants and how some
+	of them are canonicalized with the ICU function uloc_canonicalize:
+	
+	ICU 3.0 has:
+		en_US_POSIX			x	no change
+		hy_AM_REVISED		x	no change
+		ja_JP_TRADITIONAL	->	ja_JP@calendar=japanese
+		th_TH_TRADITIONAL	->	th_TH@calendar=buddhist
+
+	ICU 2.8 also had the following (now obsolete):
+		ca_ES_PREEURO
+		de__PHONEBOOK		->	de@collation=phonebook
+		de_AT_PREEURO
+		de_DE_PREEURO
+		de_LU_PREEURO
+		el_GR_PREEURO
+		en_BE_PREEURO
+		en_GB_EURO			->	en_GB@currency=EUR
+		en_IE_PREEURO		->	en_IE@currency=IEP
+		es__TRADITIONAL		->	es@collation=traditional
+		es_ES_PREEURO
+		eu_ES_PREEURO
+		fi_FI_PREEURO
+		fr_BE_PREEURO
+		fr_FR_PREEURO		->	fr_FR@currency=FRF
+		fr_LU_PREEURO
+		ga_IE_PREEURO
+		gl_ES_PREEURO
+		hi__DIRECT			->	hi@collation=direct  
+		it_IT_PREEURO
+		nl_BE_PREEURO
+		nl_NL_PREEURO
+		pt_PT_PREEURO
+		zh__PINYIN			->	zh@collation=pinyin
+		zh_TW_STROKE		->	zh_TW@collation=stroke
+	
+*/
+
+// _CompareTestEntryToTableEntryKey
+// (Local function for CFLocaleCreateCanonicalLocaleIdentifierFromString)
+// comparison function for bsearch
+static int _CompareTestEntryToTableEntryKey(const void *testEntryPtr, const void *tableEntryKeyPtr) {
+    return strcmp( ((const KeyStringToResultString *)testEntryPtr)->key, ((const KeyStringToResultString *)tableEntryKeyPtr)->key );
+}
+
+// _CompareTestEntryPrefixToTableEntryKey
+// (Local function for CFLocaleCreateCanonicalLocaleIdentifierFromString)
+// Comparison function for bsearch. Assumes prefix IS terminated with '-' or '_'.
+// Do the following instead of strlen & strncmp so we don't walk tableEntry key twice.
+static int _CompareTestEntryPrefixToTableEntryKey(const void *testEntryPtr, const void *tableEntryKeyPtr) {
+    const char *    testPtr = ((const KeyStringToResultString *)testEntryPtr)->key;
+    const char *    tablePtr = ((const KeyStringToResultString *)tableEntryKeyPtr)->key;
+    
+    while ( *testPtr == *tablePtr && *tablePtr != 0 ) {
+        testPtr++; tablePtr++;
+    }
+    if ( *tablePtr != 0 ) {
+        // strings are different, and the string in the table has not run out;
+        // i.e. the table entry is not a prefix of the text string.
+        return ( *testPtr < *tablePtr )? -1: 1;
+    }
+    return 0;
+}
+
+// _CompareLowerTestEntryPrefixToTableEntryKey
+// (Local function for CFLocaleCreateCanonicalLocaleIdentifierFromString)
+// Comparison function for bsearch. Assumes prefix NOT terminated with '-' or '_'.
+// Lowercases the test string before comparison (the table should already have lowercased entries).
+static int _CompareLowerTestEntryPrefixToTableEntryKey(const void *testEntryPtr, const void *tableEntryKeyPtr) {
+    const char *    testPtr = ((const KeyStringToResultString *)testEntryPtr)->key;
+    const char *    tablePtr = ((const KeyStringToResultString *)tableEntryKeyPtr)->key;
+    char            lowerTestChar;
+    
+    while ( (lowerTestChar = tolower(*testPtr)) == *tablePtr && *tablePtr != 0 && lowerTestChar != '_' ) {  // <1.9>
+        testPtr++; tablePtr++;
+    }
+    if ( *tablePtr != 0 ) {
+        // strings are different, and the string in the table has not run out;
+        // i.e. the table entry is not a prefix of the text string.
+        if (lowerTestChar == '_')                                                           // <1.9>
+            return -1;                                                                      // <1.9>
+        return ( lowerTestChar < *tablePtr )? -1: 1;
+    }
+    // The string in the table has run out. If the test string char is not alnum,
+    // then the string matches, else the test string sorts after.
+    return ( !isalnum(lowerTestChar) )? 0: 1;
+}
+
+// _DeleteCharsAtPointer
+// (Local function for CFLocaleCreateCanonicalLocaleIdentifierFromString)
+// remove _length_ characters from the beginning of the string indicated by _stringPtr_
+// (we know that the string has at least _length_ characters in it)
+static void _DeleteCharsAtPointer(char *stringPtr, int length) {
+    do {
+        *stringPtr = stringPtr[length];
+    } while (*stringPtr++ != 0);
+}
+
+// _CopyReplacementAtPointer
+// (Local function for CFLocaleCreateCanonicalLocaleIdentifierFromString)
+// Copy replacement string (*excluding* terminating NULL byte) to the place indicated by stringPtr
+static void _CopyReplacementAtPointer(char *stringPtr, const char *replacementPtr) {
+    while (*replacementPtr != 0) {
+        *stringPtr++ = *replacementPtr++;
+    }
+}
+
+// _CheckForTag
+// (Local function for CFLocaleCreateCanonicalLocaleIdentifierFromString)
+static Boolean _CheckForTag(const char *localeStringPtr, const char *tagPtr, int tagLen) {
+    return ( strncmp(localeStringPtr, tagPtr, tagLen) == 0 && !isalnum(localeStringPtr[tagLen]) );
+}
+
+// _ReplacePrefix
+// Move this code from _UpdateFullLocaleString into separate function                       // <1.10>
+static void _ReplacePrefix(char locString[], int locStringMaxLen, int oldPrefixLen, const char *newPrefix) {
+    int newPrefixLen = (int)strlen(newPrefix);
+    int lengthDelta = newPrefixLen - oldPrefixLen;
+    
+    if (lengthDelta < 0) {
+        // replacement is shorter, delete chars by shifting tail of string
+        _DeleteCharsAtPointer(locString + newPrefixLen, -lengthDelta);
+    } else if (lengthDelta > 0) {
+        // replacement is longer...
+        int stringLen = (int)strlen(locString);
+        
+        if (stringLen + lengthDelta < locStringMaxLen) {
+            // make room by shifting tail of string
+            char *  tailShiftPtr = locString + stringLen;
+            char *  tailStartPtr = locString + oldPrefixLen;    // pointer to tail of string to shift
+            
+            while (tailShiftPtr >= tailStartPtr) {
+                tailShiftPtr[lengthDelta] = *tailShiftPtr;
+                tailShiftPtr--;
+            }
+        } else {
+            // no room, can't do substitution
+            newPrefix = NULL;
+        }
+    }
+    
+    if (newPrefix) {
+        // do the substitution
+        _CopyReplacementAtPointer(locString, newPrefix);
+    }
+}
+
+// _UpdateFullLocaleString
+// Given a locale string that uses standard codes (not a special old-style Apple string),
+// update all the language codes and region codes to latest versions, map 3-letter
+// language codes to 2-letter codes if possible, and normalize casing. If requested, return
+// pointers to a language-region variant subtag (if present) and a region tag (if present).
+// (add locStringMaxLen parameter)                                                          // <1.10>
+static void _UpdateFullLocaleString(char inLocaleString[], int locStringMaxLen,
+									char **langRegSubtagRef, char **regionTagRef,
+									char varKeyValueString[])								// <1.17>
+{
+    KeyStringToResultString     testEntry;
+    KeyStringToResultString *   foundEntry;
+    const SpecialCaseUpdates *  specialCasePtr;
+    char *      inLocalePtr;
+    char *      subtagPtr;
+    char *      langRegSubtag = NULL;
+    char *      regionTag = NULL;
+    char *		variantTag = NULL;
+    Boolean     subtagHasDigits, pastPrimarySubtag, hadRegion;
+    
+    // 1. First replace any non-canonical prefix (case insensitive) with canonical
+    // (change 3-letter ISO 639 code to 2-letter, update obsolete ISO 639 codes & RFC 3066 tags, etc.)
+    
+    testEntry.key = inLocaleString;
+    foundEntry = (KeyStringToResultString *)bsearch( &testEntry, localeStringPrefixToCanonical, kNumLocaleStringPrefixToCanonical,
+                                                    sizeof(KeyStringToResultString), _CompareLowerTestEntryPrefixToTableEntryKey );
+    if (foundEntry) {
+        // replace key (at beginning of string) with result
+        _ReplacePrefix(inLocaleString, locStringMaxLen, (int)strlen(foundEntry->key), foundEntry->result);   // <1.10>
+    }
+    
+    // 2. Walk through input string, normalizing case & marking use of ISO 3166 codes
+    
+    inLocalePtr = inLocaleString;
+    subtagPtr = inLocaleString;
+    subtagHasDigits = false;
+    pastPrimarySubtag = false;
+    hadRegion = false;
+    
+    while ( true ) {
+        if ( isalpha(*inLocalePtr) ) {
+            // if not past a region tag, then lowercase, else uppercase
+            *inLocalePtr = (!hadRegion)? tolower(*inLocalePtr): toupper(*inLocalePtr);
+        } else if ( isdigit(*inLocalePtr) ) {
+            subtagHasDigits = true;
+        } else {
+            
+            if (!pastPrimarySubtag) {
+                // may have a NULL primary subtag
+                if (subtagHasDigits) {
+                    break;
+                }
+                pastPrimarySubtag = true;
+            } else if (!hadRegion) {
+                // We are after any primary language subtag, but not past any region tag.
+                // This subtag is preceded by '-' or '_'.
+                int subtagLength = inLocalePtr - subtagPtr; // includes leading '-' or '_'
+                
+				if (subtagLength == 3 && !subtagHasDigits) {
+					// potential ISO 3166 code for region or language variant; if so, needs uppercasing
+					if (*subtagPtr == '_') {
+						regionTag = subtagPtr;
+						hadRegion = true;
+						subtagPtr[1] = toupper(subtagPtr[1]);
+						subtagPtr[2] = toupper(subtagPtr[2]);
+					} else if (langRegSubtag == NULL) {
+						langRegSubtag = subtagPtr;
+						subtagPtr[1] = toupper(subtagPtr[1]);
+						subtagPtr[2] = toupper(subtagPtr[2]);
+					}
+				} else if (subtagLength == 4 && subtagHasDigits) {
+					// potential UN M.49 region code
+					if (*subtagPtr == '_') {
+						regionTag = subtagPtr;
+						hadRegion = true;
+					} else if (langRegSubtag == NULL) {
+						langRegSubtag = subtagPtr;
+					}
+				} else if (subtagLength == 5 && !subtagHasDigits) {
+					// ISO 15924 script code, uppercase just the first letter
+					subtagPtr[1] = toupper(subtagPtr[1]);
+				} else if (subtagLength == 1 && *subtagPtr == '_') {						// <1.17>
+					hadRegion = true;
+				}
+                
+                if (!hadRegion) {
+                    // convert improper '_' to '-'
+                    *subtagPtr = '-';
+                }
+            } else {
+            	variantTag = subtagPtr;															// <1.17>
+            }
+            
+            if (*inLocalePtr == '-' || *inLocalePtr == '_') {
+                subtagPtr = inLocalePtr;
+                subtagHasDigits = false;
+            } else {
+                break;
+            }
+        }
+    
+        inLocalePtr++;
+    }
+    
+    // 3 If there is a variant tag, see if ICU canonicalizes it to keywords.					// <1.17> [3577669]
+    // If so, copy the keywords to varKeyValueString and delete the variant tag
+    // from the original string (but don't otherwise use the ICU canonicalization).
+    varKeyValueString[0] = 0;
+    if (variantTag) {
+		UErrorCode	icuStatus;
+		int			icuCanonStringLen;
+		char * 		varKeyValueStringPtr = varKeyValueString;
+		
+		icuStatus = U_ZERO_ERROR;
+		icuCanonStringLen = uloc_canonicalize( inLocaleString, varKeyValueString, locStringMaxLen, &icuStatus );
+		if ( U_SUCCESS(icuStatus) ) {
+			char *	icuCanonStringPtr = varKeyValueString;
+			
+			if (icuCanonStringLen >= locStringMaxLen)
+				icuCanonStringLen = locStringMaxLen - 1;
+			varKeyValueString[icuCanonStringLen] = 0;
+			while (*icuCanonStringPtr != 0 && *icuCanonStringPtr != ULOC_KEYWORD_SEPARATOR)
+				++icuCanonStringPtr;
+			if (*icuCanonStringPtr != 0) {
+				// the canonicalized string has keywords
+				// delete the variant tag in the original string (and other trailing '_' or '-')
+				*variantTag-- = 0;
+				while (*variantTag == '_')
+					*variantTag-- = 0;
+				// delete all of the canonicalized string except the keywords
+				while (*icuCanonStringPtr != 0)
+					*varKeyValueStringPtr++ = *icuCanonStringPtr++;
+			}
+		*varKeyValueStringPtr = 0;
+		}
+    }
+    
+    // 4. Handle special cases of updating region codes, or updating language codes based on
+    // region code.
+    for (specialCasePtr = specialCases; specialCasePtr->reg1 != NULL; specialCasePtr++) {
+        if ( specialCasePtr->lang == NULL || _CheckForTag(inLocaleString, specialCasePtr->lang, 2) ) {
+            // OK, we matched any language specified. Now what needs updating?
+            char * foundTag;
+            
+            if ( isupper(specialCasePtr->update1[0]) ) {
+                // updating a region code
+                if ( ( foundTag = strstr(inLocaleString, specialCasePtr->reg1) ) && !isalnum(foundTag[3]) ) {
+                    _CopyReplacementAtPointer(foundTag+1, specialCasePtr->update1);
+                }
+                if ( regionTag && _CheckForTag(regionTag+1, specialCasePtr->reg1 + 1, 2) ) {
+                    _CopyReplacementAtPointer(regionTag+1, specialCasePtr->update1);
+                }
+                
+            } else {
+                // updating the language, there will be two choices based on region
+                if        ( ( regionTag && _CheckForTag(regionTag+1, specialCasePtr->reg1 + 1, 2) ) ||
+                            ( ( foundTag = strstr(inLocaleString, specialCasePtr->reg1) ) && !isalnum(foundTag[3]) ) ) {
+                    _CopyReplacementAtPointer(inLocaleString, specialCasePtr->update1);
+                } else if ( ( regionTag && _CheckForTag(regionTag+1, specialCasePtr->reg2 + 1, 2) ) ||
+                            ( ( foundTag = strstr(inLocaleString, specialCasePtr->reg2) ) && !isalnum(foundTag[3]) ) ) {
+                    _CopyReplacementAtPointer(inLocaleString, specialCasePtr->update2);
+                }
+            }
+        }
+    }
+
+    // 5. return pointers if requested.
+    if (langRegSubtagRef != NULL) {
+        *langRegSubtagRef = langRegSubtag;
+    }
+    if (regionTagRef != NULL) {
+        *regionTagRef = regionTag;
+    }
+}
+
+
+// _RemoveSubstringsIfPresent
+// (Local function for CFLocaleCreateCanonicalLocaleIdentifierFromString)
+// substringList is a list of space-separated substrings to strip if found in localeString
+static void _RemoveSubstringsIfPresent(char *localeString, const char *substringList) {
+    while (*substringList != 0) {
+        char    currentSubstring[kLocaleIdentifierCStringMax];
+        int     substringLength = 0;
+        char *  foundSubstring;
+
+        // copy current substring & get its length
+        while ( isgraph(*substringList) ) {
+            currentSubstring[substringLength++] = *substringList++;
+        }
+        // move to next substring
+        while ( isspace(*substringList) ) {
+            substringList++;
+        }
+
+        // search for current substring in locale string
+        if (substringLength == 0)
+            continue;
+        currentSubstring[substringLength] = 0;
+        foundSubstring = strstr(localeString, currentSubstring);
+
+        // if substring is found, delete it
+        if (foundSubstring) {
+            _DeleteCharsAtPointer(foundSubstring, substringLength);
+        }
+    }
+}
+
+
+// _GetKeyValueString                                                                       // <1.10>
+// Removes any key-value string from inLocaleString, puts canonized version in keyValueString
+
+static void _GetKeyValueString(char inLocaleString[], char keyValueString[]) {
+    char *  inLocalePtr = inLocaleString;
+    
+    while (*inLocalePtr != 0 && *inLocalePtr != ULOC_KEYWORD_SEPARATOR) {
+        inLocalePtr++;
+    }
+    if (*inLocalePtr != 0) {    // we found a key-value section
+        char *  keyValuePtr = keyValueString;
+        
+        *keyValuePtr = *inLocalePtr;
+        *inLocalePtr = 0;
+        do {
+            if ( *(++inLocalePtr) != ' ' ) {
+                *(++keyValuePtr) = *inLocalePtr;    // remove "tolower() for *inLocalePtr"  // <1.11>
+            }
+        } while (*inLocalePtr != 0);
+    } else {
+        keyValueString[0] = 0;
+    }
+}
+
+static void _AppendKeyValueString(char inLocaleString[], int locStringMaxLen, char keyValueString[]) {
+	if (keyValueString[0] != 0) {
+		UErrorCode		uerr = U_ZERO_ERROR;
+		UEnumeration *	uenum = uloc_openKeywords(keyValueString, &uerr);
+		if ( uenum != NULL ) {
+			const char *	keyword;
+			int32_t			length;
+			char			value[ULOC_KEYWORDS_CAPACITY];	// use as max for keyword value
+			while ( U_SUCCESS(uerr) ) {
+				keyword = uenum_next(uenum, &length, &uerr);
+				if ( keyword == NULL ) {
+					break;
+				}
+				length = uloc_getKeywordValue( keyValueString, keyword, value, sizeof(value), &uerr );
+				length = uloc_setKeywordValue( keyword, value, inLocaleString, locStringMaxLen, &uerr );
+			}
+			uenum_close(uenum);
+		}
+	}
+}
+
+__private_extern__ CFStringRef _CFLocaleCreateCanonicalLanguageIdentifierForCFBundle(CFAllocatorRef allocator, CFStringRef localeIdentifier) {
+    char            inLocaleString[kLocaleIdentifierCStringMax];
+    CFStringRef     outStringRef = NULL;
+    
+    if ( localeIdentifier && CFStringGetCString(localeIdentifier, inLocaleString,  sizeof(inLocaleString), kCFStringEncodingASCII) ) {
+        KeyStringToResultString     testEntry;
+        KeyStringToResultString *   foundEntry;
+        char                        keyValueString[sizeof(inLocaleString)];				// <1.10>
+        char						varKeyValueString[sizeof(inLocaleString)];			// <1.17>
+
+        _GetKeyValueString(inLocaleString, keyValueString);								// <1.10>
+        testEntry.result = NULL;
+        
+        // A. First check if input string matches an old-style string that has a replacement
+        // (do this before case normalization)
+        testEntry.key = inLocaleString;
+        foundEntry = (KeyStringToResultString *)bsearch( &testEntry, oldAppleLocaleToCanonical, kNumOldAppleLocaleToCanonical,
+                                                        sizeof(KeyStringToResultString), _CompareTestEntryToTableEntryKey );
+        if (foundEntry) {
+            // It does match, so replace old string with new
+            strlcpy(inLocaleString, foundEntry->result, sizeof(inLocaleString));
+             varKeyValueString[0] = 0;
+        } else {
+            // B. No match with an old-style string, use input string but update codes, normalize case, etc.
+            _UpdateFullLocaleString(inLocaleString, sizeof(inLocaleString), NULL, NULL, varKeyValueString);   // <1.10><1.17>
+        }
+        
+        // C. Now we have an up-to-date locale string, but we need to strip defaults and turn it into a language string
+        
+        // 1. Strip defaults in input string based on initial part of locale string
+        // (mainly to strip default script tag for a language)
+        testEntry.key = inLocaleString;
+        foundEntry = (KeyStringToResultString *)bsearch( &testEntry, localeStringPrefixToDefaults, kNumLocaleStringPrefixToDefaults,
+                                                        sizeof(KeyStringToResultString), _CompareTestEntryPrefixToTableEntryKey );
+        if (foundEntry) {
+            // The input string begins with a character sequence for which
+            // there are default substrings which should be stripped if present
+            _RemoveSubstringsIfPresent(inLocaleString, foundEntry->result);         
+        }
+        
+        // 2. If the string matches a locale string used by Apple as a language string, turn it into a language string
+        testEntry.key = inLocaleString;
+        foundEntry = (KeyStringToResultString *)bsearch( &testEntry, appleLocaleToLanguageStringForCFBundle, kNumAppleLocaleToLanguageStringForCFBundle,
+                                                        sizeof(KeyStringToResultString), _CompareTestEntryToTableEntryKey );
+        if (foundEntry) {
+            // it does match
+            strlcpy(inLocaleString, foundEntry->result, sizeof(inLocaleString));
+        } else {
+            // just delete the region tag and anything after
+            char *  inLocalePtr = inLocaleString;
+            while (*inLocalePtr != 0 && *inLocalePtr != '_') {
+                inLocalePtr++;
+            }
+            *inLocalePtr = 0;
+        }
+        
+        // D. Re-append any key-value strings, now canonical										// <1.10><1.17>
+		_AppendKeyValueString( inLocaleString, sizeof(inLocaleString), varKeyValueString );
+		_AppendKeyValueString( inLocaleString, sizeof(inLocaleString), keyValueString );
+        
+        // All done, return what we came up with.
+        outStringRef = CFStringCreateWithCString(allocator, inLocaleString, kCFStringEncodingASCII);
+    }
+
+    return outStringRef;
+}
+
+CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier) {
+    char            inLocaleString[kLocaleIdentifierCStringMax];
+    CFStringRef     outStringRef = NULL;
+    
+    if ( localeIdentifier && CFStringGetCString(localeIdentifier, inLocaleString,  sizeof(inLocaleString), kCFStringEncodingASCII) ) {
+        KeyStringToResultString     testEntry;
+        KeyStringToResultString *   foundEntry;
+        char                        keyValueString[sizeof(inLocaleString)];				// <1.10>
+        char						varKeyValueString[sizeof(inLocaleString)];			// <1.17>
+
+        _GetKeyValueString(inLocaleString, keyValueString);								// <1.10>
+        testEntry.result = NULL;
+        
+        // A. First check if input string matches an old-style string that has a replacement
+        // (do this before case normalization)
+        testEntry.key = inLocaleString;
+        foundEntry = (KeyStringToResultString *)bsearch( &testEntry, oldAppleLocaleToCanonical, kNumOldAppleLocaleToCanonical,
+                                                        sizeof(KeyStringToResultString), _CompareTestEntryToTableEntryKey );
+        if (foundEntry) {
+            // It does match, so replace old string with new
+            strlcpy(inLocaleString, foundEntry->result, sizeof(inLocaleString));
+             varKeyValueString[0] = 0;
+        } else {
+            char *      langRegSubtag = NULL;
+            char *      regionTag = NULL;
+
+            // B. No match with an old-style string, use input string but update codes, normalize case, etc.
+            _UpdateFullLocaleString(inLocaleString, sizeof(inLocaleString), &langRegSubtag, &regionTag, varKeyValueString);   // <1.10><1.17><1.19>
+            
+            // if the language part already includes a regional variant, then delete any region tag. <1.19>
+            if (langRegSubtag && regionTag)
+            	*regionTag = 0;
+        }
+        
+        // C. Now we have an up-to-date locale string, but we need to strip defaults and turn it into a language string
+        
+        // 1. Strip defaults in input string based on initial part of locale string
+        // (mainly to strip default script tag for a language)
+        testEntry.key = inLocaleString;
+        foundEntry = (KeyStringToResultString *)bsearch( &testEntry, localeStringPrefixToDefaults, kNumLocaleStringPrefixToDefaults,
+                                                        sizeof(KeyStringToResultString), _CompareTestEntryPrefixToTableEntryKey );
+        if (foundEntry) {
+            // The input string begins with a character sequence for which
+            // there are default substrings which should be stripped if present
+            _RemoveSubstringsIfPresent(inLocaleString, foundEntry->result);         
+        }
+        
+        // 2. If the string matches a locale string used by Apple as a language string, turn it into a language string
+        testEntry.key = inLocaleString;
+        foundEntry = (KeyStringToResultString *)bsearch( &testEntry, appleLocaleToLanguageString, kNumAppleLocaleToLanguageString,
+                                                        sizeof(KeyStringToResultString), _CompareTestEntryToTableEntryKey );
+        if (foundEntry) {
+            // it does match
+            strlcpy(inLocaleString, foundEntry->result, sizeof(inLocaleString));
+        } else {
+            // skip to any region tag or java-type variant
+            char *  inLocalePtr = inLocaleString;
+            while (*inLocalePtr != 0 && *inLocalePtr != '_') {
+                inLocalePtr++;
+            }
+            // if there is still a region tag, turn it into a language variant <1.19>
+            if (*inLocalePtr == '_') {
+            	// handle 3-digit regions in addition to 2-letter ones
+            	char *	regionTag = inLocalePtr++;
+            	long	expectedLength = 0;
+            	if ( isalpha(*inLocalePtr) ) {
+            		while ( isalpha(*(++inLocalePtr)) )
+            			;
+            		expectedLength = 3;
+            	} else if ( isdigit(*inLocalePtr) ) {
+            		while ( isdigit(*(++inLocalePtr)) )
+            			;
+            		expectedLength = 4;
+            	}
+            	*regionTag = (inLocalePtr - regionTag == expectedLength)? '-': 0;
+             }
+             // anything else at/after '_' just gets deleted
+            *inLocalePtr = 0;
+        }
+        
+        // D. Re-append any key-value strings, now canonical										// <1.10><1.17>
+		_AppendKeyValueString( inLocaleString, sizeof(inLocaleString), varKeyValueString );
+		_AppendKeyValueString( inLocaleString, sizeof(inLocaleString), keyValueString );
+        
+        // All done, return what we came up with.
+        outStringRef = CFStringCreateWithCString(allocator, inLocaleString, kCFStringEncodingASCII);
+    }
+
+    return outStringRef;
+}
+
+
+CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier) {
+    char            inLocaleString[kLocaleIdentifierCStringMax];
+    CFStringRef     outStringRef = NULL;
+    
+    if ( localeIdentifier && CFStringGetCString(localeIdentifier, inLocaleString,  sizeof(inLocaleString), kCFStringEncodingASCII) ) {
+        KeyStringToResultString     testEntry;
+        KeyStringToResultString *   foundEntry;
+        char                        keyValueString[sizeof(inLocaleString)];				// <1.10>
+        char			    		varKeyValueString[sizeof(inLocaleString)];			// <1.17>
+
+        _GetKeyValueString(inLocaleString, keyValueString);								// <1.10>
+        testEntry.result = NULL;
+        
+        // A. First check if input string matches an old-style Apple string that has a replacement
+        // (do this before case normalization)
+        testEntry.key = inLocaleString;
+        foundEntry = (KeyStringToResultString *)bsearch( &testEntry, oldAppleLocaleToCanonical, kNumOldAppleLocaleToCanonical,
+                                                        sizeof(KeyStringToResultString), _CompareTestEntryToTableEntryKey );
+        if (foundEntry) {
+            // It does match, so replace old string with new                                // <1.10>
+            strlcpy(inLocaleString, foundEntry->result, sizeof(inLocaleString));
+            varKeyValueString[0] = 0;
+        } else {
+            char *      langRegSubtag = NULL;
+            char *      regionTag = NULL;
+
+            // B. No match with an old-style string, use input string but update codes, normalize case, etc.
+            _UpdateFullLocaleString(inLocaleString, sizeof(inLocaleString), &langRegSubtag, &regionTag, varKeyValueString);   // <1.10><1.17>
+
+
+            // C. Now strip defaults that are implied by other fields.
+
+            // 1. If an ISO 3166 region tag matches an ISO 3166 regional language variant subtag, strip the latter.
+            if ( langRegSubtag && regionTag && strncmp(langRegSubtag+1, regionTag+1, 2) == 0 ) {
+                _DeleteCharsAtPointer(langRegSubtag, 3);
+            }
+
+            // 2. Strip defaults in input string based on final region tag in locale string
+            // (mainly for Chinese, to strip -Hans for _CN/_SG, -Hant for _TW/_HK/_MO)
+            if ( regionTag ) {
+                testEntry.key = regionTag;
+                foundEntry = (KeyStringToResultString *)bsearch( &testEntry, localeStringRegionToDefaults, kNumLocaleStringRegionToDefaults,
+                                                                sizeof(KeyStringToResultString), _CompareTestEntryToTableEntryKey );
+                if (foundEntry) {
+                    _RemoveSubstringsIfPresent(inLocaleString, foundEntry->result);
+                }
+            }
+            
+            // 3. Strip defaults in input string based on initial part of locale string
+            // (mainly to strip default script tag for a language)
+            testEntry.key = inLocaleString;
+            foundEntry = (KeyStringToResultString *)bsearch( &testEntry, localeStringPrefixToDefaults, kNumLocaleStringPrefixToDefaults,
+                                                            sizeof(KeyStringToResultString), _CompareTestEntryPrefixToTableEntryKey );
+            if (foundEntry) {
+                // The input string begins with a character sequence for which
+                // there are default substrings which should be stripped if present
+                _RemoveSubstringsIfPresent(inLocaleString, foundEntry->result);         
+            }
+        }
+
+        // D. Re-append any key-value strings, now canonical								// <1.10><1.17>
+		_AppendKeyValueString( inLocaleString, sizeof(inLocaleString), varKeyValueString );
+		_AppendKeyValueString( inLocaleString, sizeof(inLocaleString), keyValueString );
+        
+        // Now create the CFString (even if empty!)
+        outStringRef = CFStringCreateWithCString(allocator, inLocaleString, kCFStringEncodingASCII);
+    }
+
+    return outStringRef;
+}
+
+// CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes, based on
+// the first part of the SPI CFBundleCopyLocalizationForLocalizationInfo in CFBundle_Resources.c
+CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode) {
+    CFStringRef result = NULL;
+    if (0 <= rcode && rcode < kNumRegionCodeToLocaleString) {
+	const char *localeString = regionCodeToLocaleString[rcode];
+	if (localeString != NULL && *localeString != '\0') {
+	    result = CFStringCreateWithCStringNoCopy(allocator, localeString, kCFStringEncodingASCII, kCFAllocatorNull);
+	}
+    }
+    if (result) return result;
+    if (0 <= lcode && lcode < kNumLangCodeToLocaleString) {
+	const char *localeString = langCodeToLocaleString[lcode];
+	if (localeString != NULL && *localeString != '\0') {
+	    result = CFStringCreateWithCStringNoCopy(allocator, localeString, kCFStringEncodingASCII, kCFAllocatorNull);
+	}
+    }
+    return result;
+}
+
+
+CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID) {
+    char cLocaleID[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    char buffer[ULOC_FULLNAME_CAPACITY+ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    CFMutableDictionaryRef working = CFDictionaryCreateMutable(allocator, 10, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    int32_t length = 0;
+    
+    // Extract the C string locale ID, for ICU
+    CFIndex outBytes = 0;
+    CFStringGetBytes(localeID, CFRangeMake(0, CFStringGetLength(localeID)), kCFStringEncodingASCII, (UInt8) '?', true, (unsigned char *)cLocaleID, sizeof(cLocaleID)/sizeof(char) - 1, &outBytes);
+    cLocaleID[outBytes] = '\0';
+
+    // Get the components
+    length = uloc_getLanguage(cLocaleID, buffer, sizeof(buffer)/sizeof(char), &icuStatus);
+    if (U_SUCCESS(icuStatus) && length > 0)
+    {
+        CFStringRef string = CFStringCreateWithBytes(allocator, (UInt8 *)buffer, length, kCFStringEncodingASCII, true);
+        CFDictionaryAddValue(working, kCFLocaleLanguageCode, string);
+        CFRelease(string);
+    }
+    icuStatus = U_ZERO_ERROR;
+    
+    length = uloc_getScript(cLocaleID, buffer, sizeof(buffer)/sizeof(char), &icuStatus);
+    if (U_SUCCESS(icuStatus) && length > 0)
+    {
+        CFStringRef string = CFStringCreateWithBytes(allocator, (UInt8 *)buffer, length, kCFStringEncodingASCII, true);
+        CFDictionaryAddValue(working, kCFLocaleScriptCode, string);
+        CFRelease(string);
+    }
+    icuStatus = U_ZERO_ERROR;
+    
+    length = uloc_getCountry(cLocaleID, buffer, sizeof(buffer)/sizeof(char), &icuStatus);
+    if (U_SUCCESS(icuStatus) && length > 0)
+    {
+        CFStringRef string = CFStringCreateWithBytes(allocator, (UInt8 *)buffer, length, kCFStringEncodingASCII, true);
+        CFDictionaryAddValue(working, kCFLocaleCountryCode, string);
+        CFRelease(string);
+    }
+    icuStatus = U_ZERO_ERROR;
+    
+    length = uloc_getVariant(cLocaleID, buffer, sizeof(buffer)/sizeof(char), &icuStatus);
+    if (U_SUCCESS(icuStatus) && length > 0)
+    {
+        CFStringRef string = CFStringCreateWithBytes(allocator, (UInt8 *)buffer, length, kCFStringEncodingASCII, true);
+        CFDictionaryAddValue(working, kCFLocaleVariantCode, string);
+        CFRelease(string);
+    }
+    icuStatus = U_ZERO_ERROR;
+    
+    // Now get the keywords; open an enumerator on them
+    UEnumeration *iter = uloc_openKeywords(cLocaleID, &icuStatus);
+    const char *locKey = NULL;
+    int32_t locKeyLen = 0;
+    while ((locKey = uenum_next(iter, &locKeyLen, &icuStatus)) && U_SUCCESS(icuStatus))
+    {
+        char locValue[ULOC_KEYWORD_AND_VALUES_CAPACITY];
+    
+        // Get the value for this keyword
+        if (uloc_getKeywordValue(cLocaleID, locKey, locValue, sizeof(locValue)/sizeof(char), &icuStatus) > 0
+            && U_SUCCESS(icuStatus))
+        {
+            CFStringRef key = CFStringCreateWithBytes(allocator, (UInt8 *)locKey, (CFIndex)strlen(locKey), kCFStringEncodingASCII, true);
+            CFStringRef value = CFStringCreateWithBytes(allocator, (UInt8 *)locValue, (CFIndex)strlen(locValue), kCFStringEncodingASCII, true);
+            if (key && value)
+                CFDictionaryAddValue(working, key, value);
+            if (key)
+                CFRelease(key);
+            if (value)
+                CFRelease(value);
+        }
+    }
+    uenum_close(iter);
+    
+    // Convert to an immutable dictionary and return
+    CFDictionaryRef result = CFDictionaryCreateCopy(allocator, working);
+    CFRelease(working);
+    return result;
+}
+
+typedef struct __AppendContext
+{
+    char                separator;
+    CFMutableStringRef  working;
+} __AppendContext;
+
+static void __AppendKeywords(const void *k, const void *v, void *c)
+{
+    __AppendContext *context = (__AppendContext *) c;
+    CFStringRef key = (CFStringRef) k;
+    CFStringRef value = (CFStringRef) v;
+    if (CFEqual(key, kCFLocaleLanguageCode) || CFEqual(key, kCFLocaleScriptCode) || CFEqual(key, kCFLocaleCountryCode) || CFEqual(key, kCFLocaleVariantCode))
+        return;
+    CFStringAppendFormat(context->working, NULL, CFSTR("%c%@%c%@"), context->separator, key, ULOC_KEYWORD_ASSIGN, value);
+    context->separator = ULOC_KEYWORD_ITEM_SEPARATOR;
+}
+
+CFStringRef CFLocaleCreateLocaleIdentifierFromComponents(CFAllocatorRef allocator, CFDictionaryRef dictionary) {
+    CFMutableStringRef working = CFStringCreateMutable(allocator, 0);
+    CFStringRef value = NULL;
+    bool country = false;
+    __AppendContext context = {ULOC_KEYWORD_SEPARATOR, working};
+    
+    if ((value = (CFStringRef) CFDictionaryGetValue(dictionary, kCFLocaleLanguageCode)))
+    {
+        CFStringAppend(working, value);
+    }
+
+    if ((value = (CFStringRef) CFDictionaryGetValue(dictionary, kCFLocaleScriptCode)))
+    {
+        CFStringAppendFormat(working, NULL, CFSTR("_%@"), value);
+    }
+    
+    if ((value = (CFStringRef) CFDictionaryGetValue(dictionary, kCFLocaleCountryCode)))
+    {
+        CFStringAppendFormat(working, NULL, CFSTR("_%@"), value);
+        country = true;
+    }
+    
+    if ((value = (CFStringRef) CFDictionaryGetValue(dictionary, kCFLocaleVariantCode)))
+    {
+        if (!country)
+            CFStringAppend(working, CFSTR("_"));
+        CFStringAppendFormat(working, NULL, CFSTR("_%@"), value);
+    }
+    
+    // Now iterate through any remaining entries and append as keywords
+    CFDictionaryApplyFunction(dictionary, __AppendKeywords, &context);
+    
+    // Convert to immutable string and return
+    CFStringRef result = (CFStringRef)CFStringCreateCopy(allocator, working);
+    CFRelease(working);
+    return result;
+}
+
diff --git a/CoreFoundation/CFLogUtilities.h b/CoreFoundation/CFLogUtilities.h
new file mode 100644
index 0000000..f035265
--- /dev/null
+++ b/CoreFoundation/CFLogUtilities.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+/*
+        APPLE SPI:  NOT TO BE USED OUTSIDE APPLE!
+*/
+
+#if !defined(__COREFOUNDATION_CFLOGUTILITIES__)
+#define __COREFOUNDATION_CFLOGUTILITIES__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFString.h>
+
+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/CoreFoundation/CFMachPort.c b/CoreFoundation/CFMachPort.c
new file mode 100644
index 0000000..10b3d1c
--- /dev/null
+++ b/CoreFoundation/CFMachPort.c
@@ -0,0 +1,595 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+/* 
+   [The following dissertation was written mostly for the
+   benefit of open source developers.]
+
+   Writing a run loop source can be a tricky business, but
+   for CFMachPort that part is relatively straightforward.
+   Thus, it makes a good example for study.  Particularly
+   interesting for examination is the process of caching
+   the objects in a non-retaining cache, the invalidation
+   and deallocation sequences, locking for thread-safety,
+   and how the invalidation callback is used.
+
+   CFMachPort is a version 1 CFRunLoopSource, implemented
+   by a few functions.  See CFMachPortCreateRunLoopSource()
+   for details on how the run loop source is setup.  Note
+   how the source is kept track of by the CFMachPort, so
+   that it can be returned again and again from that function.
+   This helps not only reduce the amount of memory expended
+   in run loop source objects, but eliminates redundant
+   registrations with the run loop and the excess time and
+   memory that would consume.  It also allows the CFMachPort
+   to propogate its own invalidation to the run loop source
+   representing it.
+
+   CFMachPortCreateWithPort() is the funnel point for the
+   creation of CFMachPort instances.  The cache is first
+   probed to see if an instance with that port is already
+   available, and return that.  The object is next allocated
+   and mostly initialized, before it is registered for death
+   notification.  This is because cleaning up the memory is
+   simpler than trying to get rid of the registration if
+   memory allocation later fails.  The new object must be at
+   least partially initialized (into a harmless state) so
+   that it can be safely invalidated/deallocated if something
+   fails later in creation.  Any object allocated with
+   _CFRuntimeCreateInstance() may only be disposed by using
+   CFRelease() (never CFAllocatorDeallocate!) so the class
+   deallocation function __CFMachPortDeallocate() must be
+   able to handle that, and initializing the object to have
+   NULL fields and whatnot makes that possible.  The creation
+   eventually inserts the new object in the cache.
+
+   A CFMachPort may be explicitly invalidated, autoinvalidated
+   due to the death of the port (that process is not discussed
+   further here), or invalidated as part of the deallocation
+   process when the last reference is released.  For
+   convenience, in all cases this is done through
+   CFMachPortInvalidate().  To prevent the CFMachPort from
+   being freed in mid-function due to the callouts, the object
+   is retained at the beginning of the function.  But if this
+   invalidation is due to the object being deallocated, a
+   retain and then release at the end of the function would
+   cause a recursive call to __CFMachPortDeallocate().  The
+   retain protection should be immaterial though at that stage.
+   Invalidation also removes the object from the cache; though
+   the object itself is not yet destroyed, invalidation makes
+   it "useless".
+   
+   The best way to learn about the locking is to look through
+   the code -- it's fairly straightforward.  The one thing
+   worth calling attention to is how locks must be unlocked
+   before invoking any user-defined callout function, and
+   usually retaken after it returns.  This supports reentrancy
+   (which is distinct from thread-safety).
+
+   The invalidation callback, if one has been set, is called
+   at invalidation time, but before the object has been torn
+   down so that the port and other properties may be retrieved
+   from the object in the callback.  Note that if the callback
+   is attempted to be set after the CFMachPort is invalid,
+   the function is simply called.  This helps with certain
+   race conditions where the invalidation notification might
+   be lost.  Only the owner/creator of a CFMachPort should
+   really be setting the invalidation callback.
+
+   Now, the CFMachPort is not retained/released around all
+   callouts, but the callout may release the last reference.
+   Also, sometimes it is friendly to retain/release the
+   user-defined "info" around callouts, so that clients
+   don't have to worry about that.  These may be some things
+   to think about in the future, but is usually overkill.
+
+   In general, with higher level functionalities in the system,
+   it isn't even possible for a process to fork() and the child
+   not exec(), but continue running, since the higher levels
+   have done one-time initializations that aren't going to
+   happen again.
+
+	- Chris Kane
+
+*/
+
+#if DEPLOYMENT_TARGET_MACOSX
+
+#include <CoreFoundation/CFMachPort.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFByteOrder.h>
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+#include <mach/notify.h>
+#include <unistd.h>
+#include "CFInternal.h"
+#include <dlfcn.h>
+
+static CFSpinLock_t __CFAllMachPortsLock = CFSpinLockInit;
+static CFMutableDictionaryRef __CFAllMachPorts = NULL;
+static mach_port_t __CFNotifyRawMachPort = MACH_PORT_NULL;
+static CFMachPortRef __CFNotifyMachPort = NULL;
+
+struct __CFMachPort {
+    CFRuntimeBase _base;
+    CFSpinLock_t _lock;
+    mach_port_t _port;			/* immutable; invalidated */
+    mach_port_t _oldnotify;		/* immutable; invalidated */
+    CFRunLoopSourceRef _source;		/* immutable, once created; invalidated */
+    CFMachPortInvalidationCallBack _icallout;
+    CFMachPortCallBack _callout;	/* immutable */
+    CFMachPortContext _context;		/* immutable; invalidated */
+};
+
+/* Bit 0 in the base reserved bits is used for invalid state */
+/* Bit 1 in the base reserved bits is used for has-receive-ref state */
+/* Bit 2 in the base reserved bits is used for has-send-ref state */
+/* Bit 3 in the base reserved bits is used for is-deallocing state */
+
+CF_INLINE Boolean __CFMachPortIsValid(CFMachPortRef mp) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 0, 0);
+}
+
+CF_INLINE void __CFMachPortSetValid(CFMachPortRef mp) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 0, 0, 1);
+}
+
+CF_INLINE void __CFMachPortUnsetValid(CFMachPortRef mp) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 0, 0, 0);
+}
+
+CF_INLINE Boolean __CFMachPortHasReceive(CFMachPortRef mp) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 1, 1);
+}
+
+CF_INLINE void __CFMachPortSetHasReceive(CFMachPortRef mp) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 1, 1, 1);
+}
+
+CF_INLINE Boolean __CFMachPortHasSend(CFMachPortRef mp) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 2, 2);
+}
+
+CF_INLINE void __CFMachPortSetHasSend(CFMachPortRef mp) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 2, 2, 1);
+}
+
+CF_INLINE Boolean __CFMachPortIsDeallocing(CFMachPortRef mp) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 3, 3);
+}
+
+CF_INLINE void __CFMachPortSetIsDeallocing(CFMachPortRef mp) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)mp)->_cfinfo[CF_INFO_BITS], 3, 3, 1);
+}
+
+CF_INLINE void __CFMachPortLock(CFMachPortRef mp) {
+    __CFSpinLock(&(mp->_lock));
+}
+
+CF_INLINE void __CFMachPortUnlock(CFMachPortRef mp) {
+    __CFSpinUnlock(&(mp->_lock));
+}
+
+void _CFMachPortInstallNotifyPort(CFRunLoopRef rl, CFStringRef mode) {
+    CFRunLoopSourceRef source;
+    if (NULL == __CFNotifyMachPort) return;
+    source = CFMachPortCreateRunLoopSource(kCFAllocatorSystemDefault, __CFNotifyMachPort, -1000);
+    CFRunLoopAddSource(rl, source, mode);
+    CFRelease(source);
+}
+
+static void __CFNotifyDeadMachPort(CFMachPortRef port, void *msg, CFIndex size, void *info) {
+    mach_msg_header_t *header = (mach_msg_header_t *)msg;
+    mach_port_t dead_port = MACH_PORT_NULL;
+    if (header && header->msgh_id == MACH_NOTIFY_DEAD_NAME) {
+	dead_port = ((mach_dead_name_notification_t *)msg)->not_port;
+	if (((mach_dead_name_notification_t *)msg)->NDR.int_rep != NDR_record.int_rep) {
+	    dead_port = CFSwapInt32(dead_port);	
+	}
+    } else if (header && header->msgh_id == MACH_NOTIFY_PORT_DELETED) {
+	dead_port = ((mach_port_deleted_notification_t *)msg)->not_port;
+	if (((mach_port_deleted_notification_t *)msg)->NDR.int_rep != NDR_record.int_rep) {
+	    dead_port = CFSwapInt32(dead_port);	
+	}
+    } else {
+	return;
+    }
+
+    CFMachPortRef existing;
+    /* If the CFMachPort has already been invalidated, it won't be found here. */
+    __CFSpinLock(&__CFAllMachPortsLock);
+    if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)(uintptr_t)dead_port, (const void **)&existing)) {
+	CFDictionaryRemoveValue(__CFAllMachPorts, (void *)(uintptr_t)dead_port);
+	CFRetain(existing);
+	__CFSpinUnlock(&__CFAllMachPortsLock);
+	__CFMachPortLock(existing);
+	mach_port_t old_port = existing->_oldnotify;
+	existing->_oldnotify = MACH_PORT_NULL;
+	__CFMachPortUnlock(existing);
+	if (MACH_PORT_NULL != old_port) {
+	    header->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0) | MACH_MSGH_BITS_COMPLEX;
+	    header->msgh_local_port = MACH_PORT_NULL;
+	    header->msgh_remote_port = old_port;
+	    mach_msg(header, MACH_SEND_MSG, header->msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+	}
+	CFMachPortInvalidate(existing);
+	CFRelease(existing);
+    } else {
+	__CFSpinUnlock(&__CFAllMachPortsLock);
+    }
+
+    if (header && header->msgh_id == MACH_NOTIFY_DEAD_NAME) {
+	/* Delete port reference we got for this notification */
+	mach_port_deallocate(mach_task_self(), dead_port);
+    }
+}
+
+static Boolean __CFMachPortEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFMachPortRef mp1 = (CFMachPortRef)cf1;
+    CFMachPortRef mp2 = (CFMachPortRef)cf2;
+    return (mp1->_port == mp2->_port);
+}
+
+static CFHashCode __CFMachPortHash(CFTypeRef cf) {
+    CHECK_FOR_FORK();
+    CFMachPortRef mp = (CFMachPortRef)cf;
+    return (CFHashCode)mp->_port;
+}
+
+static CFStringRef __CFMachPortCopyDescription(CFTypeRef cf) {
+    CFMachPortRef mp = (CFMachPortRef)cf;
+    CFStringRef result;
+    const char *locked;
+    CFStringRef contextDesc = NULL;
+    locked = mp->_lock ? "Yes" : "No";
+    if (NULL != mp->_context.info && NULL != mp->_context.copyDescription) {
+        contextDesc = mp->_context.copyDescription(mp->_context.info);
+    }
+    if (NULL == contextDesc) {
+        contextDesc = CFStringCreateWithFormat(CFGetAllocator(mp), NULL, CFSTR("<CFMachPort context %p>"), mp->_context.info);
+    }
+    void *addr = (void*)mp->_callout;
+    Dl_info info;
+    const char *name = (dladdr(addr, &info) && info.dli_saddr == addr && info.dli_sname) ? info.dli_sname : "???";
+    result = CFStringCreateWithFormat(CFGetAllocator(mp), NULL, CFSTR("<CFMachPort %p [%p]>{locked = %s, valid = %s, port = %p, source = %p, callout = %s (%p), context = %@}"), cf, CFGetAllocator(mp), locked, (__CFMachPortIsValid(mp) ? "Yes" : "No"), mp->_port, mp->_source, name, addr, (NULL != contextDesc ? contextDesc : CFSTR("<no description>")));
+    if (NULL != contextDesc) {
+        CFRelease(contextDesc);
+    }
+    return result;
+}
+
+static void __CFMachPortDeallocate(CFTypeRef cf) {
+    CHECK_FOR_FORK();
+    CFMachPortRef mp = (CFMachPortRef)cf;
+    __CFMachPortSetIsDeallocing(mp);
+    CFMachPortInvalidate(mp);
+    // MUST deallocate the send right FIRST if necessary,
+    // then the receive right if necessary.  Don't ask me why;
+    // if it's done in the other order the port will leak.
+    if (__CFMachPortHasSend(mp)) {
+	mach_port_mod_refs(mach_task_self(), mp->_port, MACH_PORT_RIGHT_SEND, -1);
+    }
+    if (__CFMachPortHasReceive(mp)) {
+	mach_port_mod_refs(mach_task_self(), mp->_port, MACH_PORT_RIGHT_RECEIVE, -1);
+    }
+}
+
+static CFTypeID __kCFMachPortTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFMachPortClass = {
+    0,
+    "CFMachPort",
+    NULL,      // init
+    NULL,      // copy
+    __CFMachPortDeallocate,
+    __CFMachPortEqual,
+    __CFMachPortHash,
+    NULL,      // 
+    __CFMachPortCopyDescription
+};
+
+__private_extern__ void __CFMachPortInitialize(void) {
+    __kCFMachPortTypeID = _CFRuntimeRegisterClass(&__CFMachPortClass);
+}
+
+CFTypeID CFMachPortGetTypeID(void) {
+    return __kCFMachPortTypeID;
+}
+
+CFMachPortRef CFMachPortCreate(CFAllocatorRef allocator, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo) {
+    CFMachPortRef result;
+    mach_port_t port;
+    kern_return_t ret;
+    if (shouldFreeInfo) *shouldFreeInfo = true;
+    ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port);
+    if (KERN_SUCCESS != ret) {
+	return NULL;
+    }
+    ret = mach_port_insert_right(mach_task_self(), port, port, MACH_MSG_TYPE_MAKE_SEND);
+    if (KERN_SUCCESS != ret) {
+	mach_port_destroy(mach_task_self(), port);
+	return NULL;
+    }
+    result = CFMachPortCreateWithPort(allocator, port, callout, context, shouldFreeInfo);
+    if (NULL != result) {
+	__CFMachPortSetHasReceive(result);
+	__CFMachPortSetHasSend(result);
+    }
+    return result;
+}
+
+/* Note: any receive or send rights that the port contains coming in will
+ * not be cleaned up by CFMachPort; it will increment and decrement
+ * references on the port if the kernel ever allows that in the future,
+ * but will not cleanup any references you got when you got the port. */
+CFMachPortRef CFMachPortCreateWithPort(CFAllocatorRef allocator, mach_port_t port, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo) {
+    CHECK_FOR_FORK();
+    CFMachPortRef memory;
+    SInt32 size;
+    Boolean didCreateNotifyPort = false;
+    CFRunLoopSourceRef source;
+    if (shouldFreeInfo) *shouldFreeInfo = true;
+    __CFSpinLock(&__CFAllMachPortsLock);
+    if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)(uintptr_t)port, (const void **)&memory)) {
+	CFRetain(memory);
+	__CFSpinUnlock(&__CFAllMachPortsLock);
+	return (CFMachPortRef)(memory);
+    }
+    size = sizeof(struct __CFMachPort) - sizeof(CFRuntimeBase);
+    memory = (CFMachPortRef)_CFRuntimeCreateInstance(allocator, __kCFMachPortTypeID, size, NULL);
+    if (NULL == memory) {
+	__CFSpinUnlock(&__CFAllMachPortsLock);
+	return NULL;
+    }
+    __CFMachPortUnsetValid(memory);
+    memory->_lock = CFSpinLockInit;
+    memory->_port = port;
+    memory->_source = NULL;
+    memory->_icallout = NULL;
+    memory->_context.info = NULL;
+    memory->_context.retain = NULL;
+    memory->_context.release = NULL;
+    memory->_context.copyDescription = NULL;
+    if (MACH_PORT_NULL == __CFNotifyRawMachPort) {
+	kern_return_t ret;
+	ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &__CFNotifyRawMachPort);
+	if (KERN_SUCCESS != ret) {
+	    __CFSpinUnlock(&__CFAllMachPortsLock);
+	    CFRelease(memory);
+	    return NULL;
+	}
+	didCreateNotifyPort = true;
+    }
+    // Do not register for notifications on the notify port
+    if (MACH_PORT_NULL != __CFNotifyRawMachPort && port != __CFNotifyRawMachPort) {
+	mach_port_t old_port;
+	kern_return_t ret;
+	old_port = MACH_PORT_NULL;
+	ret = mach_port_request_notification(mach_task_self(), port, MACH_NOTIFY_DEAD_NAME, 0, __CFNotifyRawMachPort, MACH_MSG_TYPE_MAKE_SEND_ONCE, &old_port);
+	if (ret != KERN_SUCCESS) {
+	    __CFSpinUnlock(&__CFAllMachPortsLock);
+	    CFRelease(memory);
+	    return NULL;
+	}
+	memory->_oldnotify = old_port;
+    }
+    __CFMachPortSetValid(memory);
+    memory->_callout = callout;
+    if (NULL != context) {
+	CF_WRITE_BARRIER_MEMMOVE(&memory->_context, context, sizeof(CFMachPortContext));
+	memory->_context.info = context->retain ? (void *)context->retain(context->info) : context->info;
+    }
+    if (NULL == __CFAllMachPorts) {
+	__CFAllMachPorts = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);
+	_CFDictionarySetCapacity(__CFAllMachPorts, 20);
+    }
+    CFDictionaryAddValue(__CFAllMachPorts, (void *)(uintptr_t)port, memory);
+    __CFSpinUnlock(&__CFAllMachPortsLock);
+    if (didCreateNotifyPort) {
+	// __CFNotifyMachPort ends up in cache
+	CFMachPortRef mp = CFMachPortCreateWithPort(kCFAllocatorSystemDefault, __CFNotifyRawMachPort, __CFNotifyDeadMachPort, NULL, NULL);
+	__CFMachPortSetHasReceive(mp);
+	__CFNotifyMachPort = mp;
+    }
+    if (NULL != __CFNotifyMachPort) {
+	// We do this so that it gets into each thread's run loop, since
+	// we don't know which run loop is the main thread's, and that's
+	// not necessarily the "right" one anyway.  This won't happen for
+	// the call which creates the __CFNotifyMachPort itself, but that's
+	// OK since it will happen in the invocation of this function
+	// from which that call was triggered.
+	source = CFMachPortCreateRunLoopSource(kCFAllocatorSystemDefault, __CFNotifyMachPort, -1000);
+	CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
+	CFRelease(source);
+    }
+    if (shouldFreeInfo) *shouldFreeInfo = false;
+    return memory;
+}
+
+mach_port_t CFMachPortGetPort(CFMachPortRef mp) {
+    CHECK_FOR_FORK();
+    CF_OBJC_FUNCDISPATCH0(__kCFMachPortTypeID, mach_port_t, mp, "machPort");
+    __CFGenericValidateType(mp, __kCFMachPortTypeID);
+    return mp->_port;
+}
+
+void CFMachPortGetContext(CFMachPortRef mp, CFMachPortContext *context) {
+    __CFGenericValidateType(mp, __kCFMachPortTypeID);
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+    CF_WRITE_BARRIER_MEMMOVE(context, &mp->_context, sizeof(CFMachPortContext));
+}
+
+void CFMachPortInvalidate(CFMachPortRef mp) {
+    CHECK_FOR_FORK();
+    CF_OBJC_FUNCDISPATCH0(__kCFMachPortTypeID, void, mp, "invalidate");
+    __CFGenericValidateType(mp, __kCFMachPortTypeID);
+    if (!__CFMachPortIsDeallocing(mp)) {
+	CFRetain(mp);
+    }
+    __CFSpinLock(&__CFAllMachPortsLock);
+    if (NULL != __CFAllMachPorts) {
+	CFDictionaryRemoveValue(__CFAllMachPorts, (void *)(uintptr_t)(mp->_port));
+    }
+    __CFSpinUnlock(&__CFAllMachPortsLock);
+    __CFMachPortLock(mp);
+    if (__CFMachPortIsValid(mp)) {
+	CFRunLoopSourceRef source;
+	void *info;
+	mach_port_t old_port = mp->_oldnotify;
+	CFMachPortInvalidationCallBack callout = mp->_icallout;
+	__CFMachPortUnsetValid(mp);
+	__CFMachPortUnlock(mp);
+	if (NULL != callout) {
+	    callout(mp, mp->_context.info);
+	}
+	__CFMachPortLock(mp);
+	// For hashing and equality purposes, cannot get rid of _port here
+	source = mp->_source;
+	mp->_source = NULL;
+	info = mp->_context.info;
+	mp->_context.info = NULL;
+	__CFMachPortUnlock(mp);
+	if (NULL != mp->_context.release) {
+	    mp->_context.release(info);
+	}
+	if (NULL != source) {
+	    CFRunLoopSourceInvalidate(source);
+	    CFRelease(source);
+	}
+	if (MACH_PORT_NULL != old_port) {
+	    mach_port_deallocate(mach_task_self(), old_port);
+	}
+    } else {
+	__CFMachPortUnlock(mp);
+    }
+    if (!__CFMachPortIsDeallocing(mp)) {
+	CFRelease(mp);
+    }
+}
+
+Boolean CFMachPortIsValid(CFMachPortRef mp) {
+    CF_OBJC_FUNCDISPATCH0(__kCFMachPortTypeID, Boolean, mp, "isValid");
+    __CFGenericValidateType(mp, __kCFMachPortTypeID);
+    return __CFMachPortIsValid(mp);
+}
+
+CFMachPortInvalidationCallBack CFMachPortGetInvalidationCallBack(CFMachPortRef mp) {
+    __CFGenericValidateType(mp, __kCFMachPortTypeID);
+    return mp->_icallout;
+}
+
+void CFMachPortSetInvalidationCallBack(CFMachPortRef mp, CFMachPortInvalidationCallBack callout) {
+    __CFGenericValidateType(mp, __kCFMachPortTypeID);
+    if (!__CFMachPortIsValid(mp) && NULL != callout) {
+	callout(mp, mp->_context.info);
+    } else {
+	mp->_icallout = callout;
+    }
+}
+
+/* Returns the number of messages queued for a receive port.  */
+CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp) {  
+    CHECK_FOR_FORK();
+    mach_port_status_t status;
+    mach_msg_type_number_t num = MACH_PORT_RECEIVE_STATUS_COUNT;
+    kern_return_t ret;
+    ret = mach_port_get_attributes(mach_task_self(), mp->_port, MACH_PORT_RECEIVE_STATUS, (mach_port_info_t)&status, &num);
+    return (KERN_SUCCESS != ret) ? 0 : status.mps_msgcount;
+}
+
+static mach_port_t __CFMachPortGetPort(void *info) {
+    CFMachPortRef mp = (CFMachPortRef)info;
+    return mp->_port;
+}
+
+static void *__CFMachPortPerform(void *msg, CFIndex size, CFAllocatorRef allocator, void *info) {
+    CHECK_FOR_FORK();
+    CFMachPortRef mp = (CFMachPortRef)info;
+    void *context_info;
+    void (*context_release)(const void *);
+    __CFMachPortLock(mp);
+    if (!__CFMachPortIsValid(mp)) {
+	__CFMachPortUnlock(mp);
+	return NULL;
+    }
+    if (NULL != mp->_context.retain) {
+	context_info = (void *)mp->_context.retain(mp->_context.info);
+	context_release = mp->_context.release;
+    } else {
+	context_info = mp->_context.info;
+	context_release = NULL;
+    }
+    __CFMachPortUnlock(mp);
+    mp->_callout(mp, msg, size, mp->_context.info);
+    CHECK_FOR_FORK();
+    if (context_release) {
+	context_release(context_info);
+    }
+    return NULL;
+}
+
+CFRunLoopSourceRef CFMachPortCreateRunLoopSource(CFAllocatorRef allocator, CFMachPortRef mp, CFIndex order) {
+    CHECK_FOR_FORK();
+    CFRunLoopSourceRef result = NULL;
+    __CFGenericValidateType(mp, __kCFMachPortTypeID);
+    __CFMachPortLock(mp);
+    if (!__CFMachPortIsValid(mp)) {
+        __CFMachPortUnlock(mp);
+        return NULL;
+    }
+    if (NULL == mp->_source) {
+	CFRunLoopSourceContext1 context;
+	context.version = 1;
+	context.info = (void *)mp;
+	context.retain = (const void *(*)(const void *))CFRetain;
+	context.release = (void (*)(const void *))CFRelease;
+	context.copyDescription = (CFStringRef (*)(const void *))__CFMachPortCopyDescription;
+	context.equal = (Boolean (*)(const void *, const void *))__CFMachPortEqual;
+	context.hash = (CFHashCode (*)(const void *))__CFMachPortHash;
+	context.getPort = __CFMachPortGetPort;
+	context.perform = __CFMachPortPerform;
+	mp->_source = CFRunLoopSourceCreate(allocator, order, (CFRunLoopSourceContext *)&context);
+    }
+    if (NULL != mp->_source) {
+	result = (CFRunLoopSourceRef)CFRetain(mp->_source);
+    }
+    __CFMachPortUnlock(mp);
+    return result;
+}
+
+#endif
diff --git a/CoreFoundation/CFMachPort.h b/CoreFoundation/CFMachPort.h
new file mode 100644
index 0000000..e977de3
--- /dev/null
+++ b/CoreFoundation/CFMachPort.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFMACHPORT__)
+#define __COREFOUNDATION_CFMACHPORT__ 1
+
+#if DEPLOYMENT_TARGET_MACOSX
+
+#include <CoreFoundation/CFRunLoop.h>
+#include <mach/port.h>
+
+CF_EXTERN_C_BEGIN
+
+typedef struct __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
+
+#endif /* DEPLOYMENT_TARGET_MACOSX */
+#endif /* ! __COREFOUNDATION_CFMACHPORT__ */
+
diff --git a/CoreFoundation/CFMessagePort.c b/CoreFoundation/CFMessagePort.c
new file mode 100644
index 0000000..0e74abd
--- /dev/null
+++ b/CoreFoundation/CFMessagePort.c
@@ -0,0 +1,982 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#if DEPLOYMENT_TARGET_MACOSX
+
+#include <CoreFoundation/CFMessagePort.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFMachPort.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFByteOrder.h>
+#include <limits.h>
+#include <unistd.h>
+#include "CFInternal.h"
+#include <mach/mach.h>
+#include <mach/message.h>
+#include <mach/mach_error.h>
+#include <bootstrap_priv.h>
+#include <math.h>
+#include <mach/mach_time.h>
+#include <dlfcn.h>
+
+
+#define __kCFMessagePortMaxNameLengthMax 255
+
+#if defined(BOOTSTRAP_MAX_NAME_LEN)
+    #define __kCFMessagePortMaxNameLength BOOTSTRAP_MAX_NAME_LEN
+#else
+    #define __kCFMessagePortMaxNameLength 128
+#endif
+
+#if __kCFMessagePortMaxNameLengthMax < __kCFMessagePortMaxNameLength
+    #undef __kCFMessagePortMaxNameLength
+    #define __kCFMessagePortMaxNameLength __kCFMessagePortMaxNameLengthMax
+#endif
+
+static CFSpinLock_t __CFAllMessagePortsLock = CFSpinLockInit;
+static CFMutableDictionaryRef __CFAllLocalMessagePorts = NULL;
+static CFMutableDictionaryRef __CFAllRemoteMessagePorts = NULL;
+
+struct __CFMessagePort {
+    CFRuntimeBase _base;
+    CFSpinLock_t _lock;
+    CFStringRef _name;
+    CFMachPortRef _port;		/* immutable; invalidated */
+    CFMutableDictionaryRef _replies;
+    int32_t _convCounter;
+    int32_t _perPID;			/* zero if not per-pid, else pid */
+    CFMachPortRef _replyPort;		/* only used by remote port; immutable once created; invalidated */
+    CFRunLoopSourceRef _source;		/* only used by local port; immutable once created; invalidated */
+    CFMessagePortInvalidationCallBack _icallout;
+    CFMessagePortCallBack _callout;	/* only used by local port; immutable */
+    CFMessagePortContext _context;	/* not part of remote port; immutable; invalidated */
+};
+
+/* Bit 0 in the base reserved bits is used for invalid state */
+/* Bit 1 of the base reserved bits is used for has-extra-port-refs state */
+/* Bit 2 of the base reserved bits is used for is-remote state */
+/* Bit 3 in the base reserved bits is used for is-deallocing state */
+
+CF_INLINE Boolean __CFMessagePortIsValid(CFMessagePortRef ms) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 0, 0);
+}
+
+CF_INLINE void __CFMessagePortSetValid(CFMessagePortRef ms) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 0, 0, 1);
+}
+
+CF_INLINE void __CFMessagePortUnsetValid(CFMessagePortRef ms) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 0, 0, 0);
+}
+
+CF_INLINE Boolean __CFMessagePortExtraMachRef(CFMessagePortRef ms) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 1, 1);
+}
+
+CF_INLINE void __CFMessagePortSetExtraMachRef(CFMessagePortRef ms) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 1, 1, 1);
+}
+
+CF_INLINE void __CFMessagePortUnsetExtraMachRef(CFMessagePortRef ms) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 1, 1, 0);
+}
+
+CF_INLINE Boolean __CFMessagePortIsRemote(CFMessagePortRef ms) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 2, 2);
+}
+
+CF_INLINE void __CFMessagePortSetRemote(CFMessagePortRef ms) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 2, 2, 1);
+}
+
+CF_INLINE void __CFMessagePortUnsetRemote(CFMessagePortRef ms) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 2, 2, 0);
+}
+
+CF_INLINE Boolean __CFMessagePortIsDeallocing(CFMessagePortRef ms) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 3, 3);
+}
+
+CF_INLINE void __CFMessagePortSetIsDeallocing(CFMessagePortRef ms) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)ms)->_cfinfo[CF_INFO_BITS], 3, 3, 1);
+}
+
+CF_INLINE void __CFMessagePortLock(CFMessagePortRef ms) {
+    __CFSpinLock(&(ms->_lock));
+}
+
+CF_INLINE void __CFMessagePortUnlock(CFMessagePortRef ms) {
+    __CFSpinUnlock(&(ms->_lock));
+}
+
+// Just a heuristic
+#define __CFMessagePortMaxInlineBytes 4096*10
+
+struct __CFMessagePortMachMsg0 {
+    int32_t msgid;
+    int32_t byteslen;
+    uint8_t bytes[__CFMessagePortMaxInlineBytes];
+};
+
+struct __CFMessagePortMachMsg1 {
+    mach_msg_descriptor_t desc;
+    int32_t msgid;
+};
+
+struct __CFMessagePortMachMessage {
+    mach_msg_header_t head;
+    mach_msg_body_t body;
+    union {
+	struct __CFMessagePortMachMsg0 msg0;
+	struct __CFMessagePortMachMsg1 msg1;
+    } contents;
+};
+
+static struct __CFMessagePortMachMessage *__CFMessagePortCreateMessage(CFAllocatorRef allocator, bool reply, mach_port_t port, mach_port_t replyPort, int32_t convid, int32_t msgid, const uint8_t *bytes, int32_t byteslen) {
+    struct __CFMessagePortMachMessage *msg;
+    int32_t size = sizeof(mach_msg_header_t) + sizeof(mach_msg_body_t);
+    if (byteslen < __CFMessagePortMaxInlineBytes) {
+	size += 2 * sizeof(int32_t) + ((byteslen + 3) & ~0x3);
+    } else {
+	size += sizeof(struct __CFMessagePortMachMsg1);
+    }
+    msg = (struct __CFMessagePortMachMessage*)CFAllocatorAllocate(allocator, size, 0);
+    msg->head.msgh_id = convid;
+    msg->head.msgh_size = size;
+    msg->head.msgh_remote_port = port;
+    msg->head.msgh_local_port = replyPort;
+    msg->head.msgh_reserved = 0;
+//    msg->head.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, (replyPort ? MACH_MSG_TYPE_MAKE_SEND : 0));
+    msg->head.msgh_bits = MACH_MSGH_BITS((reply ? MACH_MSG_TYPE_MOVE_SEND_ONCE : MACH_MSG_TYPE_COPY_SEND), (MACH_PORT_NULL != replyPort ? MACH_MSG_TYPE_MAKE_SEND_ONCE : 0));
+    if (byteslen < __CFMessagePortMaxInlineBytes) {
+	msg->body.msgh_descriptor_count = 0;
+	msg->contents.msg0.msgid = CFSwapInt32HostToLittle(msgid);
+	msg->contents.msg0.byteslen = CFSwapInt32HostToLittle(byteslen);
+	if (NULL != bytes && 0 < byteslen) {
+	    memmove(msg->contents.msg0.bytes, bytes, byteslen);
+	}
+	memset(msg->contents.msg0.bytes + byteslen, 0, ((byteslen + 3) & ~0x3) - byteslen);
+    } else {
+	msg->head.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
+	msg->body.msgh_descriptor_count = 1;
+	msg->contents.msg1.desc.out_of_line.deallocate = false;
+	msg->contents.msg1.desc.out_of_line.copy = MACH_MSG_VIRTUAL_COPY;
+	msg->contents.msg1.desc.out_of_line.address = (void *)bytes;
+	msg->contents.msg1.desc.out_of_line.size = byteslen;
+	msg->contents.msg1.desc.out_of_line.type = MACH_MSG_OOL_DESCRIPTOR;
+	msg->contents.msg1.msgid = CFSwapInt32HostToLittle(msgid);
+    }
+    return msg;
+}
+
+static CFStringRef __CFMessagePortCopyDescription(CFTypeRef cf) {
+    CFMessagePortRef ms = (CFMessagePortRef)cf;
+    CFStringRef result;
+    const char *locked;
+    CFStringRef contextDesc = NULL;
+    locked = ms->_lock ? "Yes" : "No";
+    if (!__CFMessagePortIsRemote(ms)) {
+	if (NULL != ms->_context.info && NULL != ms->_context.copyDescription) {
+	    contextDesc = ms->_context.copyDescription(ms->_context.info);
+	}
+	if (NULL == contextDesc) {
+	    contextDesc = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFMessagePort context %p>"), ms->_context.info);
+	}
+	result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFMessagePort %p [%p]>{locked = %s, valid = %s, remote = %s, name = %@}"), cf, CFGetAllocator(ms), locked, (__CFMessagePortIsValid(ms) ? "Yes" : "No"), (__CFMessagePortIsRemote(ms) ? "Yes" : "No"), ms->_name);
+    } else {
+	void *addr = (void*)ms->_callout;
+	Dl_info info;
+	const char *name = (dladdr(addr, &info) && info.dli_saddr == addr && info.dli_sname) ? info.dli_sname : "???";
+	result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFMessagePort %p [%p]>{locked = %s, valid = %s, remote = %s, name = %@, source = %p, callout = %s (%p), context = %@}"), cf, CFGetAllocator(ms), locked, (__CFMessagePortIsValid(ms) ? "Yes" : "No"), (__CFMessagePortIsRemote(ms) ? "Yes" : "No"), ms->_name, ms->_source, name, addr, (NULL != contextDesc ? contextDesc : CFSTR("<no description>")));
+    }
+    if (NULL != contextDesc) {
+	CFRelease(contextDesc);
+    }
+    return result;
+}
+
+static void __CFMessagePortDeallocate(CFTypeRef cf) {
+    CFMessagePortRef ms = (CFMessagePortRef)cf;
+    __CFMessagePortSetIsDeallocing(ms);
+    CFMessagePortInvalidate(ms);
+    // Delay cleanup of _replies until here so that invalidation during
+    // SendRequest does not cause _replies to disappear out from under that function.
+    if (NULL != ms->_replies) {
+	CFRelease(ms->_replies);
+    }
+    if (NULL != ms->_name) {
+	CFRelease(ms->_name);
+    }
+    if (NULL != ms->_port) {
+	if (__CFMessagePortExtraMachRef(ms)) {
+	    mach_port_mod_refs(mach_task_self(), CFMachPortGetPort(ms->_port), MACH_PORT_RIGHT_SEND, -1);
+	    mach_port_mod_refs(mach_task_self(), CFMachPortGetPort(ms->_port), MACH_PORT_RIGHT_RECEIVE, -1);
+	}
+	CFMachPortInvalidate(ms->_port);
+	CFRelease(ms->_port);
+    }
+
+    // A remote message port for a local message port in the same process will get the
+    // same mach port, and the remote port will keep the mach port from being torn down,
+    // thus keeping the remote port from getting any sort of death notification and
+    // auto-invalidating; so we manually implement the 'auto-invalidation' here by
+    // tickling each remote port to check its state after any message port is destroyed,
+    // but most importantly after local message ports are destroyed.
+    __CFSpinLock(&__CFAllMessagePortsLock);
+    CFMessagePortRef *remotePorts = NULL;
+    CFIndex cnt = 0;
+    if (NULL != __CFAllRemoteMessagePorts) {
+	cnt = CFDictionaryGetCount(__CFAllRemoteMessagePorts);
+	remotePorts = (CFMessagePortRef*)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(CFMessagePortRef), __kCFAllocatorGCScannedMemory);
+	CFDictionaryGetKeysAndValues(__CFAllRemoteMessagePorts, NULL, (const void **)remotePorts);
+	for (CFIndex idx = 0; idx < cnt; idx++) {
+	    CFRetain(remotePorts[idx]);
+	}
+    }
+    __CFSpinUnlock(&__CFAllMessagePortsLock);
+    if (remotePorts) {
+	for (CFIndex idx = 0; idx < cnt; idx++) {
+	    // as a side-effect, this will auto-invalidate the CFMessagePort if the CFMachPort is invalid
+	    CFMessagePortIsValid(remotePorts[idx]);
+	    CFRelease(remotePorts[idx]);
+	}
+	CFAllocatorDeallocate(kCFAllocatorSystemDefault, remotePorts);
+    }
+}
+
+static CFTypeID __kCFMessagePortTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFMessagePortClass = {
+    0,
+    "CFMessagePort",
+    NULL,      // init
+    NULL,      // copy
+    __CFMessagePortDeallocate,
+    NULL,
+    NULL,
+    NULL,      // 
+    __CFMessagePortCopyDescription
+};
+
+__private_extern__ void __CFMessagePortInitialize(void) {
+    __kCFMessagePortTypeID = _CFRuntimeRegisterClass(&__CFMessagePortClass);
+}
+
+CFTypeID CFMessagePortGetTypeID(void) {
+    return __kCFMessagePortTypeID;
+}
+
+static CFStringRef __CFMessagePortSanitizeStringName(CFAllocatorRef allocator, CFStringRef name, uint8_t **utfnamep, CFIndex *utfnamelenp) {
+    uint8_t *utfname;
+    CFIndex utflen;
+    CFStringRef result;
+    utfname = (uint8_t*)CFAllocatorAllocate(allocator, __kCFMessagePortMaxNameLength + 1, 0);
+    CFStringGetBytes(name, CFRangeMake(0, CFStringGetLength(name)), kCFStringEncodingUTF8, 0, false, utfname, __kCFMessagePortMaxNameLength, &utflen);
+    utfname[utflen] = '\0';
+    /* A new string is created, because the original string may have been
+       truncated to the max length, and we want the string name to definitely
+       match the raw UTF-8 chunk that has been created. Also, this is useful
+       to get a constant string in case the original name string was mutable. */
+    result = CFStringCreateWithBytes(allocator, utfname, utflen, kCFStringEncodingUTF8, false);
+    if (NULL != utfnamep) {
+	*utfnamep = utfname;
+    } else {
+	CFAllocatorDeallocate(allocator, utfname);
+    }
+    if (NULL != utfnamelenp) {
+	*utfnamelenp = utflen;
+    }
+    return result;
+}
+
+static void __CFMessagePortDummyCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) {
+    // not supposed to be implemented
+}
+
+static void __CFMessagePortInvalidationCallBack(CFMachPortRef port, void *info) {
+    // info has been setup as the CFMessagePort owning the CFMachPort
+    CFMessagePortInvalidate((CFMessagePortRef)info);
+}
+
+static CFMessagePortRef __CFMessagePortCreateLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo, Boolean perPID) {
+    CFMessagePortRef memory;
+    uint8_t *utfname = NULL;
+
+    if (shouldFreeInfo) *shouldFreeInfo = true;
+    if (NULL != name) {
+	name = __CFMessagePortSanitizeStringName(allocator, name, &utfname, NULL);
+    }
+    __CFSpinLock(&__CFAllMessagePortsLock);
+    if (!perPID && NULL != name) {
+	CFMessagePortRef existing;
+	if (NULL != __CFAllLocalMessagePorts && CFDictionaryGetValueIfPresent(__CFAllLocalMessagePorts, name, (const void **)&existing)) {
+	    CFRetain(existing);
+	    __CFSpinUnlock(&__CFAllMessagePortsLock);
+	    CFRelease(name);
+	    CFAllocatorDeallocate(allocator, utfname);
+	    return (CFMessagePortRef)(existing);
+	}
+    }
+    __CFSpinUnlock(&__CFAllMessagePortsLock);
+    CFIndex size = sizeof(struct __CFMessagePort) - sizeof(CFRuntimeBase);
+    memory = (CFMessagePortRef)_CFRuntimeCreateInstance(allocator, __kCFMessagePortTypeID, size, NULL);
+    if (NULL == memory) {
+	if (NULL != name) {
+	    CFRelease(name);
+	}
+	CFAllocatorDeallocate(allocator, utfname);
+	return NULL;
+    }
+    __CFMessagePortUnsetValid(memory);
+    __CFMessagePortUnsetExtraMachRef(memory);
+    __CFMessagePortUnsetRemote(memory);
+    memory->_lock = CFSpinLockInit;
+    memory->_name = name;
+    memory->_port = NULL;
+    memory->_replies = NULL;
+    memory->_convCounter = 0;
+    memory->_perPID = perPID ? getpid() : 0;	// actual value not terribly useful for local ports
+    memory->_replyPort = NULL;
+    memory->_source = NULL;
+    memory->_icallout = NULL;
+    memory->_callout = callout;
+    memory->_context.info = NULL;
+    memory->_context.retain = NULL;
+    memory->_context.release = NULL;
+    memory->_context.copyDescription = NULL;
+
+    if (NULL != name) {
+	CFMachPortRef native = NULL;
+	kern_return_t ret;
+	mach_port_t bs, mp;
+	task_get_bootstrap_port(mach_task_self(), &bs);
+	if (!perPID) {
+	    ret = bootstrap_check_in(bs, (char *)utfname, &mp); /* If we're started by launchd or the old mach_init */
+	    if (ret == KERN_SUCCESS) {
+		ret = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
+		if (KERN_SUCCESS == ret) {
+		    CFMachPortContext ctx = {0, memory, NULL, NULL, NULL};
+		    native = CFMachPortCreateWithPort(allocator, mp, __CFMessagePortDummyCallback, &ctx, NULL);
+		    __CFMessagePortSetExtraMachRef(memory);
+		} else {
+		    CFLog(kCFLogLevelWarning, CFSTR("*** CFMessagePort: mach_port_insert_member() after bootstrap_check_in(): failed %d (0x%x) '%s', port = 0x%x, name = '%s'"), ret, ret, bootstrap_strerror(ret), mp, utfname);
+		    mach_port_destroy(mach_task_self(), mp);
+		    CFAllocatorDeallocate(allocator, utfname);
+		    // name is released by deallocation
+		    CFRelease(memory);
+		    return NULL;
+		}
+	    }
+	}
+	if (!native) {
+	    CFMachPortContext ctx = {0, memory, NULL, NULL, NULL};
+	    native = CFMachPortCreate(allocator, __CFMessagePortDummyCallback, &ctx, NULL);
+	    mp = CFMachPortGetPort(native);
+	    ret = bootstrap_register2(bs, (char *)utfname, mp, perPID ? BOOTSTRAP_PER_PID_SERVICE : 0);
+	    if (ret != KERN_SUCCESS) {
+		CFLog(kCFLogLevelWarning, CFSTR("*** CFMessagePort: bootstrap_register(): failed %d (0x%x) '%s', port = 0x%x, name = '%s'\nSee /usr/include/servers/bootstrap_defs.h for the error codes."), ret, ret, bootstrap_strerror(ret), mp, utfname);
+		CFMachPortInvalidate(native);
+		CFRelease(native);
+		CFAllocatorDeallocate(allocator, utfname);
+		// name is released by deallocation
+		CFRelease(memory);
+		return NULL;
+	    }
+	}
+	CFMachPortSetInvalidationCallBack(native, __CFMessagePortInvalidationCallBack);
+	memory->_port = native;
+    }
+
+    CFAllocatorDeallocate(allocator, utfname);
+    __CFMessagePortSetValid(memory);
+    if (NULL != context) {
+	memmove(&memory->_context, context, sizeof(CFMessagePortContext));
+	memory->_context.info = context->retain ? (void *)context->retain(context->info) : context->info;
+    }
+    __CFSpinLock(&__CFAllMessagePortsLock);
+    if (!perPID && NULL != name) {
+        CFMessagePortRef existing;
+        if (NULL != __CFAllLocalMessagePorts && CFDictionaryGetValueIfPresent(__CFAllLocalMessagePorts, name, (const void **)&existing)) {
+            CFRetain(existing);
+            __CFSpinUnlock(&__CFAllMessagePortsLock); 
+	    CFRelease(memory);
+            return (CFMessagePortRef)(existing);
+        }       
+	if (NULL == __CFAllLocalMessagePorts) {
+	    __CFAllLocalMessagePorts = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, NULL);
+	}
+	CFDictionaryAddValue(__CFAllLocalMessagePorts, name, memory);
+    }
+    __CFSpinUnlock(&__CFAllMessagePortsLock);
+    if (shouldFreeInfo) *shouldFreeInfo = false;
+    return memory;
+}
+
+CFMessagePortRef CFMessagePortCreateLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo) {
+    return __CFMessagePortCreateLocal(allocator, name, callout, context, shouldFreeInfo, false);
+}
+
+CFMessagePortRef CFMessagePortCreatePerProcessLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo) {
+    return __CFMessagePortCreateLocal(allocator, name, callout, context, shouldFreeInfo, true);
+}
+
+static CFMessagePortRef __CFMessagePortCreateRemote(CFAllocatorRef allocator, CFStringRef name, Boolean perPID, CFIndex pid) {
+    CFMessagePortRef memory;
+    CFMachPortRef native;
+    CFMachPortContext ctx;
+    uint8_t *utfname = NULL;
+    CFIndex size;
+    mach_port_t bp, port;
+    kern_return_t ret;
+
+    name = __CFMessagePortSanitizeStringName(allocator, name, &utfname, NULL);
+    if (NULL == name) {
+	return NULL;
+    }
+    __CFSpinLock(&__CFAllMessagePortsLock);
+    if (!perPID && NULL != name) {
+	CFMessagePortRef existing;
+	if (NULL != __CFAllRemoteMessagePorts && CFDictionaryGetValueIfPresent(__CFAllRemoteMessagePorts, name, (const void **)&existing)) {
+	    CFRetain(existing);
+	    __CFSpinUnlock(&__CFAllMessagePortsLock);
+	    CFRelease(name);
+	    CFAllocatorDeallocate(allocator, utfname);
+	    return (CFMessagePortRef)(existing);
+	}
+    }
+    __CFSpinUnlock(&__CFAllMessagePortsLock);
+    size = sizeof(struct __CFMessagePort) - sizeof(CFMessagePortContext) - sizeof(CFRuntimeBase);
+    memory = (CFMessagePortRef)_CFRuntimeCreateInstance(allocator, __kCFMessagePortTypeID, size, NULL);
+    if (NULL == memory) {
+	if (NULL != name) {
+	    CFRelease(name);
+	}
+	CFAllocatorDeallocate(allocator, utfname);
+	return NULL;
+    }
+    __CFMessagePortUnsetValid(memory);
+    __CFMessagePortUnsetExtraMachRef(memory);
+    __CFMessagePortSetRemote(memory);
+    memory->_lock = CFSpinLockInit;
+    memory->_name = name;
+    memory->_port = NULL;
+    memory->_replies = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);
+    memory->_convCounter = 0;
+    memory->_perPID = perPID ? pid : 0;
+    memory->_replyPort = NULL;
+    memory->_source = NULL;
+    memory->_icallout = NULL;
+    memory->_callout = NULL;
+    ctx.version = 0;
+    ctx.info = memory;
+    ctx.retain = NULL;
+    ctx.release = NULL;
+    ctx.copyDescription = NULL;
+    task_get_bootstrap_port(mach_task_self(), &bp);
+    ret = bootstrap_look_up2(bp, (char *)utfname, &port, perPID ? (pid_t)pid : 0, perPID ? BOOTSTRAP_PER_PID_SERVICE : 0);
+    native = (KERN_SUCCESS == ret) ? CFMachPortCreateWithPort(allocator, port, __CFMessagePortDummyCallback, &ctx, NULL) : NULL;
+    CFAllocatorDeallocate(allocator, utfname);
+    if (NULL == native) {
+	// name is released by deallocation
+	CFRelease(memory);
+	return NULL;
+    }
+    memory->_port = native;
+    CFMachPortSetInvalidationCallBack(native, __CFMessagePortInvalidationCallBack);
+    __CFMessagePortSetValid(memory);
+    __CFSpinLock(&__CFAllMessagePortsLock);
+    if (!perPID && NULL != name) {
+	CFMessagePortRef existing;
+	if (NULL != __CFAllRemoteMessagePorts && CFDictionaryGetValueIfPresent(__CFAllRemoteMessagePorts, name, (const void **)&existing)) {
+	    CFRetain(existing);
+	    __CFSpinUnlock(&__CFAllMessagePortsLock);
+	    CFRelease(memory);
+	    return (CFMessagePortRef)(existing);
+	}
+	if (NULL == __CFAllRemoteMessagePorts) {
+	    __CFAllRemoteMessagePorts = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, NULL);
+	}
+	CFDictionaryAddValue(__CFAllRemoteMessagePorts, name, memory);
+    }
+    __CFSpinUnlock(&__CFAllMessagePortsLock);
+    return (CFMessagePortRef)memory;
+}
+
+CFMessagePortRef CFMessagePortCreateRemote(CFAllocatorRef allocator, CFStringRef name) {
+    return __CFMessagePortCreateRemote(allocator, name, false, 0);
+}
+
+CFMessagePortRef CFMessagePortCreatePerProcessRemote(CFAllocatorRef allocator, CFStringRef name, CFIndex pid) {
+    return __CFMessagePortCreateRemote(allocator, name, true, pid);
+}
+
+Boolean CFMessagePortIsRemote(CFMessagePortRef ms) {
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+    return __CFMessagePortIsRemote(ms);
+}
+
+CFStringRef CFMessagePortGetName(CFMessagePortRef ms) {
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+    return ms->_name;
+}
+
+Boolean CFMessagePortSetName(CFMessagePortRef ms, CFStringRef name) {
+    CFAllocatorRef allocator = CFGetAllocator(ms);
+    uint8_t *utfname = NULL;
+
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+    if (ms->_perPID || __CFMessagePortIsRemote(ms)) return false;
+    name = __CFMessagePortSanitizeStringName(allocator, name, &utfname, NULL);
+    if (NULL == name) {
+	return false;
+    }
+    __CFSpinLock(&__CFAllMessagePortsLock);
+    if (NULL != name) {
+	CFMessagePortRef existing;
+	if (NULL != __CFAllLocalMessagePorts && CFDictionaryGetValueIfPresent(__CFAllLocalMessagePorts, name, (const void **)&existing)) {
+	    __CFSpinUnlock(&__CFAllMessagePortsLock);
+	    CFRelease(name);
+	    CFAllocatorDeallocate(allocator, utfname);
+	    return false;
+	}
+    }
+    __CFSpinUnlock(&__CFAllMessagePortsLock);
+
+    if (NULL != name && (NULL == ms->_name || !CFEqual(ms->_name, name))) {
+	CFMachPortRef oldPort = ms->_port;
+        CFMachPortRef native = NULL;
+        kern_return_t ret;
+        mach_port_t bs, mp;
+        task_get_bootstrap_port(mach_task_self(), &bs);
+        ret = bootstrap_check_in(bs, (char *)utfname, &mp); /* If we're started by launchd or the old mach_init */
+        if (ret == KERN_SUCCESS) {
+            ret = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
+            if (KERN_SUCCESS == ret) {
+                CFMachPortContext ctx = {0, ms, NULL, NULL, NULL};
+                native = CFMachPortCreateWithPort(allocator, mp, __CFMessagePortDummyCallback, &ctx, NULL);
+		__CFMessagePortSetExtraMachRef(ms);
+            } else {
+                mach_port_destroy(mach_task_self(), mp);
+                CFAllocatorDeallocate(allocator, utfname);
+		CFRelease(name);
+                return false;
+            }
+        } 
+        if (!native) {
+            CFMachPortContext ctx = {0, ms, NULL, NULL, NULL};
+            native = CFMachPortCreate(allocator, __CFMessagePortDummyCallback, &ctx, NULL);
+            mp = CFMachPortGetPort(native);
+            ret = bootstrap_register2(bs, (char *)utfname, mp, 0);
+            if (ret != KERN_SUCCESS) {
+                CFLog(kCFLogLevelWarning, CFSTR("*** CFMessagePort: bootstrap_register(): failed %d (0x%x) '%s', port = 0x%x, name = '%s'\nSee /usr/include/servers/bootstrap_defs.h for the error codes."), ret, ret, bootstrap_strerror(ret), mp, utfname);
+                CFMachPortInvalidate(native);
+                CFRelease(native);
+                CFAllocatorDeallocate(allocator, utfname);
+                CFRelease(name);
+                return false;
+            }
+        }
+        CFMachPortSetInvalidationCallBack(native, __CFMessagePortInvalidationCallBack);
+        ms->_port = native;
+	if (NULL != oldPort && oldPort != native) {
+	    if (__CFMessagePortExtraMachRef(ms)) {
+		mach_port_mod_refs(mach_task_self(), CFMachPortGetPort(oldPort), MACH_PORT_RIGHT_SEND, -1);
+		mach_port_mod_refs(mach_task_self(), CFMachPortGetPort(oldPort), MACH_PORT_RIGHT_RECEIVE, -1);
+	    }
+	    CFMachPortInvalidate(oldPort);
+	    CFRelease(oldPort);
+	}
+	__CFSpinLock(&__CFAllMessagePortsLock);
+	// This relocking without checking to see if something else has grabbed
+	// that name in the cache is rather suspect, but what would that even
+	// mean has happened?  We'd expect the bootstrap_* calls above to have
+	// failed for this one and not gotten this far, or failed for all of the
+	// other simultaneous attempts to get the name (and having succeeded for
+	// this one, gotten here).  So we're not going to try very hard here
+	// with the thread-safety.
+	if (NULL == __CFAllLocalMessagePorts) {
+	    __CFAllLocalMessagePorts = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, NULL);
+	}
+	if (NULL != ms->_name) {
+	    CFDictionaryRemoveValue(__CFAllLocalMessagePorts, ms->_name);
+	    CFRelease(ms->_name);
+	}
+	ms->_name = name;
+	CFDictionaryAddValue(__CFAllLocalMessagePorts, name, ms);
+	__CFSpinUnlock(&__CFAllMessagePortsLock);
+    }
+
+    CFAllocatorDeallocate(allocator, utfname);
+    return true;
+}
+
+void CFMessagePortGetContext(CFMessagePortRef ms, CFMessagePortContext *context) {
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+//#warning CF: assert that this is a local port
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+    memmove(context, &ms->_context, sizeof(CFMessagePortContext));
+}
+
+void CFMessagePortInvalidate(CFMessagePortRef ms) {
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+    if (!__CFMessagePortIsDeallocing(ms)) {
+	CFRetain(ms);
+    }
+    __CFMessagePortLock(ms);
+    if (__CFMessagePortIsValid(ms)) {
+	CFMessagePortInvalidationCallBack callout = ms->_icallout;
+	CFRunLoopSourceRef source = ms->_source;
+	CFMachPortRef replyPort = ms->_replyPort;
+	CFMachPortRef port = ms->_port;
+	CFStringRef name = ms->_name;
+	void *info = NULL;
+
+	__CFMessagePortUnsetValid(ms);
+	if (!__CFMessagePortIsRemote(ms)) {
+	    info = ms->_context.info;
+	    ms->_context.info = NULL;
+	}
+	ms->_source = NULL;
+	ms->_replyPort = NULL;
+	__CFMessagePortUnlock(ms);
+
+	__CFSpinLock(&__CFAllMessagePortsLock);
+	if (0 == ms->_perPID && NULL != (__CFMessagePortIsRemote(ms) ? __CFAllRemoteMessagePorts : __CFAllLocalMessagePorts)) {
+	    CFDictionaryRemoveValue(__CFMessagePortIsRemote(ms) ? __CFAllRemoteMessagePorts : __CFAllLocalMessagePorts, name);
+	}
+	__CFSpinUnlock(&__CFAllMessagePortsLock);
+	if (NULL != callout) {
+	    callout(ms, info);
+	}
+	// We already know we're going invalid, don't need this callback
+	// anymore; plus, this solves a reentrancy deadlock; also, this
+	// must be done before the deallocate of the Mach port, to
+	// avoid a race between the notification message which could be
+	// handled in another thread, and this NULL'ing out.
+	CFMachPortSetInvalidationCallBack(port, NULL);
+	// For hashing and equality purposes, cannot get rid of _port here
+	if (!__CFMessagePortIsRemote(ms) && NULL != ms->_context.release) {
+	    ms->_context.release(info);
+	}
+	if (NULL != source) {
+	    CFRunLoopSourceInvalidate(source);
+	    CFRelease(source);
+	}
+	if (NULL != replyPort) {
+	    CFMachPortInvalidate(replyPort);
+	    CFRelease(replyPort);
+	}
+	if (__CFMessagePortIsRemote(ms)) {
+	    // Get rid of our extra ref on the Mach port gotten from bs server
+	    mach_port_deallocate(mach_task_self(), CFMachPortGetPort(port));
+	}
+    } else {
+	__CFMessagePortUnlock(ms);
+    }
+    if (!__CFMessagePortIsDeallocing(ms)) {
+	CFRelease(ms);
+    }
+}
+
+Boolean CFMessagePortIsValid(CFMessagePortRef ms) {
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+    if (!__CFMessagePortIsValid(ms)) return false;
+    if (NULL != ms->_port && !CFMachPortIsValid(ms->_port)) {
+	CFMessagePortInvalidate(ms);
+	return false;
+    }
+    if (NULL != ms->_replyPort && !CFMachPortIsValid(ms->_replyPort)) {
+	CFMessagePortInvalidate(ms);
+	return false;
+    }
+    if (NULL != ms->_source && !CFRunLoopSourceIsValid(ms->_source)) {
+	CFMessagePortInvalidate(ms);
+	return false;
+    }
+    return true;
+}
+
+CFMessagePortInvalidationCallBack CFMessagePortGetInvalidationCallBack(CFMessagePortRef ms) {
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+    return ms->_icallout;
+}
+
+void CFMessagePortSetInvalidationCallBack(CFMessagePortRef ms, CFMessagePortInvalidationCallBack callout) {
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+    if (!__CFMessagePortIsValid(ms) && NULL != callout) {
+	callout(ms, ms->_context.info);
+    } else {
+	ms->_icallout = callout;
+    }
+}
+
+static void __CFMessagePortReplyCallBack(CFMachPortRef port, void *msg, CFIndex size, void *info) {
+    CFMessagePortRef ms = (CFMessagePortRef)info;
+    struct __CFMessagePortMachMessage *msgp = (struct __CFMessagePortMachMessage *)msg;
+    struct __CFMessagePortMachMessage *replymsg;
+    __CFMessagePortLock(ms);
+    if (!__CFMessagePortIsValid(ms)) {
+	__CFMessagePortUnlock(ms);
+	return;
+    }
+// assert: (int32_t)msgp->head.msgh_id < 0
+    if (CFDictionaryContainsKey(ms->_replies, (void *)(uintptr_t)msgp->head.msgh_id)) {
+	CFDataRef reply = NULL;
+	replymsg = (struct __CFMessagePortMachMessage *)msg;
+	if (0 == replymsg->body.msgh_descriptor_count) {
+	    int32_t byteslen = CFSwapInt32LittleToHost(replymsg->contents.msg0.byteslen);
+	    if (0 <= byteslen) {
+		reply = CFDataCreate(kCFAllocatorSystemDefault, replymsg->contents.msg0.bytes, byteslen);
+	    } else {
+		reply = (CFDataRef)((void *)~0);	// means NULL data
+	    }
+	} else {
+//#warning CF: should create a no-copy data here that has a custom VM-freeing allocator, and not vm_dealloc here
+	    reply = CFDataCreate(kCFAllocatorSystemDefault, (const UInt8*)replymsg->contents.msg1.desc.out_of_line.address, replymsg->contents.msg1.desc.out_of_line.size);
+	    vm_deallocate(mach_task_self(), (vm_address_t)replymsg->contents.msg1.desc.out_of_line.address, replymsg->contents.msg1.desc.out_of_line.size);
+	}
+	CFDictionarySetValue(ms->_replies, (void *)(uintptr_t)msgp->head.msgh_id, (void *)reply);
+    } else {	/* discard message */
+	if (1 == msgp->body.msgh_descriptor_count) {
+	    vm_deallocate(mach_task_self(), (vm_address_t)msgp->contents.msg1.desc.out_of_line.address, msgp->contents.msg1.desc.out_of_line.size);
+	}
+    }
+    __CFMessagePortUnlock(ms);
+}
+
+SInt32 CFMessagePortSendRequest(CFMessagePortRef remote, SInt32 msgid, CFDataRef data, CFTimeInterval sendTimeout, CFTimeInterval rcvTimeout, CFStringRef replyMode, CFDataRef *returnDatap) {
+    struct __CFMessagePortMachMessage *sendmsg;
+    CFRunLoopRef currentRL = CFRunLoopGetCurrent();
+    CFRunLoopSourceRef source = NULL;
+    CFDataRef reply = NULL;
+    int64_t termTSR;
+    uint32_t sendOpts = 0, sendTimeOut = 0;
+    int32_t desiredReply;
+    Boolean didRegister = false;
+    kern_return_t ret;
+
+    //#warning CF: This should be an assert
+    // if (!__CFMessagePortIsRemote(remote)) return -999;
+    if (!__CFMessagePortIsValid(remote)) return kCFMessagePortIsInvalid;
+    __CFMessagePortLock(remote);
+    if (NULL == remote->_replyPort) {
+	CFMachPortContext context;
+	context.version = 0;
+	context.info = remote;
+	context.retain = (const void *(*)(const void *))CFRetain;
+	context.release = (void (*)(const void *))CFRelease;
+	context.copyDescription = (CFStringRef (*)(const void *))__CFMessagePortCopyDescription;
+	remote->_replyPort = CFMachPortCreate(CFGetAllocator(remote), __CFMessagePortReplyCallBack, &context, NULL);
+    }
+    remote->_convCounter++;
+    desiredReply = -remote->_convCounter;
+    sendmsg = __CFMessagePortCreateMessage(kCFAllocatorSystemDefault, false, CFMachPortGetPort(remote->_port), (replyMode != NULL ? CFMachPortGetPort(remote->_replyPort) : MACH_PORT_NULL), -desiredReply, msgid, (data ? CFDataGetBytePtr(data) : NULL), (data ? CFDataGetLength(data) : 0));
+    __CFMessagePortUnlock(remote);
+    if (replyMode != NULL) {
+        CFDictionarySetValue(remote->_replies, (void *)(uintptr_t)desiredReply, NULL);
+        source = CFMachPortCreateRunLoopSource(CFGetAllocator(remote), remote->_replyPort, -100);
+        didRegister = !CFRunLoopContainsSource(currentRL, source, replyMode);
+	if (didRegister) {
+            CFRunLoopAddSource(currentRL, source, replyMode);
+	}
+    }
+    if (sendTimeout < 10.0*86400) {
+	// anything more than 10 days is no timeout!
+	sendOpts = MACH_SEND_TIMEOUT;
+	sendTimeout *= 1000.0;
+	if (sendTimeout < 1.0) sendTimeout = 0.0;
+	sendTimeOut = floor(sendTimeout);
+    }
+    ret = mach_msg((mach_msg_header_t *)sendmsg, MACH_SEND_MSG|sendOpts, sendmsg->head.msgh_size, 0, MACH_PORT_NULL, sendTimeOut, MACH_PORT_NULL);
+    if (KERN_SUCCESS != ret) {
+	// need to deallocate the send-once right that might have been created
+	if (replyMode != NULL) mach_port_deallocate(mach_task_self(), ((mach_msg_header_t *)sendmsg)->msgh_local_port);
+	if (didRegister) {
+	    CFRunLoopRemoveSource(currentRL, source, replyMode);
+	}
+	if (source) CFRelease(source);
+        CFAllocatorDeallocate(kCFAllocatorSystemDefault, sendmsg);
+	return (MACH_SEND_TIMED_OUT == ret) ? kCFMessagePortSendTimeout : kCFMessagePortTransportError;
+    }
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, sendmsg);
+    if (replyMode == NULL) {
+	return kCFMessagePortSuccess;
+    }
+    CFRetain(remote); // retain during run loop to avoid invalidation causing freeing
+    _CFMachPortInstallNotifyPort(currentRL, replyMode);
+    termTSR = mach_absolute_time() + __CFTimeIntervalToTSR(rcvTimeout);
+    for (;;) {
+	CFRunLoopRunInMode(replyMode, __CFTSRToTimeInterval(termTSR - mach_absolute_time()), true);
+	// warning: what, if anything, should be done if remote is now invalid?
+	reply = (CFDataRef)CFDictionaryGetValue(remote->_replies, (void *)(uintptr_t)desiredReply);
+	if (NULL != reply || termTSR < (int64_t)mach_absolute_time()) {
+	    break;
+	}
+	if (!CFMessagePortIsValid(remote)) {
+	    // no reason that reply port alone should go invalid so we don't check for that
+	    break;
+	}
+    }
+    // Should we uninstall the notify port?  A complex question...
+    if (didRegister) {
+        CFRunLoopRemoveSource(currentRL, source, replyMode);
+    }
+    if (source) CFRelease(source);
+    if (NULL == reply) {
+	CFDictionaryRemoveValue(remote->_replies, (void *)(uintptr_t)desiredReply);
+	CFRelease(remote);
+	return CFMessagePortIsValid(remote) ? kCFMessagePortReceiveTimeout : -5;
+    }
+    if (NULL != returnDatap) {
+	*returnDatap = ((void *)~0 == reply) ? NULL : reply;
+    } else if ((void *)~0 != reply) {
+	CFRelease(reply);
+    }
+    CFDictionaryRemoveValue(remote->_replies, (void *)(uintptr_t)desiredReply);
+    CFRelease(remote);
+    return kCFMessagePortSuccess;
+}
+
+static mach_port_t __CFMessagePortGetPort(void *info) {
+    CFMessagePortRef ms = (CFMessagePortRef)info;
+    if (!ms->_port) CFLog(kCFLogLevelWarning, CFSTR("*** Warning: A local CFMessagePort (%p) is being put in a run loop, but it has not been named yet, so this will be a no-op and no messages are going to be received, even if named later."), info);
+    return ms->_port ? CFMachPortGetPort(ms->_port) : MACH_PORT_NULL;
+}
+
+static void *__CFMessagePortPerform(void *msg, CFIndex size, CFAllocatorRef allocator, void *info) {
+    CFMessagePortRef ms = (CFMessagePortRef)info;
+    struct __CFMessagePortMachMessage *msgp = (struct __CFMessagePortMachMessage *)msg;
+    struct __CFMessagePortMachMessage *replymsg;
+    void *context_info;
+    void (*context_release)(const void *);
+    CFDataRef returnData, data = NULL;
+    void *return_bytes = NULL;
+    CFIndex return_len = 0;
+    int32_t msgid;
+
+    __CFMessagePortLock(ms);
+    if (!__CFMessagePortIsValid(ms)) {
+	__CFMessagePortUnlock(ms);
+	return NULL;
+    }
+// assert: 0 < (int32_t)msgp->head.msgh_id
+    if (NULL != ms->_context.retain) {
+	context_info = (void *)ms->_context.retain(ms->_context.info);
+	context_release = ms->_context.release;
+    } else {
+	context_info = ms->_context.info;
+	context_release = NULL;
+    }
+    __CFMessagePortUnlock(ms);
+    /* Create no-copy, no-free-bytes wrapper CFData */
+    if (0 == msgp->body.msgh_descriptor_count) {
+	int32_t byteslen = CFSwapInt32LittleToHost(msgp->contents.msg0.byteslen);
+	msgid = CFSwapInt32LittleToHost(msgp->contents.msg0.msgid);
+	if (0 <= byteslen) {
+	    data = CFDataCreateWithBytesNoCopy(kCFAllocatorSystemDefault, msgp->contents.msg0.bytes, byteslen, kCFAllocatorNull);
+	}
+    } else {
+	msgid = CFSwapInt32LittleToHost(msgp->contents.msg1.msgid);
+	data = CFDataCreateWithBytesNoCopy(kCFAllocatorSystemDefault, (const UInt8*)msgp->contents.msg1.desc.out_of_line.address, msgp->contents.msg1.desc.out_of_line.size, kCFAllocatorNull);
+    }
+    returnData = ms->_callout(ms, msgid, data, context_info);
+    /* Now, returnData could be (1) NULL, (2) an ordinary data < MAX_INLINE,
+    (3) ordinary data >= MAX_INLINE, (4) a no-copy data < MAX_INLINE,
+    (5) a no-copy data >= MAX_INLINE. In cases (2) and (4), we send the return
+    bytes inline in the Mach message, so can release the returnData object
+    here. In cases (3) and (5), we'll send the data out-of-line, we need to
+    create a copy of the memory, which we'll have the kernel autodeallocate
+    for us on send. In case (4) also, the bytes in the return data may be part
+    of the bytes in "data" that we sent into the callout, so if the incoming
+    data was received out of line, we wouldn't be able to clean up the out-of-line
+    wad until the message was sent either, if we didn't make the copy. */
+    if (NULL != returnData) {
+	return_len = CFDataGetLength(returnData);
+	if (return_len < __CFMessagePortMaxInlineBytes) {
+	    return_bytes = (void *)CFDataGetBytePtr(returnData);
+	} else {
+	    return_bytes = NULL;
+	    vm_allocate(mach_task_self(), (vm_address_t *)&return_bytes, return_len, VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_MACH_MSG));
+	    /* vm_copy would only be a win here if the source address
+		is page aligned; it is a lose in all other cases, since
+		the kernel will just do the memmove for us (but not in
+		as simple a way). */
+	    memmove(return_bytes, CFDataGetBytePtr(returnData), return_len);
+	}
+    }
+    replymsg = __CFMessagePortCreateMessage(allocator, true, msgp->head.msgh_remote_port, MACH_PORT_NULL, -1 * (int32_t)msgp->head.msgh_id, msgid, (const uint8_t*)return_bytes, return_len);
+    if (1 == replymsg->body.msgh_descriptor_count) {
+	replymsg->contents.msg1.desc.out_of_line.deallocate = true;
+    }
+    if (data) CFRelease(data);
+    if (1 == msgp->body.msgh_descriptor_count) {
+	vm_deallocate(mach_task_self(), (vm_address_t)msgp->contents.msg1.desc.out_of_line.address, msgp->contents.msg1.desc.out_of_line.size);
+    }
+    if (returnData) CFRelease(returnData);
+    if (context_release) {
+	context_release(context_info);
+    }
+    return replymsg;
+}
+
+CFRunLoopSourceRef CFMessagePortCreateRunLoopSource(CFAllocatorRef allocator, CFMessagePortRef ms, CFIndex order) {
+    CFRunLoopSourceRef result = NULL;
+    __CFGenericValidateType(ms, __kCFMessagePortTypeID);
+//#warning CF: This should be an assert
+   // if (__CFMessagePortIsRemote(ms)) return NULL;
+    __CFMessagePortLock(ms);
+    if (NULL == ms->_source && __CFMessagePortIsValid(ms)) {
+	CFRunLoopSourceContext1 context;
+	context.version = 1;
+	context.info = (void *)ms;
+	context.retain = (const void *(*)(const void *))CFRetain;
+	context.release = (void (*)(const void *))CFRelease;
+	context.copyDescription = (CFStringRef (*)(const void *))__CFMessagePortCopyDescription;
+	context.equal = NULL;
+	context.hash = NULL;
+	context.getPort = __CFMessagePortGetPort;
+	context.perform = __CFMessagePortPerform;
+	ms->_source = CFRunLoopSourceCreate(allocator, order, (CFRunLoopSourceContext *)&context);
+    }
+    if (NULL != ms->_source) {
+	result = (CFRunLoopSourceRef)CFRetain(ms->_source);
+    }
+    __CFMessagePortUnlock(ms);
+    return result;
+}
+
+#endif
diff --git a/CoreFoundation/CFMessagePort.h b/CoreFoundation/CFMessagePort.h
new file mode 100644
index 0000000..3061291
--- /dev/null
+++ b/CoreFoundation/CFMessagePort.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFMESSAGEPORT__)
+#define __COREFOUNDATION_CFMESSAGEPORT__ 1
+
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFData.h>
+
+CF_EXTERN_C_BEGIN
+
+typedef struct __CFMessagePort * CFMessagePortRef;
+
+enum {
+    kCFMessagePortSuccess = 0,
+    kCFMessagePortSendTimeout = -1,
+    kCFMessagePortReceiveTimeout = -2,
+    kCFMessagePortIsInvalid = -3,
+    kCFMessagePortTransportError = -4
+};
+
+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_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFMESSAGEPORT__ */
+
diff --git a/CoreFoundation/CFNumber.c b/CoreFoundation/CFNumber.c
new file mode 100644
index 0000000..b73f338
--- /dev/null
+++ b/CoreFoundation/CFNumber.c
@@ -0,0 +1,1136 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Ali Ozer
+*/
+
+#include <CoreFoundation/CFNumber.h>
+#include "CFInternal.h"
+#include "CFPriv.h"
+#include <math.h>
+#include <float.h>
+
+#if (DEPLOYMENT_TARGET_WINDOWS && !defined(__GNUC__))
+#define isnan _isnan
+#define copysign _copysign
+#define isinf !_finite
+#endif
+
+#define __CFAssertIsBoolean(cf) __CFGenericValidateType(cf, __kCFBooleanTypeID)
+
+struct __CFBoolean {
+    CFRuntimeBase _base;
+};
+
+static struct __CFBoolean __kCFBooleanTrue = {
+    INIT_CFRUNTIME_BASE()
+};
+const CFBooleanRef kCFBooleanTrue = &__kCFBooleanTrue;
+
+static struct __CFBoolean __kCFBooleanFalse = {
+    INIT_CFRUNTIME_BASE()
+};
+const CFBooleanRef kCFBooleanFalse = &__kCFBooleanFalse;
+
+static CFStringRef __CFBooleanCopyDescription(CFTypeRef cf) {
+    CFBooleanRef boolean = (CFBooleanRef)cf;
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFBoolean %p [%p]>{value = %s}"), cf, CFGetAllocator(cf), (boolean == kCFBooleanTrue) ? "true" : "false");
+}
+
+static CFStringRef __CFBooleanCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    CFBooleanRef boolean = (CFBooleanRef)cf;
+    return (CFStringRef)CFRetain((boolean == kCFBooleanTrue) ? CFSTR("true") : CFSTR("false"));
+}
+
+static void __CFBooleanDeallocate(CFTypeRef cf) {
+    CFAssert(false, __kCFLogAssertion, "Deallocated CFBoolean!");
+}
+
+static CFTypeID __kCFBooleanTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFBooleanClass = {
+    0,
+    "CFBoolean",
+    NULL,      // init
+    NULL,      // copy
+    __CFBooleanDeallocate,
+    NULL,
+    NULL,
+    __CFBooleanCopyFormattingDescription,
+    __CFBooleanCopyDescription
+};
+
+__private_extern__ void __CFBooleanInitialize(void) {
+    __kCFBooleanTypeID = _CFRuntimeRegisterClass(&__CFBooleanClass);
+    _CFRuntimeSetInstanceTypeID(&__kCFBooleanTrue, __kCFBooleanTypeID);
+    __kCFBooleanTrue._base._cfisa = __CFISAForTypeID(__kCFBooleanTypeID);
+    _CFRuntimeSetInstanceTypeID(&__kCFBooleanFalse, __kCFBooleanTypeID);
+    __kCFBooleanFalse._base._cfisa = __CFISAForTypeID(__kCFBooleanTypeID);
+}
+
+CFTypeID CFBooleanGetTypeID(void) {
+    return __kCFBooleanTypeID;
+}
+
+Boolean CFBooleanGetValue(CFBooleanRef boolean) {
+    CF_OBJC_FUNCDISPATCH0(__kCFBooleanTypeID, Boolean, boolean, "boolValue");
+    return (boolean == kCFBooleanTrue) ? true : false;
+}
+
+
+/*** CFNumber ***/
+
+#define __CFAssertIsNumber(cf) __CFGenericValidateType(cf, __kCFNumberTypeID)
+#define __CFAssertIsValidNumberType(type) CFAssert2((0 < type && type <= kCFNumberMaxType) || (type == kCFNumberSInt128Type), __kCFLogAssertion, "%s(): bad CFNumber type %d", __PRETTY_FUNCTION__, type);
+
+/* The IEEE bit patterns... Also have:
+0x7f800000		float +Inf
+0x7fc00000		float NaN
+0xff800000		float -Inf
+*/
+#define BITSFORDOUBLENAN	((uint64_t)0x7ff8000000000000ULL)
+#define BITSFORDOUBLEPOSINF	((uint64_t)0x7ff0000000000000ULL)
+#define BITSFORDOUBLENEGINF	((uint64_t)0xfff0000000000000ULL)
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || (DEPLOYMENT_TARGET_WINDOWS && __GNUC__)
+#define FLOAT_POSITIVE_2_TO_THE_64	0x1.0p+64L
+#define FLOAT_NEGATIVE_2_TO_THE_127	-0x1.0p+127L
+#define FLOAT_POSITIVE_2_TO_THE_127	0x1.0p+127L
+#elif (DEPLOYMENT_TARGET_WINDOWS && !defined(__GNUC__))
+#define FLOAT_POSITIVE_2_TO_THE_64	18446744073709551616.0
+#define FLOAT_NEGATIVE_2_TO_THE_127	-1.7014118346046923173168730371588e38
+#define FLOAT_POSITIVE_2_TO_THE_127	-1.7014118346046923173168730371588e38
+#endif
+
+typedef struct {	// NOTE WELL: these two fields may switch position someday, do not use '= {high, low}' -style initialization
+    int64_t high;
+    uint64_t low;
+} CFSInt128Struct;
+
+enum {
+    kCFNumberSInt128Type = 17
+};
+
+static uint8_t isNeg128(const CFSInt128Struct *in) {
+    return in->high < 0;
+}
+
+static CFComparisonResult cmp128(const CFSInt128Struct *in1, const CFSInt128Struct *in2) {
+    if (in1->high < in2->high) return kCFCompareLessThan;
+    if (in1->high > in2->high) return kCFCompareGreaterThan;
+    if (in1->low < in2->low) return kCFCompareLessThan;
+    if (in1->low > in2->low) return kCFCompareGreaterThan;
+    return kCFCompareEqualTo;
+}
+
+// allows out to be the same as in1 or in2
+static void add128(CFSInt128Struct *out, CFSInt128Struct *in1, CFSInt128Struct *in2) {
+    CFSInt128Struct tmp;
+    tmp.low = in1->low + in2->low;
+    tmp.high = in1->high + in2->high;
+    if (UINT64_MAX - in1->low < in2->low) {
+        tmp.high++;
+    }
+    *out = tmp;
+}
+
+// allows out to be the same as in
+static void neg128(CFSInt128Struct *out, CFSInt128Struct *in) {
+    uint64_t tmplow = ~in->low;
+    out->low = tmplow + 1;
+    out->high = ~in->high;
+    if (UINT64_MAX == tmplow) {
+	out->high++;
+    }
+}
+
+static const CFSInt128Struct powersOf10[] = {
+    { 0x4B3B4CA85A86C47ALL, 0x098A224000000000ULL },
+    { 0x0785EE10D5DA46D9LL, 0x00F436A000000000ULL },
+    { 0x00C097CE7BC90715LL, 0xB34B9F1000000000ULL },
+    { 0x0013426172C74D82LL, 0x2B878FE800000000ULL },
+    { 0x0001ED09BEAD87C0LL, 0x378D8E6400000000ULL },
+    { 0x0000314DC6448D93LL, 0x38C15B0A00000000ULL },
+    { 0x000004EE2D6D415BLL, 0x85ACEF8100000000ULL },
+    { 0x0000007E37BE2022LL, 0xC0914B2680000000ULL },
+    { 0x0000000C9F2C9CD0LL, 0x4674EDEA40000000ULL },
+    { 0x00000001431E0FAELL, 0x6D7217CAA0000000ULL },
+    { 0x00000000204FCE5ELL, 0x3E25026110000000ULL },
+    { 0x00000000033B2E3CLL, 0x9FD0803CE8000000ULL },
+    { 0x000000000052B7D2LL, 0xDCC80CD2E4000000ULL },
+    { 0x0000000000084595LL, 0x161401484A000000ULL },
+    { 0x000000000000D3C2LL, 0x1BCECCEDA1000000ULL },
+    { 0x000000000000152DLL, 0x02C7E14AF6800000ULL },
+    { 0x000000000000021ELL, 0x19E0C9BAB2400000ULL },
+    { 0x0000000000000036LL, 0x35C9ADC5DEA00000ULL },
+    { 0x0000000000000005LL, 0x6BC75E2D63100000ULL },
+    { 0x0000000000000000LL, 0x8AC7230489E80000ULL },
+    { 0x0000000000000000LL, 0x0DE0B6B3A7640000ULL },
+    { 0x0000000000000000LL, 0x016345785D8A0000ULL },
+    { 0x0000000000000000LL, 0x002386F26FC10000ULL },
+    { 0x0000000000000000LL, 0x00038D7EA4C68000ULL },
+    { 0x0000000000000000LL, 0x00005AF3107A4000ULL },
+    { 0x0000000000000000LL, 0x000009184E72A000ULL },
+    { 0x0000000000000000LL, 0x000000E8D4A51000ULL },
+    { 0x0000000000000000LL, 0x000000174876E800ULL },
+    { 0x0000000000000000LL, 0x00000002540BE400ULL },
+    { 0x0000000000000000LL, 0x000000003B9ACA00ULL },
+    { 0x0000000000000000LL, 0x0000000005F5E100ULL },
+    { 0x0000000000000000LL, 0x0000000000989680ULL },
+    { 0x0000000000000000LL, 0x00000000000F4240ULL },
+    { 0x0000000000000000LL, 0x00000000000186A0ULL },
+    { 0x0000000000000000LL, 0x0000000000002710ULL },
+    { 0x0000000000000000LL, 0x00000000000003E8ULL },
+    { 0x0000000000000000LL, 0x0000000000000064ULL },
+    { 0x0000000000000000LL, 0x000000000000000AULL },
+    { 0x0000000000000000LL, 0x0000000000000001ULL },
+};
+
+static const CFSInt128Struct neg_powersOf10[] = {
+    { 0xB4C4B357A5793B85LL, 0xF675DDC000000000ULL },
+    { 0xF87A11EF2A25B926LL, 0xFF0BC96000000000ULL },
+    { 0xFF3F68318436F8EALL, 0x4CB460F000000000ULL },
+    { 0xFFECBD9E8D38B27DLL, 0xD478701800000000ULL },
+    { 0xFFFE12F64152783FLL, 0xC872719C00000000ULL },
+    { 0xFFFFCEB239BB726CLL, 0xC73EA4F600000000ULL },
+    { 0xFFFFFB11D292BEA4LL, 0x7A53107F00000000ULL },
+    { 0xFFFFFF81C841DFDDLL, 0x3F6EB4D980000000ULL },
+    { 0xFFFFFFF360D3632FLL, 0xB98B1215C0000000ULL },
+    { 0xFFFFFFFEBCE1F051LL, 0x928DE83560000000ULL },
+    { 0xFFFFFFFFDFB031A1LL, 0xC1DAFD9EF0000000ULL },
+    { 0xFFFFFFFFFCC4D1C3LL, 0x602F7FC318000000ULL },
+    { 0xFFFFFFFFFFAD482DLL, 0x2337F32D1C000000ULL },
+    { 0xFFFFFFFFFFF7BA6ALL, 0xE9EBFEB7B6000000ULL },
+    { 0xFFFFFFFFFFFF2C3DLL, 0xE43133125F000000ULL },
+    { 0xFFFFFFFFFFFFEAD2LL, 0xFD381EB509800000ULL },
+    { 0xFFFFFFFFFFFFFDE1LL, 0xE61F36454DC00000ULL },
+    { 0xFFFFFFFFFFFFFFC9LL, 0xCA36523A21600000ULL },
+    { 0xFFFFFFFFFFFFFFFALL, 0x9438A1D29CF00000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0x7538DCFB76180000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xF21F494C589C0000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFE9CBA87A2760000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFDC790D903F0000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFC72815B398000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFA50CEF85C000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFF6E7B18D6000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFF172B5AF000ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFE8B7891800ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFDABF41C00ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFC4653600ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFA0A1F00ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFF676980ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFF0BDC0ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFE7960ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFD8F0ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFC18ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFF9CULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFF6ULL },
+    { 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFULL },
+};
+
+static void emit128(char *buffer, const CFSInt128Struct *in, Boolean forcePlus) {
+    CFSInt128Struct tmp = *in;
+    if (isNeg128(&tmp)) {
+	neg128(&tmp, &tmp);
+	*buffer++ = '-';
+    } else if (forcePlus) {
+	*buffer++ = '+';
+    }
+    Boolean doneOne = false;
+    int idx;
+    for (idx = 0; idx < sizeof(powersOf10) / sizeof(powersOf10[0]); idx++) {
+	int count = 0;
+        while (cmp128(&powersOf10[idx], &tmp) <= 0) {
+	    add128(&tmp, &tmp, (CFSInt128Struct *)&neg_powersOf10[idx]);
+	    count++;
+	}
+	if (0 != count || doneOne) {
+	    *buffer++ = '0' + count;
+	    doneOne = true;
+	}
+    }
+    if (!doneOne) {
+	*buffer++ = '0';
+    }
+    *buffer = '\0';
+}
+
+static void cvtSInt128ToFloat64(Float64 *out, const CFSInt128Struct *in) {
+    // switching to a positive number results in better accuracy
+    // for negative numbers close to zero, because the multiply
+    // of -1 by 2^64 (scaling the Float64 high) is avoided
+    Boolean wasNeg = false;
+    CFSInt128Struct tmp = *in;
+    if (isNeg128(&tmp)) {
+	neg128(&tmp, &tmp);
+	wasNeg = true;
+    }
+    Float64 d = (Float64)tmp.high * FLOAT_POSITIVE_2_TO_THE_64 + (Float64)tmp.low;
+    if (wasNeg) d = -d;
+    *out = d;
+}
+
+static void cvtFloat64ToSInt128(CFSInt128Struct *out, const Float64 *in) {
+    CFSInt128Struct i;
+    Float64 d = *in;
+    if (d < FLOAT_NEGATIVE_2_TO_THE_127) {
+	i.high = 0x8000000000000000LL;
+	i.low = 0x0000000000000000ULL;
+	*out = i;
+	return;
+    }
+    if (FLOAT_POSITIVE_2_TO_THE_127<= d) {
+	i.high = 0x7fffffffffffffffLL;
+	i.low = 0xffffffffffffffffULL;
+	*out = i;
+	return;
+    }
+    Float64 t = floor(d / FLOAT_POSITIVE_2_TO_THE_64);
+    i.high = (int64_t)t;
+    i.low = (uint64_t)(d - t * FLOAT_POSITIVE_2_TO_THE_64);
+    *out = i;
+}
+
+struct __CFNumber {
+    CFRuntimeBase _base;
+    uint64_t _pad; // need this space here for the constant objects
+    /* 0 or 8 more bytes allocated here */
+};
+
+/* Seven bits in base:
+    Bits 6..5: unused
+    Bits 4..0: CFNumber type
+*/
+
+static struct __CFNumber __kCFNumberNaN = {
+    INIT_CFRUNTIME_BASE(), 0ULL
+};
+const CFNumberRef kCFNumberNaN = &__kCFNumberNaN;
+
+static struct __CFNumber __kCFNumberNegativeInfinity = {
+    INIT_CFRUNTIME_BASE(), 0ULL
+};
+const CFNumberRef kCFNumberNegativeInfinity = &__kCFNumberNegativeInfinity;
+
+static struct __CFNumber __kCFNumberPositiveInfinity = {
+    INIT_CFRUNTIME_BASE(), 0ULL
+};
+const CFNumberRef kCFNumberPositiveInfinity = &__kCFNumberPositiveInfinity;
+
+static const struct {
+    uint16_t canonicalType:5;	// canonical fixed-width type
+    uint16_t floatBit:1;	// is float
+    uint16_t storageBit:1;	// storage size (0: (float ? 4 : 8), 1: (float ? 8 : 16) bits)
+    uint16_t lgByteSize:3;	// base-2 log byte size of public type
+    uint16_t unused:6;
+} __CFNumberTypeTable[] = {
+    /* 0 */			{0, 0, 0, 0},
+
+    /* kCFNumberSInt8Type */	{kCFNumberSInt8Type, 0, 0, 0, 0},
+    /* kCFNumberSInt16Type */	{kCFNumberSInt16Type, 0, 0, 1, 0},
+    /* kCFNumberSInt32Type */	{kCFNumberSInt32Type, 0, 0, 2, 0},
+    /* kCFNumberSInt64Type */	{kCFNumberSInt64Type, 0, 0, 3, 0},
+    /* kCFNumberFloat32Type */	{kCFNumberFloat32Type, 1, 0, 2, 0},
+    /* kCFNumberFloat64Type */	{kCFNumberFloat64Type, 1, 1, 3, 0},
+
+    /* kCFNumberCharType */	{kCFNumberSInt8Type, 0, 0, 0, 0},
+    /* kCFNumberShortType */	{kCFNumberSInt16Type, 0, 0, 1, 0},
+    /* kCFNumberIntType */	{kCFNumberSInt32Type, 0, 0, 2, 0},
+#if __LP64__
+    /* kCFNumberLongType */	{kCFNumberSInt64Type, 0, 0, 3, 0},
+#else
+    /* kCFNumberLongType */	{kCFNumberSInt32Type, 0, 0, 2, 0},
+#endif
+    /* kCFNumberLongLongType */	{kCFNumberSInt64Type, 0, 0, 3, 0},
+    /* kCFNumberFloatType */	{kCFNumberFloat32Type, 1, 0, 2, 0},
+    /* kCFNumberDoubleType */	{kCFNumberFloat64Type, 1, 1, 3, 0},
+
+#if __LP64__
+    /* kCFNumberCFIndexType */	{kCFNumberSInt64Type, 0, 0, 3, 0},
+    /* kCFNumberNSIntegerType */ {kCFNumberSInt64Type, 0, 0, 3, 0},
+    /* kCFNumberCGFloatType */	{kCFNumberFloat64Type, 1, 1, 3, 0},
+#else
+    /* kCFNumberCFIndexType */	{kCFNumberSInt32Type, 0, 0, 2, 0},
+    /* kCFNumberNSIntegerType */ {kCFNumberSInt32Type, 0, 0, 2, 0},
+    /* kCFNumberCGFloatType */	{kCFNumberFloat32Type, 1, 0, 2, 0},
+#endif
+
+    /* kCFNumberSInt128Type */	{kCFNumberSInt128Type, 0, 1, 4, 0},
+};
+
+CF_INLINE CFNumberType __CFNumberGetType(CFNumberRef num) {
+    return __CFBitfieldGetValue(num->_base._cfinfo[CF_INFO_BITS], 4, 0);
+}
+
+#define CVT(SRC_TYPE, DST_TYPE, DST_MIN, DST_MAX) do { \
+	SRC_TYPE sv; memmove(&sv, data, sizeof(SRC_TYPE)); \
+	DST_TYPE dv = (sv < DST_MIN) ? (DST_TYPE)DST_MIN : (DST_TYPE)(((DST_MAX < sv) ? DST_MAX : sv)); \
+	memmove(valuePtr, &dv, sizeof(DST_TYPE)); \
+	SRC_TYPE vv = (SRC_TYPE)dv; return (vv == sv); \
+	} while (0)
+
+#define CVT128ToInt(SRC_TYPE, DST_TYPE, DST_MIN, DST_MAX) do { \
+        SRC_TYPE sv; memmove(&sv, data, sizeof(SRC_TYPE)); \
+	DST_TYPE dv; Boolean noLoss = false; \
+	if (0 < sv.high || (0 == sv.high && (int64_t)DST_MAX < sv.low)) { \
+	    dv = DST_MAX; \
+	} else if (sv.high < -1 || (-1 == sv.high && sv.low < (int64_t)DST_MIN)) { \
+	    dv = DST_MIN; \
+	} else { \
+	    dv = (DST_TYPE)sv.low; \
+	    noLoss = true; \
+	} \
+        memmove(valuePtr, &dv, sizeof(DST_TYPE)); \
+        return noLoss; \
+        } while (0)
+
+// returns false if the output value is not the same as the number's value, which
+// can occur due to accuracy loss and the value not being within the target range
+static Boolean __CFNumberGetValue(CFNumberRef number, CFNumberType type, void *valuePtr) {
+    type = __CFNumberTypeTable[type].canonicalType;
+    CFNumberType ntype = __CFNumberGetType(number);
+    const void *data = &(number->_pad);
+    switch (type) {
+    case kCFNumberSInt8Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT(Float32, int8_t, INT8_MIN, INT8_MAX);
+	    } else {
+		CVT(Float64, int8_t, INT8_MIN, INT8_MAX);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT(int64_t, int8_t, INT8_MIN, INT8_MAX);
+	    } else {
+		CVT128ToInt(CFSInt128Struct, int8_t, INT8_MIN, INT8_MAX);
+	    }
+	}
+	return true;
+    case kCFNumberSInt16Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT(Float32, int16_t, INT16_MIN, INT16_MAX);
+	    } else {
+                CVT(Float64, int16_t, INT16_MIN, INT16_MAX);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT(int64_t, int16_t, INT16_MIN, INT16_MAX);
+	    } else {
+		CVT128ToInt(CFSInt128Struct, int16_t, INT16_MIN, INT16_MAX);
+	    }
+	}
+	return true;
+    case kCFNumberSInt32Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT(Float32, int32_t, INT32_MIN, INT32_MAX);
+	    } else {
+                CVT(Float64, int32_t, INT32_MIN, INT32_MAX);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT(int64_t, int32_t, INT32_MIN, INT32_MAX);
+	    } else {
+		CVT128ToInt(CFSInt128Struct, int32_t, INT32_MIN, INT32_MAX);
+	    }
+	}
+	return true;
+    case kCFNumberSInt64Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT(Float32, int64_t, INT64_MIN, INT64_MAX);
+	    } else {
+                CVT(Float64, int64_t, INT64_MIN, INT64_MAX);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		memmove(valuePtr, data, 8);
+	    } else {
+		CVT128ToInt(CFSInt128Struct, int64_t, INT64_MIN, INT64_MAX);
+	    }
+	}
+	return true;
+    case kCFNumberSInt128Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		Float32 f;
+		memmove(&f, data, 4);
+		Float64 d = f;
+		CFSInt128Struct i;
+		cvtFloat64ToSInt128(&i, &d);
+		memmove(valuePtr, &i, 16);
+		Float64 d2;
+		cvtSInt128ToFloat64(&d2, &i);
+		Float32 f2 = (Float32)d2;
+		return (f2 == f);
+	    } else {
+		Float64 d;
+		memmove(&d, data, 8);
+		CFSInt128Struct i;
+		cvtFloat64ToSInt128(&i, &d);
+		memmove(valuePtr, &i, 16);
+		Float64 d2;
+		cvtSInt128ToFloat64(&d2, &i);
+		return (d2 == d);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		int64_t j;
+		memmove(&j, data, 8);
+		CFSInt128Struct i;
+		i.low = j;
+		i.high = (j < 0) ? -1LL : 0LL;
+		memmove(valuePtr, &i, 16);
+	    } else {
+		memmove(valuePtr, data, 16);
+	    }
+	}
+	return true;
+    case kCFNumberFloat32Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		memmove(valuePtr, data, 4);
+	    } else {
+		double d;
+		memmove(&d, data, 8);
+		if (isnan(d)) {
+		    uint32_t l = 0x7fc00000;
+		    memmove(valuePtr, &l, 4);
+		    return true;
+		} else if (isinf(d)) {
+		    uint32_t l = 0x7f800000;
+		    if (d < 0.0) l += 0x80000000UL;
+		    memmove(valuePtr, &l, 4);
+		    return true;
+		}
+		CVT(Float64, Float32, -FLT_MAX, FLT_MAX);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT(int64_t, Float32, -FLT_MAX, FLT_MAX);
+	    } else {
+		CFSInt128Struct i;
+		memmove(&i, data, 16);
+		Float64 d;
+		cvtSInt128ToFloat64(&d, &i);
+		Float32 f = (Float32)d;
+		memmove(valuePtr, &f, 4);
+		d = f;
+		CFSInt128Struct i2;
+		cvtFloat64ToSInt128(&i2, &d);
+		return cmp128(&i2, &i) == kCFCompareEqualTo;
+	    }
+	}
+	return true;
+    case kCFNumberFloat64Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		float f;
+		memmove(&f, data, 4);
+		if (isnan(f)) {
+		    uint64_t l = BITSFORDOUBLENAN;
+		    memmove(valuePtr, &l, 8);
+		    return true;
+		} else if (isinf(f)) {
+		    uint64_t l = BITSFORDOUBLEPOSINF;
+		    if (f < 0.0) l += 0x8000000000000000ULL;
+		    memmove(valuePtr, &l, 8);
+		    return true;
+		}
+		CVT(Float32, Float64, -DBL_MAX, DBL_MAX);
+	    } else {
+		memmove(valuePtr, data, 8);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT(int64_t, Float64, -DBL_MAX, DBL_MAX);
+	    } else {
+                CFSInt128Struct i;
+                memmove(&i, data, 16);
+                Float64 d;
+                cvtSInt128ToFloat64(&d, &i);
+                memmove(valuePtr, &d, 8);
+                CFSInt128Struct i2;
+                cvtFloat64ToSInt128(&i2, &d);
+                return cmp128(&i2, &i) == kCFCompareEqualTo;
+	    }
+	}
+	return true;
+    }
+    return false;
+}
+
+#define CVT_COMPAT(SRC_TYPE, DST_TYPE, FT) do { \
+	SRC_TYPE sv; memmove(&sv, data, sizeof(SRC_TYPE)); \
+	DST_TYPE dv = (DST_TYPE)(sv); \
+	memmove(valuePtr, &dv, sizeof(DST_TYPE)); \
+	SRC_TYPE vv = (SRC_TYPE)dv; return (FT) || (vv == sv); \
+	} while (0)
+
+#define CVT128ToInt_COMPAT(SRC_TYPE, DST_TYPE) do { \
+        SRC_TYPE sv; memmove(&sv, data, sizeof(SRC_TYPE)); \
+	DST_TYPE dv; dv = (DST_TYPE)sv.low; \
+        memmove(valuePtr, &dv, sizeof(DST_TYPE)); \
+	uint64_t vv = (uint64_t)dv; return (vv == sv.low); \
+        } while (0)
+
+// this has the old cast-style behavior
+static Boolean __CFNumberGetValueCompat(CFNumberRef number, CFNumberType type, void *valuePtr) {
+    type = __CFNumberTypeTable[type].canonicalType;
+    CFNumberType ntype = __CFNumberGetType(number);
+    const void *data = &(number->_pad);
+    switch (type) {
+    case kCFNumberSInt8Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT_COMPAT(Float32, int8_t, 0);
+	    } else {
+		CVT_COMPAT(Float64, int8_t, 0);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT_COMPAT(int64_t, int8_t, 1);
+	    } else {
+		CVT128ToInt_COMPAT(CFSInt128Struct, int8_t);
+	    }
+	}
+	return true;
+    case kCFNumberSInt16Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT_COMPAT(Float32, int16_t, 0);
+	    } else {
+		CVT_COMPAT(Float64, int16_t, 0);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT_COMPAT(int64_t, int16_t, 1);
+	    } else {
+		CVT128ToInt_COMPAT(CFSInt128Struct, int16_t);
+	    }
+	}
+	return true;
+    case kCFNumberSInt32Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT_COMPAT(Float32, int32_t, 0);
+	    } else {
+		CVT_COMPAT(Float64, int32_t, 0);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT_COMPAT(int64_t, int32_t, 0);
+	    } else {
+		CVT128ToInt_COMPAT(CFSInt128Struct, int32_t);
+	    }
+	}
+	return true;
+    case kCFNumberSInt64Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT_COMPAT(Float32, int64_t, 0);
+	    } else {
+		CVT_COMPAT(Float64, int64_t, 0);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+                CVT_COMPAT(int64_t, int64_t, 0);
+	    } else {
+		CVT128ToInt_COMPAT(CFSInt128Struct, int64_t);
+	    }
+	}
+	return true;
+    case kCFNumberSInt128Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		Float32 f;
+		memmove(&f, data, 4);
+		Float64 d = f;
+		CFSInt128Struct i;
+		cvtFloat64ToSInt128(&i, &d);
+		memmove(valuePtr, &i, 16);
+		Float64 d2;
+		cvtSInt128ToFloat64(&d2, &i);
+		Float32 f2 = (Float32)d2;
+		return (f2 == f);
+	    } else {
+		Float64 d;
+		memmove(&d, data, 8);
+		CFSInt128Struct i;
+		cvtFloat64ToSInt128(&i, &d);
+		memmove(valuePtr, &i, 16);
+		Float64 d2;
+		cvtSInt128ToFloat64(&d2, &i);
+		return (d2 == d);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		int64_t j;
+		memmove(&j, data, 8);
+		CFSInt128Struct i;
+		i.low = j;
+		i.high = (j < 0) ? -1LL : 0LL;
+		memmove(valuePtr, &i, 16);
+	    } else {
+		memmove(valuePtr, data, 16);
+	    }
+	}
+	return true;
+    case kCFNumberFloat32Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		memmove(valuePtr, data, 4);
+	    } else {
+		CVT_COMPAT(Float64, Float32, 0);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT_COMPAT(int64_t, Float32, 0);
+	    } else {
+		CFSInt128Struct i;
+		memmove(&i, data, 16);
+		Float64 d;
+		cvtSInt128ToFloat64(&d, &i);
+		Float32 f = (Float32)d;
+		memmove(valuePtr, &f, 4);
+		d = f;
+		CFSInt128Struct i2;
+		cvtFloat64ToSInt128(&i2, &d);
+		return cmp128(&i2, &i) == kCFCompareEqualTo;
+	    }
+	}
+	return true;
+    case kCFNumberFloat64Type:
+	if (__CFNumberTypeTable[ntype].floatBit) {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT_COMPAT(Float32, Float64, 0);
+	    } else {
+		memmove(valuePtr, data, 8);
+	    }
+	} else {
+	    if (0 == __CFNumberTypeTable[ntype].storageBit) {
+		CVT_COMPAT(int64_t, Float64, 0);
+	    } else {
+		CFSInt128Struct i;
+		memmove(&i, data, 16);
+		Float64 d;
+		cvtSInt128ToFloat64(&d, &i);
+		memmove(valuePtr, &d, 8);
+		CFSInt128Struct i2;
+		cvtFloat64ToSInt128(&i2, &d);
+		return cmp128(&i2, &i) == kCFCompareEqualTo;
+	    }
+	}
+	return true;
+    }
+    return false;
+}
+
+static CFStringRef __CFNumberCopyDescription(CFTypeRef cf) {
+    CFNumberRef number = (CFNumberRef)cf;
+    CFNumberType type = __CFNumberGetType(number);
+    CFMutableStringRef mstr = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+    CFStringAppendFormat(mstr, NULL, CFSTR("<CFNumber %p [%p]>{value = "), cf, CFGetAllocator(cf));
+    if (__CFNumberTypeTable[type].floatBit) {
+	Float64 d;
+        __CFNumberGetValue(number, kCFNumberFloat64Type, &d);
+	if (isnan(d)) {
+	    CFStringAppend(mstr, CFSTR("nan"));
+	} else if (isinf(d)) {
+	    CFStringAppend(mstr, (0.0 < d) ? CFSTR("+infinity") : CFSTR("-infinity"));
+	} else if (0.0 == d) {
+	    CFStringAppend(mstr, (copysign(1.0, d) < 0.0) ? CFSTR("-0.0") : CFSTR("+0.0"));
+	} else {
+	    CFStringAppendFormat(mstr, NULL, CFSTR("%+.*f"), (__CFNumberTypeTable[type].storageBit ? 20 : 10), d);
+	}
+	const char *typeName = "unknown float";
+	switch (type) {
+	case kCFNumberFloat32Type: typeName = "kCFNumberFloat32Type"; break;
+	case kCFNumberFloat64Type: typeName = "kCFNumberFloat64Type"; break;
+	}
+	CFStringAppendFormat(mstr, NULL, CFSTR(", type = %s}"), typeName);
+    } else {
+	CFSInt128Struct i;
+	__CFNumberGetValue(number, kCFNumberSInt128Type, &i);
+	char buffer[128];
+	emit128(buffer, &i, true);
+	const char *typeName = "unknown integer";
+	switch (type) {
+	case kCFNumberSInt8Type: typeName = "kCFNumberSInt8Type"; break;
+	case kCFNumberSInt16Type: typeName = "kCFNumberSInt16Type"; break;
+	case kCFNumberSInt32Type: typeName = "kCFNumberSInt32Type"; break;
+	case kCFNumberSInt64Type: typeName = "kCFNumberSInt64Type"; break;
+	case kCFNumberSInt128Type: typeName = "kCFNumberSInt128Type"; break;
+	}
+	CFStringAppendFormat(mstr, NULL, CFSTR("%s, type = %s}"), buffer, typeName);
+    }
+    return mstr;
+}
+
+// This function separated out from __CFNumberCopyFormattingDescription() so the plist creation can use it as well.
+
+static CFStringRef __CFNumberCopyFormattingDescriptionAsFloat64_new(CFTypeRef cf) {
+    Float64 d;
+    CFNumberGetValue((CFNumberRef)cf, kCFNumberFloat64Type, &d);
+    if (isnan(d)) {
+	return (CFStringRef)CFRetain(CFSTR("nan"));
+    }
+    if (isinf(d)) {
+	return (CFStringRef)CFRetain((0.0 < d) ? CFSTR("+infinity") : CFSTR("-infinity"));
+    }
+    if (0.0 == d) {
+	return (CFStringRef)CFRetain(CFSTR("0.0"));
+    }
+    // if %g is used here, need to use DBL_DIG + 2 on Mac OS X, but %f needs +1
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%.*g"), DBL_DIG + 2, d);
+}
+
+__private_extern__ CFStringRef __CFNumberCopyFormattingDescriptionAsFloat64(CFTypeRef cf) {
+    CFStringRef result = __CFNumberCopyFormattingDescriptionAsFloat64_new(cf);
+    return result;
+}
+
+static CFStringRef __CFNumberCopyFormattingDescription_new(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    CFNumberRef number = (CFNumberRef)cf;
+    CFNumberType type = __CFNumberGetType(number);
+    if (__CFNumberTypeTable[type].floatBit) {
+        return __CFNumberCopyFormattingDescriptionAsFloat64(number);
+    }
+    CFSInt128Struct i;
+    __CFNumberGetValue(number, kCFNumberSInt128Type, &i);
+    char buffer[128];
+    emit128(buffer, &i, false);
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%s"), buffer);
+}
+
+static CFStringRef __CFNumberCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    CFStringRef result = __CFNumberCopyFormattingDescription_new(cf, formatOptions);
+    return result;
+}
+
+
+static Boolean __CFNumberEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    Boolean b = CFNumberCompare((CFNumberRef)cf1, (CFNumberRef)cf2, 0) == kCFCompareEqualTo;
+    return b;
+}
+
+static CFHashCode __CFNumberHash(CFTypeRef cf) {
+    CFHashCode h;
+    CFNumberRef number = (CFNumberRef)cf;
+    switch (__CFNumberGetType(number)) {
+	case kCFNumberSInt8Type:
+	case kCFNumberSInt16Type:
+	case kCFNumberSInt32Type: {
+	    SInt32 i;
+	    __CFNumberGetValue(number, kCFNumberSInt32Type, &i);
+	    h = _CFHashInt(i);
+	    break;
+	}
+	default: {
+	    Float64 d;
+	    __CFNumberGetValue(number, kCFNumberFloat64Type, &d);
+	    h = _CFHashDouble((double)d);
+	    break;
+	}
+    }
+    return h;
+}
+
+static CFTypeID __kCFNumberTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFNumberClass = {
+    0,
+    "CFNumber",
+    NULL,      // init
+    NULL,      // copy
+    NULL,
+    __CFNumberEqual,
+    __CFNumberHash,
+    __CFNumberCopyFormattingDescription,
+    __CFNumberCopyDescription
+};
+
+__private_extern__ void __CFNumberInitialize(void) {
+    __kCFNumberTypeID = _CFRuntimeRegisterClass(&__CFNumberClass);
+
+    _CFRuntimeSetInstanceTypeID(&__kCFNumberNaN, __kCFNumberTypeID);
+    __kCFNumberNaN._base._cfisa = __CFISAForTypeID(__kCFNumberTypeID);
+    __CFBitfieldSetValue(__kCFNumberNaN._base._cfinfo[CF_INFO_BITS], 4, 0, kCFNumberFloat64Type);
+    __kCFNumberNaN._pad = BITSFORDOUBLENAN;
+
+    _CFRuntimeSetInstanceTypeID(& __kCFNumberNegativeInfinity, __kCFNumberTypeID);
+    __kCFNumberNegativeInfinity._base._cfisa = __CFISAForTypeID(__kCFNumberTypeID);
+    __CFBitfieldSetValue(__kCFNumberNegativeInfinity._base._cfinfo[CF_INFO_BITS], 4, 0, kCFNumberFloat64Type);
+    __kCFNumberNegativeInfinity._pad = BITSFORDOUBLENEGINF;
+
+    _CFRuntimeSetInstanceTypeID(& __kCFNumberPositiveInfinity, __kCFNumberTypeID);
+    __kCFNumberPositiveInfinity._base._cfisa = __CFISAForTypeID(__kCFNumberTypeID);
+    __CFBitfieldSetValue(__kCFNumberPositiveInfinity._base._cfinfo[CF_INFO_BITS], 4, 0, kCFNumberFloat64Type);
+    __kCFNumberPositiveInfinity._pad = BITSFORDOUBLEPOSINF;
+}
+
+CFTypeID CFNumberGetTypeID(void) {
+    return __kCFNumberTypeID;
+}
+
+#define MinCachedInt (-1)
+#define MaxCachedInt (12)
+#define NotToBeCached (MinCachedInt - 1)
+static CFNumberRef __CFNumberCache[MaxCachedInt - MinCachedInt + 1] = {NULL};	// Storing CFNumberRefs for range MinCachedInt..MaxCachedInt
+
+CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType type, const void *valuePtr) {
+    __CFAssertIsValidNumberType(type);
+//printf("+ [%p] CFNumberCreate(%p, %d, %p)\n", pthread_self(), allocator, type, valuePtr);
+
+    // Look for cases where we can return a cached instance.
+    // We only use cached objects if the allocator is the system
+    // default allocator, except for the special floating point
+    // constant objects, where we return the cached object
+    // regardless of allocator, since that is what has always
+    // been done (and now must for compatibility).
+    if (!allocator) allocator = __CFGetDefaultAllocator();
+    int64_t valToBeCached = NotToBeCached;
+
+    if (__CFNumberTypeTable[type].floatBit) {
+	CFNumberRef cached = NULL;
+	if (0 == __CFNumberTypeTable[type].storageBit) {
+	    Float32 f = *(Float32 *)valuePtr;
+	    if (isnan(f)) cached = kCFNumberNaN;
+	    if (isinf(f)) cached = (f < 0.0) ? kCFNumberNegativeInfinity : kCFNumberPositiveInfinity;
+	} else {
+            Float64 d = *(Float64 *)valuePtr;
+	    if (isnan(d)) cached = kCFNumberNaN;
+	    if (isinf(d)) cached = (d < 0.0) ? kCFNumberNegativeInfinity : kCFNumberPositiveInfinity;
+	}
+	if (cached) return (CFNumberRef)CFRetain(cached);
+    } else if (kCFAllocatorSystemDefault == allocator) {
+	switch (__CFNumberTypeTable[type].canonicalType) {
+	case kCFNumberSInt8Type:   {int8_t  val = *(int8_t *)valuePtr;  if (MinCachedInt <= val && val <= MaxCachedInt) valToBeCached = (int64_t)val; break;}
+	case kCFNumberSInt16Type:  {int16_t val = *(int16_t *)valuePtr; if (MinCachedInt <= val && val <= MaxCachedInt) valToBeCached = (int64_t)val; break;}
+	case kCFNumberSInt32Type:  {int32_t val = *(int32_t *)valuePtr; if (MinCachedInt <= val && val <= MaxCachedInt) valToBeCached = (int64_t)val; break;}
+	case kCFNumberSInt64Type:  {int64_t val = *(int64_t *)valuePtr; if (MinCachedInt <= val && val <= MaxCachedInt) valToBeCached = (int64_t)val; break;}
+	}
+	if (NotToBeCached != valToBeCached) {
+	    CFNumberRef cached = __CFNumberCache[valToBeCached - MinCachedInt];	    // Atomic to access the value in the cache
+	    if (NULL != cached) return (CFNumberRef)CFRetain(cached);
+	}
+    }
+
+    CFIndex size = 8 + ((!__CFNumberTypeTable[type].floatBit && __CFNumberTypeTable[type].storageBit) ? 8 : 0);
+    CFNumberRef result = (CFNumberRef)_CFRuntimeCreateInstance(allocator, __kCFNumberTypeID, size, NULL);
+    if (NULL == result) {
+	return NULL;
+    }
+    __CFBitfieldSetValue(((struct __CFNumber *)result)->_base._cfinfo[CF_INFO_BITS], 4, 0, (uint8_t)__CFNumberTypeTable[type].canonicalType);
+
+
+    // for a value to be cached, we already have the value handy
+    if (NotToBeCached != valToBeCached) {
+	memmove((void *)&result->_pad, &valToBeCached, 8);
+	// Put this in the cache unless the cache is already filled (by another thread).  If we do put it in the cache, retain it an extra time for the cache.
+	// Note that we don't bother freeing this result and returning the cached value if the cache was filled, since cached CFNumbers are not guaranteed unique.
+	// Barrier assures that the number that is placed in the cache is properly formed.
+	CFNumberType origType = __CFNumberGetType(result);
+	// Force all cached numbers to have the same type, so that the type does not
+	// depend on the order and original type in/with which the numbers are created.
+	// Forcing the type AFTER it was cached would cause a race condition with other
+	// threads pulling the number object out of the cache and using it.
+	__CFBitfieldSetValue(((struct __CFNumber *)result)->_base._cfinfo[CF_INFO_BITS], 4, 0, (uint8_t)kCFNumberSInt32Type);
+	if (_CFAtomicCompareAndSwapPtrBarrier(NULL, (void *)result, (void *volatile *)&__CFNumberCache[valToBeCached - MinCachedInt])) {
+	    CFRetain(result);
+	} else {
+	    // Did not cache the number object, put original type back.
+	    __CFBitfieldSetValue(((struct __CFNumber *)result)->_base._cfinfo[CF_INFO_BITS], 4, 0, (uint8_t)origType);
+	}
+	return result;
+    }
+
+    uint64_t value;
+    switch (__CFNumberTypeTable[type].canonicalType) {
+    case kCFNumberSInt8Type:   value = (uint64_t)(int64_t)*(int8_t *)valuePtr; goto smallVal;
+    case kCFNumberSInt16Type:  value = (uint64_t)(int64_t)*(int16_t *)valuePtr; goto smallVal;
+    case kCFNumberSInt32Type:  value = (uint64_t)(int64_t)*(int32_t *)valuePtr; goto smallVal;
+			smallVal: memmove((void *)&result->_pad, &value, 8); break;
+    case kCFNumberSInt64Type:  memmove((void *)&result->_pad, valuePtr, 8); break;
+    case kCFNumberSInt128Type: memmove((void *)&result->_pad, valuePtr, 16); break;
+    case kCFNumberFloat32Type: memmove((void *)&result->_pad, valuePtr, 4); break;
+    case kCFNumberFloat64Type: memmove((void *)&result->_pad, valuePtr, 8); break;
+    }
+//printf("  => %p\n", result);
+    return result;
+}
+
+CFNumberType CFNumberGetType(CFNumberRef number) {
+//printf("+ [%p] CFNumberGetType(%p)\n", pthread_self(), number);
+    CF_OBJC_FUNCDISPATCH0(__kCFNumberTypeID, CFNumberType, number, "_cfNumberType");
+    __CFAssertIsNumber(number);
+    CFNumberType type = __CFNumberGetType(number);
+    if (kCFNumberSInt128Type == type) type = kCFNumberSInt64Type; // must hide this type, since it is not public
+//printf("  => %d\n", type);
+    return type;
+}
+
+CFNumberType _CFNumberGetType2(CFNumberRef number) {
+    __CFAssertIsNumber(number);
+    return __CFNumberGetType(number);
+}
+
+CFIndex CFNumberGetByteSize(CFNumberRef number) {
+//printf("+ [%p] CFNumberGetByteSize(%p)\n", pthread_self(), number);
+    __CFAssertIsNumber(number);
+    CFIndex r = 1 << __CFNumberTypeTable[CFNumberGetType(number)].lgByteSize;
+//printf("  => %d\n", r);
+    return r;
+}
+
+Boolean CFNumberIsFloatType(CFNumberRef number) {
+//printf("+ [%p] CFNumberIsFloatType(%p)\n", pthread_self(), number);
+    __CFAssertIsNumber(number);
+    Boolean r = __CFNumberTypeTable[CFNumberGetType(number)].floatBit;
+//printf("  => %d\n", r);
+    return r;
+}
+
+Boolean	CFNumberGetValue(CFNumberRef number, CFNumberType type, void *valuePtr) {
+//printf("+ [%p] CFNumberGetValue(%p, %d, %p)\n", pthread_self(), number, type, valuePtr);
+    CF_OBJC_FUNCDISPATCH2(__kCFNumberTypeID, Boolean, number, "_getValue:forType:", valuePtr, __CFNumberTypeTable[type].canonicalType);
+    __CFAssertIsNumber(number);
+    __CFAssertIsValidNumberType(type);
+    uint8_t localMemory[128];
+    Boolean r = __CFNumberGetValueCompat(number, type, valuePtr ? valuePtr : localMemory);
+//printf("  => %d\n", r);
+    return r;
+}
+
+static CFComparisonResult CFNumberCompare_new(CFNumberRef number1, CFNumberRef number2, void *context) {
+    CF_OBJC_FUNCDISPATCH1(__kCFNumberTypeID, CFComparisonResult, number1, "compare:", number2);
+    CF_OBJC_FUNCDISPATCH1(__kCFNumberTypeID, CFComparisonResult, number2, "_reverseCompare:", number1);
+    __CFAssertIsNumber(number1);
+    __CFAssertIsNumber(number2);
+
+    CFNumberType type1 = __CFNumberGetType(number1);
+    CFNumberType type2 = __CFNumberGetType(number2);
+    // Both numbers are integers
+    if (!__CFNumberTypeTable[type1].floatBit && !__CFNumberTypeTable[type2].floatBit) {
+        CFSInt128Struct i1, i2;
+        __CFNumberGetValue(number1, kCFNumberSInt128Type, &i1);
+        __CFNumberGetValue(number2, kCFNumberSInt128Type, &i2);
+        return cmp128(&i1, &i2);
+    }
+    // Both numbers are floats
+    if (__CFNumberTypeTable[type1].floatBit && __CFNumberTypeTable[type2].floatBit) {
+	Float64 d1, d2;
+        __CFNumberGetValue(number1, kCFNumberFloat64Type, &d1);
+        __CFNumberGetValue(number2, kCFNumberFloat64Type, &d2);
+	double s1 = copysign(1.0, d1);
+	double s2 = copysign(1.0, d2);
+	if (isnan(d1) && isnan(d2)) return kCFCompareEqualTo;
+	if (isnan(d1)) return (s2 < 0.0) ? kCFCompareGreaterThan : kCFCompareLessThan;
+	if (isnan(d2)) return (s1 < 0.0) ? kCFCompareLessThan : kCFCompareGreaterThan;
+	// at this point, we know we don't have any NaNs
+	if (s1 < s2) return kCFCompareLessThan;
+	if (s2 < s1) return kCFCompareGreaterThan;
+	// at this point, we know the signs are the same; do not combine these tests
+	if (d1 < d2) return kCFCompareLessThan;
+	if (d2 < d1) return kCFCompareGreaterThan;
+        return kCFCompareEqualTo;
+    }
+    // One float, one integer; swap if necessary so number1 is the float
+    Boolean swapResult = false;
+    if (__CFNumberTypeTable[type2].floatBit) {
+        CFNumberRef tmp = number1;
+	number1 = number2;
+	number2 = tmp;
+	swapResult = true;
+    }
+    // At large integer values, the precision of double is quite low
+    // e.g. all values roughly 2^127 +- 2^73 are represented by 1 double, 2^127.
+    // If we just used double compare, that would make the 2^73 largest 128-bit
+    // integers look equal, so we have to use integer comparison when possible.
+    Float64 d1, d2;
+    __CFNumberGetValue(number1, kCFNumberFloat64Type, &d1);
+    // if the double value is really big, cannot be equal to integer
+    // nan d1 will not compare true here
+    if (d1 < FLOAT_NEGATIVE_2_TO_THE_127) {
+	return !swapResult ? kCFCompareLessThan : kCFCompareGreaterThan;
+    }
+    if (FLOAT_POSITIVE_2_TO_THE_127 <= d1) {
+	return !swapResult ? kCFCompareGreaterThan : kCFCompareLessThan;
+    }
+    CFSInt128Struct i1, i2;
+    __CFNumberGetValue(number1, kCFNumberSInt128Type, &i1);
+    __CFNumberGetValue(number2, kCFNumberSInt128Type, &i2);
+    CFComparisonResult res = cmp128(&i1, &i2);
+    if (kCFCompareEqualTo != res) {
+	return !swapResult ? res : -res;
+    }
+    // now things are equal, but perhaps due to rounding or nan
+    if (isnan(d1)) {
+	if (isNeg128(&i2)) {
+	    return !swapResult ? kCFCompareGreaterThan : kCFCompareLessThan;
+	}
+	// nan compares less than positive 0 too
+	return !swapResult ? kCFCompareLessThan : kCFCompareGreaterThan;
+    }
+    // at this point, we know we don't have NaN
+    double s1 = copysign(1.0, d1);
+    double s2 = isNeg128(&i2) ? -1.0 : 1.0;
+    if (s1 < s2) return !swapResult ? kCFCompareLessThan : kCFCompareGreaterThan;
+    if (s2 < s1) return !swapResult ? kCFCompareGreaterThan : kCFCompareLessThan;
+    // at this point, we know the signs are the same; do not combine these tests
+    __CFNumberGetValue(number2, kCFNumberFloat64Type, &d2);
+    if (d1 < d2) return !swapResult ? kCFCompareLessThan : kCFCompareGreaterThan;
+    if (d2 < d1) return !swapResult ? kCFCompareGreaterThan : kCFCompareLessThan;
+    return kCFCompareEqualTo;
+}
+
+CFComparisonResult CFNumberCompare(CFNumberRef number1, CFNumberRef number2, void *context) {
+//printf("+ [%p] CFNumberCompare(%p, %p, %p)\n", pthread_self(), number1, number2, context);
+    CFComparisonResult r = CFNumberCompare_new(number1, number2, context);
+//printf("  => %d\n", r);
+    return r;
+}
+
+#undef __CFAssertIsBoolean
+#undef __CFAssertIsNumber
+#undef __CFAssertIsValidNumberType
+#undef BITSFORDOUBLENAN
+#undef BITSFORDOUBLEPOSINF
+#undef BITSFORDOUBLENEGINF
+#undef MinCachedInt
+#undef MaxCachedInt
+#undef NotToBeCached
+
diff --git a/CoreFoundation/CFNumber.h b/CoreFoundation/CFNumber.h
new file mode 100644
index 0000000..c8152dc
--- /dev/null
+++ b/CoreFoundation/CFNumber.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFNUMBER__)
+#define __COREFOUNDATION_CFNUMBER__ 1
+
+#include <CoreFoundation/CFBase.h>
+
+CF_EXTERN_C_BEGIN
+
+typedef const struct __CFBoolean * CFBooleanRef;
+
+CF_EXPORT
+const CFBooleanRef kCFBooleanTrue;
+CF_EXPORT
+const CFBooleanRef kCFBooleanFalse;
+
+CF_EXPORT
+CFTypeID CFBooleanGetTypeID(void);
+
+CF_EXPORT
+Boolean CFBooleanGetValue(CFBooleanRef boolean);
+
+enum {
+    /* 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,
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+    kCFNumberNSIntegerType = 15,
+    kCFNumberCGFloatType = 16,
+    kCFNumberMaxType = 16
+#else
+    kCFNumberMaxType = 14
+#endif
+};
+typedef CFIndex CFNumberType;
+
+typedef const struct __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
+
+#endif /* ! __COREFOUNDATION_CFNUMBER__ */
+
diff --git a/CoreFoundation/CFNumberFormatter.c b/CoreFoundation/CFNumberFormatter.c
new file mode 100644
index 0000000..2758871
--- /dev/null
+++ b/CoreFoundation/CFNumberFormatter.c
@@ -0,0 +1,1007 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 2002-2003, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFNumberFormatter.h>
+#include "CFInternal.h"
+#include <unicode/unum.h>
+#include <unicode/ucurr.h>
+#include <math.h>
+#include <float.h>
+
+static void __CFNumberFormatterCustomize(CFNumberFormatterRef formatter);
+
+#define BUFFER_SIZE 768
+
+struct __CFNumberFormatter {
+    CFRuntimeBase _base;
+    UNumberFormat *_nf;
+    CFLocaleRef _locale;
+    CFNumberFormatterStyle _style;
+    CFStringRef _format;	// NULL for RBNFs
+    CFStringRef _defformat;
+    CFNumberRef _multiplier;
+    CFStringRef _zeroSym;
+};
+
+static CFStringRef __CFNumberFormatterCopyDescription(CFTypeRef cf) {
+    CFNumberFormatterRef formatter = (CFNumberFormatterRef)cf;
+    return CFStringCreateWithFormat(CFGetAllocator(formatter), NULL, CFSTR("<CFNumberFormatter %p [%p]>"), cf, CFGetAllocator(formatter));
+}
+
+static void __CFNumberFormatterDeallocate(CFTypeRef cf) {
+    CFNumberFormatterRef formatter = (CFNumberFormatterRef)cf;
+    if (formatter->_nf) unum_close(formatter->_nf);
+    if (formatter->_locale) CFRelease(formatter->_locale);
+    if (formatter->_format) CFRelease(formatter->_format);
+    if (formatter->_defformat) CFRelease(formatter->_defformat);
+    if (formatter->_multiplier) CFRelease(formatter->_multiplier);
+    if (formatter->_zeroSym) CFRelease(formatter->_zeroSym);
+}
+
+static CFTypeID __kCFNumberFormatterTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFNumberFormatterClass = {
+    0,
+    "CFNumberFormatter",
+    NULL,	// init
+    NULL,	// copy
+    __CFNumberFormatterDeallocate,
+    NULL,
+    NULL,
+    NULL,	// 
+    __CFNumberFormatterCopyDescription
+};
+
+static void __CFNumberFormatterInitialize(void) {
+    __kCFNumberFormatterTypeID = _CFRuntimeRegisterClass(&__CFNumberFormatterClass);
+}
+
+CFTypeID CFNumberFormatterGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFNumberFormatterTypeID) __CFNumberFormatterInitialize();
+    return __kCFNumberFormatterTypeID;
+}
+
+CFNumberFormatterRef CFNumberFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFNumberFormatterStyle style) {
+    struct __CFNumberFormatter *memory;
+    uint32_t size = sizeof(struct __CFNumberFormatter) - sizeof(CFRuntimeBase);
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(locale, CFLocaleGetTypeID());
+    memory = (struct __CFNumberFormatter *)_CFRuntimeCreateInstance(allocator, CFNumberFormatterGetTypeID(), size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    memory->_nf = NULL;
+    memory->_locale = NULL;
+    memory->_format = NULL;
+    memory->_defformat = NULL;
+    memory->_multiplier = NULL;
+    memory->_zeroSym = NULL;
+    if (NULL == locale) locale = CFLocaleGetSystem();
+    memory->_style = style;
+    uint32_t ustyle;
+    switch (style) {
+    case kCFNumberFormatterNoStyle: ustyle = UNUM_IGNORE; break;
+    case kCFNumberFormatterDecimalStyle: ustyle = UNUM_DECIMAL; break;
+    case kCFNumberFormatterCurrencyStyle: ustyle = UNUM_CURRENCY; break;
+    case kCFNumberFormatterPercentStyle: ustyle = UNUM_PERCENT; break;
+    case kCFNumberFormatterScientificStyle: ustyle = UNUM_SCIENTIFIC; break;
+    case kCFNumberFormatterSpellOutStyle: ustyle = UNUM_SPELLOUT; break;
+    default:
+	CFAssert2(0, __kCFLogAssertion, "%s(): unknown style %d", __PRETTY_FUNCTION__, style);
+	ustyle = UNUM_DECIMAL;
+	memory->_style = kCFNumberFormatterDecimalStyle;
+	break;
+    }
+    CFStringRef localeName = locale ? CFLocaleGetIdentifier(locale) : CFSTR("");
+    char buffer[BUFFER_SIZE];
+    const char *cstr = CFStringGetCStringPtr(localeName, kCFStringEncodingASCII);
+    if (NULL == cstr) {
+	if (CFStringGetCString(localeName, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;
+    }
+    if (NULL == cstr) {
+	CFRelease(memory);
+	return NULL;
+    }
+    UErrorCode status = U_ZERO_ERROR;
+    memory->_nf = unum_open((UNumberFormatStyle)ustyle, NULL, 0, cstr, NULL, &status);
+    CFAssert2(memory->_nf, __kCFLogAssertion, "%s(): error (%d) creating number formatter", __PRETTY_FUNCTION__, status);
+    if (NULL == memory->_nf) {
+	CFRelease(memory);
+	return NULL;
+    }
+    UChar ubuff[4];
+    if (kCFNumberFormatterNoStyle == style) {
+        status = U_ZERO_ERROR;
+	ubuff[0] = '#'; ubuff[1] = ';'; ubuff[2] = '#';
+        unum_applyPattern(memory->_nf, false, ubuff, 3, NULL, &status);
+	unum_setAttribute(memory->_nf, UNUM_MAX_INTEGER_DIGITS, 42);
+	unum_setAttribute(memory->_nf, UNUM_MAX_FRACTION_DIGITS, 0);
+    }
+    memory->_locale = locale ? CFLocaleCreateCopy(allocator, locale) : CFLocaleGetSystem();
+    __CFNumberFormatterCustomize(memory);
+    if (kCFNumberFormatterSpellOutStyle != memory->_style) {
+	UChar ubuffer[BUFFER_SIZE];
+	status = U_ZERO_ERROR;
+	int32_t ret = unum_toPattern(memory->_nf, false, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && ret <= BUFFER_SIZE) {
+	    memory->_format = CFStringCreateWithCharacters(allocator, (const UniChar *)ubuffer, ret);
+	}
+    }
+    memory->_defformat = memory->_format ? (CFStringRef)CFRetain(memory->_format) : NULL;
+    if (kCFNumberFormatterSpellOutStyle != memory->_style) {
+	int32_t n = unum_getAttribute(memory->_nf, UNUM_MULTIPLIER);
+	if (1 != n) {
+	    memory->_multiplier = CFNumberCreate(allocator, kCFNumberSInt32Type, &n);
+	    unum_setAttribute(memory->_nf, UNUM_MULTIPLIER, 1);
+	}
+    }
+    return (CFNumberFormatterRef)memory;
+}
+
+extern CFDictionaryRef __CFLocaleGetPrefs(CFLocaleRef locale);
+
+static void __substituteFormatStringFromPrefsNF(CFNumberFormatterRef formatter) {
+    CFIndex formatStyle = formatter->_style;
+    if (kCFNumberFormatterSpellOutStyle == formatStyle) return;
+    CFStringRef prefName = CFSTR("AppleICUNumberFormatStrings");
+    if (kCFNumberFormatterNoStyle != formatStyle) {
+	CFStringRef pref = NULL;
+	CFDictionaryRef prefs = __CFLocaleGetPrefs(formatter->_locale);
+	CFPropertyListRef metapref = prefs ? CFDictionaryGetValue(prefs, prefName) : NULL;
+	if (NULL != metapref && CFGetTypeID(metapref) == CFDictionaryGetTypeID()) {
+	    CFStringRef key;
+	    switch (formatStyle) {
+	    case kCFNumberFormatterDecimalStyle: key = CFSTR("1"); break;
+	    case kCFNumberFormatterCurrencyStyle: key = CFSTR("2"); break;
+	    case kCFNumberFormatterPercentStyle: key = CFSTR("3"); break;
+	    case kCFNumberFormatterScientificStyle: key = CFSTR("4"); break;
+	    case kCFNumberFormatterSpellOutStyle: key = CFSTR("5"); break;
+	    default: key = CFSTR("0"); break;
+	    }
+	    pref = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)metapref, key);
+	}
+	if (NULL != pref && CFGetTypeID(pref) == CFStringGetTypeID()) {
+	    int32_t icustyle = UNUM_IGNORE;
+	    switch (formatStyle) {
+	    case kCFNumberFormatterDecimalStyle: icustyle = UNUM_DECIMAL; break;
+	    case kCFNumberFormatterCurrencyStyle: icustyle = UNUM_CURRENCY; break;
+	    case kCFNumberFormatterPercentStyle: icustyle = UNUM_PERCENT; break;
+	    case kCFNumberFormatterScientificStyle: icustyle = UNUM_SCIENTIFIC; break;
+	    case kCFNumberFormatterSpellOutStyle: icustyle = UNUM_SPELLOUT; break;
+	    }
+	    CFStringRef localeName = CFLocaleGetIdentifier(formatter->_locale);
+	    char buffer[BUFFER_SIZE];
+	    const char *cstr = CFStringGetCStringPtr(localeName, kCFStringEncodingASCII);
+	    if (NULL == cstr) {
+		if (CFStringGetCString(localeName, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;
+	    }
+	    UErrorCode status = U_ZERO_ERROR;
+	    UNumberFormat *nf = unum_open((UNumberFormatStyle)icustyle, NULL, 0, cstr, NULL, &status);
+	    if (NULL != nf) {
+		UChar ubuffer[BUFFER_SIZE];
+		status = U_ZERO_ERROR;
+		int32_t number_len = unum_toPattern(nf, false, ubuffer, BUFFER_SIZE, &status);
+		if (U_SUCCESS(status) && number_len <= BUFFER_SIZE) {
+		    CFStringRef numberString = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (const UniChar *)ubuffer, number_len);
+		    status = U_ZERO_ERROR;
+		    int32_t formatter_len = unum_toPattern(formatter->_nf, false, ubuffer, BUFFER_SIZE, &status);
+		    if (U_SUCCESS(status) && formatter_len <= BUFFER_SIZE) {
+			CFMutableStringRef formatString = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+			CFStringAppendCharacters(formatString, (const UniChar *)ubuffer, formatter_len);
+			// find numberString inside formatString, substitute the pref in that range
+			CFRange result;
+			if (CFStringFindWithOptions(formatString, numberString, CFRangeMake(0, formatter_len), 0, &result)) {
+			    CFStringReplace(formatString, result, pref);
+			    int32_t new_len = CFStringGetLength(formatString);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+             STACK_BUFFER_DECL(UChar, new_buffer, new_len);
+#else
+             UChar new_buffer[BUFFER_SIZE];
+#endif
+			    const UChar *new_ustr = (const UChar *)CFStringGetCharactersPtr(formatString);
+			    if (NULL == new_ustr) {
+                 CFStringGetCharacters(formatString, CFRangeMake(0, new_len), (UniChar *)new_buffer);
+                 new_ustr = new_buffer;
+			    }
+			    status = U_ZERO_ERROR;
+			    unum_applyPattern(formatter->_nf, false, new_ustr, new_len, NULL, &status);
+			}
+			CFRelease(formatString);
+		    }
+		    CFRelease(numberString);
+		}
+		unum_close(nf);
+	    }
+	}
+    }
+}
+
+static void __CFNumberFormatterApplySymbolPrefs(const void *key, const void *value, void *context) {
+    if (CFGetTypeID(key) == CFStringGetTypeID() && CFGetTypeID(value) == CFStringGetTypeID()) {
+	CFNumberFormatterRef formatter = (CFNumberFormatterRef)context;
+	UNumberFormatSymbol sym = (UNumberFormatSymbol)CFStringGetIntValue((CFStringRef)key);
+	CFStringRef item = (CFStringRef)value;
+	CFIndex item_cnt = CFStringGetLength(item);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+	STACK_BUFFER_DECL(UChar, item_buffer, item_cnt);
+#else
+    UChar item_buffer[BUFFER_SIZE];
+#endif
+	UChar *item_ustr = (UChar *)CFStringGetCharactersPtr(item);
+	if (NULL == item_ustr) {
+	    CFStringGetCharacters(item, CFRangeMake(0, __CFMin(BUFFER_SIZE, item_cnt)), (UniChar *)item_buffer);
+	    item_ustr = item_buffer;
+	}
+	UErrorCode status = U_ZERO_ERROR;
+	unum_setSymbol(formatter->_nf, sym, item_ustr, item_cnt, &status);
+   }
+}
+
+static void __CFNumberFormatterCustomize(CFNumberFormatterRef formatter) {
+    __substituteFormatStringFromPrefsNF(formatter);
+    CFDictionaryRef prefs = __CFLocaleGetPrefs(formatter->_locale);
+    CFPropertyListRef metapref = prefs ? CFDictionaryGetValue(prefs, CFSTR("AppleICUNumberSymbols")) : NULL;
+    if (NULL != metapref && CFGetTypeID(metapref) == CFDictionaryGetTypeID()) {
+	CFDictionaryApplyFunction((CFDictionaryRef)metapref, __CFNumberFormatterApplySymbolPrefs, formatter);
+    }
+}
+
+CFLocaleRef CFNumberFormatterGetLocale(CFNumberFormatterRef formatter) {
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    return formatter->_locale;
+}
+
+CFNumberFormatterStyle CFNumberFormatterGetStyle(CFNumberFormatterRef formatter) {
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    return formatter->_style;
+}
+
+CFStringRef CFNumberFormatterGetFormat(CFNumberFormatterRef formatter) {
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    if (kCFNumberFormatterSpellOutStyle == formatter->_style) return NULL;
+    UChar ubuffer[BUFFER_SIZE];
+    CFStringRef newString = NULL;
+    UErrorCode status = U_ZERO_ERROR;
+    int32_t ret = unum_toPattern(formatter->_nf, false, ubuffer, BUFFER_SIZE, &status);
+    if (U_SUCCESS(status) && ret <= BUFFER_SIZE) {
+	newString = CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, ret);
+    }
+    if (newString && !formatter->_format) {
+	formatter->_format = newString;
+    } else if (newString && !CFEqual(newString, formatter->_format)) {
+	CFRelease(formatter->_format);
+	formatter->_format = newString;
+    } else if (newString) {
+	CFRelease(newString);
+    }
+    return formatter->_format;
+}
+
+void CFNumberFormatterSetFormat(CFNumberFormatterRef formatter, CFStringRef formatString) {
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    __CFGenericValidateType(formatString, CFStringGetTypeID());
+    if (kCFNumberFormatterSpellOutStyle == formatter->_style) return;
+    CFIndex cnt = CFStringGetLength(formatString);
+    CFAssert1(cnt <= 1024, __kCFLogAssertion, "%s(): format string too long", __PRETTY_FUNCTION__);
+    if ((!formatter->_format || !CFEqual(formatter->_format, formatString)) && cnt <= 1024) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+	STACK_BUFFER_DECL(UChar, ubuffer, cnt);
+#else
+    UChar ubuffer[BUFFER_SIZE];
+#endif
+	const UChar *ustr = (const UChar *)CFStringGetCharactersPtr(formatString);
+	if (NULL == ustr) {
+	    CFStringGetCharacters(formatString, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	    ustr = ubuffer;
+	}
+	UErrorCode status = U_ZERO_ERROR;
+	unum_applyPattern(formatter->_nf, false, ustr, cnt, NULL, &status);
+	if (U_SUCCESS(status)) {
+	    if (formatter->_format) CFRelease(formatter->_format);
+	    UChar ubuffer2[BUFFER_SIZE];
+	    status = U_ZERO_ERROR;
+	    int32_t ret = unum_toPattern(formatter->_nf, false, ubuffer2, BUFFER_SIZE, &status);
+	    if (U_SUCCESS(status) && ret <= BUFFER_SIZE) {
+		formatter->_format = CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer2, ret);
+	    }
+	}
+    }
+}
+
+CFStringRef CFNumberFormatterCreateStringWithNumber(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFNumberRef number) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    __CFGenericValidateType(number, CFNumberGetTypeID());
+    CFNumberType type = CFNumberGetType(number);
+    char buffer[64];
+    CFNumberGetValue(number, type, buffer);
+    return CFNumberFormatterCreateStringWithValue(allocator, formatter, type, buffer);
+}
+
+#define FORMAT(T, FUNC)							\
+	T value = *(T *)valuePtr;					\
+	if (0 == value && formatter->_zeroSym) { return (CFStringRef)CFRetain(formatter->_zeroSym); }	\
+	if (1.0 != multiplier) value = (T)(value * multiplier);		\
+	status = U_ZERO_ERROR;						\
+	used = FUNC(formatter->_nf, value, ubuffer, cnt, NULL, &status); \
+	if (status == U_BUFFER_OVERFLOW_ERROR || cnt < used) {		\
+	    cnt = used + 1;						\
+	    ustr = (UChar *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(UChar) * cnt, 0); \
+	    status = U_ZERO_ERROR;					\
+	    used = FUNC(formatter->_nf, value, ustr, cnt, NULL, &status); \
+	}
+
+CFStringRef CFNumberFormatterCreateStringWithValue(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFNumberType numberType, const void *valuePtr) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    double multiplier = 1.0;
+    if (formatter->_multiplier) {
+	if (!CFNumberGetValue(formatter->_multiplier, kCFNumberFloat64Type, &multiplier)) {
+	    multiplier = 1.0;
+	}
+    }
+    UChar *ustr = NULL, ubuffer[BUFFER_SIZE];
+    UErrorCode status = U_ZERO_ERROR;
+    CFIndex used, cnt = BUFFER_SIZE;
+    if (numberType == kCFNumberFloat64Type || numberType == kCFNumberDoubleType) {
+	FORMAT(double, unum_formatDouble)
+    } else if (numberType == kCFNumberFloat32Type || numberType == kCFNumberFloatType) {
+	FORMAT(float, unum_formatDouble)
+    } else if (numberType == kCFNumberSInt64Type || numberType == kCFNumberLongLongType) {
+	FORMAT(int64_t, unum_formatInt64)
+    } else if (numberType == kCFNumberLongType || numberType == kCFNumberCFIndexType) {
+#if __LP64__
+	FORMAT(int64_t, unum_formatInt64)
+#else
+	FORMAT(int32_t, unum_formatInt64)
+#endif
+    } else if (numberType == kCFNumberSInt32Type || numberType == kCFNumberIntType) {
+	FORMAT(int32_t, unum_formatInt64)
+    } else if (numberType == kCFNumberSInt16Type || numberType == kCFNumberShortType) {
+	FORMAT(int16_t, unum_formatInt64)
+    } else if (numberType == kCFNumberSInt8Type || numberType == kCFNumberCharType) {
+	FORMAT(int8_t, unum_formatInt64)
+    } else {
+	CFAssert2(0, __kCFLogAssertion, "%s(): unknown CFNumberType (%d)", __PRETTY_FUNCTION__, numberType);
+	return NULL;
+    }
+    CFStringRef string = NULL;
+    if (U_SUCCESS(status)) {
+	string = CFStringCreateWithCharacters(allocator, ustr ? (const UniChar *)ustr : (const UniChar *)ubuffer, used);
+    }
+    if (ustr) CFAllocatorDeallocate(kCFAllocatorSystemDefault, ustr);
+    return string;
+}
+
+#undef FORMAT
+
+CFNumberRef CFNumberFormatterCreateNumberFromString(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFOptionFlags options) {
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    __CFGenericValidateType(string, CFStringGetTypeID());
+    CFNumberType type = (options & kCFNumberFormatterParseIntegersOnly) ? kCFNumberSInt64Type : kCFNumberFloat64Type;
+    char buffer[16];
+    if (CFNumberFormatterGetValueFromString(formatter, string, rangep, type, buffer)) {
+	return CFNumberCreate(allocator, type, buffer);
+    }
+    return NULL;
+}
+
+Boolean CFNumberFormatterGetValueFromString(CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFNumberType numberType, void *valuePtr) {
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    __CFGenericValidateType(string, CFStringGetTypeID());
+    Boolean isZero = false;
+    CFRange range = {0, 0};
+    if (rangep) {
+        range = *rangep;
+    } else {
+        range.length = CFStringGetLength(string);
+    }
+    if (formatter->_zeroSym && kCFCompareEqualTo == CFStringCompareWithOptions(string, formatter->_zeroSym, range, 0)) {
+        isZero = true;
+    }
+    if (1024 < range.length) range.length = 1024;
+    const UChar *ustr = (const UChar *)CFStringGetCharactersPtr(string);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(UChar, ubuffer, (NULL == ustr) ? range.length : 1);
+#else
+    UChar ubuffer[1024];
+#endif
+    if (NULL == ustr) {
+        CFStringGetCharacters(string, range, (UniChar *)ubuffer);
+        ustr = ubuffer;
+    } else {
+        ustr += range.location;
+    }
+    Boolean integerOnly = 1;
+    switch (numberType) {
+    case kCFNumberSInt8Type: case kCFNumberCharType:
+    case kCFNumberSInt16Type: case kCFNumberShortType:
+    case kCFNumberSInt32Type: case kCFNumberIntType:
+    case kCFNumberLongType: case kCFNumberCFIndexType:
+    case kCFNumberSInt64Type: case kCFNumberLongLongType:
+	unum_setAttribute(formatter->_nf, UNUM_PARSE_INT_ONLY, 1);
+	break;
+    default:
+	unum_setAttribute(formatter->_nf, UNUM_PARSE_INT_ONLY, 0);
+	integerOnly = 0;
+	break;
+    }
+    int32_t dpos = 0;
+    UErrorCode status = U_ZERO_ERROR;
+    int64_t dreti = 0;
+    double dretd = 0.0;
+    if (isZero) {
+	dpos = rangep ? rangep->length : 0;
+    } else {
+	if (integerOnly) {
+	    dreti = unum_parseInt64(formatter->_nf, ustr, range.length, &dpos, &status);
+	} else {
+	    dretd = unum_parseDouble(formatter->_nf, ustr, range.length, &dpos, &status);
+	}
+    }
+    if (rangep) rangep->length = dpos;
+    if (U_FAILURE(status)) {
+	return false;
+    }
+    if (formatter->_multiplier) {
+        double multiplier = 1.0;
+        if (!CFNumberGetValue(formatter->_multiplier, kCFNumberFloat64Type, &multiplier)) {
+            multiplier = 1.0;
+        }
+        dreti = (int64_t)((double)dreti / multiplier); // integer truncation
+        dretd = dretd / multiplier;
+    }
+    switch (numberType) {
+    case kCFNumberSInt8Type: case kCFNumberCharType:
+	if (INT8_MIN <= dreti && dreti <= INT8_MAX) {
+	    *(int8_t *)valuePtr = (int8_t)dreti;
+	    return true;
+	}
+	break;
+    case kCFNumberSInt16Type: case kCFNumberShortType:
+	if (INT16_MIN <= dreti && dreti <= INT16_MAX) {
+	    *(int16_t *)valuePtr = (int16_t)dreti;
+	    return true;
+	}
+	break;
+    case kCFNumberSInt32Type: case kCFNumberIntType:
+#if !__LP64__
+    case kCFNumberLongType: case kCFNumberCFIndexType:
+#endif
+	if (INT32_MIN <= dreti && dreti <= INT32_MAX) {
+	    *(int32_t *)valuePtr = (int32_t)dreti;
+	    return true;
+	}
+	break;
+    case kCFNumberSInt64Type: case kCFNumberLongLongType:
+#if __LP64__
+    case kCFNumberLongType: case kCFNumberCFIndexType:
+#endif
+	if (INT64_MIN <= dreti && dreti <= INT64_MAX) {
+	    *(int64_t *)valuePtr = (int64_t)dreti;
+	    return true;
+	}
+	break;
+    case kCFNumberFloat32Type: case kCFNumberFloatType:
+	if (-FLT_MAX <= dretd && dretd <= FLT_MAX) {
+	    *(float *)valuePtr = (float)dretd;
+	    return true;
+	}
+	break;
+    case kCFNumberFloat64Type: case kCFNumberDoubleType:
+	if (-DBL_MAX <= dretd && dretd <= DBL_MAX) {
+	    *(double *)valuePtr = (double)dretd;
+	    return true;
+	}
+	break;
+    }
+    return false;
+}
+
+void CFNumberFormatterSetProperty(CFNumberFormatterRef formatter, CFStringRef key, CFTypeRef value) {
+    int32_t n;
+    double d;
+    UErrorCode status = U_ZERO_ERROR;
+    UChar ubuffer[BUFFER_SIZE];
+    CFIndex cnt;
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    __CFGenericValidateType(key, CFStringGetTypeID());
+    if (kCFNumberFormatterCurrencyCode == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setTextAttribute(formatter->_nf, UNUM_CURRENCY_CODE, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterDecimalSeparator == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_DECIMAL_SEPARATOR_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterCurrencyDecimalSeparator == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_MONETARY_SEPARATOR_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterAlwaysShowDecimalSeparator == key) {
+	__CFGenericValidateType(value, CFBooleanGetTypeID());
+	unum_setAttribute(formatter->_nf, UNUM_DECIMAL_ALWAYS_SHOWN, (kCFBooleanTrue == value));
+    } else if (kCFNumberFormatterGroupingSeparator == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_GROUPING_SEPARATOR_SYMBOL, (const UChar *)ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterUseGroupingSeparator == key) {
+	__CFGenericValidateType(value, CFBooleanGetTypeID());
+	unum_setAttribute(formatter->_nf, UNUM_GROUPING_USED, (kCFBooleanTrue == value));
+    } else if (kCFNumberFormatterPercentSymbol == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_PERCENT_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterZeroSymbol == key) {
+        __CFGenericValidateType(value, CFStringGetTypeID());
+        CFStringRef old = formatter->_zeroSym;
+        formatter->_zeroSym = value ? (CFStringRef)CFRetain(value) : NULL;
+        if (old) CFRelease(old);
+    } else if (kCFNumberFormatterNaNSymbol == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_NAN_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterInfinitySymbol == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_INFINITY_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterMinusSign == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_MINUS_SIGN_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterPlusSign == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_PLUS_SIGN_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterCurrencySymbol == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_CURRENCY_SYMBOL, (const UChar *)ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterExponentSymbol == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setSymbol(formatter->_nf, UNUM_EXPONENTIAL_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterMinIntegerDigits == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_MIN_INTEGER_DIGITS, n);
+    } else if (kCFNumberFormatterMaxIntegerDigits == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_MAX_INTEGER_DIGITS, n);
+    } else if (kCFNumberFormatterMinFractionDigits == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_MIN_FRACTION_DIGITS, n);
+    } else if (kCFNumberFormatterMaxFractionDigits == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_MAX_FRACTION_DIGITS, n);
+    } else if (kCFNumberFormatterGroupingSize == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_GROUPING_SIZE, n);
+    } else if (kCFNumberFormatterSecondaryGroupingSize == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_SECONDARY_GROUPING_SIZE, n);
+    } else if (kCFNumberFormatterRoundingMode == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_ROUNDING_MODE, n);
+    } else if (kCFNumberFormatterRoundingIncrement == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberDoubleType, &d);
+	unum_setDoubleAttribute(formatter->_nf, UNUM_ROUNDING_INCREMENT, d);
+    } else if (kCFNumberFormatterFormatWidth == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_FORMAT_WIDTH, n);
+    } else if (kCFNumberFormatterPaddingPosition == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_PADDING_POSITION, n);
+    } else if (kCFNumberFormatterPaddingCharacter == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setTextAttribute(formatter->_nf, UNUM_PADDING_CHARACTER, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterDefaultFormat == key) {
+	// read-only attribute
+    } else if (kCFNumberFormatterMultiplier == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+        CFNumberRef old = formatter->_multiplier;
+        formatter->_multiplier = value ? (CFNumberRef)CFRetain(value) : NULL;
+        if (old) CFRelease(old);
+    } else if (kCFNumberFormatterPositivePrefix == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setTextAttribute(formatter->_nf, UNUM_POSITIVE_PREFIX, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterPositiveSuffix == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setTextAttribute(formatter->_nf, UNUM_POSITIVE_SUFFIX, (const UChar *)ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterNegativePrefix == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setTextAttribute(formatter->_nf, UNUM_NEGATIVE_PREFIX, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterNegativeSuffix == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+	cnt = CFStringGetLength((CFStringRef)value);
+	if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+	CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+	unum_setTextAttribute(formatter->_nf, UNUM_NEGATIVE_SUFFIX, (const UChar *)ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterPerMillSymbol == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+        cnt = CFStringGetLength((CFStringRef)value);
+        if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+        CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+        unum_setSymbol(formatter->_nf, UNUM_PERMILL_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterInternationalCurrencySymbol == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+        cnt = CFStringGetLength((CFStringRef)value);
+        if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+        CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+        unum_setSymbol(formatter->_nf, UNUM_INTL_CURRENCY_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterCurrencyGroupingSeparator == key) {
+	__CFGenericValidateType(value, CFStringGetTypeID());
+        cnt = CFStringGetLength((CFStringRef)value);
+        if (BUFFER_SIZE < cnt) cnt = BUFFER_SIZE;
+        CFStringGetCharacters((CFStringRef)value, CFRangeMake(0, cnt), (UniChar *)ubuffer);
+        unum_setSymbol(formatter->_nf, UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL, ubuffer, cnt, &status);
+    } else if (kCFNumberFormatterIsLenient == key) {
+	__CFGenericValidateType(value, CFBooleanGetTypeID());
+	unum_setAttribute(formatter->_nf, UNUM_LENIENT_PARSE, (kCFBooleanTrue == value));
+    } else if (kCFNumberFormatterUseSignificantDigits == key) {
+	__CFGenericValidateType(value, CFBooleanGetTypeID());
+	unum_setAttribute(formatter->_nf, UNUM_SIGNIFICANT_DIGITS_USED, (kCFBooleanTrue == value));
+    } else if (kCFNumberFormatterMinSignificantDigits == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_MIN_SIGNIFICANT_DIGITS, n);
+    } else if (kCFNumberFormatterMaxSignificantDigits == key) {
+	__CFGenericValidateType(value, CFNumberGetTypeID());
+	CFNumberGetValue((CFNumberRef)value, kCFNumberSInt32Type, &n);
+	unum_setAttribute(formatter->_nf, UNUM_MAX_SIGNIFICANT_DIGITS, n);
+    } else {
+	CFAssert3(0, __kCFLogAssertion, "%s(): unknown key %p (%@)", __PRETTY_FUNCTION__, key, key);
+    }
+}
+
+CFTypeRef CFNumberFormatterCopyProperty(CFNumberFormatterRef formatter, CFStringRef key) {
+    int32_t n;
+    double d;
+    UErrorCode status = U_ZERO_ERROR;
+    UChar ubuffer[BUFFER_SIZE];
+    CFIndex cnt;
+    __CFGenericValidateType(formatter, CFNumberFormatterGetTypeID());
+    __CFGenericValidateType(key, CFStringGetTypeID());
+    if (kCFNumberFormatterCurrencyCode == key) {
+	cnt = unum_getTextAttribute(formatter->_nf, UNUM_CURRENCY_CODE, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt == 0) {
+	    CFStringRef localeName = CFLocaleGetIdentifier(formatter->_locale);
+	    char buffer[BUFFER_SIZE];
+	    const char *cstr = CFStringGetCStringPtr(localeName, kCFStringEncodingASCII);
+	    if (NULL == cstr) {
+		if (CFStringGetCString(localeName, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;
+	    }
+	    if (NULL == cstr) {
+	        return NULL;
+	    }
+	    UErrorCode status = U_ZERO_ERROR;
+	    UNumberFormat *nf = unum_open(UNUM_CURRENCY, NULL, 0, cstr, NULL, &status);
+	    if (NULL != nf) {
+		cnt = unum_getTextAttribute(nf, UNUM_CURRENCY_CODE, ubuffer, BUFFER_SIZE, &status);
+		unum_close(nf);
+	    }
+	}
+	if (U_SUCCESS(status) && 0 < cnt && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterDecimalSeparator == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_DECIMAL_SEPARATOR_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterCurrencyDecimalSeparator == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_MONETARY_SEPARATOR_SYMBOL, (UChar *)ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterAlwaysShowDecimalSeparator == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_DECIMAL_ALWAYS_SHOWN);
+	if (1) {
+	    return CFRetain(n ? kCFBooleanTrue : kCFBooleanFalse);
+	}
+    } else if (kCFNumberFormatterGroupingSeparator == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_GROUPING_SEPARATOR_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterUseGroupingSeparator == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_GROUPING_USED);
+	if (1) {
+	    return CFRetain(n ? kCFBooleanTrue : kCFBooleanFalse);
+	}
+   } else if (kCFNumberFormatterPercentSymbol == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_PERCENT_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterZeroSymbol == key) {
+        return formatter->_zeroSym ? CFRetain(formatter->_zeroSym) : NULL;
+    } else if (kCFNumberFormatterNaNSymbol == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_NAN_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterInfinitySymbol == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_INFINITY_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterMinusSign == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_MINUS_SIGN_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterPlusSign == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_PLUS_SIGN_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterCurrencySymbol == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_CURRENCY_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterExponentSymbol == key) {
+	cnt = unum_getSymbol(formatter->_nf, UNUM_EXPONENTIAL_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterMinIntegerDigits == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_MIN_INTEGER_DIGITS);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterMaxIntegerDigits == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_MAX_INTEGER_DIGITS);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterMinFractionDigits == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_MIN_FRACTION_DIGITS);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterMaxFractionDigits == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_MAX_FRACTION_DIGITS);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterGroupingSize == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_GROUPING_SIZE);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterSecondaryGroupingSize == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_SECONDARY_GROUPING_SIZE);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterRoundingMode == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_ROUNDING_MODE);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterRoundingIncrement == key) {
+	d = unum_getDoubleAttribute(formatter->_nf, UNUM_ROUNDING_INCREMENT);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberDoubleType, &d);
+	}
+    } else if (kCFNumberFormatterFormatWidth == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_FORMAT_WIDTH);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterPaddingPosition == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_PADDING_POSITION);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterPaddingCharacter == key) {
+	cnt = unum_getTextAttribute(formatter->_nf, UNUM_PADDING_CHARACTER, ubuffer, BUFFER_SIZE, &status);
+	if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+	    return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+	}
+    } else if (kCFNumberFormatterDefaultFormat == key) {
+	return formatter->_defformat ? CFRetain(formatter->_defformat) : NULL;
+    } else if (kCFNumberFormatterMultiplier == key) {
+        return formatter->_multiplier ? CFRetain(formatter->_multiplier) : NULL;
+    } else if (kCFNumberFormatterPositivePrefix == key) {
+        cnt = unum_getTextAttribute(formatter->_nf, UNUM_POSITIVE_PREFIX, ubuffer, BUFFER_SIZE, &status);
+        if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+            return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+        }
+    } else if (kCFNumberFormatterPositiveSuffix == key) {
+        cnt = unum_getTextAttribute(formatter->_nf, UNUM_POSITIVE_SUFFIX, ubuffer, BUFFER_SIZE, &status);
+        if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+            return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+        }
+    } else if (kCFNumberFormatterNegativePrefix == key) {
+        cnt = unum_getTextAttribute(formatter->_nf, UNUM_NEGATIVE_PREFIX, ubuffer, BUFFER_SIZE, &status);
+        if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+            return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+        }
+    } else if (kCFNumberFormatterNegativeSuffix == key) {
+        cnt = unum_getTextAttribute(formatter->_nf, UNUM_NEGATIVE_SUFFIX, ubuffer, BUFFER_SIZE, &status);
+        if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+            return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+        }
+    } else if (kCFNumberFormatterPerMillSymbol == key) {
+        cnt = unum_getSymbol(formatter->_nf, UNUM_PERMILL_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+        if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+            return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+        }
+    } else if (kCFNumberFormatterInternationalCurrencySymbol == key) {
+        cnt = unum_getSymbol(formatter->_nf, UNUM_INTL_CURRENCY_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+        if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+            return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+        }
+    } else if (kCFNumberFormatterCurrencyGroupingSeparator == key) {
+        cnt = unum_getSymbol(formatter->_nf, UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL, ubuffer, BUFFER_SIZE, &status);
+        if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+            return CFStringCreateWithCharacters(CFGetAllocator(formatter), (const UniChar *)ubuffer, cnt);
+        }
+    } else if (kCFNumberFormatterIsLenient == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_LENIENT_PARSE);
+	if (1) {
+	    return CFRetain(n ? kCFBooleanTrue : kCFBooleanFalse);
+	}
+    } else if (kCFNumberFormatterUseSignificantDigits == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_SIGNIFICANT_DIGITS_USED);
+	if (1) {
+	    return CFRetain(n ? kCFBooleanTrue : kCFBooleanFalse);
+	}
+    } else if (kCFNumberFormatterMinSignificantDigits == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_MIN_SIGNIFICANT_DIGITS);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else if (kCFNumberFormatterMaxSignificantDigits == key) {
+	n = unum_getAttribute(formatter->_nf, UNUM_MAX_SIGNIFICANT_DIGITS);
+	if (1) {
+	    return CFNumberCreate(CFGetAllocator(formatter), kCFNumberSInt32Type, &n);
+	}
+    } else {
+	CFAssert3(0, __kCFLogAssertion, "%s(): unknown key %p (%@)", __PRETTY_FUNCTION__, key, key);
+    }
+    return NULL;
+}
+
+CONST_STRING_DECL(kCFNumberFormatterCurrencyCode, "kCFNumberFormatterCurrencyCode")
+CONST_STRING_DECL(kCFNumberFormatterDecimalSeparator, "kCFNumberFormatterDecimalSeparator")
+CONST_STRING_DECL(kCFNumberFormatterCurrencyDecimalSeparator, "kCFNumberFormatterCurrencyDecimalSeparator")
+CONST_STRING_DECL(kCFNumberFormatterAlwaysShowDecimalSeparator, "kCFNumberFormatterAlwaysShowDecimalSeparator")
+CONST_STRING_DECL(kCFNumberFormatterGroupingSeparator, "kCFNumberFormatterGroupingSeparator")
+CONST_STRING_DECL(kCFNumberFormatterUseGroupingSeparator, "kCFNumberFormatterUseGroupingSeparator")
+CONST_STRING_DECL(kCFNumberFormatterPercentSymbol, "kCFNumberFormatterPercentSymbol")
+CONST_STRING_DECL(kCFNumberFormatterZeroSymbol, "kCFNumberFormatterZeroSymbol")
+CONST_STRING_DECL(kCFNumberFormatterNaNSymbol, "kCFNumberFormatterNaNSymbol")
+CONST_STRING_DECL(kCFNumberFormatterInfinitySymbol, "kCFNumberFormatterInfinitySymbol")
+CONST_STRING_DECL(kCFNumberFormatterMinusSign, "kCFNumberFormatterMinusSignSymbol")
+CONST_STRING_DECL(kCFNumberFormatterPlusSign, "kCFNumberFormatterPlusSignSymbol")
+CONST_STRING_DECL(kCFNumberFormatterCurrencySymbol, "kCFNumberFormatterCurrencySymbol")
+CONST_STRING_DECL(kCFNumberFormatterExponentSymbol, "kCFNumberFormatterExponentSymbol")
+CONST_STRING_DECL(kCFNumberFormatterMinIntegerDigits, "kCFNumberFormatterMinIntegerDigits")
+CONST_STRING_DECL(kCFNumberFormatterMaxIntegerDigits, "kCFNumberFormatterMaxIntegerDigits")
+CONST_STRING_DECL(kCFNumberFormatterMinFractionDigits, "kCFNumberFormatterMinFractionDigits")
+CONST_STRING_DECL(kCFNumberFormatterMaxFractionDigits, "kCFNumberFormatterMaxFractionDigits")
+CONST_STRING_DECL(kCFNumberFormatterGroupingSize, "kCFNumberFormatterGroupingSize")
+CONST_STRING_DECL(kCFNumberFormatterSecondaryGroupingSize, "kCFNumberFormatterSecondaryGroupingSize")
+CONST_STRING_DECL(kCFNumberFormatterRoundingMode, "kCFNumberFormatterRoundingMode")
+CONST_STRING_DECL(kCFNumberFormatterRoundingIncrement, "kCFNumberFormatterRoundingIncrement")
+CONST_STRING_DECL(kCFNumberFormatterFormatWidth, "kCFNumberFormatterFormatWidth")
+CONST_STRING_DECL(kCFNumberFormatterPaddingPosition, "kCFNumberFormatterPaddingPosition")
+CONST_STRING_DECL(kCFNumberFormatterPaddingCharacter, "kCFNumberFormatterPaddingCharacter")
+CONST_STRING_DECL(kCFNumberFormatterDefaultFormat, "kCFNumberFormatterDefaultFormat")
+
+CONST_STRING_DECL(kCFNumberFormatterMultiplier, "kCFNumberFormatterMultiplier")
+CONST_STRING_DECL(kCFNumberFormatterPositivePrefix, "kCFNumberFormatterPositivePrefix")
+CONST_STRING_DECL(kCFNumberFormatterPositiveSuffix, "kCFNumberFormatterPositiveSuffix")
+CONST_STRING_DECL(kCFNumberFormatterNegativePrefix, "kCFNumberFormatterNegativePrefix")
+CONST_STRING_DECL(kCFNumberFormatterNegativeSuffix, "kCFNumberFormatterNegativeSuffix")
+CONST_STRING_DECL(kCFNumberFormatterPerMillSymbol, "kCFNumberFormatterPerMillSymbol")
+CONST_STRING_DECL(kCFNumberFormatterInternationalCurrencySymbol, "kCFNumberFormatterInternationalCurrencySymbol")
+
+CONST_STRING_DECL(kCFNumberFormatterCurrencyGroupingSeparator, "kCFNumberFormatterCurrencyGroupingSeparator")
+CONST_STRING_DECL(kCFNumberFormatterIsLenient, "kCFNumberFormatterIsLenient")
+CONST_STRING_DECL(kCFNumberFormatterUseSignificantDigits, "kCFNumberFormatterUseSignificantDigits")
+CONST_STRING_DECL(kCFNumberFormatterMinSignificantDigits, "kCFNumberFormatterMinSignificantDigits")
+CONST_STRING_DECL(kCFNumberFormatterMaxSignificantDigits, "kCFNumberFormatterMaxSignificantDigits")
+
+Boolean CFNumberFormatterGetDecimalInfoForCurrencyCode(CFStringRef currencyCode, int32_t *defaultFractionDigits, double *roundingIncrement) {
+    UChar ubuffer[4];
+    __CFGenericValidateType(currencyCode, CFStringGetTypeID());
+    CFAssert1(3 == CFStringGetLength(currencyCode), __kCFLogAssertion, "%s(): currencyCode is not 3 characters", __PRETTY_FUNCTION__);
+    CFStringGetCharacters(currencyCode, CFRangeMake(0, 3), (UniChar *)ubuffer);
+    ubuffer[3] = 0;
+    UErrorCode icuStatus = U_ZERO_ERROR;
+    if (defaultFractionDigits) *defaultFractionDigits = ucurr_getDefaultFractionDigits(ubuffer, &icuStatus);
+    if (roundingIncrement) *roundingIncrement = ucurr_getRoundingIncrement(ubuffer, &icuStatus);
+    if (U_FAILURE(icuStatus))
+        return false;
+    return (!defaultFractionDigits || 0 <= *defaultFractionDigits) && (!roundingIncrement || 0.0 <= *roundingIncrement);
+}
+
+#undef BUFFER_SIZE
+
diff --git a/CoreFoundation/CFNumberFormatter.h b/CoreFoundation/CFNumberFormatter.h
new file mode 100644
index 0000000..e453cb9
--- /dev/null
+++ b/CoreFoundation/CFNumberFormatter.h
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFNUMBERFORMATTER__)
+#define __COREFOUNDATION_CFNUMBERFORMATTER__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFLocale.h>
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+
+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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+enum {	// number format styles
+	kCFNumberFormatterNoStyle = 0,
+	kCFNumberFormatterDecimalStyle = 1,
+	kCFNumberFormatterCurrencyStyle = 2,
+	kCFNumberFormatterPercentStyle = 3,
+	kCFNumberFormatterScientificStyle = 4,
+	kCFNumberFormatterSpellOutStyle = 5
+};
+typedef CFIndex CFNumberFormatterStyle;
+
+
+CF_EXPORT
+CFNumberFormatterRef CFNumberFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFNumberFormatterStyle style) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Returns a CFNumberFormatter, localized to the given locale, which
+	// will format numbers to the given style.
+
+CF_EXPORT
+CFLocaleRef CFNumberFormatterGetLocale(CFNumberFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFNumberFormatterStyle CFNumberFormatterGetStyle(CFNumberFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Get the properties with which the number formatter was created.
+
+CF_EXPORT
+CFStringRef CFNumberFormatterGetFormat(CFNumberFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+void CFNumberFormatterSetFormat(CFNumberFormatterRef formatter, CFStringRef formatString) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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 (and Java I believe).
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFStringRef CFNumberFormatterCreateStringWithValue(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFNumberType numberType, const void *valuePtr) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Create a string representation of the given number or value
+	// using the current state of the number formatter.
+
+
+enum {
+    kCFNumberFormatterParseIntegersOnly = 1	/* only parse integers */
+};
+typedef CFOptionFlags CFNumberFormatterOptionFlags;
+
+CF_EXPORT
+CFNumberRef CFNumberFormatterCreateNumberFromString(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFOptionFlags options) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+Boolean CFNumberFormatterGetValueFromString(CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFNumberType numberType, void *valuePtr) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFTypeRef CFNumberFormatterCopyProperty(CFNumberFormatterRef formatter, CFStringRef key) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// Set and get various properties of the number formatter, the set of
+	// which may be expanded in the future.
+
+CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyCode AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterDecimalSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyDecimalSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterAlwaysShowDecimalSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // CFBoolean
+CF_EXPORT const CFStringRef kCFNumberFormatterGroupingSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterUseGroupingSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFBoolean
+CF_EXPORT const CFStringRef kCFNumberFormatterPercentSymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterZeroSymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterNaNSymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterInfinitySymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterMinusSign AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterPlusSign AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterCurrencySymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterExponentSymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterMinIntegerDigits AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterMaxIntegerDigits AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterMinFractionDigits AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterMaxFractionDigits AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterGroupingSize AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterSecondaryGroupingSize AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterRoundingMode AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterRoundingIncrement AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterFormatWidth AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterPaddingPosition AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterPaddingCharacter AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;	// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterDefaultFormat AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterMultiplier AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterPositivePrefix AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterPositiveSuffix AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterNegativePrefix AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterNegativeSuffix AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterPerMillSymbol AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;		// CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterInternationalCurrencySymbol AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyGroupingSeparator AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFString
+CF_EXPORT const CFStringRef kCFNumberFormatterIsLenient AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;		// CFBoolean
+CF_EXPORT const CFStringRef kCFNumberFormatterUseSignificantDigits AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;	// CFBoolean
+CF_EXPORT const CFStringRef kCFNumberFormatterMinSignificantDigits AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;	// CFNumber
+CF_EXPORT const CFStringRef kCFNumberFormatterMaxSignificantDigits AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;	// CFNumber
+
+enum {
+    kCFNumberFormatterRoundCeiling = 0,
+    kCFNumberFormatterRoundFloor = 1,
+    kCFNumberFormatterRoundDown = 2,
+    kCFNumberFormatterRoundUp = 3,
+    kCFNumberFormatterRoundHalfEven = 4,
+    kCFNumberFormatterRoundHalfDown = 5,
+    kCFNumberFormatterRoundHalfUp = 6
+};
+typedef CFIndex CFNumberFormatterRoundingMode;
+
+enum {
+    kCFNumberFormatterPadBeforePrefix = 0,
+    kCFNumberFormatterPadAfterPrefix = 1,
+    kCFNumberFormatterPadBeforeSuffix = 2,
+    kCFNumberFormatterPadAfterSuffix = 3
+};
+typedef CFIndex CFNumberFormatterPadPosition;
+
+
+CF_EXPORT
+Boolean CFNumberFormatterGetDecimalInfoForCurrencyCode(CFStringRef currencyCode, int32_t *defaultFractionDigits, double *roundingIncrement) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+	// 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
+
+#endif
+
+#endif /* ! __COREFOUNDATION_CFNUMBERFORMATTER__ */
+
diff --git a/CoreFoundation/CFPlatform.c b/CoreFoundation/CFPlatform.c
new file mode 100644
index 0000000..23fefd6
--- /dev/null
+++ b/CoreFoundation/CFPlatform.c
@@ -0,0 +1,558 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFPlatform.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include "CFInternal.h"
+#include "CFPriv.h"
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#if DEPLOYMENT_TARGET_WINDOWS
+/* In typical fragile fashion, order of include on Windows is important */
+#include <io.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <windows.h>
+#include <tchar.h>
+#ifndef _WIN32_IE
+#define _WIN32_IE 0x0600
+#endif
+#define strdup _strdup
+#include <shlobj.h>
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+extern size_t strlcat(char *dst, const char *src, size_t siz);
+#ifndef SHGFP_TYPE_CURRENT
+#define SHGFP_TYPE_CURRENT 0
+#endif
+#else
+#include <sys/stat.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <stdio.h>
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach-o/dyld.h>
+#include <crt_externs.h>
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+#define kCFPlatformInterfaceStringEncoding	kCFStringEncodingUTF8
+#else
+#define kCFPlatformInterfaceStringEncoding	CFStringGetSystemEncoding()
+#endif
+
+static CFStringRef _CFUserName(void);
+
+#if DEPLOYMENT_TARGET_MACOSX
+// CoreGraphics and LaunchServices are only projects (1 Dec 2006) that use these
+char **_CFArgv(void) { return *_NSGetArgv(); }
+int _CFArgc(void) { return *_NSGetArgc(); }
+#endif
+
+
+__private_extern__ Boolean _CFGetCurrentDirectory(char *path, int maxlen) {
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+    DWORD len = GetCurrentDirectoryA(maxlen, path);
+    return ((0 != len) && (maxlen > 0) && (len + 1 <= (DWORD)maxlen));
+#else
+    return getcwd(path, maxlen) != NULL;
+#endif
+}
+
+static Boolean __CFIsCFM = false;
+
+// If called super early, we just return false
+__private_extern__ Boolean _CFIsCFM(void) {
+    return __CFIsCFM;
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+#define PATH_SEP '\\'
+#else
+#define PATH_SEP '/'
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#define PATH_LIST_SEP ';'
+#else
+#define PATH_LIST_SEP ':'
+#endif
+
+static char *_CFSearchForNameInPath(const char *name, char *path) {
+    struct stat statbuf;
+#if DEPLOYMENT_TARGET_WINDOWS && !defined(__GNUC__)
+    char nname[MAX_PATH + 1];
+#else
+    char nname[strlen(name) + strlen(path) + 2];
+#endif
+#if !DEPLOYMENT_TARGET_WINDOWS
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+#endif
+    for (;;) {
+        char *p = (char *)strchr(path, PATH_LIST_SEP);
+        if (NULL != p) {
+            *p = '\0';
+        }
+        nname[0] = '\0';
+        strlcat(nname, path, sizeof(nname));
+        strlcat(nname, "/", sizeof(nname));
+        strlcat(nname, name, sizeof(nname));
+        // Could also do access(us, X_OK) == 0 in next condition,
+        // for executable-only searching
+        if (0 == stat(nname, &statbuf) && (statbuf.st_mode & S_IFMT) == S_IFREG) {
+            if (p != NULL) {
+                *p = PATH_LIST_SEP;
+            }
+#if !DEPLOYMENT_TARGET_WINDOWS
+           close(no_hang_fd);
+#endif
+           return strdup(nname);
+        }
+        if (NULL == p) {
+            break;
+        }
+        *p = PATH_LIST_SEP;
+        path = p + 1;
+    }
+#if !DEPLOYMENT_TARGET_WINDOWS
+    close(no_hang_fd);
+#endif
+    return NULL;
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS
+// Returns the path to the CF DLL, which we can then use to find resources like char sets
+
+__private_extern__ const char* _CFDLLPath(void) {
+    static char cachedPath[MAX_PATH+1] = "";
+
+    if ('\0' == cachedPath[0]) {
+#if defined(DEBUG)
+        char* DLLFileName = "CoreFoundation_debug";
+#elif defined(PROFILE)
+        char* DLLFileName = "CoreFoundation_profile";
+#else
+        char* DLLFileName = "CoreFoundation";
+#endif
+        HMODULE ourModule = GetModuleHandleA(DLLFileName);
+        CFAssert(ourModule, __kCFLogAssertion, "GetModuleHandle failed");
+
+        DWORD wResult = GetModuleFileNameA(ourModule, cachedPath, MAX_PATH+1);
+        CFAssert1(wResult > 0, __kCFLogAssertion, "GetModuleFileName failed: %d", GetLastError());
+        CFAssert1(wResult < MAX_PATH+1, __kCFLogAssertion, "GetModuleFileName result truncated: %s", cachedPath);
+
+        // strip off last component, the DLL name
+        CFIndex idx;
+        for (idx = wResult - 1; idx; idx--) {
+            if ('\\' == cachedPath[idx]) {
+                cachedPath[idx] = '\0';
+                break;
+            }
+        }
+    }
+    return cachedPath;
+}
+#endif
+
+static const char *__CFProcessPath = NULL;
+static const char *__CFprogname = NULL;
+
+const char **_CFGetProgname(void) {
+    if (!__CFprogname)
+        _CFProcessPath();		// sets up __CFprogname as a side-effect
+    return &__CFprogname;
+}
+
+const char **_CFGetProcessPath(void) {
+    if (!__CFProcessPath)
+        _CFProcessPath();		// sets up __CFProcessPath as a side-effect
+    return &__CFProcessPath;
+}
+
+const char *_CFProcessPath(void) {
+    if (__CFProcessPath) return __CFProcessPath;
+
+    char *thePath = NULL;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+	if (!_CFIsSetUgid()) {
+#else
+    if (!__CFProcessPath) {
+#endif
+        thePath = getenv("CFProcessPath");
+        if (thePath) {
+	         int len = (int)strlen(thePath);
+            __CFProcessPath = (const char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, len+1, 0);
+            if (__CFOASafe) __CFSetLastAllocationEventName((void *)__CFProcessPath, "CFUtilities (process-path)");
+            memmove((char *)__CFProcessPath, thePath, len + 1);
+        }
+    }
+#if DEPLOYMENT_TARGET_WINDOWS
+    if (!__CFProcessPath) {
+        char buf[CFMaxPathSize] = {0};
+        HINSTANCE hinst = GetModuleHandle(NULL);
+        DWORD rlen = hinst ? GetModuleFileNameA(hinst, buf, CFMaxPathSize) : 0;
+	     thePath = rlen ? buf : NULL;
+#elif DEPLOYMENT_TARGET_MACOSX
+    int execIndex = 0;
+    
+    if (!__CFProcessPath && NULL != (*_NSGetArgv())[execIndex]) {
+        int no_hang_fd = open("/dev/autofs_nowait", 0);
+        char buf[CFMaxPathSize] = {0};
+        struct stat statbuf;
+        const char *arg0 = (*_NSGetArgv())[execIndex];
+        if (arg0[0] == '/') {
+            // We've got an absolute path; look no further;
+            thePath = (char *)arg0;
+        } else {
+            char *theList = getenv("PATH");
+            if (NULL != theList && NULL == strrchr(arg0, '/')) {
+                thePath = _CFSearchForNameInPath(arg0, theList);
+                if (thePath) {
+                    // User could have "." or "../bin" or other relative path in $PATH
+                    if (('/' != thePath[0]) && _CFGetCurrentDirectory(buf, CFMaxPathSize)) {
+                        strlcat(buf, "/", sizeof(buf));
+                        strlcat(buf, thePath, sizeof(buf));
+                        if (0 == stat(buf, &statbuf)) {
+                            free(thePath);
+                            thePath = buf;
+                        }
+                    }
+                    if (thePath != buf) {
+                        strlcpy(buf, thePath, sizeof(buf));
+                        free((void *)thePath);
+                        thePath = buf;
+                    }
+                }
+            }
+        }
+        
+        // After attempting a search through $PATH, if existant,
+        // try prepending the current directory to argv[0].
+        if (!thePath && _CFGetCurrentDirectory(buf, CFMaxPathSize)) {
+            if (buf[strlen(buf)-1] != '/') {
+                strlcat(buf, "/", sizeof(buf));
+            }
+            strlcat(buf, arg0, CFMaxPathSize);
+            if (0 == stat(buf, &statbuf)) {
+                thePath = buf;
+            }
+        }
+
+        if (thePath) {
+            // We are going to process the buffer replacing all "/./" and "//" with "/"
+            CFIndex srcIndex = 0, dstIndex = 0;
+            CFIndex len = strlen(thePath);
+            for (srcIndex=0; srcIndex<len; srcIndex++) {
+                thePath[dstIndex] = thePath[srcIndex];
+                dstIndex++;
+                while (srcIndex < len-1 && thePath[srcIndex] == '/' && (thePath[srcIndex+1] == '/' || (thePath[srcIndex+1] == '.' && srcIndex < len-2 && thePath[srcIndex+2] == '/'))) srcIndex += (thePath[srcIndex+1] == '/' ? 1 : 2);
+            }
+            thePath[dstIndex] = 0;
+        }
+        if (!thePath) {
+            thePath = (*_NSGetArgv())[execIndex];
+        }
+#elif DEPLOYMENT_TARGET_LINUX
+	if (!__CFProcessPath) {
+		pid_t pid = getpid();
+		char buf[2][CFMaxPathSize] = {{0}, {0}};
+		int n;
+
+		n = snprintf(buf[0], CFMaxPathSize, "/proc/%u/exe", pid);
+
+		if (n > 0) {
+			n = readlink(buf[0], buf[1], CFMaxPathLength);
+			if (n > 0 && n <= CFMaxPathLength) {
+				buf[1][n] = '\0';
+				thePath = buf[1];
+			}
+		}
+#else
+#error "Don't know how to compute the process path for this platform."
+#endif
+
+        if (thePath) {
+            int len = (int)strlen(thePath);
+            __CFProcessPath = (const char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, len + 1, 0);
+            if (__CFOASafe) __CFSetLastAllocationEventName((void *)__CFProcessPath, "CFUtilities (process-path)");
+            memmove((char *)__CFProcessPath, thePath, len + 1);
+        }
+        if (__CFProcessPath) {            
+            const char *p = 0;
+            int i;
+            for (i = 0; __CFProcessPath[i] != 0; i++){
+               if (__CFProcessPath[i] == PATH_SEP)
+                    p = __CFProcessPath + i; 
+            }
+            if (p != 0)
+                __CFprogname = p + 1;
+            else
+                __CFprogname = __CFProcessPath;
+        }
+
+#if DEPLOYMENT_TARGET_MACOSX
+        close(no_hang_fd);
+#endif
+
+    }
+
+    if (!__CFProcessPath) {
+        __CFProcessPath = "";
+        __CFprogname = __CFProcessPath;
+    } else {
+        const char *p = 0;
+        int i;
+        for (i = 0; __CFProcessPath[i] != 0; i++){
+            if (__CFProcessPath[i] == PATH_SEP)
+                p = __CFProcessPath + i; 
+        }
+        if (p != 0)
+            __CFprogname = p + 1;
+        else
+            __CFprogname = __CFProcessPath;
+    }
+    return __CFProcessPath;
+}
+
+__private_extern__ CFStringRef _CFProcessNameString(void) {
+    static CFStringRef __CFProcessNameString = NULL;
+    if (!__CFProcessNameString) {
+        const char *processName = *_CFGetProgname();
+        if (!processName) processName = "";
+        __CFProcessNameString = CFStringCreateWithCString(__CFGetDefaultAllocator(), processName, kCFPlatformInterfaceStringEncoding);
+    }
+    return __CFProcessNameString;
+}
+
+static CFStringRef __CFUserName = NULL;
+
+#if (DEPLOYMENT_TARGET_MACOSX) || defined(__svr4__) || defined(__hpux__) || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+static CFURLRef __CFHomeDirectory = NULL;
+static uint32_t __CFEUID = -1;
+static uint32_t __CFUID = -1;
+
+static CFURLRef _CFCopyHomeDirURLForUser(struct passwd *upwd) {
+    CFURLRef home = NULL;
+    if (!_CFIsSetUgid()) {
+	const char *path = getenv("CFFIXED_USER_HOME");
+	if (path) {
+	    home = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)path, strlen(path), true);
+	}
+    }
+    if (!home) {
+        if (upwd && upwd->pw_dir) {
+            home = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)upwd->pw_dir, strlen(upwd->pw_dir), true);
+	}
+    }
+    return home;
+}
+
+static void _CFUpdateUserInfo(void) {
+    struct passwd *upwd;
+
+    __CFEUID = geteuid();
+    __CFUID = getuid();
+    if (__CFHomeDirectory)  CFRelease(__CFHomeDirectory);
+    __CFHomeDirectory = NULL;
+    if (__CFUserName) CFRelease(__CFUserName);
+    __CFUserName = NULL;
+
+    upwd = getpwuid(__CFEUID ? __CFEUID : __CFUID);
+    __CFHomeDirectory = _CFCopyHomeDirURLForUser(upwd);
+    if (!__CFHomeDirectory) {
+        const char *cpath = getenv("HOME");
+        if (cpath) {
+            __CFHomeDirectory = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)cpath, strlen(cpath), true);
+        }
+    }
+
+    // This implies that UserManager stores directory info in CString
+    // rather than FileSystemRep.  Perhaps this is wrong & we should
+    // expect NeXTSTEP encodings.  A great test of our localized system would
+    // be to have a user "O-umlat z e r".  XXX
+    if (upwd && upwd->pw_name) {
+        __CFUserName = CFStringCreateWithCString(kCFAllocatorSystemDefault, upwd->pw_name, kCFPlatformInterfaceStringEncoding);
+    } else {
+        const char *cuser = getenv("USER");
+        if (cuser)
+            __CFUserName = CFStringCreateWithCString(kCFAllocatorSystemDefault, cuser, kCFPlatformInterfaceStringEncoding);
+    }
+}
+#endif
+
+static CFURLRef _CFCreateHomeDirectoryURLForUser(CFStringRef uName) {
+#if (DEPLOYMENT_TARGET_MACOSX) || defined(__svr4__) || defined(__hpux__) || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    if (!uName) {
+        if (geteuid() != __CFEUID || getuid() != __CFUID || !__CFHomeDirectory)
+            _CFUpdateUserInfo();
+        if (__CFHomeDirectory) CFRetain(__CFHomeDirectory);
+        return __CFHomeDirectory;
+    } else {
+        struct passwd *upwd = NULL;
+        char buf[128], *user;
+        SInt32 len = CFStringGetLength(uName), size = CFStringGetMaximumSizeForEncoding(len, kCFPlatformInterfaceStringEncoding);
+        CFIndex usedSize;
+        if (size < 127) {
+            user = buf;
+        } else {
+            user = (char*)CFAllocatorAllocate(kCFAllocatorSystemDefault, size+1, 0);
+            if (__CFOASafe) __CFSetLastAllocationEventName(user, "CFUtilities (temp)");
+        }
+        if (CFStringGetBytes(uName, CFRangeMake(0, len), kCFPlatformInterfaceStringEncoding, 0, true, (uint8_t *)user, size, &usedSize) == len) {
+            user[usedSize] = '\0';
+            upwd = getpwnam(user);
+        }
+        if (buf != user) {
+            CFAllocatorDeallocate(kCFAllocatorSystemDefault, user);
+        }
+        return _CFCopyHomeDirURLForUser(upwd);
+    }
+#elif DEPLOYMENT_TARGET_WINDOWS
+    CFStringRef user = !uName ? _CFUserName() : uName;
+    CFURLRef home = NULL;
+
+    if (!uName || CFEqual(user, _CFUserName())) {
+        const char *cpath = getenv("HOMEPATH");
+        const char *cdrive = getenv("HOMEDRIVE");
+        if (cdrive && cpath) {
+            char fullPath[CFMaxPathSize];
+            CFStringRef str;
+            strlcpy(fullPath, cdrive, sizeof(fullPath));
+            strlcat(fullPath, cpath, sizeof(fullPath));
+            str = CFStringCreateWithCString(kCFAllocatorSystemDefault, fullPath, kCFPlatformInterfaceStringEncoding);
+            home = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str, kCFURLWindowsPathStyle, true);
+            CFRelease(str);
+        }
+    }
+    if (home == NULL) {
+		UniChar pathChars[MAX_PATH];
+		if (S_OK == SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, (LPWSTR) pathChars)) {
+			UniChar* p = pathChars;
+			CFIndex len = 0;
+			CFStringRef str;
+			while (*p++ != 0)
+				++len;
+			str = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, pathChars, len);
+            home = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str, kCFURLWindowsPathStyle, true);
+            CFRelease(str);
+                } else {
+                    // We have to get "some" directory location, so fall-back to the 
+                    // processes current directory.
+                    UniChar currDir[MAX_PATH];
+                    DWORD dwChars = GetCurrentDirectory(MAX_PATH + 1, (LPWSTR)currDir);
+                    if (dwChars > 0) {
+                        UniChar* p = currDir;
+			            CFIndex len = 0;
+			            CFStringRef str;
+			            while (*p++ != 0)
+				            ++len;
+			            str = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, currDir, len);
+                        home = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str, kCFURLWindowsPathStyle, true);
+                    }
+                }
+    }
+    // We could do more here (as in KB Article Q101507). If that article is to
+    // be believed, we should only run into this case on Win95, or through
+    // user error.
+    if (home) {
+        CFStringRef str = CFURLCopyFileSystemPath(home, kCFURLWindowsPathStyle);
+        if (str && CFStringGetLength(str) == 0) {
+            CFRelease(home);
+            home=NULL;
+        }
+        if (str) CFRelease(str);
+    }
+    return home;
+#else
+#error Dont know how to compute users home directories on this platform
+#endif
+}
+
+static CFStringRef _CFUserName(void) {
+#if (DEPLOYMENT_TARGET_MACOSX) || defined(__svr4__) || defined(__hpux__) || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    if (geteuid() != __CFEUID || getuid() != __CFUID)
+	_CFUpdateUserInfo();
+#elif DEPLOYMENT_TARGET_WINDOWS
+    if (!__CFUserName) {
+	char username[1040];
+	DWORD size = 1040;
+	username[0] = 0;
+	if (GetUserNameA(username, &size)) {
+            __CFUserName = CFStringCreateWithCString(kCFAllocatorSystemDefault, username, kCFPlatformInterfaceStringEncoding);
+	} else {
+	    const char *cname = getenv("USERNAME");
+	    if (cname)
+                __CFUserName = CFStringCreateWithCString(kCFAllocatorSystemDefault, cname, kCFPlatformInterfaceStringEncoding);
+	}
+    }
+#else
+#error Dont know how to compute user name on this platform
+#endif
+    if (!__CFUserName)
+        __CFUserName = (CFStringRef)CFRetain(CFSTR(""));
+    return __CFUserName;
+}
+
+__private_extern__ CFStringRef _CFGetUserName(void) {
+    return CFStringCreateCopy(kCFAllocatorSystemDefault, _CFUserName());
+}
+
+#define CFMaxHostNameLength	256
+#define CFMaxHostNameSize	(CFMaxHostNameLength+1)
+
+__private_extern__ CFStringRef _CFStringCreateHostName(void) {
+    char myName[CFMaxHostNameSize];
+
+    // return @"" instead of nil a la CFUserName() and Ali Ozer
+    if (0 != gethostname(myName, CFMaxHostNameSize)) myName[0] = '\0';
+    return CFStringCreateWithCString(kCFAllocatorSystemDefault, myName, kCFPlatformInterfaceStringEncoding);
+}
+
+/* These are sanitized versions of the above functions. We might want to eliminate the above ones someday.
+   These can return NULL.
+*/
+CF_EXPORT CFStringRef CFGetUserName(void) {
+    return _CFUserName();
+}
+
+CF_EXPORT CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName) {
+    return _CFCreateHomeDirectoryURLForUser(uName);
+}
+
+#undef CFMaxHostNameLength
+#undef CFMaxHostNameSize
+
diff --git a/CoreFoundation/CFPlugIn.c b/CoreFoundation/CFPlugIn.c
new file mode 100644
index 0000000..80eb2f4
--- /dev/null
+++ b/CoreFoundation/CFPlugIn.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#include "CFBundle_Internal.h"
+#include "CFInternal.h"
+
+CONST_STRING_DECL(kCFPlugInDynamicRegistrationKey, "CFPlugInDynamicRegistration")
+CONST_STRING_DECL(kCFPlugInDynamicRegisterFunctionKey, "CFPlugInDynamicRegisterFunction")
+CONST_STRING_DECL(kCFPlugInUnloadFunctionKey, "CFPlugInUnloadFunction")
+CONST_STRING_DECL(kCFPlugInFactoriesKey, "CFPlugInFactories")
+CONST_STRING_DECL(kCFPlugInTypesKey, "CFPlugInTypes")
+
+__private_extern__ void __CFPlugInInitialize(void) {
+}
+
+/* ===================== Finding factories and creating instances ===================== */
+/* For plugIn hosts. */
+/* Functions for finding factories to create specific types and actually creating instances of a type. */
+
+CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeID) {
+    CFArrayRef array = _CFPFactoryFindForType(typeID);
+    CFMutableArrayRef result = NULL;
+    
+    if (array) {
+        SInt32 i, c = CFArrayGetCount(array);
+
+        // Use default allocator
+        result = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+        
+        for (i=0; i<c; i++) {
+            CFArrayAppendValue(result, _CFPFactoryGetFactoryID((_CFPFactory *)CFArrayGetValueAtIndex(array, i)));
+        }
+    }
+    return result;
+}
+
+CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeID, CFPlugInRef plugIn) {
+    CFArrayRef array = _CFPFactoryFindForType(typeID);
+    CFMutableArrayRef result = NULL;
+
+    if (array) {
+        SInt32 i, c = CFArrayGetCount(array);
+        _CFPFactory *factory;
+        
+        // Use default allocator
+        result = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+
+        for (i=0; i<c; i++) {
+            factory = (_CFPFactory *)CFArrayGetValueAtIndex(array, i);
+            if (_CFPFactoryGetPlugIn(factory) == plugIn) {
+                CFArrayAppendValue(result, _CFPFactoryGetFactoryID(factory));
+            }
+        }
+    }
+    return result;
+}
+
+CF_EXPORT void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryID, CFUUIDRef typeID) {
+    _CFPFactory *factory = _CFPFactoryFind(factoryID, true);
+    void *result = NULL;
+    if (!factory) {
+        /* MF:!!! No such factory. */
+        CFLog(__kCFLogPlugIn, CFSTR("Cannot find factory %@"), factoryID);
+    } else {
+        if (!_CFPFactorySupportsType(factory, typeID)) {
+            /* MF:!!! Factory does not support type. */
+            CFLog(__kCFLogPlugIn, CFSTR("Factory %@ does not support type %@"), factoryID, typeID);
+        } else {
+            result = _CFPFactoryCreateInstance(allocator, factory, typeID);
+        }
+    }
+    return result;
+}
+
+/* ===================== 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 factoryID, CFPlugInFactoryFunction func) {
+    // Create factories without plugIns from default allocator
+    // MF:!!! Should probably check that this worked, and maybe do some pre-checking to see if it already exists
+    // _CFPFactory *factory =
+    (void)_CFPFactoryCreate(kCFAllocatorSystemDefault, factoryID, func);
+    return true;
+}
+
+CF_EXPORT Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryID, CFPlugInRef plugIn, CFStringRef functionName) {
+    // Create factories with plugIns from plugIn's allocator
+    // MF:!!! Should probably check that this worked, and maybe do some pre-checking to see if it already exists
+    // _CFPFactory *factory =
+    (void)_CFPFactoryCreateByName(CFGetAllocator(plugIn), factoryID, plugIn, functionName);
+    return true;
+}
+
+CF_EXPORT Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryID) {
+    _CFPFactory *factory = _CFPFactoryFind(factoryID, true);
+    
+    if (!factory) {
+        /* MF:!!! Error.  No factory registered for this ID. */
+    } else {
+        _CFPFactoryDisable(factory);
+    }
+    return true;
+}
+
+CF_EXPORT Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryID, CFUUIDRef typeID) {
+    _CFPFactory *factory = _CFPFactoryFind(factoryID, true);
+
+    if (!factory) {
+        /* MF:!!! Error.  Factory must be registered (and not disabled) before types can be associated with it. */
+    } else {
+        _CFPFactoryAddType(factory, typeID);
+    }
+    return true;
+}
+
+CF_EXPORT Boolean CFPlugInUnregisterPlugInType(CFUUIDRef factoryID, CFUUIDRef typeID) {
+    _CFPFactory *factory = _CFPFactoryFind(factoryID, true);
+
+    if (!factory) {
+        /* MF:!!! Error.  Could not find factory. */
+    } else {
+        _CFPFactoryRemoveType(factory, typeID);
+    }
+    return true;
+}
+
+
+/* ================= 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) {
+    _CFPFactory *factory = _CFPFactoryFind(factoryID, true);
+
+    if (!factory) {
+        /* MF:!!! Error.  Could not find factory. */
+    } else {
+        _CFPFactoryAddInstance(factory);
+    }
+}
+
+CF_EXPORT void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID) {
+    _CFPFactory *factory = _CFPFactoryFind(factoryID, true);
+
+    if (!factory) {
+        /* MF:!!! Error.  Could not find factory. */
+    } else {
+        _CFPFactoryRemoveInstance(factory);
+    }
+}
diff --git a/CoreFoundation/CFPlugIn.h b/CoreFoundation/CFPlugIn.h
new file mode 100644
index 0000000..6b4be37
--- /dev/null
+++ b/CoreFoundation/CFPlugIn.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFUUID.h>
+
+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. */
+
+CF_EXPORT
+CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeUUID);
+    /* This function finds all the factories from any plugin for the given type.  Returns an array that the caller must release. */
+    
+CF_EXPORT
+CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeUUID, CFPlugInRef plugIn);
+    /* 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
+void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
+    /* This function returns the IUnknown interface for the new instance. */
+
+/* ================= 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);
+CF_EXPORT
+CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance);
+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
+
+#if !COREFOUNDATION_CFPLUGINCOM_SEPARATE
+#include <CoreFoundation/CFPlugInCOM.h>
+#endif /* !COREFOUNDATION_CFPLUGINCOM_SEPARATE */
+
+#endif /* ! __COREFOUNDATION_CFPLUGIN__ */
+
diff --git a/CoreFoundation/CFPlugInCOM.h b/CoreFoundation/CFPlugInCOM.h
new file mode 100644
index 0000000..6628e7c
--- /dev/null
+++ b/CoreFoundation/CFPlugInCOM.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFPLUGINCOM__)
+#define __COREFOUNDATION_CFPLUGINCOM__ 1
+
+#include <CoreFoundation/CFPlugIn.h>
+
+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__) && !defined(__MACH__)
+ : __comobject
+#endif /* __MWERKS__ && !__MACH__ */
+{
+    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/CoreFoundation/CFPlugIn_Factory.c b/CoreFoundation/CFPlugIn_Factory.c
new file mode 100644
index 0000000..1801707
--- /dev/null
+++ b/CoreFoundation/CFPlugIn_Factory.c
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#include "CFBundle_Internal.h"
+#include "CFInternal.h"
+
+static CFSpinLock_t CFPlugInGlobalDataLock = CFSpinLockInit;
+static CFMutableDictionaryRef _factoriesByFactoryID = NULL; /* Value is _CFPFactory */
+static CFMutableDictionaryRef _factoriesByTypeID = NULL; /* Value is array of _CFPFactory */
+
+static void _CFPFactoryAddToTable(_CFPFactory *factory) {
+    __CFSpinLock(&CFPlugInGlobalDataLock);
+    if (_factoriesByFactoryID == NULL) {
+        CFDictionaryValueCallBacks _factoryDictValueCallbacks = {0, NULL, NULL, NULL, NULL};
+        // Use default allocator
+        _factoriesByFactoryID = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &_factoryDictValueCallbacks);
+    }
+    CFDictionarySetValue(_factoriesByFactoryID, factory->_uuid, factory);
+    __CFSpinUnlock(&CFPlugInGlobalDataLock);
+}
+
+static void _CFPFactoryRemoveFromTable(_CFPFactory *factory) {
+    __CFSpinLock(&CFPlugInGlobalDataLock);
+    if (_factoriesByFactoryID != NULL) {
+        CFDictionaryRemoveValue(_factoriesByFactoryID, factory->_uuid);
+    }
+    __CFSpinUnlock(&CFPlugInGlobalDataLock);
+}
+
+__private_extern__ _CFPFactory *_CFPFactoryFind(CFUUIDRef factoryID, Boolean enabled) {
+    _CFPFactory *result = NULL;
+    
+    __CFSpinLock(&CFPlugInGlobalDataLock);
+    if (_factoriesByFactoryID != NULL) {
+        result = (_CFPFactory *)CFDictionaryGetValue(_factoriesByFactoryID, factoryID);
+        if (result && result->_enabled != enabled) {
+            result = NULL;
+        }
+    }
+    __CFSpinUnlock(&CFPlugInGlobalDataLock);
+    return result;
+}
+
+static void _CFPFactoryDeallocate(_CFPFactory *factory) {
+    CFAllocatorRef allocator = factory->_allocator;
+    SInt32 c;
+    
+    _CFPFactoryRemoveFromTable(factory);
+
+    if (factory->_plugIn) {
+        _CFPlugInRemoveFactory(factory->_plugIn, factory);
+    }
+
+    /* Remove all types for this factory. */
+    c = CFArrayGetCount(factory->_types);
+    while (c--) {
+        _CFPFactoryRemoveType(factory, (CFUUIDRef)CFArrayGetValueAtIndex(factory->_types, c));
+    }
+    CFRelease(factory->_types);
+
+    if (factory->_funcName) {
+        CFRelease(factory->_funcName);
+    }
+
+    if (factory->_uuid) {
+        CFRelease(factory->_uuid);
+    }
+
+    CFAllocatorDeallocate(allocator, factory);
+    CFRelease(allocator);
+}
+
+static _CFPFactory *_CFPFactoryCommonCreate(CFAllocatorRef allocator, CFUUIDRef factoryID) {
+    _CFPFactory *factory;
+    UInt32 size;
+    size = sizeof(_CFPFactory);
+    allocator = ((NULL == allocator) ? (CFAllocatorRef)CFRetain(__CFGetDefaultAllocator()) : (CFAllocatorRef)CFRetain(allocator));
+    factory = (_CFPFactory *)CFAllocatorAllocate(allocator, size, 0);
+    if (NULL == factory) {
+        CFRelease(allocator);
+        return NULL;
+    }
+
+    factory->_allocator = allocator;
+
+    factory->_uuid = (CFUUIDRef)CFRetain(factoryID);
+    factory->_enabled = true;
+    factory->_instanceCount = 0;
+
+    _CFPFactoryAddToTable(factory);
+
+    factory->_types = CFArrayCreateMutable(allocator, 0, &kCFTypeArrayCallBacks);
+
+    return factory;
+}
+
+__private_extern__ _CFPFactory *_CFPFactoryCreate(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInFactoryFunction func) {
+    _CFPFactory *factory = _CFPFactoryCommonCreate(allocator, factoryID);
+
+    factory->_func = func;
+    factory->_plugIn = NULL;
+    factory->_funcName = NULL;
+
+    return factory;
+}
+
+__private_extern__ _CFPFactory *_CFPFactoryCreateByName(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInRef plugIn, CFStringRef funcName) {
+    _CFPFactory *factory = _CFPFactoryCommonCreate(allocator, factoryID);
+
+    factory->_func = NULL;
+    factory->_plugIn = plugIn;
+    if (plugIn) {
+        _CFPlugInAddFactory(plugIn, factory);
+    }
+    factory->_funcName = (funcName ? (CFStringRef)CFStringCreateCopy(allocator, funcName) : NULL);
+
+    return factory;
+}
+
+__private_extern__ CFUUIDRef _CFPFactoryGetFactoryID(_CFPFactory *factory) {
+    return factory->_uuid;
+}
+
+__private_extern__ CFPlugInRef _CFPFactoryGetPlugIn(_CFPFactory *factory) {
+    return factory->_plugIn;
+}
+
+__private_extern__ void *_CFPFactoryCreateInstance(CFAllocatorRef allocator, _CFPFactory *factory, CFUUIDRef typeID) {
+    void *result = NULL;
+    if (factory->_enabled) {
+        if (factory->_func == NULL) {
+            factory->_func = (CFPlugInFactoryFunction)CFBundleGetFunctionPointerForName(factory->_plugIn, factory->_funcName);
+            if (factory->_func == NULL) {
+                CFLog(__kCFLogPlugIn, CFSTR("Cannot find function pointer %@ for factory %@ in %@"), factory->_funcName, factory->_uuid, factory->_plugIn);
+            }
+#if BINARY_SUPPORT_CFM
+            else {
+                // return values from CFBundleGetFunctionPointerForName will always be dyld, but
+                // we must force-fault them because pointers to glue code do not fault correctly
+                factory->_func = (void *)((uint32_t)(factory->_func) | 0x1);
+            }
+#endif /* BINARY_SUPPORT_CFM */
+        }
+        if (factory->_func) {
+            // UPPGOOP
+            FAULT_CALLBACK((void **)&(factory->_func));
+            result = (void *)INVOKE_CALLBACK2(factory->_func, allocator, typeID);
+        }
+    } else {
+        CFLog(__kCFLogPlugIn, CFSTR("Factory %@ is disabled"), factory->_uuid);
+    }
+    return result;
+}
+
+__private_extern__ void _CFPFactoryDisable(_CFPFactory *factory) {
+    factory->_enabled = false;
+    if (factory->_instanceCount == 0) {
+        _CFPFactoryDeallocate(factory);
+    }
+}
+
+__private_extern__ Boolean _CFPFactoryIsEnabled(_CFPFactory *factory) {
+    return factory->_enabled;
+}
+
+__private_extern__ void _CFPFactoryFlushFunctionCache(_CFPFactory *factory) {
+    /* MF:!!! Assert that this factory belongs to a plugIn. */
+    /* This is called by the factory's plugIn when the plugIn unloads its code. */
+    factory->_func = NULL;
+}
+
+__private_extern__ void _CFPFactoryAddType(_CFPFactory *factory, CFUUIDRef typeID) {
+    CFMutableArrayRef array;
+    
+    /* Add the type to the factory's type list */
+    CFArrayAppendValue(factory->_types, typeID);
+
+    /* Add the factory to the type's array of factories */
+    __CFSpinLock(&CFPlugInGlobalDataLock);
+    if (_factoriesByTypeID == NULL) {
+        // Create this from default allocator
+        _factoriesByTypeID = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    }
+    array = (CFMutableArrayRef)CFDictionaryGetValue(_factoriesByTypeID, typeID);
+    if (array == NULL) {
+        CFArrayCallBacks _factoryArrayCallbacks = {0, NULL, NULL, NULL, NULL};
+        // Create this from default allocator
+        array = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &_factoryArrayCallbacks);
+        CFDictionarySetValue(_factoriesByTypeID, typeID, array);
+        CFRelease(array);
+    }
+    CFArrayAppendValue(array, factory);
+    __CFSpinUnlock(&CFPlugInGlobalDataLock);
+}
+
+__private_extern__ void _CFPFactoryRemoveType(_CFPFactory *factory, CFUUIDRef typeID) {
+    /* Remove it from the factory's type list */
+    SInt32 idx;
+
+    idx = CFArrayGetFirstIndexOfValue(factory->_types, CFRangeMake(0, CFArrayGetCount(factory->_types)), typeID);
+    if (idx >=0) {
+        CFArrayRemoveValueAtIndex(factory->_types, idx);
+    }
+
+    /* Remove the factory from the type's list of factories */
+    __CFSpinLock(&CFPlugInGlobalDataLock);
+    if (_factoriesByTypeID != NULL) {
+        CFMutableArrayRef array = (CFMutableArrayRef)CFDictionaryGetValue(_factoriesByTypeID, typeID);
+        if (array != NULL) {
+            idx = CFArrayGetFirstIndexOfValue(array, CFRangeMake(0, CFArrayGetCount(array)), factory);
+            if (idx >=0) {
+                CFArrayRemoveValueAtIndex(array, idx);
+                if (CFArrayGetCount(array) == 0) {
+                    CFDictionaryRemoveValue(_factoriesByTypeID, typeID);
+                }
+            }
+        }
+    }
+    __CFSpinUnlock(&CFPlugInGlobalDataLock);
+}
+
+__private_extern__ Boolean _CFPFactorySupportsType(_CFPFactory *factory, CFUUIDRef typeID) {
+    SInt32 idx;
+
+    idx = CFArrayGetFirstIndexOfValue(factory->_types, CFRangeMake(0, CFArrayGetCount(factory->_types)), typeID);
+    return ((idx >= 0) ? true : false);
+}
+
+__private_extern__ CFArrayRef _CFPFactoryFindForType(CFUUIDRef typeID) {
+    CFArrayRef result = NULL;
+
+    __CFSpinLock(&CFPlugInGlobalDataLock);
+    if (_factoriesByTypeID != NULL) {
+        result = (CFArrayRef)CFDictionaryGetValue(_factoriesByTypeID, typeID);
+    }
+    __CFSpinUnlock(&CFPlugInGlobalDataLock);
+
+    return result;
+}
+
+/* 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. */
+__private_extern__ void _CFPFactoryAddInstance(_CFPFactory *factory) {
+    /* MF:!!! Assert that factory is enabled. */
+    factory->_instanceCount++;
+    if (factory->_plugIn) {
+        _CFPlugInAddPlugInInstance(factory->_plugIn);
+    }
+}
+
+__private_extern__ void _CFPFactoryRemoveInstance(_CFPFactory *factory) {
+    /* MF:!!! Assert that _instanceCount > 0. */
+    factory->_instanceCount--;
+    if (factory->_plugIn) {
+        _CFPlugInRemovePlugInInstance(factory->_plugIn);
+    }
+    if ((factory->_instanceCount == 0) && (!factory->_enabled)) {
+        _CFPFactoryDeallocate(factory);
+    }
+}
diff --git a/CoreFoundation/CFPlugIn_Factory.h b/CoreFoundation/CFPlugIn_Factory.h
new file mode 100644
index 0000000..2714320
--- /dev/null
+++ b/CoreFoundation/CFPlugIn_Factory.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 {
+    CFAllocatorRef _allocator;
+
+    CFUUIDRef _uuid;
+    Boolean _enabled;
+    char _padding[3];
+    SInt32 _instanceCount;
+
+    CFPlugInFactoryFunction _func;
+    
+    CFPlugInRef _plugIn;
+    CFStringRef _funcName;
+
+    CFMutableArrayRef _types;
+} _CFPFactory;
+
+extern _CFPFactory *_CFPFactoryCreate(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInFactoryFunction func);
+extern _CFPFactory *_CFPFactoryCreateByName(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInRef plugIn, CFStringRef funcName);
+
+extern _CFPFactory *_CFPFactoryFind(CFUUIDRef factoryID, Boolean enabled);
+
+extern CFUUIDRef _CFPFactoryGetFactoryID(_CFPFactory *factory);
+extern CFPlugInRef _CFPFactoryGetPlugIn(_CFPFactory *factory);
+
+extern void *_CFPFactoryCreateInstance(CFAllocatorRef allocator, _CFPFactory *factory, CFUUIDRef typeID);
+extern void _CFPFactoryDisable(_CFPFactory *factory);
+extern Boolean _CFPFactoryIsEnabled(_CFPFactory *factory);
+
+extern void _CFPFactoryFlushFunctionCache(_CFPFactory *factory);
+
+extern void _CFPFactoryAddType(_CFPFactory *factory, CFUUIDRef typeID);
+extern void _CFPFactoryRemoveType(_CFPFactory *factory, CFUUIDRef typeID);
+
+extern Boolean _CFPFactorySupportsType(_CFPFactory *factory, CFUUIDRef typeID);
+extern CFArrayRef _CFPFactoryFindForType(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(_CFPFactory *factory);
+extern void _CFPFactoryRemoveInstance(_CFPFactory *factory);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFPLUGIN_FACTORY__ */
+
diff --git a/CoreFoundation/CFPlugIn_Instance.c b/CoreFoundation/CFPlugIn_Instance.c
new file mode 100644
index 0000000..783c745
--- /dev/null
+++ b/CoreFoundation/CFPlugIn_Instance.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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_Instance.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#include "CFBundle_Internal.h"
+#include "CFInternal.h"
+
+static CFTypeID __kCFPlugInInstanceTypeID = _kCFRuntimeNotATypeID;
+
+struct __CFPlugInInstance {
+    CFRuntimeBase _base;
+    
+    _CFPFactory *factory;
+    
+    CFPlugInInstanceGetInterfaceFunction getInterfaceFunction;
+    CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceDataFunction;
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4200)
+#endif //_MSC_VER
+    uint8_t _instanceData[0];
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif //_MSC_VER
+};
+
+static CFStringRef __CFPlugInInstanceCopyDescription(CFTypeRef cf) {
+    /* MF:!!! Implement me */
+    return CFSTR("Some CFPlugInInstance");
+}
+
+static void __CFPlugInInstanceDeallocate(CFTypeRef cf) {
+    CFPlugInInstanceRef instance = (CFPlugInInstanceRef)cf;
+    
+    __CFGenericValidateType(cf, __kCFPlugInInstanceTypeID);
+
+    if (instance->deallocateInstanceDataFunction) {
+        FAULT_CALLBACK((void **)&(instance->deallocateInstanceDataFunction));
+        (void)INVOKE_CALLBACK1(instance->deallocateInstanceDataFunction, (void *)(&instance->_instanceData[0]));
+    }
+
+    if (instance->factory) {
+        _CFPFactoryRemoveInstance(instance->factory);
+    }
+}
+
+static const CFRuntimeClass __CFPlugInInstanceClass = {
+    0,
+    "CFPlugInInstance",
+    NULL,      // init
+    NULL,      // copy
+    __CFPlugInInstanceDeallocate,
+    NULL,      // equal
+    NULL,      // hash
+    NULL,      // 
+    __CFPlugInInstanceCopyDescription
+};
+
+__private_extern__ void __CFPlugInInstanceInitialize(void) {
+    __kCFPlugInInstanceTypeID = _CFRuntimeRegisterClass(&__CFPlugInInstanceClass);
+}
+
+CFTypeID CFPlugInInstanceGetTypeID(void) {
+    return __kCFPlugInInstanceTypeID;
+}
+CF_EXPORT CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize(CFAllocatorRef allocator, CFIndex instanceDataSize, CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, CFStringRef factoryName, CFPlugInInstanceGetInterfaceFunction getInterfaceFunction) {
+    CFPlugInInstanceRef instance;
+    UInt32 size;
+    size = sizeof(struct __CFPlugInInstance) + instanceDataSize - sizeof(CFRuntimeBase);
+    instance = (CFPlugInInstanceRef)_CFRuntimeCreateInstance(allocator, __kCFPlugInInstanceTypeID, size, NULL);
+    if (NULL == instance) {
+        return NULL;
+    }
+
+    instance->factory = _CFPFactoryFind((CFUUIDRef)factoryName, true);
+    if (instance->factory) {
+        _CFPFactoryAddInstance(instance->factory);
+    }
+    instance->getInterfaceFunction = getInterfaceFunction;
+    instance->deallocateInstanceDataFunction = deallocateInstanceFunction;
+
+    return instance;
+}
+
+CF_EXPORT Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl) {
+    void *myFtbl;
+    Boolean result = false;
+
+    if (instance->getInterfaceFunction) {
+        FAULT_CALLBACK((void **)&(instance->getInterfaceFunction));
+        result = INVOKE_CALLBACK3(instance->getInterfaceFunction, instance, interfaceName, &myFtbl) ? true : false;
+    }
+    if (ftbl) {
+        *ftbl = (result ? myFtbl : NULL);
+    }
+    return result;
+}
+
+CF_EXPORT CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance) {
+    return (CFStringRef)_CFPFactoryGetFactoryID(instance->factory);
+}
+
+CF_EXPORT void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance) {
+    return (void *)(&instance->_instanceData[0]);
+}
+
diff --git a/CoreFoundation/CFPlugIn_PlugIn.c b/CoreFoundation/CFPlugIn_PlugIn.c
new file mode 100644
index 0000000..30279a5
--- /dev/null
+++ b/CoreFoundation/CFPlugIn_PlugIn.c
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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_PlugIn.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#include "CFBundle_Internal.h"
+#include "CFInternal.h"
+
+
+static void _registerFactory(const void *key, const void *val, void *context) {
+    CFStringRef factoryIDStr = (CFStringRef)key;
+    CFStringRef factoryFuncStr = (CFStringRef)val;
+    CFBundleRef bundle = (CFBundleRef)context;
+    CFUUIDRef factoryID = (CFGetTypeID(factoryIDStr) == CFStringGetTypeID()) ? CFUUIDCreateFromString(kCFAllocatorSystemDefault, factoryIDStr) : NULL;
+    if (NULL == factoryID) factoryID = (CFUUIDRef)CFRetain(factoryIDStr);
+    if (CFGetTypeID(factoryFuncStr) != CFStringGetTypeID() || CFStringGetLength(factoryFuncStr) <= 0) factoryFuncStr = NULL;
+    CFPlugInRegisterFactoryFunctionByName(factoryID, bundle, factoryFuncStr);
+    if (NULL != factoryID) CFRelease(factoryID);
+}
+
+static void _registerType(const void *key, const void *val, void *context) {
+    CFStringRef typeIDStr = (CFStringRef)key;
+    CFArrayRef factoryIDStrArray = (CFArrayRef)val;
+    CFBundleRef bundle = (CFBundleRef)context;
+    SInt32 i, c = (CFGetTypeID(factoryIDStrArray) == CFArrayGetTypeID()) ? CFArrayGetCount(factoryIDStrArray) : 0;
+    CFStringRef curFactoryIDStr;
+    CFUUIDRef typeID = (CFGetTypeID(typeIDStr) == CFStringGetTypeID()) ? CFUUIDCreateFromString(kCFAllocatorSystemDefault, typeIDStr) : NULL;
+    CFUUIDRef curFactoryID;
+    if (NULL == typeID) typeID = (CFUUIDRef)CFRetain(typeIDStr);
+    if (0 == c && (CFGetTypeID(factoryIDStrArray) != CFArrayGetTypeID())) {
+        curFactoryIDStr = (CFStringRef)val;
+        curFactoryID = (CFGetTypeID(curFactoryIDStr) == CFStringGetTypeID()) ? CFUUIDCreateFromString(CFGetAllocator(bundle), curFactoryIDStr) : NULL;
+        if (NULL == curFactoryID) curFactoryID = (CFUUIDRef)CFRetain(curFactoryIDStr);
+        CFPlugInRegisterPlugInType(curFactoryID, typeID);
+        if (NULL != curFactoryID) CFRelease(curFactoryID);
+    } else for (i=0; i<c; i++) {
+        curFactoryIDStr = (CFStringRef)CFArrayGetValueAtIndex(factoryIDStrArray, i);
+        curFactoryID = (CFGetTypeID(curFactoryIDStr) == CFStringGetTypeID()) ? CFUUIDCreateFromString(CFGetAllocator(bundle), curFactoryIDStr) : NULL;
+        if (NULL == curFactoryID) curFactoryID = (CFUUIDRef)CFRetain(curFactoryIDStr);
+        CFPlugInRegisterPlugInType(curFactoryID, typeID);
+        if (NULL != curFactoryID) CFRelease(curFactoryID);
+    }
+    if (NULL != typeID) CFRelease(typeID);
+}
+
+__private_extern__ Boolean _CFBundleNeedsInitPlugIn(CFBundleRef bundle) {
+    Boolean result = false;
+    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle), factoryDict;
+    CFStringRef tempStr;
+    if (infoDict) {
+        factoryDict = (CFDictionaryRef)CFDictionaryGetValue(infoDict, kCFPlugInFactoriesKey);
+        if (factoryDict != NULL && CFGetTypeID(factoryDict) == CFDictionaryGetTypeID()) result = true;
+        tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegistrationKey);
+        if (tempStr != NULL && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) result = true;
+    }
+    return result;
+}
+
+__private_extern__ void _CFBundleInitPlugIn(CFBundleRef bundle) {
+    CFArrayCallBacks _pluginFactoryArrayCallbacks = {0, NULL, NULL, NULL, NULL};
+    Boolean doDynamicReg = false;
+    CFDictionaryRef infoDict;
+    CFDictionaryRef factoryDict;
+    CFDictionaryRef typeDict;
+    CFStringRef tempStr;
+
+    infoDict = CFBundleGetInfoDictionary(bundle);
+    if (infoDict == NULL) {
+        return;
+    }
+    factoryDict = (CFDictionaryRef)CFDictionaryGetValue(infoDict, kCFPlugInFactoriesKey);
+    if (factoryDict != NULL && CFGetTypeID(factoryDict) != CFDictionaryGetTypeID()) factoryDict = NULL;
+    tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegistrationKey);
+    if (tempStr != NULL && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+        doDynamicReg = true;
+    }
+    if (!factoryDict && !doDynamicReg) {
+        // This is not a plugIn.
+        return;
+    }
+
+    /* loadOnDemand is true by default if the plugIn does not do dynamic registration.  It is false, by default if it does do dynamic registration.  The dynamic register function can set this. */
+    __CFBundleGetPlugInData(bundle)->_isPlugIn = true;
+    __CFBundleGetPlugInData(bundle)->_loadOnDemand = true;
+    __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
+    __CFBundleGetPlugInData(bundle)->_instanceCount = 0;
+
+    __CFBundleGetPlugInData(bundle)->_factories = CFArrayCreateMutable(CFGetAllocator(bundle), 0, &_pluginFactoryArrayCallbacks);
+
+    /* Now do the registration */
+
+    /* First do static registrations, if any. */
+    if (factoryDict != NULL) {
+        CFDictionaryApplyFunction(factoryDict, _registerFactory, bundle);
+    }
+    typeDict = (CFDictionaryRef)CFDictionaryGetValue(infoDict, kCFPlugInTypesKey);
+    if (typeDict != NULL && CFGetTypeID(typeDict) != CFDictionaryGetTypeID()) typeDict = NULL;
+    if (typeDict != NULL) {
+        CFDictionaryApplyFunction(typeDict, _registerType, bundle);
+    }
+
+    /* Now set key for dynamic registration if necessary */
+    if (doDynamicReg) {
+        CFDictionarySetValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"), CFSTR("YES"));
+        if (CFBundleIsExecutableLoaded(bundle)) _CFBundlePlugInLoaded(bundle);
+    }
+}
+
+__private_extern__ void _CFBundlePlugInLoaded(CFBundleRef bundle) {
+    CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
+    CFStringRef tempStr;
+    CFPlugInDynamicRegisterFunction func = NULL;
+
+    if (!__CFBundleGetPlugInData(bundle)->_isPlugIn || __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration || !infoDict || !CFBundleIsExecutableLoaded(bundle)) return;
+
+    tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
+    if (tempStr != NULL && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+        CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
+        tempStr = (CFStringRef)CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegisterFunctionKey);
+        if (tempStr == NULL || CFGetTypeID(tempStr) != CFStringGetTypeID() || CFStringGetLength(tempStr) <= 0) {
+            tempStr = CFSTR("CFPlugInDynamicRegister");
+        }
+        __CFBundleGetPlugInData(bundle)->_loadOnDemand = false;
+        __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true;
+
+        /* Find the symbol and call it. */
+        func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr);
+        if (func) {
+            func(bundle);
+            // MF:!!! Unload function is never called.  Need to deal with this!
+        }
+
+        __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
+        if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && (__CFBundleGetPlugInData(bundle)->_instanceCount == 0)) {
+            /* Unload now if we can/should. */
+            CFBundleUnloadExecutable(bundle);
+        }
+    } else {
+        CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
+    }
+}
+
+__private_extern__ void _CFBundleDeallocatePlugIn(CFBundleRef bundle) {
+    if (__CFBundleGetPlugInData(bundle)->_isPlugIn) {
+        SInt32 c;
+
+        /* Go through factories disabling them.  Disabling these factories should cause them to dealloc since we wouldn't be deallocating if any of the factories had outstanding instances.  So go backwards. */
+        c = CFArrayGetCount(__CFBundleGetPlugInData(bundle)->_factories);
+        while (c--) {
+            _CFPFactoryDisable((_CFPFactory *)CFArrayGetValueAtIndex(__CFBundleGetPlugInData(bundle)->_factories, c));
+        }
+        CFRelease(__CFBundleGetPlugInData(bundle)->_factories);
+
+        __CFBundleGetPlugInData(bundle)->_isPlugIn = false;
+    }
+}
+
+CFTypeID CFPlugInGetTypeID(void) {
+    return CFBundleGetTypeID();
+}
+
+CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL) {
+    CFBundleRef bundle = CFBundleCreate(allocator, plugInURL);
+    return (CFPlugInRef)bundle;
+}
+
+CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn) {
+    return (CFBundleRef)plugIn;
+}
+
+void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag) {
+    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
+        __CFBundleGetPlugInData(plugIn)->_loadOnDemand = flag;
+        if (__CFBundleGetPlugInData(plugIn)->_loadOnDemand && !__CFBundleGetPlugInData(plugIn)->_isDoingDynamicRegistration && (__CFBundleGetPlugInData(plugIn)->_instanceCount == 0)) {
+            /* Unload now if we can/should. */
+            /* If we are doing dynamic registration currently, do not unload.  The unloading will happen when dynamic registration is done, if necessary. */
+            CFBundleUnloadExecutable(plugIn);
+        } else if (!__CFBundleGetPlugInData(plugIn)->_loadOnDemand) {
+            /* Make sure we're loaded now. */
+            CFBundleLoadExecutable(plugIn);
+        }
+    }
+}
+
+Boolean CFPlugInIsLoadOnDemand(CFPlugInRef plugIn) {
+    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
+        return __CFBundleGetPlugInData(plugIn)->_loadOnDemand;
+    } else {
+        return false;
+    }
+}
+
+__private_extern__ void _CFPlugInWillUnload(CFPlugInRef plugIn) {
+    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
+        SInt32 c = CFArrayGetCount(__CFBundleGetPlugInData(plugIn)->_factories);
+        /* First, flush all the function pointers that may be cached by our factories. */
+        while (c--) {
+            _CFPFactoryFlushFunctionCache((_CFPFactory *)CFArrayGetValueAtIndex(__CFBundleGetPlugInData(plugIn)->_factories, c));
+        }
+    }
+}
+
+__private_extern__ void _CFPlugInAddPlugInInstance(CFPlugInRef plugIn) {
+    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
+        if ((__CFBundleGetPlugInData(plugIn)->_instanceCount == 0) && (__CFBundleGetPlugInData(plugIn)->_loadOnDemand)) {
+            /* Make sure we are not scheduled for unloading */
+            _CFBundleUnscheduleForUnloading(CFPlugInGetBundle(plugIn));
+        }
+        __CFBundleGetPlugInData(plugIn)->_instanceCount++;
+        /* Instances also retain the CFBundle */
+        CFRetain(plugIn);
+    }
+}
+
+__private_extern__ void _CFPlugInRemovePlugInInstance(CFPlugInRef plugIn) {
+    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
+        /* MF:!!! Assert that instanceCount > 0. */
+        __CFBundleGetPlugInData(plugIn)->_instanceCount--;
+        if ((__CFBundleGetPlugInData(plugIn)->_instanceCount == 0) && (__CFBundleGetPlugInData(plugIn)->_loadOnDemand)) {
+            // We unload the code lazily because the code that caused this function to be called is probably code from the plugin itself.  If we unload now, we will hose things.
+            //CFBundleUnloadExecutable(plugIn);
+            _CFBundleScheduleForUnloading(CFPlugInGetBundle(plugIn));
+        }
+        /* Instances also retain the CFPlugIn */
+        /* MF:!!! This will cause immediate unloading if it was the last ref on the plugin. */
+        CFRelease(plugIn);
+    }
+}
+
+__private_extern__ void _CFPlugInAddFactory(CFPlugInRef plugIn, _CFPFactory *factory) {
+    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
+        CFArrayAppendValue(__CFBundleGetPlugInData(plugIn)->_factories, factory);
+    }
+}
+
+__private_extern__ void _CFPlugInRemoveFactory(CFPlugInRef plugIn, _CFPFactory *factory) {
+    if (__CFBundleGetPlugInData(plugIn)->_isPlugIn) {
+        SInt32 idx = CFArrayGetFirstIndexOfValue(__CFBundleGetPlugInData(plugIn)->_factories, CFRangeMake(0, CFArrayGetCount(__CFBundleGetPlugInData(plugIn)->_factories)), factory);
+        if (idx >= 0) {
+            CFArrayRemoveValueAtIndex(__CFBundleGetPlugInData(plugIn)->_factories, idx);
+        }
+    }
+}
diff --git a/CoreFoundation/CFPreferences.c b/CoreFoundation/CFPreferences.c
new file mode 100644
index 0000000..5369d0f
--- /dev/null
+++ b/CoreFoundation/CFPreferences.c
@@ -0,0 +1,781 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Chris Parker
+*/
+
+#include <CoreFoundation/CFPreferences.h>
+#include <CoreFoundation/CFURLAccess.h>
+#ifndef DEPLOYMENT_TARGET_WINDOWS
+#include <CoreFoundation/CFUserNotification.h>
+#endif
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFPriv.h>
+#include "CFPriv.h"
+#include "CFInternal.h"
+#include <sys/stat.h>
+#if !DEPLOYMENT_TARGET_WINDOWS
+#include <unistd.h>
+#endif
+
+#if DEBUG_PREFERENCES_MEMORY
+#include "../Tests/CFCountingAllocator.c"
+#endif
+
+static CFURLRef _CFPreferencesURLForStandardDomainWithSafetyLevel(CFStringRef domainName, CFStringRef userName, CFStringRef hostName, unsigned long safeLevel);
+
+struct __CFPreferencesDomain {
+    CFRuntimeBase _base;
+    /* WARNING - not copying the callbacks; we know they are always static structs */
+    const _CFPreferencesDomainCallBacks *_callBacks;
+    CFTypeRef _context;
+    void *_domain;
+};
+
+CONST_STRING_DECL(kCFPreferencesAnyApplication, "kCFPreferencesAnyApplication")
+CONST_STRING_DECL(kCFPreferencesAnyHost, "kCFPreferencesAnyHost")
+CONST_STRING_DECL(kCFPreferencesAnyUser, "kCFPreferencesAnyUser")
+CONST_STRING_DECL(kCFPreferencesCurrentApplication, "kCFPreferencesCurrentApplication")
+CONST_STRING_DECL(kCFPreferencesCurrentHost, "kCFPreferencesCurrentHost")
+CONST_STRING_DECL(kCFPreferencesCurrentUser, "kCFPreferencesCurrentUser")
+
+
+static CFAllocatorRef _preferencesAllocator = NULL;
+__private_extern__ CFAllocatorRef __CFPreferencesAllocator(void) {
+    if (!_preferencesAllocator) {
+#if DEBUG_PREFERENCES_MEMORY
+        _preferencesAllocator = CFCountingAllocatorCreate(NULL);
+#else
+        _preferencesAllocator = __CFGetDefaultAllocator();
+        CFRetain(_preferencesAllocator);
+#endif
+    }
+    return _preferencesAllocator;
+}
+
+// declaration for telling the 
+void _CFApplicationPreferencesDomainHasChanged(CFPreferencesDomainRef);
+
+#if DEBUG_PREFERENCES_MEMORY
+#warning Preferences debugging on
+CF_EXPORT void CFPreferencesDumpMem(void) {
+    if (_preferencesAllocator) {
+//        CFCountingAllocatorPrintSummary(_preferencesAllocator);
+        CFCountingAllocatorPrintPointers(_preferencesAllocator);
+    }
+//    CFCountingAllocatorReset(_preferencesAllocator);
+}
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+#pragma mark -
+#pragma mark Determining host UUID
+#endif
+
+
+__private_extern__ CFStringRef _CFPreferencesGetByHostIdentifierString(void) {
+    return CFSTR("");
+}
+
+
+
+static unsigned long __CFSafeLaunchLevel = 0;
+
+#if 0
+#include <shfolder.h>
+
+CF_INLINE CFIndex strlen_UniChar(const UniChar* p) {
+	CFIndex result = 0;
+	while ((*p++) != 0)
+		++result;
+	return result;
+}
+
+#endif
+
+static CFURLRef _preferencesDirectoryForUserHostSafetyLevel(CFStringRef userName, CFStringRef hostName, unsigned long safeLevel) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+#if 0
+
+	CFURLRef url = NULL;
+
+	UniChar szPath[MAX_PATH];
+	if (S_OK == SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (LPWSTR) szPath)) {
+		CFStringRef directoryPath = CFStringCreateWithCharacters(alloc, szPath, strlen_UniChar(szPath));
+		if (directoryPath) {
+			CFStringRef completePath = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@\\Apple\\"), directoryPath);
+			if (completePath) {
+				url = CFURLCreateWithFileSystemPath(alloc, completePath, kCFURLWindowsPathStyle, true);
+				CFRelease(completePath);
+			}
+			CFRelease(directoryPath);
+		}
+	}
+
+	// Can't find a better place?  Home directory then?
+	if (url == NULL)
+		url = CFCopyHomeDirectoryURLForUser((userName == kCFPreferencesCurrentUser) ? NULL : userName);
+
+	return url;
+ 
+#else
+    CFURLRef  home = NULL;
+    CFURLRef  url;
+    int levels = 0;
+    //    if (hostName != kCFPreferencesCurrentHost && hostName != kCFPreferencesAnyHost) return NULL; // Arbitrary host access not permitted
+    if (userName == kCFPreferencesAnyUser) {
+        if (!home) home = CFURLCreateWithFileSystemPath(alloc, CFSTR("/Library/Preferences/"), kCFURLPOSIXPathStyle, true);
+        levels = 1;
+        if (hostName == kCFPreferencesCurrentHost) url = home;
+        else {
+            url = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("Network/"), kCFURLPOSIXPathStyle, true, home);
+            levels ++;
+            CFRelease(home);
+        }
+    } else {
+        home = CFCopyHomeDirectoryURLForUser((userName == kCFPreferencesCurrentUser) ? NULL : userName);
+        if (home) {
+            url = (safeLevel > 0) ? CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("Library/Safe Preferences/"), kCFURLPOSIXPathStyle, true, home) :
+            CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("Library/Preferences/"), kCFURLPOSIXPathStyle, true, home);
+            levels = 2;
+            CFRelease(home);
+            if (hostName != kCFPreferencesAnyHost) {
+                home = url;
+                url = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("ByHost/"), kCFURLPOSIXPathStyle, true, home);
+                levels ++;
+                CFRelease(home);
+            }
+        } else {
+            url = NULL;
+        }
+    }
+    return url;
+#endif
+}
+
+static CFURLRef  _preferencesDirectoryForUserHost(CFStringRef  userName, CFStringRef  hostName) {
+    return _preferencesDirectoryForUserHostSafetyLevel(userName, hostName, __CFSafeLaunchLevel);
+}
+
+static Boolean __CFPreferencesWritesXML = true;
+
+Boolean __CFPreferencesShouldWriteXML(void) {
+    return __CFPreferencesWritesXML;
+}
+
+static CFSpinLock_t domainCacheLock = CFSpinLockInit;
+static CFMutableDictionaryRef  domainCache = NULL; // mutable
+
+// Public API
+
+CFTypeRef  CFPreferencesCopyValue(CFStringRef  key, CFStringRef  appName, CFStringRef  user, CFStringRef  host) {
+    CFPreferencesDomainRef domain;
+    CFAssert1(appName != NULL && user != NULL && host != NULL, __kCFLogAssertion, "%s(): Cannot access preferences for a NULL application name, user, or host", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+    
+    domain = _CFPreferencesStandardDomain(appName, user, host);
+    if (domain) {
+        return _CFPreferencesDomainCreateValueForKey(domain, key);
+    } else {
+        return NULL;
+    }
+}
+
+CFDictionaryRef CFPreferencesCopyMultiple(CFArrayRef keysToFetch, CFStringRef appName, CFStringRef user, CFStringRef host) {
+    CFPreferencesDomainRef domain;
+    CFMutableDictionaryRef result;
+    CFIndex idx, count;
+
+    CFAssert1(appName != NULL && user != NULL && host != NULL, __kCFLogAssertion, "%s(): Cannot access preferences for a NULL application name, user, or host", __PRETTY_FUNCTION__);
+    __CFGenericValidateType(appName, CFStringGetTypeID());
+    __CFGenericValidateType(user, CFStringGetTypeID());
+    __CFGenericValidateType(host, CFStringGetTypeID());
+
+    domain = _CFPreferencesStandardDomain(appName, user, host);
+    if (!domain) return NULL;
+    if (!keysToFetch) {
+        return _CFPreferencesDomainDeepCopyDictionary(domain);
+    } else {
+        __CFGenericValidateType(keysToFetch, CFArrayGetTypeID());
+        count = CFArrayGetCount(keysToFetch);
+        result = CFDictionaryCreateMutable(CFGetAllocator(domain), count, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        if (!result) return NULL;
+        for (idx = 0; idx < count; idx ++) {
+            CFStringRef key = (CFStringRef)CFArrayGetValueAtIndex(keysToFetch, idx);
+            CFPropertyListRef value;
+            __CFGenericValidateType(key, CFStringGetTypeID());
+            value = _CFPreferencesDomainCreateValueForKey(domain, key);
+            if (value) {
+                CFDictionarySetValue(result, key, value);
+                CFRelease(value);
+            }
+        }
+    }
+    return result;
+}
+
+void CFPreferencesSetValue(CFStringRef  key, CFTypeRef  value, CFStringRef  appName, CFStringRef  user, CFStringRef  host) {
+    CFPreferencesDomainRef domain;
+    CFAssert1(appName != NULL && user != NULL && host != NULL, __kCFLogAssertion, "%s(): Cannot access preferences for a NULL application name, user, or host", __PRETTY_FUNCTION__);
+    CFAssert1(key != NULL, __kCFLogAssertion, "%s(): Cannot access preferences with a NULL key", __PRETTY_FUNCTION__);
+
+    domain = _CFPreferencesStandardDomain(appName, user, host);
+    if (domain) {
+        _CFPreferencesDomainSet(domain, key, value);
+        _CFApplicationPreferencesDomainHasChanged(domain);
+    }
+}
+
+
+void CFPreferencesSetMultiple(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef appName, CFStringRef user, CFStringRef host) {
+    CFPreferencesDomainRef domain;
+    CFIndex idx, count;
+    CFAssert1(appName != NULL && user != NULL && host != NULL, __kCFLogAssertion, "%s(): Cannot access preferences for a NULL application name, user, or host", __PRETTY_FUNCTION__);
+    if (keysToSet) __CFGenericValidateType(keysToSet, CFDictionaryGetTypeID());
+    if (keysToRemove) __CFGenericValidateType(keysToRemove, CFArrayGetTypeID());
+    __CFGenericValidateType(appName, CFStringGetTypeID());
+    __CFGenericValidateType(user, CFStringGetTypeID());
+    __CFGenericValidateType(host, CFStringGetTypeID());
+
+    CFTypeRef *keys = NULL;
+    CFTypeRef *values;
+    CFIndex numOfKeysToSet = 0;
+    
+    domain = _CFPreferencesStandardDomain(appName, user, host);
+    if (!domain) return;
+
+    CFAllocatorRef alloc = CFGetAllocator(domain);
+    
+    if (keysToSet && (count = CFDictionaryGetCount(keysToSet))) {
+        numOfKeysToSet = count;
+        keys = (CFTypeRef *)CFAllocatorAllocate(alloc, 2*count*sizeof(CFTypeRef), 0);
+        if (keys) {
+            values = &(keys[count]);
+            CFDictionaryGetKeysAndValues(keysToSet, keys, values);
+            for (idx = 0; idx < count; idx ++) {
+                _CFPreferencesDomainSet(domain, (CFStringRef)keys[idx], values[idx]);
+            }
+        }
+    }
+    if (keysToRemove && (count = CFArrayGetCount(keysToRemove))) {
+        for (idx = 0; idx < count; idx ++) {
+            CFStringRef removedKey = (CFStringRef)CFArrayGetValueAtIndex(keysToRemove, idx);
+            _CFPreferencesDomainSet(domain, removedKey, NULL);
+        }
+    }
+
+
+    _CFApplicationPreferencesDomainHasChanged(domain);
+    
+    if(keys) CFAllocatorDeallocate(alloc, keys);
+}
+
+Boolean CFPreferencesSynchronize(CFStringRef  appName, CFStringRef  user, CFStringRef  host) {
+    CFPreferencesDomainRef domain;
+    CFAssert1(appName != NULL && user != NULL && host != NULL, __kCFLogAssertion, "%s(): Cannot access preferences for a NULL application name, user, or host", __PRETTY_FUNCTION__);
+
+    domain = _CFPreferencesStandardDomain(appName, user, host);
+    if(domain) _CFApplicationPreferencesDomainHasChanged(domain);
+    
+    return domain ? _CFPreferencesDomainSynchronize(domain) : false;
+}
+
+CFArrayRef  CFPreferencesCopyApplicationList(CFStringRef  user, CFStringRef  host) {
+    CFArrayRef  array;
+    CFAssert1(user != NULL && host != NULL, __kCFLogAssertion, "%s(): Cannot access preferences for a NULL user or host", __PRETTY_FUNCTION__);
+    array = _CFPreferencesCreateDomainList(user, host);
+    return array;
+}
+
+CFArrayRef  CFPreferencesCopyKeyList(CFStringRef  appName, CFStringRef  user, CFStringRef  host) {
+    CFPreferencesDomainRef domain;
+    CFAssert1(appName != NULL && user != NULL && host != NULL, __kCFLogAssertion, "%s(): Cannot access preferences for a NULL application name, user, or host", __PRETTY_FUNCTION__);
+
+    domain = _CFPreferencesStandardDomain(appName, user, host);
+    if (!domain) {
+        return NULL;
+    } else {
+        CFArrayRef  result;
+
+	CFAllocatorRef alloc = __CFPreferencesAllocator();
+	CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain);
+	CFIndex count = d ? CFDictionaryGetCount(d) : 0;
+	CFTypeRef *keys = (CFTypeRef *)CFAllocatorAllocate(alloc, count * sizeof(CFTypeRef), 0);
+	if (d) CFDictionaryGetKeysAndValues(d, keys, NULL);
+        if (count == 0) {
+            result = NULL;
+        } else {
+            result = CFArrayCreate(alloc, keys, count, &kCFTypeArrayCallBacks);
+        }
+	CFAllocatorDeallocate(alloc, keys);
+	if (d) CFRelease(d);
+        return result;
+    }
+}
+
+
+/****************************/
+/*  CFPreferencesDomain     */
+/****************************/
+
+static CFStringRef __CFPreferencesDomainCopyDescription(CFTypeRef cf) {
+    return CFStringCreateWithFormat(__CFPreferencesAllocator(), NULL, CFSTR("<Private CFType %p>\n"), cf);
+}
+
+static void __CFPreferencesDomainDeallocate(CFTypeRef cf) {
+    const struct __CFPreferencesDomain *domain = (struct __CFPreferencesDomain *)cf;
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    domain->_callBacks->freeDomain(alloc, domain->_context, domain->_domain);
+    if (domain->_context) CFRelease(domain->_context);
+}
+
+static CFTypeID __kCFPreferencesDomainTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFPreferencesDomainClass = {
+    0,
+    "CFPreferencesDomain",
+    NULL,      // init
+    NULL,      // copy
+    __CFPreferencesDomainDeallocate,
+    NULL,
+    NULL,
+    NULL,      // 
+    __CFPreferencesDomainCopyDescription
+};
+
+/* This is called once at CFInitialize() time. */
+__private_extern__ void __CFPreferencesDomainInitialize(void) {
+    __kCFPreferencesDomainTypeID = _CFRuntimeRegisterClass(&__CFPreferencesDomainClass);
+}
+
+/* We spend a lot of time constructing these prefixes; we should cache.  REW, 7/19/99 */
+static CFStringRef  _CFPreferencesCachePrefixForUserHost(CFStringRef  userName, CFStringRef  hostName) {
+    if (userName == kCFPreferencesAnyUser && hostName == kCFPreferencesAnyHost) {
+        return (CFStringRef)CFRetain(CFSTR("*/*/"));
+    }
+    CFMutableStringRef result = CFStringCreateMutable(__CFPreferencesAllocator(), 0);
+    if (userName == kCFPreferencesCurrentUser) {
+        userName = CFGetUserName();
+        CFStringAppend(result, userName);
+        CFStringAppend(result, CFSTR("/"));
+    } else if (userName == kCFPreferencesAnyUser) {
+        CFStringAppend(result, CFSTR("*/"));
+    }
+    if (hostName == kCFPreferencesCurrentHost) {
+        CFStringRef hostID = _CFPreferencesGetByHostIdentifierString();
+        CFStringAppend(result, hostID);
+        CFStringAppend(result, CFSTR("/"));
+    } else if (hostName == kCFPreferencesAnyHost) {
+        CFStringAppend(result, CFSTR("*/"));
+    }
+    return result;
+}
+
+// It would be nice if we could remember the key for "well-known" combinations, so we're not constantly allocing more strings....  - REW 2/3/99
+static CFStringRef  _CFPreferencesStandardDomainCacheKey(CFStringRef  domainName, CFStringRef  userName, CFStringRef  hostName) {
+    CFStringRef  prefix = _CFPreferencesCachePrefixForUserHost(userName, hostName);
+    CFStringRef  result = NULL;
+    
+    if (prefix) {
+        result = CFStringCreateWithFormat(__CFPreferencesAllocator(), NULL, CFSTR("%@%@"), prefix, domainName);
+        CFRelease(prefix);
+    }
+    return result;
+}
+
+static CFURLRef _CFPreferencesURLForStandardDomainWithSafetyLevel(CFStringRef domainName, CFStringRef userName, CFStringRef hostName, unsigned long safeLevel) {
+    CFURLRef theURL = NULL;
+    CFAllocatorRef prefAlloc = __CFPreferencesAllocator();
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    CFURLRef prefDir = _preferencesDirectoryForUserHostSafetyLevel(userName, hostName, safeLevel);
+    CFStringRef  appName;
+    CFStringRef  fileName;
+    Boolean mustFreeAppName = false;
+    
+    if (!prefDir) return NULL;
+    if (domainName == kCFPreferencesAnyApplication) {
+        appName = CFSTR(".GlobalPreferences");
+    } else if (domainName == kCFPreferencesCurrentApplication) {
+        CFBundleRef mainBundle = CFBundleGetMainBundle();
+        appName = mainBundle ? CFBundleGetIdentifier(mainBundle) : NULL;
+        if (!appName || CFStringGetLength(appName) == 0) {
+            appName = _CFProcessNameString();
+        }
+    } else {
+        appName = domainName;
+    }
+    if (userName != kCFPreferencesAnyUser) {
+        if (hostName == kCFPreferencesAnyHost) {
+            fileName = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR("%@.plist"), appName);
+        } else if (hostName == kCFPreferencesCurrentHost) {
+            CFStringRef hostID = _CFPreferencesGetByHostIdentifierString();
+            fileName = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR("%@.%@.plist"), appName, hostID);
+        } else {
+            fileName = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR("%@.%@.plist"), appName, hostName);      // sketchy - this allows someone to set an arbitrary hostname.
+        }
+    } else {
+        fileName = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR("%@.plist"), appName);
+    }
+    if (mustFreeAppName) {
+	CFRelease(appName);
+    }
+    if (fileName) {
+        theURL = CFURLCreateWithFileSystemPathRelativeToBase(prefAlloc, fileName, kCFURLPOSIXPathStyle, false, prefDir);
+        if (prefDir) CFRelease(prefDir);
+        CFRelease(fileName);
+    }
+#else
+//#error Do not know where to store NSUserDefaults on this platform
+#endif
+    return theURL;
+}
+
+static CFURLRef _CFPreferencesURLForStandardDomain(CFStringRef domainName, CFStringRef userName, CFStringRef hostName) {
+    return _CFPreferencesURLForStandardDomainWithSafetyLevel(domainName, userName, hostName, __CFSafeLaunchLevel);
+}
+
+CFPreferencesDomainRef _CFPreferencesStandardDomain(CFStringRef  domainName, CFStringRef  userName, CFStringRef  hostName) {
+    CFPreferencesDomainRef domain;
+    CFStringRef  domainKey;
+    Boolean shouldReleaseDomain = true;
+     domainKey = _CFPreferencesStandardDomainCacheKey(domainName, userName, hostName);
+    __CFSpinLock(&domainCacheLock);
+    if (!domainCache) {
+        CFAllocatorRef alloc = __CFPreferencesAllocator();
+        domainCache = CFDictionaryCreateMutable(alloc, 0, & kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    }
+    domain = (CFPreferencesDomainRef)CFDictionaryGetValue(domainCache, domainKey);
+    __CFSpinUnlock(&domainCacheLock);
+    if (!domain) {
+        // Domain's not in the cache; load from permanent storage
+		CFURLRef  theURL = _CFPreferencesURLForStandardDomain(domainName, userName, hostName);
+        if (theURL) {
+			domain = _CFPreferencesDomainCreate(theURL, &__kCFXMLPropertyListDomainCallBacks);
+
+            if (userName == kCFPreferencesAnyUser) {
+                _CFPreferencesDomainSetIsWorldReadable(domain, true);
+            }
+            CFRelease(theURL);
+        }
+	__CFSpinLock(&domainCacheLock);
+        if (domain && domainCache) {
+            // We've just synthesized a domain & we're about to throw it in the domain cache. The problem is that someone else might have gotten in here behind our backs, so we can't just blindly set the domain (3021920). We'll need to check to see if this happened, and compensate.
+            CFPreferencesDomainRef checkDomain = (CFPreferencesDomainRef)CFDictionaryGetValue(domainCache, domainKey);
+            if(checkDomain) {
+                // Someone got in here ahead of us, so we shouldn't smash the domain we're given. checkDomain is the current version, we should use that.
+                // checkDomain was retrieved with a Get, so we don't want to over-release.
+                shouldReleaseDomain = false;
+                CFRelease(domain);	// release the domain we synthesized earlier.
+                domain = checkDomain;	// repoint it at the domain picked up out of the cache.
+            } else {
+                // We must not have found the domain in the cache, so it's ok for us to put this in.
+                CFDictionarySetValue(domainCache, domainKey, domain);                
+            }
+            if(shouldReleaseDomain) CFRelease(domain);
+        }
+	__CFSpinUnlock(&domainCacheLock);
+    }
+    CFRelease(domainKey);
+    return domain;
+}
+
+static void __CFPreferencesPerformSynchronize(const void *key, const void *value, void *context) {
+    CFPreferencesDomainRef domain = (CFPreferencesDomainRef)value;
+    Boolean *cumulativeResult = (Boolean *)context;
+    if (!_CFPreferencesDomainSynchronize(domain)) *cumulativeResult = false;
+}
+
+__private_extern__ Boolean _CFSynchronizeDomainCache(void) {
+    Boolean result = true;
+    __CFSpinLock(&domainCacheLock);
+    if (domainCache) {
+        CFDictionaryApplyFunction(domainCache, __CFPreferencesPerformSynchronize, &result);
+    }
+    __CFSpinUnlock(&domainCacheLock);
+    return result;
+}
+
+__private_extern__ void _CFPreferencesPurgeDomainCache(void) {
+    _CFSynchronizeDomainCache();
+    __CFSpinLock(&domainCacheLock);
+    if (domainCache) {
+        CFRelease(domainCache);
+        domainCache = NULL;
+    }
+    __CFSpinUnlock(&domainCacheLock);
+}
+
+__private_extern__ CFArrayRef  _CFPreferencesCreateDomainList(CFStringRef  userName, CFStringRef  hostName) {
+    CFAllocatorRef prefAlloc = __CFPreferencesAllocator();
+    CFArrayRef  domains;
+    CFMutableArrayRef  marray;
+    CFStringRef  *cachedDomainKeys;
+    CFPreferencesDomainRef *cachedDomains;
+    SInt32 idx, cnt;
+    CFStringRef  suffix;
+    UInt32 suffixLen;
+    CFURLRef prefDir = _preferencesDirectoryForUserHost(userName, hostName);
+    
+    if (!prefDir) {
+        return NULL;
+    }
+    if (hostName == kCFPreferencesAnyHost) {
+        suffix = CFStringCreateWithCString(prefAlloc, ".plist", kCFStringEncodingASCII);
+    } else if (hostName == kCFPreferencesCurrentHost) {
+        CFStringRef hostID = _CFPreferencesGetByHostIdentifierString();
+        suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostID);
+    } else {
+        suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostName);   // sketchy - this allows someone to create a domain list for an arbitrary hostname.
+    }
+    suffixLen = CFStringGetLength(suffix);
+    
+    domains = (CFArrayRef)CFURLCreatePropertyFromResource(prefAlloc, prefDir, kCFURLFileDirectoryContents, NULL);
+    CFRelease(prefDir);
+    if (domains){
+        marray = CFArrayCreateMutableCopy(prefAlloc, 0, domains);
+        CFRelease(domains);
+    } else {
+        marray = CFArrayCreateMutable(prefAlloc, 0, & kCFTypeArrayCallBacks);
+    }
+    for (idx = CFArrayGetCount(marray)-1; idx >= 0; idx --) {
+        CFURLRef  url = (CFURLRef)CFArrayGetValueAtIndex(marray, idx);
+        CFStringRef string = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+        if (!CFStringHasSuffix(string, suffix)) {
+            CFArrayRemoveValueAtIndex(marray, idx);
+        } else {
+            CFStringRef  dom = CFStringCreateWithSubstring(prefAlloc, string, CFRangeMake(0, CFStringGetLength(string) - suffixLen));
+            if (CFEqual(dom, CFSTR(".GlobalPreferences"))) {
+                CFArraySetValueAtIndex(marray, idx, kCFPreferencesAnyApplication);
+            } else {
+                CFArraySetValueAtIndex(marray, idx, dom);
+            }
+            CFRelease(dom);
+        }
+        CFRelease(string);
+    }
+    CFRelease(suffix);
+    
+    // Now add any domains added in the cache; delete any that have been deleted in the cache
+    __CFSpinLock(&domainCacheLock);
+    if (!domainCache) {
+        __CFSpinUnlock(&domainCacheLock);
+        return marray;
+    }
+    cnt = CFDictionaryGetCount(domainCache);
+    cachedDomainKeys = (CFStringRef *)CFAllocatorAllocate(prefAlloc, 2 * cnt * sizeof(CFStringRef), 0);
+    cachedDomains = (CFPreferencesDomainRef *)(cachedDomainKeys + cnt);
+    CFDictionaryGetKeysAndValues(domainCache, (const void **)cachedDomainKeys, (const void **)cachedDomains);
+    __CFSpinUnlock(&domainCacheLock);
+    suffix = _CFPreferencesCachePrefixForUserHost(userName, hostName);
+    suffixLen = CFStringGetLength(suffix);
+    
+    for (idx = 0; idx < cnt; idx ++) {
+        CFStringRef  domainKey = cachedDomainKeys[idx];
+        CFPreferencesDomainRef domain = cachedDomains[idx];
+        CFStringRef  domainName;
+        CFIndex keyCount = 0;
+        
+        if (!CFStringHasPrefix(domainKey, suffix)) continue;
+        domainName = CFStringCreateWithSubstring(prefAlloc, domainKey, CFRangeMake(suffixLen, CFStringGetLength(domainKey) - suffixLen));
+        if (CFEqual(domainName, CFSTR("*"))) {
+            CFRelease(domainName);
+            domainName = (CFStringRef)CFRetain(kCFPreferencesAnyApplication);
+        } else if (CFEqual(domainName, kCFPreferencesCurrentApplication)) {
+            CFRelease(domainName);
+            domainName = (CFStringRef)CFRetain(_CFProcessNameString());
+        }
+        CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain);
+        keyCount = d ? CFDictionaryGetCount(d) : 0;
+        if (keyCount) CFRelease(d);
+        if (keyCount == 0) {
+            // Domain was deleted
+            SInt32 firstIndexOfValue = CFArrayGetFirstIndexOfValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName);
+            if (0 <= firstIndexOfValue) {
+                CFArrayRemoveValueAtIndex(marray, firstIndexOfValue);
+            }
+        } else if (!CFArrayContainsValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName)) {
+            CFArrayAppendValue(marray, domainName);
+        }
+        CFRelease(domainName);
+    }
+    CFRelease(suffix);
+    CFAllocatorDeallocate(prefAlloc, cachedDomainKeys);
+    return marray;
+}
+
+//
+// CFPreferencesDomain functions
+//
+
+CFPreferencesDomainRef _CFPreferencesDomainCreate(CFTypeRef  context, const _CFPreferencesDomainCallBacks *callBacks) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    CFPreferencesDomainRef newDomain;
+    CFAssert(callBacks != NULL && callBacks->createDomain != NULL && callBacks->freeDomain != NULL && callBacks->fetchValue != NULL && callBacks->writeValue != NULL, __kCFLogAssertion, "Cannot create a domain with NULL callbacks");
+    newDomain = (CFPreferencesDomainRef)_CFRuntimeCreateInstance(alloc, __kCFPreferencesDomainTypeID, sizeof(struct __CFPreferencesDomain) - sizeof(CFRuntimeBase), NULL);
+    if (newDomain) {
+        newDomain->_callBacks = callBacks;
+        if (context) CFRetain(context);
+        newDomain->_context = context;
+        newDomain->_domain = callBacks->createDomain(alloc, context);
+    }
+    return newDomain;
+}
+
+CFTypeRef  _CFPreferencesDomainCreateValueForKey(CFPreferencesDomainRef domain, CFStringRef key) {
+    return domain->_callBacks->fetchValue(domain->_context, domain->_domain, key);
+}
+
+void _CFPreferencesDomainSet(CFPreferencesDomainRef domain, CFStringRef  key, CFTypeRef  value) {
+    domain->_callBacks->writeValue(domain->_context, domain->_domain, key, value);
+}
+
+__private_extern__ Boolean _CFPreferencesDomainSynchronize(CFPreferencesDomainRef domain) {
+    return domain->_callBacks->synchronize(domain->_context, domain->_domain);
+}
+
+__private_extern__ void _CFPreferencesDomainSetIsWorldReadable(CFPreferencesDomainRef domain, Boolean isWorldReadable) {
+    if (domain->_callBacks->setIsWorldReadable) {
+        domain->_callBacks->setIsWorldReadable(domain->_context, domain->_domain, isWorldReadable);
+    }
+}
+
+__private_extern__ void *_CFPreferencesDomainCopyDictFunc(CFPreferencesDomainRef domain) {
+    return (void*)domain->_callBacks->copyDomainDictionary;
+}
+
+void _CFPreferencesDomainSetDictionary(CFPreferencesDomainRef domain, CFDictionaryRef dict) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain);
+    CFIndex idx, count = d ? CFDictionaryGetCount(d) : 0;
+
+    CFTypeRef *keys = (CFTypeRef *)CFAllocatorAllocate(alloc, count * sizeof(CFTypeRef), 0);
+    if (d) CFDictionaryGetKeysAndValues(d, keys, NULL);
+    for (idx = 0; idx < count; idx ++) {
+        _CFPreferencesDomainSet(domain, (CFStringRef)keys[idx], NULL);
+    }
+    CFAllocatorDeallocate(alloc, keys);
+    if (d) CFRelease(d);
+
+    if (dict && (count = CFDictionaryGetCount(dict)) != 0) {
+        CFStringRef *newKeys = (CFStringRef *)CFAllocatorAllocate(alloc, count * sizeof(CFStringRef), 0);
+        CFDictionaryGetKeysAndValues(dict, (const void **)newKeys, NULL);
+        for (idx = 0; idx < count; idx ++) {
+            CFStringRef key = newKeys[idx];
+            _CFPreferencesDomainSet(domain, key, (CFTypeRef)CFDictionaryGetValue(dict, key));
+        }
+            CFAllocatorDeallocate(alloc, newKeys);
+    }
+}
+
+CFDictionaryRef _CFPreferencesDomainDeepCopyDictionary(CFPreferencesDomainRef domain) {
+    CFDictionaryRef result = domain->_callBacks->copyDomainDictionary(domain->_context, domain->_domain);
+    if(result && CFDictionaryGetCount(result) == 0) {
+        CFRelease(result);
+        result = NULL;
+    }
+    return result;
+}
+
+Boolean _CFPreferencesDomainExists(CFStringRef domainName, CFStringRef userName, CFStringRef hostName) {
+    CFPreferencesDomainRef domain;
+    domain = _CFPreferencesStandardDomain(domainName, userName, hostName);
+    if (domain) {
+		CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain);
+		if (d) CFRelease(d);
+		return d != NULL;
+    } else {
+        return false;
+    }
+}
+
+/* Volatile domains - context is ignored; domain is a CFDictionary (mutable) */
+static void *createVolatileDomain(CFAllocatorRef allocator, CFTypeRef  context) {
+    return CFDictionaryCreateMutable(allocator, 0, & kCFTypeDictionaryKeyCallBacks, & kCFTypeDictionaryValueCallBacks);
+}
+
+static void freeVolatileDomain(CFAllocatorRef allocator, CFTypeRef  context, void *domain) {
+    CFRelease((CFTypeRef)domain);
+}
+
+static CFTypeRef  fetchVolatileValue(CFTypeRef  context, void *domain, CFStringRef  key) {
+    CFTypeRef  result = CFDictionaryGetValue((CFMutableDictionaryRef  )domain, key);
+    if (result) CFRetain(result);
+    return result;
+}
+
+static void writeVolatileValue(CFTypeRef  context, void *domain, CFStringRef  key, CFTypeRef  value) {
+    if (value)
+        CFDictionarySetValue((CFMutableDictionaryRef  )domain, key, value);
+    else
+        CFDictionaryRemoveValue((CFMutableDictionaryRef  )domain, key);
+}
+
+static Boolean synchronizeVolatileDomain(CFTypeRef  context, void *domain) {
+    return true;
+}
+
+static void getVolatileKeysAndValues(CFAllocatorRef alloc, CFTypeRef context, void *domain, void **buf[], CFIndex *numKeyValuePairs) {
+    CFMutableDictionaryRef dict = (CFMutableDictionaryRef)domain;
+    CFIndex count = CFDictionaryGetCount(dict);
+
+    if (buf) {
+        void **values;
+        if ( count < *numKeyValuePairs ) {
+            values = *buf + count;
+            CFDictionaryGetKeysAndValues(dict, (const void **)*buf, (const void **)values);
+        } else if (alloc != kCFAllocatorNull) {
+            if (*buf) {
+                *buf = (void **)CFAllocatorReallocate(alloc, *buf, count * 2 * sizeof(void *), 0);
+            } else {
+                *buf = (void **)CFAllocatorAllocate(alloc, count*2*sizeof(void *), 0);
+            }
+            if (*buf) {
+                values = *buf + count;
+                CFDictionaryGetKeysAndValues(dict, (const void **)*buf, (const void **)values);
+            }
+        }
+    }
+    *numKeyValuePairs = count;
+}
+
+static CFDictionaryRef copyVolatileDomainDictionary(CFTypeRef context, void *volatileDomain) {
+    CFMutableDictionaryRef dict = (CFMutableDictionaryRef)volatileDomain;
+    
+    CFDictionaryRef result = (CFDictionaryRef)CFPropertyListCreateDeepCopy(__CFPreferencesAllocator(), dict, kCFPropertyListImmutable);
+    return result;
+}
+
+const _CFPreferencesDomainCallBacks __kCFVolatileDomainCallBacks = {createVolatileDomain, freeVolatileDomain, fetchVolatileValue, writeVolatileValue, synchronizeVolatileDomain, getVolatileKeysAndValues, copyVolatileDomainDictionary, NULL};
diff --git a/CoreFoundation/CFPreferences.h b/CoreFoundation/CFPreferences.h
new file mode 100644
index 0000000..44d1cef
--- /dev/null
+++ b/CoreFoundation/CFPreferences.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFPREFERENCES__)
+#define __COREFOUNDATION_CFPREFERENCES__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFString.h>
+
+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);
+
+/* 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
+
+#endif /* ! __COREFOUNDATION_CFPREFERENCES__ */
+
diff --git a/CoreFoundation/CFPriv.h b/CoreFoundation/CFPriv.h
new file mode 100644
index 0000000..b27c59a
--- /dev/null
+++ b/CoreFoundation/CFPriv.h
@@ -0,0 +1,436 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+/*
+        APPLE SPI:  NOT TO BE USED OUTSIDE APPLE!
+*/
+
+#if !defined(__COREFOUNDATION_CFPRIV__)
+#define __COREFOUNDATION_CFPRIV__ 1
+
+#include <string.h>
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFBundlePriv.h>
+
+
+#if defined(__MACH__)
+#include <CoreFoundation/CFMachPort.h>
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFSocket.h>
+#endif
+
+#if defined(COCOTRON) || (defined(__GNUC__) && HAVE_OBJC_OBJC_H) || DEPLOYMENT_TARGET_MACOSX
+#import <objc/objc.h>
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#include <shlobj.h>
+#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 defined(__MACH__)
+CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void);
+CF_EXPORT SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
+
+CF_EXPORT void _CFRunLoopSetCurrent(CFRunLoopRef rl);
+
+CF_EXPORT Boolean _CFRunLoopModeContainsMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef candidateContainedName);
+CF_EXPORT void _CFRunLoopAddModeToMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef toModeName);
+CF_EXPORT void _CFRunLoopRemoveModeFromMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef fromModeName);
+CF_EXPORT void _CFRunLoopStopMode(CFRunLoopRef rl, CFStringRef modeName);
+
+#if defined(__MACH__)
+CF_EXPORT CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp);
+#endif
+
+CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
+CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation);
+#endif
+CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
+CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation);
+
+CF_EXPORT void CFPreferencesFlushCaches(void);
+
+#if !__LP64__
+#if !defined(__WIN32__)
+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
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+enum {
+	kCFURLComponentDecompositionNonHierarchical,
+	kCFURLComponentDecompositionRFC1808, /* use this for RFC 1738 decompositions as well */
+	kCFURLComponentDecompositionRFC2396
+};
+typedef CFIndex CFURLComponentDecomposition;
+
+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
+#endif
+
+
+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 */
+CF_EXPORT
+CFStringRef CFGetUserName(void);
+
+CF_EXPORT
+CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName);	/* Pass NULL for the current user's home directory */
+
+
+/* Extra user notification key for iPhone */
+CF_EXPORT
+const CFStringRef kCFUserNotificationKeyboardTypesKey AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+
+/*
+	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
+	CFStrings. 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.
+*/
+enum {
+    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) */
+    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 CFIndex CFSearchPathDirectory;
+
+enum {
+    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 */
+};
+typedef CFOptionFlags CFSearchPathDomainMask;
+
+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, should be API'd
+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.
+*/
+enum {
+    CFSystemVersionCheetah = 0,         /* 10.0 */
+    CFSystemVersionPuma = 1,            /* 10.1 */
+    CFSystemVersionJaguar = 2,          /* 10.2 */
+    CFSystemVersionPanther = 3,         /* 10.3 */
+    CFSystemVersionPinot = 3,           /* Deprecated name for Panther */
+    CFSystemVersionTiger = 4,           /* 10.4 */
+    CFSystemVersionMerlot = 4,          /* Deprecated name for Tiger */
+    CFSystemVersionLeopard = 5,         /* Post-Tiger */
+    CFSystemVersionChablis = 5,         /* Deprecated name for Leopard */
+    CFSystemVersionMax                  /* This should bump up when new entries are added */
+};
+typedef CFIndex CFSystemVersion;
+
+CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version);
+
+
+enum {
+    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 */
+};
+typedef CFIndex CFStringCharacterClusterType;
+
+CF_EXPORT CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type);
+
+// Compatibility kCFCompare flags. Use the new public kCFCompareDiacriticInsensitive
+enum {
+    kCFCompareDiacriticsInsensitive = 128, /* kCFCompareDiacriticInsensitive */
+    kCFCompareDiacriticsInsensitiveCompatibilityMask = ((1 << 28)|kCFCompareDiacriticsInsensitive),
+};
+
+/* 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);
+
+#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->directBuffer) {
+        return buf->directBuffer + 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;
+            CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
+        }
+
+        return buf->buffer + (desiredRange.location - buf->bufferedRangeStart);
+    }
+}
+
+CF_INLINE void CFStringGetCharactersFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange, UniChar *outBuf) {
+    if (buf->directBuffer) {
+        memmove(outBuf, buf->directBuffer + 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) CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
+    }
+}
+
+#else
+#define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directBuffer ? (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL)
+
+#define CFStringGetCharactersFromInlineBuffer(buf, desiredRange, outBuf) \
+    if (buf->directBuffer) memmove(outBuf, (buf)->directBuffer + (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 */
+
+/*
+ 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 = (1 << 0),
+    kCFCharacterSetNoBitmapAvailable = (1 << 1),
+    kCFCharacterSetIsInverted = (1 << 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(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] & (1 << (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] & (1 << (character % 8))) isInverted = !isInverted;
+            }
+        }
+    }
+    return isInverted;
+}
+#else /* CF_INLINE */
+#define CFCharacterSetInlineBufferIsLongCharacterMember(buffer, character) (CFCharacterSetIsLongCharacterMember(buffer->cset, character))
+#endif /* CF_INLINE */
+
+
+#if defined(__MACH__)
+#include <CoreFoundation/CFMessagePort.h>
+
+CFMessagePortRef CFMessagePortCreatePerProcessLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo);
+CFMessagePortRef CFMessagePortCreatePerProcessRemote(CFAllocatorRef allocator, CFStringRef name, CFIndex pid);
+#endif
+
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFPRIV__ */
+
diff --git a/CoreFoundation/CFPropertyList.c b/CoreFoundation/CFPropertyList.c
new file mode 100644
index 0000000..a1c99c7
--- /dev/null
+++ b/CoreFoundation/CFPropertyList.c
@@ -0,0 +1,2724 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFSet.h>
+#include "CFPriv.h"
+#include "CFStringEncodingConverter.h"
+#include "CFInternal.h"
+#include <CoreFoundation/CFStream.h>
+#include <CoreFoundation/CFCalendar.h>
+#include <limits.h>
+#include <float.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#include <ctype.h>
+#include <CoreFoundation/CFPreferences.h>
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach-o/dyld.h>
+#endif
+
+
+__private_extern__ bool allowMissingSemi = false;
+
+// Should move this somewhere else
+intptr_t _CFDoOperation(intptr_t code, intptr_t subcode1, intptr_t subcode2) {
+    switch (code) {
+    case 15317: allowMissingSemi = subcode1 ? true : false; break;
+    }
+    return code;
+}
+
+#define PLIST_IX    0
+#define ARRAY_IX    1
+#define DICT_IX     2
+#define KEY_IX      3
+#define STRING_IX   4
+#define DATA_IX     5
+#define DATE_IX     6
+#define REAL_IX     7
+#define INTEGER_IX  8
+#define TRUE_IX     9
+#define FALSE_IX    10
+#define DOCTYPE_IX  11
+#define CDSECT_IX   12
+
+#define PLIST_TAG_LENGTH	5
+#define ARRAY_TAG_LENGTH	5
+#define DICT_TAG_LENGTH		4
+#define KEY_TAG_LENGTH		3
+#define STRING_TAG_LENGTH	6
+#define DATA_TAG_LENGTH		4
+#define DATE_TAG_LENGTH		4
+#define REAL_TAG_LENGTH		4
+#define INTEGER_TAG_LENGTH	7
+#define TRUE_TAG_LENGTH		4
+#define FALSE_TAG_LENGTH	5
+#define DOCTYPE_TAG_LENGTH	7
+#define CDSECT_TAG_LENGTH	9
+
+// don't allow _CFKeyedArchiverUID here
+#define __CFAssertIsPList(cf) CFAssert2(CFGetTypeID(cf) == CFStringGetTypeID() || CFGetTypeID(cf) == CFArrayGetTypeID() || CFGetTypeID(cf) == CFBooleanGetTypeID() || CFGetTypeID(cf) == CFNumberGetTypeID() || CFGetTypeID(cf) == CFDictionaryGetTypeID() || CFGetTypeID(cf) == CFDateGetTypeID() || CFGetTypeID(cf) == CFDataGetTypeID(), __kCFLogAssertion, "%s(): %p not of a property list type", __PRETTY_FUNCTION__, cf);
+
+static bool __CFPropertyListIsValidAux(CFPropertyListRef plist, bool recursive, CFMutableSetRef set, CFPropertyListFormat format);
+
+static CFTypeID stringtype = -1, datatype = -1, numbertype = -1, datetype = -1;
+static CFTypeID booltype = -1, nulltype = -1, dicttype = -1, arraytype = -1, settype = -1;
+
+static void initStatics() {
+    if ((CFTypeID)-1 == stringtype) {
+        stringtype = CFStringGetTypeID();
+    }
+    if ((CFTypeID)-1 == datatype) {
+        datatype = CFDataGetTypeID();
+    }
+    if ((CFTypeID)-1 == numbertype) {
+        numbertype = CFNumberGetTypeID();
+    }
+    if ((CFTypeID)-1 == booltype) {
+        booltype = CFBooleanGetTypeID();
+    }
+    if ((CFTypeID)-1 == datetype) {
+        datetype = CFDateGetTypeID();
+    }
+    if ((CFTypeID)-1 == dicttype) {
+        dicttype = CFDictionaryGetTypeID();
+    }
+    if ((CFTypeID)-1 == arraytype) {
+        arraytype = CFArrayGetTypeID();
+    }
+    if ((CFTypeID)-1 == settype) {
+        settype = CFSetGetTypeID();
+    }
+    if ((CFTypeID)-1 == nulltype) {
+        nulltype = CFNullGetTypeID();
+    }
+}
+
+struct context {
+    bool answer;
+    CFMutableSetRef set;
+    CFPropertyListFormat format;
+};
+
+static void __CFPropertyListIsArrayPlistAux(const void *value, void *context) {
+    struct context *ctx = (struct context *)context;
+    if (!ctx->answer) return;
+#if defined(DEBUG)
+    if (!value) CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListIsValid(): property list arrays cannot contain NULL"));
+#endif
+    ctx->answer = value && __CFPropertyListIsValidAux(value, true, ctx->set, ctx->format);
+}
+
+static void __CFPropertyListIsDictPlistAux(const void *key, const void *value, void *context) {
+    struct context *ctx = (struct context *)context;
+    if (!ctx->answer) return;
+#if defined(DEBUG)
+    if (!key) CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListIsValid(): property list dictionaries cannot contain NULL keys"));
+    if (!value) CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListIsValid(): property list dictionaries cannot contain NULL values"));
+    if (stringtype != CFGetTypeID(key)) {
+	CFStringRef desc = CFCopyTypeIDDescription(CFGetTypeID(key));
+	CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListIsValid(): property list dictionaries may only have keys which are CFStrings, not '%@'"), desc);
+	CFRelease(desc);
+    }
+#endif
+    ctx->answer = key && value && (stringtype == CFGetTypeID(key)) && __CFPropertyListIsValidAux(value, true, ctx->set, ctx->format);
+}
+
+static bool __CFPropertyListIsValidAux(CFPropertyListRef plist, bool recursive, CFMutableSetRef set, CFPropertyListFormat format) {
+    CFTypeID type;
+#if defined(DEBUG)
+    if (!plist) CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListIsValid(): property lists cannot contain NULL"));
+#endif
+    if (!plist) return false;
+    type = CFGetTypeID(plist);
+    if (stringtype == type) return true;
+    if (datatype == type) return true;
+    if (kCFPropertyListOpenStepFormat != format) {
+	if (booltype == type) return true;
+	if (numbertype == type) return true;
+	if (datetype == type) return true;
+#if DEPLOYMENT_TARGET_MACOSX
+	if (_CFKeyedArchiverUIDGetTypeID() == type) return true;
+#endif
+    }
+    if (!recursive && arraytype == type) return true;
+    if (!recursive && dicttype == type) return true;
+    // at any one invocation of this function, set should contain the objects in the "path" down to this object
+#if defined(DEBUG)
+    if (CFSetContainsValue(set, plist)) CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListIsValid(): property lists cannot contain recursive container references"));
+#endif
+    if (CFSetContainsValue(set, plist)) return false;
+    if (arraytype == type) {
+	struct context ctx = {true, set, format}; 
+	CFSetAddValue(set, plist);
+	CFArrayApplyFunction((CFArrayRef)plist, CFRangeMake(0, CFArrayGetCount((CFArrayRef)plist)), __CFPropertyListIsArrayPlistAux, &ctx);
+	CFSetRemoveValue(set, plist);
+	return ctx.answer;
+    }
+    if (dicttype == type) {
+	struct context ctx = {true, set, format}; 
+	CFSetAddValue(set, plist);
+	CFDictionaryApplyFunction((CFDictionaryRef)plist, __CFPropertyListIsDictPlistAux, &ctx);
+	CFSetRemoveValue(set, plist);
+	return ctx.answer;
+    }
+#if defined(DEBUG)
+    {
+	CFStringRef desc = CFCopyTypeIDDescription(type);
+	CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListIsValid(): property lists cannot contain objects of type '%@'"), desc);
+	CFRelease(desc);
+    }
+#endif
+    return false;
+}
+
+Boolean CFPropertyListIsValid(CFPropertyListRef plist, CFPropertyListFormat format) {
+    initStatics();
+    CFAssert1(plist != NULL, __kCFLogAssertion, "%s(): NULL is not a property list", __PRETTY_FUNCTION__);
+    CFMutableSetRef set = CFSetCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+    bool result = __CFPropertyListIsValidAux(plist, true, set, format);
+    CFRelease(set);
+    return result;
+}
+
+static const UniChar CFXMLPlistTags[13][10]= {
+{'p', 'l', 'i', 's', 't',   '\0', '\0', '\0', '\0', '\0'},
+{'a', 'r', 'r', 'a', 'y',   '\0', '\0', '\0', '\0', '\0'},
+{'d', 'i', 'c', 't',  '\0', '\0', '\0', '\0', '\0', '\0'},
+{'k', 'e', 'y', '\0', '\0', '\0', '\0', '\0', '\0', '\0'},
+{'s', 't', 'r', 'i', 'n', 'g',    '\0', '\0', '\0', '\0'},
+{'d', 'a', 't', 'a',  '\0', '\0', '\0', '\0', '\0', '\0'},
+{'d', 'a', 't', 'e',  '\0', '\0', '\0', '\0', '\0', '\0'},
+{'r', 'e', 'a', 'l',  '\0', '\0', '\0', '\0', '\0', '\0'},
+{'i', 'n', 't', 'e', 'g', 'e', 'r',     '\0', '\0', '\0'},
+{'t', 'r', 'u', 'e',  '\0', '\0', '\0', '\0', '\0', '\0'},
+{'f', 'a', 'l', 's', 'e',   '\0', '\0', '\0', '\0', '\0'},
+{'D', 'O', 'C', 'T', 'Y', 'P', 'E',     '\0', '\0', '\0'},
+{'<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[',       '\0'}
+};
+
+typedef struct {
+    const UniChar *begin; // first character of the XML to be parsed
+    const UniChar *curr;  // current parse location
+    const UniChar *end;   // the first character _after_ the end of the XML
+    CFStringRef errorString;
+    CFAllocatorRef allocator;
+    UInt32 mutabilityOption;
+    CFMutableSetRef stringSet;  // set of all strings involved in this parse; allows us to share non-mutable strings in the returned plist
+    CFMutableStringRef tmpString; // Mutable string with external characters that functions can feel free to use as temporary storage as the parse progresses
+    Boolean allowNewTypes; // Whether to allow the new types supported by XML property lists, but not by the old, OPENSTEP ASCII property lists (CFNumber, CFBoolean, CFDate)
+    char _padding[3];
+} _CFXMLPlistParseInfo;
+
+static CFTypeRef parseOldStylePropertyListOrStringsFile(_CFXMLPlistParseInfo *pInfo);
+
+
+
+// The following set of _plist... functions append various things to a mutable data which is in UTF8 encoding. These are pretty general. Assumption is call characters and CFStrings can be converted to UTF8 and appeneded.
+
+// Null-terminated, ASCII or UTF8 string
+//
+static void _plistAppendUTF8CString(CFMutableDataRef mData, const char *cString) {
+    CFDataAppendBytes (mData, (const UInt8 *)cString, (CFIndex)strlen(cString));
+}
+
+// UniChars
+//
+static void _plistAppendCharacters(CFMutableDataRef mData, const UniChar *chars, CFIndex length) {
+    CFIndex curLoc = 0;
+
+    do {	// Flush out ASCII chars, BUFLEN at a time
+        #define BUFLEN 400
+	UInt8 buf[BUFLEN], *bufPtr = buf;
+	CFIndex cnt = 0;
+        while (cnt < length && (cnt - curLoc < BUFLEN) && (chars[cnt] < 128)) *bufPtr++ = (UInt8)(chars[cnt++]);
+        if (cnt > curLoc) {	// Flush any ASCII bytes
+            CFDataAppendBytes(mData, buf, cnt - curLoc);
+            curLoc = cnt;
+        }
+    } while (curLoc < length && (chars[curLoc] < 128));	// We will exit out of here when we run out of chars or hit a non-ASCII char
+
+    if (curLoc < length) {	// Now deal with non-ASCII chars
+        CFDataRef data = NULL;
+        CFStringRef str = NULL;
+        if ((str = CFStringCreateWithCharactersNoCopy(kCFAllocatorSystemDefault, chars + curLoc, length - curLoc, kCFAllocatorNull))) {
+            if ((data = CFStringCreateExternalRepresentation(kCFAllocatorSystemDefault, str, kCFStringEncodingUTF8, 0))) {
+                CFDataAppendBytes (mData, CFDataGetBytePtr(data), CFDataGetLength(data));
+                CFRelease(data);
+            }
+            CFRelease(str);
+        }
+        CFAssert1(str && data, __kCFLogAssertion, "%s(): Error writing plist", __PRETTY_FUNCTION__); 
+    }
+}
+
+// Append CFString
+//
+static void _plistAppendString(CFMutableDataRef mData, CFStringRef str) {
+    const UniChar *chars;
+    const char *cStr;
+    CFDataRef data;
+    if ((chars = CFStringGetCharactersPtr(str))) {
+        _plistAppendCharacters(mData, chars, CFStringGetLength(str));
+    } else if ((cStr = CFStringGetCStringPtr(str, kCFStringEncodingASCII)) || (cStr = CFStringGetCStringPtr(str, kCFStringEncodingUTF8))) {
+        _plistAppendUTF8CString(mData, cStr);
+    } else if ((data = CFStringCreateExternalRepresentation(kCFAllocatorSystemDefault, str, kCFStringEncodingUTF8, 0))) {
+        CFDataAppendBytes (mData, CFDataGetBytePtr(data), CFDataGetLength(data));
+        CFRelease(data);
+    } else {
+	CFAssert1(TRUE, __kCFLogAssertion, "%s(): Error in plist writing", __PRETTY_FUNCTION__);
+    }
+}
+
+
+// Append CFString-style format + arguments
+//
+static void _plistAppendFormat(CFMutableDataRef mData, CFStringRef format, ...) {
+    CFStringRef fStr; 
+    va_list argList;
+
+    va_start(argList, format);
+    fStr = CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, NULL, format, argList);
+    va_end(argList);
+
+    CFAssert1(fStr, __kCFLogAssertion, "%s(): Error writing plist", __PRETTY_FUNCTION__);
+    _plistAppendString(mData, fStr);
+    CFRelease(fStr);
+}
+
+
+
+static void _appendIndents(CFIndex numIndents, CFMutableDataRef str) {
+#define NUMTABS 4
+    static const UniChar tabs[NUMTABS] = {'\t','\t','\t','\t'};
+    for (; numIndents > 0; numIndents -= NUMTABS) _plistAppendCharacters(str, tabs, (numIndents >= NUMTABS) ? NUMTABS : numIndents);
+}
+
+/* Append the escaped version of origStr to mStr.
+*/
+static void _appendEscapedString(CFStringRef origStr, CFMutableDataRef mStr) {
+#define BUFSIZE 64
+    CFIndex i, length = CFStringGetLength(origStr);
+    CFIndex bufCnt = 0;
+    UniChar buf[BUFSIZE];
+    CFStringInlineBuffer inlineBuffer;
+
+    CFStringInitInlineBuffer(origStr, &inlineBuffer, CFRangeMake(0, length));
+
+    for (i = 0; i < length; i ++) {
+	UniChar ch = __CFStringGetCharacterFromInlineBufferQuick(&inlineBuffer, i);
+        switch(ch) {
+            case '<':
+		if (bufCnt) _plistAppendCharacters(mStr, buf, bufCnt);
+		bufCnt = 0;
+	  	_plistAppendUTF8CString(mStr, "&lt;");
+                break;
+            case '>':
+		if (bufCnt) _plistAppendCharacters(mStr, buf, bufCnt);
+		bufCnt = 0;
+	  	_plistAppendUTF8CString(mStr, "&gt;");
+                break;
+            case '&':
+		if (bufCnt) _plistAppendCharacters(mStr, buf, bufCnt);
+		bufCnt = 0;
+	  	_plistAppendUTF8CString(mStr, "&amp;");
+                break;
+            default:
+		buf[bufCnt++] = ch;
+		if (bufCnt == BUFSIZE) {
+		    _plistAppendCharacters(mStr, buf, bufCnt);
+		    bufCnt = 0;
+		}
+		break;
+        }
+    }
+    if (bufCnt) _plistAppendCharacters(mStr, buf, bufCnt);
+}
+
+
+
+/* Base-64 encoding/decoding */
+
+/* The base-64 encoding packs three 8-bit bytes into four 7-bit ASCII
+ * characters.  If the number of bytes in the original data isn't divisable
+ * by three, "=" characters are used to pad the encoded data.  The complete
+ * set of characters used in base-64 are:
+ *
+ *      'A'..'Z' => 00..25
+ *      'a'..'z' => 26..51
+ *      '0'..'9' => 52..61
+ *      '+'      => 62
+ *      '/'      => 63
+ *      '='      => pad
+ */
+
+// Write the inputData to the mData using Base 64 encoding
+
+static void _XMLPlistAppendDataUsingBase64(CFMutableDataRef mData, CFDataRef inputData, CFIndex indent) {
+    static const char __CFPLDataEncodeTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+    #define MAXLINELEN 76
+    char buf[MAXLINELEN + 4 + 2];	// For the slop and carriage return and terminating NULL
+    
+    const uint8_t *bytes = CFDataGetBytePtr(inputData);
+    CFIndex length = CFDataGetLength(inputData);
+    CFIndex i, pos;
+    const uint8_t *p;
+
+    if (indent > 8) indent = 8; // refuse to indent more than 64 characters
+
+    pos = 0;		// position within buf
+
+    for (i = 0, p = bytes; i < length; i++, p++) {
+        /* 3 bytes are encoded as 4 */
+        switch (i % 3) {
+            case 0:
+                buf[pos++] = __CFPLDataEncodeTable [ ((p[0] >> 2) & 0x3f)];
+                break;
+            case 1:
+                buf[pos++] = __CFPLDataEncodeTable [ ((((p[-1] << 8) | p[0]) >> 4) & 0x3f)];
+                break;
+            case 2:
+                buf[pos++] = __CFPLDataEncodeTable [ ((((p[-1] << 8) | p[0]) >> 6) & 0x3f)];
+                buf[pos++] = __CFPLDataEncodeTable [ (p[0] & 0x3f)];
+                break;
+        }
+        /* Flush the line out every 76 (or fewer) chars --- indents count against the line length*/
+        if (pos >= MAXLINELEN - 8 * indent) {
+            buf[pos++] = '\n';
+            buf[pos++] = 0;
+            _appendIndents(indent, mData);
+            _plistAppendUTF8CString(mData, buf);
+            pos = 0;
+        }
+    }
+        
+    switch (i % 3) {
+	case 0:
+            break;
+	case 1:
+            buf[pos++] = __CFPLDataEncodeTable [ ((p[-1] << 4) & 0x30)];
+            buf[pos++] = '=';
+            buf[pos++] = '=';
+            break;
+	case 2:
+            buf[pos++] =  __CFPLDataEncodeTable [ ((p[-1] << 2) & 0x3c)];
+            buf[pos++] = '=';
+            break;
+    }
+    
+    if (pos > 0) {
+        buf[pos++] = '\n';
+        buf[pos++] = 0;
+        _appendIndents(indent, mData);
+        _plistAppendUTF8CString(mData, buf);
+    }
+}
+
+extern CFStringRef __CFNumberCopyFormattingDescriptionAsFloat64(CFTypeRef cf);
+
+static void _CFAppendXML0(CFTypeRef object, UInt32 indentation, CFMutableDataRef xmlString) {
+    UInt32 typeID = CFGetTypeID(object);
+    _appendIndents(indentation, xmlString);
+    if (typeID == stringtype) {
+        _plistAppendUTF8CString(xmlString, "<");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[STRING_IX], STRING_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">");
+	_appendEscapedString((CFStringRef)object, xmlString);
+        _plistAppendUTF8CString(xmlString, "</");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[STRING_IX], STRING_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    } else if (typeID == _CFKeyedArchiverUIDGetTypeID()) {
+        _plistAppendUTF8CString(xmlString, "<");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DICT_IX], DICT_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+	    _appendIndents(indentation+1, xmlString);
+	    _plistAppendUTF8CString(xmlString, "<");
+	    _plistAppendCharacters(xmlString, CFXMLPlistTags[KEY_IX], KEY_TAG_LENGTH);
+	    _plistAppendUTF8CString(xmlString, ">");
+	    _appendEscapedString(CFSTR("CF$UID"), xmlString);
+	    _plistAppendUTF8CString(xmlString, "</");
+	    _plistAppendCharacters(xmlString, CFXMLPlistTags[KEY_IX], KEY_TAG_LENGTH);
+	    _plistAppendUTF8CString(xmlString, ">\n");
+	    _appendIndents(indentation + 1, xmlString);
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[INTEGER_IX], INTEGER_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">");
+
+	    uint64_t v = _CFKeyedArchiverUIDGetValue((CFKeyedArchiverUIDRef)object);
+	    CFNumberRef num = CFNumberCreate(kCFAllocatorSystemDefault, kCFNumberSInt64Type, &v);
+            _plistAppendFormat(xmlString, CFSTR("%@"), num);
+	    CFRelease(num);
+
+            _plistAppendUTF8CString(xmlString, "</");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[INTEGER_IX], INTEGER_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">\n");
+        _appendIndents(indentation, xmlString);
+        _plistAppendUTF8CString(xmlString, "</");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DICT_IX], DICT_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+#elif 0
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+    } else if (typeID == arraytype) {
+        UInt32 i, count = CFArrayGetCount((CFArrayRef)object);
+        if (count == 0) {
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[ARRAY_IX], ARRAY_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, "/>\n");
+            return;
+        }
+        _plistAppendUTF8CString(xmlString, "<");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[ARRAY_IX], ARRAY_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+        for (i = 0; i < count; i ++) {
+            _CFAppendXML0(CFArrayGetValueAtIndex((CFArrayRef)object, i), indentation+1, xmlString);
+        }
+        _appendIndents(indentation, xmlString);
+        _plistAppendUTF8CString(xmlString, "</");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[ARRAY_IX], ARRAY_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+    } else if (typeID == dicttype) {
+        UInt32 i, count = CFDictionaryGetCount((CFDictionaryRef)object);
+        CFMutableArrayRef keyArray;
+        CFTypeRef *keys;
+        if (count == 0) {
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[DICT_IX], DICT_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, "/>\n");
+            return;
+        }
+        _plistAppendUTF8CString(xmlString, "<");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DICT_IX], DICT_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+        keys = (CFTypeRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, count * sizeof(CFTypeRef), 0);
+        CFDictionaryGetKeysAndValues((CFDictionaryRef)object, keys, NULL);
+        keyArray = CFArrayCreateMutable(kCFAllocatorSystemDefault, count, &kCFTypeArrayCallBacks);
+        CFArrayReplaceValues(keyArray, CFRangeMake(0, 0), keys, count);
+        CFArraySortValues(keyArray, CFRangeMake(0, count), (CFComparatorFunction)CFStringCompare, NULL);
+        CFArrayGetValues(keyArray, CFRangeMake(0, count), keys);
+        CFRelease(keyArray);
+        for (i = 0; i < count; i ++) {
+            CFTypeRef key = keys[i];
+            _appendIndents(indentation+1, xmlString);
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[KEY_IX], KEY_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">");
+	    _appendEscapedString((CFStringRef)key, xmlString);
+            _plistAppendUTF8CString(xmlString, "</");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[KEY_IX], KEY_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">\n");
+            _CFAppendXML0(CFDictionaryGetValue((CFDictionaryRef)object, key), indentation+1, xmlString);
+        }
+        CFAllocatorDeallocate(kCFAllocatorSystemDefault, keys);
+        _appendIndents(indentation, xmlString);
+        _plistAppendUTF8CString(xmlString, "</");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DICT_IX], DICT_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+    } else if (typeID == datatype) {
+        _plistAppendUTF8CString(xmlString, "<");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DATA_IX], DATA_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+        _XMLPlistAppendDataUsingBase64(xmlString, (CFDataRef)object, indentation);       
+        _appendIndents(indentation, xmlString);
+        _plistAppendUTF8CString(xmlString, "</");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DATA_IX], DATA_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+    } else if (typeID == datetype) {
+        // YYYY '-' MM '-' DD 'T' hh ':' mm ':' ss 'Z'
+	int32_t y = 0, M = 0, d = 0, H = 0, m = 0, s = 0;
+#if 1
+        CFGregorianDate date = CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime((CFDateRef)object), NULL);
+	y = date.year;
+	M = date.month;
+	d = date.day;
+	H = date.hour;
+	m = date.minute;
+	s = (int32_t)date.second;
+#else
+	CFCalendarRef calendar = CFCalendarCreateWithIdentifier(kCFAllocatorSystemDefault, kCFGregorianCalendar);
+	CFTimeZoneRef tz = CFTimeZoneCreateWithName(kCFAllocatorSystemDefault, CFSTR("GMT"), true);
+	CFCalendarSetTimeZone(calendar, tz);
+	CFCalendarDecomposeAbsoluteTime(calendar, CFDateGetAbsoluteTime((CFDateRef)object), (const uint8_t *)"yMdHms", &y, &M, &d, &H, &m, &s);
+	CFRelease(calendar);
+	CFRelease(tz);
+#endif
+        _plistAppendUTF8CString(xmlString, "<");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DATE_IX], DATE_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">");
+        _plistAppendFormat(xmlString, CFSTR("%04d-%02d-%02dT%02d:%02d:%02dZ"), y, M, d, H, m, s);
+        _plistAppendUTF8CString(xmlString, "</");
+        _plistAppendCharacters(xmlString, CFXMLPlistTags[DATE_IX], DATE_TAG_LENGTH);
+        _plistAppendUTF8CString(xmlString, ">\n");
+    } else if (typeID == numbertype) {
+        if (CFNumberIsFloatType((CFNumberRef)object)) {
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">");
+                CFStringRef s = __CFNumberCopyFormattingDescriptionAsFloat64(object);
+                _plistAppendString(xmlString, s);
+                CFRelease(s);
+            _plistAppendUTF8CString(xmlString, "</");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">\n");
+        } else {
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[INTEGER_IX], INTEGER_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">");
+
+            _plistAppendFormat(xmlString, CFSTR("%@"), object);
+
+            _plistAppendUTF8CString(xmlString, "</");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[INTEGER_IX], INTEGER_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, ">\n");
+        }
+    } else if (typeID == booltype) {
+        if (CFBooleanGetValue((CFBooleanRef)object)) {
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[TRUE_IX], TRUE_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, "/>\n");
+        } else {
+            _plistAppendUTF8CString(xmlString, "<");
+            _plistAppendCharacters(xmlString, CFXMLPlistTags[FALSE_IX], FALSE_TAG_LENGTH);
+            _plistAppendUTF8CString(xmlString, "/>\n");
+        }
+    }
+}
+
+static void _CFGenerateXMLPropertyListToData(CFMutableDataRef xml, CFTypeRef propertyList) {
+    _plistAppendUTF8CString(xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE ");
+    _plistAppendCharacters(xml, CFXMLPlistTags[PLIST_IX], PLIST_TAG_LENGTH);
+    _plistAppendUTF8CString(xml, " PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<");
+    _plistAppendCharacters(xml, CFXMLPlistTags[PLIST_IX], PLIST_TAG_LENGTH);
+    _plistAppendUTF8CString(xml, " version=\"1.0\">\n");
+
+    _CFAppendXML0(propertyList, 0, xml);
+
+    _plistAppendUTF8CString(xml, "</");
+    _plistAppendCharacters(xml, CFXMLPlistTags[PLIST_IX], PLIST_TAG_LENGTH);
+    _plistAppendUTF8CString(xml, ">\n");
+}
+
+CFDataRef CFPropertyListCreateXMLData(CFAllocatorRef allocator, CFPropertyListRef propertyList) {
+    initStatics();
+    CFMutableDataRef xml;
+    CFAssert1(propertyList != NULL, __kCFLogAssertion, "%s(): Cannot be called with a NULL property list", __PRETTY_FUNCTION__);
+    __CFAssertIsPList(propertyList);
+	if (!CFPropertyListIsValid(propertyList, kCFPropertyListXMLFormat_v1_0)) return NULL;
+    xml = CFDataCreateMutable(allocator, 0);
+    _CFGenerateXMLPropertyListToData(xml, propertyList);
+    return xml;
+}
+
+CFDataRef _CFPropertyListCreateXMLDataWithExtras(CFAllocatorRef allocator, CFPropertyListRef propertyList) {
+    initStatics();
+    CFMutableDataRef xml;
+    CFAssert1(propertyList != NULL, __kCFLogAssertion, "%s(): Cannot be called with a NULL property list", __PRETTY_FUNCTION__);
+    xml = CFDataCreateMutable(allocator, 0);
+    _CFGenerateXMLPropertyListToData(xml, propertyList);
+    return xml;
+}
+
+// ========================================================================
+
+//
+// ------------------------- Reading plists ------------------
+// 
+
+static void skipInlineDTD(_CFXMLPlistParseInfo *pInfo);
+static CFTypeRef parseXMLElement(_CFXMLPlistParseInfo *pInfo, Boolean *isKey);
+
+// warning: doesn't have a good idea of Unicode line separators
+static UInt32 lineNumber(_CFXMLPlistParseInfo *pInfo) {
+    const UniChar *p = pInfo->begin;
+    UInt32 count = 1;
+    while (p < pInfo->curr) {
+        if (*p == '\r') {
+            count ++;
+            if (*(p + 1) == '\n')
+                p ++;
+        } else if (*p == '\n') {
+            count ++;
+        }
+        p ++;
+    }
+    return count;
+}
+
+// warning: doesn't have a good idea of Unicode white space
+CF_INLINE void skipWhitespace(_CFXMLPlistParseInfo *pInfo) {
+    while (pInfo->curr < pInfo->end) {
+        switch (*(pInfo->curr)) {
+            case ' ':
+            case '\t':
+            case '\n':
+            case '\r':
+                pInfo->curr ++;
+                continue;
+            default:
+                return;
+        }
+    }
+}
+
+/* All of these advance to the end of the given construct and return a pointer to the first character beyond the construct.  If the construct doesn't parse properly, NULL is returned. */
+
+// pInfo should be just past "<!--"
+static void skipXMLComment(_CFXMLPlistParseInfo *pInfo) {
+    const UniChar *p = pInfo->curr;
+    const UniChar *end = pInfo->end - 3; // Need at least 3 characters to compare against
+    while (p < end) {
+        if (*p == '-' && *(p+1) == '-' && *(p+2) == '>') {
+            pInfo->curr = p+3;
+            return;
+        }
+        p ++; 
+    }
+    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unterminated comment started on line %d"), lineNumber(pInfo));
+}
+
+// stringToMatch and buf must both be of at least len
+static Boolean matchString(const UniChar *buf, const UniChar *stringToMatch, UInt32 len) {
+    switch (len) {
+	case 10: if (buf[9] != stringToMatch[9]) return false;
+	case 9: if (buf[8] != stringToMatch[8]) return false;
+	case 8: if (buf[7] != stringToMatch[7]) return false;
+	case 7: if (buf[6] != stringToMatch[6]) return false;
+	case 6: if (buf[5] != stringToMatch[5]) return false;
+	case 5: if (buf[4] != stringToMatch[4]) return false;
+	case 4: if (buf[3] != stringToMatch[3]) return false;
+	case 3: if (buf[2] != stringToMatch[2]) return false;
+	case 2: if (buf[1] != stringToMatch[1]) return false;
+	case 1: if (buf[0] != stringToMatch[0]) return false;
+	case 0: return true;
+    }
+    return false; // internal error
+}
+
+// pInfo should be set to the first character after "<?"
+static void skipXMLProcessingInstruction(_CFXMLPlistParseInfo *pInfo) {
+    const UniChar *begin = pInfo->curr, *end = pInfo->end - 2; // Looking for "?>" so we need at least 2 characters
+    while (pInfo->curr < end) {
+        if (*(pInfo->curr) == '?' && *(pInfo->curr+1) == '>') {
+            pInfo->curr += 2;
+            return;
+        }
+        pInfo->curr ++; 
+    }
+    pInfo->curr = begin;
+    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected EOF while parsing the processing instruction begun on line %d"), lineNumber(pInfo));
+}
+
+// first character should be immediately after the "<!"
+static void skipDTD(_CFXMLPlistParseInfo *pInfo) {
+    // First pass "DOCTYPE"
+    if (pInfo->end - pInfo->curr < DOCTYPE_TAG_LENGTH || !matchString(pInfo->curr, CFXMLPlistTags[DOCTYPE_IX], DOCTYPE_TAG_LENGTH)) {
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Malformed DTD on line %d"), lineNumber(pInfo));
+        return;
+    }
+    pInfo->curr += DOCTYPE_TAG_LENGTH;
+    skipWhitespace(pInfo);
+
+    // Look for either the beginning of a complex DTD or the end of the DOCTYPE structure
+    while (pInfo->curr < pInfo->end) {
+        UniChar ch = *(pInfo->curr);
+        if (ch == '[') break; // inline DTD
+        if (ch == '>') {  // End of the DTD
+            pInfo->curr ++;
+            return;
+        }
+        pInfo->curr ++;
+    }
+    if (pInfo->curr == pInfo->end) {
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF while parsing DTD", CFStringGetSystemEncoding());
+        return;
+    }
+
+    // *Sigh* Must parse in-line DTD
+    skipInlineDTD(pInfo);
+    if (pInfo->errorString)  return;
+    skipWhitespace(pInfo);
+    if (pInfo->errorString) return;
+    if (pInfo->curr < pInfo->end) {
+        if (*(pInfo->curr) == '>') {
+            pInfo->curr ++;
+        } else {
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c on line %d while parsing DTD"), *(pInfo->curr), lineNumber(pInfo));
+        }
+    } else {
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF while parsing DTD", CFStringGetSystemEncoding());
+    }
+}
+
+static void skipPERef(_CFXMLPlistParseInfo *pInfo) {
+    const UniChar *p = pInfo->curr;
+    while (p < pInfo->end) {
+        if (*p == ';') {
+            pInfo->curr = p+1;
+            return;
+        }
+        p ++;
+    }
+    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected EOF while parsing percent-escape sequence begun on line %d"), lineNumber(pInfo));
+}
+
+// First character should be just past '['
+static void skipInlineDTD(_CFXMLPlistParseInfo *pInfo) {
+    while (!pInfo->errorString && pInfo->curr < pInfo->end) {
+        UniChar ch;
+        skipWhitespace(pInfo);
+        ch = *pInfo->curr;
+        if (ch == '%') {
+            pInfo->curr ++;
+            skipPERef(pInfo);
+        } else if (ch == '<') {
+            pInfo->curr ++;
+            if (pInfo->curr >= pInfo->end) {
+                pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF while parsing inline DTD", CFStringGetSystemEncoding());
+                return;
+            }
+            ch = *(pInfo->curr);
+            if (ch == '?') {
+                pInfo->curr ++;
+                skipXMLProcessingInstruction(pInfo);
+            } else if (ch == '!') {
+                if (pInfo->curr + 2 < pInfo->end && (*(pInfo->curr+1) == '-' && *(pInfo->curr+2) == '-')) {
+                    pInfo->curr += 3;
+                    skipXMLComment(pInfo);
+                } else {
+                    // Skip the myriad of DTD declarations of the form "<!string" ... ">"
+                    pInfo->curr ++; // Past both '<' and '!'
+                    while (pInfo->curr < pInfo->end) {
+                        if (*(pInfo->curr) == '>') break;
+                        pInfo->curr ++;
+                    }
+                    if (*(pInfo->curr) != '>') {
+                        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF while parsing inline DTD", CFStringGetSystemEncoding());
+                        return;
+                 
+   }
+                    pInfo->curr ++;
+                }
+            } else {
+                pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c on line %d while parsing inline DTD"), ch, lineNumber(pInfo));
+                return;
+            }
+        } else if (ch == ']') {
+            pInfo->curr ++;
+            return;
+        } else {
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c on line %d while parsing inline DTD"), ch, lineNumber(pInfo));
+            return;
+        }
+    }
+    if (!pInfo->errorString)
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF while parsing inline DTD", CFStringGetSystemEncoding());
+}
+
+/* A bit wasteful to do everything with unichars (since we know all the characters we're going to see are 7-bit ASCII), but since our data is coming from or going to a CFString, this prevents the extra cost of converting formats. */
+
+static const signed char __CFPLDataDecodeTable[128] = {
+    /* 000 */ -1, -1, -1, -1, -1, -1, -1, -1,
+    /* 010 */ -1, -1, -1, -1, -1, -1, -1, -1,
+    /* 020 */ -1, -1, -1, -1, -1, -1, -1, -1,
+    /* 030 */ -1, -1, -1, -1, -1, -1, -1, -1,
+    /* ' ' */ -1, -1, -1, -1, -1, -1, -1, -1,
+    /* '(' */ -1, -1, -1, 62, -1, -1, -1, 63,
+    /* '0' */ 52, 53, 54, 55, 56, 57, 58, 59,
+    /* '8' */ 60, 61, -1, -1, -1,  0, -1, -1,
+    /* '@' */ -1,  0,  1,  2,  3,  4,  5,  6,
+    /* 'H' */  7,  8,  9, 10, 11, 12, 13, 14,
+    /* 'P' */ 15, 16, 17, 18, 19, 20, 21, 22,
+    /* 'X' */ 23, 24, 25, -1, -1, -1, -1, -1,
+    /* '`' */ -1, 26, 27, 28, 29, 30, 31, 32,
+    /* 'h' */ 33, 34, 35, 36, 37, 38, 39, 40,
+    /* 'p' */ 41, 42, 43, 44, 45, 46, 47, 48,
+    /* 'x' */ 49, 50, 51, -1, -1, -1, -1, -1
+};
+
+static CFDataRef __CFPLDataDecode(_CFXMLPlistParseInfo *pInfo, Boolean isMutable) {
+    int tmpbufpos = 0;
+    int tmpbuflen = 256;
+    uint8_t *tmpbuf;
+    int numeq = 0;
+    int acc = 0;
+    int cntr = 0;
+
+    tmpbuf = (uint8_t *)CFAllocatorAllocate(pInfo->allocator, tmpbuflen, 0);
+    for (; pInfo->curr < pInfo->end; pInfo->curr++) {
+        UniChar c = *(pInfo->curr);
+        if (c == '<') {
+            break;
+	}
+        if ('=' == c) {
+            numeq++;
+        } else if (!isspace(c)) {
+            numeq = 0;
+        }
+        if (__CFPLDataDecodeTable[c] < 0)
+            continue;
+        cntr++;
+        acc <<= 6;
+        acc += __CFPLDataDecodeTable[c];
+        if (0 == (cntr & 0x3)) {
+            if (tmpbuflen <= tmpbufpos + 2) {
+		if (tmpbuflen < 256 * 1024) {
+		    tmpbuflen *= 4;
+		} else if (tmpbuflen < 16 * 1024 * 1024) {
+		    tmpbuflen *= 2;
+		} else {
+		    // once in this stage, this will be really slow
+		    // and really potentially fragment memory
+		    tmpbuflen += 256 * 1024;
+		}
+                tmpbuf = (uint8_t *)CFAllocatorReallocate(pInfo->allocator, tmpbuf, tmpbuflen, 0);
+		if (!tmpbuf) HALT;
+            }
+            tmpbuf[tmpbufpos++] = (acc >> 16) & 0xff;
+            if (numeq < 2)
+                tmpbuf[tmpbufpos++] = (acc >> 8) & 0xff;
+            if (numeq < 1)
+                tmpbuf[tmpbufpos++] = acc & 0xff;
+        }
+    }
+    if (isMutable) {
+        CFMutableDataRef result = CFDataCreateMutable(pInfo->allocator, 0);
+        CFDataAppendBytes(result, tmpbuf, tmpbufpos);
+	CFAllocatorDeallocate(pInfo->allocator, tmpbuf);
+        return result;
+    } else {
+        return CFDataCreateWithBytesNoCopy(pInfo->allocator, tmpbuf, tmpbufpos, pInfo->allocator);
+    }
+}
+
+// content ::== (element | CharData | Reference | CDSect | PI | Comment)*
+// In the context of a plist, CharData, Reference and CDSect are not legal (they all resolve to strings).  Skipping whitespace, then, the next character should be '<'.  From there, we figure out which of the three remaining cases we have (element, PI, or Comment).
+static CFTypeRef getContentObject(_CFXMLPlistParseInfo *pInfo, Boolean *isKey) {
+    if (isKey) *isKey = false;
+    while (!pInfo->errorString && pInfo->curr < pInfo->end) {
+        skipWhitespace(pInfo);
+        if (pInfo->curr >= pInfo->end) {
+            pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+            return NULL;
+        }
+        if (*(pInfo->curr) != '<') {
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c on line %d"), *(pInfo->curr), lineNumber(pInfo));
+            return NULL;
+        }
+        pInfo->curr ++;
+        if (pInfo->curr >= pInfo->end) {
+            pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+            return NULL;
+        }
+        switch (*(pInfo->curr)) {
+            case '?':
+                // Processing instruction
+                skipXMLProcessingInstruction(pInfo);
+                break;
+            case '!':
+                // Could be a comment
+                if (pInfo->curr+2 >= pInfo->end) {
+                    pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+                    return NULL;
+                }
+                if (*(pInfo->curr+1) == '-' && *(pInfo->curr+2) == '-') {
+                    pInfo->curr += 2;
+                    skipXMLComment(pInfo);
+                } else {
+                    pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+                    return NULL;
+                }
+                break;
+            case '/':
+                // Whoops!  Looks like we got to the end tag for the element whose content we're parsing
+                pInfo->curr --; // Back off to the '<'
+                return NULL;
+            default:
+                // Should be an element
+                return parseXMLElement(pInfo, isKey);
+        }
+    }
+    // Do not set the error string here; if it wasn't already set by one of the recursive parsing calls, the caller will quickly detect the failure (b/c pInfo->curr >= pInfo->end) and provide a more useful one of the form "end tag for <blah> not found"
+    return NULL;
+}
+
+static void _catFromMarkToBuf(const UniChar *mark, const UniChar *buf, CFMutableStringRef *string, CFAllocatorRef allocator ) {
+    if (!(*string)) {
+        *string = CFStringCreateMutable(allocator, 0);
+    }
+    CFStringAppendCharacters(*string, mark, buf-mark);
+}
+
+static void parseCDSect_pl(_CFXMLPlistParseInfo *pInfo, CFMutableStringRef string) {
+    const UniChar *end, *begin;
+    if (pInfo->end - pInfo->curr < CDSECT_TAG_LENGTH) {
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+        return;
+    }
+    if (!matchString(pInfo->curr, CFXMLPlistTags[CDSECT_IX], CDSECT_TAG_LENGTH)) {
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered improper CDATA opening at line %d"), lineNumber(pInfo));
+        return;
+    }
+    pInfo->curr += CDSECT_TAG_LENGTH;
+    begin = pInfo->curr; // Marks the first character of the CDATA content
+    end = pInfo->end-2; // So we can safely look 2 characters beyond p
+    while (pInfo->curr < end) {
+        if (*(pInfo->curr) == ']' && *(pInfo->curr+1) == ']' && *(pInfo->curr+2) == '>') {
+           // Found the end!
+            CFStringAppendCharacters(string, begin, pInfo->curr-begin);
+            pInfo->curr += 3;
+            return;
+        }
+        pInfo->curr ++;
+    }
+    // Never found the end mark
+    pInfo->curr = begin;
+    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Could not find end of CDATA started on line %d"), lineNumber(pInfo));
+}
+
+// Only legal references are {lt, gt, amp, apos, quote, #ddd, #xAAA}
+static void parseEntityReference_pl(_CFXMLPlistParseInfo *pInfo, CFMutableStringRef string) {
+    int len;
+    UniChar ch;
+    pInfo->curr ++; // move past the '&';
+    len = pInfo->end - pInfo->curr; // how many characters we can safely scan
+    if (len < 1) {
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+        return;
+    }
+    switch (*(pInfo->curr)) {
+        case 'l':  // "lt"
+            if (len >= 3 && *(pInfo->curr+1) == 't' && *(pInfo->curr+2) == ';') {
+                ch = '<';
+                pInfo->curr += 3;
+                break;
+            }
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(pInfo));
+            return;
+        case 'g': // "gt"
+            if (len >= 3 && *(pInfo->curr+1) == 't' && *(pInfo->curr+2) == ';') {
+                ch = '>';
+                pInfo->curr += 3;
+                break;
+            }
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(pInfo));
+            return;
+        case 'a': // "apos" or "amp"
+            if (len < 4) {   // Not enough characters for either conversion
+                pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+                return;
+            }
+            if (*(pInfo->curr+1) == 'm') {
+                // "amp"
+                if (*(pInfo->curr+2) == 'p' && *(pInfo->curr+3) == ';') {
+                    ch = '&';
+                    pInfo->curr += 4;
+                    break;
+                }
+            } else if (*(pInfo->curr+1) == 'p') {
+                // "apos"
+                if (len > 4 && *(pInfo->curr+2) == 'o' && *(pInfo->curr+3) == 's' && *(pInfo->curr+4) == ';') {
+                    ch = '\'';
+                    pInfo->curr += 5;
+                    break;
+                }
+            }
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(pInfo));
+            return;
+        case 'q':  // "quote"
+            if (len >= 5 && *(pInfo->curr+1) == 'u' && *(pInfo->curr+2) == 'o' && *(pInfo->curr+3) == 't' && *(pInfo->curr+4) == ';') {
+                ch = '\"';
+                pInfo->curr += 5;
+                break;
+            }
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(pInfo));
+            return;
+        case '#':
+        {
+            uint16_t num = 0;
+            Boolean isHex = false;
+            if ( len < 4) {  // Not enough characters to make it all fit!  Need at least "&#d;"
+                pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+                return;
+            }
+            pInfo->curr ++;
+            if (*(pInfo->curr) == 'x') {
+                isHex = true;
+                pInfo->curr ++;
+            }
+            while (pInfo->curr < pInfo->end) {
+                ch = *(pInfo->curr);
+                pInfo->curr ++;
+                if (ch == ';') {
+                    CFStringAppendCharacters(string, &num, 1);
+                    return;
+                }
+                if (!isHex) num = num*10;
+                else num = num << 4;
+                if (ch <= '9' && ch >= '0') {
+                    num += (ch - '0');
+                } else if (!isHex) {
+                    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c at line %d"), ch, lineNumber(pInfo));
+                    return;
+                } else if (ch >= 'a' && ch <= 'f') {
+                    num += 10 + (ch - 'a');
+                } else if (ch >= 'A' && ch <= 'F') {
+                    num += 10 + (ch - 'A');
+                } else {
+                    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c at line %d"), ch, lineNumber(pInfo));
+                    return;                    
+                }
+            }
+            pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+            return;
+        }
+        default:
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(pInfo));
+            return;
+    }
+    CFStringAppendCharacters(string, &ch, 1);
+}
+
+static CFStringRef _uniqueStringForString(_CFXMLPlistParseInfo *pInfo, CFStringRef stringToUnique) {
+    if (!pInfo->stringSet) {
+        pInfo->stringSet = CFSetCreateMutable(pInfo->allocator, 0, &kCFCopyStringSetCallBacks);
+	_CFSetSetCapacity(pInfo->stringSet, 160);	// set capacity high to avoid lots of rehashes, though waste some memory
+    }
+    CFSetAddValue(pInfo->stringSet, stringToUnique);
+    return (CFStringRef)CFSetGetValue(pInfo->stringSet, stringToUnique);
+}
+
+extern void _CFStrSetDesiredCapacity(CFMutableStringRef str, CFIndex len);
+
+static CFStringRef _uniqueStringForCharacters(_CFXMLPlistParseInfo *pInfo, const UniChar *base, CFIndex length) {
+    CFIndex idx;
+    uint8_t *ascii, buffer[1024];
+    bool isASCII;
+    if (!pInfo->stringSet) {
+        pInfo->stringSet = CFSetCreateMutable(pInfo->allocator, 0, &kCFCopyStringSetCallBacks);
+	_CFSetSetCapacity(pInfo->stringSet, 160);	// set capacity high to avoid lots of rehashes, though waste some memory
+    }
+    if (pInfo->tmpString) {
+	CFStringDelete(pInfo->tmpString, CFRangeMake(0, CFStringGetLength(pInfo->tmpString)));
+    } else {
+        pInfo->tmpString = CFStringCreateMutable(pInfo->allocator, 0);
+	_CFStrSetDesiredCapacity(pInfo->tmpString, 512);
+    }
+    // This is to avoid having to promote the buffers of all the strings compared against
+    // during the set probe; if a Unicode string is passed in, that's what happens.
+    isASCII = true;
+    for (idx = 0; isASCII && idx < length; idx++) isASCII = isASCII && (base[idx] < 0x80);
+    if (isASCII) {
+	ascii = (length < (CFIndex)sizeof(buffer)) ? buffer : (uint8_t *)CFAllocatorAllocate(kCFAllocatorSystemDefault, length + 1, 0);
+	for (idx = 0; idx < length; idx++) ascii[idx] = (uint8_t)base[idx];
+	ascii[length] = '\0';
+	CFStringAppendCString(pInfo->tmpString, (char *)ascii, kCFStringEncodingASCII);
+	if (ascii != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, ascii);
+    } else {
+	CFStringAppendCharacters(pInfo->tmpString, base, length);
+    }
+    CFSetAddValue(pInfo->stringSet, pInfo->tmpString);
+    return (CFStringRef)CFSetGetValue(pInfo->stringSet, pInfo->tmpString);
+}
+
+
+// String could be comprised of characters, CDSects, or references to one of the "well-known" entities ('<', '>', '&', ''', '"')
+// returns a retained object in *string.
+static CFStringRef getString(_CFXMLPlistParseInfo *pInfo) {
+    const UniChar *mark = pInfo->curr; // At any time in the while loop below, the characters between mark and p have not yet been added to *string
+    CFMutableStringRef string = NULL;
+    while (!pInfo->errorString && pInfo->curr < pInfo->end) {
+        UniChar ch = *(pInfo->curr);
+        if (ch == '<') {
+	    if (pInfo->curr + 1 >= pInfo->end) break;
+            // Could be a CDSect; could be the end of the string
+            if (*(pInfo->curr+1) != '!') break; // End of the string
+            _catFromMarkToBuf(mark, pInfo->curr, &string, pInfo->allocator);
+            parseCDSect_pl(pInfo, string);
+            mark = pInfo->curr;
+        } else if (ch == '&') {
+            _catFromMarkToBuf(mark, pInfo->curr, &string, pInfo->allocator);
+            parseEntityReference_pl(pInfo, string);
+            mark = pInfo->curr;
+        } else {
+            pInfo->curr ++;
+        }
+    }
+
+    if (pInfo->errorString) {
+        if (string) CFRelease(string);
+        return NULL;
+    }
+    if (!string) {
+        if (pInfo->mutabilityOption != kCFPropertyListMutableContainersAndLeaves) {
+            CFStringRef uniqueString = _uniqueStringForCharacters(pInfo, mark, pInfo->curr-mark);
+            if (uniqueString) CFRetain(uniqueString);
+            return uniqueString;
+        } else {
+            string = CFStringCreateMutable(pInfo->allocator, 0);
+            CFStringAppendCharacters(string, mark, pInfo->curr - mark);
+            return string;
+        }
+    }
+    _catFromMarkToBuf(mark, pInfo->curr, &string, pInfo->allocator);
+    if (pInfo->mutabilityOption != kCFPropertyListMutableContainersAndLeaves) {
+        CFStringRef uniqueString = _uniqueStringForString(pInfo, string);
+        if (uniqueString) CFRetain(uniqueString);
+        CFRelease(string);
+        return uniqueString;
+    }
+    return string;
+}
+
+static Boolean checkForCloseTag(_CFXMLPlistParseInfo *pInfo, const UniChar *tag, CFIndex tagLen) {
+    if (pInfo->end - pInfo->curr < tagLen + 3) {
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+        return false;
+    }
+    if (*(pInfo->curr) != '<' || *(++pInfo->curr) != '/') {
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c on line %d"), *(pInfo->curr), lineNumber(pInfo));
+        return false;
+    }
+    pInfo->curr ++;
+    if (!matchString(pInfo->curr, tag, tagLen)) {
+        CFStringRef str = CFStringCreateWithCharactersNoCopy(pInfo->allocator, tag, tagLen, kCFAllocatorNull);
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Close tag on line %d does not match open tag %@"), lineNumber(pInfo), str);
+        CFRelease(str);
+        return false;
+    }
+    pInfo->curr += tagLen;
+    skipWhitespace(pInfo);
+    if (pInfo->curr == pInfo->end) {
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+        return false;
+    }
+    if (*(pInfo->curr) != '>') {
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected character %c on line %d"), *(pInfo->curr), lineNumber(pInfo));
+        return false;
+    }
+    pInfo->curr ++;
+    return true;
+}
+
+// pInfo should be set to the first content character of the <plist>
+static CFTypeRef parsePListTag(_CFXMLPlistParseInfo *pInfo) {
+    CFTypeRef result, tmp = NULL;
+    const UniChar *save;
+    result = getContentObject(pInfo, NULL);
+    if (!result) {
+        if (!pInfo->errorString) pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered empty plist tag", CFStringGetSystemEncoding());
+        return NULL;
+    }
+    save = pInfo->curr; // Save this in case the next step fails
+    tmp = getContentObject(pInfo, NULL);
+    if (tmp) {
+        // Got an extra object
+        CFRelease(tmp);
+        CFRelease(result);
+        pInfo->curr = save;
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unexpected element at line %d (plist can only include one object)"), lineNumber(pInfo));
+        return NULL;
+    }
+    if (pInfo->errorString) {
+        // Parse failed catastrophically
+        CFRelease(result);
+        return NULL;
+    }
+    if (checkForCloseTag(pInfo, CFXMLPlistTags[PLIST_IX], PLIST_TAG_LENGTH)) {
+        return result;
+    }
+    CFRelease(result);
+    return NULL;
+}
+
+static int allowImmutableCollections = -1;
+
+static void checkImmutableCollections(void) {
+    allowImmutableCollections = (NULL == getenv("CFPropertyListAllowImmutableCollections")) ? 0 : 1;
+}
+
+static CFTypeRef parseArrayTag(_CFXMLPlistParseInfo *pInfo) {
+    CFMutableArrayRef array = CFArrayCreateMutable(pInfo->allocator, 0, &kCFTypeArrayCallBacks);
+    CFTypeRef tmp = getContentObject(pInfo, NULL);
+    while (tmp) {
+        CFArrayAppendValue(array, tmp);
+        CFRelease(tmp);
+        tmp = getContentObject(pInfo, NULL);
+    }
+    if (pInfo->errorString) { // getContentObject encountered a parse error
+        CFRelease(array);
+        return NULL;
+    }
+    if (checkForCloseTag(pInfo, CFXMLPlistTags[ARRAY_IX], ARRAY_TAG_LENGTH)) {
+	if (-1 == allowImmutableCollections) checkImmutableCollections();
+	if (1 == allowImmutableCollections) {
+	    if (pInfo->mutabilityOption == kCFPropertyListImmutable) {
+		CFArrayRef newArray = CFArrayCreateCopy(pInfo->allocator, array);
+		CFRelease(array);
+		array = (CFMutableArrayRef)newArray;
+	    }
+	}
+	return array;
+    }
+    CFRelease(array);
+    return NULL;
+}
+
+static CFTypeRef parseDictTag(_CFXMLPlistParseInfo *pInfo) {
+    CFMutableDictionaryRef dict = NULL;
+    CFTypeRef key=NULL, value=NULL;
+    Boolean gotKey;
+    const UniChar *base = pInfo->curr;
+    key = getContentObject(pInfo, &gotKey);
+    while (key) {
+        if (!gotKey) {
+            if (key) CFRelease(key);
+            if (dict) CFRelease(dict);
+            pInfo->curr = base;
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Found non-key inside <dict> at line %d"), lineNumber(pInfo));
+            return NULL;
+        }
+        value = getContentObject(pInfo, NULL);
+        if (!value) {
+            if (key) CFRelease(key);
+            if (dict) CFRelease(dict);
+            if (!pInfo->errorString)
+                pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Value missing for key inside <dict> at line %d"), lineNumber(pInfo));
+            return NULL;
+        }
+	if (NULL == dict) {
+	    dict = CFDictionaryCreateMutable(pInfo->allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+	    _CFDictionarySetCapacity(dict, 10);
+	}
+        CFDictionarySetValue(dict, key, value);
+        CFRelease(key);
+        key = NULL;
+        CFRelease(value);
+        value = NULL;
+        base = pInfo->curr;
+        key = getContentObject(pInfo, &gotKey);
+    }
+    if (checkForCloseTag(pInfo, CFXMLPlistTags[DICT_IX], DICT_TAG_LENGTH)) {
+	if (NULL == dict) {
+	    if (pInfo->mutabilityOption == kCFPropertyListImmutable) {
+		dict = (CFMutableDictionaryRef)CFDictionaryCreate(pInfo->allocator, NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+	    } else {
+		dict = CFDictionaryCreateMutable(pInfo->allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+	    }
+	} else {
+	    CFIndex cnt = CFDictionaryGetCount(dict);
+#if DEPLOYMENT_TARGET_MACOSX
+	    if (1 == cnt) {
+		CFTypeRef val = CFDictionaryGetValue(dict, CFSTR("CF$UID"));
+		if (val && CFGetTypeID(val) == numbertype) {
+		    CFTypeRef uid;
+		    uint32_t v;
+		    CFNumberGetValue((CFNumberRef)val, kCFNumberSInt32Type, &v);
+		    uid = (CFTypeRef)_CFKeyedArchiverUIDCreate(pInfo->allocator, v);
+		    CFRelease(dict);
+		    return uid;
+		}
+	    }
+#endif
+	    if (-1 == allowImmutableCollections) checkImmutableCollections();
+	    if (1 == allowImmutableCollections) {
+		if (pInfo->mutabilityOption == kCFPropertyListImmutable) {
+		    CFDictionaryRef newDict = CFDictionaryCreateCopy(pInfo->allocator, dict);
+		    CFRelease(dict);
+		    dict = (CFMutableDictionaryRef)newDict;
+		}
+	    }
+	}
+        return dict;
+    }
+    if (dict) CFRelease(dict);
+    return NULL;
+}
+
+static CFTypeRef parseDataTag(_CFXMLPlistParseInfo *pInfo) {
+    CFDataRef result;
+    const UniChar *base = pInfo->curr;
+    result = __CFPLDataDecode(pInfo, pInfo->mutabilityOption == kCFPropertyListMutableContainersAndLeaves);
+    if (!result) {
+        pInfo->curr = base;
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Could not interpret <data> at line %d (should be base64-encoded)"), lineNumber(pInfo));
+        return NULL;
+    }
+    if (checkForCloseTag(pInfo, CFXMLPlistTags[DATA_IX], DATA_TAG_LENGTH)) return result;
+    CFRelease(result);
+    return NULL;
+}
+
+CF_INLINE Boolean read2DigitNumber(_CFXMLPlistParseInfo *pInfo, int32_t *result) {
+    UniChar ch1, ch2;
+    if (pInfo->curr + 2 >= pInfo->end) return false;
+    ch1 = *pInfo->curr;
+    ch2 = *(pInfo->curr + 1);
+    pInfo->curr += 2;
+    if (!isdigit(ch1) || !isdigit(ch2)) return false;
+    *result = (ch1 - '0')*10 + (ch2 - '0');
+    return true;
+}
+
+// YYYY '-' MM '-' DD 'T' hh ':' mm ':' ss 'Z'
+static CFTypeRef parseDateTag(_CFXMLPlistParseInfo *pInfo) {
+    int32_t year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
+    int32_t num = 0;
+    Boolean badForm = false;
+
+    while (pInfo->curr < pInfo->end && isdigit(*pInfo->curr)) {
+        year = 10*year + (*pInfo->curr) - '0';
+        pInfo->curr ++;
+    }
+    if (pInfo->curr >= pInfo->end || *pInfo->curr != '-') {
+        badForm = true;
+    } else {
+        pInfo->curr ++;
+    }
+
+    if (!badForm && read2DigitNumber(pInfo, &month) && pInfo->curr < pInfo->end && *pInfo->curr == '-') {
+        pInfo->curr ++;
+    } else {
+        badForm = true;
+    }
+
+    if (!badForm && read2DigitNumber(pInfo, &day) && pInfo->curr < pInfo->end && *pInfo->curr == 'T') {
+        pInfo->curr ++;
+    } else {
+        badForm = true;
+    }
+
+    if (!badForm && read2DigitNumber(pInfo, &hour) && pInfo->curr < pInfo->end && *pInfo->curr == ':') {
+        pInfo->curr ++;
+    } else {
+        badForm = true;
+    }
+
+    if (!badForm && read2DigitNumber(pInfo, &minute) && pInfo->curr < pInfo->end && *pInfo->curr == ':') {
+        pInfo->curr ++;
+    } else {
+        badForm = true;
+    }
+
+    if (!badForm && read2DigitNumber(pInfo, &num) && pInfo->curr < pInfo->end && *pInfo->curr == 'Z') {
+        second = num;
+        pInfo->curr ++;
+    } else {
+        badForm = true;
+    }
+
+    if (badForm) {
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Could not interpret <date> at line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    if (!checkForCloseTag(pInfo, CFXMLPlistTags[DATE_IX], DATE_TAG_LENGTH)) return NULL;
+
+    CFAbsoluteTime at = 0.0;
+#if 1
+    CFGregorianDate date = {year, month, day, hour, minute, second};
+    at = CFGregorianDateGetAbsoluteTime(date, NULL);
+#else
+    CFCalendarRef calendar = CFCalendarCreateWithIdentifier(kCFAllocatorSystemDefault, kCFGregorianCalendar);
+    CFTimeZoneRef tz = CFTimeZoneCreateWithName(kCFAllocatorSystemDefault, CFSTR("GMT"), true);
+    CFCalendarSetTimeZone(calendar, tz);
+    CFCalendarComposeAbsoluteTime(calendar, &at, (const uint8_t *)"yMdHms", year, month, day, hour, minute, second);
+    CFRelease(calendar);
+    CFRelease(tz);
+#endif
+    return CFDateCreate(pInfo->allocator, at);
+}
+
+static CFTypeRef parseRealTag(_CFXMLPlistParseInfo *pInfo) {
+    CFStringRef str = getString(pInfo);
+    SInt32 idx, len;
+    double val;
+    CFNumberRef result;
+    CFStringInlineBuffer buf;
+    if (!str) {
+        if (!pInfo->errorString)
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered empty <real> on line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    
+	if (kCFCompareEqualTo == CFStringCompare(str, CFSTR("nan"), kCFCompareCaseInsensitive)) {
+	    CFRelease(str);
+	    return (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) ? CFRetain(kCFNumberNaN) : NULL;
+	}
+	if (kCFCompareEqualTo == CFStringCompare(str, CFSTR("+infinity"), kCFCompareCaseInsensitive)) {
+	    CFRelease(str);
+	    return (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) ? CFRetain(kCFNumberPositiveInfinity) : NULL;
+	}
+	if (kCFCompareEqualTo == CFStringCompare(str, CFSTR("-infinity"), kCFCompareCaseInsensitive)) {
+	    CFRelease(str);
+	    return (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) ? CFRetain(kCFNumberNegativeInfinity) : NULL;
+	}
+	if (kCFCompareEqualTo == CFStringCompare(str, CFSTR("infinity"), kCFCompareCaseInsensitive)) {
+	    CFRelease(str);
+	    return (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) ? CFRetain(kCFNumberPositiveInfinity) : NULL;
+	}
+	if (kCFCompareEqualTo == CFStringCompare(str, CFSTR("-inf"), kCFCompareCaseInsensitive)) {
+	    CFRelease(str);
+	    return (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) ? CFRetain(kCFNumberNegativeInfinity) : NULL;
+	}
+	if (kCFCompareEqualTo == CFStringCompare(str, CFSTR("inf"), kCFCompareCaseInsensitive)) {
+	    CFRelease(str);
+	    return (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) ? CFRetain(kCFNumberPositiveInfinity) : NULL;
+	}
+	if (kCFCompareEqualTo == CFStringCompare(str, CFSTR("+inf"), kCFCompareCaseInsensitive)) {
+	    CFRelease(str);
+	    return (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) ? CFRetain(kCFNumberPositiveInfinity) : NULL;
+	}
+
+    len = CFStringGetLength(str);
+    CFStringInitInlineBuffer(str, &buf, CFRangeMake(0, len));
+    idx = 0;
+    if (!__CFStringScanDouble(&buf, NULL, &idx, &val) || idx != len) {
+        CFRelease(str);
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered misformatted real on line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    CFRelease(str);
+    result = CFNumberCreate(pInfo->allocator, kCFNumberDoubleType, &val);
+    if (checkForCloseTag(pInfo, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH)) return result;
+    CFRelease(result);
+    return NULL;
+}
+
+#define GET_CH	if (pInfo->curr == pInfo->end) {	\
+			pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Premature end of file after <integer> on line %d"), lineNumber(pInfo)); \
+			return NULL;			\
+		}					\
+		ch = *(pInfo->curr)
+
+typedef struct {
+    int64_t high;
+    uint64_t low;
+} CFSInt128Struct;
+
+enum {
+    kCFNumberSInt128Type = 17
+};
+
+static CFTypeRef parseIntegerTag(_CFXMLPlistParseInfo *pInfo) {
+    bool isHex = false, isNeg = false, hadLeadingZero = false;
+    UniChar ch = 0;
+
+	// decimal_constant	S*(-|+)?S*[0-9]+		(S == space)
+	// hex_constant		S*(-|+)?S*0[xX][0-9a-fA-F]+	(S == space)
+
+    while (pInfo->curr < pInfo->end && __CFIsWhitespace(*(pInfo->curr))) pInfo->curr++;
+    GET_CH;
+    if ('<' == ch) {
+	pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered empty <integer> on line %d"), lineNumber(pInfo));
+	return NULL;
+    }
+    if ('-' == ch || '+' == ch) {
+	isNeg = ('-' == ch);
+	pInfo->curr++;
+	while (pInfo->curr < pInfo->end && __CFIsWhitespace(*(pInfo->curr))) pInfo->curr++;
+    }
+    GET_CH;
+    if ('0' == ch) {
+	if (pInfo->curr + 1 < pInfo->end && ('x' == *(pInfo->curr + 1) || 'X' == *(pInfo->curr + 1))) {
+	    pInfo->curr++;
+	    isHex = true;
+	} else {
+	    hadLeadingZero = true;
+	}
+	pInfo->curr++;
+    }
+    GET_CH;
+    while ('0' == ch) {
+	hadLeadingZero = true;
+	pInfo->curr++;
+	GET_CH;
+    }
+    if ('<' == ch && hadLeadingZero) {	// nothing but zeros
+	int32_t val = 0;
+        if (!checkForCloseTag(pInfo, CFXMLPlistTags[INTEGER_IX], INTEGER_TAG_LENGTH)) {
+	    // checkForCloseTag() sets error string
+	    return NULL;
+        }
+	return CFNumberCreate(pInfo->allocator, kCFNumberSInt32Type, &val);
+    }
+    if ('<' == ch) {
+	pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Incomplete <integer> on line %d"), lineNumber(pInfo));
+	return NULL;
+    }
+    uint64_t value = 0;
+    uint32_t multiplier = (isHex ? 16 : 10);
+    while ('<' != ch) {
+	uint32_t new_digit = 0;
+	switch (ch) {
+	case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
+	    new_digit = (ch - '0');
+	    break;
+	case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+	    new_digit = (ch - 'a' + 10);
+	    break;
+	case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+	    new_digit = (ch - 'A' + 10);
+	    break;
+	default:	// other character
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unknown character '%c' (0x%x) in <integer> on line %d"), ch, ch, lineNumber(pInfo));
+	    return NULL;
+	}
+	if (!isHex && new_digit > 9) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Hex digit in non-hex <integer> on line %d"), lineNumber(pInfo));
+	    return NULL;
+	}
+	if (UINT64_MAX / multiplier < value) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Integer overflow in <integer> on line %d"), lineNumber(pInfo));
+	    return NULL;
+	}
+	value = multiplier * value;
+	if (UINT64_MAX - new_digit < value) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Integer overflow in <integer> on line %d"), lineNumber(pInfo));
+	    return NULL;
+	}
+	value = value + new_digit;
+	if (isNeg && (uint64_t)INT64_MAX + 1 < value) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Integer underflow in <integer> on line %d"), lineNumber(pInfo));
+	    return NULL;
+	}
+	pInfo->curr++;
+	GET_CH;
+    }
+    if (!checkForCloseTag(pInfo, CFXMLPlistTags[INTEGER_IX], INTEGER_TAG_LENGTH)) {
+	// checkForCloseTag() sets error string
+	return NULL;
+    }
+    if (isNeg || value <= INT64_MAX) {
+	int64_t v = value;
+	if (isNeg) v = -v;	// no-op if INT64_MIN
+        return CFNumberCreate(pInfo->allocator, kCFNumberSInt64Type, &v);
+    }
+    CFSInt128Struct val;
+    val.high = 0;
+    val.low = value;
+    return CFNumberCreate(pInfo->allocator, kCFNumberSInt128Type, &val);
+}
+
+#undef GET_CH
+
+// Returned object is retained; caller must free.  pInfo->curr expected to point to the first character after the '<'
+static CFTypeRef parseXMLElement(_CFXMLPlistParseInfo *pInfo, Boolean *isKey) {
+    const UniChar *marker = pInfo->curr;
+    int markerLength = -1;
+    Boolean isEmpty;
+    int markerIx = -1;
+    
+    if (isKey) *isKey = false;
+    while (pInfo->curr < pInfo->end) {
+        UniChar ch = *(pInfo->curr);
+        if (ch == ' ' || ch ==  '\t' || ch == '\n' || ch =='\r') {
+            if (markerLength == -1) markerLength = pInfo->curr - marker;
+        } else if (ch == '>') {
+            break;
+        }
+        pInfo->curr ++;
+    }
+    if (pInfo->curr >= pInfo->end) return NULL;
+    isEmpty = (*(pInfo->curr-1) == '/');
+    if (markerLength == -1)
+        markerLength = pInfo->curr - (isEmpty ? 1 : 0) - marker;
+    pInfo->curr ++; // Advance past '>'
+    if (markerLength == 0) {
+        // Back up to the beginning of the marker
+        pInfo->curr = marker;
+        pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Malformed tag on line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    switch (*marker) {
+        case 'a':   // Array
+            if (markerLength == ARRAY_TAG_LENGTH && matchString(marker, CFXMLPlistTags[ARRAY_IX], ARRAY_TAG_LENGTH))
+                markerIx = ARRAY_IX;
+            break;
+        case 'd': // Dictionary, data, or date; Fortunately, they all have the same marker length....
+            if (markerLength != DICT_TAG_LENGTH)
+                break;
+            if (matchString(marker, CFXMLPlistTags[DICT_IX], DICT_TAG_LENGTH))
+                markerIx = DICT_IX;
+            else if (matchString(marker, CFXMLPlistTags[DATA_IX], DATA_TAG_LENGTH))
+                markerIx = DATA_IX;
+            else if (matchString(marker, CFXMLPlistTags[DATE_IX], DATE_TAG_LENGTH))
+                markerIx = DATE_IX;
+            break;
+        case 'f': // false (boolean)
+            if (markerLength == FALSE_TAG_LENGTH && matchString(marker, CFXMLPlistTags[FALSE_IX], FALSE_TAG_LENGTH)) {
+                markerIx = FALSE_IX;
+            }
+            break;
+        case 'i': // integer
+            if (markerLength == INTEGER_TAG_LENGTH && matchString(marker, CFXMLPlistTags[INTEGER_IX], INTEGER_TAG_LENGTH))
+                markerIx = INTEGER_IX;
+            break;
+        case 'k': // Key of a dictionary
+            if (markerLength == KEY_TAG_LENGTH && matchString(marker, CFXMLPlistTags[KEY_IX], KEY_TAG_LENGTH)) {
+                markerIx = KEY_IX;
+                if (isKey) *isKey = true;
+            }
+            break;
+        case 'p': // Plist
+            if (markerLength == PLIST_TAG_LENGTH && matchString(marker, CFXMLPlistTags[PLIST_IX], PLIST_TAG_LENGTH))
+                markerIx = PLIST_IX;
+            break;
+        case 'r': // real
+            if (markerLength == REAL_TAG_LENGTH && matchString(marker, CFXMLPlistTags[REAL_IX], REAL_TAG_LENGTH))
+                markerIx = REAL_IX;
+            break;
+        case 's': // String
+            if (markerLength == STRING_TAG_LENGTH && matchString(marker, CFXMLPlistTags[STRING_IX], STRING_TAG_LENGTH))
+                markerIx = STRING_IX;
+            break;
+        case 't': // true (boolean)
+            if (markerLength == TRUE_TAG_LENGTH && matchString(marker, CFXMLPlistTags[TRUE_IX], TRUE_TAG_LENGTH))
+                markerIx = TRUE_IX;
+            break;
+    }
+
+    if (!pInfo->allowNewTypes && markerIx != PLIST_IX && markerIx != ARRAY_IX && markerIx != DICT_IX && markerIx != STRING_IX && markerIx != KEY_IX && markerIx != DATA_IX) {
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered new tag when expecting only old-style property list objects", CFStringGetSystemEncoding());
+        return NULL;
+    }
+
+    switch (markerIx) {
+        case PLIST_IX:
+            if (isEmpty) {
+                pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered empty plist tag", CFStringGetSystemEncoding());
+                return NULL;
+            }
+            return parsePListTag(pInfo);
+        case ARRAY_IX: 
+            if (isEmpty) {
+                return pInfo->mutabilityOption == kCFPropertyListImmutable ?  CFArrayCreate(pInfo->allocator, NULL, 0, &kCFTypeArrayCallBacks) : CFArrayCreateMutable(pInfo->allocator, 0, &kCFTypeArrayCallBacks);
+            } else {
+                return parseArrayTag(pInfo);
+            }
+        case DICT_IX:
+            if (isEmpty) {
+                if (pInfo->mutabilityOption == kCFPropertyListImmutable) {
+                    return CFDictionaryCreate(pInfo->allocator, NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+                } else {
+                    return CFDictionaryCreateMutable(pInfo->allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+                }
+            } else {
+                return parseDictTag(pInfo);
+            }
+        case KEY_IX:
+        case STRING_IX:
+        {
+            CFStringRef str;
+            int tagLen = (markerIx == KEY_IX) ? KEY_TAG_LENGTH : STRING_TAG_LENGTH;
+            if (isEmpty) {
+                return pInfo->mutabilityOption == kCFPropertyListMutableContainersAndLeaves ? CFStringCreateMutable(pInfo->allocator, 0) : CFStringCreateWithCharacters(pInfo->allocator, NULL, 0);
+            }
+            str = getString(pInfo);
+            if (!str) return NULL; // getString will already have set the error string
+            if (!checkForCloseTag(pInfo, CFXMLPlistTags[markerIx], tagLen)) {
+                CFRelease(str);
+                return NULL;
+            }
+            return str;
+        }
+        case DATA_IX:
+            if (isEmpty) {
+                pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered empty <data> on line %d"), lineNumber(pInfo));
+                return NULL;
+            } else {
+                return parseDataTag(pInfo);
+            }
+        case DATE_IX:
+            if (isEmpty) {
+                pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered empty <date> on line %d"), lineNumber(pInfo));
+                return NULL;
+            } else {
+                return parseDateTag(pInfo);
+            }
+        case TRUE_IX:
+            if (!isEmpty) {
+		if (!checkForCloseTag(pInfo, CFXMLPlistTags[TRUE_IX], TRUE_TAG_LENGTH)) return NULL;
+	    }
+	    return CFRetain(kCFBooleanTrue);
+        case FALSE_IX:
+            if (!isEmpty) {
+		if (!checkForCloseTag(pInfo, CFXMLPlistTags[FALSE_IX], FALSE_TAG_LENGTH)) return NULL;
+	    }
+            return CFRetain(kCFBooleanFalse);
+        case REAL_IX:
+            if (isEmpty) {
+                pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered empty <real> on line %d"), lineNumber(pInfo));
+                return NULL;
+            } else {
+                return parseRealTag(pInfo);
+            }
+        case INTEGER_IX:
+            if (isEmpty) {
+                pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered empty <integer> on line %d"), lineNumber(pInfo));
+                return NULL;
+            } else {
+                return parseIntegerTag(pInfo);
+            }
+        default:  {
+            CFStringRef markerStr = CFStringCreateWithCharacters(pInfo->allocator, marker, markerLength);
+            pInfo->curr = marker;
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Encountered unknown tag %@ on line %d"), markerStr, lineNumber(pInfo));
+            CFRelease(markerStr);
+            return NULL;
+        }
+    }
+}
+
+static CFTypeRef parseXMLPropertyList(_CFXMLPlistParseInfo *pInfo) {
+    while (!pInfo->errorString && pInfo->curr < pInfo->end) {
+        UniChar ch;
+        skipWhitespace(pInfo);
+        if (pInfo->curr+1 >= pInfo->end) {
+            pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "No XML content found", CFStringGetSystemEncoding());
+            return NULL;
+        }
+        if (*(pInfo->curr) != '<') {
+            pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unexpected character %c at line %d"), *(pInfo->curr), lineNumber(pInfo));
+            return NULL;
+        }
+        ch = *(++ pInfo->curr);
+        if (ch == '!') {
+            // Comment or DTD
+            ++ pInfo->curr;
+            if (pInfo->curr+1 < pInfo->end && *pInfo->curr == '-' && *(pInfo->curr+1) == '-') {
+                // Comment
+                pInfo->curr += 2;
+                skipXMLComment(pInfo);
+            } else {
+                skipDTD(pInfo);
+            }
+        } else if (ch == '?') {
+            // Processing instruction
+            pInfo->curr++;
+            skipXMLProcessingInstruction(pInfo);
+        } else {
+            // Tag or malformed
+            return parseXMLElement(pInfo, NULL);
+            // Note we do not verify that there was only one element, so a file that has garbage after the first element will nonetheless successfully parse
+        }
+    }
+    // Should never get here
+    if (!(pInfo->errorString))
+        pInfo->errorString = CFStringCreateWithCString(pInfo->allocator, "Encountered unexpected EOF", CFStringGetSystemEncoding());
+    return NULL;
+}
+
+static CFStringEncoding encodingForXMLData(CFDataRef data, CFStringRef *error) {
+    const uint8_t *bytes = (uint8_t *)CFDataGetBytePtr(data);
+    UInt32 length = CFDataGetLength(data);
+    const uint8_t *idx, *end;
+    char quote;
+    
+    // Check for the byte order mark first
+    if (length > 2 &&
+        ((*bytes == 0xFF && *(bytes+1) == 0xFE) ||
+         (*bytes == 0xFE && *(bytes+1) == 0xFF) ||
+         *bytes == 0x00 || *(bytes+1) == 0x00)) // This clause checks for a Unicode sequence lacking the byte order mark; technically an error, but this check is recommended by the XML spec
+        return kCFStringEncodingUnicode;
+    
+    // Scan for the <?xml.... ?> opening
+    if (length < 5 || strncmp((char const *) bytes, "<?xml", 5) != 0) return kCFStringEncodingUTF8;
+    idx = bytes + 5;
+    end = bytes + length;
+    // Found "<?xml"; now we scan for "encoding"
+    while (idx < end) {
+        uint8_t ch = *idx;
+        const uint8_t *scan;
+        if ( ch == '?' || ch == '>') return kCFStringEncodingUTF8;
+        idx ++;
+        scan = idx;
+        if (ch == 'e' && *scan++ == 'n' && *scan++ == 'c' && *scan++ == 'o' && *scan++ == 'd' && *scan++ == 'i'
+            && *scan++ == 'n' && *scan++ == 'g' && *scan++ == '=') {
+            idx = scan;
+            break;
+        }
+    }
+    if (idx >= end) return kCFStringEncodingUTF8;
+    quote = *idx;
+    if (quote != '\'' && quote != '\"') return kCFStringEncodingUTF8;
+    else {
+        CFStringRef encodingName;
+        const uint8_t *base = idx+1; // Move past the quote character
+        CFStringEncoding enc;
+        UInt32 len;
+        idx ++;
+        while (idx < end && *idx != quote) idx ++;
+        if (idx >= end) return kCFStringEncodingUTF8;
+        len = idx - base;
+        if (len == 5 && (*base == 'u' || *base == 'U') && (base[1] == 't' || base[1] == 'T') && (base[2] == 'f' || base[2] == 'F') && (base[3] == '-') && (base[4] == '8'))
+            return kCFStringEncodingUTF8;
+        encodingName = CFStringCreateWithBytes(kCFAllocatorSystemDefault, base, len, kCFStringEncodingISOLatin1, false);
+        enc = CFStringConvertIANACharSetNameToEncoding(encodingName);
+        if (enc != kCFStringEncodingInvalidId) {
+            CFRelease(encodingName);
+            return enc;
+        }
+
+        if (error) {
+            *error = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("Encountered unknown encoding (%@)"), encodingName);
+            CFRelease(encodingName);
+        }
+        return 0;
+    }
+}
+
+extern bool __CFTryParseBinaryPlist(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFPropertyListRef *plist, CFStringRef *errorString);
+int32_t _CFPropertyListAllowNonUTF8 = 0;
+
+#define SAVE_PLISTS 0
+
+#if SAVE_PLISTS
+static Boolean __savePlistData(CFDataRef data, CFOptionFlags opt) {
+    uint8_t pn[2048];
+    uint8_t fn[2048];
+    uint32_t pnlen = sizeof(pn);
+    uint8_t *pnp = NULL;
+    if (0 == _NSGetExecutablePath((char *)pn, &pnlen)) {
+	pnp = strrchr((char *)pn, '/');
+    }
+    if (!pnp) {
+	pnp = pn;
+    } else {
+	pnp++;
+    }
+    if (0 == strcmp((char *)pnp, "parse_plists")) return true;
+    CFUUIDRef r = CFUUIDCreate(kCFAllocatorSystemDefault);
+    CFStringRef s = CFUUIDCreateString(kCFAllocatorSystemDefault, r);
+    CFStringRef p = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("/tmp/plists/%s#%@#0x%x"), pnp, s, opt);
+    _CFStringGetFileSystemRepresentation(p, fn, sizeof(fn));
+    CFRelease(r);
+    CFRelease(s);
+    CFRelease(p);
+    int fd = open((const char *)fn, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+    if (fd < 0) return false;
+    int len = CFDataGetLength(data);
+    int w = write(fd, CFDataGetBytePtr(data), len);
+    fsync(fd);
+    close(fd);
+    if (w != len) return false;
+    return true;
+}
+#endif
+
+CFTypeRef _CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format) {
+    initStatics();
+    CFStringEncoding encoding;
+    CFStringRef xmlString;
+    UInt32 length;
+    CFPropertyListRef plist;
+
+    if (errorString) *errorString = NULL;
+    if (!xmlData || CFDataGetLength(xmlData) == 0) {
+        if (errorString) {
+            *errorString = CFSTR("Cannot parse a NULL or zero-length data");
+            CFRetain(*errorString); // Caller expects to release
+        }
+        return NULL;
+    }
+
+#if SAVE_PLISTS
+    __savePlistData(xmlData, option);
+#endif
+
+    if (__CFTryParseBinaryPlist(allocator, xmlData, option, &plist, errorString)) {
+	if (format) *format = kCFPropertyListBinaryFormat_v1_0;
+	return plist;
+    }
+    
+    allocator = allocator ? allocator : __CFGetDefaultAllocator();
+    CFRetain(allocator);
+    
+    encoding = encodingForXMLData(xmlData, errorString); // 0 is an error return, NOT MacRoman.
+
+    if (encoding == 0) {
+        // Couldn't find an encoding; encodingForXMLData already set *errorString if necessary
+        // Note that encodingForXMLData() will give us the right values for a standard plist, too.
+        if (errorString) *errorString = CFStringCreateWithFormat(allocator, NULL, CFSTR("Could not determine the encoding of the XML data"));
+        return NULL;
+    }
+
+    xmlString = CFStringCreateWithBytes(allocator, CFDataGetBytePtr(xmlData), CFDataGetLength(xmlData), encoding, true);
+    if (NULL == xmlString && (!_CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard) || _CFPropertyListAllowNonUTF8)) {	// conversion failed, probably because not in proper encoding
+        // Call __CFStringCreateImmutableFunnel3() the same way CFStringCreateWithBytes() does, except with the addt'l flag
+		if (encoding == kCFStringEncodingUTF8) xmlString = __CFStringCreateImmutableFunnel3(allocator, CFDataGetBytePtr(xmlData), CFDataGetLength(xmlData), kCFStringEncodingUTF8, true, true, false, false, false, (CFAllocatorRef)-1  /* ALLOCATORSFREEFUNC */, kCFStringEncodingLenientUTF8Conversion);
+    }
+    length = xmlString ? CFStringGetLength(xmlString) : 0;
+
+    if (length) {
+        _CFXMLPlistParseInfo pInfoBuf;
+        _CFXMLPlistParseInfo *pInfo = &pInfoBuf;
+        CFTypeRef result;
+        UniChar *buf = (UniChar *)CFStringGetCharactersPtr(xmlString);
+
+        if (errorString) *errorString = NULL;
+        if (!buf) {
+            buf = (UniChar *)CFAllocatorAllocate(allocator, length * sizeof(UniChar), 0);
+            CFStringGetCharacters(xmlString, CFRangeMake(0, length), buf);
+            CFRelease(xmlString);
+            xmlString = NULL;
+        }
+        pInfo->begin = buf;
+        pInfo->end = buf+length;
+        pInfo->curr = buf;
+        pInfo->allocator = allocator;
+        pInfo->errorString = NULL;
+        pInfo->stringSet = NULL;
+        pInfo->tmpString = NULL;
+        pInfo->mutabilityOption = option;
+        pInfo->allowNewTypes = allowNewTypes;
+        
+        // Haven't done anything XML-specific to this point.  However, the encoding we used to translate the bytes should be kept in mind; we used Unicode if the byte-order mark was present; UTF-8 otherwise.  If the system encoding is not UTF-8 or some variant of 7-bit ASCII, we'll be in trouble.....
+        result = parseXMLPropertyList(pInfo);
+        if (result && format) *format = kCFPropertyListXMLFormat_v1_0;
+        if (!result) {
+	    CFStringRef err = pInfo->errorString;
+            // Reset pInfo so we can try again
+            pInfo->curr = pInfo->begin;
+            pInfo->errorString = NULL;
+            // Try pList
+            result = parseOldStylePropertyListOrStringsFile(pInfo);
+	    if (result && format) *format = kCFPropertyListOpenStepFormat;
+            if (!result) {
+		if (errorString) *errorString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("XML parser error:\n\t%@\nOld-style plist parser error:\n\t%@\n"), err, pInfo->errorString);
+            }
+	    if (err) CFRelease(err);
+	    if (pInfo->errorString) CFRelease(pInfo->errorString);
+        }
+        if (xmlString) {
+            CFRelease(xmlString);
+        } else {
+            CFAllocatorDeallocate(allocator, (void *)pInfo->begin);
+        }
+        if (pInfo->stringSet) CFRelease(pInfo->stringSet);
+        if (pInfo->tmpString) CFRelease(pInfo->tmpString);
+        CFRelease(allocator);
+        return result;
+    } else {
+        if (errorString)
+            *errorString = (CFStringRef)CFRetain(CFSTR("Conversion of data failed. The file is not UTF-8, or in the encoding specified in XML header if XML."));
+        return NULL;
+    }
+}
+
+CFTypeRef CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString) {
+    initStatics();
+    CFAssert1(xmlData != NULL, __kCFLogAssertion, "%s(): NULL data not allowed", __PRETTY_FUNCTION__);
+    CFAssert2(option == kCFPropertyListImmutable || option == kCFPropertyListMutableContainers || option == kCFPropertyListMutableContainersAndLeaves, __kCFLogAssertion, "%s(): Unrecognized option %d", __PRETTY_FUNCTION__, option);
+    return _CFPropertyListCreateFromXMLData(allocator, xmlData, option, errorString, true, NULL);
+}
+
+CFIndex CFPropertyListWriteToStream(CFPropertyListRef propertyList, CFWriteStreamRef stream, CFPropertyListFormat format, CFStringRef *errorString) {
+    initStatics();
+    CFAssert1(stream != NULL, __kCFLogAssertion, "%s(): NULL stream not allowed", __PRETTY_FUNCTION__);
+    CFAssert2(format == kCFPropertyListOpenStepFormat || format == kCFPropertyListXMLFormat_v1_0 || format == kCFPropertyListBinaryFormat_v1_0, __kCFLogAssertion, "%s(): Unrecognized option %d", __PRETTY_FUNCTION__, format);
+    CFAssert1(propertyList != NULL, __kCFLogAssertion, "%s(): Cannot be called with a NULL property list", __PRETTY_FUNCTION__);
+    __CFAssertIsPList(propertyList);
+    CFAssert1(CFWriteStreamGetTypeID() == CFGetTypeID(stream), __kCFLogAssertion, "%s(): stream argument is not a write stream", __PRETTY_FUNCTION__);
+    CFAssert1(kCFStreamStatusOpen == CFWriteStreamGetStatus(stream) || kCFStreamStatusWriting == CFWriteStreamGetStatus(stream), __kCFLogAssertion, "%s():  stream is not open", __PRETTY_FUNCTION__);
+
+    if (errorString) *errorString = NULL;
+    if (!CFPropertyListIsValid(propertyList, format)) {
+        if (errorString) *errorString = (CFStringRef)CFRetain(CFSTR("Property list invalid for format"));
+        return 0;
+    }
+    if (format == kCFPropertyListOpenStepFormat) {
+        if (errorString) *errorString = (CFStringRef)CFRetain(CFSTR("Property list format kCFPropertyListOpenStepFormat not supported for writing"));
+        return 0;
+    }
+    if (format == kCFPropertyListXMLFormat_v1_0) {
+        CFDataRef data = CFPropertyListCreateXMLData(kCFAllocatorSystemDefault, propertyList);
+	if (!data) {
+	    if (errorString) *errorString = (CFStringRef)CFRetain(CFSTR("Property list in XML format could not be created for unknown reasons."));
+	    return 0;
+	}
+        CFIndex len = CFDataGetLength(data);
+	const uint8_t *ptr = CFDataGetBytePtr(data);
+	while (0 < len) {
+	    CFIndex ret = CFWriteStreamWrite(stream, ptr, len);
+	    if (ret == 0) {
+	        if (errorString) *errorString = (CFStringRef)CFRetain(CFSTR("Property list writing could not be completed because stream is full."));
+	        return 0;
+	    }
+	    if (ret < 0) {
+		CFErrorRef err = CFWriteStreamCopyError(stream);
+		CFStringRef str = err ? CFErrorCopyDescription(err) : NULL;
+		if (errorString) *errorString = str ? str : (CFStringRef)CFRetain(CFSTR("Property list writing could not be completed because the stream had an unknown error."));
+		if (err) CFRelease(err);
+		return 0;
+	    }
+	    ptr += ret;
+	    len -= ret;
+	}
+	len = CFDataGetLength(data);
+	CFRelease(data);
+        return len;
+    }
+    if (format == kCFPropertyListBinaryFormat_v1_0) {
+	CFIndex len = __CFBinaryPlistWriteToStream(propertyList, stream);
+        return len;
+    }
+    if (errorString) *errorString = (CFStringRef)CFRetain(CFSTR("Unknown format option"));
+    return 0;
+}
+
+static void __CFConvertReadStreamToBytes(CFReadStreamRef stream, CFIndex max, uint8_t **buffer, CFIndex *length) {
+    int32_t buflen = 0, bufsize = 0, retlen;
+    uint8_t *buf = NULL, sbuf[8192];
+    for (;;) {
+	retlen = CFReadStreamRead(stream, sbuf, __CFMin(8192, max));
+	if (retlen <= 0) {
+	    *buffer = buf;
+	    *length = buflen;
+	    return;
+	}
+        if (bufsize < buflen + retlen) {
+	    if (bufsize < 256 * 1024) {
+		bufsize *= 4;
+	    } else if (bufsize < 16 * 1024 * 1024) {
+		bufsize *= 2;
+	    } else {
+		// once in this stage, this will be really slow
+		// and really potentially fragment memory
+		bufsize += 256 * 1024;
+	    }
+	    if (bufsize < buflen + retlen) bufsize = buflen + retlen;
+	    buf = (uint8_t *)CFAllocatorReallocate(kCFAllocatorSystemDefault, buf, bufsize, 0);
+	    if (!buf) HALT;
+	}
+	memmove(buf + buflen, sbuf, retlen);
+	buflen += retlen;
+        max -= retlen;
+	if (max <= 0) {
+	    *buffer = buf;
+	    *length = buflen;
+	    return;
+	}
+    }
+}
+
+CFPropertyListRef CFPropertyListCreateFromStream(CFAllocatorRef allocator, CFReadStreamRef stream, CFIndex length, CFOptionFlags mutabilityOption, CFPropertyListFormat *format, CFStringRef *errorString) {
+    initStatics();
+    CFPropertyListRef pl;
+    CFDataRef data;
+    CFIndex buflen = 0;
+    uint8_t *buffer = NULL;
+    CFAssert1(stream != NULL, __kCFLogAssertion, "%s(): NULL stream not allowed", __PRETTY_FUNCTION__);
+    CFAssert1(CFReadStreamGetTypeID() == CFGetTypeID(stream), __kCFLogAssertion, "%s(): stream argument is not a read stream", __PRETTY_FUNCTION__);
+    CFAssert1(kCFStreamStatusOpen == CFReadStreamGetStatus(stream) || kCFStreamStatusReading == CFReadStreamGetStatus(stream), __kCFLogAssertion, "%s():  stream is not open", __PRETTY_FUNCTION__);
+    CFAssert2(mutabilityOption == kCFPropertyListImmutable || mutabilityOption == kCFPropertyListMutableContainers || mutabilityOption == kCFPropertyListMutableContainersAndLeaves, __kCFLogAssertion, "%s(): Unrecognized option %d", __PRETTY_FUNCTION__, mutabilityOption);
+
+    if (errorString) *errorString = NULL;
+    if (0 == length) length = INT_MAX;
+    __CFConvertReadStreamToBytes(stream, length, &buffer, &buflen);
+    if (!buffer || buflen < 6) {
+        if (buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, buffer);
+        if (errorString) *errorString = (CFStringRef)CFRetain(CFSTR("stream had too few bytes"));
+        return NULL;
+    }
+    data = CFDataCreateWithBytesNoCopy(kCFAllocatorSystemDefault, buffer, buflen, kCFAllocatorSystemDefault);
+    pl = _CFPropertyListCreateFromXMLData(allocator, data, mutabilityOption, errorString, true, format);
+    CFRelease(data);
+    return pl;
+}
+
+// ========================================================================
+
+//
+// Old NeXT-style property lists
+//
+
+static CFTypeRef parsePlistObject(_CFXMLPlistParseInfo *pInfo, bool requireObject);
+
+#define isValidUnquotedStringCharacter(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || ((x) >= '0' && (x) <= '9') || (x) == '_' || (x) == '$' || (x) == '/' || (x) == ':' || (x) == '.' || (x) == '-')
+
+static void advanceToNonSpace(_CFXMLPlistParseInfo *pInfo) {
+    UniChar ch2;
+    while (pInfo->curr < pInfo->end) {
+	ch2 = *(pInfo->curr);
+        pInfo->curr ++;
+        if (ch2 >= 9 && ch2 <= 0x0d) continue;	// tab, newline, vt, form feed, carriage return
+        if (ch2 == ' ' || ch2 == 0x2028 || ch2 == 0x2029) continue;	// space and Unicode line sep, para sep
+	if (ch2 == '/') {
+            if (pInfo->curr >= pInfo->end) {
+                // whoops; back up and return
+                pInfo->curr --;
+                return;
+            } else if (*(pInfo->curr) == '/') {
+                pInfo->curr ++;
+                while (pInfo->curr < pInfo->end) {	// go to end of comment line
+                    UniChar ch3 = *(pInfo->curr);
+                    if (ch3 == '\n' || ch3 == '\r' || ch3 == 0x2028 || ch3 == 0x2029) break;
+                    pInfo->curr ++;
+		}
+	    } else if (*(pInfo->curr) == '*') {		// handle /* ... */
+                pInfo->curr ++;
+		while (pInfo->curr < pInfo->end) {
+		    ch2 = *(pInfo->curr);
+                    pInfo->curr ++;
+		    if (ch2 == '*' && pInfo->curr < pInfo->end && *(pInfo->curr) == '/') {
+                        pInfo->curr ++; // advance past the '/'
+                        break;
+                    }
+                }
+            } else {
+                pInfo->curr --;
+                return;
+	    }
+        } else {
+            pInfo->curr --;
+            return;
+        }
+    }
+}
+
+static UniChar getSlashedChar(_CFXMLPlistParseInfo *pInfo) {
+    UniChar ch = *(pInfo->curr);
+    pInfo->curr ++;
+    switch (ch) {
+	case '0':
+	case '1':	
+	case '2':	
+	case '3':	
+	case '4':	
+	case '5':	
+	case '6':	
+	case '7':  {
+            uint8_t num = ch - '0';
+            UniChar result;
+            CFIndex usedCharLen;
+	    /* three digits maximum to avoid reading \000 followed by 5 as \5 ! */
+	    if ((ch = *(pInfo->curr)) >= '0' && ch <= '7') { // we use in this test the fact that the buffer is zero-terminated
+                pInfo->curr ++;
+		num = (num << 3) + ch - '0';
+		if ((pInfo->curr < pInfo->end) && (ch = *(pInfo->curr)) >= '0' && ch <= '7') {
+                    pInfo->curr ++;
+		    num = (num << 3) + ch - '0';
+		}
+	    }
+            CFStringEncodingBytesToUnicode(kCFStringEncodingNextStepLatin, 0, &num, sizeof(uint8_t), NULL,  &result, 1, &usedCharLen);
+            return (usedCharLen == 1) ? result : 0;
+	}
+	case 'U': {
+	    unsigned num = 0, numDigits = 4;	/* Parse four digits */
+	    while (pInfo->curr < pInfo->end && numDigits--) {
+                if (((ch = *(pInfo->curr)) < 128) && isxdigit(ch)) { 
+                    pInfo->curr ++;
+		    num = (num << 4) + ((ch <= '9') ? (ch - '0') : ((ch <= 'F') ? (ch - 'A' + 10) : (ch - 'a' + 10)));
+		}
+	    }
+	    return num;
+	}
+	case 'a':	return '\a';	// Note: the meaning of '\a' varies with -traditional to gcc
+	case 'b':	return '\b';
+	case 'f':	return '\f';
+	case 'n':	return '\n';
+	case 'r':	return '\r';
+	case 't':	return '\t';
+	case 'v':	return '\v';
+	case '"':	return '\"';
+	case '\n':	return '\n';
+    }
+    return ch;
+}
+
+static CFStringRef parseQuotedPlistString(_CFXMLPlistParseInfo *pInfo, UniChar quote) {
+    CFMutableStringRef str = NULL;
+    const UniChar *startMark = pInfo->curr;
+    const UniChar *mark = pInfo->curr;
+    while (pInfo->curr < pInfo->end) {
+	UniChar ch = *(pInfo->curr);
+        if (ch == quote) break;
+        if (ch == '\\') {
+            _catFromMarkToBuf(mark, pInfo->curr, &str, pInfo->allocator);
+            pInfo->curr ++;
+            ch = getSlashedChar(pInfo);
+            CFStringAppendCharacters(str, &ch, 1);
+            mark = pInfo->curr;
+	} else {
+            // Note that the original NSParser code was much more complex at this point, but it had to deal with 8-bit characters in a non-UniChar stream.  We always have UniChar (we translated the data by the system encoding at the very beginning, hopefully), so this is safe.
+            pInfo->curr ++;
+        }
+    }
+    if (pInfo->end <= pInfo->curr) {
+        if (str) CFRelease(str);
+	    pInfo->curr = startMark;
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unterminated quoted string starting on line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    if (!str) {
+        if (pInfo->mutabilityOption == kCFPropertyListMutableContainersAndLeaves) {
+            _catFromMarkToBuf(mark, pInfo->curr, &str, pInfo->allocator);
+        } else {
+            str = (CFMutableStringRef)_uniqueStringForCharacters(pInfo, mark, pInfo->curr-mark);
+            CFRetain(str);
+        }
+    } else {
+        if (mark != pInfo->curr) {
+            _catFromMarkToBuf(mark, pInfo->curr, &str, pInfo->allocator);
+        }
+        if (pInfo->mutabilityOption != kCFPropertyListMutableContainersAndLeaves) {
+            CFStringRef uniqueString = _uniqueStringForString(pInfo, str);
+            CFRetain(uniqueString);
+            CFRelease(str);
+            str = (CFMutableStringRef)uniqueString;
+        }
+    }
+    pInfo->curr ++;  // Advance past the quote character before returning.
+    if (pInfo->errorString) {
+	CFRelease(pInfo->errorString);
+	pInfo->errorString = NULL;
+    }
+    return str;
+}
+
+static CFStringRef parseUnquotedPlistString(_CFXMLPlistParseInfo *pInfo) {
+    const UniChar *mark = pInfo->curr;
+    while (pInfo->curr < pInfo->end) {
+        UniChar ch = *pInfo->curr;
+        if (isValidUnquotedStringCharacter(ch))
+            pInfo->curr ++;
+        else break;
+    }
+    if (pInfo->curr != mark) {
+        if (pInfo->mutabilityOption != kCFPropertyListMutableContainersAndLeaves) {
+            CFStringRef str = _uniqueStringForCharacters(pInfo, mark, pInfo->curr-mark);
+            CFRetain(str);
+            return str;
+        } else {
+            CFMutableStringRef str = CFStringCreateMutable(pInfo->allocator, 0);
+            CFStringAppendCharacters(str, mark, pInfo->curr - mark);
+            return str;
+        }
+    }
+	pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unexpected EOF"));
+    return NULL;
+}
+
+static CFStringRef parsePlistString(_CFXMLPlistParseInfo *pInfo, bool requireObject) {
+    UniChar ch;
+    advanceToNonSpace(pInfo);
+    if (pInfo->curr >= pInfo->end) {
+	if (requireObject) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unexpected EOF while parsing string"));
+	}
+        return NULL;
+    }
+    ch = *(pInfo->curr);
+    if (ch == '\'' || ch == '\"') {
+        pInfo->curr ++;
+        return parseQuotedPlistString(pInfo, ch);
+    } else if (isValidUnquotedStringCharacter(ch)) {
+        return parseUnquotedPlistString(pInfo);
+    } else {
+	if (requireObject) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Invalid string character at line %d"), lineNumber(pInfo));
+	}
+        return NULL;
+    }
+}
+
+static CFTypeRef parsePlistArray(_CFXMLPlistParseInfo *pInfo) {
+    CFMutableArrayRef array = CFArrayCreateMutable(pInfo->allocator, 0, &kCFTypeArrayCallBacks);
+    CFTypeRef tmp = parsePlistObject(pInfo, false);
+    while (tmp) {
+        CFArrayAppendValue(array, tmp);
+        CFRelease(tmp);
+        advanceToNonSpace(pInfo);
+        if (*pInfo->curr != ',') {
+            tmp = NULL;
+        } else {
+            pInfo->curr ++;
+            tmp = parsePlistObject(pInfo, false);
+        }
+    }
+    advanceToNonSpace(pInfo);
+    if (*pInfo->curr != ')') {
+        CFRelease(array);
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Expected terminating ')' for array at line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    if (pInfo->errorString) {
+	CFRelease(pInfo->errorString);
+	pInfo->errorString = NULL;
+    }
+    pInfo->curr ++;
+    return array;
+}
+
+static CFDictionaryRef parsePlistDictContent(_CFXMLPlistParseInfo *pInfo) {
+    CFMutableDictionaryRef dict = CFDictionaryCreateMutable(pInfo->allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFStringRef key = NULL;
+    Boolean failedParse = false;
+    key = parsePlistString(pInfo, false);
+    while (key) {
+        CFTypeRef value;
+        advanceToNonSpace(pInfo);
+	if (*pInfo->curr == ';') {
+	    /* This is a strings file using the shortcut format */
+	    /* although this check here really applies to all plists. */
+	    value = CFRetain(key);
+	} else if (*pInfo->curr == '=') {
+	    pInfo->curr ++;
+	    value = parsePlistObject(pInfo, true);
+	    if (!value) {
+		failedParse = true;
+		break;
+	    }
+	} else {
+		pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unexpected ';' or '=' after key at line %d"), lineNumber(pInfo));
+	    failedParse = true;
+	    break;
+	}
+	CFDictionarySetValue(dict, key, value);
+	CFRelease(key);
+	key = NULL;
+	CFRelease(value);
+	value = NULL;
+	advanceToNonSpace(pInfo);
+	if (*pInfo->curr == ';') {
+	    pInfo->curr ++;
+	    key = parsePlistString(pInfo, false);
+	} else if (!allowMissingSemi && _CFExecutableLinkedOnOrAfter(CFSystemVersionJaguar)) {
+		CFLog(kCFLogLevelWarning, CFSTR("CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary."));
+	    failedParse = true;
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Missing ';' on line %d"), lineNumber(pInfo));
+	} else {
+	    // on pre-Jaguar systems, do nothing except silently ignore the rest
+	    // of the dictionary, which is what happened on those systems.
+	}
+    }
+
+    if (failedParse) {
+        if (key) CFRelease(key);
+        CFRelease(dict);
+        return NULL;
+    }
+    if (pInfo->errorString) {
+	CFRelease(pInfo->errorString);
+	pInfo->errorString = NULL;
+    }
+    return dict;
+}
+
+static CFTypeRef parsePlistDict(_CFXMLPlistParseInfo *pInfo) {
+    CFDictionaryRef dict = parsePlistDictContent(pInfo);
+    if (!dict) return NULL;
+    advanceToNonSpace(pInfo);
+    if (*pInfo->curr != '}') {
+        CFRelease(dict);
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Expected terminating '}' for dictionary at line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    pInfo->curr ++;
+    return dict;
+}
+
+CF_INLINE unsigned char fromHexDigit(unsigned char ch) {
+    if (isdigit(ch)) return ch - '0';
+    if ((ch >= 'a') && (ch <= 'f')) return ch - 'a' + 10;
+    if ((ch >= 'A') && (ch <= 'F')) return ch - 'A' + 10;
+    return 0xff; // Just choose a large number for the error code
+}
+
+/* Gets up to bytesSize bytes from a plist data. Returns number of bytes actually read. Leaves cursor at first non-space, non-hex character.
+   -1 is returned for unexpected char, -2 for uneven number of hex digits
+*/
+static int getDataBytes(_CFXMLPlistParseInfo *pInfo, unsigned char *bytes, int bytesSize) {
+    int numBytesRead = 0;
+    while ((pInfo->curr < pInfo->end) && (numBytesRead < bytesSize)) {
+	int first, second;
+	UniChar ch1 = *pInfo->curr;
+	if (ch1 == '>') return numBytesRead;  // Meaning we're done
+	first = fromHexDigit((unsigned char)ch1);
+	if (first != 0xff) {	// If the first char is a hex, then try to read a second hex
+	    pInfo->curr++;
+	    if (pInfo->curr >= pInfo->end) return -2;   // Error: uneven number of hex digits
+	    UniChar ch2 = *pInfo->curr;
+	    second = fromHexDigit((unsigned char)ch2);
+	    if (second == 0xff) return -2;  // Error: uneven number of hex digits
+	    bytes[numBytesRead++] = (first << 4) + second;
+	    pInfo->curr++;
+	} else if (ch1 == ' ' || ch1 == '\n' || ch1 == '\t' || ch1 == '\r' || ch1 == 0x2028 || ch1 == 0x2029) {
+	    pInfo->curr++;
+	} else {
+	    return -1;  // Error: unexpected character
+	}
+    }
+    return numBytesRead;    // This does likely mean we didn't encounter a '>', but we'll let the caller deal with that
+}
+
+#define numBytes 400
+static CFTypeRef parsePlistData(_CFXMLPlistParseInfo *pInfo) {
+    CFMutableDataRef result = CFDataCreateMutable(pInfo->allocator, 0);
+
+    // Read hex bytes and append them to result
+    while (1) {
+	unsigned char bytes[numBytes];
+	int numBytesRead = getDataBytes(pInfo, bytes, numBytes);
+	if (numBytesRead < 0) {
+	    CFRelease(result);
+		switch (numBytesRead) {
+		    case -2: pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Malformed data byte group at line %d; uneven length"), lineNumber(pInfo)); break;
+		    default: pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Malformed data byte group at line %d; invalid hex"), lineNumber(pInfo)); break;
+		}
+	    return NULL;
+	}
+	if (numBytesRead == 0) break;
+	CFDataAppendBytes(result, bytes, numBytesRead);
+    }
+
+    if (pInfo->errorString) {
+	CFRelease(pInfo->errorString);
+	pInfo->errorString = NULL;
+    }
+
+    if (*(pInfo->curr) == '>') {
+        pInfo->curr ++; // Move past '>'
+        return result;
+    } else {
+        CFRelease(result);
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Expected terminating '>' for data at line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+}
+#undef numBytes
+
+// Returned object is retained; caller must free.
+static CFTypeRef parsePlistObject(_CFXMLPlistParseInfo *pInfo, bool requireObject) {
+    UniChar ch;
+    advanceToNonSpace(pInfo);
+    if (pInfo->curr + 1 >= pInfo->end) {
+	if (requireObject) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unexpected EOF while parsing plist"));
+	}
+        return NULL;
+    }
+    ch = *(pInfo->curr);
+    pInfo->curr ++;
+    if (ch == '{') {
+        return parsePlistDict(pInfo);
+    } else if (ch == '(') {
+        return parsePlistArray(pInfo);
+    } else if (ch == '<') {
+        return parsePlistData(pInfo);
+    } else if (ch == '\'' || ch == '\"') {
+        return parseQuotedPlistString(pInfo, ch);
+    } else if (isValidUnquotedStringCharacter(ch)) {
+        pInfo->curr --;
+        return parseUnquotedPlistString(pInfo);
+    } else {
+        pInfo->curr --;  // Must back off the charcter we just read
+	if (requireObject) {
+	    pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Unexpected character '0x%x' at line %d"), ch, lineNumber(pInfo));
+	}
+        return NULL;
+    }
+}
+
+static CFTypeRef parseOldStylePropertyListOrStringsFile(_CFXMLPlistParseInfo *pInfo) {
+    const UniChar *begin = pInfo->curr;
+    CFTypeRef result;
+    advanceToNonSpace(pInfo);
+    // A file consisting only of whitespace (or empty) is now defined to be an empty dictionary
+    if (pInfo->curr >= pInfo->end) return CFDictionaryCreateMutable(pInfo->allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    result = parsePlistObject(pInfo, true);
+    advanceToNonSpace(pInfo);
+    if (pInfo->curr >= pInfo->end) return result;
+    if (!result) return NULL;
+    if (CFGetTypeID(result) != stringtype) {
+        CFRelease(result);
+	pInfo->errorString = CFStringCreateWithFormat(pInfo->allocator, NULL, CFSTR("Junk after plist at line %d"), lineNumber(pInfo));
+        return NULL;
+    }
+    CFRelease(result);
+    // Check for a strings file (looks like a dictionary without the opening/closing curly braces)
+    pInfo->curr = begin;
+    return parsePlistDictContent(pInfo);
+}
+
+#undef isValidUnquotedStringCharacter
+
+static CFArrayRef _arrayDeepImmutableCopy(CFAllocatorRef allocator, CFArrayRef array, CFOptionFlags mutabilityOption) {
+    CFArrayRef result = NULL;
+    CFIndex i, c = CFArrayGetCount(array);
+    CFTypeRef *values;
+    if (c == 0) {
+        result = CFArrayCreate(allocator, NULL, 0, &kCFTypeArrayCallBacks);
+    } else if ((values = (CFTypeRef *)CFAllocatorAllocate(allocator, c*sizeof(CFTypeRef), 0)) != NULL) {
+        CFArrayGetValues(array, CFRangeMake(0, c), values);
+        for (i = 0; i < c; i ++) {
+            values[i] = CFPropertyListCreateDeepCopy(allocator, values[i], mutabilityOption);
+            if (values[i] == NULL) {
+                break;
+            }
+        }
+        result = (i == c) ? CFArrayCreate(allocator, values, c, &kCFTypeArrayCallBacks) : NULL;
+        c = i;
+        for (i = 0; i < c; i ++) {
+            CFRelease(values[i]);
+        }
+        CFAllocatorDeallocate(allocator, values);
+    }
+    return result;
+}
+
+static CFMutableArrayRef _arrayDeepMutableCopy(CFAllocatorRef allocator, CFArrayRef array, CFOptionFlags mutabilityOption) {
+    CFIndex i, c = CFArrayGetCount(array);
+    CFMutableArrayRef result = CFArrayCreateMutable(allocator, 0, &kCFTypeArrayCallBacks);
+    if (result) {
+        for (i = 0; i < c; i ++) {
+            CFTypeRef newValue = CFPropertyListCreateDeepCopy(allocator, CFArrayGetValueAtIndex(array, i), mutabilityOption);
+            if (!newValue) break;
+            CFArrayAppendValue(result, newValue);
+            CFRelease(newValue);
+        }
+        if (i != c) {
+            CFRelease(result);
+            result = NULL;
+        }
+    }
+    return result;
+}
+
+CFPropertyListRef CFPropertyListCreateDeepCopy(CFAllocatorRef allocator, CFPropertyListRef propertyList, CFOptionFlags mutabilityOption) {
+    initStatics();
+    CFTypeID typeID;
+    CFPropertyListRef result = NULL;
+    CFAssert1(propertyList != NULL, __kCFLogAssertion, "%s(): cannot copy a NULL property list", __PRETTY_FUNCTION__);
+    __CFAssertIsPList(propertyList);
+    CFAssert2(mutabilityOption == kCFPropertyListImmutable || mutabilityOption == kCFPropertyListMutableContainers || mutabilityOption == kCFPropertyListMutableContainersAndLeaves, __kCFLogAssertion, "%s(): Unrecognized option %d", __PRETTY_FUNCTION__, mutabilityOption);
+	if (!CFPropertyListIsValid(propertyList, kCFPropertyListBinaryFormat_v1_0)) return NULL;
+    
+    if (allocator == NULL) {
+        allocator = (CFAllocatorRef)CFRetain(__CFGetDefaultAllocator());
+    } else {
+        CFRetain(allocator);
+    }
+    
+    typeID = CFGetTypeID(propertyList);
+    if (typeID == dicttype) {
+        CFDictionaryRef dict = (CFDictionaryRef)propertyList;
+        Boolean isMutable = (mutabilityOption != kCFPropertyListImmutable);
+        CFIndex count = CFDictionaryGetCount(dict);
+        CFTypeRef *keys, *values;
+        if (count == 0) {
+            result = isMutable ? CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks): CFDictionaryCreate(allocator, NULL, NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        } else if ((keys = (CFTypeRef *)CFAllocatorAllocate(allocator, 2 * count * sizeof(CFTypeRef), 0)) != NULL)   {
+            CFIndex i;
+            values = keys+count;
+            CFDictionaryGetKeysAndValues(dict, keys, values);
+            for (i = 0; i < count; i ++) {
+                keys[i] = CFStringCreateCopy(allocator, (CFStringRef)keys[i]);
+                if (keys[i] == NULL) {
+                    break;
+                }
+                values[i] = CFPropertyListCreateDeepCopy(allocator, values[i], mutabilityOption);
+                if (values[i] == NULL) {
+                    CFRelease(keys[i]);
+                    break;
+                }
+            }
+            if (i == count) {
+                result = isMutable ? CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) : CFDictionaryCreate(allocator, keys, values, count, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+                for (i = 0; i < count; i ++) {
+                    if (isMutable) {
+                        CFDictionarySetValue((CFMutableDictionaryRef)result, keys[i], values[i]);
+                    }
+                    CFRelease(keys[i]);
+                    CFRelease(values[i]);
+                }
+            } else {
+                result = NULL;
+                count = i;
+                for (i = 0; i < count; i ++) {
+                    CFRelease(keys[i]);
+                    CFRelease(values[i]);
+                }
+            }
+            CFAllocatorDeallocate(allocator, keys);
+        } else {
+            result = NULL;
+        }
+    } else if (typeID == arraytype) {
+        if (mutabilityOption == kCFPropertyListImmutable) {
+            result = _arrayDeepImmutableCopy(allocator, (CFArrayRef)propertyList, mutabilityOption);
+        } else {
+            result = _arrayDeepMutableCopy(allocator, (CFArrayRef)propertyList, mutabilityOption);
+        }
+    } else if (typeID == datatype) {
+        if (mutabilityOption == kCFPropertyListMutableContainersAndLeaves) {
+            result = CFDataCreateMutableCopy(allocator, 0, (CFDataRef)propertyList);
+        } else {
+            result = CFDataCreateCopy(allocator, (CFDataRef)propertyList);
+        }
+    } else if (typeID == numbertype) {
+        // Warning - this will break if byteSize is ever greater than 32
+        uint8_t bytes[32];
+        CFNumberType numType = CFNumberGetType((CFNumberRef)propertyList);
+        CFNumberGetValue((CFNumberRef)propertyList, numType, (void *)bytes);
+        result = CFNumberCreate(allocator, numType, (void *)bytes);
+    } else if (typeID == booltype) {
+        // Booleans are immutable & shared instances
+        CFRetain(propertyList);
+        result = propertyList;
+    } else if (typeID == datetype) {
+        // Dates are immutable
+        result = CFDateCreate(allocator, CFDateGetAbsoluteTime((CFDateRef)propertyList));
+    } else if (typeID == stringtype) {
+        if (mutabilityOption == kCFPropertyListMutableContainersAndLeaves) {
+            result = CFStringCreateMutableCopy(allocator, 0, (CFStringRef)propertyList);
+        } else {
+            result = CFStringCreateCopy(allocator, (CFStringRef)propertyList);
+        }
+    } else {
+        CFAssert2(false, __kCFLogAssertion, "%s(): %p is not a property list type", __PRETTY_FUNCTION__, propertyList);
+        result = NULL;
+    }
+    CFRelease(allocator);
+    return result;
+}
+
diff --git a/CoreFoundation/CFPropertyList.h b/CoreFoundation/CFPropertyList.h
new file mode 100644
index 0000000..9ac413b
--- /dev/null
+++ b/CoreFoundation/CFPropertyList.h
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFPROPERTYLIST__)
+#define __COREFOUNDATION_CFPROPERTYLIST__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFStream.h>
+
+CF_EXTERN_C_BEGIN
+
+enum {
+    kCFPropertyListImmutable = 0,
+    kCFPropertyListMutableContainers,
+    kCFPropertyListMutableContainersAndLeaves
+};
+typedef CFOptionFlags CFPropertyListMutabilityOptions;
+    
+/*
+	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.
+*/
+CF_EXPORT
+CFPropertyListRef CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags mutabilityOption, CFStringRef *errorString);
+
+/*
+	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.
+*/
+CF_EXPORT
+CFDataRef CFPropertyListCreateXMLData(CFAllocatorRef allocator, CFPropertyListRef propertyList);
+
+/*
+	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);
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+
+enum {
+    kCFPropertyListOpenStepFormat = 1,
+    kCFPropertyListXMLFormat_v1_0 = 100,
+    kCFPropertyListBinaryFormat_v1_0 = 200
+};
+typedef CFIndex CFPropertyListFormat;
+
+CF_EXPORT
+Boolean CFPropertyListIsValid(CFPropertyListRef plist, CFPropertyListFormat format);
+
+/* 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
+CFIndex CFPropertyListWriteToStream(CFPropertyListRef propertyList, CFWriteStreamRef stream, CFPropertyListFormat format, CFStringRef *errorString);
+
+/* 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. */
+
+CF_EXPORT
+CFPropertyListRef CFPropertyListCreateFromStream(CFAllocatorRef allocator, CFReadStreamRef stream, CFIndex streamLength, CFOptionFlags mutabilityOption, CFPropertyListFormat *format, CFStringRef *errorString);
+
+/* 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. */
+
+#endif
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFPROPERTYLIST__ */
+
diff --git a/CoreFoundation/CFRunLoop.c b/CoreFoundation/CFRunLoop.c
new file mode 100644
index 0000000..d190406
--- /dev/null
+++ b/CoreFoundation/CFRunLoop.c
@@ -0,0 +1,3215 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFSet.h>
+#include <CoreFoundation/CFBag.h>
+#include "CFInternal.h"
+#include <math.h>
+#include <stdio.h>
+#include <limits.h>
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach/mach.h>
+#include <mach/clock_types.h>
+#include <mach/clock.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#if !defined(__MINGW32__) && !defined(__CYGWIN__)
+// With the MS headers, turning off Standard-C gets you macros for stat vs _stat.
+// Strictly speaking, this is supposed to control traditional vs ANSI C features.
+#undef __STDC__
+#endif
+#include <windows.h>
+#include <process.h>
+#if !defined(__MINGW32__) && !defined(__CYGWIN__)
+#define __STDC__
+#endif
+#elif DEPLOYMENT_TARGET_LINUX
+#include <dlfcn.h>
+#include <pthread.h>
+#include <semaphore.h>
+#endif
+
+static int _LogCFRunLoop = 0;
+
+#if 0 || 0
+static pthread_t kNilThreadT = { nil, nil };
+#define pthreadPointer(a) a.p
+#define lockCount(a) a.LockCount
+#define NativeThread pthread_t
+#elif DEPLOYMENT_TARGET_WINDOWS
+DWORD GetInternalThreadId(HANDLE t);
+
+static HANDLE kNilThreadT = 0;
+static DWORD __kCFMainThread = 0;
+#define pthreadPointer(a) ((void*)GetInternalThreadId(a))
+// Note: Windows RTL_CRITICAL_SECTION LockCount is initialized to -1
+// indicating no lock.  So add one so lock count shows a valid 'count'.
+#define lockCount(a) (a.LockCount + 1)
+#define NativeThread HANDLE
+#elif DEPLOYMENT_TARGET_LINUX
+static pthread_t kNilThreadT = (pthread_t)0;
+static pthread_t __kCFMainThread = (pthread_t)0;
+#define pthreadPointer(a) (void *)a
+#define lockCount(a) a.lock
+#define NativeThread pthread_t
+#else
+static pthread_t kNilThreadT = (pthread_t)0;
+#define pthreadPointer(a) a
+#define lockCount(a) a
+#define NativeThread pthread_t
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+#include <sys/types.h>
+#include <sys/event.h>
+
+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	(*perform)(const struct kevent *kev, void *info);
+    struct kevent event;
+} CFRunLoopSourceContext2;
+
+// The bits in the flags field in the kevent structure are cleared except for EV_ONESHOT and EV_CLEAR.
+// Do not use the udata field of the kevent structure -- that field is smashed by CFRunLoop.
+// There is no way to EV_ENABLE or EV_DISABLE a kevent.
+// The "autoinvalidation" of EV_ONESHOT is not handled properly by CFRunLoop yet.
+// The "autoinvalidation" of EV_DELETE on the last close of a file descriptor is not handled properly by CFRunLoop yet.
+// There is no way to reset the state in a kevent (such as clearing the EV_EOF state for fifos).
+#endif
+
+extern bool CFDictionaryGetKeyIfPresent(CFDictionaryRef dict, const void *key, const void **actualkey);
+
+// In order to reuse most of the code across Mach and Windows v1 RunLoopSources, we define a
+// simple abstraction layer spanning Mach ports and Windows HANDLES
+#if DEPLOYMENT_TARGET_MACOSX
+
+typedef mach_port_t __CFPort;
+#define CFPORT_NULL MACH_PORT_NULL
+#define CFPORTSET_NULL MACH_PORT_NULL
+typedef mach_port_t __CFPortSet;
+
+static __CFPort __CFPortAllocate(void) {
+    __CFPort result;
+    kern_return_t ret;
+    ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &result);
+    if (KERN_SUCCESS == ret) {
+        ret = mach_port_insert_right(mach_task_self(), result, result, MACH_MSG_TYPE_MAKE_SEND);
+    }
+    if (KERN_SUCCESS == ret) {
+        mach_port_limits_t limits;
+        limits.mpl_qlimit = 1;
+        ret = mach_port_set_attributes(mach_task_self(), result, MACH_PORT_LIMITS_INFO, (mach_port_info_t)&limits, MACH_PORT_LIMITS_INFO_COUNT);
+    }
+    return (KERN_SUCCESS == ret) ? result : CFPORT_NULL;
+}
+
+CF_INLINE void __CFPortFree(__CFPort port) {
+    mach_port_destroy(mach_task_self(), port);
+}
+
+CF_INLINE __CFPortSet __CFPortSetAllocate(void) {
+    __CFPortSet result;
+    kern_return_t ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &result);
+    return (KERN_SUCCESS == ret) ? result : CFPORT_NULL;
+}
+
+CF_INLINE Boolean __CFPortSetInsert(__CFPort port, __CFPortSet portSet) {
+    kern_return_t ret = mach_port_insert_member(mach_task_self(), port, portSet);
+    return (KERN_SUCCESS == ret);
+}
+
+CF_INLINE Boolean __CFPortSetRemove(__CFPort port, __CFPortSet portSet) {
+    kern_return_t ret = mach_port_extract_member(mach_task_self(), port, portSet);
+    return (KERN_SUCCESS == ret);
+}
+
+CF_INLINE void __CFPortSetFree(__CFPortSet portSet) {
+    kern_return_t ret;
+    mach_port_name_array_t array;
+    mach_msg_type_number_t idx, number;
+
+    ret = mach_port_get_set_status(mach_task_self(), portSet, &array, &number);
+    if (KERN_SUCCESS == ret) {
+        for (idx = 0; idx < number; idx++) {
+            mach_port_extract_member(mach_task_self(), array[idx], portSet);
+        }
+        vm_deallocate(mach_task_self(), (vm_address_t)array, number * sizeof(mach_port_name_t));
+    }
+    mach_port_destroy(mach_task_self(), portSet);
+}
+
+#elif DEPLOYMENT_TARGET_WINDOWS
+
+typedef HANDLE __CFPort;
+#define CFPORT_NULL NULL
+#define CFPORTSET_NULL NULL
+#define MAX_PORTS MAXIMUM_WAIT_OBJECTS
+
+CF_INLINE __CFPort __CFPortAllocate(void) {
+    return CreateEvent(NULL, true, false, NULL);
+}
+
+CF_INLINE void __CFPortFree(__CFPort port) {
+    CloseHandle(port);
+}
+
+#elif DEPLOYMENT_TARGET_LINUX
+
+typedef sem_t * __CFPort;
+#define CFPORT_NULL NULL
+#define CFPORTSET_NULL NULL
+#define MAX_PORTS 16
+
+CF_INLINE __CFPort __CFPortAllocate(void) {
+	__CFPort port = CFPORT_NULL;
+	int status;
+
+	port = (__CFPort)CFAllocatorAllocate(kCFAllocatorSystemDefault,
+										 sizeof(sem_t), 0);
+	CFAssert1(port != CFPORT_NULL, __kCFLogAssertion,
+			  "%s(): Could not allocate port memory.", __PRETTY_FUNCTION__);
+	if (port != CFPORT_NULL) {
+		status = sem_init(port, false, 0);
+		CFAssert1(status == 0, __kCFLogAssertion,
+				  "%s(): Could not initialize port.", __PRETTY_FUNCTION__);
+	}
+
+	return port;
+}
+
+CF_INLINE void __CFPortFree(__CFPort port) {
+	int status;
+	CFAssert1(port != CFPORT_NULL, __kCFLogAssertion,
+			  "%s(): Attemping to free an invalid port.", __PRETTY_FUNCTION__);
+	status = sem_destroy(port);
+	CFAllocatorDeallocate(kCFAllocatorSystemDefault, port);
+}
+
+#endif /* DEPLOYMENT_TARGET_MACOSX */
+
+#if !DEPLOYMENT_TARGET_MACOSX
+
+// A simple dynamic array of __CFPorts, which grows to a high-water mark
+typedef struct ___CFPortSet {
+    uint16_t	used;
+    uint16_t	size;
+    __CFPort	*ports;
+    CFSpinLock_t lock;		// insert and remove must be thread safe, like the Mach calls
+} *__CFPortSet;
+
+static __CFPortSet __CFPortSetAllocate(void) {
+    __CFPortSet result = (__CFPortSet)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(struct ___CFPortSet), 0);
+    result->used = 0;
+    result->size = 4;
+    result->ports = (__CFPort *)CFAllocatorAllocate(kCFAllocatorSystemDefault, result->size * sizeof(__CFPort), 0);
+    CF_SPINLOCK_INIT_FOR_STRUCTS(result->lock);
+    return result;
+}
+
+static void __CFPortSetFree(__CFPortSet portSet) {
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, portSet->ports);
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, portSet);
+}
+
+// Returns portBuf if ports fit in that space, else returns another ptr that must be freed
+static __CFPort *__CFPortSetGetPorts(__CFPortSet portSet, __CFPort *portBuf, uint32_t bufSize, uint32_t *portsUsed) {
+    __CFSpinLock(&(portSet->lock));
+    __CFPort *result = portBuf;
+    if (bufSize > portSet->used)
+        result = (__CFPort *)CFAllocatorAllocate(kCFAllocatorSystemDefault, portSet->used * sizeof(__CFPort), 0);
+    memmove(result, portSet->ports, portSet->used * sizeof(__CFPort));
+    *portsUsed = portSet->used;
+    __CFSpinUnlock(&(portSet->lock));
+    return result;
+}
+
+static Boolean __CFPortSetInsert(__CFPort port, __CFPortSet portSet) {
+    __CFSpinLock(&(portSet->lock));
+    if (portSet->used >= portSet->size) {
+        portSet->size += 4;
+        portSet->ports = (__CFPort*)CFAllocatorReallocate(kCFAllocatorSystemDefault, portSet->ports, portSet->size * sizeof(__CFPort), 0);
+    }
+    if (portSet->used >= MAX_PORTS)
+        CFLog(kCFLogLevelWarning, CFSTR("*** More than %d ports added to a port set. The last ones will be ignored."), MAX_PORTS);
+    portSet->ports[portSet->used++] = port;
+    __CFSpinUnlock(&(portSet->lock));
+    return true;
+}
+
+static Boolean __CFPortSetRemove(__CFPort port, __CFPortSet portSet) {
+    int i, j;
+    __CFSpinLock(&(portSet->lock));
+    for (i = 0; i < portSet->used; i++) {
+        if (portSet->ports[i] == port) {
+            for (j = i+1; j < portSet->used; j++) {
+                portSet->ports[j-1] = portSet->ports[j];
+            }
+            portSet->used--;
+            __CFSpinUnlock(&(portSet->lock));
+            return true;
+        }
+    }
+    __CFSpinUnlock(&(portSet->lock));
+    return false;
+}
+
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+extern mach_port_name_t mk_timer_create(void);
+extern kern_return_t mk_timer_destroy(mach_port_name_t name);
+extern kern_return_t mk_timer_arm(mach_port_name_t name, AbsoluteTime expire_time);
+extern kern_return_t mk_timer_cancel(mach_port_name_t name, AbsoluteTime *result_time);
+
+CF_INLINE AbsoluteTime __CFUInt64ToAbsoluteTime(int64_t x) {
+    AbsoluteTime a;
+    a.hi = x >> 32;
+    a.lo = x & (int64_t)0xFFFFFFFF;
+    return a;
+}
+
+static uint32_t __CFSendTrivialMachMessage(mach_port_t port, uint32_t msg_id, CFOptionFlags options, uint32_t timeout) {
+    kern_return_t result;
+    mach_msg_header_t header;
+    header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
+    header.msgh_size = sizeof(mach_msg_header_t);
+    header.msgh_remote_port = port;
+    header.msgh_local_port = MACH_PORT_NULL;
+    header.msgh_id = msg_id;
+    result = mach_msg(&header, MACH_SEND_MSG|options, header.msgh_size, 0, MACH_PORT_NULL, timeout, MACH_PORT_NULL);
+    if (result == MACH_SEND_TIMED_OUT) mach_msg_destroy(&header);
+    return result;
+}
+#endif
+
+/* unlock a run loop and modes before doing callouts/sleeping */
+/* never try to take the run loop lock with a mode locked */
+/* be very careful of common subexpression elimination and compacting code, particular across locks and unlocks! */
+/* run loop mode structures should never be deallocated, even if they become empty */
+
+static CFTypeID __kCFRunLoopModeTypeID = _kCFRuntimeNotATypeID;
+static CFTypeID __kCFRunLoopTypeID = _kCFRuntimeNotATypeID;
+static CFTypeID __kCFRunLoopSourceTypeID = _kCFRuntimeNotATypeID;
+static CFTypeID __kCFRunLoopObserverTypeID = _kCFRuntimeNotATypeID;
+static CFTypeID __kCFRunLoopTimerTypeID = _kCFRuntimeNotATypeID;
+
+typedef struct __CFRunLoopMode *CFRunLoopModeRef;
+
+struct __CFRunLoopMode {
+    CFRuntimeBase _base;
+    CFSpinLock_t _lock;	/* must have the run loop locked before locking this */
+    CFStringRef _name;
+    Boolean _stopped;
+    char _padding[3];
+    CFMutableSetRef _sources;
+    CFMutableSetRef _observers;
+    CFMutableSetRef _timers;
+    CFMutableArrayRef _submodes; // names of the submodes
+    __CFPortSet _portSet;
+#if DEPLOYMENT_TARGET_MACOSX
+    int _kq;
+#elif DEPLOYMENT_TARGET_WINDOWS
+    DWORD _msgQMask;
+#endif
+};
+
+static int64_t __CFRunLoopGetNextTimerFireTSR(CFRunLoopRef rl, CFRunLoopModeRef rlm);
+
+CF_INLINE void __CFRunLoopModeLock(CFRunLoopModeRef rlm) {
+    __CFSpinLock(&(rlm->_lock));
+}
+
+CF_INLINE void __CFRunLoopModeUnlock(CFRunLoopModeRef rlm) {
+    __CFSpinUnlock(&(rlm->_lock));
+}
+
+static Boolean __CFRunLoopModeEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFRunLoopModeRef rlm1 = (CFRunLoopModeRef)cf1;
+    CFRunLoopModeRef rlm2 = (CFRunLoopModeRef)cf2;
+    return CFEqual(rlm1->_name, rlm2->_name);
+}
+
+static CFHashCode __CFRunLoopModeHash(CFTypeRef cf) {
+    CFRunLoopModeRef rlm = (CFRunLoopModeRef)cf;
+    return CFHash(rlm->_name);
+}
+
+static CFStringRef __CFRunLoopModeCopyDescription(CFTypeRef cf) {
+    CFRunLoopModeRef rlm = (CFRunLoopModeRef)cf;
+    CFMutableStringRef result;
+    result = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+    CFStringAppendFormat(result, NULL, CFSTR("<CFRunLoopMode %p [%p]>{name = %@, "), rlm, CFGetAllocator(rlm), rlm->_name);
+#if DEPLOYMENT_TARGET_MACOSX
+    CFStringAppendFormat(result, NULL, CFSTR("port set = %p,"), rlm->_portSet);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    CFStringAppendFormat(result, NULL, CFSTR("MSGQ mask = %p,"), rlm->_msgQMask);
+#endif
+    CFStringAppendFormat(result, NULL, CFSTR("\n\tsources = %@,\n\tobservers == %@,\n\ttimers = %@\n},\n"), rlm->_sources, rlm->_observers, rlm->_timers);
+    return result;
+}
+
+static void __CFRunLoopModeDeallocate(CFTypeRef cf) {
+    CFRunLoopModeRef rlm = (CFRunLoopModeRef)cf;
+    if (NULL != rlm->_sources) CFRelease(rlm->_sources);
+    if (NULL != rlm->_observers) CFRelease(rlm->_observers);
+    if (NULL != rlm->_timers) CFRelease(rlm->_timers);
+    if (NULL != rlm->_submodes) CFRelease(rlm->_submodes);
+    CFRelease(rlm->_name);
+    __CFPortSetFree(rlm->_portSet);
+#if DEPLOYMENT_TARGET_MACOSX
+    if (-1 != rlm->_kq) close(rlm->_kq);
+#endif
+}
+
+struct __CFRunLoop {
+    CFRuntimeBase _base;
+    CFSpinLock_t _lock;			/* locked for accessing mode list */
+    __CFPort _wakeUpPort;			// used for CFRunLoopWakeUp 
+    volatile uint32_t *_stopped;
+    CFMutableSetRef _commonModes;
+    CFMutableSetRef _commonModeItems;
+    CFRunLoopModeRef _currentMode;
+    CFMutableSetRef _modes;
+    void *_counterpart;
+};
+
+/* Bit 0 of the base reserved bits is used for stopped state */
+/* Bit 1 of the base reserved bits is used for sleeping state */
+/* Bit 2 of the base reserved bits is used for deallocating state */
+
+CF_INLINE Boolean __CFRunLoopIsStopped(CFRunLoopRef rl) {
+    return (rl->_stopped && rl->_stopped[2]) ? true : false;
+}
+
+CF_INLINE void __CFRunLoopSetStopped(CFRunLoopRef rl) {
+    if (rl->_stopped) rl->_stopped[2] = 0x53544F50;	// 'STOP'
+}
+
+CF_INLINE void __CFRunLoopUnsetStopped(CFRunLoopRef rl) {
+    if (rl->_stopped) rl->_stopped[2] = 0x0;
+}
+
+CF_INLINE Boolean __CFRunLoopIsSleeping(CFRunLoopRef rl) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)rl)->_cfinfo[CF_INFO_BITS], 1, 1);
+}
+
+CF_INLINE void __CFRunLoopSetSleeping(CFRunLoopRef rl) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rl)->_cfinfo[CF_INFO_BITS], 1, 1, 1);
+}
+
+CF_INLINE void __CFRunLoopUnsetSleeping(CFRunLoopRef rl) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rl)->_cfinfo[CF_INFO_BITS], 1, 1, 0);
+}
+
+CF_INLINE Boolean __CFRunLoopIsDeallocating(CFRunLoopRef rl) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)rl)->_cfinfo[CF_INFO_BITS], 2, 2);
+}
+
+CF_INLINE void __CFRunLoopSetDeallocating(CFRunLoopRef rl) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rl)->_cfinfo[CF_INFO_BITS], 2, 2, 1);
+}
+
+CF_INLINE void __CFRunLoopLock(CFRunLoopRef rl) {
+    __CFSpinLock(&(((CFRunLoopRef)rl)->_lock));
+}
+
+CF_INLINE void __CFRunLoopUnlock(CFRunLoopRef rl) {
+    __CFSpinUnlock(&(((CFRunLoopRef)rl)->_lock));
+}
+
+static CFStringRef __CFRunLoopCopyDescription(CFTypeRef cf) {
+    CFRunLoopRef rl = (CFRunLoopRef)cf;
+    CFMutableStringRef result;
+    result = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+    CFStringAppendFormat(result, NULL, CFSTR("<CFRunLoop %p [%p]>{wait port = 0x%x, stopped = %s,\ncurrent mode = %@,\n"), cf, CFGetAllocator(cf), rl->_wakeUpPort, (rl->_stopped && (rl->_stopped[2] == 0x53544F50)) ? "true" : "false", rl->_currentMode ? rl->_currentMode->_name : CFSTR("(none)"));
+    CFStringAppendFormat(result, NULL, CFSTR("common modes = %@,\ncommon mode items = %@,\nmodes = %@}\n"), rl->_commonModes, rl->_commonModeItems, rl->_modes);
+    return result;
+}
+
+/* call with rl locked */
+static CFRunLoopModeRef __CFRunLoopFindMode(CFRunLoopRef rl, CFStringRef modeName, Boolean create) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    struct __CFRunLoopMode srlm;
+    srlm._base._cfisa = __CFISAForTypeID(__kCFRunLoopModeTypeID);
+    srlm._base._cfinfo[CF_INFO_BITS] = 0;
+    _CFRuntimeSetInstanceTypeID(&srlm, __kCFRunLoopModeTypeID);
+    srlm._name = modeName;
+    rlm = (CFRunLoopModeRef)CFSetGetValue(rl->_modes, &srlm);
+    if (NULL != rlm) {
+	__CFRunLoopModeLock(rlm);
+	return rlm;
+    }
+    if (!create) {
+	return NULL;
+    }
+    rlm = (CFRunLoopModeRef)_CFRuntimeCreateInstance(CFGetAllocator(rl), __kCFRunLoopModeTypeID, sizeof(struct __CFRunLoopMode) - sizeof(CFRuntimeBase), NULL);
+    if (NULL == rlm) {
+	return NULL;
+    }
+    CF_SPINLOCK_INIT_FOR_STRUCTS(rlm->_lock);
+    rlm->_name = CFStringCreateCopy(CFGetAllocator(rlm), modeName);
+    rlm->_stopped = false;
+    rlm->_sources = NULL;
+    rlm->_observers = NULL;
+    rlm->_timers = NULL;
+    rlm->_submodes = NULL;
+    rlm->_portSet = __CFPortSetAllocate();
+    if (CFPORTSET_NULL == rlm->_portSet) HALT;
+    if (!__CFPortSetInsert(rl->_wakeUpPort, rlm->_portSet)) HALT;
+#if DEPLOYMENT_TARGET_MACOSX
+    rlm->_kq = -1;
+#elif DELPOYMENT_TARGET_WIN32
+    rlm->_msgQMask = 0;
+#endif
+    CFSetAddValue(rl->_modes, rlm);
+    CFRelease(rlm);
+    __CFRunLoopModeLock(rlm);	/* return mode locked */
+    return rlm;
+}
+
+
+// expects rl and rlm locked
+static Boolean __CFRunLoopModeIsEmpty(CFRunLoopRef rl, CFRunLoopModeRef rlm) {
+    CHECK_FOR_FORK();
+    if (NULL == rlm) return true;
+#if DEPLOYMENT_TARGET_WINDOWS
+    if (0 != rlm->_msgQMask) return false;
+#endif
+    if (NULL != rlm->_sources && 0 < CFSetGetCount(rlm->_sources)) return false;
+    if (NULL != rlm->_timers && 0 < CFSetGetCount(rlm->_timers)) return false;
+    if (NULL != rlm->_submodes) {
+	CFIndex idx, cnt;
+	for (idx = 0, cnt = CFArrayGetCount(rlm->_submodes); idx < cnt; idx++) {
+	    CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(rlm->_submodes, idx);
+	    CFRunLoopModeRef subrlm;
+	    Boolean subIsEmpty;
+	    subrlm = __CFRunLoopFindMode(rl, modeName, false);
+	    subIsEmpty = (NULL != subrlm) ? __CFRunLoopModeIsEmpty(rl, subrlm) : true;
+	    if (NULL != subrlm) __CFRunLoopModeUnlock(subrlm);
+	    if (!subIsEmpty) return false;
+	}
+    }
+    return true;
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS
+DWORD __CFRunLoopGetWindowsMessageQueueMask(CFRunLoopRef rl, CFStringRef modeName) {
+    CFRunLoopModeRef rlm;
+    DWORD result = 0;
+    __CFRunLoopLock(rl);
+    rlm = __CFRunLoopFindMode(rl, modeName, false);
+    if (rlm) {
+	result = rlm->_msgQMask;
+	__CFRunLoopModeUnlock(rlm);
+    }
+    __CFRunLoopUnlock(rl);
+    return result;
+}
+
+void __CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef rl, DWORD mask, CFStringRef modeName) {
+    CFRunLoopModeRef rlm;
+    __CFRunLoopLock(rl);
+    rlm = __CFRunLoopFindMode(rl, modeName, true);
+    rlm->_msgQMask = mask;
+    __CFRunLoopModeUnlock(rlm);
+    __CFRunLoopUnlock(rl);
+}
+#endif
+
+/* Bit 3 in the base reserved bits is used for invalid state in run loop objects */
+
+CF_INLINE Boolean __CFIsValid(const void *cf) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 3);
+}
+
+CF_INLINE void __CFSetValid(void *cf) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 3, 1);
+}
+
+CF_INLINE void __CFUnsetValid(void *cf) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 3, 3, 0);
+}
+
+struct __CFRunLoopSource {
+    CFRuntimeBase _base;
+    uint32_t _bits;
+    CFSpinLock_t _lock;
+    CFIndex _order;			/* immutable */
+    CFMutableBagRef _runLoops;
+    union {
+	CFRunLoopSourceContext version0;	/* immutable, except invalidation */
+        CFRunLoopSourceContext1 version1;	/* immutable, except invalidation */
+    } _context;
+};
+
+/* Bit 1 of the base reserved bits is used for signalled state */
+
+CF_INLINE Boolean __CFRunLoopSourceIsSignaled(CFRunLoopSourceRef rls) {
+    return (Boolean)__CFBitfieldGetValue(rls->_bits, 1, 1);
+}
+
+CF_INLINE void __CFRunLoopSourceSetSignaled(CFRunLoopSourceRef rls) {
+    __CFBitfieldSetValue(rls->_bits, 1, 1, 1);
+}
+
+CF_INLINE void __CFRunLoopSourceUnsetSignaled(CFRunLoopSourceRef rls) {
+    __CFBitfieldSetValue(rls->_bits, 1, 1, 0);
+}
+
+CF_INLINE void __CFRunLoopSourceLock(CFRunLoopSourceRef rls) {
+    __CFSpinLock(&(rls->_lock));
+}
+
+CF_INLINE void __CFRunLoopSourceUnlock(CFRunLoopSourceRef rls) {
+    __CFSpinUnlock(&(rls->_lock));
+}
+
+/* rlm is not locked */
+static void __CFRunLoopSourceSchedule(CFRunLoopSourceRef rls, CFRunLoopRef rl, CFRunLoopModeRef rlm) {	/* DOES CALLOUT */
+    __CFRunLoopSourceLock(rls);
+    if (NULL == rls->_runLoops) {
+	rls->_runLoops = CFBagCreateMutable(CFGetAllocator(rls), 0, NULL);
+    }
+    CFBagAddValue(rls->_runLoops, rl);
+    __CFRunLoopSourceUnlock(rls);	// have to unlock before the callout -- cannot help clients with safety
+    if (0 == rls->_context.version0.version) {
+	if (NULL != rls->_context.version0.schedule) {
+	    rls->_context.version0.schedule(rls->_context.version0.info, rl, rlm->_name);
+	}
+    } else if (1 == rls->_context.version0.version) {
+        __CFPort port = rls->_context.version1.getPort(rls->_context.version1.info);	/* CALLOUT */
+	if (CFPORT_NULL != port) {
+            __CFPortSetInsert(port, rlm->_portSet);
+	}
+    }
+}
+
+/* rlm is not locked */
+static void __CFRunLoopSourceCancel(CFRunLoopSourceRef rls, CFRunLoopRef rl, CFRunLoopModeRef rlm) {	/* DOES CALLOUT */
+    if (0 == rls->_context.version0.version) {
+	if (NULL != rls->_context.version0.cancel) {
+	    rls->_context.version0.cancel(rls->_context.version0.info, rl, rlm->_name);	/* CALLOUT */
+	}
+    } else if (1 == rls->_context.version0.version) {
+        __CFPort port = rls->_context.version1.getPort(rls->_context.version1.info);	/* CALLOUT */
+        if (CFPORT_NULL != port) {
+            __CFPortSetRemove(port, rlm->_portSet);
+	}
+    }
+    __CFRunLoopSourceLock(rls);
+    if (NULL != rls->_runLoops) {
+        CFBagRemoveValue(rls->_runLoops, rl);
+    }
+    __CFRunLoopSourceUnlock(rls);
+}
+
+struct __CFRunLoopObserver {
+    CFRuntimeBase _base;
+    CFSpinLock_t _lock;
+    CFRunLoopRef _runLoop;
+    CFIndex _rlCount;
+    CFOptionFlags _activities;		/* immutable */
+    CFIndex _order;			/* immutable */
+    CFRunLoopObserverCallBack _callout;	/* immutable */
+    CFRunLoopObserverContext _context;	/* immutable, except invalidation */
+};
+
+/* Bit 0 of the base reserved bits is used for firing state */
+/* Bit 1 of the base reserved bits is used for repeats state */
+
+CF_INLINE Boolean __CFRunLoopObserverIsFiring(CFRunLoopObserverRef rlo) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)rlo)->_cfinfo[CF_INFO_BITS], 0, 0);
+}
+
+CF_INLINE void __CFRunLoopObserverSetFiring(CFRunLoopObserverRef rlo) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlo)->_cfinfo[CF_INFO_BITS], 0, 0, 1);
+}
+
+CF_INLINE void __CFRunLoopObserverUnsetFiring(CFRunLoopObserverRef rlo) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlo)->_cfinfo[CF_INFO_BITS], 0, 0, 0);
+}
+
+CF_INLINE Boolean __CFRunLoopObserverRepeats(CFRunLoopObserverRef rlo) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)rlo)->_cfinfo[CF_INFO_BITS], 1, 1);
+}
+
+CF_INLINE void __CFRunLoopObserverSetRepeats(CFRunLoopObserverRef rlo) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlo)->_cfinfo[CF_INFO_BITS], 1, 1, 1);
+}
+
+CF_INLINE void __CFRunLoopObserverUnsetRepeats(CFRunLoopObserverRef rlo) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlo)->_cfinfo[CF_INFO_BITS], 1, 1, 0);
+}
+
+CF_INLINE void __CFRunLoopObserverLock(CFRunLoopObserverRef rlo) {
+    __CFSpinLock(&(rlo->_lock));
+}
+
+CF_INLINE void __CFRunLoopObserverUnlock(CFRunLoopObserverRef rlo) {
+    __CFSpinUnlock(&(rlo->_lock));
+}
+
+static void __CFRunLoopObserverSchedule(CFRunLoopObserverRef rlo, CFRunLoopRef rl, CFRunLoopModeRef rlm) {
+    __CFRunLoopObserverLock(rlo);
+    if (0 == rlo->_rlCount) {
+	rlo->_runLoop = rl;
+    }
+    rlo->_rlCount++;
+    __CFRunLoopObserverUnlock(rlo);
+}
+
+static void __CFRunLoopObserverCancel(CFRunLoopObserverRef rlo, CFRunLoopRef rl, CFRunLoopModeRef rlm) {
+    __CFRunLoopObserverLock(rlo);
+    rlo->_rlCount--;
+    if (0 == rlo->_rlCount) {
+	rlo->_runLoop = NULL;
+    }
+    __CFRunLoopObserverUnlock(rlo);
+}
+
+struct __CFRunLoopTimer {
+    CFRuntimeBase _base;
+    CFSpinLock_t _lock;
+    CFRunLoopRef _runLoop;
+    CFIndex _rlCount;
+#if DEPLOYMENT_TARGET_MACOSX
+    mach_port_name_t _port;
+#endif
+    CFIndex _order;			/* immutable */
+    int64_t _fireTSR;			/* TSR units */
+    int64_t _intervalTSR;		/* immutable; 0 means non-repeating; TSR units */
+    CFRunLoopTimerCallBack _callout;	/* immutable */
+    CFRunLoopTimerContext _context;	/* immutable, except invalidation */
+};
+
+/* Bit 0 of the base reserved bits is used for firing state */
+/* Bit 1 of the base reserved bits is used for fired-during-callout state */
+
+CF_INLINE Boolean __CFRunLoopTimerIsFiring(CFRunLoopTimerRef rlt) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)rlt)->_cfinfo[CF_INFO_BITS], 0, 0);
+}
+
+CF_INLINE void __CFRunLoopTimerSetFiring(CFRunLoopTimerRef rlt) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlt)->_cfinfo[CF_INFO_BITS], 0, 0, 1);
+}
+
+CF_INLINE void __CFRunLoopTimerUnsetFiring(CFRunLoopTimerRef rlt) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlt)->_cfinfo[CF_INFO_BITS], 0, 0, 0);
+}
+
+CF_INLINE Boolean __CFRunLoopTimerDidFire(CFRunLoopTimerRef rlt) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)rlt)->_cfinfo[CF_INFO_BITS], 1, 1);
+}
+
+CF_INLINE void __CFRunLoopTimerSetDidFire(CFRunLoopTimerRef rlt) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlt)->_cfinfo[CF_INFO_BITS], 1, 1, 1);
+}
+
+CF_INLINE void __CFRunLoopTimerUnsetDidFire(CFRunLoopTimerRef rlt) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)rlt)->_cfinfo[CF_INFO_BITS], 1, 1, 0);
+}
+
+CF_INLINE void __CFRunLoopTimerLock(CFRunLoopTimerRef rlt) {
+    __CFSpinLock(&(rlt->_lock));
+}
+
+CF_INLINE void __CFRunLoopTimerUnlock(CFRunLoopTimerRef rlt) {
+    __CFSpinUnlock(&(rlt->_lock));
+}
+
+static CFSpinLock_t __CFRLTFireTSRLock = CFSpinLockInit;
+
+CF_INLINE void __CFRunLoopTimerFireTSRLock(void) {
+    __CFSpinLock(&__CFRLTFireTSRLock);
+}
+
+CF_INLINE void __CFRunLoopTimerFireTSRUnlock(void) {
+    __CFSpinUnlock(&__CFRLTFireTSRLock);
+}
+
+#if DEPLOYMENT_TARGET_MACOSX
+static CFMutableDictionaryRef __CFRLTPortMap = NULL;
+static CFSpinLock_t __CFRLTPortMapLock = CFSpinLockInit;
+
+CF_INLINE void __CFRunLoopTimerPortMapLock(void) {
+    __CFSpinLock(&__CFRLTPortMapLock);
+}
+
+CF_INLINE void __CFRunLoopTimerPortMapUnlock(void) {
+    __CFSpinUnlock(&__CFRLTPortMapLock);
+}
+#endif
+
+static void __CFRunLoopTimerSchedule(CFRunLoopTimerRef rlt, CFRunLoopRef rl, CFRunLoopModeRef rlm) {
+#if DEPLOYMENT_TARGET_MACOSX
+    __CFRunLoopTimerLock(rlt);
+    if (0 == rlt->_rlCount) {
+	rlt->_runLoop = rl;
+	if (MACH_PORT_NULL == rlt->_port) {
+	    rlt->_port = mk_timer_create();
+	}
+	__CFRunLoopTimerPortMapLock();
+	if (NULL == __CFRLTPortMap) {
+	    __CFRLTPortMap = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);
+	}
+	CFDictionarySetValue(__CFRLTPortMap, (void *)(uintptr_t)rlt->_port, rlt);
+	__CFRunLoopTimerPortMapUnlock();
+    }
+    rlt->_rlCount++;
+    mach_port_insert_member(mach_task_self(), rlt->_port, rlm->_portSet);
+    mk_timer_arm(rlt->_port, __CFUInt64ToAbsoluteTime(rlt->_fireTSR));
+    __CFRunLoopTimerUnlock(rlt);
+#endif
+}
+
+static void __CFRunLoopTimerCancel(CFRunLoopTimerRef rlt, CFRunLoopRef rl, CFRunLoopModeRef rlm) {
+#if DEPLOYMENT_TARGET_MACOSX
+    __CFRunLoopTimerLock(rlt);
+    __CFPortSetRemove(rlt->_port, rlm->_portSet);
+    rlt->_rlCount--;
+    if (0 == rlt->_rlCount) {
+	__CFRunLoopTimerPortMapLock();
+	if (NULL != __CFRLTPortMap) {
+	    CFDictionaryRemoveValue(__CFRLTPortMap, (void *)(uintptr_t)rlt->_port);
+	}
+	__CFRunLoopTimerPortMapUnlock();
+	rlt->_runLoop = NULL;
+	mk_timer_cancel(rlt->_port, NULL);
+    }
+    __CFRunLoopTimerUnlock(rlt);
+#endif
+}
+
+// Caller must hold the Timer lock for safety
+static void __CFRunLoopTimerRescheduleWithAllModes(CFRunLoopTimerRef rlt, CFRunLoopRef rl) {
+#if DEPLOYMENT_TARGET_MACOSX
+    mk_timer_arm(rlt->_port, __CFUInt64ToAbsoluteTime(rlt->_fireTSR));
+#endif
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+typedef struct _collectTimersContext {
+    CFMutableArrayRef results;
+    int64_t cutoffTSR;
+};
+
+static void __CFRunLoopCollectTimers(const void *value, void *ctx) {
+    CFRunLoopTimerRef rlt = (CFRunLoopTimerRef)value;
+    struct _collectTimersContext *context = (struct _collectTimersContext*)ctx;
+    if (rlt->_fireTSR <= context->cutoffTSR) {
+        if (NULL == context->results)
+            context->results = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+        CFArrayAppendValue(context->results, rlt);
+    }
+}
+
+// RunLoop and RunLoopMode must be locked
+static void __CFRunLoopTimersToFireRecursive(CFRunLoopRef rl, CFRunLoopModeRef rlm, struct _collectTimersContext *ctxt) {
+    if (NULL != rlm->_timers && 0 < CFSetGetCount(rlm->_timers)) {
+        __CFRunLoopTimerFireTSRLock();
+        CFSetApplyFunction(rlm->_timers, __CFRunLoopCollectTimers, ctxt);
+        __CFRunLoopTimerFireTSRUnlock();
+    }
+    if (NULL != rlm->_submodes) {
+        CFIndex idx, cnt;
+        for (idx = 0, cnt = CFArrayGetCount(rlm->_submodes); idx < cnt; idx++) {
+            CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(rlm->_submodes, idx);
+            CFRunLoopModeRef subrlm;
+            subrlm = __CFRunLoopFindMode(rl, modeName, false);
+            if (NULL != subrlm) {
+                __CFRunLoopTimersToFireRecursive(rl, subrlm, ctxt);
+                __CFRunLoopModeUnlock(subrlm);
+            }
+        }
+    }
+}
+
+// RunLoop and RunLoopMode must be locked
+static CFArrayRef __CFRunLoopTimersToFire(CFRunLoopRef rl, CFRunLoopModeRef rlm) {
+    struct _collectTimersContext ctxt = {NULL, __CFReadTSR()};
+    __CFRunLoopTimersToFireRecursive(rl, rlm, &ctxt);
+    return ctxt.results;
+}
+#endif // DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+
+/* CFRunLoop */
+
+CONST_STRING_DECL(kCFRunLoopDefaultMode, "kCFRunLoopDefaultMode")
+CONST_STRING_DECL(kCFRunLoopCommonModes, "kCFRunLoopCommonModes")
+
+struct _findsource {
+    __CFPort port;
+    CFRunLoopSourceRef result;
+};
+
+static void __CFRunLoopFindSource(const void *value, void *ctx) {
+    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)value;
+    struct _findsource *context = (struct _findsource *)ctx;
+    __CFPort port;
+    if (NULL != context->result) return;
+    if (1 != rls->_context.version0.version) return;
+    __CFRunLoopSourceLock(rls);
+    port = rls->_context.version1.getPort(rls->_context.version1.info);
+    if (port == context->port) {
+	context->result = rls;
+    }
+    __CFRunLoopSourceUnlock(rls);
+}
+
+// call with rl and rlm locked
+static CFRunLoopSourceRef __CFRunLoopModeFindSourceForMachPort(CFRunLoopRef rl, CFRunLoopModeRef rlm, __CFPort port) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    struct _findsource context = {port, NULL};
+    if (NULL != rlm->_sources) {
+	CFSetApplyFunction(rlm->_sources, (__CFRunLoopFindSource), &context);
+    }
+    if (NULL == context.result && NULL != rlm->_submodes) {
+	CFIndex idx, cnt;
+	for (idx = 0, cnt = CFArrayGetCount(rlm->_submodes); idx < cnt; idx++) {
+	    CFRunLoopSourceRef source = NULL;
+	    CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(rlm->_submodes, idx);
+	    CFRunLoopModeRef subrlm;
+            subrlm = __CFRunLoopFindMode(rl, modeName, false);
+	    if (NULL != subrlm) {
+		source = __CFRunLoopModeFindSourceForMachPort(rl, subrlm, port);
+		__CFRunLoopModeUnlock(subrlm);
+	    }
+	    if (NULL != source) {
+		context.result = source;
+		break;
+	    }
+	}
+    }
+    return context.result;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX
+// call with rl and rlm locked
+static CFRunLoopTimerRef __CFRunLoopModeFindTimerForMachPort(CFRunLoopModeRef rlm, __CFPort port) {
+    CHECK_FOR_FORK();
+    CFRunLoopTimerRef result = NULL;
+    __CFRunLoopTimerPortMapLock();
+    if (NULL != __CFRLTPortMap) {
+	result = (CFRunLoopTimerRef)CFDictionaryGetValue(__CFRLTPortMap, (void *)(uintptr_t)port);
+    }
+    __CFRunLoopTimerPortMapUnlock();
+    return result;
+}
+#endif
+
+static void __CFRunLoopDeallocateSources(const void *value, void *context) {
+    CFRunLoopModeRef rlm = (CFRunLoopModeRef)value;
+    CFRunLoopRef rl = (CFRunLoopRef)context;
+    CFIndex idx, cnt;
+    const void **list, *buffer[256];
+    if (NULL == rlm->_sources) return;
+    cnt = CFSetGetCount(rlm->_sources);
+    list = (cnt <= 256) ? buffer : (const void**)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(void *), 0);
+    CFSetGetValues(rlm->_sources, list);
+    for (idx = 0; idx < cnt; idx++) {
+	CFRetain(list[idx]);
+    }
+    CFSetRemoveAllValues(rlm->_sources);
+    for (idx = 0; idx < cnt; idx++) {
+	__CFRunLoopSourceCancel((CFRunLoopSourceRef)list[idx], rl, rlm);
+	CFRelease(list[idx]);
+    }
+    if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+}
+
+static void __CFRunLoopDeallocateObservers(const void *value, void *context) {
+    CFRunLoopModeRef rlm = (CFRunLoopModeRef)value;
+    CFRunLoopRef rl = (CFRunLoopRef)context;
+    CFIndex idx, cnt;
+    const void **list, *buffer[256];
+    if (NULL == rlm->_observers) return;
+    cnt = CFSetGetCount(rlm->_observers);
+    list = (cnt <= 256) ? buffer : (const void**)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(void *), 0);
+    CFSetGetValues(rlm->_observers, list);
+    for (idx = 0; idx < cnt; idx++) {
+	CFRetain(list[idx]);
+    }
+    CFSetRemoveAllValues(rlm->_observers);
+    for (idx = 0; idx < cnt; idx++) {
+	__CFRunLoopObserverCancel((CFRunLoopObserverRef)list[idx], rl, rlm);
+	CFRelease(list[idx]);
+    }
+    if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+}
+
+static void __CFRunLoopDeallocateTimers(const void *value, void *context) {
+    CFRunLoopModeRef rlm = (CFRunLoopModeRef)value;
+    CFRunLoopRef rl = (CFRunLoopRef)context;
+    CFIndex idx, cnt;
+    const void **list, *buffer[256];
+    if (NULL == rlm->_timers) return;
+    cnt = CFSetGetCount(rlm->_timers);
+    list = (cnt <= 256) ? buffer : (const void**)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(void *), 0);
+    CFSetGetValues(rlm->_timers, list);
+    for (idx = 0; idx < cnt; idx++) {
+	CFRetain(list[idx]);
+    }
+    CFSetRemoveAllValues(rlm->_timers);
+    for (idx = 0; idx < cnt; idx++) {
+	__CFRunLoopTimerCancel((CFRunLoopTimerRef)list[idx], rl, rlm);
+	CFRelease(list[idx]);
+    }
+    if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+}
+
+static void __CFRunLoopDeallocate(CFTypeRef cf) {
+    CFRunLoopRef rl = (CFRunLoopRef)cf;
+    /* We try to keep the run loop in a valid state as long as possible,
+       since sources may have non-retained references to the run loop.
+       Another reason is that we don't want to lock the run loop for
+       callback reasons, if we can get away without that.  We start by
+       eliminating the sources, since they are the most likely to call
+       back into the run loop during their "cancellation". Common mode
+       items will be removed from the mode indirectly by the following
+       three lines. */
+    __CFRunLoopSetDeallocating(rl);
+    if (NULL != rl->_modes) {
+	CFSetApplyFunction(rl->_modes, (__CFRunLoopDeallocateSources), rl);
+	CFSetApplyFunction(rl->_modes, (__CFRunLoopDeallocateObservers), rl);
+	CFSetApplyFunction(rl->_modes, (__CFRunLoopDeallocateTimers), rl);
+    }
+    __CFRunLoopLock(rl);
+    if (NULL != rl->_commonModeItems) {
+	CFRelease(rl->_commonModeItems);
+    }
+    if (NULL != rl->_commonModes) {
+	CFRelease(rl->_commonModes);
+    }
+    if (NULL != rl->_modes) {
+	CFRelease(rl->_modes);
+    }
+    __CFPortFree(rl->_wakeUpPort);
+    rl->_wakeUpPort = CFPORT_NULL;
+    __CFRunLoopUnlock(rl);
+}
+
+static const CFRuntimeClass __CFRunLoopModeClass = {
+    0,
+    "CFRunLoopMode",
+    NULL,      // init
+    NULL,      // copy
+    __CFRunLoopModeDeallocate,
+    __CFRunLoopModeEqual,
+    __CFRunLoopModeHash,
+    NULL,      // 
+    __CFRunLoopModeCopyDescription
+};
+
+static const CFRuntimeClass __CFRunLoopClass = {
+    0,
+    "CFRunLoop",
+    NULL,      // init
+    NULL,      // copy
+    __CFRunLoopDeallocate,
+    NULL,
+    NULL,
+    NULL,      // 
+    __CFRunLoopCopyDescription
+};
+
+CF_INLINE NativeThread _CFThreadSelf(void) {
+#if DEPLOYMENT_TARGET_MACOS || DEPLOYMENT_TARGET_FREEBSD || DEPLOYMENT_TARGET_LINUX
+	return pthread_self();
+#elif DEPLOYMENT_TARGET_WINDOWS
+	return GetCurrentThread();
+#else
+	HALT;
+	return kNilThreadT;
+#endif
+}
+
+CF_INLINE Boolean _CFThreadIsMain(void) {
+	Boolean result = false;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_FREEBSD
+	result = pthread_main_np();
+#elif DEPLOYMENT_TARGET_LINUX
+	result = (__kCFMainThread == _CFThreadSelf());
+#elif DEPLOYMENT_TARGET_WINDOWS
+	result = (__kCFMainThread == GetCurrentThreadId());
+#else
+	HALT;
+#endif
+	return result;
+}
+
+CF_INLINE Boolean _CFThreadsAreEqual(NativeThread a, NativeThread b) {
+	Boolean result = false;
+#if DEPLOYMENT_TARGET_MACOS || DEPLOYMENT_TARGET_FREEBSD || DEPLOYMENT_TARGET_LINUX
+	result = pthread_equal(a, b);
+#elif DEPLOYMENT_TARGET_WINDOWS
+	result = (pthreadPointer(a) == pthreadPointer(b));
+#else
+	HALT;
+#endif
+	return result;
+}
+
+__private_extern__ void __CFRunLoopInitialize(void) {
+    __kCFRunLoopTypeID = _CFRuntimeRegisterClass(&__CFRunLoopClass);
+    __kCFRunLoopModeTypeID = _CFRuntimeRegisterClass(&__CFRunLoopModeClass);
+#if DEPLOYMENT_TARGET_LINUX
+    __kCFMainThread = _CFThreadSelf();
+#elif DEPLOYMENT_TARGET_WINDOWS
+    __kCFMainThread = GetInternalThreadId (_CFThreadSelf());
+#endif
+}
+ 
+CFTypeID CFRunLoopGetTypeID(void) {
+    return __kCFRunLoopTypeID;
+}
+
+static CFRunLoopRef __CFRunLoopCreate(void) {
+    CFRunLoopRef loop = NULL;
+    CFRunLoopModeRef rlm;
+    uint32_t size = sizeof(struct __CFRunLoop) - sizeof(CFRuntimeBase);
+    loop = (CFRunLoopRef)_CFRuntimeCreateInstance(kCFAllocatorSystemDefault, __kCFRunLoopTypeID, size, NULL);
+    if (NULL == loop) {
+        return NULL;
+    }
+    loop->_stopped = NULL;
+    CF_SPINLOCK_INIT_FOR_STRUCTS(loop->_lock);
+    loop->_wakeUpPort = __CFPortAllocate();
+    if (CFPORT_NULL == loop->_wakeUpPort) HALT;
+    loop->_commonModes = CFSetCreateMutable(CFGetAllocator(loop), 0, &kCFTypeSetCallBacks);
+    CFSetAddValue(loop->_commonModes, kCFRunLoopDefaultMode);
+    loop->_commonModeItems = NULL;
+    loop->_currentMode = NULL;
+    loop->_modes = CFSetCreateMutable(CFGetAllocator(loop), 0, &kCFTypeSetCallBacks);
+    _CFSetSetCapacity(loop->_modes, 10);
+    loop->_counterpart = NULL;
+    rlm = __CFRunLoopFindMode(loop, kCFRunLoopDefaultMode, true);
+    if (NULL != rlm) __CFRunLoopModeUnlock(rlm);
+    return loop;
+}
+
+static CFMutableDictionaryRef runLoops = NULL;
+static char setMainLoop = 0;
+static CFSpinLock_t loopsLock = CFSpinLockInit;
+
+// If this is called on a non-main thread, and the main thread pthread_t is passed in,
+// and this has not yet beed called on the main thread (since the last fork(), this will
+// produce a different run loop that will probably be tossed away eventually, than the
+// main thread run loop. There's nothing much we can do about that, without a call to
+// fetch the main thread's pthread_t from the pthreads subsystem.
+
+// t==0 is a synonym for "main thread" that always works
+__private_extern__ CFRunLoopRef _CFRunLoop0(NativeThread t) {
+    CFRunLoopRef loop = NULL;
+    __CFSpinLock(&loopsLock);
+    if (!runLoops) {
+        __CFSpinUnlock(&loopsLock);
+        CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);
+        CFRunLoopRef mainLoop = __CFRunLoopCreate();
+        CFDictionarySetValue(dict, 0, mainLoop);
+    	 if (!_CFAtomicCompareAndSwapPtrBarrier(NULL, dict, (void * volatile *)&runLoops)) {
+	        CFRelease(dict);
+	        CFRelease(mainLoop);
+	    }
+       __CFSpinLock(&loopsLock);
+    }
+    if (_CFThreadIsMain() && _CFThreadsAreEqual(t, _CFThreadSelf())) {
+        t = kNilThreadT;
+    }
+    loop = (CFRunLoopRef)CFDictionaryGetValue(runLoops, pthreadPointer(t));
+    if (!loop) {
+        __CFSpinUnlock(&loopsLock);
+        CFRunLoopRef newLoop = __CFRunLoopCreate();
+        __CFGetThreadSpecificData();	// just cause the thread finalizer to be called as a side effect
+        __CFSpinLock(&loopsLock);
+       loop = (CFRunLoopRef)CFDictionaryGetValue(runLoops, pthreadPointer(t));
+	    if (loop) {
+	        CFRelease(newLoop);
+       } else {
+           CFDictionarySetValue(runLoops, pthreadPointer(t), newLoop);
+           loop = newLoop;
+        }
+    }
+    if (!setMainLoop && _CFThreadIsMain()) {
+		if (_CFThreadsAreEqual(t, kNilThreadT)) {
+			CFDictionarySetValue(runLoops, pthreadPointer(_CFThreadSelf()), loop);
+	     } else {
+            CFRunLoopRef mainLoop = (CFRunLoopRef)CFDictionaryGetValue(runLoops, pthreadPointer(kNilThreadT));
+            CFDictionarySetValue(runLoops, pthreadPointer(_CFThreadSelf()), mainLoop);
+        }
+        setMainLoop = 1;
+    }
+    __CFSpinUnlock(&loopsLock);
+    return loop;
+}
+
+__private_extern__ void _CFRunLoop1(void) {
+    __CFSpinLock(&loopsLock);
+    if (runLoops) {
+	NativeThread t = _CFThreadSelf();
+	CFRunLoopRef currentLoop = (CFRunLoopRef)CFDictionaryGetValue(runLoops, pthreadPointer(t));
+	CFRunLoopRef mainLoop = (CFRunLoopRef)CFDictionaryGetValue(runLoops, pthreadPointer(kNilThreadT));
+	if (currentLoop && mainLoop != currentLoop) {
+	    CFDictionaryRemoveValue(runLoops, pthreadPointer(t));
+	    CFRelease(currentLoop);
+	}
+    }
+    __CFSpinUnlock(&loopsLock);
+}
+
+CFRunLoopRef CFRunLoopGetMain(void) {
+    CHECK_FOR_FORK();
+    return _CFRunLoop0(kNilThreadT);
+}
+
+CFRunLoopRef CFRunLoopGetCurrent(void) {
+    CHECK_FOR_FORK();
+    return _CFRunLoop0(_CFThreadSelf());
+}
+
+void _CFRunLoopSetCurrent(CFRunLoopRef rl) {
+    __CFSpinLock(&loopsLock);
+    CFRunLoopRef currentLoop = runLoops ? (CFRunLoopRef)CFDictionaryGetValue(runLoops, pthreadPointer(_CFThreadSelf())) : NULL;
+    if (rl != currentLoop) {
+	// intentionally leak currentLoop so we don't kill any ports in the child
+	// if (currentLoop) CFRelease(currentLoop);
+	if (rl) {
+	    if (!runLoops) {
+		runLoops = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);
+		CFRunLoopRef mainLoop = __CFRunLoopCreate();
+		CFDictionarySetValue(runLoops, pthreadPointer(kNilThreadT), mainLoop);
+	    }
+	    CFRetain(rl);
+	    CFDictionarySetValue(runLoops, pthreadPointer(_CFThreadSelf()), rl);
+	} else {
+	    CFDictionaryRemoveValue(runLoops, pthreadPointer(_CFThreadSelf()));
+	}
+    }
+    __CFSpinUnlock(&loopsLock);
+}
+
+CFStringRef CFRunLoopCopyCurrentMode(CFRunLoopRef rl) {
+    CHECK_FOR_FORK();
+    CFStringRef result = NULL;
+    __CFRunLoopLock(rl);
+    if (NULL != rl->_currentMode) {
+        result = (CFStringRef)CFRetain(rl->_currentMode->_name);
+    }
+    __CFRunLoopUnlock(rl);
+    return result;
+}
+
+static void __CFRunLoopGetModeName(const void *value, void *context) {
+    CFRunLoopModeRef rlm = (CFRunLoopModeRef)value;
+    CFMutableArrayRef array = (CFMutableArrayRef)context;
+    CFArrayAppendValue(array, rlm->_name);
+}
+
+CFArrayRef CFRunLoopCopyAllModes(CFRunLoopRef rl) {
+    CHECK_FOR_FORK();
+    CFMutableArrayRef array;
+    __CFRunLoopLock(rl);
+    array = CFArrayCreateMutable(kCFAllocatorSystemDefault, CFSetGetCount(rl->_modes), &kCFTypeArrayCallBacks);
+    CFSetApplyFunction(rl->_modes, (__CFRunLoopGetModeName), array);
+    __CFRunLoopUnlock(rl);
+    return array;
+}
+
+static void __CFRunLoopAddItemsToCommonMode(const void *value, void *ctx) {
+    CFTypeRef item = (CFTypeRef)value;
+    CFRunLoopRef rl = (CFRunLoopRef)(((CFTypeRef *)ctx)[0]);
+    CFStringRef modeName = (CFStringRef)(((CFTypeRef *)ctx)[1]);
+    if (CFGetTypeID(item) == __kCFRunLoopSourceTypeID) {
+	CFRunLoopAddSource(rl, (CFRunLoopSourceRef)item, modeName);
+    } else if (CFGetTypeID(item) == __kCFRunLoopObserverTypeID) {
+	CFRunLoopAddObserver(rl, (CFRunLoopObserverRef)item, modeName);
+    } else if (CFGetTypeID(item) == __kCFRunLoopTimerTypeID) {
+	CFRunLoopAddTimer(rl, (CFRunLoopTimerRef)item, modeName);
+    }
+}
+
+static void __CFRunLoopAddItemToCommonModes(const void *value, void *ctx) {
+    CFStringRef modeName = (CFStringRef)value;
+    CFRunLoopRef rl = (CFRunLoopRef)(((CFTypeRef *)ctx)[0]);
+    CFTypeRef item = (CFTypeRef)(((CFTypeRef *)ctx)[1]);
+    if (CFGetTypeID(item) == __kCFRunLoopSourceTypeID) {
+	CFRunLoopAddSource(rl, (CFRunLoopSourceRef)item, modeName);
+    } else if (CFGetTypeID(item) == __kCFRunLoopObserverTypeID) {
+	CFRunLoopAddObserver(rl, (CFRunLoopObserverRef)item, modeName);
+    } else if (CFGetTypeID(item) == __kCFRunLoopTimerTypeID) {
+	CFRunLoopAddTimer(rl, (CFRunLoopTimerRef)item, modeName);
+    }
+}
+
+static void __CFRunLoopRemoveItemFromCommonModes(const void *value, void *ctx) {
+    CFStringRef modeName = (CFStringRef)value;
+    CFRunLoopRef rl = (CFRunLoopRef)(((CFTypeRef *)ctx)[0]);
+    CFTypeRef item = (CFTypeRef)(((CFTypeRef *)ctx)[1]);
+    if (CFGetTypeID(item) == __kCFRunLoopSourceTypeID) {
+	CFRunLoopRemoveSource(rl, (CFRunLoopSourceRef)item, modeName);
+    } else if (CFGetTypeID(item) == __kCFRunLoopObserverTypeID) {
+	CFRunLoopRemoveObserver(rl, (CFRunLoopObserverRef)item, modeName);
+    } else if (CFGetTypeID(item) == __kCFRunLoopTimerTypeID) {
+	CFRunLoopRemoveTimer(rl, (CFRunLoopTimerRef)item, modeName);
+    }
+}
+
+Boolean _CFRunLoop01(CFRunLoopRef rl, CFStringRef modeName) {
+    __CFRunLoopLock(rl);
+    Boolean present = CFSetContainsValue(rl->_commonModes, modeName);
+    __CFRunLoopUnlock(rl);
+    return present; 
+}
+
+void *_CFRunLoop02(CFRunLoopRef rl) {
+    return rl->_counterpart;
+}
+
+void _CFRunLoop03(CFRunLoopRef rl, void *ns) {
+    rl->_counterpart = ns;
+}
+
+void CFRunLoopAddCommonMode(CFRunLoopRef rl, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    if (__CFRunLoopIsDeallocating(rl)) return;
+    __CFRunLoopLock(rl);
+    if (!CFSetContainsValue(rl->_commonModes, modeName)) {
+	CFSetRef set = rl->_commonModeItems ? CFSetCreateCopy(kCFAllocatorSystemDefault, rl->_commonModeItems) : NULL;
+	CFSetAddValue(rl->_commonModes, modeName);
+	__CFRunLoopUnlock(rl);
+	if (NULL != set) {
+	    CFTypeRef context[2] = {rl, modeName};
+	    /* add all common-modes items to new mode */
+	    CFSetApplyFunction(set, (__CFRunLoopAddItemsToCommonMode), (void *)context);
+	    CFRelease(set);
+	}
+    } else {
+	__CFRunLoopUnlock(rl);
+    }
+}
+
+static CFComparisonResult __CFRunLoopObserverQSortComparator(const void *val1, const void *val2, void *context) {
+    CFRunLoopObserverRef o1 = *((CFRunLoopObserverRef *)val1);
+    CFRunLoopObserverRef o2 = *((CFRunLoopObserverRef *)val2);
+    if (!o1) {
+	return (!o2) ? kCFCompareEqualTo : kCFCompareLessThan;
+    }
+    if (!o2) {
+	return kCFCompareGreaterThan;
+    }
+    if (o1->_order < o2->_order) return kCFCompareLessThan;
+    if (o2->_order < o1->_order) return kCFCompareGreaterThan;
+    return kCFCompareEqualTo;
+}
+
+
+/* rl is unlocked, rlm is locked on entrance and exit */
+/* ALERT: this should collect all the candidate observers from the top level
+ * and all submodes, recursively, THEN start calling them, in order to obey
+ * the ordering parameter. */
+static void __CFRunLoopDoObservers(CFRunLoopRef rl, CFRunLoopModeRef rlm, CFRunLoopActivity activity) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    CFIndex idx, cnt;
+    CFArrayRef submodes;
+
+    /* Fire the observers */
+    submodes = (NULL != rlm->_submodes && 0 < CFArrayGetCount(rlm->_submodes)) ? CFArrayCreateCopy(kCFAllocatorSystemDefault, rlm->_submodes) : NULL;
+    if (NULL != rlm->_observers) {
+	cnt = CFSetGetCount(rlm->_observers);
+	if (0 < cnt) {
+#if __GNUC__
+	    CFRunLoopObserverRef buffer[(cnt <= 1024) ? cnt : 1];
+#else
+	    CFRunLoopObserverRef buffer[1024];
+#endif
+	    CFRunLoopObserverRef *collectedObservers = (cnt <= 1024) ? buffer : (CFRunLoopObserverRef*)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(CFRunLoopObserverRef), 0);
+	    CFSetGetValues(rlm->_observers, (const void **)collectedObservers);
+	    for (idx = 0; idx < cnt; idx++) {
+		CFRunLoopObserverRef rlo = collectedObservers[idx];
+		if (0 != (rlo->_activities & activity) && __CFIsValid(rlo) && !__CFRunLoopObserverIsFiring(rlo)) {
+		    CFRetain(rlo);
+		} else {
+		    /* We're not interested in this one - set it to NULL so we don't process it later */
+		    collectedObservers[idx] = NULL;
+		}
+	    }
+	    __CFRunLoopModeUnlock(rlm);
+	    CFQSortArray(collectedObservers, cnt, sizeof(CFRunLoopObserverRef), __CFRunLoopObserverQSortComparator, NULL);
+	    for (idx = 0; idx < cnt; idx++) {
+		CFRunLoopObserverRef rlo = collectedObservers[idx];
+		if (rlo) {
+		    __CFRunLoopObserverLock(rlo);
+		    if (__CFIsValid(rlo)) {
+			__CFRunLoopObserverUnlock(rlo);
+			__CFRunLoopObserverSetFiring(rlo);
+			rlo->_callout(rlo, activity, rlo->_context.info);	/* CALLOUT */
+			__CFRunLoopObserverUnsetFiring(rlo);
+			if (!__CFRunLoopObserverRepeats(rlo)) {
+			    CFRunLoopObserverInvalidate(rlo);
+			}
+		    } else {
+			__CFRunLoopObserverUnlock(rlo);
+ 		    }
+		    CFRelease(rlo);
+ 		}
+	    }
+	    __CFRunLoopModeLock(rlm);
+	    if (collectedObservers != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, collectedObservers);
+	}
+    }
+    if (NULL != submodes) {
+	__CFRunLoopModeUnlock(rlm);
+	for (idx = 0, cnt = CFArrayGetCount(submodes); idx < cnt; idx++) {
+	    CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(submodes, idx);
+	    CFRunLoopModeRef subrlm;
+            __CFRunLoopLock(rl);
+            subrlm = __CFRunLoopFindMode(rl, modeName, false);
+	    __CFRunLoopUnlock(rl);
+	    if (NULL != subrlm) {
+		__CFRunLoopDoObservers(rl, subrlm, activity);
+		__CFRunLoopModeUnlock(subrlm);
+	    }
+	}
+	CFRelease(submodes);
+        __CFRunLoopModeLock(rlm);
+    }
+}
+
+static CFComparisonResult __CFRunLoopSourceComparator(const void *val1, const void *val2, void *context) {
+    CFRunLoopSourceRef o1 = (CFRunLoopSourceRef)val1;
+    CFRunLoopSourceRef o2 = (CFRunLoopSourceRef)val2;
+    if (o1->_order < o2->_order) return kCFCompareLessThan;
+    if (o2->_order < o1->_order) return kCFCompareGreaterThan;
+    return kCFCompareEqualTo;
+}
+
+static void __CFRunLoopCollectSources0(const void *value, void *context) {
+    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)value;
+    CFTypeRef *sources = (CFTypeRef *)context;
+    if (0 == rls->_context.version0.version && __CFIsValid(rls) && __CFRunLoopSourceIsSignaled(rls)) {
+	if (NULL == *sources) {
+	    *sources = CFRetain(rls);
+	} else if (CFGetTypeID(*sources) == __kCFRunLoopSourceTypeID) {
+	    CFTypeRef oldrls = *sources;
+	    *sources = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+	    CFArrayAppendValue((CFMutableArrayRef)*sources, oldrls);
+	    CFArrayAppendValue((CFMutableArrayRef)*sources, rls);
+	    CFRelease(oldrls);
+	} else {
+	    CFArrayAppendValue((CFMutableArrayRef)*sources, rls);
+	}
+    }
+}
+
+/* rl is unlocked, rlm is locked on entrance and exit */
+static Boolean __CFRunLoopDoSources0(CFRunLoopRef rl, CFRunLoopModeRef rlm, Boolean stopAfterHandle) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    CFTypeRef sources = NULL;
+    Boolean sourceHandled = false;
+    CFIndex idx, cnt;
+
+    __CFRunLoopModeUnlock(rlm); // locks have to be taken in order
+    __CFRunLoopLock(rl);
+    __CFRunLoopModeLock(rlm);
+    /* Fire the version 0 sources */
+    if (NULL != rlm->_sources && 0 < CFSetGetCount(rlm->_sources)) {
+	CFSetApplyFunction(rlm->_sources, (__CFRunLoopCollectSources0), &sources);
+    }
+    for (idx = 0, cnt = (NULL != rlm->_submodes) ? CFArrayGetCount(rlm->_submodes) : 0; idx < cnt; idx++) {
+	CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(rlm->_submodes, idx);
+	CFRunLoopModeRef subrlm;
+	subrlm = __CFRunLoopFindMode(rl, modeName, false);
+	if (NULL != subrlm) {
+	    if (NULL != subrlm->_sources && 0 < CFSetGetCount(subrlm->_sources)) {
+		CFSetApplyFunction(subrlm->_sources, (__CFRunLoopCollectSources0), &sources);
+	    }
+	    __CFRunLoopModeUnlock(subrlm);
+	}
+    }
+    __CFRunLoopUnlock(rl);
+    if (NULL != sources) {
+	// sources is either a single (retained) CFRunLoopSourceRef or an array of (retained) CFRunLoopSourceRef
+	__CFRunLoopModeUnlock(rlm);
+	if (CFGetTypeID(sources) == __kCFRunLoopSourceTypeID) {
+	    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)sources;
+	    __CFRunLoopSourceLock(rls);
+	    __CFRunLoopSourceUnsetSignaled(rls);
+	    if (__CFIsValid(rls)) {
+		__CFRunLoopSourceUnlock(rls);
+		if (NULL != rls->_context.version0.perform) {
+		    rls->_context.version0.perform(rls->_context.version0.info); /* CALLOUT */
+		    CHECK_FOR_FORK();
+		}
+		sourceHandled = true;
+	    } else {
+		__CFRunLoopSourceUnlock(rls);
+	    }
+	} else {
+	    cnt = CFArrayGetCount((CFArrayRef)sources);
+	    CFArraySortValues((CFMutableArrayRef)sources, CFRangeMake(0, cnt), (__CFRunLoopSourceComparator), NULL);
+	    for (idx = 0; idx < cnt; idx++) {
+		CFRunLoopSourceRef rls = (CFRunLoopSourceRef)CFArrayGetValueAtIndex((CFArrayRef)sources, idx);
+		__CFRunLoopSourceLock(rls);
+		__CFRunLoopSourceUnsetSignaled(rls);
+		if (__CFIsValid(rls)) {
+		    __CFRunLoopSourceUnlock(rls);
+		    if (NULL != rls->_context.version0.perform) {
+			rls->_context.version0.perform(rls->_context.version0.info); /* CALLOUT */
+		        CHECK_FOR_FORK();
+		    }
+		    sourceHandled = true;
+		} else {
+		    __CFRunLoopSourceUnlock(rls);
+		}
+		if (stopAfterHandle && sourceHandled) {
+		    break;
+		}
+	    }
+	}
+	CFRelease(sources);
+	__CFRunLoopModeLock(rlm);
+    }
+    return sourceHandled;
+}
+
+// msg, size and reply are unused on Windows
+static Boolean __CFRunLoopDoSource1(CFRunLoopRef rl, CFRunLoopModeRef rlm, CFRunLoopSourceRef rls
+#if DEPLOYMENT_TARGET_MACOSX
+                                    , mach_msg_header_t *msg, CFIndex size, mach_msg_header_t **reply
+#endif
+                                    ) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    Boolean sourceHandled = false;
+
+    /* Fire a version 1 source */
+    CFRetain(rls);
+    __CFRunLoopModeUnlock(rlm);
+    __CFRunLoopSourceLock(rls);
+    if (__CFIsValid(rls)) {
+	__CFRunLoopSourceUnsetSignaled(rls);
+	__CFRunLoopSourceUnlock(rls);
+	if (NULL != rls->_context.version1.perform) {
+#if DEPLOYMENT_TARGET_MACOSX
+	    *reply = (mach_msg_header_t*)rls->_context.version1.perform(msg, size, kCFAllocatorSystemDefault, rls->_context.version1.info); /* CALLOUT */
+	    CHECK_FOR_FORK();
+#else
+            if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("%p (%s) __CFRunLoopDoSource1 performing rls %p"), CFRunLoopGetCurrent(), *_CFGetProgname(), rls); }
+            rls->_context.version1.perform(rls->_context.version1.info); /* CALLOUT */
+	    CHECK_FOR_FORK();
+#endif
+	} else {
+        if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("%p (%s) __CFRunLoopDoSource1 perform is NULL"), CFRunLoopGetCurrent(), *_CFGetProgname()); }
+    }
+	sourceHandled = true;
+    } else {
+        if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("%p (%s) __CFRunLoopDoSource1 rls %p is invalid"), CFRunLoopGetCurrent(), *_CFGetProgname(), rls); }
+	__CFRunLoopSourceUnlock(rls);
+    }
+    CFRelease(rls);
+    __CFRunLoopModeLock(rlm);
+    return sourceHandled;
+}
+
+static Boolean __CFRunLoopDoTimer(CFRunLoopRef rl, CFRunLoopModeRef rlm, CFRunLoopTimerRef rlt) {	/* DOES CALLOUT */
+    Boolean timerHandled = false;
+    int64_t oldFireTSR = 0;
+
+    /* Fire a timer */
+    CFRetain(rlt);
+    __CFRunLoopModeUnlock(rlm);
+    __CFRunLoopTimerLock(rlt);
+    if (__CFIsValid(rlt) && !__CFRunLoopTimerIsFiring(rlt)) {
+	__CFRunLoopTimerUnsetDidFire(rlt);
+	__CFRunLoopTimerSetFiring(rlt);
+	__CFRunLoopTimerUnlock(rlt);
+	__CFRunLoopTimerFireTSRLock();
+	oldFireTSR = rlt->_fireTSR;
+	__CFRunLoopTimerFireTSRUnlock();
+	rlt->_callout(rlt, rlt->_context.info);	/* CALLOUT */
+	CHECK_FOR_FORK();
+	__CFRunLoopTimerUnsetFiring(rlt);
+	timerHandled = true;
+    } else {
+	// If the timer fires while it is firing in a higher activiation,
+	// it is not allowed to fire, but we have to remember that fact.
+	// Later, if the timer's fire date is being handled manually, we
+	// need to re-arm the kernel timer, since it has possibly already
+	// fired (this firing which is being skipped, say) and the timer
+	// will permanently stop if we completely drop this firing.
+	if (__CFRunLoopTimerIsFiring(rlt)) __CFRunLoopTimerSetDidFire(rlt);
+	__CFRunLoopTimerUnlock(rlt);
+    }
+    if (__CFIsValid(rlt) && timerHandled) {
+	if (0 == rlt->_intervalTSR) {
+	    CFRunLoopTimerInvalidate(rlt);      /* DOES CALLOUT */
+	} else {
+	    /* This is just a little bit tricky: we want to support calling
+	     * CFRunLoopTimerSetNextFireDate() from within the callout and
+	     * honor that new time here if it is a later date, otherwise
+	     * it is completely ignored. */
+	    int64_t currentFireTSR;
+	    __CFRunLoopTimerFireTSRLock();
+	    currentFireTSR = rlt->_fireTSR;
+	    if (oldFireTSR < currentFireTSR) {
+		/* Next fire TSR was set, and set to a date after the previous
+		 * fire date, so we honor it. */
+		if (__CFRunLoopTimerDidFire(rlt)) {
+		    __CFRunLoopTimerRescheduleWithAllModes(rlt, rl);
+		    __CFRunLoopTimerUnsetDidFire(rlt);
+		}
+	    } else {
+		if ((uint64_t)LLONG_MAX <= (uint64_t)oldFireTSR + (uint64_t)rlt->_intervalTSR) {
+		    currentFireTSR = LLONG_MAX;
+		} else {
+		    int64_t currentTSR = (int64_t)__CFReadTSR();
+		    currentFireTSR = oldFireTSR;
+		    while (currentFireTSR <= currentTSR) {
+			currentFireTSR += rlt->_intervalTSR;
+		    }
+		}
+	        rlt->_fireTSR = currentFireTSR;
+	        __CFRunLoopTimerRescheduleWithAllModes(rlt, rl);
+	    }
+	    __CFRunLoopTimerFireTSRUnlock();
+	}
+    }
+    CFRelease(rlt);
+    __CFRunLoopModeLock(rlm);
+    return timerHandled;
+}
+
+CF_EXPORT Boolean _CFRunLoopFinished(CFRunLoopRef rl, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    Boolean result = false;
+    __CFRunLoopLock(rl);
+    rlm = __CFRunLoopFindMode(rl, modeName, false);
+    if (NULL == rlm || __CFRunLoopModeIsEmpty(rl, rlm)) {
+	result = true;
+    }
+    __CFRunLoopUnlock(rl);
+    if (rlm) __CFRunLoopModeUnlock(rlm);
+    return result;
+}
+
+// rl is locked, rlm is locked on entry and exit
+static void __CFRunLoopModeAddPortsToPortSet(CFRunLoopRef rl, CFRunLoopModeRef rlm, __CFPortSet portSet) {
+    CFIndex idx, cnt;
+    const void **list, *buffer[256];
+
+    // Timers and version 1 sources go into the portSet currently
+    if (NULL != rlm->_sources) {
+	cnt = CFSetGetCount(rlm->_sources);
+	list = (cnt <= 256) ? buffer : (const void**)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(void *), 0);
+	CFSetGetValues(rlm->_sources, list);
+	for (idx = 0; idx < cnt; idx++) {
+	    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)list[idx];
+	    if (1 == rls->_context.version0.version) {
+		__CFPort port = rls->_context.version1.getPort(rls->_context.version1.info);	/* CALLOUT */
+		if (CFPORT_NULL != port) {
+		    __CFPortSetInsert(port, portSet);
+		}
+	    }
+	}
+	if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+    }
+#if DEPLOYMENT_TARGET_MACOSX
+    if (NULL != rlm->_timers) {
+	cnt = CFSetGetCount(rlm->_timers);
+	list = (cnt <= 256) ? buffer : (const void**)CFAllocatorAllocate(kCFAllocatorSystemDefault, cnt * sizeof(void *), 0);
+	CFSetGetValues(rlm->_timers, list);
+	for (idx = 0; idx < cnt; idx++) {
+	    CFRunLoopTimerRef rlt = (CFRunLoopTimerRef)list[idx];
+	    if (MACH_PORT_NULL != rlt->_port) {
+		mach_port_insert_member(mach_task_self(), rlt->_port, portSet);
+	    }
+	}
+	if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list);
+    }
+#endif
+    // iterate over submodes
+    for (idx = 0, cnt = NULL != rlm->_submodes ? CFArrayGetCount(rlm->_submodes) : 0; idx < cnt; idx++) {
+	CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(rlm->_submodes, idx);
+	CFRunLoopModeRef subrlm;
+	subrlm = __CFRunLoopFindMode(rl, modeName, false);
+	if (NULL != subrlm) {
+	    __CFRunLoopModeAddPortsToPortSet(rl, subrlm, portSet);
+	    __CFRunLoopModeUnlock(subrlm);
+	}
+    }
+}
+
+static __CFPortSet _LastMainWaitSet = CFPORTSET_NULL;
+
+// return NO if we're the main runloop and there are no messages waiting on the port set
+int _CFRunLoopInputsReady(void) {
+    CHECK_FOR_FORK();
+    // XXX_PCB:  the following 2 lines aren't safe to call during GC, because another
+    // thread may have entered CFRunLoopGetMain(), which grabs a spink lock, and then
+    // is suspended by the GC. We can check for the main thread more directly
+    // by calling pthread_main_np().
+    // CFRunLoopRef current = CFRunLoopGetMain()
+    // if (current != CFRunLoopGetMain()) return true;
+    if (!_CFThreadIsMain()) return true;
+
+    // XXX_PCB:  can't be any messages waiting if the wait set is NULL.
+    if (_LastMainWaitSet == CFPORTSET_NULL) return false;
+
+#if DEPLOYMENT_TARGET_MACOSX 
+    // prepare a message header with no space for any data, nor a trailer
+    mach_msg_header_t msg;
+    msg.msgh_size = sizeof(msg);    // just the header, ma'am
+    // need the waitset, actually XXX
+    msg.msgh_local_port = _LastMainWaitSet;
+    msg.msgh_remote_port = MACH_PORT_NULL;
+    msg.msgh_id = 0;
+    
+    kern_return_t ret = mach_msg(&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT | MACH_RCV_LARGE, 0, msg.msgh_size, _LastMainWaitSet, 0, MACH_PORT_NULL);
+    
+    return (MACH_RCV_TOO_LARGE == ret);
+#endif
+    return true;
+}
+
+#if 0
+static void print_msg_scan_header(void) {
+    printf("======== ======== ======== ========\n");
+    printf("description\tport\tport type\t\treferences\n");
+}
+
+static void print_one_port_info(const char *desc, mach_port_t port, mach_msg_type_name_t type) {
+    mach_port_urefs_t refs;
+    kern_return_t ret = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, &refs);
+    if (ret != KERN_SUCCESS) refs = 0;
+    const char *type_name = "???";
+    switch (type) {
+    case MACH_MSG_TYPE_MOVE_SEND: type_name = "MACH_MSG_TYPE_MOVE_SEND"; break;
+    case MACH_MSG_TYPE_MOVE_SEND_ONCE: type_name = "MACH_MSG_TYPE_MOVE_SEND_ONCE"; break;
+    case MACH_MSG_TYPE_MOVE_RECEIVE: type_name = "MACH_MSG_TYPE_MOVE_RECEIVE"; break;
+    case MACH_MSG_TYPE_MAKE_SEND: type_name = "MACH_MSG_TYPE_MAKE_SEND"; break;
+    case MACH_MSG_TYPE_MAKE_SEND_ONCE: type_name = "MACH_MSG_TYPE_MAKE_SEND_ONCE"; break;
+    }
+    printf("%s\t%p\t%-20s\t%u\n", desc, port, type_name, refs);
+}
+
+static void mach_msg_scan(mach_msg_header_t *msg, int clean) {
+    Boolean printed_header = false;
+    /*
+     *	The msgh_local_port field doesn't hold a port right.
+     *	The receive operation consumes the destination port right.
+     */
+    if (MACH_PORT_NULL != msg->msgh_remote_port) {
+	if (! printed_header) print_msg_scan_header();
+	printed_header = true;
+	print_one_port_info("msg->msgh_remote_port", msg->msgh_remote_port, MACH_MSGH_BITS_REMOTE(msg->msgh_bits));
+    }
+    if (msg->msgh_bits & MACH_MSGH_BITS_COMPLEX) {
+    	mach_msg_body_t *body = (mach_msg_body_t *) (msg + 1);
+    	mach_msg_descriptor_t *saddr = (mach_msg_descriptor_t *) ((mach_msg_base_t *) msg + 1);
+    	mach_msg_descriptor_t *eaddr =  saddr + body->msgh_descriptor_count;
+	for  ( ; saddr < eaddr; saddr++) {
+	    switch (saddr->type.type) {
+	    case MACH_MSG_PORT_DESCRIPTOR:;
+		mach_msg_port_descriptor_t *dsc = &saddr->port;
+		if (! printed_header) print_msg_scan_header();
+		printed_header = true;
+		print_one_port_info("port in body", dsc->name, dsc->disposition);
+//		if (clean) mach_port_deallocate(mach_task_self(), dsc->name);
+		break;
+	    case MACH_MSG_OOL_PORTS_DESCRIPTOR:;
+		    mach_msg_ool_ports_descriptor_t *dsc2 = &saddr->ool_ports;
+		    mach_port_t *ports = (mach_port_t *) dsc2->address;
+		    for (mach_msg_type_number_t j = 0; j < dsc2->count; j++, ports++)  {
+			if (! printed_header) print_msg_scan_header();
+			printed_header = true;
+			print_one_port_info("port in OOL ports", *ports, dsc2->disposition);
+		    }
+		    break;
+	    }
+	}
+    }
+}
+#endif
+
+/* rl is unlocked, rlm locked on entrance and exit */
+static int32_t __CFRunLoopRun(CFRunLoopRef rl, CFRunLoopModeRef rlm, CFTimeInterval seconds, Boolean stopAfterHandle, Boolean waitIfEmpty) {  /* DOES CALLOUT */
+    int64_t termTSR;
+#if DEPLOYMENT_TARGET_MACOSX
+    mach_port_name_t timeoutPort = MACH_PORT_NULL;
+    Boolean timeoutPortAdded = false;
+#endif
+    Boolean poll = false;
+    Boolean firstPass = true;
+
+    if (__CFRunLoopIsStopped(rl)) {
+        return kCFRunLoopRunStopped;
+    } else if (rlm->_stopped) {
+        rlm->_stopped = false;
+        return kCFRunLoopRunStopped;
+    }
+    if (seconds <= 0.0) {
+        termTSR = 0;
+    } else if (3.1556952e+9 < seconds) {
+        termTSR = LLONG_MAX;
+    } else {
+        termTSR = (int64_t)__CFReadTSR() + __CFTimeIntervalToTSR(seconds);
+#if DEPLOYMENT_TARGET_MACOSX
+        timeoutPort = mk_timer_create();
+        mk_timer_arm(timeoutPort, __CFUInt64ToAbsoluteTime(termTSR));
+#endif
+    }
+    if (seconds <= 0.0) {
+        poll = true;
+    }
+    if (rl == _CFRunLoop0(kNilThreadT)) _LastMainWaitSet = CFPORTSET_NULL;
+    for (;;) {
+        __CFPortSet waitSet = CFPORTSET_NULL;
+        waitSet = CFPORTSET_NULL;
+        Boolean destroyWaitSet = false;
+        CFRunLoopSourceRef rls;
+#if DEPLOYMENT_TARGET_MACOSX
+        mach_msg_header_t *msg;
+        kern_return_t ret;
+        uint8_t buffer[1024 + 80] = {0};	// large enough for 1k of inline payload; must be zeroed for GC
+#elif DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+        CFArrayRef timersToCall = NULL;
+#endif
+        int32_t returnValue = 0;
+        Boolean sourceHandledThisLoop = false;
+
+        __CFRunLoopDoObservers(rl, rlm, kCFRunLoopBeforeTimers);
+        __CFRunLoopDoObservers(rl, rlm, kCFRunLoopBeforeSources);
+
+        sourceHandledThisLoop = __CFRunLoopDoSources0(rl, rlm, stopAfterHandle);
+
+        if (sourceHandledThisLoop) {
+            poll = true;
+        }
+
+        if (!poll) {
+            __CFRunLoopDoObservers(rl, rlm, kCFRunLoopBeforeWaiting);
+            __CFRunLoopSetSleeping(rl);
+        }
+        if (NULL != rlm->_submodes) {
+            // !!! what do we do if this doesn't succeed?
+            waitSet = __CFPortSetAllocate();
+            if (CFPORTSET_NULL == waitSet) HALT;
+            __CFRunLoopModeUnlock(rlm);
+            __CFRunLoopLock(rl);
+            __CFRunLoopModeLock(rlm);
+            __CFRunLoopModeAddPortsToPortSet(rl, rlm, waitSet);
+            __CFRunLoopUnlock(rl);
+#if DEPLOYMENT_TARGET_MACOSX
+            if (CFPORT_NULL != timeoutPort) {
+                __CFPortSetInsert(timeoutPort, waitSet);
+            }
+#endif
+            destroyWaitSet = true;
+        } else {
+            waitSet = rlm->_portSet;
+#if DEPLOYMENT_TARGET_MACOSX
+            if (!timeoutPortAdded && CFPORT_NULL != timeoutPort) {
+                __CFPortSetInsert(timeoutPort, waitSet);
+                timeoutPortAdded = true;
+            }
+#endif
+        }
+        if (rl == _CFRunLoop0(kNilThreadT)) _LastMainWaitSet = waitSet;
+        __CFRunLoopModeUnlock(rlm);
+
+#if DEPLOYMENT_TARGET_MACOSX
+        msg = (mach_msg_header_t *)buffer;
+        msg->msgh_size = sizeof(buffer);
+
+        /* In that sleep of death what nightmares may come ... */
+try_receive:
+        msg->msgh_bits = 0;
+        msg->msgh_local_port = waitSet;
+        msg->msgh_remote_port = MACH_PORT_NULL;
+        msg->msgh_id = 0;
+        ret = mach_msg(msg, MACH_RCV_MSG|MACH_RCV_LARGE|(poll ? MACH_RCV_TIMEOUT : 0)|MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)|MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT), 0, msg->msgh_size, waitSet, 0, MACH_PORT_NULL);
+        if (MACH_RCV_TOO_LARGE == ret) {
+            uint32_t newSize = round_msg(msg->msgh_size) + sizeof(mach_msg_audit_trailer_t);
+            if (msg == (mach_msg_header_t *)buffer) msg = NULL;
+            msg = (mach_msg_header_t*)CFAllocatorReallocate(kCFAllocatorSystemDefault, msg, newSize, 0);
+            msg->msgh_size = newSize;
+            goto try_receive;
+        } else if (MACH_RCV_TIMED_OUT == ret) {
+            // timeout, for poll
+            if (msg != (mach_msg_header_t *)buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, msg);
+            msg = NULL;
+        } else if (MACH_MSG_SUCCESS != ret) {
+            HALT;
+        }
+#elif DEPLOYMENT_TARGET_WINDOWS
+        DWORD waitResult = WAIT_TIMEOUT;
+        __CFPort portBuf[MAX_PORTS];
+        __CFPort *ports;
+        CFIndex portCount;
+        Boolean freePorts;
+        if (destroyWaitSet) {
+            // wait set is a local, no one else could modify it, no need to copy handles
+            ports = waitSet->ports;
+            portCount = waitSet->used;
+            freePorts = false;
+        } else {
+            // copy out the ports to be safe from other threads at work
+            ports = __CFPortSetGetPorts(waitSet, portBuf, MAX_PORTS, (uint32_t*)&portCount);
+            freePorts = (ports != portBuf);
+        }
+        // should msgQMask be an OR'ing of this and all submodes' masks?
+        if (0 == GetQueueStatus(rlm->_msgQMask)) {
+            DWORD timeout;
+            if (poll)
+                timeout = 0;
+            else {
+                __CFRunLoopModeLock(rlm);
+                int64_t nextStop = __CFRunLoopGetNextTimerFireTSR(rl, rlm);
+                if (nextStop <= 0)
+                    nextStop = termTSR;
+                else if (nextStop > termTSR)
+                    nextStop = termTSR;
+                // else the next stop is dictated by the next timer
+                int64_t timeoutTSR = nextStop - __CFReadTSR();
+                if (timeoutTSR < 0)
+                    timeout = 0;
+                else {
+                    CFTimeInterval timeoutCF = __CFTSRToTimeInterval(timeoutTSR) * 1000;
+                    if (timeoutCF > MAXDWORD)
+                        timeout = INFINITE;
+                    else
+                        timeout = (DWORD)timeoutCF;
+                }
+            }
+            if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("%p (%s)- about to wait for %d objects, wakeupport is %p"), CFRunLoopGetCurrent(), *_CFGetProgname(), portCount, rl->_wakeUpPort); }
+            if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("All RLM sources = %@"), rlm->_sources); }
+            waitResult = MsgWaitForMultipleObjects(__CFMin(portCount, MAX_PORTS), ports, false, timeout, rlm->_msgQMask);
+            if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("%p (%s)- waitResult was %d"), CFRunLoopGetCurrent(), *_CFGetProgname(), waitResult); }
+        }
+        ResetEvent(rl->_wakeUpPort);
+#elif DEPLOYMENT_TARGET_LINUX
+		// XXX - More to fill in here.
+#endif
+        if (destroyWaitSet) {
+            __CFPortSetFree(waitSet);
+            if (rl == _CFRunLoop0(kNilThreadT)) _LastMainWaitSet = CFPORTSET_NULL;
+        }
+        __CFRunLoopLock(rl);
+        __CFRunLoopModeLock(rlm);
+        __CFRunLoopUnlock(rl);
+        if (!poll) {
+            __CFRunLoopUnsetSleeping(rl);
+            __CFRunLoopDoObservers(rl, rlm, kCFRunLoopAfterWaiting);
+        }
+        poll = false;
+        __CFRunLoopModeUnlock(rlm);
+        __CFRunLoopLock(rl);
+        __CFRunLoopModeLock(rlm);
+
+        __CFPort livePort = CFPORT_NULL;
+#if DEPLOYMENT_TARGET_MACOSX
+        if (NULL != msg) {
+            livePort = msg->msgh_local_port;
+        }
+#elif DEPLOYMENT_TARGET_WINDOWS
+        CFAssert2(waitResult != WAIT_FAILED, __kCFLogAssertion, "%s(): error %d from MsgWaitForMultipleObjects", __PRETTY_FUNCTION__, GetLastError());
+        if (waitResult == WAIT_TIMEOUT) {
+            // do nothing, just return to caller
+        } else if (waitResult >= WAIT_OBJECT_0 && waitResult < WAIT_OBJECT_0+portCount) {
+            // a port was signalled
+            livePort = ports[waitResult-WAIT_OBJECT_0];
+            if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("%p (%s)- Resetting event %p"), CFRunLoopGetCurrent(), *_CFGetProgname(), livePort); }
+        } else if (waitResult == WAIT_OBJECT_0+portCount) {
+            // windows message received - the CFWindowsMessageQueue will pick this up when
+            // the v0 RunLoopSources get their chance
+        } else if (waitResult >= WAIT_ABANDONED_0 && waitResult < WAIT_ABANDONED_0+portCount) {
+            // an "abandoned mutex object"
+            livePort = ports[waitResult-WAIT_ABANDONED_0];
+        } else {
+            CFAssert2(waitResult == WAIT_FAILED, __kCFLogAssertion, "%s(): unexpected result from MsgWaitForMultipleObjects: %d", __PRETTY_FUNCTION__, waitResult);
+        }
+        if (freePorts)
+            CFAllocatorDeallocate(kCFAllocatorSystemDefault, ports);
+        timersToCall = __CFRunLoopTimersToFire(rl, rlm);
+#elif DEPLOYMENT_TARGET_LINUX
+		// XXX - More to fill in here.
+        timersToCall = __CFRunLoopTimersToFire(rl, rlm);
+#endif
+
+        if (CFPORT_NULL == livePort) {
+            __CFRunLoopUnlock(rl);
+        } else if (livePort == rl->_wakeUpPort) {
+            // wakeup
+            if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("wakeupPort was signalled")); }        
+            __CFRunLoopUnlock(rl);
+        }
+#if DEPLOYMENT_TARGET_MACOSX
+        else if (livePort == timeoutPort) {
+            returnValue = kCFRunLoopRunTimedOut;
+            __CFRunLoopUnlock(rl);
+        } else if (NULL != (rls = __CFRunLoopModeFindSourceForMachPort(rl, rlm, livePort))) {
+            mach_msg_header_t *reply = NULL;
+            __CFRunLoopUnlock(rl);
+//		mach_msg_scan(msg, 0);
+            if (__CFRunLoopDoSource1(rl, rlm, rls, msg, msg->msgh_size, &reply)) {
+                sourceHandledThisLoop = true;
+            }
+//		mach_msg_scan(msg, 1);
+            if (NULL != reply) {
+                ret = mach_msg(reply, MACH_SEND_MSG, reply->msgh_size, 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+//#warning CF: what should be done with the return value?
+                CFAllocatorDeallocate(kCFAllocatorSystemDefault, reply);
+            }
+        } else {
+            CFRunLoopTimerRef rlt;
+            rlt = __CFRunLoopModeFindTimerForMachPort(rlm, livePort);
+            __CFRunLoopUnlock(rl);
+            if (NULL != rlt) {
+                __CFRunLoopDoTimer(rl, rlm, rlt);
+            }
+        }
+        if (msg != (mach_msg_header_t *)buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, msg);
+#else
+        else if (NULL != (rls = __CFRunLoopModeFindSourceForMachPort(rl, rlm, livePort))) {
+            __CFRunLoopUnlock(rl);
+            if (_LogCFRunLoop) { CFLog(kCFLogLevelDebug, CFSTR("Source %@ was signalled"), rls); }
+            if (__CFRunLoopDoSource1(rl, rlm, rls)) {
+                sourceHandledThisLoop = true;
+            }
+        }
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+	if (NULL != timersToCall) {
+		CFIndex i;
+		for (i = CFArrayGetCount(timersToCall) - 1; i >= 0; i--) {
+			CFRunLoopTimerRef rlt = (CFRunLoopTimerRef)CFArrayGetValueAtIndex(timersToCall, i);			
+			if (NULL != rlt) {
+				__CFRunLoopDoTimer(rl, rlm, rlt);
+			}
+		}
+            CFRelease(timersToCall);
+        }
+#endif // DEPLOYMENT_TARGER_WINDOWS || DEPLOYMENT_TARGET_LINUX
+
+        __CFRunLoopModeUnlock(rlm);	// locks must be taken in order
+        __CFRunLoopLock(rl);
+        __CFRunLoopModeLock(rlm);
+        if (sourceHandledThisLoop && stopAfterHandle) {
+             returnValue = kCFRunLoopRunHandledSource;
+             // If we're about to timeout, but we just did a zero-timeout poll that only found our own
+             // internal wakeup signal on the first look at the portset, we'll go around the loop one
+             // more time, so as not to starve a v1 source that was just added along with a runloop wakeup.
+        } else if (0 != returnValue || (uint64_t)termTSR <= __CFReadTSR()) {
+            returnValue = kCFRunLoopRunTimedOut;
+        } else if (__CFRunLoopIsStopped(rl)) {
+            returnValue = kCFRunLoopRunStopped;
+        } else if (rlm->_stopped) {
+            rlm->_stopped = false;
+            returnValue = kCFRunLoopRunStopped;
+        } else if (!waitIfEmpty && __CFRunLoopModeIsEmpty(rl, rlm)) {
+            returnValue = kCFRunLoopRunFinished;
+        }
+        __CFRunLoopUnlock(rl);
+        if (0 != returnValue) {
+#if DEPLOYMENT_TARGET_MACOSX
+            if (MACH_PORT_NULL != timeoutPort) {
+                if (!destroyWaitSet) __CFPortSetRemove(timeoutPort, waitSet);
+                mk_timer_destroy(timeoutPort);
+            }
+#endif
+            return returnValue;
+        }
+        firstPass = false;
+    }
+}
+
+SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled) {     /* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    if (__CFRunLoopIsDeallocating(rl)) return kCFRunLoopRunFinished;
+    __CFRunLoopLock(rl);
+    CFRunLoopModeRef currentMode = __CFRunLoopFindMode(rl, modeName, false);
+    if (NULL == currentMode || __CFRunLoopModeIsEmpty(rl, currentMode)) {
+	if (currentMode) __CFRunLoopModeUnlock(currentMode);
+	__CFRunLoopUnlock(rl);
+	return kCFRunLoopRunFinished;
+    }
+    uint32_t *previousStopped = (uint32_t *)rl->_stopped;
+    rl->_stopped = (volatile uint32_t*)CFAllocatorAllocate(kCFAllocatorSystemDefault, 4 * sizeof(uint32_t), 0);
+    rl->_stopped[0] = 0x4346524C;
+    rl->_stopped[1] = 0x4346524C; // 'CFRL'
+    rl->_stopped[2] = 0x00000000; // here the value is stored
+    rl->_stopped[3] = 0x4346524C;
+    CFRunLoopModeRef previousMode = rl->_currentMode;
+    rl->_currentMode = currentMode;
+    __CFRunLoopUnlock(rl);
+    int32_t result;
+    __CFRunLoopDoObservers(rl, currentMode, kCFRunLoopEntry);
+    result = __CFRunLoopRun(rl, currentMode, seconds, returnAfterSourceHandled, false);
+    __CFRunLoopDoObservers(rl, currentMode, kCFRunLoopExit);
+    __CFRunLoopModeUnlock(currentMode);
+    __CFRunLoopLock(rl);
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, (uint32_t *)rl->_stopped);
+    rl->_stopped = previousStopped;
+    rl->_currentMode = previousMode;
+    __CFRunLoopUnlock(rl);
+    return result;
+}
+
+void CFRunLoopRun(void) {	/* DOES CALLOUT */
+    int32_t result;
+    do {
+        result = CFRunLoopRunSpecific(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode, 1.0e10, false);
+        CHECK_FOR_FORK();
+    } while (kCFRunLoopRunStopped != result && kCFRunLoopRunFinished != result);
+}
+
+SInt32 CFRunLoopRunInMode(CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled) {     /* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    return CFRunLoopRunSpecific(CFRunLoopGetCurrent(), modeName, seconds, returnAfterSourceHandled);
+}
+
+static void __CFRunLoopFindMinTimer(const void *value, void *ctx) {
+    CFRunLoopTimerRef rlt = (CFRunLoopTimerRef)value;
+    if (__CFIsValid(rlt)) {
+        CFRunLoopTimerRef *result = (CFRunLoopTimerRef*)ctx;
+        if (NULL == *result || rlt->_fireTSR < (*result)->_fireTSR) {
+            *result = rlt;
+        }
+    }
+}
+
+static int64_t __CFRunLoopGetNextTimerFireTSR(CFRunLoopRef rl, CFRunLoopModeRef rlm) {
+    CFRunLoopTimerRef result = NULL;
+    int64_t fireTime = 0;
+    if (rlm) {
+	if (NULL != rlm->_timers && 0 < CFSetGetCount(rlm->_timers)) {
+	    __CFRunLoopTimerFireTSRLock();
+	    CFSetApplyFunction(rlm->_timers, (__CFRunLoopFindMinTimer), &result);
+            if (result)
+                fireTime = result->_fireTSR;
+	    __CFRunLoopTimerFireTSRUnlock();
+	}
+        if (NULL != rlm->_submodes) {
+            CFIndex idx, cnt;
+            for (idx = 0, cnt = CFArrayGetCount(rlm->_submodes); idx < cnt; idx++) {
+                CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(rlm->_submodes, idx);
+                CFRunLoopModeRef subrlm;
+                subrlm = __CFRunLoopFindMode(rl, modeName, false);
+                if (NULL != subrlm) {
+                    int64_t newFireTime = __CFRunLoopGetNextTimerFireTSR(rl, subrlm);
+                    __CFRunLoopModeUnlock(subrlm);
+                    if (fireTime == 0 || (newFireTime != 0 && newFireTime < fireTime))
+                        fireTime = newFireTime;
+                }
+            }
+        }
+        __CFRunLoopModeUnlock(rlm);
+    }
+    return fireTime;
+}
+
+CFAbsoluteTime CFRunLoopGetNextTimerFireDate(CFRunLoopRef rl, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    int64_t fireTSR;
+    __CFRunLoopLock(rl);
+    rlm = __CFRunLoopFindMode(rl, modeName, false);
+    __CFRunLoopUnlock(rl);
+    fireTSR = __CFRunLoopGetNextTimerFireTSR(rl, rlm);
+    int64_t now2 = __CFReadTSR();
+    CFAbsoluteTime now1 = CFAbsoluteTimeGetCurrent();
+    return (0 == fireTSR) ? 0.0 : (now1 + __CFTSRToTimeInterval(fireTSR - now2));
+}
+
+Boolean CFRunLoopIsWaiting(CFRunLoopRef rl) {
+    CHECK_FOR_FORK();
+    return __CFRunLoopIsSleeping(rl);
+}
+
+void CFRunLoopWakeUp(CFRunLoopRef rl) {
+    CHECK_FOR_FORK();
+#if DEPLOYMENT_TARGET_MACOSX
+    kern_return_t ret;
+    /* We unconditionally try to send the message, since we don't want
+     * to lose a wakeup, but the send may fail if there is already a
+     * wakeup pending, since the queue length is 1. */
+    ret = __CFSendTrivialMachMessage(rl->_wakeUpPort, 0, MACH_SEND_TIMEOUT, 0);
+    if (ret != MACH_MSG_SUCCESS && ret != MACH_SEND_TIMED_OUT) {
+	HALT;
+    }
+#elif DEPLOYMENT_TARGET_WINDOWS
+    SetEvent(rl->_wakeUpPort);
+#elif DEPLOYMENT_TARGET_LINUX
+	sem_post(rl->_wakeUpPort);
+#endif
+}
+
+void CFRunLoopStop(CFRunLoopRef rl) {
+    CHECK_FOR_FORK();
+    __CFRunLoopLock(rl);
+    __CFRunLoopSetStopped(rl);
+    __CFRunLoopUnlock(rl);
+    CFRunLoopWakeUp(rl);
+}
+
+CF_EXPORT void _CFRunLoopStopMode(CFRunLoopRef rl, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    __CFRunLoopLock(rl);
+    rlm = __CFRunLoopFindMode(rl, modeName, true);
+    __CFRunLoopUnlock(rl);
+    if (NULL != rlm) {
+	rlm->_stopped = true;
+	__CFRunLoopModeUnlock(rlm);
+    }
+    CFRunLoopWakeUp(rl);
+}
+
+CF_EXPORT Boolean _CFRunLoopModeContainsMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef candidateContainedName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    if (modeName == kCFRunLoopCommonModes || candidateContainedName == kCFRunLoopCommonModes) {
+	return false;
+    } else if (CFEqual(modeName, candidateContainedName)) {
+	return true;
+    }
+    __CFRunLoopLock(rl);
+    rlm = __CFRunLoopFindMode(rl, modeName, true);
+    __CFRunLoopUnlock(rl);
+    if (NULL != rlm) {
+	CFArrayRef submodes;
+	if (NULL == rlm->_submodes) {
+	    __CFRunLoopModeUnlock(rlm);
+	    return false;
+	}
+	if (CFArrayContainsValue(rlm->_submodes, CFRangeMake(0, CFArrayGetCount(rlm->_submodes)), candidateContainedName)) {
+	    __CFRunLoopModeUnlock(rlm);
+	    return true;
+	}
+	submodes = (NULL != rlm->_submodes && 0 < CFArrayGetCount(rlm->_submodes)) ? CFArrayCreateCopy(kCFAllocatorSystemDefault, rlm->_submodes) : NULL;
+	__CFRunLoopModeUnlock(rlm);
+	if (NULL != submodes) {
+	    CFIndex idx, cnt;
+	    for (idx = 0, cnt = CFArrayGetCount(submodes); idx < cnt; idx++) {
+		CFStringRef subname = (CFStringRef)CFArrayGetValueAtIndex(submodes, idx);
+		if (_CFRunLoopModeContainsMode(rl, subname, candidateContainedName)) {
+		    CFRelease(submodes);
+		    return true;
+		}
+	    }
+	    CFRelease(submodes);
+	}
+    }
+    return false;
+}
+
+CF_EXPORT void _CFRunLoopAddModeToMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef toModeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    if (__CFRunLoopIsDeallocating(rl)) return;
+    // should really do a recursive check here, to make sure that a cycle isn't
+    // introduced; of course, if that happens, you aren't going to get very far.
+    if (modeName == kCFRunLoopCommonModes || toModeName == kCFRunLoopCommonModes || CFEqual(modeName, toModeName)) {
+	return;
+    } else {
+	__CFRunLoopLock(rl);
+	rlm = __CFRunLoopFindMode(rl, toModeName, true);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm) {
+	    if (NULL == rlm->_submodes) {
+		rlm->_submodes = CFArrayCreateMutable(CFGetAllocator(rlm), 0, &kCFTypeArrayCallBacks);
+	    }
+	    if (!CFArrayContainsValue(rlm->_submodes, CFRangeMake(0, CFArrayGetCount(rlm->_submodes)), modeName)) {
+		CFArrayAppendValue(rlm->_submodes, modeName);
+	    }
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+CF_EXPORT void _CFRunLoopRemoveModeFromMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef fromModeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    // should really do a recursive check here, to make sure that a cycle isn't
+    // introduced; of course, if that happens, you aren't going to get very far.
+    if (modeName == kCFRunLoopCommonModes || fromModeName == kCFRunLoopCommonModes || CFEqual(modeName, fromModeName)) {
+	return;
+    } else {
+	__CFRunLoopLock(rl);
+	rlm = __CFRunLoopFindMode(rl, fromModeName, true);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm) {
+	    if (NULL != rlm->_submodes) {
+		CFIndex idx, cnt = CFArrayGetCount(rlm->_submodes);
+		idx = CFArrayGetFirstIndexOfValue(rlm->_submodes, CFRangeMake(0, cnt), modeName);
+		if (0 <= idx) CFArrayRemoveValueAtIndex(rlm->_submodes, idx);
+	    }
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+Boolean CFRunLoopContainsSource(CFRunLoopRef rl, CFRunLoopSourceRef rls, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    Boolean hasValue = false;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	if (NULL != rl->_commonModeItems) {
+	    hasValue = CFSetContainsValue(rl->_commonModeItems, rls);
+	}
+	__CFRunLoopUnlock(rl);
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, false);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL != rlm->_sources) {
+	    hasValue = CFSetContainsValue(rlm->_sources, rls);
+	    __CFRunLoopModeUnlock(rlm);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+    return hasValue;
+}
+
+void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef rls, CFStringRef modeName) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    if (__CFRunLoopIsDeallocating(rl)) return;
+    if (!__CFIsValid(rls)) return;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	CFSetRef set = rl->_commonModes ? CFSetCreateCopy(kCFAllocatorSystemDefault, rl->_commonModes) : NULL;
+	if (NULL == rl->_commonModeItems) {
+	    rl->_commonModeItems = CFSetCreateMutable(CFGetAllocator(rl), 0, &kCFTypeSetCallBacks);
+	    _CFSetSetCapacity(rl->_commonModeItems, 20);
+	}
+	CFSetAddValue(rl->_commonModeItems, rls);
+	__CFRunLoopUnlock(rl);
+	if (NULL != set) {
+	    CFTypeRef context[2] = {rl, rls};
+	    /* add new item to all common-modes */
+	    CFSetApplyFunction(set, (__CFRunLoopAddItemToCommonModes), (void *)context);
+	    CFRelease(set);
+	}
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, true);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL == rlm->_sources) {
+	    rlm->_sources = CFSetCreateMutable(CFGetAllocator(rlm), 0, &kCFTypeSetCallBacks);
+	    _CFSetSetCapacity(rlm->_sources, 10);
+	}
+	if (NULL != rlm && !CFSetContainsValue(rlm->_sources, rls)) {
+	    CFSetAddValue(rlm->_sources, rls);
+	    __CFRunLoopModeUnlock(rlm);
+	    __CFRunLoopSourceSchedule(rls, rl, rlm);	/* DOES CALLOUT */
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+void CFRunLoopRemoveSource(CFRunLoopRef rl, CFRunLoopSourceRef rls, CFStringRef modeName) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	if (NULL != rl->_commonModeItems && CFSetContainsValue(rl->_commonModeItems, rls)) {
+	    CFSetRef set = rl->_commonModes ? CFSetCreateCopy(kCFAllocatorSystemDefault, rl->_commonModes) : NULL;
+	    CFSetRemoveValue(rl->_commonModeItems, rls);
+	    __CFRunLoopUnlock(rl);
+	    if (NULL != set) {
+		CFTypeRef context[2] = {rl, rls};
+		/* remove new item from all common-modes */
+		CFSetApplyFunction(set, (__CFRunLoopRemoveItemFromCommonModes), (void *)context);
+		CFRelease(set);
+	    }
+	} else {
+	    __CFRunLoopUnlock(rl);
+	}
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, false);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL != rlm->_sources && CFSetContainsValue(rlm->_sources, rls)) {
+	    CFRetain(rls);
+	    CFSetRemoveValue(rlm->_sources, rls);
+	    __CFRunLoopModeUnlock(rlm);
+	    __CFRunLoopSourceCancel(rls, rl, rlm);	/* DOES CALLOUT */
+	    CFRelease(rls);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+Boolean CFRunLoopContainsObserver(CFRunLoopRef rl, CFRunLoopObserverRef rlo, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    Boolean hasValue = false;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	if (NULL != rl->_commonModeItems) {
+	    hasValue = CFSetContainsValue(rl->_commonModeItems, rlo);
+	}
+	__CFRunLoopUnlock(rl);
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, false);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL != rlm->_observers) {
+	    hasValue = CFSetContainsValue(rlm->_observers, rlo);
+	    __CFRunLoopModeUnlock(rlm);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+    return hasValue;
+}
+
+void CFRunLoopAddObserver(CFRunLoopRef rl, CFRunLoopObserverRef rlo, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    if (__CFRunLoopIsDeallocating(rl)) return;
+    if (!__CFIsValid(rlo) || (NULL != rlo->_runLoop && rlo->_runLoop != rl)) return;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	CFSetRef set = rl->_commonModes ? CFSetCreateCopy(kCFAllocatorSystemDefault, rl->_commonModes) : NULL;
+	if (NULL == rl->_commonModeItems) {
+	    rl->_commonModeItems = CFSetCreateMutable(CFGetAllocator(rl), 0, &kCFTypeSetCallBacks);
+	}
+	CFSetAddValue(rl->_commonModeItems, rlo);
+	__CFRunLoopUnlock(rl);
+	if (NULL != set) {
+	    CFTypeRef context[2] = {rl, rlo};
+	    /* add new item to all common-modes */
+	    CFSetApplyFunction(set, (__CFRunLoopAddItemToCommonModes), (void *)context);
+	    CFRelease(set);
+	}
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, true);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL == rlm->_observers) {
+	    rlm->_observers = CFSetCreateMutable(CFGetAllocator(rlm), 0, &kCFTypeSetCallBacks);
+	}
+	if (NULL != rlm && !CFSetContainsValue(rlm->_observers, rlo)) {
+	    CFSetAddValue(rlm->_observers, rlo);
+	    __CFRunLoopModeUnlock(rlm);
+	    __CFRunLoopObserverSchedule(rlo, rl, rlm);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+void CFRunLoopRemoveObserver(CFRunLoopRef rl, CFRunLoopObserverRef rlo, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	if (NULL != rl->_commonModeItems && CFSetContainsValue(rl->_commonModeItems, rlo)) {
+	    CFSetRef set = rl->_commonModes ? CFSetCreateCopy(kCFAllocatorSystemDefault, rl->_commonModes) : NULL;
+	    CFSetRemoveValue(rl->_commonModeItems, rlo);
+	    __CFRunLoopUnlock(rl);
+	    if (NULL != set) {
+		CFTypeRef context[2] = {rl, rlo};
+		/* remove new item from all common-modes */
+		CFSetApplyFunction(set, (__CFRunLoopRemoveItemFromCommonModes), (void *)context);
+		CFRelease(set);
+	    }
+	} else {
+	    __CFRunLoopUnlock(rl);
+	}
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, false);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL != rlm->_observers && CFSetContainsValue(rlm->_observers, rlo)) {
+	    CFRetain(rlo);
+	    CFSetRemoveValue(rlm->_observers, rlo);
+	    __CFRunLoopModeUnlock(rlm);
+	    __CFRunLoopObserverCancel(rlo, rl, rlm);
+	    CFRelease(rlo);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+Boolean CFRunLoopContainsTimer(CFRunLoopRef rl, CFRunLoopTimerRef rlt, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    Boolean hasValue = false;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	if (NULL != rl->_commonModeItems) {
+	    hasValue = CFSetContainsValue(rl->_commonModeItems, rlt);
+	}
+	__CFRunLoopUnlock(rl);
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, false);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL != rlm->_timers) {
+	    hasValue = CFSetContainsValue(rlm->_timers, rlt);
+	    __CFRunLoopModeUnlock(rlm);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+    return hasValue;
+}
+
+void CFRunLoopAddTimer(CFRunLoopRef rl, CFRunLoopTimerRef rlt, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    if (__CFRunLoopIsDeallocating(rl)) return;
+    if (!__CFIsValid(rlt) || (NULL != rlt->_runLoop && rlt->_runLoop != rl)) return;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	CFSetRef set = rl->_commonModes ? CFSetCreateCopy(kCFAllocatorSystemDefault, rl->_commonModes) : NULL;
+	if (NULL == rl->_commonModeItems) {
+	    rl->_commonModeItems = CFSetCreateMutable(CFGetAllocator(rl), 0, &kCFTypeSetCallBacks);
+	}
+	CFSetAddValue(rl->_commonModeItems, rlt);
+	__CFRunLoopUnlock(rl);
+	if (NULL != set) {
+	    CFTypeRef context[2] = {rl, rlt};
+	    /* add new item to all common-modes */
+	    CFSetApplyFunction(set, (__CFRunLoopAddItemToCommonModes), (void *)context);
+	    CFRelease(set);
+	}
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, true);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL == rlm->_timers) {
+	    rlm->_timers = CFSetCreateMutable(CFGetAllocator(rlm), 0, &kCFTypeSetCallBacks);
+	}
+	if (NULL != rlm && !CFSetContainsValue(rlm->_timers, rlt)) {
+	    CFSetAddValue(rlm->_timers, rlt);
+	    __CFRunLoopModeUnlock(rlm);
+	    __CFRunLoopTimerSchedule(rlt, rl, rlm);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+void CFRunLoopRemoveTimer(CFRunLoopRef rl, CFRunLoopTimerRef rlt, CFStringRef modeName) {
+    CHECK_FOR_FORK();
+    CFRunLoopModeRef rlm;
+    __CFRunLoopLock(rl);
+    if (modeName == kCFRunLoopCommonModes) {
+	if (NULL != rl->_commonModeItems && CFSetContainsValue(rl->_commonModeItems, rlt)) {
+	    CFSetRef set = rl->_commonModes ? CFSetCreateCopy(kCFAllocatorSystemDefault, rl->_commonModes) : NULL;
+	    CFSetRemoveValue(rl->_commonModeItems, rlt);
+	    __CFRunLoopUnlock(rl);
+	    if (NULL != set) {
+		CFTypeRef context[2] = {rl, rlt};
+		/* remove new item from all common-modes */
+		CFSetApplyFunction(set, (__CFRunLoopRemoveItemFromCommonModes), (void *)context);
+		CFRelease(set);
+	    }
+	} else {
+	    __CFRunLoopUnlock(rl);
+	}
+    } else {
+	rlm = __CFRunLoopFindMode(rl, modeName, false);
+	__CFRunLoopUnlock(rl);
+	if (NULL != rlm && NULL != rlm->_timers && CFSetContainsValue(rlm->_timers, rlt)) {
+	    CFRetain(rlt);
+	    CFSetRemoveValue(rlm->_timers, rlt);
+	    __CFRunLoopModeUnlock(rlm);
+	    __CFRunLoopTimerCancel(rlt, rl, rlm);
+	    CFRelease(rlt);
+	} else if (NULL != rlm) {
+	    __CFRunLoopModeUnlock(rlm);
+	}
+    }
+}
+
+
+/* CFRunLoopSource */
+
+static Boolean __CFRunLoopSourceEqual(CFTypeRef cf1, CFTypeRef cf2) {	/* DOES CALLOUT */
+    CFRunLoopSourceRef rls1 = (CFRunLoopSourceRef)cf1;
+    CFRunLoopSourceRef rls2 = (CFRunLoopSourceRef)cf2;
+    if (rls1 == rls2) return true;
+    if (rls1->_order != rls2->_order) return false;
+    if (rls1->_context.version0.version != rls2->_context.version0.version) return false;
+    if (rls1->_context.version0.hash != rls2->_context.version0.hash) return false;
+    if (rls1->_context.version0.equal != rls2->_context.version0.equal) return false;
+    if (0 == rls1->_context.version0.version && rls1->_context.version0.perform != rls2->_context.version0.perform) return false;
+    if (1 == rls1->_context.version0.version && rls1->_context.version1.perform != rls2->_context.version1.perform) return false;
+    if (rls1->_context.version0.equal)
+	return rls1->_context.version0.equal(rls1->_context.version0.info, rls2->_context.version0.info);
+    return (rls1->_context.version0.info == rls2->_context.version0.info);
+}
+
+static CFHashCode __CFRunLoopSourceHash(CFTypeRef cf) {	/* DOES CALLOUT */
+    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)cf;
+    if (rls->_context.version0.hash)
+	return rls->_context.version0.hash(rls->_context.version0.info);
+    return (CFHashCode)rls->_context.version0.info;
+}
+
+static CFStringRef __CFRunLoopSourceCopyDescription(CFTypeRef cf) {	/* DOES CALLOUT */
+    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)cf;
+    CFStringRef result;
+    CFStringRef contextDesc = NULL;
+    if (NULL != rls->_context.version0.copyDescription) {
+	contextDesc = rls->_context.version0.copyDescription(rls->_context.version0.info);
+    }
+    if (NULL == contextDesc) {
+	void *addr = rls->_context.version0.version == 0 ? (void *)rls->_context.version0.perform : (rls->_context.version0.version == 1 ? (void *)rls->_context.version1.perform : NULL);
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+	Dl_info info;
+	const char *name = (dladdr(addr, &info) && info.dli_saddr == addr && info.dli_sname) ? info.dli_sname : "???";
+	contextDesc = CFStringCreateWithFormat(CFGetAllocator(rls), NULL, CFSTR("<CFRunLoopSource context>{version = %ld, info = %p, callout = %s (%p)}"), rls->_context.version0.version, rls->_context.version0.info, name, addr);
+#elif DEPLOYMENT_TARGET_WINDOWS
+   const char *name = "???";
+	contextDesc = CFStringCreateWithFormat(CFGetAllocator(rls), NULL, CFSTR("<CFRunLoopSource context>{version = %ld, info = %p, callout = %s (%p)}"), rls->_context.version0.version, rls->_context.version0.info, name, addr);
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+    }
+result = CFStringCreateWithFormat(CFGetAllocator(rls), NULL, CFSTR("<CFRunLoopSource %p [%p]>{signalled = %s, valid = %s, order = %d, context = %@}"), cf, CFGetAllocator(rls), __CFRunLoopSourceIsSignaled(rls) ? "Yes" : "No", __CFIsValid(rls) ? "Yes" : "No", rls->_order, contextDesc);
+    CFRelease(contextDesc);
+    return result;
+}
+
+static void __CFRunLoopSourceDeallocate(CFTypeRef cf) {	/* DOES CALLOUT */
+    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)cf;
+    CFRunLoopSourceInvalidate(rls);
+    if (rls->_context.version0.release) {
+	rls->_context.version0.release(rls->_context.version0.info);
+    }
+}
+
+static const CFRuntimeClass __CFRunLoopSourceClass = {
+    _kCFRuntimeScannedObject,
+    "CFRunLoopSource",
+    NULL,      // init
+    NULL,      // copy
+    __CFRunLoopSourceDeallocate,
+    __CFRunLoopSourceEqual,
+    __CFRunLoopSourceHash,
+    NULL,      // 
+    __CFRunLoopSourceCopyDescription
+};
+
+__private_extern__ void __CFRunLoopSourceInitialize(void) {
+    __kCFRunLoopSourceTypeID = _CFRuntimeRegisterClass(&__CFRunLoopSourceClass);
+}
+
+CFTypeID CFRunLoopSourceGetTypeID(void) {
+    return __kCFRunLoopSourceTypeID;
+}
+
+CFRunLoopSourceRef CFRunLoopSourceCreate(CFAllocatorRef allocator, CFIndex order, CFRunLoopSourceContext *context) {
+    CHECK_FOR_FORK();
+    CFRunLoopSourceRef memory;
+    uint32_t size;
+    if (NULL == context) HALT;
+    size = sizeof(struct __CFRunLoopSource) - sizeof(CFRuntimeBase);
+    memory = (CFRunLoopSourceRef)_CFRuntimeCreateInstance(allocator, __kCFRunLoopSourceTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    __CFSetValid(memory);
+    __CFRunLoopSourceUnsetSignaled(memory);
+    CF_SPINLOCK_INIT_FOR_STRUCTS(memory->_lock);
+    memory->_bits = 0;
+    memory->_order = order;
+    memory->_runLoops = NULL;
+    size = 0;
+    switch (context->version) {
+    case 0:
+	size = sizeof(CFRunLoopSourceContext);
+	break;
+    case 1:
+	size = sizeof(CFRunLoopSourceContext1);
+	break;
+#if DEPLOYMENT_TARGET_MACOSX
+    case 2:
+	size = sizeof(CFRunLoopSourceContext2);
+	break;
+#endif
+    }
+    CF_WRITE_BARRIER_MEMMOVE(&memory->_context, context, size);
+    if (context->retain) {
+	memory->_context.version0.info = (void *)context->retain(context->info);
+    }
+    return memory;
+}
+
+CFIndex CFRunLoopSourceGetOrder(CFRunLoopSourceRef rls) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rls, __kCFRunLoopSourceTypeID);
+    return rls->_order;
+}
+
+static void __CFRunLoopSourceRemoveFromRunLoop(const void *value, void *context) {
+    CFRunLoopRef rl = (CFRunLoopRef)value;
+    CFTypeRef *params = (CFTypeRef*)context;
+    CFRunLoopSourceRef rls = (CFRunLoopSourceRef)params[0];
+    CFArrayRef array;
+    CFIndex idx;
+    if (rl == params[1]) return;
+    array = CFRunLoopCopyAllModes(rl);
+    for (idx = CFArrayGetCount(array); idx--;) {
+	CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(array, idx);
+	CFRunLoopRemoveSource(rl, rls, modeName);
+    }
+    CFRunLoopRemoveSource(rl, rls, kCFRunLoopCommonModes);
+    CFRelease(array);
+    params[1] = rl;
+}
+
+void CFRunLoopSourceInvalidate(CFRunLoopSourceRef rls) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rls, __kCFRunLoopSourceTypeID);
+    CFRetain(rls);
+    __CFRunLoopSourceLock(rls);
+    if (__CFIsValid(rls)) {
+	__CFUnsetValid(rls);
+        __CFRunLoopSourceUnsetSignaled(rls);
+	if (NULL != rls->_runLoops) {
+	    CFTypeRef params[2] = {rls, NULL};
+	    CFBagRef bag = CFBagCreateCopy(kCFAllocatorSystemDefault, rls->_runLoops);
+	    CFRelease(rls->_runLoops);
+	    rls->_runLoops = NULL;
+	    __CFRunLoopSourceUnlock(rls);
+	    CFBagApplyFunction(bag, (__CFRunLoopSourceRemoveFromRunLoop), params);
+	    CFRelease(bag);
+	} else {
+	    __CFRunLoopSourceUnlock(rls);
+	}
+	/* for hashing- and equality-use purposes, can't actually release the context here */
+    } else {
+	__CFRunLoopSourceUnlock(rls);
+    }
+    CFRelease(rls);
+}
+
+Boolean CFRunLoopSourceIsValid(CFRunLoopSourceRef rls) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rls, __kCFRunLoopSourceTypeID);
+    return __CFIsValid(rls);
+}
+
+void CFRunLoopSourceGetContext(CFRunLoopSourceRef rls, CFRunLoopSourceContext *context) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rls, __kCFRunLoopSourceTypeID);
+    CFAssert1(0 == context->version || 1 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0 or 1", __PRETTY_FUNCTION__);
+    CFIndex size = 0;
+    switch (context->version) {
+    case 0:
+	size = sizeof(CFRunLoopSourceContext);
+	break;
+    case 1:
+	size = sizeof(CFRunLoopSourceContext1);
+	break;
+#if DEPLOYMENT_TARGET_MACOSX
+    case 2:
+	size = sizeof(CFRunLoopSourceContext2);
+	break;
+#endif
+    }
+    memmove(context, &rls->_context, size);
+}
+
+void CFRunLoopSourceSignal(CFRunLoopSourceRef rls) {
+    CHECK_FOR_FORK();
+    __CFRunLoopSourceLock(rls);
+    if (__CFIsValid(rls)) {
+	__CFRunLoopSourceSetSignaled(rls);
+    }
+    __CFRunLoopSourceUnlock(rls);
+}
+
+Boolean CFRunLoopSourceIsSignalled(CFRunLoopSourceRef rls) {
+    CHECK_FOR_FORK();
+    __CFRunLoopSourceLock(rls);
+    Boolean ret = __CFRunLoopSourceIsSignaled(rls) ? true : false;
+    __CFRunLoopSourceUnlock(rls);
+    return ret;
+}
+
+/* CFRunLoopObserver */
+
+static CFStringRef __CFRunLoopObserverCopyDescription(CFTypeRef cf) {	/* DOES CALLOUT */
+    CFRunLoopObserverRef rlo = (CFRunLoopObserverRef)cf;
+    CFStringRef result;
+    CFStringRef contextDesc = NULL;
+    if (NULL != rlo->_context.copyDescription) {
+	contextDesc = rlo->_context.copyDescription(rlo->_context.info);
+    }
+    if (!contextDesc) {
+	contextDesc = CFStringCreateWithFormat(CFGetAllocator(rlo), NULL, CFSTR("<CFRunLoopObserver context %p>"), rlo->_context.info);
+    }
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    void *addr = (void*)rlo->_callout;
+    Dl_info info;
+    const char *name = (dladdr(addr, &info) && info.dli_saddr == addr && info.dli_sname) ? info.dli_sname : "???";
+    result = CFStringCreateWithFormat(CFGetAllocator(rlo), NULL, CFSTR("<CFRunLoopObserver %p [%p]>{valid = %s, activities = 0x%x, repeats = %s, order = %d, callout = %s (%p), context = %@}"), cf, CFGetAllocator(rlo), __CFIsValid(rlo) ? "Yes" : "No", rlo->_activities, __CFRunLoopObserverRepeats(rlo) ? "Yes" : "No", rlo->_order, name, addr, contextDesc);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    void *addr = rlo->_callout;
+    const char *name = "???";
+    result = CFStringCreateWithFormat(CFGetAllocator(rlo), NULL, CFSTR("<CFRunLoopObserver %p [%p]>{locked = %s, valid = %s, activities = 0x%x, repeats = %s, order = %d, callout = %s (%p), context = %@}"), cf, CFGetAllocator(rlo), lockCount(rlo->_lock) ? "Yes" : "No", __CFIsValid(rlo) ? "Yes" : "No", rlo->_activities, __CFRunLoopObserverRepeats(rlo) ? "Yes" : "No", rlo->_order, name, addr, contextDesc);
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+    CFRelease(contextDesc);
+    return result;
+}
+
+static void __CFRunLoopObserverDeallocate(CFTypeRef cf) {	/* DOES CALLOUT */
+    CFRunLoopObserverRef rlo = (CFRunLoopObserverRef)cf;
+    CFRunLoopObserverInvalidate(rlo);
+}
+
+static const CFRuntimeClass __CFRunLoopObserverClass = {
+    0,
+    "CFRunLoopObserver",
+    NULL,      // init
+    NULL,      // copy
+    __CFRunLoopObserverDeallocate,
+    NULL,
+    NULL,
+    NULL,      // 
+    __CFRunLoopObserverCopyDescription
+};
+
+__private_extern__ void __CFRunLoopObserverInitialize(void) {
+    __kCFRunLoopObserverTypeID = _CFRuntimeRegisterClass(&__CFRunLoopObserverClass);
+}
+
+CFTypeID CFRunLoopObserverGetTypeID(void) {
+    return __kCFRunLoopObserverTypeID;
+}
+
+CFRunLoopObserverRef CFRunLoopObserverCreate(CFAllocatorRef allocator, CFOptionFlags activities, Boolean repeats, CFIndex order, CFRunLoopObserverCallBack callout, CFRunLoopObserverContext *context) {
+    CHECK_FOR_FORK();
+    CFRunLoopObserverRef memory;
+    UInt32 size;
+    size = sizeof(struct __CFRunLoopObserver) - sizeof(CFRuntimeBase);
+    memory = (CFRunLoopObserverRef)_CFRuntimeCreateInstance(allocator, __kCFRunLoopObserverTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    __CFSetValid(memory);
+    __CFRunLoopObserverUnsetFiring(memory);
+    if (repeats) {
+	__CFRunLoopObserverSetRepeats(memory);
+    } else {
+	__CFRunLoopObserverUnsetRepeats(memory);
+    }
+    CF_SPINLOCK_INIT_FOR_STRUCTS(memory->_lock);
+    memory->_runLoop = NULL;
+    memory->_rlCount = 0;
+    memory->_activities = activities;
+    memory->_order = order;
+    memory->_callout = callout;
+    if (context) {
+	if (context->retain) {
+	    memory->_context.info = (void *)context->retain(context->info);
+	} else {
+	    memory->_context.info = context->info;
+	}
+	memory->_context.retain = context->retain;
+	memory->_context.release = context->release;
+	memory->_context.copyDescription = context->copyDescription;
+    } else {
+	memory->_context.info = 0;
+	memory->_context.retain = 0;
+	memory->_context.release = 0;
+	memory->_context.copyDescription = 0;
+    }
+    return memory;
+}
+
+CFOptionFlags CFRunLoopObserverGetActivities(CFRunLoopObserverRef rlo) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rlo, __kCFRunLoopObserverTypeID);
+    return rlo->_activities;
+}
+
+CFIndex CFRunLoopObserverGetOrder(CFRunLoopObserverRef rlo) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rlo, __kCFRunLoopObserverTypeID);
+    return rlo->_order;
+}
+
+Boolean CFRunLoopObserverDoesRepeat(CFRunLoopObserverRef rlo) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rlo, __kCFRunLoopObserverTypeID);
+    return __CFRunLoopObserverRepeats(rlo);
+}
+
+void CFRunLoopObserverInvalidate(CFRunLoopObserverRef rlo) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rlo, __kCFRunLoopObserverTypeID);
+    CFRetain(rlo);
+    __CFRunLoopObserverLock(rlo);
+    if (__CFIsValid(rlo)) {
+	CFRunLoopRef rl = rlo->_runLoop;
+	__CFUnsetValid(rlo);
+	__CFRunLoopObserverUnlock(rlo);
+	if (NULL != rl) {
+	    CFArrayRef array;
+	    CFIndex idx;
+	    array = CFRunLoopCopyAllModes(rl);
+	    for (idx = CFArrayGetCount(array); idx--;) {
+		CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(array, idx);
+		CFRunLoopRemoveObserver(rl, rlo, modeName);
+	    }
+	    CFRunLoopRemoveObserver(rl, rlo, kCFRunLoopCommonModes);
+	    CFRelease(array);
+	}
+	if (rlo->_context.release)
+	    rlo->_context.release(rlo->_context.info);	/* CALLOUT */
+	rlo->_context.info = NULL;
+    } else {
+	__CFRunLoopObserverUnlock(rlo);
+    }
+    CFRelease(rlo);
+}
+
+Boolean CFRunLoopObserverIsValid(CFRunLoopObserverRef rlo) {
+    CHECK_FOR_FORK();
+    return __CFIsValid(rlo);
+}
+
+void CFRunLoopObserverGetContext(CFRunLoopObserverRef rlo, CFRunLoopObserverContext *context) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rlo, __kCFRunLoopObserverTypeID);
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+    *context = rlo->_context;
+}
+
+/* CFRunLoopTimer */
+
+static CFStringRef __CFRunLoopTimerCopyDescription(CFTypeRef cf) {	/* DOES CALLOUT */
+    CFRunLoopTimerRef rlt = (CFRunLoopTimerRef)cf;
+    CFStringRef result;
+    CFStringRef contextDesc = NULL;
+    int64_t fireTime;
+    __CFRunLoopTimerFireTSRLock();
+    fireTime = rlt->_fireTSR;
+    __CFRunLoopTimerFireTSRUnlock();
+    if (NULL != rlt->_context.copyDescription) {
+	contextDesc = rlt->_context.copyDescription(rlt->_context.info);
+    }
+    if (NULL == contextDesc) {
+	contextDesc = CFStringCreateWithFormat(CFGetAllocator(rlt), NULL, CFSTR("<CFRunLoopTimer context %p>"), rlt->_context.info);
+    }
+    int64_t now2 = __CFReadTSR();
+    CFAbsoluteTime now1 = CFAbsoluteTimeGetCurrent();
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    void *addr = (void*)rlt->_callout;
+    Dl_info info;
+    const char *name = (dladdr(addr, &info) && info.dli_saddr == addr && info.dli_sname) ? info.dli_sname : "???";
+    result = CFStringCreateWithFormat(CFGetAllocator(rlt), NULL, CFSTR("<CFRunLoopTimer %p [%p]>{valid = %s, interval = %0.09g, next fire date = %0.09g, order = %d, callout = %s (%p), context = %@}"), cf, CFGetAllocator(rlt), __CFIsValid(rlt) ? "Yes" : "No", __CFTSRToTimeInterval(rlt->_intervalTSR), now1 + __CFTSRToTimeInterval(fireTime - now2), rlt->_order, name, addr, contextDesc);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    void *addr = rlt->_callout;
+    const char *name = "???";
+    result = CFStringCreateWithFormat(CFGetAllocator(rlt), NULL, CFSTR("<CFRunLoopTimer %p [%p]>{locked = %s, valid = %s, interval = %0.09g, next fire date = %0.09g, order = %d, callout = %s (%p), context = %@}"), cf, CFGetAllocator(rlt), lockCount(rlt->_lock) ? "Yes" : "No", __CFIsValid(rlt) ? "Yes" : "No", __CFTSRToTimeInterval(rlt->_intervalTSR), now1 + __CFTSRToTimeInterval(fireTime - now2), rlt->_order, name, addr, contextDesc);
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+    CFRelease(contextDesc);
+    return result;
+}
+
+static void __CFRunLoopTimerDeallocate(CFTypeRef cf) {	/* DOES CALLOUT */
+    CFRunLoopTimerRef rlt = (CFRunLoopTimerRef)cf;
+    CFRunLoopTimerInvalidate(rlt);	/* DOES CALLOUT */
+}
+
+static const CFRuntimeClass __CFRunLoopTimerClass = {
+    0,
+    "CFRunLoopTimer",
+    NULL,      // init
+    NULL,      // copy
+    __CFRunLoopTimerDeallocate,
+    NULL,	// equal
+    NULL,
+    NULL,      // 
+    __CFRunLoopTimerCopyDescription
+};
+
+__private_extern__ void __CFRunLoopTimerInitialize(void) {
+    __kCFRunLoopTimerTypeID = _CFRuntimeRegisterClass(&__CFRunLoopTimerClass);
+}
+
+CFTypeID CFRunLoopTimerGetTypeID(void) {
+    return __kCFRunLoopTimerTypeID;
+}
+
+CFRunLoopTimerRef CFRunLoopTimerCreate(CFAllocatorRef allocator, CFAbsoluteTime fireDate, CFTimeInterval interval, CFOptionFlags flags, CFIndex order, CFRunLoopTimerCallBack callout, CFRunLoopTimerContext *context) {
+    CHECK_FOR_FORK();
+    CFRunLoopTimerRef memory;
+    UInt32 size;
+    size = sizeof(struct __CFRunLoopTimer) - sizeof(CFRuntimeBase);
+    memory = (CFRunLoopTimerRef)_CFRuntimeCreateInstance(allocator, __kCFRunLoopTimerTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    __CFSetValid(memory);
+    __CFRunLoopTimerUnsetFiring(memory);
+    __CFRunLoopTimerUnsetDidFire(memory);
+    CF_SPINLOCK_INIT_FOR_STRUCTS(memory->_lock);
+    memory->_runLoop = NULL;
+    memory->_rlCount = 0;
+    memory->_order = order;
+#if DEPLOYMENT_TARGET_MACOSX
+    memory->_port = MACH_PORT_NULL;
+#endif
+    int64_t now2 = __CFReadTSR();
+    CFAbsoluteTime now1 = CFAbsoluteTimeGetCurrent();
+    if (3.1556952e+9 < fireDate) fireDate = 3.1556952e+9;
+    if (fireDate < now1) {
+	memory->_fireTSR = now2;
+    } else if (now1 + __CFTSRToTimeInterval(LLONG_MAX) < fireDate) {
+	memory->_fireTSR = LLONG_MAX;
+    } else {
+	memory->_fireTSR = now2 + __CFTimeIntervalToTSR(fireDate - now1);
+    }
+    if (3.1556952e+9 < interval) interval = 3.1556952e+9;
+    if (interval <= 0.0) {
+	memory->_intervalTSR = 0;
+    } else if (__CFTSRToTimeInterval(LLONG_MAX) < interval) {
+	memory->_intervalTSR = LLONG_MAX;
+    } else {
+	memory->_intervalTSR = __CFTimeIntervalToTSR(interval);
+    }
+    memory->_callout = callout;
+    if (NULL != context) {
+	if (context->retain) {
+	    memory->_context.info = (void *)context->retain(context->info);
+	} else {
+	    memory->_context.info = context->info;
+	}
+	memory->_context.retain = context->retain;
+	memory->_context.release = context->release;
+	memory->_context.copyDescription = context->copyDescription;
+    } else {
+	memory->_context.info = 0;
+	memory->_context.retain = 0;
+	memory->_context.release = 0;
+	memory->_context.copyDescription = 0;
+    }
+    return memory;
+}
+
+CFAbsoluteTime CFRunLoopTimerGetNextFireDate(CFRunLoopTimerRef rlt) {
+    CHECK_FOR_FORK();
+    int64_t fireTime, result = 0;
+    CF_OBJC_FUNCDISPATCH0(__kCFRunLoopTimerTypeID, CFAbsoluteTime, rlt, "_cffireTime");
+    __CFGenericValidateType(rlt, __kCFRunLoopTimerTypeID);
+    __CFRunLoopTimerFireTSRLock();
+    fireTime = rlt->_fireTSR;
+    __CFRunLoopTimerFireTSRUnlock();
+    __CFRunLoopTimerLock(rlt);
+    if (__CFIsValid(rlt)) {
+	result = fireTime;
+    }
+    __CFRunLoopTimerUnlock(rlt);
+    int64_t now2 = __CFReadTSR();
+    CFAbsoluteTime now1 = CFAbsoluteTimeGetCurrent();
+    return (0 == result) ? 0.0 : now1 + __CFTSRToTimeInterval(result - now2);
+}
+
+void CFRunLoopTimerSetNextFireDate(CFRunLoopTimerRef rlt, CFAbsoluteTime fireDate) {
+    CHECK_FOR_FORK();
+    __CFRunLoopTimerFireTSRLock();
+    int64_t now2 = __CFReadTSR();
+    CFAbsoluteTime now1 = CFAbsoluteTimeGetCurrent();
+    if (3.1556952e+9 < fireDate) fireDate = 3.1556952e+9;
+    if (fireDate < now1) {
+	rlt->_fireTSR = now2;
+    } else if (now1 + __CFTSRToTimeInterval(LLONG_MAX) < fireDate) {
+	rlt->_fireTSR = LLONG_MAX;
+    } else {
+	rlt->_fireTSR = now2 + __CFTimeIntervalToTSR(fireDate - now1);
+    }
+    if (rlt->_runLoop != NULL) {
+	__CFRunLoopTimerRescheduleWithAllModes(rlt, rlt->_runLoop);
+    }
+    __CFRunLoopTimerFireTSRUnlock();
+}
+
+CFTimeInterval CFRunLoopTimerGetInterval(CFRunLoopTimerRef rlt) {
+    CHECK_FOR_FORK();
+    CF_OBJC_FUNCDISPATCH0(__kCFRunLoopTimerTypeID, CFTimeInterval, rlt, "timeInterval");
+    __CFGenericValidateType(rlt, __kCFRunLoopTimerTypeID);
+    return __CFTSRToTimeInterval(rlt->_intervalTSR);
+}
+
+Boolean CFRunLoopTimerDoesRepeat(CFRunLoopTimerRef rlt) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rlt, __kCFRunLoopTimerTypeID);
+    return (0 != rlt->_intervalTSR);
+}
+
+CFIndex CFRunLoopTimerGetOrder(CFRunLoopTimerRef rlt) {
+    CHECK_FOR_FORK();
+    CF_OBJC_FUNCDISPATCH0(__kCFRunLoopTimerTypeID, CFIndex, rlt, "order");
+    __CFGenericValidateType(rlt, __kCFRunLoopTimerTypeID);
+    return rlt->_order;
+}
+
+void CFRunLoopTimerInvalidate(CFRunLoopTimerRef rlt) {	/* DOES CALLOUT */
+    CHECK_FOR_FORK();
+    CF_OBJC_FUNCDISPATCH0(__kCFRunLoopTimerTypeID, void, rlt, "invalidate");
+    __CFGenericValidateType(rlt, __kCFRunLoopTimerTypeID);
+    CFRetain(rlt);
+    __CFRunLoopTimerLock(rlt);
+    if (__CFIsValid(rlt)) {
+	CFRunLoopRef rl = rlt->_runLoop;
+	void *info = rlt->_context.info;
+	__CFUnsetValid(rlt);
+#if DEPLOYMENT_TARGET_MACOSX
+	__CFRunLoopTimerPortMapLock();
+	if (NULL != __CFRLTPortMap) {
+	    CFDictionaryRemoveValue(__CFRLTPortMap, (void *)(uintptr_t)rlt->_port);
+	}
+	__CFRunLoopTimerPortMapUnlock();
+	mk_timer_destroy(rlt->_port);
+	rlt->_port = MACH_PORT_NULL;
+#endif
+	rlt->_context.info = NULL;
+	__CFRunLoopTimerUnlock(rlt);
+	if (NULL != rl) {
+	    CFArrayRef array;
+	    CFIndex idx;
+	    array = CFRunLoopCopyAllModes(rl);
+	    for (idx = CFArrayGetCount(array); idx--;) {
+		CFStringRef modeName = (CFStringRef)CFArrayGetValueAtIndex(array, idx);
+		CFRunLoopRemoveTimer(rl, rlt, modeName);
+	    }
+	    CFRunLoopRemoveTimer(rl, rlt, kCFRunLoopCommonModes);
+	    CFRelease(array);
+	}
+	if (NULL != rlt->_context.release) {
+	    rlt->_context.release(info);	/* CALLOUT */
+	}
+    } else {
+	__CFRunLoopTimerUnlock(rlt);
+    }
+    CFRelease(rlt);
+}
+
+Boolean CFRunLoopTimerIsValid(CFRunLoopTimerRef rlt) {
+    CHECK_FOR_FORK();
+    CF_OBJC_FUNCDISPATCH0(__kCFRunLoopTimerTypeID, Boolean, rlt, "isValid");
+    __CFGenericValidateType(rlt, __kCFRunLoopTimerTypeID);
+    return __CFIsValid(rlt);
+}
+
+void CFRunLoopTimerGetContext(CFRunLoopTimerRef rlt, CFRunLoopTimerContext *context) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(rlt, __kCFRunLoopTimerTypeID);
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+    *context = rlt->_context;
+}
+
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#include <Winternl.h>
+typedef NTSTATUS (__stdcall *pfnNtQueryInformationThread) (HANDLE, THREADINFOCLASS, PVOID, ULONG, PULONG);
+
+typedef struct _CLIENT_ID
+{
+DWORD UniqueProcess; 
+DWORD UniqueThread;
+} CLIENT_ID, *PCLIENT_ID;
+
+typedef struct _THREAD_BASIC_INFORMATION
+{
+NTSTATUS ExitStatus;
+PVOID TebBaseAddress;
+CLIENT_ID ClientId;
+LONG AffinityMask;
+LONG Priority;
+LONG BasePriority;
+} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
+
+/**
+ * This API function exists in Vista and beyond, but is not
+ * available in other OS releases.
+ *
+ * It uses undocumented/internal calls and is very evil.
+ * Thankfully, Vista+ users can call the true API function.
+ */
+DWORD GetInternalThreadId(HANDLE t)
+{
+   static HMODULE hModule = LoadLibraryA("ntdll.dll");
+   static pfnNtQueryInformationThread queryInformationThread = 0;
+
+   if (!t)
+      return 0;   // Don't process null handles
+
+   if (!queryInformationThread)
+   {
+      queryInformationThread = (pfnNtQueryInformationThread) GetProcAddress(hModule, "NtQueryInformationThread");
+      if (!queryInformationThread)
+         return 0;	// failed to get proc address
+   }
+
+   THREAD_BASIC_INFORMATION tbi;
+   THREADINFOCLASS tic = (THREADINFOCLASS)0; // basic information
+   if (queryInformationThread(GetCurrentThread(), tic, &tbi, sizeof(tbi), NULL))
+   {
+      // NtQueryInformationThread failed...
+      FreeLibrary(hModule);
+      return 0;
+   }
+
+    return tbi.ClientId.UniqueThread;
+}
+#endif
diff --git a/CoreFoundation/CFRunLoop.h b/CoreFoundation/CFRunLoop.h
new file mode 100644
index 0000000..3521a43
--- /dev/null
+++ b/CoreFoundation/CFRunLoop.h
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFRUNLOOP__)
+#define __COREFOUNDATION_CFRUNLOOP__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFString.h>
+#if defined(__MACH__)
+    #include <mach/port.h>
+#elif DEPLOYMENT_TARGET_LINUX
+	#include <semaphore.h>
+#endif
+
+CF_EXTERN_C_BEGIN
+
+typedef struct __CFRunLoop * CFRunLoopRef;
+
+typedef struct __CFRunLoopSource * CFRunLoopSourceRef;
+
+typedef struct __CFRunLoopObserver * CFRunLoopObserverRef;
+
+typedef struct __CFRunLoopTimer * CFRunLoopTimerRef;
+
+/* Reasons for CFRunLoopRunInMode() to Return */
+enum {
+    kCFRunLoopRunFinished = 1,
+    kCFRunLoopRunStopped = 2,
+    kCFRunLoopRunTimedOut = 3,
+    kCFRunLoopRunHandledSource = 4
+};
+
+/* Run Loop Observer Activities */
+enum {
+    kCFRunLoopEntry = (1 << 0),
+    kCFRunLoopBeforeTimers = (1 << 1),
+    kCFRunLoopBeforeSources = (1 << 2),
+    kCFRunLoopBeforeWaiting = (1 << 5),
+    kCFRunLoopAfterWaiting = (1 << 6),
+    kCFRunLoopExit = (1 << 7),
+    kCFRunLoopAllActivities = 0x0FFFFFFFU
+};
+typedef CFOptionFlags CFRunLoopActivity;
+
+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) AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER;
+
+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);
+
+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 defined(__MACH__)
+    mach_port_t	(*getPort)(void *info);
+    void *	(*perform)(void *msg, CFIndex size, CFAllocatorRef allocator, void *info);
+#elif DEPLOYMENT_TARGET_LINUX
+    sem_t *	(*getPort)(void *info);
+    void	(*perform)(void *info);
+#else
+    HANDLE	(*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);
+
+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);
+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);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFRUNLOOP__ */
+
diff --git a/CoreFoundation/CFRunLoopPriv.h b/CoreFoundation/CFRunLoopPriv.h
new file mode 100644
index 0000000..b346271
--- /dev/null
+++ b/CoreFoundation/CFRunLoopPriv.h
@@ -0,0 +1,387 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*      CFRunLoopPriv.h
+        Copyright (c) 2006-2007, Apple Inc. All rights reserved.
+*/
+
+#if (DEPLOYMENT_TARGET_MACOSX || 0)
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+#import "CFObject.h"
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFMachPort.h>
+#include <CoreFoundation/CFSocket.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFBag.h>
+#include <mach/mach.h>
+#include <sys/event.h>
+#include <pthread.h>
+
+@class CFRunLoopSourceSet;
+typedef CFRunLoopSourceContext CFRunLoopSourceContext0;
+typedef CFMachPortContext CFRunLoopMachPortContext;
+typedef CFSocketContext CFRunLoopSocketContext;
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopSource : CFObject {
+    uint8_t _cfruntime_[8]; // large enough for 32-bit or 64-bit
+    int _kq;
+    mach_port_t _portset;
+    mach_port_t _port;
+    CFIndex _order;
+    uint8_t _invalid;
+    uint8_t _firing;
+    uint8_t _ownsPort;
+    uint8_t _async;
+}
+
+- (int)kqueue;
+- (mach_port_t)machPortSet;
+- (mach_port_t)machPort;
+
+- (void)setOrder:(CFIndex)o;
+- (CFIndex)order;
+
+- (void)setAsyncStrategy:(uint8_t)s;
+- (uint8_t)asyncStrategy;
+
+- (void)perform:(mach_msg_header_t *)msg;
+
+- (void)invalidate;
+- (Boolean)isValid;
+
+- (void)noteAddedToSourceSet:(CFRunLoopSourceSet *)ss;
+- (void)noteRemovedFromSourceSet:(CFRunLoopSourceSet *)ss;
+
+- (CFStringRef)copyPartialDebugDescription; // subclasses override
+- (CFStringRef)copyDebugDescription;
+
+@end
+
+@interface CFRunLoopVersion0SourceCFRef : CFRunLoopSource {
+    CFRunLoopSourceContext0 _context;
+}
+
+- (Boolean)setContext:(CFRunLoopSourceContext0)c;
+- (CFRunLoopSourceContext0)context;
+
+- (void)markReady;
+- (void)handle;
+
+- (void)scheduleInRunLoop:(CFRunLoopRef)rl mode:(CFStringRef)n;
+- (void)cancelFromRunLoop:(CFRunLoopRef)rl mode:(CFStringRef)n;
+
+@end
+
+@interface CFRunLoopVersion1SourceCFRef : CFRunLoopSource {
+    CFRunLoopSourceContext1 _context;
+}
+
+- (Boolean)setContext:(CFRunLoopSourceContext1)c;
+- (CFRunLoopSourceContext1)context;
+
+- (void)markReady;
+- (void)handle:(mach_msg_header_t *)msg;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopTimerSource : CFRunLoopSource {
+    CFAbsoluteTime _fireAT;
+    CFTimeInterval _interval;
+}
+
+- (void)setFireTime:(CFAbsoluteTime)at;
+- (CFAbsoluteTime)fireTime;
+
+- (void)setInterval:(CFTimeInterval)i;
+- (CFTimeInterval)interval;
+
+- (void)handle;
+
+@end
+
+@interface CFRunLoopTimerSourceCFRef : CFRunLoopTimerSource {
+    void *_function;
+    CFRunLoopTimerContext _context;
+}
+
+- (void)setFunction:(void *)f;
+- (void *)function;
+
+- (Boolean)setContext:(CFRunLoopTimerContext)c;
+- (CFRunLoopTimerContext)context;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopMachPortSource : CFRunLoopSource {
+    mach_port_t _notifyPort;
+    mach_port_t _oldNotifyPort;
+}
+
++ (id)newWithPort:(mach_port_t)p;
+
+- (void)handle:(mach_msg_header_t *)msg;
+
+@end
+
+@interface CFRunLoopMachPortSourceCFRef : CFRunLoopMachPortSource {
+    void *_function;
+    CFRunLoopMachPortContext _context;
+    void *_invalidation;
+}
+
+- (void)setFunction:(void *)f;
+- (void *)function;
+
+- (Boolean)setContext:(CFRunLoopMachPortContext)c;
+- (CFRunLoopMachPortContext)context;
+
+- (void)setInvalidationFunction:(void *)f;
+- (void *)invalidationFunction;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopKEventSource : CFRunLoopSource {
+    struct kevent _filter;
+}
+
+- (Boolean)setFilter:(struct kevent)kev;
+- (struct kevent)filter;
+
+- (void)handle:(struct kevent *)kev;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopSignalSource : CFRunLoopSource {
+    int _signal;
+}
+
+- (Boolean)setSignal:(int)sig;
+- (int)signal;
+
+- (long)poll;
+
+- (void)handle:(long)n;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopProcessDeathSource : CFRunLoopSource {
+    int _pid;
+}
+
+- (Boolean)setProcessID:(int)pid;
+- (int)processID;
+
+- (void)handle;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopSocketSource : CFRunLoopSource {
+    int _socket;
+    uint8_t _ownsSocket;
+    uint8_t _enabledR;
+    uint8_t _enabledW;
+}
+
++ (id)newWithSocket:(int)s;
+
+- (int)socket;
+- (CFDataRef)copyLocalAddress;
+- (CFDataRef)copyRemoteAddress;
+
+- (void)setReadEventsEnabled:(Boolean)b;
+- (Boolean)readEventsEnabled;
+
+- (void)setWriteEventsEnabled:(Boolean)b;
+- (Boolean)writeEventsEnabled;
+
+- (void)handleReadability:(CFIndex)amt endOfFile:(Boolean)b;
+- (void)performRead:(struct kevent *)kev;
+
+- (void)handleWritability:(CFIndex)amt endOfFile:(Boolean)b;
+- (void)performWrite:(struct kevent *)kev;
+
+@end
+
+@interface CFRunLoopSocketSourceCFRef : CFRunLoopSocketSource {
+    void *_function;
+    CFRunLoopSocketContext _context;
+    uint8_t _callbacks;
+    uint8_t _flags;
+    uint8_t _disabled;
+}
+
+- (void)setFunction:(void *)f;
+- (void *)function;
+
+- (Boolean)setContext:(CFRunLoopSocketContext)c;
+- (CFRunLoopSocketContext)context;
+
+- (void)setCallBackTypes:(uint8_t)f;
+- (uint8_t)callBackTypes;
+
+- (void)setFlags:(uint8_t)f;
+- (uint8_t)flags;
+
+- (void)setDisabledFlags:(uint8_t)f;
+- (uint8_t)disabledFlags;
+
+- (Boolean)handleAcceptError:(int)err;
+- (Boolean)handleReadError:(int)err;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopObserver : CFRunLoopSource {
+}
+
+- (void)observeEntry:(CFRunLoopSourceSet *)ss;
+- (void)observeBeforeWaiting:(CFRunLoopSourceSet *)ss;
+- (void)observeAfterWaiting:(CFRunLoopSourceSet *)ss;
+- (void)observeExit:(CFRunLoopSourceSet *)ss;
+
+@end
+
+@interface CFRunLoopObserverCFRef : CFRunLoopObserver {
+    void *_function;
+    CFRunLoopObserverContext _context;
+    CFOptionFlags _activities;
+    uint8_t _oneshot;
+}
+
+- (void)setFunction:(void *)f;
+- (void *)function;
+
+- (Boolean)setContext:(CFRunLoopObserverContext)c;
+- (CFRunLoopObserverContext)context;
+
+- (void)setActivities:(CFOptionFlags)a;
+- (CFOptionFlags)activities;
+
+- (void)setOneshot:(Boolean)b;
+- (Boolean)oneshot;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopSourceSet : CFRunLoopObserver {
+    CFMutableBagRef _sources;
+    CFStringRef _name;
+    pthread_t _thread;
+    CFMutableArrayRef _observers[4];
+    CFRunLoopTimerSource *_timeoutTimer;
+    CFRunLoopMachPortSource *_wakeupPort;
+    uint8_t _stopped;
+    uint8_t _waiting;
+}
+
++ (void)removeSourceFromAllSets:(CFRunLoopSource *)src;
+
+- (void)setName:(CFStringRef)n;
+- (CFStringRef)name;
+
+- (void)setAffineThread:(pthread_t)t;
+- (pthread_t)affineThread;
+
+- (Boolean)containsObserver:(CFRunLoopObserver *)o;
+- (void)addObserver:(CFRunLoopObserver *)o activities:(CFRunLoopActivity)a;
+- (void)removeObserver:(CFRunLoopObserver *)o activities:(CFRunLoopActivity)a;
+
+- (Boolean)containsSource:(CFRunLoopSource *)src;
+- (void)addSource:(CFRunLoopSource *)src;
+- (void)removeSource:(CFRunLoopSource *)src;
+
+- (void)forEachSource:(Boolean (*)(CFRunLoopSource *, void *))f context:(void *)c;
+
+- (void)stop;
+- (void)wakeup;
+- (Boolean)isWaiting;
+- (Boolean)isEmpty;
+- (Boolean)hasInputAvailable;
+
+- (int32_t)serviceUntil:(CFAbsoluteTime)at handleOne:(Boolean)handleOne;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+@interface CFRunLoopCFRef : CFObject {
+    uint8_t _cfruntime_[8]; // large enough for 32-bit or 64-bit
+    pthread_t _thread;
+    void *_counterpart;
+    CFMutableArrayRef _sourceSets;
+    CFRunLoopSourceSet *_currentSet;
+    uint8_t _invalid;
+}
+
+- (void)setAffineThread:(pthread_t)t;
+- (pthread_t)affineThread;
+
+- (void)setCounterpart:(void *)c;
+- (void *)counterpart;
+
+- (void)invalidate;
+- (Boolean)isValid;
+
+- (CFArrayRef)copySourceSets;
+
+- (void)setCurrentSourceSet:(CFRunLoopSourceSet *)ss;
+- (CFRunLoopSourceSet *)currentSourceSet;
+
+- (CFRunLoopSourceSet *)lookupSourceSetWithName:(CFStringRef)n;
+- (CFRunLoopSourceSet *)lookupOrCreateSourceSetWithName:(CFStringRef)n;
+
+- (CFStringRef)copyDebugDescription;
+
+@end
+
+/* -------- -------- -------- -------- -------- -------- -------- -------- */
+
+#endif
+
diff --git a/CoreFoundation/CFRuntime.c b/CoreFoundation/CFRuntime.c
new file mode 100644
index 0000000..2aad365
--- /dev/null
+++ b/CoreFoundation/CFRuntime.c
@@ -0,0 +1,1131 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#define ENABLE_ZOMBIES 1
+
+#include "CFRuntime.h"
+#include "CFInternal.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#if DEPLOYMENT_TARGET_MACOSX
+#include <dlfcn.h>
+#include <mach-o/dyld.h>
+#include <monitor.h>
+#include <crt_externs.h>
+#include <unistd.h>
+#else
+#include <locale.h>
+#endif
+#include "auto_stubs.h"
+
+#define __CFRecordAllocationEvent(a, b, c, d, e) ((void)0)
+
+enum {
+// retain/release recording constants -- must match values
+// used by OA for now; probably will change in the future
+__kCFRetainEvent = 28,
+__kCFReleaseEvent = 29
+};
+
+#if DEPLOYMENT_TARGET_MACOSX
+#include <malloc/malloc.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <malloc.h>
+/* On Win32 we should use _msize instead of malloc_size
+ * (Aleksey Dukhnyakov)
+ */
+CF_INLINE size_t malloc_size(void* memblock) {
+    return _msize(memblock);
+}
+#endif
+
+extern void __HALT(void);
+
+static CFTypeID __kCFNotATypeTypeID = _kCFRuntimeNotATypeID;
+
+#if !defined (__cplusplus)
+static const CFRuntimeClass __CFNotATypeClass = {
+    0,
+    "Not A Type",
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT
+};
+
+static CFTypeID __kCFTypeTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFTypeClass = {
+    0,
+    "CFType",
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT,
+    (void *)__HALT
+};
+#else
+void SIG1(CFTypeRef){__HALT();};;
+CFTypeRef SIG2(CFAllocatorRef,CFTypeRef){__HALT();return NULL;};
+Boolean SIG3(CFTypeRef,CFTypeRef){__HALT();return FALSE;};
+CFHashCode SIG4(CFTypeRef){__HALT(); return 0;};
+CFStringRef SIG5(CFTypeRef,CFDictionaryRef){__HALT();return NULL;};
+CFStringRef SIG6(CFTypeRef){__HALT();return NULL;};
+
+static const CFRuntimeClass __CFNotATypeClass = {
+    0,
+    "Not A Type",
+    SIG1,
+    SIG2,
+    SIG1,
+    SIG3,
+    SIG4,
+    SIG5,
+    SIG6
+};
+
+static CFTypeID __kCFTypeTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFTypeClass = {
+    0,
+    "CFType",
+    SIG1,
+    SIG2,
+    SIG1,
+    SIG3,
+    SIG4,
+    SIG5,
+    SIG6
+};
+#endif //__cplusplus
+
+static CFRuntimeClass ** __CFRuntimeClassTable = NULL;
+int32_t __CFRuntimeClassTableSize = 0;
+static int32_t __CFRuntimeClassTableCount = 0;
+
+#if DEPLOYMENT_TARGET_MACOSX
+__private_extern__ void * (*__CFSendObjCMsg)(const void *, SEL, ...) = NULL;
+#endif
+
+__private_extern__ malloc_zone_t *__CFCollectableZone = NULL;
+
+bool (*__CFObjCIsCollectable)(void *) = NULL;
+
+static const void* objc_AssignIvar_none(const void *value, const void *base, const void **slot) { return (*slot = value); }
+const void* (*__CFObjCAssignIvar)(const void *value, const void *base, const void **slot) = objc_AssignIvar_none;
+
+static const void* objc_StrongAssign_none(const void *value, const void **slot) { return (*slot = value); }
+const void* (*__CFObjCStrongAssign)(const void *value, const void **slot) = objc_StrongAssign_none;
+
+void* (*__CFObjCMemmoveCollectable)(void *dst, const void *, size_t) = memmove;
+
+// GC: to be moved to objc if necessary.
+static void objc_WriteBarrierRange_none(void *ptr, size_t size) {}
+static void objc_WriteBarrierRange_auto(void *ptr, size_t size) { auto_zone_write_barrier_range(__CFCollectableZone, ptr, size); }
+void (*__CFObjCWriteBarrierRange)(void *, size_t) = objc_WriteBarrierRange_none;
+
+// Compiler uses this symbol name; must match compiler built-in decl
+#if __LP64__
+int __CFConstantStringClassReference[24] = {0};
+#else
+int __CFConstantStringClassReference[12] = {0};
+#endif
+
+// #warning the whole business of reallocating the ClassTables is not thread-safe, because access to those values is not protected
+
+CFTypeID _CFRuntimeRegisterClass(const CFRuntimeClass * const cls) {
+// version field must be 0
+// className must be pure ASCII string, non-null
+    if (__CFMaxRuntimeTypes <= __CFRuntimeClassTableCount) {
+	CFLog(kCFLogLevelWarning, CFSTR("*** CoreFoundation class table full; registration failing for class '%s'.  Program will crash soon."), cls->className);
+	return _kCFRuntimeNotATypeID;
+    }
+    if (__CFRuntimeClassTableSize <= __CFRuntimeClassTableCount) {
+	int32_t old_size = __CFRuntimeClassTableSize;
+	int32_t new_size = __CFRuntimeClassTableSize * 4;
+
+	void *new_table1 = calloc(new_size, sizeof(CFRuntimeClass *));
+	memmove(new_table1, __CFRuntimeClassTable, old_size * sizeof(CFRuntimeClass *));
+	__CFRuntimeClassTable = (CFRuntimeClass**)new_table1;
+	__CFRuntimeClassTableSize = new_size;
+	// The old value of __CFRuntimeClassTable is intentionally leaked
+	// for thread-safety reasons:
+	// other threads might have loaded the value of that, in functions here
+	// in this file executing in other threads, and may attempt to use it after
+	// this thread gets done reallocating here, so freeing is unsafe. We
+	// don't want to pay the expense of locking around all uses of these variables.
+	// The old value of __CFRuntimeObjCClassTable is intentionally leaked
+	// for thread-safety reasons:
+	// other threads might have loaded the value of that, since it is
+	// accessible via CFBridgingPriv.h, and may attempt to use it after
+	// this thread gets done reallocating here, so freeing is unsafe.
+    }
+    __CFRuntimeClassTable[__CFRuntimeClassTableCount++] = (CFRuntimeClass *)cls;
+    return __CFRuntimeClassTableCount - 1;
+}
+
+void _CFRuntimeBridgeClasses(CFTypeID cf_typeID, const char *objc_classname) {
+    return;
+}
+
+const CFRuntimeClass * _CFRuntimeGetClassWithTypeID(CFTypeID typeID) {
+    return __CFRuntimeClassTable[typeID];
+}
+
+void _CFRuntimeUnregisterClassWithTypeID(CFTypeID typeID) {
+    __CFRuntimeClassTable[typeID] = NULL;
+}
+
+
+#if defined(DEBUG) || defined(ENABLE_ZOMBIES)
+
+/* CFZombieLevel levels:
+ *	bit 0: scribble deallocated CF object memory
+ *	bit 1: do not scribble on CFRuntimeBase header (when bit 0)
+ *	bit 4: do not free CF objects
+ *	bit 7: use 3rd-order byte as scribble byte for dealloc (otherwise 0xFC)
+ */
+
+static uint32_t __CFZombieLevel = 0x0;
+static uint8_t __CFZombieEnabled = 0;
+static uint8_t __CFDeallocateZombies = 0;
+static void *_original_objc_dealloc = 0;
+
+#endif /* DEBUG */
+
+// XXX_PCB:  use the class version field as a bitmask, to allow classes to opt-in for GC scanning.
+
+#define CF_GET_COLLECTABLE_MEMORY_TYPE(x) (0)
+
+CFTypeRef _CFRuntimeCreateInstance(CFAllocatorRef allocator, CFTypeID typeID, CFIndex extraBytes, unsigned char *category) {
+    CFRuntimeBase *memory;
+    Boolean usesSystemDefaultAllocator;
+    CFIndex size;
+
+    CFAssert1(typeID != _kCFRuntimeNotATypeID, __kCFLogAssertion, "%s(): Uninitialized type id", __PRETTY_FUNCTION__);
+
+    //XXXBS Check __CFRuntimeClasstable for NULL before trying to access elements in it
+    if ((NULL == __CFRuntimeClassTable) || (NULL == __CFRuntimeClassTable[typeID])) {
+        return NULL;
+    }
+    allocator = (NULL == allocator) ? __CFGetDefaultAllocator() : allocator;
+    usesSystemDefaultAllocator = (allocator == kCFAllocatorSystemDefault);
+    size = sizeof(CFRuntimeBase) + extraBytes + (usesSystemDefaultAllocator ? 0 : sizeof(CFAllocatorRef));
+    size = (size + 0xF) & ~0xF;	// CF objects are multiples of 16 in size
+    // CFType version 0 objects are unscanned by default since they don't have write-barriers and hard retain their innards
+    // CFType version 1 objects are scanned and use hand coded write-barriers to store collectable storage within
+    memory = (CFRuntimeBase *)CFAllocatorAllocate(allocator, size, CF_GET_COLLECTABLE_MEMORY_TYPE(__CFRuntimeClassTable[typeID]));
+    if (NULL == memory) {
+	return NULL;
+    }
+#if DEPLOYMENT_TARGET_WINDOWS
+    // malloc_size won't work if the memory address has been moved
+    // (such as a custom allocator that adds its own metadata
+    // (e.g. under/overflow guard data), so don't attempt to call it
+    // on the allocation return.
+    size_t msize = (usesSystemDefaultAllocator) ? malloc_size(memory) : size;
+#elif DEPLOYMENT_TARGET_LINUX
+    // On Linux, across various architectures and versions of the GNU
+    // C Library, malloc_usable_size has been observed to at times return
+    // incorrect values. Since the introspection value-add it provides to
+    // CoreFoundation seems to be of limited utility, we eliminate it and
+    // simpy use the caller-requested size. In addition, memsetting this
+    // small tail block has also been found to cause heap consistency
+    // problems.
+    size_t msize = size;
+#else
+    size_t msize = malloc_size(memory);
+#endif
+    memset(memory, 0, msize);
+    if (__CFOASafe && category) {
+	__CFSetLastAllocationEventName(memory, (char *)category);
+    } else if (__CFOASafe) {
+	__CFSetLastAllocationEventName(memory, (char *)__CFRuntimeClassTable[typeID]->className);
+    }
+    if (!usesSystemDefaultAllocator) {
+        // add space to hold allocator ref for non-standard allocators.
+        // (this screws up 8 byte alignment but seems to work)
+	*(CFAllocatorRef *)((char *)memory) = (CFAllocatorRef)CFRetain(allocator);
+	memory = (CFRuntimeBase *)((char *)memory + sizeof(CFAllocatorRef));
+    }
+    memory->_cfisa = __CFISAForTypeID(typeID);
+#if __LP64__
+    *(uint32_t *)(memory->_cfinfo) = (uint32_t)((0 << 24) + ((typeID & 0xFFFF) << 8) + (usesSystemDefaultAllocator ? 0x80 : 0x00));
+    memory->_rc = 1;
+#else
+    *(uint32_t *)(memory->_cfinfo) = (uint32_t)((1 << 24) + ((typeID & 0xFFFF) << 8) + (usesSystemDefaultAllocator ? 0x80 : 0x00));
+#endif
+    if (NULL != __CFRuntimeClassTable[typeID]->init) {
+	(__CFRuntimeClassTable[typeID]->init)(memory);
+    }
+    return memory;
+}
+
+void _CFRuntimeInitStaticInstance(void *ptr, CFTypeID typeID) {
+    CFRuntimeBase *memory = (CFRuntimeBase *)ptr;
+    CFAssert1(typeID != _kCFRuntimeNotATypeID, __kCFLogAssertion, "%s(): Uninitialized type id", __PRETTY_FUNCTION__);
+    if (NULL == __CFRuntimeClassTable[typeID]) {
+	return;
+    }
+    memory->_cfisa = __CFISAForTypeID(typeID);
+    *(uint32_t *)(memory->_cfinfo) = (uint32_t)((0 << 24) + ((typeID & 0xFFFF) << 8) + 0x80);
+#if __LP64__
+    memory->_rc = 0;
+#endif
+    if (NULL != __CFRuntimeClassTable[typeID]->init) {
+	(__CFRuntimeClassTable[typeID]->init)(memory);
+    }
+}
+
+void _CFRuntimeSetInstanceTypeID(CFTypeRef cf, CFTypeID typeID) {
+    *(uint16_t *)(((CFRuntimeBase *)cf)->_cfinfo + 1) = (uint16_t)(typeID & 0xFFFF);
+}
+
+#if 0
+// BAF:  This seems to be some garbage collection magic.  Not for us mortals to look at!
+__private_extern__ Boolean __CFRuntimeIsFreedObject(id anObject) {
+   if (!anObject) return false;
+   static Class freedClass = Nil;
+   if (!freedClass) freedClass = _objc_getFreedObjectClass();
+   Class cls = object_getClass(anObject);
+   if (cls == freedClass) return true;
+   // in 64-bit, a future class has nil isa, and calling class_getName() on
+   // such will crash so we do this test; zombie classes are not future classes
+   if (objc_getClass((id)cls) == nil) return false;
+   const char *cname = class_getName(cls);
+   if (cname && 0 == strncmp(cname, "_NSZombie_", 10)) return true;
+   return false;
+}
+#endif
+
+CFTypeID __CFGenericTypeID(const void *cf) {
+    return (*(uint32_t *)(((CFRuntimeBase *)cf)->_cfinfo) >> 8) & 0xFFFF;
+}
+
+CF_INLINE CFTypeID __CFGenericTypeID_inline(const void *cf) {
+    return (*(uint32_t *)(((CFRuntimeBase *)cf)->_cfinfo) >> 8) & 0xFFFF;
+}
+
+CFTypeID CFTypeGetTypeID(void) {
+    return __kCFTypeTypeID;
+}
+
+__private_extern__ void __CFGenericValidateType_(CFTypeRef cf, CFTypeID type, const char *func) {
+    if (cf && CF_IS_OBJC(type, cf)) return;
+    CFAssert2((cf != NULL) && (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]) && (__kCFNotATypeTypeID != __CFGenericTypeID_inline(cf)) && (__kCFTypeTypeID != __CFGenericTypeID_inline(cf)), __kCFLogAssertion, "%s(): pointer %p is not a CF object", func, cf); \
+    CFAssert3(__CFGenericTypeID_inline(cf) == type, __kCFLogAssertion, "%s(): pointer %p is not a %s", func, cf, __CFRuntimeClassTable[type]->className);	\
+}
+
+#define __CFGenericAssertIsCF(cf) \
+    CFAssert2(cf != NULL && (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]) && (__kCFNotATypeTypeID != __CFGenericTypeID_inline(cf)) && (__kCFTypeTypeID != __CFGenericTypeID_inline(cf)), __kCFLogAssertion, "%s(): pointer %p is not a CF object", __PRETTY_FUNCTION__, cf);
+
+#define CFTYPE_IS_OBJC(obj) (false)
+#define CFTYPE_OBJC_FUNCDISPATCH0(rettype, obj, sel) do {} while (0)
+#define CFTYPE_OBJC_FUNCDISPATCH1(rettype, obj, sel, a1) do {} while (0)
+
+CFTypeID CFGetTypeID(CFTypeRef cf) {
+#if defined(DEBUG)
+    if (NULL == cf) HALT;
+#endif
+    CFTYPE_OBJC_FUNCDISPATCH0(CFTypeID, cf, "_cfTypeID");
+    __CFGenericAssertIsCF(cf);
+    return __CFGenericTypeID_inline(cf);
+}
+
+CFStringRef CFCopyTypeIDDescription(CFTypeID type) {
+    CFAssert2((NULL != __CFRuntimeClassTable[type]) && __kCFNotATypeTypeID != type && __kCFTypeTypeID != type, __kCFLogAssertion, "%s(): type %d is not a CF type ID", __PRETTY_FUNCTION__, type);
+    return CFStringCreateWithCString(kCFAllocatorSystemDefault, __CFRuntimeClassTable[type]->className, kCFStringEncodingASCII);
+}
+
+#define DISGUISE(object)       ((void *)(((uintptr_t)object) + 1))
+#define UNDISGUISE(disguised)  ((id)(((uintptr_t)disguised) - 1))
+
+// Bit 31 (highest bit) in second word of cf instance indicates external ref count
+
+CF_EXPORT void _CFRelease(CFTypeRef cf);
+CF_EXPORT CFTypeRef _CFRetain(CFTypeRef cf);
+CF_EXPORT CFHashCode _CFHash(CFTypeRef cf);
+
+CFTypeRef CFRetain(CFTypeRef cf) {
+    if (CF_IS_COLLECTABLE(cf)) {
+        // always honor CFRetain's with a GC-visible retain.
+        auto_zone_retain(__CFCollectableZone, (void*)cf);
+        return cf;
+    }
+    CFTYPE_OBJC_FUNCDISPATCH0(CFTypeRef, cf, "retain");
+    if (cf) __CFGenericAssertIsCF(cf);
+    return _CFRetain(cf);
+}
+
+__private_extern__ void __CFAllocatorDeallocate(CFTypeRef cf);
+
+void CFRelease(CFTypeRef cf) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+    if (CF_IS_COLLECTABLE(cf)) {
+        // release the GC-visible reference.
+        if (auto_zone_release(__CFCollectableZone, (void*)cf) == 0 && !CFTYPE_IS_OBJC(cf)) {
+            CFRuntimeClass *cfClass = __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)];
+            if (cfClass->version & _kCFRuntimeResourcefulObject) {
+                if (cfClass->reclaim) cfClass->reclaim(cf);
+            }
+        }
+        return;
+    }
+#endif
+    CFTYPE_OBJC_FUNCDISPATCH0(void, cf, "release");
+    if (cf) __CFGenericAssertIsCF(cf);
+    _CFRelease(cf);
+}
+
+
+__private_extern__ const void *__CFStringCollectionCopy(CFAllocatorRef allocator, const void *ptr) {
+    CFStringRef theString = (CFStringRef)ptr;
+    CFStringRef result = CFStringCreateCopy(allocator, theString);
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        result = (CFStringRef)CFMakeCollectable(result);
+    }
+    return (const void *)result;
+}
+
+extern void CFCollection_non_gc_storage_error(void);
+
+__private_extern__ const void *__CFTypeCollectionRetain(CFAllocatorRef allocator, const void *ptr) {
+    CFTypeRef cf = (CFTypeRef)ptr;
+    // only collections allocated in the GC zone can opt-out of reference counting.
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        if (CFTYPE_IS_OBJC(cf)) return cf;  // do nothing for OBJC objects.
+        if (auto_zone_is_valid_pointer(__CFCollectableZone, ptr)) {
+            CFRuntimeClass *cfClass = __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)];
+            if (cfClass->version & _kCFRuntimeResourcefulObject) {
+                // GC: If this a CF object in the GC heap that is marked resourceful, then
+                // it must be retained keep it alive in a CF collection.
+                // We're basically inlining CFRetain() here, to avoid an extra heap membership test.
+                auto_zone_retain(__CFCollectableZone, (void*)cf);
+            }
+            else
+                ;   // don't retain normal CF objects
+            return cf;
+        } else {
+            // support constant CFTypeRef objects.
+#if __LP64__
+            uint32_t lowBits = ((CFRuntimeBase *)cf)->_rc;
+#else
+            uint32_t lowBits = ((CFRuntimeBase *)cf)->_cfinfo[CF_RC_BITS];
+#endif
+            if (lowBits == 0) return cf;
+            // complain about non-GC objects in GC containers.
+            CFLog(kCFLogLevelWarning, CFSTR("storing a non-GC object %p in a GC collection, break on CFCollection_non_gc_storage_error to debug."), cf);
+            CFCollection_non_gc_storage_error();
+            // XXX should halt, except Patrick is using this somewhere.
+            // HALT;
+        }
+    }
+    return CFRetain(cf);
+}
+
+
+__private_extern__ void __CFTypeCollectionRelease(CFAllocatorRef allocator, const void *ptr) {
+    CFTypeRef cf = (CFTypeRef)ptr;
+    // only collections allocated in the GC zone can opt-out of reference counting.
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        if (CFTYPE_IS_OBJC(cf)) return; // do nothing for OBJC objects.
+        if (auto_zone_is_valid_pointer(__CFCollectableZone, cf)) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+            // GC: If this a CF object in the GC heap that is marked uncollectable, then
+            // must balance the retain done in __CFTypeCollectionRetain().
+            // We're basically inlining CFRelease() here, to avoid an extra heap membership test.
+            CFRuntimeClass *cfClass = __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)];
+            if (cfClass->version & _kCFRuntimeResourcefulObject && auto_zone_release(__CFCollectableZone, (void*)cf) == 0) {
+                // ResourceFull objects trigger 'reclaim' on transition to zero
+                if (cfClass->reclaim) cfClass->reclaim(cf);
+            }
+            else // avoid releasing normal CF objects.  Like other collections, for example
+                ;
+            return;
+#endif
+        } else {
+            // support constant CFTypeRef objects.
+#if __LP64__
+            uint32_t lowBits = ((CFRuntimeBase *)cf)->_rc;
+#else
+            uint32_t lowBits = ((CFRuntimeBase *)cf)->_cfinfo[CF_RC_BITS];
+#endif
+            if (lowBits == 0) return;
+        }
+    }
+    CFRelease(cf);
+}
+
+#if !__LP64__
+static CFSpinLock_t __CFRuntimeExternRefCountTableLock = CFSpinLockInit;
+static CFMutableBagRef __CFRuntimeExternRefCountTable = NULL;
+#endif
+
+static uint64_t __CFGetFullRetainCount(CFTypeRef cf) {
+#if __LP64__
+    uint32_t lowBits = ((CFRuntimeBase *)cf)->_rc;
+    if (0 == lowBits) {
+        return (uint64_t)0x0fffffffffffffffULL;
+    }
+    return lowBits;
+#else
+    uint32_t lowBits = ((CFRuntimeBase *)cf)->_cfinfo[CF_RC_BITS];
+    if (0 == lowBits) {
+        return (uint64_t)0x0fffffffffffffffULL;
+    }
+    uint64_t highBits = 0;
+    if ((lowBits & 0x80) != 0) {
+	__CFSpinLock(&__CFRuntimeExternRefCountTableLock);
+	highBits = (uint64_t)CFBagGetCountOfValue(__CFRuntimeExternRefCountTable, DISGUISE(cf));
+	__CFSpinUnlock(&__CFRuntimeExternRefCountTableLock);
+    }
+    uint64_t compositeRC = (lowBits & 0x7f) + (highBits << 6);
+    return compositeRC;
+#endif
+}
+
+CFTypeRef _CFRetainGC(CFTypeRef cf) {
+#if defined(DEBUG)
+    if (CF_USING_COLLECTABLE_MEMORY && !CF_IS_COLLECTABLE(cf)) {
+        fprintf(stderr, "non-auto object %p passed to _CFRetainGC.\n", cf);
+        HALT;
+    }
+#endif
+    return CF_USING_COLLECTABLE_MEMORY ? cf : CFRetain(cf);
+}
+
+void _CFReleaseGC(CFTypeRef cf) {
+#if defined(DEBUG)
+    if (CF_USING_COLLECTABLE_MEMORY && !CF_IS_COLLECTABLE(cf)) {
+        fprintf(stderr, "non-auto object %p passed to _CFReleaseGC.\n", cf);
+        HALT;
+    }
+#endif
+    if (!CF_USING_COLLECTABLE_MEMORY) CFRelease(cf);
+}
+
+CFIndex CFGetRetainCount(CFTypeRef cf) {
+    if (NULL == cf) return 0;
+    if (CF_IS_COLLECTABLE(cf)) {
+        return auto_zone_retain_count(__CFCollectableZone, cf);
+    }
+    CFTYPE_OBJC_FUNCDISPATCH0(CFIndex, cf, "retainCount");
+    __CFGenericAssertIsCF(cf);
+    uint64_t rc = __CFGetFullRetainCount(cf);
+    return (rc < (uint64_t)LONG_MAX) ? (CFIndex)rc : (CFIndex)LONG_MAX;
+}
+
+CFTypeRef CFMakeCollectable(CFTypeRef cf) {
+    if (NULL == cf) return NULL;
+    if (CF_IS_COLLECTABLE(cf)) {
+#if defined(DEBUG)
+        CFAllocatorRef allocator = CFGetAllocator(cf);
+        if (!CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+            CFLog(kCFLogLevelWarning, CFSTR("object %p with non-GC allocator %p passed to CFMakeCollectable."), cf, allocator);
+            HALT;
+        }
+#endif
+        if (!CFTYPE_IS_OBJC(cf)) {
+            CFRuntimeClass *cfClass = __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)];
+            if (cfClass->version & (_kCFRuntimeResourcefulObject)) {
+                // don't allow the collector to manage uncollectable objects.
+                CFLog(kCFLogLevelWarning, CFSTR("uncollectable object %p passed to CFMakeCollectable."), cf);
+                HALT;
+            }
+        }
+        if (auto_zone_retain_count(__CFCollectableZone, cf) == 0) {
+            CFLog(kCFLogLevelWarning, CFSTR("object %p with 0 retain-count passed to CFMakeCollectable."), cf);
+            return cf;
+        }
+        auto_zone_release(__CFCollectableZone, (void *)cf);
+    }
+    return cf;
+}
+
+Boolean CFEqual(CFTypeRef cf1, CFTypeRef cf2) {
+#if defined(DEBUG)
+    if (NULL == cf1) HALT;
+    if (NULL == cf2) HALT;
+#endif
+    if (cf1 == cf2) return true;
+    CFTYPE_OBJC_FUNCDISPATCH1(Boolean, cf1, "isEqual:", cf2);
+    CFTYPE_OBJC_FUNCDISPATCH1(Boolean, cf2, "isEqual:", cf1);
+    __CFGenericAssertIsCF(cf1);
+    __CFGenericAssertIsCF(cf2);
+    if (__CFGenericTypeID_inline(cf1) != __CFGenericTypeID_inline(cf2)) return false;
+    if (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf1)]->equal) {
+	return __CFRuntimeClassTable[__CFGenericTypeID_inline(cf1)]->equal(cf1, cf2);
+    }
+    return false;
+}
+
+CFHashCode CFHash(CFTypeRef cf) {
+    CFTYPE_OBJC_FUNCDISPATCH0(CFHashCode, cf, "hash");
+    __CFGenericAssertIsCF(cf);
+    return _CFHash(cf);
+}
+
+// definition: produces a normally non-NULL debugging description of the object
+CFStringRef CFCopyDescription(CFTypeRef cf) {
+#if defined(DEBUG)
+    if (NULL == cf) HALT;
+#endif
+    __CFGenericAssertIsCF(cf);
+    if (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyDebugDesc) {
+	CFStringRef result;
+	result = __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyDebugDesc(cf);
+	if (NULL != result) return result;
+    }
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<%s %p [%p]>"), __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->className, cf, CFGetAllocator(cf));
+}
+
+// Definition: if type produces a formatting description, return that string, otherwise NULL
+__private_extern__ CFStringRef __CFCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+#if defined(DEBUG)
+    if (NULL == cf) HALT;
+#endif
+    __CFGenericAssertIsCF(cf);
+    if (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyFormattingDesc) {
+	return __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyFormattingDesc(cf, formatOptions);
+    }
+    return NULL;
+}
+
+extern CFAllocatorRef __CFAllocatorGetAllocator(CFTypeRef);
+
+CFAllocatorRef CFGetAllocator(CFTypeRef cf) {
+    if (NULL == cf) return kCFAllocatorSystemDefault;
+    if (__kCFAllocatorTypeID_CONST == __CFGenericTypeID_inline(cf)) {
+	return __CFAllocatorGetAllocator(cf);
+    }
+    return __CFGetAllocator(cf);
+}
+
+extern void __CFBaseInitialize(void);
+extern void __CFNullInitialize(void);
+extern void __CFAllocatorInitialize(void);
+extern void __CFStringInitialize(void);
+extern void __CFArrayInitialize(void);
+extern void __CFBagInitialize(void);
+extern void __CFBooleanInitialize(void);
+extern void __CFCharacterSetInitialize(void);
+extern void __CFLocaleInitialize(void);
+#if DEPLOYMENT_TARGET_WINDOWS
+extern CFStringRef __CFLocaleWindowsLCIDToISOLocaleNameUsingHyphen(LCID id);
+#endif
+extern void __CFDataInitialize(void);
+extern void __CFDateInitialize(void);
+extern void __CFDictionaryInitialize(void);
+extern void __CFNumberInitialize(void);
+extern void __CFSetInitialize(void);
+extern void __CFStorageInitialize(void);
+extern void __CFErrorInitialize(void);
+extern void __CFTimeZoneInitialize(void);
+extern void __CFTreeInitialize(void);
+extern void __CFURLInitialize(void);
+#if DEPLOYMENT_TARGET_MACOSX
+extern void __CFMachPortInitialize(void);
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+extern void __CFMessagePortInitialize(void);
+#endif
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS
+extern void __CFRunLoopInitialize(void);
+extern void __CFRunLoopObserverInitialize(void);
+extern void __CFRunLoopSourceInitialize(void);
+extern void __CFRunLoopTimerInitialize(void);
+extern void __CFSocketInitialize(void);
+#endif
+extern void __CFBundleInitialize(void);
+extern void __CFPlugInInitialize(void);
+extern void __CFPlugInInstanceInitialize(void);
+extern void __CFUUIDInitialize(void);
+extern void __CFBinaryHeapInitialize(void);
+extern void __CFBitVectorInitialize(void);
+#if DEPLOYMENT_TARGET_WINDOWS
+extern void __CFWindowsMessageQueueInitialize(void);
+extern void __CFBaseCleanup(void);
+#endif
+extern void __CFStreamInitialize(void);
+extern void __CFPreferencesDomainInitialize(void);
+extern void __CFUserNotificationInitialize(void);
+
+#if DEPLOYMENT_TARGET_MACOSX
+static void __exceptionInit(void) {}
+static void __collatorInit(void) {}
+static void __forwarding_prep_0___(void) {}
+static void __forwarding_prep_1___(void) {}
+static void __NSFastEnumerationMutationHandler(id obj) {}
+#endif
+const void *__CFArgStuff = NULL;
+__private_extern__ void *__CFAppleLanguages = NULL;
+
+bool kCFUseCollectableAllocator = false;
+
+
+#if DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+static void __CFInitialize(void) __attribute__ ((constructor));
+static
+#elif DEPLOYMENT_TARGET_WINDOWS
+CF_EXPORT
+#endif
+void __CFInitialize(void) {
+    static int __done = 0;
+
+    if (!__done) {
+        __done = 1;
+
+#if defined(DEBUG) || defined(ENABLE_ZOMBIES)
+	const char *value = getenv("NSZombieEnabled");
+	if (value && (*value == 'Y' || *value == 'y')) __CFZombieEnabled = 0xff;
+	value = getenv("NSDeallocateZombies");
+	if (value && (*value == 'Y' || *value == 'y')) __CFDeallocateZombies = 0xff;
+
+	value = getenv("CFZombieLevel");
+	if (NULL != value) {
+#if DEPLOYMENT_TARGET_MACOSX
+	    __CFZombieLevel = (uint32_t)strtoul_l(value, NULL, 0, NULL);
+#else
+	    __CFZombieLevel = (uint32_t)strtoul(value, NULL, 0);
+#endif
+	}
+	if (0x0 == __CFZombieLevel) __CFZombieLevel = 0x0000FC00; // default
+#endif
+
+        __CFRuntimeClassTableSize = 1024;
+        __CFRuntimeClassTable = (CFRuntimeClass **)calloc(__CFRuntimeClassTableSize, sizeof(CFRuntimeClass *));
+        __CFBaseInitialize();
+
+        /* Here so that two runtime classes get indices 0, 1. */
+        __kCFNotATypeTypeID = _CFRuntimeRegisterClass(&__CFNotATypeClass);
+        __kCFTypeTypeID = _CFRuntimeRegisterClass(&__CFTypeClass);
+
+        /* Here so that __kCFAllocatorTypeID gets index 2. */
+        __CFAllocatorInitialize();
+
+#if DEPLOYMENT_TARGET_MACOSX
+        {
+            CFIndex idx, cnt;
+            char **args = *_NSGetArgv();
+            cnt = *_NSGetArgc();
+            for (idx = 1; idx < cnt - 1; idx++) {
+                if (NULL == args[idx]) continue;
+                if (0 == strcmp(args[idx], "-AppleLanguages") && args[idx + 1]) {
+                    CFIndex length = strlen(args[idx + 1]);
+                    __CFAppleLanguages = malloc(length + 1);
+                    memmove(__CFAppleLanguages, args[idx + 1], length + 1);
+                    break;
+                }
+            }
+        }
+#endif
+
+
+        /* CFBag needs to be up before CFString. */
+        __CFBagInitialize();
+
+#if !__LP64__
+        // Creating this lazily in CFRetain causes recursive call to CFRetain
+        __CFRuntimeExternRefCountTable = CFBagCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+#endif
+
+        /*** _CFRuntimeCreateInstance() can finally be called generally after this line. ***/
+
+        __CFRuntimeClassTableCount = 7;
+        __CFStringInitialize();		// CFString's TypeID must be 0x7, now and forever
+        __CFRuntimeClassTableCount = 16;
+        __CFDictionaryInitialize();
+        __CFArrayInitialize();
+        __CFDataInitialize();
+        __CFSetInitialize();
+        __CFNullInitialize();		// See above for hard-coding of this position
+        __CFBooleanInitialize();	// See above for hard-coding of this position
+        __CFNumberInitialize();		// See above for hard-coding of this position
+
+
+        __CFDateInitialize();	// just initializes the time goo
+//	_CFRuntimeBridgeClasses(CFDateGetTypeID(), objc_lookUpClass("NSCFDate") ? "NSCFDate" : "__NSCFDate");
+        __CFTimeZoneInitialize();
+//	_CFRuntimeBridgeClasses(CFTimeZoneGetTypeID(), "NSCFTimeZone");
+        __CFBinaryHeapInitialize();
+        __CFBitVectorInitialize();
+        __CFCharacterSetInitialize();
+#if DEPLOYMENT_TARGET_WINDOWS
+        __CFLocaleInitialize();
+#endif
+        __CFStorageInitialize();
+        __CFErrorInitialize();
+        __CFTreeInitialize();
+        __CFURLInitialize();
+        __CFBundleInitialize();
+#if DEPLOYMENT_TARGET_MACOSX
+        __CFPlugInInitialize();
+        __CFPlugInInstanceInitialize();
+#endif //__MACH__
+        __CFUUIDInitialize();
+#if DEPLOYMENT_TARGET_MACOSX
+        __CFMessagePortInitialize();
+        __CFMachPortInitialize();
+#endif
+        __CFStreamInitialize();
+        __CFPreferencesDomainInitialize();
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+        __CFRunLoopInitialize();
+        __CFRunLoopObserverInitialize();
+        __CFRunLoopSourceInitialize();
+        __CFRunLoopTimerInitialize();
+        __CFSocketInitialize();
+#endif
+
+
+#if DEPLOYMENT_TARGET_MACOSX
+        {
+            CFIndex idx, cnt;
+            char **args;
+            args = *_NSGetArgv();
+            cnt = *_NSGetArgc();
+            CFIndex count;
+            CFStringRef *list, buffer[256];
+            list = (cnt <= 256) ? (CFStringRef*)buffer : (CFStringRef*)malloc(cnt * sizeof(CFStringRef));
+            for (idx = 0, count = 0; idx < cnt; idx++) {
+                if (NULL == args[idx]) continue;
+                list[count] = CFStringCreateWithCString(kCFAllocatorSystemDefault, args[idx], kCFStringEncodingUTF8);
+                if (NULL == list[count]) {
+                    list[count] = CFStringCreateWithCString(kCFAllocatorSystemDefault, args[idx], kCFStringEncodingISOLatin1);
+                    // We CANNOT use the string SystemEncoding here;
+                    // Do not argue: it is not initialized yet, but these
+                    // arguments MUST be initialized before it is.
+                    // We should just ignore the argument if the UTF-8
+                    // conversion fails, but out of charity we try once
+                    // more with ISO Latin1, a standard unix encoding.
+                }
+                if (NULL != list[count]) count++;
+            }
+            __CFArgStuff = CFArrayCreate(kCFAllocatorSystemDefault, (const void **)list, count, &kCFTypeArrayCallBacks);
+        }
+#endif
+        _CFProcessPath();	// cache this early
+
+        if (__CFRuntimeClassTableCount < 256) __CFRuntimeClassTableCount = 256;
+
+#if defined(DEBUG) && !DEPLOYMENT_TARGET_WINDOWS
+        CFLog(kCFLogLevelWarning, CFSTR("Assertions enabled"));
+#endif
+    }
+}
+
+#ifdef _BUILD_NET_FOUNDATION_
+#ifdef __cplusplus
+extern "C"{
+#endif //C++
+extern void _CFFTPCleanup(void);
+extern void _CFHTTPMessageCleanup(void);
+extern void _CFHTTPStreamCleanup(void);
+#ifdef __cplusplus
+}
+#endif //C++
+
+#endif //_BUILD_NET_FOUNDATION_
+
+#if DEPLOYMENT_TARGET_WINDOWS
+
+extern void __CFBaseCleanup (void);
+extern void __CFSocketCleanup (void);
+extern void __CFStreamCleanup (void);
+extern void __CFStringCleanup (void);
+extern void __CFUniCharCleanup (void);
+
+/* We have to call __CFInitialize when library is attached to the process.
+ * (Sergey Zubarev)
+ */
+#if defined(_BUILD_NET_FOUNDATION_)
+extern "C" {
+BOOL WINAPI CoreFoundationDllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID pReserved );
+}
+
+BOOL WINAPI CoreFoundationDllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID pReserved ) {
+#else
+BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID pReserved ) {
+#endif
+    static CFBundleRef cfBundle = NULL;
+    if (dwReason == DLL_PROCESS_ATTACH) {
+        __CFInitialize();
+        //cfBundle = RegisterCoreFoundationBundle(); -- Not in sources!
+    } else if (dwReason == DLL_PROCESS_DETACH) {
+        if (cfBundle) CFRelease(cfBundle);
+        __CFStringCleanup();
+        __CFSocketCleanup();
+        __CFUniCharCleanup();
+        __CFStreamCleanup();
+        __CFBaseCleanup();
+    } else if (dwReason == DLL_THREAD_DETACH) {
+        __CFFinalizeThreadData(NULL);
+    }
+    return TRUE;
+}
+
+#endif
+
+// Functions that avoid ObC dispatch and CF type validation, for use by NSNotifyingCFArray, etc.
+// Hopefully all of this will just go away.  3321464.  M.P. To Do - 7/9/03
+
+Boolean _CFEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    if (cf1 == cf2) return true;
+    if (NULL == cf1) return false;
+    if (NULL == cf2) return false;
+    __CFGenericAssertIsCF(cf1);
+    __CFGenericAssertIsCF(cf2);
+    if (__CFGenericTypeID_inline(cf1) != __CFGenericTypeID_inline(cf2)) return false;
+    if (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf1)]->equal) {
+	return __CFRuntimeClassTable[__CFGenericTypeID_inline(cf1)]->equal(cf1, cf2);
+    }
+    return false;
+}
+
+CFIndex _CFGetRetainCount(CFTypeRef cf) {
+    if (NULL == cf) return 0;
+    if (CF_IS_COLLECTABLE(cf)) {
+        return auto_zone_retain_count(__CFCollectableZone, cf);
+    }
+    uint64_t rc = __CFGetFullRetainCount(cf);
+    return (rc < (uint64_t)LONG_MAX) ? (CFIndex)rc : (CFIndex)LONG_MAX;
+}
+
+CFHashCode _CFHash(CFTypeRef cf) {
+    if (NULL == cf) return 0;
+    if (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->hash) {
+	return __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->hash(cf);
+    }
+    return (CFHashCode)cf;
+}
+
+CF_EXPORT CFTypeRef _CFRetain(CFTypeRef cf) {
+    if (NULL == cf) return NULL;
+#if __LP64__
+    uint32_t lowBits;
+    do {
+	lowBits = ((CFRuntimeBase *)cf)->_rc;
+	if (0 == lowBits) return cf;	// Constant CFTypeRef
+    } while (!_CFAtomicCompareAndSwap32Barrier(lowBits, lowBits + 1, (int32_t *)&((CFRuntimeBase *)cf)->_rc));
+#else
+#define RC_START 24
+#define RC_END 31
+    volatile UInt32 *infoLocation = (UInt32 *)&(((CFRuntimeBase *)cf)->_cfinfo);
+    CFIndex rcLowBits = __CFBitfieldGetValue(*infoLocation, RC_END, RC_START);
+    if (__builtin_expect(0 == rcLowBits, 0)) return cf;	// Constant CFTypeRef
+    bool success = 0;
+    do {
+        UInt32 initialCheckInfo = *infoLocation;
+        UInt32 prospectiveNewInfo = initialCheckInfo; // don't want compiler to generate prospectiveNewInfo = *infoLocation.  This is why infoLocation is declared as a pointer to volatile memory.
+        prospectiveNewInfo += (1 << RC_START);
+        rcLowBits = __CFBitfieldGetValue(prospectiveNewInfo, RC_END, RC_START);
+        if (__builtin_expect((rcLowBits & 0x7f) == 0, 0)) {
+            /* Roll over another bit to the external ref count
+             Real ref count = low 7 bits of info[CF_RC_BITS]  + external ref count << 6
+             Bit 8 of low bits indicates that external ref count is in use.
+             External ref count is shifted by 6 rather than 7 so that we can set the low
+		bits to to 1100 0000 rather than 1000 0000.
+		This prevents needing to access the external ref count for successive retains and releases
+		when the composite retain count is right around a multiple of 1 << 7.
+             */
+            prospectiveNewInfo = initialCheckInfo;
+            __CFBitfieldSetValue(prospectiveNewInfo, RC_END, RC_START, ((1 << 7) | (1 << 6)));
+            __CFSpinLock(&__CFRuntimeExternRefCountTableLock);
+            success = _CFAtomicCompareAndSwap32Barrier(*(int32_t *)&initialCheckInfo, *(int32_t *)&prospectiveNewInfo, (int32_t *)infoLocation);
+            if (__builtin_expect(success, 1)) {
+                CFBagAddValue(__CFRuntimeExternRefCountTable, DISGUISE(cf));
+            }
+            __CFSpinUnlock(&__CFRuntimeExternRefCountTableLock);
+        } else {
+            success = _CFAtomicCompareAndSwap32Barrier(*(int32_t *)&initialCheckInfo, *(int32_t *)&prospectiveNewInfo, (int32_t *)infoLocation);
+        }
+    } while (__builtin_expect(!success, 0));
+#endif
+    if (__builtin_expect(__CFOASafe, 0)) {
+	__CFRecordAllocationEvent(__kCFRetainEvent, (void *)cf, 0, _CFGetRetainCount(cf), NULL);
+    }
+    return cf;
+}
+
+CF_EXPORT void _CFRelease(CFTypeRef cf) {
+    Boolean isAllocator = false;
+#if __LP64__
+    uint32_t lowBits;
+    do {
+	lowBits = ((CFRuntimeBase *)cf)->_rc;
+	if (0 == lowBits) return;	// Constant CFTypeRef
+	if (1 == lowBits) {
+	    // CANNOT WRITE ANY NEW VALUE INTO [CF_RC_BITS] UNTIL AFTER FINALIZATION
+	    CFTypeID typeID = __CFGenericTypeID_inline(cf);
+	    isAllocator = (__kCFAllocatorTypeID_CONST == typeID);
+            CFRuntimeClass *cfClass = __CFRuntimeClassTable[typeID];
+            if (cfClass->version & _kCFRuntimeResourcefulObject && cfClass->reclaim != NULL) {
+                cfClass->reclaim(cf);
+            }
+            void (*func)(CFTypeRef) = __CFRuntimeClassTable[typeID]->finalize;
+	    if (NULL != func) {
+		func(cf);
+	    }
+	    // We recheck lowBits to see if the object has been retained again during
+	    // the finalization process.  This allows for the finalizer to resurrect,
+	    // but the main point is to allow finalizers to be able to manage the
+	    // removal of objects from uniquing caches, which may race with other threads
+	    // which are allocating (looking up and finding) objects from those caches,
+	    // which (that thread) would be the thing doing the extra retain in that case.
+	    if (isAllocator || _CFAtomicCompareAndSwap32Barrier(1, 0, (int32_t *)&((CFRuntimeBase *)cf)->_rc)) {
+		goto really_free;
+	    }
+	}
+    } while (!_CFAtomicCompareAndSwap32Barrier(lowBits, lowBits - 1, (int32_t *)&((CFRuntimeBase *)cf)->_rc));
+#else
+    volatile UInt32 *infoLocation = (UInt32 *)&(((CFRuntimeBase *)cf)->_cfinfo);
+    CFIndex rcLowBits = __CFBitfieldGetValue(*infoLocation, RC_END, RC_START);
+    if (__builtin_expect(0 == rcLowBits, 0)) return;        // Constant CFTypeRef
+    bool success = 0;
+    do {
+        UInt32 initialCheckInfo = *infoLocation;
+        rcLowBits = __CFBitfieldGetValue(initialCheckInfo, RC_END, RC_START);
+        if (__builtin_expect(1 == rcLowBits, 0)) {
+            // we think cf should be deallocated
+            if (__builtin_expect(__kCFAllocatorTypeID_CONST == __CFGenericTypeID_inline(cf), 0)) {
+                if (__builtin_expect(__CFOASafe, 0)) __CFRecordAllocationEvent(__kCFReleaseEvent, (void *)cf, 0, 0, NULL);
+               __CFAllocatorDeallocate((void *)cf);
+                success = 1;
+            } else {
+                // CANNOT WRITE ANY NEW VALUE INTO [CF_RC_BITS] UNTIL AFTER FINALIZATION
+                CFTypeID typeID = __CFGenericTypeID_inline(cf);
+                CFRuntimeClass *cfClass = __CFRuntimeClassTable[typeID];
+                if (cfClass->version & _kCFRuntimeResourcefulObject && cfClass->reclaim != NULL) {
+                    cfClass->reclaim(cf);
+                }
+                if (NULL != __CFRuntimeClassTable[typeID]->finalize) {
+                    __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->finalize(cf);
+                }
+                // We recheck rcLowBits to see if the object has been retained again during
+                // the finalization process.  This allows for the finalizer to resurrect,
+                // but the main point is to allow finalizers to be able to manage the
+                // removal of objects from uniquing caches, which may race with other threads
+                // which are allocating (looking up and finding) objects from those caches,
+                // which (that thread) would be the thing doing the extra retain in that case.
+                rcLowBits = __CFBitfieldGetValue(*infoLocation, RC_END, RC_START);
+                success = (1 == rcLowBits);
+                if (__builtin_expect(success, 1)) {
+                    goto really_free;
+                }
+            }
+        } else {
+            // not yet junk
+            UInt32 prospectiveNewInfo = initialCheckInfo; // don't want compiler to generate prospectiveNewInfo = *infoLocation.  This is why infoLocation is declared as a pointer to volatile memory.
+            if (__builtin_expect((1 << 7) == rcLowBits, 0)) {
+                // Time to remove a bit from the external ref count
+                __CFSpinLock(&__CFRuntimeExternRefCountTableLock);
+                CFIndex rcHighBitsCnt = CFBagGetCountOfValue(__CFRuntimeExternRefCountTable, DISGUISE(cf));
+                if (1 == rcHighBitsCnt) {
+                    __CFBitfieldSetValue(prospectiveNewInfo, RC_END, RC_START, (1 << 6) - 1);
+                } else {
+                    __CFBitfieldSetValue(prospectiveNewInfo, RC_END, RC_START, ((1 << 6) | (1 << 7)) - 1);
+                }
+                success = _CFAtomicCompareAndSwap32Barrier(*(int32_t *)&initialCheckInfo, *(int32_t *)&prospectiveNewInfo, (int32_t *)infoLocation);
+                if (__builtin_expect(success, 1)) {
+                    CFBagRemoveValue(__CFRuntimeExternRefCountTable, DISGUISE(cf));
+                }
+                __CFSpinUnlock(&__CFRuntimeExternRefCountTableLock);
+            } else {
+                prospectiveNewInfo -= (1 << RC_START);
+                success = _CFAtomicCompareAndSwap32Barrier(*(int32_t *)&initialCheckInfo, *(int32_t *)&prospectiveNewInfo, (int32_t *)infoLocation);
+            }
+        }
+    } while (__builtin_expect(!success, 0));
+
+#endif
+    if (__builtin_expect(__CFOASafe, 0)) {
+	__CFRecordAllocationEvent(__kCFReleaseEvent, (void *)cf, 0, _CFGetRetainCount(cf), NULL);
+    }
+    return;
+
+    really_free:;
+    if (__builtin_expect(__CFOASafe, 0)) {
+	// do not use _CFGetRetainCount() because cf has been freed if it was an allocator
+	__CFRecordAllocationEvent(__kCFReleaseEvent, (void *)cf, 0, 0, NULL);
+    }
+    // cannot zombify allocators, which get deallocated by __CFAllocatorDeallocate (finalize)
+    if (!isAllocator) {
+	CFAllocatorRef allocator;
+	Boolean usesSystemDefaultAllocator;
+
+	if (__CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 7, 7)) {
+	    allocator = kCFAllocatorSystemDefault;
+	} else {
+	    allocator = CFGetAllocator(cf);
+	}
+	usesSystemDefaultAllocator = (allocator == kCFAllocatorSystemDefault);
+
+	if (__CFZombieLevel & (1 << 0)) {
+#if !DEPLOYMENT_TARGET_LINUX
+	    uint8_t *ptr = (uint8_t *)cf - (usesSystemDefaultAllocator ? 0 : sizeof(CFAllocatorRef));
+	    size_t size = malloc_size(ptr);
+	    uint8_t byte = 0xFC;
+	    if (__CFZombieLevel & (1 << 1)) {
+		ptr = (uint8_t *)cf + sizeof(CFRuntimeBase);
+		size = size - sizeof(CFRuntimeBase) - (usesSystemDefaultAllocator ? 0 : sizeof(CFAllocatorRef));
+	    }
+	    if (__CFZombieLevel & (1 << 7)) {
+		byte = (__CFZombieLevel >> 8) & 0xFF;
+	    }
+	    memset(ptr, byte, size);
+#endif /* !DEPLOYMENT_TARGET_LINUX */
+	}
+	if (!(__CFZombieLevel & (1 << 4))) {
+	    CFAllocatorDeallocate(allocator, (uint8_t *)cf - (usesSystemDefaultAllocator ? 0 : sizeof(CFAllocatorRef)));
+	}
+	
+	if (kCFAllocatorSystemDefault != allocator) {
+	    CFRelease(allocator);
+	}
+    }
+}
+
+#undef __kCFAllocatorTypeID_CONST
+#undef __CFGenericAssertIsCF
+
diff --git a/CoreFoundation/CFRuntime.h b/CoreFoundation/CFRuntime.h
new file mode 100644
index 0000000..d81d656
--- /dev/null
+++ b/CoreFoundation/CFRuntime.h
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFRUNTIME__)
+#define __COREFOUNDATION_CFRUNTIME__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <stddef.h>
+
+CF_EXTERN_C_BEGIN
+
+// GC: until we link against ObjC must use indirect functions.  Overridden in CFSetupFoundationBridging
+extern bool kCFUseCollectableAllocator;
+extern bool (*__CFObjCIsCollectable)(void *);
+extern const void* (*__CFObjCAssignIvar)(const void *value, const void *base, const void **slot);
+extern const void* (*__CFObjCStrongAssign)(const void *value, const void **slot);
+extern void* (*__CFObjCMemmoveCollectable)(void *dest, const void *src, size_t);
+extern void (*__CFObjCWriteBarrierRange)(void *, size_t);
+
+// GC: primitives.
+// is GC on?
+#define CF_USING_COLLECTABLE_MEMORY (kCFUseCollectableAllocator)
+// is GC on and is this the GC allocator?
+#define CF_IS_COLLECTABLE_ALLOCATOR(allocator) (CF_USING_COLLECTABLE_MEMORY && (NULL == (allocator) || kCFAllocatorSystemDefault == (allocator)))
+// is this allocated by the collector?
+#define CF_IS_COLLECTABLE(obj) (__CFObjCIsCollectable ? __CFObjCIsCollectable((void*)obj) : false)
+
+// XXX_PCB for generational GC support.
+
+CF_INLINE const void* __CFAssignIvar(CFAllocatorRef allocator, const void *rvalue, const void *base, const void **lvalue) {
+    if (rvalue && CF_IS_COLLECTABLE_ALLOCATOR(allocator))
+        return __CFObjCAssignIvar(rvalue, base, lvalue);
+    else
+        return (*lvalue = rvalue);
+}
+
+CF_INLINE const void* __CFStrongAssign(CFAllocatorRef allocator, const void *rvalue, const void **lvalue) {
+    if (rvalue && CF_IS_COLLECTABLE_ALLOCATOR(allocator))
+        return __CFObjCStrongAssign(rvalue, lvalue);
+    else
+        return (*lvalue = rvalue);
+}
+
+// Use this form when the base pointer to the object is known.
+#define CF_WRITE_BARRIER_BASE_ASSIGN(allocator, base, lvalue, rvalue) __CFAssignIvar(allocator, (const void*)rvalue, (const void*)base, (const void**)&(lvalue))
+
+// Use this form when the base pointer to the object isn't known.
+#define CF_WRITE_BARRIER_ASSIGN(allocator, lvalue, rvalue) __CFStrongAssign(allocator, (const void*)rvalue, (const void**)&(lvalue))
+
+// Write-barrier memory move.
+#define CF_WRITE_BARRIER_MEMMOVE(dst, src, size) __CFObjCMemmoveCollectable(dst, src, size)
+
+// Used by frameworks to assert they "KNOW WHAT THEY'RE DOING under GC."
+CF_EXPORT CFAllocatorRef _CFAllocatorCreateGC(CFAllocatorRef allocator, CFAllocatorContext *context);
+
+// 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);
+
+enum {
+    _kCFRuntimeNotATypeID =                0,
+    _kCFRuntimeScannedObject =       (1 << 0),
+    /* _kCFRuntimeUncollectableObject = (1 << 1),  No longer used; obsolete. */
+    _kCFRuntimeResourcefulObject =   (1 << 2)
+};
+
+typedef struct __CFRuntimeClass {	// Version 0 struct
+    CFIndex version;
+    const char *className;
+    void (*init)(CFTypeRef cf);
+    CFTypeRef (*copy)(CFAllocatorRef allocator, CFTypeRef cf);
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    void (*finalize)(CFTypeRef cf);
+#else
+    void (*dealloc)(CFTypeRef cf);
+#endif
+    Boolean (*equal)(CFTypeRef cf1, CFTypeRef cf2);
+    CFHashCode (*hash)(CFTypeRef cf);
+    CFStringRef (*copyFormattingDesc)(CFTypeRef cf, CFDictionaryRef formatOptions);	// str with retain
+    CFStringRef (*copyDebugDesc)(CFTypeRef cf);	// str with retain
+#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
+#define CF_RECLAIM_AVAILABLE 1
+    void (*reclaim)(CFTypeRef cf);
+#endif
+} 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.
+	 * - 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.
+	 */
+
+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.
+	 */
+#define CF_HAS_INIT_STATIC_INSTANCE 1
+
+#if 0
+// ========================= EXAMPLE =========================
+
+// Example: EXRange -- a "range" object, which keeps the starting
+//       location and length of the range. ("EX" as in "EXample").
+
+// ---- API ----
+
+typedef const struct __EXRange * EXRangeRef;
+
+CFTypeID EXRangeGetTypeID(void);
+
+EXRangeRef EXRangeCreate(CFAllocatorRef allocator, uint32_t location, uint32_t length);
+
+uint32_t EXRangeGetLocation(EXRangeRef rangeref);
+uint32_t EXRangeGetLength(EXRangeRef rangeref);
+
+
+// ---- implementation ----
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFString.h>
+
+struct __EXRange {
+    CFRuntimeBase _base;
+    uint32_t _location;
+    uint32_t _length;
+};
+
+static Boolean __EXRangeEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    EXRangeRef rangeref1 = (EXRangeRef)cf1;
+    EXRangeRef rangeref2 = (EXRangeRef)cf2;
+    if (rangeref1->_location != rangeref2->_location) return false;
+    if (rangeref1->_length != rangeref2->_length) return false;
+    return true;
+}
+
+static CFHashCode __EXRangeHash(CFTypeRef cf) {
+    EXRangeRef rangeref = (EXRangeRef)cf;
+    return (CFHashCode)(rangeref->_location + rangeref->_length);
+}
+
+static CFStringRef __EXRangeCopyFormattingDesc(CFTypeRef cf, CFDictionaryRef formatOpts) {
+    EXRangeRef rangeref = (EXRangeRef)cf;
+    return CFStringCreateWithFormat(CFGetAllocator(rangeref), formatOpts,
+		CFSTR("[%u, %u)"),
+		rangeref->_location,
+		rangeref->_location + rangeref->_length);
+}
+
+static CFStringRef __EXRangeCopyDebugDesc(CFTypeRef cf) {
+    EXRangeRef rangeref = (EXRangeRef)cf;
+    return CFStringCreateWithFormat(CFGetAllocator(rangeref), NULL,
+		CFSTR("<EXRange %p [%p]>{loc = %u, len = %u}"),
+		rangeref,
+		CFGetAllocator(rangeref),
+		rangeref->_location,
+		rangeref->_length);
+}
+
+static void __EXRangeEXRangeFinalize(CFTypeRef cf) {
+    EXRangeRef rangeref = (EXRangeRef)cf;
+    // nothing to finalize
+}
+
+static CFTypeID _kEXRangeID = _kCFRuntimeNotATypeID;
+
+static CFRuntimeClass _kEXRangeClass = {0};
+
+/* Something external to this file is assumed to call this
+ * before the EXRange class is used.
+ */
+void __EXRangeClassInitialize(void) {
+    _kEXRangeClass.version = 0;
+    _kEXRangeClass.className = "EXRange";
+    _kEXRangeClass.init = NULL;
+    _kEXRangeClass.copy = NULL;
+    _kEXRangeClass.finalize = __EXRangeEXRangeFinalize;
+    _kEXRangeClass.equal = __EXRangeEqual;
+    _kEXRangeClass.hash = __EXRangeHash;
+    _kEXRangeClass.copyFormattingDesc = __EXRangeCopyFormattingDesc;
+    _kEXRangeClass.copyDebugDesc = __EXRangeCopyDebugDesc;
+    _kEXRangeID = _CFRuntimeRegisterClass((const CFRuntimeClass * const)&_kEXRangeClass);
+}
+
+CFTypeID EXRangeGetTypeID(void) {
+    return _kEXRangeID;
+}
+
+EXRangeRef EXRangeCreate(CFAllocatorRef allocator, uint32_t location, uint32_t length) {
+    struct __EXRange *newrange;
+    uint32_t extra = sizeof(struct __EXRange) - sizeof(CFRuntimeBase);
+    newrange = (struct __EXRange *)_CFRuntimeCreateInstance(allocator, _kEXRangeID, extra, NULL);
+    if (NULL == newrange) {
+	return NULL;
+    }
+    newrange->_location = location;
+    newrange->_length = length;
+    return (EXRangeRef)newrange;
+}
+
+uint32_t EXRangeGetLocation(EXRangeRef rangeref) {
+    return rangeref->_location;
+}
+
+uint32_t EXRangeGetLength(EXRangeRef rangeref) {
+    return rangeref->_length;
+}
+
+#endif
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFRUNTIME__ */
diff --git a/CoreFoundation/CFSet.c b/CoreFoundation/CFSet.c
new file mode 100644
index 0000000..2bb9d8b
--- /dev/null
+++ b/CoreFoundation/CFSet.c
@@ -0,0 +1,1484 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2006, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+        Machine generated from Notes/HashingCode.template
+*/
+
+
+
+
+#include <CoreFoundation/CFSet.h>
+#include "CFInternal.h"
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach-o/dyld.h>
+#endif
+
+#define CFDictionary 0
+#define CFSet 0
+#define CFBag 0
+#undef CFSet
+#define CFSet 1
+
+#if CFDictionary
+const CFSetKeyCallBacks kCFTypeSetKeyCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFSetKeyCallBacks kCFCopyStringSetKeyCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFSetValueCallBacks kCFTypeSetValueCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual};
+static const CFSetKeyCallBacks __kCFNullSetKeyCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+static const CFSetValueCallBacks __kCFNullSetValueCallBacks = {0, NULL, NULL, NULL, NULL};
+
+#define CFHashRef CFDictionaryRef
+#define CFMutableHashRef CFMutableDictionaryRef
+#define __kCFHashTypeID __kCFDictionaryTypeID
+#endif
+
+#if CFSet
+const CFSetCallBacks kCFTypeSetCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFSetCallBacks kCFCopyStringSetCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+static const CFSetCallBacks __kCFNullSetCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+
+#define CFSetKeyCallBacks CFSetCallBacks
+#define CFSetValueCallBacks CFSetCallBacks
+#define kCFTypeSetKeyCallBacks kCFTypeSetCallBacks
+#define kCFTypeSetValueCallBacks kCFTypeSetCallBacks
+#define __kCFNullSetKeyCallBacks __kCFNullSetCallBacks
+#define __kCFNullSetValueCallBacks __kCFNullSetCallBacks
+
+#define CFHashRef CFSetRef
+#define CFMutableHashRef CFMutableSetRef
+#define __kCFHashTypeID __kCFSetTypeID
+#endif
+
+#if CFBag
+const CFSetCallBacks kCFTypeSetCallBacks = {0, __CFTypeCollectionRetain, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+const CFSetCallBacks kCFCopyStringSetCallBacks = {0, __CFStringCollectionCopy, __CFTypeCollectionRelease, CFCopyDescription, CFEqual, CFHash};
+static const CFSetCallBacks __kCFNullSetCallBacks = {0, NULL, NULL, NULL, NULL, NULL};
+
+#define CFSetKeyCallBacks CFSetCallBacks
+#define CFSetValueCallBacks CFSetCallBacks
+#define kCFTypeSetKeyCallBacks kCFTypeSetCallBacks
+#define kCFTypeSetValueCallBacks kCFTypeSetCallBacks
+#define __kCFNullSetKeyCallBacks __kCFNullSetCallBacks
+#define __kCFNullSetValueCallBacks __kCFNullSetCallBacks
+
+#define CFHashRef CFBagRef
+#define CFMutableHashRef CFMutableBagRef
+#define __kCFHashTypeID __kCFBagTypeID
+#endif
+
+#define GETNEWKEY(newKey, oldKey) \
+        any_t (*kretain)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))__CFSetGetKeyCallBacks(hc)->retain \
+            : (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        any_t newKey = kretain ? (any_t)INVOKE_CALLBACK3(kretain, allocator, (any_t)key, hc->_context) : (any_t)oldKey
+
+#define RELEASEKEY(oldKey) \
+        void (*krelease)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (void (*)(CFAllocatorRef,any_t,any_pointer_t))__CFSetGetKeyCallBacks(hc)->release \
+            : (void (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        if (krelease) INVOKE_CALLBACK3(krelease, allocator, oldKey, hc->_context)
+        
+#if CFDictionary
+#define GETNEWVALUE(newValue) \
+        any_t (*vretain)(CFAllocatorRef, any_t, any_pointer_t) = \
+          !hasBeenFinalized(hc) \
+            ? (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))__CFSetGetValueCallBacks(hc)->retain \
+            : (any_t (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+        any_t newValue = vretain ? (any_t)INVOKE_CALLBACK3(vretain, allocator, (any_t)value, hc->_context) : (any_t)value
+
+#define RELEASEVALUE(oldValue) \
+    void (*vrelease)(CFAllocatorRef, any_t, any_pointer_t) = \
+      !hasBeenFinalized(hc) \
+        ? (void (*)(CFAllocatorRef,any_t,any_pointer_t))__CFSetGetValueCallBacks(hc)->release \
+        : (void (*)(CFAllocatorRef,any_t,any_pointer_t))0; \
+    if (vrelease) INVOKE_CALLBACK3(vrelease, allocator, oldValue, hc->_context)
+
+#endif
+
+static void __CFSetHandleOutOfMemory(CFTypeRef obj, CFIndex numBytes) {
+    CFStringRef msg = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("Attempt to allocate %ld bytes for NS/CFSet failed"), numBytes);
+    CFBadErrorCallBack cb = _CFGetOutOfMemoryErrorCallBack();
+    if (NULL == cb || !cb(obj, CFSTR("NS/CFSet"), msg)) {
+        CFLog(kCFLogLevelCritical, CFSTR("%@"), msg);
+	HALT;
+    }
+    CFRelease(msg);
+}
+
+
+// Max load is 3/4 number of buckets
+CF_INLINE CFIndex __CFHashRoundUpCapacity(CFIndex capacity) {
+    return 3 * ((CFIndex)1 << (flsl((capacity - 1) / 3)));
+}
+
+// Returns next power of two higher than the capacity
+// threshold for the given input capacity.
+CF_INLINE CFIndex __CFHashNumBucketsForCapacity(CFIndex capacity) {
+    return 4 * ((CFIndex)1 << (flsl((capacity - 1) / 3)));
+}
+
+enum {                /* Bits 1-0 */
+    __kCFHashImmutable = 0,        /* unchangable and fixed capacity */
+    __kCFHashMutable = 1,                /* changeable and variable capacity */
+};
+
+enum {                /* Bits 5-4 (value), 3-2 (key) */
+    __kCFHashHasNullCallBacks = 0,
+    __kCFHashHasCFTypeCallBacks = 1,
+    __kCFHashHasCustomCallBacks = 3        /* callbacks are at end of header */
+};
+
+// Under GC, we fudge the key/value memory in two ways
+// First, if we had null callbacks or null for both retain/release, we use unscanned memory and get
+// standard 'dangling' references.
+// This means that if people were doing addValue:[xxx new] and never removing, well, that doesn't work
+//
+// Second, if we notice standard retain/release implementations we use scanned memory, and fudge the
+// standard callbacks to generally do nothing if the collection was allocated in GC memory. On special
+// CF objects, however, like those used for precious resources like video-card buffers, we do indeed
+// do CFRetain on input and CFRelease on output.  The tricky case is GC finalization; we need to remember
+// that we did the CFReleases so that subsequent collection operations, like removal, don't double CFRelease.
+// (In fact we don't really use CFRetain/CFRelease but go directly to the collector)
+//
+
+enum {
+    __kCFHashFinalized =         (1 << 7),
+    __kCFHashWeakKeys =          (1 << 8),
+    __kCFHashWeakValues =        (1 << 9)
+};
+
+typedef uintptr_t any_t;
+typedef const void * const_any_pointer_t;
+typedef void * any_pointer_t;
+
+struct __CFSet {
+    CFRuntimeBase _base;
+    CFIndex _count;             /* number of values */
+    CFIndex _bucketsNum;        /* number of buckets */
+    CFIndex _bucketsUsed;       /* number of used buckets */
+    CFIndex _bucketsCap;        /* maximum number of used buckets */
+    CFIndex _mutations;
+    CFIndex _deletes;
+    any_pointer_t _context;     /* private */
+    CFOptionFlags _xflags;
+    any_t _marker;
+    any_t *_keys;     /* can be NULL if not allocated yet */
+    any_t *_values;   /* can be NULL if not allocated yet */
+};
+
+/* Bits 1-0 of the _xflags are used for mutability variety */
+/* Bits 3-2 of the _xflags are used for key callback indicator bits */
+/* Bits 5-4 of the _xflags are used for value callback indicator bits */
+/* Bit 6 of the _xflags is special KVO actions bit */
+/* Bits 7,8,9 are GC use */
+
+CF_INLINE bool hasBeenFinalized(CFTypeRef collection) {
+    return __CFBitfieldGetValue(((const struct __CFSet *)collection)->_xflags, 7, 7) != 0;
+}
+
+CF_INLINE void markFinalized(CFTypeRef collection) {
+    __CFBitfieldSetValue(((struct __CFSet *)collection)->_xflags, 7, 7, 1);
+}
+
+
+CF_INLINE CFIndex __CFHashGetType(CFHashRef hc) {
+    return __CFBitfieldGetValue(hc->_xflags, 1, 0);
+}
+
+CF_INLINE CFIndex __CFSetGetSizeOfType(CFIndex t) {
+    CFIndex size = sizeof(struct __CFSet);
+    if (__CFBitfieldGetValue(t, 3, 2) == __kCFHashHasCustomCallBacks) {
+        size += sizeof(CFSetKeyCallBacks);
+    }
+    if (__CFBitfieldGetValue(t, 5, 4) == __kCFHashHasCustomCallBacks) {
+        size += sizeof(CFSetValueCallBacks);
+    }
+    return size;
+}
+
+CF_INLINE const CFSetKeyCallBacks *__CFSetGetKeyCallBacks(CFHashRef hc) {
+    CFSetKeyCallBacks *result = NULL;
+    switch (__CFBitfieldGetValue(hc->_xflags, 3, 2)) {
+    case __kCFHashHasNullCallBacks:
+        return &__kCFNullSetKeyCallBacks;
+    case __kCFHashHasCFTypeCallBacks:
+        return &kCFTypeSetKeyCallBacks;
+    case __kCFHashHasCustomCallBacks:
+        break;
+    }
+    result = (CFSetKeyCallBacks *)((uint8_t *)hc + sizeof(struct __CFSet));
+    return result;
+}
+
+CF_INLINE Boolean __CFSetKeyCallBacksMatchNull(const CFSetKeyCallBacks *c) {
+    return (NULL == c ||
+        (c->retain == __kCFNullSetKeyCallBacks.retain &&
+         c->release == __kCFNullSetKeyCallBacks.release &&
+         c->copyDescription == __kCFNullSetKeyCallBacks.copyDescription &&
+         c->equal == __kCFNullSetKeyCallBacks.equal &&
+         c->hash == __kCFNullSetKeyCallBacks.hash));
+}
+
+CF_INLINE Boolean __CFSetKeyCallBacksMatchCFType(const CFSetKeyCallBacks *c) {
+    return (&kCFTypeSetKeyCallBacks == c ||
+        (c->retain == kCFTypeSetKeyCallBacks.retain &&
+         c->release == kCFTypeSetKeyCallBacks.release &&
+         c->copyDescription == kCFTypeSetKeyCallBacks.copyDescription &&
+         c->equal == kCFTypeSetKeyCallBacks.equal &&
+         c->hash == kCFTypeSetKeyCallBacks.hash));
+}
+
+CF_INLINE const CFSetValueCallBacks *__CFSetGetValueCallBacks(CFHashRef hc) {
+    CFSetValueCallBacks *result = NULL;
+    switch (__CFBitfieldGetValue(hc->_xflags, 5, 4)) {
+    case __kCFHashHasNullCallBacks:
+        return &__kCFNullSetValueCallBacks;
+    case __kCFHashHasCFTypeCallBacks:
+        return &kCFTypeSetValueCallBacks;
+    case __kCFHashHasCustomCallBacks:
+        break;
+    }
+    if (__CFBitfieldGetValue(hc->_xflags, 3, 2) == __kCFHashHasCustomCallBacks) {
+        result = (CFSetValueCallBacks *)((uint8_t *)hc + sizeof(struct __CFSet) + sizeof(CFSetKeyCallBacks));
+    } else {
+        result = (CFSetValueCallBacks *)((uint8_t *)hc + sizeof(struct __CFSet));
+    }
+    return result;
+}
+
+CF_INLINE Boolean __CFSetValueCallBacksMatchNull(const CFSetValueCallBacks *c) {
+    return (NULL == c ||
+        (c->retain == __kCFNullSetValueCallBacks.retain &&
+         c->release == __kCFNullSetValueCallBacks.release &&
+         c->copyDescription == __kCFNullSetValueCallBacks.copyDescription &&
+         c->equal == __kCFNullSetValueCallBacks.equal));
+}
+
+CF_INLINE Boolean __CFSetValueCallBacksMatchCFType(const CFSetValueCallBacks *c) {
+    return (&kCFTypeSetValueCallBacks == c ||
+        (c->retain == kCFTypeSetValueCallBacks.retain &&
+         c->release == kCFTypeSetValueCallBacks.release &&
+         c->copyDescription == kCFTypeSetValueCallBacks.copyDescription &&
+         c->equal == kCFTypeSetValueCallBacks.equal));
+}
+
+CFIndex _CFSetGetKVOBit(CFHashRef hc) {
+    return __CFBitfieldGetValue(hc->_xflags, 6, 6);
+}
+
+void _CFSetSetKVOBit(CFHashRef hc, CFIndex bit) {
+    __CFBitfieldSetValue(((CFMutableHashRef)hc)->_xflags, 6, 6, ((uintptr_t)bit & 0x1));
+}
+
+CF_INLINE Boolean __CFSetShouldShrink(CFHashRef hc) {
+    return (__kCFHashMutable == __CFHashGetType(hc)) &&
+                !(CF_USING_COLLECTABLE_MEMORY && auto_zone_is_finalized(__CFCollectableZone, hc)) && /* GC:  don't shrink finalizing hcs! */
+                (hc->_bucketsNum < 4 * hc->_deletes || (256 <= hc->_bucketsCap && hc-> _bucketsUsed < 3 * hc->_bucketsCap / 16));
+}
+
+CF_INLINE CFIndex __CFHashGetOccurrenceCount(CFHashRef hc, CFIndex idx) {
+#if CFBag
+    return hc->_values[idx];
+#endif
+    return 1;
+}
+
+CF_INLINE Boolean __CFHashKeyIsValue(CFHashRef hc, any_t key) {
+    return (hc->_marker != key && ~hc->_marker != key) ? true : false;
+}
+
+CF_INLINE Boolean __CFHashKeyIsMagic(CFHashRef hc, any_t key) {
+    return (hc->_marker == key || ~hc->_marker == key) ? true : false;
+}
+
+
+#if !defined(CF_OBJC_KVO_WILLCHANGE)
+#define CF_OBJC_KVO_WILLCHANGE(obj, key)
+#define CF_OBJC_KVO_DIDCHANGE(obj, key)
+#endif
+
+CF_INLINE uintptr_t __CFSetScrambleHash(uintptr_t k) {
+#if 0
+    return k;
+#else
+#if __LP64__
+    uintptr_t a = 0x4368726973746F70ULL;
+    uintptr_t b = 0x686572204B616E65ULL;
+#else
+    uintptr_t a = 0x4B616E65UL;
+    uintptr_t b = 0x4B616E65UL;
+#endif
+    uintptr_t c = 1;
+    a += k;
+#if __LP64__
+    a -= b; a -= c; a ^= (c >> 43);
+    b -= c; b -= a; b ^= (a << 9);
+    c -= a; c -= b; c ^= (b >> 8);
+    a -= b; a -= c; a ^= (c >> 38);
+    b -= c; b -= a; b ^= (a << 23);
+    c -= a; c -= b; c ^= (b >> 5);
+    a -= b; a -= c; a ^= (c >> 35);
+    b -= c; b -= a; b ^= (a << 49);
+    c -= a; c -= b; c ^= (b >> 11);
+    a -= b; a -= c; a ^= (c >> 12);
+    b -= c; b -= a; b ^= (a << 18);
+    c -= a; c -= b; c ^= (b >> 22);
+#else
+    a -= b; a -= c; a ^= (c >> 13);
+    b -= c; b -= a; b ^= (a << 8);
+    c -= a; c -= b; c ^= (b >> 13);
+    a -= b; a -= c; a ^= (c >> 12);
+    b -= c; b -= a; b ^= (a << 16);
+    c -= a; c -= b; c ^= (b >> 5);
+    a -= b; a -= c; a ^= (c >> 3);
+    b -= c; b -= a; b ^= (a << 10);
+    c -= a; c -= b; c ^= (b >> 15);
+#endif
+    return c;
+#endif
+}
+
+static CFIndex __CFSetFindBuckets1a(CFHashRef hc, any_t key) {
+    CFHashCode keyHash = (CFHashCode)key;
+    keyHash = (CFHashCode)__CFSetScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            return kCFNotFound;
+        } else if (~marker == currKey) {        /* deleted */
+            /* do nothing */
+        } else if (currKey == key) {
+            return probe;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return kCFNotFound;
+        }
+    }
+}
+
+static CFIndex __CFSetFindBuckets1b(CFHashRef hc, any_t key) {
+    const CFSetKeyCallBacks *cb = __CFSetGetKeyCallBacks(hc);
+    CFHashCode keyHash = cb->hash ? (CFHashCode)INVOKE_CALLBACK2(((CFHashCode (*)(any_t, any_pointer_t))cb->hash), key, hc->_context) : (CFHashCode)key;
+    keyHash = (CFHashCode)__CFSetScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            return kCFNotFound;
+        } else if (~marker == currKey) {        /* deleted */
+            /* do nothing */
+        } else if (currKey == key || (cb->equal && INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))cb->equal, currKey, key, hc->_context))) {
+            return probe;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return kCFNotFound;
+        }
+    }
+}
+
+CF_INLINE CFIndex __CFSetFindBuckets1(CFHashRef hc, any_t key) {
+    if (__kCFHashHasNullCallBacks == __CFBitfieldGetValue(hc->_xflags, 3, 2)) {
+        return __CFSetFindBuckets1a(hc, key);
+    }
+    return __CFSetFindBuckets1b(hc, key);
+}
+
+static void __CFSetFindBuckets2(CFHashRef hc, any_t key, CFIndex *match, CFIndex *nomatch) {
+    const CFSetKeyCallBacks *cb = __CFSetGetKeyCallBacks(hc);
+    CFHashCode keyHash = cb->hash ? (CFHashCode)INVOKE_CALLBACK2(((CFHashCode (*)(any_t, any_pointer_t))cb->hash), key, hc->_context) : (CFHashCode)key;
+    keyHash = (CFHashCode)__CFSetScrambleHash(keyHash);
+    any_t *keys = hc->_keys;
+    any_t marker = hc->_marker;
+    CFIndex probe = keyHash & (hc->_bucketsNum - 1);
+    CFIndex probeskip = 1;        // See RemoveValue() for notes before changing this value
+    CFIndex start = probe;
+    *match = kCFNotFound;
+    *nomatch = kCFNotFound;
+    for (;;) {
+        any_t currKey = keys[probe];
+        if (marker == currKey) {                /* empty */
+            if (nomatch) *nomatch = probe;
+            return;
+        } else if (~marker == currKey) {        /* deleted */
+            if (nomatch) {
+                *nomatch = probe;
+                nomatch = NULL;
+            }
+        } else if (currKey == key || (cb->equal && INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))cb->equal, currKey, key, hc->_context))) {
+            *match = probe;
+            return;
+        }
+        probe = probe + probeskip;
+        // This alternative to probe % buckets assumes that
+        // probeskip is always positive and less than the
+        // number of buckets.
+        if (hc->_bucketsNum <= probe) {
+            probe -= hc->_bucketsNum;
+        }
+        if (start == probe) {
+            return;
+        }
+    }
+}
+
+static void __CFSetFindNewMarker(CFHashRef hc) {
+    any_t *keys = hc->_keys;
+    any_t newMarker;
+    CFIndex idx, nbuckets;
+    Boolean hit;
+
+    nbuckets = hc->_bucketsNum;
+    newMarker = hc->_marker;
+    do {
+        newMarker--;
+        hit = false;
+        for (idx = 0; idx < nbuckets; idx++) {
+            if (newMarker == keys[idx] || ~newMarker == keys[idx]) {
+                hit = true;
+                break;
+            }
+        }
+    } while (hit);
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (hc->_marker == keys[idx]) {
+            keys[idx] = newMarker;
+        } else if (~hc->_marker == keys[idx]) {
+            keys[idx] = ~newMarker;
+        }
+    }
+    ((struct __CFSet *)hc)->_marker = newMarker;
+}
+
+static Boolean __CFSetEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFHashRef hc1 = (CFHashRef)cf1;
+    CFHashRef hc2 = (CFHashRef)cf2;
+    const CFSetKeyCallBacks *cb1, *cb2;
+    const CFSetValueCallBacks *vcb1, *vcb2;
+    any_t *keys;
+    CFIndex idx, nbuckets;
+    if (hc1 == hc2) return true;
+    if (hc1->_count != hc2->_count) return false;
+    cb1 = __CFSetGetKeyCallBacks(hc1);
+    cb2 = __CFSetGetKeyCallBacks(hc2);
+    if (cb1->equal != cb2->equal) return false;
+    vcb1 = __CFSetGetValueCallBacks(hc1);
+    vcb2 = __CFSetGetValueCallBacks(hc2);
+    if (vcb1->equal != vcb2->equal) return false;
+    if (0 == hc1->_bucketsUsed) return true; /* after function comparison! */
+    keys = hc1->_keys;
+    nbuckets = hc1->_bucketsNum;
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (hc1->_marker != keys[idx] && ~hc1->_marker != keys[idx]) {
+#if CFDictionary
+            const_any_pointer_t value;
+            if (!CFSetGetValueIfPresent(hc2, (any_pointer_t)keys[idx], &value)) return false;
+	    if (hc1->_values[idx] != (any_t)value) {
+		if (NULL == vcb1->equal) return false;
+	        if (!INVOKE_CALLBACK3((Boolean (*)(any_t, any_t, any_pointer_t))vcb1->equal, hc1->_values[idx], (any_t)value, hc1->_context)) return false;
+            }
+#endif
+#if  CFSet
+            const_any_pointer_t value;
+            if (!CFSetGetValueIfPresent(hc2, (any_pointer_t)keys[idx], &value)) return false;
+#endif
+#if CFBag
+            if (hc1->_values[idx] != CFSetGetCountOfValue(hc2, (any_pointer_t)keys[idx])) return false;
+#endif
+        }
+    }
+    return true;
+}
+
+static CFHashCode __CFSetHash(CFTypeRef cf) {
+    CFHashRef hc = (CFHashRef)cf;
+    return hc->_count;
+}
+
+static CFStringRef __CFSetCopyDescription(CFTypeRef cf) {
+    CFHashRef hc = (CFHashRef)cf;
+    CFAllocatorRef allocator;
+    const CFSetKeyCallBacks *cb;
+    const CFSetValueCallBacks *vcb;
+    any_t *keys;
+    CFIndex idx, nbuckets;
+    CFMutableStringRef result;
+    cb = __CFSetGetKeyCallBacks(hc);
+    vcb = __CFSetGetValueCallBacks(hc);
+    keys = hc->_keys;
+    nbuckets = hc->_bucketsNum;
+    allocator = CFGetAllocator(hc);
+    result = CFStringCreateMutable(allocator, 0);
+    const char *type = "?";
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashImmutable: type = "immutable"; break;
+    case __kCFHashMutable: type = "mutable"; break;
+    }
+    CFStringAppendFormat(result, NULL, CFSTR("<CFSet %p [%p]>{type = %s, count = %u, capacity = %u, pairs = (\n"), cf, allocator, type, hc->_count, hc->_bucketsCap);
+    for (idx = 0; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            CFStringRef kDesc = NULL, vDesc = NULL;
+            if (NULL != cb->copyDescription) {
+                kDesc = (CFStringRef)INVOKE_CALLBACK2(((CFStringRef (*)(any_t, any_pointer_t))cb->copyDescription), keys[idx], hc->_context);
+            }
+            if (NULL != vcb->copyDescription) {
+                vDesc = (CFStringRef)INVOKE_CALLBACK2(((CFStringRef (*)(any_t, any_pointer_t))vcb->copyDescription), hc->_values[idx], hc->_context);
+            }
+#if CFDictionary
+            if (NULL != kDesc && NULL != vDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ = %@\n"), idx, kDesc, vDesc);
+                CFRelease(kDesc);
+                CFRelease(vDesc);
+            } else if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ = <%p>\n"), idx, kDesc, hc->_values[idx]);
+                CFRelease(kDesc);
+            } else if (NULL != vDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> = %@\n"), idx, keys[idx], vDesc);
+                CFRelease(vDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> = <%p>\n"), idx, keys[idx], hc->_values[idx]);
+            }
+#endif
+#if CFSet
+            if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@\n"), idx, kDesc);
+                CFRelease(kDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p>\n"), idx, keys[idx]);
+            }
+#endif
+#if CFBag
+            if (NULL != kDesc) {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : %@ (%ld)\n"), idx, kDesc, hc->_values[idx]);
+                CFRelease(kDesc);
+            } else {
+                CFStringAppendFormat(result, NULL, CFSTR("\t%u : <%p> (%ld)\n"), idx, keys[idx], hc->_values[idx]);
+            }
+#endif
+        }
+    }
+    CFStringAppend(result, CFSTR(")}"));
+    return result;
+}
+
+static void __CFSetDeallocate(CFTypeRef cf) {
+    CFMutableHashRef hc = (CFMutableHashRef)cf;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    const CFSetKeyCallBacks *cb = __CFSetGetKeyCallBacks(hc);
+    const CFSetValueCallBacks *vcb = __CFSetGetValueCallBacks(hc);
+
+    // mark now in case any callout somehow tries to add an entry back in
+    markFinalized(cf);
+    if (vcb->release || cb->release) {
+        any_t *keys = hc->_keys;
+        CFIndex idx, nbuckets = hc->_bucketsNum;
+        for (idx = 0; idx < nbuckets; idx++) {
+            any_t oldkey = keys[idx];
+            if (hc->_marker != oldkey && ~hc->_marker != oldkey) {
+                if (vcb->release) {
+                    INVOKE_CALLBACK3(((void (*)(CFAllocatorRef, any_t, any_pointer_t))vcb->release), allocator, hc->_values[idx], hc->_context);
+                }
+                if (cb->release) {
+                    INVOKE_CALLBACK3(((void (*)(CFAllocatorRef, any_t, any_pointer_t))cb->release), allocator, oldkey, hc->_context);
+                }
+            }
+        }
+    }
+
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        // return early so that contents are preserved after finalization
+        return;
+    }
+    
+    _CFAllocatorDeallocateGC(allocator, hc->_keys);
+#if CFDictionary || CFBag
+    _CFAllocatorDeallocateGC(allocator, hc->_values);
+#endif
+    hc->_keys = NULL;
+    hc->_values = NULL;
+    hc->_count = 0;  // GC: also zero count, so the hc will appear empty.
+    hc->_bucketsUsed = 0;
+    hc->_bucketsNum = 0;
+}
+
+static CFTypeID __kCFSetTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFSetClass = {
+    _kCFRuntimeScannedObject,
+    "CFSet",
+    NULL,        // init
+    NULL,        // copy
+    __CFSetDeallocate,
+    __CFSetEqual,
+    __CFSetHash,
+    NULL,        //
+    __CFSetCopyDescription
+};
+
+__private_extern__ void __CFSetInitialize(void) {
+    __kCFHashTypeID = _CFRuntimeRegisterClass(&__CFSetClass);
+}
+
+CFTypeID CFSetGetTypeID(void) {
+    return __kCFHashTypeID;
+}
+
+static CFMutableHashRef __CFSetInit(CFAllocatorRef allocator, CFOptionFlags flags, CFIndex capacity, const CFSetKeyCallBacks *keyCallBacks
+#if CFDictionary
+, const CFSetValueCallBacks *valueCallBacks
+#endif
+) {
+    struct __CFSet *hc;
+    CFIndex size;
+    __CFBitfieldSetValue(flags, 31, 2, 0);
+    CFOptionFlags xflags = 0;
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        // preserve NULL for key or value CB, otherwise fix up.
+        if (!keyCallBacks || (keyCallBacks->retain == NULL && keyCallBacks->release == NULL)) {
+            xflags = __kCFHashWeakKeys;
+        }
+#if CFDictionary
+        if (!valueCallBacks || (valueCallBacks->retain == NULL && valueCallBacks->release == NULL)) {
+            xflags |= __kCFHashWeakValues;
+        }
+#endif
+#if CFBag
+        xflags |= __kCFHashWeakValues;
+#endif
+    }
+    if (__CFSetKeyCallBacksMatchNull(keyCallBacks)) {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasNullCallBacks);
+    } else if (__CFSetKeyCallBacksMatchCFType(keyCallBacks)) {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasCFTypeCallBacks);
+    } else {
+        __CFBitfieldSetValue(flags, 3, 2, __kCFHashHasCustomCallBacks);
+    }
+#if CFDictionary
+    if (__CFSetValueCallBacksMatchNull(valueCallBacks)) {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasNullCallBacks);
+    } else if (__CFSetValueCallBacksMatchCFType(valueCallBacks)) {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasCFTypeCallBacks);
+    } else {
+        __CFBitfieldSetValue(flags, 5, 4, __kCFHashHasCustomCallBacks);
+    }
+#endif
+    size = __CFSetGetSizeOfType(flags) - sizeof(CFRuntimeBase);
+    hc = (struct __CFSet *)_CFRuntimeCreateInstance(allocator, __kCFHashTypeID, size, NULL);
+    if (NULL == hc) {
+        return NULL;
+    }
+    hc->_count = 0;
+    hc->_bucketsUsed = 0;
+    hc->_marker = (any_t)0xa1b1c1d3;
+    hc->_context = NULL;
+    hc->_deletes = 0;
+    hc->_mutations = 1;
+    hc->_xflags = xflags | flags;
+    switch (__CFBitfieldGetValue(flags, 1, 0)) {
+    case __kCFHashImmutable:
+        if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFSet (immutable)");
+        break;
+    case __kCFHashMutable:
+        if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFSet (mutable-variable)");
+        break;
+    }
+    hc->_bucketsCap = __CFHashRoundUpCapacity(1);
+    hc->_bucketsNum = 0;
+    hc->_keys = NULL;
+    hc->_values = NULL;
+    if (__kCFHashHasCustomCallBacks == __CFBitfieldGetValue(flags, 3, 2)) {
+        CFSetKeyCallBacks *cb = (CFSetKeyCallBacks *)__CFSetGetKeyCallBacks((CFHashRef)hc);
+        *cb = *keyCallBacks;
+        FAULT_CALLBACK((void **)&(cb->retain));
+        FAULT_CALLBACK((void **)&(cb->release));
+        FAULT_CALLBACK((void **)&(cb->copyDescription));
+        FAULT_CALLBACK((void **)&(cb->equal));
+        FAULT_CALLBACK((void **)&(cb->hash));
+    }
+#if CFDictionary
+    if (__kCFHashHasCustomCallBacks == __CFBitfieldGetValue(flags, 5, 4)) {
+        CFSetValueCallBacks *vcb = (CFSetValueCallBacks *)__CFSetGetValueCallBacks((CFHashRef)hc);
+        *vcb = *valueCallBacks;
+        FAULT_CALLBACK((void **)&(vcb->retain));
+        FAULT_CALLBACK((void **)&(vcb->release));
+        FAULT_CALLBACK((void **)&(vcb->copyDescription));
+        FAULT_CALLBACK((void **)&(vcb->equal));
+    }
+#endif
+    return hc;
+}
+
+#if CFDictionary
+CFHashRef CFSetCreate(CFAllocatorRef allocator, const_any_pointer_t *keys, const_any_pointer_t *values, CFIndex numValues, const CFSetKeyCallBacks *keyCallBacks, const CFSetValueCallBacks *valueCallBacks) {
+#endif
+#if CFSet || CFBag
+CFHashRef CFSetCreate(CFAllocatorRef allocator, const_any_pointer_t *keys, CFIndex numValues, const CFSetKeyCallBacks *keyCallBacks) {
+#endif
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%ld) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+#if CFDictionary
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashImmutable, numValues, keyCallBacks, valueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashImmutable, numValues, keyCallBacks);
+#endif
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashMutable);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+#if CFDictionary
+        CFSetAddValue(hc, keys[idx], values[idx]);
+#endif
+#if CFSet || CFBag
+        CFSetAddValue(hc, keys[idx]);
+#endif
+    }
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    return (CFHashRef)hc;
+}
+
+#if CFDictionary
+CFMutableHashRef CFSetCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFSetKeyCallBacks *keyCallBacks, const CFSetValueCallBacks *valueCallBacks) {
+#endif
+#if CFSet || CFBag
+CFMutableHashRef CFSetCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFSetKeyCallBacks *keyCallBacks) {
+#endif
+    CFAssert2(0 <= capacity, __kCFLogAssertion, "%s(): capacity (%ld) cannot be less than zero", __PRETTY_FUNCTION__, capacity);
+#if CFDictionary
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashMutable, capacity, keyCallBacks, valueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashMutable, capacity, keyCallBacks);
+#endif
+    return hc;
+}
+
+#if CFDictionary || CFSet
+// does not have Add semantics for Bag; it has Set semantics ... is that best?
+static void __CFSetGrow(CFMutableHashRef hc, CFIndex numNewValues);
+
+// This creates a hc which is for CFTypes or NSObjects, with a CFRetain style ownership transfer;
+// the hc does not take a retain (since it claims 1), and the caller does not need to release the inserted objects (since we do it).
+// The incoming objects must also be collectable if allocated out of a collectable allocator - and are neither released nor retained.
+#if CFDictionary
+CFHashRef _CFSetCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const_any_pointer_t *keys, const_any_pointer_t *values, CFIndex numValues) {
+#endif
+#if CFSet || CFBag
+CFHashRef _CFSetCreate_ex(CFAllocatorRef allocator, Boolean isMutable, const_any_pointer_t *keys, CFIndex numValues) {
+#endif
+    CFAssert2(0 <= numValues, __kCFLogAssertion, "%s(): numValues (%ld) cannot be less than zero", __PRETTY_FUNCTION__, numValues);
+#if CFDictionary
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashMutable, numValues, &kCFTypeSetKeyCallBacks, &kCFTypeSetValueCallBacks);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashMutable, numValues, &kCFTypeSetKeyCallBacks);
+#endif
+    __CFSetGrow(hc, numValues);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+        CFIndex match, nomatch;
+        __CFSetFindBuckets2(hc, (any_t)keys[idx], &match, &nomatch);
+        if (kCFNotFound == match) {
+            CFAllocatorRef allocator = __CFGetAllocator(hc);
+            any_t newKey = (any_t)keys[idx];
+            if (__CFHashKeyIsMagic(hc, newKey)) {
+                __CFSetFindNewMarker(hc);
+            }
+            if (hc->_keys[nomatch] == ~hc->_marker) {
+                hc->_deletes--;
+            }
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+            any_t newValue = (any_t)values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+            hc->_values[nomatch] = 1;
+#endif
+            hc->_bucketsUsed++;
+            hc->_count++;
+        } else {
+            CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+            any_t oldKey = hc->_keys[match];
+            any_t newKey = (any_t)keys[idx];
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+            if (__CFHashKeyIsMagic(hc, newKey)) {
+                __CFSetFindNewMarker(hc);
+            }
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+            RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+            any_t oldValue = hc->_values[match];
+            any_t newValue = (any_t)values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+            RELEASEVALUE(oldValue);
+#endif
+        }
+    }
+    if (!isMutable) __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    return (CFHashRef)hc;
+}
+#endif
+
+CFHashRef CFSetCreateCopy(CFAllocatorRef allocator, CFHashRef other) {
+    CFMutableHashRef hc = CFSetCreateMutableCopy(allocator, CFSetGetCount(other), other);
+    __CFBitfieldSetValue(hc->_xflags, 1, 0, __kCFHashImmutable);
+    if (__CFOASafe) __CFSetLastAllocationEventName(hc, "CFSet (immutable)");
+    return hc;
+}
+
+CFMutableHashRef CFSetCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFHashRef other) {
+    CFIndex numValues = CFSetGetCount(other);
+    const_any_pointer_t *list, buffer[256];
+    list = (numValues <= 256) ? buffer : (const_any_pointer_t *)CFAllocatorAllocate(allocator, numValues * sizeof(const_any_pointer_t), 0);
+    if (list != buffer && __CFOASafe) __CFSetLastAllocationEventName(list, "CFSet (temp)");
+#if CFDictionary
+    const_any_pointer_t *vlist, vbuffer[256];
+    vlist = (numValues <= 256) ? vbuffer : (const_any_pointer_t *)CFAllocatorAllocate(allocator, numValues * sizeof(const_any_pointer_t), 0);
+    if (vlist != vbuffer && __CFOASafe) __CFSetLastAllocationEventName(vlist, "CFSet (temp)");
+#endif
+#if CFSet || CFBag
+    CFSetGetValues(other, list);
+#endif
+#if CFDictionary
+    CFSetGetKeysAndValues(other, list, vlist);
+#endif
+    const CFSetKeyCallBacks *kcb;
+    const CFSetValueCallBacks *vcb;
+    if (CF_IS_OBJC(__kCFHashTypeID, other)) {
+        kcb = &kCFTypeSetKeyCallBacks;
+        vcb = &kCFTypeSetValueCallBacks;
+    } else {
+        kcb = __CFSetGetKeyCallBacks(other);
+        vcb = __CFSetGetValueCallBacks(other);
+    }
+#if CFDictionary
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashMutable, capacity, kcb, vcb);
+#endif
+#if CFSet || CFBag
+    CFMutableHashRef hc = __CFSetInit(allocator, __kCFHashMutable, capacity, kcb);
+#endif
+    if (0 == capacity) _CFSetSetCapacity(hc, numValues);
+    for (CFIndex idx = 0; idx < numValues; idx++) {
+#if CFDictionary
+        CFSetAddValue(hc, list[idx], vlist[idx]);
+#endif
+#if CFSet || CFBag
+        CFSetAddValue(hc, list[idx]);
+#endif
+    }
+    if (list != buffer) CFAllocatorDeallocate(allocator, list);
+#if CFDictionary
+    if (vlist != vbuffer) CFAllocatorDeallocate(allocator, vlist);
+#endif
+    return hc;
+}
+
+// Used by NSHashTables/NSMapTables and KVO
+void _CFSetSetContext(CFHashRef hc, any_pointer_t context) {
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    CF_WRITE_BARRIER_BASE_ASSIGN(__CFGetAllocator(hc), hc, hc->_context, context);
+}
+
+any_pointer_t _CFSetGetContext(CFHashRef hc) {
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    return hc->_context;
+}
+
+CFIndex CFSetGetCount(CFHashRef hc) {
+    if (CFDictionary || CFSet) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, CFIndex, hc, "count");
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    return hc->_count;
+}
+
+#if CFDictionary
+CFIndex CFSetGetCountOfKey(CFHashRef hc, const_any_pointer_t key) {
+#endif
+#if CFSet || CFBag
+CFIndex CFSetGetCountOfValue(CFHashRef hc, const_any_pointer_t key) {
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    CFIndex match = __CFSetFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? __CFHashGetOccurrenceCount(hc, match) : 0);
+}
+
+#if CFDictionary
+Boolean CFSetContainsKey(CFHashRef hc, const_any_pointer_t key) {
+#endif
+#if CFSet || CFBag
+Boolean CFSetContainsValue(CFHashRef hc, const_any_pointer_t key) {
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFSetFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? true : false);
+}
+
+#if CFDictionary
+CFIndex CFSetGetCountOfValue(CFHashRef hc, const_any_pointer_t value) {
+    CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, CFIndex, hc, "countForObject:", value);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    any_t *keys = hc->_keys;
+    Boolean (*equal)(any_t, any_t, any_pointer_t) = (Boolean (*)(any_t, any_t, any_pointer_t))__CFSetGetValueCallBacks(hc)->equal;
+    CFIndex cnt = 0;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            if ((hc->_values[idx] == (any_t)value) || (equal && INVOKE_CALLBACK3(equal, hc->_values[idx], (any_t)value, hc->_context))) {
+                cnt++;
+            }
+        }
+    }
+    return cnt;
+}
+
+Boolean CFSetContainsValue(CFHashRef hc, const_any_pointer_t value) {
+    CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, char, hc, "containsObject:", value);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    any_t *keys = hc->_keys;
+    Boolean (*equal)(any_t, any_t, any_pointer_t) = (Boolean (*)(any_t, any_t, any_pointer_t))__CFSetGetValueCallBacks(hc)->equal;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            if ((hc->_values[idx] == (any_t)value) || (equal && INVOKE_CALLBACK3(equal, hc->_values[idx], (any_t)value, hc->_context))) {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+#endif
+
+const_any_pointer_t CFSetGetValue(CFHashRef hc, const_any_pointer_t key) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, const_any_pointer_t, hc, "objectForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, const_any_pointer_t, hc, "member:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return 0;
+    CFIndex match = __CFSetFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? (const_any_pointer_t)(CFDictionary ? hc->_values[match] : hc->_keys[match]) : 0);
+}
+
+Boolean CFSetGetValueIfPresent(CFHashRef hc, const_any_pointer_t key, const_any_pointer_t *value) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "_getValue:forKey:", (any_t *)value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "_getValue:forObj:", (any_t *)value, key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFSetFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? ((value ? __CFObjCStrongAssign((const_any_pointer_t)(CFDictionary ? hc->_values[match] : hc->_keys[match]), value) : 0), true) : false);
+}
+
+#if CFDictionary
+Boolean CFSetGetKeyIfPresent(CFHashRef hc, const_any_pointer_t key, const_any_pointer_t *actualkey) {
+    CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, Boolean, hc, "getActualKey:forKey:", actualkey, key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (0 == hc->_bucketsUsed) return false;
+    CFIndex match = __CFSetFindBuckets1(hc, (any_t)key);
+    return (kCFNotFound != match ? ((actualkey ? __CFObjCStrongAssign((const_any_pointer_t)hc->_keys[match], actualkey) : NULL), true) : false);
+}
+#endif
+
+#if CFDictionary
+void CFSetGetKeysAndValues(CFHashRef hc, const_any_pointer_t *keybuf, const_any_pointer_t *valuebuf) {
+#endif
+#if CFSet || CFBag
+void CFSetGetValues(CFHashRef hc, const_any_pointer_t *keybuf) {
+    const_any_pointer_t *valuebuf = 0;
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "getObjects:andKeys:", (any_t *)valuebuf, (any_t *)keybuf);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "getObjects:", (any_t *)keybuf);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    if (CF_USING_COLLECTABLE_MEMORY) {
+        // GC: speculatively issue a write-barrier on the copied to buffers
+        __CFObjCWriteBarrierRange(keybuf, hc->_count * sizeof(any_t));
+        __CFObjCWriteBarrierRange(valuebuf, hc->_count * sizeof(any_t));
+    }
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            for (CFIndex cnt = __CFHashGetOccurrenceCount(hc, idx); cnt--;) {
+                if (keybuf) *keybuf++ = (const_any_pointer_t)keys[idx];
+                if (valuebuf) *valuebuf++ = (const_any_pointer_t)hc->_values[idx];
+            }
+        }
+    }
+}
+
+#if CFDictionary || CFSet
+unsigned long _CFSetFastEnumeration(CFHashRef hc, struct __objcFastEnumerationStateEquivalent *state, void *stackbuffer, unsigned long count) {
+    /* copy as many as count items over */
+    if (0 == state->state) {        /* first time */
+        state->mutationsPtr = (unsigned long *)&hc->_mutations;
+    }
+    state->itemsPtr = (unsigned long *)stackbuffer;
+    CFIndex cnt = 0;
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = (CFIndex)state->state, nbuckets = hc->_bucketsNum; idx < nbuckets && cnt < (CFIndex)count; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            state->itemsPtr[cnt++] = (unsigned long)keys[idx];
+        }
+        state->state++;
+    }
+    return cnt;
+}
+#endif
+
+void CFSetApplyFunction(CFHashRef hc, CFSetApplierFunction applier, any_pointer_t context) {
+    FAULT_CALLBACK((void **)&(applier));
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_apply:context:", applier, context);
+    if (CFSet) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_applyValues:context:", applier, context);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, hc->_keys[idx])) {
+            for (CFIndex cnt = __CFHashGetOccurrenceCount(hc, idx); cnt--;) {
+#if CFDictionary
+                INVOKE_CALLBACK3(applier, (const_any_pointer_t)hc->_keys[idx], (const_any_pointer_t)hc->_values[idx], context);
+#endif
+#if CFSet || CFBag
+                INVOKE_CALLBACK2(applier, (const_any_pointer_t)hc->_keys[idx], context);
+#endif
+            }
+        }
+    }
+}
+
+
+// This function is for Foundation's benefit; no one else should use it.
+bool _CFSetIsMutable(CFSetRef set) { 
+    return (__CFHashGetType(set) != __kCFHashImmutable);
+}
+
+static void __CFSetGrow(CFMutableHashRef hc, CFIndex numNewValues) {
+    any_t *oldkeys = hc->_keys;
+    any_t *oldvalues = hc->_values;
+    CFIndex nbuckets = hc->_bucketsNum;
+    hc->_bucketsCap = __CFHashRoundUpCapacity(hc->_bucketsUsed + numNewValues);
+    hc->_bucketsNum = __CFHashNumBucketsForCapacity(hc->_bucketsCap);
+    hc->_deletes = 0;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    CFOptionFlags weakOrStrong = (hc->_xflags & __kCFHashWeakKeys) ? 0 : __kCFAllocatorGCScannedMemory;
+    any_t *mem = (any_t *)_CFAllocatorAllocateGC(allocator, hc->_bucketsNum * sizeof(any_t), weakOrStrong);
+    if (NULL == mem) __CFSetHandleOutOfMemory(hc, hc->_bucketsNum * sizeof(any_t));
+    if (__CFOASafe) __CFSetLastAllocationEventName(mem, "CFSet (key-store)");
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, hc, hc->_keys, mem);
+    CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;  // GC: avoids write-barrier in weak case.
+    any_t *keysBase = mem;
+#if CFDictionary || CFBag
+    weakOrStrong = (hc->_xflags & __kCFHashWeakValues) ? 0 : __kCFAllocatorGCScannedMemory;
+    mem = (any_t *)_CFAllocatorAllocateGC(allocator, hc->_bucketsNum * sizeof(any_t), weakOrStrong);
+    if (NULL == mem) __CFSetHandleOutOfMemory(hc, hc->_bucketsNum * sizeof(any_t));
+    if (__CFOASafe) __CFSetLastAllocationEventName(mem, "CFSet (value-store)");
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, hc, hc->_values, mem);
+#endif
+#if CFDictionary
+    CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator; // GC: avoids write-barrier in weak case.
+    any_t *valuesBase = mem;
+#endif
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        hc->_keys[idx] = hc->_marker;
+#if CFDictionary || CFBag
+        hc->_values[idx] = 0;
+#endif
+    }
+    if (NULL == oldkeys) return;
+    for (CFIndex idx = 0; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, oldkeys[idx])) {
+            CFIndex match, nomatch;
+            __CFSetFindBuckets2(hc, oldkeys[idx], &match, &nomatch);
+            CFAssert3(kCFNotFound == match, __kCFLogAssertion, "%s(): two values (%p, %p) now hash to the same slot; mutable value changed while in table or hash value is not immutable", __PRETTY_FUNCTION__, oldkeys[idx], hc->_keys[match]);
+            if (kCFNotFound != nomatch) {
+                CF_WRITE_BARRIER_BASE_ASSIGN(keysAllocator, keysBase, hc->_keys[nomatch], oldkeys[idx]);
+#if CFDictionary
+                CF_WRITE_BARRIER_BASE_ASSIGN(valuesAllocator, valuesBase, hc->_values[nomatch], oldvalues[idx]);
+#endif
+#if CFBag
+                hc->_values[nomatch] = oldvalues[idx];
+#endif
+            }
+        }
+    }
+    _CFAllocatorDeallocateGC(allocator, oldkeys);
+    _CFAllocatorDeallocateGC(allocator, oldvalues);
+}
+
+// This function is for Foundation's benefit; no one else should use it.
+void _CFSetSetCapacity(CFMutableHashRef hc, CFIndex cap) {
+    if (CF_IS_OBJC(__kCFHashTypeID, hc)) return;
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    CFAssert1(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): collection is immutable", __PRETTY_FUNCTION__);
+    CFAssert3(hc->_bucketsUsed <= cap, __kCFLogAssertion, "%s(): desired capacity (%ld) is less than bucket count (%ld)", __PRETTY_FUNCTION__, cap, hc->_bucketsUsed);
+    __CFSetGrow(hc, cap - hc->_bucketsUsed);
+}
+
+
+#if CFDictionary
+void CFSetAddValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFSetAddValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_addObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "addObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        if (hc->_bucketsUsed == hc->_bucketsCap || NULL == hc->_keys) {
+            __CFSetGrow(hc, 1);
+        }
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    CFIndex match, nomatch;
+    __CFSetFindBuckets2(hc, (any_t)key, &match, &nomatch);
+    if (kCFNotFound != match) {
+#if CFBag
+        CF_OBJC_KVO_WILLCHANGE(hc, hc->_keys[match]);
+        hc->_values[match]++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, hc->_keys[match]);
+#endif
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        GETNEWKEY(newKey, key);
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFSetFindNewMarker(hc);
+        }
+        if (hc->_keys[nomatch] == ~hc->_marker) {
+            hc->_deletes--;
+        }
+        CF_OBJC_KVO_WILLCHANGE(hc, key);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+        hc->_values[nomatch] = 1;
+#endif
+        hc->_bucketsUsed++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, key);
+    }
+}
+
+#if CFDictionary
+void CFSetReplaceValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFSetReplaceValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "_replaceObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "_replaceObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFIndex match = __CFSetFindBuckets1(hc, (any_t)key);
+    if (kCFNotFound == match) return;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+    GETNEWKEY(newKey, key);
+#endif
+#if CFDictionary
+    GETNEWVALUE(newValue);
+#endif
+    any_t oldKey = hc->_keys[match];
+    CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFSet || CFBag
+    CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+    CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+    if (__CFHashKeyIsMagic(hc, newKey)) {
+        __CFSetFindNewMarker(hc);
+    }
+    CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+#endif
+#if CFDictionary
+    any_t oldValue = hc->_values[match];
+    CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+    CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+#endif
+    CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+#if CFSet || CFBag
+    RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+    RELEASEVALUE(oldValue);
+#endif
+}
+
+#if CFDictionary
+void CFSetSetValue(CFMutableHashRef hc, const_any_pointer_t key, const_any_pointer_t value) {
+#endif
+#if CFSet || CFBag
+void CFSetSetValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    #define value 0
+#endif
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH2(__kCFHashTypeID, void, hc, "setObject:forKey:", value, key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "_setObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        if (hc->_bucketsUsed == hc->_bucketsCap || NULL == hc->_keys) {
+            __CFSetGrow(hc, 1);
+        }
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    CFIndex match, nomatch;
+    __CFSetFindBuckets2(hc, (any_t)key, &match, &nomatch);
+    if (kCFNotFound == match) {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        GETNEWKEY(newKey, key);
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFSetFindNewMarker(hc);
+        }
+        if (hc->_keys[nomatch] == ~hc->_marker) {
+            hc->_deletes--;
+        }
+        CF_OBJC_KVO_WILLCHANGE(hc, key);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[nomatch], newKey);
+#if CFDictionary
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[nomatch], newValue);
+#endif
+#if CFBag
+        hc->_values[nomatch] = 1;
+#endif
+        hc->_bucketsUsed++;
+        hc->_count++;
+        CF_OBJC_KVO_DIDCHANGE(hc, key);
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+#if CFSet || CFBag
+        GETNEWKEY(newKey, key);
+#endif
+#if CFDictionary
+        GETNEWVALUE(newValue);
+#endif
+        any_t oldKey = hc->_keys[match];
+        CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFSet || CFBag
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+        if (__CFHashKeyIsMagic(hc, newKey)) {
+            __CFSetFindNewMarker(hc);
+        }
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], newKey);
+#endif
+#if CFDictionary
+        any_t oldValue = hc->_values[match];
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], newValue);
+#endif
+        CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+#if CFSet || CFBag
+        RELEASEKEY(oldKey);
+#endif
+#if CFDictionary
+        RELEASEVALUE(oldValue);
+#endif
+    }
+}
+
+void CFSetRemoveValue(CFMutableHashRef hc, const_any_pointer_t key) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "removeObjectForKey:", key);
+    if (CFSet) CF_OBJC_FUNCDISPATCH1(__kCFHashTypeID, void, hc, "removeObject:", key);
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFIndex match = __CFSetFindBuckets1(hc, (any_t)key);
+    if (kCFNotFound == match) return;
+    if (1 < __CFHashGetOccurrenceCount(hc, match)) {
+#if CFBag
+        CF_OBJC_KVO_WILLCHANGE(hc, hc->_keys[match]);
+        hc->_values[match]--;
+        hc->_count--;
+        CF_OBJC_KVO_DIDCHANGE(hc, hc->_keys[match]);
+#endif
+    } else {
+        CFAllocatorRef allocator = __CFGetAllocator(hc);
+        any_t oldKey = hc->_keys[match];
+        CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+        CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[match], ~hc->_marker);
+#if CFDictionary
+        any_t oldValue = hc->_values[match];
+        CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+        CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[match], 0);
+#endif
+#if CFBag
+        hc->_values[match] = 0;
+#endif
+        hc->_count--;
+        hc->_bucketsUsed--;
+        hc->_deletes++;
+        CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+        RELEASEKEY(oldKey);
+#if CFDictionary
+        RELEASEVALUE(oldValue);
+#endif
+        if (__CFSetShouldShrink(hc)) {
+            __CFSetGrow(hc, 0);
+        } else {
+            // When the probeskip == 1 always and only, a DELETED slot followed by an EMPTY slot
+            // can be converted to an EMPTY slot.  By extension, a chain of DELETED slots followed
+            // by an EMPTY slot can be converted to EMPTY slots, which is what we do here.
+            if (match < hc->_bucketsNum - 1 && hc->_keys[match + 1] == hc->_marker) {
+                while (0 <= match && hc->_keys[match] == ~hc->_marker) {
+                    hc->_keys[match] = hc->_marker;
+                    hc->_deletes--;
+                    match--;
+                }
+            }
+        }
+    }
+}
+
+void CFSetRemoveAllValues(CFMutableHashRef hc) {
+    if (CFDictionary) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, void, hc, "removeAllObjects");
+    if (CFSet) CF_OBJC_FUNCDISPATCH0(__kCFHashTypeID, void, hc, "removeAllObjects");
+    __CFGenericValidateType(hc, __kCFHashTypeID);
+    switch (__CFHashGetType(hc)) {
+    case __kCFHashMutable:
+        break;
+    default:
+        CFAssert2(__CFHashGetType(hc) != __kCFHashImmutable, __kCFLogAssertion, "%s(): immutable collection %p passed to mutating operation", __PRETTY_FUNCTION__, hc);
+        break;
+    }
+    hc->_mutations++;
+    if (0 == hc->_bucketsUsed) return;
+    CFAllocatorRef allocator = __CFGetAllocator(hc);
+    any_t *keys = hc->_keys;
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        if (__CFHashKeyIsValue(hc, keys[idx])) {
+            any_t oldKey = keys[idx];
+            CF_OBJC_KVO_WILLCHANGE(hc, oldKey);
+#if CFDictionary || CFSet
+            hc->_count--;
+#endif
+#if CFBag
+            hc->_count -= hc->_values[idx];
+#endif
+            CFAllocatorRef keysAllocator = (hc->_xflags & __kCFHashWeakKeys) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(keysAllocator, hc->_keys[idx], ~hc->_marker);
+#if CFDictionary
+            any_t oldValue = hc->_values[idx];
+            CFAllocatorRef valuesAllocator = (hc->_xflags & __kCFHashWeakValues) ? kCFAllocatorNull : allocator;
+            CF_WRITE_BARRIER_ASSIGN(valuesAllocator, hc->_values[idx], 0);
+#endif
+#if CFBag
+            hc->_values[idx] = 0;
+#endif
+            hc->_bucketsUsed--;
+            hc->_deletes++;
+            CF_OBJC_KVO_DIDCHANGE(hc, oldKey);
+            RELEASEKEY(oldKey);
+#if CFDictionary
+            RELEASEVALUE(oldValue);
+#endif
+        }
+    }
+    for (CFIndex idx = 0, nbuckets = hc->_bucketsNum; idx < nbuckets; idx++) {
+        keys[idx] = hc->_marker;
+    }
+    hc->_deletes = 0;
+    hc->_bucketsUsed = 0;
+    hc->_count = 0;
+    if (__CFSetShouldShrink(hc) && (256 <= hc->_bucketsCap)) {
+        __CFSetGrow(hc, 128);
+    }
+}
+
+#undef CF_OBJC_KVO_WILLCHANGE
+#undef CF_OBJC_KVO_DIDCHANGE
+
diff --git a/CoreFoundation/CFSet.h b/CoreFoundation/CFSet.h
new file mode 100644
index 0000000..d9a095c
--- /dev/null
+++ b/CoreFoundation/CFSet.h
@@ -0,0 +1,516 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+/*!
+        @header CFSet
+        CFSet implements a container which stores unique values.
+*/
+
+#if !defined(__COREFOUNDATION_CFSET__)
+#define __COREFOUNDATION_CFSET__ 1
+
+#include <CoreFoundation/CFBase.h>
+
+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 __CFSet * CFSetRef;
+
+/*!
+        @typedef CFMutableSetRef
+	This is the type of a reference to mutable CFSets.
+*/
+typedef struct __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 synomous to SFSetContainsValue.
+	@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 CFSetGetValue
+	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
+
+#endif /* ! __COREFOUNDATION_CFSET__ */
+
diff --git a/CoreFoundation/CFSocket.c b/CoreFoundation/CFSocket.c
new file mode 100644
index 0000000..5dc72f8
--- /dev/null
+++ b/CoreFoundation/CFSocket.c
@@ -0,0 +1,2393 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#define _DARWIN_UNLIMITED_SELECT 1
+
+#include <CoreFoundation/CFSocket.h>
+#include <sys/types.h>
+#include <math.h>
+#include <limits.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include "CFInternal.h"
+#if DEPLOYMENT_TARGET_MACOSX
+#include <libc.h>
+#include <dlfcn.h>
+#define SOCK_DATA_TYPE uint8_t*
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <fcntl.h>
+#include <io.h>
+#include <stdio.h>
+// Careful with remapping these - different WinSock routines return different errors than
+// on BSD, so if these are used many places they won't work.
+#define EINPROGRESS	WSAEINPROGRESS
+#ifdef EBADF
+#undef EBADF
+#endif
+#define EBADF 		WSAENOTSOCK
+extern void gettimeofday(struct timeval *tv, void *dummy);
+#elif DEPLOYMENT_TARGET_LINUX
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#endif /* DEPLOYMENT_TARGET_MACOSX */
+#include "auto_stubs.h"
+
+#if defined(DEBUG)
+#include <stdio.h>
+#endif
+
+#if DEPLOYMENT_TARGET_ANDROID
+#define NBBY 8
+typedef long int fd_mask;
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
+/* Use crazy Microsoft signatures */
+#define SOCK_DATA char*
+#define SOCK_CONST_DATA const char*
+#define read _read
+
+/* The following macro is from:
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * BSD license
+ */
+#define timersub(x, y, z)                       \
+  do                                            \
+  {                                             \
+    (z)->tv_sec = (x)->tv_sec - (y)->tv_sec;    \
+                                                \
+    (z)->tv_usec = (x)->tv_usec - (y)->tv_usec; \
+                                                \
+    if ((z)->tv_usec < 0)                       \
+    {                                           \
+      (z)->tv_sec--;                            \
+      (z)->tv_usec += 1000000;                  \
+    }                                           \
+  }                                             \
+  while (0)
+
+#else
+#define SOCK_DATA void*
+#define SOCK_CONST_DATA const void*
+#endif
+
+// On Mach we use a v0 RunLoopSource to make client callbacks.  That source is signalled by a
+// separate SocketManager thread who uses select() to watch the sockets' fds.
+
+//#define LOG_CFSOCKET
+
+#if !DEPLOYMENT_TARGET_WINDOWS
+#define INVALID_SOCKET (CFSocketNativeHandle)(-1)
+#endif
+
+enum {
+    kCFSocketLeaveErrors = 64   // candidate for publicization in future
+};
+
+static uint16_t __CFSocketDefaultNameRegistryPortNumber = 2454;
+
+CONST_STRING_DECL(kCFSocketCommandKey, "Command")
+CONST_STRING_DECL(kCFSocketNameKey, "Name")
+CONST_STRING_DECL(kCFSocketValueKey, "Value")
+CONST_STRING_DECL(kCFSocketResultKey, "Result")
+CONST_STRING_DECL(kCFSocketErrorKey, "Error")
+CONST_STRING_DECL(kCFSocketRegisterCommand, "Register")
+CONST_STRING_DECL(kCFSocketRetrieveCommand, "Retrieve")
+CONST_STRING_DECL(__kCFSocketRegistryRequestRunLoopMode, "CFSocketRegistryRequest")
+
+#if DEPLOYMENT_TARGET_WINDOWS
+static Boolean __CFSocketWinSockInitialized = false;
+#else
+#define closesocket(a) close((a))
+#define ioctlsocket(a,b,c) ioctl((a),(b),(c))
+#endif
+
+
+CF_INLINE int __CFSocketLastError(void) {
+#if DEPLOYMENT_TARGET_WINDOWS
+    return WSAGetLastError();
+#else
+    return thread_errno();
+#endif
+}
+
+CF_INLINE CFIndex __CFSocketFdGetSize(CFDataRef fdSet) {
+#if DEPLOYMENT_TARGET_WINDOWS
+    fd_set* set = (fd_set*)CFDataGetBytePtr(fdSet);
+    return set ? set->fd_count : 0;
+#else
+    return NBBY * CFDataGetLength(fdSet);
+#endif
+}
+
+CF_INLINE Boolean __CFSocketFdSet(CFSocketNativeHandle sock, CFMutableDataRef fdSet) {
+    /* returns true if a change occurred, false otherwise */
+    Boolean retval = false;
+    if (INVALID_SOCKET != sock && 0 <= sock) {
+#if DEPLOYMENT_TARGET_WINDOWS
+        fd_set* set = (fd_set*)CFDataGetMutableBytePtr(fdSet);
+        if ((set->fd_count * sizeof(SOCKET) + sizeof(u_int)) >= CFDataGetLength(fdSet)) {
+            CFDataIncreaseLength(fdSet, sizeof(SOCKET));
+            set = (fd_set*)CFDataGetMutableBytePtr(fdSet);
+        }
+        if (!FD_ISSET(sock, set)) {
+            retval = true;
+            FD_SET(sock, set);
+        }
+#else
+        CFIndex numFds = NBBY * CFDataGetLength(fdSet);
+        fd_mask *fds_bits;
+        if (sock >= numFds) {
+            CFIndex oldSize = numFds / NFDBITS, newSize = (sock + NFDBITS) / NFDBITS, changeInBytes = (newSize - oldSize) * sizeof(fd_mask);
+            CFDataIncreaseLength(fdSet, changeInBytes);
+            fds_bits = (fd_mask *)CFDataGetMutableBytePtr(fdSet);
+            memset(fds_bits + oldSize, 0, changeInBytes);
+        } else {
+            fds_bits = (fd_mask *)CFDataGetMutableBytePtr(fdSet);
+        }
+        if (!FD_ISSET(sock, (fd_set *)fds_bits)) {
+            retval = true;
+            FD_SET(sock, (fd_set *)fds_bits);
+        }
+#endif
+    }
+    return retval;
+}
+
+
+#define NEW_SOCKET 0
+#if NEW_SOCKET
+
+__private_extern__ void __CFSocketInitialize(void) {}
+
+#else
+
+#define MAX_SOCKADDR_LEN 256
+#define MAX_DATA_SIZE 65535
+#define MAX_CONNECTION_ORIENTED_DATA_SIZE 32768
+
+/* locks are to be acquired in the following order:
+   (1) __CFAllSocketsLock
+   (2) an individual CFSocket's lock
+   (3) __CFActiveSocketsLock
+*/
+static CFSpinLock_t __CFAllSocketsLock = CFSpinLockInit; /* controls __CFAllSockets */
+static CFMutableDictionaryRef __CFAllSockets = NULL;
+static CFSpinLock_t __CFActiveSocketsLock = CFSpinLockInit; /* controls __CFRead/WriteSockets, __CFRead/WriteSocketsFds, __CFSocketManagerThread, and __CFSocketManagerIteration */
+static volatile UInt32 __CFSocketManagerIteration = 0;
+static CFMutableArrayRef __CFWriteSockets = NULL;
+static CFMutableArrayRef __CFReadSockets = NULL;
+static CFMutableDataRef __CFWriteSocketsFds = NULL;
+static CFMutableDataRef __CFReadSocketsFds = NULL;
+#if DEPLOYMENT_TARGET_WINDOWS
+// We need to select on exceptFDs on Win32 to hear of connect failures
+static CFMutableDataRef __CFExceptSocketsFds = NULL;
+#endif
+static CFDataRef zeroLengthData = NULL;
+static Boolean __CFReadSocketsTimeoutInvalid = true;  /* rebuild the timeout value before calling select */
+
+static CFSocketNativeHandle __CFWakeupSocketPair[2] = {INVALID_SOCKET, INVALID_SOCKET};
+static void *__CFSocketManagerThread = NULL;
+
+static CFTypeID __kCFSocketTypeID = _kCFRuntimeNotATypeID;
+static void __CFSocketDoCallback(CFSocketRef s, CFDataRef data, CFDataRef address, CFSocketNativeHandle sock);
+
+struct __CFSocket {
+    CFRuntimeBase _base;
+    struct {
+        unsigned client:8;	// flags set by client (reenable, CloseOnInvalidate)
+        unsigned disabled:8;	// flags marking disabled callbacks
+        unsigned connected:1;	// Are we connected yet?  (also true for connectionless sockets)
+        unsigned writableHint:1;  // Did the polling the socket show it to be writable?
+        unsigned closeSignaled:1;  // Have we seen FD_CLOSE? (only used on Win32)
+        unsigned unused:13;
+    } _f;
+    CFSpinLock_t _lock;
+    CFSpinLock_t _writeLock;
+    CFSocketNativeHandle _socket;	/* immutable */
+    SInt32 _socketType;
+    SInt32 _errorCode;
+    CFDataRef _address;
+    CFDataRef _peerAddress;
+    SInt32 _socketSetCount;
+    CFRunLoopSourceRef _source0;	// v0 RLS, messaged from SocketMgr
+    CFMutableArrayRef _runLoops;
+    CFSocketCallBack _callout;		/* immutable */
+    CFSocketContext _context;		/* immutable */
+    CFMutableArrayRef _dataQueue;	// queues to pass data from SocketMgr thread
+    CFMutableArrayRef _addressQueue;
+	
+	struct timeval _readBufferTimeout;
+	CFMutableDataRef _readBuffer;
+	CFIndex _bytesToBuffer;			/* is length of _readBuffer */
+	CFIndex _bytesToBufferPos;		/* where the next _CFSocketRead starts from */
+	CFIndex _bytesToBufferReadPos;	/* Where the buffer will next be read into (always after _bytesToBufferPos, but less than _bytesToBuffer) */
+	Boolean _atEOF;
+    int _bufferedReadError;
+	
+	CFMutableDataRef _leftoverBytes;
+};
+
+/* Bit 6 in the base reserved bits is used for write-signalled state (mutable) */
+/* Bit 5 in the base reserved bits is used for read-signalled state (mutable) */
+/* Bit 4 in the base reserved bits is used for invalid state (mutable) */
+/* Bits 0-3 in the base reserved bits are used for callback types (immutable) */
+/* Of this, bits 0-1 are used for the read callback type. */
+
+CF_INLINE Boolean __CFSocketIsWriteSignalled(CFSocketRef s) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 6, 6);
+}
+
+CF_INLINE void __CFSocketSetWriteSignalled(CFSocketRef s) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 6, 6, 1);
+}
+
+CF_INLINE void __CFSocketUnsetWriteSignalled(CFSocketRef s) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 6, 6, 0);
+}
+
+CF_INLINE Boolean __CFSocketIsReadSignalled(CFSocketRef s) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 5, 5);
+}
+
+CF_INLINE void __CFSocketSetReadSignalled(CFSocketRef s) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 5, 5, 1);
+}
+
+CF_INLINE void __CFSocketUnsetReadSignalled(CFSocketRef s) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 5, 5, 0);
+}
+
+CF_INLINE Boolean __CFSocketIsValid(CFSocketRef s) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 4, 4);
+}
+
+CF_INLINE void __CFSocketSetValid(CFSocketRef s) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 4, 4, 1);
+}
+
+CF_INLINE void __CFSocketUnsetValid(CFSocketRef s) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 4, 4, 0);
+}
+
+CF_INLINE uint8_t __CFSocketCallBackTypes(CFSocketRef s) {
+    return (uint8_t)__CFBitfieldGetValue(((const CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 3, 0);
+}
+
+CF_INLINE uint8_t __CFSocketReadCallBackType(CFSocketRef s) {
+    return (uint8_t)__CFBitfieldGetValue(((const CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 1, 0);
+}
+
+CF_INLINE void __CFSocketSetCallBackTypes(CFSocketRef s, uint8_t types) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)s)->_cfinfo[CF_INFO_BITS], 3, 0, types & 0xF);
+}
+
+CF_INLINE void __CFSocketLock(CFSocketRef s) {
+    __CFSpinLock(&(s->_lock));
+}
+
+CF_INLINE void __CFSocketUnlock(CFSocketRef s) {
+    __CFSpinUnlock(&(s->_lock));
+}
+
+CF_INLINE Boolean __CFSocketIsConnectionOriented(CFSocketRef s) {
+    return (SOCK_STREAM == s->_socketType || SOCK_SEQPACKET == s->_socketType);
+}
+
+CF_INLINE Boolean __CFSocketIsScheduled(CFSocketRef s) {
+    return (s->_socketSetCount > 0);
+}
+
+CF_INLINE void __CFSocketEstablishAddress(CFSocketRef s) {
+    /* socket should already be locked */
+    uint8_t name[MAX_SOCKADDR_LEN];
+    int namelen = sizeof(name);
+    if (__CFSocketIsValid(s) && NULL == s->_address && INVALID_SOCKET != s->_socket && 0 == getsockname(s->_socket, (struct sockaddr *)name, (socklen_t *)&namelen) && NULL != name && 0 < namelen) {
+        s->_address = CFDataCreate(CFGetAllocator(s), name, namelen);
+    }
+}
+
+CF_INLINE void __CFSocketEstablishPeerAddress(CFSocketRef s) {
+    /* socket should already be locked */
+    uint8_t name[MAX_SOCKADDR_LEN];
+    int namelen = sizeof(name);
+    if (__CFSocketIsValid(s) && NULL == s->_peerAddress && INVALID_SOCKET != s->_socket && 0 == getpeername(s->_socket, (struct sockaddr *)name, (socklen_t *)&namelen) && NULL != name && 0 < namelen) {
+        s->_peerAddress = CFDataCreate(CFGetAllocator(s), name, namelen);
+    }
+}
+
+static Boolean __CFNativeSocketIsValid(CFSocketNativeHandle sock) {
+#if DEPLOYMENT_TARGET_WINDOWS
+    SInt32 flags = ioctlsocket (sock, FIONREAD, 0);
+    return (0 == flags);
+#else
+    SInt32 flags = fcntl(sock, F_GETFL, 0);
+    return !(0 > flags && EBADF == thread_errno());
+#endif
+}
+
+CF_INLINE Boolean __CFSocketFdClr(CFSocketNativeHandle sock, CFMutableDataRef fdSet) {
+    /* returns true if a change occurred, false otherwise */
+    Boolean retval = false;
+    if (INVALID_SOCKET != sock && 0 <= sock) {
+#if DEPLOYMENT_TARGET_WINDOWS
+        fd_set* set = (fd_set*)CFDataGetMutableBytePtr(fdSet);
+        if (FD_ISSET(sock, set)) {
+            retval = true;
+            FD_CLR(sock, set);
+        }
+#else
+        CFIndex numFds = NBBY * CFDataGetLength(fdSet);
+        fd_mask *fds_bits;
+        if (sock < numFds) {
+            fds_bits = (fd_mask *)CFDataGetMutableBytePtr(fdSet);
+            if (FD_ISSET(sock, (fd_set *)fds_bits)) {
+                retval = true;
+                FD_CLR(sock, (fd_set *)fds_bits);
+            }
+        }
+#endif
+    }
+    return retval;
+}
+
+static SInt32 __CFSocketCreateWakeupSocketPair(void) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+    return socketpair(PF_LOCAL, SOCK_DGRAM, 0, __CFWakeupSocketPair);
+#else
+    //??? should really use native Win32 facilities
+    UInt32 i;
+    SInt32 error = 0;
+    struct sockaddr_in address[2];
+    int namelen = sizeof(struct sockaddr_in);
+    for (i = 0; i < 2; i++) {
+        __CFWakeupSocketPair[i] = (CFSocketNativeHandle)socket(PF_INET, SOCK_DGRAM, 0);
+        memset(&(address[i]), 0, sizeof(struct sockaddr_in));
+        address[i].sin_family = AF_INET;
+        address[i].sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+        if (0 <= error) error = bind(__CFWakeupSocketPair[i], (struct sockaddr *)&(address[i]), sizeof(struct sockaddr_in));
+        if (0 <= error) error = getsockname(__CFWakeupSocketPair[i], (struct sockaddr *)&(address[i]), &namelen);
+        if (sizeof(struct sockaddr_in) != namelen) error = -1;
+    }
+    if (0 <= error) error = connect(__CFWakeupSocketPair[0], (struct sockaddr *)&(address[1]), sizeof(struct sockaddr_in));
+    if (0 <= error) error = connect(__CFWakeupSocketPair[1], (struct sockaddr *)&(address[0]), sizeof(struct sockaddr_in));
+    if (0 > error) {
+        closesocket(__CFWakeupSocketPair[0]);
+        closesocket(__CFWakeupSocketPair[1]);
+    }
+    return error;
+#endif
+}
+
+
+// Version 0 RunLoopSources set a mask in an FD set to control what socket activity we hear about.
+CF_INLINE Boolean __CFSocketSetFDForRead(CFSocketRef s) {
+    __CFReadSocketsTimeoutInvalid = true;   
+    return __CFSocketFdSet(s->_socket, __CFReadSocketsFds);
+}
+
+CF_INLINE Boolean __CFSocketClearFDForRead(CFSocketRef s) {
+    __CFReadSocketsTimeoutInvalid = true;   
+    return __CFSocketFdClr(s->_socket, __CFReadSocketsFds);
+}
+
+CF_INLINE Boolean __CFSocketSetFDForWrite(CFSocketRef s) {
+    return __CFSocketFdSet(s->_socket, __CFWriteSocketsFds);
+}
+
+CF_INLINE Boolean __CFSocketClearFDForWrite(CFSocketRef s) {
+    return __CFSocketFdClr(s->_socket, __CFWriteSocketsFds);
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS
+static Boolean WinSockUsed = FALSE;
+
+static void __CFSocketInitializeWinSock_Guts(void) {
+    if (!WinSockUsed) {
+        WinSockUsed = TRUE;
+        WORD versionRequested = MAKEWORD(2, 0);
+        WSADATA wsaData;
+        int errorStatus = WSAStartup(versionRequested, &wsaData);
+        if (errorStatus != 0 || LOBYTE(wsaData.wVersion) != LOBYTE(versionRequested) || HIBYTE(wsaData.wVersion) != HIBYTE(versionRequested)) {
+            WSACleanup();
+            CFLog(0, CFSTR("*** Could not initialize WinSock subsystem!!!"));
+        }
+    }
+}
+
+CF_EXPORT void __CFSocketInitializeWinSock(void) {
+    __CFSpinLock(&__CFActiveSocketsLock);
+    __CFSocketInitializeWinSock_Guts();
+    __CFSpinUnlock(&__CFActiveSocketsLock);
+}
+
+__private_extern__ void __CFSocketCleanup(void) {
+    __CFSpinLock(&__CFActiveSocketsLock);
+    if (NULL != __CFReadSockets) {
+        CFRelease(__CFWriteSockets);
+        __CFWriteSockets = NULL;
+        CFRelease(__CFReadSockets);
+        __CFReadSockets = NULL;
+        CFRelease(__CFWriteSocketsFds);
+        __CFWriteSocketsFds = NULL;
+        CFRelease(__CFReadSocketsFds);
+        __CFReadSocketsFds = NULL;
+        CFRelease(__CFExceptSocketsFds);
+        __CFExceptSocketsFds = NULL;
+        CFRelease(zeroLengthData);
+        zeroLengthData = NULL;
+    }
+    if (NULL != __CFAllSockets) {
+        CFRelease(__CFAllSockets);
+        __CFAllSockets = NULL;
+    }
+    if (INVALID_SOCKET != __CFWakeupSocketPair[0]) {
+        closesocket(__CFWakeupSocketPair[0]);
+        __CFWakeupSocketPair[0] = INVALID_SOCKET;
+    }
+    if (INVALID_SOCKET != __CFWakeupSocketPair[1]) {
+        closesocket(__CFWakeupSocketPair[1]);
+        __CFWakeupSocketPair[1] = INVALID_SOCKET;
+    }
+    if (WinSockUsed) {
+        WSACleanup();
+    }
+    __CFSpinUnlock(&__CFActiveSocketsLock);
+}
+#endif
+
+
+// CFNetwork needs to call this, especially for Win32 to get WSAStartup
+static void __CFSocketInitializeSockets(void) {
+    __CFWriteSockets = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+    __CFReadSockets = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, NULL);
+    __CFWriteSocketsFds = CFDataCreateMutable(kCFAllocatorSystemDefault, 0);
+    __CFReadSocketsFds = CFDataCreateMutable(kCFAllocatorSystemDefault, 0);
+    zeroLengthData = CFDataCreateMutable(kCFAllocatorSystemDefault, 0);
+#if DEPLOYMENT_TARGET_WINDOWS
+    __CFSocketInitializeWinSock_Guts();
+    // make sure we have space for the count field and the first socket
+    CFDataIncreaseLength(__CFWriteSocketsFds, sizeof(u_int) + sizeof(SOCKET));
+    CFDataIncreaseLength(__CFReadSocketsFds, sizeof(u_int) + sizeof(SOCKET));
+    __CFExceptSocketsFds = CFDataCreateMutable(kCFAllocatorSystemDefault, 0);
+    CFDataIncreaseLength(__CFExceptSocketsFds, sizeof(u_int) + sizeof(SOCKET));
+#endif
+    if (0 > __CFSocketCreateWakeupSocketPair()) {
+        CFLog(kCFLogLevelWarning, CFSTR("*** Could not create wakeup socket pair for CFSocket!!!"));
+    } else {
+#if DEPLOYMENT_TARGET_WINDOWS
+        u_long yes = 1;
+#else
+        UInt32 yes = 1;
+#endif
+        /* wakeup sockets must be non-blocking */
+        ioctlsocket(__CFWakeupSocketPair[0], FIONBIO, &yes);
+        ioctlsocket(__CFWakeupSocketPair[1], FIONBIO, &yes);
+        __CFSocketFdSet(__CFWakeupSocketPair[1], __CFReadSocketsFds);
+    }
+}
+
+static CFRunLoopRef __CFSocketCopyRunLoopToWakeUp(CFSocketRef s) {
+    CFRunLoopRef rl = NULL;
+    SInt32 idx, cnt = CFArrayGetCount(s->_runLoops);
+    if (0 < cnt) {
+        rl = (CFRunLoopRef)CFArrayGetValueAtIndex(s->_runLoops, 0);
+        for (idx = 1; NULL != rl && idx < cnt; idx++) {
+            CFRunLoopRef value = (CFRunLoopRef)CFArrayGetValueAtIndex(s->_runLoops, idx);
+            if (value != rl) rl = NULL;
+        }
+        if (NULL == rl) {	/* more than one different rl, so we must pick one */
+            /* ideally, this would be a run loop which isn't also in a
+            * signaled state for this or another source, but that's tricky;
+            * we pick one that is running in an appropriate mode for this
+            * source, and from those if possible one that is waiting; then
+            * we move this run loop to the end of the list to scramble them
+            * a bit, and always search from the front */
+            Boolean foundIt = false, foundBackup = false;
+            SInt32 foundIdx = 0;
+            for (idx = 0; !foundIt && idx < cnt; idx++) {
+                CFRunLoopRef value = (CFRunLoopRef)CFArrayGetValueAtIndex(s->_runLoops, idx);
+                CFStringRef currentMode = CFRunLoopCopyCurrentMode(value);
+                if (NULL != currentMode) {
+                    if (CFRunLoopContainsSource(value, s->_source0, currentMode)) {
+                        if (CFRunLoopIsWaiting(value)) {
+                            foundIdx = idx;
+                            foundIt = true;
+                        } else if (!foundBackup) {
+                            foundIdx = idx;
+                            foundBackup = true;
+                        }
+                    }
+                    CFRelease(currentMode);
+                }
+            }
+            rl = (CFRunLoopRef)CFArrayGetValueAtIndex(s->_runLoops, foundIdx);
+            CFRetain(rl);
+            CFArrayRemoveValueAtIndex(s->_runLoops, foundIdx);
+            CFArrayAppendValue(s->_runLoops, rl);
+        } else {
+            CFRetain(rl);
+        }
+    }
+    return rl;
+}
+
+// If callBackNow, we immediately do client callbacks, else we have to signal a v0 RunLoopSource so the
+// callbacks can happen in another thread.
+static void __CFSocketHandleWrite(CFSocketRef s, Boolean callBackNow) {
+    SInt32 errorCode = 0;
+    int errorSize = sizeof(errorCode);
+    CFOptionFlags writeCallBacksAvailable;
+    
+    if (!CFSocketIsValid(s)) return;
+#if DEPLOYMENT_TARGET_WINDOWS
+    if (0 != (s->_f.client & kCFSocketLeaveErrors) || 0 != getsockopt(s->_socket, SOL_SOCKET, SO_ERROR, (char *)&errorCode, (socklen_t *)&errorSize)) errorCode = 0;	// cast for WinSock bad API
+#else
+    if (0 != (s->_f.client & kCFSocketLeaveErrors) || 0 != getsockopt(s->_socket, SOL_SOCKET, SO_ERROR, (void *)&errorCode, (socklen_t *)&errorSize)) errorCode = 0;	// cast for WinSock bad API
+#endif
+#if defined(LOG_CFSOCKET)
+    if (errorCode) fprintf(stdout, "error %ld on socket %d\n", errorCode, s->_socket);
+#endif
+    __CFSocketLock(s);
+    writeCallBacksAvailable = __CFSocketCallBackTypes(s) & (kCFSocketWriteCallBack | kCFSocketConnectCallBack);
+    if ((s->_f.client & kCFSocketConnectCallBack) != 0) writeCallBacksAvailable &= ~kCFSocketConnectCallBack;
+    if (!__CFSocketIsValid(s) || ((s->_f.disabled & writeCallBacksAvailable) == writeCallBacksAvailable)) {
+        __CFSocketUnlock(s);
+        return;
+    }
+    s->_errorCode = errorCode;
+    __CFSocketSetWriteSignalled(s);
+#if defined(LOG_CFSOCKET)
+    fprintf(stdout, "write signaling source for socket %d\n", s->_socket);
+#endif
+    if (callBackNow) {
+        __CFSocketDoCallback(s, NULL, NULL, 0);
+    } else {
+        CFRunLoopRef rl;
+        CFRunLoopSourceSignal(s->_source0);
+        rl = __CFSocketCopyRunLoopToWakeUp(s);
+        __CFSocketUnlock(s);
+        if (NULL != rl) {
+            CFRunLoopWakeUp(rl);
+            CFRelease(rl);
+        }
+    }
+}
+
+static void __CFSocketHandleRead(CFSocketRef s, Boolean causedByTimeout)
+{
+    CFDataRef data = NULL, address = NULL;
+    CFSocketNativeHandle sock = INVALID_SOCKET;
+    if (!CFSocketIsValid(s)) return;
+    if (__CFSocketReadCallBackType(s) == kCFSocketDataCallBack) {
+        uint8_t bufferArray[MAX_CONNECTION_ORIENTED_DATA_SIZE], *buffer;
+        uint8_t name[MAX_SOCKADDR_LEN];
+#if !DEPLOYMENT_TARGET_WINDOWS
+        int namelen = sizeof(name);
+#else
+	     int namelen = 0;
+#endif
+        SInt32 recvlen = 0;
+        if (__CFSocketIsConnectionOriented(s)) {
+            buffer = bufferArray;
+            recvlen = recvfrom(s->_socket, (SOCK_DATA)buffer, MAX_CONNECTION_ORIENTED_DATA_SIZE, 0, (struct sockaddr *)name, (socklen_t *)&namelen);
+        } else {
+            buffer = (uint8_t*)malloc(MAX_DATA_SIZE);
+            if (buffer) recvlen = recvfrom(s->_socket, (SOCK_DATA)buffer, MAX_DATA_SIZE, 0, (struct sockaddr *)name, (socklen_t *)&namelen);
+        }
+#if defined(LOG_CFSOCKET)
+        fprintf(stdout, "read %ld bytes on socket %d\n", recvlen, s->_socket);
+#endif
+        if (0 >= recvlen) {
+            //??? should return error if <0
+            /* zero-length data is the signal for perform to invalidate */
+            data = (CFDataRef)CFRetain(zeroLengthData);
+        } else {
+            data = CFDataCreate(CFGetAllocator(s), buffer, recvlen);
+        }
+        if (buffer && buffer != bufferArray) free(buffer);
+        __CFSocketLock(s);
+        if (!__CFSocketIsValid(s)) {
+            CFRelease(data);
+            __CFSocketUnlock(s);
+            return;
+        }
+        __CFSocketSetReadSignalled(s);
+        if (NULL != name && 0 < namelen) {
+            //??? possible optimizations:  uniquing; storing last value
+            address = CFDataCreate(CFGetAllocator(s), name, namelen);
+        } else if (__CFSocketIsConnectionOriented(s)) {
+            if (NULL == s->_peerAddress) __CFSocketEstablishPeerAddress(s);
+            if (NULL != s->_peerAddress) address = (CFDataRef)CFRetain(s->_peerAddress);
+        }
+        if (NULL == address) {
+            address = (CFDataRef)CFRetain(zeroLengthData);
+        }
+        if (NULL == s->_dataQueue) {
+            s->_dataQueue = CFArrayCreateMutable(CFGetAllocator(s), 0, &kCFTypeArrayCallBacks);
+        }
+        if (NULL == s->_addressQueue) {
+            s->_addressQueue = CFArrayCreateMutable(CFGetAllocator(s), 0, &kCFTypeArrayCallBacks);
+        }
+        CFArrayAppendValue(s->_dataQueue, data);
+        CFRelease(data);
+        CFArrayAppendValue(s->_addressQueue, address);
+        CFRelease(address);
+        if (0 < recvlen
+            && (s->_f.client & kCFSocketDataCallBack) != 0 && (s->_f.disabled & kCFSocketDataCallBack) == 0
+            && __CFSocketIsScheduled(s)
+        ) {
+            __CFSpinLock(&__CFActiveSocketsLock);
+            /* restore socket to fds */
+            __CFSocketSetFDForRead(s);
+            __CFSpinUnlock(&__CFActiveSocketsLock);
+        }
+    } else if (__CFSocketReadCallBackType(s) == kCFSocketAcceptCallBack) {
+        uint8_t name[MAX_SOCKADDR_LEN];
+        int namelen = sizeof(name);
+        sock = (CFSocketNativeHandle)accept(s->_socket, (struct sockaddr *)name, (socklen_t *)&namelen);
+        if (INVALID_SOCKET == sock) {
+            //??? should return error
+            return;
+        }
+        if (NULL != name && 0 < namelen) {
+            address = CFDataCreate(CFGetAllocator(s), name, namelen);
+        } else {
+            address = (CFDataRef)CFRetain(zeroLengthData);
+        }
+        __CFSocketLock(s);
+        if (!__CFSocketIsValid(s)) {
+            closesocket(sock);
+            CFRelease(address);
+            __CFSocketUnlock(s);
+            return;
+        }
+        __CFSocketSetReadSignalled(s);
+        if (NULL == s->_dataQueue) {
+            s->_dataQueue = CFArrayCreateMutable(CFGetAllocator(s), 0, NULL);
+        }
+        if (NULL == s->_addressQueue) {
+            s->_addressQueue = CFArrayCreateMutable(CFGetAllocator(s), 0, &kCFTypeArrayCallBacks);
+        }
+        CFArrayAppendValue(s->_dataQueue, (void *)(uintptr_t)sock);
+        CFArrayAppendValue(s->_addressQueue, address);
+        CFRelease(address);
+        if ((s->_f.client & kCFSocketAcceptCallBack) != 0 && (s->_f.disabled & kCFSocketAcceptCallBack) == 0
+            && __CFSocketIsScheduled(s)
+        ) {
+            __CFSpinLock(&__CFActiveSocketsLock);
+            /* restore socket to fds */
+            __CFSocketSetFDForRead(s);
+            __CFSpinUnlock(&__CFActiveSocketsLock);
+        }
+    } else {
+        __CFSocketLock(s);
+        if (!__CFSocketIsValid(s) || (s->_f.disabled & kCFSocketReadCallBack) != 0) {
+            __CFSocketUnlock(s);
+            return;
+        }
+		
+		if (causedByTimeout) {
+#if defined(LOG_CFSOCKET)
+			fprintf(stdout, "TIMEOUT RECEIVED - WILL SIGNAL IMMEDIATELY TO FLUSH (%d buffered)\n", s->_bytesToBufferPos);
+#endif
+            /* we've got a timeout, but no bytes read.  Ignore the timeout. */
+            if (s->_bytesToBufferPos == 0) {
+#if defined(LOG_CFSOCKET)
+                fprintf(stdout, "TIMEOUT - but no bytes, restoring to active set\n");
+                fflush(stdout);
+#endif
+
+                __CFSpinLock(&__CFActiveSocketsLock);
+                /* restore socket to fds */
+                __CFSocketSetFDForRead(s);
+                __CFSpinUnlock(&__CFActiveSocketsLock);
+                __CFSocketUnlock(s);
+                return;
+            }
+		} else if (s->_bytesToBuffer != 0 && ! s->_atEOF) {
+			UInt8* base;
+			CFIndex ctRead;
+			CFIndex ctRemaining = s->_bytesToBuffer - s->_bytesToBufferPos;
+
+			/* if our buffer has room, we go ahead and buffer */
+			if (ctRemaining > 0) {
+				base = CFDataGetMutableBytePtr(s->_readBuffer);
+			
+				do {
+					ctRead = read(CFSocketGetNative(s), &base[s->_bytesToBufferPos], ctRemaining);
+				} while (ctRead == -1 && errno == EAGAIN);
+
+				switch (ctRead) {
+				case -1:
+					s->_bufferedReadError = errno;
+					s->_atEOF = true;
+#if defined(LOG_CFSOCKET)
+					fprintf(stderr, "BUFFERED READ GOT ERROR %d\n", errno);
+#endif
+					break;
+
+				case 0:
+	#if defined(LOG_CFSOCKET)
+					fprintf(stdout, "DONE READING (EOF) - GOING TO SIGNAL\n");
+	#endif
+					s->_atEOF = true;
+					break;
+			
+				default:
+					s->_bytesToBufferPos += ctRead;
+					if (s->_bytesToBuffer != s->_bytesToBufferPos) {
+	#if defined(LOG_CFSOCKET)
+						fprintf(stdout, "READ %d - need %d MORE - GOING BACK FOR MORE\n", ctRead, s->_bytesToBuffer - s->_bytesToBufferPos);
+	#endif
+						__CFSpinLock(&__CFActiveSocketsLock);
+						/* restore socket to fds */
+						__CFSocketSetFDForRead(s);
+						__CFSpinUnlock(&__CFActiveSocketsLock);
+						__CFSocketUnlock(s);
+						return;
+					} else {
+	#if defined(LOG_CFSOCKET)
+						fprintf(stdout, "DONE READING (read %d bytes) - GOING TO SIGNAL\n", ctRead);
+	#endif
+					}
+				}
+			}
+		}
+
+		__CFSocketSetReadSignalled(s);
+    }
+#if defined(LOG_CFSOCKET)
+    fprintf(stdout, "read signaling source for socket %d\n", s->_socket);
+#endif
+    CFRunLoopSourceSignal(s->_source0);
+    CFRunLoopRef rl = __CFSocketCopyRunLoopToWakeUp(s);
+    __CFSocketUnlock(s);
+    if (NULL != rl) {
+        CFRunLoopWakeUp(rl);
+        CFRelease(rl);
+    }
+}
+
+static struct timeval* intervalToTimeval(CFTimeInterval timeout, struct timeval* tv)
+{
+    if (timeout == 0.0)
+        timerclear(tv);
+    else {
+        tv->tv_sec = (0 >= timeout || INT_MAX <= timeout) ? INT_MAX : (int)(float)floor(timeout);
+        tv->tv_usec = (int)((timeout - floor(timeout)) * 1.0E6);
+    }
+    return tv;
+}
+
+/* note that this returns a pointer to the min value, which won't have changed during
+ the dictionary apply, since we've got the active sockets lock held */
+static void _calcMinTimeout_locked(const void* val, void* ctxt)
+{
+	CFSocketRef s = (CFSocketRef) val;
+	struct timeval** minTime = (struct timeval**) ctxt;
+	if (timerisset(&s->_readBufferTimeout) && (*minTime == NULL || timercmp(&s->_readBufferTimeout, *minTime, <)))
+		*minTime = &s->_readBufferTimeout;
+   else if (s->_leftoverBytes) {
+      /* If there's anyone with leftover bytes, they'll need to be awoken immediately */
+      static struct timeval sKickerTime = { 0, 0 };
+      *minTime = &sKickerTime;
+   }
+}
+
+void __CFSocketSetSocketReadBufferAttrs(CFSocketRef s, CFTimeInterval timeout, CFIndex length)
+{
+   struct timeval timeoutVal;
+   
+   intervalToTimeval(timeout, &timeoutVal);
+   
+	/* lock ordering is socket lock, activesocketslock */
+	/* activesocketslock protects our timeout calculation */
+   __CFSocketLock(s);
+	__CFSpinLock(&__CFActiveSocketsLock);
+   
+#if defined(LOG_CFSOCKET)
+   s->didLogSomething = false;
+#endif
+   
+	if (s->_bytesToBuffer != length) {
+      CFIndex ctBuffer = s->_bytesToBufferPos - s->_bytesToBufferReadPos;
+      
+      if (ctBuffer) {
+			/* As originally envisaged, you were supposed to be sure to drain the buffer before 
+			 * issuing another request on the socket.  In practice, there seem to be times when we want to re-use 
+			 * the stream (or perhaps, are on our way to closing it out) and this policy doesn't work so well.  
+			 * So, if someone changes the buffer size while we have bytes already buffered, we put them 
+			 * aside and use them to satisfy any subsequent reads. 
+			 */
+#if defined(LOG_CFSOCKET)
+         __socketLog("%s(%d): WARNING: shouldn't set read buffer length while data (%d bytes) is still in the read buffer (leftover total %d)", __FUNCTION__, __LINE__, ctBuffer, s->_leftoverBytes? CFDataGetLength(s->_leftoverBytes) : 0);
+#endif
+         
+			if (s->_leftoverBytes == NULL)
+				s->_leftoverBytes = CFDataCreateMutable(CFGetAllocator(s), 0);
+         
+			/* append the current buffered bytes over.  We'll keep draining _leftoverBytes while we have them... */
+         CFDataAppendBytes(s->_leftoverBytes, CFDataGetBytePtr(s->_readBuffer) + s->_bytesToBufferReadPos, ctBuffer);
+			CFRelease(s->_readBuffer);
+			s->_readBuffer = NULL;
+         
+			s->_bytesToBuffer = 0;
+			s->_bytesToBufferPos = 0;
+			s->_bytesToBufferReadPos = 0;
+		}
+		if (length == 0) {
+			s->_bytesToBuffer = 0;
+			s->_bytesToBufferPos = 0;
+			s->_bytesToBufferReadPos = 0;
+			if (s->_readBuffer) {
+				CFRelease(s->_readBuffer);
+				s->_readBuffer = NULL;
+			}
+         // Zero length buffer, smash the timeout
+         static struct timeval sReset = { 0, 0 };
+         timeoutVal = sReset;
+		} else {
+			/* if the buffer shrank, we can re-use the old one */
+			if (length > s->_bytesToBuffer) {
+				if (s->_readBuffer) {
+					CFRelease(s->_readBuffer);
+					s->_readBuffer = NULL;
+				}
+			}
+			
+			s->_bytesToBuffer = length;
+			s->_bytesToBufferPos = 0;
+			s->_bytesToBufferReadPos = 0;
+			if (s->_readBuffer == NULL) {
+            s->_readBuffer = CFDataCreateMutable(kCFAllocatorSystemDefault, length);
+				CFDataSetLength(s->_readBuffer, length);
+			}
+		}
+	}
+   
+   if (timercmp(&s->_readBufferTimeout, &timeoutVal, !=)) {
+      s->_readBufferTimeout = timeoutVal;
+      __CFReadSocketsTimeoutInvalid = true;
+   }
+   
+   __CFSpinUnlock(&__CFActiveSocketsLock);
+	__CFSocketUnlock(s);
+}
+
+void __CFSocketSetReadBufferTimeout(CFSocketRef s, CFTimeInterval timeout)
+{
+#if defined(LOG_CFSOCKET)
+   __socketLog("### (%s DEPRECATED) SET READ BUFFER TIMEOUT for %p (bufferSize %d, timeout %d.%d)\n", __FUNCTION__, s, s->_bytesToBuffer, s->_readBufferTimeout.tv_sec, s->_readBufferTimeout.tv_usec);
+#endif
+   
+   __CFSocketSetSocketReadBufferAttrs(s, timeout, s->_bytesToBuffer);
+}
+
+void __CFSocketSetReadBufferLength(CFSocketRef s, CFIndex length)
+{
+#if defined(LOG_CFSOCKET)
+   __socketLog("### (%s DEPRECATED) SET READ BUFFER LENGTH for %p (bufferSize %d, timeout %d.%d)\n", __FUNCTION__, s, s->_bytesToBuffer, s->_readBufferTimeout.tv_sec, s->_readBufferTimeout.tv_usec);
+#endif
+   
+   CFTimeInterval timeout;
+   
+   if (! timerisset(&s->_readBufferTimeout))
+      timeout = 0;
+   else
+      timeout = 0.1;
+   
+   __CFSocketSetSocketReadBufferAttrs(s, timeout, length);   
+}
+
+CFIndex __CFSocketRead(CFSocketRef s, UInt8* buffer, CFIndex length, int* error)
+{
+#if defined(LOG_CFSOCKET)
+	fprintf(stdout, "READING BYTES FOR SOCKET %d (%d buffered, out of %d desired, eof = %d, err = %d)\n", s->_socket, s->_bytesToBufferPos, s->_bytesToBuffer, s->_atEOF, s->_bufferedReadError);
+#endif
+
+    CFIndex result = -1;
+
+    __CFSocketLock(s);
+
+	*error = 0;
+	
+	/* Any leftover buffered bytes? */
+	if (s->_leftoverBytes) {
+		CFIndex ctBuffer = CFDataGetLength(s->_leftoverBytes);
+#if defined(DEBUG)
+		fprintf(stderr, "%s(%d): WARNING: Draining %lu leftover bytes first\n\n", __FUNCTION__, __LINE__, ctBuffer);
+#endif
+		if (ctBuffer > length)
+			ctBuffer = length;
+		memcpy(buffer, CFDataGetBytePtr(s->_leftoverBytes), ctBuffer);
+		if (ctBuffer < CFDataGetLength(s->_leftoverBytes))
+			CFDataReplaceBytes(s->_leftoverBytes, CFRangeMake(0, ctBuffer), NULL, 0);
+		else {
+			CFRelease(s->_leftoverBytes);
+			s->_leftoverBytes = NULL;
+		}
+		result = ctBuffer;
+		goto unlock;
+	}
+	
+	/* return whatever we've buffered */
+	if (s->_bytesToBuffer != 0) {
+		CFIndex ctBuffer = s->_bytesToBufferPos - s->_bytesToBufferReadPos;
+		if (ctBuffer > 0) {
+			/* drain our buffer first */
+			if (ctBuffer > length)
+				ctBuffer = length;
+			memcpy(buffer, CFDataGetBytePtr(s->_readBuffer) + s->_bytesToBufferReadPos, ctBuffer);
+			s->_bytesToBufferReadPos += ctBuffer;
+			if (s->_bytesToBufferReadPos == s->_bytesToBufferPos) {
+#if defined(LOG_CFSOCKET)
+				fprintf(stdout, "DRAINED BUFFER - SHOULD START BUFFERING AGAIN!\n");
+#endif
+				s->_bytesToBufferPos = 0;
+				s->_bytesToBufferReadPos = 0;
+			}
+			
+#if defined(LOG_CFSOCKET)
+			fprintf(stdout, "SLURPED %d BYTES FROM BUFFER %d LEFT TO READ!\n", ctBuffer, length);
+#endif
+
+			result = ctBuffer;
+            goto unlock;
+		}
+	}
+	/* nothing buffered, or no buffer selected */
+	
+	/* Did we get an error on a previous read (or buffered read)? */
+	if (s->_bufferedReadError != 0) {
+#if defined(LOG_CFSOCKET)
+		fprintf(stdout, "RETURNING ERROR %d\n", s->_bufferedReadError);
+#endif
+		*error = s->_bufferedReadError;
+        result = -1;
+        goto unlock;
+	}
+	
+	/* nothing buffered, if we've hit eof, don't bother reading any more */
+	if (s->_atEOF) {
+#if defined(LOG_CFSOCKET)
+		fprintf(stdout, "RETURNING EOF\n");
+#endif
+		result = 0;
+        goto unlock;
+	}
+	
+	/* normal read */
+	result = read(CFSocketGetNative(s), buffer, length);
+#if defined(LOG_CFSOCKET)
+	fprintf(stdout, "READ %d bytes", result);
+#endif
+
+    if (result == 0) {
+        /* note that we hit EOF */
+        s->_atEOF = true;
+    } else if (result < 0) {
+        *error = errno;
+
+        /* if it wasn't EAGAIN, record it (although we shouldn't get called again) */
+        if (*error != EAGAIN) {
+            s->_bufferedReadError = *error;
+        }
+    }
+
+unlock:
+    __CFSocketUnlock(s);
+
+    return result;
+}
+
+Boolean __CFSocketGetBytesAvailable(CFSocketRef s, CFIndex* ctBytesAvailable)
+{
+	CFIndex ctBuffer = s->_bytesToBufferPos - s->_bytesToBufferReadPos;
+	if (ctBuffer != 0) {
+		*ctBytesAvailable = ctBuffer;
+		return true;
+	} else {
+		int result;
+#if DEPLOYMENT_TARGET_MACOSX
+	    int bytesAvailable, intLen = sizeof(bytesAvailable);
+	    result = getsockopt(CFSocketGetNative(s), SOL_SOCKET, SO_NREAD, &bytesAvailable, (socklen_t *)&intLen);
+#elif DEPLOYMENT_TARGET_WINDOWS
+	    unsigned long bytesAvailable;
+	    result = ioctlsocket(CFSocketGetNative(s), FIONREAD, &bytesAvailable);
+#else
+		CFIndex bytesAvailable = 0;
+		result = -1;
+#endif
+		if (result < 0)
+			return false;
+		*ctBytesAvailable = (CFIndex) bytesAvailable;
+		return true;
+	}
+}
+
+#if defined(LOG_CFSOCKET)
+static void __CFSocketWriteSocketList(CFArrayRef sockets, CFDataRef fdSet, Boolean onlyIfSet) {
+    fd_set *tempfds = (fd_set *)CFDataGetBytePtr(fdSet);
+    SInt32 idx, cnt;
+    for (idx = 0, cnt = CFArrayGetCount(sockets); idx < cnt; idx++) {
+        CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(sockets, idx);
+        if (FD_ISSET(s->_socket, tempfds)) {
+            fprintf(stdout, "%d ", s->_socket);
+        } else if (!onlyIfSet) {
+            fprintf(stdout, "(%d) ", s->_socket);
+        }
+    }
+}
+#endif
+
+#ifdef __GNUC__
+__attribute__ ((noreturn))	// mostly interesting for shutting up a warning
+#endif /* __GNUC__ */
+static void __CFSocketManager(void * arg)
+{
+#if defined(__OBJC__)
+    if (objc_collecting_enabled()) auto_zone_register_thread(auto_zone());
+#endif
+    SInt32 nrfds, maxnrfds, fdentries = 1;
+    SInt32 rfds, wfds;
+#if !DEPLOYMENT_TARGET_WINDOWS
+    fd_set *exceptfds = NULL;
+    fd_set *writefds = (fd_set *)CFAllocatorAllocate(kCFAllocatorSystemDefault, fdentries * sizeof(fd_mask), 0);
+    fd_set *readfds = (fd_set *)CFAllocatorAllocate(kCFAllocatorSystemDefault, fdentries * sizeof(fd_mask), 0);
+#else
+    fd_set *exceptfds = (fd_set *)CFAllocatorAllocate(kCFAllocatorSystemDefault, fdentries * sizeof(SOCKET) + sizeof(u_int), 0);
+    fd_set *writefds = (fd_set *)CFAllocatorAllocate(kCFAllocatorSystemDefault, fdentries * sizeof(SOCKET) + sizeof(u_int), 0);
+    fd_set *readfds = (fd_set *)CFAllocatorAllocate(kCFAllocatorSystemDefault, fdentries * sizeof(SOCKET) + sizeof(u_int), 0);
+#endif
+    fd_set *tempfds;
+    SInt32 idx, cnt;
+    uint8_t buffer[256];
+    CFMutableArrayRef selectedWriteSockets = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    CFMutableArrayRef selectedReadSockets = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    CFIndex selectedWriteSocketsIndex = 0, selectedReadSocketsIndex = 0;
+    
+	struct timeval tv;
+	struct timeval* pTimeout = NULL;
+	struct timeval timeBeforeSelect;
+	
+    for (;;) {       
+        __CFSpinLock(&__CFActiveSocketsLock);
+        __CFSocketManagerIteration++;
+#if defined(LOG_CFSOCKET)
+        fprintf(stdout, "socket manager iteration %lu looking at read sockets ", __CFSocketManagerIteration);
+        __CFSocketWriteSocketList(__CFReadSockets, __CFReadSocketsFds, FALSE);
+        if (0 < CFArrayGetCount(__CFWriteSockets)) {
+            fprintf(stdout, " and write sockets ");
+            __CFSocketWriteSocketList(__CFWriteSockets, __CFWriteSocketsFds, FALSE);
+#if DEPLOYMENT_TARGET_WINDOWS
+            fprintf(stdout, " and except sockets ");
+            __CFSocketWriteSocketList(__CFWriteSockets, __CFExceptSocketsFds, TRUE);
+#endif
+        }
+        fprintf(stdout, "\n");
+#endif
+        rfds = __CFSocketFdGetSize(__CFReadSocketsFds);
+        wfds = __CFSocketFdGetSize(__CFWriteSocketsFds);
+        maxnrfds = __CFMax(rfds, wfds);
+#if !DEPLOYMENT_TARGET_WINDOWS
+        if (maxnrfds > fdentries * (int)NFDBITS) {
+            fdentries = (maxnrfds + NFDBITS - 1) / NFDBITS;
+            writefds = (fd_set *)CFAllocatorReallocate(kCFAllocatorSystemDefault, writefds, fdentries * sizeof(fd_mask), 0);
+            readfds = (fd_set *)CFAllocatorReallocate(kCFAllocatorSystemDefault, readfds, fdentries * sizeof(fd_mask), 0);
+        }
+        memset(writefds, 0, fdentries * sizeof(fd_mask)); 
+        memset(readfds, 0, fdentries * sizeof(fd_mask));
+#else
+        if (maxnrfds > fdentries) {
+            fdentries = maxnrfds;
+            exceptfds = (fd_set *)CFAllocatorReallocate(kCFAllocatorSystemDefault, exceptfds, fdentries * sizeof(SOCKET) + sizeof(u_int), 0);
+            writefds = (fd_set *)CFAllocatorReallocate(kCFAllocatorSystemDefault, writefds, fdentries * sizeof(SOCKET) + sizeof(u_int), 0);
+            readfds = (fd_set *)CFAllocatorReallocate(kCFAllocatorSystemDefault, readfds, fdentries * sizeof(SOCKET) + sizeof(u_int), 0);
+        }
+        memset(exceptfds, 0, fdentries * sizeof(SOCKET) + sizeof(u_int));
+        memset(writefds, 0, fdentries * sizeof(SOCKET) + sizeof(u_int));
+        memset(readfds, 0, fdentries * sizeof(SOCKET) + sizeof(u_int));
+        CFDataGetBytes(__CFExceptSocketsFds, CFRangeMake(0, __CFSocketFdGetSize(__CFExceptSocketsFds) * sizeof(SOCKET) + sizeof(u_int)), (UInt8 *)exceptfds);
+#endif
+        CFDataGetBytes(__CFWriteSocketsFds, CFRangeMake(0, CFDataGetLength(__CFWriteSocketsFds)), (UInt8 *)writefds);
+        CFDataGetBytes(__CFReadSocketsFds, CFRangeMake(0, CFDataGetLength(__CFReadSocketsFds)), (UInt8 *)readfds); 
+		
+        if (__CFReadSocketsTimeoutInvalid) {
+            struct timeval* minTimeout = NULL;
+            __CFReadSocketsTimeoutInvalid = false;
+#if defined(LOG_CFSOCKET)
+			fprintf(stdout, "Figuring out which sockets have timeouts...\n");
+#endif
+            CFArrayApplyFunction(__CFReadSockets, CFRangeMake(0, CFArrayGetCount(__CFReadSockets)), _calcMinTimeout_locked, (void*) &minTimeout);
+
+            if (minTimeout == NULL) {
+#if defined(LOG_CFSOCKET)
+				fprintf(stdout, "No one wants a timeout!\n");
+#endif
+                pTimeout = NULL;
+            } else {
+#if defined(LOG_CFSOCKET)
+				fprintf(stdout, "timeout will be %d, %d!\n", minTimeout->tv_sec, minTimeout->tv_usec);
+#endif
+                tv = *minTimeout;
+                pTimeout = &tv;
+            }
+        }
+
+        if (pTimeout) {
+#if defined(LOG_CFSOCKET)
+			fprintf(stdout, "select will have a %d, %d timeout\n", pTimeout->tv_sec, pTimeout->tv_usec);
+#endif
+            gettimeofday(&timeBeforeSelect, NULL);
+        }
+		
+		__CFSpinUnlock(&__CFActiveSocketsLock);
+
+        nrfds = select(maxnrfds, readfds, writefds, exceptfds, pTimeout);
+
+#if defined(LOG_CFSOCKET)
+		fprintf(stdout, "socket manager woke from select, ret=%ld\n", nrfds);
+#endif
+
+		/*
+		 * select returned a timeout
+		 */
+        if (0 == nrfds) {
+			struct timeval timeAfterSelect;
+			struct timeval deltaTime;
+			gettimeofday(&timeAfterSelect, NULL);
+			/* timeBeforeSelect becomes the delta */
+			timersub(&timeAfterSelect, &timeBeforeSelect, &deltaTime);
+			
+#if defined(LOG_CFSOCKET)
+			fprintf(stdout, "Socket manager received timeout - kicking off expired reads (expired delta %d, %d)\n", deltaTime.tv_sec, deltaTime.tv_usec);
+#endif
+			
+			__CFSpinLock(&__CFActiveSocketsLock);
+			
+			tempfds = NULL;
+			cnt = CFArrayGetCount(__CFReadSockets);
+			for (idx = 0; idx < cnt; idx++) {
+				CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(__CFReadSockets, idx);
+				if (timerisset(&s->_readBufferTimeout) || s->_leftoverBytes) {
+					CFSocketNativeHandle sock = s->_socket;
+					// We might have an new element in __CFReadSockets that we weren't listening to,
+					// in which case we must be sure not to test a bit in the fdset that is
+					// outside our mask size.
+					Boolean sockInBounds = (0 <= sock && sock < maxnrfds);
+					/* if this sockets timeout is less than or equal elapsed time, then signal it */
+					if (INVALID_SOCKET != sock && sockInBounds) {
+#if defined(LOG_CFSOCKET)
+						fprintf(stdout, "Expiring socket %d (delta %d, %d)\n", sock, s->_readBufferTimeout.tv_sec, s->_readBufferTimeout.tv_usec);
+#endif
+						CFArraySetValueAtIndex(selectedReadSockets, selectedReadSocketsIndex, s);
+						selectedReadSocketsIndex++;
+						/* socket is removed from fds here, will be restored in read handling or in perform function */
+						if (!tempfds) tempfds = (fd_set *)CFDataGetMutableBytePtr(__CFReadSocketsFds);
+						FD_CLR(sock, tempfds);
+					}
+				}
+			}
+			
+			__CFSpinUnlock(&__CFActiveSocketsLock);
+			
+			/* and below, we dispatch through the normal read dispatch mechanism */
+		} 
+		
+		if (0 > nrfds) {
+            SInt32 selectError = __CFSocketLastError();
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "socket manager received error %ld from select\n", selectError);
+#endif
+            if (EBADF == selectError) {
+                CFMutableArrayRef invalidSockets = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+                __CFSpinLock(&__CFActiveSocketsLock);
+                cnt = CFArrayGetCount(__CFWriteSockets);
+                for (idx = 0; idx < cnt; idx++) {
+                    CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(__CFWriteSockets, idx);
+                    if (!__CFNativeSocketIsValid(s->_socket)) {
+#if defined(LOG_CFSOCKET)
+                        fprintf(stdout, "socket manager found write socket %d invalid\n", s->_socket);
+#endif
+                        CFArrayAppendValue(invalidSockets, s);
+                    }
+                }
+                cnt = CFArrayGetCount(__CFReadSockets);
+                for (idx = 0; idx < cnt; idx++) {
+                    CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(__CFReadSockets, idx);
+                    if (!__CFNativeSocketIsValid(s->_socket)) {
+#if defined(LOG_CFSOCKET)
+                        fprintf(stdout, "socket manager found read socket %d invalid\n", s->_socket);
+#endif
+                        CFArrayAppendValue(invalidSockets, s);
+                    }
+                }
+                __CFSpinUnlock(&__CFActiveSocketsLock);
+        
+                cnt = CFArrayGetCount(invalidSockets);
+                for (idx = 0; idx < cnt; idx++) {
+                    CFSocketInvalidate(((CFSocketRef)CFArrayGetValueAtIndex(invalidSockets, idx)));
+                }
+                CFRelease(invalidSockets);
+            }
+            continue;
+        }
+        if (FD_ISSET(__CFWakeupSocketPair[1], readfds)) {
+            recv(__CFWakeupSocketPair[1], (SOCK_DATA)buffer, sizeof(buffer), 0);
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "socket manager received %c on wakeup socket\n", buffer[0]);
+#endif
+        }
+        __CFSpinLock(&__CFActiveSocketsLock);
+        tempfds = NULL;
+        cnt = CFArrayGetCount(__CFWriteSockets);
+        for (idx = 0; idx < cnt; idx++) {
+            CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(__CFWriteSockets, idx);
+            CFSocketNativeHandle sock = s->_socket;
+            // We might have an new element in __CFWriteSockets that we weren't listening to,
+            // in which case we must be sure not to test a bit in the fdset that is
+            // outside our mask size.
+#if !DEPLOYMENT_TARGET_WINDOWS
+            Boolean sockInBounds = (0 <= sock && sock < maxnrfds);
+#else
+            Boolean sockInBounds = true;
+#endif
+            if (INVALID_SOCKET != sock && sockInBounds) {
+                if (FD_ISSET(sock, writefds)) {
+                    CFArraySetValueAtIndex(selectedWriteSockets, selectedWriteSocketsIndex, s);
+                    selectedWriteSocketsIndex++;
+                    /* socket is removed from fds here, restored by CFSocketReschedule */
+                    if (!tempfds) tempfds = (fd_set *)CFDataGetMutableBytePtr(__CFWriteSocketsFds);
+                    FD_CLR(sock, tempfds);
+#if DEPLOYMENT_TARGET_WINDOWS
+                    fd_set *exfds = (fd_set *)CFDataGetMutableBytePtr(__CFExceptSocketsFds);
+                    FD_CLR(sock, exfds);
+#endif
+
+                }
+#if DEPLOYMENT_TARGET_WINDOWS
+                else if (FD_ISSET(sock, exceptfds)) {
+                    // On Win32 connect errors come in on exceptFDs.  We treat these as if
+                    // they had come on writeFDs, since the rest of our Unix-based code
+                    // expects that.
+                    CFArrayAppendValue(selectedWriteSockets, s);
+                    fd_set *exfds = (fd_set *)CFDataGetMutableBytePtr(__CFExceptSocketsFds);
+                    FD_CLR(sock, exfds);
+                }
+#endif
+            }
+        }
+        tempfds = NULL;
+        cnt = CFArrayGetCount(__CFReadSockets);
+        for (idx = 0; idx < cnt; idx++) {
+            CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(__CFReadSockets, idx);
+            CFSocketNativeHandle sock = s->_socket;
+#if !DEPLOYMENT_TARGET_WINDOWS
+            // We might have an new element in __CFReadSockets that we weren't listening to,
+            // in which case we must be sure not to test a bit in the fdset that is
+            // outside our mask size.
+            Boolean sockInBounds = (0 <= sock && sock < maxnrfds);
+#else
+            // fdset's are arrays, so we don't have that issue above
+            Boolean sockInBounds = true;
+#endif
+            if (INVALID_SOCKET != sock && sockInBounds && FD_ISSET(sock, readfds)) {
+                CFArraySetValueAtIndex(selectedReadSockets, selectedReadSocketsIndex, s);
+                selectedReadSocketsIndex++;
+                /* socket is removed from fds here, will be restored in read handling or in perform function */
+                if (!tempfds) tempfds = (fd_set *)CFDataGetMutableBytePtr(__CFReadSocketsFds);
+                FD_CLR(sock, tempfds);
+            }
+        }
+        __CFSpinUnlock(&__CFActiveSocketsLock);
+        
+        for (idx = 0; idx < selectedWriteSocketsIndex; idx++) {
+            CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(selectedWriteSockets, idx);
+            if (kCFNull == (CFNullRef)s) continue;
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "socket manager signaling socket %d for write\n", s->_socket);
+#endif
+            __CFSocketHandleWrite(s, FALSE);
+            CFArraySetValueAtIndex(selectedWriteSockets, idx, kCFNull);
+        }
+        selectedWriteSocketsIndex = 0;
+        
+        for (idx = 0; idx < selectedReadSocketsIndex; idx++) {
+            CFSocketRef s = (CFSocketRef)CFArrayGetValueAtIndex(selectedReadSockets, idx);
+            if (kCFNull == (CFNullRef)s) continue;
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "socket manager signaling socket %d for read\n", s->_socket);
+#endif
+            __CFSocketHandleRead(s, nrfds == 0);
+            CFArraySetValueAtIndex(selectedReadSockets, idx, kCFNull);
+        }
+        selectedReadSocketsIndex = 0;
+    }
+#if defined(__OBJC__)
+    if (objc_collecting_enabled()) auto_zone_unregister_thread(auto_zone());
+#endif
+}
+
+static CFStringRef __CFSocketCopyDescription(CFTypeRef cf) {
+    CFSocketRef s = (CFSocketRef)cf;
+    CFMutableStringRef result;
+    CFStringRef contextDesc = NULL;
+    void *contextInfo = NULL;
+    CFStringRef (*contextCopyDescription)(const void *info) = NULL;
+    result = CFStringCreateMutable(CFGetAllocator(s), 0);
+    __CFSocketLock(s);
+    void *addr = (void*)s->_callout;
+#if DEPLOYMENT_TARGET_WINDOWS
+    // FIXME:  Get name using win32 analog of dladdr?
+    const char* name = "???";
+#else
+    Dl_info info;
+    const char *name = (dladdr(addr, &info) && info.dli_saddr == addr && info.dli_sname) ? info.dli_sname : "???";
+#endif
+    CFStringAppendFormat(result, NULL, CFSTR("<CFSocket %p [%p]>{valid = %s, type = %d, socket = %d, socket set count = %ld,\n    callback types = 0x%x, callout = %s (%p), source = %p,\n    run loops = %@,\n    context = "), cf, CFGetAllocator(s), (__CFSocketIsValid(s) ? "Yes" : "No"), s->_socketType, s->_socket, s->_socketSetCount, __CFSocketCallBackTypes(s), name, addr, s->_source0, s->_runLoops);
+    contextInfo = s->_context.info;
+    contextCopyDescription = s->_context.copyDescription;
+    __CFSocketUnlock(s);
+    if (NULL != contextInfo && NULL != contextCopyDescription) {
+        contextDesc = (CFStringRef)contextCopyDescription(contextInfo);
+    }
+    if (NULL == contextDesc) {
+        contextDesc = CFStringCreateWithFormat(CFGetAllocator(s), NULL, CFSTR("<CFSocket context %p>"), contextInfo);
+    }
+    CFStringAppend(result, contextDesc);
+    CFStringAppend(result, CFSTR("}"));
+    CFRelease(contextDesc);
+    return result;
+}
+
+static void __CFSocketDeallocate(CFTypeRef cf) {
+    /* Since CFSockets are cached, we can only get here sometime after being invalidated */
+    CFSocketRef s = (CFSocketRef)cf;
+    if (NULL != s->_address) {
+        CFRelease(s->_address);
+        s->_address = NULL;
+    }
+    if (NULL != s->_readBuffer) {
+        CFRelease(s->_readBuffer);
+        s->_readBuffer = NULL;
+    }
+	if (NULL != s->_leftoverBytes) {
+		CFRelease(s->_leftoverBytes);
+		s->_leftoverBytes = NULL;
+	}
+    timerclear(&s->_readBufferTimeout);
+    s->_bytesToBuffer = 0;
+    s->_bytesToBufferPos = 0;
+    s->_bytesToBufferReadPos = 0;
+    s->_atEOF = true;
+	s->_bufferedReadError = 0;
+}
+
+static const CFRuntimeClass __CFSocketClass = {
+    0,
+    "CFSocket",
+    NULL,      // init
+    NULL,      // copy
+    __CFSocketDeallocate,
+    NULL,      // equal
+    NULL,      // hash
+    NULL,      // 
+    __CFSocketCopyDescription
+};
+
+__private_extern__ void __CFSocketInitialize(void) {
+    __kCFSocketTypeID = _CFRuntimeRegisterClass(&__CFSocketClass);
+}
+
+CFTypeID CFSocketGetTypeID(void) {
+    return __kCFSocketTypeID;
+}
+static CFSocketRef _CFSocketCreateWithNative(CFAllocatorRef allocator, CFSocketNativeHandle sock, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context, Boolean useExistingInstance) {
+    CHECK_FOR_FORK();
+    CFSocketRef memory;
+    int typeSize = sizeof(memory->_socketType);
+    __CFSpinLock(&__CFActiveSocketsLock);
+    if (NULL == __CFReadSockets) __CFSocketInitializeSockets();
+    __CFSpinUnlock(&__CFActiveSocketsLock);
+    __CFSpinLock(&__CFAllSocketsLock);
+    if (NULL == __CFAllSockets) {
+        __CFAllSockets = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
+    }
+    if (INVALID_SOCKET != sock && CFDictionaryGetValueIfPresent(__CFAllSockets, (void *)(uintptr_t)sock, (const void **)&memory)) {
+        if (useExistingInstance) {
+			__CFSpinUnlock(&__CFAllSocketsLock);
+			CFRetain(memory);
+			return memory;
+		} else {
+#if defined(LOG_CFSOCKET)
+			fprintf(stdout, "useExistingInstance is FALSE, removing existing instance %d from __CFAllSockets\n", (int)memory);
+#endif
+			__CFSpinUnlock(&__CFAllSocketsLock);
+			CFSocketInvalidate(memory);
+			__CFSpinLock(&__CFAllSocketsLock);
+		}
+    }
+    memory = (CFSocketRef)_CFRuntimeCreateInstance(allocator, __kCFSocketTypeID, sizeof(struct __CFSocket) - sizeof(CFRuntimeBase), NULL);
+    if (NULL == memory) {
+        __CFSpinUnlock(&__CFAllSocketsLock);
+        return NULL;
+    }
+    __CFSocketSetCallBackTypes(memory, callBackTypes);
+    if (INVALID_SOCKET != sock) __CFSocketSetValid(memory);
+    __CFSocketUnsetWriteSignalled(memory);
+    __CFSocketUnsetReadSignalled(memory);
+    memory->_f.client = ((callBackTypes & (~kCFSocketConnectCallBack)) & (~kCFSocketWriteCallBack)) | kCFSocketCloseOnInvalidate;
+    memory->_f.disabled = 0;
+    memory->_f.connected = FALSE;
+    memory->_f.writableHint = FALSE;
+    memory->_f.closeSignaled = FALSE;
+    CF_SPINLOCK_INIT_FOR_STRUCTS(memory->_lock);
+    CF_SPINLOCK_INIT_FOR_STRUCTS(memory->_writeLock);
+    memory->_socket = sock;
+    if (INVALID_SOCKET == sock || 0 != getsockopt(sock, SOL_SOCKET, SO_TYPE, (SOCK_DATA)&(memory->_socketType), (socklen_t *)&typeSize)) memory->_socketType = 0;		// cast for WinSock bad API
+    memory->_errorCode = 0;
+    memory->_address = NULL;
+    memory->_peerAddress = NULL;
+    memory->_socketSetCount = 0;
+    memory->_source0 = NULL;
+    if (INVALID_SOCKET != sock) {
+        memory->_runLoops = CFArrayCreateMutable(allocator, 0, NULL);
+    } else {
+        memory->_runLoops = NULL;
+    }
+    memory->_callout = callout;
+    memory->_dataQueue = NULL;
+    memory->_addressQueue = NULL;
+    memory->_context.info = 0;
+    memory->_context.retain = 0;
+    memory->_context.release = 0;
+    memory->_context.copyDescription = 0;
+    timerclear(&memory->_readBufferTimeout);
+	memory->_readBuffer = NULL;
+	memory->_bytesToBuffer = 0;
+	memory->_bytesToBufferPos = 0;
+	memory->_bytesToBufferReadPos = 0;
+	memory->_atEOF = false;
+	memory->_bufferedReadError = 0;
+   memory->_leftoverBytes = NULL;
+	
+    if (INVALID_SOCKET != sock) CFDictionaryAddValue(__CFAllSockets, (void *)(uintptr_t)sock, memory);
+    __CFSpinUnlock(&__CFAllSocketsLock);
+    if (NULL != context) {
+        void *contextInfo = context->retain ? (void *)context->retain(context->info) : context->info;
+        __CFSocketLock(memory);
+        memory->_context.retain = context->retain;
+        memory->_context.release = context->release;
+        memory->_context.copyDescription = context->copyDescription;
+        memory->_context.info = contextInfo;
+        __CFSocketUnlock(memory);
+    }
+    return memory;
+}
+
+CFSocketRef CFSocketCreateWithNative(CFAllocatorRef allocator, CFSocketNativeHandle sock, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context) {
+	return _CFSocketCreateWithNative(allocator, sock, callBackTypes, callout, context, TRUE);
+}
+
+void CFSocketInvalidate(CFSocketRef s) {
+    CHECK_FOR_FORK();
+    UInt32 previousSocketManagerIteration;
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+#if defined(LOG_CFSOCKET)
+    fprintf(stdout, "invalidating socket %d with flags 0x%x disabled 0x%x connected 0x%x\n", s->_socket, s->_f.client, s->_f.disabled, s->_f.connected);
+#endif
+    CFRetain(s);
+    __CFSpinLock(&__CFAllSocketsLock);
+    __CFSocketLock(s);
+    if (__CFSocketIsValid(s)) {
+        SInt32 idx;
+        CFRunLoopSourceRef source0;
+        void *contextInfo = NULL;
+        void (*contextRelease)(const void *info) = NULL;
+        __CFSocketUnsetValid(s);
+        __CFSocketUnsetWriteSignalled(s);
+        __CFSocketUnsetReadSignalled(s);
+        __CFSpinLock(&__CFActiveSocketsLock);
+        idx = CFArrayGetFirstIndexOfValue(__CFWriteSockets, CFRangeMake(0, CFArrayGetCount(__CFWriteSockets)), s);
+        if (0 <= idx) {
+            CFArrayRemoveValueAtIndex(__CFWriteSockets, idx);
+            __CFSocketClearFDForWrite(s);
+#if DENT_TARGET_WIN32
+            __CFSocketFdClr(s->_socket, __CFExceptSocketsFds);
+#endif
+        }
+        // No need to clear FD's for V1 sources, since we'll just throw the whole event away
+        idx = CFArrayGetFirstIndexOfValue(__CFReadSockets, CFRangeMake(0, CFArrayGetCount(__CFReadSockets)), s);
+        if (0 <= idx) {
+            CFArrayRemoveValueAtIndex(__CFReadSockets, idx);
+            __CFSocketClearFDForRead(s);
+        }
+        previousSocketManagerIteration = __CFSocketManagerIteration;
+        __CFSpinUnlock(&__CFActiveSocketsLock);
+        CFDictionaryRemoveValue(__CFAllSockets, (void *)(uintptr_t)(s->_socket));
+        if ((s->_f.client & kCFSocketCloseOnInvalidate) != 0) closesocket(s->_socket);
+        s->_socket = INVALID_SOCKET;
+        if (NULL != s->_peerAddress) {
+            CFRelease(s->_peerAddress);
+            s->_peerAddress = NULL;
+        }
+        if (NULL != s->_dataQueue) {
+            CFRelease(s->_dataQueue);
+            s->_dataQueue = NULL;
+        }
+        if (NULL != s->_addressQueue) {
+            CFRelease(s->_addressQueue);
+            s->_addressQueue = NULL;
+        }
+        s->_socketSetCount = 0;
+        for (idx = CFArrayGetCount(s->_runLoops); idx--;) {
+            CFRunLoopWakeUp((CFRunLoopRef)CFArrayGetValueAtIndex(s->_runLoops, idx));
+        }
+        CFRelease(s->_runLoops);
+        s->_runLoops = NULL;
+        source0 = s->_source0;
+        s->_source0 = NULL;
+        contextInfo = s->_context.info;
+        contextRelease = s->_context.release;
+        s->_context.info = 0;
+        s->_context.retain = 0;
+        s->_context.release = 0;
+        s->_context.copyDescription = 0;
+        __CFSocketUnlock(s);
+        if (NULL != contextRelease) {
+            contextRelease(contextInfo);
+        }
+        if (NULL != source0) {
+            CFRunLoopSourceInvalidate(source0);
+            CFRelease(source0);
+        }
+    } else {
+        __CFSocketUnlock(s);
+    }
+    __CFSpinUnlock(&__CFAllSocketsLock);
+    CFRelease(s);
+}
+
+Boolean CFSocketIsValid(CFSocketRef s) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    return __CFSocketIsValid(s);
+}
+
+CFSocketNativeHandle CFSocketGetNative(CFSocketRef s) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    return s->_socket;
+}
+
+CFDataRef CFSocketCopyAddress(CFSocketRef s) {
+    CHECK_FOR_FORK();
+    CFDataRef result = NULL;
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    __CFSocketLock(s);
+    __CFSocketEstablishAddress(s);
+    if (NULL != s->_address) {
+        result = (CFDataRef)CFRetain(s->_address);
+    }
+    __CFSocketUnlock(s);
+    return result;
+}
+
+CFDataRef CFSocketCopyPeerAddress(CFSocketRef s) {
+    CHECK_FOR_FORK();
+    CFDataRef result = NULL;
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    __CFSocketLock(s);
+    __CFSocketEstablishPeerAddress(s);
+    if (NULL != s->_peerAddress) {
+        result = (CFDataRef)CFRetain(s->_peerAddress);
+    }
+    __CFSocketUnlock(s);
+    return result;
+}
+
+void CFSocketGetContext(CFSocketRef s, CFSocketContext *context) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+    *context = s->_context;
+}
+
+CFOptionFlags CFSocketGetSocketFlags(CFSocketRef s) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    return s->_f.client;
+}
+
+void CFSocketSetSocketFlags(CFSocketRef s, CFOptionFlags flags) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    __CFSocketLock(s);
+#if defined(LOG_CFSOCKET)
+        fprintf(stdout, "setting flags for socket %d, from 0x%x to 0x%lx\n", s->_socket, s->_f.client, flags);
+#endif
+    s->_f.client = flags;
+    __CFSocketUnlock(s);
+}
+
+void CFSocketDisableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes) {
+    CHECK_FOR_FORK();
+    Boolean wakeup = false;
+    uint8_t readCallBackType;
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    __CFSocketLock(s);
+    if (__CFSocketIsValid(s) && __CFSocketIsScheduled(s)) {
+        callBackTypes &= __CFSocketCallBackTypes(s);
+        readCallBackType = __CFSocketReadCallBackType(s);
+        s->_f.disabled |= callBackTypes;
+#if defined(LOG_CFSOCKET)
+        fprintf(stdout, "unscheduling socket %d with flags 0x%x disabled 0x%x connected 0x%x for types 0x%lx\n", s->_socket, s->_f.client, s->_f.disabled, s->_f.connected, callBackTypes);
+#endif
+        __CFSpinLock(&__CFActiveSocketsLock);
+        if ((readCallBackType == kCFSocketAcceptCallBack) || !__CFSocketIsConnectionOriented(s)) s->_f.connected = TRUE;
+        if (((callBackTypes & kCFSocketWriteCallBack) != 0) || (((callBackTypes & kCFSocketConnectCallBack) != 0) && !s->_f.connected)) {
+            if (__CFSocketClearFDForWrite(s)) {
+                // do not wake up the socket manager thread if all relevant write callbacks are disabled
+                CFOptionFlags writeCallBacksAvailable = __CFSocketCallBackTypes(s) & (kCFSocketWriteCallBack | kCFSocketConnectCallBack);
+                if (s->_f.connected) writeCallBacksAvailable &= ~kCFSocketConnectCallBack;
+                if ((s->_f.disabled & writeCallBacksAvailable) != writeCallBacksAvailable) wakeup = true;
+            }
+        }
+        if (readCallBackType != kCFSocketNoCallBack && (callBackTypes & readCallBackType) != 0) {
+            if (__CFSocketClearFDForRead(s)) {
+                // do not wake up the socket manager thread if callback type is read
+                if (readCallBackType != kCFSocketReadCallBack) wakeup = true;
+            }
+        }
+        __CFSpinUnlock(&__CFActiveSocketsLock);
+    }
+    __CFSocketUnlock(s);
+    if (wakeup && __CFSocketManagerThread) {
+        uint8_t c = 'u';
+        send(__CFWakeupSocketPair[0], (SOCK_CONST_DATA)&c, sizeof(c), 0);
+    }
+}
+
+// "force" means to clear the disabled bits set by DisableCallBacks and always reenable.
+// if (!force) we respect those bits, meaning they may stop us from enabling.
+// In addition, if !force we assume that the sockets have already been added to the
+// __CFReadSockets and __CFWriteSockets arrays.  This is true because the callbacks start
+// enabled when the CFSocket is created (at which time we enable with force).
+// Called with SocketLock held, returns with it released!
+void __CFSocketEnableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes, Boolean force, uint8_t wakeupChar) {
+    CHECK_FOR_FORK();
+    Boolean wakeup = FALSE;
+    if (!callBackTypes) {
+        __CFSocketUnlock(s);
+        return;
+    }
+    if (__CFSocketIsValid(s) && __CFSocketIsScheduled(s)) {
+        Boolean turnOnWrite = FALSE, turnOnConnect = FALSE, turnOnRead = FALSE;
+        uint8_t readCallBackType = __CFSocketReadCallBackType(s);        
+        callBackTypes &= __CFSocketCallBackTypes(s);
+        if (force) s->_f.disabled &= ~callBackTypes;
+#if defined(LOG_CFSOCKET)
+        fprintf(stdout, "rescheduling socket %d with flags 0x%x disabled 0x%x connected 0x%x for types 0x%lx\n", s->_socket, s->_f.client, s->_f.disabled, s->_f.connected, callBackTypes);
+#endif
+        /* We will wait for connection only for connection-oriented, non-rendezvous sockets that are not already connected.  Mark others as already connected. */
+        if ((readCallBackType == kCFSocketAcceptCallBack) || !__CFSocketIsConnectionOriented(s)) s->_f.connected = TRUE;
+
+        // First figure out what to turn on
+        if (s->_f.connected || (callBackTypes & kCFSocketConnectCallBack) == 0) {
+            // if we want write callbacks and they're not disabled...
+            if ((callBackTypes & kCFSocketWriteCallBack) != 0 && (s->_f.disabled & kCFSocketWriteCallBack) == 0) turnOnWrite = TRUE;
+        } else {
+            // if we want connect callbacks and they're not disabled...
+            if ((callBackTypes & kCFSocketConnectCallBack) != 0 && (s->_f.disabled & kCFSocketConnectCallBack) == 0) turnOnConnect = TRUE;
+        }
+        // if we want read callbacks and they're not disabled...
+        if (readCallBackType != kCFSocketNoCallBack && (callBackTypes & readCallBackType) != 0 && (s->_f.disabled & kCFSocketReadCallBack) == 0) turnOnRead = TRUE;
+
+        // Now turn on the callbacks we've determined that we want on
+        if (turnOnRead || turnOnWrite || turnOnConnect) {
+            __CFSpinLock(&__CFActiveSocketsLock);
+            if (turnOnWrite || turnOnConnect) {
+                if (force) {
+                    SInt32 idx = CFArrayGetFirstIndexOfValue(__CFWriteSockets, CFRangeMake(0, CFArrayGetCount(__CFWriteSockets)), s);
+                    if (kCFNotFound == idx) CFArrayAppendValue(__CFWriteSockets, s);
+                }
+                if (__CFSocketSetFDForWrite(s)) wakeup = true;
+#if DEPLOYMENT_TARGET_WINDOWS
+                if ((callBackTypes & kCFSocketConnectCallBack) != 0 && !s->_f.connected) __CFSocketFdSet(s->_socket, __CFExceptSocketsFds);
+#endif
+            }
+            if (turnOnRead) {
+                if (force) {
+                    SInt32 idx = CFArrayGetFirstIndexOfValue(__CFReadSockets, CFRangeMake(0, CFArrayGetCount(__CFReadSockets)), s);
+                    if (kCFNotFound == idx) CFArrayAppendValue(__CFReadSockets, s);
+                }
+                if (__CFSocketSetFDForRead(s)) wakeup = true;
+            }
+            if (wakeup && NULL == __CFSocketManagerThread) __CFSocketManagerThread = __CFStartSimpleThread((void*)__CFSocketManager, 0);
+            __CFSpinUnlock(&__CFActiveSocketsLock);
+        }
+    }
+    __CFSocketUnlock(s);
+    if (wakeup) send(__CFWakeupSocketPair[0], (SOCK_CONST_DATA)&wakeupChar, sizeof(wakeupChar), 0);
+}
+
+void CFSocketEnableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes) {
+    CHECK_FOR_FORK();
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    __CFSocketLock(s);
+    __CFSocketEnableCallBacks(s, callBackTypes, TRUE, 'r');
+}
+
+static void __CFSocketSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) {
+    CFSocketRef s = (CFSocketRef)info;
+    __CFSocketLock(s);
+    //??? also need to arrange delivery of all pending data
+    if (__CFSocketIsValid(s)) {
+        CFArrayAppendValue(s->_runLoops, rl);
+        s->_socketSetCount++;
+        // Since the v0 source is listened to on the SocketMgr thread, no matter how many modes it
+        // is added to we just need to enable it there once (and _socketSetCount gives us a refCount
+        // to know when we can finally disable it).
+        if (1 == s->_socketSetCount) {
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "scheduling socket %d\n", s->_socket);
+#endif
+            __CFSocketEnableCallBacks(s, __CFSocketCallBackTypes(s), TRUE, 's');  // unlocks s
+        } else
+            __CFSocketUnlock(s);
+    } else
+        __CFSocketUnlock(s);
+}
+
+static void __CFSocketCancel(void *info, CFRunLoopRef rl, CFStringRef mode) {
+    CFSocketRef s = (CFSocketRef)info;
+    SInt32 idx;
+    __CFSocketLock(s);
+    s->_socketSetCount--;
+    if (0 == s->_socketSetCount) {
+        __CFSpinLock(&__CFActiveSocketsLock);
+        idx = CFArrayGetFirstIndexOfValue(__CFWriteSockets, CFRangeMake(0, CFArrayGetCount(__CFWriteSockets)), s);
+        if (0 <= idx) {
+            CFArrayRemoveValueAtIndex(__CFWriteSockets, idx);
+            __CFSocketClearFDForWrite(s);
+#if DEPLOYMENT_TARGET_WINDOWS
+            __CFSocketFdClr(s->_socket, __CFExceptSocketsFds);
+#endif
+        }
+        idx = CFArrayGetFirstIndexOfValue(__CFReadSockets, CFRangeMake(0, CFArrayGetCount(__CFReadSockets)), s);
+        if (0 <= idx) {
+            CFArrayRemoveValueAtIndex(__CFReadSockets, idx);
+            __CFSocketClearFDForRead(s);
+        }
+        __CFSpinUnlock(&__CFActiveSocketsLock);
+    }
+    if (NULL != s->_runLoops) {
+        idx = CFArrayGetFirstIndexOfValue(s->_runLoops, CFRangeMake(0, CFArrayGetCount(s->_runLoops)), rl);
+        if (0 <= idx) CFArrayRemoveValueAtIndex(s->_runLoops, idx);
+    }
+    __CFSocketUnlock(s);
+}
+
+// Note:  must be called with socket lock held, then returns with it released
+// Used by both the v0 and v1 RunLoopSource perform routines
+static void __CFSocketDoCallback(CFSocketRef s, CFDataRef data, CFDataRef address, CFSocketNativeHandle sock) {
+    CFSocketCallBack callout = NULL;
+    void *contextInfo = NULL;
+    SInt32 errorCode = 0;
+    Boolean readSignalled = false, writeSignalled = false, connectSignalled = false, calledOut = false;
+    uint8_t readCallBackType, callBackTypes;
+    
+    callBackTypes = __CFSocketCallBackTypes(s);
+    readCallBackType = __CFSocketReadCallBackType(s);
+    readSignalled = __CFSocketIsReadSignalled(s);
+    writeSignalled = __CFSocketIsWriteSignalled(s);
+    connectSignalled = writeSignalled && !s->_f.connected;
+    __CFSocketUnsetReadSignalled(s);
+    __CFSocketUnsetWriteSignalled(s);
+    callout = s->_callout;
+    contextInfo = s->_context.info;
+#if defined(LOG_CFSOCKET)
+    fprintf(stdout, "entering perform for socket %d with read signalled %d write signalled %d connect signalled %d callback types %d\n", s->_socket, readSignalled, writeSignalled, connectSignalled, callBackTypes);
+#endif
+    if (writeSignalled) {
+        errorCode = s->_errorCode;
+        s->_f.connected = TRUE;
+    }
+    __CFSocketUnlock(s);
+    if ((callBackTypes & kCFSocketConnectCallBack) != 0) {
+        if (connectSignalled && (!calledOut || CFSocketIsValid(s))) {
+            if (errorCode) {
+#if defined(LOG_CFSOCKET)
+                fprintf(stdout, "perform calling out error %ld to socket %d\n", errorCode, s->_socket);
+#endif
+                if (callout) callout(s, kCFSocketConnectCallBack, NULL, &errorCode, contextInfo);
+                calledOut = true;
+            } else {
+#if defined(LOG_CFSOCKET)
+                fprintf(stdout, "perform calling out connect to socket %d\n", s->_socket);
+#endif
+                if (callout) callout(s, kCFSocketConnectCallBack, NULL, NULL, contextInfo);
+                calledOut = true;
+            }
+        }
+    }
+    if (kCFSocketDataCallBack == readCallBackType) {
+        if (NULL != data && (!calledOut || CFSocketIsValid(s))) {
+            SInt32 datalen = CFDataGetLength(data);
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "perform calling out data of length %ld to socket %d\n", datalen, s->_socket);
+#endif
+            if (callout) callout(s, kCFSocketDataCallBack, address, data, contextInfo);
+            calledOut = true;
+            if (0 == datalen) CFSocketInvalidate(s);
+        }
+    } else if (kCFSocketAcceptCallBack == readCallBackType) {
+        if (INVALID_SOCKET != sock && (!calledOut || CFSocketIsValid(s))) {
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "perform calling out accept of socket %d to socket %d\n", sock, s->_socket);
+#endif
+            if (callout) callout(s, kCFSocketAcceptCallBack, address, &sock, contextInfo);
+            calledOut = true;
+        }
+    } else if (kCFSocketReadCallBack == readCallBackType) {
+        if (readSignalled && (!calledOut || CFSocketIsValid(s))) {
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "perform calling out read to socket %d\n", s->_socket);
+#endif
+            if (callout) callout(s, kCFSocketReadCallBack, NULL, NULL, contextInfo);
+            calledOut = true;
+        }
+    }
+    if ((callBackTypes & kCFSocketWriteCallBack) != 0) {
+        if (writeSignalled && !errorCode && (!calledOut || CFSocketIsValid(s))) {
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "perform calling out write to socket %d\n", s->_socket);
+#endif
+            if (callout) callout(s, kCFSocketWriteCallBack, NULL, NULL, contextInfo);
+            calledOut = true;
+        }
+    }
+}
+
+static void __CFSocketPerformV0(void *info) {
+    CFSocketRef s = (CFSocketRef)info;
+    CFDataRef data = NULL;
+    CFDataRef address = NULL;
+    CFSocketNativeHandle sock = INVALID_SOCKET;
+    uint8_t readCallBackType, callBackTypes;
+    CFRunLoopRef rl = NULL;
+
+    __CFSocketLock(s);
+    if (!__CFSocketIsValid(s)) {
+        __CFSocketUnlock(s);
+        return;
+    }
+    callBackTypes = __CFSocketCallBackTypes(s);
+    readCallBackType = __CFSocketReadCallBackType(s);
+    CFOptionFlags callBacksSignalled = 0;
+    if (__CFSocketIsReadSignalled(s)) callBacksSignalled |= readCallBackType;
+    if (__CFSocketIsWriteSignalled(s)) callBacksSignalled |= kCFSocketWriteCallBack;
+
+    if (kCFSocketDataCallBack == readCallBackType) {
+        if (NULL != s->_dataQueue && 0 < CFArrayGetCount(s->_dataQueue)) {
+            data = (CFDataRef)CFArrayGetValueAtIndex(s->_dataQueue, 0);
+            CFRetain(data);
+            CFArrayRemoveValueAtIndex(s->_dataQueue, 0);
+            address = (CFDataRef)CFArrayGetValueAtIndex(s->_addressQueue, 0);
+            CFRetain(address);
+            CFArrayRemoveValueAtIndex(s->_addressQueue, 0);
+        }
+    } else if (kCFSocketAcceptCallBack == readCallBackType) {
+        if (NULL != s->_dataQueue && 0 < CFArrayGetCount(s->_dataQueue)) {
+            sock = (CFSocketNativeHandle)(uintptr_t)CFArrayGetValueAtIndex(s->_dataQueue, 0);
+            CFArrayRemoveValueAtIndex(s->_dataQueue, 0);
+            address = (CFDataRef)CFArrayGetValueAtIndex(s->_addressQueue, 0);
+            CFRetain(address);
+            CFArrayRemoveValueAtIndex(s->_addressQueue, 0);
+        }
+    }
+
+    __CFSocketDoCallback(s, data, address, sock);	// does __CFSocketUnlock(s)
+    if (NULL != data) CFRelease(data);
+    if (NULL != address) CFRelease(address);
+
+    __CFSocketLock(s);
+    if (__CFSocketIsValid(s) && kCFSocketNoCallBack != readCallBackType) {
+        // if there's still more data, we want to wake back up right away
+        if ((kCFSocketDataCallBack == readCallBackType || kCFSocketAcceptCallBack == readCallBackType) && NULL != s->_dataQueue && 0 < CFArrayGetCount(s->_dataQueue)) {
+            CFRunLoopSourceSignal(s->_source0);
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "perform short-circuit signaling source for socket %d with flags 0x%x disabled 0x%x connected 0x%x\n", s->_socket, s->_f.client, s->_f.disabled, s->_f.connected);
+#endif
+            rl = __CFSocketCopyRunLoopToWakeUp(s);
+        }
+    }
+    // Only reenable callbacks that are auto-reenabled
+    __CFSocketEnableCallBacks(s, callBacksSignalled & s->_f.client, FALSE, 'p');  // unlocks s
+
+    if (NULL != rl) {
+        CFRunLoopWakeUp(rl);
+        CFRelease(rl);
+    }
+}
+
+CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator, CFSocketRef s, CFIndex order) {
+    CHECK_FOR_FORK();
+    CFRunLoopSourceRef result = NULL;
+    __CFGenericValidateType(s, __kCFSocketTypeID);
+    __CFSocketLock(s);
+    if (__CFSocketIsValid(s)) {
+        if (NULL == s->_source0) {
+            CFRunLoopSourceContext context;
+            context.version = 0;
+            context.info = s;
+            context.retain = CFRetain;
+            context.release = CFRelease;
+            context.copyDescription = CFCopyDescription;
+            context.equal = CFEqual;
+            context.hash = CFHash;
+            context.schedule = __CFSocketSchedule;
+            context.cancel = __CFSocketCancel;
+            context.perform = __CFSocketPerformV0;
+            s->_source0 = CFRunLoopSourceCreate(allocator, order, &context);
+        }
+        CFRetain(s->_source0);        /* This retain is for the receiver */
+        result = s->_source0;
+    }
+    __CFSocketUnlock(s);
+    return result;
+}
+
+#endif /* NEW_SOCKET */
+
+static CFSpinLock_t __CFSocketWriteLock_ = CFSpinLockInit;
+//#warning can only send on one socket at a time now
+
+CF_INLINE void __CFSocketWriteLock(CFSocketRef s) {
+    __CFSpinLock(& __CFSocketWriteLock_);
+}
+
+CF_INLINE void __CFSocketWriteUnlock(CFSocketRef s) {
+    __CFSpinUnlock(& __CFSocketWriteLock_);
+}
+
+//??? need timeout, error handling, retries
+CFSocketError CFSocketSendData(CFSocketRef s, CFDataRef address, CFDataRef data, CFTimeInterval timeout) {
+    CHECK_FOR_FORK();
+    const uint8_t *dataptr, *addrptr = NULL;
+    SInt32 datalen, addrlen = 0, size = 0;
+    CFSocketNativeHandle sock = INVALID_SOCKET;
+    struct timeval tv;
+    __CFGenericValidateType(s, CFSocketGetTypeID());
+    if (address) {
+        addrptr = CFDataGetBytePtr(address);
+        addrlen = CFDataGetLength(address);
+    }
+    dataptr = CFDataGetBytePtr(data);
+    datalen = CFDataGetLength(data);
+    if (CFSocketIsValid(s)) sock = CFSocketGetNative(s);
+    if (INVALID_SOCKET != sock) {
+        CFRetain(s);
+        __CFSocketWriteLock(s);
+        tv.tv_sec = (0 >= timeout || INT_MAX <= timeout) ? INT_MAX : (int)(float)floor(timeout);
+        tv.tv_usec = (int)((timeout - floor(timeout)) * 1.0E6);
+        setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (SOCK_CONST_DATA)&tv, sizeof(tv));	// cast for WinSock bad API
+        if (NULL != addrptr && 0 < addrlen) {
+            size = sendto(sock, (SOCK_CONST_DATA)dataptr, datalen, 0, (struct sockaddr *)addrptr, addrlen);
+        } else {
+            size = send(sock, (SOCK_CONST_DATA)dataptr, datalen, 0);
+        }
+#if defined(LOG_CFSOCKET)
+        fprintf(stdout, "wrote %ld bytes to socket %d\n", size, sock);
+#endif
+        __CFSocketWriteUnlock(s);
+        CFRelease(s);
+    }
+    return (size > 0) ? kCFSocketSuccess : kCFSocketError;
+}
+
+CFSocketError CFSocketSetAddress(CFSocketRef s, CFDataRef address) {
+    CHECK_FOR_FORK();
+    const uint8_t *name;
+    SInt32 namelen, result = 0;
+    __CFGenericValidateType(s, CFSocketGetTypeID());
+    if (NULL == address) return -1;
+    if (!CFSocketIsValid(s)) return 0;
+    name = CFDataGetBytePtr(address);
+    namelen = CFDataGetLength(address);
+    if (!name || namelen <= 0) return 0;
+    CFSocketNativeHandle sock = CFSocketGetNative(s);
+        result = bind(sock, (struct sockaddr *)name, namelen);
+        if (0 == result) {
+            listen(sock, 256);
+        }
+    //??? should return errno
+    return result;
+}
+
+CFSocketError CFSocketConnectToAddress(CFSocketRef s, CFDataRef address, CFTimeInterval timeout) {
+    CHECK_FOR_FORK();
+    //??? need error handling, retries
+    const uint8_t *name;
+    SInt32 namelen, result = -1, connect_err = 0, select_err = 0;
+#if DEPLOYMENT_TARGET_WINDOWS
+    u_long yes = 1, no = 0;
+#else
+    UInt32 yes = 1, no = 0;
+#endif
+    Boolean wasBlocking = true;
+
+    __CFGenericValidateType(s, CFSocketGetTypeID());
+    if (!CFSocketIsValid(s)) return 0;
+    name = CFDataGetBytePtr(address);
+    namelen = CFDataGetLength(address);
+    if (!name || namelen <= 0) return 0;
+    CFSocketNativeHandle sock = CFSocketGetNative(s);
+    {
+#if !DEPLOYMENT_TARGET_WINDOWS
+        SInt32 flags = fcntl(sock, F_GETFL, 0);
+        if (flags >= 0) wasBlocking = ((flags & O_NONBLOCK) == 0);
+#endif
+        if (wasBlocking && (timeout > 0.0 || timeout < 0.0)) ioctlsocket(sock, FIONBIO, &yes);
+        result = connect(sock, (struct sockaddr *)name, namelen);
+        if (result != 0) {
+            connect_err = __CFSocketLastError();
+#if DEPLOYMENT_TARGET_WINDOWS
+            if (connect_err == WSAEWOULDBLOCK) connect_err = EINPROGRESS;
+#endif
+        }
+#if defined(LOG_CFSOCKET)
+#if !DEPLOYMENT_TARGET_WINDOWS
+        fprintf(stdout, "connection attempt returns %ld error %ld on socket %d (flags 0x%lx blocking %d)\n", result, connect_err, sock, flags, wasBlocking);
+#else
+        fprintf(stdout, "connection attempt returns %ld error %ld on socket %d\n", result, connect_err, s->_socket);
+#endif
+
+#endif
+        if (EINPROGRESS == connect_err && timeout >= 0.0) {
+            /* select on socket */
+            SInt32 nrfds;
+            int error_size = sizeof(select_err);
+            struct timeval tv;
+            CFMutableDataRef fds = CFDataCreateMutable(kCFAllocatorSystemDefault, 0);
+#if DEPLOYMENT_TARGET_WINDOWS
+            CFDataIncreaseLength(fds , sizeof(u_int) + sizeof(SOCKET));
+#endif
+            __CFSocketFdSet(sock, fds);
+            tv.tv_sec = (0 >= timeout || INT_MAX <= timeout) ? INT_MAX : (int)(float)floor(timeout);
+            tv.tv_usec = (int)((timeout - floor(timeout)) * 1.0E6);
+            nrfds = select(__CFSocketFdGetSize(fds), NULL, (fd_set *)CFDataGetMutableBytePtr(fds), NULL, &tv);
+            if (nrfds < 0) {
+                select_err = __CFSocketLastError();
+                result = -1;
+            } else if (nrfds == 0) {
+                result = -2;
+            } else {
+                if (0 != getsockopt(sock, SOL_SOCKET, SO_ERROR, (SOCK_DATA)&select_err, (socklen_t *)&error_size)) select_err = 0;
+                result = (select_err == 0) ? 0 : -1;
+            }
+            CFRelease(fds);
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "timed connection attempt %s on socket %d, result %ld, select returns %ld error %ld\n", (result == 0) ? "succeeds" : "fails", sock, result, nrfds, select_err);
+#endif
+        }
+        if (wasBlocking && (timeout > 0.0 || timeout < 0.0)) ioctlsocket(sock, FIONBIO, &no);
+        if (EINPROGRESS == connect_err && timeout < 0.0) {
+            result = 0;
+#if defined(LOG_CFSOCKET)
+            fprintf(stdout, "connection attempt continues in background on socket %d\n", sock);
+#endif
+        }
+    }
+    //??? should return errno
+    return result;
+}
+
+CFSocketRef CFSocketCreate(CFAllocatorRef allocator, SInt32 protocolFamily, SInt32 socketType, SInt32 protocol, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context) {
+    CHECK_FOR_FORK();
+    CFSocketNativeHandle sock = INVALID_SOCKET;
+    CFSocketRef s = NULL;
+    if (0 >= protocolFamily) protocolFamily = PF_INET;
+    if (PF_INET == protocolFamily) {
+        if (0 >= socketType) socketType = SOCK_STREAM;
+        if (0 >= protocol && SOCK_STREAM == socketType) protocol = IPPROTO_TCP;
+        if (0 >= protocol && SOCK_DGRAM == socketType) protocol = IPPROTO_UDP;
+    }
+#if !DEPLOYMENT_TARGET_WINDOWS
+    if (PF_LOCAL == protocolFamily && 0 >= socketType) socketType = SOCK_STREAM;
+#else
+    __CFSocketInitializeWinSock();
+#endif
+    sock = (CFSocketNativeHandle)socket(protocolFamily, socketType, protocol);
+    if (INVALID_SOCKET != sock) {
+        s = _CFSocketCreateWithNative(allocator, sock, callBackTypes, callout, context, FALSE);
+    }
+    return s;
+}
+
+CFSocketRef CFSocketCreateWithSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context) {
+    CHECK_FOR_FORK();
+    CFSocketRef s = CFSocketCreate(allocator, signature->protocolFamily, signature->socketType, signature->protocol, callBackTypes, callout, context);
+    if (NULL != s && (!CFSocketIsValid(s) || kCFSocketSuccess != CFSocketSetAddress(s, signature->address))) {
+        CFSocketInvalidate(s);
+        CFRelease(s);
+        s = NULL;
+    }
+    return s;
+}
+
+CFSocketRef CFSocketCreateConnectedToSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context, CFTimeInterval timeout) {
+    CHECK_FOR_FORK();
+    CFSocketRef s = CFSocketCreate(allocator, signature->protocolFamily, signature->socketType, signature->protocol, callBackTypes, callout, context);
+    if (NULL != s && (!CFSocketIsValid(s) || kCFSocketSuccess != CFSocketConnectToAddress(s, signature->address, timeout))) {
+        CFSocketInvalidate(s);
+        CFRelease(s);
+        s = NULL;
+    }
+    return s;
+}
+
+typedef struct {
+    CFSocketError *error;
+    CFPropertyListRef *value;
+    CFDataRef *address;
+} __CFSocketNameRegistryResponse;
+
+static void __CFSocketHandleNameRegistryReply(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) {
+    CFDataRef replyData = (CFDataRef)data;
+    __CFSocketNameRegistryResponse *response = (__CFSocketNameRegistryResponse *)info;
+    CFDictionaryRef replyDictionary = NULL;
+    CFPropertyListRef value;
+    replyDictionary = (CFDictionaryRef)CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, replyData, kCFPropertyListImmutable, NULL);
+    if (NULL != response->error) *(response->error) = kCFSocketError;
+    if (NULL != replyDictionary) {
+        if (CFGetTypeID((CFTypeRef)replyDictionary) == CFDictionaryGetTypeID() && NULL != (value = CFDictionaryGetValue(replyDictionary, kCFSocketResultKey))) {
+            if (NULL != response->error) *(response->error) = kCFSocketSuccess;
+            if (NULL != response->value) *(response->value) = CFRetain(value);
+            if (NULL != response->address) *(response->address) = address ? CFDataCreateCopy(kCFAllocatorSystemDefault, address) : NULL;
+        }
+        CFRelease(replyDictionary);
+    }
+    CFSocketInvalidate(s);
+}
+
+static void __CFSocketSendNameRegistryRequest(CFSocketSignature *signature, CFDictionaryRef requestDictionary, __CFSocketNameRegistryResponse *response, CFTimeInterval timeout) {
+    CFDataRef requestData = NULL;
+    CFSocketContext context = {0, response, NULL, NULL, NULL};
+    CFSocketRef s = NULL;
+    CFRunLoopSourceRef source = NULL;
+    if (NULL != response->error) *(response->error) = kCFSocketError;
+    requestData = CFPropertyListCreateXMLData(kCFAllocatorSystemDefault, requestDictionary);
+    if (NULL != requestData) {
+        if (NULL != response->error) *(response->error) = kCFSocketTimeout;
+        s = CFSocketCreateConnectedToSocketSignature(kCFAllocatorSystemDefault, signature, kCFSocketDataCallBack, __CFSocketHandleNameRegistryReply, &context, timeout);
+        if (NULL != s) {
+            if (kCFSocketSuccess == CFSocketSendData(s, NULL, requestData, timeout)) {
+                source = CFSocketCreateRunLoopSource(kCFAllocatorSystemDefault, s, 0);
+                CFRunLoopAddSource(CFRunLoopGetCurrent(), source, __kCFSocketRegistryRequestRunLoopMode);
+                CFRunLoopRunInMode(__kCFSocketRegistryRequestRunLoopMode, timeout, false);
+                CFRelease(source);
+            }
+            CFSocketInvalidate(s);
+            CFRelease(s);
+        }
+        CFRelease(requestData);
+    }
+}
+
+static void __CFSocketValidateSignature(const CFSocketSignature *providedSignature, CFSocketSignature *signature, uint16_t defaultPortNumber) {
+    struct sockaddr_in sain, *sainp;
+    memset(&sain, 0, sizeof(sain));
+#if DEPLOYMENT_TARGET_MACOSX
+    sain.sin_len = sizeof(sain);
+#endif
+    sain.sin_family = AF_INET;
+    sain.sin_port = htons(__CFSocketDefaultNameRegistryPortNumber);
+    sain.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+    if (NULL == providedSignature) {
+        signature->protocolFamily = PF_INET;
+        signature->socketType = SOCK_STREAM;
+        signature->protocol = IPPROTO_TCP;
+        signature->address = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)&sain, sizeof(sain));
+    } else {
+        signature->protocolFamily = providedSignature->protocolFamily;
+        signature->socketType = providedSignature->socketType;
+        signature->protocol = providedSignature->protocol;
+        if (0 >= signature->protocolFamily) signature->protocolFamily = PF_INET;
+        if (PF_INET == signature->protocolFamily) {
+            if (0 >= signature->socketType) signature->socketType = SOCK_STREAM;
+            if (0 >= signature->protocol && SOCK_STREAM == signature->socketType) signature->protocol = IPPROTO_TCP;
+            if (0 >= signature->protocol && SOCK_DGRAM == signature->socketType) signature->protocol = IPPROTO_UDP;
+        }
+        if (NULL == providedSignature->address) {
+            signature->address = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)&sain, sizeof(sain));
+        } else {
+            sainp = (struct sockaddr_in *)CFDataGetBytePtr(providedSignature->address);
+            if ((int)sizeof(struct sockaddr_in) <= CFDataGetLength(providedSignature->address) && (AF_INET == sainp->sin_family || 0 == sainp->sin_family)) {
+#if DEPLOYMENT_TARGET_MACOSX
+                sain.sin_len = sizeof(sain);
+#endif
+                sain.sin_family = AF_INET;
+                sain.sin_port = sainp->sin_port;
+                if (0 == sain.sin_port) sain.sin_port = htons(defaultPortNumber);
+                sain.sin_addr.s_addr = sainp->sin_addr.s_addr;
+                if (htonl(INADDR_ANY) == sain.sin_addr.s_addr) sain.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+                signature->address = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)&sain, sizeof(sain));
+            } else {
+                signature->address = (CFDataRef)CFRetain(providedSignature->address);
+            }
+        }
+    }
+}
+
+CFSocketError CFSocketRegisterValue(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFPropertyListRef value) {
+    CFSocketSignature signature;
+    CFMutableDictionaryRef dictionary = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFSocketError retval = kCFSocketError;
+    __CFSocketNameRegistryResponse response = {&retval, NULL, NULL};
+    CFDictionaryAddValue(dictionary, kCFSocketCommandKey, kCFSocketRegisterCommand);
+    CFDictionaryAddValue(dictionary, kCFSocketNameKey, name);
+    if (NULL != value) CFDictionaryAddValue(dictionary, kCFSocketValueKey, value);
+    __CFSocketValidateSignature(nameServerSignature, &signature, __CFSocketDefaultNameRegistryPortNumber);
+    __CFSocketSendNameRegistryRequest(&signature, dictionary, &response, timeout);
+    CFRelease(dictionary);
+    CFRelease(signature.address);
+    return retval;
+}
+
+CFSocketError CFSocketCopyRegisteredValue(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFPropertyListRef *value, CFDataRef *serverAddress) {
+    CFSocketSignature signature;
+    CFMutableDictionaryRef dictionary = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFSocketError retval = kCFSocketError;
+    __CFSocketNameRegistryResponse response = {&retval, value, serverAddress};
+    CFDictionaryAddValue(dictionary, kCFSocketCommandKey, kCFSocketRetrieveCommand);
+    CFDictionaryAddValue(dictionary, kCFSocketNameKey, name);
+    __CFSocketValidateSignature(nameServerSignature, &signature, __CFSocketDefaultNameRegistryPortNumber);
+    __CFSocketSendNameRegistryRequest(&signature, dictionary, &response, timeout);
+    CFRelease(dictionary);
+    CFRelease(signature.address);
+    return retval;
+}
+
+CFSocketError CFSocketRegisterSocketSignature(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, const CFSocketSignature *signature) {
+    CFSocketSignature validatedSignature;
+    CFMutableDataRef data = NULL;
+    CFSocketError retval;
+    CFIndex length;
+    uint8_t bytes[4];
+    if (NULL == signature) {
+        retval = CFSocketUnregister(nameServerSignature, timeout, name);
+    } else {
+        __CFSocketValidateSignature(signature, &validatedSignature, 0);
+        if (NULL == validatedSignature.address || 0 > validatedSignature.protocolFamily || 255 < validatedSignature.protocolFamily || 0 > validatedSignature.socketType || 255 < validatedSignature.socketType || 0 > validatedSignature.protocol || 255 < validatedSignature.protocol || 0 >= (length = CFDataGetLength(validatedSignature.address)) || 255 < length) {
+            retval = kCFSocketError;
+        } else {
+            data = CFDataCreateMutable(kCFAllocatorSystemDefault, sizeof(bytes) + length);
+            bytes[0] = validatedSignature.protocolFamily;
+            bytes[1] = validatedSignature.socketType;
+            bytes[2] = validatedSignature.protocol;
+            bytes[3] = (uint8_t)length;
+            CFDataAppendBytes(data, bytes, sizeof(bytes));
+            CFDataAppendBytes(data, CFDataGetBytePtr(validatedSignature.address), length);
+            retval = CFSocketRegisterValue(nameServerSignature, timeout, name, data);
+            CFRelease(data);
+        }
+        CFRelease(validatedSignature.address);
+    }
+    return retval;
+}
+
+CFSocketError CFSocketCopyRegisteredSocketSignature(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFSocketSignature *signature, CFDataRef *nameServerAddress) {
+    CFDataRef data = NULL;
+    CFSocketSignature returnedSignature;
+    const uint8_t *ptr = NULL, *aptr = NULL;
+    uint8_t *mptr;
+    CFIndex length = 0;
+    CFDataRef serverAddress = NULL;
+    CFSocketError retval = CFSocketCopyRegisteredValue(nameServerSignature, timeout, name, (CFPropertyListRef *)&data, &serverAddress);
+    if (NULL == data || CFGetTypeID(data) != CFDataGetTypeID() || NULL == (ptr = CFDataGetBytePtr(data)) || (length = CFDataGetLength(data)) < 4) retval = kCFSocketError;
+    if (kCFSocketSuccess == retval && NULL != signature) {
+        returnedSignature.protocolFamily = (SInt32)*ptr++;
+        returnedSignature.socketType = (SInt32)*ptr++;
+        returnedSignature.protocol = (SInt32)*ptr++;
+        ptr++;
+        returnedSignature.address = CFDataCreate(kCFAllocatorSystemDefault, ptr, length - 4);
+        __CFSocketValidateSignature(&returnedSignature, signature, 0);
+        CFRelease(returnedSignature.address);
+        ptr = CFDataGetBytePtr(signature->address);
+        if (CFDataGetLength(signature->address) >= (int)sizeof(struct sockaddr_in) && AF_INET == ((struct sockaddr *)ptr)->sa_family && NULL != serverAddress && CFDataGetLength(serverAddress) >= (int)sizeof(struct sockaddr_in) && NULL != (aptr = CFDataGetBytePtr(serverAddress)) && AF_INET == ((struct sockaddr *)aptr)->sa_family) {
+            CFMutableDataRef address = CFDataCreateMutableCopy(kCFAllocatorSystemDefault, CFDataGetLength(signature->address), signature->address);
+            mptr = CFDataGetMutableBytePtr(address);
+            ((struct sockaddr_in *)mptr)->sin_addr = ((struct sockaddr_in *)aptr)->sin_addr;
+            CFRelease(signature->address);
+            signature->address = address;
+        }
+        if (NULL != nameServerAddress) *nameServerAddress = serverAddress ? (CFDataRef)CFRetain(serverAddress) : NULL;
+    }
+    if (NULL != data) CFRelease(data);
+    if (NULL != serverAddress) CFRelease(serverAddress);
+    return retval;
+}
+
+CFSocketError CFSocketUnregister(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name) {
+    return CFSocketRegisterValue(nameServerSignature, timeout, name, NULL);
+}
+
+CF_EXPORT void CFSocketSetDefaultNameRegistryPortNumber(uint16_t port) {
+    __CFSocketDefaultNameRegistryPortNumber = port;
+}
+
+CF_EXPORT uint16_t CFSocketGetDefaultNameRegistryPortNumber(void) {
+    return __CFSocketDefaultNameRegistryPortNumber;
+}
+
+
diff --git a/CoreFoundation/CFSocket.h b/CoreFoundation/CFSocket.h
new file mode 100644
index 0000000..919f2d8
--- /dev/null
+++ b/CoreFoundation/CFSocket.h
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSOCKET__)
+#define __COREFOUNDATION_CFSOCKET__ 1
+
+#ifdef WIN32
+// Avoid actually including <winsock2.h>, as it can screw up lots of data type definitions
+typedef unsigned int CFSocketNativeHandle;
+#else
+typedef int CFSocketNativeHandle;
+#endif
+
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFData.h>
+
+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 */
+enum {
+    kCFSocketSuccess = 0,
+    kCFSocketError = -1,
+    kCFSocketTimeout = -2
+};
+typedef CFIndex CFSocketError;
+
+typedef struct {
+    SInt32	protocolFamily;
+    SInt32	socketType;
+    SInt32	protocol;
+    CFDataRef	address;
+} CFSocketSignature;
+
+/* Values for CFSocketCallBackType */
+enum {
+    kCFSocketNoCallBack = 0,
+    kCFSocketReadCallBack = 1,
+    kCFSocketAcceptCallBack = 2,
+    kCFSocketDataCallBack = 3,
+    kCFSocketConnectCallBack = 4
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    ,
+    kCFSocketWriteCallBack = 8
+#endif
+};
+typedef CFOptionFlags CFSocketCallBackType;
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/* Socket flags */
+enum {
+    kCFSocketAutomaticallyReenableReadCallBack = 1,
+    kCFSocketAutomaticallyReenableAcceptCallBack = 2,
+    kCFSocketAutomaticallyReenableDataCallBack = 3,
+    kCFSocketAutomaticallyReenableWriteCallBack = 8,
+    kCFSocketCloseOnInvalidate = 128
+};
+#endif
+
+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;
+
+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);
+CF_EXPORT CFSocketRef	CFSocketCreateConnectedToSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context, CFTimeInterval timeout);
+/* CFSocketCreateWithSignature creates a socket of the requested type and binds its address (using CFSocketSetAddress) to the requested address.  If this fails, it returns NULL.  CFSocketCreateConnectedToSignature 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);
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+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);
+#endif
+
+/* 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
+
+#endif /* ! __COREFOUNDATION_CFSOCKET__ */
+
diff --git a/CoreFoundation/CFSocketStream.c b/CoreFoundation/CFSocketStream.c
new file mode 100644
index 0000000..fdca231
--- /dev/null
+++ b/CoreFoundation/CFSocketStream.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFSocketStream.c
+	Copyright 2000-2002, Apple, Inc. All rights reserved.
+	Responsibility: Jeremy Wyld
+*/
+//	Original Author: Becky Willrich
+#include <CoreFoundation/CFStream.h>
+#include <CoreFoundation/CFNumber.h>
+#include "CFInternal.h"
+#include "CFStreamInternal.h"
+#include "CFStreamPriv.h"
+
+#if DEPLOYMENT_TARGET_MACOSX
+// On Mach these live in CF for historical reasons, even though they are declared in CFNetwork
+
+const int kCFStreamErrorDomainSSL = 3;
+const int kCFStreamErrorDomainSOCKS = 5;
+
+CONST_STRING_DECL(kCFStreamPropertyShouldCloseNativeSocket, "kCFStreamPropertyShouldCloseNativeSocket")
+CONST_STRING_DECL(kCFStreamPropertyAutoErrorOnSystemChange, "kCFStreamPropertyAutoErrorOnSystemChange");
+
+CONST_STRING_DECL(kCFStreamPropertySOCKSProxy, "kCFStreamPropertySOCKSProxy")
+CONST_STRING_DECL(kCFStreamPropertySOCKSProxyHost, "SOCKSProxy")
+CONST_STRING_DECL(kCFStreamPropertySOCKSProxyPort, "SOCKSPort")
+CONST_STRING_DECL(kCFStreamPropertySOCKSVersion, "kCFStreamPropertySOCKSVersion")
+CONST_STRING_DECL(kCFStreamSocketSOCKSVersion4, "kCFStreamSocketSOCKSVersion4")
+CONST_STRING_DECL(kCFStreamSocketSOCKSVersion5, "kCFStreamSocketSOCKSVersion5")
+CONST_STRING_DECL(kCFStreamPropertySOCKSUser, "kCFStreamPropertySOCKSUser")
+CONST_STRING_DECL(kCFStreamPropertySOCKSPassword, "kCFStreamPropertySOCKSPassword")
+
+CONST_STRING_DECL(kCFStreamPropertySocketSecurityLevel, "kCFStreamPropertySocketSecurityLevel");
+CONST_STRING_DECL(kCFStreamSocketSecurityLevelNone, "kCFStreamSocketSecurityLevelNone");
+CONST_STRING_DECL(kCFStreamSocketSecurityLevelSSLv2, "kCFStreamSocketSecurityLevelSSLv2");
+CONST_STRING_DECL(kCFStreamSocketSecurityLevelSSLv3, "kCFStreamSocketSecurityLevelSSLv3");
+CONST_STRING_DECL(kCFStreamSocketSecurityLevelTLSv1, "kCFStreamSocketSecurityLevelTLSv1");
+CONST_STRING_DECL(kCFStreamSocketSecurityLevelNegotiatedSSL, "kCFStreamSocketSecurityLevelNegotiatedSSL");
+
+#endif
+
+// These are duplicated in CFNetwork, who actually externs them in its headers
+CONST_STRING_DECL(kCFStreamPropertySocketSSLContext, "kCFStreamPropertySocketSSLContext")
+CONST_STRING_DECL(_kCFStreamPropertySocketSecurityAuthenticatesServerCertificate, "_kCFStreamPropertySocketSecurityAuthenticatesServerCertificate");
+
+
+CF_EXPORT
+void _CFSocketStreamSetAuthenticatesServerCertificateDefault(Boolean shouldAuthenticate) {
+    CFLog(__kCFLogAssertion, CFSTR("_CFSocketStreamSetAuthenticatesServerCertificateDefault(): This call has been deprecated.  Use SetProperty(_kCFStreamPropertySocketSecurityAuthenticatesServerCertificate, kCFBooleanTrue/False)\n"));
+}
+
+
+/* CF_EXPORT */ Boolean
+_CFSocketStreamGetAuthenticatesServerCertificateDefault(void) {
+    CFLog(__kCFLogAssertion, CFSTR("_CFSocketStreamGetAuthenticatesServerCertificateDefault(): This call has been removed as a security risk.  Use security properties on individual streams instead.\n"));
+    return FALSE;
+}
+
+
+/* CF_EXPORT */ void
+_CFSocketStreamPairSetAuthenticatesServerCertificate(CFReadStreamRef rStream, CFWriteStreamRef wStream, Boolean authenticates) {
+    
+    CFBooleanRef value = (!authenticates ? kCFBooleanFalse : kCFBooleanTrue);
+    
+    if (rStream)
+        CFReadStreamSetProperty(rStream, _kCFStreamPropertySocketSecurityAuthenticatesServerCertificate, value);
+    else
+        CFWriteStreamSetProperty(wStream, _kCFStreamPropertySocketSecurityAuthenticatesServerCertificate, value);
+}
+
+
+// Flags for dyld loading of libraries.
+enum {
+    kTriedToLoad = 0,
+    kInitialized
+};
+
+typedef void          (*cf_net_CreatePair)(CFAllocatorRef, CFStringRef, UInt32, CFSocketNativeHandle, const CFSocketSignature*, CFReadStreamRef*, CFWriteStreamRef*);
+typedef CFErrorRef    (*cf_net_StreamError)(CFAllocatorRef, CFStreamError*);
+typedef CFStreamError (*cf_net_FromCFError)(CFErrorRef);
+
+static struct {
+    CFSpinLock_t lock;
+    UInt32	flags;
+    void (*_CFSocketStreamCreatePair)(CFAllocatorRef, CFStringRef, UInt32, CFSocketNativeHandle, const CFSocketSignature*, CFReadStreamRef*, CFWriteStreamRef*);
+    CFErrorRef (*_CFErrorCreateWithStreamError)(CFAllocatorRef, CFStreamError*);
+    CFStreamError (*_CFStreamErrorFromCFError)(CFErrorRef);
+} CFNetworkSupport = {
+    CFSpinLockInit,
+    0x0,
+    NULL,
+    NULL,
+    NULL
+};
+
+#define CFNETWORK_CALL(sym, args)		((CFNetworkSupport.sym)args)
+
+#if DEPLOYMENT_TARGET_MACOSX
+#define CFNETWORK_LOAD_SYM(sym)   __CFLookupCFNetworkFunction(#sym)
+//#elif DEPLOYMENT_TARGET_WINDOWS
+//#define CFNETWORK_LOAD_SYM(sym)   (void *)GetProcAddress(CFNetworkSupport.image, #sym)
+#endif
+
+static void initializeCFNetworkSupport(void) {
+    __CFBitSet(CFNetworkSupport.flags, kTriedToLoad);
+
+#if DEPLOYMENT_TARGET_MACOSX
+    CFNetworkSupport._CFSocketStreamCreatePair = (cf_net_CreatePair)CFNETWORK_LOAD_SYM(_CFSocketStreamCreatePair);
+    CFNetworkSupport._CFErrorCreateWithStreamError = (cf_net_StreamError)CFNETWORK_LOAD_SYM(_CFErrorCreateWithStreamError);
+    CFNetworkSupport._CFStreamErrorFromCFError = (cf_net_FromCFError)CFNETWORK_LOAD_SYM(_CFStreamErrorFromCFError);
+#endif
+   
+    if (!CFNetworkSupport._CFSocketStreamCreatePair) CFLog(__kCFLogAssertion, CFSTR("CoreFoundation: failed to dynamically link symbol _CFSocketStreamCreatePair"));
+    if (!CFNetworkSupport._CFErrorCreateWithStreamError) CFLog(__kCFLogAssertion, CFSTR("CoreFoundation: failed to dynamically link symbol _CFErrorCreateWithStreamError"));
+    if (!CFNetworkSupport._CFStreamErrorFromCFError) CFLog(__kCFLogAssertion, CFSTR("CoreFoundation: failed to dynamically link symbol _CFStreamErrorFromCFError"));
+            
+    __CFBitSet(CFNetworkSupport.flags, kInitialized);
+}
+
+static void
+createPair(CFAllocatorRef alloc, CFStringRef host, UInt32 port, CFSocketNativeHandle sock, const CFSocketSignature* sig, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream)
+{
+    if (readStream)
+        *readStream = NULL;
+        
+    if (writeStream)
+        *writeStream = NULL;
+
+    __CFSpinLock(&(CFNetworkSupport.lock));
+    if (!__CFBitIsSet(CFNetworkSupport.flags, kTriedToLoad)) initializeCFNetworkSupport();
+    __CFSpinUnlock(&(CFNetworkSupport.lock));
+
+    CFNETWORK_CALL(_CFSocketStreamCreatePair, (alloc, host, port, sock, sig, readStream, writeStream));
+}
+
+
+extern void CFStreamCreatePairWithSocket(CFAllocatorRef alloc, CFSocketNativeHandle sock, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream) {
+    createPair(alloc, NULL, 0, sock, NULL, readStream, writeStream);
+}
+
+extern void CFStreamCreatePairWithSocketToHost(CFAllocatorRef alloc, CFStringRef host, UInt32 port, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream) {
+    createPair(alloc, host, port, 0, NULL, readStream, writeStream);
+}
+
+extern void CFStreamCreatePairWithPeerSocketSignature(CFAllocatorRef alloc, const CFSocketSignature* sig, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream) {
+    createPair(alloc, NULL, 0, 0, sig, readStream, writeStream);
+}
+
+__private_extern__ CFStreamError _CFStreamErrorFromError(CFErrorRef error) {
+    CFStreamError result;
+    Boolean canUpCall;
+    
+    __CFSpinLock(&(CFNetworkSupport.lock));
+    if (!__CFBitIsSet(CFNetworkSupport.flags, kTriedToLoad)) initializeCFNetworkSupport();
+    canUpCall = (CFNetworkSupport._CFStreamErrorFromCFError != NULL);
+    __CFSpinUnlock(&(CFNetworkSupport.lock));
+
+    if (canUpCall) {
+        result = CFNETWORK_CALL(_CFStreamErrorFromCFError, (error));
+    } else {
+        CFStringRef domain = CFErrorGetDomain(error); 
+        if (CFEqual(domain, kCFErrorDomainPOSIX)) {
+            result.domain = kCFStreamErrorDomainPOSIX;
+        } else if (CFEqual(domain, kCFErrorDomainOSStatus)) {
+            result.domain = kCFStreamErrorDomainMacOSStatus;
+        } else if (CFEqual(domain, kCFErrorDomainMach)) {
+            result.domain = 11; // kCFStreamErrorDomainMach, but that symbol is in CFNetwork
+        } else {
+            result.domain = kCFStreamErrorDomainCustom;
+        }
+        result.error = CFErrorGetCode(error);
+    }
+    return result;
+}
+
+__private_extern__ CFErrorRef _CFErrorFromStreamError(CFAllocatorRef alloc, CFStreamError *streamError) {
+    CFErrorRef result;
+    Boolean canUpCall;
+    
+    __CFSpinLock(&(CFNetworkSupport.lock));
+    if (!__CFBitIsSet(CFNetworkSupport.flags, kTriedToLoad)) initializeCFNetworkSupport();
+    canUpCall = (CFNetworkSupport._CFErrorCreateWithStreamError != NULL);
+    __CFSpinUnlock(&(CFNetworkSupport.lock));
+
+    if (canUpCall) {
+        result = CFNETWORK_CALL(_CFErrorCreateWithStreamError, (alloc, streamError));
+    } else {
+        if (streamError->domain == kCFStreamErrorDomainPOSIX) {
+            return CFErrorCreate(alloc, kCFErrorDomainPOSIX, streamError->error, NULL);
+        } else if (streamError->domain == kCFStreamErrorDomainMacOSStatus) {
+            return CFErrorCreate(alloc, kCFErrorDomainOSStatus, streamError->error, NULL);
+        } else {
+            CFStringRef key = CFSTR("CFStreamErrorDomainKey");
+            CFNumberRef value = CFNumberCreate(alloc, kCFNumberCFIndexType, &streamError->domain);
+            CFDictionaryRef dict = CFDictionaryCreate(alloc, (const void **)(&key), (const void **)(&value), 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+            result = CFErrorCreate(alloc, CFSTR("BogusCFStreamErrorCompatibilityDomain"), streamError->error, dict);
+            CFRelease(value);
+            CFRelease(dict);
+        }
+    }
+    return result;
+}
diff --git a/CoreFoundation/CFSortFunctions.c b/CoreFoundation/CFSortFunctions.c
new file mode 100644
index 0000000..4a7e8d9
--- /dev/null
+++ b/CoreFoundation/CFSortFunctions.c
@@ -0,0 +1,1035 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFSortFunctions.c
+	Copyright 1999-2007, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+/* This file contains code copied from the Libc project's files
+   qsort.c and merge.c, and modified to suit the
+   needs of CF, which needs the comparison callback to have an
+   additional parameter. The code is collected into this one
+   file so that the individual BSD sort routines can remain
+   private and static.
+*/
+
+#include <CoreFoundation/CFBase.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+#include <sys/types.h>
+#else
+#define EINVAL		22
+#endif
+#include "CFInternal.h"
+
+#include <stdio.h>
+
+typedef CFComparisonResult (*Comparison_Func)(const void *, const void *, void *);
+
+/* stdlib.subproj/qsort.c ============================================== */
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)qsort.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/qsort.c,v 1.12 2002/09/10 02:04:49 wollman Exp $");
+#endif
+
+#include <stdlib.h>
+
+#ifdef I_AM_QSORT_R
+typedef int		 cmp_t(void *, const void *, const void *);
+#else
+typedef CFComparisonResult		 cmp_t(const void *, const void *, void *);
+#endif
+static inline char	*med3(char *, char *, char *, cmp_t *, void *);
+static inline void	 swapfunc(char *, char *, long, long);
+
+#if !defined(min)
+#define min(a, b)	(a) < (b) ? a : b
+#endif
+/*
+ * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
+ */
+#define swapcode(TYPE, parmi, parmj, n) { 		\
+	long i = (n) / sizeof (TYPE); 			\
+	TYPE *pi = (TYPE *) (parmi); 		\
+	TYPE *pj = (TYPE *) (parmj); 		\
+	do { 						\
+		TYPE	t = *pi;		\
+		*pi++ = *pj;				\
+		*pj++ = t;				\
+        } while (--i > 0);				\
+}
+
+#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
+	es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
+
+static inline void
+swapfunc(char *a, char *b, long n, long swaptype)
+{
+	if(swaptype <= 1)
+		swapcode(long, a, b, n)
+	else
+		swapcode(char, a, b, n)
+}
+
+#define swap(a, b)					\
+	if (swaptype == 0) {				\
+		long t = *(long *)(a);			\
+		*(long *)(a) = *(long *)(b);		\
+		*(long *)(b) = t;			\
+	} else						\
+		swapfunc(a, b, es, swaptype)
+
+#define vecswap(a, b, n) 	if ((n) > 0) swapfunc(a, b, n, swaptype)
+
+#ifdef I_AM_QSORT_R
+#define	CMP(t, x, y) (cmp((t), (x), (y)))
+#else
+#define	CMP(t, x, y) (cmp((x), (y), (t)))
+#endif
+
+static inline char *
+med3(char *a, char *b, char *c, cmp_t *cmp, void *thunk)
+{
+	return CMP(thunk, a, b) < 0 ?
+	       (CMP(thunk, b, c) < 0 ? b : (CMP(thunk, a, c) < 0 ? c : a ))
+              :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c ));
+}
+
+#ifdef I_AM_QSORT_R
+void
+qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp)
+#else
+static void
+bsd_qsort(void *a, size_t n, size_t es, cmp_t *cmp, void *thunk)
+#endif
+{
+	char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
+	long d, r, swaptype, swap_cnt;
+
+loop:	SWAPINIT(a, es);
+	swap_cnt = 0;
+	if (n < 7) {
+		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+			for (pl = pm; 
+			     pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
+	}
+	pm = (char *)a + (n / 2) * es;
+	if (n > 7) {
+		pl = (char *)a;
+		pn = (char *)a + (n - 1) * es;
+		if (n > 40) {
+			d = (n / 8) * es;
+			pl = med3(pl, pl + d, pl + 2 * d, cmp, thunk);
+			pm = med3(pm - d, pm, pm + d, cmp, thunk);
+			pn = med3(pn - 2 * d, pn - d, pn, cmp, thunk);
+		}
+		pm = med3(pl, pm, pn, cmp, thunk);
+	}
+	swap((char *)a, pm);
+	pa = pb = (char *)a + es;
+
+	pc = pd = (char *)a + (n - 1) * es;
+	for (;;) {
+		while (pb <= pc && (r = CMP(thunk, pb, a)) <= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pa, pb);
+				pa += es;
+			}
+			pb += es;
+		}
+		while (pb <= pc && (r = CMP(thunk, pc, a)) >= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pc, pd);
+				pd -= es;
+			}
+			pc -= es;
+		}
+		if (pb > pc)
+			break;
+		swap(pb, pc);
+		swap_cnt = 1;
+		pb += es;
+		pc -= es;
+	}
+	if (swap_cnt == 0) {  /* Switch to insertion sort */
+		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+			for (pl = pm; 
+			     pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
+	}
+
+	pn = (char *)a + n * es;
+	r = min(pa - (char *)a, pb - pa);
+	vecswap((char *)a, pb - r, r);
+	r = min(pd - pc, pn - pd - es);
+	vecswap(pb, pn - r, r);
+	if ((r = pb - pa) > es)
+#ifdef I_AM_QSORT_R
+		qsort_r(a, r / es, es, thunk, cmp);
+#else
+		bsd_qsort(a, r / es, es, cmp, thunk);
+#endif
+	if ((r = pd - pc) > es) {
+		/* Iterate rather than recurse to save stack space */
+		a = pn - r;
+		n = r / es;
+		goto loop;
+	}
+/*		qsort(pn - r, r / es, es, cmp);*/
+}
+
+
+/* And now for something not so completely different, a copy/paste version that uses write-barriers so as to notify GC as necessary of changes */
+#define ASSIGN __CFObjCStrongAssign
+//#define ASSIGN objc_assign_strongCast
+
+#define swapcode_wb(TYPE, parmi, parmj, n) { 		\
+	long i = (n) / sizeof (TYPE); 			\
+	TYPE *pi = (TYPE *) (parmi); 		\
+	TYPE *pj = (TYPE *) (parmj); 		\
+	do { 						\
+		TYPE	t = *pi;		\
+                ASSIGN(*pj, pi++);   \
+                ASSIGN(t, pj++); \
+        } while (--i > 0);				\
+}
+
+
+static inline void
+swapfunc_wb(char *a, char *b, long n, long swaptype)
+{
+	if(swaptype <= 1)
+		swapcode_wb(const void *, a, b, n)
+	else
+		swapcode(char, a, b, n)
+}
+
+#define swap_wb(a, b)					\
+	if (swaptype == 0) {				\
+		const void *t = *(const void **)(a);			\
+		ASSIGN(*(void **)(b), (const void **)a); \
+		ASSIGN(t, (const void **)(b));    \
+	} else \
+		printf("bad things happening\n");
+                //swapfunc_wb(a, b, es, swaptype)
+
+#define vecswap_wb(a, b, n) 	if ((n) > 0) swapfunc_wb(a, b, n, swaptype)
+
+static void
+bsd_qsort_wb(void *a, size_t n, size_t es, cmp_t *cmp, void *thunk)
+{
+	char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
+	long d, r, swaptype, swap_cnt;
+
+loop:	SWAPINIT(a, es);
+	swap_cnt = 0;
+	if (n < 7) {
+		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+			for (pl = pm; 
+			     pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
+			     pl -= es)
+				swap_wb(pl, pl - es);
+		return;
+	}
+	pm = (char *)a + (n / 2) * es;
+	if (n > 7) {
+		pl = (char *)a;
+		pn = (char *)a + (n - 1) * es;
+		if (n > 40) {
+			d = (n / 8) * es;
+			pl = med3(pl, pl + d, pl + 2 * d, cmp, thunk);
+			pm = med3(pm - d, pm, pm + d, cmp, thunk);
+			pn = med3(pn - 2 * d, pn - d, pn, cmp, thunk);
+		}
+		pm = med3(pl, pm, pn, cmp, thunk);
+	}
+	swap_wb(a, pm);
+	pa = pb = (char *)a + es;
+
+	pc = pd = (char *)a + (n - 1) * es;
+	for (;;) {
+		while (pb <= pc && (r = CMP(thunk, pb, a)) <= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap_wb(pa, pb);
+				pa += es;
+			}
+			pb += es;
+		}
+		while (pb <= pc && (r = CMP(thunk, pc, a)) >= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap_wb(pc, pd);
+				pd -= es;
+			}
+			pc -= es;
+		}
+		if (pb > pc)
+			break;
+		swap_wb(pb, pc);
+		swap_cnt = 1;
+		pb += es;
+		pc -= es;
+	}
+	if (swap_cnt == 0) {  /* Switch to insertion sort */
+		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+			for (pl = pm; 
+			     pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
+			     pl -= es)
+				swap_wb(pl, pl - es);
+		return;
+	}
+
+	pn = (char *)a + n * es;
+	r = min(pa - (char *)a, pb - pa);
+	vecswap_wb((char *)a, pb - r, r);
+	r = min(pd - pc, pn - pd - es);
+	vecswap_wb(pb, pn - r, r);
+	if ((r = pb - pa) > es)
+		bsd_qsort_wb(a, r / es, es, cmp, thunk);
+	if ((r = pd - pc) > es) {
+		/* Iterate rather than recurse to save stack space */
+		a = pn - r;
+		n = r / es;
+		goto loop;
+	}
+/*		qsort(pn - r, r / es, es, cmp);*/
+}
+
+/* Comparator is passed the address of the values. */
+void CFQSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context) {
+    if (CF_USING_COLLECTABLE_MEMORY && (auto_zone_get_layout_type(__CFCollectableZone, list) & AUTO_UNSCANNED) == 0)
+        bsd_qsort_wb(list, count, elementSize, comparator, context);
+    else
+        bsd_qsort(list, count, elementSize, comparator, context);
+}
+
+#undef thunk
+#undef CMP
+#undef vecswap
+//#undef swap
+#undef SWAPINIT
+#undef swapcode
+#undef min
+
+/* stdlib.subproj/mergesort.c ========================================== */
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Peter McIlroy.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)merge.c	8.2 (Berkeley) 2/14/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/merge.c,v 1.6 2002/03/21 22:48:42 obrien Exp $");
+#endif
+
+/*
+ * Hybrid exponential search/linear search merge sort with hybrid
+ * natural/pairwise first pass.  Requires about .3% more comparisons
+ * for random data than LSMS with pairwise first pass alone.
+ * It works for objects as small as two bytes.
+ */
+
+#define NATURAL
+#define THRESHOLD 16	/* Best choice for natural merge cut-off. */
+
+/* #define NATURAL to get hybrid natural merge.
+ * (The default is pairwise merging.)
+ */
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void setup(u_char *, u_char *, size_t, size_t, Comparison_Func, void *);
+static void insertionsort(u_char *, size_t, size_t, Comparison_Func, void *);
+
+#define ISIZE sizeof(long)
+#define PSIZE sizeof(u_char *)
+#define ICOPY_LIST(src, dst, last)				\
+	do							\
+	*(long*)dst = *(long*)src, src += ISIZE, dst += ISIZE;	\
+	while(src < last)
+#define ICOPY_ELT(src, dst, i)					\
+	do							\
+	*(long*) dst = *(long*) src, src += ISIZE, dst += ISIZE;	\
+	while (i -= ISIZE)
+
+#define CCOPY_LIST(src, dst, last)		\
+	do					\
+		*dst++ = *src++;		\
+	while (src < last)
+#define CCOPY_ELT(src, dst, i)			\
+	do					\
+		*dst++ = *src++;		\
+	while (i -= 1)
+
+/*
+ * Find the next possible pointer head.  (Trickery for forcing an array
+ * to do double duty as a linked list when objects do not align with word
+ * boundaries.
+ */
+/* Assumption: PSIZE is a power of 2. */
+#define EVAL(p) (u_char **)						\
+	((u_char *)0 +							\
+	    (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1)))
+
+/*
+ * Arguments are as for qsort.
+ */
+static int
+bsd_mergesort(void *base, size_t nmemb, size_t size, Comparison_Func cmp, void *context)
+{
+	long i, sense;
+	long big, iflag;
+	u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
+	u_char *list2, *list1, *p2, *p, *last, **p1;
+
+	if (size < PSIZE / 2) {		/* Pointers must fit into 2 * size. */
+		errno = EINVAL;
+		return (-1);
+	}
+
+	if (nmemb == 0)
+		return (0);
+
+	/*
+	 * XXX
+	 * Stupid subtraction for the Cray.
+	 */
+	iflag = 0;
+	if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
+		iflag = 1;
+
+	if ((list2 = (u_char*)malloc(nmemb * size + PSIZE)) == NULL)
+		return (-1);
+
+	list1 = (u_char*)base;
+	setup(list1, list2, nmemb, size, cmp, context);
+	last = list2 + nmemb * size;
+	i = big = 0;
+	while (*EVAL(list2) != last) {
+	    l2 = list1;
+	    p1 = EVAL(list1);
+	    for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
+	    	p2 = *EVAL(p2);
+	    	f1 = l2;
+	    	f2 = l1 = list1 + (p2 - list2);
+	    	if (p2 != last)
+	    		p2 = *EVAL(p2);
+	    	l2 = list1 + (p2 - list2);
+	    	while (f1 < l1 && f2 < l2) {
+	    		if ((*cmp)(f1, f2, context) <= 0) {
+	    			q = f2;
+	    			b = f1, t = l1;
+	    			sense = -1;
+	    		} else {
+	    			q = f1;
+	    			b = f2, t = l2;
+	    			sense = 0;
+	    		}
+	    		if (!big) {	/* here i = 0 */
+				while ((b += size) < t && cmp(q, b, context) >sense)
+	    				if (++i == 6) {
+	    					big = 1;
+	    					goto EXPONENTIAL;
+	    				}
+	    		} else {
+EXPONENTIAL:	    		for (i = size; ; i <<= 1)
+	    				if ((p = (b + i)) >= t) {
+	    					if ((p = t - size) > b &&
+						    (*cmp)(q, p, context) <= sense)
+	    						t = p;
+	    					else
+	    						b = p;
+	    					break;
+	    				} else if ((*cmp)(q, p, context) <= sense) {
+	    					t = p;
+	    					if (i == size)
+	    						big = 0;
+	    					goto FASTCASE;
+	    				} else
+	    					b = p;
+				while (t > b+size) {
+	    				i = (((t - b) / size) >> 1) * size;
+	    				if ((*cmp)(q, p = b + i, context) <= sense)
+	    					t = p;
+	    				else
+	    					b = p;
+	    			}
+	    			goto COPY;
+FASTCASE:	    		while (i > size)
+	    				if ((*cmp)(q,
+	    					p = b + (i >>= 1), context) <= sense)
+	    					t = p;
+	    				else
+	    					b = p;
+COPY:	    			b = t;
+	    		}
+	    		i = size;
+	    		if (q == f1) {
+	    			if (iflag) {
+	    				ICOPY_LIST(f2, tp2, b);
+	    				ICOPY_ELT(f1, tp2, i);
+	    			} else {
+	    				CCOPY_LIST(f2, tp2, b);
+	    				CCOPY_ELT(f1, tp2, i);
+	    			}
+	    		} else {
+	    			if (iflag) {
+	    				ICOPY_LIST(f1, tp2, b);
+	    				ICOPY_ELT(f2, tp2, i);
+	    			} else {
+	    				CCOPY_LIST(f1, tp2, b);
+	    				CCOPY_ELT(f2, tp2, i);
+	    			}
+	    		}
+	    	}
+	    	if (f2 < l2) {
+	    		if (iflag)
+	    			ICOPY_LIST(f2, tp2, l2);
+	    		else
+	    			CCOPY_LIST(f2, tp2, l2);
+	    	} else if (f1 < l1) {
+	    		if (iflag)
+	    			ICOPY_LIST(f1, tp2, l1);
+	    		else
+	    			CCOPY_LIST(f1, tp2, l1);
+	    	}
+	    	*p1 = l2;
+	    }
+	    tp2 = list1;	/* swap list1, list2 */
+	    list1 = list2;
+	    list2 = tp2;
+	    last = list2 + nmemb*size;
+	}
+	if (base == list2) {
+		memmove(list2, list1, nmemb*size);
+		list2 = list1;
+	}
+	free(list2);
+	return (0);
+}
+
+#undef swap
+#define	swap(a, b) {					\
+		s = b;					\
+		i = size;				\
+		do {					\
+			tmp = *a; *a++ = *s; *s++ = tmp; \
+		} while (--i);				\
+		a -= size;				\
+	}
+#define reverse(bot, top) {				\
+	s = top;					\
+	do {						\
+		i = size;				\
+		do {					\
+			tmp = *bot; *bot++ = *s; *s++ = tmp; \
+		} while (--i);				\
+		s -= size2;				\
+	} while(bot < s);				\
+}
+
+/*
+ * Optional hybrid natural/pairwise first pass.  Eats up list1 in runs of
+ * increasing order, list2 in a corresponding linked list.  Checks for runs
+ * when THRESHOLD/2 pairs compare with same sense.  (Only used when NATURAL
+ * is defined.  Otherwise simple pairwise merging is used.)
+ */
+static void
+setup(u_char *list1, u_char *list2, size_t n, size_t size, Comparison_Func cmp, void *context)
+{
+	long i, length, size2, tmp, sense;
+	u_char *f1, *f2, *s, *l2, *last, *p2;
+
+	size2 = size*2;
+	if (n <= 5) {
+		insertionsort(list1, n, size, cmp, context);
+		*EVAL(list2) = (u_char*) list2 + n*size;
+		return;
+	}
+	/*
+	 * Avoid running pointers out of bounds; limit n to evens
+	 * for simplicity.
+	 */
+	i = 4 + (n & 1);
+	insertionsort(list1 + (n - i) * size, i, size, cmp, context);
+	last = list1 + size * (n - i);
+	*EVAL(list2 + (last - list1)) = list2 + n * size;
+
+#ifdef NATURAL
+	p2 = list2;
+	f1 = list1;
+	sense = (cmp(f1, f1 + size, context) > 0);
+	for (; f1 < last; sense = !sense) {
+		length = 2;
+					/* Find pairs with same sense. */
+		for (f2 = f1 + size2; f2 < last; f2 += size2) {
+			if ((cmp(f2, f2+ size, context) > 0) != sense)
+				break;
+			length += 2;
+		}
+		if (length < THRESHOLD) {		/* Pairwise merge */
+			do {
+				p2 = *EVAL(p2) = f1 + size2 - list1 + list2;
+				if (sense > 0)
+					swap (f1, f1 + size);
+			} while ((f1 += size2) < f2);
+		} else {				/* Natural merge */
+			l2 = f2;
+			for (f2 = f1 + size2; f2 < l2; f2 += size2) {
+				if ((cmp(f2-size, f2, context) > 0) != sense) {
+					p2 = *EVAL(p2) = f2 - list1 + list2;
+					if (sense > 0)
+						reverse(f1, f2-size);
+					f1 = f2;
+				}
+			}
+			if (sense > 0)
+				reverse (f1, f2-size);
+			f1 = f2;
+			if (f2 < last || cmp(f2 - size, f2, context) > 0)
+				p2 = *EVAL(p2) = f2 - list1 + list2;
+			else
+				p2 = *EVAL(p2) = list2 + n*size;
+		}
+	}
+#else		/* pairwise merge only. */
+	for (f1 = list1, p2 = list2; f1 < last; f1 += size2) {
+		p2 = *EVAL(p2) = p2 + size2;
+		if (cmp (f1, f1 + size, context) > 0)
+			swap(f1, f1 + size);
+	}
+#endif /* NATURAL */
+}
+
+/*
+ * This is to avoid out-of-bounds addresses in sorting the
+ * last 4 elements.
+ */
+static void
+insertionsort(u_char *a, size_t n, size_t size, Comparison_Func cmp, void *context)
+{
+	u_char *ai, *s, *t, *u, tmp;
+	long i;
+
+	for (ai = a+size; --n >= 1; ai += size)
+		for (t = ai; t > a; t -= size) {
+			u = t - size;
+			if (cmp(u, t, context) <= 0)
+				break;
+			swap(u, t);
+		}
+}
+
+/* Another version, also not so completely different, in order to handle necessary write-barriers in the face of GC */
+
+#undef ASSIGN
+#define ASSIGN __CFObjCStrongAssign
+//#define ASSIGN log_assign
+
+static void setup_wb(u_char *, u_char *, size_t, size_t, Comparison_Func, void *);
+static void insertionsort_wb(u_char *, size_t, size_t, Comparison_Func, void *);
+
+#undef ICOPY_ELT
+
+#define ICOPY_ELT(src, dst, i)					\
+	do							\
+	ASSIGN(*(const void**)src, (const void **)dst), src += ISIZE, dst += ISIZE;	\
+	while (i -= ISIZE)
+
+#undef ICOPY_LIST
+
+#define ICOPY_LIST(src, dst, last) \
+        do \
+        ASSIGN(*(const void **)src, (const void **)dst), src += ISIZE, dst += ISIZE; \
+        while (src < last)
+
+
+/*
+ * Arguments are as for qsort.
+ */
+static int
+bsd_mergesort_wb(void *base, size_t nmemb, size_t size, Comparison_Func cmp, void *context)
+{
+	long i, sense;
+	long big, iflag;
+	u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
+	u_char *list2, *list1, *p2, *p, *last, **p1;
+
+	if (size < PSIZE / 2) {		/* Pointers must fit into 2 * size. */
+		errno = EINVAL;
+		return (-1);
+	}
+
+	if (nmemb == 0)
+		return (0);
+
+	/*
+	 * XXX
+	 * Stupid subtraction for the Cray.
+	 */
+	iflag = 0;
+	if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
+		iflag = 1;
+
+        if (!iflag)
+            return -1;      // only set up for "integer" swaps, e.g. long integer
+            
+	if ((list2 = (u_char*)CFAllocatorAllocate(NULL, (CFIndex)(nmemb * size + PSIZE), __kCFAllocatorGCScannedMemory)) == NULL)
+		return (-1);
+
+	list1 = (u_char*)base;
+	setup_wb(list1, list2, nmemb, size, cmp, context);
+	last = list2 + nmemb * size;
+	i = big = 0;
+	while (*EVAL(list2) != last) {
+	    l2 = list1;
+	    p1 = EVAL(list1);
+	    for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
+	    	p2 = *EVAL(p2);
+	    	f1 = l2;
+	    	f2 = l1 = list1 + (p2 - list2);
+	    	if (p2 != last)
+	    		p2 = *EVAL(p2);
+	    	l2 = list1 + (p2 - list2);
+	    	while (f1 < l1 && f2 < l2) {
+	    		if ((*cmp)(f1, f2, context) <= 0) {
+	    			q = f2;
+	    			b = f1, t = l1;
+	    			sense = -1;
+	    		} else {
+	    			q = f1;
+	    			b = f2, t = l2;
+	    			sense = 0;
+	    		}
+	    		if (!big) {	/* here i = 0 */
+				while ((b += size) < t && cmp(q, b, context) >sense)
+	    				if (++i == 6) {
+	    					big = 1;
+	    					goto EXPONENTIAL;
+	    				}
+	    		} else {
+EXPONENTIAL:	    		for (i = size; ; i <<= 1)
+	    				if ((p = (b + i)) >= t) {
+	    					if ((p = t - size) > b &&
+						    (*cmp)(q, p, context) <= sense)
+	    						t = p;
+	    					else
+	    						b = p;
+	    					break;
+	    				} else if ((*cmp)(q, p, context) <= sense) {
+	    					t = p;
+	    					if (i == size)
+	    						big = 0;
+	    					goto FASTCASE;
+	    				} else
+	    					b = p;
+				while (t > b+size) {
+	    				i = (((t - b) / size) >> 1) * size;
+	    				if ((*cmp)(q, p = b + i, context) <= sense)
+	    					t = p;
+	    				else
+	    					b = p;
+	    			}
+	    			goto COPY;
+FASTCASE:	    		while (i > size)
+	    				if ((*cmp)(q,
+	    					p = b + (i >>= 1), context) <= sense)
+	    					t = p;
+	    				else
+	    					b = p;
+COPY:	    			b = t;
+	    		}
+	    		i = size;
+	    		if (q == f1) {
+	    			if (iflag) {
+	    				ICOPY_LIST(f2, tp2, b);
+	    				ICOPY_ELT(f1, tp2, i);
+	    			} else {
+	    				CCOPY_LIST(f2, tp2, b);
+	    				CCOPY_ELT(f1, tp2, i);
+	    			}
+	    		} else {
+	    			if (iflag) {
+	    				ICOPY_LIST(f1, tp2, b);
+	    				ICOPY_ELT(f2, tp2, i);
+	    			} else {
+	    				CCOPY_LIST(f1, tp2, b);
+	    				CCOPY_ELT(f2, tp2, i);
+	    			}
+	    		}
+	    	}
+	    	if (f2 < l2) {
+	    		if (iflag)
+	    			ICOPY_LIST(f2, tp2, l2);
+	    		else
+	    			CCOPY_LIST(f2, tp2, l2);
+	    	} else if (f1 < l1) {
+	    		if (iflag)
+	    			ICOPY_LIST(f1, tp2, l1);
+	    		else
+	    			CCOPY_LIST(f1, tp2, l1);
+	    	}
+	    	*p1 = l2;
+	    }
+	    tp2 = list1;	/* swap list1, list2 */
+	    list1 = list2;
+	    list2 = tp2;
+	    last = list2 + nmemb*size;
+	}
+	if (base == list2) {
+		CF_WRITE_BARRIER_MEMMOVE(list2, list1, nmemb*size);
+		list2 = list1;
+	}
+	free(list2);
+	return (0);
+}
+
+#undef swap_wb
+#define swap_wb(a, b) { \
+        const void *object = *(void **)a; \
+        ASSIGN(*(const void **)b, (const void **)a); \
+        ASSIGN(object, (const void **)b); \
+    }
+
+#define reverse_wb(bot, top) {				\
+	s = top;					\
+	do {						\
+                swap_wb(bot, s);                           \
+                bot += size;                           \
+		s -= size;				\
+	} while(bot < s);				\
+}
+
+/*
+ * Optional hybrid natural/pairwise first pass.  Eats up list1 in runs of
+ * increasing order, list2 in a corresponding linked list.  Checks for runs
+ * when THRESHOLD/2 pairs compare with same sense.  (Only used when NATURAL
+ * is defined.  Otherwise simple pairwise merging is used.)
+ */
+static void
+setup_wb(u_char *list1, u_char *list2, size_t n, size_t size, Comparison_Func cmp, void *context)
+{
+	long i, length, size2, tmp, sense;
+	u_char *f1, *f2, *s, *l2, *last, *p2;
+
+	size2 = size*2;
+	if (n <= 5) {
+		insertionsort_wb(list1, n, size, cmp, context);
+		*EVAL(list2) = (u_char*) list2 + n*size;
+		return;
+	}
+	/*
+	 * Avoid running pointers out of bounds; limit n to evens
+	 * for simplicity.
+	 */
+	i = 4 + (n & 1);
+	insertionsort_wb(list1 + (n - i) * size, i, size, cmp, context);
+	last = list1 + size * (n - i);
+	*EVAL(list2 + (last - list1)) = list2 + n * size;
+
+#ifdef NATURAL
+	p2 = list2;
+	f1 = list1;
+	sense = (cmp(f1, f1 + size, context) > 0);
+	for (; f1 < last; sense = !sense) {
+		length = 2;
+					/* Find pairs with same sense. */
+		for (f2 = f1 + size2; f2 < last; f2 += size2) {
+			if ((cmp(f2, f2+ size, context) > 0) != sense)
+				break;
+			length += 2;
+		}
+		if (length < THRESHOLD) {		/* Pairwise merge */
+			do {
+				p2 = *EVAL(p2) = f1 + size2 - list1 + list2;
+				if (sense > 0)
+					swap (f1, f1 + size);
+			} while ((f1 += size2) < f2);
+		} else {				/* Natural merge */
+			l2 = f2;
+			for (f2 = f1 + size2; f2 < l2; f2 += size2) {
+				if ((cmp(f2-size, f2, context) > 0) != sense) {
+					p2 = *EVAL(p2) = f2 - list1 + list2;
+					if (sense > 0) {
+						reverse_wb(f1, f2-size);
+                                        }
+					f1 = f2;
+				}
+			}
+			if (sense > 0) {
+				reverse_wb (f1, f2-size);
+                        }
+			f1 = f2;
+			if (f2 < last || cmp(f2 - size, f2, context) > 0) {
+				p2 = *EVAL(p2) = f2 - list1 + list2;
+                        }
+			else {
+				p2 = *EVAL(p2) = list2 + n*size;
+                        }
+		}
+	}
+#else		/* pairwise merge only. */
+#error unchanged
+	for (f1 = list1, p2 = list2; f1 < last; f1 += size2) {
+		p2 = *EVAL(p2) = p2 + size2;
+		if (cmp (f1, f1 + size, context) > 0)
+			swap_wb(f1, f1 + size);
+	}
+#endif /* NATURAL */
+}
+
+/*
+ * This is to avoid out-of-bounds addresses in sorting the
+ * last 4 elements.
+ */
+static void
+insertionsort_wb(u_char *a, size_t n, size_t size, CFComparisonResult (*cmp)(const void *, const void *, void *), void *context)
+{
+	u_char *ai, *s, *t, *u, tmp;
+	long i;
+
+	for (ai = a+size; --n >= 1; ai += size)
+		for (t = ai; t > a; t -= size) {
+			u = t - size;
+			if (cmp(u, t, context) <= 0)
+				break;
+			swap(u, t);
+		}
+}
+
+void CFMergeSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context) {
+    if (CF_USING_COLLECTABLE_MEMORY && (auto_zone_get_layout_type(__CFCollectableZone, list) & AUTO_UNSCANNED) == 0)
+        bsd_mergesort_wb(list, count, elementSize, comparator, context);
+    else
+        bsd_mergesort(list, count, elementSize, comparator, context);
+} 
+
+#undef NATURAL
+#undef THRESHOLD
+#undef ISIZE
+#undef PSIZE
+#undef ICOPY_LIST
+#undef ICOPY_ELT
+#undef CCOPY_LIST
+#undef CCOPY_ELT
+#undef EVAL
+#undef swap
+#undef reverse
+
+/* ===================================================================== */
+
+#undef EINVAL
+
diff --git a/CoreFoundation/CFStorage.c b/CoreFoundation/CFStorage.c
new file mode 100644
index 0000000..2079cbe
--- /dev/null
+++ b/CoreFoundation/CFStorage.c
@@ -0,0 +1,786 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2007, Apple, Inc. All rights reserved.
+	Responsibility: Ali Ozer
+*/
+
+/*
+2-3 tree storing arbitrary sized values.
+
+??? Currently elementSize cannot be greater than storage->maxLeafCapacity, which is less than or equal to __CFStorageMaxLeafCapacity
+
+CFStorage is thread-safe for multiple readers, but not thread safe for simultaneous reading and  writing.
+*/
+
+#include "CFStorage.h"
+#include "CFInternal.h"
+
+#if !defined(PAGE_SIZE)
+#define PAGE_SIZE 4096
+#endif
+
+// Above 15K, malloc switches (??? or used to in early Leopard) to using vm allocates for blocks; it seems best to avoid that.
+// Also, tests with StorageTimer.c done in 4/07 indicate that 4096 * 3 is better than smaller or larger node sizes.
+#define __CFStorageMaxLeafCapacity (4096 * 3)
+
+// If the max length of a node is less than can fit in a half-word (half of a long), we can get away without ever caching the high half-word the cachedRange
+#if __LP64__
+#if __CFStorageMaxLeafCapacity > 0xFFFFFFFFULL
+#define POSSIBLE_TO_HAVE_LENGTH_MORE_THAN_HALFWORD 1
+#endif
+#else
+#if __CFStorageMaxLeafCapacity > 0xFFFFUL
+#define POSSIBLE_TO_HAVE_LENGTH_MORE_THAN_HALFWORD 1
+#endif
+#endif
+
+#define COPYMEM(src,dst,n) CF_WRITE_BARRIER_MEMMOVE((dst), (src), (n))
+#define PAGE_LIMIT ((CFIndex)PAGE_SIZE / 2)
+
+CF_INLINE int32_t roundToPage(int32_t num) {
+    return (num + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+}
+
+
+
+/* Each node in the storage.  isLeaf determines whether the node is a leaf node or a node inside the tree. If latter, number of children are determined by the number of non-NULL entries in child[]. (NULL entries are at the end.)
+*/
+typedef struct __CFStorageNode {
+    CFIndex numBytes;	/* Number of actual bytes in this node and all its children */
+    bool isLeaf;
+    union {
+        struct {
+            CFIndex capacityInBytes;	// capacityInBytes is capacity of memory; this is either 0, or >= numBytes
+            uint8_t *memory;
+        } leaf;
+        struct {
+            struct __CFStorageNode *child[3];
+        } notLeaf;
+    } info;
+} CFStorageNode;
+
+/* This is the struct used to store the cache in the CFStorage; it enables us to make the cache thread-safe for multiple readers (which update the cache).  The values in this cache store half the desired value in the top half, and the genCount of the writer in the low half. This cache is consistent only if all of the genCounts are the same.  Note that the cache does not provide thread-safety for readers in the presence of a writer.
+
+The cached range (location, length) is in terms of values; if the cached range is not (0,0), then the cached node needs to be non-NULL and pointing at a leaf node.
+*/
+typedef struct {
+    unsigned long locationHi, locationLo;	// cachedRange.location
+#if POSSIBLE_TO_HAVE_LENGTH_MORE_THAN_HALFWORD
+    unsigned long lengthHi;		    
+#endif
+    unsigned long lengthLo;			// cachedRange.length; note that we actually do not bother with lengthHi if __CFStorageMaxLeafCapacity is less than half-word
+    unsigned long cachedNodeHi, cachedNodeLo;	// cachedNode
+} CFStorageAccessCacheParts;
+
+/* The CFStorage object.
+*/
+struct __CFStorage {
+    CFRuntimeBase base;
+    CFIndex valueSize;
+    CFSpinLock_t cacheReaderMemoryAllocationLock;
+    int cacheGenerationCount;
+    CFStorageAccessCacheParts cacheParts;
+    CFIndex maxLeafCapacity;	    // In terms of bytes
+    CFStorageNode rootNode;
+    CFOptionFlags nodeHint;	    // __kCFAllocatorGCScannedMemory or 0.
+};
+
+
+
+
+/* Allocates the memory and initializes the capacity in a leaf. __CFStorageAllocLeafNodeMemory() is the entry point; __CFStorageAllocLeafNodeMemoryAux is called if actual reallocation is needed. __CFStorageAllocLeafNodeMemoryAux() locks not for mutations (mutations are not thread-safe in general), but for lazy allocation of storage during reading.
+*/
+static void __CFStorageAllocLeafNodeMemoryAux(CFAllocatorRef allocator, CFStorageRef storage, CFStorageNode *node, CFIndex cap) {
+    __CFSpinLock(&(storage->cacheReaderMemoryAllocationLock));
+    CF_WRITE_BARRIER_ASSIGN(allocator, node->info.leaf.memory, _CFAllocatorReallocateGC(allocator, node->info.leaf.memory, cap, storage->nodeHint));	// This will free...
+    if (__CFOASafe) __CFSetLastAllocationEventName(node->info.leaf.memory, "CFStorage (node bytes)");
+    node->info.leaf.capacityInBytes = cap;
+    __CFSpinUnlock(&(storage->cacheReaderMemoryAllocationLock));
+}
+
+CF_INLINE void __CFStorageAllocLeafNodeMemory(CFAllocatorRef allocator, CFStorageRef storage, CFStorageNode *node, CFIndex cap, bool compact) {
+    if (cap > PAGE_LIMIT) {
+        cap = roundToPage(cap);
+	if (cap > storage->maxLeafCapacity) cap = storage->maxLeafCapacity;
+    } else {
+        cap = (((cap + 63) / 64) * 64);
+    }
+    if (compact ? (cap != node->info.leaf.capacityInBytes) : (cap > node->info.leaf.capacityInBytes)) __CFStorageAllocLeafNodeMemoryAux(allocator, storage, node, cap);
+}
+
+
+
+
+#if __LP64__
+#define genCountMask	0x00000000FFFFFFFFUL
+#define dataMask	0xFFFFFFFF00000000UL
+#define shiftLowWordBy	32
+#else
+#define genCountMask	0x0000FFFFUL
+#define dataMask	0xFFFF0000UL
+#define shiftLowWordBy	16
+#endif
+
+/* Sets the cache to point at the specified node. loc and len are in terms of values, not bytes. To clear the cache set these two to 0.
+   At least one of node or memory should be non-NULL. memory is consulted first when using the cache.
+*/
+CF_INLINE void __CFStorageSetCache(CFStorageRef storage, CFStorageNode *node, CFIndex loc, CFIndex len) {
+	unsigned int genCount = ((unsigned int)_CFAtomicIncrement32(&storage->cacheGenerationCount)) & genCountMask;
+    CFStorageAccessCacheParts cacheParts;
+    cacheParts.locationHi = (loc & dataMask) | genCount;
+    cacheParts.locationLo = (loc << shiftLowWordBy) | genCount;
+#if POSSIBLE_TO_HAVE_LENGTH_MORE_THAN_HALFWORD
+    cacheParts.lengthHi = (len & dataMask) | genCount;
+#endif
+    cacheParts.lengthLo = (len << shiftLowWordBy) | genCount;
+    cacheParts.cachedNodeHi = ((unsigned long)node & dataMask) | genCount;
+    cacheParts.cachedNodeLo = ((unsigned long)node << shiftLowWordBy) | genCount;
+    storage->cacheParts = cacheParts;
+}
+
+/* Thread-safely get the cached range and node info.
+*/
+CF_INLINE Boolean __CFStorageGetCache(CFStorageRef storage, CFRange *cachedRangePtr, CFStorageNode **cachedNodePtr) {
+    CFStorageAccessCacheParts cacheParts = storage->cacheParts;
+
+    unsigned int genCount = cacheParts.locationHi & genCountMask;
+    
+    // Check to make sure the genCounts of all the items are the same; if not, the cache was inconsistent
+    if ((cacheParts.locationLo & genCountMask) == genCount &&
+#if POSSIBLE_TO_HAVE_LENGTH_MORE_THAN_HALFWORD
+	(cacheParts.lengthHi & genCountMask) == genCount &&
+#endif
+	(cacheParts.lengthLo & genCountMask) == genCount &&
+	(cacheParts.cachedNodeHi & genCountMask) == genCount &&
+	(cacheParts.cachedNodeLo & genCountMask) == genCount) {
+	
+	*cachedNodePtr = (CFStorageNode *)((cacheParts.cachedNodeHi & dataMask) | ((cacheParts.cachedNodeLo & dataMask) >> shiftLowWordBy));
+	cachedRangePtr->location = (cacheParts.locationHi & dataMask) | ((cacheParts.locationLo & dataMask) >> shiftLowWordBy);
+	cachedRangePtr->length = (cacheParts.lengthLo & dataMask) >> shiftLowWordBy;
+#if POSSIBLE_TO_HAVE_LENGTH_MORE_THAN_HALFWORD
+	cachedRangePtr->length |= (cacheParts.lengthHi & dataMask);
+#endif
+
+	return true;
+    }
+    return false;
+}
+
+/* Gets the location for the specified absolute loc from the cached info.
+   Returns NULL if the location is not in the cache.
+*/
+CF_INLINE uint8_t *__CFStorageGetFromCache(CFStorageRef storage, CFIndex loc, CFRange *validConsecutiveValueRange) {
+    CFRange cachedRange = {0, 0};
+    CFStorageNode *cachedNode = 0;
+
+    // If we can't get values from the cache, return NULL
+    if (!__CFStorageGetCache(storage, &cachedRange, &cachedNode)) return NULL;
+
+    // Check to see if the index is in the cache
+    if (loc < cachedRange.location || loc >= cachedRange.location + cachedRange.length) return NULL;
+
+    // If the cached node has no memory, return here; it will be allocated as a result of the non-cached lookup.
+    if (!cachedNode->info.leaf.memory) return NULL;
+    
+    // The cache has consistent values, and in fact, the values we're looking for!
+    uint8_t *result = cachedNode->info.leaf.memory + (loc - cachedRange.location) * storage->valueSize;
+    *validConsecutiveValueRange = cachedRange;
+    
+    return result;
+}
+
+
+
+
+/* Returns the number of the child containing the desired value and the relative index of the value in that child.
+   forInsertion = true means that we are looking for the child in which to insert; this changes the behavior when the index is at the end of a child
+   relativeByteNum (not optional, for performance reasons) returns the relative byte number of the specified byte in the child.
+   Don't call with leaf nodes!
+*/
+CF_INLINE void __CFStorageFindChild(CFStorageNode *node, CFIndex byteNum, bool forInsertion, CFIndex *childNum, CFIndex *relativeByteNum) {
+    if (forInsertion) byteNum--;	/* If for insertion, we do <= checks, not <, so this accomplishes the same thing */
+    if (byteNum < node->info.notLeaf.child[0]->numBytes) *childNum = 0;
+    else {
+        byteNum -= node->info.notLeaf.child[0]->numBytes;
+        if (byteNum < node->info.notLeaf.child[1]->numBytes) *childNum = 1;
+        else {
+            byteNum -= node->info.notLeaf.child[1]->numBytes;
+            *childNum = 2;
+        }
+    }
+    if (forInsertion) byteNum++;
+    *relativeByteNum = byteNum;
+}
+
+/* Finds the location where the specified byte is stored. If validConsecutiveByteRange is not NULL, returns
+   the range of bytes that are consecutive with this one.
+   !!! Assumes the byteNum is within the range of this node.
+*/
+static void *__CFStorageFindByte(CFStorageRef storage, CFStorageNode *node, CFIndex byteNum, CFStorageNode **resultNode, CFRange *validConsecutiveByteRange) {
+    if (node->isLeaf) {
+        if (validConsecutiveByteRange) *validConsecutiveByteRange = CFRangeMake(0, node->numBytes);
+        __CFStorageAllocLeafNodeMemory(CFGetAllocator(storage), storage, node, node->numBytes, false);
+	if (resultNode) *resultNode = node;
+        return node->info.leaf.memory + byteNum; 
+    } else {
+        void *result;
+        CFIndex childNum;
+        CFIndex relativeByteNum;
+        __CFStorageFindChild(node, byteNum, false, &childNum, &relativeByteNum);
+        result = __CFStorageFindByte(storage, node->info.notLeaf.child[childNum], relativeByteNum, resultNode, validConsecutiveByteRange);
+        if (validConsecutiveByteRange) {
+            if (childNum > 0) validConsecutiveByteRange->location += node->info.notLeaf.child[0]->numBytes;
+            if (childNum > 1) validConsecutiveByteRange->location += node->info.notLeaf.child[1]->numBytes;
+        }
+        return result;
+    }
+}
+
+/* Guts of CFStorageGetValueAtIndex(); note that validConsecutiveValueRange is not optional.
+   Consults and updates cache.
+*/
+CF_INLINE void *__CFStorageGetValueAtIndex(CFStorageRef storage, CFIndex idx, CFRange *validConsecutiveValueRange) {
+    uint8_t *result;
+    if (!(result = __CFStorageGetFromCache(storage, idx, validConsecutiveValueRange))) {
+        CFRange rangeInBytes;
+	CFStorageNode *resultNode;
+        result = (uint8_t *)__CFStorageFindByte(storage, &storage->rootNode, idx * storage->valueSize, &resultNode, &rangeInBytes);
+	CFRange rangeInValues = CFRangeMake(rangeInBytes.location / storage->valueSize, rangeInBytes.length / storage->valueSize);
+        __CFStorageSetCache(storage, resultNode, rangeInValues.location, rangeInValues.length);
+	*validConsecutiveValueRange = rangeInValues;
+    }
+    return result;
+}
+
+static CFStorageNode *__CFStorageCreateNode(CFAllocatorRef allocator, bool isLeaf, CFIndex numBytes) {
+    CFStorageNode *newNode = (CFStorageNode *)_CFAllocatorAllocateGC(allocator, sizeof(CFStorageNode), __kCFAllocatorGCScannedMemory);
+    if (__CFOASafe) __CFSetLastAllocationEventName(newNode, "CFStorage (node)");
+    newNode->isLeaf = isLeaf;
+    newNode->numBytes = numBytes;
+    if (isLeaf) {
+        newNode->info.leaf.capacityInBytes = 0;
+        newNode->info.leaf.memory = NULL;
+    } else {
+        newNode->info.notLeaf.child[0] = newNode->info.notLeaf.child[1] = newNode->info.notLeaf.child[2] = NULL;
+    }
+    return newNode;
+}
+
+static void __CFStorageNodeDealloc(CFAllocatorRef allocator, CFStorageNode *node, bool freeNodeItself) {
+    if (node->isLeaf) {
+        _CFAllocatorDeallocateGC(allocator, node->info.leaf.memory);
+    } else {
+        int cnt;
+        for (cnt = 0; cnt < 3; cnt++) if (node->info.notLeaf.child[cnt]) __CFStorageNodeDealloc(allocator, node->info.notLeaf.child[cnt], true);
+    }
+    if (freeNodeItself) _CFAllocatorDeallocateGC(allocator, node);
+}
+
+static CFIndex __CFStorageGetNumChildren(CFStorageNode *node) {
+    if (!node || node->isLeaf) return 0;
+    if (node->info.notLeaf.child[2]) return 3;
+    if (node->info.notLeaf.child[1]) return 2;
+    if (node->info.notLeaf.child[0]) return 1;
+    return 0;
+}
+
+/* The boolean compact indicates whether leaf nodes that get smaller should be realloced.
+*/
+static void __CFStorageDelete(CFAllocatorRef allocator, CFStorageRef storage, CFStorageNode *node, CFRange range, bool compact) {
+    if (node->isLeaf) {
+	node->numBytes -= range.length;
+        // If this node had memory allocated, readjust the bytes...
+	if (node->info.leaf.memory) {
+            COPYMEM(node->info.leaf.memory + range.location + range.length, node->info.leaf.memory + range.location, node->numBytes - range.location);
+	    if (compact) __CFStorageAllocLeafNodeMemory(allocator, storage, node, node->numBytes, true);
+	}
+   } else {
+        bool childrenAreLeaves = node->info.notLeaf.child[0]->isLeaf;
+	node->numBytes -= range.length;
+	while (range.length > 0) {
+            CFRange rangeToDelete;
+            CFIndex relativeByteNum;
+            CFIndex childNum;
+            __CFStorageFindChild(node, range.location + range.length, true, &childNum, &relativeByteNum);
+            if (range.length > relativeByteNum) {
+                rangeToDelete.length = relativeByteNum;
+                rangeToDelete.location = 0;
+            } else {
+                rangeToDelete.length = range.length;
+                rangeToDelete.location = relativeByteNum - range.length;
+            }
+            __CFStorageDelete(allocator, storage, node->info.notLeaf.child[childNum], rangeToDelete, compact);
+            if (node->info.notLeaf.child[childNum]->numBytes == 0) {		// Delete empty node and compact
+                int cnt;
+                _CFAllocatorDeallocateGC(allocator, node->info.notLeaf.child[childNum]);
+                for (cnt = childNum; cnt < 2; cnt++) {
+                    CF_WRITE_BARRIER_ASSIGN(allocator, node->info.notLeaf.child[cnt], node->info.notLeaf.child[cnt+1]);
+                }
+                node->info.notLeaf.child[2] = NULL;
+            }
+	    range.length -= rangeToDelete.length;
+	}
+        // At this point the remaining children are packed
+        if (childrenAreLeaves) {
+            // Children are leaves; if their total bytes is smaller than a leaf's worth, collapse into one...
+            if (node->numBytes > 0 && node->numBytes <= storage->maxLeafCapacity) {
+                __CFStorageAllocLeafNodeMemory(allocator, storage, node->info.notLeaf.child[0], node->numBytes, false);
+                if (node->info.notLeaf.child[1] && node->info.notLeaf.child[1]->numBytes) {
+                    COPYMEM(node->info.notLeaf.child[1]->info.leaf.memory, node->info.notLeaf.child[0]->info.leaf.memory + node->info.notLeaf.child[0]->numBytes, node->info.notLeaf.child[1]->numBytes);
+                    if (node->info.notLeaf.child[2] && node->info.notLeaf.child[2]->numBytes) {
+                        COPYMEM(node->info.notLeaf.child[2]->info.leaf.memory, node->info.notLeaf.child[0]->info.leaf.memory + node->info.notLeaf.child[0]->numBytes + node->info.notLeaf.child[1]->numBytes, node->info.notLeaf.child[2]->numBytes);
+                        __CFStorageNodeDealloc(allocator, node->info.notLeaf.child[2], true);
+                        node->info.notLeaf.child[2] = NULL;
+                    }
+                    __CFStorageNodeDealloc(allocator, node->info.notLeaf.child[1], true);
+                    node->info.notLeaf.child[1] = NULL;
+                }
+                node->info.notLeaf.child[0]->numBytes = node->numBytes;
+            }
+        } else {
+            // Children are not leaves; combine their children to assure each node has 2 or 3 children...
+	    // (Could try to bypass all this by noting up above whether the number of grandchildren changed...)
+            CFStorageNode *gChildren[9];
+            CFIndex cCnt, gCnt, cnt;
+            CFIndex totalG = 0;	// Total number of grandchildren
+            for (cCnt = 0; cCnt < 3; cCnt++) {
+                CFStorageNode *child = node->info.notLeaf.child[cCnt];
+                if (child) {
+		    for (gCnt = 0; gCnt < 3; gCnt++) if (child->info.notLeaf.child[gCnt]) {
+                        gChildren[totalG++] = child->info.notLeaf.child[gCnt];
+                        child->info.notLeaf.child[gCnt] = NULL;
+                    }
+		    child->numBytes = 0;
+		}
+            }
+            gCnt = 0;	// Total number of grandchildren placed
+	    for (cCnt = 0; cCnt < 3; cCnt++) {
+                // These tables indicate how many children each child should have, given the total number of grandchildren (last child gets remainder)
+                static const unsigned char forChild0[10] = {0, 1, 2, 3, 2, 3, 3, 3, 3, 3};
+                static const unsigned char forChild1[10] = {0, 0, 0, 0, 2, 2, 3, 2, 3, 3};
+		// sCnt is the number of grandchildren to be placed into child cCnt
+		// Depending on child number, pick the right number
+                CFIndex sCnt = (cCnt == 0) ? forChild0[totalG] : ((cCnt == 1) ? forChild1[totalG] : totalG);
+		// Assure we have that many grandchildren...
+		if (sCnt > totalG - gCnt) sCnt = totalG - gCnt;
+                if (sCnt) {
+                    if (!node->info.notLeaf.child[cCnt]) {
+                        CFStorageNode *newNode = __CFStorageCreateNode(allocator, false, 0);
+                        CF_WRITE_BARRIER_ASSIGN(allocator, node->info.notLeaf.child[cCnt], newNode);
+                    }
+                    for (cnt = 0; cnt < sCnt; cnt++) {
+                        node->info.notLeaf.child[cCnt]->numBytes += gChildren[gCnt]->numBytes;
+                        CF_WRITE_BARRIER_ASSIGN(allocator, node->info.notLeaf.child[cCnt]->info.notLeaf.child[cnt], gChildren[gCnt++]);
+                    }
+                } else {
+                    if (node->info.notLeaf.child[cCnt]) {
+                        _CFAllocatorDeallocateGC(allocator, node->info.notLeaf.child[cCnt]);
+                        node->info.notLeaf.child[cCnt] = NULL;
+                    }
+                }
+	    }
+        }
+    }
+}
+
+
+/* Returns NULL or additional node to come after this node
+   Assumption: size is never > storage->maxLeafCapacity
+*/
+static CFStorageNode *__CFStorageInsert(CFAllocatorRef allocator, CFStorageRef storage, CFStorageNode *node, CFIndex byteNum, CFIndex size, CFIndex absoluteByteNum) {
+    if (node->isLeaf) {
+        if (size + node->numBytes > storage->maxLeafCapacity) {	// Need to create more child nodes
+            if (byteNum == node->numBytes) {	// Inserting at end; easy...
+                CFStorageNode *newNode = __CFStorageCreateNode(allocator, true, size);
+                __CFStorageSetCache(storage, newNode, absoluteByteNum / storage->valueSize, size / storage->valueSize);
+                return newNode;
+            } else if (byteNum == 0) {	// Inserting at front; also easy, but we need to swap node and newNode
+                CFStorageNode *newNode = __CFStorageCreateNode(allocator, true, 0);
+                CF_WRITE_BARRIER_MEMMOVE(newNode, node, sizeof(CFStorageNode));
+                node->isLeaf = true;
+                node->numBytes = size;
+                node->info.leaf.capacityInBytes = 0;
+                node->info.leaf.memory = NULL;
+                __CFStorageSetCache(storage, node, absoluteByteNum / storage->valueSize, size / storage->valueSize);
+                return newNode;
+            } else if (byteNum + size <= storage->maxLeafCapacity) {	// Inserting at middle; inserted region will fit into existing child
+                // Create new node to hold the overflow
+                CFStorageNode *newNode = __CFStorageCreateNode(allocator, true, node->numBytes - byteNum);
+                if (node->info.leaf.memory) {	// We allocate memory lazily...
+                    __CFStorageAllocLeafNodeMemory(allocator, storage, newNode, node->numBytes - byteNum, false);
+                    COPYMEM(node->info.leaf.memory + byteNum, newNode->info.leaf.memory, node->numBytes - byteNum);
+                    __CFStorageAllocLeafNodeMemory(allocator, storage, node, byteNum + size, false);
+                }
+                node->numBytes = byteNum + size;
+                __CFStorageSetCache(storage, node, (absoluteByteNum - byteNum) / storage->valueSize, node->numBytes / storage->valueSize);
+                return newNode;
+            } else {	// Inserting some of new into one node, rest into another; remember that the assumption is size <= storage->maxLeafCapacity
+                CFStorageNode *newNode = __CFStorageCreateNode(allocator, true, node->numBytes + size - storage->maxLeafCapacity);	// New stuff
+                if (node->info.leaf.memory) {	// We allocate memory lazily...
+                    __CFStorageAllocLeafNodeMemory(allocator, storage, newNode, node->numBytes + size - storage->maxLeafCapacity, false);
+                    COPYMEM(node->info.leaf.memory + byteNum, newNode->info.leaf.memory + byteNum + size - storage->maxLeafCapacity, node->numBytes - byteNum);
+                    __CFStorageAllocLeafNodeMemory(allocator, storage, node, storage->maxLeafCapacity, false);
+                }
+                node->numBytes = storage->maxLeafCapacity;
+                __CFStorageSetCache(storage, node, (absoluteByteNum - byteNum) / storage->valueSize, node->numBytes / storage->valueSize);
+                return newNode;
+            }
+        } else {	// No need to create new nodes!
+            if (node->info.leaf.memory) {
+                __CFStorageAllocLeafNodeMemory(allocator, storage, node, node->numBytes + size, false);
+                COPYMEM(node->info.leaf.memory + byteNum, node->info.leaf.memory + byteNum + size, node->numBytes - byteNum);
+            }
+            node->numBytes += size;
+            __CFStorageSetCache(storage, node, (absoluteByteNum - byteNum) / storage->valueSize, node->numBytes / storage->valueSize);
+            return NULL;
+        }
+    } else {
+        CFIndex relativeByteNum;
+        CFIndex childNum;
+        CFStorageNode *newNode;
+        __CFStorageFindChild(node, byteNum, true, &childNum, &relativeByteNum);
+        newNode = __CFStorageInsert(allocator, storage, node->info.notLeaf.child[childNum], relativeByteNum, size, absoluteByteNum);
+        if (newNode) {
+            if (node->info.notLeaf.child[2] == NULL) {	// There's an empty slot for the new node, cool
+                if (childNum == 0) CF_WRITE_BARRIER_ASSIGN(allocator, node->info.notLeaf.child[2], node->info.notLeaf.child[1]);	// Make room
+                CF_WRITE_BARRIER_ASSIGN(allocator, node->info.notLeaf.child[childNum + 1], newNode);
+                node->numBytes += size;
+                return NULL;
+            } else {
+                CFStorageNode *anotherNode = __CFStorageCreateNode(allocator, false, 0);	// Create another node
+                if (childNum == 0) {	// Last two children go to new node
+                    CF_WRITE_BARRIER_ASSIGN(allocator, anotherNode->info.notLeaf.child[0], node->info.notLeaf.child[1]);
+                    CF_WRITE_BARRIER_ASSIGN(allocator, anotherNode->info.notLeaf.child[1], node->info.notLeaf.child[2]);
+                    CF_WRITE_BARRIER_ASSIGN(allocator, node->info.notLeaf.child[1], newNode);
+                    node->info.notLeaf.child[2] = NULL;
+                } else if (childNum == 1) {	// Last child goes to new node
+                    CF_WRITE_BARRIER_ASSIGN(allocator, anotherNode->info.notLeaf.child[0], newNode);
+                    CF_WRITE_BARRIER_ASSIGN(allocator, anotherNode->info.notLeaf.child[1], node->info.notLeaf.child[2]);
+                    node->info.notLeaf.child[2] = NULL;
+                } else {	// New node contains the new comers...
+                    CF_WRITE_BARRIER_ASSIGN(allocator, anotherNode->info.notLeaf.child[0], node->info.notLeaf.child[2]);
+                    CF_WRITE_BARRIER_ASSIGN(allocator, anotherNode->info.notLeaf.child[1], newNode);
+                    node->info.notLeaf.child[2] = NULL;
+                }
+                node->numBytes = node->info.notLeaf.child[0]->numBytes + node->info.notLeaf.child[1]->numBytes;
+                anotherNode->numBytes = anotherNode->info.notLeaf.child[0]->numBytes + anotherNode->info.notLeaf.child[1]->numBytes;
+                return anotherNode;
+            }
+        } else {
+            node->numBytes += size;
+        }
+    }
+    return NULL;
+}
+
+CF_INLINE CFIndex __CFStorageGetCount(CFStorageRef storage) {
+    return storage->rootNode.numBytes / storage->valueSize;
+}
+
+static Boolean __CFStorageEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFStorageRef storage1 = (CFStorageRef)cf1;
+    CFStorageRef storage2 = (CFStorageRef)cf2;
+    CFIndex loc, count, valueSize;
+    CFRange range1, range2;
+    uint8_t *ptr1, *ptr2;
+
+    count = __CFStorageGetCount(storage1);
+    if (count != __CFStorageGetCount(storage2)) return false;
+
+    valueSize = __CFStorageGetValueSize(storage1);
+    if (valueSize != __CFStorageGetValueSize(storage2)) return false;
+
+    loc = range1.location = range1.length = range2.location = range2.length = 0;
+    ptr1 = ptr2 = NULL;
+
+    while (loc < count) {
+	CFIndex cntThisTime;
+	if (loc >= range1.location + range1.length) ptr1 = (uint8_t *)CFStorageGetValueAtIndex(storage1, loc, &range1);
+	if (loc >= range2.location + range2.length) ptr2 = (uint8_t *)CFStorageGetValueAtIndex(storage2, loc, &range2);
+	cntThisTime = range1.location + range1.length;
+	if (range2.location + range2.length < cntThisTime) cntThisTime = range2.location + range2.length;
+	cntThisTime -= loc;
+	if (memcmp(ptr1, ptr2, valueSize * cntThisTime) != 0) return false;
+	ptr1 += valueSize * cntThisTime;
+	ptr2 += valueSize * cntThisTime;
+	loc += cntThisTime;
+    }
+    return true;
+}
+
+static CFHashCode __CFStorageHash(CFTypeRef cf) {
+    CFStorageRef Storage = (CFStorageRef)cf;
+    return __CFStorageGetCount(Storage);
+}
+
+static void __CFStorageDescribeNode(CFStorageNode *node, CFMutableStringRef str, CFIndex level) {
+    int cnt;
+    for (cnt = 0; cnt < level; cnt++) CFStringAppendCString(str, "  ", CFStringGetSystemEncoding());
+
+    if (node->isLeaf) {
+        CFStringAppendFormat(str, NULL, CFSTR("Leaf %d/%d\n"), node->numBytes, node->info.leaf.capacityInBytes);
+    } else {
+        CFStringAppendFormat(str, NULL, CFSTR("Node %d\n"), node->numBytes);
+        for (cnt = 0; cnt < 3; cnt++) if (node->info.notLeaf.child[cnt]) __CFStorageDescribeNode(node->info.notLeaf.child[cnt], str, level+1);
+    }
+}
+
+static CFIndex __CFStorageGetNodeCapacity(CFStorageNode *node) {
+    if (!node) return 0;
+    if (node->isLeaf) return node->info.leaf.capacityInBytes;
+    return __CFStorageGetNodeCapacity(node->info.notLeaf.child[0]) + __CFStorageGetNodeCapacity(node->info.notLeaf.child[1]) + __CFStorageGetNodeCapacity(node->info.notLeaf.child[2]);
+}
+
+CFIndex __CFStorageGetCapacity(CFStorageRef storage) {
+    return __CFStorageGetNodeCapacity(&storage->rootNode) / storage->valueSize;
+}
+
+CFIndex __CFStorageGetValueSize(CFStorageRef storage) {
+    return storage->valueSize;
+}
+
+static CFStringRef __CFStorageCopyDescription(CFTypeRef cf) {
+    CFStorageRef storage = (CFStorageRef)cf;
+    CFMutableStringRef result;
+    CFAllocatorRef allocator = CFGetAllocator(storage);
+    result = CFStringCreateMutable(allocator, 0);
+    CFStringAppendFormat(result, NULL, CFSTR("<CFStorage %p [%p]>[count = %u, capacity = %u]\n"), storage, allocator, __CFStorageGetCount(storage), __CFStorageGetCapacity(storage));
+    __CFStorageDescribeNode(&storage->rootNode, result, 0);
+    return result;
+}
+
+static void __CFStorageDeallocate(CFTypeRef cf) {
+    CFStorageRef storage = (CFStorageRef)cf;
+    CFAllocatorRef allocator = CFGetAllocator(storage);
+    if (CF_IS_COLLECTABLE_ALLOCATOR(allocator)) return; // XXX_PCB GC will take care of us.
+    __CFStorageNodeDealloc(allocator, &storage->rootNode, false);
+}
+
+static CFTypeID __kCFStorageTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFStorageClass = {
+    _kCFRuntimeScannedObject,
+    "CFStorage",
+    NULL,	// init
+    NULL,	// copy
+    __CFStorageDeallocate,
+    __CFStorageEqual,
+    __CFStorageHash,
+    NULL,	// 
+    __CFStorageCopyDescription
+};
+
+__private_extern__ void __CFStorageInitialize(void) {
+    __kCFStorageTypeID = _CFRuntimeRegisterClass(&__CFStorageClass);
+}
+
+/*** Public API ***/
+
+CFStorageRef CFStorageCreate(CFAllocatorRef allocator, CFIndex valueSize) {
+    CFStorageRef storage;
+    CFIndex size = sizeof(struct __CFStorage) - sizeof(CFRuntimeBase);
+    storage = (CFStorageRef)_CFRuntimeCreateInstance(allocator, __kCFStorageTypeID, size, NULL);
+    if (NULL == storage) {
+	return NULL;
+    }
+    storage->valueSize = valueSize;
+    CF_SPINLOCK_INIT_FOR_STRUCTS(storage->cacheReaderMemoryAllocationLock);
+    storage->cacheGenerationCount = 0;
+    storage->cacheParts.locationHi = 0;
+    storage->cacheParts.locationLo = 0;
+#if POSSIBLE_TO_HAVE_LENGTH_MORE_THAN_HALFWORD
+    storage->cacheParts.lengthHi = 0;
+#endif
+    storage->cacheParts.lengthLo = 0;
+    storage->cacheParts.cachedNodeHi = 0;
+    storage->cacheParts.cachedNodeLo = 0;
+    storage->maxLeafCapacity = __CFStorageMaxLeafCapacity;
+    if (valueSize && ((storage->maxLeafCapacity % valueSize) != 0)) {	
+        storage->maxLeafCapacity = (storage->maxLeafCapacity / valueSize) * valueSize;	// Make it fit perfectly (3406853)
+    }
+    memset(&(storage->rootNode), 0, sizeof(CFStorageNode));
+    storage->rootNode.isLeaf = true;
+    storage->nodeHint = __kCFAllocatorGCScannedMemory;
+    if (__CFOASafe) __CFSetLastAllocationEventName(storage, "CFStorage");
+    return storage;    
+}
+
+CFTypeID CFStorageGetTypeID(void) {
+    return __kCFStorageTypeID;
+}
+
+CFIndex CFStorageGetCount(CFStorageRef storage) {
+    return __CFStorageGetCount(storage);
+}
+
+/* Returns pointer to the specified value
+   index and validConsecutiveValueRange are in terms of values
+*/
+void *CFStorageGetValueAtIndex(CFStorageRef storage, CFIndex idx, CFRange *validConsecutiveValueRange) {
+    CFRange range;
+    return __CFStorageGetValueAtIndex(storage, idx, validConsecutiveValueRange ? validConsecutiveValueRange : &range);
+}
+
+/* Makes space for range.length values at location range.location
+   This function deepens the tree if necessary...
+*/
+void CFStorageInsertValues(CFStorageRef storage, CFRange range) {
+    CFIndex numBytesToInsert = range.length * storage->valueSize;
+    CFIndex byteNum = range.location * storage->valueSize;
+    while (numBytesToInsert > 0) {
+        CFStorageNode *newNode;
+        CFAllocatorRef allocator = CFGetAllocator(storage);
+        CFIndex insertThisTime = numBytesToInsert;
+        if (insertThisTime > storage->maxLeafCapacity) {
+            insertThisTime = (storage->maxLeafCapacity / storage->valueSize) * storage->valueSize;
+        }
+        newNode = __CFStorageInsert(allocator, storage, &storage->rootNode, byteNum, insertThisTime, byteNum);
+        if (newNode) {
+            CFStorageNode *tempRootNode = __CFStorageCreateNode(allocator, false, 0);	// Will copy the (static) rootNode over to this
+            CF_WRITE_BARRIER_MEMMOVE(tempRootNode, &storage->rootNode, sizeof(CFStorageNode));
+            storage->rootNode.isLeaf = false;
+            CF_WRITE_BARRIER_BASE_ASSIGN(allocator, storage, storage->rootNode.info.notLeaf.child[0], tempRootNode);
+            CF_WRITE_BARRIER_BASE_ASSIGN(allocator, storage, storage->rootNode.info.notLeaf.child[1], newNode);
+            storage->rootNode.info.notLeaf.child[2] = NULL;
+            storage->rootNode.numBytes = tempRootNode->numBytes + newNode->numBytes;
+#if 1
+	    // ???
+	    __CFStorageSetCache(storage, NULL, 0, 0);
+#else
+            if (storage->cache.cachedNode == &(storage->rootNode)) CF_WRITE_BARRIER_BASE_ASSIGN(allocator, storage, storage->cache.cachedNode, tempRootNode);	// The cache should follow the node
+#endif
+	}
+        numBytesToInsert -= insertThisTime;
+        byteNum += insertThisTime;
+    }
+}
+
+/* Deletes the values in the specified range
+   This function gets rid of levels if necessary...
+*/
+void CFStorageDeleteValues(CFStorageRef storage, CFRange range) {
+    CFAllocatorRef allocator = CFGetAllocator(storage);
+    range.location *= storage->valueSize;
+    range.length *= storage->valueSize;
+    __CFStorageDelete(allocator, storage, &storage->rootNode, range, true);
+    while (__CFStorageGetNumChildren(&storage->rootNode) == 1) {
+        CFStorageNode *child = storage->rootNode.info.notLeaf.child[0];	// The single child
+        CF_WRITE_BARRIER_MEMMOVE(&storage->rootNode, child, sizeof(CFStorageNode));
+        _CFAllocatorDeallocateGC(allocator, child);
+    }
+    if (__CFStorageGetNumChildren(&storage->rootNode) == 0 && !storage->rootNode.isLeaf) {
+	storage->rootNode.isLeaf = true;
+	storage->rootNode.info.leaf.capacityInBytes = 0;
+	storage->rootNode.info.leaf.memory = NULL;
+    }
+    // !!! Need to update the cache
+    __CFStorageSetCache(storage, NULL, 0, 0);
+}
+
+void CFStorageGetValues(CFStorageRef storage, CFRange range, void *values) {
+    while (range.length > 0) {
+        CFRange leafRange;
+        void *storagePtr = __CFStorageGetValueAtIndex(storage, range.location, &leafRange);
+        CFIndex cntThisTime = range.length;
+        if (cntThisTime > leafRange.length - (range.location - leafRange.location)) cntThisTime = leafRange.length - (range.location - leafRange.location);
+        COPYMEM(storagePtr, values, cntThisTime * storage->valueSize);
+        values = (uint8_t *)values + (cntThisTime * storage->valueSize);
+        range.location += cntThisTime;
+        range.length -= cntThisTime;
+    }
+}
+
+unsigned long _CFStorageFastEnumeration(CFStorageRef storage, struct __objcFastEnumerationStateEquivalent *state, void *stackbuffer, unsigned long count) {
+    // without trying to understand the data structure, each time through search for block containing index
+    CFRange leafRange;
+    if (state->state == 0) { /* first time, get length */
+        state->extra[0] = __CFStorageGetCount(storage);
+    }
+    if (state->state >= state->extra[0]) return 0;
+    state->itemsPtr = (unsigned long *)CFStorageGetValueAtIndex(storage, state->state, &leafRange);
+    state->state += leafRange.length;
+    return leafRange.length;
+}
+
+void CFStorageApplyFunction(CFStorageRef storage, CFRange range, CFStorageApplierFunction applier, void *context) {
+    while (0 < range.length) {
+        CFRange leafRange;
+        const void *storagePtr;
+        CFIndex idx, cnt;
+        storagePtr = CFStorageGetValueAtIndex(storage, range.location, &leafRange);
+        cnt = __CFMin(range.length, leafRange.location + leafRange.length - range.location);
+        for (idx = 0; idx < cnt; idx++) {
+            applier(storagePtr, context);
+            storagePtr = (const char *)storagePtr + storage->valueSize;
+        }
+        range.length -= cnt;
+        range.location += cnt;
+    }
+}
+
+void CFStorageReplaceValues(CFStorageRef storage, CFRange range, const void *values) {
+    while (range.length > 0) {
+        CFRange leafRange;
+        void *storagePtr = __CFStorageGetValueAtIndex(storage, range.location, &leafRange);
+        CFIndex cntThisTime = range.length;
+        if (cntThisTime > leafRange.length - (range.location - leafRange.location)) cntThisTime = leafRange.length - (range.location - leafRange.location);
+        COPYMEM(values, storagePtr, cntThisTime * storage->valueSize);
+		values = (const uint8_t *)values + (cntThisTime * storage->valueSize);
+        range.location += cntThisTime;
+        range.length -= cntThisTime;
+    }
+}
+
+/* Used by CFArray.c */
+
+static void __CFStorageNodeSetLayoutType(CFStorageNode *node, auto_zone_t *zone, auto_memory_type_t type) {
+    if (node->isLeaf) {
+        auto_zone_set_layout_type(zone, node->info.leaf.memory, type);
+    } else {
+        CFStorageNode **children = node->info.notLeaf.child;
+        if (children[0]) __CFStorageNodeSetLayoutType(children[0], zone, type);
+        if (children[1]) __CFStorageNodeSetLayoutType(children[1], zone, type);
+        if (children[2]) __CFStorageNodeSetLayoutType(children[2], zone, type);
+    }
+}
+
+__private_extern__ void _CFStorageSetWeak(CFStorageRef storage) {
+    storage->nodeHint = 0;
+    __CFStorageNodeSetLayoutType(&storage->rootNode, __CFCollectableZone, CF_GET_GC_MEMORY_TYPE(storage->nodeHint));
+}
+
+#undef COPYMEM
+#undef PAGE_LIMIT
+
diff --git a/CoreFoundation/CFStorage.h b/CoreFoundation/CFStorage.h
new file mode 100644
index 0000000..77b4e05
--- /dev/null
+++ b/CoreFoundation/CFStorage.h
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+
+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);
+
+/*!
+        @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 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 the no values are inserted.
+*/
+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 the 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.
+	@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 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 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_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFSTORAGE__ */
+
diff --git a/CoreFoundation/CFStream.c b/CoreFoundation/CFStream.c
new file mode 100644
index 0000000..1795a51
--- /dev/null
+++ b/CoreFoundation/CFStream.c
@@ -0,0 +1,1566 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 2000-2002, Apple, Inc. All rights reserved.
+	Responsibility: Becky Willrich
+*/
+
+#include <CoreFoundation/CFRuntime.h>
+#include <CoreFoundation/CFNumber.h>
+#include <string.h>
+#include "CFStreamInternal.h"
+#include "CFInternal.h"
+#include <stdio.h>
+
+
+enum {
+	MIN_STATUS_CODE_BIT	= 0,
+        // ..status bits...
+	MAX_STATUS_CODE_BIT	= 4,
+    
+	CONSTANT_CALLBACKS	= 5,
+	CALLING_CLIENT		= 6,	// MUST remain 6 since it's value is used elsewhere.
+	
+    HAVE_CLOSED			= 7,
+    
+    // Values above used to be defined and others may rely on their values
+    
+    // Values below should not matter if they are re-ordered or shift
+    
+    SHARED_SOURCE
+};
+
+
+/* CALLING_CLIENT really determines whether stream events will be sent to the client immediately, or posted for the next time through the runloop.  Since the client may not be prepared for re-entrancy, we must always set/clear this bit around public entry points. -- REW, 9/5/2001 
+    Also, CALLING_CLIENT is now used from CFFilteredStream.c (which has a copy of the #define above).  Really gross.  We should find a way to avoid that.... -- REW, 3/27/2002  */
+// Used in CFNetwork too
+
+/* sSharesSources holds two mappings, one the inverse of the other, between a stream and the
+   RunLoop+RunLoopMode pair that it's scheduled in.  If the stream is scheduled in more than
+   one loop or mode, it can't share RunLoopSources with others, and is not in this dict.
+*/
+static CFSpinLock_t sSourceLock = CFSpinLockInit;
+static CFMutableDictionaryRef sSharedSources = NULL;
+
+static CFTypeID __kCFReadStreamTypeID = _kCFRuntimeNotATypeID;
+static CFTypeID __kCFWriteStreamTypeID = _kCFRuntimeNotATypeID;
+
+// Just reads the bits, for those cases where we don't want to go through any callback checking
+#define __CFStreamGetStatus(x) __CFBitfieldGetValue((x)->flags, MAX_STATUS_CODE_BIT, MIN_STATUS_CODE_BIT)
+
+static void _CFStreamSignalEventSynch(void* info);
+__private_extern__ CFStreamStatus _CFStreamGetStatus(struct _CFStream *stream);
+static Boolean _CFStreamRemoveRunLoopAndModeFromArray(CFMutableArrayRef runLoopsAndModes, CFRunLoopRef rl, CFStringRef mode);
+static void _wakeUpRunLoop(struct _CFStream *stream);
+
+CF_INLINE const struct _CFStreamCallBacks *_CFStreamGetCallBackPtr(struct _CFStream *stream) {
+    return stream->callBacks;
+}
+
+CF_INLINE void _CFStreamSetStatusCode(struct _CFStream *stream, CFStreamStatus newStatus) {
+    CFStreamStatus status = __CFStreamGetStatus(stream);
+    if (((status != kCFStreamStatusClosed) && (status != kCFStreamStatusError)) ||
+        ((status == kCFStreamStatusClosed) && (newStatus == kCFStreamStatusError)))
+    {
+        __CFBitfieldSetValue(stream->flags, MAX_STATUS_CODE_BIT, MIN_STATUS_CODE_BIT, newStatus);
+    }
+}
+
+CF_INLINE void _CFStreamScheduleEvent(struct _CFStream *stream, CFStreamEventType event) {
+    if (stream->client && (stream->client->when & event) && stream->client->rlSource) {
+        stream->client->whatToSignal |= event;
+        CFRunLoopSourceSignal(stream->client->rlSource);
+        _wakeUpRunLoop(stream);
+    }
+}
+
+CF_INLINE void _CFStreamSetStreamError(struct _CFStream *stream, CFStreamError *err) {
+    if (!stream->error) {
+        stream->error = (CFErrorRef)CFAllocatorAllocate(CFGetAllocator(stream), sizeof(CFStreamError), 0);
+    }
+    memmove(stream->error, err, sizeof(CFStreamError));
+}
+
+static CFStringRef __CFStreamCopyDescription(CFTypeRef cf) {
+    struct _CFStream *stream = (struct _CFStream *)cf;
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    CFStringRef contextDescription;
+    CFStringRef desc;
+    if (cb->copyDescription) {
+        if (cb->version == 0) {
+            contextDescription = ((CFStringRef(*)(void *))cb->copyDescription)(_CFStreamGetInfoPointer(stream));
+        } else {
+            contextDescription = cb->copyDescription(stream, _CFStreamGetInfoPointer(stream));
+        }
+    } else {
+        contextDescription = CFStringCreateWithFormat(CFGetAllocator(stream), NULL, CFSTR("info = %p"), _CFStreamGetInfoPointer(stream));
+    }
+    if (CFGetTypeID(cf) == __kCFReadStreamTypeID) {
+        desc = CFStringCreateWithFormat(CFGetAllocator(stream), NULL, CFSTR("<CFReadStream %p>{%@}"), stream, contextDescription);
+    } else {
+        desc = CFStringCreateWithFormat(CFGetAllocator(stream), NULL, CFSTR("<CFWriteStream %p>{%@}"), stream, contextDescription);
+    }
+    CFRelease(contextDescription);
+    return desc;
+}
+
+__private_extern__ void _CFStreamClose(struct _CFStream *stream) {
+    CFStreamStatus status = _CFStreamGetStatus(stream);
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (status == kCFStreamStatusNotOpen || status == kCFStreamStatusClosed || (status == kCFStreamStatusError && __CFBitIsSet(stream->flags, HAVE_CLOSED))) {
+        // Stream is not open from the client's perspective; do not callout and do not update our status to "closed"
+        return;
+    }
+    __CFBitSet(stream->flags, HAVE_CLOSED);
+    __CFBitSet(stream->flags, CALLING_CLIENT);
+    if (cb->close) {
+        cb->close(stream, _CFStreamGetInfoPointer(stream));
+    }
+    if (stream->client && stream->client->rlSource) {
+        
+        if (!__CFBitIsSet(stream->flags, SHARED_SOURCE)) {
+            CFRunLoopSourceInvalidate(stream->client->rlSource);
+            CFRelease(stream->client->rlSource);
+            stream->client->rlSource = NULL;
+        }
+        else {
+            
+            CFArrayRef key;
+            CFMutableArrayRef list;
+            CFIndex c, i;
+            
+            __CFSpinLock(&sSourceLock);
+            
+            key = (CFArrayRef)CFDictionaryGetValue(sSharedSources, stream);
+            list = (CFMutableArrayRef)CFDictionaryGetValue(sSharedSources, key);
+            
+            c = CFArrayGetCount(list);
+            i = CFArrayGetFirstIndexOfValue(list, CFRangeMake(0, c), stream);
+            if (i != kCFNotFound) {
+                CFArrayRemoveValueAtIndex(list, i);
+                c--;
+            }
+            
+            CFAssert(CFArrayGetFirstIndexOfValue(list, CFRangeMake(0, CFArrayGetCount(list)), stream) == kCFNotFound, __kCFLogAssertion, "CFStreamClose: stream found twice in its shared source's list");
+
+            if (!c) {
+                CFRunLoopRemoveSource((CFRunLoopRef)CFArrayGetValueAtIndex(key, 0), stream->client->rlSource, (CFStringRef)CFArrayGetValueAtIndex(key, 1));
+                CFRunLoopSourceInvalidate(stream->client->rlSource);
+                CFDictionaryRemoveValue(sSharedSources, key);
+            }
+            
+            CFDictionaryRemoveValue(sSharedSources, stream);
+            
+            CFRelease(stream->client->rlSource);
+            stream->client->rlSource = NULL;
+            __CFBitClear(stream->flags, SHARED_SOURCE);
+
+            __CFSpinUnlock(&sSourceLock);
+        }
+    }
+    _CFStreamSetStatusCode(stream, kCFStreamStatusClosed);
+    __CFBitClear(stream->flags, CALLING_CLIENT);
+}
+
+//static int numStreamInstances = 0;
+
+static void __CFStreamDeallocate(CFTypeRef cf) {
+    struct _CFStream *stream = (struct _CFStream *)cf;
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    CFAllocatorRef alloc = CFGetAllocator(stream);
+//    numStreamInstances --;
+
+    // Close the stream
+    _CFStreamClose(stream);
+
+    if (stream->client) {
+        CFStreamClientContext *cbContext;
+        cbContext = &(stream->client->cbContext);
+        if (cbContext->info && cbContext->release) {
+            cbContext->release(cbContext->info);
+        }
+        if (stream->client->rlSource) {
+            if (!__CFBitIsSet(stream->flags, SHARED_SOURCE)) {
+                CFRunLoopSourceInvalidate(stream->client->rlSource);
+                CFRelease(stream->client->rlSource);
+                stream->client->rlSource = NULL;
+            }
+            else {
+                
+                CFArrayRef key;
+                CFMutableArrayRef list;
+                CFIndex c, i;
+
+                __CFSpinLock(&sSourceLock);
+                
+                key = (CFArrayRef)CFDictionaryGetValue(sSharedSources, stream);
+                list = (CFMutableArrayRef)CFDictionaryGetValue(sSharedSources, key);
+                
+                c = CFArrayGetCount(list);
+                i = CFArrayGetFirstIndexOfValue(list, CFRangeMake(0, c), stream);
+                if (i != kCFNotFound) {
+                    CFArrayRemoveValueAtIndex(list, i);
+                    c--;
+                }
+                
+                if (!c) {
+                    CFRunLoopRemoveSource((CFRunLoopRef)CFArrayGetValueAtIndex(key, 0), stream->client->rlSource, (CFStringRef)CFArrayGetValueAtIndex(key, 1));
+                    CFRunLoopSourceInvalidate(stream->client->rlSource);
+                    CFDictionaryRemoveValue(sSharedSources, key);
+                }
+                
+                CFDictionaryRemoveValue(sSharedSources, stream);
+                
+                CFRelease(stream->client->rlSource);
+                stream->client->rlSource = NULL;
+                __CFBitClear(stream->flags, SHARED_SOURCE);
+
+                __CFSpinUnlock(&sSourceLock);
+            }
+        }
+        if (stream->client->runLoopsAndModes) {
+            CFRelease(stream->client->runLoopsAndModes);
+        }
+        
+        CFAllocatorDeallocate(alloc, stream->client);
+        stream->client = NULL; // Just in case finalize, below, calls back in to us
+    }
+    if (cb->finalize) {
+        if (cb->version == 0) {
+            ((void(*)(void *))cb->finalize)(_CFStreamGetInfoPointer(stream));
+        } else {
+            cb->finalize(stream, _CFStreamGetInfoPointer(stream));
+        }
+    }
+    if (stream->error) {
+        if (cb->version < 2) {
+            CFAllocatorDeallocate(alloc, stream->error);
+        } else {
+            CFRelease(stream->error);
+        }
+    }
+    if (!__CFBitIsSet(stream->flags, CONSTANT_CALLBACKS)) {
+        CFAllocatorDeallocate(alloc, (void *)stream->callBacks);
+    }
+}
+
+static const CFRuntimeClass __CFReadStreamClass = {
+    0,
+    "CFReadStream",
+    NULL,      // init
+    NULL,      // copy
+    __CFStreamDeallocate,
+    NULL,
+    NULL,
+    NULL,      // copyHumanDesc
+    __CFStreamCopyDescription
+};
+
+static const CFRuntimeClass __CFWriteStreamClass = {
+    0,
+    "CFWriteStream",
+    NULL,      // init
+    NULL,      // copy
+    __CFStreamDeallocate,
+    NULL,
+    NULL,
+    NULL,      // copyHumanDesc
+    __CFStreamCopyDescription
+};
+
+CONST_STRING_DECL(kCFStreamPropertySocketNativeHandle, "kCFStreamPropertySocketNativeHandle")
+CONST_STRING_DECL(kCFStreamPropertySocketRemoteHostName, "kCFStreamPropertySocketRemoteHostName")
+CONST_STRING_DECL(kCFStreamPropertySocketRemotePortNumber, "kCFStreamPropertySocketRemotePortNumber")
+CONST_STRING_DECL(kCFStreamPropertyDataWritten, "kCFStreamPropertyDataWritten")
+CONST_STRING_DECL(kCFStreamPropertyAppendToFile, "kCFStreamPropertyAppendToFile")
+
+__private_extern__ void __CFStreamInitialize(void) {
+    __kCFReadStreamTypeID = _CFRuntimeRegisterClass(&__CFReadStreamClass);
+    __kCFWriteStreamTypeID = _CFRuntimeRegisterClass(&__CFWriteStreamClass);
+}
+
+
+CF_EXPORT CFTypeID CFReadStreamGetTypeID(void) {
+    return __kCFReadStreamTypeID;
+}
+
+CF_EXPORT CFTypeID CFWriteStreamGetTypeID(void) {
+    return __kCFWriteStreamTypeID;
+}
+
+static struct _CFStream *_CFStreamCreate(CFAllocatorRef allocator, Boolean isReadStream) {
+    struct _CFStream *newStream = (struct _CFStream *)_CFRuntimeCreateInstance(allocator, isReadStream ? __kCFReadStreamTypeID : __kCFWriteStreamTypeID, sizeof(struct _CFStream) - sizeof(CFRuntimeBase), NULL);
+    if (newStream) {
+//        numStreamInstances ++;
+        newStream->flags = 0;
+        _CFStreamSetStatusCode(newStream, kCFStreamStatusNotOpen);
+        newStream->error = NULL;
+        newStream->client = NULL;
+        newStream->info = NULL;
+        newStream->callBacks = NULL;
+    }
+    return newStream;
+}
+
+__private_extern__ struct _CFStream *_CFStreamCreateWithConstantCallbacks(CFAllocatorRef alloc, void *info,  const struct _CFStreamCallBacks *cb, Boolean isReading) {
+    struct _CFStream *newStream;
+    if (cb->version != 1) return NULL;
+    newStream = _CFStreamCreate(alloc, isReading);
+    if (newStream) {
+        __CFBitSet(newStream->flags, CONSTANT_CALLBACKS);
+        newStream->callBacks = cb;
+        if (cb->create) {
+            newStream->info = cb->create(newStream, info);
+        } else {
+            newStream->info = info;
+        }
+    }
+    return newStream;
+}
+
+CF_EXPORT void _CFStreamSetInfoPointer(struct _CFStream *stream, void *info, const struct _CFStreamCallBacks *cb) {
+    if (info != stream->info) {
+        if (stream->callBacks->finalize) {
+            stream->callBacks->finalize(stream, stream->info);
+        }
+        if (cb->create) {
+            stream->info = cb->create(stream, info);
+        } else {
+            stream->info = info;
+        }
+    }
+    stream->callBacks = cb;
+}
+
+
+CF_EXPORT CFReadStreamRef CFReadStreamCreate(CFAllocatorRef alloc, const CFReadStreamCallBacks *callbacks, void *info) {
+    struct _CFStream *newStream = _CFStreamCreate(alloc, TRUE);
+    struct _CFStreamCallBacks *cb;
+    if (!newStream) return NULL;
+    cb = (struct _CFStreamCallBacks *)CFAllocatorAllocate(alloc, sizeof(struct _CFStreamCallBacks), 0);
+    if (!cb) {
+        CFRelease(newStream);
+        return NULL;
+    }
+    if (callbacks->version == 0) {
+        CFReadStreamCallBacksV0 *cbV0 = (CFReadStreamCallBacksV0 *)callbacks;
+        CFStreamClientContext *ctxt = (CFStreamClientContext *)info;
+        newStream->info = ctxt->retain ? (void *)ctxt->retain(ctxt->info) : ctxt->info;
+        cb->version = 0;
+        cb->create = (void *(*)(struct _CFStream *, void *))ctxt->retain;
+        cb->finalize = (void(*)(struct _CFStream *, void *))ctxt->release;
+        cb->copyDescription = (CFStringRef(*)(struct _CFStream *, void *))ctxt->copyDescription;
+        cb->open = (Boolean(*)(struct _CFStream *, CFErrorRef *, Boolean *, void *))cbV0->open;
+        cb->openCompleted = (Boolean (*)(struct _CFStream *, CFErrorRef *, void *))cbV0->openCompleted;
+        cb->read = (CFIndex (*)(CFReadStreamRef, UInt8 *, CFIndex, CFErrorRef *, Boolean *, void *))cbV0->read;
+        cb->getBuffer = (const UInt8 *(*)(CFReadStreamRef, CFIndex, CFIndex *, CFErrorRef *, Boolean *, void *))cbV0->getBuffer;
+        cb->canRead = (Boolean (*)(CFReadStreamRef, CFErrorRef*, void*))cbV0->canRead;
+        cb->write = NULL;
+        cb->canWrite = NULL;
+        cb->close = (void (*)(struct _CFStream *, void *))cbV0->close;
+        cb->copyProperty = (CFTypeRef (*)(struct _CFStream *, CFStringRef, void *))cbV0->copyProperty;
+        cb->setProperty = NULL;
+        cb->requestEvents = NULL;
+        cb->schedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV0->schedule;
+        cb->unschedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV0->unschedule;
+    } else if (callbacks->version == 1) {
+        CFReadStreamCallBacksV1 *cbV1 = (CFReadStreamCallBacksV1 *)callbacks;
+        newStream->info = cbV1->create ? cbV1->create((CFReadStreamRef)newStream, info) : info;
+        cb->version = 1;
+        cb->create = (void *(*)(struct _CFStream *, void *))cbV1->create;
+        cb->finalize = (void(*)(struct _CFStream *, void *))cbV1->finalize;
+        cb->copyDescription = (CFStringRef(*)(struct _CFStream *, void *))cbV1->copyDescription;
+        cb->open = (Boolean(*)(struct _CFStream *, CFErrorRef *, Boolean *, void *))cbV1->open;
+        cb->openCompleted = (Boolean (*)(struct _CFStream *, CFErrorRef *, void *))cbV1->openCompleted;
+        cb->read = (CFIndex (*)(CFReadStreamRef, UInt8 *, CFIndex, CFErrorRef *, Boolean *, void *))cbV1->read;
+        cb->getBuffer = (const UInt8 *(*)(CFReadStreamRef, CFIndex, CFIndex *, CFErrorRef *, Boolean *, void *))cbV1->getBuffer;
+        cb->canRead = (Boolean (*)(CFReadStreamRef, CFErrorRef*, void*))cbV1->canRead;
+        cb->write = NULL;
+        cb->canWrite = NULL;
+        cb->close = (void (*)(struct _CFStream *, void *))cbV1->close;
+        cb->copyProperty = (CFTypeRef (*)(struct _CFStream *, CFStringRef, void *))cbV1->copyProperty;
+        cb->setProperty = (Boolean(*)(struct _CFStream *, CFStringRef, CFTypeRef, void *))cbV1->setProperty;
+        cb->requestEvents = (void(*)(struct _CFStream *, CFOptionFlags, void *))cbV1->requestEvents;
+        cb->schedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV1->schedule;
+        cb->unschedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV1->unschedule;
+    } else {
+        newStream->info = callbacks->create ? callbacks->create((CFReadStreamRef)newStream, info) : info;
+        cb->version = 2;
+        cb->create = (void *(*)(struct _CFStream *, void *))callbacks->create;
+        cb->finalize = (void(*)(struct _CFStream *, void *))callbacks->finalize;
+        cb->copyDescription = (CFStringRef(*)(struct _CFStream *, void *))callbacks->copyDescription;
+        cb->open = (Boolean(*)(struct _CFStream *, CFErrorRef *, Boolean *, void *))callbacks->open;
+        cb->openCompleted = (Boolean (*)(struct _CFStream *, CFErrorRef *, void *))callbacks->openCompleted;
+        cb->read = callbacks->read;
+        cb->getBuffer = callbacks->getBuffer;
+        cb->canRead = callbacks->canRead;
+        cb->write = NULL;
+        cb->canWrite = NULL;
+        cb->close = (void (*)(struct _CFStream *, void *))callbacks->close;
+        cb->copyProperty = (CFTypeRef (*)(struct _CFStream *, CFStringRef, void *))callbacks->copyProperty;
+        cb->setProperty = (Boolean(*)(struct _CFStream *, CFStringRef, CFTypeRef, void *))callbacks->setProperty;
+        cb->requestEvents = (void(*)(struct _CFStream *, CFOptionFlags, void *))callbacks->requestEvents;
+        cb->schedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))callbacks->schedule;
+        cb->unschedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))callbacks->unschedule;
+   }
+    
+    newStream->callBacks = cb;
+    return (CFReadStreamRef)newStream;
+}
+
+CF_EXPORT CFWriteStreamRef CFWriteStreamCreate(CFAllocatorRef alloc, const CFWriteStreamCallBacks *callbacks, void *info) {
+    struct _CFStream *newStream = _CFStreamCreate(alloc, FALSE);
+    struct _CFStreamCallBacks *cb;
+    if (!newStream) return NULL;
+    cb = (struct _CFStreamCallBacks *)CFAllocatorAllocate(alloc, sizeof(struct _CFStreamCallBacks), 0);
+    if (!cb) {
+        CFRelease(newStream);
+        return NULL;
+    }
+    if (callbacks->version == 0) {
+        CFWriteStreamCallBacksV0 *cbV0 = (CFWriteStreamCallBacksV0 *)callbacks;
+        CFStreamClientContext *ctxt = (CFStreamClientContext *)info;
+        newStream->info = ctxt->retain ? (void *)ctxt->retain(ctxt->info) : ctxt->info;
+        cb->version = 0;
+        cb->create = (void *(*)(struct _CFStream *, void *))ctxt->retain;
+        cb->finalize = (void(*)(struct _CFStream *, void *))ctxt->release;
+        cb->copyDescription = (CFStringRef(*)(struct _CFStream *, void *))ctxt->copyDescription;
+        cb->open = (Boolean(*)(struct _CFStream *, CFErrorRef *, Boolean *, void *))cbV0->open;
+        cb->openCompleted = (Boolean (*)(struct _CFStream *, CFErrorRef *, void *))cbV0->openCompleted;
+        cb->read = NULL;
+        cb->getBuffer = NULL;
+        cb->canRead = NULL;
+        cb->write = (CFIndex(*)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info))cbV0->write;
+        cb->canWrite = (Boolean(*)(CFWriteStreamRef stream, CFErrorRef *error, void *info))cbV0->canWrite;
+        cb->close = (void (*)(struct _CFStream *, void *))cbV0->close;
+        cb->copyProperty = (CFTypeRef (*)(struct _CFStream *, CFStringRef, void *))cbV0->copyProperty;
+        cb->setProperty = NULL;
+        cb->requestEvents = NULL;
+        cb->schedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV0->schedule;
+        cb->unschedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV0->unschedule;
+    } else if (callbacks->version == 1) {
+        CFWriteStreamCallBacksV1 *cbV1 = (CFWriteStreamCallBacksV1 *)callbacks;
+        cb->version = 1;
+        newStream->info = cbV1->create ? cbV1->create((CFWriteStreamRef)newStream, info) : info;
+        cb->create = (void *(*)(struct _CFStream *, void *))cbV1->create;
+        cb->finalize = (void(*)(struct _CFStream *, void *))cbV1->finalize;
+        cb->copyDescription = (CFStringRef(*)(struct _CFStream *, void *))cbV1->copyDescription;
+        cb->open = (Boolean(*)(struct _CFStream *, CFErrorRef *, Boolean *, void *))cbV1->open;
+        cb->openCompleted = (Boolean (*)(struct _CFStream *, CFErrorRef *, void *))cbV1->openCompleted;
+        cb->read = NULL;
+        cb->getBuffer = NULL;
+        cb->canRead = NULL;
+        cb->write = (CFIndex(*)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info))cbV1->write;
+        cb->canWrite = (Boolean(*)(CFWriteStreamRef stream, CFErrorRef *error, void *info))cbV1->canWrite;
+        cb->close = (void (*)(struct _CFStream *, void *))cbV1->close;        
+        cb->copyProperty = (CFTypeRef (*)(struct _CFStream *, CFStringRef, void *))cbV1->copyProperty;
+        cb->setProperty = (Boolean (*)(struct _CFStream *, CFStringRef, CFTypeRef, void *))cbV1->setProperty;
+        cb->requestEvents = (void(*)(struct _CFStream *, CFOptionFlags, void *))cbV1->requestEvents;
+        cb->schedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV1->schedule;
+        cb->unschedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))cbV1->unschedule;
+    } else {
+        cb->version = callbacks->version;
+        newStream->info = callbacks->create ? callbacks->create((CFWriteStreamRef)newStream, info) : info;
+        cb->create = (void *(*)(struct _CFStream *, void *))callbacks->create;
+        cb->finalize = (void(*)(struct _CFStream *, void *))callbacks->finalize;
+        cb->copyDescription = (CFStringRef(*)(struct _CFStream *, void *))callbacks->copyDescription;
+        cb->open = (Boolean(*)(struct _CFStream *, CFErrorRef *, Boolean *, void *))callbacks->open;
+        cb->openCompleted = (Boolean (*)(struct _CFStream *, CFErrorRef *, void *))callbacks->openCompleted;
+        cb->read = NULL;
+        cb->getBuffer = NULL;
+        cb->canRead = NULL;
+        cb->write = callbacks->write;
+        cb->canWrite = callbacks->canWrite;
+        cb->close = (void (*)(struct _CFStream *, void *))callbacks->close;        
+        cb->copyProperty = (CFTypeRef (*)(struct _CFStream *, CFStringRef, void *))callbacks->copyProperty;
+        cb->setProperty = (Boolean (*)(struct _CFStream *, CFStringRef, CFTypeRef, void *))callbacks->setProperty;
+        cb->requestEvents = (void(*)(struct _CFStream *, CFOptionFlags, void *))callbacks->requestEvents;
+        cb->schedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))callbacks->schedule;
+        cb->unschedule = (void (*)(struct _CFStream *, CFRunLoopRef, CFStringRef, void *))callbacks->unschedule;
+    }
+    newStream->callBacks = cb;
+    return (CFWriteStreamRef)newStream;
+}
+
+static void _CFStreamSignalEventSynch(void* info) {
+
+    struct _CFStream *stream = NULL;
+    CFOptionFlags eventMask, whatToSignal = 0;
+    
+    if (CFGetTypeID((CFTypeRef)info) != CFArrayGetTypeID()) {
+        stream = (struct _CFStream*)info;
+        whatToSignal = stream->client->whatToSignal;
+        stream->client->whatToSignal = 0;
+    }
+    else {
+        
+        CFMutableArrayRef list = (CFMutableArrayRef)info;
+        CFIndex c, i;
+
+        __CFSpinLock(&sSourceLock);
+
+        c = CFArrayGetCount(list);
+        for (i = 0; i < c; i++) {
+            struct _CFStream* s = (struct _CFStream*)CFArrayGetValueAtIndex(list, i);
+            if (s->client->whatToSignal) {
+                stream = s;
+                whatToSignal = stream->client->whatToSignal;
+                s->client->whatToSignal = 0;
+                break;
+            }
+        }
+        
+        while (i < c) {
+            struct _CFStream* s = (struct _CFStream*)CFArrayGetValueAtIndex(list, i);
+            if (s->client->whatToSignal) {
+                CFRunLoopSourceSignal(s->client->rlSource);
+                break;
+            }
+            i++;
+        }
+
+        __CFSpinUnlock(&sSourceLock);
+    }
+
+    if (!stream)
+        return;
+
+    CFRetain(stream); // In case the client releases the stream while we're still in the for loop....
+
+    __CFBitSet(stream->flags, CALLING_CLIENT);
+
+    for (eventMask = 1; eventMask <= whatToSignal; eventMask = eventMask << 1) {
+        if ((eventMask & whatToSignal) && (stream->client->when & eventMask)) {
+            stream->client->cb(stream, eventMask, stream->client->cbContext.info);
+        }
+    }
+
+    __CFBitClear(stream->flags, CALLING_CLIENT);
+
+    CFRelease(stream);
+}
+
+// Largely cribbed from CFSocket.c; find a run loop where our source is scheduled and wake it up.  We skip the runloop cycling, so we
+// are likely to signal the same run loop over and over again.  Don't know if we should worry about that.
+static void _wakeUpRunLoop(struct _CFStream *stream) {
+    CFRunLoopRef rl = NULL;
+    SInt32 idx, cnt;
+    CFArrayRef rlArray;
+    if (!stream->client || !stream->client->runLoopsAndModes) return;
+    rlArray = stream->client->runLoopsAndModes;
+    cnt = CFArrayGetCount(rlArray);
+    if (cnt == 0) return;
+    if (cnt == 2) {
+        rl = (CFRunLoopRef)CFArrayGetValueAtIndex(rlArray, 0);
+    } else {
+        rl = (CFRunLoopRef)CFArrayGetValueAtIndex(rlArray, 0);
+        for (idx = 2; NULL != rl && idx < cnt; idx+=2) {
+            CFRunLoopRef value = (CFRunLoopRef)CFArrayGetValueAtIndex(rlArray, idx);
+            if (value != rl) rl = NULL;
+        }
+        if (NULL == rl) {	/* more than one different rl, so we must pick one */
+            for (idx = 0; idx < cnt; idx+=2) {
+                CFRunLoopRef value = (CFRunLoopRef)CFArrayGetValueAtIndex(rlArray, idx);
+                CFStringRef currentMode = CFRunLoopCopyCurrentMode(value);
+                if (NULL != currentMode && CFEqual(currentMode, CFArrayGetValueAtIndex(rlArray, idx+1)) && CFRunLoopIsWaiting(value)) {
+                    CFRelease(currentMode);
+                    rl = value;
+                    break;
+                }
+                if (NULL != currentMode) CFRelease(currentMode);
+            }
+            if (NULL == rl) {	/* didn't choose one above, so choose first */
+                rl = (CFRunLoopRef)CFArrayGetValueAtIndex(rlArray, 0);
+            }
+        }
+    }
+    if (NULL != rl && CFRunLoopIsWaiting(rl)) CFRunLoopWakeUp(rl);
+}
+
+__private_extern__ void _CFStreamSignalEvent(struct _CFStream *stream, CFStreamEventType event, CFErrorRef error, Boolean synchronousAllowed) {
+    // Update our internal status; we must use the primitive __CFStreamGetStatus(), because CFStreamGetStatus() calls us, and we can end up in an infinite loop.
+    CFStreamStatus status = __CFStreamGetStatus(stream);
+
+    // Sanity check the event
+    if (status == kCFStreamStatusNotOpen) {
+        // No events allowed; this is almost certainly a bug in the stream's implementation
+        CFLog(__kCFLogAssertion, CFSTR("Stream %p is sending an event before being opened"), stream);
+        event = 0;
+    } else if (status == kCFStreamStatusClosed || status == kCFStreamStatusError) {
+        // no further events are allowed
+        event = 0;
+    } else if (status == kCFStreamStatusAtEnd) {
+        // Only error events are allowed
+        event &= kCFStreamEventErrorOccurred;
+    } else if (status != kCFStreamStatusOpening) {
+        // cannot send open completed; that happened already
+        event &= ~kCFStreamEventOpenCompleted;
+    }
+    
+    // Change status if appropriate
+    if (event & kCFStreamEventOpenCompleted && status == kCFStreamStatusOpening) {
+        _CFStreamSetStatusCode(stream, kCFStreamStatusOpen);
+    }
+    if (event & kCFStreamEventEndEncountered && status < kCFStreamStatusAtEnd) {
+        _CFStreamSetStatusCode(stream, kCFStreamStatusAtEnd);
+    }
+    if (event & kCFStreamEventErrorOccurred) {
+        if (_CFStreamGetCallBackPtr(stream)->version < 2) {
+            _CFStreamSetStreamError(stream, (CFStreamError *)error);
+        } else {
+            CFAssert(error, __kCFLogAssertion, "CFStream: kCFStreamEventErrorOccurred signalled, but error is NULL!");
+            CFRetain(error);
+            if (stream->error) CFRelease(stream->error);
+            stream->error = error;
+        }
+        _CFStreamSetStatusCode(stream, kCFStreamStatusError);
+    }
+
+    // Now signal any pertinent event 
+    if (stream->client && stream->client->rlSource && (stream->client->when & event)) {
+    
+        Boolean signalNow = FALSE;
+        
+        stream->client->whatToSignal |= event;
+        
+        if (synchronousAllowed && !__CFBitIsSet(stream->flags, CALLING_CLIENT)) {
+            
+            CFRunLoopRef rl = CFRunLoopGetCurrent();
+            CFStringRef mode = CFRunLoopCopyCurrentMode(rl);
+            
+            if (mode) {
+                if (CFRunLoopContainsSource(rl, stream->client->rlSource, mode))
+                    signalNow = TRUE;
+                CFRelease(mode);
+            }
+        }
+
+        if (signalNow) {
+            // Can call out safely right now
+            _CFStreamSignalEventSynch(stream);
+        } else {
+            // Schedule for later delivery
+            CFRunLoopSourceSignal(stream->client->rlSource);
+            _wakeUpRunLoop(stream);
+        }
+    }
+}
+
+__private_extern__ CFStreamStatus _CFStreamGetStatus(struct _CFStream *stream) {
+  CFStreamStatus status = __CFStreamGetStatus(stream);
+  // Status code just represents the value when last we checked; if we were in the middle of doing work at that time, we need to find out if the work has completed, now.  If we find out about a status change, we need to inform the client as well, so we call _CFStreamSignalEvent.  This will take care of updating our internal status correctly, too.
+  __CFBitSet(stream->flags, CALLING_CLIENT);
+  if (status == kCFStreamStatusOpening) {
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (cb->openCompleted) {
+      Boolean isComplete;
+      if (cb->version < 2) {
+	CFStreamError err = {0, 0};
+	isComplete = ((_CFStreamCBOpenCompletedV1)(cb->openCompleted))(stream, &err, _CFStreamGetInfoPointer(stream));
+	if (err.error != 0) _CFStreamSetStreamError(stream, &err);
+      } else {
+	isComplete = cb->openCompleted(stream, &(stream->error), _CFStreamGetInfoPointer(stream));
+      }
+      if (isComplete) {
+	if (!stream->error) {
+	  status = kCFStreamStatusOpen;
+	} else {
+	  status = kCFStreamStatusError;
+	}
+	_CFStreamSetStatusCode(stream, status);
+	if (status == kCFStreamStatusOpen) {
+	  _CFStreamScheduleEvent(stream, kCFStreamEventOpenCompleted);
+	} else {
+	  _CFStreamScheduleEvent(stream, kCFStreamEventErrorOccurred);
+	}
+      }
+    }
+  }
+  __CFBitClear(stream->flags, CALLING_CLIENT);
+  return status;
+}
+
+CF_EXPORT CFStreamStatus CFReadStreamGetStatus(CFReadStreamRef stream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFReadStreamTypeID, CFStreamStatus, stream, "streamStatus");
+    return _CFStreamGetStatus((struct _CFStream *)stream);
+}
+
+CF_EXPORT CFStreamStatus CFWriteStreamGetStatus(CFWriteStreamRef stream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFWriteStreamTypeID, CFStreamStatus, stream, "streamStatus");
+    return _CFStreamGetStatus((struct _CFStream *)stream);
+}
+
+static CFStreamError _CFStreamGetStreamError(struct _CFStream *stream) {
+    CFStreamError result;
+    if (!stream->error) {
+        result.error = 0;
+        result.domain = 0;
+    } else if (_CFStreamGetCallBackPtr(stream)->version < 2) {
+        CFStreamError *streamError = (CFStreamError *)(stream->error);
+        result.error = streamError->error;
+        result.domain = streamError->domain;
+    } else {
+        result = _CFStreamErrorFromError(stream->error);
+    }
+    return result;
+}
+
+CF_EXPORT CFStreamError CFReadStreamGetError(CFReadStreamRef stream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFReadStreamTypeID, CFStreamError, stream, "_cfStreamError");
+    return _CFStreamGetStreamError((struct _CFStream *)stream);
+}
+
+CF_EXPORT CFStreamError CFWriteStreamGetError(CFWriteStreamRef stream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFWriteStreamTypeID, CFStreamError, stream, "_cfStreamError");
+    return _CFStreamGetStreamError((struct _CFStream *)stream);
+}
+
+static CFErrorRef _CFStreamCopyError(struct _CFStream *stream) {
+    if (!stream->error) {
+        return NULL;
+    } else if (_CFStreamGetCallBackPtr(stream)->version < 2) {
+        return _CFErrorFromStreamError(CFGetAllocator(stream), (CFStreamError *)(stream->error));
+    } else {
+        CFRetain(stream->error);
+        return stream->error;
+    }
+}
+
+CF_EXPORT CFErrorRef CFReadStreamCopyError(CFReadStreamRef stream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFReadStreamTypeID, CFErrorRef, stream, "streamError");
+    return _CFStreamCopyError((struct _CFStream *)stream);
+}
+
+CF_EXPORT CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream) {
+    return _CFStreamCopyError((struct _CFStream *)stream);
+    CF_OBJC_FUNCDISPATCH0(__kCFWriteStreamTypeID, CFErrorRef, stream, "streamError");
+}
+
+__private_extern__ Boolean _CFStreamOpen(struct _CFStream *stream) {
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    Boolean success, openComplete;
+    if (_CFStreamGetStatus(stream) != kCFStreamStatusNotOpen) {
+        return FALSE;
+    }
+    __CFBitSet(stream->flags, CALLING_CLIENT);
+    _CFStreamSetStatusCode(stream, kCFStreamStatusOpening);
+    if (cb->open) {
+        if (cb->version < 2) {
+            CFStreamError err = {0, 0};
+            success = ((_CFStreamCBOpenV1)(cb->open))(stream, &err, &openComplete, _CFStreamGetInfoPointer(stream));
+            if (err.error != 0) _CFStreamSetStreamError(stream, &err);
+        } else {
+            success = cb->open(stream, &(stream->error), &openComplete, _CFStreamGetInfoPointer(stream));
+        }
+    } else {
+        success = TRUE;
+        openComplete = TRUE;
+    }
+    if (openComplete) {
+        if (success) {
+            // 2957690 - Guard against the possibility that the stream has already signalled itself in to a later state (like AtEnd)
+            if (__CFStreamGetStatus(stream) == kCFStreamStatusOpening) {
+                _CFStreamSetStatusCode(stream, kCFStreamStatusOpen);
+            }
+            _CFStreamScheduleEvent(stream, kCFStreamEventOpenCompleted);
+        } else {
+            _CFStreamSetStatusCode(stream, kCFStreamStatusError);
+            _CFStreamScheduleEvent(stream, kCFStreamEventErrorOccurred);
+        }
+    }
+    __CFBitClear(stream->flags, CALLING_CLIENT);
+    return success;
+}
+
+CF_EXPORT Boolean CFReadStreamOpen(CFReadStreamRef stream) {
+    if(CF_IS_OBJC(__kCFReadStreamTypeID, stream)) {
+        CF_OBJC_VOIDCALL0(stream, "open");
+        return TRUE;
+    }
+    return _CFStreamOpen((struct _CFStream *)stream);
+}
+
+CF_EXPORT Boolean CFWriteStreamOpen(CFWriteStreamRef stream) {
+    if(CF_IS_OBJC(__kCFWriteStreamTypeID, stream)) {
+        CF_OBJC_VOIDCALL0(stream, "open");
+        return TRUE;
+    }
+    return _CFStreamOpen((struct _CFStream *)stream);
+}
+
+CF_EXPORT void CFReadStreamClose(CFReadStreamRef stream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFReadStreamTypeID, void, stream, "close");
+    _CFStreamClose((struct _CFStream *)stream);
+}
+
+CF_EXPORT void CFWriteStreamClose(CFWriteStreamRef stream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFWriteStreamTypeID, void, stream, "close");
+    _CFStreamClose((struct _CFStream *)stream);
+}
+
+CF_EXPORT Boolean CFReadStreamHasBytesAvailable(CFReadStreamRef readStream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFReadStreamTypeID, Boolean, readStream, "hasBytesAvailable");
+    struct _CFStream *stream = (struct _CFStream *)readStream;
+    CFStreamStatus status = _CFStreamGetStatus(stream);
+    const struct _CFStreamCallBacks *cb;
+    if (status != kCFStreamStatusOpen && status != kCFStreamStatusReading) {
+        return FALSE;
+    } 
+    cb  = _CFStreamGetCallBackPtr(stream);
+    if (cb->canRead == NULL) {
+        return TRUE;  // No way to know without trying....
+    } else {
+        Boolean result;
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        if (cb->version < 2) {
+            result = ((_CFStreamCBCanReadV1)(cb->canRead))((CFReadStreamRef)stream, _CFStreamGetInfoPointer(stream));
+        } else {
+            result = cb->canRead((CFReadStreamRef)stream, &(stream->error), _CFStreamGetInfoPointer(stream));
+            if (stream->error) {
+                _CFStreamSetStatusCode(stream, kCFStreamStatusError);
+                _CFStreamScheduleEvent(stream, kCFStreamEventErrorOccurred);
+            }
+        }
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        return result;
+    }
+}
+
+static void waitForOpen(struct _CFStream *stream);
+CFIndex CFReadStreamRead(CFReadStreamRef readStream, UInt8 *buffer, CFIndex bufferLength) {
+    CF_OBJC_FUNCDISPATCH2(__kCFReadStreamTypeID, CFIndex, readStream, "read:maxLength:", buffer, bufferLength);
+    struct _CFStream *stream = (struct _CFStream *)readStream;
+    CFStreamStatus status = _CFStreamGetStatus(stream);
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (status == kCFStreamStatusOpening) {
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        waitForOpen(stream);
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        status = _CFStreamGetStatus(stream);
+    }
+        
+    if (status != kCFStreamStatusOpen && status != kCFStreamStatusReading && status != kCFStreamStatusAtEnd) {
+        return -1;
+    } else  if (status == kCFStreamStatusAtEnd) {
+        return 0;
+    } else {
+        Boolean atEOF;
+        CFIndex bytesRead;
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        if (stream->client) {
+            stream->client->whatToSignal &= ~kCFStreamEventHasBytesAvailable;
+        }
+        _CFStreamSetStatusCode(stream, kCFStreamStatusReading);
+        if (cb->version < 2) {
+            CFStreamError err = {0, 0};
+            bytesRead = ((_CFStreamCBReadV1)(cb->read))((CFReadStreamRef)stream, buffer, bufferLength, &err, &atEOF, _CFStreamGetInfoPointer(stream));
+            if (err.error != 0) _CFStreamSetStreamError(stream, &err);
+        } else {
+            bytesRead = cb->read((CFReadStreamRef)stream, buffer, bufferLength, &(stream->error), &atEOF, _CFStreamGetInfoPointer(stream));
+        }
+        if (stream->error) {
+            bytesRead = -1;
+            _CFStreamSetStatusCode(stream, kCFStreamStatusError);
+            _CFStreamScheduleEvent(stream, kCFStreamEventErrorOccurred);
+        } else if (atEOF) {
+            _CFStreamSetStatusCode(stream, kCFStreamStatusAtEnd);
+            _CFStreamScheduleEvent(stream, kCFStreamEventEndEncountered);
+        } else {
+            _CFStreamSetStatusCode(stream, kCFStreamStatusOpen);
+        }
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        return bytesRead;
+    }
+}
+
+CF_EXPORT const UInt8 *CFReadStreamGetBuffer(CFReadStreamRef readStream, CFIndex maxBytesToRead, CFIndex *numBytesRead) {
+    if (CF_IS_OBJC(__kCFReadStreamTypeID, readStream)) {
+        uint8_t *bufPtr = NULL;
+        Boolean gotBytes;
+        CF_OBJC_CALL2(Boolean, gotBytes, readStream, "getBuffer:length:", &bufPtr, numBytesRead); 
+        if(gotBytes) {
+            return (const UInt8 *)bufPtr;
+        } else {
+            return NULL;
+        }
+    }
+    struct _CFStream *stream = (struct _CFStream *)readStream;
+    CFStreamStatus status = _CFStreamGetStatus(stream);
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    const UInt8 *buffer;
+    if (status == kCFStreamStatusOpening) {
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        waitForOpen(stream);
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        status = _CFStreamGetStatus(stream);
+    }
+    if (status != kCFStreamStatusOpen && status != kCFStreamStatusReading && status != kCFStreamStatusAtEnd) {
+        *numBytesRead = -1;
+        buffer = NULL;
+    } else  if (status == kCFStreamStatusAtEnd || cb->getBuffer == NULL) {
+        *numBytesRead = 0;
+        buffer = NULL;
+    } else {
+        Boolean atEOF;
+        Boolean hadBytes = stream->client && (stream->client->whatToSignal & kCFStreamEventHasBytesAvailable);
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        if (hadBytes) {
+            stream->client->whatToSignal &= ~kCFStreamEventHasBytesAvailable;
+        }
+        _CFStreamSetStatusCode(stream, kCFStreamStatusReading);
+        if (cb->version < 2) {
+            CFStreamError err = {0, 0};
+            buffer = ((_CFStreamCBGetBufferV1)(cb->getBuffer))((CFReadStreamRef)stream, maxBytesToRead, numBytesRead, &err, &atEOF, _CFStreamGetInfoPointer(stream));
+            if (err.error != 0) _CFStreamSetStreamError(stream, &err);
+        } else {
+            buffer = cb->getBuffer((CFReadStreamRef)stream, maxBytesToRead, numBytesRead, &(stream->error), &atEOF, _CFStreamGetInfoPointer(stream));
+        }
+        if (stream->error) {
+            *numBytesRead = -1;
+            _CFStreamSetStatusCode(stream, kCFStreamStatusError);
+            buffer = NULL;
+            _CFStreamScheduleEvent(stream, kCFStreamEventErrorOccurred);
+        } else if (atEOF) {
+            _CFStreamSetStatusCode(stream, kCFStreamStatusAtEnd);
+            _CFStreamScheduleEvent(stream, kCFStreamEventEndEncountered);
+        } else {
+            if (!buffer && hadBytes) {
+                stream->client->whatToSignal |= kCFStreamEventHasBytesAvailable;
+            }
+            _CFStreamSetStatusCode(stream, kCFStreamStatusOpen);
+        }
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+    }
+    return buffer;
+}
+
+CF_EXPORT Boolean CFWriteStreamCanAcceptBytes(CFWriteStreamRef writeStream) {
+    CF_OBJC_FUNCDISPATCH0(__kCFWriteStreamTypeID, Boolean, writeStream, "hasSpaceAvailable");
+    struct _CFStream *stream = (struct _CFStream *)writeStream;
+    CFStreamStatus status = _CFStreamGetStatus(stream);
+    const struct _CFStreamCallBacks *cb;
+    if (status != kCFStreamStatusOpen && status != kCFStreamStatusWriting) {
+        return FALSE;
+    } 
+    cb  = _CFStreamGetCallBackPtr(stream);
+    if (cb->canWrite == NULL) {
+        return TRUE;  // No way to know without trying....
+    } else {
+        Boolean result;
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        if (cb->version < 2) {
+            result = ((_CFStreamCBCanWriteV1)(cb->canWrite))((CFWriteStreamRef)stream, _CFStreamGetInfoPointer(stream));
+        } else {
+            result = cb->canWrite((CFWriteStreamRef)stream, &(stream->error), _CFStreamGetInfoPointer(stream));
+            if (stream->error) {
+                _CFStreamSetStatusCode(stream, kCFStreamStatusError);
+                _CFStreamScheduleEvent(stream, kCFStreamEventErrorOccurred);
+            }
+        }
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        return result;
+    }
+}
+
+CF_EXPORT CFIndex CFWriteStreamWrite(CFWriteStreamRef writeStream, const UInt8 *buffer, CFIndex bufferLength) {
+    CF_OBJC_FUNCDISPATCH2(__kCFWriteStreamTypeID, CFIndex, writeStream, "write:maxLength:", buffer, bufferLength);
+    struct _CFStream *stream = (struct _CFStream *)writeStream;
+    CFStreamStatus status = _CFStreamGetStatus(stream);
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (status == kCFStreamStatusOpening) {
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        waitForOpen(stream);
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        status = _CFStreamGetStatus(stream);
+    }
+    if (status != kCFStreamStatusOpen && status != kCFStreamStatusWriting) {
+        return -1;
+    } else {
+        CFIndex result;
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        _CFStreamSetStatusCode(stream, kCFStreamStatusWriting);
+        if (stream->client) {
+            stream->client->whatToSignal &= ~kCFStreamEventCanAcceptBytes;
+        }
+        if (cb->version < 2) {
+            CFStreamError err = {0, 0};
+            result = ((_CFStreamCBWriteV1)(cb->write))((CFWriteStreamRef)stream, buffer, bufferLength, &err, _CFStreamGetInfoPointer(stream));
+            if (err.error) _CFStreamSetStreamError(stream, &err);
+        } else {
+            result = cb->write((CFWriteStreamRef)stream, buffer, bufferLength, &(stream->error), _CFStreamGetInfoPointer(stream));
+        }
+        if (stream->error) {
+            _CFStreamSetStatusCode(stream, kCFStreamStatusError);
+            _CFStreamScheduleEvent(stream, kCFStreamEventErrorOccurred);
+        } else if (result == 0) {
+            _CFStreamSetStatusCode(stream, kCFStreamStatusAtEnd);
+            _CFStreamScheduleEvent(stream, kCFStreamEventEndEncountered);
+        } else {
+            _CFStreamSetStatusCode(stream, kCFStreamStatusOpen);
+        }
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        return result;
+    }
+}
+
+__private_extern__ CFTypeRef _CFStreamCopyProperty(struct _CFStream *stream, CFStringRef propertyName) {
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (cb->copyProperty == NULL) {
+        return NULL;
+    } else {
+        CFTypeRef result;
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        result = cb->copyProperty(stream, propertyName, _CFStreamGetInfoPointer(stream));
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        return result;
+    }
+}
+
+CF_EXPORT CFTypeRef CFReadStreamCopyProperty(CFReadStreamRef stream, CFStringRef propertyName) {
+    CF_OBJC_FUNCDISPATCH1(__kCFReadStreamTypeID, CFTypeRef, stream, "propertyForKey:", propertyName);
+    return _CFStreamCopyProperty((struct _CFStream *)stream, propertyName);
+}
+
+CF_EXPORT CFTypeRef CFWriteStreamCopyProperty(CFWriteStreamRef stream, CFStringRef propertyName) {
+    CF_OBJC_FUNCDISPATCH1(__kCFWriteStreamTypeID, CFTypeRef, stream, "propertyForKey:", propertyName);
+    return _CFStreamCopyProperty((struct _CFStream *)stream, propertyName);
+}
+
+__private_extern__ Boolean _CFStreamSetProperty(struct _CFStream *stream, CFStringRef prop, CFTypeRef val) {
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (cb->setProperty == NULL) {
+        return FALSE;
+    } else {
+        Boolean result;
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        result = cb->setProperty(stream, prop, val, _CFStreamGetInfoPointer(stream));
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+        return result;
+    }
+}
+
+CF_EXPORT
+Boolean CFReadStreamSetProperty(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue) {
+    CF_OBJC_FUNCDISPATCH2(__kCFReadStreamTypeID, Boolean, stream, "setProperty:forKey:", propertyValue, propertyName);
+    return _CFStreamSetProperty((struct _CFStream *)stream, propertyName, propertyValue);
+}
+
+CF_EXPORT
+Boolean CFWriteStreamSetProperty(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue) {
+    CF_OBJC_FUNCDISPATCH2(__kCFWriteStreamTypeID, Boolean, stream, "setProperty:forKey:", propertyValue, propertyName);
+    return _CFStreamSetProperty((struct _CFStream *)stream, propertyName, propertyValue);
+}
+
+static void _initializeClient(struct _CFStream *stream) {
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (!cb->schedule) return; // Do we wish to allow this?
+    stream->client = (struct _CFStreamClient *)CFAllocatorAllocate(CFGetAllocator(stream), sizeof(struct _CFStreamClient), 0);
+    memset(stream->client, 0, sizeof(struct _CFStreamClient));
+}
+
+/* If we add a setClient callback to the concrete stream callbacks, we must set/clear CALLING_CLIENT around it */
+__private_extern__ Boolean _CFStreamSetClient(struct _CFStream *stream, CFOptionFlags streamEvents, void (*clientCB)(struct _CFStream *, CFStreamEventType, void *), CFStreamClientContext *clientCallBackContext) {
+
+    Boolean removingClient = (streamEvents == kCFStreamEventNone || clientCB == NULL || clientCallBackContext == NULL);
+    if (removingClient) {
+        clientCB = NULL;
+        streamEvents = kCFStreamEventNone;
+        clientCallBackContext = NULL;
+    }
+    if (!stream->client) {
+        if (removingClient) {
+            // We have no client now, and we've been asked to add none???
+            return TRUE;
+        }
+        _initializeClient(stream);
+        if (!stream->client) {
+            // Asynch not supported
+            return FALSE;
+        }
+    }
+    if (stream->client->cb && stream->client->cbContext.release) {
+        stream->client->cbContext.release(stream->client->cbContext.info);
+    }
+    stream->client->cb = clientCB;
+    if (clientCallBackContext) {
+        stream->client->cbContext.version = clientCallBackContext->version;
+        stream->client->cbContext.retain = clientCallBackContext->retain;
+        stream->client->cbContext.release = clientCallBackContext->release;
+        stream->client->cbContext.copyDescription = clientCallBackContext->copyDescription;
+        stream->client->cbContext.info = (clientCallBackContext->retain && clientCallBackContext->info) ? clientCallBackContext->retain(clientCallBackContext->info) : clientCallBackContext->info;
+    } else {
+        stream->client->cbContext.retain = NULL;
+        stream->client->cbContext.release = NULL;
+        stream->client->cbContext.copyDescription = NULL;
+        stream->client->cbContext.info = NULL;
+    }
+    if (stream->client->when != streamEvents) {
+        const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+        stream->client->when = streamEvents;
+        if (cb->requestEvents) {
+            cb->requestEvents(stream, streamEvents, _CFStreamGetInfoPointer(stream));
+        }
+    }
+    return TRUE;
+}
+
+CF_EXPORT Boolean CFReadStreamSetClient(CFReadStreamRef readStream, CFOptionFlags streamEvents, CFReadStreamClientCallBack clientCB, CFStreamClientContext *clientContext) {
+    CF_OBJC_FUNCDISPATCH3(__kCFReadStreamTypeID, Boolean, readStream, "_setCFClientFlags:callback:context:", streamEvents, clientCB, clientContext);
+    streamEvents &= ~kCFStreamEventCanAcceptBytes;
+    return _CFStreamSetClient((struct _CFStream *)readStream, streamEvents, (void (*)(struct _CFStream *, CFStreamEventType, void *))clientCB, clientContext);
+}
+
+CF_EXPORT Boolean CFWriteStreamSetClient(CFWriteStreamRef writeStream, CFOptionFlags streamEvents, CFWriteStreamClientCallBack clientCB, CFStreamClientContext *clientContext) {
+    CF_OBJC_FUNCDISPATCH3(__kCFWriteStreamTypeID, Boolean, writeStream, "_setCFClientFlags:callback:context:", streamEvents, clientCB, clientContext);
+    streamEvents &= ~kCFStreamEventHasBytesAvailable;
+    return _CFStreamSetClient((struct _CFStream *)writeStream, streamEvents, (void (*)(struct _CFStream *, CFStreamEventType, void *))clientCB, clientContext);
+}
+
+CF_INLINE void *_CFStreamGetClient(struct _CFStream *stream) {
+    if (stream->client) return stream->client->cbContext.info;
+    else return NULL;
+}
+
+CF_EXPORT void *_CFReadStreamGetClient(CFReadStreamRef readStream) {
+    return _CFStreamGetClient((struct _CFStream *)readStream);
+}
+
+CF_EXPORT void *_CFWriteStreamGetClient(CFWriteStreamRef writeStream) {
+    return _CFStreamGetClient((struct _CFStream *)writeStream);
+}
+
+
+__private_extern__ void _CFStreamScheduleWithRunLoop(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode) {
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    
+    if (!stream->client) {
+        _initializeClient(stream);
+        if (!stream->client) return; // we don't support asynch.
+    }
+    
+    if (!stream->client->rlSource) {
+        
+        CFArrayRef key;
+        CFMutableArrayRef list;
+        CFTypeRef a[2];
+        
+        a[0] = runLoop;
+        a[1] = runLoopMode;
+        
+        key = CFArrayCreate(kCFAllocatorSystemDefault, a, sizeof(a) / sizeof(a[0]), &kCFTypeArrayCallBacks);
+
+        __CFSpinLock(&sSourceLock);
+        
+        if (!sSharedSources)
+            sSharedSources = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        
+        list = (CFMutableArrayRef)CFDictionaryGetValue(sSharedSources, key);
+        if (list) {
+            stream->client->rlSource = (CFRunLoopSourceRef)CFRetain(((struct _CFStream*)CFArrayGetValueAtIndex(list, 0))->client->rlSource);
+            CFRetain(list);
+        }
+        else {
+            CFRunLoopSourceContext ctxt = {
+                0,
+                NULL,
+                NULL,	// Do not use CFRetain/CFRelease callbacks here; that will cause a retain loop 
+                NULL,	// Do not use CFRetain/CFRelease callbacks here; that will cause a retain loop
+                (CFStringRef(*)(const void *))CFCopyDescription,
+		NULL,
+		NULL,
+                NULL,
+                NULL,
+                (void(*)(void *))_CFStreamSignalEventSynch
+            };
+
+            list = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+            CFDictionaryAddValue(sSharedSources, key, list);
+
+            ctxt.info = list;
+            
+            stream->client->rlSource = CFRunLoopSourceCreate(CFGetAllocator(stream), 0, &ctxt);
+            stream->client->whatToSignal = 0;
+            
+            CFRunLoopAddSource(runLoop, stream->client->rlSource, runLoopMode);
+        }
+        
+        CFArrayAppendValue(list, stream);
+        CFDictionaryAddValue(sSharedSources, stream, key);
+        
+        CFRelease(key);
+        CFRelease(list);
+        
+        __CFBitSet(stream->flags, SHARED_SOURCE);
+
+        __CFSpinUnlock(&sSourceLock);
+    }
+    else if (__CFBitIsSet(stream->flags, SHARED_SOURCE)) {
+        
+        CFArrayRef key;
+        CFMutableArrayRef list;
+        CFIndex c, i;
+        
+        CFAllocatorRef alloc = CFGetAllocator(stream);
+        CFRunLoopSourceContext ctxt = {
+            0,
+            (void *)stream,
+            NULL,														// Do not use CFRetain/CFRelease callbacks here; that will cause a retain loop 
+            NULL,														// Do not use CFRetain/CFRelease callbacks here; that will cause a retain loop
+            (CFStringRef(*)(const void *))CFCopyDescription,
+	    NULL,
+	    NULL,
+            NULL,
+            NULL,
+            (void(*)(void *))_CFStreamSignalEventSynch
+        };
+
+        __CFSpinLock(&sSourceLock);
+        
+        key = (CFArrayRef)CFRetain((CFTypeRef)CFDictionaryGetValue(sSharedSources, stream));
+        list = (CFMutableArrayRef)CFDictionaryGetValue(sSharedSources, key);
+        
+        c = CFArrayGetCount(list);
+        i = CFArrayGetFirstIndexOfValue(list, CFRangeMake(0, c), stream);
+        if (i != kCFNotFound) {
+            CFArrayRemoveValueAtIndex(list, i);
+            c--;
+        }
+        
+        if (!c) {
+            CFRunLoopRemoveSource((CFRunLoopRef)CFArrayGetValueAtIndex(key, 0), stream->client->rlSource, (CFStringRef)CFArrayGetValueAtIndex(key, 1));
+            CFRunLoopSourceInvalidate(stream->client->rlSource);
+            CFDictionaryRemoveValue(sSharedSources, key);
+        }
+        
+        CFDictionaryRemoveValue(sSharedSources, stream);
+        
+        CFRelease(stream->client->rlSource);
+        __CFBitClear(stream->flags, SHARED_SOURCE);
+
+        __CFSpinUnlock(&sSourceLock);
+        
+        stream->client->rlSource = CFRunLoopSourceCreate(alloc, 0, &ctxt);
+        
+        CFRunLoopAddSource((CFRunLoopRef)CFArrayGetValueAtIndex(key, 0), stream->client->rlSource, (CFStringRef)CFArrayGetValueAtIndex(key, 1));
+        
+        CFRelease(key);
+        
+        CFRunLoopAddSource(runLoop, stream->client->rlSource, runLoopMode);
+    } else {
+        CFRunLoopAddSource(runLoop, stream->client->rlSource, runLoopMode);
+    }
+    
+    if (!stream->client->runLoopsAndModes) {
+        stream->client->runLoopsAndModes = CFArrayCreateMutable(CFGetAllocator(stream), 0, &kCFTypeArrayCallBacks);
+    }
+    CFArrayAppendValue(stream->client->runLoopsAndModes, runLoop);
+    CFArrayAppendValue(stream->client->runLoopsAndModes, runLoopMode);
+    
+    if (cb->schedule) {
+        __CFBitSet(stream->flags, CALLING_CLIENT);
+        cb->schedule(stream, runLoop, runLoopMode, _CFStreamGetInfoPointer(stream));
+        __CFBitClear(stream->flags, CALLING_CLIENT);
+    }
+}
+
+CF_EXPORT void CFReadStreamScheduleWithRunLoop(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode) {
+    CF_OBJC_FUNCDISPATCH2(__kCFReadStreamTypeID, void, stream, "_scheduleInCFRunLoop:forMode:", runLoop, runLoopMode);
+    _CFStreamScheduleWithRunLoop((struct _CFStream *)stream, runLoop, runLoopMode);
+}
+
+CF_EXPORT void CFWriteStreamScheduleWithRunLoop(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode) {
+    CF_OBJC_FUNCDISPATCH2(__kCFWriteStreamTypeID, void, stream, "_scheduleInCFRunLoop:forMode:", runLoop, runLoopMode);
+    _CFStreamScheduleWithRunLoop((struct _CFStream *)stream, runLoop, runLoopMode);
+}
+
+
+__private_extern__ void _CFStreamUnscheduleFromRunLoop(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode) {
+    const struct _CFStreamCallBacks *cb = _CFStreamGetCallBackPtr(stream);
+    if (!stream->client) return;
+    if (!stream->client->rlSource) return;
+    
+    if (!__CFBitIsSet(stream->flags, SHARED_SOURCE)) {
+        CFRunLoopRemoveSource(runLoop, stream->client->rlSource, runLoopMode);
+    } else {
+        CFArrayRef key;
+        CFMutableArrayRef list;
+        CFIndex c, i;
+
+        __CFSpinLock(&sSourceLock);
+        
+        key = (CFArrayRef)CFDictionaryGetValue(sSharedSources, stream);
+        list = (CFMutableArrayRef)CFDictionaryGetValue(sSharedSources, key);
+        
+        c = CFArrayGetCount(list);
+        i = CFArrayGetFirstIndexOfValue(list, CFRangeMake(0, c), stream);
+        if (i != kCFNotFound) {
+            CFArrayRemoveValueAtIndex(list, i);
+            c--;
+        }
+        
+        if (!c) {
+            CFRunLoopRemoveSource(runLoop, stream->client->rlSource, runLoopMode);
+            CFRunLoopSourceInvalidate(stream->client->rlSource);
+            CFDictionaryRemoveValue(sSharedSources, key);
+        }
+        
+        CFDictionaryRemoveValue(sSharedSources, stream);
+        
+        CFRelease(stream->client->rlSource);
+        stream->client->rlSource = NULL;
+        __CFBitClear(stream->flags, SHARED_SOURCE);
+
+        __CFSpinUnlock(&sSourceLock);
+    }
+    
+    _CFStreamRemoveRunLoopAndModeFromArray(stream->client->runLoopsAndModes, runLoop, runLoopMode);
+
+    if (cb->unschedule) {
+        cb->unschedule(stream, runLoop, runLoopMode, _CFStreamGetInfoPointer(stream));
+    }
+}
+
+CF_EXPORT void CFReadStreamUnscheduleFromRunLoop(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode) {
+    CF_OBJC_FUNCDISPATCH2(__kCFReadStreamTypeID, void, stream, "_unscheduleFromCFRunLoop:forMode:", runLoop, runLoopMode);
+    _CFStreamUnscheduleFromRunLoop((struct _CFStream *)stream, runLoop, runLoopMode);
+}
+
+void CFWriteStreamUnscheduleFromRunLoop(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode) {
+    CF_OBJC_FUNCDISPATCH2(__kCFWriteStreamTypeID, void, stream, "_unscheduleFromCFRunLoop:forMode:", runLoop, runLoopMode);
+    _CFStreamUnscheduleFromRunLoop((struct _CFStream *)stream, runLoop, runLoopMode);
+}
+
+static void waitForOpen(struct _CFStream *stream) {
+    CFRunLoopRef runLoop = CFRunLoopGetCurrent();
+    CFStringRef privateMode = CFSTR("_kCFStreamBlockingOpenMode");
+    _CFStreamScheduleWithRunLoop(stream, runLoop, privateMode);
+    // We cannot call _CFStreamGetStatus, because that tries to set/clear CALLING_CLIENT, which should be set around this entire call (we're within a call from the client).  This should be o.k., because we're running the run loop, so our status code should be being updated in a timely fashion....
+    while (__CFStreamGetStatus(stream) == kCFStreamStatusOpening) {
+        CFRunLoopRunInMode(privateMode, 1e+20, TRUE);
+    }
+    _CFStreamUnscheduleFromRunLoop(stream, runLoop, privateMode);
+}
+
+CF_INLINE CFArrayRef _CFStreamGetRunLoopsAndModes(struct _CFStream *stream) {
+    if (stream->client) return stream->client->runLoopsAndModes;
+    else return NULL;
+}
+
+CF_EXPORT CFArrayRef _CFReadStreamGetRunLoopsAndModes(CFReadStreamRef readStream) {
+    return _CFStreamGetRunLoopsAndModes((struct _CFStream *)readStream);
+}
+
+CF_EXPORT CFArrayRef _CFWriteStreamGetRunLoopsAndModes(CFWriteStreamRef writeStream) {
+    return _CFStreamGetRunLoopsAndModes((struct _CFStream *)writeStream);
+}
+
+CF_EXPORT void CFReadStreamSignalEvent(CFReadStreamRef stream, CFStreamEventType event, const void *error) {
+    _CFStreamSignalEvent((struct _CFStream *)stream, event, (CFErrorRef)error, TRUE);
+}
+
+CF_EXPORT void CFWriteStreamSignalEvent(CFWriteStreamRef stream, CFStreamEventType event, const void *error) {
+    _CFStreamSignalEvent((struct _CFStream *)stream, event, (CFErrorRef)error, TRUE);
+}
+
+CF_EXPORT void _CFReadStreamSignalEventDelayed(CFReadStreamRef stream, CFStreamEventType event, const void *error) {
+    _CFStreamSignalEvent((struct _CFStream *)stream, event, (CFErrorRef)error, FALSE);
+}
+
+CF_EXPORT void _CFReadStreamClearEvent(CFReadStreamRef readStream, CFStreamEventType event) {
+    struct _CFStream *stream = (struct _CFStream *)readStream;
+    if (stream->client) {
+        stream->client->whatToSignal &= ~event;
+    }
+}
+
+CF_EXPORT void _CFWriteStreamSignalEventDelayed(CFWriteStreamRef stream, CFStreamEventType event, const void *error) {
+    _CFStreamSignalEvent((struct _CFStream *)stream, event, (CFErrorRef)error, FALSE);
+}
+
+CF_EXPORT void *CFReadStreamGetInfoPointer(CFReadStreamRef stream) {
+    return _CFStreamGetInfoPointer((struct _CFStream *)stream);
+}
+
+CF_EXPORT void *CFWriteStreamGetInfoPointer(CFWriteStreamRef stream) {
+    return _CFStreamGetInfoPointer((struct _CFStream *)stream);
+}
+
+/* CF_EXPORT */
+void _CFStreamSourceScheduleWithRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode)
+{
+    CFIndex count;
+    CFRange range;
+    
+    count = CFArrayGetCount(runLoopsAndModes);
+    range = CFRangeMake(0, count);
+    
+    while (range.length) {
+        
+        CFIndex i = CFArrayGetFirstIndexOfValue(runLoopsAndModes, range, runLoop);
+        
+        if (i == kCFNotFound)
+            break;
+            
+        if (CFEqual(CFArrayGetValueAtIndex(runLoopsAndModes, i + 1), runLoopMode))
+            return;
+        
+        range.location = i + 2;
+        range.length = count - range.location;
+    }
+
+	// Add the new values.
+    CFArrayAppendValue(runLoopsAndModes, runLoop);
+    CFArrayAppendValue(runLoopsAndModes, runLoopMode);
+    
+	// Schedule the source on the new loop and mode.
+    if (source)
+        CFRunLoopAddSource(runLoop, source, runLoopMode);
+}
+
+
+/* CF_EXPORT */
+void _CFStreamSourceUnscheduleFromRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode)
+{
+    CFIndex count;
+	CFRange range;
+    
+    count = CFArrayGetCount(runLoopsAndModes);
+    range = CFRangeMake(0, count);
+	
+	while (range.length) {
+    
+		CFIndex i = CFArrayGetFirstIndexOfValue(runLoopsAndModes, range, runLoop);
+		
+		// If not found, it's not scheduled on it.
+		if (i == kCFNotFound)
+			return;
+			
+		// Make sure it is scheduled in this mode.
+		if (CFEqual(CFArrayGetValueAtIndex(runLoopsAndModes, i + 1), runLoopMode)) {
+
+			// Remove mode and runloop from the list.
+            CFArrayReplaceValues(runLoopsAndModes, CFRangeMake(i, 2), NULL, 0);
+            
+            // Remove it from the runloop.
+            if (source)
+                CFRunLoopRemoveSource(runLoop, source, runLoopMode);
+			
+			return;
+		}
+		
+        range.location = i + 2;
+        range.length = count - range.location;
+	}
+}
+
+
+/* CF_EXPORT */
+void _CFStreamSourceScheduleWithAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes)
+{
+    CFIndex i, count = CFArrayGetCount(runLoopsAndModes);
+
+    if (!source)
+        return;
+
+    for (i = 0; i < count; i += 2) {
+
+        // Make sure it's scheduled on all the right loops and modes.
+        // Go through the array adding the source to all loops and modes.
+        CFRunLoopAddSource((CFRunLoopRef)CFArrayGetValueAtIndex(runLoopsAndModes, i),
+                            source,
+                            (CFStringRef)CFArrayGetValueAtIndex(runLoopsAndModes, i + 1));
+	}
+}
+
+
+/* CF_EXPORT */
+void _CFStreamSourceUncheduleFromAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes)
+{
+    CFIndex i, count = CFArrayGetCount(runLoopsAndModes);
+
+    if (!source)
+        return;
+
+    for (i = 0; i < count; i += 2) {
+
+        // Go through the array removing the source from all loops and modes.
+        CFRunLoopRemoveSource((CFRunLoopRef)CFArrayGetValueAtIndex(runLoopsAndModes, i),
+                              source,
+                              (CFStringRef)CFArrayGetValueAtIndex(runLoopsAndModes, i + 1));
+	}
+}
+
+Boolean _CFStreamRemoveRunLoopAndModeFromArray(CFMutableArrayRef runLoopsAndModes, CFRunLoopRef rl, CFStringRef mode) {
+    CFIndex idx, cnt;
+    Boolean found = FALSE;
+    
+    if (!runLoopsAndModes) return FALSE;
+
+    cnt = CFArrayGetCount(runLoopsAndModes);
+    for (idx = 0; idx + 1 < cnt; idx += 2) {
+        if (CFEqual(CFArrayGetValueAtIndex(runLoopsAndModes, idx), rl) && CFEqual(CFArrayGetValueAtIndex(runLoopsAndModes, idx + 1), mode)) {
+            CFArrayRemoveValueAtIndex(runLoopsAndModes, idx);
+            CFArrayRemoveValueAtIndex(runLoopsAndModes, idx);
+            found = TRUE;
+            break;
+        }
+    }
+    return found;
+}
+
+// Used by NSStream to properly allocate the bridged objects
+CF_EXPORT CFIndex _CFStreamInstanceSize(void) {
+    return sizeof(struct _CFStream);
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS
+
+__private_extern__ void __CFStreamCleanup(void) {
+    __CFSpinLock(&sSourceLock);
+    if (sSharedSources) {
+        CFIndex count = CFDictionaryGetCount(sSharedSources);
+        if (count == 0) {
+            // Only release if empty.  If it's still holding streams (which would be a client
+            // bug leak), freeing this dict would free the streams, which then need to access the
+            // dict to remove themselves, which leads to a deadlock.
+            CFRelease(sSharedSources);
+            sSharedSources = NULL;
+        } else
+            fprintf(stderr, "*** CFNetwork is shutting down, but %ld streams are still scheduled.\n", count);
+    }
+    __CFSpinUnlock(&sSourceLock);
+}
+
+#endif
+
+
diff --git a/CoreFoundation/CFStream.h b/CoreFoundation/CFStream.h
new file mode 100644
index 0000000..584cbef
--- /dev/null
+++ b/CoreFoundation/CFStream.h
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTREAM__)
+#define __COREFOUNDATION_CFSTREAM__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFSocket.h>
+#include <CoreFoundation/CFError.h>
+
+CF_EXTERN_C_BEGIN
+
+enum {
+    kCFStreamStatusNotOpen = 0,
+    kCFStreamStatusOpening,  /* open is in-progress */
+    kCFStreamStatusOpen,
+    kCFStreamStatusReading,
+    kCFStreamStatusWriting,
+    kCFStreamStatusAtEnd,    /* no further bytes can be read/written */
+    kCFStreamStatusClosed,
+    kCFStreamStatusError
+};
+typedef CFIndex CFStreamStatus;
+
+enum {
+    kCFStreamEventNone = 0,
+    kCFStreamEventOpenCompleted = 1,
+    kCFStreamEventHasBytesAvailable = 2,
+    kCFStreamEventCanAcceptBytes = 4, 
+    kCFStreamEventErrorOccurred = 8,
+    kCFStreamEventEndEncountered = 16
+};
+typedef CFOptionFlags CFStreamEventType;
+
+typedef struct {
+    CFIndex version;
+    void *info;
+    void *(*retain)(void *info);
+    void (*release)(void *info);
+    CFStringRef (*copyDescription)(void *info);
+} CFStreamClientContext;
+
+typedef struct __CFReadStream * CFReadStreamRef;
+typedef struct __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_EXPORT
+void CFStreamCreateBoundPair(CFAllocatorRef alloc, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream, CFIndex transferBufferSize);
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/* 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;
+#endif
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+
+CF_EXPORT const CFStringRef kCFStreamPropertyFileCurrentOffset AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;   // Value is a CFNumber
+
+#endif
+
+/* 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;
+
+/* 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);
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+CF_EXPORT
+void CFStreamCreatePairWithPeerSocketSignature(CFAllocatorRef alloc, const CFSocketSignature *signature, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream);
+#endif
+
+
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+CF_EXPORT
+CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/* 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);
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/* 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);
+#endif
+
+/* 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, you need to schedule a run loop on which that client
+   can be notified.  You may schedule multiple run loops (for instance, if you are 
+   using a thread pool).  The client callback will be triggered via one of the scheduled
+   run loops; 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);
+
+
+/* The following API is deprecated starting in 10.5; please use CFRead/WriteStreamCopyError(), above, instead */
+enum {
+    kCFStreamErrorDomainCustom = -1,      /* custom to the kind of stream in question */
+    kCFStreamErrorDomainPOSIX = 1,        /* POSIX errno; interpret using <sys/errno.h> */
+    kCFStreamErrorDomainMacOSStatus      /* OSStatus type from Carbon APIs; interpret using <MacTypes.h> */
+};
+typedef CFIndex CFStreamErrorDomain;
+
+typedef struct {
+    CFIndex domain; 
+    SInt32 error;
+} CFStreamError;
+CF_EXPORT
+CFStreamError CFReadStreamGetError(CFReadStreamRef stream);
+CF_EXPORT
+CFStreamError CFWriteStreamGetError(CFWriteStreamRef stream);
+
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFSTREAM__ */
diff --git a/CoreFoundation/CFStreamAbstract.h b/CoreFoundation/CFStreamAbstract.h
new file mode 100644
index 0000000..e800867
--- /dev/null
+++ b/CoreFoundation/CFStreamAbstract.h
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTREAMABSTRACT__)
+#define __COREFOUNDATION_CFSTREAMABSTRACT__ 1
+
+#include <CoreFoundation/CFStream.h>
+
+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
+CF_EXPORT
+CFArrayRef _CFReadStreamGetRunLoopsAndModes(CFReadStreamRef readStream);
+CF_EXPORT
+CFArrayRef _CFWriteStreamGetRunLoopsAndModes(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/CoreFoundation/CFStreamInternal.h b/CoreFoundation/CFStreamInternal.h
new file mode 100644
index 0000000..2eacd31
--- /dev/null
+++ b/CoreFoundation/CFStreamInternal.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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 <CoreFoundation/CFStreamAbstract.h>
+#include <CoreFoundation/CFStreamPriv.h>
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFRuntime.h>
+
+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.
+__private_extern__ CFErrorRef _CFErrorFromStreamError(CFAllocatorRef alloc, CFStreamError *err);
+__private_extern__ CFStreamError _CFStreamErrorFromError(CFErrorRef error);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFSTREAMINTERNAL__ */
+
+
diff --git a/CoreFoundation/CFStreamPriv.h b/CoreFoundation/CFStreamPriv.h
new file mode 100644
index 0000000..ae7099b
--- /dev/null
+++ b/CoreFoundation/CFStreamPriv.h
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTREAMPRIV__)
+#define __COREFOUNDATION_CFSTREAMPRIV__ 1
+
+#include <CoreFoundation/CFStream.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFRuntime.h>
+
+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 {
+    CFRuntimeBase _cfBase;
+    CFOptionFlags flags;  
+    CFErrorRef error; // if callBacks->version < 2, this is actually a pointer to a CFStreamError
+    struct _CFStreamClient *client;
+    void *info;
+    const struct _CFStreamCallBacks *callBacks;  // This will not exist (will not be allocated) if the callbacks are from our known, "blessed" set.
+    void *_reserved1;
+};
+
+
+CF_INLINE void *_CFStreamGetInfoPointer(struct _CFStream *stream) {
+    return stream->info;
+}
+
+
+// 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 defined (__MACH__)
+// This symbol is exported from CFNetwork (see CFSocketStream.i).  Only __MACH__ systems will
+// get this symbol from CoreFoundation.
+extern const int kCFStreamErrorDomainSSL;
+#endif //__MACH__
+
+/*
+ * 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);
+
+CF_EXPORT
+void __CFSocketSetReadBufferLength(CFSocketRef s, CFIndex length);
+
+CF_EXPORT
+void __CFSocketSetReadBufferTimeout(CFSocketRef s, CFTimeInterval timeout);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFSTREAMPRIV__ */
+
diff --git a/CoreFoundation/CFString.c b/CoreFoundation/CFString.c
new file mode 100644
index 0000000..4ac01e5
--- /dev/null
+++ b/CoreFoundation/CFString.c
@@ -0,0 +1,5838 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Ali Ozer
+        
+!!! For performance reasons, it's important that all functions marked CF_INLINE in this file are inlined.
+*/
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFDictionary.h>
+#include "CFStringEncodingConverterExt.h"
+#include "CFUniChar.h"
+#include "CFUnicodeDecomposition.h"
+#include "CFUnicodePrecomposition.h"
+#include "CFPriv.h"
+#include "CFInternal.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+#include <unistd.h>
+#else
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+extern size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+#if defined(__GNUC__)
+#define LONG_DOUBLE_SUPPORT 1
+#else
+#define LONG_DOUBLE_SUPPORT 0
+#endif
+
+
+
+#define USE_STRING_ROM 0
+
+
+#ifndef INSTRUMENT_SHARED_STRINGS
+#define INSTRUMENT_SHARED_STRINGS 0
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+__private_extern__
+#else
+CF_EXPORT const
+#endif
+CFStringRef __kCFLocaleCollatorID;
+
+#if INSTRUMENT_SHARED_STRINGS
+#include <sys/stat.h> /* for umask() */
+
+static void __CFRecordStringAllocationEvent(const char *encoding, const char *bytes, CFIndex byteCount) {
+    static CFSpinLock_t lock = CFSpinLockInit;
+    
+    if (memchr(bytes, '\n', byteCount)) return; //never record string allocation events for strings with newlines, because those confuse our parser and because they'll never go into the ROM
+    
+    __CFSpinLock(&lock);
+    static int fd;
+    if (! fd) {
+	extern char **_NSGetProgname(void);
+	const char *name = *_NSGetProgname();
+	if (! name) name = "UNKNOWN";
+	umask(0);
+	char path[1024];
+	sprintf(path, "/tmp/CFSharedStringInstrumentation_%s_%d.txt", name, getpid());
+	fd = open(path, O_WRONLY | O_APPEND | O_CREAT, 0666);
+	if (fd <= 0) {
+	    int error = errno;
+	    const char *errString = strerror(error);
+	    fprintf(stderr, "open() failed with error %d (%s)\n", error, errString);
+	}
+    }
+    if (fd > 0) {
+	char *buffer = NULL;
+	char formatString[256];
+	sprintf(formatString, "%%-8d\t%%-16s\t%%.%lds\n", byteCount);
+	int resultCount = asprintf(&buffer, formatString, getpid(), encoding, bytes);
+	if (buffer && resultCount > 0) write(fd, buffer, resultCount);
+	else puts("Couldn't record allocation event");
+	free(buffer);
+    }
+    __CFSpinUnlock(&lock);
+}
+#endif //INSTRUMENT_SHARED_STRINGS
+
+
+
+typedef Boolean (*UNI_CHAR_FUNC)(UInt32 flags, UInt8 ch, UniChar *unicodeChar);
+
+#if DEPLOYMENT_TARGET_MACOSX
+extern size_t malloc_good_size(size_t size);
+#endif
+extern void __CFStrConvertBytesToUnicode(const uint8_t *bytes, UniChar *buffer, CFIndex numChars);
+
+#if defined(DEBUG)
+
+// We put this into C & Pascal strings if we can't convert
+#define CONVERSIONFAILURESTR "CFString conversion failed"
+
+// We set this to true when purging the constant string table, so CFStringDeallocate doesn't assert
+static Boolean __CFConstantStringTableBeingFreed = false;
+
+#endif
+
+
+
+// This section is for CFString compatibility and other behaviors...
+
+static CFOptionFlags _CFStringCompatibilityMask = 0;
+
+#define Bug2967272 1
+
+void _CFStringSetCompatibility(CFOptionFlags mask) {
+    _CFStringCompatibilityMask |= mask;
+}
+
+CF_INLINE Boolean __CFStringGetCompatibility(CFOptionFlags mask) {
+    return (_CFStringCompatibilityMask & mask) == mask;
+}
+
+
+
+// Two constant strings used by CFString; these are initialized in CFStringInitialize
+CONST_STRING_DECL(kCFEmptyString, "")
+
+// This is separate for C++
+struct __notInlineMutable {
+    void *buffer;
+    CFIndex length;
+        CFIndex capacity;                           // Capacity in bytes
+    unsigned int hasGap:1;                      // Currently unused
+    unsigned int isFixedCapacity:1;
+    unsigned int isExternalMutable:1;
+    unsigned int capacityProvidedExternally:1;
+#if __LP64__
+    unsigned long desiredCapacity:60;
+#else
+    unsigned long desiredCapacity:28;
+#endif
+    CFAllocatorRef contentsAllocator;           // Optional
+};                             // The only mutable variant for CFString
+
+
+/* !!! Never do sizeof(CFString); the union is here just to make it easier to access some fields.
+*/
+struct __CFString {
+    CFRuntimeBase base;
+    union {	// In many cases the allocated structs are smaller than these
+	struct __inline1 {
+	    CFIndex length;
+        } inline1;                                      // Bytes follow the length
+	struct __notInlineImmutable1 {
+	    void *buffer;                               // Note that the buffer is in the same place for all non-inline variants of CFString
+	    CFIndex length;                             
+	    CFAllocatorRef contentsDeallocator;		// Optional; just the dealloc func is used
+	} notInlineImmutable1;                          // This is the usual not-inline immutable CFString
+	struct __notInlineImmutable2 {
+	    void *buffer;
+	    CFAllocatorRef contentsDeallocator;		// Optional; just the dealloc func is used
+	} notInlineImmutable2;                          // This is the not-inline immutable CFString when length is stored with the contents (first byte)
+	struct __notInlineMutable notInlineMutable;
+    } variants;
+};
+
+/* 
+I = is immutable
+E = not inline contents
+U = is Unicode
+N = has NULL byte
+L = has length byte
+D = explicit deallocator for contents (for mutable objects, allocator)
+C = length field is CFIndex (rather than UInt32); only meaningful for 64-bit, really
+    if needed this bit (valuable real-estate) can be given up for another bit elsewhere, since this info is needed just for 64-bit
+
+Also need (only for mutable)
+F = is fixed
+G = has gap
+Cap, DesCap = capacity
+
+B7 B6 B5 B4 B3 B2 B1 B0
+         U  N  L  C  I
+
+B6 B5
+ 0  0   inline contents
+ 0  1   E (freed with default allocator)
+ 1  0   E (not freed)
+ 1  1   E D
+
+!!! Note: Constant CFStrings use the bit patterns:
+C8 (11001000 = default allocator, not inline, not freed contents; 8-bit; has NULL byte; doesn't have length; is immutable)
+D0 (11010000 = default allocator, not inline, not freed contents; Unicode; is immutable)
+The bit usages should not be modified in a way that would effect these bit patterns.
+*/
+
+enum {
+    __kCFFreeContentsWhenDoneMask = 0x020,
+        __kCFFreeContentsWhenDone = 0x020,
+    __kCFContentsMask = 0x060,
+	__kCFHasInlineContents = 0x000,
+	__kCFNotInlineContentsNoFree = 0x040,		// Don't free
+	__kCFNotInlineContentsDefaultFree = 0x020,	// Use allocator's free function
+	__kCFNotInlineContentsCustomFree = 0x060,		// Use a specially provided free function
+    __kCFHasContentsAllocatorMask = 0x060,
+        __kCFHasContentsAllocator = 0x060,		// (For mutable strings) use a specially provided allocator
+    __kCFHasContentsDeallocatorMask = 0x060,
+        __kCFHasContentsDeallocator = 0x060,
+    __kCFIsMutableMask = 0x01,
+	__kCFIsMutable = 0x01,
+    __kCFIsUnicodeMask = 0x10,
+	__kCFIsUnicode = 0x10,
+    __kCFHasNullByteMask = 0x08,
+	__kCFHasNullByte = 0x08,
+    __kCFHasLengthByteMask = 0x04,
+	__kCFHasLengthByte = 0x04,
+    // !!! Bit 0x02 has been freed up
+};
+
+
+// !!! Assumptions:
+// Mutable strings are not inline
+// Compile-time constant strings are not inline
+// Mutable strings always have explicit length (but they might also have length byte and null byte)
+// If there is an explicit length, always use that instead of the length byte (length byte is useful for quickly returning pascal strings)
+// Never look at the length byte for the length; use __CFStrLength or __CFStrLength2
+
+/* The following set of functions and macros need to be updated on change to the bit configuration
+*/
+CF_INLINE Boolean __CFStrIsMutable(CFStringRef str)                 {return (str->base._cfinfo[CF_INFO_BITS] & __kCFIsMutableMask) == __kCFIsMutable;}
+CF_INLINE Boolean __CFStrIsInline(CFStringRef str)                  {return (str->base._cfinfo[CF_INFO_BITS] & __kCFContentsMask) == __kCFHasInlineContents;}
+CF_INLINE Boolean __CFStrFreeContentsWhenDone(CFStringRef str)      {return (str->base._cfinfo[CF_INFO_BITS] & __kCFFreeContentsWhenDoneMask) == __kCFFreeContentsWhenDone;}
+CF_INLINE Boolean __CFStrHasContentsDeallocator(CFStringRef str)    {return (str->base._cfinfo[CF_INFO_BITS] & __kCFHasContentsDeallocatorMask) == __kCFHasContentsDeallocator;}
+CF_INLINE Boolean __CFStrIsUnicode(CFStringRef str)                 {return (str->base._cfinfo[CF_INFO_BITS] & __kCFIsUnicodeMask) == __kCFIsUnicode;}
+CF_INLINE Boolean __CFStrIsEightBit(CFStringRef str)                {return (str->base._cfinfo[CF_INFO_BITS] & __kCFIsUnicodeMask) != __kCFIsUnicode;}
+CF_INLINE Boolean __CFStrHasNullByte(CFStringRef str)               {return (str->base._cfinfo[CF_INFO_BITS] & __kCFHasNullByteMask) == __kCFHasNullByte;}
+CF_INLINE Boolean __CFStrHasLengthByte(CFStringRef str)             {return (str->base._cfinfo[CF_INFO_BITS] & __kCFHasLengthByteMask) == __kCFHasLengthByte;}
+CF_INLINE Boolean __CFStrHasExplicitLength(CFStringRef str)         {return (str->base._cfinfo[CF_INFO_BITS] & (__kCFIsMutableMask | __kCFHasLengthByteMask)) != __kCFHasLengthByte;}	// Has explicit length if (1) mutable or (2) not mutable and no length byte
+CF_INLINE Boolean __CFStrIsConstant(CFStringRef str) {
+#if __LP64__
+    return str->base._rc == 0;
+#else
+    return (str->base._cfinfo[CF_RC_BITS]) == 0;
+#endif
+}
+
+CF_INLINE SInt32 __CFStrSkipAnyLengthByte(CFStringRef str)          {return ((str->base._cfinfo[CF_INFO_BITS] & __kCFHasLengthByteMask) == __kCFHasLengthByte) ? 1 : 0;}	// Number of bytes to skip over the length byte in the contents
+
+/* Returns ptr to the buffer (which might include the length byte)
+*/
+CF_INLINE const void *__CFStrContents(CFStringRef str) {
+    if (__CFStrIsInline(str)) {
+	return (const void *)(((uintptr_t)&(str->variants)) + (__CFStrHasExplicitLength(str) ? sizeof(CFIndex) : 0));
+    } else {	// Not inline; pointer is always word 2
+	return str->variants.notInlineImmutable1.buffer;
+    }
+}
+
+static CFAllocatorRef *__CFStrContentsDeallocatorPtr(CFStringRef str) {
+    return __CFStrHasExplicitLength(str) ? &(((CFMutableStringRef)str)->variants.notInlineImmutable1.contentsDeallocator) : &(((CFMutableStringRef)str)->variants.notInlineImmutable2.contentsDeallocator); }
+
+// Assumption: Called with immutable strings only, and on strings that are known to have a contentsDeallocator
+CF_INLINE CFAllocatorRef __CFStrContentsDeallocator(CFStringRef str) {
+    return *__CFStrContentsDeallocatorPtr(str); 
+}
+
+// Assumption: Called with immutable strings only, and on strings that are known to have a contentsDeallocator
+CF_INLINE void __CFStrSetContentsDeallocator(CFStringRef str, CFAllocatorRef contentsAllocator) {
+    *__CFStrContentsDeallocatorPtr(str) = contentsAllocator;
+}
+
+static CFAllocatorRef *__CFStrContentsAllocatorPtr(CFStringRef str) {
+    CFAssert(!__CFStrIsInline(str), __kCFLogAssertion, "Asking for contents allocator of inline string");
+    CFAssert(__CFStrIsMutable(str), __kCFLogAssertion, "Asking for contents allocator of an immutable string");
+    return (CFAllocatorRef *)&(str->variants.notInlineMutable.contentsAllocator);
+}
+
+// Assumption: Called with strings that have a contents allocator; also, contents allocator follows custom
+CF_INLINE CFAllocatorRef __CFStrContentsAllocator(CFMutableStringRef str) {
+    return *(__CFStrContentsAllocatorPtr(str));
+}
+
+// Assumption: Called with strings that have a contents allocator; also, contents allocator follows custom
+CF_INLINE void __CFStrSetContentsAllocator(CFMutableStringRef str, CFAllocatorRef alloc) {
+    *(__CFStrContentsAllocatorPtr(str)) = alloc;
+}
+
+/* Returns length; use __CFStrLength2 if contents buffer pointer has already been computed.
+*/
+CF_INLINE CFIndex __CFStrLength(CFStringRef str) {
+    if (__CFStrHasExplicitLength(str)) {
+	if (__CFStrIsInline(str)) {
+            return str->variants.inline1.length;
+	} else {
+            return str->variants.notInlineImmutable1.length;
+ 	}
+    } else {
+	return (CFIndex)(*((uint8_t *)__CFStrContents(str)));
+    }
+}
+
+CF_INLINE CFIndex __CFStrLength2(CFStringRef str, const void *buffer) {
+    if (__CFStrHasExplicitLength(str)) {
+        if (__CFStrIsInline(str)) {
+            return str->variants.inline1.length;
+	} else {
+            return str->variants.notInlineImmutable1.length;
+ 	}
+    } else {
+        return (CFIndex)(*((uint8_t *)buffer));
+    }
+}
+
+Boolean __CFStringIsMutable(CFStringRef str) {
+    return __CFStrIsMutable(str);
+}
+
+Boolean __CFStringIsEightBit(CFStringRef str) {
+    return __CFStrIsEightBit(str);
+}
+
+/* Sets the content pointer for immutable or mutable strings.
+*/
+CF_INLINE void __CFStrSetContentPtr(CFStringRef str, const void *p) {
+    // XXX_PCB catch all writes for mutable string case.
+    CF_WRITE_BARRIER_BASE_ASSIGN(__CFGetAllocator(str), str, ((CFMutableStringRef)str)->variants.notInlineImmutable1.buffer, (void *)p);
+}
+CF_INLINE void __CFStrSetInfoBits(CFStringRef str, UInt32 v)		{__CFBitfieldSetValue(((CFMutableStringRef)str)->base._cfinfo[CF_INFO_BITS], 6, 0, v);}
+
+CF_INLINE void __CFStrSetExplicitLength(CFStringRef str, CFIndex v) {
+    if (__CFStrIsInline(str)) {
+	((CFMutableStringRef)str)->variants.inline1.length = v;
+    } else {
+	((CFMutableStringRef)str)->variants.notInlineImmutable1.length = v;
+    }
+}
+
+CF_INLINE void __CFStrSetUnicode(CFMutableStringRef str)		    {str->base._cfinfo[CF_INFO_BITS] |= __kCFIsUnicode;}
+CF_INLINE void __CFStrClearUnicode(CFMutableStringRef str)		    {str->base._cfinfo[CF_INFO_BITS] &= ~__kCFIsUnicode;}
+CF_INLINE void __CFStrSetHasLengthAndNullBytes(CFMutableStringRef str)	    {str->base._cfinfo[CF_INFO_BITS] |= (__kCFHasLengthByte | __kCFHasNullByte);}
+CF_INLINE void __CFStrClearHasLengthAndNullBytes(CFMutableStringRef str)    {str->base._cfinfo[CF_INFO_BITS] &= ~(__kCFHasLengthByte | __kCFHasNullByte);}
+
+
+// Assumption: The following set of inlines (using str->variants.notInlineMutable) are called with mutable strings only
+CF_INLINE Boolean __CFStrIsFixed(CFStringRef str)   		{return str->variants.notInlineMutable.isFixedCapacity;}
+CF_INLINE Boolean __CFStrIsExternalMutable(CFStringRef str)	{return str->variants.notInlineMutable.isExternalMutable;}
+CF_INLINE Boolean __CFStrHasContentsAllocator(CFStringRef str)	{return (str->base._cfinfo[CF_INFO_BITS] & __kCFHasContentsAllocatorMask) == __kCFHasContentsAllocator;}
+CF_INLINE void __CFStrSetIsFixed(CFMutableStringRef str)		    {str->variants.notInlineMutable.isFixedCapacity = 1;}
+CF_INLINE void __CFStrSetIsExternalMutable(CFMutableStringRef str)	    {str->variants.notInlineMutable.isExternalMutable = 1;}
+CF_INLINE void __CFStrSetHasGap(CFMutableStringRef str)			    {str->variants.notInlineMutable.hasGap = 1;}
+
+// If capacity is provided externally, we only change it when we need to grow beyond it
+CF_INLINE Boolean __CFStrCapacityProvidedExternally(CFStringRef str)   		{return str->variants.notInlineMutable.capacityProvidedExternally;}
+CF_INLINE void __CFStrSetCapacityProvidedExternally(CFMutableStringRef str)	{str->variants.notInlineMutable.capacityProvidedExternally = 1;}
+CF_INLINE void __CFStrClearCapacityProvidedExternally(CFMutableStringRef str)	{str->variants.notInlineMutable.capacityProvidedExternally = 0;}
+
+// "Capacity" is stored in number of bytes, not characters. It indicates the total number of bytes in the contents buffer.
+CF_INLINE CFIndex __CFStrCapacity(CFStringRef str)				{return str->variants.notInlineMutable.capacity;}
+CF_INLINE void __CFStrSetCapacity(CFMutableStringRef str, CFIndex cap)		{str->variants.notInlineMutable.capacity = cap;}
+
+// "Desired capacity" is in number of characters; it is the client requested capacity; if fixed, it is the upper bound on the mutable string backing store.
+CF_INLINE CFIndex __CFStrDesiredCapacity(CFStringRef str)			{return str->variants.notInlineMutable.desiredCapacity;}
+CF_INLINE void __CFStrSetDesiredCapacity(CFMutableStringRef str, CFIndex size)	{str->variants.notInlineMutable.desiredCapacity = size;}
+
+
+static void *__CFStrAllocateMutableContents(CFMutableStringRef str, CFIndex size) {
+    void *ptr;
+    CFAllocatorRef alloc = (__CFStrHasContentsAllocator(str)) ? __CFStrContentsAllocator(str) : __CFGetAllocator(str);
+    ptr = CFAllocatorAllocate(alloc, size, 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(ptr, "CFString (store)");
+    return ptr;
+}
+
+static void __CFStrDeallocateMutableContents(CFMutableStringRef str, void *buffer) {
+    CFAllocatorRef alloc = (__CFStrHasContentsAllocator(str)) ? __CFStrContentsAllocator(str) : __CFGetAllocator(str);
+    if (CF_IS_COLLECTABLE_ALLOCATOR(alloc)) {
+        // GC:  for finalization safety, let collector reclaim the buffer in the next GC cycle.
+        auto_zone_release(__CFCollectableZone, buffer);
+    } else {
+        CFAllocatorDeallocate(alloc, buffer);
+    }
+}
+
+
+
+
+/* CFString specific init flags
+   Note that you cannot count on the external buffer not being copied.
+   Also, if you specify an external buffer, you should not change it behind the CFString's back.
+*/
+enum {
+    __kCFThinUnicodeIfPossible = 0x1000000,		/* See if the Unicode contents can be thinned down to 8-bit */
+    kCFStringPascal = 0x10000,				/* Indicating that the string data has a Pascal string structure (length byte at start) */
+    kCFStringNoCopyProvidedContents = 0x20000,		/* Don't copy the provided string contents if possible; free it when no longer needed */
+    kCFStringNoCopyNoFreeProvidedContents = 0x30000	/* Don't copy the provided string contents if possible; don't free it when no longer needed */
+};
+
+/* System Encoding.
+*/
+static CFStringEncoding __CFDefaultSystemEncoding = kCFStringEncodingInvalidId;
+static CFStringEncoding __CFDefaultFileSystemEncoding = kCFStringEncodingInvalidId;
+CFStringEncoding __CFDefaultEightBitStringEncoding = kCFStringEncodingInvalidId;
+
+CFStringEncoding CFStringGetSystemEncoding(void) {
+
+    if (__CFDefaultSystemEncoding == kCFStringEncodingInvalidId) {
+        const CFStringEncodingConverter *converter = NULL;
+#if DEPLOYMENT_TARGET_MACOSX
+            __CFDefaultSystemEncoding = kCFStringEncodingMacRoman; // MacRoman is built-in so always available
+#elif DEPLOYMENT_TARGET_WINDOWS
+            __CFDefaultSystemEncoding = kCFStringEncodingWindowsLatin1; // WinLatin1 is built-in so always available
+#elif DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+            __CFDefaultSystemEncoding = kCFStringEncodingISOLatin1; // a reasonable default
+#else // Solaris && HP-UX ?
+            __CFDefaultSystemEncoding = kCFStringEncodingISOLatin1; // a reasonable default
+#endif
+            converter = CFStringEncodingGetConverter(__CFDefaultSystemEncoding);
+
+		__CFSetCharToUniCharFunc(converter->encodingClass == kCFStringEncodingConverterCheapEightBit ? (UNI_CHAR_FUNC)converter->toUnicode : NULL);
+    }
+
+    return __CFDefaultSystemEncoding;
+}
+
+// Fast version for internal use
+
+CF_INLINE CFStringEncoding __CFStringGetSystemEncoding(void) {
+    if (__CFDefaultSystemEncoding == kCFStringEncodingInvalidId) (void)CFStringGetSystemEncoding();
+    return __CFDefaultSystemEncoding;
+}
+
+CFStringEncoding CFStringFileSystemEncoding(void) {
+    if (__CFDefaultFileSystemEncoding == kCFStringEncodingInvalidId) {
+#if DEPLOYMENT_TARGET_MACOSX
+        __CFDefaultFileSystemEncoding = kCFStringEncodingUTF8;
+#else
+        __CFDefaultFileSystemEncoding = CFStringGetSystemEncoding();
+#endif
+    }
+
+    return __CFDefaultFileSystemEncoding;
+}
+
+/* ??? Is returning length when no other answer is available the right thing?
+*/
+CFIndex CFStringGetMaximumSizeForEncoding(CFIndex length, CFStringEncoding encoding) {
+    if (encoding == kCFStringEncodingUTF8) {
+        return _CFExecutableLinkedOnOrAfter(CFSystemVersionPanther) ? (length * 3) : (length * 6); // 1 Unichar could expand to 3 bytes; we return 6 for older apps for compatibility
+    } else if ((encoding == kCFStringEncodingUTF32) || (encoding == kCFStringEncodingUTF32BE) || (encoding == kCFStringEncodingUTF32LE)) { // UTF-32
+        return length * sizeof(UTF32Char);
+    } else {
+        encoding &= 0xFFF; // Mask off non-base part
+    }
+    switch (encoding) {
+        case kCFStringEncodingUnicode:
+            return length * sizeof(UniChar);
+
+        case kCFStringEncodingNonLossyASCII:
+            return length * 6; // 1 Unichar could expand to 6 bytes
+
+        case kCFStringEncodingMacRoman:
+        case kCFStringEncodingWindowsLatin1:
+        case kCFStringEncodingISOLatin1:
+        case kCFStringEncodingNextStepLatin:
+        case kCFStringEncodingASCII:
+            return length / sizeof(uint8_t);
+
+        default:
+            return length / sizeof(uint8_t);
+    }
+}
+
+
+/* Returns whether the indicated encoding can be stored in 8-bit chars
+*/
+CF_INLINE Boolean __CFStrEncodingCanBeStoredInEightBit(CFStringEncoding encoding) {
+    switch (encoding & 0xFFF) { // just use encoding base
+        case kCFStringEncodingInvalidId:
+        case kCFStringEncodingUnicode:
+        case kCFStringEncodingNonLossyASCII:
+            return false;
+
+        case kCFStringEncodingMacRoman:
+        case kCFStringEncodingWindowsLatin1:
+        case kCFStringEncodingISOLatin1:
+        case kCFStringEncodingNextStepLatin:
+        case kCFStringEncodingASCII:
+            return true;
+
+        default: return false;
+    }
+}
+
+/* Returns the encoding used in eight bit CFStrings (can't be any encoding which isn't 1-to-1 with Unicode)
+   ??? Perhaps only ASCII fits the bill due to Unicode decomposition.
+*/
+CFStringEncoding __CFStringComputeEightBitStringEncoding(void) {
+    if (__CFDefaultEightBitStringEncoding == kCFStringEncodingInvalidId) {
+        CFStringEncoding systemEncoding = CFStringGetSystemEncoding();
+	if (systemEncoding == kCFStringEncodingInvalidId) { // We're right in the middle of querying system encoding from default database. Delaying to set until system encoding is determined.
+	    return kCFStringEncodingASCII;
+	} else if (__CFStrEncodingCanBeStoredInEightBit(systemEncoding)) {
+            __CFDefaultEightBitStringEncoding = systemEncoding;
+        } else {
+            __CFDefaultEightBitStringEncoding = kCFStringEncodingASCII;
+        }
+    }
+
+    return __CFDefaultEightBitStringEncoding;
+}
+
+/* Returns whether the provided bytes can be stored in ASCII
+*/
+CF_INLINE Boolean __CFBytesInASCII(const uint8_t *bytes, CFIndex len) {
+    while (len--) if ((uint8_t)(*bytes++) >= 128) return false;
+    return true;
+}
+
+/* Returns whether the provided 8-bit string in the specified encoding can be stored in an 8-bit CFString. 
+*/
+CF_INLINE Boolean __CFCanUseEightBitCFStringForBytes(const uint8_t *bytes, CFIndex len, CFStringEncoding encoding) {
+    if (encoding == __CFStringGetEightBitStringEncoding()) return true;
+    if (__CFStringEncodingIsSupersetOfASCII(encoding) && __CFBytesInASCII(bytes, len)) return true;
+    return false;
+}
+
+
+/* Returns whether a length byte can be tacked on to a string of the indicated length.
+*/
+CF_INLINE Boolean __CFCanUseLengthByte(CFIndex len) {
+#define __kCFMaxPascalStrLen 255	
+    return (len <= __kCFMaxPascalStrLen) ? true : false;
+}
+
+/* Various string assertions
+*/
+#define __CFAssertIsString(cf) __CFGenericValidateType(cf, __kCFStringTypeID)
+#define __CFAssertIndexIsInStringBounds(cf, idx) CFAssert3((idx) >= 0 && (idx) < __CFStrLength(cf), __kCFLogAssertion, "%s(): string index %d out of bounds (length %d)", __PRETTY_FUNCTION__, idx, __CFStrLength(cf))
+#define __CFAssertRangeIsInStringBounds(cf, idx, count) CFAssert4((idx) >= 0 && (idx + count) <= __CFStrLength(cf), __kCFLogAssertion, "%s(): string range %d,%d out of bounds (length %d)", __PRETTY_FUNCTION__, idx, count, __CFStrLength(cf))
+#define __CFAssertIsStringAndMutable(cf) {__CFGenericValidateType(cf, __kCFStringTypeID); CFAssert1(__CFStrIsMutable(cf), __kCFLogAssertion, "%s(): string not mutable", __PRETTY_FUNCTION__);}
+#define __CFAssertIsStringAndExternalMutable(cf) {__CFGenericValidateType(cf, __kCFStringTypeID); CFAssert1(__CFStrIsMutable(cf) && __CFStrIsExternalMutable(cf), __kCFLogAssertion, "%s(): string not external mutable", __PRETTY_FUNCTION__);}
+#define __CFAssertIsNotNegative(idx) CFAssert2(idx >= 0, __kCFLogAssertion, "%s(): index %d is negative", __PRETTY_FUNCTION__, idx)
+#define __CFAssertIfFixedLengthIsOK(cf, reqLen) CFAssert2(!__CFStrIsFixed(cf) || (reqLen <= __CFStrDesiredCapacity(cf)), __kCFLogAssertion, "%s(): length %d too large", __PRETTY_FUNCTION__, reqLen)
+
+
+/* Basic algorithm is to shrink memory when capacity is SHRINKFACTOR times the required capacity or to allocate memory when the capacity is less than GROWFACTOR times the required capacity.
+Additional complications are applied in the following order:
+- desiredCapacity, which is the minimum (except initially things can be at zero)
+- rounding up to factor of 8
+- compressing (to fit the number if 16 bits), which effectively rounds up to factor of 256
+- we need to make sure GROWFACTOR computation doesn't suffer from overflow issues on 32-bit, hence the casting to unsigned. Normally for required capacity of C bytes, the allocated space is (3C+1)/2. If C > ULONG_MAX/3, we instead simply return LONG_MAX
+*/
+#define SHRINKFACTOR(c) (c / 2)
+
+#if __LP64__
+#define GROWFACTOR(c) ((c * 3 + 1) / 2)
+#else
+#define GROWFACTOR(c) (((c) >= (ULONG_MAX / 3UL)) ? __CFMax(LONG_MAX - 4095, (c)) : (((unsigned long)c * 3 + 1) / 2))
+#endif
+
+CF_INLINE CFIndex __CFStrNewCapacity(CFMutableStringRef str, CFIndex reqCapacity, CFIndex capacity, Boolean leaveExtraRoom, CFIndex charSize) {
+    if (capacity != 0 || reqCapacity != 0) {	/* If initially zero, and space not needed, leave it at that... */
+        if ((capacity < reqCapacity) ||		/* We definitely need the room... */
+            (!__CFStrCapacityProvidedExternally(str) && 	/* Assuming we control the capacity... */
+		((reqCapacity < SHRINKFACTOR(capacity)) ||		/* ...we have too much room! */
+                 (!leaveExtraRoom && (reqCapacity < capacity))))) {	/* ...we need to eliminate the extra space... */
+            CFIndex newCapacity = leaveExtraRoom ? GROWFACTOR(reqCapacity) : reqCapacity;	/* Grow by 3/2 if extra room is desired */
+	    CFIndex desiredCapacity = __CFStrDesiredCapacity(str) * charSize;
+            if (newCapacity < desiredCapacity) {	/* If less than desired, bump up to desired */
+                newCapacity = desiredCapacity;
+            } else if (__CFStrIsFixed(str)) {		/* Otherwise, if fixed, no need to go above the desired (fixed) capacity */
+                newCapacity = __CFMax(desiredCapacity, reqCapacity);	/* !!! So, fixed is not really fixed, but "tight" */
+            }
+	    if (__CFStrHasContentsAllocator(str)) {	/* Also apply any preferred size from the allocator; should we do something for  */
+                newCapacity = CFAllocatorGetPreferredSizeForSize(__CFStrContentsAllocator(str), newCapacity, 0);
+#if defined(__APPLE__)
+            } else {
+                newCapacity = malloc_good_size(newCapacity);
+#endif
+            }
+            return newCapacity; // If packing: __CFStrUnpackNumber(__CFStrPackNumber(newCapacity));
+        }
+    }
+    return capacity;
+}
+
+
+/* rearrangeBlocks() rearranges the blocks of data within the buffer so that they are "evenly spaced". buffer is assumed to have enough room for the result.
+  numBlocks is current total number of blocks within buffer.
+  blockSize is the size of each block in bytes
+  ranges and numRanges hold the ranges that are no longer needed; ranges are stored sorted in increasing order, and don't overlap
+  insertLength is the final spacing between the remaining blocks
+
+Example: buffer = A B C D E F G H, blockSize = 1, ranges = { (2,1) , (4,2) }  (so we want to "delete" C and E F), fromEnd = NO
+if insertLength = 4, result = A B ? ? ? ? D ? ? ? ? G H
+if insertLength = 0, result = A B D G H
+
+Example: buffer = A B C D E F G H I J K L M N O P Q R S T U, blockSize = 1, ranges { (1,1), (3,1), (5,11), (17,1), (19,1) }, fromEnd = NO
+if insertLength = 3, result = A ? ? ? C ? ? ? E ? ? ? Q ? ? ? S ? ? ? U
+
+*/
+typedef struct _CFStringDeferredRange {
+    CFIndex beginning;
+    CFIndex length;
+    CFIndex shift;
+} CFStringDeferredRange;
+
+typedef struct _CFStringStackInfo {
+    CFIndex capacity;		// Capacity (if capacity == count, need to realloc to add another)
+    CFIndex count;			// Number of elements actually stored
+    CFStringDeferredRange *stack;
+    Boolean hasMalloced;	// Indicates "stack" is allocated and needs to be deallocated when done
+    char _padding[3];
+} CFStringStackInfo;
+
+CF_INLINE void pop (CFStringStackInfo *si, CFStringDeferredRange *topRange) {
+    si->count = si->count - 1;
+    *topRange = si->stack[si->count];
+}
+
+CF_INLINE void push (CFStringStackInfo *si, const CFStringDeferredRange *newRange) {
+    if (si->count == si->capacity) {
+        // increase size of the stack
+        si->capacity = (si->capacity + 4) * 2;
+        if (si->hasMalloced) {
+            si->stack = (CFStringDeferredRange *)CFAllocatorReallocate(kCFAllocatorSystemDefault, si->stack, si->capacity * sizeof(CFStringDeferredRange), 0);
+        } else {
+            CFStringDeferredRange *newStack = (CFStringDeferredRange *)CFAllocatorAllocate(kCFAllocatorSystemDefault, si->capacity * sizeof(CFStringDeferredRange), 0);
+            memmove(newStack, si->stack, si->count * sizeof(CFStringDeferredRange));
+            si->stack = newStack;
+            si->hasMalloced = true;
+        }
+    }
+    si->stack[si->count] = *newRange;
+    si->count = si->count + 1;
+}
+
+static void rearrangeBlocks(
+	uint8_t *buffer, 
+	CFIndex numBlocks, 
+	CFIndex blockSize,
+	const CFRange *ranges, 
+	CFIndex numRanges, 
+	CFIndex insertLength) {
+
+#define origStackSize 10
+    CFStringDeferredRange origStack[origStackSize];
+    CFStringStackInfo si = {origStackSize, 0, origStack, false, {0, 0, 0}};
+    CFStringDeferredRange currentNonRange = {0, 0, 0};
+    CFIndex currentRange = 0;
+    CFIndex amountShifted = 0;
+    
+    // must have at least 1 range left.
+    
+    while (currentRange < numRanges) {
+        currentNonRange.beginning = (ranges[currentRange].location + ranges[currentRange].length) * blockSize;
+        if ((numRanges - currentRange) == 1) {
+            // at the end.
+            currentNonRange.length = numBlocks * blockSize - currentNonRange.beginning;
+            if (currentNonRange.length == 0) break;
+        } else {
+            currentNonRange.length = (ranges[currentRange + 1].location * blockSize) - currentNonRange.beginning;
+        }
+        currentNonRange.shift = amountShifted + (insertLength * blockSize) - (ranges[currentRange].length * blockSize);
+        amountShifted = currentNonRange.shift;
+        if (amountShifted <= 0) {
+            // process current item and rest of stack
+            if (currentNonRange.shift && currentNonRange.length) memmove (&buffer[currentNonRange.beginning + currentNonRange.shift], &buffer[currentNonRange.beginning], currentNonRange.length);
+            while (si.count > 0) {
+                pop (&si, &currentNonRange);  // currentNonRange now equals the top element of the stack.	
+                if (currentNonRange.shift && currentNonRange.length) memmove (&buffer[currentNonRange.beginning + currentNonRange.shift], &buffer[currentNonRange.beginning], currentNonRange.length);
+            }
+        } else {
+            // add currentNonRange to stack.
+            push (&si, &currentNonRange);
+        }
+        currentRange++;
+    }
+    
+    // no more ranges.  if anything is on the stack, process.
+
+    while (si.count > 0) {
+        pop (&si, &currentNonRange);  // currentNonRange now equals the top element of the stack.	
+        if (currentNonRange.shift && currentNonRange.length) memmove (&buffer[currentNonRange.beginning + currentNonRange.shift], &buffer[currentNonRange.beginning], currentNonRange.length);
+    }
+    if (si.hasMalloced) CFAllocatorDeallocate (kCFAllocatorSystemDefault, si.stack);
+}
+
+/* See comments for rearrangeBlocks(); this is the same, but the string is assembled in another buffer (dstBuffer), so the algorithm is much easier. We also take care of the case where the source is not-Unicode but destination is. (The reverse case is not supported.)
+*/
+static void copyBlocks(
+	const uint8_t *srcBuffer, 
+        uint8_t *dstBuffer,
+	CFIndex srcLength, 
+        Boolean srcIsUnicode,
+        Boolean dstIsUnicode,
+	const CFRange *ranges, 
+	CFIndex numRanges, 
+	CFIndex insertLength) {
+        
+    CFIndex srcLocationInBytes = 0;	// in order to avoid multiplying all the time, this is in terms of bytes, not blocks
+    CFIndex dstLocationInBytes = 0;	// ditto
+    CFIndex srcBlockSize = srcIsUnicode ? sizeof(UniChar) : sizeof(uint8_t);
+    CFIndex insertLengthInBytes = insertLength * (dstIsUnicode ? sizeof(UniChar) : sizeof(uint8_t));
+    CFIndex rangeIndex = 0;
+    CFIndex srcToDstMultiplier = (srcIsUnicode == dstIsUnicode) ? 1 : (sizeof(UniChar) / sizeof(uint8_t));
+        
+    // Loop over the ranges, copying the range to be preserved (right before each range)
+    while (rangeIndex < numRanges) {
+        CFIndex srcLengthInBytes = ranges[rangeIndex].location * srcBlockSize - srcLocationInBytes;	// srcLengthInBytes is in terms of bytes, not blocks; represents length of region to be preserved
+        if (srcLengthInBytes > 0) {
+            if (srcIsUnicode == dstIsUnicode) {
+                memmove(dstBuffer + dstLocationInBytes, srcBuffer + srcLocationInBytes, srcLengthInBytes);
+            } else {
+                __CFStrConvertBytesToUnicode(srcBuffer + srcLocationInBytes, (UniChar *)(dstBuffer + dstLocationInBytes), srcLengthInBytes);
+            }
+        }
+        srcLocationInBytes += srcLengthInBytes + ranges[rangeIndex].length * srcBlockSize;	// Skip over the just-copied and to-be-deleted stuff
+        dstLocationInBytes += srcLengthInBytes * srcToDstMultiplier + insertLengthInBytes;
+        rangeIndex++;
+    }
+
+    // Do last range (the one beyond last range)
+    if (srcLocationInBytes < srcLength * srcBlockSize) {
+        if (srcIsUnicode == dstIsUnicode) {
+            memmove(dstBuffer + dstLocationInBytes, srcBuffer + srcLocationInBytes, srcLength * srcBlockSize - srcLocationInBytes);
+        } else {
+            __CFStrConvertBytesToUnicode(srcBuffer + srcLocationInBytes, (UniChar *)(dstBuffer + dstLocationInBytes), srcLength * srcBlockSize - srcLocationInBytes);
+        }
+    }
+}
+
+/* Call the callback; if it doesn't exist or returns false, then log
+*/
+static void __CFStringHandleOutOfMemory(CFTypeRef obj) {
+    CFStringRef msg = CFSTR("Out of memory. We suggest restarting the application. If you have an unsaved document, create a backup copy in Finder, then try to save.");
+    CFBadErrorCallBack cb = _CFGetOutOfMemoryErrorCallBack();
+    if (NULL == cb || !cb(obj, CFSTR("NS/CFString"), msg)) {
+	CFLog(kCFLogLevelCritical, CFSTR("%@"), msg);
+    }
+}
+
+/* Reallocates the backing store of the string to accomodate the new length. Space is reserved or characters are deleted as indicated by insertLength and the ranges in deleteRanges. The length is updated to reflect the new state. Will also maintain a length byte and a null byte in 8-bit strings. If length cannot fit in length byte, the space will still be reserved, but will be 0. (Hence the reason the length byte should never be looked at as length unless there is no explicit length.)
+*/
+static void __CFStringChangeSizeMultiple(CFMutableStringRef str, const CFRange *deleteRanges, CFIndex numDeleteRanges, CFIndex insertLength, Boolean makeUnicode) {
+    const uint8_t *curContents = (uint8_t *)__CFStrContents(str);
+    CFIndex curLength = curContents ? __CFStrLength2(str, curContents) : 0;
+    CFIndex newLength;
+    
+    // Compute new length of the string
+    if (numDeleteRanges == 1) {
+        newLength = curLength + insertLength - deleteRanges[0].length;
+    } else {
+        CFIndex cnt;
+        newLength = curLength + insertLength * numDeleteRanges;
+        for (cnt = 0; cnt < numDeleteRanges; cnt++) newLength -= deleteRanges[cnt].length;
+    }
+
+    __CFAssertIfFixedLengthIsOK(str, newLength);
+
+    if (newLength == 0) {
+        // An somewhat optimized code-path for this special case, with the following implicit values:
+        // newIsUnicode = false
+        // useLengthAndNullBytes = false
+        // newCharSize = sizeof(uint8_t)
+        // If the newCapacity happens to be the same as the old, we don't free the buffer; otherwise we just free it totally
+        // instead of doing a potentially useless reallocation (as the needed capacity later might turn out to be different anyway)
+        CFIndex curCapacity = __CFStrCapacity(str);
+        CFIndex newCapacity = __CFStrNewCapacity(str, 0, curCapacity, true, sizeof(uint8_t));
+        if (newCapacity != curCapacity) {	// If we're reallocing anyway (larger or smaller --- larger could happen if desired capacity was changed in the meantime), let's just free it all
+            if (curContents) __CFStrDeallocateMutableContents(str, (uint8_t *)curContents);
+            __CFStrSetContentPtr(str, NULL);
+            __CFStrSetCapacity(str, 0);
+            __CFStrClearCapacityProvidedExternally(str);
+            __CFStrClearHasLengthAndNullBytes(str);
+            if (!__CFStrIsExternalMutable(str)) __CFStrClearUnicode(str);	// External mutable implies Unicode
+        } else {
+            if (!__CFStrIsExternalMutable(str)) {
+                __CFStrClearUnicode(str);
+                if (curCapacity >= (int)(sizeof(uint8_t) * 2)) {	// If there's room 
+                    __CFStrSetHasLengthAndNullBytes(str);
+                    ((uint8_t *)curContents)[0] = ((uint8_t *)curContents)[1] = 0;
+                } else {
+                    __CFStrClearHasLengthAndNullBytes(str);
+                }
+            }
+        }
+        __CFStrSetExplicitLength(str, 0);
+    } else {	/* This else-clause assumes newLength > 0 */
+        Boolean oldIsUnicode = __CFStrIsUnicode(str);
+        Boolean newIsUnicode = makeUnicode || (oldIsUnicode /* && (newLength > 0) - implicit */ ) || __CFStrIsExternalMutable(str);
+        CFIndex newCharSize = newIsUnicode ? sizeof(UniChar) : sizeof(uint8_t);
+        Boolean useLengthAndNullBytes = !newIsUnicode /* && (newLength > 0) - implicit */;
+        CFIndex numExtraBytes = useLengthAndNullBytes ? 2 : 0;	/* 2 extra bytes to keep the length byte & null... */
+        CFIndex curCapacity = __CFStrCapacity(str);
+        CFIndex newCapacity = __CFStrNewCapacity(str, newLength * newCharSize + numExtraBytes, curCapacity, true, newCharSize);
+        Boolean allocNewBuffer = (newCapacity != curCapacity) || (curLength > 0 && !oldIsUnicode && newIsUnicode);	/* We alloc new buffer if oldIsUnicode != newIsUnicode because the contents have to be copied */
+	uint8_t *newContents;
+	if (allocNewBuffer) {
+	    newContents = (uint8_t *)__CFStrAllocateMutableContents(str, newCapacity);
+	    if (!newContents) {	    // Try allocating without extra room
+		newCapacity = __CFStrNewCapacity(str, newLength * newCharSize + numExtraBytes, curCapacity, false, newCharSize);
+		newContents = (uint8_t *)__CFStrAllocateMutableContents(str, newCapacity);
+		if (!newContents) {
+		    __CFStringHandleOutOfMemory(str);
+		    // Ideally control doesn't come here at all since we expect the above call to raise an exception.
+		    // If control comes here, there isn't much we can do.
+		}
+	    }
+	} else {
+	    newContents = (uint8_t *)curContents;
+	}
+
+        Boolean hasLengthAndNullBytes = __CFStrHasLengthByte(str);
+    
+        CFAssert1(hasLengthAndNullBytes == __CFStrHasNullByte(str), __kCFLogAssertion, "%s(): Invalid state in 8-bit string", __PRETTY_FUNCTION__);
+    
+        if (hasLengthAndNullBytes) curContents++;
+        if (useLengthAndNullBytes) newContents++;
+    
+        if (curContents) {
+            if (oldIsUnicode == newIsUnicode) {
+                if (newContents == curContents) {
+                    rearrangeBlocks(newContents, curLength, newCharSize, deleteRanges, numDeleteRanges, insertLength);
+                } else {
+                    copyBlocks(curContents, newContents, curLength, oldIsUnicode, newIsUnicode, deleteRanges, numDeleteRanges, insertLength);
+                }
+            } else if (newIsUnicode) {	/* this implies we have a new buffer */
+                copyBlocks(curContents, newContents, curLength, oldIsUnicode, newIsUnicode, deleteRanges, numDeleteRanges, insertLength);
+            }
+            if (hasLengthAndNullBytes) curContents--;	/* Undo the damage from above */
+            if (allocNewBuffer && __CFStrFreeContentsWhenDone(str)) __CFStrDeallocateMutableContents(str, (void *)curContents);
+        }
+    
+        if (!newIsUnicode) {
+            if (useLengthAndNullBytes) {
+                newContents[newLength] = 0;	/* Always have null byte, if not unicode */
+                newContents--;	/* Undo the damage from above */
+                newContents[0] = __CFCanUseLengthByte(newLength) ? (uint8_t)newLength : 0;
+                if (!hasLengthAndNullBytes) __CFStrSetHasLengthAndNullBytes(str);
+            } else {
+                if (hasLengthAndNullBytes) __CFStrClearHasLengthAndNullBytes(str);
+            }
+            if (oldIsUnicode) __CFStrClearUnicode(str);
+        } else {	// New is unicode...
+            if (!oldIsUnicode) __CFStrSetUnicode(str);
+            if (hasLengthAndNullBytes) __CFStrClearHasLengthAndNullBytes(str);
+        }
+        __CFStrSetExplicitLength(str, newLength);
+    
+        if (allocNewBuffer) {
+            __CFStrSetCapacity(str, newCapacity);
+            __CFStrClearCapacityProvidedExternally(str);
+            __CFStrSetContentPtr(str, newContents);
+        }
+    }
+}
+
+/* Same as above, but takes one range (very common case)
+*/
+CF_INLINE void __CFStringChangeSize(CFMutableStringRef str, CFRange range, CFIndex insertLength, Boolean makeUnicode) {
+    __CFStringChangeSizeMultiple(str, &range, 1, insertLength, makeUnicode);
+}
+
+
+#if defined(DEBUG)
+static Boolean __CFStrIsConstantString(CFStringRef str);
+#endif
+
+static void __CFStringDeallocate(CFTypeRef cf) {
+    CFStringRef str = (CFStringRef)cf;
+
+    // If in DEBUG mode, check to see if the string a CFSTR, and complain.
+    CFAssert1(__CFConstantStringTableBeingFreed || !__CFStrIsConstantString((CFStringRef)cf), __kCFLogAssertion, "Tried to deallocate CFSTR(\"%@\")", str);
+
+    if (!__CFStrIsInline(str)) {
+        uint8_t *contents;
+	Boolean isMutable = __CFStrIsMutable(str);
+        if (__CFStrFreeContentsWhenDone(str) && (contents = (uint8_t *)__CFStrContents(str))) {
+            if (isMutable) {
+	        __CFStrDeallocateMutableContents((CFMutableStringRef)str, contents);
+	    } else {
+		if (__CFStrHasContentsDeallocator(str)) {
+                    CFAllocatorRef contentsDeallocator = __CFStrContentsDeallocator(str);
+		    CFAllocatorDeallocate(contentsDeallocator, contents);
+		    CFRelease(contentsDeallocator);
+		} else {
+		    CFAllocatorRef alloc = __CFGetAllocator(str);
+		    CFAllocatorDeallocate(alloc, contents);
+		}
+	    }
+	}
+	if (isMutable && __CFStrHasContentsAllocator(str)) CFRelease(__CFStrContentsAllocator((CFMutableStringRef)str));
+    }
+}
+
+static Boolean __CFStringEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFStringRef str1 = (CFStringRef)cf1;
+    CFStringRef str2 = (CFStringRef)cf2;
+    const uint8_t *contents1;
+    const uint8_t *contents2;
+    CFIndex len1;
+
+    /* !!! We do not need IsString assertions, as the CFBase runtime assures this */
+    /* !!! We do not need == test, as the CFBase runtime assures this */
+
+    contents1 = (uint8_t *)__CFStrContents(str1);
+    contents2 = (uint8_t *)__CFStrContents(str2);
+    len1 = __CFStrLength2(str1, contents1);
+
+    if (len1 != __CFStrLength2(str2, contents2)) return false;
+
+    contents1 += __CFStrSkipAnyLengthByte(str1);
+    contents2 += __CFStrSkipAnyLengthByte(str2);
+
+    if (__CFStrIsEightBit(str1) && __CFStrIsEightBit(str2)) {
+        return memcmp((const char *)contents1, (const char *)contents2, len1) ? false : true;
+    } else if (__CFStrIsEightBit(str1)) {	/* One string has Unicode contents */
+        CFStringInlineBuffer buf;
+	CFIndex buf_idx = 0;
+
+        CFStringInitInlineBuffer(str1, &buf, CFRangeMake(0, len1));
+	for (buf_idx = 0; buf_idx < len1; buf_idx++) {
+	    if (__CFStringGetCharacterFromInlineBufferQuick(&buf, buf_idx) != ((UniChar *)contents2)[buf_idx]) return false;
+  	}
+    } else if (__CFStrIsEightBit(str2)) {	/* One string has Unicode contents */
+        CFStringInlineBuffer buf;
+	CFIndex buf_idx = 0;
+
+        CFStringInitInlineBuffer(str2, &buf, CFRangeMake(0, len1));
+        for (buf_idx = 0; buf_idx < len1; buf_idx++) {
+            if (__CFStringGetCharacterFromInlineBufferQuick(&buf, buf_idx) != ((UniChar *)contents1)[buf_idx]) return false;
+        }
+    } else {					/* Both strings have Unicode contents */
+	CFIndex idx;
+        for (idx = 0; idx < len1; idx++) {
+            if (((UniChar *)contents1)[idx] != ((UniChar *)contents2)[idx]) return false;
+        }
+    }
+    return true;
+}
+
+
+/* String hashing: Should give the same results whatever the encoding; so we hash UniChars.
+If the length is less than or equal to 96, then the hash function is simply the 
+following (n is the nth UniChar character, starting from 0):
+   
+  hash(-1) = length
+  hash(n) = hash(n-1) * 257 + unichar(n);
+  Hash = hash(length-1) * ((length & 31) + 1)
+
+If the length is greater than 96, then the above algorithm applies to 
+characters 0..31, (length/2)-16..(length/2)+15, and length-32..length-1, inclusive;
+thus the first, middle, and last 32 characters.
+
+Note that the loops below are unrolled; and: 257^2 = 66049; 257^3 = 16974593; 257^4 = 4362470401;  67503105 is 257^4 - 256^4
+If hashcode is changed from UInt32 to something else, this last piece needs to be readjusted.  
+!!! We haven't updated for LP64 yet
+
+NOTE: The hash algorithm used to be duplicated in CF and Foundation; but now it should only be in the four functions below.
+
+Hash function was changed between Panther and Tiger, and Tiger and Leopard.
+*/
+#define HashEverythingLimit 96
+
+#define HashNextFourUniChars(accessStart, accessEnd, pointer) \
+    {result = result * 67503105 + (accessStart 0 accessEnd) * 16974593  + (accessStart 1 accessEnd) * 66049  + (accessStart 2 accessEnd) * 257 + (accessStart 3 accessEnd); pointer += 4;}
+
+#define HashNextUniChar(accessStart, accessEnd, pointer) \
+    {result = result * 257 + (accessStart 0 accessEnd); pointer++;}
+
+
+/* In this function, actualLen is the length of the original string; but len is the number of characters in buffer. The buffer is expected to contain the parts of the string relevant to hashing.
+*/
+CF_INLINE CFHashCode __CFStrHashCharacters(const UniChar *uContents, CFIndex len, CFIndex actualLen) {
+    CFHashCode result = actualLen;
+    if (len <= HashEverythingLimit) {
+        const UniChar *end4 = uContents + (len & ~3);
+        const UniChar *end = uContents + len;
+        while (uContents < end4) HashNextFourUniChars(uContents[, ], uContents); 	// First count in fours
+        while (uContents < end) HashNextUniChar(uContents[, ], uContents);		// Then for the last <4 chars, count in ones...
+    } else {
+        const UniChar *contents, *end;
+	contents = uContents;
+        end = contents + 32;
+        while (contents < end) HashNextFourUniChars(contents[, ], contents);
+	contents = uContents + (len >> 1) - 16;
+        end = contents + 32;
+        while (contents < end) HashNextFourUniChars(contents[, ], contents);
+	end = uContents + len;
+        contents = end - 32;
+        while (contents < end) HashNextFourUniChars(contents[, ], contents);
+    }
+    return result + (result << (actualLen & 31));
+}
+
+/* This hashes cString in the eight bit string encoding. It also includes the little debug-time sanity check.
+*/
+CF_INLINE CFHashCode __CFStrHashEightBit(const uint8_t *cContents, CFIndex len) {
+#if defined(DEBUG)
+    if (!__CFCharToUniCharFunc) {	// A little sanity verification: If this is not set, trying to hash high byte chars would be a bad idea
+        CFIndex cnt;
+        Boolean err = false;
+        if (len <= HashEverythingLimit) {
+            for (cnt = 0; cnt < len; cnt++) if (cContents[cnt] >= 128) err = true;
+        } else {
+            for (cnt = 0; cnt < 32; cnt++) if (cContents[cnt] >= 128) err = true;
+            for (cnt = (len >> 1) - 16; cnt < (len >> 1) + 16; cnt++) if (cContents[cnt] >= 128) err = true;
+            for (cnt = (len - 32); cnt < len; cnt++) if (cContents[cnt] >= 128) err = true;
+        }
+        if (err) {
+            // Can't do log here, as it might be too early
+            fprintf(stderr, "Warning: CFHash() attempting to hash CFString containing high bytes before properly initialized to do so\n");
+        }
+    }
+#endif
+    CFHashCode result = len;
+    if (len <= HashEverythingLimit) {
+        const uint8_t *end4 = cContents + (len & ~3);
+        const uint8_t *end = cContents + len;
+        while (cContents < end4) HashNextFourUniChars(__CFCharToUniCharTable[cContents[, ]], cContents); 	// First count in fours
+        while (cContents < end) HashNextUniChar(__CFCharToUniCharTable[cContents[, ]], cContents);		// Then for the last <4 chars, count in ones...
+    } else {
+	const uint8_t *contents, *end;
+	contents = cContents;
+        end = contents + 32;
+        while (contents < end) HashNextFourUniChars(__CFCharToUniCharTable[contents[, ]], contents);
+	contents = cContents + (len >> 1) - 16;
+        end = contents + 32;
+        while (contents < end) HashNextFourUniChars(__CFCharToUniCharTable[contents[, ]], contents);
+	end = cContents + len;
+        contents = end - 32;
+        while (contents < end) HashNextFourUniChars(__CFCharToUniCharTable[contents[, ]], contents);
+    }
+    return result + (result << (len & 31));
+}
+
+CFHashCode CFStringHashISOLatin1CString(const uint8_t *bytes, CFIndex len) {
+    CFHashCode result = len;
+    if (len <= HashEverythingLimit) {
+        const uint8_t *end4 = bytes + (len & ~3);
+        const uint8_t *end = bytes + len;
+        while (bytes < end4) HashNextFourUniChars(bytes[, ], bytes); 	// First count in fours
+        while (bytes < end) HashNextUniChar(bytes[, ], bytes);		// Then for the last <4 chars, count in ones...
+    } else {
+        const uint8_t *contents, *end;
+	contents = bytes;
+        end = contents + 32;
+        while (contents < end) HashNextFourUniChars(contents[, ], contents);
+	contents = bytes + (len >> 1) - 16;
+        end = contents + 32;
+        while (contents < end) HashNextFourUniChars(contents[, ], contents);
+	end = bytes + len;
+        contents = end - 32;
+        while (contents < end) HashNextFourUniChars(contents[, ], contents);
+    }
+    return result + (result << (len & 31));
+}
+
+CFHashCode CFStringHashCString(const uint8_t *bytes, CFIndex len) {
+    return __CFStrHashEightBit(bytes, len);
+}
+
+CFHashCode CFStringHashCharacters(const UniChar *characters, CFIndex len) {
+    return __CFStrHashCharacters(characters, len, len);
+}
+
+/* This is meant to be called from NSString or subclassers only. It is an error for this to be called without the ObjC runtime or an argument which is not an NSString or subclass. It can be called with NSCFString, although that would be inefficient (causing indirection) and won't normally happen anyway, as NSCFString overrides hash.
+*/
+CFHashCode CFStringHashNSString(CFStringRef str) {
+    UniChar buffer[HashEverythingLimit];
+    CFIndex bufLen;		// Number of characters in the buffer for hashing
+    CFIndex len = 0;	// Actual length of the string
+    
+    CF_OBJC_CALL0(CFIndex, len, str, "length");
+   if (len <= HashEverythingLimit) {
+        CF_OBJC_VOIDCALL2(str, "getCharacters:range:", buffer, CFRangeMake(0, len));
+        bufLen = len;
+    } else {
+        CF_OBJC_VOIDCALL2(str, "getCharacters:range:", buffer, CFRangeMake(0, 32));
+        CF_OBJC_VOIDCALL2(str, "getCharacters:range:", buffer+32, CFRangeMake((len >> 1) - 16, 32));
+        CF_OBJC_VOIDCALL2(str, "getCharacters:range:", buffer+64, CFRangeMake(len - 32, 32));
+        bufLen = HashEverythingLimit;
+    }
+    return __CFStrHashCharacters(buffer, bufLen, len);
+}
+
+CFHashCode __CFStringHash(CFTypeRef cf) {
+    /* !!! We do not need an IsString assertion here, as this is called by the CFBase runtime only */
+    CFStringRef str = (CFStringRef)cf;
+    const uint8_t *contents = (uint8_t *)__CFStrContents(str);
+    CFIndex len = __CFStrLength2(str, contents);
+
+    if (__CFStrIsEightBit(str)) {
+        contents += __CFStrSkipAnyLengthByte(str);
+        return __CFStrHashEightBit(contents, len);
+    } else {
+        return __CFStrHashCharacters((const UniChar *)contents, len, len);
+    }
+}
+
+
+static CFStringRef __CFStringCopyDescription(CFTypeRef cf) {
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFString %p [%p]>{contents = \"%@\"}"), cf, __CFGetAllocator(cf), cf);
+}
+
+static CFStringRef __CFStringCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    return (CFStringRef)CFStringCreateCopy(__CFGetAllocator(cf), (CFStringRef)cf);
+}
+
+static CFTypeID __kCFStringTypeID = _kCFRuntimeNotATypeID;
+
+typedef CFTypeRef (*CF_STRING_CREATE_COPY)(CFAllocatorRef alloc, CFTypeRef theString);
+
+static const CFRuntimeClass __CFStringClass = {
+    0,
+    "CFString",
+    NULL,      // init
+    (CF_STRING_CREATE_COPY)CFStringCreateCopy,
+    __CFStringDeallocate,
+    __CFStringEqual,
+    __CFStringHash,
+    __CFStringCopyFormattingDescription,
+    __CFStringCopyDescription
+};
+
+__private_extern__ void __CFStringInitialize(void) {
+    __kCFStringTypeID = _CFRuntimeRegisterClass(&__CFStringClass);
+}
+
+CFTypeID CFStringGetTypeID(void) {
+    return __kCFStringTypeID;
+}
+
+
+static Boolean CFStrIsUnicode(CFStringRef str) {
+    CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, Boolean, str, "_encodingCantBeStoredInEightBitCFString");
+    return __CFStrIsUnicode(str);
+}
+
+
+
+#define ALLOCATORSFREEFUNC ((CFAllocatorRef)-1)
+
+/* contentsDeallocator indicates how to free the data if it's noCopy == true:
+	kCFAllocatorNull: don't free
+	ALLOCATORSFREEFUNC: free with main allocator's free func (don't pass in the real func ptr here)
+	NULL: default allocator
+	otherwise it's the allocator that should be used (it will be explicitly stored)
+   if noCopy == false, then freeFunc should be ALLOCATORSFREEFUNC
+   hasLengthByte, hasNullByte: refers to bytes; used only if encoding != Unicode
+   possiblyExternalFormat indicates that the bytes might have BOM and be swapped
+   tryToReduceUnicode means that the Unicode should be checked to see if it contains just ASCII (and reduce it if so)
+   numBytes contains the actual number of bytes in "bytes", including Length byte, 
+	BUT not the NULL byte at the end
+   bytes should not contain BOM characters
+   !!! Various flags should be combined to reduce number of arguments, if possible
+*/
+__private_extern__ 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) {
+    
+    CFMutableStringRef str;
+    CFVarWidthCharBuffer vBuf;
+    CFIndex size;
+    Boolean useLengthByte = false;
+    Boolean useNullByte = false;
+    Boolean useInlineData = false;
+
+#if INSTRUMENT_SHARED_STRINGS
+    const char *recordedEncoding;
+    char encodingBuffer[128];
+    if (encoding == kCFStringEncodingUnicode) recordedEncoding = "Unicode";
+    else if (encoding == kCFStringEncodingASCII) recordedEncoding = "ASCII";
+    else if (encoding == kCFStringEncodingUTF8) recordedEncoding = "UTF8";
+    else if (encoding == kCFStringEncodingMacRoman) recordedEncoding = "MacRoman";
+    else {
+	sprintf(encodingBuffer, "0x%lX", (unsigned long)encoding);
+	recordedEncoding = encodingBuffer;
+    }
+#endif
+
+    if (alloc == NULL) alloc = __CFGetDefaultAllocator();
+
+    if (contentsDeallocator == ALLOCATORSFREEFUNC) {
+	contentsDeallocator = alloc;
+    } else if (contentsDeallocator == NULL) {
+	contentsDeallocator = __CFGetDefaultAllocator();
+    }
+
+    if ((NULL != kCFEmptyString) && (numBytes == 0) && (alloc == kCFAllocatorSystemDefault)) {	// If we are using the system default allocator, and the string is empty, then use the empty string!
+	if (noCopy && (contentsDeallocator != kCFAllocatorNull)) {	// See 2365208... This change was done after Sonata; before we didn't free the bytes at all (leak).
+	    CFAllocatorDeallocate(contentsDeallocator, (void *)bytes); 
+	}
+	return (CFStringRef)CFRetain(kCFEmptyString);	// Quick exit; won't catch all empty strings, but most
+    }
+
+    // At this point, contentsDeallocator is either same as alloc, or kCFAllocatorNull, or something else, but not NULL
+
+    vBuf.shouldFreeChars = false;	// We use this to remember to free the buffer possibly allocated by decode
+
+    // Record whether we're starting out with an ASCII-superset string, because we need to know this later for the string ROM; this may get changed later if we successfully convert down from Unicode.  We only record this once because __CFCanUseEightBitCFStringForBytes() can be expensive.
+    Boolean stringSupportsEightBitCFRepresentation = encoding != kCFStringEncodingUnicode && __CFCanUseEightBitCFStringForBytes((const uint8_t *)bytes, numBytes, encoding);
+    
+    // We may also change noCopy within this function if we have to decode the string into an external buffer.  We do not want to avoid the use of the string ROM merely because we tried to be efficient and reuse the decoded buffer for the CFString's external storage.  Therefore, we use this variable to track whether we actually can ignore the noCopy flag (which may or may not be set anyways).
+    Boolean stringROMShouldIgnoreNoCopy = false;
+
+    // First check to see if the data needs to be converted...
+    // ??? We could be more efficient here and in some cases (Unicode data) eliminate a copy
+
+    if ((encoding == kCFStringEncodingUnicode && possiblyExternalFormat) || (encoding != kCFStringEncodingUnicode && !stringSupportsEightBitCFRepresentation)) {
+        const void *realBytes = (uint8_t *) bytes + (hasLengthByte ? 1 : 0);
+        CFIndex realNumBytes = numBytes - (hasLengthByte ? 1 : 0);
+        Boolean usingPassedInMemory = false;
+
+	vBuf.allocator = __CFGetDefaultAllocator();	// We don't want to use client's allocator for temp stuff
+        vBuf.chars.unicode = NULL;	// This will cause the decode function to allocate memory if necessary
+
+        if (!__CFStringDecodeByteStream3((const uint8_t *)realBytes, realNumBytes, encoding, false, &vBuf, &usingPassedInMemory, converterFlags)) {
+	    // Note that if the string can't be created, we don't free the buffer, even if there is a contents deallocator. This is on purpose.
+	    return NULL;
+	}
+
+        encoding = vBuf.isASCII ? kCFStringEncodingASCII : kCFStringEncodingUnicode;
+	
+	// Update our flag according to whether the decoded buffer is ASCII
+	stringSupportsEightBitCFRepresentation = vBuf.isASCII;
+	
+        if (!usingPassedInMemory) {
+
+	    // Because __CFStringDecodeByteStream3() allocated our buffer, it's OK for us to free it if we can get the string from the ROM.
+	    stringROMShouldIgnoreNoCopy = true;
+
+            // Make the parameters fit the new situation
+            numBytes = vBuf.isASCII ? vBuf.numChars : (vBuf.numChars * sizeof(UniChar));
+            hasLengthByte = hasNullByte = false;
+
+            // Get rid of the original buffer if its not being used
+            if (noCopy && (contentsDeallocator != kCFAllocatorNull)) {
+                CFAllocatorDeallocate(contentsDeallocator, (void *)bytes);
+            }
+            contentsDeallocator = alloc;	// At this point we are using the string's allocator, as the original buffer is gone...
+
+            // See if we can reuse any storage the decode func might have allocated
+            // We do this only for Unicode, as otherwise we would not have NULL and Length bytes
+
+            if (vBuf.shouldFreeChars && (alloc == vBuf.allocator) && encoding == kCFStringEncodingUnicode) {
+                vBuf.shouldFreeChars = false;	// Transferring ownership to the CFString
+                bytes = CFAllocatorReallocate(vBuf.allocator, (void *)vBuf.chars.unicode, numBytes, 0);	// Tighten up the storage
+                noCopy = true;
+#if INSTRUMENT_SHARED_STRINGS
+		if (encoding == kCFStringEncodingASCII) recordedEncoding = "ForeignASCII-NoCopy";
+		else recordedEncoding = "ForeignUnicode-NoCopy";
+#endif
+            } else {
+#if INSTRUMENT_SHARED_STRINGS
+		if (encoding == kCFStringEncodingASCII) recordedEncoding = "ForeignASCII-Copy";
+		else recordedEncoding = "ForeignUnicode-Copy";
+#endif
+                bytes = vBuf.chars.unicode;
+                noCopy = false;			// Can't do noCopy anymore
+                // If vBuf.shouldFreeChars is true, the buffer will be freed as intended near the end of this func
+            }
+
+        }
+
+	// At this point, all necessary input arguments have been changed to reflect the new state
+
+    } else if (encoding == kCFStringEncodingUnicode && tryToReduceUnicode) {	// Check to see if we can reduce Unicode to ASCII
+        CFIndex cnt;
+        CFIndex len = numBytes / sizeof(UniChar);
+        Boolean allASCII = true;
+
+        for (cnt = 0; cnt < len; cnt++) if (((const UniChar *)bytes)[cnt] > 127) {
+            allASCII = false;
+            break;
+        }
+
+        if (allASCII) {	// Yes we can!
+            uint8_t *ptr, *mem;
+            Boolean newHasLengthByte = __CFCanUseLengthByte(len);
+            numBytes = (len + 1 + (newHasLengthByte ? 1 : 0)) * sizeof(uint8_t);	// NULL and possible length byte
+            // See if we can use that temporary local buffer in vBuf...
+	    if (numBytes >= __kCFVarWidthLocalBufferSize) {
+		mem = ptr = (uint8_t *)CFAllocatorAllocate(alloc, numBytes, 0);
+		if (__CFOASafe) __CFSetLastAllocationEventName(mem, "CFString (store)");
+	    } else {
+		mem = ptr = (uint8_t *)(vBuf.localBuffer);
+	    }
+	    if (mem) {	// If we can't allocate memory for some reason, use what we had (that is, as if we didn't have all ASCII)
+		// Copy the Unicode bytes into the new ASCII buffer
+		hasLengthByte = newHasLengthByte;
+		hasNullByte = true;
+		if (hasLengthByte) *ptr++ = (uint8_t)len;
+		for (cnt = 0; cnt < len; cnt++) ptr[cnt] = (uint8_t)(((const UniChar *)bytes)[cnt]);
+		ptr[len] = 0;
+		if (noCopy && (contentsDeallocator != kCFAllocatorNull)) {
+		    CFAllocatorDeallocate(contentsDeallocator, (void *)bytes);
+		}
+		// Now make everything look like we had an ASCII buffer to start with
+		bytes = mem;
+		encoding = kCFStringEncodingASCII;
+		contentsDeallocator = alloc;	// At this point we are using the string's allocator, as the original buffer is gone...
+		noCopy = (numBytes >= __kCFVarWidthLocalBufferSize);	// If we had to allocate it, make sure it's kept around
+		numBytes--;		// Should not contain the NULL byte at end...
+		stringSupportsEightBitCFRepresentation = true; // We're ASCII now!
+		stringROMShouldIgnoreNoCopy = true; // We allocated this buffer, so we should feel free to get rid of it if we can use the string ROM
+#if INSTRUMENT_SHARED_STRINGS
+		recordedEncoding = "U->A";
+#endif
+	    }
+        }
+
+        // At this point, all necessary input arguments have been changed to reflect the new state
+    }
+
+    // Now determine the necessary size
+    
+    Boolean stringSupportsROM = stringSupportsEightBitCFRepresentation;
+
+#if INSTRUMENT_SHARED_STRINGS
+    if (stringSupportsROM) {
+        const void *realBytes = (uint8_t *) bytes + (hasLengthByte ? 1 : 0);
+        CFIndex realNumBytes = numBytes - !! hasLengthByte;
+	__CFRecordStringAllocationEvent(recordedEncoding, realBytes, realNumBytes);
+    }
+#endif
+
+    CFStringRef romResult = NULL;
+
+#if USE_STRING_ROM
+
+    if (stringSupportsROM) {
+        // Disable the string ROM if necessary
+	static char sDisableStringROM = -1;
+	if (sDisableStringROM == -1) sDisableStringROM = !! getenv("CFStringDisableROM");
+
+	if (sDisableStringROM == 0) romResult = _CFSearchStringROM(bytes + !! hasLengthByte, numBytes - !! hasLengthByte);
+    }
+    /* if we get a result from our ROM, and noCopy is set, then deallocate the buffer immediately */
+    if (romResult) {
+	if (noCopy && (contentsDeallocator != kCFAllocatorNull)) {
+	    CFAllocatorDeallocate(contentsDeallocator, (void *)bytes);
+	}
+	
+	/* these don't get used again, but clear them for consistency */
+	noCopy = false;
+	bytes = NULL;
+	
+	/* set our result to the ROM result which is not really mutable, of course, but that's OK because we don't try to modify it. */
+	str = (CFMutableStringRef)romResult;
+    }
+#endif
+
+    if (! romResult) {
+	// Now determine the necessary size
+
+	if (noCopy) {
+
+	    size = sizeof(void *);				// Pointer to the buffer
+	    if (contentsDeallocator != alloc && contentsDeallocator != kCFAllocatorNull) {
+		size += sizeof(void *);	// The contentsDeallocator
+	    }
+	    if (!hasLengthByte) size += sizeof(CFIndex);	// Explicit length
+	    useLengthByte = hasLengthByte;
+	    useNullByte = hasNullByte;
+
+	} else {	// Inline data; reserve space for it
+
+	    useInlineData = true;
+	    size = numBytes;
+
+	    if (hasLengthByte || (encoding != kCFStringEncodingUnicode && __CFCanUseLengthByte(numBytes))) {
+		useLengthByte = true;
+		if (!hasLengthByte) size += 1;
+	    } else {
+		size += sizeof(CFIndex);	// Explicit length
+	    }	    
+	    if (hasNullByte || encoding != kCFStringEncodingUnicode) {
+		useNullByte = true;
+		size += 1;
+	    }
+	}
+
+#ifdef STRING_SIZE_STATS
+	// Dump alloced CFString size info every so often
+	static int cnt = 0;
+	static unsigned sizes[256] = {0};
+	int allocedSize = size + sizeof(CFRuntimeBase);
+	if (allocedSize < 255) sizes[allocedSize]++; else sizes[255]++;
+	if ((++cnt % 1000) == 0) {
+	    printf ("\nTotal: %d\n", cnt);
+	    int i; for (i = 0; i < 256; i++) printf("%03d: %5d%s", i, sizes[i], ((i % 8) == 7) ? "\n" : " ");
+	}
+#endif
+     
+	// Finally, allocate!
+
+	str = (CFMutableStringRef)_CFRuntimeCreateInstance(alloc, __kCFStringTypeID, size, NULL);
+	if (str) {
+	    if (__CFOASafe) __CFSetLastAllocationEventName(str, "CFString (immutable)");
+
+	    __CFStrSetInfoBits(str,
+				(useInlineData ? __kCFHasInlineContents : (contentsDeallocator == alloc ? __kCFNotInlineContentsDefaultFree : (contentsDeallocator == kCFAllocatorNull ? __kCFNotInlineContentsNoFree : __kCFNotInlineContentsCustomFree))) |
+				((encoding == kCFStringEncodingUnicode) ? __kCFIsUnicode : 0) |
+				(useNullByte ? __kCFHasNullByte : 0) |
+				(useLengthByte ? __kCFHasLengthByte : 0));
+
+	    if (!useLengthByte) {
+		CFIndex length = numBytes - (hasLengthByte ? 1 : 0);
+		if (encoding == kCFStringEncodingUnicode) length /= sizeof(UniChar);
+		__CFStrSetExplicitLength(str, length);
+	    }
+
+	    if (useInlineData) {
+		uint8_t *contents = (uint8_t *)__CFStrContents(str);
+		if (useLengthByte && !hasLengthByte) *contents++ = (uint8_t)numBytes;
+		memmove(contents, bytes, numBytes);
+		if (useNullByte) contents[numBytes] = 0;
+	    } else {
+		__CFStrSetContentPtr(str, bytes);
+		if (contentsDeallocator != alloc && contentsDeallocator != kCFAllocatorNull) __CFStrSetContentsDeallocator(str, (CFAllocatorRef)CFRetain(contentsDeallocator)); 
+	    }
+	} else {
+	    if (noCopy && (contentsDeallocator != kCFAllocatorNull)) {
+		CFAllocatorDeallocate(contentsDeallocator, (void *)bytes); 
+	    }
+	}
+    }
+    if (vBuf.shouldFreeChars) CFAllocatorDeallocate(vBuf.allocator, (void *)bytes);
+
+    return str;
+}
+
+/* !!! __CFStringCreateImmutableFunnel2() is kept around for compatibility; it should be deprecated
+*/
+CFStringRef __CFStringCreateImmutableFunnel2(
+                                             CFAllocatorRef alloc, const void *bytes, CFIndex numBytes, CFStringEncoding encoding,
+                                             Boolean possiblyExternalFormat, Boolean tryToReduceUnicode, Boolean hasLengthByte, Boolean hasNullByte, Boolean noCopy,
+                                             CFAllocatorRef contentsDeallocator) {
+    return __CFStringCreateImmutableFunnel3(alloc, bytes, numBytes, encoding, possiblyExternalFormat, tryToReduceUnicode, hasLengthByte, hasNullByte, noCopy, contentsDeallocator, 0);
+}
+
+
+
+CFStringRef  CFStringCreateWithPascalString(CFAllocatorRef alloc, ConstStringPtr pStr, CFStringEncoding encoding) {
+    CFIndex len = (CFIndex)(*(uint8_t *)pStr);
+    return __CFStringCreateImmutableFunnel3(alloc, pStr, len+1, encoding, false, false, true, false, false, ALLOCATORSFREEFUNC, 0);
+}
+
+
+CFStringRef  CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding) {
+    CFIndex len = (CFIndex)strlen(cStr);
+    return __CFStringCreateImmutableFunnel3(alloc, cStr, len, encoding, false, false, false, true, false, ALLOCATORSFREEFUNC, 0);
+}
+
+CFStringRef  CFStringCreateWithPascalStringNoCopy(CFAllocatorRef alloc, ConstStringPtr pStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator) {
+    CFIndex len = (CFIndex)(*(uint8_t *)pStr);
+    return __CFStringCreateImmutableFunnel3(alloc, pStr, len+1, encoding, false, false, true, false, true, contentsDeallocator, 0);
+}
+
+
+CFStringRef  CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator) {
+    CFIndex len = (CFIndex)strlen(cStr);
+    return __CFStringCreateImmutableFunnel3(alloc, cStr, len, encoding, false, false, false, true, true, contentsDeallocator, 0);
+}
+
+
+CFStringRef  CFStringCreateWithCharacters(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars) {
+    return __CFStringCreateImmutableFunnel3(alloc, chars, numChars * sizeof(UniChar), kCFStringEncodingUnicode, false, true, false, false, false, ALLOCATORSFREEFUNC, 0);
+}
+
+
+CFStringRef  CFStringCreateWithCharactersNoCopy(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars, CFAllocatorRef contentsDeallocator) {
+    return __CFStringCreateImmutableFunnel3(alloc, chars, numChars * sizeof(UniChar), kCFStringEncodingUnicode, false, false, false, false, true, contentsDeallocator, 0);
+}
+
+
+CFStringRef  CFStringCreateWithBytes(CFAllocatorRef alloc, const uint8_t *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat) {
+    return __CFStringCreateImmutableFunnel3(alloc, bytes, numBytes, encoding, externalFormat, true, false, false, false, ALLOCATORSFREEFUNC, 0);
+}
+
+CFStringRef  _CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const uint8_t *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator) {
+    return __CFStringCreateImmutableFunnel3(alloc, bytes, numBytes, encoding, externalFormat, true, false, false, true, contentsDeallocator, 0);
+}
+
+CFStringRef  CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const uint8_t *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator) {
+    return __CFStringCreateImmutableFunnel3(alloc, bytes, numBytes, encoding, externalFormat, true, false, false, true, contentsDeallocator, 0);
+}
+
+CFStringRef  CFStringCreateWithFormatAndArguments(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) {
+    return _CFStringCreateWithFormatAndArgumentsAux(alloc, NULL, formatOptions, format, arguments);
+}
+
+CFStringRef  _CFStringCreateWithFormatAndArgumentsAux(CFAllocatorRef alloc, CFStringRef (*copyDescFunc)(void *, const void *), CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) {
+    CFStringRef str;
+    CFMutableStringRef outputString = CFStringCreateMutable(__CFGetDefaultAllocator(), 0); //should use alloc if no copy/release
+    __CFStrSetDesiredCapacity(outputString, 120);	// Given this will be tightened later, choosing a larger working string is fine
+    _CFStringAppendFormatAndArgumentsAux(outputString, copyDescFunc, formatOptions, format, arguments);
+    // ??? copy/release should not be necessary here -- just make immutable, compress if possible
+    // (However, this does make the string inline, and cause the supplied allocator to be used...)
+    str = (CFStringRef)CFStringCreateCopy(alloc, outputString);
+    CFRelease(outputString);
+    return str;
+}
+
+CFStringRef  CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...) {
+    CFStringRef result;
+    va_list argList;
+
+    va_start(argList, format);
+    result = CFStringCreateWithFormatAndArguments(alloc, formatOptions, format, argList);
+    va_end(argList);
+
+    return result;
+}
+
+CFStringRef CFStringCreateWithSubstring(CFAllocatorRef alloc, CFStringRef str, CFRange range) {
+//      CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, CFStringRef , str, "_createSubstringWithRange:", CFRangeMake(range.location, range.length));
+
+    __CFAssertIsString(str);
+    __CFAssertRangeIsInStringBounds(str, range.location, range.length);
+
+    if ((range.location == 0) && (range.length == __CFStrLength(str))) {	/* The substring is the whole string... */
+	return (CFStringRef)CFStringCreateCopy(alloc, str);
+    } else if (__CFStrIsEightBit(str)) {
+	const uint8_t *contents = (const uint8_t *)__CFStrContents(str);
+        return __CFStringCreateImmutableFunnel3(alloc, contents + range.location + __CFStrSkipAnyLengthByte(str), range.length, __CFStringGetEightBitStringEncoding(), false, false, false, false, false, ALLOCATORSFREEFUNC, 0);
+    } else {
+	const UniChar *contents = (UniChar *)__CFStrContents(str);
+        return __CFStringCreateImmutableFunnel3(alloc, contents + range.location, range.length * sizeof(UniChar), kCFStringEncodingUnicode, false, true, false, false, false, ALLOCATORSFREEFUNC, 0);
+    }
+}
+
+CFStringRef CFStringCreateCopy(CFAllocatorRef alloc, CFStringRef str) {
+//  CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, CFStringRef, str, "copy");
+
+    __CFAssertIsString(str);
+    if (!__CFStrIsMutable((CFStringRef)str) && 								// If the string is not mutable
+        ((alloc ? alloc : __CFGetDefaultAllocator()) == __CFGetAllocator(str)) &&		//  and it has the same allocator as the one we're using
+        (__CFStrIsInline((CFStringRef)str) || __CFStrFreeContentsWhenDone((CFStringRef)str) || __CFStrIsConstant((CFStringRef)str))) {	//  and the characters are inline, or are owned by the string, or the string is constant
+	CFRetain(str);										// Then just retain instead of making a true copy
+	return str;
+    }
+    if (__CFStrIsEightBit((CFStringRef)str)) {
+        const uint8_t *contents = (const uint8_t *)__CFStrContents((CFStringRef)str);
+        return __CFStringCreateImmutableFunnel3(alloc, contents + __CFStrSkipAnyLengthByte((CFStringRef)str), __CFStrLength2((CFStringRef)str, contents), __CFStringGetEightBitStringEncoding(), false, false, false, false, false, ALLOCATORSFREEFUNC, 0);
+    } else {
+        const UniChar *contents = (const UniChar *)__CFStrContents((CFStringRef)str);
+        return __CFStringCreateImmutableFunnel3(alloc, contents, __CFStrLength2((CFStringRef)str, contents) * sizeof(UniChar), kCFStringEncodingUnicode, false, true, false, false, false, ALLOCATORSFREEFUNC, 0);
+    }
+}
+
+
+
+/*** Constant string stuff... ***/
+
+/* Table which holds constant strings created with CFSTR, when -fconstant-cfstrings option is not used. These dynamically created constant strings are stored in constantStringTable. The keys are the 8-bit constant C-strings from the compiler; the values are the CFStrings created for them. _CFSTRLock protects this table.
+*/
+static CFMutableDictionaryRef constantStringTable = NULL;
+static CFSpinLock_t _CFSTRLock = CFSpinLockInit;
+
+static CFStringRef __cStrCopyDescription(const void *ptr) {
+    return CFStringCreateWithCStringNoCopy(kCFAllocatorSystemDefault, (const char *)ptr, __CFStringGetEightBitStringEncoding(), kCFAllocatorNull);
+}
+
+static Boolean __cStrEqual(const void *ptr1, const void *ptr2) {
+    return (strcmp((const char *)ptr1, (const char *)ptr2) == 0);
+}
+
+static CFHashCode __cStrHash(const void *ptr) {
+    // It doesn't quite matter if we convert to Unicode correctly, as long as we do it consistently    
+    const char *cStr = (const char *)ptr;
+    CFIndex len = (CFIndex)strlen(cStr);
+    CFHashCode result = 0;
+    if (len <= 4) {	// All chars
+        unsigned cnt = len;
+        while (cnt--) result += (result << 8) + *cStr++;
+    } else {		// First and last 2 chars
+        result += (result << 8) + cStr[0];
+        result += (result << 8) + cStr[1];
+        result += (result << 8) + cStr[len-2];
+        result += (result << 8) + cStr[len-1];
+    }
+    result += (result << (len & 31));
+    return result;    
+}
+
+
+CFStringRef __CFStringMakeConstantString(const char *cStr) {
+    CFStringRef result;
+#if defined(DEBUG)
+    // StringTest checks that we share kCFEmptyString, which is defeated by constantStringAllocatorForDebugging 
+    if ('\0' == *cStr) return kCFEmptyString;
+#endif
+    if (constantStringTable == NULL) {
+        CFDictionaryKeyCallBacks constantStringCallBacks = {0, NULL, NULL, __cStrCopyDescription, __cStrEqual, __cStrHash};
+        CFDictionaryValueCallBacks constantStringValueCallBacks = kCFTypeDictionaryValueCallBacks;
+        constantStringValueCallBacks.equal = NULL;      // So that we only find strings that are ==
+	CFMutableDictionaryRef table = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &constantStringCallBacks, &constantStringValueCallBacks);
+	_CFDictionarySetCapacity(table, 2500);          // avoid lots of rehashing
+	__CFSpinLock(&_CFSTRLock);
+	if (constantStringTable == NULL) constantStringTable = table;
+	__CFSpinUnlock(&_CFSTRLock);
+	if (constantStringTable != table) CFRelease(table);
+    }
+
+    __CFSpinLock(&_CFSTRLock);
+    if ((result = (CFStringRef)CFDictionaryGetValue(constantStringTable, cStr))) {
+	__CFSpinUnlock(&_CFSTRLock);
+    } else {
+	__CFSpinUnlock(&_CFSTRLock);
+
+        {
+	char *key;
+	Boolean isASCII = true;
+	// Given this code path is rarer these days, OK to do this extra work to verify the strings
+        const char *tmp = cStr;
+        while (*tmp) {
+            if (*(tmp++) & 0x80) {
+                isASCII = false;
+                break;
+            }
+        }
+	if (!isASCII) {
+            CFMutableStringRef ms = CFStringCreateMutable(kCFAllocatorSystemDefault, 0);
+            tmp = cStr;
+            while (*tmp) {
+                CFStringAppendFormat(ms, NULL, (*tmp & 0x80) ? CFSTR("\\%3o") : CFSTR("%1c"), *tmp);
+                tmp++;
+            }
+            CFLog(kCFLogLevelWarning, CFSTR("WARNING: CFSTR(\"%@\") has non-7 bit chars, interpreting using MacOS Roman encoding for now, but this will change. Please eliminate usages of non-7 bit chars (including escaped characters above \\177 octal) in CFSTR()."), ms);
+            CFRelease(ms);
+	}
+	// Treat non-7 bit chars in CFSTR() as MacOSRoman, for compatibility
+	result = CFStringCreateWithCString(kCFAllocatorSystemDefault, cStr, kCFStringEncodingMacRoman);
+	if (result == NULL) {
+	    CFLog(__kCFLogAssertion, CFSTR("Can't interpret CFSTR() as MacOS Roman, crashing"));
+	    HALT;
+	}
+	if (__CFOASafe) __CFSetLastAllocationEventName((void *)result, "CFString (CFSTR)");
+	if (__CFStrIsEightBit(result)) {	
+	    key = (char *)__CFStrContents(result) + __CFStrSkipAnyLengthByte(result);
+	} else {	// For some reason the string is not 8-bit!
+	    key = (char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, (CFIndex)strlen(cStr) + 1, 0);
+	    if (__CFOASafe) __CFSetLastAllocationEventName((void *)key, "CFString (CFSTR key)");
+	    strlcpy(key, cStr, strlen(cStr) + 1);	// !!! We will leak this, if the string is removed from the table (or table is freed)
+	}
+
+	{
+            CFStringRef resultToBeReleased = result;
+	    CFIndex count;
+	    __CFSpinLock(&_CFSTRLock);
+	    count = CFDictionaryGetCount(constantStringTable);
+	    CFDictionaryAddValue(constantStringTable, key, result);
+	    if (CFDictionaryGetCount(constantStringTable) == count) { // add did nothing, someone already put it there
+		result = (CFStringRef)CFDictionaryGetValue(constantStringTable, key);
+            } else {
+#if __LP64__
+                ((struct __CFString *)result)->base._rc = 0;
+#else
+                ((struct __CFString *)result)->base._cfinfo[CF_RC_BITS] = 0;
+#endif
+	    }
+	    __CFSpinUnlock(&_CFSTRLock);
+	    // This either eliminates the extra retain on the freshly created string, or frees it, if it was actually not inserted into the table
+            CFRelease(resultToBeReleased);
+	}
+	}
+    }
+    return result;
+}
+
+#if defined(DEBUG)
+static Boolean __CFStrIsConstantString(CFStringRef str) {
+    Boolean found = false;
+    if (constantStringTable) {
+	__CFSpinLock(&_CFSTRLock);
+	found = CFDictionaryContainsValue(constantStringTable, str);
+	__CFSpinUnlock(&_CFSTRLock);
+    }
+    return found;
+}
+#endif
+
+
+#if DEPLOYMENT_TARGET_WINDOWS
+__private_extern__ void __CFStringCleanup (void) {
+    /* in case library is unloaded, release store for the constant string table */
+    if (constantStringTable != NULL) {
+#if defined(DEBUG)
+    	__CFConstantStringTableBeingFreed = true;
+        CFRelease(constantStringTable);
+        __CFConstantStringTableBeingFreed = false;
+#else 
+        CFRelease(constantStringTable);
+#endif
+    }
+}
+#endif
+
+
+// Can pass in NSString as replacement string
+// Call with numRanges > 0, and incrementing ranges
+
+static void __CFStringReplaceMultiple(CFMutableStringRef str, CFRange *ranges, CFIndex numRanges, CFStringRef replacement) {
+    int cnt;
+    CFStringRef copy = NULL;
+    if (replacement == str) copy = replacement = CFStringCreateCopy(kCFAllocatorSystemDefault, replacement);   // Very special and hopefully rare case
+    CFIndex replacementLength = CFStringGetLength(replacement);
+
+    __CFStringChangeSizeMultiple(str, ranges, numRanges, replacementLength, (replacementLength > 0) && CFStrIsUnicode(replacement));
+
+    if (__CFStrIsUnicode(str)) {
+        UniChar *contents = (UniChar *)__CFStrContents(str);
+        UniChar *firstReplacement = contents + ranges[0].location;
+        // Extract the replacementString into the first location, then copy from there
+        CFStringGetCharacters(replacement, CFRangeMake(0, replacementLength), firstReplacement);
+        for (cnt = 1; cnt < numRanges; cnt++) {
+            // The ranges are in terms of the original string; so offset by the change in length due to insertion
+            contents += replacementLength - ranges[cnt - 1].length;
+            memmove(contents + ranges[cnt].location, firstReplacement, replacementLength * sizeof(UniChar));
+        }
+    } else {
+        uint8_t *contents = (uint8_t *)__CFStrContents(str);
+        uint8_t *firstReplacement = contents + ranges[0].location + __CFStrSkipAnyLengthByte(str);
+        // Extract the replacementString into the first location, then copy from there
+        CFStringGetBytes(replacement, CFRangeMake(0, replacementLength), __CFStringGetEightBitStringEncoding(), 0, false, firstReplacement, replacementLength, NULL);
+        contents += __CFStrSkipAnyLengthByte(str);	// Now contents will simply track the location to insert next string into
+        for (cnt = 1; cnt < numRanges; cnt++) {
+            // The ranges are in terms of the original string; so offset by the change in length due to insertion
+            contents += replacementLength - ranges[cnt - 1].length;
+            memmove(contents + ranges[cnt].location, firstReplacement, replacementLength);
+        }
+    }
+    if (copy) CFRelease(copy);
+}
+
+// Can pass in NSString as replacement string
+
+CF_INLINE void __CFStringReplace(CFMutableStringRef str, CFRange range, CFStringRef replacement) {
+    CFStringRef copy = NULL;
+    if (replacement == str) copy = replacement = (CFStringRef)CFStringCreateCopy(kCFAllocatorSystemDefault, replacement);   // Very special and hopefully rare case
+    CFIndex replacementLength = CFStringGetLength(replacement);
+
+    __CFStringChangeSize(str, range, replacementLength, (replacementLength > 0) && CFStrIsUnicode(replacement));
+
+    if (__CFStrIsUnicode(str)) {
+        UniChar *contents = (UniChar *)__CFStrContents(str);
+        CFStringGetCharacters(replacement, CFRangeMake(0, replacementLength), contents + range.location);
+    } else {
+        uint8_t *contents = (uint8_t *)__CFStrContents(str);
+        CFStringGetBytes(replacement, CFRangeMake(0, replacementLength), __CFStringGetEightBitStringEncoding(), 0, false, contents + range.location + __CFStrSkipAnyLengthByte(str), replacementLength, NULL);
+    }
+
+    if (copy) CFRelease(copy);
+}
+
+/* If client does not provide a minimum capacity
+*/
+#define DEFAULTMINCAPACITY 32
+
+CF_INLINE CFMutableStringRef __CFStringCreateMutableFunnel(CFAllocatorRef alloc, CFIndex maxLength, UInt32 additionalInfoBits) {
+    CFMutableStringRef str;
+    Boolean hasExternalContentsAllocator = (additionalInfoBits & __kCFHasContentsAllocator) ? true : false;
+
+    if (alloc == NULL) alloc = __CFGetDefaultAllocator();
+
+    // Note that if there is an externalContentsAllocator, then we also have the storage for the string allocator...
+    str = (CFMutableStringRef)_CFRuntimeCreateInstance(alloc, __kCFStringTypeID, sizeof(struct __notInlineMutable) - (hasExternalContentsAllocator ? 0 : sizeof(CFAllocatorRef)), NULL);
+    if (str) {
+        if (__CFOASafe) __CFSetLastAllocationEventName(str, "CFString (mutable)");
+
+        __CFStrSetInfoBits(str, __kCFIsMutable | additionalInfoBits);
+        str->variants.notInlineMutable.buffer = NULL;
+        __CFStrSetExplicitLength(str, 0);
+	str->variants.notInlineMutable.hasGap = str->variants.notInlineMutable.isFixedCapacity = str->variants.notInlineMutable.isExternalMutable = str->variants.notInlineMutable.capacityProvidedExternally = 0;
+	if (maxLength != 0) __CFStrSetIsFixed(str);
+        __CFStrSetDesiredCapacity(str, (maxLength == 0) ? DEFAULTMINCAPACITY : maxLength);
+        __CFStrSetCapacity(str, 0);
+    }
+    return str;
+}
+
+CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator) {
+    CFOptionFlags contentsAllocationBits = externalCharactersAllocator ? ((externalCharactersAllocator == kCFAllocatorNull) ? __kCFNotInlineContentsNoFree : __kCFHasContentsAllocator) : __kCFNotInlineContentsDefaultFree;
+    CFMutableStringRef string = __CFStringCreateMutableFunnel(alloc, 0, contentsAllocationBits | __kCFIsUnicode);
+    if (string) {
+	__CFStrSetIsExternalMutable(string);
+        if (contentsAllocationBits == __kCFHasContentsAllocator) __CFStrSetContentsAllocator(string, (CFAllocatorRef)CFRetain(externalCharactersAllocator));
+        CFStringSetExternalCharactersNoCopy(string, chars, numChars, capacity);
+    }
+    return string;
+}
+ 
+CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength) {
+    return __CFStringCreateMutableFunnel(alloc, maxLength, __kCFNotInlineContentsDefaultFree);
+}
+
+CFMutableStringRef  CFStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFStringRef string) {
+    CFMutableStringRef newString;
+
+    //  CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, CFMutableStringRef, string, "mutableCopy");
+
+    __CFAssertIsString(string);
+
+    newString = CFStringCreateMutable(alloc, maxLength);
+    __CFStringReplace(newString, CFRangeMake(0, 0), string);
+
+    return newString;
+}
+
+
+__private_extern__ void _CFStrSetDesiredCapacity(CFMutableStringRef str, CFIndex len) {
+    __CFAssertIsStringAndMutable(str);
+    __CFStrSetDesiredCapacity(str, len);
+}
+
+
+/* This one is for CF
+*/
+CFIndex CFStringGetLength(CFStringRef str) {
+    CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, CFIndex, str, "length");
+
+    __CFAssertIsString(str);
+    return __CFStrLength(str);
+}
+
+/* This one is for NSCFString; it does not ObjC dispatch or assertion check
+*/
+CFIndex _CFStringGetLength2(CFStringRef str) {
+    return __CFStrLength(str);
+}
+
+
+/* Guts of CFStringGetCharacterAtIndex(); called from the two functions below. Don't call it from elsewhere.
+*/
+CF_INLINE UniChar __CFStringGetCharacterAtIndexGuts(CFStringRef str, CFIndex idx, const uint8_t *contents) {
+    if (__CFStrIsEightBit(str)) {
+        contents += __CFStrSkipAnyLengthByte(str);
+#if defined(DEBUG)
+        if (!__CFCharToUniCharFunc && (contents[idx] >= 128)) {
+            // Can't do log here, as it might be too early
+            fprintf(stderr, "Warning: CFStringGetCharacterAtIndex() attempted on CFString containing high bytes before properly initialized to do so\n");
+        }
+#endif
+	return __CFCharToUniCharTable[contents[idx]];
+    }
+
+    return ((UniChar *)contents)[idx];
+}
+
+/* This one is for the CF API
+*/
+UniChar CFStringGetCharacterAtIndex(CFStringRef str, CFIndex idx) {
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, UniChar, str, "characterAtIndex:", idx);
+
+    __CFAssertIsString(str);
+    __CFAssertIndexIsInStringBounds(str, idx);
+    return __CFStringGetCharacterAtIndexGuts(str, idx, (const uint8_t *)__CFStrContents(str));
+}
+
+/* This one is for NSCFString usage; it doesn't do ObjC dispatch; but it does do range check
+*/
+int _CFStringCheckAndGetCharacterAtIndex(CFStringRef str, CFIndex idx, UniChar *ch) {
+    const uint8_t *contents = (const uint8_t *)__CFStrContents(str);
+    if (idx >= __CFStrLength2(str, contents) && __CFStringNoteErrors()) return _CFStringErrBounds;
+    *ch = __CFStringGetCharacterAtIndexGuts(str, idx, contents);
+    return _CFStringErrNone;
+}
+
+
+/* Guts of CFStringGetCharacters(); called from the two functions below. Don't call it from elsewhere.
+*/
+CF_INLINE void __CFStringGetCharactersGuts(CFStringRef str, CFRange range, UniChar *buffer, const uint8_t *contents) {
+    if (__CFStrIsEightBit(str)) {
+        __CFStrConvertBytesToUnicode(((uint8_t *)contents) + (range.location + __CFStrSkipAnyLengthByte(str)), buffer, range.length);
+    } else {
+        const UniChar *uContents = ((UniChar *)contents) + range.location;
+        memmove(buffer, uContents, range.length * sizeof(UniChar));
+    }
+}
+
+/* This one is for the CF API
+*/
+void CFStringGetCharacters(CFStringRef str, CFRange range, UniChar *buffer) {
+    CF_OBJC_FUNCDISPATCH2(__kCFStringTypeID, void, str, "getCharacters:range:", buffer, CFRangeMake(range.location, range.length));
+
+    __CFAssertIsString(str);
+    __CFAssertRangeIsInStringBounds(str, range.location, range.length);
+    __CFStringGetCharactersGuts(str, range, buffer, (const uint8_t *)__CFStrContents(str));
+}
+
+/* This one is for NSCFString usage; it doesn't do ObjC dispatch; but it does do range check
+*/
+int _CFStringCheckAndGetCharacters(CFStringRef str, CFRange range, UniChar *buffer) {
+     const uint8_t *contents = (const uint8_t *)__CFStrContents(str);
+     if (range.location + range.length > __CFStrLength2(str, contents) && __CFStringNoteErrors()) return _CFStringErrBounds;
+     __CFStringGetCharactersGuts(str, range, buffer, contents);
+     return _CFStringErrNone;
+}
+
+
+CFIndex CFStringGetBytes(CFStringRef str, CFRange range, CFStringEncoding encoding, uint8_t lossByte, Boolean isExternalRepresentation, uint8_t *buffer, CFIndex maxBufLen, CFIndex *usedBufLen) {
+
+    /* No objc dispatch needed here since __CFStringEncodeByteStream works with both CFString and NSString */
+    __CFAssertIsNotNegative(maxBufLen);
+
+    if (!CF_IS_OBJC(__kCFStringTypeID, str)) {	// If we can grope the ivars, let's do it...
+        __CFAssertIsString(str);
+        __CFAssertRangeIsInStringBounds(str, range.location, range.length);
+
+        if (__CFStrIsEightBit(str) && ((__CFStringGetEightBitStringEncoding() == encoding) || (__CFStringGetEightBitStringEncoding() == kCFStringEncodingASCII && __CFStringEncodingIsSupersetOfASCII(encoding)))) {	// Requested encoding is equal to the encoding in string
+            const unsigned char *contents = (const unsigned char *)__CFStrContents(str);
+            CFIndex cLength = range.length;
+
+            if (buffer) {
+                if (cLength > maxBufLen) cLength = maxBufLen;
+                memmove(buffer, contents + __CFStrSkipAnyLengthByte(str) + range.location, cLength);
+            }
+            if (usedBufLen) *usedBufLen = cLength;
+
+            return cLength;
+        }
+    }
+
+    return __CFStringEncodeByteStream(str, range.location, range.length, isExternalRepresentation, encoding, lossByte, buffer, maxBufLen, usedBufLen);
+}
+
+
+ConstStringPtr CFStringGetPascalStringPtr (CFStringRef str, CFStringEncoding encoding) {
+
+    if (!CF_IS_OBJC(__kCFStringTypeID, str)) {	/* ??? Hope the compiler optimizes this away if OBJC_MAPPINGS is not on */
+        __CFAssertIsString(str);
+        if (__CFStrHasLengthByte(str) && __CFStrIsEightBit(str) && ((__CFStringGetEightBitStringEncoding() == encoding) || (__CFStringGetEightBitStringEncoding() == kCFStringEncodingASCII && __CFStringEncodingIsSupersetOfASCII(encoding)))) {	// Requested encoding is equal to the encoding in string || the contents is in ASCII
+	    const uint8_t *contents = (const uint8_t *)__CFStrContents(str);
+	    if (__CFStrHasExplicitLength(str) && (__CFStrLength2(str, contents) != (SInt32)(*contents))) return NULL;	// Invalid length byte
+	    return (ConstStringPtr)contents;
+	}
+	// ??? Also check for encoding = SystemEncoding and perhaps bytes are all ASCII?
+    }
+    return NULL;
+}
+
+
+const char * CFStringGetCStringPtr(CFStringRef str, CFStringEncoding encoding) {
+
+    if (encoding != __CFStringGetEightBitStringEncoding() && (kCFStringEncodingASCII != __CFStringGetEightBitStringEncoding() || !__CFStringEncodingIsSupersetOfASCII(encoding))) return NULL;
+    // ??? Also check for encoding = SystemEncoding and perhaps bytes are all ASCII?
+
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, const char *, str, "_fastCStringContents:", true);
+
+    __CFAssertIsString(str);
+
+    if (__CFStrHasNullByte(str)) {
+        // Note: this is called a lot, 27000 times to open a small xcode project with one file open.
+        // Of these uses about 1500 are for cStrings/utf8strings.
+	return (const char *)__CFStrContents(str) + __CFStrSkipAnyLengthByte(str);
+    } else {
+	return NULL;
+    }
+}
+
+
+const UniChar *CFStringGetCharactersPtr(CFStringRef str) {
+
+    CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, const UniChar *, str, "_fastCharacterContents");
+    
+    __CFAssertIsString(str);
+    if (__CFStrIsUnicode(str)) return (const UniChar *)__CFStrContents(str);
+    return NULL;
+}
+
+
+Boolean CFStringGetPascalString(CFStringRef str, Str255 buffer, CFIndex bufferSize, CFStringEncoding encoding) {
+    CFIndex length;
+    CFIndex usedLen;
+
+    __CFAssertIsNotNegative(bufferSize);
+    if (bufferSize < 1) return false;
+
+    if (CF_IS_OBJC(__kCFStringTypeID, str)) {	/* ??? Hope the compiler optimizes this away if OBJC_MAPPINGS is not on */
+	length = CFStringGetLength(str);
+        if (!__CFCanUseLengthByte(length)) return false; // Can't fit into pstring
+    } else {
+	const uint8_t *contents;
+
+        __CFAssertIsString(str);
+
+        contents = (const uint8_t *)__CFStrContents(str);
+        length = __CFStrLength2(str, contents);
+
+        if (!__CFCanUseLengthByte(length)) return false; // Can't fit into pstring
+
+        if (__CFStrIsEightBit(str) && ((__CFStringGetEightBitStringEncoding() == encoding) || (__CFStringGetEightBitStringEncoding() == kCFStringEncodingASCII && __CFStringEncodingIsSupersetOfASCII(encoding)))) {	// Requested encoding is equal to the encoding in string
+	    if (length >= bufferSize) return false;
+            memmove((void*)(1 + (const char*)buffer), (__CFStrSkipAnyLengthByte(str) + contents), length);
+            *buffer = (unsigned char)length;
+	    return true;
+	}
+    }
+
+	if (__CFStringEncodeByteStream(str, 0, length, false, encoding, false, (UInt8 *)(1 + (uint8_t *)buffer), bufferSize - 1, &usedLen) != length) {
+
+#if defined(DEBUG)
+	if (bufferSize > 0) {
+	    strlcpy((char *)buffer + 1, CONVERSIONFAILURESTR, bufferSize - 1);
+	    buffer[0] = (unsigned char)((CFIndex)sizeof(CONVERSIONFAILURESTR) < (bufferSize - 1) ? (CFIndex)sizeof(CONVERSIONFAILURESTR) : (bufferSize - 1));
+	}
+#else
+	if (bufferSize > 0) buffer[0] = 0;
+#endif
+	return false;
+    }
+    *buffer = (unsigned char)usedLen;
+    return true;
+}
+                                   
+Boolean CFStringGetCString(CFStringRef str, char *buffer, CFIndex bufferSize, CFStringEncoding encoding) {
+    const uint8_t *contents;
+    CFIndex len;
+
+    __CFAssertIsNotNegative(bufferSize);
+    if (bufferSize < 1) return false;
+
+    CF_OBJC_FUNCDISPATCH3(__kCFStringTypeID, Boolean, str, "_getCString:maxLength:encoding:", buffer, bufferSize - 1, encoding);
+
+    __CFAssertIsString(str);
+
+    contents = (const uint8_t *)__CFStrContents(str);
+    len = __CFStrLength2(str, contents);
+
+    if (__CFStrIsEightBit(str) && ((__CFStringGetEightBitStringEncoding() == encoding) || (__CFStringGetEightBitStringEncoding() == kCFStringEncodingASCII && __CFStringEncodingIsSupersetOfASCII(encoding)))) {	// Requested encoding is equal to the encoding in string
+        if (len >= bufferSize) return false;
+	memmove(buffer, contents + __CFStrSkipAnyLengthByte(str), len);
+	buffer[len] = 0;
+        return true;
+    } else {
+        CFIndex usedLen;
+
+        if (__CFStringEncodeByteStream(str, 0, len, false, encoding, false, (unsigned char*) buffer, bufferSize - 1, &usedLen) == len) {
+            buffer[usedLen] = '\0';
+            return true;
+        } else {
+#if defined(DEBUG)
+            strlcpy(buffer, CONVERSIONFAILURESTR, bufferSize);
+#else
+	    if (bufferSize > 0) buffer[0] = 0;
+#endif
+            return false;
+        }
+    }
+}
+
+static const char *_CFStrGetLanguageIdentifierForLocale(CFLocaleRef locale) {
+    CFStringRef collatorID;
+    const char *langID = NULL;
+    static const void *lastLocale = NULL;
+    static const char *lastLangID = NULL;
+    static CFSpinLock_t lock = CFSpinLockInit;
+
+    __CFSpinLock(&lock);
+    if ((NULL != lastLocale) && (lastLocale == locale)) {
+        __CFSpinUnlock(&lock);
+        return lastLangID;
+    }
+    __CFSpinUnlock(&lock);
+
+    collatorID = (CFStringRef)CFLocaleGetValue(locale, __kCFLocaleCollatorID);
+
+    // This is somewhat depending on CFLocale implementation always creating CFString for locale identifer ???
+    if (__CFStrLength(collatorID) > 1) {
+        const void *contents = __CFStrContents(collatorID);
+        const char *string;
+        char buffer[2];
+        
+        if (__CFStrIsEightBit(collatorID)) {
+            string = ((const char *)contents) + __CFStrSkipAnyLengthByte(collatorID);
+        } else {
+            const UTF16Char *characters = (const UTF16Char *)contents;
+            
+            buffer[0] = (char)*(characters++);
+            buffer[1] = (char)*characters;
+            string = buffer;
+        }
+        
+        if (!strncmp(string, "az", 2)) { // Azerbaijani
+            langID = "az";
+        } else if (!strncmp(string, "lt", 2)) { // Lithuanian
+            langID = "lt";
+        } else if (!strncmp(string, "tr", 2)) { // Turkish
+            langID = "tr";
+        }
+    }
+
+    __CFSpinLock(&lock);
+    lastLocale = locale;
+    lastLangID = langID;
+    __CFSpinUnlock(&lock);
+
+    return langID;
+}
+
+static int8_t __CFCheckLocaleCFType = -1;
+
+CF_INLINE bool _CFCanUseLocale(CFLocaleRef locale) {
+    if (locale) {
+        if (__CFCheckLocaleCFType < 0) __CFCheckLocaleCFType = !_CFExecutableLinkedOnOrAfter(CFSystemVersionPanther);
+        if (!__CFCheckLocaleCFType || (CFGetTypeID(locale) == CFLocaleGetTypeID())) return true;
+    }
+    return false;
+}
+
+#define MAX_CASE_MAPPING_BUF (8)
+#define ZERO_WIDTH_JOINER (0x200D)
+#define COMBINING_GRAPHEME_JOINER (0x034F)
+// Hangul ranges
+#define HANGUL_CHOSEONG_START (0x1100)
+#define HANGUL_CHOSEONG_END (0x115F)
+#define HANGUL_JUNGSEONG_START (0x1160)
+#define HANGUL_JUNGSEONG_END (0x11A2)
+#define HANGUL_JONGSEONG_START (0x11A8)
+#define HANGUL_JONGSEONG_END (0x11F9)
+
+#define HANGUL_SYLLABLE_START (0xAC00)
+#define HANGUL_SYLLABLE_END (0xD7AF)
+
+
+// Returns the length of characters filled into outCharacters. If no change, returns 0. maxBufLen shoule be at least 8
+static CFIndex __CFStringFoldCharacterClusterAtIndex(UTF32Char character, CFStringInlineBuffer *buffer, CFIndex index, CFOptionFlags flags, const uint8_t *langCode, UTF32Char *outCharacters, CFIndex maxBufferLength, CFIndex *consumedLength) {
+    CFIndex filledLength = 0, currentIndex = index;
+
+    if (0 != character) {
+        UTF16Char lowSurrogate;
+        CFIndex planeNo = (character >> 16);
+        bool isTurkikCapitalI = false;
+        static const uint8_t *decompBMP = NULL;
+        static const uint8_t *graphemeBMP = NULL;
+
+        if (NULL == decompBMP) {
+            decompBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, 0);
+            graphemeBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, 0);
+        }
+
+        ++currentIndex;
+        
+        if ((character < 0x0080) && ((NULL == langCode) || (character != 'I'))) { // ASCII
+            if ((flags & kCFCompareCaseInsensitive) && (character >= 'A') && (character <= 'Z')) {
+                character += ('a' - 'A');
+                *outCharacters = character;
+                filledLength = 1;
+            }
+        } else {
+            // do width-insensitive mapping
+            if ((flags & kCFCompareWidthInsensitive) && (character >= 0xFF00) && (character <= 0xFFEF)) {
+                (void)CFUniCharCompatibilityDecompose(&character, 1, 1);
+                *outCharacters = character;
+                filledLength = 1;
+            }
+
+            // map surrogates
+            if ((0 == planeNo) && CFUniCharIsSurrogateHighCharacter(character) && CFUniCharIsSurrogateLowCharacter((lowSurrogate = CFStringGetCharacterFromInlineBuffer(buffer, currentIndex)))) {
+                character = CFUniCharGetLongCharacterForSurrogatePair(character, lowSurrogate);
+                ++currentIndex;
+                planeNo = (character >> 16);
+            }
+
+            // decompose
+            if (flags & (kCFCompareDiacriticsInsensitiveCompatibilityMask|kCFCompareNonliteral)) {
+                if (CFUniCharIsMemberOfBitmap(character, ((0 == planeNo) ? decompBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, planeNo)))) {
+                    UTF32Char original = character;
+
+                    filledLength = CFUniCharDecomposeCharacter(character, outCharacters, maxBufferLength);
+                    character = *outCharacters;
+
+                    if ((flags & kCFCompareDiacriticsInsensitiveCompatibilityMask) && (character < 0x0510)) {
+                        filledLength = 1; // reset if Roman, Greek, Cyrillic
+                    } else if (0 == (flags & kCFCompareNonliteral)) {
+                        character = original;
+                        filledLength = 0;
+                    }
+                }
+            }
+
+            // fold case
+            if (flags & kCFCompareCaseInsensitive) {
+                const uint8_t *nonBaseBitmap;
+                bool filterNonBase = (((flags & kCFCompareDiacriticsInsensitiveCompatibilityMask) && (character < 0x0510)) ? true : false);
+                static const uint8_t *lowerBMP = NULL;
+                static const uint8_t *caseFoldBMP = NULL;
+                
+                if (NULL == lowerBMP) {
+                    lowerBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharHasNonSelfLowercaseCharacterSet, 0);
+                    caseFoldBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharHasNonSelfCaseFoldingCharacterSet, 0);
+                }
+
+                if ((NULL != langCode) && ('I' == character) && ((0 == strcmp((const char *)langCode, "tr")) || (0 == strcmp((const char *)langCode, "az")))) { // do Turkik special-casing
+                    if (filledLength > 1) {
+                        if (0x0307 == outCharacters[1]) {
+                            if (--filledLength > 1) memmove((outCharacters + 1), (outCharacters + 2), sizeof(UTF32Char) * (filledLength - 1));
+                            character = *outCharacters = 'i';
+                            isTurkikCapitalI = true;
+                        }
+                    } else if (0x0307 == CFStringGetCharacterFromInlineBuffer(buffer, currentIndex)) {
+                        character = *outCharacters = 'i';
+                        filledLength = 1;
+                        ++currentIndex;
+                        isTurkikCapitalI = true;
+                    }
+                }
+                if (!isTurkikCapitalI && (CFUniCharIsMemberOfBitmap(character, ((0 == planeNo) ? lowerBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharHasNonSelfLowercaseCharacterSet, planeNo))) || CFUniCharIsMemberOfBitmap(character, ((0 == planeNo) ? caseFoldBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharHasNonSelfCaseFoldingCharacterSet, planeNo))))) {
+                    UTF16Char caseFoldBuffer[MAX_CASE_MAPPING_BUF];
+                    const UTF16Char *bufferP = caseFoldBuffer, *bufferLimit;
+                    UTF32Char *outCharactersP = outCharacters;
+                    uint32_t bufferLength = CFUniCharMapCaseTo(character, caseFoldBuffer, MAX_CASE_MAPPING_BUF, kCFUniCharCaseFold, 0, langCode);
+                    
+                    bufferLimit = bufferP + bufferLength;
+                    
+                    if (filledLength > 0) --filledLength; // decrement filledLength (will add back later)
+
+                    // make space for casefold characters
+                    if ((filledLength > 0) && (bufferLength > 1)) {
+                        CFIndex totalScalerLength = 0;
+                        
+                        while (bufferP < bufferLimit) {
+                            if (CFUniCharIsSurrogateHighCharacter(*(bufferP++)) && (bufferP < bufferLimit) && CFUniCharIsSurrogateLowCharacter(*bufferP)) ++bufferP;
+                            ++totalScalerLength;
+                        }
+                        memmove(outCharacters + totalScalerLength, outCharacters + 1, filledLength * sizeof(UTF32Char));
+                        bufferP = caseFoldBuffer;
+                    }
+
+                    // fill
+                    while (bufferP < bufferLimit) {
+                        character = *(bufferP++);
+                        if (CFUniCharIsSurrogateHighCharacter(character) && (bufferP < bufferLimit) && CFUniCharIsSurrogateLowCharacter(*bufferP)) {
+                            character = CFUniCharGetLongCharacterForSurrogatePair(character, *(bufferP++));
+                            nonBaseBitmap = CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (character >> 16));
+                        } else {
+                            nonBaseBitmap = graphemeBMP;
+                        }
+
+                        if (!filterNonBase || !CFUniCharIsMemberOfBitmap(character, nonBaseBitmap)) {
+                            *(outCharactersP++) = character;
+                            ++filledLength;
+                        }
+                    }
+                }
+            }
+        }
+
+        // collect following combining marks
+        if (flags & (kCFCompareDiacriticsInsensitiveCompatibilityMask|kCFCompareNonliteral)) {
+            const uint8_t *nonBaseBitmap;
+            const uint8_t *decompBitmap;
+            bool doFill = (((flags & kCFCompareDiacriticsInsensitiveCompatibilityMask) && (character < 0x0510)) ? false : true);
+
+            if (0 == filledLength) {
+                *outCharacters = character; // filledLength will be updated below on demand
+                
+                if (doFill) { // check if really needs to fill
+                    UTF32Char nonBaseCharacter = CFStringGetCharacterFromInlineBuffer(buffer, currentIndex);
+                    
+                    if (CFUniCharIsSurrogateHighCharacter(nonBaseCharacter) && CFUniCharIsSurrogateLowCharacter((lowSurrogate = CFStringGetCharacterFromInlineBuffer(buffer, currentIndex + 1)))) {
+                        nonBaseCharacter = CFUniCharGetLongCharacterForSurrogatePair(nonBaseCharacter, lowSurrogate);
+                        nonBaseBitmap = CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (nonBaseCharacter >> 16));
+                        decompBitmap = CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, (nonBaseCharacter >> 16));
+                    } else {
+                        nonBaseBitmap = graphemeBMP;
+                        decompBitmap = decompBMP;
+                    }
+                    
+                    if (CFUniCharIsMemberOfBitmap(nonBaseCharacter, nonBaseBitmap)) {
+                        filledLength = 1; // For the base character
+                        
+                        if ((0 == (flags & kCFCompareDiacriticsInsensitiveCompatibilityMask)) || (nonBaseCharacter > 0x050F)) {
+                            if (CFUniCharIsMemberOfBitmap(nonBaseCharacter, decompBitmap)) {
+                                filledLength += CFUniCharDecomposeCharacter(nonBaseCharacter, &(outCharacters[filledLength]), maxBufferLength - filledLength);
+                            } else {
+                                outCharacters[filledLength++] = nonBaseCharacter;
+                            }
+                        }
+                        currentIndex += ((nonBaseBitmap == graphemeBMP) ? 1 : 2);
+                    } else {
+                        doFill = false;
+                    }
+                }
+            }
+            
+            while (filledLength < maxBufferLength) { // do the rest
+                character = CFStringGetCharacterFromInlineBuffer(buffer, currentIndex);
+                
+                if (CFUniCharIsSurrogateHighCharacter(character) && CFUniCharIsSurrogateLowCharacter((lowSurrogate = CFStringGetCharacterFromInlineBuffer(buffer, currentIndex + 1)))) {
+                    character = CFUniCharGetLongCharacterForSurrogatePair(character, lowSurrogate);
+                    nonBaseBitmap = CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (character >> 16));
+                    decompBitmap = CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, (character >> 16));
+                } else {
+                    nonBaseBitmap = graphemeBMP;
+                    decompBitmap = decompBMP;
+                }
+                if (isTurkikCapitalI) {
+                    isTurkikCapitalI = false;
+                } else if (CFUniCharIsMemberOfBitmap(character, nonBaseBitmap)) {
+                    if (doFill) {
+                        if (CFUniCharIsMemberOfBitmap(character, decompBitmap)) {
+                            CFIndex currentLength = CFUniCharDecomposeCharacter(character, &(outCharacters[filledLength]), maxBufferLength - filledLength);
+                            
+                            if (0 == currentLength) break; // didn't fit
+                            
+                            filledLength += currentLength;
+                        } else {
+                            outCharacters[filledLength++] = character;
+                        }
+                    } else if (0 == filledLength) {
+                        filledLength = 1; // For the base character
+                    }
+                    currentIndex += ((nonBaseBitmap == graphemeBMP) ? 1 : 2);
+                } else {
+                    break;
+                }
+            }
+
+            if (filledLength > 1) {
+                UTF32Char *sortCharactersLimit = outCharacters + filledLength;
+                UTF32Char *sortCharacters = sortCharactersLimit - 1;
+
+                while ((outCharacters < sortCharacters) && CFUniCharIsMemberOfBitmap(*sortCharacters, ((*sortCharacters < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (*sortCharacters >> 16))))) --sortCharacters;
+
+                if ((sortCharactersLimit - sortCharacters) > 1) CFUniCharPrioritySort(sortCharacters, (sortCharactersLimit - sortCharacters)); // priority sort
+            }
+        }
+    }
+    
+    if ((filledLength > 0) && (NULL != consumedLength)) *consumedLength = (currentIndex - index);
+    
+    return filledLength;
+}
+
+#define kCFStringStackBufferLength (64)
+
+CFComparisonResult CFStringCompareWithOptionsAndLocale(CFStringRef string, CFStringRef string2, CFRange rangeToCompare, CFOptionFlags compareOptions, CFLocaleRef locale) {
+    /* No objc dispatch needed here since CFStringInlineBuffer works with both CFString and NSString */
+    UTF32Char strBuf1[kCFStringStackBufferLength];
+    UTF32Char strBuf2[kCFStringStackBufferLength];
+    CFStringInlineBuffer inlineBuf1, inlineBuf2;
+    UTF32Char str1Char, str2Char;
+    CFIndex str1UsedLen, str2UsedLen;
+    CFIndex str1Index = 0, str2Index = 0, strBuf1Index = 0, strBuf2Index = 0, strBuf1Len = 0, strBuf2Len = 0;
+    CFIndex str2Len = CFStringGetLength(string2);
+    bool caseInsensitive = ((compareOptions & kCFCompareCaseInsensitive) ? true : false);
+    bool diacriticsInsensitive = ((compareOptions & kCFCompareDiacriticsInsensitiveCompatibilityMask) ? true : false);
+    bool equalityOptions = ((compareOptions & (kCFCompareCaseInsensitive|kCFCompareNonliteral|kCFCompareDiacriticsInsensitiveCompatibilityMask|kCFCompareWidthInsensitive)) ? true : false);
+    bool numerically = ((compareOptions & kCFCompareNumerically) ? true : false);
+    const uint8_t *graphemeBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, 0);
+    const uint8_t *langCode;
+    CFComparisonResult compareResult = kCFCompareEqualTo;
+    UTF16Char otherChar;
+    Boolean freeLocale = false;
+
+    #define _CFCompareStringsWithLocale(A, B, C, D, E, F) (0)
+    locale = NULL;
+
+    if ((compareOptions & kCFCompareLocalized) && (NULL == locale)) {
+        locale = CFLocaleCopyCurrent();
+	freeLocale = true;
+    }
+
+    langCode = ((NULL == locale) ? NULL : (const uint8_t *)_CFStrGetLanguageIdentifierForLocale(locale));
+
+    if ((NULL == locale) && !numerically) { // could do binary comp (be careful when adding new flags)
+        CFStringEncoding eightBitEncoding = __CFStringGetEightBitStringEncoding();
+        const uint8_t *str1Bytes = (const uint8_t *)CFStringGetCStringPtr(string, eightBitEncoding);
+        const uint8_t *str2Bytes = (const uint8_t *)CFStringGetCStringPtr(string2, eightBitEncoding);
+        CFIndex factor = sizeof(uint8_t);
+
+        if ((NULL != str1Bytes) && (NULL != str2Bytes)) {
+            compareOptions &= ~kCFCompareNonliteral; // remove non-literal
+
+            if (kCFStringEncodingASCII == eightBitEncoding) {
+                if (caseInsensitive) {
+#if DEPLOYMENT_TARGET_MACOSX
+                    int cmpResult = strncasecmp_l((const char *)str1Bytes + rangeToCompare.location, (const char *)str2Bytes, __CFMin(rangeToCompare.length, str2Len), NULL);
+#elif DEPLOYMENT_TARGET_WINDOWS && !defined(__GNUC__)
+                    int cmpResult = _strnicmp_l((const char*)str1Bytes + rangeToCompare.location, (const char*)str2Bytes, __CFMin(rangeToCompare.length, str2Len), NULL);
+#else
+                    int cmpResult = strncasecmp((const char *)str1Bytes + rangeToCompare.location, (const char *)str2Bytes, __CFMin(rangeToCompare.length, str2Len));
+#endif
+                    
+                    if (0 == cmpResult) cmpResult = rangeToCompare.length - str2Len;
+                    
+                    return ((0 == cmpResult) ? kCFCompareEqualTo : ((cmpResult < 0) ? kCFCompareLessThan : kCFCompareGreaterThan));
+                }
+            } else if (caseInsensitive || diacriticsInsensitive) {
+                CFIndex limitLength = __CFMin(rangeToCompare.length, str2Len);
+
+                str1Bytes += rangeToCompare.location;
+
+                while (str1Index < limitLength) {
+                    str1Char = str1Bytes[str1Index];
+                    str2Char = str2Bytes[str1Index];
+
+                    if (str1Char != str2Char) {
+                        if ((str1Char < 0x80) && (str2Char < 0x80)) {
+                            if ((str1Char >= 'A') && (str1Char <= 'Z')) str1Char += ('a' - 'A');
+                            if ((str2Char >= 'A') && (str2Char <= 'Z')) str2Char += ('a' - 'A');
+
+                            if (str1Char != str2Char) return ((str1Char < str2Char) ? kCFCompareLessThan : kCFCompareGreaterThan);
+                        } else {
+                            str1Bytes = NULL;
+                            break;
+                        }
+                    }
+                    ++str1Index;
+                }
+
+                str2Index = str1Index;
+                
+                if (str1Index == limitLength) {
+                    int cmpResult = rangeToCompare.length - str2Len;
+                    
+                    return ((0 == cmpResult) ? kCFCompareEqualTo : ((cmpResult < 0) ? kCFCompareLessThan : kCFCompareGreaterThan));
+                }
+            }
+        } else if (!equalityOptions && (NULL == str1Bytes) && (NULL == str2Bytes)) {
+            str1Bytes = (const uint8_t *)CFStringGetCharactersPtr(string);
+            str2Bytes = (const uint8_t *)CFStringGetCharactersPtr(string2);
+            factor = sizeof(UTF16Char);
+#if __LITTLE_ENDIAN__
+            if ((NULL != str1Bytes) && (NULL != str2Bytes)) { // we cannot use memcmp
+                const UTF16Char *str1 = ((const UTF16Char *)str1Bytes) + rangeToCompare.location;
+                const UTF16Char *str1Limit = str1 + __CFMin(rangeToCompare.length, str2Len);
+                const UTF16Char *str2 = (const UTF16Char *)str2Bytes;
+                CFIndex cmpResult = 0;
+
+                while ((0 == cmpResult) && (str1 < str1Limit)) cmpResult = (CFIndex)*(str1++) - (CFIndex)*(str2++);
+
+                if (0 == cmpResult) cmpResult = rangeToCompare.length - str2Len;
+                
+                return ((0 == cmpResult) ? kCFCompareEqualTo : ((cmpResult < 0) ? kCFCompareLessThan : kCFCompareGreaterThan));
+            }
+#endif /* __LITTLE_ENDIAN__ */
+        }
+        if ((NULL != str1Bytes) && (NULL != str2Bytes)) {
+            int cmpResult = memcmp(str1Bytes + (rangeToCompare.location * factor), str2Bytes, __CFMin(rangeToCompare.length, str2Len) * factor);
+            
+            if (0 == cmpResult) cmpResult = rangeToCompare.length - str2Len;
+            
+            return ((0 == cmpResult) ? kCFCompareEqualTo : ((cmpResult < 0) ? kCFCompareLessThan : kCFCompareGreaterThan));
+        }
+    }
+
+    CFStringInitInlineBuffer(string, &inlineBuf1, rangeToCompare);
+    CFStringInitInlineBuffer(string2, &inlineBuf2, CFRangeMake(0, str2Len));
+
+    while ((str1Index < rangeToCompare.length) && (str2Index < str2Len)) {
+        if (strBuf1Len == 0) {
+            str1Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index);
+            if (caseInsensitive && (str1Char >= 'A') && (str1Char <= 'Z') && ((NULL == langCode) || (str1Char != 'I'))) str1Char += ('a' - 'A');
+            str1UsedLen = 1;
+        } else {
+            str1Char = strBuf1[strBuf1Index++];
+        }
+        if (strBuf2Len == 0) {
+            str2Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index);
+            if (caseInsensitive && (str2Char >= 'A') && (str2Char <= 'Z') && ((NULL == langCode) || (str2Char != 'I'))) str2Char += ('a' - 'A');
+            str2UsedLen = 1;
+        } else {
+            str2Char = strBuf2[strBuf2Index++];
+        }
+        
+        if (numerically && ((0 == strBuf1Len) && (str1Char <= '9') && (str1Char >= '0')) && ((0 == strBuf2Len) && (str2Char <= '9') && (str2Char >= '0'))) { // If both are not ASCII digits, then don't do numerical comparison here
+            uint64_t intValue1 = 0, intValue2 = 0;	// !!! Doesn't work if numbers are > max uint64_t
+
+            do {
+                intValue1 = (intValue1 * 10) + (str1Char - '0');
+                str1Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, ++str1Index);
+            } while ((str1Char <= '9') && (str1Char >= '0'));
+
+            do {
+                intValue2 = intValue2 * 10 + (str2Char - '0');
+                str2Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, ++str2Index);
+            } while ((str2Char <= '9') && (str2Char >= '0'));
+
+            if (intValue1 == intValue2) {
+                continue;
+            } else if (intValue1 < intValue2) {
+		if (freeLocale && locale) {
+		    CFRelease(locale);
+		}
+                return kCFCompareLessThan;
+            } else {
+		if (freeLocale && locale) {
+		    CFRelease(locale);
+		}
+                return kCFCompareGreaterThan;
+            }
+        }
+
+        if (str1Char != str2Char) {
+            if (!equalityOptions) {
+		CFComparisonResult res = ((NULL == locale) ? ((str1Char < str2Char) ? kCFCompareLessThan : kCFCompareGreaterThan) : _CFCompareStringsWithLocale(&inlineBuf1, CFRangeMake(strBuf1Index, rangeToCompare.length - strBuf1Index), &inlineBuf2, CFRangeMake(strBuf2Index, str2Len - strBuf2Index), compareOptions, locale));
+                if (freeLocale && locale) {
+                    CFRelease(locale);
+                }
+		return res;
+	    }
+
+            if ((compareOptions & kCFCompareForcedOrdering) && (kCFCompareEqualTo == compareResult)) compareResult = ((str1Char < str2Char) ? kCFCompareLessThan : kCFCompareGreaterThan);
+
+            if ((str1Char < 0x80) && (str2Char < 0x80)) {
+                if (NULL != locale) {
+		    CFComparisonResult res = _CFCompareStringsWithLocale(&inlineBuf1, CFRangeMake(strBuf1Index, rangeToCompare.length - strBuf1Index), &inlineBuf2, CFRangeMake(strBuf2Index, str2Len - strBuf2Index), compareOptions, locale);
+		    if (freeLocale && locale) {
+			CFRelease(locale);
+		    }
+		    return res;
+                } else if (!caseInsensitive) {
+		    if (freeLocale && locale) {
+			CFRelease(locale);
+		    }
+                    return ((str1Char < str2Char) ? kCFCompareLessThan : kCFCompareGreaterThan);
+                }
+            }
+
+            if (CFUniCharIsSurrogateHighCharacter(str1Char) && CFUniCharIsSurrogateLowCharacter((otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index + 1)))) {
+                str1Char = CFUniCharGetLongCharacterForSurrogatePair(str1Char, otherChar);
+                str1UsedLen = 2;
+            }
+            
+            if (CFUniCharIsSurrogateHighCharacter(str2Char) && CFUniCharIsSurrogateLowCharacter((otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index + 1)))) {
+                str2Char = CFUniCharGetLongCharacterForSurrogatePair(str2Char, otherChar);
+                str2UsedLen = 2;
+            }
+            
+            if (diacriticsInsensitive && (str1Index > 0)) {
+                bool str1Skip = false;
+                bool str2Skip = false;
+                
+                if ((0 == strBuf1Len) && CFUniCharIsMemberOfBitmap(str1Char, ((str1Char < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (str1Char >> 16))))) {
+                    str1Char = str2Char;
+                    str1Skip = true;
+                }
+                if ((0 == strBuf2Len) && CFUniCharIsMemberOfBitmap(str2Char, ((str2Char < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (str2Char >> 16))))) {
+                    str2Char = str1Char;
+                    str2Skip = true;
+                }
+                
+                if (str1Skip != str2Skip) {
+                    if (str1Skip) str2Index -= str2UsedLen;
+                    if (str2Skip) str1Index -= str1UsedLen;
+                }
+            }
+
+            if (str1Char != str2Char) {
+                if (0 == strBuf1Len) {
+                    strBuf1Len = __CFStringFoldCharacterClusterAtIndex(str1Char, &inlineBuf1, str1Index, compareOptions, langCode, strBuf1, kCFStringStackBufferLength, &str1UsedLen);
+                    if (strBuf1Len > 0) {
+                        str1Char = *strBuf1;
+                        strBuf1Index = 1;
+                    }
+                }
+                
+                if ((0 == strBuf1Len) && (0 < strBuf2Len)) {
+		    CFComparisonResult res =  ((NULL == locale) ? ((str1Char < str2Char) ? kCFCompareLessThan : kCFCompareGreaterThan) : _CFCompareStringsWithLocale(&inlineBuf1, CFRangeMake(strBuf1Index, rangeToCompare.length - strBuf1Index), &inlineBuf2, CFRangeMake(strBuf2Index, str2Len - strBuf2Index), compareOptions, locale));
+		    if (freeLocale && locale) {
+			CFRelease(locale);
+		    }
+		    return res;
+		}
+                
+                if ((0 == strBuf2Len) && ((0 == strBuf1Len) || (str1Char != str2Char))) {
+                    strBuf2Len = __CFStringFoldCharacterClusterAtIndex(str2Char, &inlineBuf2, str2Index, compareOptions, langCode, strBuf2, kCFStringStackBufferLength, &str2UsedLen);
+                    if (strBuf2Len > 0) {
+                        str2Char = *strBuf2;
+                        strBuf2Index = 1;
+                    }
+                    if ((0 == strBuf2Len) || (str1Char != str2Char)) {
+			CFComparisonResult res = ((NULL == locale) ? ((str1Char < str2Char) ? kCFCompareLessThan : kCFCompareGreaterThan) : _CFCompareStringsWithLocale(&inlineBuf1, CFRangeMake(strBuf1Index, rangeToCompare.length - strBuf1Index), &inlineBuf2, CFRangeMake(strBuf2Index, str2Len - strBuf2Index), compareOptions, locale));
+			if (freeLocale && locale) {
+			    CFRelease(locale);
+			}
+			return res;
+		    }
+                }
+            }
+            
+            if ((strBuf1Len > 0) && (strBuf2Len > 0)) {
+                while ((strBuf1Index < strBuf1Len) && (strBuf2Index < strBuf2Len)) {
+                    if (strBuf1[strBuf1Index] != strBuf2[strBuf2Index]) break;
+                    ++strBuf1Index; ++strBuf2Index;
+                }
+                if ((strBuf1Index < strBuf1Len) && (strBuf2Index < strBuf2Len)) {
+		    CFComparisonResult res = ((NULL == locale) ? ((str1Char < str2Char) ? kCFCompareLessThan : kCFCompareGreaterThan) : _CFCompareStringsWithLocale(&inlineBuf1, CFRangeMake(strBuf1Index, rangeToCompare.length - strBuf1Index), &inlineBuf2, CFRangeMake(strBuf2Index, str2Len - strBuf2Index), compareOptions, locale));
+		    if (freeLocale && locale) {
+			CFRelease(locale);
+		    }
+		    return res;
+		}
+            }
+        }
+        
+        if ((strBuf1Len > 0) && (strBuf1Index == strBuf1Len)) strBuf1Len = 0;
+        if ((strBuf2Len > 0) && (strBuf2Index == strBuf2Len)) strBuf2Len = 0;
+        
+        if (strBuf1Len == 0) str1Index += str1UsedLen;
+        if (strBuf2Len == 0) str2Index += str2UsedLen;
+    }
+
+    if (diacriticsInsensitive) {
+        while (str1Index < rangeToCompare.length) {
+            str1Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index);
+            if (str1Char < 0x80) break; // found ASCII
+
+            if (CFUniCharIsSurrogateHighCharacter(str1Char) && CFUniCharIsSurrogateLowCharacter((otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index + 1)))) str1Char = CFUniCharGetLongCharacterForSurrogatePair(str1Char, otherChar);
+
+            if (!CFUniCharIsMemberOfBitmap(str1Char, ((str1Char < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (str1Char >> 16))))) break;
+
+            str1Index += ((str1Char < 0x10000) ? 1 : 2);
+        }
+
+        while (str2Index < str2Len) {
+            str2Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index);
+            if (str2Char < 0x80) break; // found ASCII
+                
+            if (CFUniCharIsSurrogateHighCharacter(str2Char) && CFUniCharIsSurrogateLowCharacter((otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index + 1)))) str2Char = CFUniCharGetLongCharacterForSurrogatePair(str2Char, otherChar);
+
+            if (!CFUniCharIsMemberOfBitmap(str2Char, ((str2Char < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (str2Char >> 16))))) break;
+
+            str2Index += ((str2Char < 0x10000) ? 1 : 2);
+        }
+    }
+
+    if (freeLocale && locale) {
+	CFRelease(locale);
+    }
+
+    return ((str1Index < rangeToCompare.length) ? kCFCompareGreaterThan : ((str2Index < str2Len) ? kCFCompareLessThan : compareResult));
+}
+
+
+CFComparisonResult CFStringCompareWithOptions(CFStringRef string, CFStringRef string2, CFRange rangeToCompare, CFOptionFlags compareOptions) { return CFStringCompareWithOptionsAndLocale(string, string2, rangeToCompare, compareOptions, NULL); }
+
+CFComparisonResult CFStringCompare(CFStringRef string, CFStringRef str2, CFOptionFlags options) {
+    return CFStringCompareWithOptions(string, str2, CFRangeMake(0, CFStringGetLength(string)), options);
+}
+
+Boolean CFStringFindWithOptionsAndLocale(CFStringRef string, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions, CFLocaleRef locale, CFRange *result)  {
+    /* No objc dispatch needed here since CFStringInlineBuffer works with both CFString and NSString */
+    CFIndex findStrLen = CFStringGetLength(stringToFind);
+    Boolean didFind = false;
+    bool lengthVariants = ((compareOptions & (kCFCompareCaseInsensitive|kCFCompareNonliteral|kCFCompareDiacriticsInsensitiveCompatibilityMask)) ? true : false);
+
+    if ((findStrLen > 0) && (rangeToSearch.length > 0) && ((findStrLen <= rangeToSearch.length) || lengthVariants)) {
+        UTF32Char strBuf1[kCFStringStackBufferLength];
+        UTF32Char strBuf2[kCFStringStackBufferLength];
+        CFStringInlineBuffer inlineBuf1, inlineBuf2;
+        UTF32Char str1Char, str2Char;
+        CFStringEncoding eightBitEncoding = __CFStringGetEightBitStringEncoding();
+        const uint8_t *str1Bytes = (const uint8_t *)CFStringGetCStringPtr(string, eightBitEncoding);
+        const uint8_t *str2Bytes = (const uint8_t *)CFStringGetCStringPtr(stringToFind, eightBitEncoding);
+        const UTF32Char *characters, *charactersLimit;
+        const uint8_t *langCode = NULL;
+        CFIndex fromLoc, toLoc;
+        CFIndex str1Index, str2Index;
+        CFIndex strBuf1Len, strBuf2Len;
+        bool equalityOptions = ((lengthVariants || (compareOptions & kCFCompareWidthInsensitive)) ? true : false);
+        bool caseInsensitive = ((compareOptions & kCFCompareCaseInsensitive) ? true : false);
+        int8_t delta;
+
+        if (NULL == locale) {
+            if (compareOptions & kCFCompareLocalized) {
+                CFLocaleRef currentLocale = CFLocaleCopyCurrent();
+                langCode = (const uint8_t *)_CFStrGetLanguageIdentifierForLocale(currentLocale);
+                CFRelease(currentLocale);
+            }
+        } else {
+            langCode = (const uint8_t *)_CFStrGetLanguageIdentifierForLocale(locale);
+        }
+
+        CFStringInitInlineBuffer(string, &inlineBuf1, CFRangeMake(0, rangeToSearch.location + rangeToSearch.length));
+        CFStringInitInlineBuffer(stringToFind, &inlineBuf2, CFRangeMake(0, findStrLen));
+
+        if (compareOptions & kCFCompareBackwards) {
+            fromLoc = rangeToSearch.location + rangeToSearch.length - (lengthVariants ? 1 : findStrLen);
+            toLoc = (((compareOptions & kCFCompareAnchored) && !lengthVariants) ? fromLoc : rangeToSearch.location);
+        } else {
+            fromLoc = rangeToSearch.location;
+            toLoc = ((compareOptions & kCFCompareAnchored) ? fromLoc : rangeToSearch.location + rangeToSearch.length - (lengthVariants ? 1 : findStrLen));
+        }
+        
+        delta = ((fromLoc <= toLoc) ? 1 : -1);
+
+        if ((NULL != str1Bytes) && (NULL != str2Bytes)) {
+            CFIndex maxStr1Index = (rangeToSearch.location + rangeToSearch.length);
+            uint8_t str1Byte, str2Byte;
+
+            while (1) {
+                str1Index = fromLoc;
+                str2Index = 0;
+
+                while ((str1Index < maxStr1Index) && (str2Index < findStrLen)) {
+                    str1Byte = str1Bytes[str1Index];
+                    str2Byte = str2Bytes[str2Index];
+
+                    if (str1Byte != str2Byte) {
+                        if (equalityOptions) {
+                            if ((str1Byte < 0x80) && ((NULL == langCode) || ('I' != str1Byte))) {
+                                if (caseInsensitive && (str1Byte >= 'A') && (str1Byte <= 'Z')) str1Byte += ('a' - 'A');
+                                *strBuf1 = str1Byte;
+                                strBuf1Len = 1;
+                            } else {
+                                str1Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index);
+                                strBuf1Len = __CFStringFoldCharacterClusterAtIndex(str1Char, &inlineBuf1, str1Index, compareOptions, langCode, strBuf1, kCFStringStackBufferLength, NULL);
+                                if (1 > strBuf1Len) {
+                                    *strBuf1 = str1Char;
+                                    strBuf1Len = 1;
+                                }
+                            }
+                            if ((str2Byte < 0x80) && ((NULL == langCode) || ('I' != str2Byte))) {
+                                if (caseInsensitive && (str2Byte >= 'A') && (str2Byte <= 'Z')) str2Byte += ('a' - 'A');
+                                *strBuf2 = str2Byte;
+                                strBuf2Len = 1;
+                            } else {
+                                str2Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index);
+                                strBuf2Len = __CFStringFoldCharacterClusterAtIndex(str2Char, &inlineBuf2, str2Index, compareOptions, langCode, strBuf2, kCFStringStackBufferLength, NULL);
+                                if (1 > strBuf2Len) {
+                                    *strBuf2 = str2Char;
+                                    strBuf2Len = 1;
+                                }
+                            }
+
+                            if ((1 == strBuf1Len) && (1 == strBuf2Len)) { // normal case
+                                if (*strBuf1 != *strBuf2) break;
+                            } else {
+                                CFIndex delta;
+
+                                if (!caseInsensitive && (strBuf1Len != strBuf2Len)) break;
+                                if (memcmp(strBuf1, strBuf2, sizeof(UTF32Char) * __CFMin(strBuf1Len, strBuf2Len))) break;
+
+                                if (strBuf1Len < strBuf2Len) {
+                                    delta = strBuf2Len - strBuf1Len;
+
+                                    if ((str1Index + strBuf1Len + delta) > (rangeToSearch.location + rangeToSearch.length)) break;
+
+                                    characters = &(strBuf2[strBuf1Len]);
+                                    charactersLimit = characters + delta;
+
+                                    while (characters < charactersLimit) {
+                                        strBuf1Len = __CFStringFoldCharacterClusterAtIndex(CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index + 1), &inlineBuf1, str1Index + 1, compareOptions, langCode, strBuf1, kCFStringStackBufferLength, NULL);
+                                        if ((strBuf1Len > 0) || (*characters != *strBuf1)) break;
+                                        ++characters; ++str1Index;
+                                    }
+                                    if (characters < charactersLimit) break;
+                                } else if (strBuf2Len < strBuf1Len) {
+                                    delta = strBuf1Len - strBuf2Len;
+                                    
+                                    if ((str2Index + strBuf2Len + delta) > findStrLen) break;
+                                    
+                                    characters = &(strBuf1[strBuf2Len]);
+                                    charactersLimit = characters + delta;
+                                    
+                                    while (characters < charactersLimit) {
+                                        strBuf2Len = __CFStringFoldCharacterClusterAtIndex(CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str1Index + 1), &inlineBuf2, str2Index + 1, compareOptions, langCode, strBuf2, kCFStringStackBufferLength, NULL);
+                                        if ((strBuf2Len > 0) || (*characters != *strBuf2)) break;
+                                        ++characters; ++str2Index;
+                                    }
+                                    if (characters < charactersLimit) break;
+                                }
+                            }
+                        } else {
+                            break;
+                        }
+                    }
+                    ++str1Index; ++str2Index;
+                }
+
+                if (str2Index == findStrLen) {
+                    if (((kCFCompareBackwards|kCFCompareAnchored) != (compareOptions & (kCFCompareBackwards|kCFCompareAnchored))) || (str1Index == (rangeToSearch.location + rangeToSearch.length))) {
+                        didFind = true;
+                        if (NULL != result) *result = CFRangeMake(fromLoc, str1Index - fromLoc);
+                    }
+                    break;
+                }
+
+                if (fromLoc == toLoc) break;
+                fromLoc += delta;
+            }
+        } else if (equalityOptions) {
+            UTF16Char otherChar;
+            CFIndex str1UsedLen, str2UsedLen, strBuf1Index = 0, strBuf2Index = 0;
+            bool diacriticsInsensitive = ((compareOptions & kCFCompareDiacriticsInsensitiveCompatibilityMask) ? true : false);
+            const uint8_t *graphemeBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, 0);
+            const uint8_t *combClassBMP = (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, 0);
+
+            while (1) {
+                str1Index = fromLoc;
+                str2Index = 0;
+
+                strBuf1Len = strBuf2Len = 0;
+
+                while (str2Index < findStrLen) {
+                    if (strBuf1Len == 0) {
+                        str1Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index);
+                        if (caseInsensitive && (str1Char >= 'A') && (str1Char <= 'Z') && ((NULL == langCode) || (str1Char != 'I'))) str1Char += ('a' - 'A');
+                        str1UsedLen = 1;
+                    } else {
+                        str1Char = strBuf1[strBuf1Index++];
+                    }
+                    if (strBuf2Len == 0) {
+                        str2Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index);
+                        if (caseInsensitive && (str2Char >= 'A') && (str2Char <= 'Z') && ((NULL == langCode) || (str2Char != 'I'))) str2Char += ('a' - 'A');
+                        str2UsedLen = 1;
+                    } else {
+                        str2Char = strBuf2[strBuf2Index++];
+                    }
+
+                    if (str1Char != str2Char) {
+                        if ((str1Char < 0x80) && (str2Char < 0x80) && ((NULL == langCode) || !caseInsensitive)) break;
+
+                        if (CFUniCharIsSurrogateHighCharacter(str1Char) && CFUniCharIsSurrogateLowCharacter((otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index + 1)))) {
+                            str1Char = CFUniCharGetLongCharacterForSurrogatePair(str1Char, otherChar);
+                            str1UsedLen = 2;
+                        }
+
+                        if (CFUniCharIsSurrogateHighCharacter(str2Char) && CFUniCharIsSurrogateLowCharacter((otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index + 1)))) {
+                            str2Char = CFUniCharGetLongCharacterForSurrogatePair(str2Char, otherChar);
+                            str2UsedLen = 2;
+                        }
+
+                        if (diacriticsInsensitive && (str1Index > fromLoc)) {
+                            bool str1Skip = false;
+                            bool str2Skip = false;
+
+                            if ((0 == strBuf1Len) && CFUniCharIsMemberOfBitmap(str1Char, ((str1Char < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (str1Char >> 16))))) {
+                                str1Char = str2Char;
+                                str1Skip = true;
+                            }
+                            if ((0 == strBuf2Len) && CFUniCharIsMemberOfBitmap(str2Char, ((str2Char < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (str2Char >> 16))))) {
+                                str2Char = str1Char;
+                                str2Skip = true;
+                            }
+
+                            if (str1Skip != str2Skip) {
+                                if (str1Skip) str2Index -= str2UsedLen;
+                                if (str2Skip) str1Index -= str1UsedLen;
+                            }
+                        }
+
+                        if (str1Char != str2Char) {
+                            if (0 == strBuf1Len) {
+                                strBuf1Len = __CFStringFoldCharacterClusterAtIndex(str1Char, &inlineBuf1, str1Index, compareOptions, langCode, strBuf1, kCFStringStackBufferLength, &str1UsedLen);
+                                if (strBuf1Len > 0) {
+                                    str1Char = *strBuf1;
+                                    strBuf1Index = 1;
+                                }
+                            }
+
+                            if ((0 == strBuf1Len) && (0 < strBuf2Len)) break;
+
+                            if ((0 == strBuf2Len) && ((0 == strBuf1Len) || (str1Char != str2Char))) {
+                                strBuf2Len = __CFStringFoldCharacterClusterAtIndex(str2Char, &inlineBuf2, str2Index, compareOptions, langCode, strBuf2, kCFStringStackBufferLength, &str2UsedLen);
+                                if ((0 == strBuf2Len) || (str1Char != *strBuf2)) break;
+                                strBuf2Index = 1;
+                            }
+                        }
+
+                        if ((strBuf1Len > 0) && (strBuf2Len > 0)) {
+                            while ((strBuf1Index < strBuf1Len) && (strBuf2Index < strBuf2Len)) {
+                                if (strBuf1[strBuf1Index] != strBuf2[strBuf2Index]) break;
+                                ++strBuf1Index; ++strBuf2Index;
+                            }
+                            if ((strBuf1Index < strBuf1Len) && (strBuf2Index < strBuf2Len)) break;
+                        }
+                    }
+                    
+                    if ((strBuf1Len > 0) && (strBuf1Index == strBuf1Len)) strBuf1Len = 0;
+                    if ((strBuf2Len > 0) && (strBuf2Index == strBuf2Len)) strBuf2Len = 0;
+
+                    if (strBuf1Len == 0) str1Index += str1UsedLen;
+                    if (strBuf2Len == 0) str2Index += str2UsedLen;
+                }
+
+                if (str2Index == findStrLen) {
+                    bool match = true;
+
+                    if (strBuf1Len > 0) {
+                        match = false;
+
+                        if ((compareOptions & kCFCompareDiacriticsInsensitiveCompatibilityMask) && (strBuf1[0] < 0x0510)) {
+                            while (strBuf1Index < strBuf1Len) {
+                                if (!CFUniCharIsMemberOfBitmap(strBuf1[strBuf1Index], ((strBuf1[strBuf1Index] < 0x10000) ? graphemeBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, (strBuf1[strBuf1Index] >> 16))))) break;
+                                ++strBuf1Index;
+                            }
+
+                            if (strBuf1Index == strBuf1Len) {
+                                str1Index += str1UsedLen;
+                                match = true;
+                            }
+                        }
+                    }
+
+                    if (match && (compareOptions & (kCFCompareDiacriticsInsensitiveCompatibilityMask|kCFCompareNonliteral)) && (str1Index < (rangeToSearch.location + rangeToSearch.length))) {
+                        const uint8_t *nonBaseBitmap;
+
+                        str1Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index);
+                        
+                        if (CFUniCharIsSurrogateHighCharacter(str1Char) && CFUniCharIsSurrogateLowCharacter((otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index + 1)))) {
+                            str1Char = CFUniCharGetLongCharacterForSurrogatePair(str1Char, otherChar);
+                            nonBaseBitmap = CFUniCharGetBitmapPtrForPlane(kCFUniCharGraphemeExtendCharacterSet, (str1Char >> 16));
+                        } else {
+                            nonBaseBitmap = graphemeBMP;
+                        }
+
+                        if (CFUniCharIsMemberOfBitmap(str1Char, nonBaseBitmap)) {
+                            if (diacriticsInsensitive) {
+                                if (str1Char < 0x10000) {
+                                    CFIndex index = str1Index;
+
+                                    do {
+                                        str1Char = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, --index);
+                                    } while (CFUniCharIsMemberOfBitmap(str1Char, graphemeBMP), (rangeToSearch.location < index));
+
+                                    if (str1Char < 0x0510) {
+                                        CFIndex maxIndex = (rangeToSearch.location + rangeToSearch.length);
+
+                                        while (++str1Index < maxIndex) if (!CFUniCharIsMemberOfBitmap(CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index), graphemeBMP)) break;
+                                    }
+                                }
+                            } else {
+                                match = false;
+                            }
+                        } else if (!diacriticsInsensitive) {
+                            otherChar = CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index - 1);
+                            
+                            // this is assuming viramas are only in BMP ???
+                            if ((str1Char == COMBINING_GRAPHEME_JOINER) || (otherChar == COMBINING_GRAPHEME_JOINER) || (otherChar == ZERO_WIDTH_JOINER) || ((otherChar >= HANGUL_CHOSEONG_START) && (otherChar <= HANGUL_JONGSEONG_END)) || (CFUniCharGetCombiningPropertyForCharacter(otherChar, combClassBMP) == 9)) {
+                                CFRange clusterRange = CFStringGetRangeOfCharacterClusterAtIndex(string, str1Index - 1, kCFStringGraphemeCluster);
+                                
+                                if (str1Index < (clusterRange.location + clusterRange.length)) match = false;
+                            }
+                        }
+                    }
+
+                    if (match) {
+                        if (((kCFCompareBackwards|kCFCompareAnchored) != (compareOptions & (kCFCompareBackwards|kCFCompareAnchored))) || (str1Index == (rangeToSearch.location + rangeToSearch.length))) {
+                            didFind = true;
+                            if (NULL != result) *result = CFRangeMake(fromLoc, str1Index - fromLoc);
+                        }
+                        break;
+                    }
+                }
+                
+                if (fromLoc == toLoc) break;
+                fromLoc += delta;
+            }
+        } else {
+            while (1) {
+                str1Index = fromLoc;
+                str2Index = 0;
+                
+                while (str2Index < findStrLen) {
+                    if (CFStringGetCharacterFromInlineBuffer(&inlineBuf1, str1Index) != CFStringGetCharacterFromInlineBuffer(&inlineBuf2, str2Index)) break;
+
+                    ++str1Index; ++str2Index;
+                }
+                
+                if (str2Index == findStrLen) {
+                    didFind = true;
+                    if (NULL != result) *result = CFRangeMake(fromLoc, findStrLen);
+                    break;
+                }
+                
+                if (fromLoc == toLoc) break;
+                fromLoc += delta;
+            }
+        }
+    }
+
+    return didFind;
+}
+
+Boolean CFStringFindWithOptions(CFStringRef string, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions, CFRange *result) { return CFStringFindWithOptionsAndLocale(string, stringToFind, rangeToSearch, compareOptions, NULL, result); }
+
+// Functions to deal with special arrays of CFRange, CFDataRef, created by CFStringCreateArrayWithFindResults()
+
+static const void *__rangeRetain(CFAllocatorRef allocator, const void *ptr) {
+    CFRetain(*(CFDataRef *)((uint8_t *)ptr + sizeof(CFRange)));
+    return ptr;
+}
+
+static void __rangeRelease(CFAllocatorRef allocator, const void *ptr) {
+    CFRelease(*(CFDataRef *)((uint8_t *)ptr + sizeof(CFRange)));
+}
+
+static CFStringRef __rangeCopyDescription(const void *ptr) {
+    CFRange range = *(CFRange *)ptr;
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("{%d, %d}"), range.location, range.length);
+}
+
+static Boolean	__rangeEqual(const void *ptr1, const void *ptr2) {
+    CFRange range1 = *(CFRange *)ptr1;
+    CFRange range2 = *(CFRange *)ptr2;
+    return (range1.location == range2.location) && (range1.length == range2.length);
+}
+
+
+CFArrayRef CFStringCreateArrayWithFindResults(CFAllocatorRef alloc, CFStringRef string, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) {
+    CFRange foundRange;
+    Boolean backwards = ((compareOptions & kCFCompareBackwards) != 0);
+    UInt32 endIndex = rangeToSearch.location + rangeToSearch.length;
+    CFMutableDataRef rangeStorage = NULL;	// Basically an array of CFRange, CFDataRef (packed)
+    uint8_t *rangeStorageBytes = NULL;
+    CFIndex foundCount = 0;
+    CFIndex capacity = 0;		// Number of CFRange, CFDataRef element slots in rangeStorage
+    
+    if (alloc == NULL) alloc = __CFGetDefaultAllocator();
+
+    while ((rangeToSearch.length > 0) && CFStringFindWithOptions(string, stringToFind, rangeToSearch, compareOptions, &foundRange)) {
+	// Determine the next range
+        if (backwards) {
+            rangeToSearch.length = foundRange.location - rangeToSearch.location;
+        } else {
+            rangeToSearch.location = foundRange.location + foundRange.length;
+            rangeToSearch.length = endIndex - rangeToSearch.location;
+        }
+
+	// If necessary, grow the data and squirrel away the found range 
+	if (foundCount >= capacity) {
+	    if (rangeStorage == NULL) rangeStorage = CFDataCreateMutable(alloc, 0);
+	    capacity = (capacity + 4) * 2;
+	    CFDataSetLength(rangeStorage, capacity * (sizeof(CFRange) + sizeof(CFDataRef)));
+	    rangeStorageBytes = (uint8_t *)CFDataGetMutableBytePtr(rangeStorage) + foundCount * (sizeof(CFRange) + sizeof(CFDataRef));
+	}
+	memmove(rangeStorageBytes, &foundRange, sizeof(CFRange));	// The range
+	memmove(rangeStorageBytes + sizeof(CFRange), &rangeStorage, sizeof(CFDataRef));	// The data
+	rangeStorageBytes += (sizeof(CFRange) + sizeof(CFDataRef));
+	foundCount++;
+    }
+
+    if (foundCount > 0) {
+	CFIndex cnt;
+	CFMutableArrayRef array;
+        const CFArrayCallBacks callbacks = {0, __rangeRetain, __rangeRelease, __rangeCopyDescription, __rangeEqual};
+
+	CFDataSetLength(rangeStorage, foundCount * (sizeof(CFRange) + sizeof(CFDataRef)));	// Tighten storage up
+	rangeStorageBytes = (uint8_t *)CFDataGetMutableBytePtr(rangeStorage);
+
+        array = CFArrayCreateMutable(alloc, foundCount * sizeof(CFRange *), &callbacks);
+	for (cnt = 0; cnt < foundCount; cnt++) {
+	    // Each element points to the appropriate CFRange in the CFData
+	    CFArrayAppendValue(array, rangeStorageBytes + cnt * (sizeof(CFRange) + sizeof(CFDataRef)));
+	}
+        CFRelease(rangeStorage);		// We want the data to go away when all CFRanges inside it are released...
+        return array;
+    } else {
+        return NULL;
+    }
+}
+
+
+CFRange CFStringFind(CFStringRef string, CFStringRef stringToFind, CFOptionFlags compareOptions) {
+    CFRange foundRange;
+
+    if (CFStringFindWithOptions(string, stringToFind, CFRangeMake(0, CFStringGetLength(string)), compareOptions, &foundRange)) {
+        return foundRange;
+    } else {
+        return CFRangeMake(kCFNotFound, 0);
+    }
+}
+
+Boolean CFStringHasPrefix(CFStringRef string, CFStringRef prefix) {
+    return CFStringFindWithOptions(string, prefix, CFRangeMake(0, CFStringGetLength(string)), kCFCompareAnchored, NULL);
+}
+
+Boolean CFStringHasSuffix(CFStringRef string, CFStringRef suffix) {
+    return CFStringFindWithOptions(string, suffix, CFRangeMake(0, CFStringGetLength(string)), kCFCompareAnchored|kCFCompareBackwards, NULL);
+}
+
+#define MAX_TRANSCODING_LENGTH 4
+
+#define HANGUL_JONGSEONG_COUNT (28)
+
+CF_INLINE bool _CFStringIsHangulLVT(UTF32Char character) {
+    return (((character - HANGUL_SYLLABLE_START) % HANGUL_JONGSEONG_COUNT) ? true : false);
+}
+
+static uint8_t __CFTranscodingHintLength[] = {
+    2, 3, 4, 4, 4, 4, 4, 2, 2, 2, 2, 4, 0, 0, 0, 0
+};
+
+enum {
+    kCFStringHangulStateL,
+    kCFStringHangulStateV,
+    kCFStringHangulStateT,
+    kCFStringHangulStateLV,
+    kCFStringHangulStateLVT,
+    kCFStringHangulStateBreak
+};
+
+static CFRange _CFStringInlineBufferGetComposedRange(CFStringInlineBuffer *buffer, CFIndex start, CFStringCharacterClusterType type, const uint8_t *bmpBitmap, CFIndex csetType) {
+    CFIndex end = start + 1;
+    const uint8_t *bitmap = bmpBitmap;
+    UTF32Char character;
+    UTF16Char otherSurrogate;
+    uint8_t step;
+
+    character = CFStringGetCharacterFromInlineBuffer(buffer, start);
+
+    // We don't combine characters in Armenian ~ Limbu range for backward deletion
+    if ((type != kCFStringBackwardDeletionCluster) || (character < 0x0530) || (character > 0x194F)) {
+        // Check if the current is surrogate
+        if (CFUniCharIsSurrogateHighCharacter(character) && CFUniCharIsSurrogateLowCharacter((otherSurrogate = CFStringGetCharacterFromInlineBuffer(buffer, start + 1)))) {
+            ++end;
+            character = CFUniCharGetLongCharacterForSurrogatePair(character, otherSurrogate);
+            bitmap = CFUniCharGetBitmapPtrForPlane(csetType, (character >> 16));
+        }
+
+        // Extend backward
+        while (start > 0) {
+            if ((type == kCFStringBackwardDeletionCluster) && (character >= 0x0530) && (character < 0x1950)) break;
+
+            if (character < 0x10000) { // the first round could be already be non-BMP
+                if (CFUniCharIsSurrogateLowCharacter(character) && CFUniCharIsSurrogateHighCharacter((otherSurrogate = CFStringGetCharacterFromInlineBuffer(buffer, start - 1)))) {
+                    character = CFUniCharGetLongCharacterForSurrogatePair(otherSurrogate, character);
+                    bitmap = CFUniCharGetBitmapPtrForPlane(csetType, (character >> 16));
+                    --start;
+                } else {
+                    bitmap = bmpBitmap;
+                }
+            }
+
+            if (!CFUniCharIsMemberOfBitmap(character, bitmap) && (character != 0xFF9E) && (character != 0xFF9F) && ((character & 0x1FFFF0) != 0xF870)) break;
+    
+            --start;
+    
+            character = CFStringGetCharacterFromInlineBuffer(buffer, start);
+        }
+    }
+
+    // Hangul
+    if (((character >= HANGUL_CHOSEONG_START) && (character <= HANGUL_JONGSEONG_END)) || ((character >= HANGUL_SYLLABLE_START) && (character <= HANGUL_SYLLABLE_END))) {
+        uint8_t state;
+        uint8_t initialState;
+
+        if (character < HANGUL_JUNGSEONG_START) {
+            state = kCFStringHangulStateL;
+        } else if (character < HANGUL_JONGSEONG_START) {
+            state = kCFStringHangulStateV;
+        } else if (character < HANGUL_SYLLABLE_START) {
+            state = kCFStringHangulStateT;
+        } else {
+            state = (_CFStringIsHangulLVT(character) ? kCFStringHangulStateLVT : kCFStringHangulStateLV);
+        }
+        initialState = state;
+
+        // Extend backward
+        while (((character = CFStringGetCharacterFromInlineBuffer(buffer, start - 1)) >= HANGUL_CHOSEONG_START) && (character <= HANGUL_SYLLABLE_END) && ((character <= HANGUL_JONGSEONG_END) || (character >= HANGUL_SYLLABLE_START))) {
+            switch (state) {
+            case kCFStringHangulStateV:
+                if (character <= HANGUL_CHOSEONG_END) {
+                    state = kCFStringHangulStateL;
+                } else if ((character >= HANGUL_SYLLABLE_START) && (character <= HANGUL_SYLLABLE_END) && !_CFStringIsHangulLVT(character)) {
+                    state = kCFStringHangulStateLV;
+                } else if (character > HANGUL_JUNGSEONG_END) {
+                    state = kCFStringHangulStateBreak;
+                }
+                break;
+
+            case kCFStringHangulStateT:
+                if ((character >= HANGUL_JUNGSEONG_START) && (character <= HANGUL_JUNGSEONG_END)) {
+                    state = kCFStringHangulStateV;
+                } else if ((character >= HANGUL_SYLLABLE_START) && (character <= HANGUL_SYLLABLE_END)) {
+                    state = (_CFStringIsHangulLVT(character) ? kCFStringHangulStateLVT : kCFStringHangulStateLV);
+                } else if (character < HANGUL_JUNGSEONG_START) {
+                    state = kCFStringHangulStateBreak;
+                }
+                break;
+
+            default:
+                state = ((character < HANGUL_JUNGSEONG_START) ? kCFStringHangulStateL : kCFStringHangulStateBreak);
+                break;
+            }
+
+            if (state == kCFStringHangulStateBreak) break;
+            --start;
+        }
+
+        // Extend forward
+        state = initialState;
+        while (((character = CFStringGetCharacterFromInlineBuffer(buffer, end)) > 0) && (((character >= HANGUL_CHOSEONG_START) && (character <= HANGUL_JONGSEONG_END)) || ((character >= HANGUL_SYLLABLE_START) && (character <= HANGUL_SYLLABLE_END)))) {
+            switch (state) {
+            case kCFStringHangulStateLV:
+            case kCFStringHangulStateV:
+                if ((character >= HANGUL_JUNGSEONG_START) && (character <= HANGUL_JONGSEONG_END)) {
+                    state = ((character < HANGUL_JONGSEONG_START) ? kCFStringHangulStateV : kCFStringHangulStateT);
+                } else {
+                    state = kCFStringHangulStateBreak;
+                }
+                break;
+
+            case kCFStringHangulStateLVT:
+            case kCFStringHangulStateT:
+                state = (((character >= HANGUL_JONGSEONG_START) && (character <= HANGUL_JONGSEONG_END)) ? kCFStringHangulStateT : kCFStringHangulStateBreak);
+                break;
+
+            default:
+                if (character < HANGUL_JUNGSEONG_START) {
+                    state = kCFStringHangulStateL;
+                } else if (character < HANGUL_JONGSEONG_START) {
+                    state = kCFStringHangulStateV;
+                } else if (character >= HANGUL_SYLLABLE_START) {
+                    state = (_CFStringIsHangulLVT(character) ? kCFStringHangulStateLVT : kCFStringHangulStateLV);
+                } else {
+                    state = kCFStringHangulStateBreak;
+                }
+                break;
+            }
+
+            if (state == kCFStringHangulStateBreak) break;
+            ++end;
+        }
+    }
+
+    // Extend forward
+    while ((character = CFStringGetCharacterFromInlineBuffer(buffer, end)) > 0) {
+        if ((type == kCFStringBackwardDeletionCluster) && (character >= 0x0530) && (character < 0x1950)) break;
+    
+        if (CFUniCharIsSurrogateHighCharacter(character) && CFUniCharIsSurrogateLowCharacter((otherSurrogate = CFStringGetCharacterFromInlineBuffer(buffer, end + 1)))) {
+            character = CFUniCharGetLongCharacterForSurrogatePair(character, otherSurrogate);
+            bitmap = CFUniCharGetBitmapPtrForPlane(csetType, (character >> 16));
+            step = 2;
+        } else {
+            bitmap = bmpBitmap;
+            step  = 1;
+        }
+
+        if (!CFUniCharIsMemberOfBitmap(character, bitmap) && (character != 0xFF9E) && (character != 0xFF9F) && ((character & 0x1FFFF0) != 0xF870)) break;
+
+        end += step;
+    } 
+
+    return CFRangeMake(start, end - start);
+}
+
+CF_INLINE bool _CFStringIsVirama(UTF32Char character, const uint8_t *combClassBMP) {
+    return ((character == COMBINING_GRAPHEME_JOINER) || (CFUniCharGetCombiningPropertyForCharacter(character, (const uint8_t *)((character < 0x10000) ? combClassBMP : CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (character >> 16)))) == 9) ? true : false);
+}
+
+CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type) {
+    CFRange range;
+    CFIndex currentIndex;
+    CFIndex length = CFStringGetLength(string);
+    CFIndex csetType = ((kCFStringGraphemeCluster == type) ? kCFUniCharGraphemeExtendCharacterSet : kCFUniCharNonBaseCharacterSet);
+    CFStringInlineBuffer stringBuffer;
+    const uint8_t *bmpBitmap;
+    const uint8_t *letterBMP;
+    const uint8_t *combClassBMP;
+    UTF32Char character;
+    UTF16Char otherSurrogate;
+
+    if (charIndex >= length) return CFRangeMake(kCFNotFound, 0);
+
+    /* Fast case.  If we're eight-bit, it's either the default encoding is cheap or the content is all ASCII.  Watch out when (or if) adding more 8bit Mac-scripts in CFStringEncodingConverters
+    */
+    if (!CF_IS_OBJC(__kCFStringTypeID, string) && __CFStrIsEightBit(string)) return CFRangeMake(charIndex, 1);
+
+    bmpBitmap = CFUniCharGetBitmapPtrForPlane(csetType, 0);
+    letterBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharLetterCharacterSet, 0);
+    combClassBMP = (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, 0);
+
+    CFStringInitInlineBuffer(string, &stringBuffer, CFRangeMake(0, length));
+
+    // Get composed character sequence first
+    range = _CFStringInlineBufferGetComposedRange(&stringBuffer, charIndex, type, bmpBitmap, csetType);
+
+    // Do grapheme joiners
+    if (type < kCFStringCursorMovementCluster) {
+        const uint8_t *letter = letterBMP;
+
+        // Check to see if we have a letter at the beginning of initial cluster
+        character = CFStringGetCharacterFromInlineBuffer(&stringBuffer, range.location);
+
+        if ((range.length > 1) && CFUniCharIsSurrogateHighCharacter(character) && CFUniCharIsSurrogateLowCharacter((otherSurrogate = CFStringGetCharacterFromInlineBuffer(&stringBuffer, range.location + 1)))) {
+            character = CFUniCharGetLongCharacterForSurrogatePair(character, otherSurrogate);
+            letter = CFUniCharGetBitmapPtrForPlane(kCFUniCharLetterCharacterSet, (character >> 16));
+        }
+
+        if ((character == ZERO_WIDTH_JOINER) || CFUniCharIsMemberOfBitmap(character, letter)) {
+            CFRange otherRange;
+
+            // Check if preceded by grapheme joiners (U034F and viramas)
+            otherRange.location = currentIndex = range.location;
+
+            while (currentIndex > 1) {
+                character = CFStringGetCharacterFromInlineBuffer(&stringBuffer, --currentIndex);
+    
+                // ??? We're assuming viramas only in BMP
+                if ((_CFStringIsVirama(character, combClassBMP) || ((character == ZERO_WIDTH_JOINER) && _CFStringIsVirama(CFStringGetCharacterFromInlineBuffer(&stringBuffer, --currentIndex), combClassBMP))) && (currentIndex > 0)) {
+                    --currentIndex;                
+                } else {
+                    break;
+                }
+
+                currentIndex = _CFStringInlineBufferGetComposedRange(&stringBuffer, currentIndex, type, bmpBitmap, csetType).location;
+    
+                character = CFStringGetCharacterFromInlineBuffer(&stringBuffer, currentIndex);
+    
+                if (CFUniCharIsSurrogateLowCharacter(character) && CFUniCharIsSurrogateHighCharacter((otherSurrogate = CFStringGetCharacterFromInlineBuffer(&stringBuffer, currentIndex - 1)))) {
+                    character = CFUniCharGetLongCharacterForSurrogatePair(character, otherSurrogate);
+                    letter = CFUniCharGetBitmapPtrForPlane(kCFUniCharLetterCharacterSet, (character >> 16));
+                    --currentIndex;
+                } else {
+                    letter = letterBMP;
+                }
+
+                if (!CFUniCharIsMemberOfBitmap(character, letter)) break;
+                range.location = currentIndex;
+            }
+
+            range.length += otherRange.location - range.location;
+
+            // Check if followed by grapheme joiners
+            if ((range.length > 1) && ((range.location + range.length) < length)) {
+                otherRange = range;
+                currentIndex = otherRange.location + otherRange.length;
+
+                do {
+                    character = CFStringGetCharacterFromInlineBuffer(&stringBuffer, currentIndex - 1);
+
+                    // ??? We're assuming viramas only in BMP
+                    if ((character != ZERO_WIDTH_JOINER) && !_CFStringIsVirama(character, combClassBMP)) break;
+
+                    character = CFStringGetCharacterFromInlineBuffer(&stringBuffer, currentIndex);
+
+                    if (character == ZERO_WIDTH_JOINER) character = CFStringGetCharacterFromInlineBuffer(&stringBuffer, ++currentIndex);
+
+                    if (CFUniCharIsSurrogateHighCharacter(character) && CFUniCharIsSurrogateLowCharacter((otherSurrogate = CFStringGetCharacterFromInlineBuffer(&stringBuffer, currentIndex + 1)))) {
+                        character = CFUniCharGetLongCharacterForSurrogatePair(character, otherSurrogate);
+                        letter = CFUniCharGetBitmapPtrForPlane(kCFUniCharLetterCharacterSet, (character >> 16));
+                    } else {
+                        letter = letterBMP;
+                    }
+        
+                    // We only conjoin letters
+                    if (!CFUniCharIsMemberOfBitmap(character, letter)) break;
+                    otherRange = _CFStringInlineBufferGetComposedRange(&stringBuffer, currentIndex, type, bmpBitmap, csetType);
+                    currentIndex = otherRange.location + otherRange.length;
+                } while ((otherRange.location + otherRange.length) < length);
+                range.length = currentIndex - range.location;
+            }
+        }
+    }
+
+    // Check if we're part of prefix transcoding hints
+    CFIndex otherIndex;
+    
+    currentIndex = (range.location + range.length) - (MAX_TRANSCODING_LENGTH + 1);
+    if (currentIndex < 0) currentIndex = 0;
+    
+    while (currentIndex <= range.location) {
+        character = CFStringGetCharacterFromInlineBuffer(&stringBuffer, currentIndex);
+        
+        if ((character & 0x1FFFF0) == 0xF860) { // transcoding hint
+            otherIndex = currentIndex + __CFTranscodingHintLength[(character - 0xF860)] + 1;
+            if (otherIndex >= (range.location + range.length)) {
+                if (otherIndex <= length) {
+                    range.location = currentIndex;
+                    range.length = otherIndex - currentIndex;
+                }
+                break;
+            }
+        }
+        ++currentIndex;
+    }
+    
+    return range;
+}
+
+#if 1 /* Using the new implementation. Leaving the old implementation if'ed out for testing purposes for now */
+CFRange CFStringGetRangeOfComposedCharactersAtIndex(CFStringRef theString, CFIndex theIndex) {
+    return CFStringGetRangeOfCharacterClusterAtIndex(theString, theIndex, kCFStringComposedCharacterCluster);
+}
+#else
+/*!
+	@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.
+*/
+#define ExtHighHalfZoneLow 0xD800
+#define ExtHighHalfZoneHigh 0xDBFF
+#define ExtLowHalfZoneLow 0xDC00
+#define ExtLowHalfZoneHigh 0xDFFF
+#define JunseongStart 0x1160
+#define JonseongEnd 0x11F9
+CF_INLINE Boolean IsHighCode(UniChar X) { return (X >= ExtHighHalfZoneLow && X <= ExtHighHalfZoneHigh); }
+CF_INLINE Boolean IsLowCode(UniChar X) { return (X >= ExtLowHalfZoneLow && X <= ExtLowHalfZoneHigh); }
+#define IsHangulConjoiningJamo(X) (X >= JunseongStart && X <= JonseongEnd)
+#define IsHalfwidthKanaVoicedMark(X) ((X == 0xFF9E) || (X == 0xFF9F))
+CF_INLINE Boolean IsNonBaseChar(UniChar X, CFCharacterSetRef nonBaseSet) { return (CFCharacterSetIsCharacterMember(nonBaseSet, X) || IsHangulConjoiningJamo(X) || IsHalfwidthKanaVoicedMark(X) || (X & 0x1FFFF0) == 0xF870); } // combining char, hangul jamo, or Apple corporate variant tag
+#define ZWJ	0x200D
+#define ZWNJ	0x200C
+#define COMBINING_GRAPHEME_JOINER (0x034F)
+
+static CFCharacterSetRef nonBaseChars = NULL;
+static CFCharacterSetRef letterChars = NULL;
+static const void *__CFCombiningClassBMP = NULL;
+
+CF_INLINE bool IsVirama(UTF32Char character) {
+    return ((character == COMBINING_GRAPHEME_JOINER) ? true : ((character < 0x10000) && (CFUniCharGetCombiningPropertyForCharacter(character, __CFCombiningClassBMP) == 9) ? true : false));
+}
+
+CFRange CFStringGetRangeOfComposedCharactersAtIndex(CFStringRef theString, CFIndex theIndex) {
+    CFIndex left, current, save;
+    CFIndex len = CFStringGetLength(theString);
+    CFStringInlineBuffer stringBuffer;
+    static volatile Boolean _isInited = false;
+
+    if (theIndex >= len) return CFRangeMake(kCFNotFound, 0);
+
+    if (!_isInited) {
+        nonBaseChars = CFCharacterSetGetPredefined(kCFCharacterSetNonBase);
+        letterChars = CFCharacterSetGetPredefined(kCFCharacterSetLetter);
+        __CFCombiningClassBMP = CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, 0);
+        _isInited = true;
+    }
+
+    save = current = theIndex;
+
+    CFStringInitInlineBuffer(theString, &stringBuffer, CFRangeMake(0, len));
+
+    /*
+     * First check for transcoding hints
+     */
+    {
+        CFRange theRange = (current > MAX_TRANSCODING_LENGTH  ? CFRangeMake(current - MAX_TRANSCODING_LENGTH, MAX_TRANSCODING_LENGTH + 1) : CFRangeMake(0, current + 1));
+
+        // Should check the next loc ?
+        if (current + 1 < len) ++theRange.length;
+
+        if (theRange.length > 1) {
+            UniChar characterBuffer[MAX_TRANSCODING_LENGTH + 2]; // Transcoding hint length + current loc + next loc
+
+            if (stringBuffer.directBuffer) {
+                memmove(characterBuffer, stringBuffer.directBuffer + theRange.location, theRange.length * sizeof(UniChar));
+            } else {
+                CFStringGetCharacters(theString, theRange, characterBuffer);
+            }
+
+            while (current >= theRange.location) {
+                if ((characterBuffer[current - theRange.location] & 0x1FFFF0) == 0xF860) {
+                    theRange = CFRangeMake(current, __CFTranscodingHintLength[characterBuffer[current - theRange.location] - 0xF860] + 1);
+                    if ((theRange.location + theRange.length) <= theIndex) break;
+                    if ((theRange.location + theRange.length) >= len) theRange.length = len - theRange.location;
+                    return theRange;
+                }
+                if (current == 0) break;
+                --current;
+            }
+            current = theIndex; // Reset current
+        }
+    }
+
+//#warning Aki 5/29/01 This does not support non-base chars in non-BMP planes (i.e. musical symbol combining stem in Unicode 3.1)
+    /*
+     * if we start NOT on a base, first move back to a base as appropriate.
+     */
+
+  roundAgain:
+
+    while ((current > 0) && IsNonBaseChar(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current), nonBaseChars)) --current;
+
+    if (current >= 1 && current < len && CFCharacterSetIsCharacterMember(letterChars, CFStringGetCharacterFromInlineBuffer(&stringBuffer, current)) && IsVirama(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current - 1))) {
+	--current;
+	goto roundAgain;
+    } else if ((current >= 2) && (CFStringGetCharacterFromInlineBuffer(&stringBuffer, current - 1) == ZWJ) && IsVirama(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current - 2))) {
+        current -= 2;
+	goto roundAgain;
+    }
+
+    /*
+     * Set the left position, then jump back to the saved original position.
+     */
+
+    if (current >= 1 && IsLowCode(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current)) && IsHighCode(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current - 1))) --current;
+    left = current;
+    current = save;
+
+    /*
+     * Now, presume we are on a base; move forward & look for the next base.
+     * Handle jumping over H/L codes.
+     */
+    if (IsHighCode(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current)) && (current + 1) < len && IsLowCode(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current + 1))) ++current;
+    ++current;
+
+  round2Again:
+
+    if (current < len)  {
+        while (IsNonBaseChar(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current), nonBaseChars)) {
+	    ++current;
+	    if (current >= len) break;
+	}
+	if ((current < len) && CFCharacterSetIsCharacterMember(letterChars, CFStringGetCharacterFromInlineBuffer(&stringBuffer, current))) {
+	    if (IsVirama(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current - 1))) {
+		++current; goto round2Again;
+	    } else if ((current >= 2) && (CFStringGetCharacterFromInlineBuffer(&stringBuffer, current - 1) == ZWJ) && IsVirama(CFStringGetCharacterFromInlineBuffer(&stringBuffer, current - 2))) {
+		++current; goto round2Again;
+	    }
+	}
+    }
+    /*
+     * Now, "current" is a base, and "left" is a base.
+     * The junk between had better contain "save"!
+     */
+    if ((! (left <= save)) || (! (save <= current))) {
+	CFLog(kCFLogLevelWarning, CFSTR("CFString: CFStringGetRangeOfComposedCharactersAtIndex:%d returned invalid\n"), save);
+    }
+    return CFRangeMake(left, current - left);
+}
+#endif
+
+/*!
+	@function CFStringFindCharacterFromSet
+	Query the range of characters 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.  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.
+*/
+#define SURROGATE_START 0xD800
+#define SURROGATE_END 0xDFFF
+
+CF_EXPORT Boolean CFStringFindCharacterFromSet(CFStringRef theString, CFCharacterSetRef theSet, CFRange rangeToSearch, CFOptionFlags searchOptions, CFRange *result) {
+    CFStringInlineBuffer stringBuffer;
+    CFCharacterSetInlineBuffer csetBuffer;
+    UniChar ch;
+    CFIndex step;
+    CFIndex fromLoc, toLoc, cnt;	// fromLoc and toLoc are inclusive
+    Boolean found = false;
+    Boolean done = false;
+
+//#warning FIX ME !! Should support kCFCompareNonliteral
+
+    if ((rangeToSearch.location + rangeToSearch.length > CFStringGetLength(theString)) || (rangeToSearch.length == 0)) return false;
+
+    if (searchOptions & kCFCompareBackwards) {
+        fromLoc = rangeToSearch.location + rangeToSearch.length - 1;
+        toLoc = rangeToSearch.location;
+    } else {       
+        fromLoc = rangeToSearch.location;
+        toLoc = rangeToSearch.location + rangeToSearch.length - 1;
+    }
+    if (searchOptions & kCFCompareAnchored) {
+	toLoc = fromLoc;
+    }
+
+    step = (fromLoc <= toLoc) ? 1 : -1;
+    cnt = fromLoc;
+    
+    CFStringInitInlineBuffer(theString, &stringBuffer, rangeToSearch);
+    CFCharacterSetInitInlineBuffer(theSet, &csetBuffer);
+
+    do {
+	ch = CFStringGetCharacterFromInlineBuffer(&stringBuffer, cnt - rangeToSearch.location);
+        if ((ch >= SURROGATE_START) && (ch <= SURROGATE_END)) {
+            int otherCharIndex = cnt + step;
+
+            if (((step < 0) && (otherCharIndex < toLoc)) || ((step > 0) && (otherCharIndex > toLoc))) {
+                done = true;
+            } else {
+                UniChar highChar;
+                UniChar lowChar = CFStringGetCharacterFromInlineBuffer(&stringBuffer, otherCharIndex - rangeToSearch.location);
+
+                if (cnt < otherCharIndex) {
+                    highChar = ch;
+                } else {
+                    highChar = lowChar;
+                    lowChar = ch;
+                }
+
+                if (CFUniCharIsSurrogateHighCharacter(highChar) && CFUniCharIsSurrogateLowCharacter(lowChar) && CFCharacterSetInlineBufferIsLongCharacterMember(&csetBuffer, CFUniCharGetLongCharacterForSurrogatePair(highChar, lowChar))) {
+                    if (result) *result = CFRangeMake((cnt < otherCharIndex ? cnt : otherCharIndex), 2);
+                    return true;
+                } else if (otherCharIndex == toLoc) {
+                    done = true;
+                } else {
+                    cnt = otherCharIndex + step;
+                }
+            }
+        } else if (CFCharacterSetInlineBufferIsLongCharacterMember(&csetBuffer, ch)) {
+	    done = found = true;
+        } else if (cnt == toLoc) {
+            done = true;
+        } else {
+            cnt += step;
+        }
+    } while (!done);
+
+    if (found && result) *result = CFRangeMake(cnt, 1);
+    return found;
+}
+
+/* Line range code */
+
+#define CarriageReturn '\r'	/* 0x0d */
+#define NewLine '\n'		/* 0x0a */
+#define NextLine 0x0085
+#define LineSeparator 0x2028
+#define ParaSeparator 0x2029
+
+CF_INLINE Boolean isALineSeparatorTypeCharacter(UniChar ch, Boolean includeLineEndings) {
+    if (ch > CarriageReturn && ch < NextLine) return false;	/* Quick test to cover most chars */
+    return (ch == NewLine || ch == CarriageReturn || ch == ParaSeparator || (includeLineEndings && (ch == NextLine || ch == LineSeparator))) ? true : false;
+}
+
+static void __CFStringGetLineOrParagraphBounds(CFStringRef string, CFRange range, CFIndex *lineBeginIndex, CFIndex *lineEndIndex, CFIndex *contentsEndIndex, Boolean includeLineEndings) {
+    CFIndex len;
+    CFStringInlineBuffer buf;
+    UniChar ch;
+
+    __CFAssertIsString(string);
+    __CFAssertRangeIsInStringBounds(string, range.location, range.length);
+
+    len = __CFStrLength(string);
+
+    if (lineBeginIndex) {
+        CFIndex start;
+        if (range.location == 0) {
+            start = 0;
+        } else {
+            CFStringInitInlineBuffer(string, &buf, CFRangeMake(0, len));
+	    CFIndex buf_idx = range.location;
+
+            /* Take care of the special case where start happens to fall right between \r and \n */
+            ch = CFStringGetCharacterFromInlineBuffer(&buf, buf_idx);
+            buf_idx--;
+            if ((ch == NewLine) && (CFStringGetCharacterFromInlineBuffer(&buf, buf_idx) == CarriageReturn)) {
+                buf_idx--;
+            }
+            while (1) {
+                if (buf_idx < 0) {
+                    start = 0;
+                    break;
+                } else if (isALineSeparatorTypeCharacter(CFStringGetCharacterFromInlineBuffer(&buf, buf_idx), includeLineEndings)) {
+                    start = buf_idx + 1;
+                    break;
+                } else {
+                    buf_idx--;
+                }
+            }
+        }
+        *lineBeginIndex = start;
+    }
+
+    /* Now find the ending point */
+    if (lineEndIndex || contentsEndIndex) {
+        CFIndex endOfContents, lineSeparatorLength = 1;	/* 1 by default */
+        CFStringInitInlineBuffer(string, &buf, CFRangeMake(0, len));
+	CFIndex buf_idx = range.location + range.length - (range.length ? 1 : 0);
+        /* First look at the last char in the range (if the range is zero length, the char after the range) to see if we're already on or within a end of line sequence... */
+        ch = __CFStringGetCharacterFromInlineBufferAux(&buf, buf_idx);
+        if (ch == NewLine) {
+            endOfContents = buf_idx;
+            buf_idx--;
+            if (__CFStringGetCharacterFromInlineBufferAux(&buf, buf_idx) == CarriageReturn) {
+                lineSeparatorLength = 2;
+                endOfContents--;
+            }
+        } else {
+            while (1) {
+                if (isALineSeparatorTypeCharacter(ch, includeLineEndings)) {
+                    endOfContents = buf_idx;	/* This is actually end of contentsRange */
+                    buf_idx++;	/* OK for this to go past the end */
+                    if ((ch == CarriageReturn) && (__CFStringGetCharacterFromInlineBufferAux(&buf, buf_idx) == NewLine)) {
+                        lineSeparatorLength = 2;
+                    }
+                    break;
+                } else if (buf_idx >= len) {
+                    endOfContents = len;
+                    lineSeparatorLength = 0;
+                    break;
+                } else {
+                    buf_idx++;
+                    ch = __CFStringGetCharacterFromInlineBufferAux(&buf, buf_idx);
+                }
+            }
+        }
+        if (contentsEndIndex) *contentsEndIndex = endOfContents;
+        if (lineEndIndex) *lineEndIndex = endOfContents + lineSeparatorLength;
+    }
+}
+
+void CFStringGetLineBounds(CFStringRef string, CFRange range, CFIndex *lineBeginIndex, CFIndex *lineEndIndex, CFIndex *contentsEndIndex) {
+    CF_OBJC_FUNCDISPATCH4(__kCFStringTypeID, void, string, "getLineStart:end:contentsEnd:forRange:", lineBeginIndex, lineEndIndex, contentsEndIndex, CFRangeMake(range.location, range.length));
+    __CFStringGetLineOrParagraphBounds(string, range, lineBeginIndex, lineEndIndex, contentsEndIndex, true);
+}
+
+void CFStringGetParagraphBounds(CFStringRef string, CFRange range, CFIndex *parBeginIndex, CFIndex *parEndIndex, CFIndex *contentsEndIndex) {
+    CF_OBJC_FUNCDISPATCH4(__kCFStringTypeID, void, string, "getParagraphStart:end:contentsEnd:forRange:", parBeginIndex, parEndIndex, contentsEndIndex, CFRangeMake(range.location, range.length));
+    __CFStringGetLineOrParagraphBounds(string, range, parBeginIndex, parEndIndex, contentsEndIndex, false);
+}
+
+
+CFStringRef CFStringCreateByCombiningStrings(CFAllocatorRef alloc, CFArrayRef array, CFStringRef separatorString) {
+    CFIndex numChars;
+    CFIndex separatorNumByte;
+    CFIndex stringCount = CFArrayGetCount(array);
+    Boolean isSepCFString = !CF_IS_OBJC(__kCFStringTypeID, separatorString); 
+    Boolean canBeEightbit = isSepCFString && __CFStrIsEightBit(separatorString);
+    CFIndex idx;
+    CFStringRef otherString;
+    void *buffer;
+    uint8_t *bufPtr;
+    const void *separatorContents = NULL;
+
+    if (stringCount == 0) {
+        return CFStringCreateWithCharacters(alloc, NULL, 0);
+    } else if (stringCount == 1) {
+        return (CFStringRef)CFStringCreateCopy(alloc, (CFStringRef)CFArrayGetValueAtIndex(array, 0));
+    }
+
+    if (alloc == NULL) alloc = __CFGetDefaultAllocator();
+
+    numChars = CFStringGetLength(separatorString) * (stringCount - 1);
+    for (idx = 0; idx < stringCount; idx++) {
+        otherString = (CFStringRef)CFArrayGetValueAtIndex(array, idx);
+        numChars += CFStringGetLength(otherString);
+	// canBeEightbit is already false if the separator is an NSString...
+        if (!CF_IS_OBJC(__kCFStringTypeID, otherString) && __CFStrIsUnicode(otherString)) canBeEightbit = false;
+    }
+
+    buffer = (uint8_t *)CFAllocatorAllocate(alloc, canBeEightbit ? ((numChars + 1) * sizeof(uint8_t)) : (numChars * sizeof(UniChar)), 0);
+	bufPtr = (uint8_t *)buffer;
+    if (__CFOASafe) __CFSetLastAllocationEventName(buffer, "CFString (store)");
+    separatorNumByte = CFStringGetLength(separatorString) * (canBeEightbit ? sizeof(uint8_t) : sizeof(UniChar));
+
+    for (idx = 0; idx < stringCount; idx++) {
+        if (idx) { // add separator here unless first string
+            if (separatorContents) {
+                memmove(bufPtr, separatorContents, separatorNumByte);
+            } else {
+                if (!isSepCFString) { // NSString
+                    CFStringGetCharacters(separatorString, CFRangeMake(0, CFStringGetLength(separatorString)), (UniChar *)bufPtr);
+                } else if (canBeEightbit || __CFStrIsUnicode(separatorString)) {
+                    memmove(bufPtr, (const uint8_t *)__CFStrContents(separatorString) + __CFStrSkipAnyLengthByte(separatorString), separatorNumByte);
+                } else {	
+                    __CFStrConvertBytesToUnicode((uint8_t *)__CFStrContents(separatorString) + __CFStrSkipAnyLengthByte(separatorString), (UniChar *)bufPtr, __CFStrLength(separatorString));
+                }
+                separatorContents = bufPtr;
+            }
+            bufPtr += separatorNumByte;
+        }
+
+        otherString = (CFStringRef )CFArrayGetValueAtIndex(array, idx);
+        if (CF_IS_OBJC(__kCFStringTypeID, otherString)) {
+            CFIndex otherLength = CFStringGetLength(otherString);
+            CFStringGetCharacters(otherString, CFRangeMake(0, otherLength), (UniChar *)bufPtr);
+            bufPtr += otherLength * sizeof(UniChar);
+        } else {
+            const uint8_t * otherContents = (const uint8_t *)__CFStrContents(otherString);
+            CFIndex otherNumByte = __CFStrLength2(otherString, otherContents) * (canBeEightbit ? sizeof(uint8_t) : sizeof(UniChar));
+
+            if (canBeEightbit || __CFStrIsUnicode(otherString)) {
+                memmove(bufPtr, otherContents + __CFStrSkipAnyLengthByte(otherString), otherNumByte);
+            } else {
+                __CFStrConvertBytesToUnicode(otherContents + __CFStrSkipAnyLengthByte(otherString), (UniChar *)bufPtr, __CFStrLength2(otherString, otherContents));
+            }
+            bufPtr += otherNumByte;
+        }
+    }
+    if (canBeEightbit) *bufPtr = 0; // NULL byte;
+
+    return canBeEightbit ? 
+		CFStringCreateWithCStringNoCopy(alloc, (const char*)buffer, __CFStringGetEightBitStringEncoding(), alloc) : 
+		CFStringCreateWithCharactersNoCopy(alloc, (UniChar *)buffer, numChars, alloc);
+}
+
+
+CFArrayRef CFStringCreateArrayBySeparatingStrings(CFAllocatorRef alloc, CFStringRef string, CFStringRef separatorString) {
+    CFArrayRef separatorRanges;
+    CFIndex length = CFStringGetLength(string);
+    /* No objc dispatch needed here since CFStringCreateArrayWithFindResults() works with both CFString and NSString */
+    if (!(separatorRanges = CFStringCreateArrayWithFindResults(alloc, string, separatorString, CFRangeMake(0, length), 0))) {
+        return CFArrayCreate(alloc, (const void **)&string, 1, & kCFTypeArrayCallBacks);
+    } else {
+        CFIndex idx;
+        CFIndex count = CFArrayGetCount(separatorRanges);
+        CFIndex startIndex = 0;
+        CFIndex numChars;
+        CFMutableArrayRef array = CFArrayCreateMutable(alloc, count + 2, & kCFTypeArrayCallBacks);
+        const CFRange *currentRange;
+        CFStringRef substring;
+
+        for (idx = 0;idx < count;idx++) {
+            currentRange = (const CFRange *)CFArrayGetValueAtIndex(separatorRanges, idx);
+            numChars = currentRange->location - startIndex;
+            substring = CFStringCreateWithSubstring(alloc, string, CFRangeMake(startIndex, numChars));
+            CFArrayAppendValue(array, substring);
+            CFRelease(substring);
+            startIndex = currentRange->location + currentRange->length;
+        }
+        substring = CFStringCreateWithSubstring(alloc, string, CFRangeMake(startIndex, length - startIndex));
+        CFArrayAppendValue(array, substring);
+        CFRelease(substring);
+
+	CFRelease(separatorRanges);
+        
+        return array;
+    }
+}
+
+CFStringRef CFStringCreateFromExternalRepresentation(CFAllocatorRef alloc, CFDataRef data, CFStringEncoding encoding) {
+    return CFStringCreateWithBytes(alloc, CFDataGetBytePtr(data), CFDataGetLength(data), encoding, true);
+}
+
+
+CFDataRef CFStringCreateExternalRepresentation(CFAllocatorRef alloc, CFStringRef string, CFStringEncoding encoding, uint8_t lossByte) {
+    CFIndex length;
+    CFIndex guessedByteLength;
+    uint8_t *bytes;
+    CFIndex usedLength;
+    SInt32 result;
+
+    if (CF_IS_OBJC(__kCFStringTypeID, string)) {	/* ??? Hope the compiler optimizes this away if OBJC_MAPPINGS is not on */
+	length = CFStringGetLength(string);
+    } else {
+        __CFAssertIsString(string);
+        length = __CFStrLength(string);
+        if (__CFStrIsEightBit(string) && ((__CFStringGetEightBitStringEncoding() == encoding) || (__CFStringGetEightBitStringEncoding() == kCFStringEncodingASCII && __CFStringEncodingIsSupersetOfASCII(encoding)))) {	// Requested encoding is equal to the encoding in string
+            return CFDataCreate(alloc, ((uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string)), __CFStrLength(string));
+        }
+    }
+
+    if (alloc == NULL) alloc = __CFGetDefaultAllocator();
+
+    if (((encoding & 0x0FFF) == kCFStringEncodingUnicode) && ((encoding == kCFStringEncodingUnicode) || ((encoding > kCFStringEncodingUTF8) && (encoding <= kCFStringEncodingUTF32LE)))) {
+        guessedByteLength = (length + 1) * ((((encoding >> 26)  & 2) == 0) ? sizeof(UTF16Char) : sizeof(UTF32Char)); // UTF32 format has the bit set
+    } else if (((guessedByteLength = CFStringGetMaximumSizeForEncoding(length, encoding)) > length) && !CF_IS_OBJC(__kCFStringTypeID, string)) { // Multi byte encoding
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+        if (__CFStrIsUnicode(string)) {
+            CFIndex aLength = CFStringEncodingByteLengthForCharacters(encoding, kCFStringEncodingPrependBOM, (const UniChar*)__CFStrContents(string), __CFStrLength(string));
+            if (aLength > 0) guessedByteLength = aLength;
+        } else {
+#endif
+        result = __CFStringEncodeByteStream(string, 0, length, true, encoding, lossByte, NULL, LONG_MAX, &guessedByteLength);
+	// if result == length, we always succeed
+	//   otherwise, if result == 0, we fail
+	//   otherwise, if there was a lossByte but still result != length, we fail
+        if ((result != length) && (!result || !lossByte)) return NULL;
+        if (guessedByteLength == length && __CFStrIsEightBit(string) && __CFStringEncodingIsSupersetOfASCII(encoding)) { // It's all ASCII !!
+            return CFDataCreate(alloc, ((uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string)), __CFStrLength(string));
+        }
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+        }
+#endif
+    }
+    bytes = (uint8_t *)CFAllocatorAllocate(alloc, guessedByteLength, 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(bytes, "CFData (store)");
+
+    result = __CFStringEncodeByteStream(string, 0, length, true, encoding, lossByte, bytes, guessedByteLength, &usedLength);
+
+    if ((result != length) && (!result || !lossByte)) {		// see comment above about what this means
+        CFAllocatorDeallocate(alloc, bytes);
+        return NULL;
+    }
+
+    return CFDataCreateWithBytesNoCopy(alloc, (uint8_t *)bytes, usedLength, alloc);
+}
+
+
+CFStringEncoding CFStringGetSmallestEncoding(CFStringRef str) {
+    CFIndex len;
+    CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, CFStringEncoding, str, "_smallestEncodingInCFStringEncoding");
+    __CFAssertIsString(str);
+
+    if (__CFStrIsEightBit(str)) return __CFStringGetEightBitStringEncoding();
+    len = __CFStrLength(str);
+    if (__CFStringEncodeByteStream(str, 0, len, false, __CFStringGetEightBitStringEncoding(), 0, NULL, LONG_MAX, NULL) == len) return __CFStringGetEightBitStringEncoding();
+    if ((__CFStringGetEightBitStringEncoding() != __CFStringGetSystemEncoding()) && (__CFStringEncodeByteStream(str, 0, len, false, __CFStringGetSystemEncoding(), 0, NULL, LONG_MAX, NULL) == len)) return __CFStringGetSystemEncoding();
+    return kCFStringEncodingUnicode;	/* ??? */
+}
+
+
+CFStringEncoding CFStringGetFastestEncoding(CFStringRef str) {
+    CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, CFStringEncoding, str, "_fastestEncodingInCFStringEncoding");
+    __CFAssertIsString(str);
+    return __CFStrIsEightBit(str) ? __CFStringGetEightBitStringEncoding() : kCFStringEncodingUnicode;	/* ??? */
+}
+
+
+SInt32 CFStringGetIntValue(CFStringRef str) {
+    Boolean success;
+    SInt32 result;
+    SInt32 idx = 0;
+    CFStringInlineBuffer buf;
+    CFStringInitInlineBuffer(str, &buf, CFRangeMake(0, CFStringGetLength(str)));
+    success = __CFStringScanInteger(&buf, NULL, &idx, false, &result);
+    return success ? result : 0;
+}
+
+
+double CFStringGetDoubleValue(CFStringRef str) {
+    Boolean success;
+    double result;
+    SInt32 idx = 0;
+    CFStringInlineBuffer buf;
+    CFStringInitInlineBuffer(str, &buf, CFRangeMake(0, CFStringGetLength(str)));
+    success = __CFStringScanDouble(&buf, NULL, &idx, &result);
+    return success ? result : 0.0;
+}
+
+
+/*** Mutable functions... ***/
+
+void CFStringSetExternalCharactersNoCopy(CFMutableStringRef string, UniChar *chars, CFIndex length, CFIndex capacity) {
+    __CFAssertIsNotNegative(length);
+    __CFAssertIsStringAndExternalMutable(string);
+    CFAssert4((length <= capacity) && ((capacity == 0) || ((capacity > 0) && chars)), __kCFLogAssertion, "%s(): Invalid args: characters %p length %d capacity %d", __PRETTY_FUNCTION__, chars, length, capacity);
+    __CFStrSetContentPtr(string, chars);
+    __CFStrSetExplicitLength(string, length);
+    __CFStrSetCapacity(string, capacity * sizeof(UniChar));
+    __CFStrSetCapacityProvidedExternally(string);
+}
+
+
+
+void CFStringInsert(CFMutableStringRef str, CFIndex idx, CFStringRef insertedStr) {
+    CF_OBJC_FUNCDISPATCH2(__kCFStringTypeID, void, str, "insertString:atIndex:", insertedStr, idx);
+    __CFAssertIsStringAndMutable(str);
+    CFAssert3(idx >= 0 && idx <= __CFStrLength(str), __kCFLogAssertion, "%s(): string index %d out of bounds (length %d)", __PRETTY_FUNCTION__, idx, __CFStrLength(str));
+    __CFStringReplace(str, CFRangeMake(idx, 0), insertedStr);
+}
+
+
+void CFStringDelete(CFMutableStringRef str, CFRange range) {
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, str, "deleteCharactersInRange:", range);
+    __CFAssertIsStringAndMutable(str);
+    __CFAssertRangeIsInStringBounds(str, range.location, range.length);
+    __CFStringChangeSize(str, range, 0, false);
+}
+
+
+void CFStringReplace(CFMutableStringRef str, CFRange range, CFStringRef replacement) {
+    CF_OBJC_FUNCDISPATCH2(__kCFStringTypeID, void, str, "replaceCharactersInRange:withString:", range, replacement);
+    __CFAssertIsStringAndMutable(str);
+    __CFAssertRangeIsInStringBounds(str, range.location, range.length);
+    __CFStringReplace(str, range, replacement);
+}
+
+
+void CFStringReplaceAll(CFMutableStringRef str, CFStringRef replacement) {
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, str, "setString:", replacement);
+    __CFAssertIsStringAndMutable(str);
+    __CFStringReplace(str, CFRangeMake(0, __CFStrLength(str)), replacement);
+}
+
+
+void CFStringAppend(CFMutableStringRef str, CFStringRef appended) {
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, str, "appendString:", appended);
+    __CFAssertIsStringAndMutable(str);
+    __CFStringReplace(str, CFRangeMake(__CFStrLength(str), 0), appended);
+}
+
+
+void CFStringAppendCharacters(CFMutableStringRef str, const UniChar *chars, CFIndex appendedLength) {
+    CFIndex strLength, idx;
+
+    __CFAssertIsNotNegative(appendedLength);
+
+    CF_OBJC_FUNCDISPATCH2(__kCFStringTypeID, void, str, "appendCharacters:length:", chars, appendedLength);
+
+    __CFAssertIsStringAndMutable(str);
+
+    strLength = __CFStrLength(str);
+    if (__CFStringGetCompatibility(Bug2967272) || __CFStrIsUnicode(str)) {
+	__CFStringChangeSize(str, CFRangeMake(strLength, 0), appendedLength, true);
+	memmove((UniChar *)__CFStrContents(str) + strLength, chars, appendedLength * sizeof(UniChar));
+    } else {
+	uint8_t *contents;
+	bool isASCII = true;
+	for (idx = 0; isASCII && idx < appendedLength; idx++) isASCII = (chars[idx] < 0x80);
+	__CFStringChangeSize(str, CFRangeMake(strLength, 0), appendedLength, !isASCII);
+	if (!isASCII) {
+	    memmove((UniChar *)__CFStrContents(str) + strLength, chars, appendedLength * sizeof(UniChar));
+	} else {
+	    contents = (uint8_t *)__CFStrContents(str) + strLength + __CFStrSkipAnyLengthByte(str);
+	    for (idx = 0; idx < appendedLength; idx++) contents[idx] = (uint8_t)chars[idx];
+	}
+    }
+}
+
+
+static void __CFStringAppendBytes(CFMutableStringRef str, const char *cStr, CFIndex appendedLength, CFStringEncoding encoding) {
+    Boolean appendedIsUnicode = false;
+    Boolean freeCStrWhenDone = false;
+    Boolean demoteAppendedUnicode = false;
+    CFVarWidthCharBuffer vBuf;
+
+    __CFAssertIsNotNegative(appendedLength);
+
+    if (encoding == kCFStringEncodingASCII || encoding == __CFStringGetEightBitStringEncoding()) {
+	// appendedLength now denotes length in UniChars
+    } else if (encoding == kCFStringEncodingUnicode) {
+	UniChar *chars = (UniChar *)cStr;
+	CFIndex idx, length = appendedLength / sizeof(UniChar);
+	bool isASCII = true;
+	for (idx = 0; isASCII && idx < length; idx++) isASCII = (chars[idx] < 0x80);
+	if (!isASCII) {
+	    appendedIsUnicode = true;
+	} else {
+	    demoteAppendedUnicode = true;
+	}
+	appendedLength = length;
+    } else {
+        Boolean usingPassedInMemory = false;
+
+	vBuf.allocator = __CFGetDefaultAllocator();	// We don't want to use client's allocator for temp stuff
+        vBuf.chars.unicode = NULL;	// This will cause the decode function to allocate memory if necessary
+
+        if (!__CFStringDecodeByteStream3((const uint8_t *)cStr, appendedLength, encoding, __CFStrIsUnicode(str), &vBuf, &usingPassedInMemory, 0)) {
+	    CFAssert1(0, __kCFLogAssertion, "Supplied bytes could not be converted specified encoding %d", encoding);
+	    return;
+	}
+
+	// If not ASCII, appendedLength now denotes length in UniChars
+	appendedLength = vBuf.numChars;
+	appendedIsUnicode = !vBuf.isASCII;
+	cStr = (const char *)vBuf.chars.ascii;
+	freeCStrWhenDone = !usingPassedInMemory && vBuf.shouldFreeChars;
+    }
+
+    if (CF_IS_OBJC(__kCFStringTypeID, str)) {
+	if (!appendedIsUnicode && !demoteAppendedUnicode) {
+	    CF_OBJC_FUNCDISPATCH2(__kCFStringTypeID, void, str, "_cfAppendCString:length:", cStr, appendedLength);
+	} else {
+	    CF_OBJC_FUNCDISPATCH2(__kCFStringTypeID, void, str, "appendCharacters:length:", cStr, appendedLength);
+	}
+    } else {
+        CFIndex strLength;
+        __CFAssertIsStringAndMutable(str);
+        strLength = __CFStrLength(str);
+
+        __CFStringChangeSize(str, CFRangeMake(strLength, 0), appendedLength, appendedIsUnicode || __CFStrIsUnicode(str));
+
+        if (__CFStrIsUnicode(str)) {
+            UniChar *contents = (UniChar *)__CFStrContents(str);
+            if (appendedIsUnicode) {
+                memmove(contents + strLength, cStr, appendedLength * sizeof(UniChar));
+            } else {
+                __CFStrConvertBytesToUnicode((const uint8_t *)cStr, contents + strLength, appendedLength);
+            }
+        } else {
+	    if (demoteAppendedUnicode) {
+		UniChar *chars = (UniChar *)cStr;
+		CFIndex idx;
+		uint8_t *contents = (uint8_t *)__CFStrContents(str) + strLength + __CFStrSkipAnyLengthByte(str);
+		for (idx = 0; idx < appendedLength; idx++) contents[idx] = (uint8_t)chars[idx];
+	    } else {
+		uint8_t *contents = (uint8_t *)__CFStrContents(str);
+		memmove(contents + strLength + __CFStrSkipAnyLengthByte(str), cStr, appendedLength);
+	    }
+        }
+    }
+
+    if (freeCStrWhenDone) CFAllocatorDeallocate(__CFGetDefaultAllocator(), (void *)cStr);
+}
+
+void CFStringAppendPascalString(CFMutableStringRef str, ConstStringPtr pStr, CFStringEncoding encoding) {
+    __CFStringAppendBytes(str, (const char *)(pStr + 1), (CFIndex)*pStr, encoding);
+}
+
+void CFStringAppendCString(CFMutableStringRef str, const char *cStr, CFStringEncoding encoding) {
+    __CFStringAppendBytes(str, cStr, (CFIndex)strlen(cStr), encoding);
+}
+
+
+void CFStringAppendFormat(CFMutableStringRef str, CFDictionaryRef formatOptions, CFStringRef format, ...) {
+    va_list argList;
+
+    va_start(argList, format);
+    CFStringAppendFormatAndArguments(str, formatOptions, format, argList);
+    va_end(argList);
+}
+
+
+CFIndex CFStringFindAndReplace(CFMutableStringRef string, CFStringRef stringToFind, CFStringRef replacementString, CFRange rangeToSearch, CFOptionFlags compareOptions) {
+    CFRange foundRange;
+    Boolean backwards = ((compareOptions & kCFCompareBackwards) != 0);
+    UInt32 endIndex = rangeToSearch.location + rangeToSearch.length;
+#define MAX_RANGES_ON_STACK (1000 / sizeof(CFRange))
+    CFRange rangeBuffer[MAX_RANGES_ON_STACK];	// Used to avoid allocating memory
+    CFRange *ranges = rangeBuffer;
+    CFIndex foundCount = 0;
+    CFIndex capacity = MAX_RANGES_ON_STACK;
+
+    __CFAssertIsStringAndMutable(string);
+    __CFAssertRangeIsInStringBounds(string, rangeToSearch.location, rangeToSearch.length);
+
+    // Note: This code is very similar to the one in CFStringCreateArrayWithFindResults().
+    while ((rangeToSearch.length > 0) && CFStringFindWithOptions(string, stringToFind, rangeToSearch, compareOptions, &foundRange)) {
+	// Determine the next range
+        if (backwards) {
+            rangeToSearch.length = foundRange.location - rangeToSearch.location;
+        } else {
+            rangeToSearch.location = foundRange.location + foundRange.length;
+            rangeToSearch.length = endIndex - rangeToSearch.location;
+        }
+
+	// If necessary, grow the array 
+	if (foundCount >= capacity) {
+            bool firstAlloc = (ranges == rangeBuffer) ? true : false;
+            capacity = (capacity + 4) * 2;
+            // Note that reallocate with NULL previous pointer is same as allocate
+            ranges = (CFRange *)CFAllocatorReallocate(kCFAllocatorSystemDefault, firstAlloc ? NULL : ranges, capacity * sizeof(CFRange), 0);
+            if (firstAlloc) memmove(ranges, rangeBuffer, MAX_RANGES_ON_STACK * sizeof(CFRange));
+	}
+        ranges[foundCount] = foundRange;
+	foundCount++;
+    }
+
+    if (foundCount > 0) {
+        if (backwards) {	// Reorder the ranges to be incrementing (better to do this here, then to check other places)
+            int head = 0;
+            int tail = foundCount - 1;
+            while (head < tail) {
+                CFRange temp = ranges[head];
+                ranges[head] = ranges[tail];
+                ranges[tail] = temp;
+                head++;
+                tail--;
+            }
+        }
+        __CFStringReplaceMultiple(string, ranges, foundCount, replacementString);
+        if (ranges != rangeBuffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, ranges);
+    }
+    
+    return foundCount;
+}
+
+
+// This function is here for NSString purposes
+// It allows checking for mutability before mutating; this allows NSString to catch invalid mutations
+
+int __CFStringCheckAndReplace(CFMutableStringRef str, CFRange range, CFStringRef replacement) {
+    if (!__CFStrIsMutable(str)) return _CFStringErrNotMutable;	// These three ifs are always here, for NSString usage
+    if (!replacement && __CFStringNoteErrors()) return _CFStringErrNilArg;
+    // We use unsigneds as that is what NSRanges do; we use uint64_t do make sure the sum doesn't wrap (otherwise we'd need to do 3 separate checks). This allows catching bad ranges as described in 3375535. (-1,1)
+    if (((uint64_t)((unsigned)range.location)) + ((uint64_t)((unsigned)range.length)) > (uint64_t)__CFStrLength(str) && __CFStringNoteErrors()) return _CFStringErrBounds;
+    __CFAssertIsStringAndMutable(str);
+    __CFAssertRangeIsInStringBounds(str, range.location, range.length);
+    __CFStringReplace(str, range, replacement);
+    return _CFStringErrNone;
+}
+
+// This function determines whether errors which would cause string exceptions should
+// be ignored or not
+
+Boolean __CFStringNoteErrors(void) {
+    return true;
+}
+
+
+
+void CFStringPad(CFMutableStringRef string, CFStringRef padString, CFIndex length, CFIndex indexIntoPad) {
+    CFIndex originalLength;
+    
+    __CFAssertIsNotNegative(length);
+    __CFAssertIsNotNegative(indexIntoPad);
+ 
+    CF_OBJC_FUNCDISPATCH3(__kCFStringTypeID, void, string, "_cfPad:length:padIndex:", padString, length, indexIntoPad);
+
+    __CFAssertIsStringAndMutable(string);
+
+    originalLength = __CFStrLength(string);
+    if (length < originalLength) {
+        __CFStringChangeSize(string, CFRangeMake(length, originalLength - length), 0, false);
+    } else if (originalLength < length) {
+        uint8_t *contents;
+        Boolean isUnicode;
+        CFIndex charSize;
+        CFIndex padStringLength;
+        CFIndex padLength;
+        CFIndex padRemaining = length - originalLength;
+        
+        if (CF_IS_OBJC(__kCFStringTypeID, padString)) {	/* ??? Hope the compiler optimizes this away if OBJC_MAPPINGS is not on */
+            padStringLength = CFStringGetLength(padString);
+            isUnicode = true;	/* !!! Bad for now */
+        } else {
+            __CFAssertIsString(padString);
+            padStringLength = __CFStrLength(padString);
+            isUnicode = __CFStrIsUnicode(string) || __CFStrIsUnicode(padString);
+        }
+
+        charSize = isUnicode ? sizeof(UniChar) : sizeof(uint8_t);
+        
+        __CFStringChangeSize(string, CFRangeMake(originalLength, 0), padRemaining, isUnicode);
+
+        contents = (uint8_t *)__CFStrContents(string) + charSize * originalLength + __CFStrSkipAnyLengthByte(string);
+        padLength = padStringLength - indexIntoPad;
+        padLength = padRemaining < padLength ? padRemaining : padLength;
+
+        while (padRemaining > 0) {
+            if (isUnicode) {
+                CFStringGetCharacters(padString, CFRangeMake(indexIntoPad, padLength), (UniChar *)contents);
+            } else {
+                CFStringGetBytes(padString, CFRangeMake(indexIntoPad, padLength), __CFStringGetEightBitStringEncoding(), 0, false, contents, padRemaining * charSize, NULL);
+            }
+            contents += padLength * charSize;
+            padRemaining -= padLength;
+            indexIntoPad = 0;
+            padLength = padRemaining < padLength ? padRemaining : padStringLength;
+        }
+    }
+}
+
+void CFStringTrim(CFMutableStringRef string, CFStringRef trimString) {
+    CFRange range;
+    CFIndex newStartIndex;
+    CFIndex length;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, string, "_cfTrim:", trimString);
+
+    __CFAssertIsStringAndMutable(string);
+    __CFAssertIsString(trimString);
+
+    newStartIndex = 0;
+    length = __CFStrLength(string);
+
+    while (CFStringFindWithOptions(string, trimString, CFRangeMake(newStartIndex, length - newStartIndex), kCFCompareAnchored, &range)) {
+        newStartIndex = range.location + range.length;
+    }
+
+    if (newStartIndex < length) {
+        CFIndex charSize = __CFStrIsUnicode(string) ? sizeof(UniChar) : sizeof(uint8_t);
+        uint8_t *contents = (uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string);
+
+        length -= newStartIndex;
+        if (__CFStrLength(trimString) < length) {
+            while (CFStringFindWithOptions(string, trimString, CFRangeMake(newStartIndex, length), kCFCompareAnchored|kCFCompareBackwards, &range)) {
+                length = range.location - newStartIndex;
+            }
+        }
+        memmove(contents, contents + newStartIndex * charSize, length * charSize);
+        __CFStringChangeSize(string, CFRangeMake(length, __CFStrLength(string) - length), 0, false);
+    } else { // Only trimString in string, trim all
+        __CFStringChangeSize(string, CFRangeMake(0, length), 0, false);
+    }
+}
+
+void CFStringTrimWhitespace(CFMutableStringRef string) {
+    CFIndex newStartIndex;
+    CFIndex length;
+    CFStringInlineBuffer buffer;
+
+    CF_OBJC_FUNCDISPATCH0(__kCFStringTypeID, void, string, "_cfTrimWS");
+
+    __CFAssertIsStringAndMutable(string);
+
+    newStartIndex = 0;
+    length = __CFStrLength(string);
+
+    CFStringInitInlineBuffer(string, &buffer, CFRangeMake(0, length));
+    CFIndex buffer_idx = 0;
+
+    while (buffer_idx < length && CFUniCharIsMemberOf(__CFStringGetCharacterFromInlineBufferQuick(&buffer, buffer_idx), kCFUniCharWhitespaceAndNewlineCharacterSet))
+        buffer_idx++;
+    newStartIndex = buffer_idx;
+
+    if (newStartIndex < length) {
+        uint8_t *contents = (uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string);
+        CFIndex charSize = (__CFStrIsUnicode(string) ? sizeof(UniChar) : sizeof(uint8_t));
+
+        buffer_idx = length - 1;
+        while (0 <= buffer_idx && CFUniCharIsMemberOf(__CFStringGetCharacterFromInlineBufferQuick(&buffer, buffer_idx), kCFUniCharWhitespaceAndNewlineCharacterSet))
+            buffer_idx--;
+        length = buffer_idx - newStartIndex + 1;
+
+        memmove(contents, contents + newStartIndex * charSize, length * charSize);
+        __CFStringChangeSize(string, CFRangeMake(length, __CFStrLength(string) - length), 0, false);
+    } else { // Whitespace only string
+        __CFStringChangeSize(string, CFRangeMake(0, length), 0, false);
+    }
+}
+
+void CFStringLowercase(CFMutableStringRef string, CFLocaleRef locale) {
+    CFIndex currentIndex = 0;
+    CFIndex length;
+    const uint8_t *langCode;
+    Boolean isEightBit = __CFStrIsEightBit(string);
+
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, string, "_cfLowercase:", locale);
+
+    __CFAssertIsStringAndMutable(string);
+
+    length = __CFStrLength(string);
+
+    langCode = (const uint8_t *)(_CFCanUseLocale(locale) ? _CFStrGetLanguageIdentifierForLocale(locale) : NULL);
+
+    if (!langCode && isEightBit) {
+        uint8_t *contents = (uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string);
+        for (;currentIndex < length;currentIndex++) {
+            if (contents[currentIndex] >= 'A' && contents[currentIndex] <= 'Z') {
+                contents[currentIndex] += 'a' - 'A';
+            } else if (contents[currentIndex] > 127) {
+                break;
+            }
+        }
+    }
+
+    if (currentIndex < length) {
+        UTF16Char *contents;
+        UniChar mappedCharacters[MAX_CASE_MAPPING_BUF];
+        CFIndex mappedLength;
+        UTF32Char currentChar;
+        UInt32 flags = 0;
+
+        if (isEightBit) __CFStringChangeSize(string, CFRangeMake(0, 0), 0, true);
+
+        contents = (UniChar *)__CFStrContents(string);
+
+        for (;currentIndex < length;currentIndex++) {
+
+            if (CFUniCharIsSurrogateHighCharacter(contents[currentIndex]) && (currentIndex + 1 < length) && CFUniCharIsSurrogateLowCharacter(contents[currentIndex + 1])) {
+                currentChar = CFUniCharGetLongCharacterForSurrogatePair(contents[currentIndex], contents[currentIndex + 1]);
+            } else {
+                currentChar = contents[currentIndex];
+            }
+            flags = ((langCode || (currentChar == 0x03A3)) ? CFUniCharGetConditionalCaseMappingFlags(currentChar, contents, currentIndex, length, kCFUniCharToLowercase, langCode, flags) : 0);
+
+            mappedLength = CFUniCharMapCaseTo(currentChar, mappedCharacters, MAX_CASE_MAPPING_BUF, kCFUniCharToLowercase, flags, langCode);
+            if (mappedLength > 0) contents[currentIndex] = *mappedCharacters;
+
+            if (currentChar > 0xFFFF) { // Non-BMP char
+                switch (mappedLength) {
+                    case 0:
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex, 2), 0, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    length -= 2;
+                    break;
+
+                    case 1:
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 1), 0, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    --length;
+                    break;
+
+                    case 2:
+                    contents[++currentIndex] = mappedCharacters[1];
+                    break;
+
+                    default:
+                    --mappedLength; // Skip the current char
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 0), mappedLength - 1, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    memmove(contents + currentIndex + 1, mappedCharacters + 1, mappedLength * sizeof(UniChar));
+                    length += (mappedLength - 1);
+                    currentIndex += mappedLength;
+                    break;
+                }
+            } else if (mappedLength == 0) {
+                __CFStringChangeSize(string, CFRangeMake(currentIndex, 1), 0, true);
+                contents = (UniChar *)__CFStrContents(string);
+                --length;
+            } else if (mappedLength > 1) {
+                --mappedLength; // Skip the current char
+                __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 0), mappedLength, true);
+                contents = (UniChar *)__CFStrContents(string);
+                memmove(contents + currentIndex + 1, mappedCharacters + 1, mappedLength * sizeof(UniChar));
+                length += mappedLength;
+                currentIndex += mappedLength;
+            }
+        }
+    }
+}
+
+void CFStringUppercase(CFMutableStringRef string, CFLocaleRef locale) {
+    CFIndex currentIndex = 0;
+    CFIndex length;
+    const uint8_t *langCode;
+    Boolean isEightBit = __CFStrIsEightBit(string);
+
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, string, "_cfUppercase:", locale);
+
+    __CFAssertIsStringAndMutable(string);
+
+    length = __CFStrLength(string);
+
+    langCode = (const uint8_t *)(_CFCanUseLocale(locale) ? _CFStrGetLanguageIdentifierForLocale(locale) : NULL);
+
+    if (!langCode && isEightBit) {
+        uint8_t *contents = (uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string);
+        for (;currentIndex < length;currentIndex++) {
+            if (contents[currentIndex] >= 'a' && contents[currentIndex] <= 'z') {
+                contents[currentIndex] -= 'a' - 'A';
+            } else if (contents[currentIndex] > 127) {
+                break;
+            }
+        }
+    }
+
+    if (currentIndex < length) {
+        UniChar *contents;
+        UniChar mappedCharacters[MAX_CASE_MAPPING_BUF];
+        CFIndex mappedLength;
+        UTF32Char currentChar;
+        UInt32 flags = 0;
+
+        if (isEightBit) __CFStringChangeSize(string, CFRangeMake(0, 0), 0, true);
+
+        contents = (UniChar *)__CFStrContents(string);
+
+        for (;currentIndex < length;currentIndex++) {
+            if (CFUniCharIsSurrogateHighCharacter(contents[currentIndex]) && (currentIndex + 1 < length) && CFUniCharIsSurrogateLowCharacter(contents[currentIndex + 1])) {
+                currentChar = CFUniCharGetLongCharacterForSurrogatePair(contents[currentIndex], contents[currentIndex + 1]);
+            } else {
+                currentChar = contents[currentIndex];
+            }
+
+            flags = (langCode ? CFUniCharGetConditionalCaseMappingFlags(currentChar, contents, currentIndex, length, kCFUniCharToUppercase, langCode, flags) : 0);
+
+            mappedLength = CFUniCharMapCaseTo(currentChar, mappedCharacters, MAX_CASE_MAPPING_BUF, kCFUniCharToUppercase, flags, langCode);
+            if (mappedLength > 0) contents[currentIndex] = *mappedCharacters;
+
+            if (currentChar > 0xFFFF) { // Non-BMP char
+                switch (mappedLength) {
+                    case 0:
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex, 2), 0, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    length -= 2;
+                    break;
+
+                    case 1:
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 1), 0, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    --length;
+                    break;
+
+                    case 2:
+                    contents[++currentIndex] = mappedCharacters[1];
+                    break;
+
+                    default:
+                    --mappedLength; // Skip the current char
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 0), mappedLength - 1, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    memmove(contents + currentIndex + 1, mappedCharacters + 1, mappedLength * sizeof(UniChar));
+                    length += (mappedLength - 1);
+                    currentIndex += mappedLength;
+                    break;
+                }
+            } else if (mappedLength == 0) {
+                __CFStringChangeSize(string, CFRangeMake(currentIndex, 1), 0, true);
+                contents = (UniChar *)__CFStrContents(string);
+                --length;
+            } else if (mappedLength > 1) {
+                --mappedLength; // Skip the current char
+                __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 0), mappedLength, true);
+                contents = (UniChar *)__CFStrContents(string);
+                memmove(contents + currentIndex + 1, mappedCharacters + 1, mappedLength * sizeof(UniChar));
+                length += mappedLength;
+                currentIndex += mappedLength;
+            }
+        }
+    }
+}
+
+
+void CFStringCapitalize(CFMutableStringRef string, CFLocaleRef locale) {
+    CFIndex currentIndex = 0;
+    CFIndex length;
+    const uint8_t *langCode;
+    Boolean isEightBit = __CFStrIsEightBit(string);
+    Boolean isLastCased = false;
+    const uint8_t *caseIgnorableForBMP;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, string, "_cfCapitalize:", locale);
+
+    __CFAssertIsStringAndMutable(string);
+
+    length = __CFStrLength(string);
+
+    caseIgnorableForBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharCaseIgnorableCharacterSet, 0);
+
+    langCode = (const uint8_t *)(_CFCanUseLocale(locale) ? _CFStrGetLanguageIdentifierForLocale(locale) : NULL);
+
+    if (!langCode && isEightBit) {
+        uint8_t *contents = (uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string);
+        for (;currentIndex < length;currentIndex++) {
+            if (contents[currentIndex] > 127) {
+                break;
+            } else if (contents[currentIndex] >= 'A' && contents[currentIndex] <= 'Z') {
+                contents[currentIndex] += (isLastCased ? 'a' - 'A' : 0);
+                isLastCased = true;
+            } else if (contents[currentIndex] >= 'a' && contents[currentIndex] <= 'z') {
+                contents[currentIndex] -= (!isLastCased ? 'a' - 'A' : 0);
+                isLastCased = true;
+            } else if (!CFUniCharIsMemberOfBitmap(contents[currentIndex], caseIgnorableForBMP)) {
+                isLastCased = false;
+            }
+        }
+    }
+
+    if (currentIndex < length) {
+        UniChar *contents;
+        UniChar mappedCharacters[MAX_CASE_MAPPING_BUF];
+        CFIndex mappedLength;
+        UTF32Char currentChar;
+        UInt32 flags = 0;
+
+        if (isEightBit) __CFStringChangeSize(string, CFRangeMake(0, 0), 0, true);
+
+        contents = (UniChar *)__CFStrContents(string);
+
+        for (;currentIndex < length;currentIndex++) {
+            if (CFUniCharIsSurrogateHighCharacter(contents[currentIndex]) && (currentIndex + 1 < length) && CFUniCharIsSurrogateLowCharacter(contents[currentIndex + 1])) {
+                currentChar = CFUniCharGetLongCharacterForSurrogatePair(contents[currentIndex], contents[currentIndex + 1]);
+            } else {
+                currentChar = contents[currentIndex];
+            }
+            flags = ((langCode || ((currentChar == 0x03A3) && isLastCased)) ? CFUniCharGetConditionalCaseMappingFlags(currentChar, contents, currentIndex, length, (isLastCased ? kCFUniCharToLowercase : kCFUniCharToTitlecase), langCode, flags) : 0);
+
+            mappedLength = CFUniCharMapCaseTo(currentChar, mappedCharacters, MAX_CASE_MAPPING_BUF, (isLastCased ? kCFUniCharToLowercase : kCFUniCharToTitlecase), flags, langCode);
+            if (mappedLength > 0) contents[currentIndex] = *mappedCharacters;
+
+            if (currentChar > 0xFFFF) { // Non-BMP char
+                switch (mappedLength) {
+                    case 0:
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex, 2), 0, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    length -= 2;
+                    break;
+
+                    case 1:
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 1), 0, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    --length;
+                    break;
+
+                    case 2:
+                    contents[++currentIndex] = mappedCharacters[1];
+                    break;
+
+                    default:
+                    --mappedLength; // Skip the current char
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 0), mappedLength - 1, true);
+                    contents = (UniChar *)__CFStrContents(string);
+                    memmove(contents + currentIndex + 1, mappedCharacters + 1, mappedLength * sizeof(UniChar));
+                    length += (mappedLength - 1);
+                    currentIndex += mappedLength;
+                    break;
+                }
+            } else if (mappedLength == 0) {
+                __CFStringChangeSize(string, CFRangeMake(currentIndex, 1), 0, true);
+                contents = (UniChar *)__CFStrContents(string);
+                --length;
+            } else if (mappedLength > 1) {
+                --mappedLength; // Skip the current char
+                __CFStringChangeSize(string, CFRangeMake(currentIndex + 1, 0), mappedLength, true);
+                contents = (UniChar *)__CFStrContents(string);
+                memmove(contents + currentIndex + 1, mappedCharacters + 1, mappedLength * sizeof(UniChar));
+                length += mappedLength;
+                currentIndex += mappedLength;
+            }
+
+            if (!((currentChar > 0xFFFF) ? CFUniCharIsMemberOf(currentChar, kCFUniCharCaseIgnorableCharacterSet) : CFUniCharIsMemberOfBitmap(currentChar, caseIgnorableForBMP))) { // We have non-caseignorable here
+                isLastCased = ((CFUniCharIsMemberOf(currentChar, kCFUniCharUppercaseLetterCharacterSet) || CFUniCharIsMemberOf(currentChar, kCFUniCharLowercaseLetterCharacterSet)) ? true : false);
+            }
+        }
+    }
+}
+
+
+#define MAX_DECOMP_BUF 64
+
+#define HANGUL_SBASE 0xAC00
+#define HANGUL_LBASE 0x1100
+#define HANGUL_VBASE 0x1161
+#define HANGUL_TBASE 0x11A7
+#define HANGUL_SCOUNT 11172
+#define HANGUL_LCOUNT 19
+#define HANGUL_VCOUNT 21
+#define HANGUL_TCOUNT 28
+#define HANGUL_NCOUNT (HANGUL_VCOUNT * HANGUL_TCOUNT)
+
+CF_INLINE uint32_t __CFGetUTF16Length(const UTF32Char *characters, uint32_t utf32Length) {
+    const UTF32Char *limit = characters + utf32Length;
+    uint32_t length = 0;
+
+    while (characters < limit) length += (*(characters++) > 0xFFFF ? 2 : 1);
+
+    return length;
+}
+
+CF_INLINE void __CFFillInUTF16(const UTF32Char *characters, UTF16Char *dst, uint32_t utf32Length) {
+    const UTF32Char *limit = characters + utf32Length;
+    UTF32Char currentChar;
+
+    while (characters < limit) {
+        currentChar = *(characters++);
+        if (currentChar > 0xFFFF) {
+            currentChar -= 0x10000;
+            *(dst++) = (UTF16Char)((currentChar >> 10) + 0xD800UL);
+            *(dst++) = (UTF16Char)((currentChar & 0x3FF) + 0xDC00UL);
+        } else {
+            *(dst++) = currentChar;
+        }
+    }
+}
+
+void CFStringNormalize(CFMutableStringRef string, CFStringNormalizationForm theForm) {
+    CFIndex currentIndex = 0;
+    CFIndex length;
+    bool needToReorder = true;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFStringTypeID, void, string, "_cfNormalize:", theForm);
+
+    __CFAssertIsStringAndMutable(string);
+
+    length = __CFStrLength(string);
+
+    if (__CFStrIsEightBit(string)) {
+        uint8_t *contents;
+
+        if (theForm == kCFStringNormalizationFormC) return; // 8bit form has no decomposition
+
+        contents = (uint8_t *)__CFStrContents(string) + __CFStrSkipAnyLengthByte(string);
+
+        for (;currentIndex < length;currentIndex++) {
+            if (contents[currentIndex] > 127) {
+                __CFStringChangeSize(string, CFRangeMake(0, 0), 0, true); // need to do harm way
+                needToReorder = false;
+                break;
+            }
+        }
+    }
+
+    if (currentIndex < length) {
+        UTF16Char *limit = (UTF16Char *)__CFStrContents(string) + length;
+        UTF16Char *contents = (UTF16Char *)__CFStrContents(string) + currentIndex;
+        UTF32Char buffer[MAX_DECOMP_BUF];
+        UTF32Char *mappedCharacters = buffer;
+        CFIndex allocatedLength = MAX_DECOMP_BUF;
+        CFIndex mappedLength;
+        CFIndex currentLength;
+        UTF32Char currentChar;
+        const uint8_t *decompBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, 0);
+        const uint8_t *nonBaseBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharNonBaseCharacterSet, 0);
+        const uint8_t *combiningBMP = (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, 0);
+
+        while (contents < limit) {
+            if (CFUniCharIsSurrogateHighCharacter(*contents) && (contents + 1 < limit) && CFUniCharIsSurrogateLowCharacter(*(contents + 1))) {
+                currentChar = CFUniCharGetLongCharacterForSurrogatePair(*contents, *(contents + 1));
+                currentLength = 2;
+                contents += 2;
+            } else {
+                currentChar = *(contents++);
+                currentLength = 1;
+            }
+
+            mappedLength = 0;
+
+            if (CFUniCharIsMemberOfBitmap(currentChar, ((currentChar < 0x10000) ? decompBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, (currentChar >> 16)))) && (0 == CFUniCharGetCombiningPropertyForCharacter(currentChar, ((currentChar < 0x10000) ? combiningBMP : (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (currentChar >> 16)))))) {
+                if ((theForm & kCFStringNormalizationFormC) == 0 || currentChar < HANGUL_SBASE || currentChar > (HANGUL_SBASE + HANGUL_SCOUNT)) { // We don't have to decompose Hangul Syllables if we're precomposing again
+                    mappedLength = CFUniCharDecomposeCharacter(currentChar, mappedCharacters, MAX_DECOMP_BUF);
+                }
+            }
+
+            if ((needToReorder || (theForm & kCFStringNormalizationFormC)) && ((contents < limit) || (mappedLength == 0))) {
+                if (mappedLength > 0) {
+                    if (CFUniCharIsSurrogateHighCharacter(*contents) && (contents + 1 < limit) && CFUniCharIsSurrogateLowCharacter(*(contents + 1))) {
+                        currentChar = CFUniCharGetLongCharacterForSurrogatePair(*contents, *(contents + 1));
+                    } else {
+                        currentChar = *contents;
+                    }
+                }
+
+                if (0 != CFUniCharGetCombiningPropertyForCharacter(currentChar, (const uint8_t *)((currentChar < 0x10000) ? combiningBMP : CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (currentChar >> 16))))) {
+                    uint32_t decompLength;
+
+                    if (mappedLength == 0) {
+                        contents -= (currentChar & 0xFFFF0000 ? 2 : 1);
+                        if (currentIndex > 0) {
+                            if (CFUniCharIsSurrogateLowCharacter(*(contents - 1)) && (currentIndex > 1) && CFUniCharIsSurrogateHighCharacter(*(contents - 2))) {
+                                *mappedCharacters = CFUniCharGetLongCharacterForSurrogatePair(*(contents - 2), *(contents - 1));
+                                currentIndex -= 2;
+                                currentLength += 2;
+                            } else {
+                                *mappedCharacters = *(contents - 1);
+                                --currentIndex;
+                                ++currentLength;
+                            }
+                            mappedLength = 1;
+                        }
+                    } else {
+                        currentLength += (currentChar & 0xFFFF0000 ? 2 : 1);
+                    }
+                    contents += (currentChar & 0xFFFF0000 ? 2 : 1);
+
+                    if (CFUniCharIsMemberOfBitmap(currentChar, ((currentChar < 0x10000) ? decompBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, (currentChar >> 16))))) { // Vietnamese accent, etc.
+                        decompLength = CFUniCharDecomposeCharacter(currentChar, mappedCharacters + mappedLength, MAX_DECOMP_BUF - mappedLength);
+                        mappedLength += decompLength;
+                    } else {
+                        mappedCharacters[mappedLength++] = currentChar;
+                    }
+
+                    while (contents < limit) {
+                        if (CFUniCharIsSurrogateHighCharacter(*contents) && (contents + 1 < limit) && CFUniCharIsSurrogateLowCharacter(*(contents + 1))) {
+                            currentChar = CFUniCharGetLongCharacterForSurrogatePair(*contents, *(contents + 1));
+                        } else {
+                            currentChar = *contents;
+                        }
+                        if (0 == CFUniCharGetCombiningPropertyForCharacter(currentChar, (const uint8_t *)((currentChar < 0x10000) ? combiningBMP : CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (currentChar >> 16))))) break;
+                        if (currentChar & 0xFFFF0000) {
+                            contents += 2;
+                            currentLength += 2;
+                        } else {
+                            ++contents;
+                            ++currentLength;
+                        }
+                        if (mappedLength == allocatedLength) {
+                            allocatedLength += MAX_DECOMP_BUF;
+                            if (mappedCharacters == buffer) {
+                                mappedCharacters = (UTF32Char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, allocatedLength * sizeof(UTF32Char), 0);
+                                memmove(mappedCharacters, buffer, MAX_DECOMP_BUF * sizeof(UTF32Char));
+                            } else {
+                                mappedCharacters = (UTF32Char *)CFAllocatorReallocate(kCFAllocatorSystemDefault, mappedCharacters, allocatedLength * sizeof(UTF32Char), 0);
+                            }
+                        }
+                        if (CFUniCharIsMemberOfBitmap(currentChar, ((currentChar < 0x10000) ? decompBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, (currentChar >> 16))))) { // Vietnamese accent, etc.
+                            decompLength = CFUniCharDecomposeCharacter(currentChar, mappedCharacters + mappedLength, MAX_DECOMP_BUF - mappedLength);
+                            mappedLength += decompLength;
+                        } else {
+                            mappedCharacters[mappedLength++] = currentChar;
+                        }
+                    }
+                }
+                if (needToReorder && mappedLength > 1) CFUniCharPrioritySort(mappedCharacters, mappedLength);
+            }
+
+            if (theForm & kCFStringNormalizationFormKD) {
+                CFIndex newLength = 0;
+
+                if (mappedLength == 0 && CFUniCharIsMemberOf(currentChar, kCFUniCharCompatibilityDecomposableCharacterSet)) {
+                    mappedCharacters[mappedLength++] = currentChar;
+                }
+                while (newLength < mappedLength) {
+                    newLength = CFUniCharCompatibilityDecompose(mappedCharacters, mappedLength, allocatedLength);
+                    if (newLength == 0) {
+                        allocatedLength += MAX_DECOMP_BUF;
+                        if (mappedCharacters == buffer) {
+                            mappedCharacters = (UTF32Char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, allocatedLength * sizeof(UTF32Char), 0);
+                            memmove(mappedCharacters, buffer, MAX_DECOMP_BUF * sizeof(UTF32Char));
+                        } else {
+                            mappedCharacters = (UTF32Char *)CFAllocatorReallocate(kCFAllocatorSystemDefault, mappedCharacters, allocatedLength * sizeof(UTF32Char), 0);
+                        }
+                    }
+                }
+                mappedLength = newLength;
+            }
+
+            if (theForm & kCFStringNormalizationFormC) {
+                UTF32Char nextChar;
+
+                if (mappedLength > 1) {
+                    CFIndex consumedLength = 1;
+                    UTF32Char *currentBase = mappedCharacters;
+                    uint8_t currentClass, lastClass = 0;
+                    bool didCombine = false;
+
+                    currentChar = *mappedCharacters;
+
+                    while (consumedLength < mappedLength) {
+                        nextChar = mappedCharacters[consumedLength];
+                        currentClass = CFUniCharGetCombiningPropertyForCharacter(nextChar, (const uint8_t *)((nextChar < 0x10000) ? combiningBMP : CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (nextChar >> 16))));
+
+                        if (theForm & kCFStringNormalizationFormKD) {
+                            if ((currentChar >= HANGUL_LBASE) && (currentChar < (HANGUL_LBASE + 0xFF))) {
+                                SInt8 lIndex = currentChar - HANGUL_LBASE;
+
+                                if ((0 <= lIndex) && (lIndex <= HANGUL_LCOUNT)) {
+                                    SInt16 vIndex = nextChar - HANGUL_VBASE;
+
+                                    if ((vIndex >= 0) && (vIndex <= HANGUL_VCOUNT)) {
+                                        SInt16 tIndex = 0;
+                                        CFIndex usedLength = mappedLength;
+
+                                        mappedCharacters[consumedLength++] = 0xFFFD;
+
+                                        if (consumedLength < mappedLength) {
+                                            tIndex = mappedCharacters[consumedLength] - HANGUL_TBASE;
+                                            if ((tIndex < 0) || (tIndex > HANGUL_TCOUNT)) {
+                                                tIndex = 0;
+                                            } else {
+                                                mappedCharacters[consumedLength++] = 0xFFFD;
+                                            }
+                                        }
+                                        *currentBase = (lIndex * HANGUL_VCOUNT + vIndex) * HANGUL_TCOUNT + tIndex + HANGUL_SBASE;
+
+                                        while (--usedLength > 0) {
+                                            if (mappedCharacters[usedLength] == 0xFFFD) {
+                                                --mappedLength;
+                                                --consumedLength;
+                                                memmove(mappedCharacters + usedLength, mappedCharacters + usedLength + 1, (mappedLength - usedLength) * sizeof(UTF32Char));
+                                            }
+                                        }
+                                        currentBase = mappedCharacters + consumedLength;
+                                        currentChar = *currentBase;
+                                        ++consumedLength;
+
+                                        continue;
+                                    }
+                                }
+                            }
+                            if (!CFUniCharIsMemberOfBitmap(nextChar, ((nextChar < 0x10000) ? nonBaseBMP : CFUniCharGetBitmapPtrForPlane(kCFUniCharNonBaseCharacterSet, (nextChar >> 16))))) {
+                                *currentBase = currentChar;
+                                currentBase = mappedCharacters + consumedLength;
+                                currentChar = nextChar;
+                                ++consumedLength;
+                                continue;
+                            }
+                        }
+
+                        if ((lastClass == 0) || (currentClass > lastClass)) {
+                            nextChar = CFUniCharPrecomposeCharacter(currentChar, nextChar);
+                            if (nextChar == 0xFFFD) {
+                                lastClass = currentClass;
+                            } else {
+                                mappedCharacters[consumedLength] = 0xFFFD;
+                                didCombine = true;
+                                currentChar = nextChar;
+                            }
+                        }
+                        ++consumedLength;
+                    }
+
+                    *currentBase = currentChar;
+                    if (didCombine) {
+                        consumedLength = mappedLength;
+                        while (--consumedLength > 0) {
+                            if (mappedCharacters[consumedLength] == 0xFFFD) {
+                                --mappedLength;
+                                memmove(mappedCharacters + consumedLength, mappedCharacters + consumedLength + 1, (mappedLength - consumedLength) * sizeof(UTF32Char));
+                            }
+                        }
+                    }
+                } else if ((currentChar >= HANGUL_LBASE) && (currentChar < (HANGUL_LBASE + 0xFF))) { // Hangul Jamo
+                    SInt8 lIndex = currentChar - HANGUL_LBASE;
+
+                    if ((contents < limit) && (0 <= lIndex) && (lIndex <= HANGUL_LCOUNT)) {
+                        SInt16 vIndex = *contents - HANGUL_VBASE;
+
+                        if ((vIndex >= 0) && (vIndex <= HANGUL_VCOUNT)) {
+                            SInt16 tIndex = 0;
+
+                            ++contents; ++currentLength;
+
+                            if (contents < limit) {
+                                tIndex = *contents - HANGUL_TBASE;
+                                if ((tIndex < 0) || (tIndex > HANGUL_TCOUNT)) {
+                                    tIndex = 0;
+                                } else {
+                                    ++contents; ++currentLength;
+                                }
+                            }
+                            *mappedCharacters = (lIndex * HANGUL_VCOUNT + vIndex) * HANGUL_TCOUNT + tIndex + HANGUL_SBASE;
+                            mappedLength = 1;
+                        }
+                    }
+                } else { // collect class 0 non-base characters
+                    while (contents < limit) {
+                        nextChar = *contents;
+                        if (CFUniCharIsSurrogateHighCharacter(nextChar) && ((contents + 1) < limit) && CFUniCharIsSurrogateLowCharacter(*(contents + 1))) {
+                            nextChar = CFUniCharGetLongCharacterForSurrogatePair(nextChar, *(contents + 1));
+                            if (!CFUniCharIsMemberOfBitmap(nextChar, (const uint8_t *)CFUniCharGetBitmapPtrForPlane(kCFUniCharNonBaseCharacterSet, (nextChar >> 16))) || (0 != CFUniCharGetCombiningPropertyForCharacter(nextChar, (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (nextChar >> 16))))) break;
+                        } else {
+                            if (!CFUniCharIsMemberOfBitmap(nextChar, nonBaseBMP) || (0 != CFUniCharGetCombiningPropertyForCharacter(nextChar, combiningBMP))) break;
+                        }
+                        currentChar = CFUniCharPrecomposeCharacter(currentChar, nextChar);
+                        if (0xFFFD == currentChar) break;
+
+                        if (nextChar < 0x10000) {
+                            ++contents; ++currentLength;
+                        } else {
+                            contents += 2;
+                            currentLength += 2;
+                        }
+
+                        *mappedCharacters = currentChar;
+                        mappedLength = 1;
+                    }
+                }
+            }
+
+            if (mappedLength > 0) {
+                CFIndex utf16Length = __CFGetUTF16Length(mappedCharacters, mappedLength);
+
+                if (utf16Length != currentLength) {
+                    __CFStringChangeSize(string, CFRangeMake(currentIndex, currentLength), utf16Length, true);
+                    currentLength = utf16Length;
+                }
+                contents = (UTF16Char *)__CFStrContents(string);
+                limit = contents + __CFStrLength(string);
+                contents += currentIndex;
+                __CFFillInUTF16(mappedCharacters, contents, mappedLength);
+                contents += utf16Length;
+            }
+            currentIndex += currentLength;
+        }
+
+        if (mappedCharacters != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, mappedCharacters);
+    }
+}
+
+void CFStringFold(CFMutableStringRef theString, CFStringCompareFlags theFlags, CFLocaleRef locale) {
+    CFStringInlineBuffer stringBuffer;
+    CFIndex length = CFStringGetLength(theString);
+    CFIndex currentIndex = 0;
+    CFIndex bufferLength = 0;
+    UTF32Char buffer[kCFStringStackBufferLength];
+    const uint8_t *cString;
+    const uint8_t *langCode;
+    CFStringEncoding eightBitEncoding;
+    bool caseInsensitive = ((theFlags & kCFCompareCaseInsensitive) ? true : false);
+    bool isObjc = CF_IS_OBJC(__kCFStringTypeID, theString);
+    CFLocaleRef theLocale = locale;
+
+    if ((theFlags & kCFCompareLocalized) && (NULL == locale)) {
+        theLocale = CFLocaleCopyCurrent();
+    }
+
+    theFlags &= (kCFCompareCaseInsensitive|kCFCompareDiacriticInsensitive|kCFCompareWidthInsensitive);
+    
+    if ((0 == theFlags) || (0 == length)) goto bail; // nothing to do
+
+    langCode = ((NULL == theLocale) ? NULL : (const uint8_t *)_CFStrGetLanguageIdentifierForLocale(theLocale));
+
+    eightBitEncoding = __CFStringGetEightBitStringEncoding();
+    cString = (const uint8_t *)CFStringGetCStringPtr(theString, eightBitEncoding);
+
+    if ((NULL != cString) && !caseInsensitive && (kCFStringEncodingASCII == eightBitEncoding)) goto bail; // All ASCII
+
+    CFStringInitInlineBuffer(theString, &stringBuffer, CFRangeMake(0, length));
+
+    if ((NULL != cString) && (theFlags & (kCFCompareCaseInsensitive|kCFCompareDiacriticInsensitive))) {
+        const uint8_t *cStringPtr = cString;
+        const uint8_t *cStringLimit = cString + length;
+        uint8_t *cStringContents = (isObjc ? NULL : (uint8_t *)__CFStrContents(theString) + __CFStrSkipAnyLengthByte(theString));
+        
+        while (cStringPtr < cStringLimit) {
+            if ((*cStringPtr < 0x80) && (NULL == langCode)) {
+                if (caseInsensitive && (*cStringPtr >= 'A') && (*cStringPtr <= 'Z')) {
+                    if (NULL == cStringContents) {
+                        break;
+                    } else {
+                        cStringContents[cStringPtr - cString] += ('a' - 'A');
+                    }
+                }
+            } else {
+                if ((bufferLength = __CFStringFoldCharacterClusterAtIndex((UTF32Char)__CFCharToUniCharTable[*cStringPtr], &stringBuffer, cStringPtr - cString, theFlags, langCode, buffer, kCFStringStackBufferLength, NULL)) > 0) {
+                    if ((*buffer > 0x7F) || (bufferLength > 1) || (NULL == cStringContents)) break;
+                    cStringContents[cStringPtr - cString] = *buffer;
+                }
+            }
+            ++cStringPtr;
+        }
+        
+        currentIndex = cStringPtr - cString;
+    }
+
+    if (currentIndex < length) {
+        UTF16Char *contents;
+
+        if (isObjc) {
+            CFMutableStringRef cfString;
+            CFRange range = CFRangeMake(currentIndex, length - currentIndex);
+
+            contents = (UTF16Char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(UTF16Char) * range.length, 0);
+
+            CFStringGetCharacters(theString, range, contents);
+
+            cfString = CFStringCreateMutableWithExternalCharactersNoCopy(kCFAllocatorSystemDefault, contents, range.length, range.length, NULL);
+
+            CFStringFold(cfString, theFlags, theLocale);
+
+            CFStringReplace(theString, range, cfString);
+
+            CFRelease(cfString);
+        } else {
+            const UTF32Char *characters;
+            const UTF32Char *charactersLimit;
+            UTF32Char character;
+            CFIndex consumedLength;
+
+            contents = NULL;
+
+            if (bufferLength > 0) {
+                __CFStringChangeSize(theString, CFRangeMake(currentIndex + 1, 0), bufferLength - 1, true);
+                length = __CFStrLength(theString);
+                CFStringInitInlineBuffer(theString, &stringBuffer, CFRangeMake(0, length));
+
+                contents = (UTF16Char *)__CFStrContents(theString) + currentIndex;
+                characters = buffer;
+                charactersLimit = characters + bufferLength;
+                while (characters < charactersLimit) *(contents++) = (UTF16Char)*(characters++);
+                ++currentIndex;
+            }
+
+            while (currentIndex < length) {
+                character = __CFStringGetCharacterFromInlineBufferQuick(&stringBuffer, currentIndex);
+
+                consumedLength = 0;
+
+                if ((NULL == langCode) && (character < 0x80) && (0 == (theFlags & kCFCompareDiacriticInsensitive))) {
+                    if (caseInsensitive && (character >= 'A') && (character <= 'Z')) {
+                        consumedLength = 1;
+                        bufferLength = 1;
+                        *buffer = character + ('a' - 'A');
+                    }
+                } else {
+                    if (CFUniCharIsSurrogateHighCharacter(character) && ((currentIndex + 1) < length)) {
+                        UTF16Char lowSurrogate = __CFStringGetCharacterFromInlineBufferQuick(&stringBuffer, currentIndex + 1);
+                        if (CFUniCharIsSurrogateLowCharacter(lowSurrogate)) character = CFUniCharGetLongCharacterForSurrogatePair(character, lowSurrogate);
+                    }
+
+                    bufferLength = __CFStringFoldCharacterClusterAtIndex(character, &stringBuffer, currentIndex, theFlags, langCode, buffer, kCFStringStackBufferLength, &consumedLength);
+                }
+
+                if (consumedLength > 0) {
+                    CFIndex utf16Length = bufferLength;
+
+                    characters = buffer;
+                    charactersLimit = characters + bufferLength;
+
+                    while (characters < charactersLimit) if (*(characters++) > 0xFFFF) ++utf16Length; // Extend bufferLength to the UTF-16 length
+
+                    if ((utf16Length != consumedLength) || __CFStrIsEightBit(theString)) {
+                        CFRange range;
+                        CFIndex insertLength;
+
+                        if (consumedLength < utf16Length) { // Need to expand
+                            range = CFRangeMake(currentIndex + consumedLength, 0);
+                            insertLength = utf16Length - consumedLength;
+                        } else {
+                            range = CFRangeMake(currentIndex + utf16Length, consumedLength - utf16Length);
+                            insertLength = 0;
+                        }
+                        __CFStringChangeSize(theString, range, insertLength, true);
+                        length = __CFStrLength(theString);
+                        CFStringInitInlineBuffer(theString, &stringBuffer, CFRangeMake(0, length));
+                    }
+
+                    (void)CFUniCharFromUTF32(buffer, bufferLength, (UTF16Char *)__CFStrContents(theString) + currentIndex, true, __CF_BIG_ENDIAN__);
+
+                    currentIndex += utf16Length;
+                } else {
+                    ++currentIndex;
+                }
+            }
+        }
+    }
+
+    bail:
+    if (NULL == locale && theLocale) {
+        CFRelease(theLocale);
+    }
+}
+
+enum {
+	kCFStringFormatZeroFlag = (1 << 0),	// if not, padding is space char
+	kCFStringFormatMinusFlag = (1 << 1),	// if not, no flag implied
+	kCFStringFormatPlusFlag = (1 << 2),	// if not, no flag implied, overrides space
+	kCFStringFormatSpaceFlag = (1 << 3)	// if not, no flag implied
+};
+
+typedef struct {
+    int16_t size;
+    int16_t type;
+    SInt32 loc;
+    SInt32 len;
+    SInt32 widthArg;
+    SInt32 precArg;
+    uint32_t flags;
+    int8_t mainArgNum;
+    int8_t precArgNum;
+    int8_t widthArgNum;
+    int8_t unused1;
+} CFFormatSpec;
+
+typedef struct {
+    int16_t type;
+    int16_t size;
+    union {
+	int64_t int64Value;
+	double doubleValue;
+#if LONG_DOUBLE_SUPPORT
+	long double longDoubleValue;
+#endif
+	void *pointerValue;
+    } value;
+} CFPrintValue;
+
+enum {
+    CFFormatDefaultSize = 0,
+    CFFormatSize1 = 1,
+    CFFormatSize2 = 2,
+    CFFormatSize4 = 3,
+    CFFormatSize8 = 4,
+    CFFormatSize16 = 5,
+#if __LP64__
+    CFFormatSizeLong = CFFormatSize8,
+    CFFormatSizePointer = CFFormatSize8
+#else
+    CFFormatSizeLong = CFFormatSize4,
+    CFFormatSizePointer = CFFormatSize4
+#endif
+};
+
+
+
+enum {
+    CFFormatLiteralType = 32,
+    CFFormatLongType = 33,
+    CFFormatDoubleType = 34,
+    CFFormatPointerType = 35,
+    CFFormatObjectType = 36,		/* handled specially */	/* ??? not used anymore, can be removed? */
+    CFFormatCFType = 37,		/* handled specially */
+    CFFormatUnicharsType = 38,		/* handled specially */
+    CFFormatCharsType = 39,		/* handled specially */
+    CFFormatPascalCharsType = 40,	/* handled specially */
+    CFFormatSingleUnicharType = 41,	/* handled specially */
+    CFFormatDummyPointerType = 42	/* special case for %n */
+};
+
+CF_INLINE void __CFParseFormatSpec(const UniChar *uformat, const uint8_t *cformat, SInt32 *fmtIdx, SInt32 fmtLen, CFFormatSpec *spec) {
+    Boolean seenDot = false;
+    for (;;) {
+	UniChar ch;
+	if (fmtLen <= *fmtIdx) return;	/* no type */
+        if (cformat) ch = (UniChar)cformat[(*fmtIdx)++]; else ch = uformat[(*fmtIdx)++];
+reswtch:switch (ch) {
+	case '#':	// ignored for now
+	    break;
+	case 0x20:
+	    if (!(spec->flags & kCFStringFormatPlusFlag)) spec->flags |= kCFStringFormatSpaceFlag;
+	    break;
+	case '-':
+	    spec->flags |= kCFStringFormatMinusFlag;
+	    spec->flags &= ~kCFStringFormatZeroFlag;	// remove zero flag
+	    break;
+	case '+':
+	    spec->flags |= kCFStringFormatPlusFlag;
+	    spec->flags &= ~kCFStringFormatSpaceFlag;	// remove space flag
+	    break;
+	case '0':
+	    if (!(spec->flags & kCFStringFormatMinusFlag)) spec->flags |= kCFStringFormatZeroFlag;
+	    break;
+	case 'h':
+	    spec->size = CFFormatSize2;
+	    break;
+	case 'l':
+	    if (*fmtIdx < fmtLen) {
+		// fetch next character, don't increment fmtIdx
+		if (cformat) ch = (UniChar)cformat[(*fmtIdx)]; else ch = uformat[(*fmtIdx)];
+		if ('l' == ch) {	// 'll' for long long, like 'q'
+		    (*fmtIdx)++;
+		    spec->size = CFFormatSize8;
+		    break;
+		}
+	    }
+	    spec->size = CFFormatSizeLong;  // 4 or 8 depending on LP64
+	    break;
+#if LONG_DOUBLE_SUPPORT
+	case 'L':
+	    spec->size = CFFormatSize16;
+	    break;
+#endif
+	case 'q':
+	    spec->size = CFFormatSize8;
+	    break;
+	case 't': case 'z':
+	    spec->size = CFFormatSizeLong;  // 4 or 8 depending on LP64
+	    break;
+	case 'j':
+	    spec->size = CFFormatSize8; 
+	    break;
+	case 'c':
+	    spec->type = CFFormatLongType;
+	    spec->size = CFFormatSize1;
+	    return;
+	case 'O': case 'o': case 'D': case 'd': case 'i': case 'U': case 'u': case 'x': case 'X':
+	    spec->type = CFFormatLongType;
+            // Seems like if spec->size == 0, we should spec->size = CFFormatSize4. However, 0 is handled correctly.
+	    return;
+	case 'a': case 'A': case 'e': case 'E': case 'f': case 'F': case 'g': case 'G':
+	    spec->type = CFFormatDoubleType;
+	    if (spec->size != CFFormatSize16) spec->size = CFFormatSize8;
+	    return;
+	case 'n':		/* %n is not handled correctly; for Leopard or newer apps, we disable it further */
+	    spec->type = _CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard) ? CFFormatDummyPointerType : CFFormatPointerType;
+	    spec->size = CFFormatSizePointer;  // 4 or 8 depending on LP64
+	    return;
+	case 'p':	
+	    spec->type = CFFormatPointerType;
+	    spec->size = CFFormatSizePointer;  // 4 or 8 depending on LP64
+	    return;
+	case 's':
+	    spec->type = CFFormatCharsType;
+	    spec->size = CFFormatSizePointer;  // 4 or 8 depending on LP64
+	    return;
+	case 'S':
+	    spec->type = CFFormatUnicharsType;
+	    spec->size = CFFormatSizePointer;  // 4 or 8 depending on LP64
+	    return;
+        case 'C':
+            spec->type = CFFormatSingleUnicharType;
+            spec->size = CFFormatSize2;
+            return;
+	case 'P':
+	    spec->type = CFFormatPascalCharsType;
+	    spec->size = CFFormatSizePointer;  // 4 or 8 depending on LP64
+	    return;
+	case '@':
+	    spec->type = CFFormatCFType;
+	    spec->size = CFFormatSizePointer;  // 4 or 8 depending on LP64
+	    return;
+	case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': {
+	    int64_t number = 0;
+	    do {
+		number = 10 * number + (ch - '0');
+                if (cformat) ch = (UniChar)cformat[(*fmtIdx)++]; else ch = uformat[(*fmtIdx)++];
+	    } while ((UInt32)(ch - '0') <= 9);
+	    if ('$' == ch) {
+		if (-2 == spec->precArgNum) {
+		    spec->precArgNum = (int8_t)number - 1;	// Arg numbers start from 1
+		} else if (-2 == spec->widthArgNum) {
+		    spec->widthArgNum = (int8_t)number - 1;	// Arg numbers start from 1
+		} else {
+		    spec->mainArgNum = (int8_t)number - 1;	// Arg numbers start from 1
+		}
+		break;
+	    } else if (seenDot) {	/* else it's either precision or width */
+		spec->precArg = (SInt32)number;
+	    } else {
+		spec->widthArg = (SInt32)number;
+	    }
+	    goto reswtch;
+	}
+	case '*':
+	    spec->widthArgNum = -2;
+	    break;
+	case '.':
+	    seenDot = true;
+            if (cformat) ch = (UniChar)cformat[(*fmtIdx)++]; else ch = uformat[(*fmtIdx)++];
+	    if ('*' == ch) {
+		spec->precArgNum = -2;
+		break;
+	    }
+	    goto reswtch;
+	default:
+	    spec->type = CFFormatLiteralType;
+	    return;
+	}
+    }
+}
+
+/* ??? It ignores the formatOptions argument.
+   ??? %s depends on handling of encodings by __CFStringAppendBytes
+*/
+void CFStringAppendFormatAndArguments(CFMutableStringRef outputString, CFDictionaryRef formatOptions, CFStringRef formatString, va_list args) {
+    _CFStringAppendFormatAndArgumentsAux(outputString, NULL, formatOptions, formatString, args);
+}
+
+#if DEPLOYMENT_TARGET_MACOSX
+#define SNPRINTF(TYPE, WHAT) {				\
+    TYPE value = (TYPE) WHAT;				\
+    if (-1 != specs[curSpec].widthArgNum) {		\
+        if (-1 != specs[curSpec].precArgNum) {		\
+            snprintf_l(buffer, 255, NULL, formatBuffer, width, precision, value); \
+        } else {					\
+            snprintf_l(buffer, 255, NULL, formatBuffer, width, value); \
+        }						\
+    } else {						\
+        if (-1 != specs[curSpec].precArgNum) {		\
+            snprintf_l(buffer, 255, NULL, formatBuffer, precision, value); \
+        } else {					\
+            snprintf_l(buffer, 255, NULL, formatBuffer, value);	\
+        }						\
+    }}
+#elif DEPLOYMENT_TARGET_WINDOWS && defined(_MSC_VER)
+#define SNPRINTF(TYPE, WHAT) {				\
+    TYPE value = (TYPE) WHAT;				\
+    if (-1 != specs[curSpec].widthArgNum) {		\
+        if (-1 != specs[curSpec].precArgNum) {		\
+            _snprintf(buffer, 255, formatBuffer, width, precision, value); \
+        } else {					\
+            _snprintf(buffer, 255, formatBuffer, width, value); \
+        }						\
+    } else {						\
+        if (-1 != specs[curSpec].precArgNum) {		\
+            _snprintf(buffer, 255, formatBuffer, precision, value); \
+        } else {					\
+            _snprintf(buffer, 255, formatBuffer, value);	\
+        }						\
+    }}
+#else
+#define SNPRINTF(TYPE, WHAT) {				\
+    TYPE value = (TYPE) WHAT;				\
+    if (-1 != specs[curSpec].widthArgNum) {		\
+        if (-1 != specs[curSpec].precArgNum) {		\
+            snprintf(buffer, 255, formatBuffer, width, precision, value); \
+        } else {					\
+            snprintf(buffer, 255, formatBuffer, width, value); \
+        }						\
+    } else {						\
+        if (-1 != specs[curSpec].precArgNum) {		\
+            snprintf(buffer, 255, formatBuffer, precision, value); \
+        } else {					\
+            snprintf(buffer, 255, formatBuffer, value);	\
+        }						\
+    }}
+#endif //__MACH__
+
+void _CFStringAppendFormatAndArgumentsAux(CFMutableStringRef outputString, CFStringRef (*copyDescFunc)(void *, const void *), CFDictionaryRef formatOptions, CFStringRef formatString, va_list args) {
+    SInt32 numSpecs, sizeSpecs, sizeArgNum, formatIdx, curSpec, argNum;
+    CFIndex formatLen;
+#define FORMAT_BUFFER_LEN 400
+    const uint8_t *cformat = NULL;
+    const UniChar *uformat = NULL;
+    UniChar *formatChars = NULL;
+    UniChar localFormatBuffer[FORMAT_BUFFER_LEN];
+
+    #define VPRINTF_BUFFER_LEN 61
+    CFFormatSpec localSpecsBuffer[VPRINTF_BUFFER_LEN];
+    CFFormatSpec *specs;
+    CFPrintValue localValuesBuffer[VPRINTF_BUFFER_LEN];
+    CFPrintValue *values;
+    CFAllocatorRef tmpAlloc = NULL;
+    
+    intmax_t dummyLocation;	    // A place for %n to do its thing in; should be the widest possible int value
+
+    numSpecs = 0;
+    sizeSpecs = 0;
+    sizeArgNum = 0;
+    specs = NULL;
+    values = NULL;
+    
+    formatLen = CFStringGetLength(formatString);
+    if (!CF_IS_OBJC(__kCFStringTypeID, formatString)) {
+        __CFAssertIsString(formatString);
+        if (!__CFStrIsUnicode(formatString)) {
+            cformat = (const uint8_t *)__CFStrContents(formatString);
+            if (cformat) cformat += __CFStrSkipAnyLengthByte(formatString);
+        } else {
+            uformat = (const UniChar *)__CFStrContents(formatString);
+        }
+    }
+    if (!cformat && !uformat) {
+        formatChars = (formatLen > FORMAT_BUFFER_LEN) ? (UniChar *)CFAllocatorAllocate(tmpAlloc = __CFGetDefaultAllocator(), formatLen * sizeof(UniChar), 0) : localFormatBuffer; 
+	if (formatChars != localFormatBuffer && __CFOASafe) __CFSetLastAllocationEventName(formatChars, "CFString (temp)");
+        CFStringGetCharacters(formatString, CFRangeMake(0, formatLen), formatChars);
+        uformat = formatChars;
+    }
+
+    /* Compute an upper bound for the number of format specifications */
+    if (cformat) {
+        for (formatIdx = 0; formatIdx < formatLen; formatIdx++) if ('%' == cformat[formatIdx]) sizeSpecs++;
+    } else {
+        for (formatIdx = 0; formatIdx < formatLen; formatIdx++) if ('%' == uformat[formatIdx]) sizeSpecs++;
+    }
+    tmpAlloc = __CFGetDefaultAllocator();
+    specs = ((2 * sizeSpecs + 1) > VPRINTF_BUFFER_LEN) ? (CFFormatSpec *)CFAllocatorAllocate(tmpAlloc, (2 * sizeSpecs + 1) * sizeof(CFFormatSpec), 0) : localSpecsBuffer;
+    if (specs != localSpecsBuffer && __CFOASafe) __CFSetLastAllocationEventName(specs, "CFString (temp)");
+
+    /* Collect format specification information from the format string */
+    for (curSpec = 0, formatIdx = 0; formatIdx < formatLen; curSpec++) {
+	SInt32 newFmtIdx;
+	specs[curSpec].loc = formatIdx;
+	specs[curSpec].len = 0;
+	specs[curSpec].size = 0;
+	specs[curSpec].type = 0;
+	specs[curSpec].flags = 0;
+	specs[curSpec].widthArg = -1;
+	specs[curSpec].precArg = -1;
+	specs[curSpec].mainArgNum = -1;
+	specs[curSpec].precArgNum = -1;
+	specs[curSpec].widthArgNum = -1;
+        if (cformat) {
+            for (newFmtIdx = formatIdx; newFmtIdx < formatLen && '%' != cformat[newFmtIdx]; newFmtIdx++);
+        } else {
+            for (newFmtIdx = formatIdx; newFmtIdx < formatLen && '%' != uformat[newFmtIdx]; newFmtIdx++);
+        }
+	if (newFmtIdx != formatIdx) {	/* Literal chunk */
+	    specs[curSpec].type = CFFormatLiteralType;
+	    specs[curSpec].len = newFmtIdx - formatIdx;
+	} else {
+	    newFmtIdx++;	/* Skip % */
+	    __CFParseFormatSpec(uformat, cformat, &newFmtIdx, formatLen, &(specs[curSpec]));
+            if (CFFormatLiteralType == specs[curSpec].type) {
+		specs[curSpec].loc = formatIdx + 1;
+		specs[curSpec].len = 1;
+	    } else {
+		specs[curSpec].len = newFmtIdx - formatIdx;
+	    }
+	}
+	formatIdx = newFmtIdx;
+
+// fprintf(stderr, "specs[%d] = {\n  size = %d,\n  type = %d,\n  loc = %d,\n  len = %d,\n  mainArgNum = %d,\n  precArgNum = %d,\n  widthArgNum = %d\n}\n", curSpec, specs[curSpec].size, specs[curSpec].type, specs[curSpec].loc, specs[curSpec].len, specs[curSpec].mainArgNum, specs[curSpec].precArgNum, specs[curSpec].widthArgNum);
+
+    }
+    numSpecs = curSpec;
+    // Max of three args per spec, reasoning thus: 1 width, 1 prec, 1 value
+    values = ((3 * sizeSpecs + 1) > VPRINTF_BUFFER_LEN) ? (CFPrintValue *)CFAllocatorAllocate(tmpAlloc, (3 * sizeSpecs + 1) * sizeof(CFPrintValue), 0) : localValuesBuffer;
+    if (values != localValuesBuffer && __CFOASafe) __CFSetLastAllocationEventName(values, "CFString (temp)");
+    memset(values, 0, (3 * sizeSpecs + 1) * sizeof(CFPrintValue));
+    sizeArgNum = (3 * sizeSpecs + 1);
+
+    /* Compute values array */
+    argNum = 0;
+    for (curSpec = 0; curSpec < numSpecs; curSpec++) {
+	SInt32 newMaxArgNum;
+	if (0 == specs[curSpec].type) continue;
+	if (CFFormatLiteralType == specs[curSpec].type) continue;
+	newMaxArgNum = sizeArgNum;
+	if (newMaxArgNum < specs[curSpec].mainArgNum) {
+	    newMaxArgNum = specs[curSpec].mainArgNum;
+	}
+	if (newMaxArgNum < specs[curSpec].precArgNum) {
+	    newMaxArgNum = specs[curSpec].precArgNum;
+	}
+	if (newMaxArgNum < specs[curSpec].widthArgNum) {
+	    newMaxArgNum = specs[curSpec].widthArgNum;
+	}
+	if (sizeArgNum < newMaxArgNum) {
+	    if (specs != localSpecsBuffer) CFAllocatorDeallocate(tmpAlloc, specs);
+	    if (values != localValuesBuffer) CFAllocatorDeallocate(tmpAlloc, values);
+	    if (formatChars && (formatChars != localFormatBuffer)) CFAllocatorDeallocate(tmpAlloc, formatChars);
+	    return;  // more args than we expected!
+	}
+	/* It is actually incorrect to reorder some specs and not all; we just do some random garbage here */
+	if (-2 == specs[curSpec].widthArgNum) {
+	    specs[curSpec].widthArgNum = argNum++;
+	}
+	if (-2 == specs[curSpec].precArgNum) {
+	    specs[curSpec].precArgNum = argNum++;
+	}
+	if (-1 == specs[curSpec].mainArgNum) {
+	    specs[curSpec].mainArgNum = argNum++;
+	}
+	values[specs[curSpec].mainArgNum].size = specs[curSpec].size;
+	values[specs[curSpec].mainArgNum].type = specs[curSpec].type;
+	if (-1 != specs[curSpec].widthArgNum) {
+	    values[specs[curSpec].widthArgNum].size = 0;
+	    values[specs[curSpec].widthArgNum].type = CFFormatLongType;
+	}
+	if (-1 != specs[curSpec].precArgNum) {
+	    values[specs[curSpec].precArgNum].size = 0;
+	    values[specs[curSpec].precArgNum].type = CFFormatLongType;
+	}
+    }
+
+    /* Collect the arguments in correct type from vararg list */
+    for (argNum = 0; argNum < sizeArgNum; argNum++) {
+	switch (values[argNum].type) {
+	case 0:
+	case CFFormatLiteralType:
+	    break;
+	case CFFormatLongType:
+        case CFFormatSingleUnicharType:
+	    if (CFFormatSize1 == values[argNum].size) {
+		values[argNum].value.int64Value = (int64_t)(int8_t)va_arg(args, int);
+	    } else if (CFFormatSize2 == values[argNum].size) {
+		values[argNum].value.int64Value = (int64_t)(int16_t)va_arg(args, int);
+	    } else if (CFFormatSize4 == values[argNum].size) {
+		values[argNum].value.int64Value = (int64_t)va_arg(args, int32_t);
+	    } else if (CFFormatSize8 == values[argNum].size) {
+		values[argNum].value.int64Value = (int64_t)va_arg(args, int64_t);
+	    } else {
+		values[argNum].value.int64Value = (int64_t)va_arg(args, int);
+	    }
+	    break;
+	case CFFormatDoubleType:
+#if LONG_DOUBLE_SUPPORT
+	    if (CFFormatSize16 == values[argNum].size) {
+		values[argNum].value.longDoubleValue = va_arg(args, long double);
+	    } else 
+#endif
+	    {
+		values[argNum].value.doubleValue = va_arg(args, double);
+	    }
+	    break;
+	case CFFormatPointerType:
+	case CFFormatObjectType:
+	case CFFormatCFType:
+	case CFFormatUnicharsType:
+	case CFFormatCharsType:
+	case CFFormatPascalCharsType:
+	    values[argNum].value.pointerValue = va_arg(args, void *);
+	    break;
+	case CFFormatDummyPointerType:
+	    (void)va_arg(args, void *);	    // Skip the provided argument
+	    values[argNum].value.pointerValue = &dummyLocation;
+	    break;
+	}
+    }
+    va_end(args);
+
+    /* Format the pieces together */
+    for (curSpec = 0; curSpec < numSpecs; curSpec++) {
+	SInt32 width = 0, precision = 0;
+	UniChar *up, ch;
+	Boolean hasWidth = false, hasPrecision = false;
+
+	// widthArgNum and widthArg are never set at the same time; same for precArg*
+	if (-1 != specs[curSpec].widthArgNum) {
+	    width = (SInt32)values[specs[curSpec].widthArgNum].value.int64Value;
+	    hasWidth = true;
+	}
+	if (-1 != specs[curSpec].precArgNum) {
+	    precision = (SInt32)values[specs[curSpec].precArgNum].value.int64Value;
+	    hasPrecision = true;
+	}
+	if (-1 != specs[curSpec].widthArg) {
+	    width = specs[curSpec].widthArg;
+	    hasWidth = true;
+	}
+	if (-1 != specs[curSpec].precArg) {
+	    precision = specs[curSpec].precArg;
+	    hasPrecision = true;
+	}
+
+	switch (specs[curSpec].type) {
+	case CFFormatLongType:
+	case CFFormatDoubleType:
+	case CFFormatPointerType: {
+                char formatBuffer[128];
+#if defined(__GNUC__)
+                char buffer[256 + width + precision];
+#else
+                char stackBuffer[512];
+                char *dynamicBuffer = NULL;
+                char *buffer = stackBuffer;
+                if (256+width+precision > 512) {
+                    dynamicBuffer = (char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, 256+width+precision, 0);
+                    buffer = dynamicBuffer;
+                }
+#endif
+                SInt32 cidx, idx, loc;
+		Boolean appended = false;
+                loc = specs[curSpec].loc;
+                // In preparation to call snprintf(), copy the format string out
+                if (cformat) {
+                    for (idx = 0, cidx = 0; cidx < specs[curSpec].len; idx++, cidx++) {
+                        if ('$' == cformat[loc + cidx]) {
+                            for (idx--; '0' <= formatBuffer[idx] && formatBuffer[idx] <= '9'; idx--);
+                        } else {
+                            formatBuffer[idx] = cformat[loc + cidx];
+                        }
+                    }
+                } else {
+                    for (idx = 0, cidx = 0; cidx < specs[curSpec].len; idx++, cidx++) {
+                        if ('$' == uformat[loc + cidx]) {
+                            for (idx--; '0' <= formatBuffer[idx] && formatBuffer[idx] <= '9'; idx--);
+                        } else {
+                            formatBuffer[idx] = (int8_t)uformat[loc + cidx];
+                        }
+                    }
+                }
+                formatBuffer[idx] = '\0';
+		// Should modify format buffer here if necessary; for example, to translate %qd to
+		// the equivalent, on architectures which do not have %q.
+                buffer[sizeof(buffer) - 1] = '\0';
+                switch (specs[curSpec].type) {
+                    case CFFormatLongType:
+                        if (CFFormatSize8 == specs[curSpec].size) {
+                            SNPRINTF(int64_t, values[specs[curSpec].mainArgNum].value.int64Value)
+                        } else {
+                            SNPRINTF(SInt32, values[specs[curSpec].mainArgNum].value.int64Value)
+                        }
+                        break;
+                    case CFFormatPointerType:
+                    case CFFormatDummyPointerType:
+                        SNPRINTF(void *, values[specs[curSpec].mainArgNum].value.pointerValue)
+                        break;
+
+                    case CFFormatDoubleType:
+#if LONG_DOUBLE_SUPPORT
+                        if (CFFormatSize16 == specs[curSpec].size) {
+			    SNPRINTF(long double, values[specs[curSpec].mainArgNum].value.longDoubleValue)
+			} else 
+#endif
+			{
+			    SNPRINTF(double, values[specs[curSpec].mainArgNum].value.doubleValue)
+			}
+			// See if we need to localize the decimal point
+                        if (formatOptions) {	// We have localization info
+			    CFStringRef decimalSeparator = (CFGetTypeID(formatOptions) == CFLocaleGetTypeID()) ? (CFStringRef)CFLocaleGetValue((CFLocaleRef)formatOptions, kCFLocaleDecimalSeparator) : (CFStringRef)CFDictionaryGetValue(formatOptions, CFSTR("NSDecimalSeparator"));
+                            if (decimalSeparator != NULL) {	// We have a decimal separator in there
+                                CFIndex decimalPointLoc = 0;
+                                while (buffer[decimalPointLoc] != 0 && buffer[decimalPointLoc] != '.') decimalPointLoc++;
+                                if (buffer[decimalPointLoc] == '.') {	// And we have a decimal point in the formatted string
+                                    buffer[decimalPointLoc] = 0;
+                                    CFStringAppendCString(outputString, (const char *)buffer, __CFStringGetEightBitStringEncoding());
+                                    CFStringAppend(outputString, decimalSeparator);
+                                    CFStringAppendCString(outputString, (const char *)(buffer + decimalPointLoc + 1), __CFStringGetEightBitStringEncoding());
+                                    appended = true;
+                                }
+                            }
+                        }
+                        break;
+                }
+                if (!appended) CFStringAppendCString(outputString, (const char *)buffer, __CFStringGetEightBitStringEncoding());            
+#if !defined(__GNUC__)
+				if (dynamicBuffer) {
+					CFAllocatorDeallocate(kCFAllocatorSystemDefault, dynamicBuffer);
+				}
+#endif		
+			}
+                break;
+	case CFFormatLiteralType:
+            if (cformat) {
+                __CFStringAppendBytes(outputString, (const char *)(cformat+specs[curSpec].loc), specs[curSpec].len, __CFStringGetEightBitStringEncoding());
+            } else {
+                CFStringAppendCharacters(outputString, uformat+specs[curSpec].loc, specs[curSpec].len);
+            }
+	    break;
+	case CFFormatPascalCharsType:
+        case CFFormatCharsType:
+	    if (values[specs[curSpec].mainArgNum].value.pointerValue == NULL) {
+		CFStringAppendCString(outputString, "(null)", kCFStringEncodingASCII);
+            } else {
+                int len;
+                const char *str = (const char *)values[specs[curSpec].mainArgNum].value.pointerValue;
+                if (specs[curSpec].type == CFFormatPascalCharsType) {	// Pascal string case
+                    len = ((unsigned char *)str)[0];
+                    str++;
+                    if (hasPrecision && precision < len) len = precision;
+                } else {	// C-string case
+                    if (!hasPrecision) {	// No precision, so rely on the terminating null character
+                        len = (CFIndex)strlen(str);
+                    } else {	// Don't blindly call strlen() if there is a precision; the string might not have a terminating null (3131988)
+                        const char *terminatingNull = (const char *)memchr(str, 0, precision);	// Basically strlen() on only the first precision characters of str
+                        if (terminatingNull) {	// There was a null in the first precision characters
+                            len = terminatingNull - str;
+                        } else {
+                            len = precision;
+                        }
+                    }
+                }
+		// Since the spec says the behavior of the ' ', '0', '#', and '+' flags is undefined for
+		// '%s', and since we have ignored them in the past, the behavior is hereby cast in stone
+		// to ignore those flags (and, say, never pad with '0' instead of space).
+		if (specs[curSpec].flags & kCFStringFormatMinusFlag) {
+		    __CFStringAppendBytes(outputString, str, len, __CFStringGetSystemEncoding());
+		    if (hasWidth && width > len) {
+			int w = width - len;	// We need this many spaces; do it ten at a time
+			do {__CFStringAppendBytes(outputString, "          ", (w > 10 ? 10 : w), kCFStringEncodingASCII);} while ((w -= 10) > 0);
+		    }
+		} else {
+		    if (hasWidth && width > len) {
+			int w = width - len;	// We need this many spaces; do it ten at a time
+			do {__CFStringAppendBytes(outputString, "          ", (w > 10 ? 10 : w), kCFStringEncodingASCII);} while ((w -= 10) > 0);
+		    }
+		    __CFStringAppendBytes(outputString, str, len, __CFStringGetSystemEncoding());
+		}
+	    }
+            break;
+        case CFFormatSingleUnicharType:
+            ch = (UniChar)values[specs[curSpec].mainArgNum].value.int64Value;
+            CFStringAppendCharacters(outputString, &ch, 1);
+            break;
+        case CFFormatUnicharsType:
+            //??? need to handle width, precision, and padding arguments
+            up = (UniChar *)values[specs[curSpec].mainArgNum].value.pointerValue;
+            if (NULL == up) {
+                CFStringAppendCString(outputString, "(null)", kCFStringEncodingASCII);
+            } else {
+                int len;
+                for (len = 0; 0 != up[len]; len++);
+		// Since the spec says the behavior of the ' ', '0', '#', and '+' flags is undefined for
+		// '%s', and since we have ignored them in the past, the behavior is hereby cast in stone
+		// to ignore those flags (and, say, never pad with '0' instead of space).
+                if (hasPrecision && precision < len) len = precision;
+		if (specs[curSpec].flags & kCFStringFormatMinusFlag) {
+		    CFStringAppendCharacters(outputString, up, len);
+		    if (hasWidth && width > len) {
+			int w = width - len;	// We need this many spaces; do it ten at a time
+			do {__CFStringAppendBytes(outputString, "          ", (w > 10 ? 10 : w), kCFStringEncodingASCII);} while ((w -= 10) > 0);
+		    }
+		} else {
+		    if (hasWidth && width > len) {
+			int w = width - len;	// We need this many spaces; do it ten at a time
+			do {__CFStringAppendBytes(outputString, "          ", (w > 10 ? 10 : w), kCFStringEncodingASCII);} while ((w -= 10) > 0);
+		    }
+		    CFStringAppendCharacters(outputString, up, len);
+		}
+            }
+            break;
+	case CFFormatCFType:
+	case CFFormatObjectType:
+            if (NULL != values[specs[curSpec].mainArgNum].value.pointerValue) {
+                CFStringRef str = NULL;
+		if (copyDescFunc) {
+		    str = copyDescFunc(values[specs[curSpec].mainArgNum].value.pointerValue, formatOptions);
+		} else {
+		    str = __CFCopyFormattingDescription(values[specs[curSpec].mainArgNum].value.pointerValue, formatOptions);
+		    if (NULL == str) {
+		        str = CFCopyDescription(values[specs[curSpec].mainArgNum].value.pointerValue);
+		    }
+		}
+                if (str) {
+                    CFStringAppend(outputString, str);
+                    CFRelease(str);
+                } else {
+                    CFStringAppendCString(outputString, "(null description)", kCFStringEncodingASCII);
+                }
+            } else {
+		CFStringAppendCString(outputString, "(null)", kCFStringEncodingASCII);
+            }
+            break;
+        }
+    }
+
+    if (specs != localSpecsBuffer) CFAllocatorDeallocate(tmpAlloc, specs);
+    if (values != localValuesBuffer) CFAllocatorDeallocate(tmpAlloc, values);
+    if (formatChars && (formatChars != localFormatBuffer)) CFAllocatorDeallocate(tmpAlloc, formatChars);
+
+}
+
+#undef SNPRINTF
+
+void CFShowStr(CFStringRef str) {
+    CFAllocatorRef alloc;
+
+    if (!str) {
+	fprintf(stdout, "(null)\n");
+	return;
+    }
+
+    if (CF_IS_OBJC(__kCFStringTypeID, str)) {
+        fprintf(stdout, "This is an NSString, not CFString\n");
+        return;
+    }
+
+    alloc = CFGetAllocator(str);
+
+    fprintf(stdout, "\nLength %d\nIsEightBit %d\n", (int)__CFStrLength(str), __CFStrIsEightBit(str));
+    fprintf(stdout, "HasLengthByte %d\nHasNullByte %d\nInlineContents %d\n",
+            __CFStrHasLengthByte(str), __CFStrHasNullByte(str), __CFStrIsInline(str));
+
+    fprintf(stdout, "Allocator ");
+    if (alloc != kCFAllocatorSystemDefault) {
+        fprintf(stdout, "%p\n", (void *)alloc);
+    } else {
+        fprintf(stdout, "SystemDefault\n");
+    }
+    fprintf(stdout, "Mutable %d\n", __CFStrIsMutable(str));
+    if (!__CFStrIsMutable(str) && __CFStrHasContentsDeallocator(str)) {
+        if (__CFStrContentsDeallocator(str)) fprintf(stdout, "ContentsDeallocatorFunc %p\n", (void *)__CFStrContentsDeallocator(str));
+        else fprintf(stdout, "ContentsDeallocatorFunc None\n");
+    } else if (__CFStrIsMutable(str) && __CFStrHasContentsAllocator(str)) {
+        fprintf(stdout, "ExternalContentsAllocator %p\n", (void *)__CFStrContentsAllocator((CFMutableStringRef)str));
+    }
+
+    if (__CFStrIsMutable(str)) {
+        fprintf(stdout, "CurrentCapacity %d\n%sCapacity %d\n", (int)__CFStrCapacity(str), __CFStrIsFixed(str) ? "Fixed" : "Desired", (int)__CFStrDesiredCapacity(str));
+    }
+    fprintf(stdout, "Contents %p\n", (void *)__CFStrContents(str));
+}
+
+
+
+#undef HANGUL_SBASE
+#undef HANGUL_LBASE
+#undef HANGUL_VBASE
+#undef HANGUL_TBASE
+#undef HANGUL_SCOUNT
+#undef HANGUL_LCOUNT
+#undef HANGUL_VCOUNT
+#undef HANGUL_TCOUNT
+#undef HANGUL_NCOUNT
+
diff --git a/CoreFoundation/CFString.h b/CoreFoundation/CFString.h
new file mode 100644
index 0000000..020741a
--- /dev/null
+++ b/CoreFoundation/CFString.h
@@ -0,0 +1,853 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTRING__)
+#define __COREFOUNDATION_CFSTRING__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFCharacterSet.h>
+#include <CoreFoundation/CFLocale.h>
+#include <stdarg.h>
+
+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.
+Furthermore, the implementation might change depending on the default
+system encoding, the user's language, the OS, or even a given release.
+
+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:
+
+  Str255 buffer;
+  StringPtr ptr = CFStringGetPascalStringPtr(str, encoding);
+  if (ptr == NULL) {
+      if (CFStringGetPascalString(str, buffer, 256, encoding)) ptr = buffer;
+  }
+
+Note that CFStringGetPascalString() or CFStringGetCString() 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 CFStringGetPascalString() in all cases --- CFStringGetPascalStringPtr()
+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)
+enum {
+    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 */
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+    ,
+    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 */
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 */
+};
+typedef CFStringEncoding CFStringBuiltInEncodings;
+
+/* CFString type ID */
+CF_EXPORT
+CFTypeID CFStringGetTypeID(void);
+
+/* Macro to allow creation of compile-time constant strings; the argument should be a constant 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.
+
+At this point non-7 bit characters (that is, characters > 127) in CFSTR() are not 
+supported and using them will lead to unpredictable results. This includes escaped
+(\nnn) characters whose values are > 127. Even if it works for you in testing, 
+it might not work for a user with a different language preference.
+*/
+#ifdef __CONSTANT_CFSTRINGS__
+#define CFSTR(cStr)  ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
+#else
+#define CFSTR(cStr)  __CFStringMakeConstantString("" cStr "")
+#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);
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+#endif
+
+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_EXPORT
+CFStringRef CFStringCreateWithFormatAndArguments(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments);
+
+/* 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.
+*/
+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 always include a BOM character if the encoding is
+   Unicode. See above for description of 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+
+/*** Comparison functions. ***/
+
+/* Find and compare flags; these are OR'ed together as compareOptions or searchOptions in the various functions. 
+   This typedef doesn't appear in the functions; instead the argument is CFOptionFlags. 
+*/
+enum {	
+    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 */
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+    ,
+    kCFCompareDiacriticInsensitive = 128, /* If specified, ignores diacritics (o-umlaut == o) */
+    kCFCompareWidthInsensitive = 256, /* If specified, ignores width differences ('a' == UFF41) */
+    kCFCompareForcedOrdering = 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) */
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 */
+};
+typedef CFOptionFlags CFStringCompareFlags;
+
+/* 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.
+*/
+#if !DEPLOYMENT_TARGET_WINDOWS
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+CF_EXPORT
+CFComparisonResult CFStringCompareWithOptionsAndLocale(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions, CFLocaleRef locale) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 */
+#endif // DEPLOYMENT_TARGET_WINDOWS
+
+/* Comparison convenience. Uses the current user locale (the return value from CFLocaleCopyCurrent()) if kCFCompareLocalized.
+*/
+CF_EXPORT
+CFComparisonResult CFStringCompareWithOptions(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags 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, CFOptionFlags 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.
+*/
+#if !defined (DEPLOYMENT_TARGET_WINDOWS)
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+CF_EXPORT
+Boolean CFStringFindWithOptionsAndLocale(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions, CFLocaleRef locale, CFRange *result) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 */
+#endif // DEPLOYMENT_TARGET_WINDOWS
+
+/* Find convenience. Uses the current user locale (the return value from CFLocaleCopyCurrent()) if kCFCompareLocalized.
+*/
+CF_EXPORT
+Boolean CFStringFindWithOptions(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags 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.
+*/
+CF_EXPORT
+CFArrayRef CFStringCreateArrayWithFindResults(CFAllocatorRef alloc, CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions);
+
+/* Find conveniences; see comments above concerning empty string and options.
+*/
+CF_EXPORT
+CFRange CFStringFind(CFStringRef theString, CFStringRef stringToFind, CFOptionFlags compareOptions);
+
+CF_EXPORT
+Boolean CFStringHasPrefix(CFStringRef theString, CFStringRef prefix);
+
+CF_EXPORT
+Boolean CFStringHasSuffix(CFStringRef theString, CFStringRef suffix);
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/*!
+	@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, CFOptionFlags searchOptions, CFRange *result);
+#endif
+
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+/*** 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_EXPORT
+void CFStringAppendFormatAndArguments(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments);
+
+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 */
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/* 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, CFOptionFlags compareOptions);
+
+#endif
+
+/* 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);
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+CF_EXPORT
+void CFStringLowercase(CFMutableStringRef theString, CFLocaleRef locale);
+
+CF_EXPORT
+void CFStringUppercase(CFMutableStringRef theString, CFLocaleRef locale);
+
+CF_EXPORT
+void CFStringCapitalize(CFMutableStringRef theString, CFLocaleRef locale);
+#else
+CF_EXPORT
+void CFStringLowercase(CFMutableStringRef theString, const void *localeTBD); // localeTBD must be NULL on pre-10.3
+
+CF_EXPORT
+void CFStringUppercase(CFMutableStringRef theString, const void *localeTBD); // localeTBD must be NULL on pre-10.3
+
+CF_EXPORT
+void CFStringCapitalize(CFMutableStringRef theString, const void *localeTBD); // localeTBD must be NULL on pre-10.3
+#endif
+
+#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/*!
+	@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().
+*/
+enum {
+	kCFStringNormalizationFormD = 0, // Canonical Decomposition
+	kCFStringNormalizationFormKD, // Compatibility Decomposition
+	kCFStringNormalizationFormC, // Canonical Decomposition followed by Canonical Composition
+	kCFStringNormalizationFormKC // Compatibility Decomposition followed by Canonical Composition
+};
+typedef CFIndex CFStringNormalizationForm;
+
+/*!
+	@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);
+#endif
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+/*!
+	@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, CFOptionFlags theFlags, CFLocaleRef theLocale) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 */
+
+/* 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.
+*/
+Boolean CFStringTransform(CFMutableStringRef string, CFRange *range, CFStringRef transform, Boolean reverse) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+/* Transform identifiers for CFStringTransform()
+*/
+CF_EXPORT const CFStringRef kCFStringTransformStripCombiningMarks AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformToLatin AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformFullwidthHalfwidth AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinKatakana AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinHiragana AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformHiraganaKatakana AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformMandarinLatin AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinHangul AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinArabic AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinHebrew AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinThai AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinCyrillic AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformLatinGreek AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformToXMLHex AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformToUnicodeName AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+CF_EXPORT const CFStringRef kCFStringTransformStripDiacritics AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+
+/*** 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 *directBuffer;
+    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->directBuffer = CFStringGetCharactersPtr(str);
+    buf->bufferedRangeStart = buf->bufferedRangeEnd = 0;
+}
+
+CF_INLINE UniChar CFStringGetCharacterFromInlineBuffer(CFStringInlineBuffer *buf, CFIndex idx) {
+    if (buf->directBuffer) {
+	if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0;
+        return buf->directBuffer[idx + buf->rangeToBuffer.location];
+    }
+    if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
+	if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0;
+	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)->directBuffer = CFStringGetCharactersPtr(str);} while (0)
+
+#define CFStringGetCharacterFromInlineBuffer(buf, idx) \
+    (((idx) < 0 || (idx) >= (buf)->rangeToBuffer.length) ? 0 : ((buf)->directBuffer ? (buf)->directBuffer[(idx) + (buf)->rangeToBuffer.location] : CFStringGetCharacterAtIndex((buf)->theString, (idx) + (buf)->rangeToBuffer.location)))
+
+#endif /* CF_INLINE */
+
+
+
+
+
+/* Rest of the stuff in this file is private and should not be used directly
+*/
+/* For debugging only
+   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);	/* Private; do not use */
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFSTRING__ */
+
diff --git a/CoreFoundation/CFStringDefaultEncoding.h b/CoreFoundation/CFStringDefaultEncoding.h
new file mode 100644
index 0000000..fd3dc72
--- /dev/null
+++ b/CoreFoundation/CFStringDefaultEncoding.h
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTRINGDEFAULTENCODING__)
+#define __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ 1
+
+/* This file defines static inline functions used both by CarbonCore & CF. */
+
+#include <CoreFoundation/CFBase.h>
+
+#if defined(__MACH__)
+#include <stdlib.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <sys/param.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <xlocale.h>
+
+CF_EXTERN_C_BEGIN
+
+#define __kCFUserEncodingEnvVariableName ("__CF_USER_TEXT_ENCODING")
+#define __kCFMaxDefaultEncodingFileLength (24)
+#define __kCFUserEncodingFileName ("/.CFUserTextEncoding")
+
+/* This function is used to obtain users' default script/region code.
+   The function first looks at environment variable __kCFUserEncodingEnvVariableName, then, reads the configuration file in user's home directory.
+*/
+CF_INLINE void __CFStringGetUserDefaultEncoding(UInt32 *oScriptValue, UInt32 *oRegionValue) {
+    char *stringValue;
+    char buffer[__kCFMaxDefaultEncodingFileLength];
+    int uid = getuid();
+
+    if ((stringValue = getenv(__kCFUserEncodingEnvVariableName)) != NULL) {
+        if ((uid == strtol_l(stringValue, &stringValue, 0, NULL)) && (':' == *stringValue)) {
+            ++stringValue;
+        } else {
+            stringValue = NULL;
+        }
+    }
+
+    if ((stringValue == NULL) && ((uid > 0) || getenv("HOME"))) {
+        struct passwd *passwdp;
+
+        if ((passwdp = getpwuid((uid_t)uid))) {
+            char filename[MAXPATHLEN + 1];
+
+	    const char *path = NULL;
+	    if (!_CFIsSetUgid()) {
+		path = getenv("CFFIXED_USER_HOME");
+	    }
+	    if (!path) {
+		path = passwdp->pw_dir;
+	    }
+
+            strlcpy(filename, path, sizeof(filename));
+            strlcat(filename, __kCFUserEncodingFileName, sizeof(filename));
+
+	    int no_hang_fd = open("/dev/autofs_nowait", 0);
+            int fd = open(filename, O_RDONLY, 0);
+            if (fd == -1) {
+                // Cannot open the file. Let's fallback to smRoman/verUS
+                snprintf(filename, sizeof(filename), "0x%X:0:0", uid);
+                setenv(__kCFUserEncodingEnvVariableName, filename, 1);
+            } else {
+                int readSize;
+
+		// cjk: We do not turn on F_NOCACHE on the fd here, because
+		// many processes read this file on startup, and caching the
+		// is probably a good thing, for the system as a whole.
+                readSize = read(fd, buffer, __kCFMaxDefaultEncodingFileLength - 1);
+                buffer[(readSize < 0 ? 0 : readSize)] = '\0';
+                close(fd);
+                stringValue = buffer;
+
+                // Well, we already have a buffer, let's reuse it
+                snprintf(filename, sizeof(filename), "0x%X:%s", uid, buffer);
+                setenv(__kCFUserEncodingEnvVariableName, filename, 1);
+            }
+	    close(no_hang_fd);
+        }
+    }
+
+    if (stringValue) {
+        *oScriptValue = strtol_l(stringValue, &stringValue, 0, NULL);
+        if (*stringValue == ':') {
+            if (oRegionValue) *oRegionValue = strtol_l(++stringValue, NULL, 0, NULL);
+            return;
+        }
+    }
+
+    // Falling back
+    *oScriptValue = 0; // smRoman
+    if (oRegionValue) *oRegionValue = 0; // verUS
+}
+
+CF_INLINE uint32_t __CFStringGetInstallationRegion() {
+    char *stringValue = NULL;
+    char buffer[__kCFMaxDefaultEncodingFileLength];
+    struct passwd *passwdp;
+    
+    if ((passwdp = getpwuid((uid_t)0))) {
+        char filename[MAXPATHLEN + 1];
+        
+	const char *path = NULL;
+	if (!_CFIsSetUgid()) {
+	    path = getenv("CFFIXED_USER_HOME");
+	}
+	if (!path) {
+	    path = passwdp->pw_dir;
+	}
+
+        strlcpy(filename, path, sizeof(filename));
+        strlcat(filename, __kCFUserEncodingFileName, sizeof(filename));
+        
+        int no_hang_fd = open("/dev/autofs_nowait", 0);
+	int fd = open(filename, O_RDONLY, 0);
+	if (fd == -1) {
+            int readSize;
+            
+            // cjk: We do not turn on F_NOCACHE on the fd here, because
+            // many processes read this file on startup, and caching the
+            // is probably a good thing, for the system as a whole.
+            readSize = read(fd, buffer, __kCFMaxDefaultEncodingFileLength - 1);
+            buffer[(readSize < 0 ? 0 : readSize)] = '\0';
+            close(fd);
+            stringValue = buffer;
+        }
+	close(no_hang_fd);
+    }
+    
+    if (stringValue) {
+        (void)strtol_l(stringValue, &stringValue, 0, NULL);
+        if (*stringValue == ':') return strtol_l(++stringValue, NULL, 0, NULL);
+    }
+
+    return 0; // verUS
+}
+
+CF_INLINE void __CFStringGetInstallationEncodingAndRegion(uint32_t *encoding, uint32_t *region) {
+    char *stringValue = NULL;
+    char buffer[__kCFMaxDefaultEncodingFileLength];
+    struct passwd *passwdp;
+
+    *encoding = 0; *region = 0;
+
+    if ((passwdp = getpwuid((uid_t)0))) {
+        char filename[MAXPATHLEN + 1];
+
+	const char *path = NULL;
+	if (!_CFIsSetUgid()) {
+	    path = getenv("CFFIXED_USER_HOME");
+	}
+	if (!path) {
+	    path = passwdp->pw_dir;
+	}
+
+        strlcpy(filename, path, sizeof(filename));
+        strlcat(filename, __kCFUserEncodingFileName, sizeof(filename));
+        
+	int no_hang_fd = open("/dev/autofs_nowait", 0);
+	int fd = open(filename, O_RDONLY, 0);
+	if (fd == -1) {
+            int readSize;
+            
+            readSize = read(fd, buffer, __kCFMaxDefaultEncodingFileLength - 1);
+            buffer[(readSize < 0 ? 0 : readSize)] = '\0';
+            close(fd);
+            stringValue = buffer;
+        }
+	close(no_hang_fd);
+    }
+    
+    if (stringValue) {
+        *encoding = strtol_l(stringValue, &stringValue, 0, NULL);
+        if (*stringValue == ':') *region = strtol_l(++stringValue, NULL, 0, NULL);
+    }
+}
+
+CF_INLINE void __CFStringSaveUserDefaultEncoding(UInt32 iScriptValue, UInt32 iRegionValue) {
+    struct passwd *passwdp;
+
+    if ((passwdp = getpwuid(getuid()))) {
+        char filename[MAXPATHLEN + 1];
+
+	const char *path = NULL;
+	if (!_CFIsSetUgid()) {
+	    path = getenv("CFFIXED_USER_HOME");
+	}
+	if (!path) {
+	    path = passwdp->pw_dir;
+	}
+
+        strlcpy(filename, path, sizeof(filename));
+        strlcat(filename, __kCFUserEncodingFileName, sizeof(filename));
+
+	int no_hang_fd = open("/dev/autofs_nowait", 0);
+        (void)unlink(filename);		// In case, file exists
+	int fd = open(filename, O_WRONLY|O_CREAT, 0400);
+	if (fd == -1) {
+            char buffer[__kCFMaxDefaultEncodingFileLength];
+            unsigned int writeSize;
+
+            writeSize = snprintf(buffer, __kCFMaxDefaultEncodingFileLength, "0x%X:0x%X", (unsigned int)iScriptValue, (unsigned int)iRegionValue);
+            (void)write(fd, buffer, (writeSize > __kCFMaxDefaultEncodingFileLength ? __kCFMaxDefaultEncodingFileLength : writeSize));
+            close(fd);
+        }
+	close(no_hang_fd);
+    }
+}
+
+CF_EXTERN_C_END
+
+#endif
+
+#endif /* ! __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ */
+
diff --git a/CoreFoundation/CFStringEncodingConverter.c b/CoreFoundation/CFStringEncodingConverter.c
new file mode 100644
index 0000000..246c672
--- /dev/null
+++ b/CoreFoundation/CFStringEncodingConverter.c
@@ -0,0 +1,1005 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Aki Inoue
+*/
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDictionary.h>
+#include "CFUniChar.h"
+#include "CFPriv.h"
+#include "CFUnicodeDecomposition.h"
+#include "CFStringEncodingConverterExt.h"
+#include "CFStringEncodingConverterPriv.h"
+#include <stdlib.h>
+#if !DEPLOYMENT_TARGET_WINDOWS
+#include <pthread.h>
+#endif
+
+
+/* Macros
+*/
+#define TO_BYTE(conv,flags,chars,numChars,bytes,max,used) (conv->_toBytes ? conv->toBytes(conv,flags,chars,numChars,bytes,max,used) : ((CFStringEncodingToBytesProc)conv->toBytes)(flags,chars,numChars,bytes,max,used))
+#define TO_UNICODE(conv,flags,bytes,numBytes,chars,max,used) (conv->_toUnicode ?  (flags & (kCFStringEncodingUseCanonical|kCFStringEncodingUseHFSPlusCanonical) ? conv->toCanonicalUnicode(conv,flags,bytes,numBytes,chars,max,used) : conv->toUnicode(conv,flags,bytes,numBytes,chars,max,used)) : ((CFStringEncodingToUnicodeProc)conv->toUnicode)(flags,bytes,numBytes,chars,max,used))
+
+#define ASCIINewLine 0x0a
+#define kSurrogateHighStart 0xD800
+#define kSurrogateHighEnd 0xDBFF
+#define kSurrogateLowStart 0xDC00
+#define kSurrogateLowEnd 0xDFFF
+
+/* Mapping 128..255 to lossy ASCII
+*/
+static const struct {
+    unsigned char chars[4];
+} _toLossyASCIITable[] = {
+    {{' ', 0, 0, 0}}, // NO-BREAK SPACE
+    {{'!', 0, 0, 0}}, // INVERTED EXCLAMATION MARK
+    {{'c', 0, 0, 0}}, // CENT SIGN
+    {{'L', 0, 0, 0}}, // POUND SIGN
+    {{'$', 0, 0, 0}}, // CURRENCY SIGN
+    {{'Y', 0, 0, 0}}, // YEN SIGN
+    {{'|', 0, 0, 0}}, // BROKEN BAR
+    {{0, 0, 0, 0}}, // SECTION SIGN
+    {{0, 0, 0, 0}}, // DIAERESIS
+    {{'(', 'C', ')', 0}}, // COPYRIGHT SIGN
+    {{'a', 0, 0, 0}}, // FEMININE ORDINAL INDICATOR
+    {{'<', '<', 0, 0}}, // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+    {{0, 0, 0, 0}}, // NOT SIGN
+    {{'-', 0, 0, 0}}, // SOFT HYPHEN
+    {{'(', 'R', ')', 0}}, // REGISTERED SIGN
+    {{0, 0, 0, 0}}, // MACRON
+    {{0, 0, 0, 0}}, // DEGREE SIGN
+    {{'+', '-', 0, 0}}, // PLUS-MINUS SIGN
+    {{'2', 0, 0, 0}}, // SUPERSCRIPT TWO
+    {{'3', 0, 0, 0}}, // SUPERSCRIPT THREE
+    {{0, 0, 0, 0}}, // ACUTE ACCENT
+    {{0, 0, 0, 0}}, // MICRO SIGN
+    {{0, 0, 0, 0}}, // PILCROW SIGN
+    {{0, 0, 0, 0}}, // MIDDLE DOT
+    {{0, 0, 0, 0}}, // CEDILLA
+    {{'1', 0, 0, 0}}, // SUPERSCRIPT ONE
+    {{'o', 0, 0, 0}}, // MASCULINE ORDINAL INDICATOR
+    {{'>', '>', 0, 0}}, // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+    {{'1', '/', '4', 0}}, // VULGAR FRACTION ONE QUARTER
+    {{'1', '/', '2', 0}}, // VULGAR FRACTION ONE HALF
+    {{'3', '/', '4', 0}}, // VULGAR FRACTION THREE QUARTERS
+    {{'?', 0, 0, 0}}, // INVERTED QUESTION MARK
+    {{'A', 0, 0, 0}}, // LATIN CAPITAL LETTER A WITH GRAVE
+    {{'A', 0, 0, 0}}, // LATIN CAPITAL LETTER A WITH ACUTE
+    {{'A', 0, 0, 0}}, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+    {{'A', 0, 0, 0}}, // LATIN CAPITAL LETTER A WITH TILDE
+    {{'A', 0, 0, 0}}, // LATIN CAPITAL LETTER A WITH DIAERESIS
+    {{'A', 0, 0, 0}}, // LATIN CAPITAL LETTER A WITH RING ABOVE
+    {{'A', 'E', 0, 0}}, // LATIN CAPITAL LETTER AE
+    {{'C', 0, 0, 0}}, // LATIN CAPITAL LETTER C WITH CEDILLA
+    {{'E', 0, 0, 0}}, // LATIN CAPITAL LETTER E WITH GRAVE
+    {{'E', 0, 0, 0}}, // LATIN CAPITAL LETTER E WITH ACUTE
+    {{'E', 0, 0, 0}}, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+    {{'E', 0, 0, 0}}, // LATIN CAPITAL LETTER E WITH DIAERESIS
+    {{'I', 0, 0, 0}}, // LATIN CAPITAL LETTER I WITH GRAVE
+    {{'I', 0, 0, 0}}, // LATIN CAPITAL LETTER I WITH ACUTE
+    {{'I', 0, 0, 0}}, // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+    {{'I', 0, 0, 0}}, // LATIN CAPITAL LETTER I WITH DIAERESIS
+    {{'T', 'H', 0, 0}}, // LATIN CAPITAL LETTER ETH (Icelandic)
+    {{'N', 0, 0, 0}}, // LATIN CAPITAL LETTER N WITH TILDE
+    {{'O', 0, 0, 0}}, // LATIN CAPITAL LETTER O WITH GRAVE
+    {{'O', 0, 0, 0}}, // LATIN CAPITAL LETTER O WITH ACUTE
+    {{'O', 0, 0, 0}}, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+    {{'O', 0, 0, 0}}, // LATIN CAPITAL LETTER O WITH TILDE
+    {{'O', 0, 0, 0}}, // LATIN CAPITAL LETTER O WITH DIAERESIS
+    {{'X', 0, 0, 0}}, // MULTIPLICATION SIGN
+    {{'O', 0, 0, 0}}, // LATIN CAPITAL LETTER O WITH STROKE
+    {{'U', 0, 0, 0}}, // LATIN CAPITAL LETTER U WITH GRAVE
+    {{'U', 0, 0, 0}}, // LATIN CAPITAL LETTER U WITH ACUTE
+    {{'U', 0, 0, 0}}, // LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+    {{'U', 0, 0, 0}}, // LATIN CAPITAL LETTER U WITH DIAERESIS
+    {{'Y', 0, 0, 0}}, // LATIN CAPITAL LETTER Y WITH ACUTE
+    {{'t', 'h', 0, 0}}, // LATIN CAPITAL LETTER THORN (Icelandic)
+    {{'s', 0, 0, 0}}, // LATIN SMALL LETTER SHARP S (German)
+    {{'a', 0, 0, 0}}, // LATIN SMALL LETTER A WITH GRAVE
+    {{'a', 0, 0, 0}}, // LATIN SMALL LETTER A WITH ACUTE
+    {{'a', 0, 0, 0}}, // LATIN SMALL LETTER A WITH CIRCUMFLEX
+    {{'a', 0, 0, 0}}, // LATIN SMALL LETTER A WITH TILDE
+    {{'a', 0, 0, 0}}, // LATIN SMALL LETTER A WITH DIAERESIS
+    {{'a', 0, 0, 0}}, // LATIN SMALL LETTER A WITH RING ABOVE
+    {{'a', 'e', 0, 0}}, // LATIN SMALL LETTER AE
+    {{'c', 0, 0, 0}}, // LATIN SMALL LETTER C WITH CEDILLA
+    {{'e', 0, 0, 0}}, // LATIN SMALL LETTER E WITH GRAVE
+    {{'e', 0, 0, 0}}, // LATIN SMALL LETTER E WITH ACUTE
+    {{'e', 0, 0, 0}}, // LATIN SMALL LETTER E WITH CIRCUMFLEX
+    {{'e', 0, 0, 0}}, // LATIN SMALL LETTER E WITH DIAERESIS
+    {{'i', 0, 0, 0}}, // LATIN SMALL LETTER I WITH GRAVE
+    {{'i', 0, 0, 0}}, // LATIN SMALL LETTER I WITH ACUTE
+    {{'i', 0, 0, 0}}, // LATIN SMALL LETTER I WITH CIRCUMFLEX
+    {{'i', 0, 0, 0}}, // LATIN SMALL LETTER I WITH DIAERESIS
+    {{'T', 'H', 0, 0}}, // LATIN SMALL LETTER ETH (Icelandic)
+    {{'n', 0, 0, 0}}, // LATIN SMALL LETTER N WITH TILDE
+    {{'o', 0, 0, 0}}, // LATIN SMALL LETTER O WITH GRAVE
+    {{'o', 0, 0, 0}}, // LATIN SMALL LETTER O WITH ACUTE
+    {{'o', 0, 0, 0}}, // LATIN SMALL LETTER O WITH CIRCUMFLEX
+    {{'o', 0, 0, 0}}, // LATIN SMALL LETTER O WITH TILDE
+    {{'o', 0, 0, 0}}, // LATIN SMALL LETTER O WITH DIAERESIS
+    {{'/', 0, 0, 0}}, // DIVISION SIGN
+    {{'o', 0, 0, 0}}, // LATIN SMALL LETTER O WITH STROKE
+    {{'u', 0, 0, 0}}, // LATIN SMALL LETTER U WITH GRAVE
+    {{'u', 0, 0, 0}}, // LATIN SMALL LETTER U WITH ACUTE
+    {{'u', 0, 0, 0}}, // LATIN SMALL LETTER U WITH CIRCUMFLEX
+    {{'u', 0, 0, 0}}, // LATIN SMALL LETTER U WITH DIAERESIS
+    {{'y', 0, 0, 0}}, // LATIN SMALL LETTER Y WITH ACUTE
+    {{'t', 'h', 0, 0}}, // LATIN SMALL LETTER THORN (Icelandic)
+    {{'y', 0, 0, 0}}, // LATIN SMALL LETTER Y WITH DIAERESIS
+};
+
+CF_INLINE CFIndex __CFToASCIILatin1Fallback(UniChar character, uint8_t *bytes, CFIndex maxByteLen) {
+    const uint8_t *losChars = (const uint8_t*)_toLossyASCIITable + (character - 0xA0) * sizeof(uint8_t[4]);
+    CFIndex numBytes = 0;
+    CFIndex idx, max = (maxByteLen && (maxByteLen < 4) ? maxByteLen : 4);
+
+    for (idx = 0;idx < max;idx++) {
+        if (losChars[idx]) {
+            if (maxByteLen) bytes[idx] = losChars[idx];
+            ++numBytes;
+        } else {
+            break;
+        }
+    }
+
+    return numBytes;
+}
+
+static CFIndex __CFDefaultToBytesFallbackProc(const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    CFIndex processCharLen = 1, filledBytesLen = 1;
+    uint8_t byte = '?';
+
+    if (*characters < 0xA0) { // 0x80 to 0x9F maps to ASCII C0 range
+        byte = (uint8_t)(*characters - 0x80);
+    } else if (*characters < 0x100) {
+        *usedByteLen = __CFToASCIILatin1Fallback(*characters, bytes, maxByteLen);
+        return 1;
+    } else if (*characters >= kSurrogateHighStart && *characters <= kSurrogateLowEnd) {
+        processCharLen = (numChars > 1 && *characters <= kSurrogateLowStart && *(characters + 1) >= kSurrogateLowStart && *(characters + 1) <= kSurrogateLowEnd ? 2 : 1);
+    } else if (CFUniCharIsMemberOf(*characters, kCFUniCharWhitespaceCharacterSet)) {
+        byte = ' ';
+    } else if (CFUniCharIsMemberOf(*characters, kCFUniCharWhitespaceAndNewlineCharacterSet)) {
+        byte = ASCIINewLine;
+    } else if (*characters == 0x2026) { // ellipsis
+        if (0 == maxByteLen) {
+            filledBytesLen = 3;
+        } else if (maxByteLen > 2) {
+            memset(bytes, '.', 3);
+            *usedByteLen = 3;
+            return processCharLen;
+        }
+    } else if (CFUniCharIsMemberOf(*characters, kCFUniCharDecomposableCharacterSet)) {
+        UTF32Char decomposed[MAX_DECOMPOSED_LENGTH];
+
+        (void)CFUniCharDecomposeCharacter(*characters, decomposed, MAX_DECOMPOSED_LENGTH);
+        if (*decomposed < 0x80) {
+            byte = (uint8_t)(*decomposed);
+        } else {
+            UTF16Char theChar = *decomposed;
+
+            return __CFDefaultToBytesFallbackProc(&theChar, 1, bytes, maxByteLen, usedByteLen);
+        }
+    }
+    
+    if (maxByteLen) *bytes = byte;
+    *usedByteLen = filledBytesLen;
+    return processCharLen;
+}
+
+static CFIndex __CFDefaultToUnicodeFallbackProc(const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    if (maxCharLen) *characters = (UniChar)'?';
+    *usedCharLen = 1;
+    return 1;
+}
+
+#define TO_BYTE_FALLBACK(conv,chars,numChars,bytes,max,used) (conv->toBytesFallback(chars,numChars,bytes,max,used))
+#define TO_UNICODE_FALLBACK(conv,bytes,numBytes,chars,max,used) (conv->toUnicodeFallback(bytes,numBytes,chars,max,used))
+
+#define EXTRA_BASE (0x0F00)
+
+/* Wrapper funcs for non-standard converters
+*/
+static CFIndex __CFToBytesCheapEightBitWrapper(const void *converter, uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    CFIndex processedCharLen = 0;
+    CFIndex length = (maxByteLen && (maxByteLen < numChars) ? maxByteLen : numChars);
+    uint8_t byte;
+
+    while (processedCharLen < length) {
+        if (!((CFStringEncodingCheapEightBitToBytesProc)((const _CFEncodingConverter*)converter)->_toBytes)(flags, characters[processedCharLen], &byte)) break;
+
+        if (maxByteLen) bytes[processedCharLen] = byte;
+        processedCharLen++;
+    }
+
+    *usedByteLen = processedCharLen;
+    return processedCharLen;
+}
+
+static CFIndex __CFToUnicodeCheapEightBitWrapper(const void *converter, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    CFIndex processedByteLen = 0;
+    CFIndex length = (maxCharLen && (maxCharLen < numBytes) ? maxCharLen : numBytes);
+    UniChar character;
+
+    while (processedByteLen < length) {
+        if (!((CFStringEncodingCheapEightBitToUnicodeProc)((const _CFEncodingConverter*)converter)->_toUnicode)(flags, bytes[processedByteLen], &character)) break;
+
+        if (maxCharLen) characters[processedByteLen] = character;
+        processedByteLen++;
+    }
+
+    *usedCharLen = processedByteLen;
+    return processedByteLen;
+}
+
+static CFIndex __CFToCanonicalUnicodeCheapEightBitWrapper(const void *converter, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    CFIndex processedByteLen = 0;
+    CFIndex theUsedCharLen = 0;
+    UTF32Char charBuffer[MAX_DECOMPOSED_LENGTH];
+    CFIndex usedLen;
+    UniChar character;
+    bool isHFSPlus = (flags & kCFStringEncodingUseHFSPlusCanonical ? true : false);
+
+    while ((processedByteLen < numBytes) && (!maxCharLen || (theUsedCharLen < maxCharLen))) {
+        if (!((CFStringEncodingCheapEightBitToUnicodeProc)((const _CFEncodingConverter*)converter)->_toUnicode)(flags, bytes[processedByteLen], &character)) break;
+
+        if (CFUniCharIsDecomposableCharacter(character, isHFSPlus)) {
+            CFIndex idx;
+
+            usedLen = CFUniCharDecomposeCharacter(character, charBuffer, MAX_DECOMPOSED_LENGTH);
+            *usedCharLen = theUsedCharLen;
+
+            for (idx = 0;idx < usedLen;idx++) {
+                if (charBuffer[idx] > 0xFFFF) { // Non-BMP
+                    if (theUsedCharLen + 2 > maxCharLen)  return processedByteLen;
+                    theUsedCharLen += 2;
+                    if (maxCharLen) {
+                        charBuffer[idx] = charBuffer[idx] - 0x10000;
+                        *(characters++) = (UniChar)(charBuffer[idx] >> 10) + 0xD800UL;
+                        *(characters++) = (UniChar)(charBuffer[idx] & 0x3FF) + 0xDC00UL;
+                    }
+                } else {
+                    if (theUsedCharLen + 1 > maxCharLen)  return processedByteLen;
+                    ++theUsedCharLen;
+                    *(characters++) = charBuffer[idx];
+                }
+            }
+        } else {
+            if (maxCharLen) *(characters++) = character;
+            ++theUsedCharLen;
+        }
+        processedByteLen++;
+    }
+
+    *usedCharLen = theUsedCharLen;
+    return processedByteLen;
+}
+
+static CFIndex __CFToBytesStandardEightBitWrapper(const void *converter, uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    CFIndex processedCharLen = 0;
+    uint8_t byte;
+    CFIndex usedLen;
+
+    *usedByteLen = 0;
+
+    while (numChars && (!maxByteLen || (*usedByteLen < maxByteLen))) {
+        if (!(usedLen = ((CFStringEncodingStandardEightBitToBytesProc)((const _CFEncodingConverter*)converter)->_toBytes)(flags, characters, numChars, &byte))) break;
+
+        if (maxByteLen) bytes[*usedByteLen] = byte;
+        (*usedByteLen)++;
+        characters += usedLen;
+        numChars -= usedLen;
+        processedCharLen += usedLen;
+    }
+
+    return processedCharLen;
+}
+
+static CFIndex __CFToUnicodeStandardEightBitWrapper(const void *converter, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    CFIndex processedByteLen = 0;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(UniChar, charBuffer, ((const _CFEncodingConverter*)converter)->maxLen);
+#else
+    UniChar charBuffer[20]; // Dynamic stack allocation is GNU specific
+#endif
+    CFIndex usedLen;
+
+    *usedCharLen = 0;
+
+    while ((processedByteLen < numBytes) && (!maxCharLen || (*usedCharLen < maxCharLen))) {
+        if (!(usedLen = ((CFStringEncodingCheapEightBitToUnicodeProc)((const _CFEncodingConverter*)converter)->_toUnicode)(flags, bytes[processedByteLen], charBuffer))) break;
+
+        if (maxCharLen) {
+            CFIndex idx;
+
+            if (*usedCharLen + usedLen > maxCharLen) break;
+
+            for (idx = 0;idx < usedLen;idx++) {
+                characters[*usedCharLen + idx] = charBuffer[idx];
+            }
+        }
+        *usedCharLen += usedLen;
+        processedByteLen++;
+    }
+
+    return processedByteLen;
+}
+
+static CFIndex __CFToCanonicalUnicodeStandardEightBitWrapper(const void *converter, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    CFIndex processedByteLen = 0;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(UniChar, charBuffer, ((const _CFEncodingConverter*)converter)->maxLen);
+#else
+    UniChar charBuffer[20]; // Dynamic stack allocation is GNU specific
+#endif
+    UTF32Char decompBuffer[MAX_DECOMPOSED_LENGTH];
+    CFIndex usedLen;
+    CFIndex decompedLen;
+    CFIndex idx, decompIndex;
+    bool isHFSPlus = (flags & kCFStringEncodingUseHFSPlusCanonical ? true : false);
+    CFIndex theUsedCharLen = 0;
+
+    while ((processedByteLen < numBytes) && (!maxCharLen || (theUsedCharLen < maxCharLen))) {
+        if (!(usedLen = ((CFStringEncodingCheapEightBitToUnicodeProc)((const _CFEncodingConverter*)converter)->_toUnicode)(flags, bytes[processedByteLen], charBuffer))) break;
+
+        for (idx = 0;idx < usedLen;idx++) {
+            if (CFUniCharIsDecomposableCharacter(charBuffer[idx], isHFSPlus)) {
+                decompedLen = CFUniCharDecomposeCharacter(charBuffer[idx], decompBuffer, MAX_DECOMPOSED_LENGTH);
+                *usedCharLen = theUsedCharLen;
+
+                for (decompIndex = 0;decompIndex < decompedLen;decompIndex++) {
+                    if (decompBuffer[decompIndex] > 0xFFFF) { // Non-BMP
+                        if (theUsedCharLen + 2 > maxCharLen)  return processedByteLen;
+                        theUsedCharLen += 2;
+                        if (maxCharLen) {
+                            charBuffer[idx] = charBuffer[idx] - 0x10000;
+                            *(characters++) = (charBuffer[idx] >> 10) + 0xD800UL;
+                            *(characters++) = (charBuffer[idx] & 0x3FF) + 0xDC00UL;
+                        }
+                    } else {
+                        if (theUsedCharLen + 1 > maxCharLen)  return processedByteLen;
+                        ++theUsedCharLen;
+                        *(characters++) = charBuffer[idx];
+                    }
+                }
+            } else {
+                if (maxCharLen) *(characters++) = charBuffer[idx];
+                ++theUsedCharLen;
+            }
+        }
+        processedByteLen++;
+    }
+
+    *usedCharLen = theUsedCharLen;
+    return processedByteLen;
+}
+
+static CFIndex __CFToBytesCheapMultiByteWrapper(const void *converter, uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    CFIndex processedCharLen = 0;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+    STACK_BUFFER_DECL(uint8_t, byteBuffer, ((const _CFEncodingConverter*)converter)->maxLen);
+#else
+    UniChar charBuffer[20]; // Dynamic stack allocation is GNU specific
+#endif
+    CFIndex usedLen;
+
+    *usedByteLen = 0;
+
+    while ((processedCharLen < numChars) && (!maxByteLen || (*usedByteLen < maxByteLen))) {
+        if (!(usedLen = ((CFStringEncodingCheapMultiByteToBytesProc)((const _CFEncodingConverter*)converter)->_toBytes)(flags, characters[processedCharLen], byteBuffer))) break;
+
+        if (maxByteLen) {
+            CFIndex idx;
+
+            if (*usedByteLen + usedLen > maxByteLen) break;
+
+            for (idx = 0;idx <usedLen;idx++) {
+                bytes[*usedByteLen + idx] = byteBuffer[idx];
+            }
+        }
+
+        *usedByteLen += usedLen;
+        processedCharLen++;
+    }
+
+    return processedCharLen;
+}
+
+static CFIndex __CFToUnicodeCheapMultiByteWrapper(const void *converter, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    CFIndex processedByteLen = 0;
+    UniChar character;
+    CFIndex usedLen;
+
+    *usedCharLen = 0;
+
+    while (numBytes && (!maxCharLen || (*usedCharLen < maxCharLen))) {
+        if (!(usedLen = ((CFStringEncodingCheapMultiByteToUnicodeProc)((const _CFEncodingConverter*)converter)->_toUnicode)(flags, bytes, numBytes, &character))) break;
+
+        if (maxCharLen) *(characters++) = character;
+        (*usedCharLen)++;
+        processedByteLen += usedLen;
+        bytes += usedLen;
+        numBytes -= usedLen;
+    }
+
+    return processedByteLen;
+}
+
+static CFIndex __CFToCanonicalUnicodeCheapMultiByteWrapper(const void *converter, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    CFIndex processedByteLen = 0;
+    UTF32Char charBuffer[MAX_DECOMPOSED_LENGTH];
+    UniChar character;
+    CFIndex usedLen;
+    CFIndex decomposedLen;
+    CFIndex theUsedCharLen = 0;
+    bool isHFSPlus = (flags & kCFStringEncodingUseHFSPlusCanonical ? true : false);
+
+    while (numBytes && (!maxCharLen || (theUsedCharLen < maxCharLen))) {
+        if (!(usedLen = ((CFStringEncodingCheapMultiByteToUnicodeProc)((const _CFEncodingConverter*)converter)->_toUnicode)(flags, bytes, numBytes, &character))) break;
+
+        if (CFUniCharIsDecomposableCharacter(character, isHFSPlus)) {
+            CFIndex idx;
+
+            decomposedLen = CFUniCharDecomposeCharacter(character, charBuffer, MAX_DECOMPOSED_LENGTH);
+            *usedCharLen = theUsedCharLen;
+
+            for (idx = 0;idx < decomposedLen;idx++) {
+                if (charBuffer[idx] > 0xFFFF) { // Non-BMP
+                    if (theUsedCharLen + 2 > maxCharLen)  return processedByteLen;
+                    theUsedCharLen += 2;
+                    if (maxCharLen) {
+                        charBuffer[idx] = charBuffer[idx] - 0x10000;
+                        *(characters++) = (UniChar)(charBuffer[idx] >> 10) + 0xD800UL;
+                        *(characters++) = (UniChar)(charBuffer[idx] & 0x3FF) + 0xDC00UL;
+                    }
+                } else {
+                    if (theUsedCharLen + 1 > maxCharLen)  return processedByteLen;
+                    ++theUsedCharLen;
+                    *(characters++) = charBuffer[idx];
+                }
+            }
+        } else {
+            if (maxCharLen) *(characters++) = character;
+            ++theUsedCharLen;
+        }
+
+        processedByteLen += usedLen;
+        bytes += usedLen;
+        numBytes -= usedLen;
+    }
+    *usedCharLen = theUsedCharLen;
+    return processedByteLen;
+}
+
+/* static functions
+*/
+static _CFConverterEntry __CFConverterEntryASCII = {
+    kCFStringEncodingASCII, NULL,
+    "Western (ASCII)", {"us-ascii", "ascii", "iso-646-us", NULL}, NULL, NULL, NULL, NULL,
+    kCFStringEncodingMacRoman // We use string encoding's script range here
+};
+
+static _CFConverterEntry __CFConverterEntryISOLatin1 = {
+    kCFStringEncodingISOLatin1, NULL,
+    "Western (ISO Latin 1)", {"iso-8859-1", "latin1","iso-latin-1", NULL}, NULL, NULL, NULL, NULL,
+    kCFStringEncodingMacRoman // We use string encoding's script range here
+};
+
+static _CFConverterEntry __CFConverterEntryMacRoman = {
+    kCFStringEncodingMacRoman, NULL,
+    "Western (Mac OS Roman)", {"macintosh", "mac", "x-mac-roman", NULL}, NULL, NULL, NULL, NULL,
+    kCFStringEncodingMacRoman // We use string encoding's script range here
+};
+
+static _CFConverterEntry __CFConverterEntryWinLatin1 = {
+    kCFStringEncodingWindowsLatin1, NULL,
+    "Western (Windows Latin 1)", {"windows-1252", "cp1252", "windows latin1", NULL}, NULL, NULL, NULL, NULL,
+    kCFStringEncodingMacRoman // We use string encoding's script range here
+};
+
+static _CFConverterEntry __CFConverterEntryNextStepLatin = {
+    kCFStringEncodingNextStepLatin, NULL,
+    "Western (NextStep)", {"x-nextstep", NULL, NULL, NULL}, NULL, NULL, NULL, NULL,
+    kCFStringEncodingMacRoman // We use string encoding's script range here
+};
+
+static _CFConverterEntry __CFConverterEntryUTF8 = {
+    kCFStringEncodingUTF8, NULL,
+    "UTF-8", {"utf-8", "unicode-1-1-utf8", NULL, NULL}, NULL, NULL, NULL, NULL,
+    kCFStringEncodingUnicode // We use string encoding's script range here
+};
+
+CF_INLINE _CFConverterEntry *__CFStringEncodingConverterGetEntry(uint32_t encoding) {
+    switch (encoding) {
+        case kCFStringEncodingInvalidId:
+        case kCFStringEncodingASCII:
+            return &__CFConverterEntryASCII;
+
+        case kCFStringEncodingISOLatin1:
+            return &__CFConverterEntryISOLatin1;
+
+        case kCFStringEncodingMacRoman:
+            return &__CFConverterEntryMacRoman;
+
+        case kCFStringEncodingWindowsLatin1:
+            return &__CFConverterEntryWinLatin1;
+
+        case kCFStringEncodingNextStepLatin:
+            return &__CFConverterEntryNextStepLatin;
+
+        case kCFStringEncodingUTF8:
+            return &__CFConverterEntryUTF8;
+
+        default: {
+            return NULL;
+        }
+    }
+}
+
+CF_INLINE _CFEncodingConverter *__CFEncodingConverterFromDefinition(const CFStringEncodingConverter *definition) {
+#define NUM_OF_ENTRIES_CYCLE (10)
+    static CFSpinLock_t _indexLock = CFSpinLockInit;
+    static uint32_t _currentIndex = 0;
+    static uint32_t _allocatedSize = 0;
+    static _CFEncodingConverter *_allocatedEntries = NULL;
+    _CFEncodingConverter *converter;
+
+
+    __CFSpinLock(&_indexLock);
+    if ((_currentIndex + 1) >= _allocatedSize) {
+        _currentIndex = 0;
+        _allocatedSize = 0;
+        _allocatedEntries = NULL;
+    }
+    if (_allocatedEntries == NULL) { // Not allocated yet
+        _allocatedEntries = (_CFEncodingConverter *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(_CFEncodingConverter) * NUM_OF_ENTRIES_CYCLE, 0);
+        _allocatedSize = NUM_OF_ENTRIES_CYCLE;
+        converter = &(_allocatedEntries[_currentIndex]);
+    } else {
+        converter = &(_allocatedEntries[++_currentIndex]);
+    }
+    __CFSpinUnlock(&_indexLock);
+
+    switch (definition->encodingClass) {
+        case kCFStringEncodingConverterStandard:
+            converter->toBytes = (_CFToBytesProc)definition->toBytes;
+            converter->toUnicode = (_CFToUnicodeProc)definition->toUnicode;
+            converter->toCanonicalUnicode = (_CFToUnicodeProc)definition->toUnicode;
+            converter->_toBytes = NULL;
+            converter->_toUnicode = NULL;
+            converter->maxLen = 2;
+            break;
+
+        case kCFStringEncodingConverterCheapEightBit:
+            converter->toBytes = __CFToBytesCheapEightBitWrapper;
+            converter->toUnicode = __CFToUnicodeCheapEightBitWrapper;
+            converter->toCanonicalUnicode = __CFToCanonicalUnicodeCheapEightBitWrapper;
+            converter->_toBytes = definition->toBytes;
+            converter->_toUnicode = definition->toUnicode;
+            converter->maxLen = 1;
+            break;
+
+        case kCFStringEncodingConverterStandardEightBit:
+            converter->toBytes = __CFToBytesStandardEightBitWrapper;
+            converter->toUnicode = __CFToUnicodeStandardEightBitWrapper;
+            converter->toCanonicalUnicode = __CFToCanonicalUnicodeStandardEightBitWrapper;
+            converter->_toBytes = definition->toBytes;
+            converter->_toUnicode = definition->toUnicode;
+            converter->maxLen = definition->maxDecomposedCharLen;
+            break;
+
+        case kCFStringEncodingConverterCheapMultiByte:
+            converter->toBytes = __CFToBytesCheapMultiByteWrapper;
+            converter->toUnicode = __CFToUnicodeCheapMultiByteWrapper;
+            converter->toCanonicalUnicode = __CFToCanonicalUnicodeCheapMultiByteWrapper;
+            converter->_toBytes = definition->toBytes;
+            converter->_toUnicode = definition->toUnicode;
+            converter->maxLen = definition->maxBytesPerChar;
+            break;
+
+        case kCFStringEncodingConverterPlatformSpecific:
+            converter->toBytes = NULL;
+            converter->toUnicode = NULL;
+            converter->toCanonicalUnicode = NULL;
+            converter->_toBytes = NULL;
+            converter->_toUnicode = NULL;
+            converter->maxLen = 0;
+            converter->toBytesLen = NULL;
+            converter->toUnicodeLen = NULL;
+            converter->toBytesFallback = NULL;
+            converter->toUnicodeFallback = NULL;
+            converter->toBytesPrecompose = NULL;
+            converter->isValidCombiningChar = NULL;
+            return converter;
+            
+        default: // Shouln't be here
+            return NULL;
+    }
+
+    converter->toBytesLen = (definition->toBytesLen ? definition->toBytesLen : (CFStringEncodingToBytesLenProc)(uintptr_t)definition->maxBytesPerChar);
+    converter->toUnicodeLen = (definition->toUnicodeLen ? definition->toUnicodeLen : (CFStringEncodingToUnicodeLenProc)(uintptr_t)definition->maxDecomposedCharLen);
+    converter->toBytesFallback = (definition->toBytesFallback ? definition->toBytesFallback : __CFDefaultToBytesFallbackProc);
+    converter->toUnicodeFallback = (definition->toUnicodeFallback ? definition->toUnicodeFallback : __CFDefaultToUnicodeFallbackProc);
+    converter->toBytesPrecompose = (definition->toBytesPrecompose ? definition->toBytesPrecompose : NULL);
+    converter->isValidCombiningChar = (definition->isValidCombiningChar ? definition->isValidCombiningChar : NULL);
+
+    return converter;
+}
+
+CF_INLINE const CFStringEncodingConverter *__CFStringEncodingConverterGetDefinition(_CFConverterEntry *entry) {
+    if (!entry) return NULL;
+    
+    switch (entry->encoding) {
+        case kCFStringEncodingASCII:
+            return &__CFConverterASCII;
+
+        case kCFStringEncodingISOLatin1:
+            return &__CFConverterISOLatin1;
+
+        case kCFStringEncodingMacRoman:
+            return &__CFConverterMacRoman;
+
+        case kCFStringEncodingWindowsLatin1:
+            return &__CFConverterWinLatin1;
+
+        case kCFStringEncodingNextStepLatin:
+            return &__CFConverterNextStepLatin;
+
+        case kCFStringEncodingUTF8:
+            return &__CFConverterUTF8;
+
+        default:
+	    return NULL;
+    }
+}
+
+static const _CFEncodingConverter *__CFGetConverter(uint32_t encoding) {
+    _CFConverterEntry *entry = __CFStringEncodingConverterGetEntry(encoding);
+
+    if (!entry) return NULL;
+
+    if (!entry->converter) {
+        const CFStringEncodingConverter *definition = __CFStringEncodingConverterGetDefinition(entry);
+
+        if (definition) {
+            entry->converter = __CFEncodingConverterFromDefinition(definition);
+            entry->toBytesFallback = definition->toBytesFallback;
+            entry->toUnicodeFallback = definition->toUnicodeFallback;
+        }
+    }
+
+    return (_CFEncodingConverter *)entry->converter;
+}
+
+/* Public API
+*/
+uint32_t CFStringEncodingUnicodeToBytes(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen) {
+    if (encoding == kCFStringEncodingUTF8) {
+        static CFStringEncodingToBytesProc __CFToUTF8 = NULL;
+        CFIndex convertedCharLen;
+        CFIndex usedLen;
+
+
+        if ((flags & kCFStringEncodingUseCanonical) || (flags & kCFStringEncodingUseHFSPlusCanonical)) {
+            (void)CFUniCharDecompose(characters, numChars, &convertedCharLen, (void *)bytes, maxByteLen, &usedLen, true, kCFUniCharUTF8Format, (flags & kCFStringEncodingUseHFSPlusCanonical ? true : false));
+        } else {
+            if (!__CFToUTF8) {
+                const CFStringEncodingConverter *utf8Converter = CFStringEncodingGetConverter(kCFStringEncodingUTF8);
+                __CFToUTF8 = (CFStringEncodingToBytesProc)utf8Converter->toBytes;
+            }
+            convertedCharLen = __CFToUTF8(0, characters, numChars, bytes, maxByteLen, &usedLen);
+        }
+        if (usedCharLen) *usedCharLen = convertedCharLen;
+        if (usedByteLen) *usedByteLen = usedLen;
+
+        if (convertedCharLen == numChars) {
+            return kCFStringEncodingConversionSuccess;
+        } else if (maxByteLen && (maxByteLen == usedLen)) {
+            return kCFStringEncodingInsufficientOutputBufferLength;
+        } else {
+            return kCFStringEncodingInvalidInputStream;
+        }
+    } else {
+        const _CFEncodingConverter *converter = __CFGetConverter(encoding);
+        CFIndex usedLen = 0;
+        CFIndex localUsedByteLen;
+        CFIndex theUsedByteLen = 0;
+        uint32_t theResult = kCFStringEncodingConversionSuccess;
+        CFStringEncodingToBytesPrecomposeProc toBytesPrecompose = NULL;
+        CFStringEncodingIsValidCombiningCharacterProc isValidCombiningChar = NULL;
+
+        if (!converter) return kCFStringEncodingConverterUnavailable;
+
+        if (flags & kCFStringEncodingSubstituteCombinings) {
+            if (!(flags & kCFStringEncodingAllowLossyConversion)) isValidCombiningChar = converter->isValidCombiningChar;
+       } else {
+            isValidCombiningChar = converter->isValidCombiningChar;
+            if (!(flags & kCFStringEncodingIgnoreCombinings)) {
+                toBytesPrecompose = converter->toBytesPrecompose;
+                flags |= kCFStringEncodingComposeCombinings;
+            }
+        }
+
+
+        while ((usedLen < numChars) && (!maxByteLen || (theUsedByteLen < maxByteLen))) {
+            if ((usedLen += TO_BYTE(converter, flags, characters + usedLen, numChars - usedLen, bytes + theUsedByteLen, (maxByteLen ? maxByteLen - theUsedByteLen : 0), &localUsedByteLen)) < numChars) {
+                CFIndex dummy;
+
+                if (isValidCombiningChar && (usedLen > 0) && isValidCombiningChar(characters[usedLen])) {
+                    if (toBytesPrecompose) {
+                        CFIndex localUsedLen = usedLen;
+
+                        while (isValidCombiningChar(characters[--usedLen]));
+                        theUsedByteLen += localUsedByteLen;
+                        if (converter->maxLen > 1) {
+                            TO_BYTE(converter, flags, characters + usedLen, localUsedLen - usedLen, NULL, 0, &localUsedByteLen);
+                            theUsedByteLen -= localUsedByteLen;
+                        } else {
+                            theUsedByteLen--;
+                        }
+                        if ((localUsedLen = toBytesPrecompose(flags, characters + usedLen, numChars - usedLen, bytes + theUsedByteLen, (maxByteLen ? maxByteLen - theUsedByteLen : 0), &localUsedByteLen)) > 0) {
+                            usedLen += localUsedLen;
+                            if ((usedLen < numChars) && isValidCombiningChar(characters[usedLen])) { // There is a non-base char not combined remaining
+                                theUsedByteLen += localUsedByteLen;
+                                theResult = kCFStringEncodingInvalidInputStream;
+                                break;
+                            }
+                        } else if (flags & kCFStringEncodingAllowLossyConversion) {
+                            uint8_t lossyByte = CFStringEncodingMaskToLossyByte(flags);
+
+                            if (lossyByte) {
+								while (isValidCombiningChar(characters[++usedLen]));
+                                localUsedByteLen = 1;
+                                if (maxByteLen) *(bytes + theUsedByteLen) = lossyByte;
+                            } else {
+                                ++usedLen;
+                                usedLen += TO_BYTE_FALLBACK(converter, characters + usedLen, numChars - usedLen, bytes + theUsedByteLen, (maxByteLen ? maxByteLen - theUsedByteLen : 0), &localUsedByteLen);
+                            }
+                        } else {
+                            theResult = kCFStringEncodingInvalidInputStream;
+                            break;
+                        }
+                    } else if (maxByteLen && ((maxByteLen == theUsedByteLen + localUsedByteLen) || TO_BYTE(converter, flags, characters + usedLen, numChars - usedLen, NULL, 0, &dummy))) { // buffer was filled up
+                                    theUsedByteLen += localUsedByteLen;
+                                    theResult = kCFStringEncodingInsufficientOutputBufferLength;
+                                    break;
+                    } else if (flags & kCFStringEncodingIgnoreCombinings) {
+                        while ((++usedLen < numChars) && isValidCombiningChar(characters[usedLen]));
+                    } else {
+                        uint8_t lossyByte = CFStringEncodingMaskToLossyByte(flags);
+
+                        theUsedByteLen += localUsedByteLen;
+                        if (lossyByte) {
+                            ++usedLen;
+                            localUsedByteLen = 1;
+                            if (maxByteLen) *(bytes + theUsedByteLen) = lossyByte;
+                        } else {
+                            usedLen += TO_BYTE_FALLBACK(converter, characters + usedLen, numChars - usedLen, bytes + theUsedByteLen, (maxByteLen ? maxByteLen - theUsedByteLen : 0), &localUsedByteLen);
+                        }
+                    }
+                } else if (maxByteLen && ((maxByteLen == theUsedByteLen + localUsedByteLen) || TO_BYTE(converter, flags, characters + usedLen, numChars - usedLen, NULL, 0, &dummy))) { // buffer was filled up
+                    theUsedByteLen += localUsedByteLen;
+
+                    if (flags & kCFStringEncodingAllowLossyConversion && !CFStringEncodingMaskToLossyByte(flags)) {
+                        CFIndex localUsedLen;
+
+                        localUsedByteLen = 0;
+                        while ((usedLen < numChars) && !localUsedByteLen && (localUsedLen = TO_BYTE_FALLBACK(converter, characters + usedLen, numChars - usedLen, NULL, 0, &localUsedByteLen))) usedLen += localUsedLen;
+                    }
+                    if (usedLen < numChars) theResult = kCFStringEncodingInsufficientOutputBufferLength;
+                    break;
+                } else if (flags & kCFStringEncodingAllowLossyConversion) {
+                    uint8_t lossyByte = CFStringEncodingMaskToLossyByte(flags);
+
+                    theUsedByteLen += localUsedByteLen;
+                    if (lossyByte) {
+                        ++usedLen;
+                        localUsedByteLen = 1;
+                        if (maxByteLen) *(bytes + theUsedByteLen) = lossyByte;
+                    } else {
+                        usedLen += TO_BYTE_FALLBACK(converter, characters + usedLen, numChars - usedLen, bytes + theUsedByteLen, (maxByteLen ? maxByteLen - theUsedByteLen : 0), &localUsedByteLen);
+                    }
+                } else {
+                    theUsedByteLen += localUsedByteLen;
+                    theResult = kCFStringEncodingInvalidInputStream;
+                    break;
+                }
+            }
+            theUsedByteLen += localUsedByteLen;
+        }
+
+        if (usedLen < numChars && maxByteLen && theResult == kCFStringEncodingConversionSuccess) {
+            if (flags & kCFStringEncodingAllowLossyConversion && !CFStringEncodingMaskToLossyByte(flags)) {
+                CFIndex localUsedLen;
+
+                localUsedByteLen = 0;
+                while ((usedLen < numChars) && !localUsedByteLen && (localUsedLen = TO_BYTE_FALLBACK(converter, characters + usedLen, numChars - usedLen, NULL, 0, &localUsedByteLen))) usedLen += localUsedLen;
+            }
+            if (usedLen < numChars) theResult = kCFStringEncodingInsufficientOutputBufferLength;
+        }
+        if (usedByteLen) *usedByteLen = theUsedByteLen;
+        if (usedCharLen) *usedCharLen = usedLen;
+
+        return theResult;
+    }
+}
+
+uint32_t CFStringEncodingBytesToUnicode(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen) {
+    const _CFEncodingConverter *converter = __CFGetConverter(encoding);
+    CFIndex usedLen = 0;
+    CFIndex theUsedCharLen = 0;
+    CFIndex localUsedCharLen;
+    uint32_t theResult = kCFStringEncodingConversionSuccess;
+
+    if (!converter) return kCFStringEncodingConverterUnavailable;
+
+
+    while ((usedLen < numBytes) && (!maxCharLen || (theUsedCharLen < maxCharLen))) {
+        if ((usedLen += TO_UNICODE(converter, flags, bytes + usedLen, numBytes - usedLen, characters + theUsedCharLen, (maxCharLen ? maxCharLen - theUsedCharLen : 0), &localUsedCharLen)) < numBytes) {
+            CFIndex tempUsedCharLen;
+
+            if (maxCharLen && ((maxCharLen == theUsedCharLen + localUsedCharLen) || (((flags & (kCFStringEncodingUseCanonical|kCFStringEncodingUseHFSPlusCanonical)) || (maxCharLen == theUsedCharLen + localUsedCharLen + 1)) && TO_UNICODE(converter, flags, bytes + usedLen, numBytes - usedLen, NULL, 0, &tempUsedCharLen)))) { // buffer was filled up
+                theUsedCharLen += localUsedCharLen;
+                theResult = kCFStringEncodingInsufficientOutputBufferLength;
+                break;
+            } else if (flags & kCFStringEncodingAllowLossyConversion) {
+                theUsedCharLen += localUsedCharLen;
+                usedLen += TO_UNICODE_FALLBACK(converter, bytes + usedLen, numBytes - usedLen, characters + theUsedCharLen, (maxCharLen ? maxCharLen - theUsedCharLen : 0), &localUsedCharLen);
+            } else {
+                theUsedCharLen += localUsedCharLen;
+                theResult = kCFStringEncodingInvalidInputStream;
+                break;
+            }
+        }
+        theUsedCharLen += localUsedCharLen;
+    }
+
+    if (usedLen < numBytes && maxCharLen && theResult == kCFStringEncodingConversionSuccess) {
+        theResult = kCFStringEncodingInsufficientOutputBufferLength;
+    }
+    if (usedCharLen) *usedCharLen = theUsedCharLen;
+    if (usedByteLen) *usedByteLen = usedLen;
+
+    return theResult;
+}
+
+__private_extern__ bool CFStringEncodingIsValidEncoding(uint32_t encoding) {
+    return (CFStringEncodingGetConverter(encoding) ? true : false);
+}
+
+__private_extern__ const char *CFStringEncodingName(uint32_t encoding) {
+    _CFConverterEntry *entry = __CFStringEncodingConverterGetEntry(encoding);
+    if (entry) return entry->encodingName;
+    return NULL;
+}
+
+__private_extern__ const char **CFStringEncodingCanonicalCharsetNames(uint32_t encoding) {
+    _CFConverterEntry *entry = __CFStringEncodingConverterGetEntry(encoding);
+    if (entry) return entry->ianaNames;
+    return NULL;
+}
+
+__private_extern__ uint32_t CFStringEncodingGetScriptCodeForEncoding(CFStringEncoding encoding) {
+    _CFConverterEntry *entry = __CFStringEncodingConverterGetEntry(encoding);
+
+    return (entry ? entry->scriptCode : ((encoding & 0x0FFF) == kCFStringEncodingUnicode ? kCFStringEncodingUnicode : (encoding < 0xFF ? encoding : kCFStringEncodingInvalidId)));
+}
+
+__private_extern__ CFIndex CFStringEncodingCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes) {
+    const _CFEncodingConverter *converter = __CFGetConverter(encoding);
+
+    if (converter) {
+        uintptr_t switchVal = (uintptr_t)(converter->toUnicodeLen);
+
+        if (switchVal < 0xFFFF) {
+            return switchVal * numBytes;
+        } else {
+            return converter->toUnicodeLen(flags, bytes, numBytes);
+	}
+    }
+
+    return 0;
+}
+
+__private_extern__ CFIndex CFStringEncodingByteLengthForCharacters(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars) {
+    const _CFEncodingConverter *converter = __CFGetConverter(encoding);
+
+    if (converter) {
+        uintptr_t switchVal = (uintptr_t)(converter->toBytesLen);
+
+	if (switchVal < 0xFFFF) {
+            return switchVal * numChars;
+        } else {
+            return converter->toBytesLen(flags, characters, numChars);
+	}
+    }
+
+    return 0;
+}
+
+__private_extern__ void CFStringEncodingRegisterFallbackProcedures(uint32_t encoding, CFStringEncodingToBytesFallbackProc toBytes, CFStringEncodingToUnicodeFallbackProc toUnicode) {
+    _CFConverterEntry *entry = __CFStringEncodingConverterGetEntry(encoding);
+
+    if (entry && __CFGetConverter(encoding)) {
+        ((_CFEncodingConverter*)entry->converter)->toBytesFallback = (toBytes ? toBytes : entry->toBytesFallback);
+        ((_CFEncodingConverter*)entry->converter)->toUnicodeFallback = (toUnicode ? toUnicode : entry->toUnicodeFallback);
+    }
+}
+
+__private_extern__ const CFStringEncodingConverter *CFStringEncodingGetConverter(uint32_t encoding) {
+    return __CFStringEncodingConverterGetDefinition(__CFStringEncodingConverterGetEntry(encoding));
+}
+
+static const uint32_t __CFBuiltinEncodings[] = {
+    kCFStringEncodingMacRoman,
+    kCFStringEncodingWindowsLatin1,
+    kCFStringEncodingISOLatin1,
+    kCFStringEncodingNextStepLatin,
+    kCFStringEncodingASCII,
+    kCFStringEncodingUTF8,
+    /* These seven are available only in CFString-level */
+    kCFStringEncodingNonLossyASCII,
+
+    kCFStringEncodingUTF16,
+    kCFStringEncodingUTF16BE,
+    kCFStringEncodingUTF16LE,
+
+    kCFStringEncodingUTF32,
+    kCFStringEncodingUTF32BE,
+    kCFStringEncodingUTF32LE,
+
+    kCFStringEncodingInvalidId,
+};
+
+
+__private_extern__ const uint32_t *CFStringEncodingListOfAvailableEncodings(void) {
+    return __CFBuiltinEncodings;
+}
+
+
+#undef TO_BYTE
+#undef TO_UNICODE
+#undef ASCIINewLine
+#undef kSurrogateHighStart
+#undef kSurrogateHighEnd
+#undef kSurrogateLowStart
+#undef kSurrogateLowEnd
+#undef TO_BYTE_FALLBACK
+#undef TO_UNICODE_FALLBACK
+#undef EXTRA_BASE
+#undef NUM_OF_ENTRIES_CYCLE
+
diff --git a/CoreFoundation/CFStringEncodingConverter.h b/CoreFoundation/CFStringEncodingConverter.h
new file mode 100644
index 0000000..bc7dad4
--- /dev/null
+++ b/CoreFoundation/CFStringEncodingConverter.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTER__)
+#define __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ 1
+
+#include <CoreFoundation/CFString.h>
+
+
+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.
+*/
+enum {
+    kCFStringEncodingAllowLossyConversion = 1, // Uses fallback functions to substitutes non mappable chars
+    kCFStringEncodingBasicDirectionLeftToRight = (1 << 1), // Converted with original direction left-to-right.
+    kCFStringEncodingBasicDirectionRightToLeft = (1 << 2), // Converted with original direction right-to-left.
+    kCFStringEncodingSubstituteCombinings = (1 << 3), // Uses fallback function to combining chars.
+    kCFStringEncodingComposeCombinings = (1 << 4), // Checks mappable precomposed equivalents for decomposed sequences.  This is the default behavior.
+    kCFStringEncodingIgnoreCombinings = (1 << 5), // Ignores combining chars.
+    kCFStringEncodingUseCanonical = (1 << 6), // Always use canonical form
+    kCFStringEncodingUseHFSPlusCanonical = (1 << 7), // Always use canonical form but leaves 0x2000 ranges
+    kCFStringEncodingPrependBOM = (1 << 8), // Prepend BOM sequence (i.e. ISO2022KR)
+    kCFStringEncodingDisableCorporateArea = (1 << 9), // Disable the usage of 0xF8xx area for Apple proprietary chars in converting to UniChar, resulting loosely mapping.
+    kCFStringEncodingASCIICompatibleConversion = (1 << 10), // This flag forces strict ASCII compatible converion. i.e. MacJapanese 0x5C maps to Unicode 0x5C.
+    kCFStringEncodingLenientUTF8Conversion = (1 << 11) // 10.1 (Puma) compatible lenient UTF-8 conversion.
+};
+
+/* 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))
+
+/* 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), ....)
+*/
+extern 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.
+*/
+extern 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);
+
+extern bool CFStringEncodingIsValidEncoding(uint32_t encoding);
+
+/* Returns kCFStringEncodingInvalidId terminated encoding list
+*/
+extern const uint32_t *CFStringEncodingListOfAvailableEncodings(void);
+
+extern const char *CFStringEncodingName(uint32_t encoding);
+
+/* Returns NULL-terminated list of IANA registered canonical names
+*/
+extern const char **CFStringEncodingCanonicalCharsetNames(uint32_t encoding);
+
+/* Returns required length of destination buffer for conversion.  These functions are faster than specifying 0 to maxByteLen (maxCharLen), but unnecessarily optimal length
+*/
+extern CFIndex CFStringEncodingCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes);
+extern 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
+*/
+extern void CFStringEncodingRegisterFallbackProcedures(uint32_t encoding, CFStringEncodingToBytesFallbackProc toBytes, CFStringEncodingToUnicodeFallbackProc toUnicode);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ */
+
diff --git a/CoreFoundation/CFStringEncodingConverterExt.h b/CoreFoundation/CFStringEncodingConverterExt.h
new file mode 100644
index 0000000..66e56fe
--- /dev/null
+++ b/CoreFoundation/CFStringEncodingConverterExt.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__)
+#define __COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__ 1
+
+#include <CoreFoundation/CFStringEncodingConverter.h>
+
+CF_EXTERN_C_BEGIN
+
+#define MAX_DECOMPOSED_LENGTH (10)
+
+enum {
+    kCFStringEncodingConverterStandard = 0,
+    kCFStringEncodingConverterCheapEightBit = 1,
+    kCFStringEncodingConverterStandardEightBit = 2,
+    kCFStringEncodingConverterCheapMultiByte = 3,
+    kCFStringEncodingConverterPlatformSpecific = 4 // 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);
+
+extern uint32_t CFStringEncodingGetScriptCodeForEncoding(CFStringEncoding encoding);
+
+/* 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/CoreFoundation/CFStringEncodingConverterPriv.h b/CoreFoundation/CFStringEncodingConverterPriv.h
new file mode 100644
index 0000000..3c1d47b
--- /dev/null
+++ b/CoreFoundation/CFStringEncodingConverterPriv.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__)
+#define __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include "CFStringEncodingConverterExt.h"
+
+#define MAX_IANA_ALIASES (4)
+
+typedef CFIndex (*_CFToBytesProc)(const void *converter, uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen);
+typedef CFIndex (*_CFToUnicodeProc)(const void *converter, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen);
+
+typedef struct {
+    _CFToBytesProc toBytes;
+    _CFToUnicodeProc toUnicode;
+    _CFToUnicodeProc toCanonicalUnicode;
+    void *_toBytes; // original proc
+    void *_toUnicode; // original proc
+    uint16_t maxLen;
+    uint16_t :16;
+    CFStringEncodingToBytesLenProc toBytesLen;
+    CFStringEncodingToUnicodeLenProc toUnicodeLen;
+    CFStringEncodingToBytesFallbackProc toBytesFallback;
+    CFStringEncodingToUnicodeFallbackProc toUnicodeFallback;
+    CFStringEncodingToBytesPrecomposeProc toBytesPrecompose;
+    CFStringEncodingIsValidCombiningCharacterProc isValidCombiningChar;
+} _CFEncodingConverter;
+
+typedef struct {
+    uint32_t encoding;
+    _CFEncodingConverter *converter;
+    const char *encodingName;
+    const char *ianaNames[MAX_IANA_ALIASES];
+    const char *loadablePath;
+    CFStringEncodingBootstrapProc bootstrap;
+    CFStringEncodingToBytesFallbackProc toBytesFallback;
+    CFStringEncodingToUnicodeFallbackProc toUnicodeFallback;
+    uint32_t scriptCode;
+} _CFConverterEntry;
+
+extern const CFStringEncodingConverter __CFConverterASCII;
+extern const CFStringEncodingConverter __CFConverterISOLatin1;
+extern const CFStringEncodingConverter __CFConverterMacRoman;
+extern const CFStringEncodingConverter __CFConverterWinLatin1;
+extern const CFStringEncodingConverter __CFConverterNextStepLatin;
+extern const CFStringEncodingConverter __CFConverterUTF8;
+
+
+#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ */
+
diff --git a/CoreFoundation/CFStringEncodingExt.h b/CoreFoundation/CFStringEncodingExt.h
new file mode 100644
index 0000000..203023b
--- /dev/null
+++ b/CoreFoundation/CFStringEncodingExt.h
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFSTRINGENCODINGEXT__)
+#define __COREFOUNDATION_CFSTRINGENCODINGEXT__ 1
+
+#include <CoreFoundation/CFBase.h>
+
+CF_EXTERN_C_BEGIN
+
+enum {
+/*  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 */
+#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFStringEncodingISOLatin10 = 0x0210,	/* ISO 8859-16 */
+#endif
+
+    /* 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 */
+#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFStringEncodingANSEL = 0x0601,	/* ANSEL (ANSI Z39.47) */
+#endif
+    kCFStringEncodingJIS_X0201_76 = 0x0620,
+    kCFStringEncodingJIS_X0208_83 = 0x0621,
+    kCFStringEncodingJIS_X0208_90 = 0x0622,
+    kCFStringEncodingJIS_X0212_90 = 0x0623,
+    kCFStringEncodingJIS_C6226_78 = 0x0624,
+#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFStringEncodingShiftJIS_X0213 = 0x0628, /* Shift-JIS format encoding of JIS X0213 planes 1 and 2*/
+#endif
+#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFStringEncodingShiftJIS_X0213_MenKuTen = 0x0629,	/* JIS X0213 in plane-row-column notation */
+#endif
+    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*/
+#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFStringEncodingVISCII = 0x0A07,	/* RFC 1456, Vietnamese */
+    kCFStringEncodingKOI8_U = 0x0A08,	/* RFC 2319, Ukrainian */
+    kCFStringEncodingBig5_E = 0x0A09,	/* Taiwan Big-5E standard */
+#endif
+
+    /* Other platform encodings*/
+/*  kCFStringEncodingNextStepLatin = 0x0B01, defined in CoreFoundation/CFString.h */
+#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
+    kCFStringEncodingNextStepJapanese = 0x0B02,	/* NextStep Japanese encoding */
+#endif
+
+    /* 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... */
+
+    /* Deprecated constants */
+    kCFStringEncodingShiftJIS_X0213_00 = 0x0628 /* Shift-JIS format encoding of JIS X0213 planes 1 and 2 (DEPRECATED) */
+};
+typedef CFIndex CFStringEncodings;
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGEXT__ */
+
diff --git a/CoreFoundation/CFStringEncodings.c b/CoreFoundation/CFStringEncodings.c
new file mode 100644
index 0000000..6f00c07
--- /dev/null
+++ b/CoreFoundation/CFStringEncodings.c
@@ -0,0 +1,872 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFStringEncodings.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Aki Inoue
+*/
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFByteOrder.h>
+#include "CFPriv.h"
+#include <string.h>
+#include "CFStringEncodingConverterExt.h"
+#include "CFUniChar.h"
+#include "CFUnicodeDecomposition.h"
+
+static UInt32 __CFWantsToUseASCIICompatibleConversion = (UInt32)-1;
+CF_INLINE UInt32 __CFGetASCIICompatibleFlag(void) {
+    if (__CFWantsToUseASCIICompatibleConversion == (UInt32)-1) {
+        __CFWantsToUseASCIICompatibleConversion = false;
+    }
+    return (__CFWantsToUseASCIICompatibleConversion ? kCFStringEncodingASCIICompatibleConversion : 0);
+}
+
+void _CFStringEncodingSetForceASCIICompatibility(Boolean flag) {
+    __CFWantsToUseASCIICompatibleConversion = (flag ? (UInt32)true : (UInt32)false);
+}
+
+Boolean (*__CFCharToUniCharFunc)(UInt32 flags, uint8_t ch, UniChar *unicodeChar) = NULL;
+
+// To avoid early initialization issues, we just initialize this here
+// This should not be const as it is changed
+UniChar __CFCharToUniCharTable[256] = {
+  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
+ 16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
+ 32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
+ 48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
+ 64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
+ 80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
+ 96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
+};    
+
+void __CFSetCharToUniCharFunc(Boolean (*func)(UInt32 flags, UInt8 ch, UniChar *unicodeChar)) {
+    if (__CFCharToUniCharFunc != func) {
+        int ch;
+        __CFCharToUniCharFunc = func;
+        if (func) {
+            for (ch = 128; ch < 256; ch++) {
+                UniChar uch;
+                __CFCharToUniCharTable[ch] = (__CFCharToUniCharFunc(0, ch, &uch) ? uch : 0xFFFD);
+            }
+        } else {	// If we have no __CFCharToUniCharFunc, assume 128..255 return the value as-is
+            for (ch = 128; ch < 256; ch++) __CFCharToUniCharTable[ch] = ch;
+        }
+    }
+}
+
+__private_extern__ void __CFStrConvertBytesToUnicode(const uint8_t *bytes, UniChar *buffer, CFIndex numChars) {
+    CFIndex idx;
+    for (idx = 0; idx < numChars; idx++) buffer[idx] = __CFCharToUniCharTable[bytes[idx]];
+}
+
+
+/* The minimum length the output buffers should be in the above functions
+*/
+#define kCFCharConversionBufferLength 512
+
+
+#define MAX_LOCAL_CHARS		(sizeof(buffer->localBuffer) / sizeof(uint8_t))
+#define MAX_LOCAL_UNICHARS	(sizeof(buffer->localBuffer) / sizeof(UniChar))
+
+/* 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. The caller needs to free the returned buffer in either ascii or unicode (indicated by isASCII), if shouldFreeChars is true. 
+9/18/98 __CFStringDecodeByteStream now avoids to allocate buffer if buffer->chars is not NULL
+Added useClientsMemoryPtr; if not-NULL, and the provided memory can be used as is, this is set to true
+__CFStringDecodeByteStream2() is kept around for any internal clients who might be using it; it should be deprecated
+!!! converterFlags is only used for the UTF8 converter at this point
+*/
+Boolean __CFStringDecodeByteStream2(const uint8_t *bytes, UInt32 len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr) {
+    return __CFStringDecodeByteStream3(bytes, len, encoding, alwaysUnicode, buffer, useClientsMemoryPtr, 0);
+}
+
+enum {
+    __NSNonLossyErrorMode = -1,
+    __NSNonLossyASCIIMode = 0,
+    __NSNonLossyBackslashMode = 1,
+    __NSNonLossyHexInitialMode = __NSNonLossyBackslashMode + 1,
+    __NSNonLossyHexFinalMode = __NSNonLossyHexInitialMode + 4,
+    __NSNonLossyOctalInitialMode = __NSNonLossyHexFinalMode + 1,
+    __NSNonLossyOctalFinalMode = __NSNonLossyHexFinalMode + 3
+};
+
+Boolean __CFStringDecodeByteStream3(const uint8_t *bytes, CFIndex len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr, UInt32 converterFlags) {
+
+    if (useClientsMemoryPtr) *useClientsMemoryPtr = false;
+
+    buffer->isASCII = !alwaysUnicode;
+    buffer->shouldFreeChars = false;
+    buffer->numChars = 0;
+
+    if (0 == len) return true;
+
+    buffer->allocator = (buffer->allocator ? buffer->allocator : __CFGetDefaultAllocator());
+
+    if ((encoding == kCFStringEncodingUTF16) || (encoding == kCFStringEncodingUTF16BE) || (encoding == kCFStringEncodingUTF16LE)) { // UTF-16
+        const UTF16Char *src = (const UTF16Char *)bytes;
+        const UTF16Char *limit = (const UTF16Char *)(bytes + len);
+        bool swap = false;
+
+        if (kCFStringEncodingUTF16 == encoding) {
+            UTF16Char bom = ((*src == 0xFFFE) || (*src == 0xFEFF) ? *(src++) : 0);
+
+#if __CF_BIG_ENDIAN__
+            if (bom == 0xFFFE) swap = true;
+#else
+            if (bom != 0xFEFF) swap = true;
+#endif
+            if (bom) useClientsMemoryPtr = NULL;
+        } else {
+#if __CF_BIG_ENDIAN__
+            if (kCFStringEncodingUTF16LE == encoding) swap = true;
+#else
+            if (kCFStringEncodingUTF16BE == encoding) swap = true;
+#endif
+        }
+
+        buffer->numChars = limit - src;
+
+        if (useClientsMemoryPtr && !swap) { // If the caller is ready to deal with no-copy situation, and the situation is possible, indicate it...
+            *useClientsMemoryPtr = true;
+            buffer->chars.unicode = (UniChar *)src;
+            buffer->isASCII = false;
+        } else {
+            if (buffer->isASCII) {	// Let's see if we can reduce the Unicode down to ASCII...
+                const UTF16Char *characters = src;
+                UTF16Char mask = (swap ? 0x80FF : 0xFF80);
+    
+                while (characters < limit) {
+                    if (*(characters++) & mask) {
+                        buffer->isASCII = false;
+                        break;
+                    }
+                }
+            }
+    
+            if (buffer->isASCII) {
+                uint8_t *dst;
+                if (NULL == buffer->chars.ascii) { // we never reallocate when buffer is supplied
+                    if (buffer->numChars > MAX_LOCAL_CHARS) {
+                        buffer->chars.ascii = (UInt8 *)CFAllocatorAllocate(buffer->allocator, (buffer->numChars * sizeof(uint8_t)), 0);
+                        buffer->shouldFreeChars = true;
+                    } else {
+                        buffer->chars.ascii = (uint8_t *)buffer->localBuffer;
+                    }
+                }
+                dst = buffer->chars.ascii;
+    
+                if (swap) {
+                    while (src < limit) *(dst++) = (*(src++) >> 8);
+                } else {
+                    while (src < limit) *(dst++) = (uint8_t)*(src++);
+                }
+            } else {
+                UTF16Char *dst;
+
+                if (NULL == buffer->chars.unicode) { // we never reallocate when buffer is supplied
+                    if (buffer->numChars > MAX_LOCAL_UNICHARS) {
+                        buffer->chars.unicode = (UniChar *)CFAllocatorAllocate(buffer->allocator, (buffer->numChars * sizeof(UTF16Char)), 0);
+                        buffer->shouldFreeChars = true;
+                    } else {
+                        buffer->chars.unicode = (UTF16Char *)buffer->localBuffer;
+                    }
+                }
+                dst = buffer->chars.unicode;
+
+                if (swap) {
+                    while (src < limit) *(dst++) = CFSwapInt16(*(src++));
+                } else {
+                    memmove(dst, src, buffer->numChars * sizeof(UTF16Char));
+                }
+            }
+        }
+    } else if ((encoding == kCFStringEncodingUTF32) || (encoding == kCFStringEncodingUTF32BE) || (encoding == kCFStringEncodingUTF32LE)) {
+        const UTF32Char *src = (const UTF32Char *)bytes;
+        const UTF32Char *limit = (const UTF32Char *)(bytes + len);
+        bool swap = false;
+        static bool strictUTF32 = (bool)-1;
+
+        if ((bool)-1 == strictUTF32) strictUTF32 = (_CFExecutableLinkedOnOrAfter(CFSystemVersionLeopard) != 0);
+
+        if (kCFStringEncodingUTF32 == encoding) {
+            UTF32Char bom = ((*src == 0xFFFE0000) || (*src == 0x0000FEFF) ? *(src++) : 0);
+
+#if __CF_BIG_ENDIAN__
+            if (bom == 0xFFFE0000) swap = true;
+#else
+            if (bom != 0x0000FEFF) swap = true;
+#endif
+        } else {
+#if __CF_BIG_ENDIAN__
+            if (kCFStringEncodingUTF32LE == encoding) swap = true;
+#else
+            if (kCFStringEncodingUTF32BE == encoding) swap = true;
+#endif
+        }
+
+        buffer->numChars = limit - src;
+
+        {
+            // Let's see if we have non-ASCII or non-BMP
+            const UTF32Char *characters = src;
+            UTF32Char asciiMask = (swap ? 0x80FFFFFF : 0xFFFFFF80);
+            UTF32Char bmpMask = (swap ? 0x0000FFFF : 0xFFFF0000);
+    
+            while (characters < limit) {
+                if (*characters & asciiMask) {
+                    buffer->isASCII = false;
+                    if (*characters & bmpMask) {
+                        if (strictUTF32 && ((swap ? (UTF32Char)CFSwapInt32(*characters) : *characters) > 0x10FFFF)) return false; // outside of Unicode Scaler Value
+                        ++(buffer->numChars);
+                    }
+                }
+                ++characters;
+            }
+        }
+    
+        if (buffer->isASCII) {
+            uint8_t *dst;
+            if (NULL == buffer->chars.ascii) { // we never reallocate when buffer is supplied
+                if (buffer->numChars > MAX_LOCAL_CHARS) {
+                    buffer->chars.ascii = (UInt8 *)CFAllocatorAllocate(buffer->allocator, (buffer->numChars * sizeof(uint8_t)), 0);
+                    buffer->shouldFreeChars = true;
+                } else {
+                    buffer->chars.ascii = (uint8_t *)buffer->localBuffer;
+                }
+            }
+            dst = buffer->chars.ascii;
+
+            if (swap) {
+                while (src < limit) *(dst++) = (*(src++) >> 24);
+            } else {
+                while (src < limit) *(dst++) = *(src++);
+            }
+        } else {
+            if (NULL == buffer->chars.unicode) { // we never reallocate when buffer is supplied
+                if (buffer->numChars > MAX_LOCAL_UNICHARS) {
+                    buffer->chars.unicode = (UniChar *)CFAllocatorAllocate(buffer->allocator, (buffer->numChars * sizeof(UTF16Char)), 0);
+                    buffer->shouldFreeChars = true;
+                } else {
+                    buffer->chars.unicode = (UTF16Char *)buffer->localBuffer;
+                }
+            }
+            return (CFUniCharFromUTF32(src, limit - src, buffer->chars.unicode, (strictUTF32 ? false : true), __CF_BIG_ENDIAN__ ? !swap : swap) ? TRUE : FALSE);
+        }
+    } else {
+        CFIndex idx;
+        const uint8_t *chars = (const uint8_t *)bytes;
+        const uint8_t *end = chars + len;
+    
+        switch (encoding) {
+        case kCFStringEncodingNonLossyASCII: {
+            UTF16Char currentValue = 0;
+            uint8_t character;
+            int8_t mode = __NSNonLossyASCIIMode;
+    
+            buffer->isASCII = false;
+            buffer->shouldFreeChars = !buffer->chars.unicode && (len <= MAX_LOCAL_UNICHARS) ? false : true;
+            buffer->chars.unicode = (buffer->chars.unicode ? buffer->chars.unicode : (len <= MAX_LOCAL_UNICHARS) ? (UniChar *)buffer->localBuffer : (UniChar *)CFAllocatorAllocate(buffer->allocator, len * sizeof(UniChar), 0));
+            buffer->numChars = 0;
+    
+            while (chars < end) {
+                character = (*chars++);
+    
+                switch (mode) {
+                case __NSNonLossyASCIIMode:
+                    if (character == '\\') {
+                        mode = __NSNonLossyBackslashMode;
+                    } else if (character < 0x80) {
+                        currentValue = character;
+                    } else {
+                        mode = __NSNonLossyErrorMode;
+                    }
+                    break;
+    
+                case __NSNonLossyBackslashMode:
+                    if ((character == 'U') || (character == 'u')) {
+                        mode = __NSNonLossyHexInitialMode;
+                        currentValue = 0;
+                    } else if ((character >= '0') && (character <= '9')) {
+                        mode = __NSNonLossyOctalInitialMode;
+                        currentValue = character - '0';
+                    } else if (character == '\\') {
+                        mode = __NSNonLossyASCIIMode;
+                        currentValue = character;
+                    } else {
+                        mode = __NSNonLossyErrorMode;
+                    }
+                    break;
+    
+                default:
+                    if (mode < __NSNonLossyHexFinalMode) {
+                        if ((character >= '0') && (character <= '9')) {
+                            currentValue = (currentValue << 4) | (character - '0');
+                            if (++mode == __NSNonLossyHexFinalMode) mode = __NSNonLossyASCIIMode;
+                        } else {
+                            if (character >= 'a') character -= ('a' - 'A');
+                            if ((character >= 'A') && (character <= 'F')) {
+                                currentValue = (currentValue << 4) | ((character - 'A') + 10);
+                                if (++mode == __NSNonLossyHexFinalMode) mode = __NSNonLossyASCIIMode;
+                            } else {
+                                mode = __NSNonLossyErrorMode;
+                            }
+                        }
+                    } else {
+                        if ((character >= '0') && (character <= '9')) {
+                            currentValue = (currentValue << 3) | (character - '0');
+                            if (++mode == __NSNonLossyOctalFinalMode) mode = __NSNonLossyASCIIMode;
+                        } else {
+                            mode = __NSNonLossyErrorMode;
+                        }
+                    }
+                    break;
+                }
+    
+                if (mode == __NSNonLossyASCIIMode) {
+                    buffer->chars.unicode[buffer->numChars++] = currentValue;
+                } else if (mode == __NSNonLossyErrorMode) {
+                    return false;
+                }
+            }
+            return (mode == __NSNonLossyASCIIMode);
+        }
+    
+        case kCFStringEncodingUTF8:
+            if ((len >= 3) && (chars[0] == 0xef) && (chars[1] == 0xbb) && (chars[2] == 0xbf)) {	// If UTF8 BOM, skip
+                chars += 3;
+                len -= 3;
+                if (0 == len) return true;
+            }
+            if (buffer->isASCII) {
+                for (idx = 0; idx < len; idx++) {
+                    if (128 <= chars[idx]) {
+                        buffer->isASCII = false;
+                        break;
+                    }
+                }
+            }
+            if (buffer->isASCII) {
+                buffer->numChars = len;
+                buffer->shouldFreeChars = !buffer->chars.ascii && (len <= MAX_LOCAL_CHARS) ? false : true;
+                buffer->chars.ascii = (buffer->chars.ascii ? buffer->chars.ascii : (len <= MAX_LOCAL_CHARS) ? (uint8_t *)buffer->localBuffer : (UInt8 *)CFAllocatorAllocate(buffer->allocator, len * sizeof(uint8_t), 0));
+                memmove(buffer->chars.ascii, chars, len * sizeof(uint8_t));
+            } else {
+                CFIndex numDone;
+                static CFStringEncodingToUnicodeProc __CFFromUTF8 = NULL;
+    
+                if (!__CFFromUTF8) {
+                    const CFStringEncodingConverter *converter = CFStringEncodingGetConverter(kCFStringEncodingUTF8);
+                    __CFFromUTF8 = (CFStringEncodingToUnicodeProc)converter->toUnicode;
+                }
+    
+                buffer->shouldFreeChars = !buffer->chars.unicode && (len <= MAX_LOCAL_UNICHARS) ? false : true;
+                buffer->chars.unicode = (buffer->chars.unicode ? buffer->chars.unicode : (len <= MAX_LOCAL_UNICHARS) ? (UniChar *)buffer->localBuffer : (UniChar *)CFAllocatorAllocate(buffer->allocator, len * sizeof(UniChar), 0));
+                buffer->numChars = 0;
+                while (chars < end) {
+                    numDone = 0;
+                    chars += __CFFromUTF8(converterFlags, chars, end - chars, &(buffer->chars.unicode[buffer->numChars]), len - buffer->numChars, &numDone);
+    
+                    if (0 == numDone) {
+                        if (buffer->shouldFreeChars) CFAllocatorDeallocate(buffer->allocator, buffer->chars.unicode);
+                        buffer->isASCII = !alwaysUnicode;
+                        buffer->shouldFreeChars = false;
+                        buffer->chars.ascii = NULL;
+                        buffer->numChars = 0;
+                        return false;
+                    }
+                    buffer->numChars += numDone;
+                }
+            }
+            break;
+    
+        default:
+            if (CFStringEncodingIsValidEncoding(encoding)) {
+                const CFStringEncodingConverter *converter = CFStringEncodingGetConverter(encoding);
+                Boolean isASCIISuperset = __CFStringEncodingIsSupersetOfASCII(encoding);
+                
+                if (!converter) return false;
+    
+                if (!isASCIISuperset) buffer->isASCII = false;
+
+                if (buffer->isASCII) {
+                    for (idx = 0; idx < len; idx++) {
+                        if (128 <= chars[idx]) {
+                            buffer->isASCII = false;
+                            break;
+                        }
+                    }
+                }
+
+                if (converter->encodingClass == kCFStringEncodingConverterCheapEightBit) {
+                    if (buffer->isASCII) {
+                        buffer->numChars = len;
+                        buffer->shouldFreeChars = !buffer->chars.ascii && (len <= MAX_LOCAL_CHARS) ? false : true;
+                        buffer->chars.ascii = (buffer->chars.ascii ? buffer->chars.ascii : (len <= MAX_LOCAL_CHARS) ? (uint8_t *)buffer->localBuffer : (UInt8 *)CFAllocatorAllocate(buffer->allocator, len * sizeof(uint8_t), 0));
+                        memmove(buffer->chars.ascii, chars, len * sizeof(uint8_t));
+                    } else {
+                        buffer->shouldFreeChars = !buffer->chars.unicode && (len <= MAX_LOCAL_UNICHARS) ? false : true;
+                        buffer->chars.unicode = (buffer->chars.unicode ? buffer->chars.unicode : (len <= MAX_LOCAL_UNICHARS) ? (UniChar *)buffer->localBuffer : (UniChar *)CFAllocatorAllocate(buffer->allocator, len * sizeof(UniChar), 0));
+                        buffer->numChars = len;
+                        if (kCFStringEncodingASCII == encoding || kCFStringEncodingISOLatin1 == encoding) {
+                            for (idx = 0; idx < len; idx++) buffer->chars.unicode[idx] = (UniChar)chars[idx];
+                        } else {
+                            for (idx = 0; idx < len; idx++)
+                                if (chars[idx] < 0x80 && isASCIISuperset)
+                                    buffer->chars.unicode[idx] = (UniChar)chars[idx];
+                                else if (!((CFStringEncodingCheapEightBitToUnicodeProc)converter->toUnicode)(0, chars[idx], buffer->chars.unicode + idx))
+                                    return false;
+                        }
+                    }
+                } else {
+                    if (buffer->isASCII) {
+                        buffer->numChars = len;
+                        buffer->shouldFreeChars = !buffer->chars.ascii && (len <= MAX_LOCAL_CHARS) ? false : true;
+                        buffer->chars.ascii = (buffer->chars.ascii ? buffer->chars.ascii : (len <= MAX_LOCAL_CHARS) ? (uint8_t *)buffer->localBuffer : (UInt8 *)CFAllocatorAllocate(buffer->allocator, len * sizeof(uint8_t), 0));
+                        memmove(buffer->chars.ascii, chars, len * sizeof(uint8_t));
+                    } else {
+                        CFIndex guessedLength = CFStringEncodingCharLengthForBytes(encoding, 0, bytes, len);
+                        static UInt32 lossyFlag = (UInt32)-1;
+    
+                        buffer->shouldFreeChars = !buffer->chars.unicode && (guessedLength <= MAX_LOCAL_UNICHARS) ? false : true;
+                        buffer->chars.unicode = (buffer->chars.unicode ? buffer->chars.unicode : (guessedLength <= MAX_LOCAL_UNICHARS) ? (UniChar *)buffer->localBuffer : (UniChar *)CFAllocatorAllocate(buffer->allocator, guessedLength * sizeof(UniChar), 0));
+    
+                        if (lossyFlag == (UInt32)-1) lossyFlag = (_CFExecutableLinkedOnOrAfter(CFSystemVersionPanther) ? 0 : kCFStringEncodingAllowLossyConversion);
+    
+                        if (CFStringEncodingBytesToUnicode(encoding, lossyFlag|__CFGetASCIICompatibleFlag(), bytes, len, NULL, buffer->chars.unicode, (guessedLength > MAX_LOCAL_UNICHARS ? guessedLength : MAX_LOCAL_UNICHARS), &(buffer->numChars))) {
+                            if (buffer->shouldFreeChars) CFAllocatorDeallocate(buffer->allocator, buffer->chars.unicode);
+                            buffer->isASCII = !alwaysUnicode;
+                            buffer->shouldFreeChars = false;
+                            buffer->chars.ascii = NULL;
+                            buffer->numChars = 0;
+                            return false;
+                        }
+                    }
+                }
+            } else {
+                return false;
+            }
+        }
+    }
+
+    return true;
+}
+
+
+/* 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.
+   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. 
+
+   Note: This function is intended to work through CFString functions, so it should work
+   with NSStrings as well as CFStrings.
+*/
+CFIndex __CFStringEncodeByteStream(CFStringRef string, CFIndex rangeLoc, CFIndex rangeLen, Boolean generatingExternalFile, CFStringEncoding encoding, char lossByte, uint8_t *buffer, CFIndex max, CFIndex *usedBufLen) {
+    CFIndex totalBytesWritten = 0;	/* Number of written bytes */
+    CFIndex numCharsProcessed = 0;	/* Number of processed chars */
+    const UniChar *unichars;
+
+    if (encoding == kCFStringEncodingUTF8 && (unichars = CFStringGetCharactersPtr(string))) {
+        static CFStringEncodingToBytesProc __CFToUTF8 = NULL;
+
+        if (!__CFToUTF8) {
+            const CFStringEncodingConverter *utf8Converter = CFStringEncodingGetConverter(kCFStringEncodingUTF8);
+            __CFToUTF8 = (CFStringEncodingToBytesProc)utf8Converter->toBytes;
+        }
+        numCharsProcessed = __CFToUTF8((generatingExternalFile ? kCFStringEncodingPrependBOM : 0), unichars + rangeLoc, rangeLen, buffer, (buffer ? max : 0), &totalBytesWritten);
+
+    } else if (encoding == kCFStringEncodingNonLossyASCII) {
+	const char *hex = "0123456789abcdef";
+	UniChar ch;
+	CFStringInlineBuffer buf;
+	CFStringInitInlineBuffer(string, &buf, CFRangeMake(rangeLoc, rangeLen));
+	while (numCharsProcessed < rangeLen) {
+	    CFIndex reqLength; /* Required number of chars to encode this UniChar */
+	    CFIndex cnt;
+	    char tmp[6];
+	    ch = CFStringGetCharacterFromInlineBuffer(&buf, numCharsProcessed);
+	    if ((ch >= ' ' && ch <= '~' && ch != '\\') || (ch == '\n' || ch == '\r' || ch == '\t')) {
+		reqLength = 1;
+		tmp[0] = (char)ch;
+	    } else {
+		if (ch == '\\') {
+		    tmp[1] = '\\';
+		    reqLength = 2;
+		} else if (ch < 256) {	/* \nnn; note that this is not NEXTSTEP encoding but a (small) UniChar */
+		    tmp[1] = '0' + (ch >> 6);
+		    tmp[2] = '0' + ((ch >> 3) & 7);
+		    tmp[3] = '0' + (ch & 7);
+		    reqLength = 4;
+		} else {	/* \Unnnn */
+		    tmp[1] = 'u'; // Changed to small+u in order to be aligned with Java
+		    tmp[2] = hex[(ch >> 12) & 0x0f];
+		    tmp[3] = hex[(ch >> 8) & 0x0f];
+		    tmp[4] = hex[(ch >> 4) & 0x0f];
+		    tmp[5] = hex[ch & 0x0f];
+		    reqLength = 6;
+		}
+		tmp[0] = '\\';
+	    }
+            if (buffer) {
+                if (totalBytesWritten + reqLength > max) break; /* Doesn't fit..
+.*/
+                for (cnt = 0; cnt < reqLength; cnt++) {
+                    buffer[totalBytesWritten + cnt] = tmp[cnt];
+                }
+            }
+	    totalBytesWritten += reqLength;
+	    numCharsProcessed++;
+	}
+    } else if ((encoding == kCFStringEncodingUTF16) || (encoding == kCFStringEncodingUTF16BE) || (encoding == kCFStringEncodingUTF16LE)) {
+   	CFIndex extraForBOM = (generatingExternalFile && (encoding == kCFStringEncodingUTF16) ? sizeof(UniChar) : 0);
+        numCharsProcessed = rangeLen;
+        if (buffer && (numCharsProcessed * (CFIndex)sizeof(UniChar) + extraForBOM > max)) {
+            numCharsProcessed = (max > extraForBOM) ? ((max - extraForBOM) / sizeof(UniChar)) : 0;
+        }
+        totalBytesWritten = (numCharsProcessed * sizeof(UniChar)) + extraForBOM;
+	if (buffer) {
+	    if (extraForBOM) {	/* Generate BOM */
+#if __CF_BIG_ENDIAN__
+		*buffer++ = 0xfe; *buffer++ = 0xff;
+#else
+		*buffer++ = 0xff; *buffer++ = 0xfe;
+#endif
+	    }
+	    CFStringGetCharacters(string, CFRangeMake(rangeLoc, numCharsProcessed), (UniChar *)buffer);
+            if ((__CF_BIG_ENDIAN__ ?  kCFStringEncodingUTF16LE : kCFStringEncodingUTF16BE) == encoding) { // Need to swap
+                UTF16Char *characters = (UTF16Char *)buffer;
+                const UTF16Char *limit = characters + numCharsProcessed;
+
+                while (characters < limit) {
+                    *characters = CFSwapInt16(*characters);
+                    ++characters;
+                }
+            }
+	}
+    } else if ((encoding == kCFStringEncodingUTF32) || (encoding == kCFStringEncodingUTF32BE) || (encoding == kCFStringEncodingUTF32LE)) {
+        UTF32Char character;
+        CFStringInlineBuffer buf;
+        UTF32Char *characters = (UTF32Char *)buffer;
+
+        bool swap = (encoding == (__CF_BIG_ENDIAN__ ? kCFStringEncodingUTF32LE : kCFStringEncodingUTF32BE) ? true : false);
+        if (generatingExternalFile && (encoding == kCFStringEncodingUTF32)) {
+            totalBytesWritten += sizeof(UTF32Char);
+            if (characters) {
+                if (totalBytesWritten > max) { // insufficient buffer
+                    totalBytesWritten = 0;
+                } else {
+                    *(characters++) = 0x0000FEFF;
+                }
+            }
+        }
+
+        CFStringInitInlineBuffer(string, &buf, CFRangeMake(rangeLoc, rangeLen));
+        while (numCharsProcessed < rangeLen) {
+            character = CFStringGetCharacterFromInlineBuffer(&buf, numCharsProcessed);
+
+            if (CFUniCharIsSurrogateHighCharacter(character)) {
+                UTF16Char otherCharacter;
+
+                if (((numCharsProcessed + 1) < rangeLen) && CFUniCharIsSurrogateLowCharacter((otherCharacter = CFStringGetCharacterFromInlineBuffer(&buf, numCharsProcessed + 1)))) {
+                    character = CFUniCharGetLongCharacterForSurrogatePair(character, otherCharacter);
+                } else if (lossByte) {
+                    character = lossByte;
+                } else {
+                    break;
+                }
+            } else if (CFUniCharIsSurrogateLowCharacter(character)) {
+                if (lossByte) {
+                    character = lossByte;
+                } else {
+                    break;
+                }
+            }
+
+            totalBytesWritten += sizeof(UTF32Char);
+
+            if (characters) {
+                if (totalBytesWritten > max) {
+                    totalBytesWritten -= sizeof(UTF32Char);
+                    break;
+                }
+                *(characters++) = (swap ? CFSwapInt32(character) : character);
+            }
+
+            numCharsProcessed += (character > 0xFFFF ? 2 : 1);
+        }
+    } else {
+        CFIndex numChars;
+        UInt32 flags;
+        const unsigned char *cString = NULL;
+        Boolean isASCIISuperset = __CFStringEncodingIsSupersetOfASCII(encoding);
+
+        if (!CF_IS_OBJC(CFStringGetTypeID(), string) && isASCIISuperset) { // Checking for NSString to avoid infinite recursion
+            const unsigned char *ptr;
+            if ((cString = (const unsigned char *)CFStringGetCStringPtr(string, __CFStringGetEightBitStringEncoding()))) {
+                ptr = (cString += rangeLoc);
+                if (__CFStringGetEightBitStringEncoding() == encoding) {
+                    numCharsProcessed = (rangeLen < max || buffer == NULL ? rangeLen : max);
+                    if (buffer) memmove(buffer, cString, numCharsProcessed);
+                    if (usedBufLen) *usedBufLen = numCharsProcessed;
+                    return numCharsProcessed;
+                }
+                while (*ptr < 0x80 && rangeLen > 0) {
+                    ++ptr;
+                    --rangeLen;
+                }
+                numCharsProcessed = ptr - cString;
+                if (buffer) {
+                    numCharsProcessed = (numCharsProcessed < max ? numCharsProcessed : max);
+                    memmove(buffer, cString, numCharsProcessed);
+                    buffer += numCharsProcessed;
+		    max -= numCharsProcessed;
+                }
+                if (!rangeLen || (buffer && (max == 0))) {
+                    if (usedBufLen) *usedBufLen = numCharsProcessed;
+                    return numCharsProcessed;
+                }
+                rangeLoc += numCharsProcessed;
+                totalBytesWritten += numCharsProcessed;
+            }
+            if (!cString && (cString = CFStringGetPascalStringPtr(string, __CFStringGetEightBitStringEncoding()))) {
+                ptr = (cString += (rangeLoc + 1));
+                if (__CFStringGetEightBitStringEncoding() == encoding) {
+                    numCharsProcessed = (rangeLen < max || buffer == NULL ? rangeLen : max);
+                    if (buffer) memmove(buffer, cString, numCharsProcessed);
+                    if (usedBufLen) *usedBufLen = numCharsProcessed;
+                    return numCharsProcessed;
+                }
+                while (*ptr < 0x80 && rangeLen > 0) {
+                    ++ptr;
+                    --rangeLen;
+                }
+                numCharsProcessed = ptr - cString;
+                if (buffer) {
+                    numCharsProcessed = (numCharsProcessed < max ? numCharsProcessed : max);
+                    memmove(buffer, cString, numCharsProcessed);
+                    buffer += numCharsProcessed;
+		    max -= numCharsProcessed;
+                }
+                if (!rangeLen || (buffer && (max == 0))) {
+                    if (usedBufLen) *usedBufLen = numCharsProcessed;
+                    return numCharsProcessed;
+                }
+                rangeLoc += numCharsProcessed;
+                totalBytesWritten += numCharsProcessed;
+            }
+        }
+
+        if (!buffer) max = 0;
+
+        // Special case for Foundation. When lossByte == 0xFF && encoding kCFStringEncodingASCII, we do the default ASCII fallback conversion
+        // Aki 11/24/04 __CFGetASCIICompatibleFlag() is called only for non-ASCII superset encodings. Otherwise, it could lead to a deadlock (see 3890536).
+        flags = (lossByte ? ((unsigned char)lossByte == 0xFF && encoding == kCFStringEncodingASCII ? kCFStringEncodingAllowLossyConversion : CFStringEncodingLossyByteToMask(lossByte)) : 0) | (generatingExternalFile ? kCFStringEncodingPrependBOM : 0) | (isASCIISuperset ? 0 : __CFGetASCIICompatibleFlag());
+
+        if (!cString && (cString = (const unsigned char *)CFStringGetCharactersPtr(string))) { // Must be Unicode string
+            if (CFStringEncodingIsValidEncoding(encoding)) { // Converter available in CF
+                CFStringEncodingUnicodeToBytes(encoding, flags, (const UniChar *)cString + rangeLoc, rangeLen, &numCharsProcessed, buffer, max, &totalBytesWritten);
+            } else {
+                return 0;
+            }
+        } else {
+            UniChar charBuf[kCFCharConversionBufferLength];
+            CFIndex currentLength;
+            CFIndex usedLen;
+            CFIndex lastUsedLen = 0, lastNumChars = 0;
+            uint32_t result;
+            Boolean isCFBuiltin = CFStringEncodingIsValidEncoding(encoding);
+#define MAX_DECOMP_LEN (6)
+
+            while (rangeLen > 0) {
+                currentLength = (rangeLen > kCFCharConversionBufferLength ? kCFCharConversionBufferLength : rangeLen);
+                CFStringGetCharacters(string, CFRangeMake(rangeLoc, currentLength), charBuf);
+
+                // could be in the middle of surrogate pair; back up.
+                if ((rangeLen > kCFCharConversionBufferLength) && CFUniCharIsSurrogateHighCharacter(charBuf[kCFCharConversionBufferLength - 1])) --currentLength;
+
+                if (isCFBuiltin) { // Converter available in CF
+                    if ((result = CFStringEncodingUnicodeToBytes(encoding, flags, charBuf, currentLength, &numChars, buffer, max, &usedLen)) != kCFStringEncodingConversionSuccess) {
+                        if (kCFStringEncodingInvalidInputStream == result) {
+                            CFRange composedRange;
+                            // Check the tail
+                            if ((rangeLen > kCFCharConversionBufferLength) && ((currentLength - numChars) < MAX_DECOMP_LEN)) {
+                                composedRange = CFStringGetRangeOfComposedCharactersAtIndex(string, rangeLoc + currentLength);
+
+                                if ((composedRange.length <= MAX_DECOMP_LEN) && (composedRange.location < (rangeLoc + numChars))) {
+                                    result = CFStringEncodingUnicodeToBytes(encoding, flags, charBuf, composedRange.location - rangeLoc, &numChars, buffer, max, &usedLen);
+                                }
+                            }
+
+                            // Check the head
+                            if ((kCFStringEncodingConversionSuccess != result) && (lastNumChars > 0) && (numChars < MAX_DECOMP_LEN)) {
+                                composedRange = CFStringGetRangeOfComposedCharactersAtIndex(string, rangeLoc);
+
+                                if ((composedRange.length <= MAX_DECOMP_LEN) && (composedRange.location < rangeLoc)) {
+                                    // Try if the composed range can be converted
+                                    CFStringGetCharacters(string, composedRange, charBuf);
+
+                                    if (CFStringEncodingUnicodeToBytes(encoding, flags, charBuf, composedRange.length, &numChars, NULL, 0, &usedLen) == kCFStringEncodingConversionSuccess) { // OK let's try the last run
+                                        CFIndex lastRangeLoc = rangeLoc - lastNumChars;
+
+                                        currentLength = composedRange.location - lastRangeLoc;
+                                        CFStringGetCharacters(string, CFRangeMake(lastRangeLoc, currentLength), charBuf);
+
+                                        if ((result = CFStringEncodingUnicodeToBytes(encoding, flags, charBuf, currentLength, &numChars, (max ? buffer - lastUsedLen : NULL), (max ? max + lastUsedLen : 0), &usedLen)) == kCFStringEncodingConversionSuccess) { // OK let's try the last run
+                                            // Looks good. back up
+                                            totalBytesWritten -= lastUsedLen;
+                                            numCharsProcessed -= lastNumChars;
+
+                                            rangeLoc = lastRangeLoc;
+                                            rangeLen += lastNumChars;
+
+                                            if (max) {
+                                                buffer -= lastUsedLen;
+                                                max += lastUsedLen;
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+
+                        if (kCFStringEncodingConversionSuccess != result) { // really failed
+                            totalBytesWritten += usedLen;
+                            numCharsProcessed += numChars;
+                            break;
+                        }
+                    }
+                } else {
+                    return 0;
+                }
+
+                totalBytesWritten += usedLen;
+                numCharsProcessed += numChars;
+
+                rangeLoc += numChars;
+                rangeLen -= numChars;
+                if (max) {
+                    buffer += usedLen;
+                    max -= usedLen;
+                    if (max <= 0) break;
+                }
+                lastUsedLen = usedLen; lastNumChars = numChars;
+                flags &= ~kCFStringEncodingPrependBOM;
+            }
+        }
+    }
+    if (usedBufLen) *usedBufLen = totalBytesWritten;
+    return numCharsProcessed;
+}
+
+CFStringRef CFStringCreateWithFileSystemRepresentation(CFAllocatorRef alloc, const char *buffer) {
+    return CFStringCreateWithCString(alloc, buffer, CFStringFileSystemEncoding());
+}
+
+CFIndex CFStringGetMaximumSizeOfFileSystemRepresentation(CFStringRef string) {
+    CFIndex len = CFStringGetLength(string);
+    CFStringEncoding enc = CFStringGetFastestEncoding(string);
+    switch (enc) {
+	case kCFStringEncodingASCII:
+	case kCFStringEncodingMacRoman:
+	    return len * 3 + 1;
+	default:
+	    return len * 9 + 1;
+    }
+} 
+
+Boolean CFStringGetFileSystemRepresentation(CFStringRef string, char *buffer, CFIndex maxBufLen) {
+#if DEPLOYMENT_TARGET_MACOSX
+#define MAX_STACK_BUFFER_LEN	(255)
+    const UTF16Char *characters = CFStringGetCharactersPtr(string);
+    const char *bufferLimit = buffer + maxBufLen;
+    CFIndex length = CFStringGetLength(string);
+    CFIndex usedBufLen;
+
+    if (maxBufLen < length) return false; // Since we're using UTF-8, the byte length is never shorter than the char length. Also, it filters out 0 == maxBufLen
+
+    if (NULL == characters) {
+        UTF16Char charactersBuffer[MAX_STACK_BUFFER_LEN];
+        CFRange range = CFRangeMake(0, 0);
+        const char *bytes = CFStringGetCStringPtr(string, __CFStringGetEightBitStringEncoding());
+
+        if (NULL != bytes) {
+            const char *originalBytes = bytes;
+            const char *bytesLimit = bytes + length;
+
+            while ((bytes < bytesLimit) && (buffer < bufferLimit) && (0 == (*bytes & 0x80))) *(buffer++) = *(bytes++);
+
+            range.location = bytes - originalBytes;
+        }
+        while ((range.location < length) && (buffer < bufferLimit)) {
+            range.length = length - range.location;
+            if (range.length > MAX_STACK_BUFFER_LEN) range.length = MAX_STACK_BUFFER_LEN;
+
+            CFStringGetCharacters(string, range, charactersBuffer);
+            if ((range.length == MAX_STACK_BUFFER_LEN) && CFUniCharIsSurrogateHighCharacter(charactersBuffer[MAX_STACK_BUFFER_LEN - 1])) --range.length; // Backup for a high surrogate
+
+            if (!CFUniCharDecompose(charactersBuffer, range.length, NULL, (void *)buffer, bufferLimit - buffer, &usedBufLen, true, kCFUniCharUTF8Format, true)) return false;
+
+            buffer += usedBufLen;
+            range.location += range.length;
+        }
+    } else {
+        if (!CFUniCharDecompose(characters, length, NULL, (void *)buffer, maxBufLen, &usedBufLen, true, kCFUniCharUTF8Format, true)) return false;
+        buffer += usedBufLen;
+    }
+
+    if (buffer < bufferLimit) { // Since the filename has its own limit, this is ok for now
+        *buffer = '\0';
+        return true;
+    } else {
+        return false;
+    }
+#else /* __MACH__ */
+    return CFStringGetCString(string, buffer, maxBufLen, CFStringFileSystemEncoding());
+#endif /* __MACH__ */
+}
+
+Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, uint8_t *buffer, CFIndex maxBufLen) {
+    return CFStringGetFileSystemRepresentation(string, (char *)buffer, maxBufLen);
+}
+
diff --git a/CoreFoundation/CFStringScanner.c b/CoreFoundation/CFStringScanner.c
new file mode 100644
index 0000000..79528c7
--- /dev/null
+++ b/CoreFoundation/CFStringScanner.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFStringScanner.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Ali Ozer
+*/
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFString.h>
+#include <sys/types.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+CF_INLINE Boolean __CFCharacterIsADigit(UniChar ch) {
+    return (ch >= '0' && ch <= '9') ? true : false;
+}
+
+/* Returns -1 on illegal value */
+CF_INLINE SInt32 __CFCharacterNumericOrHexValue (UniChar ch) {
+    if (ch >= '0' && ch <= '9') {
+        return ch - '0';
+    } else if (ch >= 'A' && ch <= 'F') {
+        return ch + 10 - 'A';
+    } else if (ch >= 'a' && ch <= 'f') {
+        return ch + 10 - 'a';
+    } else {
+        return -1;
+    }
+}
+               
+/* Returns -1 on illegal value */
+CF_INLINE SInt32 __CFCharacterNumericValue(UniChar ch) {
+    return (ch >= '0' && ch <= '9') ? (ch - '0') : -1;
+}
+
+CF_INLINE UniChar __CFStringGetFirstNonSpaceCharacterFromInlineBuffer(CFStringInlineBuffer *buf, SInt32 *indexPtr) {
+    UniChar ch;
+    while (__CFIsWhitespace(ch = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr))) (*indexPtr)++;
+    return ch;
+}
+
+/* result is int64_t or int, depending on doLonglong
+*/
+__private_extern__ Boolean __CFStringScanInteger(CFStringInlineBuffer *buf, CFTypeRef locale, SInt32 *indexPtr, Boolean doLonglong, void *result) {
+    Boolean doingLonglong = false;	/* Set to true if doLonglong, and we overflow an int... */
+    Boolean neg = false;
+    int intResult = 0;
+    register int64_t longlongResult = 0;	/* ??? int64_t is slow when not in regs; I hope this does the right thing. */
+    UniChar ch;
+
+    ch = __CFStringGetFirstNonSpaceCharacterFromInlineBuffer(buf, indexPtr);
+
+    if (ch == '-' || ch == '+') {
+	neg = (ch == '-');
+	(*indexPtr)++;
+    	ch = __CFStringGetFirstNonSpaceCharacterFromInlineBuffer(buf, indexPtr);
+    }	
+
+    if (! __CFCharacterIsADigit(ch)) return false;	/* No digits, bail out... */
+    do {
+	if (doingLonglong) {
+            if ((longlongResult >= LLONG_MAX / 10) && ((longlongResult > LLONG_MAX / 10) || (__CFCharacterNumericValue(ch) - (neg ? 1 : 0) >= LLONG_MAX - longlongResult * 10))) {
+                /* ??? This might not handle LLONG_MIN correctly... */
+                longlongResult = neg ? LLONG_MIN : LLONG_MAX;
+                neg = false;
+                while (__CFCharacterIsADigit(ch = __CFStringGetCharacterFromInlineBufferAux(buf, ++(*indexPtr))));	/* Skip remaining digits */
+            } else {
+                longlongResult = longlongResult * 10 + __CFCharacterNumericValue(ch);
+                ch = __CFStringGetCharacterFromInlineBufferAux(buf, ++(*indexPtr));
+            }
+	} else {
+            if ((intResult >= INT_MAX / 10) && ((intResult > INT_MAX / 10) || (__CFCharacterNumericValue(ch) - (neg ? 1 : 0) >= INT_MAX - intResult * 10))) {
+                // Overflow, check for int64_t...
+                if (doLonglong) {
+                    longlongResult = intResult;
+                    doingLonglong = true;
+                } else {
+                    /* ??? This might not handle INT_MIN correctly... */
+                    intResult = neg ? INT_MIN : INT_MAX;
+                    neg = false;
+                    while (__CFCharacterIsADigit(ch = __CFStringGetCharacterFromInlineBufferAux(buf, ++(*indexPtr))));	/* Skip remaining digits */
+                }
+            } else {
+                intResult = intResult * 10 + __CFCharacterNumericValue(ch);
+                ch = __CFStringGetCharacterFromInlineBufferAux(buf, ++(*indexPtr));
+            }
+	}
+    } while (__CFCharacterIsADigit(ch));
+
+    if (result) {
+        if (doLonglong) {
+	    if (!doingLonglong) longlongResult = intResult;
+	    *(int64_t *)result = neg ? -longlongResult : longlongResult;
+	} else {
+	    *(int *)result = neg ? -intResult : intResult;
+	}
+    }
+
+    return true;
+}
+
+__private_extern__ Boolean __CFStringScanHex(CFStringInlineBuffer *buf, SInt32 *indexPtr, unsigned *result) {
+    UInt32 value = 0;
+    SInt32 curDigit;
+    UniChar ch;
+
+    ch = __CFStringGetFirstNonSpaceCharacterFromInlineBuffer(buf, indexPtr);
+    /* Ignore the optional "0x" or "0X"; if it's followed by a non-hex, just parse the "0" and leave pointer at "x" */
+    if (ch == '0') {
+	ch = __CFStringGetCharacterFromInlineBufferAux(buf, ++(*indexPtr));
+        if (ch == 'x' || ch == 'X') ch = __CFStringGetCharacterFromInlineBufferAux(buf, ++(*indexPtr));
+	curDigit = __CFCharacterNumericOrHexValue(ch);
+        if (curDigit == -1) {
+	    (*indexPtr)--;	/* Go back over the "x" or "X" */
+	    if (result) *result = 0;
+            return true;	/* We just saw "0" */
+        }
+    } else {
+	curDigit = __CFCharacterNumericOrHexValue(ch);
+        if (curDigit == -1) return false;
+    }    
+
+    do {
+        if (value > (UINT_MAX >> 4)) {	
+	    value = UINT_MAX;	/* We do this over and over again, but it's an error case anyway */
+        } else {
+            value = (value << 4) + curDigit;
+        }
+	curDigit = __CFCharacterNumericOrHexValue(__CFStringGetCharacterFromInlineBufferAux(buf, ++(*indexPtr)));
+    } while (curDigit != -1);
+
+    if (result) *result = value;
+    return true;
+}
+
+// Packed array of Boolean
+static const unsigned char __CFNumberSet[16] = {
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  nul soh stx etx eot enq ack bel
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  bs  ht  nl  vt  np  cr  so  si
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  dle dc1 dc2 dc3 dc4 nak syn etb
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  can em  sub esc fs  gs  rs  us
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  sp   !   "   #   $   %   &   '
+    0X28, // 0, 0, 0, 1, 0, 1, 0, 0, //  (   )   *   +   ,   -   .   /
+    0xFF, // 1, 1, 1, 1, 1, 1, 1, 1, //  0   1   2   3   4   5   6   7
+    0X03, // 1, 1, 0, 0, 0, 0, 0, 0, //  8   9   :   ;   <   =   >   ?
+    0X20, // 0, 0, 0, 0, 0, 1, 0, 0, //  @   A   B   C   D   E   F   G
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  H   I   J   K   L   M   N   O
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  P   Q   R   S   T   U   V   W
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  X   Y   Z   [   \   ]   ^   _
+    0X20, // 0, 0, 0, 0, 0, 1, 0, 0, //  `   a   b   c   d   e   f   g
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  h   i   j   k   l   m   n   o
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0, //  p   q   r   s   t   u   v   w
+    0X00, // 0, 0, 0, 0, 0, 0, 0, 0  //  x   y   z   {   |   }   ~  del
+};
+
+__private_extern__ Boolean __CFStringScanDouble(CFStringInlineBuffer *buf, CFTypeRef locale, SInt32 *indexPtr, double *resultPtr) {
+    #define STACK_BUFFER_SIZE 256
+    #define ALLOC_CHUNK_SIZE 256 // first and subsequent malloc size.  Should be greater than STACK_BUFFER_SIZE
+    char localCharBuffer[STACK_BUFFER_SIZE];
+    char *charPtr = localCharBuffer;
+    char *endCharPtr;
+    UniChar decimalChar = '.';
+    SInt32 numChars = 0;
+    SInt32 capacity = STACK_BUFFER_SIZE;	// in chars
+    double result;
+    UniChar ch;
+    CFAllocatorRef tmpAlloc = NULL;
+
+#if 0
+    if (locale != NULL) {
+        CFStringRef decimalSeparator = [locale objectForKey: @"NSDecimalSeparator"];
+        if (decimalSeparator != nil) decimalChar = [decimalSeparator characterAtIndex:0];
+    }
+#endif
+    ch = __CFStringGetFirstNonSpaceCharacterFromInlineBuffer(buf, indexPtr);
+    // At this point indexPtr points at the first non-space char
+#if 0
+#warning need to allow, case insensitively, all of: "nan", "inf", "-inf", "+inf", "-infinity", "+infinity", "infinity";
+#warning -- strtod() will actually do most or all of that for us
+#define BITSFORDOUBLENAN	((uint64_t)0x7ff8000000000000ULL)
+#define BITSFORDOUBLEPOSINF	((uint64_t)0x7ff0000000000000ULL)
+#define BITSFORDOUBLENEGINF	((uint64_t)0xfff0000000000000ULL)
+    if ('N' == ch || 'n' == ch) {	// check for "NaN", case insensitively
+        UniChar next1 = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + 1);
+        UniChar next2 = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + 2);
+        if (('a' == next1 || 'A' == next1) &&
+            ('N' == next2 || 'n' == next2)) {
+            *indexPtr += 3;
+            if (resultPtr) *(uint64_t *)resultPtr = BITSFORDOUBLENAN;
+            return true;
+        }
+    }
+    if ('I' == ch || 'i' == ch) {	// check for "Inf", case insensitively
+        UniChar next1 = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + 1);
+        UniChar next2 = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + 2);
+        if (('n' == next1 || 'N' == next1) &&
+            ('f' == next2 || 'F' == next2)) {
+            *indexPtr += 3;
+            if (resultPtr) *(uint64_t *)resultPtr = BITSFORDOUBLEPOSINF;
+            return true;
+        }
+    }
+    if ('+' == ch || '-' == ch) {	// check for "+/-Inf", case insensitively
+        UniChar next1 = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + 1);
+        UniChar next2 = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + 2);
+        UniChar next3 = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + 3);
+        if (('I' == next1 || 'i' == next1) &&
+            ('n' == next2 || 'N' == next2) &&
+            ('f' == next3 || 'F' == next3)) {
+            *indexPtr += 4;
+            if (resultPtr) *(uint64_t *)resultPtr = ('-' == ch) ? BITSFORDOUBLENEGINF : BITSFORDOUBLEPOSINF;
+            return true;
+        }
+    }
+#endif
+    do {
+	if (ch >= 128 || (__CFNumberSet[ch >> 3] & (1 << (ch & 7))) == 0) {
+            // Not in __CFNumberSet
+	    if (ch != decimalChar) break;
+            ch = '.';	// Replace the decimal character with something strtod will understand
+        }
+        if (numChars >= capacity - 1) {
+	    capacity += ALLOC_CHUNK_SIZE;
+	    if (tmpAlloc == NULL) tmpAlloc = __CFGetDefaultAllocator();
+	    if (charPtr == localCharBuffer) {
+		charPtr = (char *)CFAllocatorAllocate(tmpAlloc, capacity * sizeof(char), 0);
+		memmove(charPtr, localCharBuffer, numChars * sizeof(char));
+ 	    } else {
+		charPtr = (char *)CFAllocatorReallocate(tmpAlloc, charPtr, capacity * sizeof(char), 0);
+	    }
+        }
+	charPtr[numChars++] = (char)ch;
+	ch = __CFStringGetCharacterFromInlineBufferAux(buf, *indexPtr + numChars);
+    } while (true);
+    charPtr[numChars] = 0;	// Null byte for strtod
+
+#if DEPLOYMENT_TARGET_MACOSX
+    result = strtod_l(charPtr, &endCharPtr, NULL);
+#else
+    result = strtod(charPtr, &endCharPtr);
+#endif
+
+    if (tmpAlloc) CFAllocatorDeallocate(tmpAlloc, charPtr);
+    if (charPtr == endCharPtr) return false;
+    *indexPtr += (endCharPtr - charPtr);
+    if (resultPtr) *resultPtr = result; // only store result if we succeed
+    
+    return true;
+}
+
+
+#undef STACK_BUFFER_SIZE
+#undef ALLOC_CHUNK_SIZE
+
+
diff --git a/CoreFoundation/CFStringUtilities.c b/CoreFoundation/CFStringUtilities.c
new file mode 100644
index 0000000..56df893
--- /dev/null
+++ b/CoreFoundation/CFStringUtilities.c
@@ -0,0 +1,497 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFStringUtilities.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Aki Inoue
+*/
+
+#include "CFInternal.h"
+#include "CFStringEncodingConverterExt.h"
+#include "CFUniChar.h"
+#include <CoreFoundation/CFStringEncodingExt.h>
+#include <CoreFoundation/CFPreferences.h>
+#include <limits.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#include <stdlib.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <stdlib.h>
+#include <tchar.h>
+#endif
+
+
+Boolean CFStringIsEncodingAvailable(CFStringEncoding theEncoding) {
+    switch (theEncoding) {
+        case kCFStringEncodingASCII: // Built-in encodings
+        case kCFStringEncodingMacRoman:
+        case kCFStringEncodingUTF8:
+        case kCFStringEncodingNonLossyASCII:
+        case kCFStringEncodingWindowsLatin1:
+        case kCFStringEncodingNextStepLatin:
+        case kCFStringEncodingUTF16:
+        case kCFStringEncodingUTF16BE:
+        case kCFStringEncodingUTF16LE:
+        case kCFStringEncodingUTF32:
+        case kCFStringEncodingUTF32BE:
+        case kCFStringEncodingUTF32LE:
+            return true;
+
+        default:
+            return CFStringEncodingIsValidEncoding(theEncoding);
+    }
+}
+
+const CFStringEncoding* CFStringGetListOfAvailableEncodings() {
+    return (const CFStringEncoding *)CFStringEncodingListOfAvailableEncodings();
+}
+
+CFStringRef CFStringGetNameOfEncoding(CFStringEncoding theEncoding) {
+    static CFMutableDictionaryRef mappingTable = NULL;
+    CFStringRef theName = mappingTable ? (CFStringRef)CFDictionaryGetValue(mappingTable, (const void*)(uintptr_t)theEncoding) : NULL;
+
+    if (!theName) {
+        switch (theEncoding) {
+            case kCFStringEncodingUTF8: theName = CFSTR("Unicode (UTF-8)"); break;
+            case kCFStringEncodingUTF16: theName = CFSTR("Unicode (UTF-16)"); break;
+            case kCFStringEncodingUTF16BE: theName = CFSTR("Unicode (UTF-16BE)"); break;
+            case kCFStringEncodingUTF16LE: theName = CFSTR("Unicode (UTF-16LE)"); break;
+            case kCFStringEncodingUTF32: theName = CFSTR("Unicode (UTF-32)"); break;
+            case kCFStringEncodingUTF32BE: theName = CFSTR("Unicode (UTF-32BE)"); break;
+            case kCFStringEncodingUTF32LE: theName = CFSTR("Unicode (UTF-32LE)"); break;
+            case kCFStringEncodingNonLossyASCII: theName = CFSTR("Non-lossy ASCII"); break;
+    
+            default: {
+                const char *encodingName = CFStringEncodingName(theEncoding);
+    
+                if (encodingName) {
+                    theName = CFStringCreateWithCString(kCFAllocatorSystemDefault, encodingName, kCFStringEncodingASCII);
+                }
+            }
+            break;
+        }
+
+        if (theName) {
+            if (!mappingTable) mappingTable = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, (const CFDictionaryKeyCallBacks *)NULL, &kCFTypeDictionaryValueCallBacks);
+
+            CFDictionaryAddValue(mappingTable, (const void*)(uintptr_t)theEncoding, (const void*)theName);
+            CFRelease(theName);
+        }
+    }
+
+    return theName;
+}
+
+CFStringEncoding CFStringConvertIANACharSetNameToEncoding(CFStringRef  charsetName) {
+    static CFMutableDictionaryRef mappingTable = NULL;
+    CFStringEncoding result = kCFStringEncodingInvalidId;
+    CFMutableStringRef lowerCharsetName;
+
+    /* Check for common encodings first */
+    if (CFStringCompare(charsetName, CFSTR("utf-8"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+        return kCFStringEncodingUTF8;
+    } else if (CFStringCompare(charsetName, CFSTR("iso-8859-1"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+        return kCFStringEncodingISOLatin1;
+    }
+
+    /* Create lowercase copy */
+    lowerCharsetName = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, charsetName);
+    CFStringLowercase(lowerCharsetName, NULL);
+
+    if (mappingTable == NULL) {
+        CFMutableDictionaryRef table = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, (const CFDictionaryValueCallBacks *)NULL);
+        const CFStringEncoding *encodings = CFStringGetListOfAvailableEncodings();
+
+        while (*encodings != kCFStringEncodingInvalidId) {
+            const char **nameList = CFStringEncodingCanonicalCharsetNames(*encodings);
+
+            if (nameList) {
+                while (*nameList) {
+                    CFStringRef name = CFStringCreateWithCString(kCFAllocatorSystemDefault, *nameList++, kCFStringEncodingASCII);
+
+                    if (name) {
+                        CFDictionaryAddValue(table, (const void*)name, (const void*)(uintptr_t)*encodings);
+                        CFRelease(name);
+                    }
+                }
+            }
+            encodings++;
+        }
+        // Adding Unicode names
+        CFDictionaryAddValue(table, (const void*)CFSTR("unicode-1-1"), (const void*)kCFStringEncodingUTF16);
+        CFDictionaryAddValue(table, (const void*)CFSTR("iso-10646-ucs-2"), (const void*)kCFStringEncodingUTF16);
+        CFDictionaryAddValue(table, (const void*)CFSTR("utf-16"), (const void*)kCFStringEncodingUTF16);
+        CFDictionaryAddValue(table, (const void*)CFSTR("utf-16be"), (const void*)kCFStringEncodingUTF16BE);
+        CFDictionaryAddValue(table, (const void*)CFSTR("utf-16le"), (const void*)kCFStringEncodingUTF16LE);
+        CFDictionaryAddValue(table, (const void*)CFSTR("utf-32"), (const void*)kCFStringEncodingUTF32);
+        CFDictionaryAddValue(table, (const void*)CFSTR("utf-32be"), (const void*)kCFStringEncodingUTF32BE);
+        CFDictionaryAddValue(table, (const void*)CFSTR("utf-32le"), (const void*)kCFStringEncodingUTF32LE);
+
+        mappingTable = table;
+    }
+
+    if (CFDictionaryContainsKey(mappingTable, (const void*)lowerCharsetName)) {
+        result = (CFStringEncoding)(uintptr_t)CFDictionaryGetValue(mappingTable, (const void*)lowerCharsetName);
+    }
+    
+    CFRelease(lowerCharsetName);
+
+    return result;
+}
+
+CFStringRef CFStringConvertEncodingToIANACharSetName(CFStringEncoding encoding) {
+    static CFMutableDictionaryRef mappingTable = NULL;
+    CFStringRef theName = mappingTable ? (CFStringRef)CFDictionaryGetValue(mappingTable, (const void*)(uintptr_t)encoding) : NULL;
+
+    if (!theName) {
+        switch (encoding) {
+            case kCFStringEncodingUTF16: theName = CFSTR("UTF-16"); break;
+            case kCFStringEncodingUTF16BE: theName = CFSTR("UTF-16BE"); break;
+            case kCFStringEncodingUTF16LE: theName = CFSTR("UTF-16LE"); break;
+            case kCFStringEncodingUTF32: theName = CFSTR("UTF-32"); break;
+            case kCFStringEncodingUTF32BE: theName = CFSTR("UTF-32BE"); break;
+            case kCFStringEncodingUTF32LE: theName = CFSTR("UTF-32LE"); break;
+    
+    
+            default: {
+                const char **nameList = CFStringEncodingCanonicalCharsetNames(encoding);
+    
+                if (nameList && *nameList) {
+                    CFMutableStringRef upperCaseName;
+    
+                    theName = CFStringCreateWithCString(kCFAllocatorSystemDefault, *nameList, kCFStringEncodingASCII);
+                    if (theName) {
+                        upperCaseName = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, 0, theName);
+                        CFStringUppercase(upperCaseName, 0);
+                        CFRelease(theName);
+                        theName = upperCaseName;
+                    }
+                }
+            }
+            break;
+        }
+
+        if (theName) {
+            if (!mappingTable) mappingTable = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, (const CFDictionaryKeyCallBacks *)NULL, &kCFTypeDictionaryValueCallBacks);
+
+            CFDictionaryAddValue(mappingTable, (const void*)(uintptr_t)encoding, (const void*)theName);
+            CFRelease(theName);
+        }
+    }
+
+    return theName;
+}
+
+enum {
+    NSASCIIStringEncoding = 1,		/* 0..127 only */
+    NSNEXTSTEPStringEncoding = 2,
+    NSJapaneseEUCStringEncoding = 3,
+    NSUTF8StringEncoding = 4,
+    NSISOLatin1StringEncoding = 5,
+    NSSymbolStringEncoding = 6,
+    NSNonLossyASCIIStringEncoding = 7,
+    NSShiftJISStringEncoding = 8,
+    NSISOLatin2StringEncoding = 9,
+    NSUnicodeStringEncoding = 10,
+    NSWindowsCP1251StringEncoding = 11,    /* Cyrillic; same as AdobeStandardCyrillic */
+    NSWindowsCP1252StringEncoding = 12,    /* WinLatin1 */
+    NSWindowsCP1253StringEncoding = 13,    /* Greek */
+    NSWindowsCP1254StringEncoding = 14,    /* Turkish */
+    NSWindowsCP1250StringEncoding = 15,    /* WinLatin2 */
+    NSISO2022JPStringEncoding = 21,         /* ISO 2022 Japanese encoding for e-mail */
+    NSMacOSRomanStringEncoding = 30,
+
+    NSProprietaryStringEncoding = 65536    /* Installation-specific encoding */
+};
+
+#define NSENCODING_MASK (1 << 31)
+
+unsigned long CFStringConvertEncodingToNSStringEncoding(CFStringEncoding theEncoding) {
+    switch (theEncoding & 0xFFF) {
+        case kCFStringEncodingASCII: return NSASCIIStringEncoding;
+        case kCFStringEncodingNextStepLatin: return NSNEXTSTEPStringEncoding;
+        case kCFStringEncodingISOLatin1: return NSISOLatin1StringEncoding;
+        case kCFStringEncodingNonLossyASCII: return NSNonLossyASCIIStringEncoding;
+        case kCFStringEncodingWindowsLatin1: return NSWindowsCP1252StringEncoding;
+        case kCFStringEncodingMacRoman: return NSMacOSRomanStringEncoding;
+#if DEPLOYMENT_TARGET_MACOSX
+        case kCFStringEncodingEUC_JP: return NSJapaneseEUCStringEncoding;
+        case kCFStringEncodingMacSymbol: return NSSymbolStringEncoding;
+        case kCFStringEncodingDOSJapanese: return NSShiftJISStringEncoding;
+        case kCFStringEncodingISOLatin2: return NSISOLatin2StringEncoding;
+        case kCFStringEncodingWindowsCyrillic: return NSWindowsCP1251StringEncoding;
+        case kCFStringEncodingWindowsGreek: return NSWindowsCP1253StringEncoding;
+        case kCFStringEncodingWindowsLatin5: return NSWindowsCP1254StringEncoding;
+        case kCFStringEncodingWindowsLatin2: return NSWindowsCP1250StringEncoding;
+        case kCFStringEncodingISO_2022_JP: return NSISO2022JPStringEncoding;
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+        case kCFStringEncodingUnicode:
+            if (theEncoding == kCFStringEncodingUTF16) return NSUnicodeStringEncoding;
+            else if (theEncoding == kCFStringEncodingUTF8) return NSUTF8StringEncoding;
+#endif
+            /* fall-through for other encoding schemes */
+
+        default:
+            return NSENCODING_MASK | theEncoding;
+    }
+}
+
+CFStringEncoding CFStringConvertNSStringEncodingToEncoding(unsigned long theEncoding) {
+    switch (theEncoding) {
+        case NSASCIIStringEncoding: return kCFStringEncodingASCII;
+        case NSNEXTSTEPStringEncoding: return kCFStringEncodingNextStepLatin;
+        case NSUTF8StringEncoding: return kCFStringEncodingUTF8;
+        case NSISOLatin1StringEncoding: return kCFStringEncodingISOLatin1;
+        case NSNonLossyASCIIStringEncoding: return kCFStringEncodingNonLossyASCII;
+        case NSUnicodeStringEncoding: return kCFStringEncodingUTF16;
+        case NSWindowsCP1252StringEncoding: return kCFStringEncodingWindowsLatin1;
+        case NSMacOSRomanStringEncoding: return kCFStringEncodingMacRoman;
+#if DEPLOYMENT_TARGET_MACOSX
+        case NSSymbolStringEncoding: return kCFStringEncodingMacSymbol;
+        case NSJapaneseEUCStringEncoding: return kCFStringEncodingEUC_JP;
+        case NSShiftJISStringEncoding: return kCFStringEncodingDOSJapanese;
+        case NSISO2022JPStringEncoding: return kCFStringEncodingISO_2022_JP;
+        case NSISOLatin2StringEncoding: return kCFStringEncodingISOLatin2;
+        case NSWindowsCP1251StringEncoding: return kCFStringEncodingWindowsCyrillic;
+        case NSWindowsCP1253StringEncoding: return kCFStringEncodingWindowsGreek;
+        case NSWindowsCP1254StringEncoding: return kCFStringEncodingWindowsLatin5;
+        case NSWindowsCP1250StringEncoding: return kCFStringEncodingWindowsLatin2;
+#endif
+        default:
+            return ((theEncoding & NSENCODING_MASK) ? theEncoding & ~NSENCODING_MASK : kCFStringEncodingInvalidId);
+    }
+}
+
+#define MACCODEPAGE_BASE (10000)
+#define ISO8859CODEPAGE_BASE (28590)
+
+static const uint16_t _CFToDOSCodePageList[] = {
+    437, -1, -1, -1, -1, 737, 775, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x400
+    850, 851, 852, 855, 857, 860, 861, 862, 863, 864, 865, 866, 869, 874, -1, 01, // 0x410
+    932, 936, 949 , 950, // 0x420
+};
+
+static const uint16_t _CFToWindowsCodePageList[] = {
+    1252, 1250, 1251, 1253, 1254, 1255, 1256, 1257, 1258,
+};
+
+static const uint16_t _CFEUCToCodePage[] = { // 0x900
+    51932, 51936, 51950, 51949,
+};
+
+UInt32 CFStringConvertEncodingToWindowsCodepage(CFStringEncoding theEncoding) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS
+    CFStringEncoding encodingBase = theEncoding & 0x0FFF;
+#endif
+
+    switch (theEncoding & 0x0F00) {
+#if DEPLOYMENT_TARGET_MACOSX
+    case 0: // Mac OS script
+        if (encodingBase <= kCFStringEncodingMacCentralEurRoman) {
+            return MACCODEPAGE_BASE + encodingBase;
+        } else if (encodingBase == kCFStringEncodingMacTurkish) {
+            return 10081;
+        } else if (encodingBase == kCFStringEncodingMacCroatian) {
+            return 10082;
+        } else if (encodingBase == kCFStringEncodingMacIcelandic) {
+            return 10079;
+        }
+        break;
+#endif
+
+    case 0x100: // Unicode
+        switch (theEncoding) {
+        case kCFStringEncodingUTF8: return 65001;
+        case kCFStringEncodingUTF16: return 1200;
+        case kCFStringEncodingUTF16BE: return 1201;
+        case kCFStringEncodingUTF32: return 65005;
+        case kCFStringEncodingUTF32BE: return 65006;
+        }
+        break;
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS 
+    case 0x0200: // ISO 8859 series
+        if (encodingBase <= kCFStringEncodingISOLatin10) return ISO8859CODEPAGE_BASE + (encodingBase - 0x200);
+        break;
+
+    case 0x0400: // DOS codepage
+        if (encodingBase <= kCFStringEncodingDOSChineseTrad) return _CFToDOSCodePageList[encodingBase - 0x400]; 
+        break;
+
+    case 0x0500: // ANSI (Windows) codepage
+        if (encodingBase <= kCFStringEncodingWindowsVietnamese) return _CFToWindowsCodePageList[theEncoding - 0x500];
+        else if (encodingBase == kCFStringEncodingWindowsKoreanJohab) return 1361;
+        break;
+
+    case 0x600: // National standards
+        if (encodingBase == kCFStringEncodingASCII) return 20127;
+        else if (encodingBase == kCFStringEncodingGB_18030_2000) return 54936;
+        break;
+
+    case 0x0800: // ISO 2022 series
+        switch (encodingBase) {
+        case kCFStringEncodingISO_2022_JP: return 50220;
+        case kCFStringEncodingISO_2022_CN: return 50227;
+        case kCFStringEncodingISO_2022_KR: return 50225;
+        }
+        break;
+
+    case 0x0900: // EUC series
+        if (encodingBase <= kCFStringEncodingEUC_KR) return _CFEUCToCodePage[encodingBase - 0x0900];
+        break;
+
+
+    case 0x0A00: // Misc encodings
+        switch (encodingBase) {
+        case kCFStringEncodingKOI8_R: return 20866;
+        case kCFStringEncodingHZ_GB_2312: return 52936;
+        case kCFStringEncodingKOI8_U: return 21866;
+        }
+        break;
+
+    case 0x0C00: // IBM EBCDIC encodings
+        if (encodingBase == kCFStringEncodingEBCDIC_CP037) return 37;
+        break;
+#endif
+    }
+
+    return kCFStringEncodingInvalidId;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS
+static const struct {
+    uint16_t acp;
+    uint16_t encoding;
+} _CFACPToCFTable[] = {
+    {37, kCFStringEncodingEBCDIC_CP037},
+    {437, kCFStringEncodingDOSLatinUS},
+    {737, kCFStringEncodingDOSGreek},
+    {775, kCFStringEncodingDOSBalticRim},
+    {850, kCFStringEncodingDOSLatin1},
+    {851, kCFStringEncodingDOSGreek1},
+    {852, kCFStringEncodingDOSLatin2},
+    {855, kCFStringEncodingDOSCyrillic},
+    {857, kCFStringEncodingDOSTurkish},
+    {860, kCFStringEncodingDOSPortuguese},
+    {861, kCFStringEncodingDOSIcelandic},
+    {862, kCFStringEncodingDOSHebrew},
+    {863, kCFStringEncodingDOSCanadianFrench},
+    {864, kCFStringEncodingDOSArabic},
+    {865, kCFStringEncodingDOSNordic},
+    {866, kCFStringEncodingDOSRussian},
+    {869, kCFStringEncodingDOSGreek2},
+    {874, kCFStringEncodingDOSThai},
+    {932, kCFStringEncodingDOSJapanese},
+    {936, kCFStringEncodingDOSChineseSimplif},
+    {949, kCFStringEncodingDOSKorean},
+    {950, kCFStringEncodingDOSChineseTrad},
+    {1250, kCFStringEncodingWindowsLatin2},
+    {1251, kCFStringEncodingWindowsCyrillic},
+    {1252, kCFStringEncodingWindowsLatin1},
+    {1253, kCFStringEncodingWindowsGreek},
+    {1254, kCFStringEncodingWindowsLatin5},
+    {1255, kCFStringEncodingWindowsHebrew},
+    {1256, kCFStringEncodingWindowsArabic},
+    {1257, kCFStringEncodingWindowsBalticRim},
+    {1258, kCFStringEncodingWindowsVietnamese},
+    {1361, kCFStringEncodingWindowsKoreanJohab},
+    {20127, kCFStringEncodingASCII},
+    {20866, kCFStringEncodingKOI8_R},
+    {21866, kCFStringEncodingKOI8_U},
+    {50220, kCFStringEncodingISO_2022_JP},
+    {50225, kCFStringEncodingISO_2022_KR},
+    {50227, kCFStringEncodingISO_2022_CN},
+    {51932, kCFStringEncodingEUC_JP},
+    {51936, kCFStringEncodingEUC_CN},
+    {51949, kCFStringEncodingEUC_KR},
+    {51950, kCFStringEncodingEUC_TW},
+    {52936, kCFStringEncodingHZ_GB_2312},
+    {54936, kCFStringEncodingGB_18030_2000},
+};
+
+static SInt32 bsearchEncoding(uint16_t target) {
+    const unsigned int *start, *end, *divider;
+    unsigned int size = sizeof(_CFACPToCFTable) / sizeof(UInt32);
+
+    start = (const unsigned int*)_CFACPToCFTable; end = (const unsigned int*)_CFACPToCFTable + (size - 1);
+    while (start <= end) {
+        divider = start + ((end - start) / 2);
+
+        if (*(const uint16_t*)divider == target) return *((const uint16_t*)divider + 1);
+        else if (*(const uint16_t*)divider > target) end = divider - 1;
+        else if (*(const uint16_t*)(divider + 1) > target) return *((const uint16_t*)divider + 1);
+        else start = divider + 1;
+    }
+    return (kCFStringEncodingInvalidId);
+}
+#endif
+
+CFStringEncoding CFStringConvertWindowsCodepageToEncoding(UInt32 theEncoding) {
+    if (theEncoding == 0 || theEncoding == 1) { // ID for default (system) codepage
+        return CFStringGetSystemEncoding();
+    } else if ((theEncoding >= MACCODEPAGE_BASE) && (theEncoding < 20000)) { // Mac script
+        if (theEncoding <= 10029) return theEncoding - MACCODEPAGE_BASE; // up to Mac Central European
+#if (DEPLOYMENT_TARGET_MACOSX) 
+        else if (theEncoding == 10079) return kCFStringEncodingMacIcelandic;
+        else if (theEncoding == 10081) return kCFStringEncodingMacTurkish;
+        else if (theEncoding == 10082) return kCFStringEncodingMacCroatian;
+#endif
+    } else if ((theEncoding >= ISO8859CODEPAGE_BASE) && (theEncoding <= 28605)) { // ISO 8859
+        return (theEncoding - ISO8859CODEPAGE_BASE) + 0x200;
+    } else if (theEncoding == 65001) { // UTF-8
+        return kCFStringEncodingUTF8;
+    } else if (theEncoding == 12000) { // UTF-16
+        return kCFStringEncodingUTF16;
+    } else if (theEncoding == 12001) { // UTF-16BE
+        return kCFStringEncodingUTF16BE;
+    } else if (theEncoding == 65005) { // UTF-32
+        return kCFStringEncodingUTF32;
+    } else if (theEncoding == 65006) { // UTF-32BE
+        return kCFStringEncodingUTF32BE;
+    } else {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS
+        return bsearchEncoding(theEncoding);
+#endif
+    }
+
+    return kCFStringEncodingInvalidId;
+}
+
+CFStringEncoding CFStringGetMostCompatibleMacStringEncoding(CFStringEncoding encoding) {
+    CFStringEncoding macEncoding;
+
+    macEncoding = CFStringEncodingGetScriptCodeForEncoding(encoding);
+
+    return macEncoding;
+}
+
+
diff --git a/CoreFoundation/CFSystemDirectories.c b/CoreFoundation/CFSystemDirectories.c
new file mode 100644
index 0000000..6c41543
--- /dev/null
+++ b/CoreFoundation/CFSystemDirectories.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFSystemDirectories.c
+	Copyright 1997-2002, Apple, Inc. All rights reserved.
+	Responsibility: Ali Ozer
+*/
+
+/*
+        This file defines CFCopySearchPathForDirectoriesInDomains().
+        On MacOS 8, this function returns empty array.
+        On Mach, it calls the System.framework enumeration functions.
+        On Windows, it calls the enumeration functions defined here.
+*/
+
+#include <CoreFoundation/CFPriv.h>
+#include "CFInternal.h"
+
+#if DEPLOYMENT_TARGET_WINDOWS
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+extern size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+
+/* We use the System framework implementation on Mach.
+*/
+#include <libc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <NSSystemDirectories.h>
+
+CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask) {
+    return (NSSearchPathEnumerationState)NSStartSearchPathEnumeration((NSSearchPathDirectory)dir, (NSSearchPathDomainMask)domainMask);
+}
+
+CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, uint8_t *path, CFIndex pathSize) {
+    CFSearchPathEnumerationState result;
+    // NSGetNextSearchPathEnumeration requires a MAX_PATH size
+    if (pathSize < PATH_MAX) {
+        uint8_t tempPath[PATH_MAX];
+        result = NSGetNextSearchPathEnumeration(state, (char *)tempPath);
+        strlcpy((char *)path, (char *)tempPath, pathSize);
+    } else {
+        result = NSGetNextSearchPathEnumeration(state, (char *)path);
+    }
+    return result;
+}
+
+#elif DEPLOYMENT_TARGET_WINDOWS
+CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask) {
+    CFSearchPathEnumerationState result = 0;
+    //return (NSSearchPathEnumerationState)NSStartSearchPathEnumeration((NSSearchPathDirectory)dir, (NSSearchPathDomainMask)domainMask);
+    return result;
+}
+
+CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, uint8_t *path, CFIndex pathSize) {
+    CFSearchPathEnumerationState result = 0;
+    /*
+    // NSGetNextSearchPathEnumeration requires a MAX_PATH size
+    if (pathSize < PATH_MAX) {
+        uint8_t tempPath[PATH_MAX];
+        result = NSGetNextSearchPathEnumeration(state, (char *)tempPath);
+        strlcpy((char *)path, (char *)tempPath, pathSize);
+    } else {
+        result = NSGetNextSearchPathEnumeration(state, (char *)path);
+    }
+    */
+    return result;
+}
+
+#elif DEPLOYMENT_TARGET_LINUX
+CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask) {
+    return 0;
+}
+
+CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, uint8_t *path, CFIndex pathSize) {
+    return 0;
+}
+#endif
+
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+
+CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde) {
+    CFMutableArrayRef array;
+    CFSearchPathEnumerationState state;
+    CFIndex homeLen = -1;
+    char cPath[CFMaxPathSize], home[CFMaxPathSize];
+
+    array = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+    state = __CFStartSearchPathEnumeration(directory, domainMask);
+    while ((state = __CFGetNextSearchPathEnumeration(state, (uint8_t *)cPath, sizeof(cPath)))) {
+        CFURLRef url = NULL;
+        if (expandTilde && (cPath[0] == '~')) {
+            if (homeLen < 0) {
+                CFURLRef homeURL = CFCopyHomeDirectoryURLForUser(NULL);
+                if (homeURL) {
+                    CFURLGetFileSystemRepresentation(homeURL, true, (uint8_t *)home, CFMaxPathSize);
+                    homeLen = (CFIndex)strlen(home);
+                    CFRelease(homeURL);
+                }
+            }
+            if (homeLen + strlen(cPath) < CFMaxPathSize) {
+                home[homeLen] = '\0';
+                strlcat(home, &cPath[1], sizeof(home));
+                url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)home, (CFIndex)strlen(home), true);
+            }
+        } else {
+            url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorSystemDefault, (uint8_t *)cPath, (CFIndex)strlen(cPath), true);
+        }
+        if (url) {
+            CFArrayAppendValue(array, url);
+            CFRelease(url);
+        }
+    }
+    return array;
+}
+
+#endif
+
+#undef numDirs
+#undef numApplicationDirs
+#undef numLibraryDirs
+#undef numDomains
+#undef invalidDomains
+#undef invalidDomains
+
diff --git a/CoreFoundation/CFTimeZone.c b/CoreFoundation/CFTimeZone.c
new file mode 100644
index 0000000..d7b0ae8
--- /dev/null
+++ b/CoreFoundation/CFTimeZone.c
@@ -0,0 +1,1287 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 David M. Cotter <me@davevcotter.com>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFTimeZone.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include "CFPriv.h"
+#include "CFInternal.h"
+#include <math.h>
+#include <limits.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unicode/ucal.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/fcntl.h>
+#include <tzfile.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <windows.h>
+#include <winreg.h>
+#include <time.h>
+#include <tchar.h>
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#define TZZONELINK	TZDEFAULT
+#define TZZONEINFO	TZDIR "/"
+#elif DEPLOYMENT_TARGET_WINDOWS
+#define TZZONEINFO	"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
+#endif
+
+CONST_STRING_DECL(kCFTimeZoneSystemTimeZoneDidChangeNotification, "kCFTimeZoneSystemTimeZoneDidChangeNotification")
+
+static CFTimeZoneRef __CFTimeZoneSystem = NULL;
+static CFTimeZoneRef __CFTimeZoneDefault = NULL;
+static CFDictionaryRef __CFTimeZoneAbbreviationDict = NULL;
+static CFSpinLock_t __CFTimeZoneAbbreviationLock = CFSpinLockInit;
+static CFMutableDictionaryRef __CFTimeZoneCompatibilityMappingDict = NULL;
+static CFSpinLock_t __CFTimeZoneCompatibilityMappingLock = CFSpinLockInit;
+static CFArrayRef __CFKnownTimeZoneList = NULL;
+static CFMutableDictionaryRef __CFTimeZoneCache = NULL;
+static CFSpinLock_t __CFTimeZoneGlobalLock = CFSpinLockInit;
+
+CF_INLINE void __CFTimeZoneLockGlobal(void) {
+    __CFSpinLock(&__CFTimeZoneGlobalLock);
+}
+
+CF_INLINE void __CFTimeZoneUnlockGlobal(void) {
+    __CFSpinUnlock(&__CFTimeZoneGlobalLock);
+}
+
+CF_INLINE void __CFTimeZoneLockAbbreviations(void) {
+    __CFSpinLock(&__CFTimeZoneAbbreviationLock);
+}
+
+CF_INLINE void __CFTimeZoneUnlockAbbreviations(void) {
+    __CFSpinUnlock(&__CFTimeZoneAbbreviationLock);
+}
+
+CF_INLINE void __CFTimeZoneLockCompatibilityMapping(void) {
+    __CFSpinLock(&__CFTimeZoneCompatibilityMappingLock);
+}
+
+CF_INLINE void __CFTimeZoneUnlockCompatibilityMapping(void) {
+    __CFSpinUnlock(&__CFTimeZoneCompatibilityMappingLock);
+}
+
+/* This function should be used for WIN32 instead of
+ * __CFCopyRecursiveDirectoryList function.
+ * It takes TimeZone names from the registry
+ * (Aleksey Dukhnyakov)
+ */
+#if DEPLOYMENT_TARGET_WINDOWS
+static CFMutableArrayRef __CFCopyWindowsTimeZoneList() {
+    CFMutableArrayRef result = NULL;
+    HKEY hkResult;
+    TCHAR lpName[MAX_PATH+1];
+    DWORD dwIndex, retCode;
+
+    if (RegOpenKey(HKEY_LOCAL_MACHINE,_T(TZZONEINFO),&hkResult) !=
+        ERROR_SUCCESS )
+        return NULL;
+
+    result = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+
+    for (dwIndex=0; (retCode = RegEnumKey(hkResult,dwIndex,lpName,MAX_PATH)) != ERROR_NO_MORE_ITEMS ; dwIndex++) {
+
+        if (retCode != ERROR_SUCCESS) {
+            RegCloseKey(hkResult);
+            CFRelease(result);
+            return NULL;
+        }
+        else {
+#if defined(UNICODE)
+		    CFStringRef string = CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8*)lpName, (CFIndex)_tcslen(lpName), kCFStringEncodingUnicode, false);
+#else
+		    CFStringRef string = CFStringCreateWithBytes(kCFAllocatorDefault, (UInt8*)lpName, (CFIndex)_tcslen(lpName), CFStringGetSystemEncoding(), false);
+#endif
+		    CFArrayAppendValue(result, string);
+		    CFRelease(string);
+        }
+    }
+
+    RegCloseKey(hkResult);
+    return result;
+}
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+static CFMutableArrayRef __CFCopyRecursiveDirectoryList() {
+    CFMutableArrayRef result = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);
+#if !DEPLOYMENT_TARGET_WINDOWS
+    int fd = open(TZDIR "/zone.tab", O_RDONLY);
+    for (; 0 <= fd;) {
+        uint8_t buffer[4096];
+        ssize_t len = read(fd, buffer, sizeof(buffer));
+        if (len <= 0) break;
+	if (len < sizeof(buffer)) {
+	    // assumes that partial read only occurs at the end of the file
+	    buffer[len] = '\n';
+	    len++;
+	}
+        const uint8_t *bytes = buffer;
+        for (;;) {
+	    const uint8_t *nextl = (const uint8_t*)memchr(bytes, '\n', len);
+	    if (!nextl) break;
+	    nextl++;
+	    if ('#' == *bytes) {
+		len -= (nextl - bytes);
+		bytes = nextl;
+		continue;
+	    }
+	    const uint8_t *tab1 = (const uint8_t*)memchr(bytes, '\t', (nextl - bytes));
+	    if (!tab1) {
+		len -= (nextl - bytes);
+		bytes = nextl;
+		continue;
+	    }
+	    tab1++;
+	    len -= (tab1 - bytes);
+	    bytes = tab1; 
+	    const uint8_t *tab2 = (const uint8_t*)memchr(bytes, '\t', (nextl - bytes));
+	    if (!tab2) {
+		len -= (nextl - bytes);
+		bytes = nextl;
+		continue;
+	    }
+	    tab2++;
+	    len -= (tab2 - bytes);
+	    bytes = tab2; 
+	    const uint8_t *tab3 = (const uint8_t*)memchr(bytes, '\t', (nextl - bytes));
+	    int nmlen = tab3 ? (tab3 - bytes) : (nextl - 1 - bytes);
+	    CFStringRef string = CFStringCreateWithBytes(kCFAllocatorSystemDefault, bytes, nmlen, kCFStringEncodingUTF8, false);
+	    CFArrayAppendValue(result, string);
+	    CFRelease(string);
+	    len -= (nextl - bytes);
+	    bytes = nextl;
+        }
+        lseek(fd, -len, SEEK_CUR);
+    }
+    close(fd);
+#endif
+    return result;
+}
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+typedef struct _CFTZPeriod {
+    int32_t startSec;
+    CFStringRef abbrev;
+    uint32_t info;
+} CFTZPeriod;
+
+struct __CFTimeZone {
+    CFRuntimeBase _base;
+    CFStringRef _name;		/* immutable */
+    CFDataRef _data;		/* immutable */
+    CFTZPeriod *_periods;	/* immutable */
+    int32_t _periodCnt;		/* immutable */
+};
+
+/* startSec is the whole integer seconds from a CFAbsoluteTime, giving dates
+ * between 1933 and 2069; info outside these years is discarded on read-in */
+/* Bits 31-18 of the info are unused */
+/* Bit 17 of the info is used for the is-DST state */
+/* Bit 16 of the info is used for the sign of the offset (1 == negative) */
+/* Bits 15-0 of the info are used for abs(offset) in seconds from GMT */
+
+CF_INLINE void __CFTZPeriodInit(CFTZPeriod *period, int32_t startTime, CFStringRef abbrev, int32_t offset, Boolean isDST) {
+    period->startSec = startTime;
+    period->abbrev = abbrev ? (CFStringRef)CFRetain(abbrev) : NULL;
+    __CFBitfieldSetValue(period->info, 15, 0, abs(offset));
+    __CFBitfieldSetValue(period->info, 16, 16, (offset < 0 ? 1 : 0));
+    __CFBitfieldSetValue(period->info, 17, 17, (isDST ? 1 : 0));
+}
+
+CF_INLINE int32_t __CFTZPeriodStartSeconds(const CFTZPeriod *period) {
+    return period->startSec;
+}
+
+CF_INLINE CFStringRef __CFTZPeriodAbbreviation(const CFTZPeriod *period) {
+    return period->abbrev;
+}
+
+CF_INLINE int32_t __CFTZPeriodGMTOffset(const CFTZPeriod *period) {
+    int32_t v = __CFBitfieldGetValue(period->info, 15, 0);
+    if (__CFBitfieldGetValue(period->info, 16, 16)) v = -v;
+    return v;
+}
+
+CF_INLINE Boolean __CFTZPeriodIsDST(const CFTZPeriod *period) {
+    return (Boolean)__CFBitfieldGetValue(period->info, 17, 17);
+}
+
+static CFComparisonResult __CFCompareTZPeriods(const void *val1, const void *val2, void *context) {
+    CFTZPeriod *tzp1 = (CFTZPeriod *)val1;
+    CFTZPeriod *tzp2 = (CFTZPeriod *)val2;
+    // we treat equal as less than, as the code which uses the
+    // result of the bsearch doesn't expect exact matches
+    // (they're pretty rare, so no point in over-coding for them)
+    if (__CFTZPeriodStartSeconds(tzp1) <= __CFTZPeriodStartSeconds(tzp2)) return kCFCompareLessThan;
+    return kCFCompareGreaterThan;
+}
+
+static CFIndex __CFBSearchTZPeriods(CFTimeZoneRef tz, CFAbsoluteTime at) {
+    CFTZPeriod elem;
+    __CFTZPeriodInit(&elem, (int32_t)floor(at), NULL, 0, false);
+    CFIndex idx = CFBSearch(&elem, sizeof(CFTZPeriod), tz->_periods, tz->_periodCnt, __CFCompareTZPeriods, NULL);
+    if (tz->_periodCnt <= idx) {
+	idx = tz->_periodCnt;
+    } else if (0 == idx) {
+	idx = 1;
+    }
+    return idx - 1;
+}
+
+
+CF_INLINE int32_t __CFDetzcode(const unsigned char *bufp) {
+    int32_t result = (bufp[0] & 0x80) ? ~0L : 0L;
+    result = (result << 8) | (bufp[0] & 0xff);
+    result = (result << 8) | (bufp[1] & 0xff);
+    result = (result << 8) | (bufp[2] & 0xff);
+    result = (result << 8) | (bufp[3] & 0xff);
+    return result;
+}
+
+CF_INLINE void __CFEntzcode(int32_t value, unsigned char *bufp) {
+    bufp[0] = (value >> 24) & 0xff;
+    bufp[1] = (value >> 16) & 0xff;
+    bufp[2] = (value >> 8) & 0xff;
+    bufp[3] = (value >> 0) & 0xff;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+static Boolean __CFParseTimeZoneData(CFAllocatorRef allocator, CFDataRef data, CFTZPeriod **tzpp, CFIndex *cntp) {
+    int32_t len, timecnt, typecnt, charcnt, idx, cnt;
+    const uint8_t *p, *timep, *typep, *ttisp, *charp;
+    CFStringRef *abbrs;
+    Boolean result = true;
+
+    p = CFDataGetBytePtr(data);
+    len = CFDataGetLength(data);
+    if (len < (int32_t)sizeof(struct tzhead)) {
+	return false;
+    }
+    
+    if (!(p[0] == 'T' && p[1] == 'Z' && p[2] == 'i' && p[3] == 'f')) return false;  /* Don't parse without TZif at head of file */
+   
+    p += 20 + 4 + 4 + 4;	/* skip reserved, ttisgmtcnt, ttisstdcnt, leapcnt */
+    timecnt = __CFDetzcode(p);
+    p += 4;
+    typecnt = __CFDetzcode(p);
+    p += 4;
+    charcnt = __CFDetzcode(p);
+    p += 4;
+    if (typecnt <= 0 || timecnt < 0 || charcnt < 0) {
+	return false;
+    }
+    if (1024 < timecnt || 32 < typecnt || 128 < charcnt) {
+	// reject excessive timezones to avoid arithmetic overflows for
+	// security reasons and to reject potentially corrupt files
+	return false;
+    }
+    if (len - (int32_t)sizeof(struct tzhead) < (4 + 1) * timecnt + (4 + 1 + 1) * typecnt + charcnt) {
+	return false;
+    }
+    timep = p;
+    typep = timep + 4 * timecnt;
+    ttisp = typep + timecnt;
+    charp = ttisp + (4 + 1 + 1) * typecnt;
+    cnt = (0 < timecnt) ? timecnt : 1;
+    *tzpp = (CFTZPeriod*)CFAllocatorAllocate(allocator, cnt * sizeof(CFTZPeriod), 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(*tzpp, "CFTimeZone (store)");
+    memset(*tzpp, 0, cnt * sizeof(CFTZPeriod));
+    abbrs = (CFStringRef*)CFAllocatorAllocate(allocator, (charcnt + 1) * sizeof(CFStringRef), 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(abbrs, "CFTimeZone (temp)");
+    for (idx = 0; idx < charcnt + 1; idx++) {
+	abbrs[idx] = NULL;
+    }
+    for (idx = 0; idx < cnt; idx++) {
+	CFAbsoluteTime at;
+	int32_t itime, offset;
+	uint8_t type, dst, abbridx;
+
+	at = (CFAbsoluteTime)(__CFDetzcode(timep) + 0.0) - kCFAbsoluteTimeIntervalSince1970;
+	if (0 == timecnt) itime = INT_MIN;
+	else if (at < (CFAbsoluteTime)INT_MIN) itime = INT_MIN;
+	else if ((CFAbsoluteTime)INT_MAX < at) itime = INT_MAX;
+	else itime = (int32_t)at;
+	timep += 4;	/* harmless if 0 == timecnt */
+	type = (0 < timecnt) ? (uint8_t)*typep++ : 0;
+	if (typecnt <= type) {
+	    result = false;
+	    break;
+	}
+	offset = __CFDetzcode(ttisp + 6 * type);
+	dst = (uint8_t)*(ttisp + 6 * type + 4);
+	if (0 != dst && 1 != dst) {
+	    result = false;
+	    break;
+	}
+	abbridx = (uint8_t)*(ttisp + 6 * type + 5);
+	if (charcnt < abbridx) {
+	    result = false;
+	    break;
+	}
+	if (NULL == abbrs[abbridx]) {
+	    abbrs[abbridx] = CFStringCreateWithCString(allocator, (char *)&charp[abbridx], kCFStringEncodingASCII);
+	}
+	__CFTZPeriodInit(*tzpp + idx, itime, abbrs[abbridx], offset, (dst ? true : false));
+    }
+    for (idx = 0; idx < charcnt + 1; idx++) {
+	if (NULL != abbrs[idx]) {
+	    CFRelease(abbrs[idx]);
+	}
+    }
+    CFAllocatorDeallocate(allocator, abbrs);
+    if (result) {
+	// dump all but the last INT_MIN and the first INT_MAX
+	for (idx = 0; idx < cnt; idx++) {
+	    if (((*tzpp + idx)->startSec == INT_MIN) && (idx + 1 < cnt) && (((*tzpp + idx + 1)->startSec == INT_MIN))) {
+		if (NULL != (*tzpp + idx)->abbrev) CFRelease((*tzpp + idx)->abbrev);
+		cnt--;
+		memmove((*tzpp + idx), (*tzpp + idx + 1), sizeof(CFTZPeriod) * (cnt - idx));
+		idx--;
+	    }
+	}
+	// Don't combine these loops!  Watch the idx decrementing...
+	for (idx = 0; idx < cnt; idx++) {
+	    if (((*tzpp + idx)->startSec == INT_MAX) && (0 < idx) && (((*tzpp + idx - 1)->startSec == INT_MAX))) {
+		if (NULL != (*tzpp + idx)->abbrev) CFRelease((*tzpp + idx)->abbrev);
+		cnt--;
+		memmove((*tzpp + idx), (*tzpp + idx + 1), sizeof(CFTZPeriod) * (cnt - idx));
+		idx--;
+	    }
+	}
+	CFQSortArray(*tzpp, cnt, sizeof(CFTZPeriod), __CFCompareTZPeriods, NULL);
+	// if the first period is in DST and there is more than one period, drop it
+	if (1 < cnt && __CFTZPeriodIsDST(*tzpp + 0)) {
+	    if (NULL != (*tzpp + 0)->abbrev) CFRelease((*tzpp + 0)->abbrev);
+	    cnt--;
+	    memmove((*tzpp + 0), (*tzpp + 0 + 1), sizeof(CFTZPeriod) * (cnt - 0));
+	}
+	*cntp = cnt;
+    } else {
+	CFAllocatorDeallocate(allocator, *tzpp);
+	*tzpp = NULL;
+    }
+    return result;
+}
+#elif DEPLOYMENT_TARGET_WINDOWS || 0
+static Boolean __CFParseTimeZoneData(CFAllocatorRef allocator, CFDataRef data, CFTZPeriod **tzpp, CFIndex *cntp) {
+/* We use Win32 function to find TimeZone
+ * (Aleksey Dukhnyakov)
+ */
+    *tzpp = (CFTZPeriod *)CFAllocatorAllocate(allocator, sizeof(CFTZPeriod), 0);
+    memset(*tzpp, 0, sizeof(CFTZPeriod));
+    __CFTZPeriodInit(*tzpp, 0, NULL, 0, false);
+    *cntp = 1;
+    return TRUE;
+}
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+static Boolean __CFTimeZoneEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFTimeZoneRef tz1 = (CFTimeZoneRef)cf1;
+    CFTimeZoneRef tz2 = (CFTimeZoneRef)cf2;
+    if (!CFEqual(CFTimeZoneGetName(tz1), CFTimeZoneGetName(tz2))) return false;
+    if (!CFEqual(CFTimeZoneGetData(tz1), CFTimeZoneGetData(tz2))) return false;
+    return true;
+}
+
+static CFHashCode __CFTimeZoneHash(CFTypeRef cf) {
+    CFTimeZoneRef tz = (CFTimeZoneRef)cf;
+    return CFHash(CFTimeZoneGetName(tz));
+}
+
+static CFStringRef __CFTimeZoneCopyDescription(CFTypeRef cf) {
+    CFTimeZoneRef tz = (CFTimeZoneRef)cf;
+    CFStringRef result, abbrev;
+    CFAbsoluteTime at;
+    at = CFAbsoluteTimeGetCurrent();
+    abbrev = CFTimeZoneCopyAbbreviation(tz, at);
+    result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFTimeZone %p [%p]>{name = %@; abbreviation = %@; GMT offset = %g; is DST = %s}"), cf, CFGetAllocator(tz), tz->_name, abbrev, CFTimeZoneGetSecondsFromGMT(tz, at), CFTimeZoneIsDaylightSavingTime(tz, at) ? "true" : "false");
+    CFRelease(abbrev);
+    return result;
+}
+
+static void __CFTimeZoneDeallocate(CFTypeRef cf) {
+    CFTimeZoneRef tz = (CFTimeZoneRef)cf;
+    CFAllocatorRef allocator = CFGetAllocator(tz);
+    CFIndex idx;
+    if (tz->_name) CFRelease(tz->_name);
+    if (tz->_data) CFRelease(tz->_data);
+    for (idx = 0; idx < tz->_periodCnt; idx++) {
+	if (NULL != tz->_periods[idx].abbrev) CFRelease(tz->_periods[idx].abbrev);
+    }
+    if (NULL != tz->_periods) CFAllocatorDeallocate(allocator, tz->_periods);
+}
+
+static CFTypeID __kCFTimeZoneTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFTimeZoneClass = {
+    0,
+    "CFTimeZone",
+    NULL,	// init
+    NULL,	// copy
+    __CFTimeZoneDeallocate,
+    __CFTimeZoneEqual,
+    __CFTimeZoneHash,
+    NULL,	//
+    __CFTimeZoneCopyDescription
+};
+
+__private_extern__ void __CFTimeZoneInitialize(void) {
+    __kCFTimeZoneTypeID = _CFRuntimeRegisterClass(&__CFTimeZoneClass);
+}
+
+CFTypeID CFTimeZoneGetTypeID(void) {
+    return __kCFTimeZoneTypeID;
+}
+
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+static CFTimeZoneRef __CFTimeZoneCreateSystem(void) {
+    CFTimeZoneRef result = NULL;
+
+    char *tzenv;
+    int ret;
+    char linkbuf[CFMaxPathSize];
+
+    tzenv = getenv("TZFILE");
+    if (NULL != tzenv) {
+	CFStringRef name = CFStringCreateWithBytes(kCFAllocatorSystemDefault, (uint8_t *)tzenv, strlen(tzenv), kCFStringEncodingUTF8, false);
+	result = CFTimeZoneCreateWithName(kCFAllocatorSystemDefault, name, false);
+	CFRelease(name);
+	if (result) return result;
+    }
+    tzenv = getenv("TZ");
+    if (NULL != tzenv) {
+	CFStringRef name = CFStringCreateWithBytes(kCFAllocatorSystemDefault, (uint8_t *)tzenv, strlen(tzenv), kCFStringEncodingUTF8, false);
+	result = CFTimeZoneCreateWithName(kCFAllocatorSystemDefault, name, true);
+	CFRelease(name);
+	if (result) return result;
+    }
+    ret = readlink(TZZONELINK, linkbuf, sizeof(linkbuf));
+    if (0 < ret) {
+	CFStringRef name;
+	linkbuf[ret] = '\0';
+	if (strncmp(linkbuf, TZZONEINFO, sizeof(TZZONEINFO) - 1) == 0) {
+	    name = CFStringCreateWithBytes(kCFAllocatorSystemDefault, (uint8_t *)linkbuf + sizeof(TZZONEINFO) - 1, strlen(linkbuf) - sizeof(TZZONEINFO) + 1, kCFStringEncodingUTF8, false);
+	} else {
+	    name = CFStringCreateWithBytes(kCFAllocatorSystemDefault, (uint8_t *)linkbuf, strlen(linkbuf), kCFStringEncodingUTF8, false);
+	}
+	result = CFTimeZoneCreateWithName(kCFAllocatorSystemDefault, name, false);
+	CFRelease(name);
+	if (result) return result;
+    }
+    return CFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorSystemDefault, 0.0);
+}
+#elif DEPLOYMENT_TARGET_WINDOWS || 0
+static CFTimeZoneRef __CFTimeZoneCreateSystem(void) {
+    CFTimeZoneRef result = NULL;
+/* The GetTimeZoneInformation function retrieves the current
+ * time-zone parameters for Win32
+ * (Aleksey Dukhnyakov)
+ */
+    CFDataRef data;
+    TIME_ZONE_INFORMATION tz;
+    DWORD dw_result;
+    dw_result=GetTimeZoneInformation(&tz);
+
+    if ( dw_result == TIME_ZONE_ID_STANDARD ||
+            dw_result == TIME_ZONE_ID_DAYLIGHT ) {
+        CFStringRef name = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (const UniChar *)tz.StandardName, (CFIndex)wcslen(tz.StandardName));
+        data = CFDataCreate(kCFAllocatorSystemDefault, (UInt8 *)&tz, sizeof(tz));
+        result = CFTimeZoneCreate(kCFAllocatorSystemDefault, name, data);
+        CFRelease(name);
+        CFRelease(data);
+        if (result) return result;
+    }
+    return CFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorSystemDefault, 0.0);
+}
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+CFTimeZoneRef CFTimeZoneCopySystem(void) {
+    CFTimeZoneRef tz;
+    __CFTimeZoneLockGlobal();
+    if (NULL == __CFTimeZoneSystem) {
+	__CFTimeZoneUnlockGlobal();
+	tz = __CFTimeZoneCreateSystem();
+	__CFTimeZoneLockGlobal();
+	if (NULL == __CFTimeZoneSystem) {
+	    __CFTimeZoneSystem = tz;
+	} else {
+	    if (tz) CFRelease(tz);
+	}
+    }
+    tz = __CFTimeZoneSystem ? (CFTimeZoneRef)CFRetain(__CFTimeZoneSystem) : NULL;
+    __CFTimeZoneUnlockGlobal();
+    return tz;
+}
+
+static CFIndex __noteCount = 0;
+
+void CFTimeZoneResetSystem(void) {
+    __CFTimeZoneLockGlobal();
+    if (__CFTimeZoneDefault == __CFTimeZoneSystem) {
+	if (__CFTimeZoneDefault) CFRelease(__CFTimeZoneDefault);
+	__CFTimeZoneDefault = NULL;
+    }
+    CFTimeZoneRef tz = __CFTimeZoneSystem;
+    __CFTimeZoneSystem = NULL;
+    __CFTimeZoneUnlockGlobal();
+    if (tz) CFRelease(tz);
+}
+
+CFIndex _CFTimeZoneGetNoteCount(void) {
+    return __noteCount;
+}
+
+CFTimeZoneRef CFTimeZoneCopyDefault(void) {
+    CFTimeZoneRef tz;
+    __CFTimeZoneLockGlobal();
+    if (NULL == __CFTimeZoneDefault) {
+	__CFTimeZoneUnlockGlobal();
+	tz = CFTimeZoneCopySystem();
+	__CFTimeZoneLockGlobal();
+	if (NULL == __CFTimeZoneDefault) {
+	    __CFTimeZoneDefault = tz;
+	} else {
+	    if (tz) CFRelease(tz);
+	}
+    }
+    tz = __CFTimeZoneDefault ? (CFTimeZoneRef)CFRetain(__CFTimeZoneDefault) : NULL;
+    __CFTimeZoneUnlockGlobal();
+    return tz;
+}
+
+void CFTimeZoneSetDefault(CFTimeZoneRef tz) {
+    if (tz) __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    __CFTimeZoneLockGlobal();
+    if (tz != __CFTimeZoneDefault) {
+	if (tz) CFRetain(tz);
+	if (__CFTimeZoneDefault) CFRelease(__CFTimeZoneDefault);
+	__CFTimeZoneDefault = tz;
+    }
+    __CFTimeZoneUnlockGlobal();
+}
+
+static CFDictionaryRef __CFTimeZoneCopyCompatibilityDictionary(void);
+
+CFArrayRef CFTimeZoneCopyKnownNames(void) {
+    CFArrayRef tzs;
+    __CFTimeZoneLockGlobal();
+    if (NULL == __CFKnownTimeZoneList) {
+	CFMutableArrayRef list;
+/* TimeZone information locate in the registry for Win32
+ * (Aleksey Dukhnyakov)
+ */
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+        list = __CFCopyRecursiveDirectoryList();
+#elif DEPLOYMENT_TARGET_WINDOWS
+        list = __CFCopyWindowsTimeZoneList();
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+	// Remove undesirable ancient cruft
+	CFDictionaryRef dict = __CFTimeZoneCopyCompatibilityDictionary();
+	CFIndex idx;
+	for (idx = CFArrayGetCount(list); idx--; ) {
+	    CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(list, idx);
+	    if (CFDictionaryContainsKey(dict, item)) {
+		CFArrayRemoveValueAtIndex(list, idx);
+	    }
+	}
+	__CFKnownTimeZoneList = CFArrayCreateCopy(kCFAllocatorSystemDefault, list);
+	CFRelease(list);
+    }
+    tzs = __CFKnownTimeZoneList ? (CFArrayRef)CFRetain(__CFKnownTimeZoneList) : NULL;
+    __CFTimeZoneUnlockGlobal();
+    return tzs;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+/* The criteria here are sort of: coverage for the U.S. and Europe,
+ * large cities, abbreviation uniqueness, and perhaps a few others.
+ * But do not make the list too large with obscure information.
+ */
+static const char *__CFTimeZoneAbbreviationDefaults =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+" <!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">"
+" <plist version=\"1.0\">"
+" <dict>"
+"    <key>ADT</key>  <string>America/Halifax</string>"
+"    <key>AKDT</key> <string>America/Juneau</string>"
+"    <key>AKST</key> <string>America/Juneau</string>"
+"    <key>ART</key>  <string>America/Argentina/Buenos_Aires</string>"
+"    <key>AST</key>  <string>America/Halifax</string>"
+"    <key>BDT</key>  <string>Asia/Dhaka</string>"
+"    <key>BRST</key> <string>America/Sao_Paulo</string>"
+"    <key>BRT</key>  <string>America/Sao_Paulo</string>"
+"    <key>BST</key>  <string>Europe/London</string>"
+"    <key>CAT</key>  <string>Africa/Harare</string>"
+"    <key>CDT</key>  <string>America/Chicago</string>"
+"    <key>CEST</key> <string>Europe/Paris</string>"
+"    <key>CET</key>  <string>Europe/Paris</string>"
+"    <key>CLST</key> <string>America/Santiago</string>"
+"    <key>CLT</key>  <string>America/Santiago</string>"
+"    <key>COT</key>  <string>America/Bogota</string>"
+"    <key>CST</key>  <string>America/Chicago</string>"
+"    <key>EAT</key>  <string>Africa/Addis_Ababa</string>"
+"    <key>EDT</key>  <string>America/New_York</string>"
+"    <key>EEST</key> <string>Europe/Istanbul</string>"
+"    <key>EET</key>  <string>Europe/Istanbul</string>"
+"    <key>EST</key>  <string>America/New_York</string>"
+"    <key>GMT</key>  <string>GMT</string>"
+"    <key>GST</key>  <string>Asia/Dubai</string>"
+"    <key>HKT</key>  <string>Asia/Hong_Kong</string>"
+"    <key>HST</key>  <string>Pacific/Honolulu</string>"
+"    <key>ICT</key>  <string>Asia/Bangkok</string>"
+"    <key>IRST</key> <string>Asia/Tehran</string>"
+"    <key>IST</key>  <string>Asia/Calcutta</string>"
+"    <key>JST</key>  <string>Asia/Tokyo</string>"
+"    <key>KST</key>  <string>Asia/Seoul</string>"
+"    <key>MDT</key>  <string>America/Denver</string>"
+"    <key>MSD</key>  <string>Europe/Moscow</string>"
+"    <key>MSK</key>  <string>Europe/Moscow</string>"
+"    <key>MST</key>  <string>America/Denver</string>"
+"    <key>NZDT</key> <string>Pacific/Auckland</string>"
+"    <key>NZST</key> <string>Pacific/Auckland</string>"
+"    <key>PDT</key>  <string>America/Los_Angeles</string>"
+"    <key>PET</key>  <string>America/Lima</string>"
+"    <key>PHT</key>  <string>Asia/Manila</string>"
+"    <key>PKT</key>  <string>Asia/Karachi</string>"
+"    <key>PST</key>  <string>America/Los_Angeles</string>"
+"    <key>SGT</key>  <string>Asia/Singapore</string>"
+"    <key>UTC</key>  <string>UTC</string>"
+"    <key>WAT</key>  <string>Africa/Lagos</string>"
+"    <key>WEST</key> <string>Europe/Lisbon</string>"
+"    <key>WET</key>  <string>Europe/Lisbon</string>"
+"    <key>WIT</key>  <string>Asia/Jakarta</string>"
+" </dict>"
+" </plist>";
+#elif DEPLOYMENT_TARGET_WINDOWS || 0
+static const char *__CFTimeZoneAbbreviationDefaults =
+/* Mappings to time zones in Windows Registry are best-guess */
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+" <!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">"
+" <plist version=\"1.0\">"
+" <dict>"
+"    <key>ADT</key>  <string>Atlantic Standard Time</string>"
+"    <key>AKDT</key> <string>Alaskan Standard Time</string>"
+"    <key>AKST</key> <string>Alaskan Standard Time</string>"
+"    <key>ART</key>  <string>SA Eastern Standard Time</string>"
+"    <key>AST</key>  <string>Atlantic Standard Time</string>"
+"    <key>BDT</key>  <string>Central Asia Standard Time</string>"
+"    <key>BRST</key> <string>SA Eastern Standard Time</string>"
+"    <key>BRT</key>  <string>SA Eastern Standard Time</string>"
+"    <key>BST</key>  <string>GMT Standard Time</string>"
+"    <key>CAT</key>  <string>South Africa Standard Time</string>"
+"    <key>CDT</key>  <string>Central Daylight Time</string>"
+"    <key>CEST</key> <string>Central Europe Standard Time</string>"
+"    <key>CET</key>  <string>Central Europe Standard Time</string>"
+"    <key>CLST</key> <string>SA Western Standard Time</string>"
+"    <key>CLT</key>  <string>SA Western Standard Time</string>"
+"    <key>COT</key>  <string>Central Standard Time</string>"
+"    <key>CST</key>  <string>Central Standard Time</string>"
+"    <key>EAT</key>  <string>E. Africa Standard Time</string>"
+"    <key>EDT</key>  <string>Eastern Daylight Time</string>"
+"    <key>EEST</key> <string>E. Europe Standard Time</string>"
+"    <key>EET</key>  <string>E. Europe Standard Time</string>"
+"    <key>EST</key>  <string>Eastern Standard Time</string>"
+"    <key>GMT</key>  <string>Greenwich Standard Time</string>"
+"    <key>GST</key>  <string>Arabian Standard Time</string>"
+"    <key>HKT</key>  <string>China Standard Time</string>"
+"    <key>HST</key>  <string>Hawaiian Standard Time</string>"
+"    <key>ICT</key>  <string>SE Asia Standard Time</string>"
+"    <key>IRST</key> <string>Iran Standard Time</string>"
+"    <key>IST</key>  <string>India Standard Time</string>"
+"    <key>JST</key>  <string>Tokyo Standard Time</string>"
+"    <key>KST</key>  <string>Korea Standard Time</string>"
+"    <key>MDT</key>  <string>Mountain Daylight Time</string>"
+"    <key>MSD</key>  <string>E. Europe Standard Time</string>"
+"    <key>MSK</key>  <string>E. Europe Standard Time</string>"
+"    <key>MST</key>  <string>Mountain Standard Time</string>"
+"    <key>NZDT</key> <string>New Zealand Standard Time</string>"
+"    <key>NZST</key> <string>New Zealand Standard Time</string>"
+"    <key>PDT</key>  <string>Pacific Daylight Time</string>"
+"    <key>PET</key>  <string>SA Pacific Standard Time</string>"
+"    <key>PHT</key>  <string>Taipei Standard Time</string>"
+"    <key>PKT</key>  <string>West Asia Standard Time</string>"
+"    <key>PST</key>  <string>Pacific Standard Time</string>"
+"    <key>SGT</key>  <string>Singapore Standard Time</string>"
+"    <key>UTC</key>  <string>Greenwich Standard Time</string>"
+"    <key>WAT</key>  <string>W. Central Africa Standard Time</string>"
+"    <key>WEST</key> <string>W. Europe Standard Time</string>"
+"    <key>WET</key>  <string>W. Europe Standard Time</string>"
+"    <key>WIT</key>  <string>SE Asia Standard Time</string>"
+" </dict>"
+" </plist>";
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+CFDictionaryRef CFTimeZoneCopyAbbreviationDictionary(void) {
+    CFDictionaryRef dict;
+    __CFTimeZoneLockAbbreviations();
+    if (NULL == __CFTimeZoneAbbreviationDict) {
+	CFDataRef data = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)__CFTimeZoneAbbreviationDefaults, (CFIndex)strlen(__CFTimeZoneAbbreviationDefaults));
+	__CFTimeZoneAbbreviationDict = (CFDictionaryRef)CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, data, kCFPropertyListImmutable, NULL);
+	CFRelease(data);
+    }
+    if (NULL == __CFTimeZoneAbbreviationDict) {
+	__CFTimeZoneAbbreviationDict = CFDictionaryCreate(kCFAllocatorSystemDefault, NULL, NULL, 0, NULL, NULL);
+    }
+    dict = __CFTimeZoneAbbreviationDict ? (CFDictionaryRef)CFRetain(__CFTimeZoneAbbreviationDict) : NULL;
+    __CFTimeZoneUnlockAbbreviations();
+    return dict;
+}
+
+void CFTimeZoneSetAbbreviationDictionary(CFDictionaryRef dict) {
+    __CFGenericValidateType(dict, CFDictionaryGetTypeID());
+    __CFTimeZoneLockGlobal();
+    if (dict != __CFTimeZoneAbbreviationDict) {
+	if (dict) CFRetain(dict);
+	if (__CFTimeZoneAbbreviationDict) {
+	    CFIndex count, idx;
+	    count = CFDictionaryGetCount(__CFTimeZoneAbbreviationDict);
+	    CFTypeRef *keys = (CFTypeRef *)malloc(sizeof(CFTypeRef *) * count);
+	    for (idx = 0; idx < count; idx++) {
+		CFDictionaryRemoveValue(__CFTimeZoneCache, (CFStringRef)keys[idx]);
+	    }
+	    free(keys);
+	    CFRelease(__CFTimeZoneAbbreviationDict);
+	}
+	__CFTimeZoneAbbreviationDict = dict;
+    }
+    __CFTimeZoneUnlockGlobal();
+}
+
+CFTimeZoneRef CFTimeZoneCreate(CFAllocatorRef allocator, CFStringRef name, CFDataRef data) {
+// assert:    (NULL != name && NULL != data);
+    CFTimeZoneRef memory;
+    uint32_t size;
+    CFTZPeriod *tzp = NULL;
+    CFIndex idx, cnt = 0;
+
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(name, CFStringGetTypeID());
+    __CFGenericValidateType(data, CFDataGetTypeID());
+    __CFTimeZoneLockGlobal();
+    if (NULL != __CFTimeZoneCache && CFDictionaryGetValueIfPresent(__CFTimeZoneCache, name, (const void **)&memory)) {
+	__CFTimeZoneUnlockGlobal();
+	return (CFTimeZoneRef)CFRetain(memory);
+    }
+    if (!__CFParseTimeZoneData(allocator, data, &tzp, &cnt)) {
+	__CFTimeZoneUnlockGlobal();
+	return NULL;
+    }
+    size = sizeof(struct __CFTimeZone) - sizeof(CFRuntimeBase);
+    memory = (CFTimeZoneRef)_CFRuntimeCreateInstance(allocator, CFTimeZoneGetTypeID(), size, NULL);
+    if (NULL == memory) {
+	__CFTimeZoneUnlockGlobal();
+	for (idx = 0; idx < cnt; idx++) {
+	    if (NULL != tzp[idx].abbrev) CFRelease(tzp[idx].abbrev);
+	}
+	if (NULL != tzp) CFAllocatorDeallocate(allocator, tzp);
+        return NULL;
+    }
+    ((struct __CFTimeZone *)memory)->_name = (CFStringRef)CFStringCreateCopy(allocator, name);
+    ((struct __CFTimeZone *)memory)->_data = CFDataCreateCopy(allocator, data);
+    ((struct __CFTimeZone *)memory)->_periods = tzp;
+    ((struct __CFTimeZone *)memory)->_periodCnt = cnt;
+    if (NULL == __CFTimeZoneCache) {
+	__CFTimeZoneCache = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    }
+    CFDictionaryAddValue(__CFTimeZoneCache, ((struct __CFTimeZone *)memory)->_name, memory);
+    __CFTimeZoneUnlockGlobal();
+    return memory;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+static CFTimeZoneRef __CFTimeZoneCreateFixed(CFAllocatorRef allocator, int32_t seconds, CFStringRef name, int isDST) {
+    CFTimeZoneRef result;
+    CFDataRef data;
+    int32_t nameLen = CFStringGetLength(name);
+    unsigned char dataBytes[52 + nameLen + 1];
+    memset(dataBytes, 0, sizeof(dataBytes));
+    
+    // Put in correct magic bytes for timezone structures
+    dataBytes[0] = 'T';
+    dataBytes[1] = 'Z';
+    dataBytes[2] = 'i';
+    dataBytes[3] = 'f';
+    
+    __CFEntzcode(1, dataBytes + 20);
+    __CFEntzcode(1, dataBytes + 24);
+    __CFEntzcode(1, dataBytes + 36);
+    __CFEntzcode(nameLen + 1, dataBytes + 40);
+    __CFEntzcode(seconds, dataBytes + 44);
+    dataBytes[48] = isDST ? 1 : 0;
+    CFStringGetCString(name, (char *)dataBytes + 50, nameLen + 1, kCFStringEncodingASCII);
+    data = CFDataCreate(allocator, dataBytes, 52 + nameLen + 1);
+    result = CFTimeZoneCreate(allocator, name, data);
+    CFRelease(data);
+    return result;
+}
+#elif DEPLOYMENT_TARGET_WINDOWS || 0
+static CFTimeZoneRef __CFTimeZoneCreateFixed(CFAllocatorRef allocator, int32_t seconds, CFStringRef name, int isDST) {
+/* CFTimeZoneRef->_data will contain TIME_ZONE_INFORMATION structure
+ * to find current timezone
+ * (Aleksey Dukhnyakov)
+ */
+    CFTimeZoneRef result;
+    TIME_ZONE_INFORMATION tzi;
+    CFDataRef data;
+    CFIndex length = CFStringGetLength(name);
+
+    memset(&tzi,0,sizeof(tzi));
+    tzi.Bias=(long)(-seconds/60);
+    CFStringGetCharacters(name, CFRangeMake(0, length < 31 ? length : 31 ), (UniChar *)tzi.StandardName);
+    data = CFDataCreate(allocator,(UInt8 *)&tzi, sizeof(tzi));
+    result = CFTimeZoneCreate(allocator, name, data);
+    CFRelease(data);
+    return result;
+}
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+// rounds offset to nearest minute
+CFTimeZoneRef CFTimeZoneCreateWithTimeIntervalFromGMT(CFAllocatorRef allocator, CFTimeInterval ti) {
+    CFTimeZoneRef result;
+    CFStringRef name;
+    int32_t seconds, minute, hour;
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    if (ti < -18.0 * 3600 || 18.0 * 3600 < ti) return NULL;
+    ti = (ti < 0.0) ? ceil((ti / 60.0) - 0.5) * 60.0 : floor((ti / 60.0) + 0.5) * 60.0;
+    seconds = (int32_t)ti;
+    hour = (ti < 0) ? (-seconds / 3600) : (seconds / 3600);
+    seconds -= ((ti < 0) ? -hour : hour) * 3600;
+    minute = (ti < 0) ? (-seconds / 60) : (seconds / 60);
+    if (fabs(ti) < 1.0) {
+	name = (CFStringRef)CFRetain(CFSTR("GMT"));
+    } else {
+	name = CFStringCreateWithFormat(allocator, NULL, CFSTR("GMT%c%02d%02d"), (ti < 0.0 ? '-' : '+'), hour, minute);
+    }
+    result = __CFTimeZoneCreateFixed(allocator, (int32_t)ti, name, 0);
+    CFRelease(name);
+    return result;
+}
+
+CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef name, Boolean tryAbbrev) {
+    CFTimeZoneRef result = NULL;
+    CFStringRef tzName = NULL;
+    CFDataRef data = NULL;
+
+    if (allocator == NULL) allocator = __CFGetDefaultAllocator();
+    __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
+    __CFGenericValidateType(name, CFStringGetTypeID());
+    if (CFEqual(CFSTR(""), name)) {
+	// empty string is not a time zone name, just abort now,
+	// following stuff will fail anyway
+	return NULL;
+    }
+    __CFTimeZoneLockGlobal();
+    if (NULL != __CFTimeZoneCache && CFDictionaryGetValueIfPresent(__CFTimeZoneCache, name, (const void **)&result)) {
+	__CFTimeZoneUnlockGlobal();
+	return (CFTimeZoneRef)CFRetain(result);
+    }
+    __CFTimeZoneUnlockGlobal();
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    CFURLRef baseURL, tempURL;
+    void *bytes;
+    CFIndex length;
+
+    baseURL = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, CFSTR(TZZONEINFO), kCFURLPOSIXPathStyle, true);
+    if (tryAbbrev) {
+	CFDictionaryRef abbrevs = CFTimeZoneCopyAbbreviationDictionary();
+	tzName = (CFStringRef)CFDictionaryGetValue(abbrevs, name);
+	if (NULL != tzName) {
+	    tempURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, tzName, false);
+	    if (NULL != tempURL) {
+		if (_CFReadBytesFromFile(kCFAllocatorSystemDefault, tempURL, &bytes, &length, 0)) {
+		    data = CFDataCreateWithBytesNoCopy(kCFAllocatorSystemDefault, (const uint8_t*)bytes, length, kCFAllocatorSystemDefault);
+		}
+		CFRelease(tempURL);
+	    }
+	}
+	CFRelease(abbrevs);
+    }
+    if (NULL == data) {
+	CFDictionaryRef dict = __CFTimeZoneCopyCompatibilityDictionary();
+	CFStringRef mapping = (CFStringRef)CFDictionaryGetValue(dict, name);
+	if (mapping) {
+	    name = mapping;
+	} else if (CFStringHasPrefix(name, CFSTR(TZZONEINFO))) {
+	    CFMutableStringRef unprefixed = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, CFStringGetLength(name), name);
+	    CFStringDelete(unprefixed, CFRangeMake(0, sizeof(TZZONEINFO)));
+	    mapping = (CFStringRef)CFDictionaryGetValue(dict, unprefixed);
+	    if (mapping) {
+		name = mapping;
+	    }
+	    CFRelease(unprefixed);
+	}
+	CFRelease(dict);
+	if (CFEqual(CFSTR(""), name)) {
+	    return NULL;
+	}
+    }
+    if (NULL == data) {
+       tzName = name;
+       tempURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, tzName, false);
+       if (NULL != tempURL) {
+           if (_CFReadBytesFromFile(kCFAllocatorSystemDefault, tempURL, &bytes, &length, 0)) {
+               data = CFDataCreateWithBytesNoCopy(kCFAllocatorSystemDefault, (const uint8_t*)bytes, length, kCFAllocatorSystemDefault);
+           }
+           CFRelease(tempURL);
+       }
+    }
+    CFRelease(baseURL);
+    if (NULL != data) {
+	result = CFTimeZoneCreate(allocator, tzName, data);
+	if (name != tzName) {
+	    CFStringRef nameCopy = (CFStringRef)CFStringCreateCopy(allocator, name);
+	    __CFTimeZoneLockGlobal();
+	    CFDictionaryAddValue(__CFTimeZoneCache, nameCopy, result);
+	    __CFTimeZoneUnlockGlobal();
+	    CFRelease(nameCopy);
+	}
+	CFRelease(data);
+    }
+    return result;
+}
+#elif DEPLOYMENT_TARGET_WINDOWS || 0
+/* Reading GMT offset and daylight flag from the registry
+ * for TimeZone name
+ * (Aleksey Dukhnyakov)
+ */
+    {
+        CFStringRef safeName = name;
+        TIME_ZONE_INFORMATION tzi_system;
+
+        DWORD zoneID = TIME_ZONE_ID_INVALID,
+        dwSize_name1=sizeof(tzi_system.StandardName),
+        dwSize_name2=sizeof(tzi_system.DaylightName);
+
+        if (tryAbbrev) {
+            CFDictionaryRef abbrevs = CFTimeZoneCopyAbbreviationDictionary();
+            tzName = (CFStringRef)CFDictionaryGetValue(abbrevs, name);
+            if (NULL == tzName) {
+                CFRelease(abbrevs);
+                return NULL;
+            }
+            name = tzName;
+            CFRelease(abbrevs);
+        }
+
+/* CFTimeZoneRef->_data will contain TIME_ZONE_INFORMATION structure
+ * to find current timezone
+ * (Aleksey Dukhnyakov)
+ */
+       zoneID = GetTimeZoneInformation(&tzi_system);
+       if (zoneID == TIME_ZONE_ID_INVALID) {
+           return(NULL);
+       }
+       data = CFDataCreate(allocator,(UInt8 *)&tzi_system, sizeof(tzi_system));
+
+       result = CFTimeZoneCreate(allocator, name, data);
+        if (result) {
+            if (tryAbbrev)
+                result->_periods->abbrev = (CFStringRef)CFStringCreateCopy(allocator,safeName);
+        }
+        CFRelease(data);
+    }
+    return result;
+}
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+CFStringRef CFTimeZoneGetName(CFTimeZoneRef tz) {
+    CF_OBJC_FUNCDISPATCH0(CFTimeZoneGetTypeID(), CFStringRef, tz, "name");
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    return tz->_name;
+}
+
+CFDataRef CFTimeZoneGetData(CFTimeZoneRef tz) {
+    CF_OBJC_FUNCDISPATCH0(CFTimeZoneGetTypeID(), CFDataRef, tz, "data");
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    return tz->_data;
+}
+
+/* This function converts CFAbsoluteTime to (Win32) SYSTEMTIME
+ * (Aleksey Dukhnyakov)
+ */
+#if DEPLOYMENT_TARGET_WINDOWS
+BOOL __CFTimeZoneGetWin32SystemTime(SYSTEMTIME * sys_time, CFAbsoluteTime time)
+{
+    LONGLONG l;
+    FILETIME * ftime=(FILETIME*)&l;
+
+    /*  seconds between 1601 and 1970 : 11644473600,
+     *  seconds between 1970 and 2001 : 978307200,
+     *  FILETIME - number of 100-nanosecond intervals since January 1, 1601
+     */
+    l=(LONGLONG)(time+11644473600LL+978307200)*10000000;
+    if (FileTimeToSystemTime(ftime,sys_time))
+        return TRUE;
+    else
+        return FALSE;
+}
+#endif
+
+CFTimeInterval _CFTimeZoneGetDSTOffset(CFTimeZoneRef tz, CFAbsoluteTime at) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+    // #warning this does not work for non-CFTimeZoneRefs
+    CFIndex idx;
+    idx = __CFBSearchTZPeriods(tz, at);
+    // idx 0 is never returned if it is in DST
+    if (__CFTZPeriodIsDST(&(tz->_periods[idx]))) {
+        return __CFTZPeriodGMTOffset(&(tz->_periods[idx])) - __CFTZPeriodGMTOffset(&(tz->_periods[idx - 1]));
+    }
+#endif
+    return 0.0;
+}
+
+// returns 0.0 if there is no data for the next switch after 'at'
+CFAbsoluteTime _CFTimeZoneGetNextDSTSwitch(CFTimeZoneRef tz, CFAbsoluteTime at) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+// #warning this does not work for non-CFTimeZoneRefs
+    CFIndex idx;
+    idx = __CFBSearchTZPeriods(tz, at);
+    if (tz->_periodCnt <= idx + 1) {
+        return 0.0;
+    }
+    return (CFAbsoluteTime)__CFTZPeriodStartSeconds(&(tz->_periods[idx + 1]));
+#endif
+    return 0.0;
+}
+
+CFTimeInterval CFTimeZoneGetSecondsFromGMT(CFTimeZoneRef tz, CFAbsoluteTime at) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+    CFIndex idx;
+    CF_OBJC_FUNCDISPATCH1(CFTimeZoneGetTypeID(), CFTimeInterval, tz, "_secondsFromGMTForAbsoluteTime:", at);
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    idx = __CFBSearchTZPeriods(tz, at);
+    return __CFTZPeriodGMTOffset(&(tz->_periods[idx]));
+#else
+/* To calculate seconds from GMT, calculate current timezone time and
+ * subtract GMT timnezone time
+ * (Aleksey Dukhnyakov)
+ */
+    TIME_ZONE_INFORMATION tzi;
+    FILETIME ftime1,ftime2;
+    SYSTEMTIME stime0,stime1,stime2;
+    LONGLONG * l1= (LONGLONG*)&ftime1;
+    LONGLONG * l2= (LONGLONG*)&ftime2;
+    CFRange range={0,sizeof(TIME_ZONE_INFORMATION)};
+    double result;
+
+    CF_OBJC_FUNCDISPATCH1(__kCFTimeZoneTypeID, CFTimeInterval, tz, "_secondsFromGMTForAbsoluteTime:", at);
+
+    CFDataGetBytes(tz->_data,range,(UInt8*)&tzi);
+
+    if (!__CFTimeZoneGetWin32SystemTime(&stime0,at) ||
+        !SystemTimeToTzSpecificLocalTime(&tzi,&stime0,&stime1) ||
+        !SystemTimeToFileTime(&stime1,&ftime1) )
+    {
+        CFAssert(0, __kCFLogAssertion, "Win32 system time/timezone failed !\n");
+        return 0;
+    }
+
+    tzi.DaylightDate.wMonth=0;
+    tzi.StandardDate.wMonth=0;
+    tzi.StandardBias=0;
+    tzi.DaylightBias=0;
+    tzi.Bias=0;
+
+	if ( !SystemTimeToTzSpecificLocalTime(&tzi,&stime0,&stime2) ||
+            !SystemTimeToFileTime(&stime2,&ftime2))
+    {
+        CFAssert(0, __kCFLogAssertion, "Win32 system time/timezone failed !\n");
+		return 0;
+    }
+    result=(double)((*l1-*l2)/10000000);
+	return result;
+#endif
+}
+
+CFStringRef CFTimeZoneCopyAbbreviation(CFTimeZoneRef tz, CFAbsoluteTime at) {
+    CFStringRef result;
+    CFIndex idx;
+    CF_OBJC_FUNCDISPATCH1(CFTimeZoneGetTypeID(), CFStringRef, tz, "_abbreviationForAbsoluteTime:", at);
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    idx = __CFBSearchTZPeriods(tz, at);
+    result = __CFTZPeriodAbbreviation(&(tz->_periods[idx]));
+    return result ? (CFStringRef)CFRetain(result) : NULL;
+}
+
+Boolean CFTimeZoneIsDaylightSavingTime(CFTimeZoneRef tz, CFAbsoluteTime at) {
+#if !DEPLOYMENT_TARGET_WINDOWS
+    CFIndex idx;
+    CF_OBJC_FUNCDISPATCH1(CFTimeZoneGetTypeID(), Boolean, tz, "_isDaylightSavingTimeForAbsoluteTime:", at);
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    idx = __CFBSearchTZPeriods(tz, at);
+    return __CFTZPeriodIsDST(&(tz->_periods[idx]));
+#else
+/* Compare current timezone time and current timezone time without
+ * transition to day light saving time
+ * (Aleskey Dukhnyakov)
+ */
+    TIME_ZONE_INFORMATION tzi;
+    SYSTEMTIME stime0,stime1,stime2;
+    CFRange range={0,sizeof(TIME_ZONE_INFORMATION)};
+
+    CF_OBJC_FUNCDISPATCH1(__kCFTimeZoneTypeID, Boolean, tz, "_isDaylightSavingTimeForAbsoluteTime:", at);
+
+    CFDataGetBytes(tz->_data,range,(UInt8*)&tzi);
+
+    if (!__CFTimeZoneGetWin32SystemTime(&stime0,at) ||
+        !SystemTimeToTzSpecificLocalTime(&tzi,&stime0,&stime1)) {
+        CFAssert(0, __kCFLogAssertion, "Win32 system time/timezone failed !\n");
+        return FALSE;
+    }
+
+    tzi.DaylightDate.wMonth=0;
+    tzi.StandardDate.wMonth=0;
+
+	if ( !SystemTimeToTzSpecificLocalTime(&tzi,&stime0,&stime2)) {
+        CFAssert(0, __kCFLogAssertion, "Win32 system time/timezone failed !\n");
+		return FALSE;
+    }
+
+    if ( !memcmp(&stime1,&stime2,sizeof(stime1)) )
+        return FALSE;
+
+    return TRUE;
+#endif
+}
+
+CFTimeInterval CFTimeZoneGetDaylightSavingTimeOffset(CFTimeZoneRef tz, CFAbsoluteTime at) {
+    CF_OBJC_FUNCDISPATCH1(CFTimeZoneGetTypeID(), CFTimeInterval, tz, "_daylightSavingTimeOffsetForAbsoluteTime:", at);
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    CFIndex idx = __CFBSearchTZPeriods(tz, at);
+    if (__CFTZPeriodIsDST(&(tz->_periods[idx]))) {
+        CFTimeInterval offset = __CFTZPeriodGMTOffset(&(tz->_periods[idx]));
+        if (idx + 1 < tz->_periodCnt) {
+            return offset - __CFTZPeriodGMTOffset(&(tz->_periods[idx + 1]));
+        } else if (0 < idx) {
+            return offset - __CFTZPeriodGMTOffset(&(tz->_periods[idx - 1]));
+        }
+    }
+    return 0.0;
+}
+
+CFAbsoluteTime CFTimeZoneGetNextDaylightSavingTimeTransition(CFTimeZoneRef tz, CFAbsoluteTime at) {
+    CF_OBJC_FUNCDISPATCH1(CFTimeZoneGetTypeID(), CFTimeInterval, tz, "_nextDaylightSavingTimeTransitionAfterAbsoluteTime:", at);
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    CFIndex idx = __CFBSearchTZPeriods(tz, at);
+    if (tz->_periodCnt <= idx + 1) {
+        return 0.0;
+    }
+    return (CFAbsoluteTime)__CFTZPeriodStartSeconds(&(tz->_periods[idx + 1]));
+}
+
+enum {
+	kCFTimeZoneNameStyleGeneric = 4,
+	kCFTimeZoneNameStyleShortGeneric = 5
+};
+
+extern UCalendar *__CFCalendarCreateUCalendar(CFStringRef calendarID, CFStringRef localeID, CFTimeZoneRef tz);
+
+#define BUFFER_SIZE 768
+
+CFStringRef CFTimeZoneCopyLocalizedName(CFTimeZoneRef tz, CFTimeZoneNameStyle style, CFLocaleRef locale) {
+    CF_OBJC_FUNCDISPATCH2(CFTimeZoneGetTypeID(), CFStringRef, tz, "localizedName:locale:", style, locale);
+    __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
+    __CFGenericValidateType(locale, CFLocaleGetTypeID());
+
+
+    CFStringRef localeID = CFLocaleGetIdentifier(locale);
+    UCalendar *cal = __CFCalendarCreateUCalendar(NULL, localeID, tz);
+    if (NULL == cal) {
+        return NULL;
+    }
+
+    char buffer[BUFFER_SIZE];
+    const char *cstr = CFStringGetCStringPtr(localeID, kCFStringEncodingASCII);
+    if (NULL == cstr) {
+        if (CFStringGetCString(localeID, buffer, BUFFER_SIZE, kCFStringEncodingASCII)) cstr = buffer;
+    }
+    if (NULL == cstr) {
+        ucal_close(cal);
+        return NULL;
+    }
+
+    UChar ubuffer[BUFFER_SIZE];
+    UErrorCode status = U_ZERO_ERROR;
+    int32_t cnt = ucal_getTimeZoneDisplayName(cal, (UCalendarDisplayNameType)style, cstr, ubuffer, BUFFER_SIZE, &status);
+    ucal_close(cal);
+    if (U_SUCCESS(status) && cnt <= BUFFER_SIZE) {
+        return CFStringCreateWithCharacters(CFGetAllocator(tz), (const UniChar *)ubuffer, cnt);
+    }
+    return NULL;
+}
+
+static CFDictionaryRef __CFTimeZoneCopyCompatibilityDictionary(void) {
+    CFDictionaryRef dict;
+    __CFTimeZoneLockCompatibilityMapping();
+    if (NULL == __CFTimeZoneCompatibilityMappingDict) {
+	__CFTimeZoneCompatibilityMappingDict = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 112, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+	// Empty string means delete/ignore these 
+    }
+    dict = __CFTimeZoneCompatibilityMappingDict ? (CFDictionaryRef)CFRetain(__CFTimeZoneCompatibilityMappingDict) : NULL;
+    __CFTimeZoneUnlockCompatibilityMapping();
+    return dict;
+}
+
+#undef TZZONEINFO
+#undef TZZONELINK
+
diff --git a/CoreFoundation/CFTimeZone.h b/CoreFoundation/CFTimeZone.h
new file mode 100644
index 0000000..612e832
--- /dev/null
+++ b/CoreFoundation/CFTimeZone.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFTIMEZONE__)
+#define __COREFOUNDATION_CFTIMEZONE__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFString.h>
+
+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 CFTimeZoneGetDSTOffset(CFTimeZoneRef tz, CFAbsoluteTime at);
+
+CF_EXPORT
+CFAbsoluteTime CFTimeZoneGetNextDSTSwitch(CFTimeZoneRef tz, CFAbsoluteTime at);
+
+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) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+CF_EXPORT
+CFAbsoluteTime CFTimeZoneGetNextDaylightSavingTimeTransition(CFTimeZoneRef tz, CFAbsoluteTime at) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
+enum {
+	kCFTimeZoneNameStyleStandard,
+	kCFTimeZoneNameStyleShortStandard,
+	kCFTimeZoneNameStyleDaylightSaving,
+	kCFTimeZoneNameStyleShortDaylightSaving
+};
+typedef CFIndex CFTimeZoneNameStyle;
+
+CF_EXPORT
+CFStringRef CFTimeZoneCopyLocalizedName(CFTimeZoneRef tz, CFTimeZoneNameStyle style, CFLocaleRef locale) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+#endif
+
+CF_EXPORT
+const CFStringRef kCFTimeZoneSystemTimeZoneDidChangeNotification AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFTIMEZONE__ */
+
diff --git a/CoreFoundation/CFTree.c b/CoreFoundation/CFTree.c
new file mode 100644
index 0000000..663c075
--- /dev/null
+++ b/CoreFoundation/CFTree.c
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include <CoreFoundation/CFTree.h>
+#include "CFInternal.h"
+#include "CFPriv.h"
+
+struct __CFTreeCallBacks {
+    CFTreeRetainCallBack		retain;
+    CFTreeReleaseCallBack		release;	
+    CFTreeCopyDescriptionCallBack	copyDescription;
+};
+
+struct __CFTree {
+    CFRuntimeBase _base;
+    CFTreeRef _parent;	/* Not retained */
+    CFTreeRef _sibling;	/* Not retained */
+    CFTreeRef _child;	/* All children get a retain from the parent */
+    CFTreeRef _rightmostChild;	/* Not retained */
+    /* This is the context, exploded.
+     * Currently the only valid version is 0, so we do not store that.
+     * _callbacks initialized if not a special form. */
+    void *_info;
+    struct __CFTreeCallBacks *_callbacks;
+};
+
+static const struct __CFTreeCallBacks __kCFTypeTreeCallBacks = {CFRetain, CFRelease, CFCopyDescription};
+static const struct __CFTreeCallBacks __kCFNullTreeCallBacks = {NULL, NULL, NULL};
+
+enum {          /* Bits 0-1 */
+    __kCFTreeHasNullCallBacks = 0,
+    __kCFTreeHasCFTypeCallBacks = 1,
+    __kCFTreeHasCustomCallBacks = 3    /* callbacks pointed to by _callbacks */
+};
+
+CF_INLINE uint32_t __CFTreeGetCallBacksType(CFTreeRef tree) {
+    return (__CFBitfieldGetValue(tree->_base._cfinfo[CF_INFO_BITS], 1, 0));
+}
+
+CF_INLINE const struct __CFTreeCallBacks *__CFTreeGetCallBacks(CFTreeRef tree) {
+    switch (__CFTreeGetCallBacksType(tree)) {
+    case __kCFTreeHasNullCallBacks:
+	return &__kCFNullTreeCallBacks;
+    case __kCFTreeHasCFTypeCallBacks:
+	return &__kCFTypeTreeCallBacks;
+    case __kCFTreeHasCustomCallBacks:
+	break;
+    }
+    return tree->_callbacks;
+}
+
+CF_INLINE bool __CFTreeCallBacksMatchNull(const CFTreeContext *c) {
+    return (NULL == c || (c->retain == NULL && c->release == NULL && c->copyDescription == NULL));
+}   
+
+CF_INLINE bool __CFTreeCallBacksMatchCFType(const CFTreeContext *c) {
+    return (NULL != c && (c->retain == CFRetain && c->release == CFRelease && c->copyDescription == CFCopyDescription));
+}   
+
+static CFStringRef __CFTreeCopyDescription(CFTypeRef cf) {
+    CFTreeRef tree = (CFTreeRef)cf;
+    CFMutableStringRef result;
+    CFStringRef contextDesc = NULL;
+    Boolean safeToReleaseContextDesc = true;
+    const struct __CFTreeCallBacks *cb;
+    CFAllocatorRef allocator;
+    allocator = CFGetAllocator(tree);
+    result = CFStringCreateMutable(allocator, 0);
+    cb = __CFTreeGetCallBacks(tree);
+    if (NULL != cb->copyDescription) {
+	contextDesc = (CFStringRef)INVOKE_CALLBACK1(cb->copyDescription, tree->_info);
+	safeToReleaseContextDesc = _CFExecutableLinkedOnOrAfter(CFSystemVersionTiger);    // Because it came from elsewhere, only free it compatibly (3593254)
+    }
+    if (NULL == contextDesc) {
+	contextDesc = CFStringCreateWithFormat(allocator, NULL, CFSTR("<CFTree context %p>"), tree->_info);
+    }
+    CFStringAppendFormat(result, NULL, CFSTR("<CFTree %p [%p]>{children = %u, context = %@}"), cf, allocator, CFTreeGetChildCount(tree), contextDesc);
+    if (contextDesc && safeToReleaseContextDesc) CFRelease(contextDesc);
+    return result;
+}
+
+static void __CFTreeDeallocate(CFTypeRef cf) {
+    CFTreeRef tree = (CFTreeRef)cf;
+    const struct __CFTreeCallBacks *cb;
+    CFAllocatorRef allocator = __CFGetAllocator(tree);
+    if (!CF_IS_COLLECTABLE_ALLOCATOR(allocator)) {
+        // GC:  keep the tree intact during finalization.
+        CFTreeRemoveAllChildren(tree);
+    }
+    cb = __CFTreeGetCallBacks(tree);
+    if (NULL != cb->release) {
+        INVOKE_CALLBACK1(cb->release, tree->_info);
+    }
+    if (__kCFTreeHasCustomCallBacks == __CFTreeGetCallBacksType(tree)) {
+        _CFAllocatorDeallocateGC(CFGetAllocator(tree), tree->_callbacks);
+    }
+}
+
+
+static CFTypeID __kCFTreeTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFTreeClass = {
+    _kCFRuntimeScannedObject,
+    "CFTree",
+    NULL,	// init
+    NULL,	// copy
+    __CFTreeDeallocate,
+    NULL,	// equal
+    NULL,	// hash
+    NULL,	// 
+    __CFTreeCopyDescription
+};
+
+__private_extern__ void __CFTreeInitialize(void) {
+    __kCFTreeTypeID = _CFRuntimeRegisterClass(&__CFTreeClass);
+}
+
+CFTypeID CFTreeGetTypeID(void) {
+    return __kCFTreeTypeID;
+}
+
+CFTreeRef CFTreeCreate(CFAllocatorRef allocator, const CFTreeContext *context) {
+    CFTreeRef memory;
+    uint32_t size;
+
+    CFAssert1(NULL != context, __kCFLogAssertion, "%s(): pointer to context may not be NULL", __PRETTY_FUNCTION__);
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+    size = sizeof(struct __CFTree) - sizeof(CFRuntimeBase);
+    memory = (CFTreeRef)_CFRuntimeCreateInstance(allocator, __kCFTreeTypeID, size, NULL);
+    if (NULL == memory) {
+	return NULL;
+    }
+    memory->_parent = NULL;
+    memory->_sibling = NULL;
+    memory->_child = NULL;
+    memory->_rightmostChild = NULL;
+
+    /* Start the context off in a recognizable state */
+    __CFBitfieldSetValue(memory->_base._cfinfo[CF_INFO_BITS], 1, 0, __kCFTreeHasNullCallBacks);
+    CFTreeSetContext(memory, context);
+    return memory;
+}
+
+CFIndex CFTreeGetChildCount(CFTreeRef tree) {
+    SInt32 cnt = 0;
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    tree = tree->_child;
+    while (NULL != tree) {
+	cnt++;
+	tree = tree->_sibling;
+    }
+    return cnt;
+}
+
+CFTreeRef CFTreeGetParent(CFTreeRef tree) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    return tree->_parent;
+}
+
+CFTreeRef CFTreeGetNextSibling(CFTreeRef tree) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    return tree->_sibling;
+}
+
+CFTreeRef CFTreeGetFirstChild(CFTreeRef tree) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    return tree->_child;
+}
+
+CFTreeRef CFTreeFindRoot(CFTreeRef tree) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    while (NULL != tree->_parent) {
+	tree = tree->_parent;
+    }
+    return tree;
+}
+
+void CFTreeGetContext(CFTreeRef tree, CFTreeContext *context) {
+    const struct __CFTreeCallBacks *cb;
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
+    cb = __CFTreeGetCallBacks(tree);
+    context->version = 0;
+    context->info = tree->_info;
+    context->retain = cb->retain;
+    context->release = cb->release;
+    context->copyDescription = cb->copyDescription;
+    UNFAULT_CALLBACK(context->retain);
+    UNFAULT_CALLBACK(context->release);
+    UNFAULT_CALLBACK(context->copyDescription);
+}
+
+void CFTreeSetContext(CFTreeRef tree, const CFTreeContext *context) {
+    uint32_t newtype, oldtype = __CFTreeGetCallBacksType(tree);
+    struct __CFTreeCallBacks *oldcb = (struct __CFTreeCallBacks *)__CFTreeGetCallBacks(tree);
+    struct __CFTreeCallBacks *newcb;
+    void *oldinfo = tree->_info;
+    CFAllocatorRef allocator = CFGetAllocator(tree);
+    
+    if (__CFTreeCallBacksMatchNull(context)) {
+        newtype = __kCFTreeHasNullCallBacks;
+    } else if (__CFTreeCallBacksMatchCFType(context)) {
+        newtype = __kCFTreeHasCFTypeCallBacks;
+    } else {
+        newtype = __kCFTreeHasCustomCallBacks;
+        CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_callbacks, _CFAllocatorAllocateGC(allocator, sizeof(struct __CFTreeCallBacks), 0));
+        if (__CFOASafe) __CFSetLastAllocationEventName(tree->_callbacks, "CFTree (callbacks)");
+        tree->_callbacks->retain = context->retain;
+        tree->_callbacks->release = context->release;
+        tree->_callbacks->copyDescription = context->copyDescription;
+        FAULT_CALLBACK((void **)&(tree->_callbacks->retain));
+        FAULT_CALLBACK((void **)&(tree->_callbacks->release));
+        FAULT_CALLBACK((void **)&(tree->_callbacks->copyDescription));
+    }
+    __CFBitfieldSetValue(tree->_base._cfinfo[CF_INFO_BITS], 1, 0, newtype);
+    newcb = (struct __CFTreeCallBacks *)__CFTreeGetCallBacks(tree);
+    if (NULL != newcb->retain) {
+        tree->_info = (void *)INVOKE_CALLBACK1(newcb->retain, context->info);
+    } else {
+        CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_info, context->info);
+    }
+    if (NULL != oldcb->release) {
+        INVOKE_CALLBACK1(oldcb->release, oldinfo);
+    }
+    if (oldtype == __kCFTreeHasCustomCallBacks) {
+        _CFAllocatorDeallocateGC(allocator, oldcb);
+    }
+}
+
+#if 0
+CFTreeRef CFTreeFindNextSibling(CFTreeRef tree, const void *info) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    tree = tree->_sibling;
+    while (NULL != tree) {
+	if (info == tree->_context.info || (tree->_context.equal && tree->_context.equal(info, tree->_context.info))) {
+	    return tree;
+	}
+	tree = tree->_sibling;
+    }
+    return NULL;
+}
+
+CFTreeRef CFTreeFindFirstChild(CFTreeRef tree, const void *info) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    tree = tree->_child;
+    while (NULL != tree) {
+	if (info == tree->_context.info || (tree->_context.equal && tree->_context.equal(info, tree->_context.info))) {
+	    return tree;
+	}
+	tree = tree->_sibling;
+    }
+    return NULL;
+}
+
+CFTreeRef CFTreeFind(CFTreeRef tree, const void *info) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    if (info == tree->_context.info || (tree->_context.equal && tree->_context.equal(info, tree->info))) {
+	return tree;
+    }
+    tree = tree->_child;
+    while (NULL != tree) {
+	CFTreeRef found = CFTreeFind(tree, info);
+	if (NULL != found) {
+	    return found;
+	}
+	tree = tree->_sibling;
+    }
+    return NULL;
+}
+#endif
+
+CFTreeRef CFTreeGetChildAtIndex(CFTreeRef tree, CFIndex idx) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    tree = tree->_child;
+    while (NULL != tree) {
+	if (0 == idx) return tree;
+	idx--;
+	tree = tree->_sibling;
+    }
+    return NULL;
+}
+
+void CFTreeGetChildren(CFTreeRef tree, CFTreeRef *children) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    tree = tree->_child;
+    while (NULL != tree) {
+	*children++ = tree;
+	tree = tree->_sibling;
+    }
+}
+
+void CFTreeApplyFunctionToChildren(CFTreeRef tree, CFTreeApplierFunction applier, void *context) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    CFAssert1(NULL != applier, __kCFLogAssertion, "%s(): pointer to applier function may not be NULL", __PRETTY_FUNCTION__);
+    tree = tree->_child;
+    while (NULL != tree) {
+	applier(tree, context);
+	tree = tree->_sibling;
+    }
+}
+
+void CFTreePrependChild(CFTreeRef tree, CFTreeRef newChild) {
+    CFAllocatorRef allocator = CFGetAllocator(tree);
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    __CFGenericValidateType(newChild, __kCFTreeTypeID);
+    CFAssert1(NULL == newChild->_parent, __kCFLogAssertion, "%s(): must remove newChild from previous parent first", __PRETTY_FUNCTION__);
+    CFAssert1(NULL == newChild->_sibling, __kCFLogAssertion, "%s(): must remove newChild from previous parent first", __PRETTY_FUNCTION__);
+    _CFRetainGC(newChild);
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, newChild, newChild->_parent, tree);
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, newChild, newChild->_sibling, tree->_child);
+    if (!tree->_child) {
+        CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_rightmostChild, newChild);
+    }
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_child, newChild);
+}
+
+void CFTreeAppendChild(CFTreeRef tree, CFTreeRef newChild) {
+    CFAllocatorRef allocator;
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    __CFGenericValidateType(newChild, __kCFTreeTypeID);
+    CFAssert1(NULL == newChild->_parent, __kCFLogAssertion, "%s(): must remove newChild from previous parent first", __PRETTY_FUNCTION__);
+    CFAssert1(NULL == newChild->_sibling, __kCFLogAssertion, "%s(): must remove newChild from previous parent first", __PRETTY_FUNCTION__);
+    if (newChild->_parent) {
+        HALT;
+    }
+    _CFRetainGC(newChild);
+    allocator = CFGetAllocator(tree);
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, newChild, newChild->_parent, tree);
+    newChild->_sibling = NULL;
+    if (!tree->_child) {
+        CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_child, newChild);
+    } else {
+        CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree->_rightmostChild, tree->_rightmostChild->_sibling, newChild);
+    }
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_rightmostChild, newChild);
+}
+
+void CFTreeInsertSibling(CFTreeRef tree, CFTreeRef newSibling) {
+    CFAllocatorRef allocator;
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    __CFGenericValidateType(newSibling, __kCFTreeTypeID);
+    CFAssert1(NULL != tree->_parent, __kCFLogAssertion, "%s(): tree must have a parent", __PRETTY_FUNCTION__);
+    CFAssert1(NULL == newSibling->_parent, __kCFLogAssertion, "%s(): must remove newSibling from previous parent first", __PRETTY_FUNCTION__);
+    CFAssert1(NULL == newSibling->_sibling, __kCFLogAssertion, "%s(): must remove newSibling from previous parent first", __PRETTY_FUNCTION__);
+    _CFRetainGC(newSibling);
+    allocator = CFGetAllocator(tree);
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, newSibling, newSibling->_parent, tree->_parent);
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, newSibling, newSibling->_sibling, tree->_sibling);
+    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_sibling, newSibling);
+    if (tree->_parent) {
+        if (tree->_parent->_rightmostChild == tree) {
+            CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree->_parent, tree->_parent->_rightmostChild, newSibling);
+        }
+    }
+}
+
+void CFTreeRemove(CFTreeRef tree) {
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    if (NULL != tree->_parent) {
+        CFAllocatorRef allocator = CFGetAllocator(tree);
+	if (tree == tree->_parent->_child) {
+            CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree->_parent, tree->_parent->_child, tree->_sibling);
+            if (tree->_sibling == NULL) {
+                tree->_parent->_rightmostChild = NULL;
+            }
+	} else {
+	    CFTreeRef prevSibling = NULL;
+	    for (prevSibling = tree->_parent->_child; prevSibling; prevSibling = prevSibling->_sibling) {
+		if (prevSibling->_sibling == tree) {
+                    CF_WRITE_BARRIER_BASE_ASSIGN(allocator, prevSibling, prevSibling->_sibling, tree->_sibling);
+                    if (tree->_parent->_rightmostChild == tree) {
+                        CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree->_parent, tree->_parent->_rightmostChild, prevSibling);
+                    }
+		    break;
+		}
+	    }
+	}
+	tree->_parent = NULL;
+	tree->_sibling = NULL;
+        _CFReleaseGC(tree);
+    }
+}
+
+void CFTreeRemoveAllChildren(CFTreeRef tree) {
+    CFTreeRef nextChild;
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    nextChild = tree->_child;
+    tree->_child = NULL;
+    tree->_rightmostChild = NULL;
+    while (NULL != nextChild) {
+	CFTreeRef nextSibling = nextChild->_sibling;
+	nextChild->_parent = NULL;
+	nextChild->_sibling = NULL;
+	_CFReleaseGC(nextChild);
+	nextChild = nextSibling;
+    }
+}
+
+struct _tcompareContext {
+    CFComparatorFunction func;
+    void *context;
+};
+
+static CFComparisonResult __CFTreeCompareValues(const void *v1, const void *v2, struct _tcompareContext *context) {
+    const void **val1 = (const void **)v1;
+    const void **val2 = (const void **)v2;
+    return (CFComparisonResult)(INVOKE_CALLBACK3(context->func, *val1, *val2, context->context));
+}
+
+void CFTreeSortChildren(CFTreeRef tree, CFComparatorFunction comparator, void *context) {
+    CFIndex children;
+    __CFGenericValidateType(tree, __kCFTreeTypeID);
+    CFAssert1(NULL != comparator, __kCFLogAssertion, "%s(): pointer to comparator function may not be NULL", __PRETTY_FUNCTION__);
+    children = CFTreeGetChildCount(tree);
+    if (1 < children) {
+        CFIndex idx;
+        CFTreeRef nextChild;
+        struct _tcompareContext ctx;
+        CFTreeRef *list, buffer[128];
+        CFAllocatorRef allocator = __CFGetAllocator(tree);
+
+        list = (children < 128) ? buffer : (CFTreeRef *)CFAllocatorAllocate(kCFAllocatorSystemDefault, children * sizeof(CFTreeRef), 0); // XXX_PCB GC OK
+	if (__CFOASafe && list != buffer) __CFSetLastAllocationEventName(tree->_callbacks, "CFTree (temp)");
+        nextChild = tree->_child;
+        for (idx = 0; NULL != nextChild; idx++) {
+            list[idx] = nextChild;
+            nextChild = nextChild->_sibling;
+        }
+
+        ctx.func = comparator;
+        ctx.context = context;
+        CFQSortArray(list, children, sizeof(CFTreeRef), (CFComparatorFunction)__CFTreeCompareValues, &ctx);
+
+        CF_WRITE_BARRIER_BASE_ASSIGN(allocator, tree, tree->_child, list[0]);
+        for (idx = 1; idx < children; idx++) {
+            CF_WRITE_BARRIER_BASE_ASSIGN(allocator, list[idx - 1], list[idx - 1]->_sibling, list[idx]);
+        }
+        list[idx - 1]->_sibling = NULL;
+        tree->_rightmostChild = list[children - 1];
+        if (list != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, list); // XXX_PCB GC OK
+    }
+}
+
diff --git a/CoreFoundation/CFTree.h b/CoreFoundation/CFTree.h
new file mode 100644
index 0000000..882c665
--- /dev/null
+++ b/CoreFoundation/CFTree.h
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+
+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
+
+#endif /* ! __COREFOUNDATION_CFTREE__ */
+
diff --git a/CoreFoundation/CFURL.c b/CoreFoundation/CFURL.c
new file mode 100644
index 0000000..db5a250
--- /dev/null
+++ b/CoreFoundation/CFURL.c
@@ -0,0 +1,4232 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2004, Apple, Inc. All rights reserved.
+	Responsibility: Becky Willrich
+*/
+
+#include <CoreFoundation/CFURL.h>
+#include "CFPriv.h"
+#include "CFCharacterSetPriv.h"
+#include <CoreFoundation/CFNumber.h>
+#include "CFInternal.h"
+#include "CFStringEncodingConverter.h"
+#include "CFPriv.h"
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#if DEPLOYMENT_TARGET_MACOSX
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
+
+static CFArrayRef WindowsPathToURLComponents(CFStringRef path, CFAllocatorRef alloc, Boolean isDir);
+static CFStringRef WindowsPathToURLPath(CFStringRef path, CFAllocatorRef alloc, Boolean isDir);
+static CFStringRef POSIXPathToURLPath(CFStringRef path, CFAllocatorRef alloc, Boolean isDirectory);
+CFStringRef CFURLCreateStringWithFileSystemPath(CFAllocatorRef allocator, CFURLRef anURL, CFURLPathStyle fsType, Boolean resolveAgainstBase);
+extern CFURLRef _CFURLCreateCurrentDirectoryURL(CFAllocatorRef allocator);
+
+#if DEPLOYMENT_TARGET_MACOSX
+static CFArrayRef HFSPathToURLComponents(CFStringRef path, CFAllocatorRef alloc, Boolean isDir);
+
+DEFINE_WEAK_CARBONCORE_FUNC(void, DisposeHandle, (Handle A), (A))
+DEFINE_WEAK_CARBONCORE_FUNC(OSErr, FSNewAlias, (const FSRef *A, const FSRef *B, AliasHandle *C), (A, B, C), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(OSErr, FSGetVolumeInfo, (FSVolumeRefNum A, ItemCount B, FSVolumeRefNum *C, FSVolumeInfoBitmap D, FSVolumeInfo *E, HFSUniStr255*F, FSRef *G), (A, B, C, D, E, F, G), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(OSErr, FSGetCatalogInfo, (const FSRef *A, FSCatalogInfoBitmap B, FSCatalogInfo *C, HFSUniStr255 *D, FSSpec *E, FSRef *F), (A, B, C, D, E, F), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(OSErr, FSMakeFSRefUnicode, (const FSRef *A, UniCharCount B, const UniChar *C, TextEncoding D, FSRef *E), (A, B, C, D, E), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(OSStatus, FSPathMakeRef, (const uint8_t *A, FSRef *B, Boolean *C), (A, B, C), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(OSStatus, FSRefMakePath, (const FSRef *A, uint8_t *B, UInt32 C), (A, B, C), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(OSErr, FSpMakeFSRef, (const FSSpec *A, FSRef *B), (A, B), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(Size, GetAliasSizeFromPtr, (AliasPtr A), (A), 0)
+DEFINE_WEAK_CARBONCORE_FUNC(OSErr, _FSGetFSRefInformationFast, (const FSRef* A, SInt16 *B, UInt32 *C, UInt32 *D, Boolean *E, Boolean *F, HFSUniStr255 *G), (A, B, C, D, E, F, G), -3296)
+DEFINE_WEAK_CARBONCORE_FUNC(OSErr, _FSGetVolumeByName, ( CFStringRef volumeNameRef, FSVolumeRefNum* vRefNumP), ( volumeNameRef, vRefNumP), -3296 )
+
+#elif DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX || 0
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+
+#ifndef DEBUG_URL_MEMORY_USAGE
+#define DEBUG_URL_MEMORY_USAGE 0
+#endif
+
+#if DEBUG_URL_MEMORY_USAGE
+static CFAllocatorRef URLAllocator = NULL;
+static UInt32 numFileURLsCreated = 0;
+static UInt32 numFileURLsConverted = 0;
+static UInt32 numFileURLsDealloced = 0;
+static UInt32 numURLs = 0;
+static UInt32 numDealloced = 0;
+static UInt32 numExtraDataAllocated = 0;
+static UInt32 numURLsWithBaseURL = 0;
+#endif
+
+/* The bit flags in myURL->_flags */
+#define HAS_SCHEME      (0x0001)
+#define HAS_USER        (0x0002)
+#define HAS_PASSWORD    (0x0004)
+#define HAS_HOST        (0x0008)
+#define HAS_PORT        (0x0010)
+#define HAS_PATH        (0x0020)
+#define HAS_PARAMETERS  (0x0040)
+#define HAS_QUERY       (0x0080)
+#define HAS_FRAGMENT    (0x0100)
+#define HAS_HTTP_SCHEME (0x0200)
+// Last free bit (0x200) in lower word goes here!
+#define IS_IPV6_ENCODED (0x0400)
+#define IS_OLD_UTF8_STYLE (0x0800)
+#define IS_DIRECTORY    (0x1000)
+#define IS_PARSED       (0x2000)
+#define IS_ABSOLUTE     (0x4000)
+#define IS_DECOMPOSABLE (0x8000)
+
+#define PATH_TYPE_MASK                 (0x000F0000)
+/* POSIX_AND_URL_PATHS_MATCH will only be true if the URL and POSIX paths are identical, character for character, except for the presence/absence of a trailing slash on directories */
+#define POSIX_AND_URL_PATHS_MATCH      (0x00100000)
+#define ORIGINAL_AND_URL_STRINGS_MATCH (0x00200000)
+
+/* If ORIGINAL_AND_URL_STRINGS_MATCH is false, these bits determine where they differ */
+// Scheme can actually never differ because if there were escaped characters prior to the colon, we'd interpret the string as a relative path
+//	#define SCHEME_DIFFERS     (0x00400000)	unused
+#define USER_DIFFERS       (0x00800000)
+#define PASSWORD_DIFFERS   (0x01000000)
+#define HOST_DIFFERS       (0x02000000)
+// Port can actually never differ because if there were a non-digit following a colon in the net location, we'd interpret the whole net location as the host 
+#define PORT_DIFFERS       (0x04000000)
+//	#define PATH_DIFFERS       (0x08000000)	unused
+// #define PARAMETERS_DIFFER  (0x10000000)	unused
+// #define QUERY_DIFFERS      (0x20000000)	unused
+// #define FRAGMENT_DIFfERS   (0x40000000)	unused
+#define HAS_FILE_SCHEME		(0x80000000)
+
+// Number of bits to shift to get from HAS_FOO to FOO_DIFFERS flag
+#define BIT_SHIFT_FROM_COMPONENT_TO_DIFFERS_FLAG (22)
+
+// Other useful defines
+#define NET_LOCATION_MASK (HAS_HOST | HAS_USER | HAS_PASSWORD | HAS_PORT)
+#define RESOURCE_SPECIFIER_MASK  (HAS_PARAMETERS | HAS_QUERY | HAS_FRAGMENT)
+#define FULL_URL_REPRESENTATION (0xF)
+
+/* URL_PATH_TYPE(anURL) will be one of the CFURLPathStyle constants, in which case string is a file system path, or will be FULL_URL_REPRESENTATION, in which case the string is the full URL string. One caveat - string always has a trailing path delimiter if the url is a directory URL.  This must be stripped before returning file system representations!  */
+#define URL_PATH_TYPE(url) (((url->_flags) & PATH_TYPE_MASK) >> 16)
+#define PATH_DELIM_FOR_TYPE(fsType) ((fsType) == kCFURLHFSPathStyle ? ':' : (((fsType) == kCFURLWindowsPathStyle) ? '\\' : '/'))
+#define PATH_DELIM_AS_STRING_FOR_TYPE(fsType) ((fsType) == kCFURLHFSPathStyle ? CFSTR(":") : (((fsType) == kCFURLWindowsPathStyle) ? CFSTR("\\") : CFSTR("/")))
+
+
+//	In order to get the sizeof ( __CFURL ) < 32 bytes, move these items into a seperate structure which is
+//	only allocated when necessary.  In my tests, it's almost never needed -- very rarely does a CFURL have
+//	either a sanitized string or a reserved pointer for URLHandle.
+struct _CFURLAdditionalData {
+    void *_reserved; // Reserved for URLHandle's use.
+    CFMutableStringRef _sanitizedString; // The fully compliant RFC string.  This is only non-NULL if ORIGINAL_AND_URL_STRINGS_MATCH is false.  This should never be mutated except when the sanatized string is first computed
+};
+
+struct __CFURL {
+    CFRuntimeBase _cfBase;
+    UInt32 _flags;
+    CFStringRef  _string; // Never NULL; the meaning of _string depends on URL_PATH_TYPE(myURL) (see above)
+	CFURLRef	_base;
+    CFRange *ranges;
+    CFStringEncoding _encoding; // The encoding to use when asked to remove percent escapes; this is never consulted if IS_OLD_UTF8_STYLE is set.
+	struct _CFURLAdditionalData* extra;
+};
+
+
+CF_INLINE void* _getReserved ( const struct __CFURL* url )
+{
+	if ( url && url->extra )
+			return url->extra->_reserved;
+
+	return NULL;
+}
+
+CF_INLINE CFMutableStringRef _getSanitizedString ( const struct __CFURL* url )
+{
+	if ( url && url->extra )
+		return url->extra->_sanitizedString;
+
+	return NULL;
+}
+
+static void _CFURLAllocateExtraDataspace( struct __CFURL* url )
+{	
+	if ( url && ! url->extra )
+	{	struct _CFURLAdditionalData* extra = (struct _CFURLAdditionalData*) CFAllocatorAllocate( CFGetAllocator( url), sizeof( struct _CFURLAdditionalData ), __kCFAllocatorGCScannedMemory);
+	
+		extra->_reserved = _getReserved( url );
+		extra->_sanitizedString = _getSanitizedString( url );
+		
+		url->extra = extra;
+		
+		#if DEBUG_URL_MEMORY_USAGE
+		numExtraDataAllocated ++;
+		#endif
+	}
+}
+
+CF_INLINE void _setReserved ( struct __CFURL* url, void* reserved )
+{
+	if ( url )
+	{
+		//	Don't allocate extra space if we're just going to be storing NULL
+		if ( ! url->extra && reserved )
+			_CFURLAllocateExtraDataspace( url );
+		
+		if ( url->extra )
+			CF_WRITE_BARRIER_BASE_ASSIGN(CFGetAllocator(url), url->extra, url->extra->_reserved, reserved);
+	}
+}
+
+CF_INLINE void _setSanitizedString ( struct __CFURL* url, CFMutableStringRef sanitizedString )
+{
+	if ( url )
+	{
+		//	Don't allocate extra space if we're just going to be storing NULL
+		if ( ! url->extra && sanitizedString )
+			_CFURLAllocateExtraDataspace( url );
+		
+		if ( url->extra )
+			url->extra->_sanitizedString = sanitizedString;
+	}
+}
+
+static void _convertToURLRepresentation(struct __CFURL *url);
+static CFURLRef _CFURLCopyAbsoluteFileURL(CFURLRef relativeURL);
+static CFStringRef _resolveFileSystemPaths(CFStringRef relativePath, CFStringRef basePath, Boolean baseIsDir, CFURLPathStyle fsType, CFAllocatorRef alloc);
+static void _parseComponents(CFAllocatorRef alloc, CFStringRef string, CFURLRef base, UInt32 *flags, CFRange **range);
+static CFRange _rangeForComponent(UInt32 flags, CFRange *ranges, UInt32 compFlag);
+static CFRange _netLocationRange(UInt32 flags, CFRange *ranges);
+static UInt32 _firstResourceSpecifierFlag(UInt32 flags);
+static void computeSanitizedString(CFURLRef url);
+static CFStringRef correctedComponent(CFStringRef component, UInt32 compFlag, CFStringEncoding enc);
+static CFMutableStringRef resolveAbsoluteURLString(CFAllocatorRef alloc, CFStringRef relString, UInt32 relFlags, CFRange *relRanges, CFStringRef baseString, UInt32 baseFlags, CFRange *baseRanges);
+static CFStringRef _resolvedPath(UniChar *pathStr, UniChar *end, UniChar pathDelimiter, Boolean stripLeadingDotDots, Boolean stripTrailingDelimiter, CFAllocatorRef alloc);
+
+
+CF_INLINE void _parseComponentsOfURL(CFURLRef url) {
+    _parseComponents(CFGetAllocator(url), url->_string, url->_base, &(((struct __CFURL *)url)->_flags), &(((struct __CFURL *)url)->ranges));
+}
+
+static Boolean _createOldUTF8StyleURLs = false;
+
+CF_INLINE Boolean createOldUTF8StyleURLs(void) {
+    return (_createOldUTF8StyleURLs);
+}
+
+// Our backdoor in case removing the UTF8 constraint for URLs creates unexpected problems.  See radar 2902530 -- REW
+CF_EXPORT
+void _CFURLCreateOnlyUTF8CompatibleURLs(Boolean createUTF8URLs) {
+    _createOldUTF8StyleURLs = createUTF8URLs;
+}
+
+enum {
+	VALID = 1,
+	UNRESERVED = 2,
+	PATHVALID = 4,
+	SCHEME = 8,
+	HEXDIGIT = 16
+};
+
+static const unsigned char sURLValidCharacters[] = {
+	/* ' '  32 */   0,
+	/* '!'  33 */   VALID | UNRESERVED | PATHVALID ,
+	/* '"'  34 */   0,
+	/* '#'  35 */   0,
+	/* '$'  36 */   VALID | PATHVALID ,
+	/* '%'  37 */   0,
+	/* '&'  38 */   VALID | PATHVALID ,
+	/* '''  39 */   VALID | UNRESERVED | PATHVALID ,
+	/* '('  40 */   VALID | UNRESERVED | PATHVALID ,
+	/* ')'  41 */   VALID | UNRESERVED | PATHVALID ,
+	/* '*'  42 */   VALID | UNRESERVED | PATHVALID ,
+	/* '+'  43 */   VALID | SCHEME | PATHVALID ,
+	/* ','  44 */   VALID | PATHVALID ,
+	/* '-'  45 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* '.'  46 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* '/'  47 */   VALID | PATHVALID ,
+	/* '0'  48 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '1'  49 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '2'  50 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '3'  51 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '4'  52 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '5'  53 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '6'  54 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '7'  55 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '8'  56 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* '9'  57 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* ':'  58 */   VALID ,
+	/* ';'  59 */   VALID ,
+	/* '<'  60 */   0,
+	/* '='  61 */   VALID | PATHVALID ,
+	/* '>'  62 */   0,
+	/* '?'  63 */   VALID ,
+	/* '@'  64 */   VALID | PATHVALID ,
+	/* 'A'  65 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'B'  66 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'C'  67 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'D'  68 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'E'  69 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'F'  70 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'G'  71 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'H'  72 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'I'  73 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'J'  74 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'K'  75 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'L'  76 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'M'  77 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'N'  78 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'O'  79 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'P'  80 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'Q'  81 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'R'  82 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'S'  83 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'T'  84 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'U'  85 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'V'  86 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'W'  87 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'X'  88 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'Y'  89 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'Z'  90 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* '['  91 */   0,
+	/* '\'  92 */   0,
+	/* ']'  93 */   0,
+	/* '^'  94 */   0,
+	/* '_'  95 */   VALID | UNRESERVED | PATHVALID ,
+	/* '`'  96 */   0,
+	/* 'a'  97 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'b'  98 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'c'  99 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'd' 100 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'e' 101 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'f' 102 */   VALID | UNRESERVED | SCHEME | PATHVALID | HEXDIGIT ,
+	/* 'g' 103 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'h' 104 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'i' 105 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'j' 106 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'k' 107 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'l' 108 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'm' 109 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'n' 110 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'o' 111 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'p' 112 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'q' 113 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'r' 114 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 's' 115 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 't' 116 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'u' 117 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'v' 118 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'w' 119 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'x' 120 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'y' 121 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* 'z' 122 */   VALID | UNRESERVED | SCHEME | PATHVALID ,
+	/* '{' 123 */   0,
+	/* '|' 124 */   0,
+	/* '}' 125 */   0,
+	/* '~' 126 */   VALID | UNRESERVED | PATHVALID ,
+	/* '' 127 */    0
+};
+
+CF_INLINE Boolean isURLLegalCharacter(UniChar ch) {
+	return ( ( 32 <= ch ) && ( ch <= 127 ) ) ? ( sURLValidCharacters[ ch - 32 ] & VALID ) : false;
+}
+
+CF_INLINE Boolean scheme_valid(UniChar ch) {
+	return ( ( 32 <= ch ) && ( ch <= 127 ) ) ? ( sURLValidCharacters[ ch - 32 ] & SCHEME ) : false;
+}
+
+// "Unreserved" as defined by RFC 2396
+CF_INLINE Boolean isUnreservedCharacter(UniChar ch) {
+	return ( ( 32 <= ch ) && ( ch <= 127 ) ) ? ( sURLValidCharacters[ ch - 32 ] & UNRESERVED ) : false;
+}
+
+CF_INLINE Boolean isPathLegalCharacter(UniChar ch) {
+	return ( ( 32 <= ch ) && ( ch <= 127 ) ) ? ( sURLValidCharacters[ ch - 32 ] & PATHVALID ) : false;
+}
+
+CF_INLINE Boolean isHexDigit(UniChar ch) {
+	return ( ( 32 <= ch ) && ( ch <= 127 ) ) ? ( sURLValidCharacters[ ch - 32 ] & HEXDIGIT ) : false;
+}
+
+// Returns false if ch1 or ch2 isn't properly formatted
+CF_INLINE Boolean _translateBytes(UniChar ch1, UniChar ch2, uint8_t *result) {
+    *result = 0;
+    if (ch1 >= '0' && ch1 <= '9') *result += (ch1 - '0');
+    else if (ch1 >= 'a' && ch1 <= 'f') *result += 10 + ch1 - 'a';
+    else if (ch1 >= 'A' && ch1 <= 'F') *result += 10 + ch1 - 'A';
+    else return false;
+
+    *result  = (*result) << 4;
+    if (ch2 >= '0' && ch2 <= '9') *result += (ch2 - '0');
+    else if (ch2 >= 'a' && ch2 <= 'f') *result += 10 + ch2 - 'a';
+    else if (ch2 >= 'A' && ch2 <= 'F') *result += 10 + ch2 - 'A';
+    else return false;
+
+    return true;
+}
+
+CF_INLINE Boolean _haveTestedOriginalString(CFURLRef url) {
+    return ((url->_flags & ORIGINAL_AND_URL_STRINGS_MATCH) != 0) || (_getSanitizedString(url) != NULL);
+}
+
+typedef CFStringRef (*StringTransformation)(CFAllocatorRef, CFStringRef, CFIndex);
+static CFArrayRef copyStringArrayWithTransformation(CFArrayRef array, StringTransformation transformation) {
+    CFAllocatorRef alloc = CFGetAllocator(array);
+    CFMutableArrayRef mArray = NULL;
+    CFIndex i, c = CFArrayGetCount(array);
+    for (i = 0; i < c; i ++) {
+        CFStringRef origComp = (CFStringRef)CFArrayGetValueAtIndex(array, i);
+        CFStringRef unescapedComp = transformation(alloc, origComp, i);
+        if (!unescapedComp) { 
+            break;
+        }
+        if (unescapedComp != origComp) {
+            if (!mArray) {
+                mArray = CFArrayCreateMutableCopy(alloc, c, array);
+            }
+            CFArraySetValueAtIndex(mArray, i, unescapedComp);
+        }
+        CFRelease(unescapedComp);
+    }
+    if (i != c) {
+        if (mArray) CFRelease(mArray);
+        return NULL;
+    } else if (mArray) {
+        return mArray;
+    } else {
+        CFRetain(array);
+        return array;
+    }
+}
+
+// Returns NULL if str cannot be converted for whatever reason, str if str contains no characters in need of escaping, or a newly-created string with the appropriate % escape codes in place.  Caller must always release the returned string.
+CF_INLINE CFStringRef _replacePathIllegalCharacters(CFStringRef str, CFAllocatorRef alloc, Boolean preserveSlashes) {
+    if (preserveSlashes) {
+        return CFURLCreateStringByAddingPercentEscapes(alloc, str, NULL, CFSTR(";?"), kCFStringEncodingUTF8);
+    } else {
+        return CFURLCreateStringByAddingPercentEscapes(alloc, str, NULL, CFSTR(";?/"), kCFStringEncodingUTF8);
+    }        
+}
+
+static CFStringRef escapePathComponent(CFAllocatorRef alloc, CFStringRef origComponent, CFIndex componentIndex) {
+    return CFURLCreateStringByAddingPercentEscapes(alloc, origComponent, NULL, CFSTR(";?/"), kCFStringEncodingUTF8);
+}
+
+// We have 2 UniChars of a surrogate; we must convert to the correct percent-encoded UTF8 string and append to str.  Added so that file system URLs can always be converted from POSIX to full URL representation.  -- REW, 8/20/2001
+static Boolean _hackToConvertSurrogates(UniChar highChar, UniChar lowChar, CFMutableStringRef str) {
+    UniChar surrogate[2];
+    uint8_t bytes[6]; // Aki sez it should never take more than 6 bytes
+    CFIndex len; 
+    uint8_t *currByte;
+    surrogate[0] = highChar;
+    surrogate[1] = lowChar;
+    if (CFStringEncodingUnicodeToBytes(kCFStringEncodingUTF8, 0, surrogate, 2, NULL, bytes, 6, &len) != kCFStringEncodingConversionSuccess) {
+        return false;
+    }
+    for (currByte = bytes; currByte < bytes + len; currByte ++) {
+        UniChar escapeSequence[3] = {'%', '\0', '\0'};
+        unsigned char high, low;
+        high = ((*currByte) & 0xf0) >> 4;
+        low = (*currByte) & 0x0f;
+        escapeSequence[1] = (high < 10) ? '0' + high : 'A' + high - 10;
+        escapeSequence[2] = (low < 10) ? '0' + low : 'A' + low - 10;
+        CFStringAppendCharacters(str, escapeSequence, 3);
+    }
+    return true;
+}
+
+static Boolean _appendPercentEscapesForCharacter(UniChar ch, CFStringEncoding encoding, CFMutableStringRef str) {
+    uint8_t bytes[6]; // 6 bytes is the maximum a single character could require in UTF8 (most common case); other encodings could require more
+    uint8_t *bytePtr = bytes, *currByte;
+    CFIndex byteLength;
+    CFAllocatorRef alloc = NULL;
+    if (CFStringEncodingUnicodeToBytes(encoding, 0, &ch, 1, NULL, bytePtr, 6, &byteLength) != kCFStringEncodingConversionSuccess) {
+        byteLength = CFStringEncodingByteLengthForCharacters(encoding, 0, &ch, 1);
+        if (byteLength <= 6) {
+            // The encoding cannot accomodate the character
+            return false;
+        }
+        alloc = CFGetAllocator(str);
+        bytePtr = (uint8_t *)CFAllocatorAllocate(alloc, byteLength, 0);
+        if (!bytePtr || CFStringEncodingUnicodeToBytes(encoding, 0, &ch, 1, NULL, bytePtr, byteLength, &byteLength) != kCFStringEncodingConversionSuccess) {
+            if (bytePtr) CFAllocatorDeallocate(alloc, bytePtr);
+            return false;
+        }
+    }
+    for (currByte = bytePtr; currByte < bytePtr + byteLength; currByte ++) {
+        UniChar escapeSequence[3] = {'%', '\0', '\0'};
+        unsigned char high, low;
+        high = ((*currByte) & 0xf0) >> 4;
+        low = (*currByte) & 0x0f;
+        escapeSequence[1] = (high < 10) ? '0' + high : 'A' + high - 10;
+        escapeSequence[2] = (low < 10) ? '0' + low : 'A' + low - 10;
+        CFStringAppendCharacters(str, escapeSequence, 3);
+    }
+    if (bytePtr != bytes) {
+        CFAllocatorDeallocate(alloc, bytePtr);
+    }
+    return true;
+}
+
+// Uses UTF-8 to translate all percent escape sequences; returns NULL if it encounters a format failure.  May return the original string.
+CFStringRef  CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef alloc, CFStringRef  originalString, CFStringRef  charactersToLeaveEscaped) {
+    CFMutableStringRef newStr = NULL;
+    CFIndex length;
+    CFIndex mark = 0;
+    CFRange percentRange, searchRange;
+    CFStringRef escapedStr = NULL;
+    CFMutableStringRef strForEscapedChar = NULL;
+    UniChar escapedChar;
+    Boolean escapeAll = (charactersToLeaveEscaped && CFStringGetLength(charactersToLeaveEscaped) == 0);
+    Boolean failed = false;
+    
+    if (!originalString) return NULL;
+
+    if (charactersToLeaveEscaped == NULL) {
+        return (CFStringRef)CFStringCreateCopy(alloc, originalString);
+    }
+
+    length = CFStringGetLength(originalString);
+    searchRange = CFRangeMake(0, length);
+
+    while (!failed && CFStringFindWithOptions(originalString, CFSTR("%"), searchRange, 0, &percentRange)) {
+        uint8_t bytes[4]; // Single UTF-8 character could require up to 4 bytes.
+        uint8_t numBytesExpected;
+        UniChar ch1, ch2;
+
+        escapedStr = NULL;
+        // Make sure we have at least 2 more characters
+        if (length - percentRange.location < 3) { failed = true; break; }
+
+        // if we don't have at least 2 more characters, we can't interpret the percent escape code,
+        // so we assume the percent character is legit, and let it pass into the string
+        ch1 = CFStringGetCharacterAtIndex(originalString, percentRange.location+1);
+        ch2 = CFStringGetCharacterAtIndex(originalString, percentRange.location+2);
+        if (!_translateBytes(ch1, ch2, bytes)) { failed = true;  break; }
+        if (!(bytes[0] & 0x80)) {
+            numBytesExpected = 1;
+        } else if (!(bytes[0] & 0x20)) {
+            numBytesExpected = 2;
+        } else if (!(bytes[0] & 0x10)) {
+            numBytesExpected = 3;
+        } else {
+            numBytesExpected = 4;
+        }
+        if (numBytesExpected == 1) {
+            // one byte sequence (most common case); handle this specially
+            escapedChar = bytes[0];
+            if (!strForEscapedChar) {
+                strForEscapedChar = CFStringCreateMutableWithExternalCharactersNoCopy(alloc, &escapedChar, 1, 1, kCFAllocatorNull);
+            }
+            escapedStr = strForEscapedChar;
+        } else {
+            CFIndex j;
+            // Make sure up front that we have enough characters
+            if (length < percentRange.location + numBytesExpected * 3) { failed = true; break; }
+            for (j = 1; j < numBytesExpected; j ++) {
+                if (CFStringGetCharacterAtIndex(originalString, percentRange.location + 3*j) != '%') { failed = true; break; }
+                ch1 = CFStringGetCharacterAtIndex(originalString, percentRange.location + 3*j + 1);
+                ch2 = CFStringGetCharacterAtIndex(originalString, percentRange.location + 3*j + 2);
+                if (!_translateBytes(ch1, ch2, bytes+j)) { failed = true; break; }
+            }
+
+            // !!! We should do the low-level bit-twiddling ourselves; this is expensive!  REW, 6/10/99
+            escapedStr = CFStringCreateWithBytes(alloc, bytes, numBytesExpected, kCFStringEncodingUTF8, false);
+            if (!escapedStr) {
+                failed = true;
+            } else if (CFStringGetLength(escapedStr) == 0 && numBytesExpected == 3 && bytes[0] == 0xef && bytes[1] == 0xbb && bytes[2] == 0xbf) {
+                // Somehow, the UCS-2 BOM got translated in to a UTF8 string
+                escapedChar = 0xfeff;
+                if (!strForEscapedChar) {
+                    strForEscapedChar = CFStringCreateMutableWithExternalCharactersNoCopy(alloc, &escapedChar, 1, 1, kCFAllocatorNull);
+                }
+                CFRelease(escapedStr);
+                escapedStr = strForEscapedChar;
+            }
+            if (failed) break;
+        }
+
+        // The new character is in escapedChar; the number of percent escapes it took is in numBytesExpected.
+        searchRange.location = percentRange.location + 3 * numBytesExpected;
+        searchRange.length = length - searchRange.location;
+        
+        if (!escapeAll) {
+            if (CFStringFind(charactersToLeaveEscaped, escapedStr, 0).location != kCFNotFound) {
+                if (escapedStr != strForEscapedChar) {
+                    CFRelease(escapedStr);
+                    escapedStr = NULL;
+                }
+                continue;
+            } 
+        }
+        
+        if (!newStr) {
+            newStr = CFStringCreateMutable(alloc, length);
+        }
+        if (percentRange.location - mark > 0) {
+            // The creation of this temporary string is unfortunate. 
+            CFStringRef substring = CFStringCreateWithSubstring(alloc, originalString, CFRangeMake(mark, percentRange.location - mark));
+            CFStringAppend(newStr, substring);
+            CFRelease(substring);
+        }
+        CFStringAppend(newStr, escapedStr);
+        if (escapedStr != strForEscapedChar) {
+            CFRelease(escapedStr);
+            escapedStr = NULL;
+        }
+        mark = searchRange.location;// We need mark to be the index of the first character beyond the escape sequence
+    }
+
+    if (escapedStr && escapedStr != strForEscapedChar) CFRelease(escapedStr);
+    if (strForEscapedChar) CFRelease(strForEscapedChar);
+    if (failed) {
+        if (newStr) CFRelease(newStr);
+        return NULL;
+    } else if (newStr) {
+        if (mark < length) {
+            // Need to cat on the remainder of the string
+            CFStringRef substring = CFStringCreateWithSubstring(alloc, originalString, CFRangeMake(mark, length - mark));
+            CFStringAppend(newStr, substring);
+            CFRelease(substring);
+        }
+        return newStr;
+    } else {
+	return (CFStringRef)CFStringCreateCopy(alloc, originalString);
+    }
+}
+
+CF_EXPORT
+CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef alloc, CFStringRef  originalString, CFStringRef  charactersToLeaveEscaped, CFStringEncoding enc) {
+    if (enc == kCFStringEncodingUTF8) {
+        return CFURLCreateStringByReplacingPercentEscapes(alloc, originalString, charactersToLeaveEscaped);
+    } else {
+        CFMutableStringRef newStr = NULL;
+        CFMutableStringRef escapedStr = NULL;
+        CFIndex length;
+        CFIndex mark = 0;
+        CFRange percentRange, searchRange;
+        Boolean escapeAll = (charactersToLeaveEscaped && CFStringGetLength(charactersToLeaveEscaped) == 0);
+        Boolean failed = false;
+        uint8_t byteBuffer[8];
+        uint8_t *bytes = byteBuffer;
+        int capacityOfBytes = 8;
+        
+        if (!originalString) return NULL;
+    
+        if (charactersToLeaveEscaped == NULL) {
+            return (CFStringRef)CFStringCreateCopy(alloc, originalString);
+        }
+    
+        length = CFStringGetLength(originalString);
+        searchRange = CFRangeMake(0, length);
+    
+        while (!failed && CFStringFindWithOptions(originalString, CFSTR("%"), searchRange, 0, &percentRange)) {
+            UniChar ch1, ch2;
+            CFIndex percentLoc = percentRange.location;
+            CFStringRef convertedString;
+            int numBytesUsed = 0;
+            do {
+                // Make sure we have at least 2 more characters
+                if (length - percentLoc < 3) { failed = true; break; }
+    
+                if (numBytesUsed == capacityOfBytes) {
+                    if (bytes == byteBuffer) {
+                        bytes = (uint8_t *)CFAllocatorAllocate(alloc, 16 * sizeof(uint8_t), 0);
+                        memmove(bytes, byteBuffer, capacityOfBytes);
+                        capacityOfBytes = 16;
+                    } else {
+			void *oldbytes = bytes;
+			int oldcap = capacityOfBytes;
+                        capacityOfBytes = 2*capacityOfBytes;
+                        bytes = (uint8_t *)CFAllocatorAllocate(alloc, capacityOfBytes * sizeof(uint8_t), 0);
+			memmove(bytes, oldbytes, oldcap);
+                        CFAllocatorDeallocate(alloc, oldbytes);
+                    }
+                }
+                percentLoc ++;
+                ch1 = CFStringGetCharacterAtIndex(originalString, percentLoc);
+                percentLoc ++;
+                ch2 = CFStringGetCharacterAtIndex(originalString, percentLoc);
+                percentLoc ++;
+                if (!_translateBytes(ch1, ch2, bytes + numBytesUsed)) { failed = true;  break; }
+                numBytesUsed ++;
+            } while (CFStringGetCharacterAtIndex(originalString, percentLoc) == '%');
+            searchRange.location = percentLoc;
+            searchRange.length = length - searchRange.location;
+
+            if (failed) break;
+            convertedString = CFStringCreateWithBytes(alloc, bytes, numBytesUsed, enc, false);
+            if (!convertedString) {
+                failed = true;
+                break;
+            }
+    
+            if (!newStr) {
+                newStr = CFStringCreateMutable(alloc, length);
+            }
+            if (percentRange.location - mark > 0) {
+                // The creation of this temporary string is unfortunate. 
+                CFStringRef substring = CFStringCreateWithSubstring(alloc, originalString, CFRangeMake(mark, percentRange.location - mark));
+                CFStringAppend(newStr, substring);
+                CFRelease(substring);
+            }
+
+            if (escapeAll) {
+                CFStringAppend(newStr, convertedString);
+                CFRelease(convertedString);
+            } else {
+                CFIndex i, c = CFStringGetLength(convertedString);
+                if (!escapedStr) {
+                    escapedStr = CFStringCreateMutableWithExternalCharactersNoCopy(alloc, &ch1, 1, 1, kCFAllocatorNull);
+                }
+                for (i = 0; i < c; i ++) {
+                    ch1 = CFStringGetCharacterAtIndex(convertedString, i);
+                    if (CFStringFind(charactersToLeaveEscaped, escapedStr, 0).location == kCFNotFound) {
+                        CFStringAppendCharacters(newStr, &ch1, 1);
+                    } else {
+                        // Must regenerate the escape sequence for this character; because we started with percent escapes, we know this call cannot fail
+                        _appendPercentEscapesForCharacter(ch1, enc, newStr);
+                    }
+                }
+            }
+            mark = searchRange.location;// We need mark to be the index of the first character beyond the escape sequence
+        }
+    
+        if (escapedStr) CFRelease(escapedStr);
+        if (bytes != byteBuffer) CFAllocatorDeallocate(alloc, bytes);
+        if (failed) {
+            if (newStr) CFRelease(newStr);
+            return NULL;
+        } else if (newStr) {
+            if (mark < length) {
+                // Need to cat on the remainder of the string
+                CFStringRef substring = CFStringCreateWithSubstring(alloc, originalString, CFRangeMake(mark, length - mark));
+                CFStringAppend(newStr, substring);
+                CFRelease(substring);
+            }
+            return newStr;
+        } else {
+            return (CFStringRef)CFStringCreateCopy(alloc, originalString);
+        }
+    }
+}
+    
+
+static CFStringRef _addPercentEscapesToString(CFAllocatorRef allocator, CFStringRef originalString, Boolean (*shouldReplaceChar)(UniChar, void*), CFIndex (*handlePercentChar)(CFIndex, CFStringRef, CFStringRef *, void *), CFStringEncoding encoding, void *context) {
+    CFMutableStringRef newString = NULL;
+    CFIndex idx, length;
+    CFStringInlineBuffer buf;
+
+    if (!originalString) return NULL;
+    length = CFStringGetLength(originalString);
+    if (length == 0) return (CFStringRef)CFStringCreateCopy(allocator, originalString);
+    CFStringInitInlineBuffer(originalString, &buf, CFRangeMake(0, length));
+
+    for (idx = 0; idx < length; idx ++) {
+        UniChar ch = CFStringGetCharacterFromInlineBuffer(&buf, idx);
+        Boolean shouldReplace = shouldReplaceChar(ch, context);
+        if (shouldReplace) {
+            // Perform the replacement
+            if (!newString) {
+                newString = CFStringCreateMutableCopy(CFGetAllocator(originalString), 0, originalString);
+                CFStringDelete(newString, CFRangeMake(idx, length-idx));
+            }
+            if (!_appendPercentEscapesForCharacter(ch, encoding, newString)) {
+//#warning FIXME - once CFString supports finding glyph boundaries walk by glyph boundaries instead of by unichars
+                if (encoding == kCFStringEncodingUTF8 && CFCharacterSetIsSurrogateHighCharacter(ch) && idx + 1 < length && CFCharacterSetIsSurrogateLowCharacter(CFStringGetCharacterFromInlineBuffer(&buf, idx+1))) {
+                    // Hack to guarantee we always safely convert file URLs between POSIX & full URL representation
+                    if (_hackToConvertSurrogates(ch, CFStringGetCharacterFromInlineBuffer(&buf, idx+1), newString)) {
+                        idx ++; // We consumed 2 characters, not 1
+                    } else {
+                        break;
+                    }
+                } else {
+                    break;
+                }
+            }
+        } else if (ch == '%' && handlePercentChar) {
+            CFStringRef replacementString = NULL;
+            CFIndex newIndex = handlePercentChar(idx, originalString, &replacementString, context);
+            if (newIndex < 0) {
+                break;
+            } else if (replacementString) {
+                if (!newString) {
+                    newString = CFStringCreateMutableCopy(CFGetAllocator(originalString), 0, originalString);
+                    CFStringDelete(newString, CFRangeMake(idx, length-idx));
+                }
+                CFStringAppend(newString, replacementString);
+                CFRelease(replacementString);
+            }
+            if (newIndex == idx) {
+                if (newString) {
+                    CFStringAppendCharacters(newString, &ch, 1);
+                }
+            } else {
+                if (!replacementString && newString) {
+                    CFIndex tmpIndex;
+                    for (tmpIndex = idx; tmpIndex < newIndex; tmpIndex ++) {
+                        ch = CFStringGetCharacterAtIndex(originalString, idx);
+                        CFStringAppendCharacters(newString, &ch, 1);
+                    }                        
+                }
+                idx = newIndex - 1;
+            }
+        } else if (newString) {
+            CFStringAppendCharacters(newString, &ch, 1);
+        }
+    }
+    if (idx < length) {
+        // Ran in to an encoding failure
+        if (newString) CFRelease(newString);
+        return NULL;
+    } else if (newString) {
+        return newString;
+    } else {
+        return (CFStringRef)CFStringCreateCopy(CFGetAllocator(originalString), originalString);
+    }
+}
+
+
+static Boolean _stringContainsCharacter(CFStringRef string, UniChar ch) {
+    CFIndex i, c = CFStringGetLength(string);
+    CFStringInlineBuffer buf;
+    CFStringInitInlineBuffer(string, &buf, CFRangeMake(0, c));
+    for (i = 0; i < c; i ++) if (__CFStringGetCharacterFromInlineBufferQuick(&buf, i) == ch) return true;
+    return false;
+}
+
+static Boolean _shouldPercentReplaceChar(UniChar ch, void *context) {
+    CFStringRef unescape = ((CFStringRef *)context)[0];
+    CFStringRef escape = ((CFStringRef *)context)[1];
+    Boolean shouldReplace = (isURLLegalCharacter(ch) == false);
+    if (shouldReplace) {
+        if (unescape && _stringContainsCharacter(unescape, ch)) {
+            shouldReplace = false;
+        }
+    } else if (escape && _stringContainsCharacter(escape, ch)) {
+        shouldReplace = true;
+    }
+    return shouldReplace;
+}
+
+CF_EXPORT CFStringRef CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) {
+    CFStringRef strings[2];
+    strings[0] = charactersToLeaveUnescaped;
+    strings[1] = legalURLCharactersToBeEscaped;
+    return _addPercentEscapesToString(allocator, originalString, _shouldPercentReplaceChar, NULL, encoding, strings);
+}
+ 
+static Boolean __CFURLEqual(CFTypeRef  cf1, CFTypeRef  cf2) {
+    CFURLRef  url1 = (CFURLRef)cf1;
+    CFURLRef  url2 = (CFURLRef)cf2;
+    UInt32 pathType1, pathType2;
+    
+    __CFGenericValidateType(cf1, CFURLGetTypeID());
+    __CFGenericValidateType(cf2, CFURLGetTypeID());
+
+    if (url1 == url2) return true;
+    if ((url1->_flags & IS_PARSED) && (url2->_flags & IS_PARSED) && (url1->_flags & IS_DIRECTORY) != (url2->_flags & IS_DIRECTORY)) return false;
+    if ( url1->_base ) {
+        if (! url2->_base) return false;
+        if (!CFEqual( url1->_base, url2->_base )) return false;
+    } else if ( url2->_base) {
+        return false;
+    }
+    
+    pathType1 = URL_PATH_TYPE(url1);
+    pathType2 = URL_PATH_TYPE(url2);
+    if (pathType1 == pathType2) {
+        if (pathType1 != FULL_URL_REPRESENTATION) {
+            return CFEqual(url1->_string, url2->_string);
+        } else {
+            // Do not compare the original strings; compare the sanatized strings.
+            return CFEqual(CFURLGetString(url1), CFURLGetString(url2));
+        }
+    } else {
+        // Try hard to avoid the expensive conversion from a file system representation to the canonical form
+        CFStringRef scheme1 = CFURLCopyScheme(url1);
+        CFStringRef scheme2 = CFURLCopyScheme(url2);
+        Boolean eq;
+        if (scheme1 && scheme2) {
+            eq = CFEqual(scheme1, scheme2);
+            CFRelease(scheme1);
+            CFRelease(scheme2);
+        } else if (!scheme1 && !scheme2) {
+            eq = TRUE;
+        } else {
+            eq = FALSE;
+            if (scheme1) CFRelease(scheme1);
+            else CFRelease(scheme2);
+        }
+        if (!eq) return false;
+
+        if (pathType1 == FULL_URL_REPRESENTATION) {
+            if (!(url1->_flags & IS_PARSED)) {
+                _parseComponentsOfURL(url1);
+            }
+            if (url1->_flags & (HAS_USER | HAS_PORT | HAS_PASSWORD | HAS_QUERY | HAS_PARAMETERS | HAS_FRAGMENT )) {
+                return false;
+            }
+        }
+
+        if (pathType2 == FULL_URL_REPRESENTATION) {
+            if (!(url2->_flags & IS_PARSED)) {
+                _parseComponentsOfURL(url2);
+            }
+            if (url2->_flags & (HAS_USER | HAS_PORT | HAS_PASSWORD | HAS_QUERY | HAS_PARAMETERS | HAS_FRAGMENT )) {
+                return false;
+            }
+        }
+
+        // No help for it; we now must convert to the canonical representation and compare.
+        return CFEqual(CFURLGetString(url1), CFURLGetString(url2));
+    }
+}
+
+static CFHashCode __CFURLHash(CFTypeRef  cf) {
+    /* This is tricky, because we do not want the hash value to change as a file system URL is changed to its canonical representation, nor do we wish to force the conversion to the canonical representation. We choose instead to take the last path component (or "/" in the unlikely case that the path is empty), then hash on that. */
+    CFURLRef  url = (CFURLRef)cf;
+    UInt32 result;
+    if (CFURLCanBeDecomposed(url)) {
+        CFStringRef lastComp = CFURLCopyLastPathComponent(url);
+		CFStringRef	hostNameRef = CFURLCopyHostName(url );
+		
+		result = 0;
+		
+        if (lastComp) {
+            result = CFHash(lastComp);
+            CFRelease(lastComp);
+        }
+		
+		if ( hostNameRef )
+		{
+			result ^= CFHash( hostNameRef );
+			CFRelease( hostNameRef );
+		}
+    } else {
+        result = CFHash(CFURLGetString(url));
+    }
+    return result;
+}
+
+static CFStringRef  __CFURLCopyFormattingDescription(CFTypeRef  cf, CFDictionaryRef formatOptions) {
+    CFURLRef  url = (CFURLRef)cf;
+    __CFGenericValidateType(cf, CFURLGetTypeID());
+    if (! url->_base) {
+        CFRetain(url->_string);
+        return url->_string;
+    } else {
+        // Do not dereference url->_base; it may be an ObjC object
+        return CFStringCreateWithFormat(CFGetAllocator(url), NULL, CFSTR("%@ -- %@"), url->_string, url->_base);
+    }
+}
+
+
+static CFStringRef __CFURLCopyDescription(CFTypeRef cf) {
+    CFURLRef url = (CFURLRef)cf;
+    CFStringRef result;
+    CFAllocatorRef alloc = CFGetAllocator(url);
+    if ( url->_base) {
+        CFStringRef baseString = CFCopyDescription(url->_base);
+        result = CFStringCreateWithFormat(alloc, NULL, CFSTR("<CFURL %p [%p]>{type = %d, string = %@,\n\tbase = %@}"), cf, alloc, URL_PATH_TYPE(url), url->_string, baseString);
+        CFRelease(baseString);
+    } else {
+        result = CFStringCreateWithFormat(alloc, NULL, CFSTR("<CFURL %p [%p]>{type = %d, string = %@, base = (null)}"), cf, alloc, URL_PATH_TYPE(url), url->_string);
+    }
+    return result;
+}
+
+#if DEBUG_URL_MEMORY_USAGE
+
+extern __attribute((used)) void __CFURLDumpMemRecord(void) {
+    CFStringRef str = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%d URLs created; %d destroyed\n%d file URLs created; %d converted; %d destroyed.  %d urls had 'extra' data allocated, %d had base urls\n"), numURLs, numDealloced, numFileURLsCreated, numFileURLsConverted, numFileURLsDealloced, numExtraDataAllocated, numURLsWithBaseURL );
+    CFShow(str);
+    CFRelease(str);
+    // if (URLAllocator) CFCountingAllocatorPrintPointers(URLAllocator);
+}
+#endif
+
+static void __CFURLDeallocate(CFTypeRef  cf) {
+    CFURLRef  url = (CFURLRef)cf;
+    CFAllocatorRef alloc;
+    __CFGenericValidateType(cf, CFURLGetTypeID());
+    alloc = CFGetAllocator(url);
+#if DEBUG_URL_MEMORY_USAGE
+    numDealloced ++;
+    if (URL_PATH_TYPE(url) != FULL_URL_REPRESENTATION) {
+        numFileURLsDealloced ++;
+    }
+#endif
+    if (url->_string) CFRelease(url->_string); // GC: 3879914
+    if (url->_base) CFRelease(url->_base);
+    if (url->ranges) CFAllocatorDeallocate(alloc, url->ranges);
+    if (_getSanitizedString(url)) CFRelease(_getSanitizedString(url));
+	
+	if ( url->extra != NULL )
+		CFAllocatorDeallocate( alloc, url->extra );
+}
+
+static CFTypeID __kCFURLTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFURLClass = {
+    0,
+    "CFURL",
+    NULL,      // init
+    NULL,      // copy
+    __CFURLDeallocate,
+    __CFURLEqual,
+    __CFURLHash,
+    __CFURLCopyFormattingDescription,
+    __CFURLCopyDescription
+};
+
+// When __CONSTANT_CFSTRINGS__ is not defined, we have separate macros for static and exported constant strings, but
+// when it is defined, we must prefix with static to prevent the string from being exported 
+#ifdef __CONSTANT_CFSTRINGS__
+static CONST_STRING_DECL(kCFURLFileScheme, "file")
+static CONST_STRING_DECL(kCFURLDataScheme, "data")
+static CONST_STRING_DECL(kCFURLHTTPScheme, "http")
+static CONST_STRING_DECL(kCFURLLocalhost, "localhost")
+#else
+CONST_STRING_DECL(kCFURLFileScheme, "file")
+CONST_STRING_DECL(kCFURLDataScheme, "data")
+CONST_STRING_DECL(kCFURLHTTPScheme, "http")
+CONST_STRING_DECL(kCFURLLocalhost, "localhost")
+#endif
+__private_extern__ void __CFURLInitialize(void) {
+    __kCFURLTypeID = _CFRuntimeRegisterClass(&__CFURLClass);
+}
+
+/* Toll-free bridging support; get the true CFURL from an NSURL */
+CF_INLINE CFURLRef _CFURLFromNSURL(CFURLRef url) {
+    CF_OBJC_FUNCDISPATCH0(__kCFURLTypeID, CFURLRef, url, "_cfurl");
+    return url;
+}
+
+CFTypeID CFURLGetTypeID(void) {
+    return __kCFURLTypeID;
+}
+
+__private_extern__ void CFShowURL(CFURLRef url) {
+    if (!url) {
+        fprintf(stdout, "(null)\n");
+        return;
+    }
+    fprintf(stdout, "<CFURL %p>{", (const void*)url);
+    if (CF_IS_OBJC(__kCFURLTypeID, url)) {
+        fprintf(stdout, "ObjC bridged object}\n");
+        return;
+    }
+    fprintf(stdout, "\n\tPath type: ");
+    switch (URL_PATH_TYPE(url)) {
+        case kCFURLPOSIXPathStyle:
+            fprintf(stdout, "POSIX");
+            break;
+        case kCFURLHFSPathStyle:
+            fprintf(stdout, "HFS");
+            break;
+        case kCFURLWindowsPathStyle:
+            fprintf(stdout, "NTFS");
+            break;
+        case FULL_URL_REPRESENTATION:
+            fprintf(stdout, "Native URL");
+            break;
+        default:
+            fprintf(stdout, "UNRECOGNIZED PATH TYPE %d", (char)URL_PATH_TYPE(url));
+    }
+    fprintf(stdout, "\n\tRelative string: ");
+    CFShow(url->_string);
+    fprintf(stdout, "\tBase URL: ");
+    if (url->_base) {
+        fprintf(stdout, "<%p> ", (const void*)url->_base);
+        CFShow(url->_base);
+    } else {
+        fprintf(stdout, "(null)\n");
+    }
+    fprintf(stdout, "\tFlags: 0x%x\n}\n", (unsigned int)url->_flags);
+}
+
+
+/***************************************************/
+/* URL creation and String/Data creation from URLS */
+/***************************************************/
+static void constructBuffers(CFAllocatorRef alloc, CFStringRef string, const char **cstring, const UniChar **ustring, Boolean *useCString, Boolean *freeCharacters) {
+    CFIndex neededLength;
+    CFIndex length;
+    CFRange rg;
+
+    *cstring = CFStringGetCStringPtr(string, kCFStringEncodingISOLatin1);
+    if (*cstring) {
+        *ustring = NULL;
+        *useCString = true;
+        *freeCharacters = false;
+        return;
+    } 
+
+    *ustring = CFStringGetCharactersPtr(string);
+    if (*ustring) {
+        *useCString = false;
+        *freeCharacters = false;
+        return;
+    } 
+
+    *freeCharacters = true;
+    length = CFStringGetLength(string);
+    rg = CFRangeMake(0, length);
+    CFStringGetBytes(string, rg, kCFStringEncodingISOLatin1, 0, false, NULL, INT_MAX, &neededLength);
+    if (neededLength == length) {
+        char *buf = (char *)CFAllocatorAllocate(alloc, length, 0);
+        CFStringGetBytes(string, rg, kCFStringEncodingISOLatin1, 0, false, (uint8_t *)buf, length, NULL);
+        *cstring = buf;
+        *useCString = true;
+    } else {
+        UniChar *buf = (UniChar *)CFAllocatorAllocate(alloc, length * sizeof(UniChar), 0);
+        CFStringGetCharacters(string, rg, buf);
+        *useCString = false;
+        *ustring = buf;
+    }
+}
+
+#define STRING_CHAR(x) (useCString ? cstring[(x)] : ustring[(x)])
+static void _parseComponents(CFAllocatorRef alloc, CFStringRef string, CFURLRef baseURL, UInt32 *theFlags, CFRange **range) {
+    CFRange ranges[9];
+    /* 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. */
+
+    CFIndex idx, base_idx = 0;
+    CFIndex string_length;
+    UInt32 flags = (IS_PARSED | *theFlags);
+    Boolean useCString, freeCharacters, isCompliant;
+    uint8_t numRanges = 0;
+    const char *cstring = NULL;
+    const UniChar *ustring = NULL;
+    
+    string_length = CFStringGetLength(string);
+    constructBuffers(alloc, string, &cstring, &ustring, &useCString, &freeCharacters);
+    
+    // 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 ('#' == STRING_CHAR(idx)) {
+            flags |= HAS_FRAGMENT;
+            ranges[8].location = idx + 1;
+            ranges[8].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 = STRING_CHAR(idx);
+        if (':' == ch) {
+            flags |= HAS_SCHEME;
+            flags |= IS_ABSOLUTE;
+            ranges[0].location = base_idx;
+            ranges[0].length = idx;
+            numRanges ++;
+			base_idx = idx + 1;
+			// optimization for http urls
+			if (idx == 4 && STRING_CHAR(0) == 'h' && STRING_CHAR(1) == 't' &&
+				STRING_CHAR(2) == 't' && STRING_CHAR(3) == 'p')
+			{
+				flags |= HAS_HTTP_SCHEME;
+			}
+			// optimization for file urls
+			if (idx == 4 && STRING_CHAR(0) == 'f' && STRING_CHAR(1) == 'i' &&
+				STRING_CHAR(2) == 'l' && STRING_CHAR(3) == 'e')
+			{
+				flags |= HAS_FILE_SCHEME;
+			}
+            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 (STRING_CHAR(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 = CFStringGetLength(string);
+        }
+        (*theFlags) = flags;
+        (*range) = (CFRange *)CFAllocatorAllocate(alloc, sizeof(CFRange), 0);
+        (*range)->location = ranges[0].location;
+        (*range)->length = ranges[0].length;
+
+        if (freeCharacters) {
+            CFAllocatorDeallocate(alloc, useCString ? (void *)cstring : (void *)ustring);
+        }
+        return;
+    }
+    // URL is 1808-compliant
+    flags |= IS_DECOMPOSABLE;
+    
+    // 3: parse the network location and login
+    if (2 <= (string_length - base_idx) && '/' == STRING_CHAR(base_idx) && '/' == STRING_CHAR(base_idx+1)) {
+        CFIndex base = 2 + base_idx, extent;
+        for (idx = base; idx < string_length; idx++) {
+            if ('/' == STRING_CHAR(idx) || '?' == STRING_CHAR(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 "<user>:<password>@<host>:<port>"
+        if (extent != base) {
+            for (idx = base; idx < extent; idx++) {
+                if ('@' == STRING_CHAR(idx)) {   // there is a user
+                    CFIndex idx2;
+                    flags |= HAS_USER;
+                    numRanges ++;
+                    ranges[1].location = base;  // base of the user
+                    for (idx2 = base; idx2 < idx; idx2++) {
+                        if (':' == STRING_CHAR(idx2)) {	// found a password separator
+                            flags |= HAS_PASSWORD;
+                            numRanges ++;
+                            ranges[2].location = idx2+1; // base of the password
+                            ranges[2].length = idx-(idx2+1);  // password extent
+                            ranges[1].length = idx2 - base; // user extent
+                            break;
+                        }
+                    }
+                    if (!(flags & HAS_PASSWORD)) {
+                        // user extends to the '@'
+                        ranges[1].length = idx - base; // user extent
+                    }
+                    base = idx + 1;
+                    break;
+                }
+            }
+            flags |= HAS_HOST;
+            numRanges ++;
+            ranges[3].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 ('[' == STRING_CHAR(idx)) {	// starting IPV6 explicit address
+					//	Find the ']' terminator of the IPv6 address, leave idx pointing to ']' or end
+					for ( ; idx < extent; ++ idx ) {
+						if ( ']' == STRING_CHAR(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 ( ':' == STRING_CHAR(idx)) {	
+                    flags |= HAS_PORT;
+                    numRanges ++;
+                    ranges[4].location = idx+1; // base of port
+                    ranges[4].length = extent - (idx+1); // port extent
+                    ranges[3].length = idx - base; // host extent
+                    break;
+                }
+            }
+            if (!(flags & HAS_PORT)) {
+                ranges[3].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 ('?' == STRING_CHAR(idx)) {
+            flags |= HAS_QUERY;
+            numRanges ++;
+            ranges[7].location = idx + 1;
+            ranges[7].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 (';' == STRING_CHAR(idx)) {
+            flags |= HAS_PARAMETERS;
+            numRanges ++;
+            ranges[6].location = idx + 1;
+            ranges[6].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;
+        ranges[5] = pathRg;
+
+        if (pathRg.length > 0) {
+            Boolean sawPercent = FALSE;
+            for (idx = pathRg.location; idx < string_length; idx++) {
+                if ('%' == STRING_CHAR(idx)) {
+                    sawPercent = TRUE;
+                    break;
+                }
+            }
+            if (!sawPercent) {
+                flags |= POSIX_AND_URL_PATHS_MATCH;
+            }
+
+            ch = STRING_CHAR(pathRg.location + pathRg.length - 1);
+            if (ch == '/') {
+                isDir = true;
+            } else if (ch == '.') {
+                if (pathRg.length == 1) {
+                    isDir = true;
+                } else {
+                    ch = STRING_CHAR(pathRg.location + pathRg.length - 2);
+                    if (ch == '/') {
+                        isDir = true;
+                    } else if (ch != '.') {
+                        isDir = false;
+                    } else if (pathRg.length == 2) {
+                        isDir = true;
+                    } else {
+                        isDir = (STRING_CHAR(pathRg.location + pathRg.length - 3) == '/');
+                    }
+                }
+            } else {
+                isDir = false;
+            }
+        } else {
+            isDir = (baseURL != NULL) ? CFURLHasDirectoryPath(baseURL) : false;
+        }
+        if (isDir) {
+            flags |= IS_DIRECTORY;
+        }
+    }
+
+    if (freeCharacters) {
+        CFAllocatorDeallocate(alloc, useCString ? (void *)cstring : (void *)ustring);
+    }
+    (*theFlags) = flags;
+    (*range) = (CFRange *)CFAllocatorAllocate(alloc, sizeof(CFRange)*numRanges, 0);
+    numRanges = 0;
+    for (idx = 0, flags = 1; flags != (1<<9); flags = (flags<<1), idx ++) {
+        if ((*theFlags) & flags) {
+            (*range)[numRanges] = ranges[idx];
+            numRanges ++;
+        }
+    }
+}
+
+static Boolean scanCharacters(CFAllocatorRef alloc, CFMutableStringRef *escapedString, UInt32 *flags, const char *cstring, const UniChar *ustring, Boolean useCString, CFIndex base, CFIndex end, CFIndex *mark, UInt32 componentFlag, CFStringEncoding encoding) {
+    CFIndex idx;
+    Boolean sawIllegalChar = false;
+    for (idx = base; idx < end; idx ++) {
+        Boolean shouldEscape;
+        UniChar ch = STRING_CHAR(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(STRING_CHAR(idx + 1)) && isHexDigit(STRING_CHAR(idx+2))) {
+            shouldEscape = false;
+        } else if (componentFlag == HAS_HOST && ((idx == base && ch == '[') || (idx == end-1 && ch == ']'))) {
+            shouldEscape = false;
+        } else {
+            shouldEscape = true;
+        }
+        if (!shouldEscape) continue;
+        
+        sawIllegalChar = true;
+        if (componentFlag && flags) {
+            *flags |= (componentFlag << BIT_SHIFT_FROM_COMPONENT_TO_DIFFERS_FLAG);
+        }
+        if (!*escapedString) {
+            *escapedString = CFStringCreateMutable(alloc, 0);
+        }
+        if (useCString) {
+            CFStringRef tempString = CFStringCreateWithBytes(alloc, (uint8_t *)&(cstring[*mark]), idx - *mark, kCFStringEncodingISOLatin1, false);
+            CFStringAppend(*escapedString, tempString);
+            CFRelease(tempString);
+        } else {
+            CFStringAppendCharacters(*escapedString, &(ustring[*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;
+} 
+
+static void computeSanitizedString(CFURLRef url) {
+    CFAllocatorRef alloc = CFGetAllocator(url);
+    CFIndex string_length = CFStringGetLength(url->_string);
+    Boolean useCString, freeCharacters;
+    const char *cstring = NULL;
+    const UniChar *ustring = NULL;
+    CFIndex base; // where to scan from
+    CFIndex mark; // first character not-yet copied to sanitized string
+    if (!(url->_flags & IS_PARSED)) {
+        _parseComponentsOfURL(url);
+    }
+    constructBuffers(alloc, url->_string, &cstring, &ustring, &useCString, &freeCharacters);
+    if (!(url->_flags & IS_DECOMPOSABLE)) {
+        // Impossible to have a problem character in the scheme
+		CFMutableStringRef	sanitizedString = NULL;
+        base = _rangeForComponent(url->_flags, url->ranges, HAS_SCHEME).length + 1;
+        mark = 0;
+        if (!scanCharacters(alloc, & sanitizedString, &(((struct __CFURL *)url)->_flags), cstring, ustring, useCString, base, string_length, &mark, 0, url->_encoding)) {
+            ((struct __CFURL *)url)->_flags |= ORIGINAL_AND_URL_STRINGS_MATCH;
+        }
+        if ( sanitizedString ) {
+            _setSanitizedString( (struct __CFURL*) url, sanitizedString );
+        }
+    } else {
+        // Go component by component
+        CFIndex currentComponent = HAS_USER;
+        CFMutableStringRef sanitizedString = NULL;
+        mark = 0;
+        while (currentComponent < (HAS_FRAGMENT << 1)) {
+            CFRange componentRange = _rangeForComponent(url->_flags, url->ranges, currentComponent);
+            if (componentRange.location != kCFNotFound) {
+                scanCharacters(alloc, & sanitizedString, &(((struct __CFURL *)url)->_flags), cstring, ustring, useCString, componentRange.location, componentRange.location + componentRange.length, &mark, currentComponent, url->_encoding);
+            }
+            currentComponent = currentComponent << 1;
+        }
+        if (sanitizedString) {
+            _setSanitizedString((struct __CFURL *)url, sanitizedString);
+        } else {
+            ((struct __CFURL *)url)->_flags |= ORIGINAL_AND_URL_STRINGS_MATCH;
+        }
+    }
+    if (_getSanitizedString(url) && mark != string_length) {
+        if (useCString) {
+            CFStringRef tempString = CFStringCreateWithBytes(alloc, (uint8_t *)&(cstring[mark]), string_length - mark, kCFStringEncodingISOLatin1, false);
+            CFStringAppend(_getSanitizedString(url), tempString);
+            CFRelease(tempString);
+        } else {
+            CFStringAppendCharacters(_getSanitizedString(url), &(ustring[mark]), string_length - mark);
+        }
+    }
+    if (freeCharacters) {
+        CFAllocatorDeallocate(alloc, useCString ? (void *)cstring : (void *)ustring);
+    }
+}
+
+
+static CFStringRef correctedComponent(CFStringRef comp, UInt32 compFlag, CFStringEncoding enc) {
+    CFAllocatorRef alloc = CFGetAllocator(comp);
+    CFIndex string_length = CFStringGetLength(comp);
+    Boolean useCString, freeCharacters;
+    const char *cstring = NULL;
+    const UniChar *ustring = NULL;
+    CFIndex mark = 0; // first character not-yet copied to sanitized string
+    CFMutableStringRef result = NULL;
+
+    constructBuffers(alloc, comp, &cstring, &ustring, &useCString, &freeCharacters);
+    scanCharacters(alloc, &result, NULL, cstring, ustring, useCString, 0, string_length, &mark, compFlag, enc);
+    if (result) {
+        if (mark < string_length) {
+            if (useCString) {
+                CFStringRef tempString = CFStringCreateWithBytes(alloc, (uint8_t *)&(cstring[mark]), string_length - mark, kCFStringEncodingISOLatin1, false);
+                CFStringAppend(result, tempString);
+                CFRelease(tempString);
+            } else {
+                CFStringAppendCharacters(result, &(ustring[mark]), string_length - mark);
+            }
+        }
+    } else {
+        // This should nevr happen
+        CFRetain(comp);
+        result = (CFMutableStringRef)comp;
+    }
+    if (freeCharacters) {
+        CFAllocatorDeallocate(alloc, useCString ? (void *)cstring : (void *)ustring);
+    }
+    return result;
+}
+
+#undef STRING_CHAR
+CF_EXPORT CFURLRef _CFURLAlloc(CFAllocatorRef allocator) {
+    struct __CFURL *url;
+#if DEBUG_URL_MEMORY_USAGE
+    numURLs ++;
+    // if (!URLAllocator) {
+	// URLAllocator = CFCountingAllocatorCreate(NULL);
+    // }
+    allocator = URLAllocator;
+#endif
+    url = (struct __CFURL *)_CFRuntimeCreateInstance(allocator, __kCFURLTypeID, sizeof(struct __CFURL) - sizeof(CFRuntimeBase), NULL);
+    if (url) {
+        url->_flags = 0;
+        if (createOldUTF8StyleURLs()) {
+            url->_flags |= IS_OLD_UTF8_STYLE;
+        }
+        url->_string = NULL;
+        url->_base = NULL;
+        url->ranges = NULL;
+        // url->_reserved = NULL;
+        url->_encoding = kCFStringEncodingUTF8;
+        // url->_sanatizedString = NULL;
+		url->extra = NULL;
+   }
+    return url;
+}
+
+// It is the caller's responsibility to guarantee that if URLString is absolute, base is NULL.  This is necessary to avoid duplicate processing for file system URLs, which had to decide whether to compute the cwd for the base; we don't want to duplicate that work.  This ALSO means it's the caller's responsibility to set the IS_ABSOLUTE bit, since we may have a degenerate URL whose string is relative, but lacks a base.
+static void _CFURLInit(struct __CFURL *url, CFStringRef URLString, UInt32 fsType, CFURLRef base) {
+    CFAssert1(URLString != NULL && CFGetTypeID(URLString) == CFStringGetTypeID() && CFStringGetLength(URLString) != 0, __kCFLogAssertion, "%s(): internal CF error; empty string encountered", __PRETTY_FUNCTION__);
+    CFAssert2((fsType == FULL_URL_REPRESENTATION) || (fsType == kCFURLPOSIXPathStyle) || (fsType == kCFURLWindowsPathStyle) || (fsType == kCFURLHFSPathStyle), __kCFLogAssertion, "%s(): Received bad fsType %d", __PRETTY_FUNCTION__, fsType);
+    
+    // Coming in, the url has its allocator flag properly set, and its base initialized, and nothing else.    
+    url->_string = (CFStringRef)CFStringCreateCopy(CFGetAllocator(url), URLString);
+    url->_flags |= (fsType << 16);
+
+	url->_base = base ? CFURLCopyAbsoluteURL(base) : NULL;
+
+	#if DEBUG_URL_MEMORY_USAGE
+    if (fsType != FULL_URL_REPRESENTATION) {
+        numFileURLsCreated ++;
+    }
+	if ( url->_base )
+		numURLsWithBaseURL ++;
+	#endif
+}
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+CF_EXPORT void _CFURLInitFSPath(CFURLRef url, CFStringRef path) {
+    CFIndex len = CFStringGetLength(path);
+    if (len && CFStringGetCharacterAtIndex(path, 0) == '/') {
+        _CFURLInit((struct __CFURL *)url, path, kCFURLPOSIXPathStyle, NULL);
+        ((struct __CFURL *)url)->_flags |= IS_ABSOLUTE;
+    } else {
+        CFURLRef cwdURL = _CFURLCreateCurrentDirectoryURL(CFGetAllocator(url));
+        _CFURLInit((struct __CFURL *)url, path, kCFURLPOSIXPathStyle, cwdURL);
+        if ( cwdURL )
+            CFRelease(cwdURL);
+    }
+    if (!len || '/' == CFStringGetCharacterAtIndex(path, len - 1))
+        ((struct __CFURL *)url)->_flags |= IS_DIRECTORY;
+}
+#elif DEPLOYMENT_TARGET_WINDOWS
+CF_EXPORT void _CFURLInitFSPath(CFURLRef url, CFStringRef path) {
+    CFIndex len = CFStringGetLength(path);
+    if (len > 2) {
+        char firstChar = CFStringGetCharacterAtIndex(path, 0);
+        char secondChar = CFStringGetCharacterAtIndex(path, 1);
+        if (((((firstChar >= 'A') && (firstChar <= 'Z')) || ((firstChar >= 'a') && (firstChar <= 'z'))) &&
+            ((secondChar == ':') || (secondChar == '|'))) ||
+        ((firstChar == '\\') && (secondChar == '\\')))
+        {
+            _CFURLInit((struct __CFURL *)url, path, kCFURLWindowsPathStyle, NULL);
+            ((struct __CFURL *)url)->_flags |= IS_ABSOLUTE;
+        } else {
+            CFURLRef cwdURL = _CFURLCreateCurrentDirectoryURL(CFGetAllocator(url));
+            _CFURLInit((struct __CFURL *)url, path, kCFURLPOSIXPathStyle, cwdURL);
+            if ( cwdURL )
+                CFRelease(cwdURL);
+        }
+    }
+    if (!len || '/' == CFStringGetCharacterAtIndex(path, len - 1))
+        ((struct __CFURL *)url)->_flags |= IS_DIRECTORY;
+}
+#elif 0
+CF_EXPORT void _CFURLInitFSPath(CFURLRef url, CFStringRef path) {
+    CFIndex len = CFStringGetLength(path);
+    if (len && CFStringGetCharacterAtIndex(path, 0) == '/') {
+        _CFURLInit((struct __CFURL *)url, path, kCFURLPOSIXPathStyle, NULL);
+        ((struct __CFURL *)url)->_flags |= IS_ABSOLUTE;
+    } else {
+        CFURLRef cwdURL = _CFURLCreateCurrentDirectoryURL(CFGetAllocator(url));
+        _CFURLInit((struct __CFURL *)url, path, kCFURLPOSIXPathStyle, cwdURL);
+        if ( cwdURL )
+            CFRelease(cwdURL);
+    }
+    if (!len || '/' == CFStringGetCharacterAtIndex(path, len - 1))
+        ((struct __CFURL *)url)->_flags |= IS_DIRECTORY;
+}
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+// Exported for Foundation's use
+CF_EXPORT Boolean _CFStringIsLegalURLString(CFStringRef string) {
+    // Check each character to make sure it is a legal URL char.  The valid characters are 'A'-'Z', 'a' - 'z', '0' - '9', plus the characters in "-_.!~*'()", and the set of reserved characters (these characters have special meanings in the URL syntax), which are ";/?:@&=+$,".  In addition, percent escape sequences '%' hex-digit hex-digit are permitted.
+    // Plus the hash character '#' which denotes the beginning of a fragment, and can appear exactly once in the entire URL string. -- REW, 12/13/2000
+    CFStringInlineBuffer stringBuffer;
+    CFIndex idx = 0, length;
+    Boolean sawHash = false;
+    if (!string) {
+        CFAssert(false, __kCFLogAssertion, "Cannot create an CFURL from a NULL string");
+        return false;
+    }
+    length = CFStringGetLength(string);
+    CFStringInitInlineBuffer(string, &stringBuffer, CFRangeMake(0, length));
+    while (idx < length) {
+        UniChar ch = CFStringGetCharacterFromInlineBuffer(&stringBuffer, idx);
+        idx ++;
+		
+		//	Make sure that two valid hex digits follow a '%' character
+		if ( ch == '%' ) {
+			if ( idx + 2 > length )
+			{
+				//CFAssert1(false, __kCFLogAssertion, "Detected illegal percent escape sequence at character %d when trying to create a CFURL", idx-1);
+				idx = -1;  // To guarantee index < length, and our failure case is triggered
+				break;
+			}
+			
+			ch = CFStringGetCharacterFromInlineBuffer(&stringBuffer, idx);
+			idx ++;
+			if (! isHexDigit(ch) ) {
+				//CFAssert1(false, __kCFLogAssertion, "Detected illegal percent escape sequence at character %d when trying to create a CFURL", idx-2);
+				idx = -1;
+				break;
+			}
+			ch = CFStringGetCharacterFromInlineBuffer(&stringBuffer, idx);
+			idx ++;
+			if (! isHexDigit(ch) ) {
+				//CFAssert1(false, __kCFLogAssertion, "Detected illegal percent escape sequence at character %d when trying to create a CFURL", idx-3);
+				idx = -1;
+				break;
+			}
+
+			continue;
+        }
+		if (ch == '[' || ch == ']') continue; // IPV6 support (RFC 2732) DCJ June/10/2002
+        if (ch == '#') {
+            if (sawHash) break;
+            sawHash = true;
+            continue;
+        }
+		if ( isURLLegalCharacter( ch ) )
+			continue;
+		break;
+    }
+    if (idx < length) {
+        return false;
+    }
+    return true;
+}
+
+CF_EXPORT void _CFURLInitWithString(CFURLRef myURL, CFStringRef string, CFURLRef baseURL) {
+    struct __CFURL *url = (struct __CFURL *)myURL; // Supress annoying compile warnings
+    Boolean isAbsolute = false;
+    CFRange colon = CFStringFind(string, CFSTR(":"), 0);
+    if (colon.location != kCFNotFound) {
+        isAbsolute = true;
+        CFIndex i;
+        for (i = 0; i < colon.location; i++) {
+            char ch = (char)CFStringGetCharacterAtIndex(string, i);
+            if (!scheme_valid(ch)) {
+                isAbsolute = false;
+                break;
+            }
+        }
+    }
+    _CFURLInit(url, string, FULL_URL_REPRESENTATION, isAbsolute ? NULL : baseURL);
+    if (isAbsolute) {
+        url->_flags |= IS_ABSOLUTE;
+    }
+}
+
+struct __CFURLEncodingTranslationParameters {
+    CFStringEncoding fromEnc;
+    CFStringEncoding toEnc;
+    const UniChar *addlChars;
+    int count;
+    Boolean escapeHighBit;
+    Boolean escapePercents;
+    Boolean agreesOverASCII;
+    Boolean encodingsMatch;
+} ;
+
+static Boolean _shouldEscapeForEncodingConversion(UniChar ch, void *context) {
+    struct __CFURLEncodingTranslationParameters *info = (struct __CFURLEncodingTranslationParameters *)context;
+    if (info->escapeHighBit && ch > 0x7F) {
+        return true;
+    } else if (ch == '%' && info->escapePercents) {
+        return true;
+    } else if (info->addlChars) {
+        const UniChar *escChar = info->addlChars;
+        int i; 
+        for (i = 0; i < info->count; escChar ++, i ++) {
+            if (*escChar == ch) {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+static CFIndex _convertEscapeSequence(CFIndex percentIndex, CFStringRef urlString, CFStringRef *newString, void *context) {
+    struct __CFURLEncodingTranslationParameters *info = (struct __CFURLEncodingTranslationParameters *)context;
+    CFMutableDataRef  newData;
+    Boolean sawNonASCIICharacter = false;
+    CFIndex i = percentIndex;
+    CFIndex length;
+    *newString = NULL;
+    if (info->encodingsMatch) return percentIndex + 3; // +3 because we want the two characters of the percent encoding to not be copied verbatim, as well
+    newData = CFDataCreateMutable(CFGetAllocator(urlString), 0);
+    length = CFStringGetLength(urlString);
+    
+    while (i < length && CFStringGetCharacterAtIndex(urlString, i) == '%') {
+        uint8_t byte;
+        if (i+2 >= length || !_translateBytes(CFStringGetCharacterAtIndex(urlString, i+1), CFStringGetCharacterAtIndex(urlString, i+2), &byte)) {
+            CFRelease(newData);
+            return -1;
+        }
+        if (byte > 0x7f) sawNonASCIICharacter = true;
+        CFDataAppendBytes(newData, &byte, 1);
+        i += 3;
+    }
+    if (!sawNonASCIICharacter && info->agreesOverASCII) {
+        return i;
+    } else {
+        CFStringRef tmp = CFStringCreateWithBytes(CFGetAllocator(urlString), CFDataGetBytePtr(newData), CFDataGetLength(newData), info->fromEnc, false);
+        CFIndex tmpIndex, tmpLen;
+        if (!tmp) {
+            CFRelease(newData);
+            return -1;
+        }
+        tmpLen = CFStringGetLength(tmp);
+        *newString = CFStringCreateMutable(CFGetAllocator(urlString), 0);
+        for (tmpIndex = 0; tmpIndex < tmpLen; tmpIndex ++) {
+            if (!_appendPercentEscapesForCharacter(CFStringGetCharacterAtIndex(tmp, tmpIndex), info->toEnc, (CFMutableStringRef)(*newString))) {
+                break;
+            }
+        }
+        CFRelease(tmp);
+        CFRelease(newData);
+        if (tmpIndex < tmpLen) {
+            CFRelease(*newString);
+            *newString = NULL;
+            return -1;
+        } else {
+            return i;
+        }
+    }
+}
+
+/* Returned string is retained for the caller; if escapePercents is true, then we do not look for any %-escape encodings in urlString */
+static CFStringRef  _convertPercentEscapes(CFStringRef urlString, CFStringEncoding fromEncoding, CFStringEncoding toEncoding, Boolean escapeAllHighBitCharacters, Boolean escapePercents, const UniChar *addlCharsToEscape, int numAddlChars) {
+    struct __CFURLEncodingTranslationParameters context;
+    context.fromEnc = fromEncoding;
+    context.toEnc = toEncoding;
+    context.addlChars = addlCharsToEscape;
+    context.count = numAddlChars;
+    context.escapeHighBit = escapeAllHighBitCharacters;
+    context.escapePercents = escapePercents;
+    context.agreesOverASCII = (__CFStringEncodingIsSupersetOfASCII(toEncoding) && __CFStringEncodingIsSupersetOfASCII(fromEncoding)) ? true : false;
+    context.encodingsMatch = (fromEncoding == toEncoding) ? true : false;
+    return _addPercentEscapesToString(CFGetAllocator(urlString), urlString, _shouldEscapeForEncodingConversion, _convertEscapeSequence, toEncoding, &context);
+}
+
+// encoding will be used both to interpret the bytes of URLBytes, and to interpret any percent-escapes within the bytes.
+CFURLRef CFURLCreateWithBytes(CFAllocatorRef allocator, const uint8_t *URLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL) {
+    CFStringRef  urlString = CFStringCreateWithBytes(allocator, URLBytes, length, encoding, false);
+    CFURLRef  result;
+    if (!urlString || CFStringGetLength(urlString) == 0) {
+        if (urlString) CFRelease(urlString);
+        return NULL;
+    }
+    if (createOldUTF8StyleURLs()) {
+        if (encoding != kCFStringEncodingUTF8) {
+            CFStringRef  tmp = _convertPercentEscapes(urlString, encoding, kCFStringEncodingUTF8, false, false, NULL, 0);
+            CFRelease(urlString);
+            urlString = tmp;
+            if (!urlString) return NULL;
+        }
+    }
+    
+    result = _CFURLAlloc(allocator);
+    if (result) {
+        _CFURLInitWithString(result, urlString, baseURL);
+        if (encoding != kCFStringEncodingUTF8 && !createOldUTF8StyleURLs()) {
+            ((struct __CFURL *)result)->_encoding = encoding;
+        }
+    }
+    CFRelease(urlString); // it's retained by result, now.
+    return result;
+}
+
+CFDataRef CFURLCreateData(CFAllocatorRef allocator, CFURLRef  url, CFStringEncoding encoding, Boolean escapeWhitespace) {
+    static const UniChar whitespaceChars[4] = {' ', '\n', '\r', '\t'};
+    CFStringRef  myStr = CFURLGetString(url);	
+    CFStringRef newStr;
+    CFDataRef result;
+    if (url->_flags & IS_OLD_UTF8_STYLE) {
+        newStr = (encoding == kCFStringEncodingUTF8) ? (CFStringRef)CFRetain(myStr) : _convertPercentEscapes(myStr, kCFStringEncodingUTF8, encoding, true, false, escapeWhitespace ? whitespaceChars : NULL, escapeWhitespace ? 4 : 0);
+    } else {
+        newStr=myStr;
+        CFRetain(newStr);
+    }	
+    result = CFStringCreateExternalRepresentation(allocator, newStr, encoding, 0);
+    CFRelease(newStr);
+    return result;
+}
+
+// Any escape sequences in URLString will be interpreted via UTF-8.
+CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef  URLString, CFURLRef  baseURL) {
+    CFURLRef url;
+    if (!URLString || CFStringGetLength(URLString) == 0) return NULL;
+    if (!_CFStringIsLegalURLString(URLString)) return NULL;
+    url = _CFURLAlloc(allocator);
+    if (url) {
+        _CFURLInitWithString(url, URLString, baseURL);
+    }
+    return url;
+}
+
+static CFURLRef _CFURLCreateWithArbitraryString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL) {
+    CFURLRef url;
+    if (!URLString || CFStringGetLength(URLString) == 0) return NULL;
+    url = _CFURLAlloc(allocator);
+    if (url) {
+        _CFURLInitWithString(url, URLString, baseURL);
+    }
+    return url;
+}
+
+CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode) {
+    CFStringRef relativeString = CFStringCreateWithBytes(alloc, relativeURLBytes, length, encoding, false);
+    if (!relativeString) {
+        return NULL;
+    }
+    if (!useCompatibilityMode) {
+        CFURLRef url = _CFURLCreateWithArbitraryString(alloc, relativeString, baseURL);
+        CFRelease(relativeString);
+        if (url) {
+			((struct __CFURL *)url)->_encoding = encoding;
+            CFURLRef absURL = CFURLCopyAbsoluteURL(url);
+            CFRelease(url);
+            return absURL;
+        } else {
+            return NULL;
+        }
+    } else {
+        UInt32 absFlags = 0;
+        CFRange *absRanges;
+        CFStringRef absString = NULL;
+        Boolean absStringIsMutable = false;
+        CFURLRef absURL;
+        if (!baseURL) {
+            absString = relativeString;
+        } else {
+            UniChar ch = CFStringGetCharacterAtIndex(relativeString, 0);
+            if (ch == '?' || ch == ';' || ch == '#') {
+                // Nothing but parameter + query + fragment; append to the baseURL string
+                CFStringRef baseString;
+                if (CF_IS_OBJC(__kCFURLTypeID, baseURL)) {
+                    baseString = CFURLGetString(baseURL);
+                } else {
+                    baseString = baseURL->_string;
+                }
+                absString = CFStringCreateMutable(alloc, CFStringGetLength(baseString) + CFStringGetLength(relativeString));
+                CFStringAppend((CFMutableStringRef)absString, baseString);
+                CFStringAppend((CFMutableStringRef)absString, relativeString);
+                absStringIsMutable = true;
+            } else {
+                UInt32 relFlags = 0;
+                CFRange *relRanges;
+                CFStringRef relString = NULL;
+                _parseComponents(alloc, relativeString, baseURL, &relFlags, &relRanges);
+                if (relFlags & HAS_SCHEME) {
+                    CFStringRef baseScheme = CFURLCopyScheme(baseURL);
+                    CFRange relSchemeRange = _rangeForComponent(relFlags, relRanges, HAS_SCHEME);
+                    if (baseScheme && CFStringGetLength(baseScheme) == relSchemeRange.length && CFStringHasPrefix(relativeString, baseScheme)) {
+                        relString = CFStringCreateWithSubstring(alloc, relativeString, CFRangeMake(relSchemeRange.length+1, CFStringGetLength(relativeString) - relSchemeRange.length - 1));
+                        CFAllocatorDeallocate(alloc, relRanges);
+                        relFlags = 0;
+                        _parseComponents(alloc, relString, baseURL, &relFlags, &relRanges);
+                    } else {
+                        // Discard the base string; the relative string is absolute and we're not in the funky edge case where the schemes match
+                        CFRetain(relativeString);
+                        absString = relativeString;
+                    }
+                    if (baseScheme) CFRelease(baseScheme);
+                } else {
+                    CFRetain(relativeString);
+                    relString = relativeString;
+                }
+                if (!absString) {
+                    if (!CF_IS_OBJC(__kCFURLTypeID, baseURL)) {
+                        if (!(baseURL->_flags & IS_PARSED)) {
+                            _parseComponentsOfURL(baseURL);
+                        }
+                        absString = resolveAbsoluteURLString(alloc, relString, relFlags, relRanges, baseURL->_string, baseURL->_flags, baseURL->ranges);
+                    } else {
+                        CFStringRef baseString;
+                        UInt32 baseFlags = 0;
+                        CFRange *baseRanges;
+                        if (CF_IS_OBJC(__kCFURLTypeID, baseURL)) {
+                            baseString = CFURLGetString(baseURL);
+                        } else {
+                            baseString = baseURL->_string;
+                        }
+                        _parseComponents(alloc, baseString, NULL, &baseFlags, &baseRanges);
+                        absString = resolveAbsoluteURLString(alloc, relString, relFlags, relRanges, baseString, baseFlags, baseRanges);
+                        CFAllocatorDeallocate(alloc, baseRanges);
+                    }
+                    absStringIsMutable = true;
+                }
+                if (relString) CFRelease(relString);
+                CFAllocatorDeallocate(alloc, relRanges);
+            }
+            CFRelease(relativeString);
+        }
+        _parseComponents(alloc, absString, NULL, &absFlags, &absRanges);
+        if (absFlags & HAS_PATH) {
+            CFRange pathRg = _rangeForComponent(absFlags, absRanges, HAS_PATH);
+            // This is expensive, but it allows us to reuse _resolvedPath.  It should be cleaned up to get this allocation removed at some point. - REW
+            UniChar *buf = (UniChar *)CFAllocatorAllocate(alloc, sizeof(UniChar) * (pathRg.length + 1), 0);
+            CFStringRef newPath;
+            CFStringGetCharacters(absString, pathRg, buf);
+            buf[pathRg.length] = '\0';
+            newPath = _resolvedPath(buf, buf + pathRg.length, '/', true, false, alloc);
+            if (CFStringGetLength(newPath) != pathRg.length) {
+                if (!absStringIsMutable) {
+                    CFStringRef tmp = CFStringCreateMutableCopy(alloc, CFStringGetLength(absString), absString);
+                    CFRelease(absString);
+                    absString = tmp;
+                }
+                CFStringReplace((CFMutableStringRef)absString, pathRg, newPath);
+            }
+            CFRelease(newPath);
+            // Do not deallocate buf; newPath took ownership of it.
+        }
+        CFAllocatorDeallocate(alloc, absRanges);
+        absURL = _CFURLCreateWithArbitraryString(alloc, absString, NULL);
+        CFRelease(absString);
+        if (absURL) {
+            ((struct __CFURL *)absURL)->_encoding = encoding;
+        }
+        return absURL;
+    }
+}
+
+/* This function is this way because I pulled it out of _resolvedURLPath (so that _resolvedFileSystemPath could use it), and I didn't want to spend a bunch of energy reworking the code.  So instead of being a bit more intelligent about inputs, it just demands a slightly perverse set of parameters, to match the old _resolvedURLPath code.  -- REW, 6/14/99 */
+static CFStringRef _resolvedPath(UniChar *pathStr, UniChar *end, UniChar pathDelimiter, Boolean stripLeadingDotDots, Boolean stripTrailingDelimiter, CFAllocatorRef alloc) {
+    UniChar *idx = pathStr;
+    while (idx < end) {
+        if (*idx == '.') {
+            if (idx+1 == end) {
+                if (idx != pathStr) {
+                    *idx = '\0';
+                    end = idx;
+                }
+                break;
+            } else if (*(idx+1) == pathDelimiter) {
+                if (idx + 2 != end || idx != pathStr) {
+                    memmove(idx, idx+2, (end-(idx+2)+1) * sizeof(UniChar));
+                    end -= 2;
+                    continue;
+                } else {
+                    // Do not delete the sole path component
+                    break;
+                }
+            } else if (( end-idx >= 2 ) &&  *(idx+1) == '.' && (idx+2 == end || (( end-idx > 2 ) && *(idx+2) == pathDelimiter))) {
+                if (idx - pathStr >= 2) {
+                    // Need at least 2 characters between index and pathStr, because we know if index != newPath, then *(index-1) == pathDelimiter, and we need something before that to compact out.
+                    UniChar *lastDelim = idx-2;
+                    while (lastDelim >= pathStr && *lastDelim != pathDelimiter) lastDelim --;
+                    lastDelim ++;
+                    if (lastDelim != idx && (idx-lastDelim != 3 || *lastDelim != '.' || *(lastDelim +1) != '.')) {
+                        // We have a genuine component to compact out
+                        if (idx+2 != end) {
+                            unsigned numCharsToMove = end - (idx+3) + 1; // +1 to move the '\0' as well
+                            memmove(lastDelim, idx+3, numCharsToMove * sizeof(UniChar));
+                            end -= (idx + 3 - lastDelim);
+                            idx = lastDelim;
+                            continue;
+                        } else if (lastDelim != pathStr) {
+                            *lastDelim = '\0';
+                            end = lastDelim;
+                            break;
+                        } else {
+                            // Don't allow the path string to devolve to the empty string.  Fall back to "." instead. - REW
+                            pathStr[0] = '.';
+                            pathStr[1] = '/';
+                            pathStr[2] = '\0';
+							end = & pathStr[3];
+                            break;
+                        }
+                    }
+                } else if (stripLeadingDotDots) {
+                    if (idx + 3 != end) {
+                        unsigned numCharsToMove = end - (idx + 3) + 1;
+                        memmove(idx, idx+3, numCharsToMove * sizeof(UniChar));
+                        end -= 3;
+                        continue;
+                    } else {
+                        // Do not devolve the last path component
+                        break;
+                    }
+                }
+            }
+        }
+		while (idx < end && *idx != pathDelimiter) idx ++;
+        idx ++;
+    }
+    if (stripTrailingDelimiter && end > pathStr && end-1 != pathStr && *(end-1) == pathDelimiter) {
+        end --;
+    }
+    return CFStringCreateWithCharactersNoCopy(alloc, pathStr, end - pathStr, alloc);
+}
+
+static CFMutableStringRef resolveAbsoluteURLString(CFAllocatorRef alloc, CFStringRef relString, UInt32 relFlags, CFRange *relRanges, CFStringRef baseString, UInt32 baseFlags, CFRange *baseRanges) {
+    CFMutableStringRef newString = CFStringCreateMutable(alloc, 0);
+    CFIndex bufLen = CFStringGetLength(baseString) + CFStringGetLength(relString); // Overkill, but guarantees we never allocate again
+    UniChar *buf = (UniChar *)CFAllocatorAllocate(alloc, bufLen * sizeof(UniChar), 0);
+    CFRange rg;
+    
+    rg = _rangeForComponent(baseFlags, baseRanges, HAS_SCHEME);
+    if (rg.location != kCFNotFound) {
+        CFStringGetCharacters(baseString, rg, buf);
+        CFStringAppendCharacters(newString, buf, rg.length);
+        CFStringAppendCString(newString, ":", kCFStringEncodingASCII);
+    }
+
+    if (relFlags & NET_LOCATION_MASK) {
+        CFStringAppend(newString, relString);
+    } else {
+        CFStringAppendCString(newString, "//", kCFStringEncodingASCII);
+        rg = _netLocationRange(baseFlags, baseRanges);
+        if (rg.location != kCFNotFound) {
+            CFStringGetCharacters(baseString, rg, buf);
+            CFStringAppendCharacters(newString, buf, rg.length);
+        }
+
+        if (relFlags & HAS_PATH) {
+            CFRange relPathRg = _rangeForComponent(relFlags, relRanges, HAS_PATH);
+            CFRange basePathRg = _rangeForComponent(baseFlags, baseRanges, HAS_PATH);
+            CFStringRef newPath;
+            Boolean useRelPath = false;
+            Boolean useBasePath = false;
+            if (basePathRg.location == kCFNotFound) {
+                useRelPath = true;
+            } else if (relPathRg.length == 0) {
+                useBasePath = true;
+            } else if (CFStringGetCharacterAtIndex(relString, relPathRg.location) == '/') {
+                useRelPath = true;
+            } else if (basePathRg.location == kCFNotFound || basePathRg.length == 0) {
+                useRelPath = true;
+            }
+            if (useRelPath) {
+                newPath = CFStringCreateWithSubstring(alloc, relString, relPathRg);
+            } else if (useBasePath) {
+                newPath = CFStringCreateWithSubstring(alloc, baseString, basePathRg);
+            } else {
+                // #warning FIXME - Get rid of this allocation
+                UniChar *newPathBuf = (UniChar *)CFAllocatorAllocate(alloc, sizeof(UniChar) * (relPathRg.length + basePathRg.length + 1), 0);
+                UniChar *idx, *end;
+                CFStringGetCharacters(baseString, basePathRg, newPathBuf);
+                idx = newPathBuf + basePathRg.length - 1;
+                while (idx != newPathBuf && *idx != '/') idx --;
+                if (*idx == '/') idx ++;
+                CFStringGetCharacters(relString, relPathRg, idx);
+                end = idx + relPathRg.length;
+                *end = 0;
+                newPath = _resolvedPath(newPathBuf, end, '/', false, false, alloc);
+            }
+            /* Under Win32 absolute path can begin with letter
+             * so we have to add one '/' to the newString
+             * (Sergey Zubarev)
+             */
+             // No - the input strings here are URL path strings, not Win32 paths.  
+             // Absolute paths should have had a '/' prepended before this point. 
+             // I have removed Sergey Zubarev's change and left his comment (and
+             // this one) as a record. - REW, 1/5/2004
+            
+            // if the relative URL does not begin with a slash and
+            // the base does not end with a slash, add a slash
+            if ((basePathRg.location == kCFNotFound || basePathRg.length == 0) && CFStringGetCharacterAtIndex(newPath, 0) != '/') {
+                CFStringAppendCString(newString, "/", kCFStringEncodingASCII);
+            }
+            
+            CFStringAppend(newString, newPath);
+            CFRelease(newPath);
+            rg.location = relPathRg.location + relPathRg.length;
+            rg.length = CFStringGetLength(relString);
+            if (rg.length > rg.location) {
+                rg.length -= rg.location; 
+                CFStringGetCharacters(relString, rg, buf);
+                CFStringAppendCharacters(newString, buf, rg.length);
+            }
+        } else {
+            rg = _rangeForComponent(baseFlags, baseRanges, HAS_PATH);
+            if (rg.location != kCFNotFound) {
+                CFStringGetCharacters(baseString, rg, buf);
+                CFStringAppendCharacters(newString, buf, rg.length);
+            }
+
+            if (!(relFlags & RESOURCE_SPECIFIER_MASK)) {
+                // ???  Can this ever happen?
+                UInt32 rsrcFlag = _firstResourceSpecifierFlag(baseFlags);
+                if (rsrcFlag) {
+                    rg.location = _rangeForComponent(baseFlags, baseRanges, rsrcFlag).location;
+                    rg.length = CFStringGetLength(baseString) - rg.location;
+                    rg.location --; // To pick up the separator
+                    rg.length ++;
+                    CFStringGetCharacters(baseString, rg, buf);
+                    CFStringAppendCharacters(newString, buf, rg.length);
+                }
+            } else if (relFlags & HAS_PARAMETERS) {
+                rg = _rangeForComponent(relFlags, relRanges, HAS_PARAMETERS);
+                rg.location --; // To get the semicolon that starts the parameters
+                rg.length = CFStringGetLength(relString) - rg.location;
+                CFStringGetCharacters(relString, rg, buf);
+                CFStringAppendCharacters(newString, buf, rg.length);
+            } else {
+                // Sigh; we have to resolve these against one another
+                rg = _rangeForComponent(baseFlags, baseRanges, HAS_PARAMETERS);
+                if (rg.location != kCFNotFound) {
+                    CFStringAppendCString(newString, ";", kCFStringEncodingASCII);
+                    CFStringGetCharacters(baseString, rg, buf);
+                    CFStringAppendCharacters(newString, buf, rg.length);
+                }
+                rg = _rangeForComponent(relFlags, relRanges, HAS_QUERY);
+                if (rg.location != kCFNotFound) {
+                    CFStringAppendCString(newString, "?", kCFStringEncodingASCII);
+                    CFStringGetCharacters(relString, rg, buf);
+                    CFStringAppendCharacters(newString, buf, rg.length);
+                } else {
+                    rg = _rangeForComponent(baseFlags, baseRanges, HAS_QUERY);
+                    if (rg.location != kCFNotFound) {
+                        CFStringAppendCString(newString, "?", kCFStringEncodingASCII);
+                        CFStringGetCharacters(baseString, rg, buf);
+                        CFStringAppendCharacters(newString, buf, rg.length);
+                    }
+                }
+                // Only the relative portion of the URL can supply the fragment; otherwise, what would be in the relativeURL?
+                rg = _rangeForComponent(relFlags, relRanges, HAS_FRAGMENT);
+                if (rg.location != kCFNotFound) {
+                    CFStringAppendCString(newString, "#", kCFStringEncodingASCII);
+                    CFStringGetCharacters(relString, rg, buf);
+                    CFStringAppendCharacters(newString, buf, rg.length);
+                }
+            }
+        }
+    }
+    CFAllocatorDeallocate(alloc, buf);
+    return newString;
+}
+
+CFURLRef CFURLCopyAbsoluteURL(CFURLRef  relativeURL) {
+    CFURLRef  anURL, base;
+    CFURLPathStyle fsType;
+    CFAllocatorRef alloc = CFGetAllocator(relativeURL);
+    CFStringRef baseString, newString;
+    UInt32 baseFlags;
+    CFRange *baseRanges;
+    Boolean baseIsObjC;
+
+    CFAssert1(relativeURL != NULL, __kCFLogAssertion, "%s(): Cannot create an absolute URL from a NULL relative URL", __PRETTY_FUNCTION__);
+    if (CF_IS_OBJC(__kCFURLTypeID, relativeURL)) {
+        CF_OBJC_CALL0(CFURLRef, anURL, relativeURL, "absoluteURL");
+        if (anURL) CFRetain(anURL);
+        return anURL;
+    } 
+
+    __CFGenericValidateType(relativeURL, __kCFURLTypeID);
+
+    base = relativeURL->_base;
+    if (!base) {
+        return (CFURLRef)CFRetain(relativeURL);
+    }
+    baseIsObjC = CF_IS_OBJC(__kCFURLTypeID, base);
+    fsType = URL_PATH_TYPE(relativeURL);
+
+    if (!baseIsObjC && fsType != FULL_URL_REPRESENTATION && fsType == URL_PATH_TYPE(base)) {
+        return _CFURLCopyAbsoluteFileURL(relativeURL);
+    }
+    if (fsType != FULL_URL_REPRESENTATION) {
+        _convertToURLRepresentation((struct __CFURL *)relativeURL);
+        fsType = FULL_URL_REPRESENTATION;
+    }
+    if (!(relativeURL->_flags & IS_PARSED)) {
+        _parseComponentsOfURL(relativeURL);
+    }
+    if ((relativeURL->_flags & POSIX_AND_URL_PATHS_MATCH) && !(relativeURL->_flags & (RESOURCE_SPECIFIER_MASK | NET_LOCATION_MASK)) && !baseIsObjC && (URL_PATH_TYPE(base) == kCFURLPOSIXPathStyle)) {
+        // There's nothing to relativeURL's string except the path
+        CFStringRef newPath = _resolveFileSystemPaths(relativeURL->_string, base->_string, CFURLHasDirectoryPath(base), kCFURLPOSIXPathStyle, alloc);
+        CFURLRef result = CFURLCreateWithFileSystemPath(alloc, newPath, kCFURLPOSIXPathStyle, CFURLHasDirectoryPath(relativeURL));
+        CFRelease(newPath);
+        return result;
+    }
+
+    if (!baseIsObjC) {
+        CFURLPathStyle baseType = URL_PATH_TYPE(base);
+        if (baseType != FULL_URL_REPRESENTATION) {
+            _convertToURLRepresentation((struct __CFURL *)base);
+        } else if (!(base->_flags & IS_PARSED)) {
+            _parseComponentsOfURL(base);
+        }
+        baseString = base->_string;
+        baseFlags = base->_flags;
+        baseRanges = base->ranges;
+    } else {
+        baseString = CFURLGetString(base);
+        baseFlags = 0;
+        baseRanges = NULL;
+        _parseComponents(alloc, baseString, NULL, &baseFlags, &baseRanges);
+    }
+    
+    newString = resolveAbsoluteURLString(alloc, relativeURL->_string, relativeURL->_flags, relativeURL->ranges, baseString, baseFlags, baseRanges);
+    if (baseIsObjC) {
+        CFAllocatorDeallocate(alloc, baseRanges);
+    }
+    anURL = _CFURLCreateWithArbitraryString(alloc, newString, NULL);
+    CFRelease(newString);
+    ((struct __CFURL *)anURL)->_encoding = relativeURL->_encoding;
+    return anURL;
+}
+
+
+/*******************/
+/* Basic accessors */
+/*******************/
+CFStringEncoding _CFURLGetEncoding(CFURLRef url) {
+    return url->_encoding;
+}
+
+Boolean CFURLCanBeDecomposed(CFURLRef  anURL) {
+    anURL = _CFURLFromNSURL(anURL);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) return true;
+    if (!(anURL->_flags & IS_PARSED)) {
+        _parseComponentsOfURL(anURL);
+    }
+    return ((anURL->_flags & IS_DECOMPOSABLE) != 0);
+}
+
+CFStringRef  CFURLGetString(CFURLRef  url) {
+    CF_OBJC_FUNCDISPATCH0(__kCFURLTypeID, CFStringRef  , url, "relativeString");
+    if (URL_PATH_TYPE(url) != FULL_URL_REPRESENTATION) {
+        if (url->_base && (url->_flags & POSIX_AND_URL_PATHS_MATCH)) {
+            return url->_string;
+        }
+        _convertToURLRepresentation((struct __CFURL *)url);
+    }
+    if (!_haveTestedOriginalString(url)) {
+        computeSanitizedString(url);
+    }
+    if (url->_flags & ORIGINAL_AND_URL_STRINGS_MATCH) {
+        return url->_string;
+    } else {
+        return _getSanitizedString( url );
+    }
+}
+
+CFIndex CFURLGetBytes(CFURLRef url, UInt8 *buffer, CFIndex bufferLength) {
+    CFIndex length, charsConverted, usedLength;
+    CFStringRef string;
+    CFStringEncoding enc;
+    if (CF_IS_OBJC(__kCFURLTypeID, url)) {
+        string = CFURLGetString(url);
+        enc = kCFStringEncodingUTF8;
+    } else {
+        if (URL_PATH_TYPE(url) != FULL_URL_REPRESENTATION) {
+            _convertToURLRepresentation((struct __CFURL *)url);
+        }
+        string = url->_string;
+        enc = url->_encoding;
+    }
+    length = CFStringGetLength(string);
+    charsConverted = CFStringGetBytes(string, CFRangeMake(0, length), enc, 0, false, buffer, bufferLength, &usedLength);
+    if (charsConverted != length) {
+        return -1;
+    } else {
+        return usedLength;
+    }
+}
+
+CFURLRef  CFURLGetBaseURL(CFURLRef  anURL) {
+    CF_OBJC_FUNCDISPATCH0(__kCFURLTypeID, CFURLRef, anURL, "baseURL");
+    return anURL->_base;
+}
+
+// Assumes the URL is already parsed
+static CFRange _rangeForComponent(UInt32 flags, CFRange *ranges, UInt32 compFlag) {
+    UInt32 idx = 0;
+    if (!(flags & compFlag)) return CFRangeMake(kCFNotFound, 0);
+    while (!(compFlag & 1)) {
+        compFlag = compFlag >> 1;
+        if (flags & 1) {
+            idx ++;
+        }
+        flags = flags >> 1;
+    }
+    return ranges[idx];
+}
+ 
+static CFStringRef _retainedComponentString(CFURLRef url, UInt32 compFlag, Boolean fromOriginalString, Boolean removePercentEscapes) {
+    CFRange rg;
+    CFStringRef comp;
+    CFAllocatorRef alloc = CFGetAllocator(url);
+    CFAssert1(URL_PATH_TYPE(url) == FULL_URL_REPRESENTATION, __kCFLogAssertion, "%s(): passed a file system URL", __PRETTY_FUNCTION__);
+    if (removePercentEscapes) fromOriginalString = true;
+    if (!(url->_flags & IS_PARSED)) {
+        _parseComponentsOfURL(url);
+    }
+    rg = _rangeForComponent(url->_flags, url->ranges, compFlag);
+    if (rg.location == kCFNotFound) return NULL;
+	if (compFlag & HAS_SCHEME && url->_flags & HAS_HTTP_SCHEME) {
+		comp = kCFURLHTTPScheme;
+		CFRetain(comp);
+	} else if (compFlag & HAS_SCHEME && url->_flags & HAS_FILE_SCHEME) {
+		comp = kCFURLFileScheme;
+		CFRetain(comp);
+	} else {
+		comp = CFStringCreateWithSubstring(alloc, url->_string, rg);
+	}
+    if (!fromOriginalString) {
+        if (!_haveTestedOriginalString(url)) {
+            computeSanitizedString(url);
+        }
+        if (!(url->_flags & ORIGINAL_AND_URL_STRINGS_MATCH) && (url->_flags & (compFlag << BIT_SHIFT_FROM_COMPONENT_TO_DIFFERS_FLAG))) {
+            CFStringRef newComp = correctedComponent(comp, compFlag, url->_encoding);
+            CFRelease(comp);
+            comp = newComp;
+        }
+    }
+    if (removePercentEscapes) {
+        CFStringRef tmp;
+        if (url->_flags & IS_OLD_UTF8_STYLE || url->_encoding == kCFStringEncodingUTF8) {
+            tmp = CFURLCreateStringByReplacingPercentEscapes(alloc, comp, CFSTR(""));
+        } else {
+            tmp = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(alloc, comp, CFSTR(""), url->_encoding);
+        }
+        CFRelease(comp);
+        comp = tmp;
+    }
+    return comp;
+}
+
+CFStringRef  CFURLCopyScheme(CFURLRef  anURL) {
+    CFStringRef scheme;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CF_OBJC_CALL0(CFStringRef, scheme, anURL, "scheme");
+        if (scheme) CFRetain(scheme);
+        return scheme;
+    } 
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        if (anURL->_base) {
+            return CFURLCopyScheme(anURL->_base);
+        } else {
+            CFRetain(kCFURLFileScheme); // because caller will release it
+            return kCFURLFileScheme;
+        }
+    } 
+    if (anURL->_flags & IS_PARSED && anURL->_flags & HAS_HTTP_SCHEME) {
+        CFRetain(kCFURLHTTPScheme);
+        return kCFURLHTTPScheme;
+    }
+    if (anURL->_flags & IS_PARSED && anURL->_flags & HAS_FILE_SCHEME) {
+        CFRetain(kCFURLFileScheme);
+        return kCFURLFileScheme;
+    }
+    scheme = _retainedComponentString(anURL, HAS_SCHEME, true, false);
+    if (scheme) {
+        return scheme;
+    } else if (anURL->_base) {
+        return CFURLCopyScheme(anURL->_base);
+    } else {
+        return NULL;
+    }
+}
+
+static CFRange _netLocationRange(UInt32 flags, CFRange *ranges) {
+    CFRange netRgs[4];
+    CFRange netRg = {kCFNotFound, 0};
+    CFIndex i, c = 4;
+
+    if ((flags & NET_LOCATION_MASK) == 0) return CFRangeMake(kCFNotFound, 0);
+
+    netRgs[0] = _rangeForComponent(flags, ranges, HAS_USER);
+    netRgs[1] = _rangeForComponent(flags, ranges, HAS_PASSWORD);
+    netRgs[2] = _rangeForComponent(flags, ranges, HAS_HOST);
+    netRgs[3] = _rangeForComponent(flags, ranges, HAS_PORT);
+    for (i = 0; i < c; i ++) {
+        if (netRgs[i].location == kCFNotFound) continue;
+        if (netRg.location == kCFNotFound) {
+            netRg = netRgs[i];
+        } else {
+            netRg.length = netRgs[i].location + netRgs[i].length - netRg.location;
+        }
+    }
+    return netRg;
+}
+
+CFStringRef CFURLCopyNetLocation(CFURLRef  anURL) {
+    anURL = _CFURLFromNSURL(anURL);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        // !!! This won't work if we go to putting the vol ref num in the net location for HFS
+        if (anURL->_base) {
+            return CFURLCopyNetLocation(anURL->_base);
+        } else {
+            CFRetain(kCFURLLocalhost);
+            return kCFURLLocalhost;
+        }
+    }
+    if (!(anURL->_flags & IS_PARSED)) {
+        _parseComponentsOfURL(anURL);
+    }
+    if (anURL->_flags & NET_LOCATION_MASK) {
+        // We provide the net location
+        CFRange netRg = _netLocationRange(anURL->_flags, anURL->ranges);
+        CFStringRef netLoc;
+        if (!_haveTestedOriginalString(anURL)) {
+            computeSanitizedString(anURL);
+        }
+        if (!(anURL->_flags & ORIGINAL_AND_URL_STRINGS_MATCH) && (anURL->_flags & (USER_DIFFERS | PASSWORD_DIFFERS | HOST_DIFFERS | PORT_DIFFERS))) {
+            // Only thing that can come before the net location is the scheme.  It's impossible for the scheme to contain percent escapes.  Therefore, we can use the location of netRg in _sanatizedString, just not the length. 
+            CFRange netLocEnd;
+            netRg.length = CFStringGetLength( _getSanitizedString(anURL)) - netRg.location;
+            if (CFStringFindWithOptions(_getSanitizedString(anURL), CFSTR("/"), netRg, 0, &netLocEnd)) {
+                netRg.length = netLocEnd.location - netRg.location;
+            }
+            netLoc = CFStringCreateWithSubstring(CFGetAllocator(anURL), _getSanitizedString(anURL), netRg);
+        } else {
+            netLoc = CFStringCreateWithSubstring(CFGetAllocator(anURL), anURL->_string, netRg);
+        }
+        return netLoc;
+    } else if (anURL->_base) {
+        return CFURLCopyNetLocation(anURL->_base);
+    } else {
+        return NULL;
+    }
+}
+
+// NOTE - if you want an absolute path, you must first get the absolute URL.  If you want a file system path, use the file system methods above.
+CFStringRef  CFURLCopyPath(CFURLRef  anURL) {
+    anURL = _CFURLFromNSURL(anURL);
+    if (URL_PATH_TYPE(anURL) == kCFURLPOSIXPathStyle && (anURL->_flags & POSIX_AND_URL_PATHS_MATCH)) {
+        CFRetain(anURL->_string);
+        return anURL->_string;
+    }
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        _convertToURLRepresentation((struct __CFURL *)anURL);
+    }
+    return _retainedComponentString(anURL, HAS_PATH, false, false);
+}
+
+/* NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL against its base.  See also CFCreateAbsoluteURL().  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.
+*/
+CFStringRef CFURLCopyStrictPath(CFURLRef anURL, Boolean *isAbsolute) {
+    CFStringRef path = CFURLCopyPath(anURL);
+    if (!path || CFStringGetLength(path) == 0) {
+        if (path) CFRelease(path);
+        if (isAbsolute) *isAbsolute = false;
+        return NULL;
+    }
+    if (CFStringGetCharacterAtIndex(path, 0) == '/') {
+        CFStringRef tmp;
+        if (isAbsolute) *isAbsolute = true;
+        tmp = CFStringCreateWithSubstring(CFGetAllocator(path), path, CFRangeMake(1, CFStringGetLength(path)-1));
+        CFRelease(path);
+        path = tmp;
+    } else {
+        if (isAbsolute) *isAbsolute = false;
+    }
+    return path;
+}
+
+Boolean CFURLHasDirectoryPath(CFURLRef  anURL) {
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) == FULL_URL_REPRESENTATION) {
+        if (!(anURL->_flags & IS_PARSED)) {
+            _parseComponentsOfURL(anURL);
+        }
+        if (!anURL->_base || (anURL->_flags & (HAS_PATH | NET_LOCATION_MASK))) {
+            return ((anURL->_flags & IS_DIRECTORY) != 0);
+        }
+        return CFURLHasDirectoryPath(anURL->_base);
+    }
+    return ((anURL->_flags & IS_DIRECTORY) != 0);
+}
+
+static UInt32 _firstResourceSpecifierFlag(UInt32 flags) {
+    UInt32 firstRsrcSpecFlag = 0;
+    UInt32 flag = HAS_FRAGMENT;
+    while (flag != HAS_PATH) {
+        if (flags & flag) {
+            firstRsrcSpecFlag = flag;
+        }
+        flag = flag >> 1;
+    }
+    return firstRsrcSpecFlag;
+}
+
+CFStringRef  CFURLCopyResourceSpecifier(CFURLRef  anURL) {
+    anURL = _CFURLFromNSURL(anURL);
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        return NULL;
+    }
+    if (!(anURL->_flags & IS_PARSED)) {
+        _parseComponentsOfURL(anURL);
+    }
+    if (!(anURL->_flags & IS_DECOMPOSABLE)) {
+        CFRange schemeRg = _rangeForComponent(anURL->_flags, anURL->ranges, HAS_SCHEME);
+        CFIndex base = schemeRg.location + schemeRg.length + 1;
+        if (!_haveTestedOriginalString(anURL)) {
+            computeSanitizedString(anURL);
+        }
+        if (_getSanitizedString(anURL)) {
+            // It is impossible to have a percent escape in the scheme (if there were one, we would have considered the URL a relativeURL with a  colon in the path instead), so this range computation is always safe.
+            return CFStringCreateWithSubstring(CFGetAllocator(anURL), _getSanitizedString(anURL), CFRangeMake(base, CFStringGetLength(_getSanitizedString(anURL))-base));
+        } else {
+            return CFStringCreateWithSubstring(CFGetAllocator(anURL), anURL->_string, CFRangeMake(base, CFStringGetLength(anURL->_string)-base));
+        }
+    } else {
+        UInt32 firstRsrcSpecFlag = _firstResourceSpecifierFlag(anURL->_flags);
+        UInt32 flag;
+        if (firstRsrcSpecFlag) {
+            Boolean canUseOriginalString = true;
+            Boolean canUseSanitizedString = true;
+            CFAllocatorRef alloc = CFGetAllocator(anURL);
+            if (!_haveTestedOriginalString(anURL)) {
+                computeSanitizedString(anURL);
+            }
+            if (!(anURL->_flags & ORIGINAL_AND_URL_STRINGS_MATCH)) {
+                // See if any pieces in the resource specifier differ between sanitized string and original string
+                for (flag = firstRsrcSpecFlag; flag != (HAS_FRAGMENT << 1); flag = flag << 1) {
+                    if (anURL->_flags & (flag << BIT_SHIFT_FROM_COMPONENT_TO_DIFFERS_FLAG)) {
+                        canUseOriginalString = false;
+                        break;
+                    }
+                }
+            }
+            if (!canUseOriginalString) {
+                // If none of the pieces prior to the first resource specifier flag differ, then we can use the offset from the original string as the offset in the sanitized string.
+                for (flag = firstRsrcSpecFlag >> 1; flag != 0; flag = flag >> 1) {
+                    if (anURL->_flags & (flag << BIT_SHIFT_FROM_COMPONENT_TO_DIFFERS_FLAG)) {
+                        canUseSanitizedString = false;
+                        break;
+                    }
+                }
+            }
+            if (canUseOriginalString) {
+                CFRange rg = _rangeForComponent(anURL->_flags, anURL->ranges, firstRsrcSpecFlag);
+                rg.location --; // Include the character that demarcates the component
+                rg.length = CFStringGetLength(anURL->_string) - rg.location;
+                return CFStringCreateWithSubstring(alloc, anURL->_string, rg);
+            } else if (canUseSanitizedString) {
+                CFRange rg = _rangeForComponent(anURL->_flags, anURL->ranges, firstRsrcSpecFlag);
+                rg.location --; // Include the character that demarcates the component
+                rg.length = CFStringGetLength(_getSanitizedString(anURL)) - rg.location;
+                return CFStringCreateWithSubstring(alloc, _getSanitizedString(anURL), rg);
+            } else {
+                // Must compute the correct string to return; just reparse....
+                UInt32 sanFlags = 0;
+                CFRange *sanRanges = NULL;
+                CFRange rg; 
+                _parseComponents(alloc, _getSanitizedString(anURL), anURL->_base, &sanFlags, &sanRanges);
+                rg = _rangeForComponent(sanFlags, sanRanges, firstRsrcSpecFlag);
+                CFAllocatorDeallocate(alloc, sanRanges);
+                rg.location --; // Include the character that demarcates the component
+                rg.length = CFStringGetLength(_getSanitizedString(anURL)) - rg.location;
+                return CFStringCreateWithSubstring(CFGetAllocator(anURL), _getSanitizedString(anURL), rg);
+            }
+        } else {
+            // The resource specifier cannot possibly come from the base.
+            return NULL;
+        }
+    }
+}
+
+/*************************************/
+/* Accessors that create new objects */
+/*************************************/
+
+// For the next four methods, it is important to realize that, if a URL supplies any part of the net location (host, user, port, or password), it must supply all of the net location (i.e. none of it comes from its base URL).  Also, it is impossible for a URL to be relative, supply none of the net location, and still have its (empty) net location take precedence over its base URL (because there's nothing that precedes the net location except the scheme, and if the URL supplied the scheme, it would be absolute, and there would be no base).
+CFStringRef  CFURLCopyHostName(CFURLRef  anURL) {
+    CFStringRef tmp;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CF_OBJC_CALL0(CFStringRef, tmp, anURL, "host");
+        if (tmp) CFRetain(tmp);
+        return tmp;
+    } 
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        if (anURL->_base) {
+            return CFURLCopyHostName(anURL->_base);
+        } else {
+            CFRetain(kCFURLLocalhost);
+            return kCFURLLocalhost;
+        }
+    }
+    tmp = _retainedComponentString(anURL, HAS_HOST, true, true);
+    if (tmp) {
+        if (anURL->_flags & IS_IPV6_ENCODED) {
+            // Have to strip off the brackets to get the true hostname.
+            // Assume that to be legal the first and last characters are brackets!
+            CFStringRef	strippedHost = CFStringCreateWithSubstring(CFGetAllocator(anURL), tmp, CFRangeMake(1, CFStringGetLength(tmp) - 2));
+            CFRelease(tmp);
+            tmp = strippedHost;
+        }
+        return tmp;
+    } else if (anURL->_base && !(anURL->_flags & NET_LOCATION_MASK) && !(anURL->_flags & HAS_SCHEME)) {
+        return CFURLCopyHostName(anURL->_base);
+    } else {
+        return NULL;
+    }
+}
+
+// Return -1 to indicate no port is specified
+SInt32 CFURLGetPortNumber(CFURLRef  anURL) {
+    CFStringRef port;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CFNumberRef cfPort;
+        CF_OBJC_CALL0(CFNumberRef, cfPort, anURL, "port");
+        SInt32 num;
+        if (cfPort && CFNumberGetValue(cfPort, kCFNumberSInt32Type, &num)) return num;
+        return -1;
+    } 
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        if (anURL->_base) {
+            return CFURLGetPortNumber(anURL->_base);
+        }
+        return -1;
+    }
+    port = _retainedComponentString(anURL, HAS_PORT, true, false);
+    if (port) {
+        SInt32 portNum, idx, length = CFStringGetLength(port);
+        CFStringInlineBuffer buf;
+        CFStringInitInlineBuffer(port, &buf, CFRangeMake(0, length));
+        idx = 0;
+        if (!__CFStringScanInteger(&buf, NULL, &idx, false, &portNum) || (idx != length)) {
+            portNum = -1;
+        }
+        CFRelease(port);
+        return portNum;
+    } else if (anURL->_base && !(anURL->_flags & NET_LOCATION_MASK) && !(anURL->_flags & HAS_SCHEME)) {
+        return CFURLGetPortNumber(anURL->_base);
+    } else {
+        return -1;
+    }
+}
+
+CFStringRef  CFURLCopyUserName(CFURLRef  anURL) {
+    CFStringRef user;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CF_OBJC_CALL0(CFStringRef, user, anURL, "user");
+        if (user) CFRetain(user);
+        return user;
+    } 
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        if (anURL->_base) {
+            return CFURLCopyUserName(anURL->_base);
+        }
+        return NULL;
+    }
+    user = _retainedComponentString(anURL, HAS_USER, true, true);
+    if (user) {
+        return user;
+    } else if (anURL->_base && !(anURL->_flags & NET_LOCATION_MASK) && !(anURL->_flags & HAS_SCHEME)) {
+        return CFURLCopyUserName(anURL->_base);
+    } else {
+        return NULL;
+    }
+}
+
+CFStringRef  CFURLCopyPassword(CFURLRef  anURL) {
+    CFStringRef passwd;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CF_OBJC_CALL0(CFStringRef, passwd, anURL, "password");
+        if (passwd) CFRetain(passwd);
+        return passwd;
+    } 
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        if (anURL->_base) {
+            return CFURLCopyPassword(anURL->_base);
+        }
+        return NULL;
+    }
+    passwd = _retainedComponentString(anURL, HAS_PASSWORD, true, true);
+    if (passwd) {
+        return passwd;
+    } else if (anURL->_base && !(anURL->_flags & NET_LOCATION_MASK) && !(anURL->_flags & HAS_SCHEME)) {
+        return CFURLCopyPassword(anURL->_base);
+    } else {
+        return NULL;
+    }
+}
+
+// The NSURL methods do not deal with escaping escape characters at all; therefore, in order to properly bridge NSURL methods, and still provide the escaping behavior that we want, we need to create functions that match the ObjC behavior exactly, and have the public CFURL... functions call these. -- REW, 10/29/98
+
+static CFStringRef  _unescapedParameterString(CFURLRef  anURL) {
+    CFStringRef str;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CF_OBJC_CALL0(CFStringRef, str, anURL, "parameterString");
+        if (str) CFRetain(str);
+        return str;
+    } 
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        return NULL;
+    }
+    str = _retainedComponentString(anURL, HAS_PARAMETERS, false, false);
+    if (str) return str;
+    if (!(anURL->_flags & IS_DECOMPOSABLE)) return NULL;
+    if (!anURL->_base || (anURL->_flags & (NET_LOCATION_MASK | HAS_PATH | HAS_SCHEME))) {
+        return NULL;
+        // Parameter string definitely coming from the relative portion of the URL
+    }
+    return _unescapedParameterString( anURL->_base);
+}
+
+CFStringRef  CFURLCopyParameterString(CFURLRef  anURL, CFStringRef charactersToLeaveEscaped) {
+    CFStringRef  param = _unescapedParameterString(anURL);
+    if (param) {
+        CFStringRef result;
+        if (anURL->_flags & IS_OLD_UTF8_STYLE || anURL->_encoding == kCFStringEncodingUTF8) {
+            result = CFURLCreateStringByReplacingPercentEscapes(CFGetAllocator(anURL), param, charactersToLeaveEscaped);
+        } else {
+            result = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFGetAllocator(anURL), param, charactersToLeaveEscaped, anURL->_encoding);
+        }
+        CFRelease(param);
+        return result;
+    }
+    return NULL;
+}
+
+static CFStringRef  _unescapedQueryString(CFURLRef  anURL) {
+    CFStringRef str;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CF_OBJC_CALL0(CFStringRef, str, anURL, "query");
+        if (str) CFRetain(str);
+        return str;
+    } 
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        return NULL;
+    }
+    str = _retainedComponentString(anURL, HAS_QUERY, false, false);
+    if (str) return str;
+    if (!(anURL->_flags & IS_DECOMPOSABLE)) return NULL;
+    if (!anURL->_base || (anURL->_flags & (HAS_SCHEME | NET_LOCATION_MASK | HAS_PATH | HAS_PARAMETERS))) {
+        return NULL;
+    }
+    return _unescapedQueryString(anURL->_base);
+}
+
+CFStringRef  CFURLCopyQueryString(CFURLRef  anURL, CFStringRef  charactersToLeaveEscaped) {
+    CFStringRef  query = _unescapedQueryString(anURL);
+    if (query) {
+        CFStringRef tmp;
+        if (anURL->_flags & IS_OLD_UTF8_STYLE || anURL->_encoding == kCFStringEncodingUTF8) {
+            tmp = CFURLCreateStringByReplacingPercentEscapes(CFGetAllocator(anURL), query, charactersToLeaveEscaped);
+        } else {
+            tmp = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFGetAllocator(anURL), query, charactersToLeaveEscaped, anURL->_encoding);
+        }
+        CFRelease(query);
+        return tmp;
+    }
+    return NULL;
+}
+
+// Fragments are NEVER taken from a base URL
+static CFStringRef  _unescapedFragment(CFURLRef  anURL) {
+    CFStringRef str;
+    if (CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        CF_OBJC_CALL0(CFStringRef, str, anURL, "fragment");
+        if (str) CFRetain(str);
+        return str;
+    } 
+    __CFGenericValidateType(anURL, __kCFURLTypeID);
+    if (URL_PATH_TYPE(anURL) != FULL_URL_REPRESENTATION) {
+        return NULL;
+    }
+    str = _retainedComponentString(anURL, HAS_FRAGMENT, false, false);
+    return str;
+}
+
+CFStringRef  CFURLCopyFragment(CFURLRef  anURL, CFStringRef  charactersToLeaveEscaped) {
+    CFStringRef  fragment = _unescapedFragment(anURL);
+    if (fragment) {
+        CFStringRef tmp;
+        if (anURL->_flags & IS_OLD_UTF8_STYLE || anURL->_encoding == kCFStringEncodingUTF8) {
+            tmp = CFURLCreateStringByReplacingPercentEscapes(CFGetAllocator(anURL), fragment, charactersToLeaveEscaped);
+        } else {
+            tmp = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFGetAllocator(anURL), fragment, charactersToLeaveEscaped, anURL->_encoding);
+        }
+        CFRelease(fragment);
+        return tmp;
+    }
+    return NULL;
+}
+
+static CFIndex insertionLocationForMask(CFURLRef url, CFOptionFlags mask) {
+    CFIndex firstMaskFlag = 1;
+    CFIndex lastComponentBeforeMask = 0;
+    while (firstMaskFlag <= HAS_FRAGMENT) {
+        if (firstMaskFlag & mask) break;
+        if (url->_flags & firstMaskFlag) lastComponentBeforeMask = firstMaskFlag;
+        firstMaskFlag = firstMaskFlag << 1;
+    }
+    if (lastComponentBeforeMask == 0) {
+        // mask includes HAS_SCHEME
+        return 0;
+    } else if (lastComponentBeforeMask == HAS_SCHEME) {
+        // Do not have to worry about the non-decomposable case here.  However, we must be prepared for the degenerate
+        // case file:/path/immediately/without/host
+        CFRange schemeRg = _rangeForComponent(url->_flags, url->ranges, HAS_SCHEME);
+        CFRange pathRg = _rangeForComponent(url->_flags, url->ranges, HAS_PATH);
+        if (schemeRg.length + 1 == pathRg.location) {
+            return schemeRg.length + 1;
+        } else {
+            return schemeRg.length + 3;
+        }
+    } else {
+        // For all other components, the separator precedes the component, so there's no need
+        // to add extra chars to get to the next insertion point
+        CFRange rg = _rangeForComponent(url->_flags, url->ranges, lastComponentBeforeMask);
+        return rg.location + rg.length;
+    }
+}
+
+static CFRange _CFURLGetCharRangeForMask(CFURLRef url, CFOptionFlags mask, CFRange *charRangeWithSeparators) {
+    CFOptionFlags currentOption;
+    CFOptionFlags firstMaskFlag = HAS_SCHEME;
+    Boolean haveReachedMask = false;
+    CFIndex beforeMask = 0;
+    CFIndex afterMask = kCFNotFound;
+    CFRange *currRange = url->ranges;
+    CFRange maskRange = {kCFNotFound, 0};
+    for (currentOption = 1; currentOption <= HAS_FRAGMENT; currentOption = currentOption << 1) {
+        if (!haveReachedMask && (currentOption & mask) != 0) {
+            firstMaskFlag = currentOption;
+            haveReachedMask = true;
+        }
+        if (!(url->_flags & currentOption)) continue;
+        if (!haveReachedMask) {
+            beforeMask = currRange->location + currRange->length;
+        } else if (currentOption <= mask) {
+            if (maskRange.location == kCFNotFound) {
+                maskRange = *currRange;
+            } else {
+                maskRange.length = currRange->location + currRange->length - maskRange.location;
+            }
+        } else {
+            afterMask = currRange->location;
+            break;
+        }
+        currRange ++;
+    }
+    if (afterMask == kCFNotFound) {
+        afterMask = maskRange.location + maskRange.length;
+    }
+    charRangeWithSeparators->location = beforeMask;
+    charRangeWithSeparators->length = afterMask - beforeMask;
+    return maskRange;
+}
+
+static CFRange _getCharRangeInDecomposableURL(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators) {
+    CFOptionFlags mask;
+    switch (component) {
+        case kCFURLComponentScheme: 
+            mask = HAS_SCHEME; 
+            break;
+        case kCFURLComponentNetLocation: 
+            mask = NET_LOCATION_MASK; 
+            break;
+        case kCFURLComponentPath: 
+            mask = HAS_PATH; 
+            break;
+        case kCFURLComponentResourceSpecifier: 
+            mask = RESOURCE_SPECIFIER_MASK; 
+            break;
+        case kCFURLComponentUser: 
+            mask = HAS_USER; 
+            break;
+        case kCFURLComponentPassword:
+            mask = HAS_PASSWORD;
+            break;
+        case kCFURLComponentUserInfo:
+            mask = HAS_USER | HAS_PASSWORD;
+            break;
+        case kCFURLComponentHost:
+            mask = HAS_HOST;
+            break;
+        case kCFURLComponentPort:
+            mask = HAS_PORT;
+            break;
+        case kCFURLComponentParameterString:
+            mask = HAS_PARAMETERS;
+            break;
+        case kCFURLComponentQuery:
+            mask = HAS_QUERY;
+            break;
+        case kCFURLComponentFragment:
+            mask = HAS_FRAGMENT;
+            break;
+        default:
+            rangeIncludingSeparators->location = kCFNotFound;
+            rangeIncludingSeparators->length = 0;
+            return CFRangeMake(kCFNotFound, 0);
+    }
+
+    if ((url->_flags & mask) == 0) {
+        rangeIncludingSeparators->location = insertionLocationForMask(url, mask);
+        rangeIncludingSeparators->length = 0;
+        return CFRangeMake(kCFNotFound, 0);
+    } else {
+        return _CFURLGetCharRangeForMask(url, mask, rangeIncludingSeparators);
+    }
+}
+
+static CFRange _getCharRangeInNonDecomposableURL(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators) {
+    if (component == kCFURLComponentScheme) {
+        CFRange schemeRg = _rangeForComponent(url->_flags, url->ranges, HAS_SCHEME);
+        rangeIncludingSeparators->location = 0;
+        rangeIncludingSeparators->length = schemeRg.length + 1;
+        return schemeRg;
+    } else if (component == kCFURLComponentResourceSpecifier) {
+        CFRange schemeRg = _rangeForComponent(url->_flags, url->ranges, HAS_SCHEME);
+        CFIndex stringLength = CFStringGetLength(url->_string);
+        if (schemeRg.length + 1 == stringLength) {
+            rangeIncludingSeparators->location = schemeRg.length + 1;
+            rangeIncludingSeparators->length = 0;
+            return CFRangeMake(kCFNotFound, 0);
+        } else {
+            rangeIncludingSeparators->location = schemeRg.length;
+            rangeIncludingSeparators->length = stringLength - schemeRg.length;
+            return CFRangeMake(schemeRg.length + 1, rangeIncludingSeparators->length - 1);
+        }
+    } else {
+        rangeIncludingSeparators->location = kCFNotFound;
+        rangeIncludingSeparators->length = 0;
+        return CFRangeMake(kCFNotFound, 0);
+    }
+    
+}
+
+CFRange CFURLGetByteRangeForComponent(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators) {
+    CFRange charRange, charRangeWithSeparators;
+    CFRange byteRange;
+    CFAssert2(component > 0 && component < 13, __kCFLogAssertion, "%s(): passed invalid component %d", __PRETTY_FUNCTION__, component);
+    url = _CFURLFromNSURL(url);
+    if (URL_PATH_TYPE(url) != FULL_URL_REPRESENTATION) {
+        _convertToURLRepresentation((struct __CFURL *)url);
+    }
+    if (!(url->_flags & IS_PARSED)) {
+        _parseComponentsOfURL(url);
+    }
+
+    if (!(url->_flags & IS_DECOMPOSABLE)) {
+        // Special-case this because non-decomposable URLs have a slightly strange flags setup
+        charRange = _getCharRangeInNonDecomposableURL(url, component, &charRangeWithSeparators);
+    } else {
+        charRange = _getCharRangeInDecomposableURL(url, component, &charRangeWithSeparators);
+    }
+    
+    if (charRangeWithSeparators.location == kCFNotFound) {
+        if (rangeIncludingSeparators) {
+            rangeIncludingSeparators->location = kCFNotFound;
+            rangeIncludingSeparators->length = 0;
+        }
+        return CFRangeMake(kCFNotFound, 0);
+    } else if (rangeIncludingSeparators) {
+        CFStringGetBytes(url->_string, CFRangeMake(0, charRangeWithSeparators.location), url->_encoding, 0, false, NULL, 0, &(rangeIncludingSeparators->location));
+
+        if (charRange.location == kCFNotFound) {
+            byteRange = charRange;
+            CFStringGetBytes(url->_string, charRangeWithSeparators, url->_encoding, 0, false, NULL, 0, &(rangeIncludingSeparators->length));
+        } else {
+            CFIndex maxCharRange = charRange.location + charRange.length;
+            CFIndex maxCharRangeWithSeparators = charRangeWithSeparators.location + charRangeWithSeparators.length;
+
+            if (charRangeWithSeparators.location == charRange.location) {
+                byteRange.location = rangeIncludingSeparators->location;
+            } else {
+                CFIndex numBytes;
+                CFStringGetBytes(url->_string, CFRangeMake(charRangeWithSeparators.location, charRange.location - charRangeWithSeparators.location), url->_encoding, 0, false, NULL, 0, &numBytes);
+                byteRange.location = charRangeWithSeparators.location + numBytes;
+            }
+            CFStringGetBytes(url->_string, charRange, url->_encoding, 0, false, NULL, 0, &(byteRange.length));
+            if (maxCharRangeWithSeparators == maxCharRange) {
+                rangeIncludingSeparators->length = byteRange.location + byteRange.length - rangeIncludingSeparators->location;
+            } else {
+                CFIndex numBytes;
+                CFRange rg;
+                rg.location = maxCharRange;
+                rg.length = maxCharRangeWithSeparators - rg.location;
+                CFStringGetBytes(url->_string, rg, url->_encoding, 0, false, NULL, 0, &numBytes);
+                rangeIncludingSeparators->length = byteRange.location + byteRange.length + numBytes - rangeIncludingSeparators->location;
+            }
+        }
+    } else if (charRange.location == kCFNotFound) {
+        byteRange = charRange;
+    } else {
+        CFStringGetBytes(url->_string, CFRangeMake(0, charRange.location), url->_encoding, 0, false, NULL, 0, &(byteRange.location));
+        CFStringGetBytes(url->_string, charRange, url->_encoding, 0, false, NULL, 0, &(byteRange.length));
+    }
+    return byteRange;
+}
+
+/* Component support */
+
+/* We convert to the CFURL immediately at the beginning of decomposition, so all the decomposition routines need not worry about having an ObjC NSURL */
+static CFStringRef schemeSpecificString(CFURLRef url) {
+    Boolean isDir;
+    isDir = ((url->_flags & IS_DIRECTORY) != 0);
+    switch (URL_PATH_TYPE(url)) {
+    case kCFURLPOSIXPathStyle:
+        if (url->_flags & POSIX_AND_URL_PATHS_MATCH) {
+            return (CFStringRef)CFRetain(url->_string);
+        } else {
+            return POSIXPathToURLPath(url->_string, CFGetAllocator(url), isDir);
+        }
+    case kCFURLWindowsPathStyle:
+        return WindowsPathToURLPath(url->_string, CFGetAllocator(url), isDir);
+    case FULL_URL_REPRESENTATION:
+        return CFURLCopyResourceSpecifier(url);
+    default:
+        return NULL;
+    }
+}
+
+static Boolean decomposeToNonHierarchical(CFURLRef url, CFURLComponentsNonHierarchical *components) {
+    if ( CFURLGetBaseURL(url) != NULL)  {
+        components->scheme = NULL;
+    } else {
+        components->scheme = CFURLCopyScheme(url);
+    }
+    components->schemeSpecific = schemeSpecificString(url);
+    return true;
+}
+
+static CFURLRef composeFromNonHierarchical(CFAllocatorRef alloc, const CFURLComponentsNonHierarchical *components) {
+    CFStringRef str;
+    if (components->scheme) {
+        UniChar ch = ':';
+        str = CFStringCreateMutableCopy(alloc, CFStringGetLength(components->scheme) + 1 + (components->schemeSpecific ? CFStringGetLength(components->schemeSpecific): 0), components->scheme);
+        CFStringAppendCharacters((CFMutableStringRef)str, &ch, 1);
+        if (components->schemeSpecific) CFStringAppend((CFMutableStringRef)str, components->schemeSpecific);
+    } else if (components->schemeSpecific) {
+        str = components->schemeSpecific;
+        CFRetain(str);
+    } else {
+        str = NULL;
+    }
+    if (str) {
+        CFURLRef url = CFURLCreateWithString(alloc, str, NULL);
+        CFRelease(str);
+        return url;
+    } else {
+        return NULL;
+    }
+}
+
+static Boolean decomposeToRFC1808(CFURLRef url, CFURLComponentsRFC1808 *components) {
+    CFAllocatorRef alloc = CFGetAllocator(url);
+    int pathType;
+    static CFStringRef emptyStr = NULL;
+    if (!emptyStr) {
+        emptyStr = CFSTR("");
+    }
+
+    if (!CFURLCanBeDecomposed(url)) {
+        return false;
+    }
+    if ((pathType = URL_PATH_TYPE(url)) == FULL_URL_REPRESENTATION) {
+        CFStringRef path = CFURLCopyPath(url);
+        if (path) {
+            components->pathComponents = CFStringCreateArrayBySeparatingStrings(alloc, path, CFSTR("/"));
+            CFRelease(path);
+        } else {
+            components->pathComponents = NULL;
+        }
+        components->baseURL = CFURLGetBaseURL(url);
+        if (components->baseURL)  {
+            CFRetain(components->baseURL);
+            components->scheme = NULL;
+        } else {
+            components->scheme = _retainedComponentString(url, HAS_SCHEME, true, false);
+        }
+        components->user = _retainedComponentString(url, HAS_USER, false, false);
+        components->password = _retainedComponentString(url, HAS_PASSWORD, false, false);
+        components->host = _retainedComponentString(url, HAS_HOST, false, false);
+        if (url->_flags & HAS_PORT) {
+            components->port = CFURLGetPortNumber(url);
+        } else {
+            components->port = kCFNotFound;
+        }
+        components->parameterString = _retainedComponentString(url, HAS_PARAMETERS, false, false);
+        components->query = _retainedComponentString(url, HAS_QUERY, false, false);
+        components->fragment = _retainedComponentString(url, HAS_FRAGMENT, false, false);
+    } else {
+        switch (pathType) {
+        case kCFURLPOSIXPathStyle: {
+            CFStringRef pathStr;
+            if (url->_flags & POSIX_AND_URL_PATHS_MATCH) {
+                pathStr = url->_string;
+                CFRetain(pathStr);
+            } else {
+                pathStr = POSIXPathToURLPath(url->_string, alloc, url->_flags & IS_DIRECTORY);
+            }
+            components->pathComponents = CFStringCreateArrayBySeparatingStrings(alloc, pathStr, CFSTR("/"));
+            CFRelease(pathStr);
+            break;
+        }
+        case kCFURLWindowsPathStyle:
+            components->pathComponents = WindowsPathToURLComponents(url->_string, alloc, ((url->_flags & IS_DIRECTORY) != 0));
+            break;
+        default:
+            components->pathComponents = NULL;
+        }
+        if (!components->pathComponents) {
+            return false;
+        }
+        components->scheme = (CFStringRef)CFRetain(kCFURLFileScheme);
+        components->user = NULL;
+        components->password = NULL;
+        components->host = (CFStringRef)CFRetain(kCFURLLocalhost);
+        components->port = kCFNotFound;
+        components->parameterString = NULL;
+        components->query = NULL;
+        components->fragment = NULL;
+        components->baseURL = CFURLGetBaseURL(url);
+        if (components->baseURL) CFRetain(components->baseURL);
+    }
+    return true;
+}
+
+static CFURLRef composeFromRFC1808(CFAllocatorRef alloc, const CFURLComponentsRFC1808 *comp) {
+    CFMutableStringRef urlString = CFStringCreateMutable(alloc, 0);
+    CFURLRef base = comp->baseURL;
+    CFURLRef url;
+    Boolean hadPrePathComponent = false;
+    if (comp->scheme) {
+        base = NULL;
+        CFStringAppend(urlString, comp->scheme);
+        CFStringAppend(urlString, CFSTR("://"));
+        hadPrePathComponent = true;
+    }
+    if (comp->user || comp->password) {
+        if (comp->user) {
+            CFStringAppend(urlString, comp->user);
+        }
+        if (comp->password) {
+            CFStringAppend(urlString, CFSTR(":"));
+            CFStringAppend(urlString, comp->password);
+        }
+        CFStringAppend(urlString, CFSTR("@"));
+        hadPrePathComponent = true;
+    }
+    if (comp->host) {
+        CFStringAppend(urlString, comp->host);
+        hadPrePathComponent = true;
+    }
+    if (comp->port != kCFNotFound) {
+        CFStringAppendFormat(urlString, NULL, CFSTR(":%d"), comp->port);
+        hadPrePathComponent = true;
+    }
+
+    if (hadPrePathComponent && (comp->pathComponents == NULL || CFStringGetLength((CFStringRef)CFArrayGetValueAtIndex(comp->pathComponents, 0)) != 0)) {
+        CFStringAppend(urlString, CFSTR("/"));
+    }
+    if (comp->pathComponents) {
+        CFStringRef pathStr = CFStringCreateByCombiningStrings(alloc, comp->pathComponents, CFSTR("/"));
+        CFStringAppend(urlString, pathStr);
+        CFRelease(pathStr);
+    }
+    if (comp->parameterString) {
+        CFStringAppend(urlString, CFSTR(";"));
+        CFStringAppend(urlString, comp->parameterString);
+    }
+    if (comp->query) {
+        CFStringAppend(urlString, CFSTR("?"));
+        CFStringAppend(urlString, comp->query);
+    }
+    if (comp->fragment) {
+        CFStringAppend(urlString, CFSTR("#"));
+        CFStringAppend(urlString, comp->fragment);
+    }
+    url = CFURLCreateWithString(alloc, urlString, base);
+    CFRelease(urlString);
+    return url;
+}
+
+static Boolean decomposeToRFC2396(CFURLRef url, CFURLComponentsRFC2396 *comp) {
+    CFAllocatorRef alloc = CFGetAllocator(url);
+    CFURLComponentsRFC1808 oldComp;
+    CFStringRef tmpStr;
+    if (!decomposeToRFC1808(url, &oldComp)) {
+        return false;
+    }
+    comp->scheme = oldComp.scheme;
+    if (oldComp.user) {
+        if (oldComp.password) {
+            comp->userinfo = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@:%@"), oldComp.user, oldComp.password);
+            CFRelease(oldComp.password);
+            CFRelease(oldComp.user);
+        } else {
+            comp->userinfo = oldComp.user;
+        }
+    } else {
+        comp->userinfo = NULL;
+    }
+    comp->host = oldComp.host;
+    comp->port = oldComp.port;
+    if (!oldComp.parameterString) {
+        comp->pathComponents = oldComp.pathComponents;
+    } else {
+        int length = CFArrayGetCount(oldComp.pathComponents);
+        comp->pathComponents = CFArrayCreateMutableCopy(alloc, length, oldComp.pathComponents);
+        tmpStr = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@;%@"), CFArrayGetValueAtIndex(comp->pathComponents, length - 1), oldComp.parameterString);
+        CFArraySetValueAtIndex((CFMutableArrayRef)comp->pathComponents, length - 1, tmpStr);
+        CFRelease(tmpStr);
+        CFRelease(oldComp.pathComponents);
+        CFRelease(oldComp.parameterString);
+    }
+    comp->query = oldComp.query;
+    comp->fragment = oldComp.fragment;
+    comp->baseURL = oldComp.baseURL;
+    return true;
+}
+
+static CFURLRef composeFromRFC2396(CFAllocatorRef alloc, const CFURLComponentsRFC2396 *comp) {
+    CFMutableStringRef urlString = CFStringCreateMutable(alloc, 0);
+    CFURLRef base = comp->baseURL;
+    CFURLRef url;
+    Boolean hadPrePathComponent = false;
+    if (comp->scheme) {
+        base = NULL;
+        CFStringAppend(urlString, comp->scheme);
+        CFStringAppend(urlString, CFSTR("://"));
+        hadPrePathComponent = true;
+    }
+    if (comp->userinfo) {
+        CFStringAppend(urlString, comp->userinfo);
+        CFStringAppend(urlString, CFSTR("@"));
+        hadPrePathComponent = true;
+    }
+    if (comp->host) {
+        CFStringAppend(urlString, comp->host);
+        if (comp->port != kCFNotFound) {
+            CFStringAppendFormat(urlString, NULL, CFSTR(":%d"), comp->port);
+        }
+        hadPrePathComponent = true;
+    }
+    if (hadPrePathComponent && (comp->pathComponents == NULL || CFStringGetLength((CFStringRef)CFArrayGetValueAtIndex(comp->pathComponents, 0)) != 0)) {
+        CFStringAppend(urlString, CFSTR("/"));
+    }
+    if (comp->pathComponents) {
+        CFStringRef pathStr = CFStringCreateByCombiningStrings(alloc, comp->pathComponents, CFSTR("/"));
+        CFStringAppend(urlString, pathStr);
+        CFRelease(pathStr);
+    }
+    if (comp->query) {
+        CFStringAppend(urlString, CFSTR("?"));
+        CFStringAppend(urlString, comp->query);
+    }
+    if (comp->fragment) {
+        CFStringAppend(urlString, CFSTR("#"));
+        CFStringAppend(urlString, comp->fragment);
+    }
+    url = CFURLCreateWithString(alloc, urlString, base);
+    CFRelease(urlString);
+    return url;
+}
+
+#undef CFURLCopyComponents
+#undef CFURLCreateFromComponents
+
+CF_EXPORT
+Boolean _CFURLCopyComponents(CFURLRef url, CFURLComponentDecomposition decompositionType, void *components) {
+    url = _CFURLFromNSURL(url);
+    switch (decompositionType) {
+    case kCFURLComponentDecompositionNonHierarchical:
+        return decomposeToNonHierarchical(url, (CFURLComponentsNonHierarchical *)components);
+    case kCFURLComponentDecompositionRFC1808:
+        return decomposeToRFC1808(url, (CFURLComponentsRFC1808 *)components);
+    case kCFURLComponentDecompositionRFC2396:
+        return decomposeToRFC2396(url, (CFURLComponentsRFC2396 *)components);
+    default:
+        return false;
+    }
+}
+
+CF_EXPORT
+CFURLRef _CFURLCreateFromComponents(CFAllocatorRef alloc, CFURLComponentDecomposition decompositionType, const void *components) {
+    switch (decompositionType) {
+    case kCFURLComponentDecompositionNonHierarchical:
+        return composeFromNonHierarchical(alloc, (const CFURLComponentsNonHierarchical *)components);
+    case kCFURLComponentDecompositionRFC1808:
+        return composeFromRFC1808(alloc, (const CFURLComponentsRFC1808 *)components);
+    case kCFURLComponentDecompositionRFC2396:
+        return composeFromRFC2396(alloc, (const CFURLComponentsRFC2396 *)components);
+    default:
+        return NULL;
+    }
+}
+
+CF_EXPORT void *__CFURLReservedPtr(CFURLRef  url) {
+    return _getReserved(url);
+}
+
+CF_EXPORT void __CFURLSetReservedPtr(CFURLRef  url, void *ptr) {
+	_setReserved ( (struct __CFURL*) url, ptr );
+}
+
+
+/* File system stuff */
+
+/* HFSPath<->URLPath functions at the bottom of the file */
+static CFArrayRef WindowsPathToURLComponents(CFStringRef path, CFAllocatorRef alloc, Boolean isDir) {
+    CFArrayRef tmp;
+    CFMutableArrayRef urlComponents = NULL;
+    CFIndex i=0;
+
+    tmp = CFStringCreateArrayBySeparatingStrings(alloc, path, CFSTR("\\"));
+    urlComponents = CFArrayCreateMutableCopy(alloc, 0, tmp);
+    CFRelease(tmp);
+
+    CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(urlComponents, 0);
+    if (CFStringGetLength(str) == 2 && CFStringGetCharacterAtIndex(str, 1) == ':') {
+        CFArrayInsertValueAtIndex(urlComponents, 0, CFSTR("")); // So we get a leading '/' below
+        i = 2; // Skip over the drive letter and the empty string we just inserted
+    }
+    CFIndex c;
+    for (c = CFArrayGetCount(urlComponents); i < c; i ++) {
+        CFStringRef fileComp = (CFStringRef)CFArrayGetValueAtIndex(urlComponents,i);
+        CFStringRef urlComp = _replacePathIllegalCharacters(fileComp, alloc, false);
+        if (!urlComp) {
+            // Couldn't decode fileComp
+            CFRelease(urlComponents);
+            return NULL;
+        }
+        if (urlComp != fileComp) {
+            CFArraySetValueAtIndex(urlComponents, i, urlComp);
+        }
+        CFRelease(urlComp);
+    }
+
+    if (isDir) {
+        if (CFStringGetLength((CFStringRef)CFArrayGetValueAtIndex(urlComponents, CFArrayGetCount(urlComponents) - 1)) != 0)
+            CFArrayAppendValue(urlComponents, CFSTR(""));
+    }
+    return urlComponents;
+}
+
+static CFStringRef WindowsPathToURLPath(CFStringRef path, CFAllocatorRef alloc, Boolean isDir) {
+    CFArrayRef urlComponents;
+    CFStringRef str;
+
+    if (CFStringGetLength(path) == 0) return CFStringCreateWithCString(alloc, "", kCFStringEncodingASCII);
+    urlComponents = WindowsPathToURLComponents(path, alloc, isDir);
+    if (!urlComponents) return CFStringCreateWithCString(alloc, "", kCFStringEncodingASCII);
+
+    // WindowsPathToURLComponents already added percent escapes for us; no need to add them again here.
+    str = CFStringCreateByCombiningStrings(alloc, urlComponents, CFSTR("/"));
+    CFRelease(urlComponents);
+    return str;
+}
+
+static CFStringRef POSIXPathToURLPath(CFStringRef path, CFAllocatorRef alloc, Boolean isDirectory) {
+    CFStringRef pathString = _replacePathIllegalCharacters(path, alloc, true);
+    if (isDirectory && CFStringGetCharacterAtIndex(path, CFStringGetLength(path)-1) != '/') {
+        CFStringRef tmp = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@/"), pathString);
+        CFRelease(pathString);
+        pathString = tmp;
+    }
+    return pathString;
+}
+
+static CFStringRef URLPathToPOSIXPath(CFStringRef path, CFAllocatorRef allocator, CFStringEncoding encoding) {
+    // This is the easiest case; just remove the percent escape codes and we're done
+    CFStringRef result = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(allocator, path, CFSTR(""), encoding);
+    if (result) {
+        CFIndex length = CFStringGetLength(result);
+        if (length > 1 && CFStringGetCharacterAtIndex(result, length-1) == '/') {
+            CFStringRef tmp = CFStringCreateWithSubstring(allocator, result, CFRangeMake(0, length-1));
+            CFRelease(result);
+            result = tmp;
+        }
+    }
+    return result;
+}
+
+
+static CFStringRef URLPathToWindowsPath(CFStringRef path, CFAllocatorRef allocator, CFStringEncoding encoding) {
+    // Check for a drive letter, then flip all the slashes
+    CFStringRef result;
+    CFArrayRef tmp = CFStringCreateArrayBySeparatingStrings(allocator, path, CFSTR("/"));
+    SInt32 count = CFArrayGetCount(tmp);
+    CFMutableArrayRef components = CFArrayCreateMutableCopy(allocator, count, tmp);
+    CFStringRef newPath;
+    
+    
+    
+    CFRelease(tmp);
+    if (CFStringGetLength((CFStringRef)CFArrayGetValueAtIndex(components,count-1)) == 0) {
+        CFArrayRemoveValueAtIndex(components, count-1);
+        count --;
+    }
+    
+    if (count > 1 && CFStringGetLength((CFStringRef)CFArrayGetValueAtIndex(components, 0)) == 0) {
+        // Absolute path; we need to check for a drive letter in the second component, and if so, remove the first component
+        CFStringRef firstComponent = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(allocator, (CFStringRef)CFArrayGetValueAtIndex(components, 1), CFSTR(""), encoding);
+        UniChar ch;
+
+	{
+            if (CFStringGetLength(firstComponent) == 2 && ((ch = CFStringGetCharacterAtIndex(firstComponent, 1)) == '|' || ch == ':')) {
+                // Drive letter
+                CFArrayRemoveValueAtIndex(components, 0);
+                if (ch == '|') {
+                    CFStringRef driveStr = CFStringCreateWithFormat(allocator, NULL, CFSTR("%c:"), CFStringGetCharacterAtIndex(firstComponent, 0));
+                    CFArraySetValueAtIndex(components, 0, driveStr);
+                    CFRelease(driveStr);
+                }
+            }
+            CFRelease(firstComponent);
+        }
+    }
+    newPath = CFStringCreateByCombiningStrings(allocator, components, CFSTR("\\"));
+    CFRelease(components);
+    result = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(allocator, newPath, CFSTR(""), encoding);
+    CFRelease(newPath);
+    return result;
+}
+
+// converts url from a file system path representation to a standard representation
+static void _convertToURLRepresentation(struct __CFURL *url) {
+    CFStringRef path = NULL;
+    Boolean isDir = ((url->_flags & IS_DIRECTORY) != 0);
+    CFAllocatorRef alloc = CFGetAllocator(url);
+
+#if DEBUG_URL_MEMORY_USAGE
+    numFileURLsConverted ++;
+#endif
+
+    switch (URL_PATH_TYPE(url)) {
+        case kCFURLPOSIXPathStyle:
+            if (url->_flags & POSIX_AND_URL_PATHS_MATCH) {
+                path = (CFStringRef)CFRetain(url->_string);
+            } else {
+                path = POSIXPathToURLPath(url->_string, alloc, isDir);
+            }
+            break;
+        case kCFURLWindowsPathStyle:
+            path = WindowsPathToURLPath(url->_string, alloc, isDir);
+            break;
+    }
+    CFAssert2(path != NULL, __kCFLogAssertion, "%s(): Encountered malformed file system URL %@", __PRETTY_FUNCTION__, url);
+    if (!url->_base) {
+	CFMutableStringRef str = CFStringCreateMutable(alloc, 0);
+	CFStringAppend(str, CFSTR("file://localhost"));
+	CFStringAppend(str, path);
+        url->_flags = (url->_flags & (IS_DIRECTORY)) | (FULL_URL_REPRESENTATION << 16) | IS_DECOMPOSABLE | IS_ABSOLUTE | IS_PARSED | HAS_SCHEME | HAS_FILE_SCHEME | HAS_HOST | HAS_PATH | ORIGINAL_AND_URL_STRINGS_MATCH;
+        CFRelease(url->_string);
+        url->_string = str;
+        url->ranges = (CFRange *)CFAllocatorAllocate(alloc, sizeof(CFRange) * 3, 0);
+        url->ranges[0] = CFRangeMake(0, 4);
+        url->ranges[1] = CFRangeMake(7, 9);
+        url->ranges[2] = CFRangeMake(16, CFStringGetLength(path));
+        CFRelease(path);
+    } else {
+        CFRelease(url->_string);
+        url->_flags = (url->_flags & (IS_DIRECTORY)) | (FULL_URL_REPRESENTATION << 16) | IS_DECOMPOSABLE | IS_PARSED | HAS_PATH | ORIGINAL_AND_URL_STRINGS_MATCH;
+        url->_string = path;
+        url->ranges = (CFRange *)CFAllocatorAllocate(alloc, sizeof(CFRange), 0);
+        *(url->ranges) = CFRangeMake(0, CFStringGetLength(path));
+    }
+}
+
+// relativeURL is known to be a file system URL whose base is a matching file system URL
+static CFURLRef _CFURLCopyAbsoluteFileURL(CFURLRef relativeURL) {
+    CFAllocatorRef alloc = CFGetAllocator(relativeURL);
+    CFURLPathStyle fsType = URL_PATH_TYPE(relativeURL);
+    CFURLRef base = relativeURL->_base;
+    CFStringRef newPath = _resolveFileSystemPaths(relativeURL->_string, base->_string, (base->_flags & IS_DIRECTORY) != 0, fsType, alloc);
+    CFURLRef result =  CFURLCreateWithFileSystemPath(alloc, newPath, fsType, (relativeURL->_flags & IS_DIRECTORY) != 0);
+    CFRelease(newPath);
+    return result;
+}
+
+// Caller must release the returned string
+static CFStringRef _resolveFileSystemPaths(CFStringRef relativePath, CFStringRef basePath, Boolean baseIsDir, CFURLPathStyle fsType, CFAllocatorRef alloc) {
+    CFIndex baseLen = CFStringGetLength(basePath);
+    CFIndex relLen = CFStringGetLength(relativePath);
+    UniChar pathDelimiter = PATH_DELIM_FOR_TYPE(fsType);
+    UniChar *buf = (UniChar *)CFAllocatorAllocate(alloc, sizeof(UniChar)*(relLen + baseLen + 2), 0);
+    CFStringGetCharacters(basePath, CFRangeMake(0, baseLen), buf);
+    if (baseIsDir) {
+        if (buf[baseLen-1] != pathDelimiter) {
+            buf[baseLen] = pathDelimiter;
+            baseLen ++;
+        }
+    } else {
+        UniChar *ptr = buf + baseLen - 1;
+        while (ptr > buf && *ptr != pathDelimiter) {
+            ptr --;
+        }
+        baseLen = ptr - buf + 1;
+    }
+    if (fsType == kCFURLHFSPathStyle) {
+        // HFS relative paths will begin with a colon, so we must remove the trailing colon from the base path first.
+        baseLen --;
+    }
+    CFStringGetCharacters(relativePath, CFRangeMake(0, relLen), buf + baseLen);
+    *(buf + baseLen + relLen) = '\0';
+    return _resolvedPath(buf, buf + baseLen + relLen, pathDelimiter, false, true, alloc);
+}
+
+CFURLRef _CFURLCreateCurrentDirectoryURL(CFAllocatorRef allocator) {
+    CFURLRef url = NULL;
+    uint8_t buf[CFMaxPathSize + 1];
+    if (_CFGetCurrentDirectory((char *)buf, CFMaxPathLength)) {
+        url = CFURLCreateFromFileSystemRepresentation(allocator, buf, (CFIndex)strlen((char *)buf), true);
+    }
+    return url;
+}
+
+CFURLRef CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle fsType, Boolean isDirectory) {
+    Boolean isAbsolute = true;
+    CFIndex len;
+    CFURLRef baseURL, result;
+
+    CFAssert2(fsType == kCFURLPOSIXPathStyle || fsType == kCFURLHFSPathStyle || fsType == kCFURLWindowsPathStyle, __kCFLogAssertion, "%s(): encountered unknown path style %d", __PRETTY_FUNCTION__, fsType);
+    CFAssert1(filePath != NULL, __kCFLogAssertion, "%s(): NULL filePath argument not permitted", __PRETTY_FUNCTION__);
+
+	len = CFStringGetLength(filePath);
+	
+    switch(fsType) {
+        case kCFURLPOSIXPathStyle:
+            isAbsolute = (len > 0 && CFStringGetCharacterAtIndex(filePath, 0) == '/');
+            break;
+        case kCFURLWindowsPathStyle:
+            isAbsolute = (len >= 3 && CFStringGetCharacterAtIndex(filePath, 1) == ':' && CFStringGetCharacterAtIndex(filePath, 2) == '\\');
+	    /* Absolute path under Win32 can begin with "\\"
+	     * (Sergey Zubarev)
+	     */
+            if (!isAbsolute) isAbsolute = (len > 2 && CFStringGetCharacterAtIndex(filePath, 0) == '\\' && CFStringGetCharacterAtIndex(filePath, 1) == '\\');
+            break;
+        case kCFURLHFSPathStyle:
+            isAbsolute = (len > 0 && CFStringGetCharacterAtIndex(filePath, 0) != ':');
+            break;
+    }
+    if (isAbsolute) {
+        baseURL = NULL;
+    } else {
+        baseURL = _CFURLCreateCurrentDirectoryURL(allocator);
+    }
+    result = CFURLCreateWithFileSystemPathRelativeToBase(allocator, filePath, fsType, isDirectory, baseURL);
+    if (baseURL) CFRelease(baseURL);
+    return result;
+}
+
+CF_EXPORT CFURLRef CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle fsType, Boolean isDirectory, CFURLRef baseURL) {
+    CFURLRef url;
+    Boolean isAbsolute = true, releaseFilePath = false;
+    UniChar pathDelim = '\0';
+    CFIndex len;
+
+    CFAssert1(filePath != NULL, __kCFLogAssertion, "%s(): NULL path string not permitted", __PRETTY_FUNCTION__);
+    CFAssert2(fsType == kCFURLPOSIXPathStyle || fsType == kCFURLHFSPathStyle || fsType == kCFURLWindowsPathStyle, __kCFLogAssertion, "%s(): encountered unknown path style %d", __PRETTY_FUNCTION__, fsType);
+    
+	len = CFStringGetLength(filePath);
+
+    switch(fsType) {
+        case kCFURLPOSIXPathStyle:
+            isAbsolute = (len > 0 && CFStringGetCharacterAtIndex(filePath, 0) == '/');
+			
+            pathDelim = '/';
+            break;
+        case kCFURLWindowsPathStyle: 
+            isAbsolute = (len >= 3 && CFStringGetCharacterAtIndex(filePath, 1) == ':' && CFStringGetCharacterAtIndex(filePath, 2) == '\\');
+	    /* Absolute path under Win32 can begin with "\\"
+	     * (Sergey Zubarev)
+	     */
+			if (!isAbsolute)
+				isAbsolute = (len > 2 && CFStringGetCharacterAtIndex(filePath, 0) == '\\' && CFStringGetCharacterAtIndex(filePath, 1) == '\\');
+             pathDelim = '\\';
+            break;
+        case kCFURLHFSPathStyle: 
+		{	CFRange	fullStrRange = CFRangeMake( 0, CFStringGetLength( filePath ) );
+		
+            isAbsolute = (len > 0 && CFStringGetCharacterAtIndex(filePath, 0) != ':');
+            pathDelim = ':';
+			
+			if ( _CFExecutableLinkedOnOrAfter( CFSystemVersionTiger ) && 
+					filePath && CFStringFindWithOptions( filePath, CFSTR("::"), fullStrRange, 0, NULL ) ) {
+				UniChar *	chars = (UniChar *) malloc( fullStrRange.length * sizeof( UniChar ) );
+				CFIndex index, writeIndex, firstColonOffset = -1;
+								
+				CFStringGetCharacters( filePath, fullStrRange, chars );
+
+				for ( index = 0, writeIndex = 0 ; index < fullStrRange.length; index ++ ) {
+					if ( chars[ index ] == ':' ) {
+						if ( index + 1 < fullStrRange.length && chars[ index + 1 ] == ':' ) {
+
+							// Don't let :: go off the 'top' of the path -- which means that there always has to be at
+							//	least one ':' to the left of the current write position to go back to.
+							if ( writeIndex > 0 && firstColonOffset >= 0 )
+							{
+								writeIndex --;
+								while ( writeIndex > 0 && writeIndex >= firstColonOffset && chars[ writeIndex ] != ':' )
+									writeIndex --;
+							}
+							index ++;	// skip over the first ':', so we replace the ':' which is there with a new one
+						}
+						
+						if ( firstColonOffset == -1 )
+							firstColonOffset = writeIndex;
+					}
+					
+					chars[ writeIndex ++ ] = chars[ index ];
+				}
+								
+				if ( releaseFilePath && filePath )
+					CFRelease( filePath );
+
+				filePath = CFStringCreateWithCharacters( allocator, chars, writeIndex );
+				// reset len because a canonical HFS path can be a different length than the original CFString
+				len = CFStringGetLength(filePath);
+				releaseFilePath = true;
+				
+				free( chars );
+			}
+			
+            break;
+		}
+    }
+    if (isAbsolute) {
+        baseURL = NULL;
+    } 
+	
+    if (isDirectory && len > 0 && CFStringGetCharacterAtIndex(filePath, len-1) != pathDelim) {
+        CFMutableStringRef tempRef = CFStringCreateMutable(allocator, 0);
+	CFStringAppend(tempRef, filePath);
+	CFStringAppendCharacters(tempRef, &pathDelim, 1);
+    	if ( releaseFilePath && filePath ) CFRelease( filePath );
+    	filePath = tempRef;
+        releaseFilePath = true;
+    } else if (!isDirectory && len > 0 && CFStringGetCharacterAtIndex(filePath, len-1) == pathDelim) {
+        if (len == 1 || CFStringGetCharacterAtIndex(filePath, len-2) == pathDelim) {
+            // Override isDirectory
+            isDirectory = true;
+        } else {
+            CFStringRef tempRef = CFStringCreateWithSubstring(allocator, filePath, CFRangeMake(0, len-1));
+			if ( releaseFilePath && filePath )
+				CFRelease( filePath );
+			filePath = tempRef;
+            releaseFilePath = true;
+        }
+    }
+    if (!filePath || CFStringGetLength(filePath) == 0) {
+        if (releaseFilePath && filePath) CFRelease(filePath);
+        return NULL;
+    }
+    url = _CFURLAlloc(allocator);
+    _CFURLInit((struct __CFURL *)url, filePath, fsType, baseURL);
+    if (releaseFilePath) CFRelease(filePath);
+    if (isDirectory) ((struct __CFURL *)url)->_flags |= IS_DIRECTORY;
+    if (fsType == kCFURLPOSIXPathStyle) {
+        // Check if relative path is equivalent to URL representation; this will be true if url->_string contains only characters from the unreserved character set, plus '/' to delimit the path, plus ';', '@', '&', '=', '+', '$', ',' (according to RFC 2396) -- REW, 12/1/2000
+        // Per Section 5 of RFC 2396, there's a special problem if a colon apears in the first path segment - in this position, it can be mistaken for the scheme name.  Otherwise, it's o.k., and can be safely identified as part of the path.  In this one case, we need to prepend "./" to make it clear what's going on.... -- REW, 8/24/2001
+        CFStringInlineBuffer buf;
+        Boolean sawSlash = FALSE;
+        Boolean mustPrependDotSlash = FALSE;
+        CFIndex idx, length = CFStringGetLength(url->_string);
+        CFStringInitInlineBuffer(url->_string, &buf, CFRangeMake(0, length));
+        for (idx = 0; idx < length; idx ++) {
+            UniChar ch = CFStringGetCharacterFromInlineBuffer(&buf, idx);
+            if (!isPathLegalCharacter(ch)) break;
+            if (!sawSlash) {
+                if (ch == '/') {
+                    sawSlash = TRUE;
+                } else if (ch == ':') {
+                    mustPrependDotSlash = TRUE;
+                }
+            }
+        }
+        if (idx == length) {
+            ((struct __CFURL *)url)->_flags |= POSIX_AND_URL_PATHS_MATCH;
+        }
+        if (mustPrependDotSlash) {
+            CFMutableStringRef newString = CFStringCreateMutable(allocator, 0);
+	    CFStringAppend(newString, CFSTR("./"));
+	    CFStringAppend(newString, url->_string);
+            CFRelease(url->_string);
+            ((struct __CFURL *)url)->_string = newString;
+        }
+    }
+    return url;
+}
+
+CF_EXPORT CFStringRef CFURLCopyFileSystemPath(CFURLRef anURL, CFURLPathStyle pathStyle) {
+    CFAssert2(pathStyle == kCFURLPOSIXPathStyle || pathStyle == kCFURLHFSPathStyle || pathStyle == kCFURLWindowsPathStyle, __kCFLogAssertion, "%s(): Encountered unknown path style %d", __PRETTY_FUNCTION__, pathStyle);
+    return CFURLCreateStringWithFileSystemPath(CFGetAllocator(anURL), anURL, pathStyle, false);
+}
+
+// There is no matching ObjC method for this functionality; because this function sits on top of the CFURL primitives, it's o.k. not to check for the need to dispatch an ObjC method instead, but this means care must be taken that this function never call anything that will result in dereferencing anURL without first checking for an ObjC dispatch.  -- REW, 10/29/98
+CFStringRef CFURLCreateStringWithFileSystemPath(CFAllocatorRef allocator, CFURLRef anURL, CFURLPathStyle fsType, Boolean resolveAgainstBase) {
+    CFURLRef base = resolveAgainstBase ? CFURLGetBaseURL(anURL) : NULL;
+    CFStringRef basePath = base ? CFURLCreateStringWithFileSystemPath(allocator, base, fsType, false) : NULL;
+    CFStringRef relPath = NULL;
+    
+    if (!CF_IS_OBJC(__kCFURLTypeID, anURL)) {
+        // We can grope the ivars
+        CFURLPathStyle myType = URL_PATH_TYPE(anURL);
+        if (myType == fsType) {
+            relPath = (CFStringRef)CFRetain(anURL->_string);
+        } else if (fsType == kCFURLPOSIXPathStyle && myType == FULL_URL_REPRESENTATION) {
+            if (!(anURL->_flags & IS_PARSED)) {
+                _parseComponentsOfURL(anURL);
+            }
+            if (anURL->_flags & POSIX_AND_URL_PATHS_MATCH) {
+                relPath = _retainedComponentString(anURL, HAS_PATH, true, true);
+            }
+        }
+    }
+
+    if (relPath == NULL) {
+        CFStringRef urlPath = CFURLCopyPath(anURL);
+        CFStringEncoding enc = (anURL->_flags & IS_OLD_UTF8_STYLE) ? kCFStringEncodingUTF8 : anURL->_encoding;
+        if (urlPath) {
+            switch (fsType) {
+                case kCFURLPOSIXPathStyle:
+                    relPath = URLPathToPOSIXPath(urlPath, allocator, enc);
+                    break;
+                case kCFURLHFSPathStyle:
+		    relPath = NULL;
+                    break;
+                case kCFURLWindowsPathStyle:
+                    relPath = URLPathToWindowsPath(urlPath, allocator, enc);
+                    break;
+                default:
+                    CFAssert2(true, __kCFLogAssertion, "%s(): Received unknown path type %d", __PRETTY_FUNCTION__, fsType);
+            }
+            CFRelease(urlPath);
+        }            
+    }
+	
+	//	For Tiger, leave this behavior in for all path types.  For Leopard, it would be nice to remove this entirely
+	//	and do a linked-on-or-later check so we don't break third parties.
+	//	See <rdar://problem/4003028> Converting volume name from POSIX to HFS form fails and
+	//	<rdar://problem/4018895> CF needs to back out 4003028 for icky details.
+	if ( relPath && CFURLHasDirectoryPath(anURL) && CFStringGetLength(relPath) > 1 && CFStringGetCharacterAtIndex(relPath, CFStringGetLength(relPath)-1) == PATH_DELIM_FOR_TYPE(fsType)) {
+        CFStringRef tmp = CFStringCreateWithSubstring(allocator, relPath, CFRangeMake(0, CFStringGetLength(relPath)-1));
+        CFRelease(relPath);
+        relPath = tmp;
+    }
+
+    // Note that !resolveAgainstBase implies !base
+    if (!basePath || !relPath) {
+        return relPath;
+    } else {
+        CFStringRef result = _resolveFileSystemPaths(relPath, basePath, CFURLHasDirectoryPath(base), fsType, allocator);
+        CFRelease(basePath);
+        CFRelease(relPath);
+        return result;
+    }
+}
+
+Boolean CFURLGetFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, uint8_t *buffer, CFIndex bufLen) {
+    CFStringRef path;
+    CFAllocatorRef alloc = CFGetAllocator(url);
+
+    if (!url) return false;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    path = CFURLCreateStringWithFileSystemPath(alloc, url, kCFURLPOSIXPathStyle, resolveAgainstBase);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    path = CFURLCreateStringWithFileSystemPath(alloc, url, kCFURLWindowsPathStyle, resolveAgainstBase);
+#endif
+   if (path) {
+        Boolean convResult = _CFStringGetFileSystemRepresentation(path, buffer, bufLen);
+        CFRelease(path);
+        return convResult;
+    }
+    return false;
+}
+
+CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const uint8_t *buffer, CFIndex bufLen, Boolean isDirectory) {
+    CFStringRef path = CFStringCreateWithBytes(allocator, buffer, bufLen, CFStringFileSystemEncoding(), false);
+    CFURLRef newURL;
+    if (!path) return NULL;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    newURL = CFURLCreateWithFileSystemPath(allocator, path, kCFURLPOSIXPathStyle, isDirectory);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    newURL = CFURLCreateWithFileSystemPath(allocator, path, kCFURLWindowsPathStyle, isDirectory);
+#endif
+   CFRelease(path);
+    return newURL;
+}
+
+CF_EXPORT CFURLRef CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator, const uint8_t *buffer, CFIndex bufLen, Boolean isDirectory, CFURLRef baseURL) {
+    CFStringRef path = CFStringCreateWithBytes(allocator, buffer, bufLen, CFStringFileSystemEncoding(), false);
+    CFURLRef newURL;
+    if (!path) return NULL;
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    newURL = CFURLCreateWithFileSystemPathRelativeToBase(allocator, path, kCFURLPOSIXPathStyle, isDirectory, baseURL);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    newURL = CFURLCreateWithFileSystemPathRelativeToBase(allocator, path, kCFURLWindowsPathStyle, isDirectory, baseURL);
+#endif
+    CFRelease(path);
+    return newURL;
+}
+
+
+/******************************/
+/* Support for path utilities */
+/******************************/
+
+// Assumes url is a CFURL (not an Obj-C NSURL)
+static CFRange _rangeOfLastPathComponent(CFURLRef url) {
+    UInt32 pathType = URL_PATH_TYPE(url);
+    CFRange pathRg, componentRg;
+    
+    if (pathType ==  FULL_URL_REPRESENTATION) {
+        if (!(url->_flags & IS_PARSED)) _parseComponentsOfURL(url);
+        pathRg = _rangeForComponent(url->_flags, url->ranges, HAS_PATH);
+    } else {
+        pathRg = CFRangeMake(0, CFStringGetLength(url->_string));
+    }
+
+    if (pathRg.location == kCFNotFound || pathRg.length == 0) {
+        // No path
+        return pathRg;
+    }
+    if (CFStringGetCharacterAtIndex(url->_string, pathRg.location + pathRg.length - 1) == PATH_DELIM_FOR_TYPE(pathType)) {
+        pathRg.length --;
+        if (pathRg.length == 0) {
+            pathRg.length ++;
+            return pathRg;
+        }
+    }
+    if (CFStringFindWithOptions(url->_string, PATH_DELIM_AS_STRING_FOR_TYPE(pathType), pathRg, kCFCompareBackwards, &componentRg)) {
+        componentRg.location ++;
+        componentRg.length = pathRg.location + pathRg.length - componentRg.location;
+    } else {
+        componentRg = pathRg;
+    }
+    return componentRg;
+}
+
+CFStringRef CFURLCopyLastPathComponent(CFURLRef url) {
+    CFStringRef result;
+
+    if (CF_IS_OBJC(__kCFURLTypeID, url)) {
+        CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+        CFIndex length;
+        CFRange rg, compRg;
+        if (!path) return NULL;
+        rg = CFRangeMake(0, CFStringGetLength(path));
+        length = rg.length; // Remember this for comparison later
+        if (CFStringGetCharacterAtIndex(path, rg.length - 1) == '/') {
+            rg.length --;
+        }
+        if (CFStringFindWithOptions(path, CFSTR("/"), rg, kCFCompareBackwards, &compRg)) {
+            rg.length = rg.location + rg.length - (compRg.location+1);
+            rg.location = compRg.location + 1;
+        }
+        if (rg.location == 0 && rg.length == length) {
+            result = path;
+        } else {
+            result = CFStringCreateWithSubstring(CFGetAllocator(url), path, rg);
+            CFRelease(path);
+        }
+    } else {
+        CFRange rg = _rangeOfLastPathComponent(url);
+        if (rg.location == kCFNotFound || rg.length == 0) {
+            // No path
+            return (CFStringRef)CFRetain(CFSTR(""));
+        }
+        if (rg.length == 1 && CFStringGetCharacterAtIndex(url->_string, rg.location) == PATH_DELIM_FOR_TYPE(URL_PATH_TYPE(url))) {
+            return (CFStringRef)CFRetain(CFSTR("/"));
+        }
+        result = CFStringCreateWithSubstring(CFGetAllocator(url), url->_string, rg);
+        if (URL_PATH_TYPE(url) == FULL_URL_REPRESENTATION && !(url->_flags & POSIX_AND_URL_PATHS_MATCH)) {
+            CFStringRef tmp;
+            if (url->_flags & IS_OLD_UTF8_STYLE || url->_encoding == kCFStringEncodingUTF8) {
+                tmp = CFURLCreateStringByReplacingPercentEscapes(CFGetAllocator(url), result, CFSTR(""));
+            } else {
+                tmp = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFGetAllocator(url), result, CFSTR(""), url->_encoding);
+            }
+            CFRelease(result);
+            result = tmp;
+        }
+    }
+    return result;
+}
+
+CFStringRef CFURLCopyPathExtension(CFURLRef url) {
+    CFStringRef lastPathComp = CFURLCopyLastPathComponent(url);
+    CFStringRef ext = NULL;
+
+    if (lastPathComp) {
+        CFRange rg = CFStringFind(lastPathComp, CFSTR("."), kCFCompareBackwards);
+        if (rg.location != kCFNotFound) {
+            rg.location ++;
+            rg.length = CFStringGetLength(lastPathComp) - rg.location;
+            if (rg.length > 0) {
+                ext = CFStringCreateWithSubstring(CFGetAllocator(url), lastPathComp, rg);
+            } else {
+                ext = (CFStringRef)CFRetain(CFSTR(""));
+            }
+        }
+        CFRelease(lastPathComp);
+    }
+    return ext;
+}
+
+CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory) {
+    UInt32 fsType;
+    CFURLRef result;
+    url = _CFURLFromNSURL(url);
+    __CFGenericValidateType(url, __kCFURLTypeID);
+    CFAssert1(pathComponent != NULL, __kCFLogAssertion, "%s(): Cannot be called with a NULL component to append", __PRETTY_FUNCTION__);
+
+    fsType = URL_PATH_TYPE(url);
+    if (fsType != FULL_URL_REPRESENTATION && CFStringFindWithOptions(pathComponent, PATH_DELIM_AS_STRING_FOR_TYPE(fsType), CFRangeMake(0, CFStringGetLength(pathComponent)), 0, NULL)) {
+        // Must convert to full representation, and then work with it
+        fsType = FULL_URL_REPRESENTATION;
+        _convertToURLRepresentation((struct __CFURL *)url);
+    }
+
+    if (fsType == FULL_URL_REPRESENTATION) {
+        CFMutableStringRef newString;
+        CFStringRef newComp;
+        CFRange pathRg;
+        if (!(url->_flags & IS_PARSED)) _parseComponentsOfURL(url);
+        if (!(url->_flags & HAS_PATH)) return NULL;
+
+        newString = CFStringCreateMutableCopy(allocator, 0, url->_string);
+        newComp = CFURLCreateStringByAddingPercentEscapes(allocator, pathComponent, NULL, CFSTR(";?"),  (url->_flags & IS_OLD_UTF8_STYLE) ? kCFStringEncodingUTF8 : url->_encoding);
+        pathRg = _rangeForComponent(url->_flags, url->ranges, HAS_PATH);
+        if (!pathRg.length || CFStringGetCharacterAtIndex(url->_string, pathRg.location + pathRg.length - 1) != '/') {
+            CFStringInsert(newString, pathRg.location + pathRg.length, CFSTR("/"));
+            pathRg.length ++;
+        }
+        CFStringInsert(newString, pathRg.location + pathRg.length, newComp);
+        if (isDirectory) {
+            CFStringInsert(newString, pathRg.location + pathRg.length + CFStringGetLength(newComp), CFSTR("/"));
+        }
+        CFRelease(newComp);
+        result = _CFURLCreateWithArbitraryString(allocator, newString, url->_base);
+        CFRelease(newString);
+    } else {
+        UniChar pathDelim = PATH_DELIM_FOR_TYPE(fsType);
+        CFStringRef newString;
+        if (CFStringGetCharacterAtIndex(url->_string, CFStringGetLength(url->_string) - 1) != pathDelim) {
+            if (isDirectory) {
+                newString = CFStringCreateWithFormat(allocator, NULL, CFSTR("%@%c%@%c"), url->_string, pathDelim, pathComponent, pathDelim);
+            } else {
+                newString = CFStringCreateWithFormat(allocator, NULL, CFSTR("%@%c%@"), url->_string, pathDelim, pathComponent);
+            }
+        } else {
+            if (isDirectory) {
+                newString = CFStringCreateWithFormat(allocator, NULL, CFSTR("%@%@%c"), url->_string, pathComponent, pathDelim);
+            } else {
+                newString = CFStringCreateWithFormat(allocator, NULL, CFSTR("%@%@"), url->_string, pathComponent);
+            }
+        }
+        result = CFURLCreateWithFileSystemPathRelativeToBase(allocator, newString, fsType, isDirectory, url->_base);
+        CFRelease(newString);
+    }
+    return result;
+}
+
+CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef url) {
+    CFURLRef result;
+    CFMutableStringRef newString;
+    CFRange lastCompRg, pathRg;
+    Boolean appendDotDot = false;
+    UInt32 fsType;
+
+    url = _CFURLFromNSURL(url);
+    CFAssert1(url != NULL, __kCFLogAssertion, "%s(): NULL argument not allowed", __PRETTY_FUNCTION__);
+    __CFGenericValidateType(url, __kCFURLTypeID);
+
+    fsType = URL_PATH_TYPE(url);
+    if (fsType == FULL_URL_REPRESENTATION) {
+        if (!(url->_flags & IS_PARSED)) _parseComponentsOfURL(url);
+        if (!(url->_flags & HAS_PATH)) return NULL;
+        pathRg = _rangeForComponent(url->_flags, url->ranges, HAS_PATH);
+    } else {
+        pathRg = CFRangeMake(0, CFStringGetLength(url->_string));
+    }
+    lastCompRg = _rangeOfLastPathComponent(url);
+    if (lastCompRg.length == 0) {
+        appendDotDot = true;
+    } else if (lastCompRg.length == 1) {
+        UniChar ch = CFStringGetCharacterAtIndex(url->_string, lastCompRg.location);
+        if (ch == '.' || ch == PATH_DELIM_FOR_TYPE(fsType)) {
+            appendDotDot = true;
+        }
+    } else if (lastCompRg.length == 2 && CFStringGetCharacterAtIndex(url->_string, lastCompRg.location) == '.' && CFStringGetCharacterAtIndex(url->_string, lastCompRg.location+1) == '.') {
+        appendDotDot = true;
+    }
+
+    newString = CFStringCreateMutableCopy(allocator, 0, url->_string);
+    if (appendDotDot) {
+        CFIndex delta = 0;
+        if (pathRg.length > 0 && CFStringGetCharacterAtIndex(url->_string, pathRg.location + pathRg.length - 1) != PATH_DELIM_FOR_TYPE(fsType)) {
+            CFStringInsert(newString, pathRg.location + pathRg.length, PATH_DELIM_AS_STRING_FOR_TYPE(fsType));
+            delta ++;
+        }
+        CFStringInsert(newString, pathRg.location + pathRg.length + delta, CFSTR(".."));
+        delta += 2;
+        CFStringInsert(newString, pathRg.location + pathRg.length + delta, PATH_DELIM_AS_STRING_FOR_TYPE(fsType));
+        delta ++;
+        // We know we have "/../" at the end of the path; we wish to know if that's immediately preceded by "/." (but that "/." doesn't start the string), in which case we want to delete the "/.".
+        if (pathRg.length + delta > 4 && CFStringGetCharacterAtIndex(newString, pathRg.location + pathRg.length + delta - 5) == '.') {
+            if (pathRg.length+delta > 7 && CFStringGetCharacterAtIndex(newString, pathRg.location + pathRg.length + delta - 6) == PATH_DELIM_FOR_TYPE(fsType)) {
+                CFStringDelete(newString, CFRangeMake(pathRg.location + pathRg.length + delta - 6, 2));
+            } else if (pathRg.length+delta == 5) {
+                CFStringDelete(newString, CFRangeMake(pathRg.location + pathRg.length + delta - 5, 2));
+            }
+        }
+    } else if (lastCompRg.location == pathRg.location) {
+        CFStringReplace(newString, pathRg, CFSTR("."));
+        CFStringInsert(newString, 1, PATH_DELIM_AS_STRING_FOR_TYPE(fsType));
+    } else {
+        CFStringDelete(newString, CFRangeMake(lastCompRg.location, pathRg.location + pathRg.length - lastCompRg.location));
+    }
+    if (fsType == FULL_URL_REPRESENTATION) {
+        result = _CFURLCreateWithArbitraryString(allocator, newString, url->_base);
+    } else {
+        result = CFURLCreateWithFileSystemPathRelativeToBase(allocator, newString, fsType, true, url->_base);
+    }
+    CFRelease(newString);
+    return result;
+}
+
+CFURLRef CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator, CFURLRef url, CFStringRef extension) {
+    CFMutableStringRef newString;
+    CFURLRef result;
+    CFRange rg;
+    CFURLPathStyle fsType;
+    
+    CFAssert1(url != NULL && extension != NULL, __kCFLogAssertion, "%s(): NULL argument not allowed", __PRETTY_FUNCTION__);
+    url = _CFURLFromNSURL(url);
+    __CFGenericValidateType(url, __kCFURLTypeID);
+    __CFGenericValidateType(extension, CFStringGetTypeID());
+
+    rg = _rangeOfLastPathComponent(url);
+    if (rg.location < 0) return NULL; // No path
+    fsType = URL_PATH_TYPE(url);
+    if (fsType != FULL_URL_REPRESENTATION && CFStringFindWithOptions(extension, PATH_DELIM_AS_STRING_FOR_TYPE(fsType), CFRangeMake(0, CFStringGetLength(extension)), 0, NULL)) {
+        _convertToURLRepresentation((struct __CFURL *)url);
+        fsType = FULL_URL_REPRESENTATION;
+        rg = _rangeOfLastPathComponent(url);
+    }
+
+    newString = CFStringCreateMutableCopy(allocator, 0, url->_string);
+    CFStringInsert(newString, rg.location + rg.length, CFSTR("."));
+    if (fsType == FULL_URL_REPRESENTATION) {
+        CFStringRef newExt = CFURLCreateStringByAddingPercentEscapes(allocator, extension, NULL, CFSTR(";?/"), (url->_flags & IS_OLD_UTF8_STYLE) ? kCFStringEncodingUTF8 : url->_encoding);
+        CFStringInsert(newString, rg.location + rg.length + 1, newExt);
+        CFRelease(newExt);
+        result =  _CFURLCreateWithArbitraryString(allocator, newString, url->_base);
+    } else {
+        CFStringInsert(newString, rg.location + rg.length + 1, extension);
+        result = CFURLCreateWithFileSystemPathRelativeToBase(allocator, newString, fsType, (url->_flags & IS_DIRECTORY) != 0 ? true : false, url->_base);
+    }
+    CFRelease(newString);
+    return result;
+}
+
+CFURLRef CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator, CFURLRef url) {
+    CFRange rg, dotRg;
+    CFURLRef result;
+
+    CFAssert1(url != NULL, __kCFLogAssertion, "%s(): NULL argument not allowed", __PRETTY_FUNCTION__);
+    url = _CFURLFromNSURL(url);
+    __CFGenericValidateType(url, __kCFURLTypeID);
+    rg = _rangeOfLastPathComponent(url);
+    if (rg.location < 0) {
+        result = NULL;
+    } else if (rg.length && CFStringFindWithOptions(url->_string, CFSTR("."), rg, kCFCompareBackwards, &dotRg)) {
+        CFMutableStringRef newString = CFStringCreateMutableCopy(allocator, 0, url->_string);
+        dotRg.length = rg.location + rg.length - dotRg.location;
+        CFStringDelete(newString, dotRg);
+        if (URL_PATH_TYPE(url) == FULL_URL_REPRESENTATION) {
+            result = _CFURLCreateWithArbitraryString(allocator, newString, url->_base);
+        } else {
+            result = CFURLCreateWithFileSystemPathRelativeToBase(allocator, newString, URL_PATH_TYPE(url), (url->_flags & IS_DIRECTORY) != 0 ? true : false, url->_base);
+        }
+        CFRelease(newString);
+    } else {
+        result = (CFURLRef)CFRetain(url);
+    }
+    return result;
+}
+
+
+
+
+
+// keys and vals must have space for at least 4 key/value pairs.  No argument can be NULL.
+// Caller must release values, but not keys
+static void __CFURLCopyPropertyListKeysAndValues(CFURLRef url, CFTypeRef *keys, CFTypeRef *vals, CFIndex *count) {
+    CFAllocatorRef alloc = CFGetAllocator(url);
+    CFURLRef base = CFURLGetBaseURL(url);
+    keys[0] = CFSTR("_CFURLStringType");
+    keys[1] = CFSTR("_CFURLString");
+    keys[2] = CFSTR("_CFURLBaseStringType");
+    keys[3] = CFSTR("_CFURLBaseURLString");
+    if (CF_IS_OBJC(__kCFURLTypeID, url)) {
+        SInt32 urlType = FULL_URL_REPRESENTATION;
+        vals[0] = CFNumberCreate(alloc, kCFNumberSInt32Type, &urlType);
+        vals[1] = CFURLGetString(url);
+    } else {
+        SInt32 urlType = URL_PATH_TYPE(url);
+        vals[0] = CFNumberCreate(alloc, kCFNumberSInt32Type, &urlType);
+        if (url->_flags & IS_DIRECTORY) {
+            if (CFStringGetCharacterAtIndex(url->_string, CFStringGetLength(url->_string) - 1) == PATH_DELIM_FOR_TYPE(urlType)) {
+                vals[1] = CFRetain(url->_string);
+            } else {
+                vals[1] = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@%c"), url->_string, PATH_DELIM_FOR_TYPE(urlType));
+            }
+        } else {
+            if (CFStringGetCharacterAtIndex(url->_string, CFStringGetLength(url->_string) - 1) != PATH_DELIM_FOR_TYPE(urlType)) {
+                vals[1] = CFRetain(url->_string);
+            } else {
+                vals[1] = CFStringCreateWithSubstring(alloc, url->_string, CFRangeMake(0, CFStringGetLength(url->_string) - 1));
+            }
+        }
+    }
+    if (base != NULL) {
+        if (CF_IS_OBJC(__kCFURLTypeID, base)) {
+            SInt32 urlType = FULL_URL_REPRESENTATION;
+            vals[2] = CFNumberCreate(alloc, kCFNumberSInt32Type, &urlType);
+            vals[3] = CFURLGetString(base);
+        } else {
+            SInt32 urlType = URL_PATH_TYPE(base);
+            vals[2] = CFNumberCreate(alloc, kCFNumberSInt32Type, &urlType);
+            if (base->_flags & IS_DIRECTORY) {
+                if (CFStringGetCharacterAtIndex(base->_string, CFStringGetLength(base->_string) - 1) == PATH_DELIM_FOR_TYPE(urlType)) {
+                    vals[3] = CFRetain(base->_string);
+                } else {
+                    vals[3] = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@%c"), base->_string, PATH_DELIM_FOR_TYPE(urlType));
+                }
+            } else {
+                if (CFStringGetCharacterAtIndex(base->_string, CFStringGetLength(base->_string) - 1) != PATH_DELIM_FOR_TYPE(urlType)) {
+                    vals[3] = CFRetain(base->_string);
+                } else {
+                    vals[3] = CFStringCreateWithSubstring(alloc, base->_string, CFRangeMake(0, CFStringGetLength(base->_string) - 1));
+                }
+            }
+        }
+        *count = 4;
+    } else {
+        *count = 2;
+    }
+}
+
+// Private API for Finder to use
+CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url) {
+    CFTypeRef keys[4], vals[4];
+    CFDictionaryRef dict;
+    CFIndex count, idx;
+    __CFURLCopyPropertyListKeysAndValues(url, keys, vals, &count);
+    dict = CFDictionaryCreate(CFGetAllocator(url), keys, vals, count, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    for (idx = 0; idx < count; idx ++) {
+        CFRelease(vals[idx]);
+    }
+    return dict;
+}
+
+CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation) {
+    CFStringRef baseString, string;
+    CFNumberRef baseTypeNum, urlTypeNum;
+    SInt32 baseType, urlType;
+    CFURLRef baseURL = NULL, url;
+    CFDictionaryRef dict = (CFDictionaryRef)pListRepresentation;
+
+    // Start by getting all the pieces and verifying they're of the correct type.
+    if (CFGetTypeID(pListRepresentation) != CFDictionaryGetTypeID()) {
+        return NULL;
+    }
+    string = (CFStringRef)CFDictionaryGetValue(dict, CFSTR("_CFURLString"));
+    if (!string || CFGetTypeID(string) != CFStringGetTypeID()) {
+        return NULL;
+    }
+    urlTypeNum = (CFNumberRef)CFDictionaryGetValue(dict, CFSTR("_CFURLStringType"));
+    if (!urlTypeNum || CFGetTypeID(urlTypeNum) != CFNumberGetTypeID() || !CFNumberGetValue(urlTypeNum, kCFNumberSInt32Type, &urlType) || (urlType != FULL_URL_REPRESENTATION && urlType != kCFURLPOSIXPathStyle && urlType != kCFURLHFSPathStyle && urlType != kCFURLWindowsPathStyle)) {
+        return NULL;
+    }
+    baseString = (CFStringRef)CFDictionaryGetValue(dict, CFSTR("_CFURLBaseURLString"));
+    if (baseString) {
+        if (CFGetTypeID(baseString) != CFStringGetTypeID()) {
+            return NULL;
+        }
+        baseTypeNum = (CFNumberRef)CFDictionaryGetValue(dict, CFSTR("_CFURLBaseStringType"));
+        if (!baseTypeNum || CFGetTypeID(baseTypeNum) != CFNumberGetTypeID() || !CFNumberGetValue(baseTypeNum, kCFNumberSInt32Type, &baseType) ||
+            (baseType != FULL_URL_REPRESENTATION && baseType != kCFURLPOSIXPathStyle && baseType != kCFURLHFSPathStyle && baseType != kCFURLWindowsPathStyle)) {
+            return NULL;
+        }
+        if (baseType == FULL_URL_REPRESENTATION) {
+            baseURL = _CFURLCreateWithArbitraryString(alloc, baseString, NULL);
+        } else {
+            baseURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, baseString, (CFURLPathStyle)baseType, CFStringGetCharacterAtIndex(baseString, CFStringGetLength(baseString)-1) == PATH_DELIM_FOR_TYPE(baseType), NULL);
+        }
+    }
+    if (urlType == FULL_URL_REPRESENTATION) {
+        url = _CFURLCreateWithArbitraryString(alloc, string, baseURL);
+    } else {
+        url = CFURLCreateWithFileSystemPathRelativeToBase(alloc, string, (CFURLPathStyle)urlType, CFStringGetCharacterAtIndex(string, CFStringGetLength(string)-1) == PATH_DELIM_FOR_TYPE(urlType), baseURL);
+    }
+    if (baseURL) CFRelease(baseURL);
+    return url;
+}
+
+
diff --git a/CoreFoundation/CFURL.h b/CoreFoundation/CFURL.h
new file mode 100644
index 0000000..d783631
--- /dev/null
+++ b/CoreFoundation/CFURL.h
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFURL__)
+#define __COREFOUNDATION_CFURL__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFString.h>
+
+CF_EXTERN_C_BEGIN
+
+enum {
+    kCFURLPOSIXPathStyle = 0,
+    kCFURLHFSPathStyle,
+    kCFURLWindowsPathStyle
+};
+typedef CFIndex CFURLPathStyle;
+    
+typedef const struct __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. */
+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);
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+
+/* 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  */
+CF_EXPORT
+CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+#endif
+
+/* 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);
+
+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
+
+<scheme> "://" <net location> <path, always starting with slash> <add'l resource specifiers>
+
+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 "<key>=<value>;"  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);
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+enum {
+	kCFURLComponentScheme = 1,
+	kCFURLComponentNetLocation = 2,
+	kCFURLComponentPath = 3,
+	kCFURLComponentResourceSpecifier = 4,
+
+	kCFURLComponentUser = 5,
+	kCFURLComponentPassword = 6,
+	kCFURLComponentUserInfo = 7,
+	kCFURLComponentHost = 8,
+	kCFURLComponentPort = 9,
+	kCFURLComponentParameterString = 10,
+	kCFURLComponentQuery = 11,
+	kCFURLComponentFragment = 12
+};
+typedef CFIndex CFURLComponentType;
+ 
+/* 
+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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+#endif
+
+/* 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);
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+#endif
+
+/* 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);
+
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFURL__ */
+
diff --git a/CoreFoundation/CFURLAccess.c b/CoreFoundation/CFURLAccess.c
new file mode 100644
index 0000000..b6d61b8
--- /dev/null
+++ b/CoreFoundation/CFURLAccess.c
@@ -0,0 +1,838 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Becky Willrich
+*/
+
+/*------
+CFData read/write routines
+-------*/
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFURLAccess.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFNumber.h>
+#include <string.h>
+#include <ctype.h>
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#include <stdlib.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <winsock2.h>
+#include <sys/stat.h>
+#include <io.h>
+#define chmod _chmod
+#endif
+
+
+#if DEPLOYMENT_TARGET_MACOSX
+
+DEFINE_WEAK_CFNETWORK_FUNC(Boolean, _CFURLCreateDataAndPropertiesFromResource, (CFAllocatorRef A, CFURLRef B, CFDataRef *C, CFDictionaryRef *D, CFArrayRef E, SInt32 *F), (A, B, C, D, E, F), false)
+DEFINE_WEAK_CFNETWORK_FUNC(Boolean, _CFURLWriteDataAndPropertiesToResource, (CFURLRef A, CFDataRef B, CFDictionaryRef C, SInt32 *D), (A, B, C, D), false)
+DEFINE_WEAK_CFNETWORK_FUNC(Boolean, _CFURLDestroyResource, (CFURLRef A, SInt32 *B), (A, B), false)
+
+#endif
+
+
+CONST_STRING_DECL(kCFURLFileExists, "kCFURLFileExists")
+CONST_STRING_DECL(kCFURLFilePOSIXMode, "kCFURLFilePOSIXMode")
+CONST_STRING_DECL(kCFURLFileDirectoryContents, "kCFURLFileDirectoryContents")
+CONST_STRING_DECL(kCFURLFileLength, "kCFURLFileLength")
+CONST_STRING_DECL(kCFURLFileLastModificationTime, "kCFURLFileLastModificationTime")
+CONST_STRING_DECL(kCFURLFileOwnerID, "kCFURLFileOwnerID")
+CONST_STRING_DECL(kCFURLHTTPStatusCode, "kCFURLHTTPStatusCode")
+CONST_STRING_DECL(kCFURLHTTPStatusLine, "kCFURLHTTPStatusLine")
+
+CONST_STRING_DECL(kCFDataURLDataLength, "kCFDataURLDataLength")
+CONST_STRING_DECL(kCFDataURLMimeType, "kCFDataURLMimeType")
+CONST_STRING_DECL(kCFDataURLTextEncodingName, "kCFDataURLTextEncodingName")
+
+// Compatibility property strings -- we obsoleted these names pre-DP4. REW, 5/22/2000
+CONST_STRING_DECL(kCFFileURLExists, "kCFURLFileExists")
+CONST_STRING_DECL(kCFFileURLPOSIXMode, "kCFURLFilePOSIXMode")
+CONST_STRING_DECL(kCFFileURLDirectoryContents, "kCFURLFileDirectoryContents")
+CONST_STRING_DECL(kCFFileURLSize, "kCFURLFileLength")
+CONST_STRING_DECL(kCFFileURLLastModificationTime, "kCFURLFileLastModificationTime")
+CONST_STRING_DECL(kCFHTTPURLStatusCode, "kCFURLHTTPStatusCode")
+CONST_STRING_DECL(kCFHTTPURLStatusLine, "kCFURLHTTPStatusLine")
+
+// Copied pretty much verbatim from NSData; note that files are still special cased in this code.  Ultimately, we probably want to treat file URLs the same way as any other URL (go through the URL Access layer).  -- REW, 10/21/98
+
+/*************************/
+/* file: access routines */
+/*************************/
+
+//#warning CF:For the moment file access failures are ill defined and set the error code to kCFURLUnknownError
+
+static CFDictionaryRef _CFFileURLCreatePropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFArrayRef desiredProperties, SInt32 *errorCode) {
+    // MF:!!! This could/should be changed to use _CFGetFileProperties() to do the actual figuring.
+    static CFArrayRef _allProps = NULL;
+    CFRange arrayRange;
+    SInt32 idx;
+    CFMutableDictionaryRef propertyDict = NULL;
+
+    Boolean exists;
+    SInt32 posixMode;
+    int64_t size;
+    CFDateRef modTime = NULL, *modTimePtr = NULL;
+    CFArrayRef contents = NULL, *contentsPtr = NULL;
+    SInt32 ownerID;
+
+    if (errorCode) *errorCode = 0;
+    if (!desiredProperties) {
+        // Cheap and dirty hack to make this work for the moment; ultimately we need to do something more sophisticated.  This will result in an error return whenever a property key is defined which isn't applicable to all file URLs.  REW, 3/2/99
+        if (!_allProps) {
+            const void *values[9];
+            values[0] = kCFURLFileExists;
+            values[1] = kCFURLFilePOSIXMode;
+            values[2] = kCFURLFileDirectoryContents;
+            values[3] = kCFURLFileLength;
+            values[4] = kCFURLFileLastModificationTime;
+            values[5] = kCFURLFileOwnerID;
+            _allProps = CFArrayCreate(kCFAllocatorSystemDefault, values, 6, &kCFTypeArrayCallBacks);
+        }
+        desiredProperties = _allProps;
+    }
+
+    arrayRange.location = 0;
+    arrayRange.length = CFArrayGetCount(desiredProperties);
+    propertyDict = CFDictionaryCreateMutable(alloc, 0, & kCFTypeDictionaryKeyCallBacks, & kCFTypeDictionaryValueCallBacks);
+    if (arrayRange.length == 0) return propertyDict;
+
+    if (CFArrayContainsValue(desiredProperties, arrayRange, kCFURLFileDirectoryContents)) {
+        contentsPtr = &contents;
+    }
+    if (CFArrayContainsValue(desiredProperties, arrayRange, kCFURLFileLastModificationTime)) {
+        modTimePtr = &modTime;
+    }
+
+    if (_CFGetFileProperties(alloc, url, &exists, &posixMode, &size, modTimePtr, &ownerID, contentsPtr) != 0) {
+        if (errorCode) {
+            *errorCode = kCFURLUnknownError;
+        }
+        return propertyDict;
+    }
+    
+    for (idx = 0; idx < arrayRange.length; idx ++) {
+        CFStringRef key = (CFMutableStringRef )CFArrayGetValueAtIndex(desiredProperties, idx);
+        if (key == kCFURLFilePOSIXMode || CFEqual(kCFURLFilePOSIXMode, key)) {
+            if (exists) {
+                CFNumberRef num = CFNumberCreate(alloc, kCFNumberSInt32Type, &posixMode);
+                CFDictionarySetValue(propertyDict, kCFURLFilePOSIXMode, num);
+                CFRelease(num);
+            } else if (errorCode) {
+                *errorCode = kCFURLUnknownError;
+            }
+        } else if (key == kCFURLFileDirectoryContents || CFEqual(kCFURLFileDirectoryContents, key)) {
+            if (exists && (posixMode & S_IFMT) == S_IFDIR && contents) {
+                CFDictionarySetValue(propertyDict, kCFURLFileDirectoryContents, contents);
+            } else if (errorCode) {
+                *errorCode = kCFURLUnknownError;
+            }
+        } else if (key == kCFURLFileLength || CFEqual(kCFURLFileLength, key)) {
+            if (exists) {
+                CFNumberRef num = CFNumberCreate(alloc, kCFNumberSInt64Type, &size);
+                CFDictionarySetValue(propertyDict, kCFURLFileLength, num);
+                CFRelease(num);
+            } else if (errorCode) {
+                *errorCode = kCFURLUnknownError;
+            }
+        } else if (key == kCFURLFileLastModificationTime || CFEqual(kCFURLFileLastModificationTime, key)) {
+            if (exists && modTime) {
+                CFDictionarySetValue(propertyDict, kCFURLFileLastModificationTime, modTime);
+            } else if (errorCode) {
+                *errorCode = kCFURLUnknownError;
+            }
+        } else if (key == kCFURLFileExists || CFEqual(kCFURLFileExists, key)) {
+            if (exists) {
+                CFDictionarySetValue(propertyDict, kCFURLFileExists, kCFBooleanTrue);
+            } else {
+                CFDictionarySetValue(propertyDict, kCFURLFileExists, kCFBooleanFalse);
+            }
+        } else if (key == kCFURLFileOwnerID || CFEqual(kCFURLFileOwnerID, key)) {
+            if (exists) {
+                CFNumberRef num  = CFNumberCreate(alloc, kCFNumberSInt32Type, &ownerID);
+                CFDictionarySetValue(propertyDict, kCFURLFileOwnerID, num);
+                CFRelease(num);
+            } else if (errorCode) {
+                *errorCode = kCFURLUnknownError;
+            }
+        // Add more properties here
+        } else if (errorCode) {
+            *errorCode = kCFURLUnknownPropertyKeyError;
+        }
+    }
+    if (modTime) CFRelease(modTime);
+    if (contents) CFRelease(contents);
+    return propertyDict;
+}
+
+static Boolean _CFFileURLWritePropertiesToResource(CFURLRef url, CFDictionaryRef propertyDict, SInt32 *errorCode) {
+    CFTypeRef buffer[16];
+    CFTypeRef *keys;
+    CFTypeRef *values;
+    Boolean result = true;
+    SInt32 idx, count;
+    char cPath[CFMaxPathSize];
+
+    if (!CFURLGetFileSystemRepresentation(url, true, (unsigned char *)cPath, CFMaxPathSize)) {
+        if (errorCode) *errorCode = kCFURLImproperArgumentsError;
+        return false;
+    }
+
+    count = CFDictionaryGetCount(propertyDict);
+    if (count < 8) {
+        keys = buffer;
+        values = buffer+8;
+    } else {
+        keys = (CFTypeRef *)CFAllocatorAllocate(CFGetAllocator(url), sizeof(void *) * count * 2, 0);
+        values = keys + count;
+    }
+    CFDictionaryGetKeysAndValues(propertyDict, keys, values);
+
+    for (idx = 0; idx < count; idx ++) {
+        CFStringRef key = (CFStringRef)keys[idx];
+        CFTypeRef value = values[idx];
+        if (key == kCFURLFilePOSIXMode || CFEqual(kCFURLFilePOSIXMode, key)) {
+            SInt32 mode;
+            int err;
+            if (CFNumberGetTypeID() == CFGetTypeID(value)) {
+                CFNumberRef modeNum = (CFNumberRef)value;
+                CFNumberGetValue(modeNum, kCFNumberSInt32Type, &mode);
+            } else {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+#define MODE_TYPE mode_t
+#elif DEPLOYMENT_TARGET_WINDOWS
+#define MODE_TYPE unsigned short
+#endif
+                const MODE_TYPE *modePtr = (const MODE_TYPE *)CFDataGetBytePtr((CFDataRef)value);
+                mode = *modePtr;
+            }
+            err = chmod(cPath, mode);
+            if (err != 0) result = false;
+        } else {
+            result = false;
+        }
+    }
+
+    if ((CFTypeRef)keys != buffer) CFAllocatorDeallocate(CFGetAllocator(url), keys);
+
+    if (errorCode) *errorCode = result ? 0 : kCFURLUnknownError;
+    return result;
+}
+
+static Boolean _CFFileURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *fetchedData, CFArrayRef desiredProperties, CFDictionaryRef *fetchedProperties, SInt32 *errorCode) {
+    Boolean success = true;
+
+    if (errorCode) *errorCode = 0;
+    if (fetchedData) {
+        void *bytes;
+        CFIndex length;
+        Boolean releaseAlloc = false;
+        
+        if (alloc == NULL) {
+            // We need a real allocator to pass to _CFReadBytesFromFile so that the CFDataRef we create with
+			//	CFDataCreateWithBytesNoCopy() can free up the object _CFReadBytesFromFile() returns.
+            alloc = (CFAllocatorRef)CFRetain(__CFGetDefaultAllocator());
+            releaseAlloc = true;
+        }
+        if (!_CFReadBytesFromFile(alloc, url, &bytes, &length, 0)) {
+            if (errorCode) *errorCode = kCFURLUnknownError;
+            *fetchedData = NULL;
+            success = false;
+        } else {
+            *fetchedData = CFDataCreateWithBytesNoCopy(alloc, (const UInt8 *)bytes, length, alloc);
+        }
+        if (releaseAlloc) {
+            // Now the CFData should be hanging on to it.
+            CFRelease(alloc);
+        }
+    }
+
+    if (fetchedProperties) {
+        *fetchedProperties = _CFFileURLCreatePropertiesFromResource(alloc, url, desiredProperties, errorCode);
+        if (!*fetchedProperties) success = false;
+    }
+
+    return success;
+}
+
+/*
+ * Support for data: URLs - RFC 2397
+ * Currently this is spi for CFNetwork, to make it API, just put these constants in CFURLAccess.h
+ */
+
+/*
+CF_EXPORT
+const CFStringRef kCFDataURLDataLength;
+CF_EXPORT
+const CFStringRef kCFDataURLMimeType;
+CF_EXPORT
+const CFStringRef kCFDataURLTextEncodingName;
+*/
+
+/* Properties for the data: scheme. */
+/* kCFDataURLDataLength is a CFNumber giving the data's length in bytes. */
+/* kCFDataURLMimeType is a CFString. */
+/* kCFDataURLTextEncodingName is a CFString. */
+
+/* REMINDSMZ: From CFURLResponse.c */
+static CFStringRef mimeTypeFromContentTypeComponent(CFStringRef component) {
+    CFIndex compLen = CFStringGetLength(component);
+    CFStringInlineBuffer buf;
+    CFIndex idx;
+    CFIndex firstChar = -1, lastChar = -1;
+    CFCharacterSetRef whitespaceSet = CFCharacterSetGetPredefined(kCFCharacterSetWhitespace);
+    CFStringInitInlineBuffer(component, &buf, CFRangeMake(0, compLen));
+    
+    for (idx = 0; idx < compLen; idx ++) {
+		UniChar ch = CFStringGetCharacterFromInlineBuffer(&buf, idx);
+		if (ch == ';') {
+			// Delimits the charset
+			break;
+		} else if (firstChar == -1) {
+			if (!CFCharacterSetIsCharacterMember(whitespaceSet, ch)) {
+				firstChar = idx;
+			}
+		} else if (!CFCharacterSetIsCharacterMember(whitespaceSet, ch)) {
+			lastChar = idx;
+		}
+    }
+    if (firstChar != -1 && lastChar != -1) {
+		CFMutableStringRef newContentType = CFStringCreateMutableCopy(CFGetAllocator(component), compLen, component);
+		if (lastChar != compLen - 1) {
+			CFStringDelete(newContentType, CFRangeMake(lastChar + 1, compLen - lastChar - 1));
+		}
+		if (firstChar > 0) {
+			CFStringDelete(newContentType, CFRangeMake(0, firstChar));
+		}
+		CFStringLowercase(newContentType, NULL);
+		return newContentType;
+    }
+    return NULL;
+}
+
+/* REMINDSMZ: From CFURLResponse.c */
+static CFStringRef charsetFromContentTypeHeader(CFStringRef contentType) {
+    // FIXME: Should this use KeyValuePair parsing to handle quoting properly?
+    CFRange range;
+    CFIndex compLen = CFStringGetLength(contentType);
+    CFIndex start, end, idx;
+    CFCharacterSetRef whitespaceSet;
+    CFMutableStringRef result;
+    
+	CFStringRef kCFURLResponseCharsetPrefix = CFSTR("charset=");
+	
+    if (!CFStringFindWithOptions(contentType, kCFURLResponseCharsetPrefix, CFRangeMake(0, compLen), kCFCompareCaseInsensitive, &range) || range.length == 0) return NULL;
+	
+    whitespaceSet = CFCharacterSetGetPredefined(kCFCharacterSetWhitespace);
+    start = -1; 
+    end = -1;
+    for (idx = range.location + range.length; idx < compLen; idx ++) {
+		UniChar ch = CFStringGetCharacterAtIndex(contentType, idx);
+		if (ch == ';' || ch == ',') break;
+		if (start == -1) {
+			if (!CFCharacterSetIsCharacterMember(whitespaceSet, ch)) {
+				start = idx;
+				end = idx;
+			} 
+		} else if (!CFCharacterSetIsCharacterMember(whitespaceSet,ch)) {
+			end = idx;
+		}
+    }
+	
+    if (start == -1) return NULL;
+	
+    result = CFStringCreateMutableCopy(CFGetAllocator(contentType), compLen,contentType);
+    if (end != compLen) {
+		CFStringDelete(result, CFRangeMake(end+1, compLen-end-1));
+    }
+    CFStringDelete(result, CFRangeMake(0, start));
+    CFStringLowercase(result, NULL);
+    return result;
+}
+
+#define STATIC_BUFFER_SIZE 1024
+
+static Boolean isHexDigit(char c)
+{
+    return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
+}
+
+static UInt8 hexDigitValue(char c)
+{
+    if (c >= '0' && c <= '9') {
+        return c - '0';
+    }
+    if (c >= 'A' && c <= 'F') {
+        return c - 'A' + 10;
+    }
+    if (c >= 'a' && c <= 'f') {
+        return c - 'a' + 10;
+    }
+    // NSURL_ERROR("illegal hex digit");
+    return 0;
+}
+
+static CFDataRef percentEscapeDecodeBuffer(CFAllocatorRef alloc, const UInt8* srcBuffer, CFRange range, Boolean stripWhitespace)
+{
+    UInt8* dstBuffer;
+    UInt8 staticDstBuffer[STATIC_BUFFER_SIZE];
+	
+    if (range.length > STATIC_BUFFER_SIZE) {
+		dstBuffer = (UInt8*) malloc(range.length);
+    } else {
+		dstBuffer = staticDstBuffer;
+    }
+	
+    CFIndex end = range.location + range.length;
+	
+    CFIndex i;
+    CFIndex j;
+    for (i = range.location, j = 0; i < end; ++i) {
+		char value;
+		
+		if (srcBuffer[i] == '%' && end > i + 2 && isHexDigit(srcBuffer[i+1]) && isHexDigit(srcBuffer[i+2])) {
+			value = hexDigitValue(srcBuffer[i+1]) * 16 + hexDigitValue(srcBuffer[i+2]);
+			i += 2;
+		} else {
+			value = srcBuffer[i];
+		}
+		
+		if (!stripWhitespace || !isspace(value)) {
+			dstBuffer[j++] = value;
+		}
+    }
+	
+    CFDataRef result = CFDataCreate(alloc, dstBuffer, j);
+	
+    if (dstBuffer != staticDstBuffer) {
+		free(dstBuffer);
+    }
+	
+    return result;
+}
+
+
+// base 64 digits: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
+
+static Boolean isBase64Digit(char c)
+{
+    return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c == '+') || (c == '/');
+}
+
+static Boolean isBase64DigitOrEqualSign(char c)
+{
+    return isBase64Digit(c) || c == '=';
+}
+
+static UInt8 base64DigitValue(char c)
+{
+    if (c >= 'A' && c <= 'Z') {
+		return c - 'A';
+    } else if (c >= 'a' && c <= 'z') {
+		return 26 + c - 'a';
+    } else if (c >= '0' && c <= '9') {
+		return 52 + c - '0';
+    } else if (c == '+') {
+		return 62;
+    } else if (c == '/') {
+		return 63;
+    } else {
+		return 0;
+    }
+}
+
+static CFDataRef base64DecodeData(CFAllocatorRef alloc, CFDataRef data)
+{
+    const UInt8 *srcBuffer = CFDataGetBytePtr(data);
+    CFIndex length = CFDataGetLength(data);
+    UInt8 *dstBuffer = NULL;
+    UInt8 staticDstBuffer[STATIC_BUFFER_SIZE];
+	CFDataRef result = NULL;
+	
+    // base64 encoded data length must be multiple of 4
+    if (length % 4 != 0) {
+		goto done;
+    }
+	
+    if (length > STATIC_BUFFER_SIZE) {
+		dstBuffer = (UInt8*) malloc(length);
+    } else {
+		dstBuffer = staticDstBuffer;
+    }
+	
+    CFIndex i;
+    CFIndex j;
+    for (i = 0, j = 0; i < length; i+=4) {
+		if (!(isBase64Digit(srcBuffer[i]) &&
+			  isBase64Digit(srcBuffer[i+1]) &&
+			  isBase64DigitOrEqualSign(srcBuffer[i+2]) &&
+			  isBase64DigitOrEqualSign(srcBuffer[i+3]))) {
+			if (dstBuffer != staticDstBuffer) {
+				free(dstBuffer);
+			}
+			return NULL;
+		}
+		
+		dstBuffer[j++] = (base64DigitValue(srcBuffer[i]) << 2) + (base64DigitValue(srcBuffer[i+1]) >> 4);
+		if (srcBuffer[i+2] != '=') {
+			dstBuffer[j++] = ((base64DigitValue(srcBuffer[i+1]) & 0xf) << 4) + (base64DigitValue(srcBuffer[i+2]) >> 2);
+		}
+		if (srcBuffer[i+3] != '=') {
+			dstBuffer[j++] = ((base64DigitValue(srcBuffer[i+2]) & 0x3) << 6) + (base64DigitValue(srcBuffer[i+3]));
+		}
+    }
+    
+    result = CFDataCreate(alloc, dstBuffer, j);
+	
+done:
+    if (dstBuffer != staticDstBuffer) {
+		free(dstBuffer);
+    }
+	
+    return result;
+}
+
+static inline CFStringRef percentExpandAndTrimContentType(CFAllocatorRef alloc, CFStringRef str, CFRange range)
+{
+	CFStringRef contentTypeUnexpanded = CFStringCreateWithSubstring(alloc, str, range);
+	CFStringRef contentTypeExpanded = CFURLCreateStringByReplacingPercentEscapes(alloc, contentTypeUnexpanded, CFSTR(""));
+	CFRelease(contentTypeUnexpanded);
+	
+	CFMutableStringRef contentTypeHeader = CFStringCreateMutableCopy(alloc, 0, contentTypeExpanded);
+	CFRelease(contentTypeExpanded);
+	CFStringTrimWhitespace(contentTypeHeader);
+	
+	return contentTypeHeader;
+}
+
+static Boolean parseDataRequestURL(CFURLRef url, CFDataRef* outData, CFStringRef* outMimeType, CFStringRef* outTextEncodingName)
+{
+    Boolean result = FALSE;
+    CFAllocatorRef alloc = CFGetAllocator(url);
+    CFStringRef str = CFURLCopyResourceSpecifier(url);
+    if (str != NULL) {
+		CFRange commaRange = CFStringFind(str, CFSTR(","), 0);
+		
+		if (commaRange.location != kCFNotFound) {
+			CFStringRef contentTypeHeader = percentExpandAndTrimContentType(alloc, str, CFRangeMake(0, commaRange.location));
+			CFStringRef mimeType = mimeTypeFromContentTypeComponent(contentTypeHeader);
+			CFStringRef textEncodingName = charsetFromContentTypeHeader(contentTypeHeader);
+
+			Boolean base64 = CFStringFind(contentTypeHeader, CFSTR(";base64"), kCFCompareCaseInsensitive).location != kCFNotFound;
+
+			if (mimeType == NULL) {
+				mimeType = (CFStringRef) CFRetain(CFSTR("text/plain"));
+			}
+			
+			if (textEncodingName == NULL) {
+				textEncodingName = (CFStringRef) CFRetain(CFSTR("us-ascii"));
+			}
+
+			CFIndex bufferSize = CFURLGetBytes(url, NULL, 0);
+			UInt8* srcBuffer = (UInt8*) malloc(bufferSize);
+			CFURLGetBytes(url, srcBuffer, bufferSize);
+			
+			CFRange dataRange = CFURLGetByteRangeForComponent(url, kCFURLComponentResourceSpecifier, NULL);
+			while (srcBuffer[dataRange.location] != ',') {
+				dataRange.location++;
+				dataRange.length--;
+			}
+			dataRange.location++;
+			dataRange.length--;
+			
+			CFDataRef dataRef = NULL;
+			
+			if (! base64) {
+				dataRef = percentEscapeDecodeBuffer(alloc, srcBuffer, dataRange, false);
+			} else {
+				CFDataRef unescapedAndStripped = percentEscapeDecodeBuffer(alloc, srcBuffer, dataRange, true);
+				if (unescapedAndStripped) {
+					dataRef = base64DecodeData(alloc, unescapedAndStripped);
+					CFRelease(unescapedAndStripped);
+				}
+			}
+			
+			if (dataRef != NULL)  {
+				*outData = dataRef;
+				*outMimeType = (CFStringRef) mimeType == NULL? NULL : CFStringCreateCopy(alloc, mimeType);
+				*outTextEncodingName = (CFStringRef) textEncodingName == NULL? NULL : CFStringCreateCopy(alloc, textEncodingName);
+				result = true;
+			}
+
+			free(srcBuffer);
+			
+			if (contentTypeHeader) CFRelease(contentTypeHeader);
+			if (mimeType) CFRelease(mimeType);
+			if (textEncodingName) CFRelease(textEncodingName);
+		}
+		
+		CFRelease(str);
+    }
+    
+    return result;
+}
+
+static Boolean _CFDataURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *fetchedData, CFArrayRef desiredProperties, CFDictionaryRef *fetchedProperties, SInt32 *errorCode) {
+    Boolean success = true;
+	
+    if (errorCode) *errorCode = 0;
+	
+	// We always need to fetch the data...
+	CFDataRef data = NULL;
+	CFStringRef mimeType = NULL;
+	CFStringRef textEncodingName = NULL;
+
+	if (! parseDataRequestURL(url, &data, &mimeType, &textEncodingName)) {
+		if (errorCode)
+			*errorCode = kCFURLUnknownError;
+		*fetchedData = NULL;
+		success = false;
+	} else {
+		if (fetchedData) {
+			*fetchedData = CFDataCreateCopy(alloc, data);
+		}
+		
+		if (fetchedProperties) {
+			const void* propKeys[] = {
+				kCFDataURLDataLength,
+				kCFDataURLMimeType,
+				kCFDataURLTextEncodingName,
+			};
+			const CFIndex propKeysCount = sizeof(propKeys) / sizeof(propKeys[0]);
+			
+			if (desiredProperties == NULL) {
+				static CFArrayRef sAllProps = NULL;
+				if (sAllProps == NULL) {
+					sAllProps = CFArrayCreate(kCFAllocatorSystemDefault, propKeys, propKeysCount, &kCFTypeArrayCallBacks);
+				}
+				desiredProperties = sAllProps;
+			}
+				
+			const void* vals[propKeysCount];
+			const void* keys[propKeysCount];
+			int ixVal = 0;
+			
+			CFIndex count = CFArrayGetCount(desiredProperties);
+			for (CFIndex i = 0;  i < count;  i++) {
+				CFStringRef key = (CFStringRef) CFArrayGetValueAtIndex(desiredProperties, i);
+				
+				if (CFEqual(key, kCFDataURLDataLength)) {
+					CFIndex len = CFDataGetLength(data);
+					keys[ixVal] = key;
+					vals[ixVal++] = CFNumberCreate(alloc, kCFNumberCFIndexType, &len);
+				} else if (CFEqual(key, kCFDataURLMimeType)) {
+					if (mimeType != NULL) {
+						keys[ixVal] = key;
+						vals[ixVal++] = CFStringCreateCopy(alloc, mimeType);
+					}
+				} else if (CFEqual(key, kCFDataURLTextEncodingName)) {
+					if (textEncodingName != NULL) {
+						keys[ixVal] = key;
+						vals[ixVal++] = CFStringCreateCopy(alloc, textEncodingName);
+					}
+				}
+			}
+			
+			*fetchedProperties = CFDictionaryCreate(alloc, keys, vals, ixVal, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+			for (CFIndex i = 0;  i < ixVal; i++) 
+				CFRelease(vals[i]);
+			if (*fetchedProperties == NULL)
+				success = false;
+		}
+		
+		if (data) CFRelease(data);
+		if (mimeType) CFRelease(mimeType);
+		if (textEncodingName) CFRelease(textEncodingName);
+    }
+	
+	
+    return success;
+}
+
+/*************************/
+/* Public routines       */
+/*************************/
+
+Boolean CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *fetchedData, CFDictionaryRef *fetchedProperties, CFArrayRef desiredProperties, SInt32 *errorCode) {
+    CFStringRef scheme = CFURLCopyScheme(url);
+
+    if (!scheme) {
+        if (errorCode) *errorCode = kCFURLImproperArgumentsError;
+        if (fetchedData) *fetchedData = NULL;
+        if (fetchedProperties) *fetchedProperties = NULL;
+        return false;
+    } else {
+        Boolean result;
+        if (CFStringCompare(scheme, CFSTR("file"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            result = _CFFileURLCreateDataAndPropertiesFromResource(alloc, url, fetchedData, desiredProperties, fetchedProperties, errorCode);
+        } else if (CFStringCompare(scheme, CFSTR("data"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+			result = _CFDataURLCreateDataAndPropertiesFromResource(alloc, url, fetchedData, desiredProperties, fetchedProperties, errorCode);
+		} else {
+#if DEPLOYMENT_TARGET_MACOSX
+         result = __CFNetwork__CFURLCreateDataAndPropertiesFromResource(alloc, url, fetchedData, fetchedProperties, desiredProperties, errorCode);
+#elif DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+			result = false;
+#endif
+	    if (!result) {
+		if (fetchedData) *fetchedData = NULL;
+		if (fetchedProperties) *fetchedProperties = NULL;
+		if (errorCode) *errorCode = kCFURLUnknownSchemeError;
+	    }
+        }
+        CFRelease(scheme);
+        return result;
+    }
+}
+
+CFTypeRef CFURLCreatePropertyFromResource(CFAllocatorRef alloc, CFURLRef url, CFStringRef property, SInt32 *errorCode) {
+    CFArrayRef array = CFArrayCreate(alloc, (const void **)&property, 1, &kCFTypeArrayCallBacks);
+    CFDictionaryRef dict;
+
+    if (CFURLCreateDataAndPropertiesFromResource(alloc, url, NULL, &dict, array, errorCode)) {
+        CFTypeRef result = CFDictionaryGetValue(dict, property);
+        if (result) CFRetain(result);
+        CFRelease(array);
+        CFRelease(dict);
+        return result;
+    } else {
+        if (dict) CFRelease(dict);
+        CFRelease(array);
+        return NULL;
+    }
+}
+
+Boolean CFURLWriteDataAndPropertiesToResource(CFURLRef url, CFDataRef data, CFDictionaryRef propertyDict, SInt32 *errorCode) {
+    CFStringRef scheme = CFURLCopyScheme(url);
+    if (!scheme) {
+        if (errorCode) *errorCode = kCFURLImproperArgumentsError;
+        return false;
+    } else if (CFStringCompare(scheme, CFSTR("file"), 0) == kCFCompareEqualTo) {
+        Boolean success = true;
+        CFRelease(scheme);
+        if (errorCode) *errorCode = 0;
+        if (data) {
+            if (CFURLHasDirectoryPath(url)) {
+                // Create a directory
+                char cPath[CFMaxPathSize];
+                if (!CFURLGetFileSystemRepresentation(url, true, (unsigned char *)cPath, CFMaxPathSize)) {
+                    if (errorCode) *errorCode = kCFURLImproperArgumentsError;
+                    success = false;
+                } else {
+                    success = _CFCreateDirectory(cPath);
+                    if (!success && errorCode) *errorCode = kCFURLUnknownError;
+                }
+            } else {
+               // Write data
+                SInt32 length = CFDataGetLength(data);
+                const void *bytes = (0 == length) ? (const void *)"" : CFDataGetBytePtr(data);
+                success = _CFWriteBytesToFile(url, bytes, length);
+                if (!success && errorCode) *errorCode = kCFURLUnknownError;
+            }
+        }
+        if (propertyDict) {
+            if (!_CFFileURLWritePropertiesToResource(url, propertyDict, errorCode))
+                success = false;
+        }
+        return success;
+    } else {
+        CFRelease(scheme);
+#if DEPLOYMENT_TARGET_MACOSX
+        Boolean result = __CFNetwork__CFURLWriteDataAndPropertiesToResource(url, data, propertyDict, errorCode);
+        if (!result) {
+            if (errorCode) *errorCode = kCFURLUnknownSchemeError;
+        }
+        return result;
+#else
+        return false;
+#endif
+    }
+}
+
+Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode) {
+    CFStringRef scheme = CFURLCopyScheme(url);
+    char cPath[CFMaxPathSize];
+
+    if (!scheme) {
+        if (errorCode) *errorCode = kCFURLImproperArgumentsError;
+        return false;
+    } else if (CFStringCompare(scheme, CFSTR("file"), 0) == kCFCompareEqualTo) {
+        CFRelease(scheme);
+        if (!CFURLGetFileSystemRepresentation(url, true, (unsigned char *)cPath, CFMaxPathSize)) {
+            if (errorCode) *errorCode = kCFURLImproperArgumentsError;
+            return false;
+        }
+
+        if (CFURLHasDirectoryPath(url)) {
+            if (_CFRemoveDirectory(cPath)) {
+                if (errorCode) *errorCode = 0;
+                return true;
+            } else {
+                if (errorCode) *errorCode = kCFURLUnknownError;
+                return false;
+            }
+        } else {
+            if (_CFDeleteFile(cPath)) {
+                if (errorCode) *errorCode = 0;
+                return true;
+            } else {
+                if (errorCode) *errorCode = kCFURLUnknownError;
+                return false;
+            }
+        }
+    } else {
+        CFRelease(scheme);
+#if DEPLOYMENT_TARGET_MACOSX
+        Boolean result = __CFNetwork__CFURLDestroyResource(url, errorCode);
+        if (!result) {
+            if (errorCode) *errorCode = kCFURLUnknownSchemeError;
+        }
+        return result;
+#else
+        return false;
+#endif
+    }
+}
+
diff --git a/CoreFoundation/CFURLAccess.h b/CoreFoundation/CFURLAccess.h
new file mode 100644
index 0000000..3a10a2a
--- /dev/null
+++ b/CoreFoundation/CFURLAccess.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFURLACCESS__)
+#define __COREFOUNDATION_CFURLACCESS__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFURL.h>
+
+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.
+
+*/
+CF_EXPORT
+Boolean CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *resourceData, CFDictionaryRef *properties, CFArrayRef desiredProperties, SInt32 *errorCode);
+
+/* 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.
+*/
+CF_EXPORT
+Boolean CFURLWriteDataAndPropertiesToResource(CFURLRef url, CFDataRef dataToWrite, CFDictionaryRef propertiesToWrite, SInt32 *errorCode);
+
+/* Destroys the resource indicated by url. */
+/* Returns success or failure; errorCode set as above. */
+CF_EXPORT
+Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode);
+
+/* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). */
+/* Returns NULL on error and sets errorCode accordingly. */
+CF_EXPORT
+CFTypeRef CFURLCreatePropertyFromResource(CFAllocatorRef alloc, CFURLRef url, CFStringRef property, SInt32 *errorCode);
+
+/* Common error codes; this list is expected to grow */
+enum {
+    kCFURLUnknownError = -10,
+    kCFURLUnknownSchemeError = -11,
+    kCFURLResourceNotFoundError = -12,
+    kCFURLResourceAccessViolationError = -13,
+    kCFURLRemoteHostUnavailableError = -14,
+    kCFURLImproperArgumentsError = -15,
+    kCFURLUnknownPropertyKeyError = -16,
+    kCFURLPropertyKeyUnavailableError = -17,
+    kCFURLTimeoutError = -18
+};
+typedef CFIndex CFURLError;
+
+/* Property keys */
+
+CF_EXPORT
+const CFStringRef kCFURLFileExists;
+CF_EXPORT
+const CFStringRef kCFURLFileDirectoryContents;
+CF_EXPORT
+const CFStringRef kCFURLFileLength;
+CF_EXPORT 
+const CFStringRef kCFURLFileLastModificationTime;
+CF_EXPORT
+const CFStringRef kCFURLFilePOSIXMode;
+CF_EXPORT
+const CFStringRef kCFURLFileOwnerID;
+CF_EXPORT
+const CFStringRef kCFURLHTTPStatusCode;
+CF_EXPORT
+const CFStringRef kCFURLHTTPStatusLine;
+
+/* 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
+
+#endif /* ! __COREFOUNDATION_CFURLACCESS__ */
+
diff --git a/CoreFoundation/CFUUID.c b/CoreFoundation/CFUUID.c
new file mode 100644
index 0000000..3c789f5
--- /dev/null
+++ b/CoreFoundation/CFUUID.c
@@ -0,0 +1,405 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright (c) 1999-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#include <CoreFoundation/CFUUID.h>
+#include "CFInternal.h"
+#if ( DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX ) && !defined(DEPLOYMENT_TARGET_ANDROID)
+#include <uuid/uuid.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <objbase.h>
+#include <stdlib.h>
+#define strtoul_l(a,b,c,d) strtoul(a,b,c)
+#endif
+
+static CFMutableDictionaryRef _uniquedUUIDs = NULL;
+static CFSpinLock_t CFUUIDGlobalDataLock = CFSpinLockInit;
+
+struct __CFUUID {
+    CFRuntimeBase _base;
+    CFUUIDBytes _bytes;
+};
+
+static Boolean __CFisEqualUUIDBytes(const void *ptr1, const void *ptr2) {
+    CFUUIDBytes *p1 = (CFUUIDBytes *)ptr1;
+    CFUUIDBytes *p2 = (CFUUIDBytes *)ptr2;
+
+    return (((p1->byte0 == p2->byte0) && (p1->byte1 == p2->byte1) && (p1->byte2 == p2->byte2) && (p1->byte3 == p2->byte3) && (p1->byte4 == p2->byte4) && (p1->byte5 == p2->byte5) && (p1->byte6 == p2->byte6) && (p1->byte7 == p2->byte7) && (p1->byte8 == p2->byte8) && (p1->byte9 == p2->byte9) && (p1->byte10 == p2->byte10) && (p1->byte11 == p2->byte11) && (p1->byte12 == p2->byte12) && (p1->byte13 == p2->byte13) && (p1->byte14 == p2->byte14) && (p1->byte15 == p2->byte15)) ? true : false);
+}
+
+static CFHashCode __CFhashUUIDBytes(const void *ptr) {
+    return CFHashBytes((uint8_t *)ptr, 16);
+}
+
+#if !defined(_MSC_VER)
+#import "auto_stubs.h"
+#endif
+
+#define LOCK() __CFSpinLock(&CFUUIDGlobalDataLock)
+#define UNLOCK() __CFSpinUnlock(&CFUUIDGlobalDataLock)
+
+#define MALLOC(x) CFAllocatorAllocate(kCFAllocatorSystemDefault, x, 0)
+#define FREE(x) CFAllocatorDeallocate(kCFAllocatorSystemDefault, x)
+#define HASH(x) CFHashBytes((uint8_t *)x, 16)
+
+
+/***** end of weak set */
+
+static void __CFUUIDAddUniqueUUID(CFUUIDRef uuid) {
+    __CFSpinLock(&CFUUIDGlobalDataLock);
+        
+    CFDictionaryKeyCallBacks __CFUUIDBytesDictionaryKeyCallBacks = {0, NULL, NULL, NULL, __CFisEqualUUIDBytes, __CFhashUUIDBytes};
+    CFDictionaryValueCallBacks __CFnonRetainedUUIDDictionaryValueCallBacks = {0, NULL, NULL, CFCopyDescription, CFEqual};
+
+    if (_uniquedUUIDs == NULL) {
+        _uniquedUUIDs = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &__CFUUIDBytesDictionaryKeyCallBacks, &__CFnonRetainedUUIDDictionaryValueCallBacks);
+    }
+    CFDictionarySetValue(_uniquedUUIDs, &(uuid->_bytes), uuid);
+    __CFSpinUnlock(&CFUUIDGlobalDataLock);
+}
+
+static void __CFUUIDRemoveUniqueUUID(CFUUIDRef uuid) {
+    __CFSpinLock(&CFUUIDGlobalDataLock);
+    if (_uniquedUUIDs != NULL) {
+        CFDictionaryRemoveValue(_uniquedUUIDs, &(uuid->_bytes));
+    }
+    __CFSpinUnlock(&CFUUIDGlobalDataLock);
+}
+
+static CFUUIDRef __CFUUIDGetUniquedUUID(CFUUIDBytes *bytes) {
+    CFUUIDRef uuid = NULL;
+    __CFSpinLock(&CFUUIDGlobalDataLock);
+    if (_uniquedUUIDs != NULL) {
+        uuid = (CFUUIDRef)CFDictionaryGetValue(_uniquedUUIDs, bytes);
+    }
+    __CFSpinUnlock(&CFUUIDGlobalDataLock);
+    return uuid;
+}
+
+static void __CFUUIDDeallocate(CFTypeRef cf) {    
+    struct __CFUUID *uuid = (struct __CFUUID *)cf;
+    __CFUUIDRemoveUniqueUUID(uuid);
+}
+
+static CFStringRef __CFUUIDCopyDescription(CFTypeRef cf) {
+    CFStringRef uuidStr = CFUUIDCreateString(CFGetAllocator(cf), (CFUUIDRef)cf);
+    CFStringRef desc = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<CFUUID %p> %@"), cf, uuidStr);
+    CFRelease(uuidStr);
+    return desc;
+}
+
+static CFStringRef __CFUUIDCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {
+    return CFUUIDCreateString(CFGetAllocator(cf), (CFUUIDRef)cf);
+}
+
+static CFTypeID __kCFUUIDTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFUUIDClass = {
+    0,
+    "CFUUID",
+    NULL,	// init
+    NULL,	// copy
+    __CFUUIDDeallocate,
+    NULL,	// equal
+    NULL,	// hash
+    __CFUUIDCopyFormattingDescription,
+    __CFUUIDCopyDescription
+};
+
+__private_extern__ void __CFUUIDInitialize(void) {
+    __kCFUUIDTypeID = _CFRuntimeRegisterClass(&__CFUUIDClass);
+}
+
+CFTypeID CFUUIDGetTypeID(void) {
+    return __kCFUUIDTypeID;
+}
+
+static CFUUIDRef __CFUUIDCreateWithBytesPrimitive(CFAllocatorRef allocator, CFUUIDBytes bytes, Boolean isConst) {
+    struct __CFUUID *uuid = (struct __CFUUID *)__CFUUIDGetUniquedUUID(&bytes);
+
+    if (uuid == NULL) {
+        size_t size;
+        size = sizeof(struct __CFUUID) - sizeof(CFRuntimeBase);
+        uuid = (struct __CFUUID *)_CFRuntimeCreateInstance(allocator, __kCFUUIDTypeID, (CFIndex)size, NULL);
+
+        if (NULL == uuid) return NULL;
+
+        uuid->_bytes = bytes;
+
+        __CFUUIDAddUniqueUUID(uuid);
+    } else if (!isConst) {
+        CFRetain(uuid);
+    }
+    
+    return (CFUUIDRef)uuid;
+}
+
+CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc) {
+    /* Create a new bytes struct and then call the primitive. */
+    CFUUIDBytes bytes;
+    uint32_t retval = 0;
+
+#if DEPLOYMENT_TARGET_ANDROID
+    retval = 1;
+#else
+    __CFSpinLock(&CFUUIDGlobalDataLock);
+    static Boolean useV1UUIDs = false, checked = false;
+    if (!checked) {
+        const char *value = getenv("CFUUIDVersionNumber");
+        if (value) {
+            if (1 == strtoul_l(value, NULL, 0, NULL)) useV1UUIDs = true;
+        } else {
+            if (!_CFExecutableLinkedOnOrAfter(CFSystemVersionTiger)) useV1UUIDs = true;
+        }
+        checked = true;
+    }
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    uuid_t uuid;
+    if (useV1UUIDs) uuid_generate_time(uuid); else uuid_generate_random(uuid);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    UUID uuidData;
+    UUID* uuid = &uuidData;
+    if (useV1UUIDs) UuidCreateSequential(uuid); else UuidCreate(uuid);
+#else
+    #error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+    memcpy(&bytes, (const void*)uuid, sizeof(uuid));
+    __CFSpinUnlock(&CFUUIDGlobalDataLock);
+#endif
+
+    return (retval == 0) ? __CFUUIDCreateWithBytesPrimitive(alloc, bytes, false) : NULL;
+}
+
+CFUUIDRef CFUUIDCreateWithBytes(CFAllocatorRef alloc, uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4, uint8_t byte5, uint8_t byte6, uint8_t byte7, uint8_t byte8, uint8_t byte9, uint8_t byte10, uint8_t byte11, uint8_t byte12, uint8_t byte13, uint8_t byte14, uint8_t byte15) {
+    CFUUIDBytes bytes;
+    // CodeWarrior can't handle the structure assignment of bytes, so we must explode this - REW, 10/8/99
+    bytes.byte0 = byte0;
+    bytes.byte1 = byte1;
+    bytes.byte2 = byte2;
+    bytes.byte3 = byte3;
+    bytes.byte4 = byte4;
+    bytes.byte5 = byte5;
+    bytes.byte6 = byte6;
+    bytes.byte7 = byte7;
+    bytes.byte8 = byte8;
+    bytes.byte9 = byte9;
+    bytes.byte10 = byte10;
+    bytes.byte11 = byte11;
+    bytes.byte12 = byte12;
+    bytes.byte13 = byte13;
+    bytes.byte14 = byte14;
+    bytes.byte15 = byte15;
+
+    return __CFUUIDCreateWithBytesPrimitive(alloc, bytes, false);
+}
+
+static void _intToHexChars(UInt32 in, UniChar *out, int digits) {
+    int shift;
+    UInt32 d;
+
+    while (--digits >= 0) {
+        shift = digits << 2;
+        d = 0x0FL & (in >> shift);
+        if (d <= 9) {
+            *out++ = (UniChar)'0' + d;
+        } else {
+            *out++ = (UniChar)'A' + (d - 10);
+        }
+    }
+}
+
+static uint8_t _byteFromHexChars(UniChar *in) {
+    uint8_t result = 0;
+    UniChar c;
+    uint8_t d;
+    CFIndex i;
+
+    for (i=0; i<2; i++) {
+        c = in[i];
+        if ((c >= (UniChar)'0') && (c <= (UniChar)'9')) {
+            d = c - (UniChar)'0';
+        } else if ((c >= (UniChar)'a') && (c <= (UniChar)'f')) {
+            d = c - ((UniChar)'a' - 10);
+        } else if ((c >= (UniChar)'A') && (c <= (UniChar)'F')) {
+            d = c - ((UniChar)'A' - 10);
+        } else {
+            return 0;
+        }
+        result = (result << 4) | d;
+    }
+    
+    return result;
+}
+
+CF_INLINE Boolean _isHexChar(UniChar c) {
+    return ((((c >= (UniChar)'0') && (c <= (UniChar)'9')) || ((c >= (UniChar)'a') && (c <= (UniChar)'f')) || ((c >= (UniChar)'A') && (c <= (UniChar)'F'))) ? true : false);
+}
+
+#define READ_A_BYTE(into) if (i+1 < len) { \
+    (into) = _byteFromHexChars(&(chars[i])); \
+        i+=2; \
+}
+
+CFUUIDRef CFUUIDCreateFromString(CFAllocatorRef alloc, CFStringRef uuidStr) {
+    /* Parse the string into a bytes struct and then call the primitive. */
+    CFUUIDBytes bytes;
+    UniChar chars[100];
+    CFIndex len;
+    CFIndex i = 0;
+    
+    if (uuidStr == NULL) return NULL;
+
+    len = CFStringGetLength(uuidStr);
+    if (len > 100) {
+        len = 100;
+    } else if (len == 0) {
+        return NULL;
+    }
+    CFStringGetCharacters(uuidStr, CFRangeMake(0, len), chars);
+    memset((void *)&bytes, 0, sizeof(bytes));
+
+    /* Skip initial random stuff */
+    while (!_isHexChar(chars[i]) && (i < len)) {
+        i++;
+    }
+
+    READ_A_BYTE(bytes.byte0);
+    READ_A_BYTE(bytes.byte1);
+    READ_A_BYTE(bytes.byte2);
+    READ_A_BYTE(bytes.byte3);
+
+    i++;
+
+    READ_A_BYTE(bytes.byte4);
+    READ_A_BYTE(bytes.byte5);
+
+    i++;
+
+    READ_A_BYTE(bytes.byte6);
+    READ_A_BYTE(bytes.byte7);
+
+    i++;
+
+    READ_A_BYTE(bytes.byte8);
+    READ_A_BYTE(bytes.byte9);
+
+    i++;
+
+    READ_A_BYTE(bytes.byte10);
+    READ_A_BYTE(bytes.byte11);
+    READ_A_BYTE(bytes.byte12);
+    READ_A_BYTE(bytes.byte13);
+    READ_A_BYTE(bytes.byte14);
+    READ_A_BYTE(bytes.byte15);
+
+    return __CFUUIDCreateWithBytesPrimitive(alloc, bytes, false);
+}
+
+CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid) {
+    CFMutableStringRef str = CFStringCreateMutable(alloc, 0);
+    UniChar buff[12];
+
+    // First segment (4 bytes, 8 digits + 1 dash)
+    _intToHexChars(uuid->_bytes.byte0, buff, 2);
+    _intToHexChars(uuid->_bytes.byte1, &(buff[2]), 2);
+    _intToHexChars(uuid->_bytes.byte2, &(buff[4]), 2);
+    _intToHexChars(uuid->_bytes.byte3, &(buff[6]), 2);
+    buff[8] = (UniChar)'-';
+    CFStringAppendCharacters(str, buff, 9);
+
+    // Second segment (2 bytes, 4 digits + 1 dash)
+    _intToHexChars(uuid->_bytes.byte4, buff, 2);
+    _intToHexChars(uuid->_bytes.byte5, &(buff[2]), 2);
+    buff[4] = (UniChar)'-';
+    CFStringAppendCharacters(str, buff, 5);
+
+    // Third segment (2 bytes, 4 digits + 1 dash)
+    _intToHexChars(uuid->_bytes.byte6, buff, 2);
+    _intToHexChars(uuid->_bytes.byte7, &(buff[2]), 2);
+    buff[4] = (UniChar)'-';
+    CFStringAppendCharacters(str, buff, 5);
+
+    // Fourth segment (2 bytes, 4 digits + 1 dash)
+    _intToHexChars(uuid->_bytes.byte8, buff, 2);
+    _intToHexChars(uuid->_bytes.byte9, &(buff[2]), 2);
+    buff[4] = (UniChar)'-';
+    CFStringAppendCharacters(str, buff, 5);
+
+    // Fifth segment (6 bytes, 12 digits)
+    _intToHexChars(uuid->_bytes.byte10, buff, 2);
+    _intToHexChars(uuid->_bytes.byte11, &(buff[2]), 2);
+    _intToHexChars(uuid->_bytes.byte12, &(buff[4]), 2);
+    _intToHexChars(uuid->_bytes.byte13, &(buff[6]), 2);
+    _intToHexChars(uuid->_bytes.byte14, &(buff[8]), 2);
+    _intToHexChars(uuid->_bytes.byte15, &(buff[10]), 2);
+    CFStringAppendCharacters(str, buff, 12);
+
+    return str;
+}
+
+CFUUIDRef CFUUIDGetConstantUUIDWithBytes(CFAllocatorRef alloc, uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4, uint8_t byte5, uint8_t byte6, uint8_t byte7, uint8_t byte8, uint8_t byte9, uint8_t byte10, uint8_t byte11, uint8_t byte12, uint8_t byte13, uint8_t byte14, uint8_t byte15) {
+    CFUUIDBytes bytes;
+    // CodeWarrior can't handle the structure assignment of bytes, so we must explode this - REW, 10/8/99
+    bytes.byte0 = byte0;
+    bytes.byte1 = byte1;
+    bytes.byte2 = byte2;
+    bytes.byte3 = byte3;
+    bytes.byte4 = byte4;
+    bytes.byte5 = byte5;
+    bytes.byte6 = byte6;
+    bytes.byte7 = byte7;
+    bytes.byte8 = byte8;
+    bytes.byte9 = byte9;
+    bytes.byte10 = byte10;
+    bytes.byte11 = byte11;
+    bytes.byte12 = byte12;
+    bytes.byte13 = byte13;
+    bytes.byte14 = byte14;
+    bytes.byte15 = byte15;
+
+    return __CFUUIDCreateWithBytesPrimitive(alloc, bytes, true);
+}
+
+CFUUIDBytes CFUUIDGetUUIDBytes(CFUUIDRef uuid) {
+    return uuid->_bytes;
+}
+
+CF_EXPORT CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes) {
+    return __CFUUIDCreateWithBytesPrimitive(alloc, bytes, false);
+}
+
+#undef READ_A_BYTE
+
diff --git a/CoreFoundation/CFUUID.h b/CoreFoundation/CFUUID.h
new file mode 100644
index 0000000..22450c3
--- /dev/null
+++ b/CoreFoundation/CFUUID.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFUUID__)
+#define __COREFOUNDATION_CFUUID__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFString.h>
+
+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
+
+#endif /* ! __COREFOUNDATION_CFUUID__ */
+
diff --git a/CoreFoundation/CFUniChar.c b/CoreFoundation/CFUniChar.c
new file mode 100644
index 0000000..00b91e4
--- /dev/null
+++ b/CoreFoundation/CFUniChar.c
@@ -0,0 +1,1271 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 2001-2002, Apple, Inc. All rights reserved.
+	Responsibility: Aki Inoue
+*/
+
+#include <CoreFoundation/CFByteOrder.h>
+#include "CFInternal.h"
+#include "CFBundle_Internal.h"
+#include "CFUniChar.h" 
+#include "CFStringEncodingConverterExt.h"
+#include "CFUnicodeDecomposition.h"
+#include "CFUniCharPriv.h"
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <stdlib.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <windows.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <io.h>
+#include <stdlib.h>
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+extern size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach/mach.h>
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+#define __kCFCharacterSetDir "/System/Library/CoreServices"
+#elif DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+#define __kCFCharacterSetDir __kCFDataDir "/CoreFoundation"
+#elif DEPLOYMENT_TARGET_WINDOWS
+#define __kCFCharacterSetDir "\\Windows\\CoreFoundation"
+#define MAXPATHLEN MAX_PATH
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+#define USE_MACHO_SEGMENT 1
+#endif //__MACH__
+
+enum {
+    kCFUniCharLastExternalSet = kCFUniCharNewlineCharacterSet,
+    kCFUniCharFirstInternalSet = kCFUniCharCompatibilityDecomposableCharacterSet,
+    kCFUniCharLastInternalSet = kCFUniCharGraphemeExtendCharacterSet,
+    kCFUniCharFirstBitmapSet = kCFUniCharDecimalDigitCharacterSet
+};
+
+CF_INLINE uint32_t __CFUniCharMapExternalSetToInternalIndex(uint32_t cset) { return ((kCFUniCharFirstInternalSet <= cset) ? ((cset - kCFUniCharFirstInternalSet) + kCFUniCharLastExternalSet) : cset) - kCFUniCharFirstBitmapSet; }
+CF_INLINE uint32_t __CFUniCharMapCompatibilitySetID(uint32_t cset) { return ((cset == kCFUniCharControlCharacterSet) ? kCFUniCharControlAndFormatterCharacterSet : (((cset > kCFUniCharLastExternalSet) && (cset < kCFUniCharFirstInternalSet)) ? ((cset - kCFUniCharLastExternalSet) + kCFUniCharFirstInternalSet) : cset)); }
+
+#if (DEPLOYMENT_TARGET_MACOSX) && USE_MACHO_SEGMENT
+
+#include <mach-o/getsect.h>
+#include <mach-o/dyld.h>
+#include <mach-o/ldsyms.h>
+
+static const void *__CFGetSectDataPtr(const char *segname, const char *sectname, uint64_t *sizep) {
+    uint32_t idx, cnt = _dyld_image_count();
+    for (idx = 0; idx < cnt; idx++) {
+       void *mh = (void *)_dyld_get_image_header(idx);
+       if (mh != &_mh_dylib_header) continue;
+#if __LP64__
+       const struct section_64 *sect = getsectbynamefromheader_64((struct mach_header_64 *)mh, segname, sectname);
+#else
+       const struct section *sect = getsectbynamefromheader((struct mach_header *)mh, segname, sectname);
+#endif
+       if (!sect) break;
+       if (sizep) *sizep = (uint64_t)sect->size;
+       return (char *)sect->addr + _dyld_get_image_vmaddr_slide(idx);
+    }
+    if (sizep) *sizep = 0ULL;
+    return NULL;
+}
+
+#endif
+
+#if !USE_MACHO_SEGMENT
+
+#if DEPLOYMENT_TARGET_WINDOWS
+extern const char* _CFDLLPath(void);
+#endif
+
+
+// Memory map the file
+
+CF_INLINE void __CFUniCharCharacterSetPath(char *cpath) {
+#if DEPLOYMENT_TARGET_MACOSX
+    strlcpy(cpath, __kCFCharacterSetDir, MAXPATHLEN);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    strlcpy(cpath, _CFDLLPath(), MAXPATHLEN);
+#else
+    strlcpy(cpath, __kCFCharacterSetDir, MAXPATHLEN);
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+#if 0
+    strncat(cpath, "\\Resources\\", MAXPATHLEN - strlen(cpath));
+#else
+    strncat(cpath, "\\CoreFoundation.resources\\CharacterSets\\", MAXPATHLEN - strlen(cpath));
+#endif
+#else
+    strlcat(cpath, "/CharacterSets/", MAXPATHLEN);
+#endif
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS
+#define MAX_BITMAP_STATE 512
+//
+//  If a string is placed into this array, then it has been previously 
+//  determined that the bitmap-file cannot be found.  Thus, we make
+//  the assumption it won't be there in future calls and we avoid
+//  hitting the disk un-necessarily.  This assumption isn't 100%
+//  correct, as bitmap-files can be added.  We would have to re-start
+//  the application in order to pick-up the new bitmap info.  
+//
+//  We should probably re-visit this.
+//
+static char *mappedBitmapState[MAX_BITMAP_STATE];
+static int __nNumStateEntries = -1;
+CRITICAL_SECTION __bitmapStateLock = {0};
+
+bool __GetBitmapStateForName(char *bitmapName) {
+    if (NULL == __bitmapStateLock.DebugInfo)
+        InitializeCriticalSection(&__bitmapStateLock);
+    EnterCriticalSection(&__bitmapStateLock);
+    if (__nNumStateEntries >= 0) {
+        for (int i = 0; i < __nNumStateEntries; i++) {
+            if (strcmp(mappedBitmapState[i], bitmapName) == 0) {
+                LeaveCriticalSection(&__bitmapStateLock);
+                return true;
+            }
+        }
+    }
+    LeaveCriticalSection(&__bitmapStateLock);
+    return false;
+}
+void __AddBitmapStateForName(char *bitmapName) {
+    if (NULL == __bitmapStateLock.DebugInfo)
+        InitializeCriticalSection(&__bitmapStateLock);
+    EnterCriticalSection(&__bitmapStateLock);
+    __nNumStateEntries++;
+    mappedBitmapState[__nNumStateEntries] = (char *)malloc((strlen(bitmapName)+1) * sizeof(char));
+    strcpy(mappedBitmapState[__nNumStateEntries], bitmapName);
+    LeaveCriticalSection(&__bitmapStateLock);
+}
+#endif // DEPLOYMENT_TARGET_WINDOWS
+
+static bool __CFUniCharLoadBytesFromFile(const char *fileName, const void **bytes) {
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+    HANDLE bitmapFileHandle = NULL;
+    HANDLE mappingHandle = NULL;
+    
+    if (__GetBitmapStateForName((char *)fileName)) {
+        // The fileName has been tried in the past, so just return false
+        // and move on.
+        *bytes = NULL;
+        return false;
+    }
+    mappingHandle = OpenFileMappingA(FILE_MAP_READ, TRUE, fileName);
+    if (NULL == mappingHandle) {
+        if ((bitmapFileHandle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) {
+            // We tried to get the bitmap file for mapping, but it's not there.  Add to list of non-existant bitmap-files so
+            // we don't have to try this again in the future.
+            __AddBitmapStateForName((char *)fileName);
+            return false;
+        }
+        mappingHandle = CreateFileMappingA(bitmapFileHandle, NULL, PAGE_READONLY, 0, 0, NULL);
+        CloseHandle(bitmapFileHandle);
+        if (!mappingHandle) return false;
+
+        *bytes = MapViewOfFileEx(mappingHandle, FILE_MAP_READ, 0, 0, 0, 0);
+        CloseHandle(mappingHandle);
+    } else {
+        *bytes = MapViewOfFileEx(mappingHandle, FILE_MAP_READ, 0, 0, 0, 0);
+        CloseHandle(mappingHandle);
+    }
+
+    return (*bytes ? true : false);
+#else
+    struct stat statBuf;
+    int fd = -1;
+
+    int no_hang_fd = open("/dev/autofs_nowait", 0);
+    if ((fd = open(fileName, O_RDONLY, 0)) < 0) {
+    CFLog(__kCFLogAssertion, CFSTR("%s(): could not open %s for read-only access."), __PRETTY_FUNCTION__, fileName);
+	close(no_hang_fd);
+	return false;
+    }
+    if (fstat(fd, &statBuf) < 0 || (*bytes = mmap(0, statBuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) == (void *)-1) {
+        CFLog(__kCFLogAssertion, CFSTR("%s(): could not map %s for read-only access."), __PRETTY_FUNCTION__, fileName);
+        close(fd);
+        return false;
+    }
+    close(fd);
+    close(no_hang_fd);
+
+    return true;
+#endif
+}
+
+#endif // USE_MACHO_SEGMENT
+
+static bool __CFUniCharLoadFile(const char *bitmapName, const void **bytes) {
+#if USE_MACHO_SEGMENT
+	*bytes = __CFGetSectDataPtr("__UNICODE", bitmapName, NULL);
+    return *bytes ? true : false;
+#else
+    char cpath[MAXPATHLEN];
+    __CFUniCharCharacterSetPath(cpath);
+	strlcat(cpath, bitmapName, MAXPATHLEN);
+    return __CFUniCharLoadBytesFromFile(cpath, bytes);
+#endif
+}
+
+// Bitmap functions
+CF_INLINE bool isControl(UTF32Char theChar, uint16_t charset, const void *data) { // ISO Control
+    return (((theChar <= 0x001F) || (theChar >= 0x007F && theChar <= 0x009F)) ? true : false);
+}
+
+CF_INLINE bool isWhitespace(UTF32Char theChar, uint16_t charset, const void *data) { // Space
+    return (((theChar == 0x0020) || (theChar == 0x0009) || (theChar == 0x00A0) || (theChar == 0x1680) || (theChar >= 0x2000 && theChar <= 0x200B) || (theChar == 0x202F) || (theChar == 0x205F) || (theChar == 0x3000)) ? true : false);
+}
+
+CF_INLINE bool isNewline(UTF32Char theChar, uint16_t charset, const void *data) { // White space
+    return (((theChar >= 0x000A && theChar <= 0x000D) || (theChar == 0x0085) || (theChar == 0x2028) || (theChar == 0x2029)) ? true : false);
+}
+
+CF_INLINE bool isWhitespaceAndNewline(UTF32Char theChar, uint16_t charset, const void *data) { // White space
+    return ((isWhitespace(theChar, charset, data) || isNewline(theChar, charset, data)) ? true : false);
+}
+
+typedef struct {
+    uint32_t _numPlanes;
+    const uint8_t **_planes;
+} __CFUniCharBitmapData;
+
+static char __CFUniCharUnicodeVersionString[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+
+static uint32_t __CFUniCharNumberOfBitmaps = 0;
+static __CFUniCharBitmapData *__CFUniCharBitmapDataArray = NULL;
+
+static CFSpinLock_t __CFUniCharBitmapLock = CFSpinLockInit;
+
+#if !defined(CF_UNICHAR_BITMAP_FILE)
+#if USE_MACHO_SEGMENT
+#define CF_UNICHAR_BITMAP_FILE "__csbitmaps"
+#else
+#define CF_UNICHAR_BITMAP_FILE "CFCharacterSetBitmaps.bitmap"
+#endif
+#endif
+
+static bool __CFUniCharLoadBitmapData(void) {
+    __CFUniCharBitmapData *array;
+    uint32_t headerSize;
+    uint32_t bitmapSize;
+    int numPlanes;
+    uint8_t currentPlane;
+    const void *bytes;
+    const void *bitmapBase;
+    const void *bitmap;
+    int idx, bitmapIndex;
+
+    __CFSpinLock(&__CFUniCharBitmapLock);
+
+    if (__CFUniCharBitmapDataArray || !__CFUniCharLoadFile(CF_UNICHAR_BITMAP_FILE, &bytes)) {
+        __CFSpinUnlock(&__CFUniCharBitmapLock);
+        return false;
+    }
+
+    for (idx = 0;idx < 4 && ((const uint8_t *)bytes)[idx];idx++) {
+        __CFUniCharUnicodeVersionString[idx * 2] = ((const uint8_t *)bytes)[idx];
+        __CFUniCharUnicodeVersionString[idx * 2 + 1] = '.';
+    }
+    __CFUniCharUnicodeVersionString[(idx < 4 ? idx * 2 - 1 : 7)] = '\0';
+
+    headerSize = CFSwapInt32BigToHost(*((uint32_t *)((char *)bytes + 4)));
+
+    bitmapBase = (uint8_t *)bytes + headerSize;
+    bytes = (uint8_t *)bytes + (sizeof(uint32_t) * 2);
+    headerSize -= (sizeof(uint32_t) * 2);
+
+    __CFUniCharNumberOfBitmaps = headerSize / (sizeof(uint32_t) * 2);
+
+    array = (__CFUniCharBitmapData *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(__CFUniCharBitmapData) * __CFUniCharNumberOfBitmaps, 0);
+
+    for (idx = 0;idx < (int)__CFUniCharNumberOfBitmaps;idx++) {
+        bitmap = (uint8_t *)bitmapBase + CFSwapInt32BigToHost(*((uint32_t *)bytes)); bytes = (uint8_t *)bytes + sizeof(uint32_t);
+        bitmapSize = CFSwapInt32BigToHost(*((uint32_t *)bytes)); bytes = (uint8_t *)bytes + sizeof(uint32_t);
+
+        numPlanes = bitmapSize / (8 * 1024);
+        numPlanes = *(const uint8_t *)((char *)bitmap + (((numPlanes - 1) * ((8 * 1024) + 1)) - 1)) + 1;
+        array[idx]._planes = (const uint8_t **)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(const void *) * numPlanes, 0);
+        array[idx]._numPlanes = numPlanes;
+
+        currentPlane = 0;
+        for (bitmapIndex = 0;bitmapIndex < numPlanes;bitmapIndex++) {
+            if (bitmapIndex == currentPlane) {
+                array[idx]._planes[bitmapIndex] = (const uint8_t *)bitmap;
+                bitmap = (uint8_t *)bitmap + (8 * 1024);
+#if defined (__cplusplus)				
+				currentPlane = *(((const uint8_t*&)bitmap)++);
+#else
+				currentPlane = *((const uint8_t *)bitmap++);
+#endif //C++
+
+            } else {
+                array[idx]._planes[bitmapIndex] = NULL;
+            }
+        }
+    }
+
+    __CFUniCharBitmapDataArray = array;
+
+    __CFSpinUnlock(&__CFUniCharBitmapLock);
+
+    return true;
+}
+
+__private_extern__ const char *__CFUniCharGetUnicodeVersionString(void) {
+    if (NULL == __CFUniCharBitmapDataArray) __CFUniCharLoadBitmapData();
+    return __CFUniCharUnicodeVersionString;
+}
+
+bool CFUniCharIsMemberOf(UTF32Char theChar, uint32_t charset) {
+    charset = __CFUniCharMapCompatibilitySetID(charset);
+
+    switch (charset) {
+        case kCFUniCharWhitespaceCharacterSet:
+            return isWhitespace(theChar, charset, NULL);
+
+        case kCFUniCharWhitespaceAndNewlineCharacterSet:
+            return isWhitespaceAndNewline(theChar, charset, NULL);
+
+        case kCFUniCharNewlineCharacterSet:
+            return isNewline(theChar, charset, NULL);
+
+        default: {
+            uint32_t tableIndex = __CFUniCharMapExternalSetToInternalIndex(charset);
+
+            if (NULL == __CFUniCharBitmapDataArray) __CFUniCharLoadBitmapData();
+
+            if (tableIndex < __CFUniCharNumberOfBitmaps) {
+                __CFUniCharBitmapData *data = __CFUniCharBitmapDataArray + tableIndex;
+                uint8_t planeNo = (theChar >> 16) & 0xFF;
+
+                // The bitmap data for kCFUniCharIllegalCharacterSet is actually LEGAL set less Plane 14 ~ 16
+                if (charset == kCFUniCharIllegalCharacterSet) {
+                    if (planeNo == 0x0E) { // Plane 14
+                        theChar &= 0xFF;
+                        return (((theChar == 0x01) || ((theChar > 0x1F) && (theChar < 0x80))) ? false : true);
+                    } else if (planeNo == 0x0F || planeNo == 0x10) { // Plane 15 & 16
+                        return ((theChar & 0xFF) > 0xFFFD ? true : false);
+                    } else {
+                        return (planeNo < data->_numPlanes && data->_planes[planeNo] ? !CFUniCharIsMemberOfBitmap(theChar, data->_planes[planeNo]) : true);
+                    }
+                } else if (charset == kCFUniCharControlAndFormatterCharacterSet) {
+                    if (planeNo == 0x0E) { // Plane 14
+                        theChar &= 0xFF;
+                        return (((theChar == 0x01) || ((theChar > 0x1F) && (theChar < 0x80))) ? true : false);
+                    } else {
+                        return (planeNo < data->_numPlanes && data->_planes[planeNo] ? CFUniCharIsMemberOfBitmap(theChar, data->_planes[planeNo]) : false);
+                    }
+                } else {
+                    return (planeNo < data->_numPlanes && data->_planes[planeNo] ? CFUniCharIsMemberOfBitmap(theChar, data->_planes[planeNo]) : false);
+                }
+            }
+            return false;
+        }
+    }
+}
+
+const uint8_t *CFUniCharGetBitmapPtrForPlane(uint32_t charset, uint32_t plane) {
+    if (NULL == __CFUniCharBitmapDataArray) __CFUniCharLoadBitmapData();
+
+    charset = __CFUniCharMapCompatibilitySetID(charset);
+
+    if ((charset > kCFUniCharWhitespaceAndNewlineCharacterSet) && (charset != kCFUniCharIllegalCharacterSet) && (charset != kCFUniCharNewlineCharacterSet)) {
+        uint32_t tableIndex = __CFUniCharMapExternalSetToInternalIndex(charset);
+
+        if (tableIndex < __CFUniCharNumberOfBitmaps) {
+            __CFUniCharBitmapData *data = __CFUniCharBitmapDataArray + tableIndex;
+
+            return (plane < data->_numPlanes ? data->_planes[plane] : NULL);
+        }
+    }
+    return NULL;
+}
+
+__private_extern__ uint8_t CFUniCharGetBitmapForPlane(uint32_t charset, uint32_t plane, void *bitmap, bool isInverted) {
+    const uint8_t *src = CFUniCharGetBitmapPtrForPlane(charset, plane);
+    int numBytes = (8 * 1024);
+
+    if (src) {
+        if (isInverted) {
+#if defined (__cplusplus)
+			while (numBytes-- > 0) *(((uint8_t *&)bitmap)++) = ~(*(src++));
+#else
+			while (numBytes-- > 0) *((uint8_t *)bitmap++) = ~(*(src++));
+#endif //C++
+        } else {
+#if defined (__cplusplus)
+            while (numBytes-- > 0) *(((uint8_t *&)bitmap)++) = *(src++);
+#else
+			while (numBytes-- > 0) *((uint8_t *)bitmap++) = *(src++);
+#endif //C++
+        }
+        return kCFUniCharBitmapFilled;
+    } else if (charset == kCFUniCharIllegalCharacterSet) {
+        __CFUniCharBitmapData *data = __CFUniCharBitmapDataArray + __CFUniCharMapExternalSetToInternalIndex(__CFUniCharMapCompatibilitySetID(charset));
+
+        if (plane < data->_numPlanes && (src = data->_planes[plane])) {
+            if (isInverted) {
+#if defined (__cplusplus)                
+				while (numBytes-- > 0) *(((uint8_t *&)bitmap)++) = *(src++);
+#else
+				while (numBytes-- > 0) *((uint8_t *)bitmap++) = *(src++);
+#endif //C++
+            } else {
+#if defined (__cplusplus)                
+                while (numBytes-- > 0) *(((uint8_t *&)bitmap)++) = ~(*(src++));
+#else
+				while (numBytes-- > 0) *((uint8_t *)bitmap++) = ~(*(src++));
+#endif //C++
+            }
+            return kCFUniCharBitmapFilled;
+        } else if (plane == 0x0E) { // Plane 14
+            int idx;
+            uint8_t asciiRange = (isInverted ? (uint8_t)0xFF : (uint8_t)0);
+            uint8_t otherRange = (isInverted ? (uint8_t)0 : (uint8_t)0xFF);
+
+#if defined (__cplusplus)
+			*(((uint8_t *&)bitmap)++) = 0x02; // UE0001 LANGUAGE TAG
+#else
+			*((uint8_t *)bitmap++) = 0x02; // UE0001 LANGUAGE TAG
+#endif //C++
+            for (idx = 1;idx < numBytes;idx++) {
+#if defined (__cplusplus)                
+				*(((uint8_t *&)bitmap)++) = ((idx >= (0x20 / 8) && (idx < (0x80 / 8))) ? asciiRange : otherRange);
+#else
+				*((uint8_t *)bitmap++) = ((idx >= (0x20 / 8) && (idx < (0x80 / 8))) ? asciiRange : otherRange);
+#endif //C++
+            }
+            return kCFUniCharBitmapFilled;
+        } else if (plane == 0x0F || plane == 0x10) { // Plane 15 & 16
+            uint32_t value = (isInverted ? ~0 : 0);
+            numBytes /= 4; // for 32bit
+
+            while (numBytes-- > 0) {
+                *((uint32_t *)bitmap) = value;
+#if defined (__cplusplus)                
+				bitmap = (uint8_t *)bitmap + sizeof(uint32_t);				
+#else
+				bitmap += sizeof(uint32_t);
+#endif //C++
+            }
+            *(((uint8_t *)bitmap) - 5) = (isInverted ? 0x3F : 0xC0); // 0xFFFE & 0xFFFF
+            return kCFUniCharBitmapFilled;
+        }
+        return (isInverted ? kCFUniCharBitmapEmpty : kCFUniCharBitmapAll);
+    } else if ((charset < kCFUniCharDecimalDigitCharacterSet) || (charset == kCFUniCharNewlineCharacterSet)) {
+        if (plane) return (isInverted ? kCFUniCharBitmapAll : kCFUniCharBitmapEmpty);
+
+        uint8_t *bitmapBase = (uint8_t *)bitmap;
+        CFIndex idx;
+        uint8_t nonFillValue = (isInverted ? (uint8_t)0xFF : (uint8_t)0);
+
+#if defined (__cplusplus)
+                    while (numBytes-- > 0) *(((uint8_t *&)bitmap)++) = nonFillValue;
+#else
+                    while (numBytes-- > 0) *((uint8_t *)bitmap++) = nonFillValue;
+#endif //C++
+
+        if ((charset == kCFUniCharWhitespaceAndNewlineCharacterSet) || (charset == kCFUniCharNewlineCharacterSet)) {
+            const UniChar newlines[] = {0x000A, 0x000B, 0x000C, 0x000D, 0x0085, 0x2028, 0x2029};
+
+            for (idx = 0;idx < (int)(sizeof(newlines) / sizeof(*newlines)); idx++) {
+                if (isInverted) {
+                    CFUniCharRemoveCharacterFromBitmap(newlines[idx], bitmapBase);
+                } else {
+                    CFUniCharAddCharacterToBitmap(newlines[idx], bitmapBase);
+                }
+            }
+
+            if (charset == kCFUniCharNewlineCharacterSet) return kCFUniCharBitmapFilled;
+        }
+
+        if (isInverted) {
+            CFUniCharRemoveCharacterFromBitmap(0x0009, bitmapBase);
+            CFUniCharRemoveCharacterFromBitmap(0x0020, bitmapBase);
+            CFUniCharRemoveCharacterFromBitmap(0x00A0, bitmapBase);
+            CFUniCharRemoveCharacterFromBitmap(0x1680, bitmapBase);
+            CFUniCharRemoveCharacterFromBitmap(0x202F, bitmapBase);
+            CFUniCharRemoveCharacterFromBitmap(0x205F, bitmapBase);
+            CFUniCharRemoveCharacterFromBitmap(0x3000, bitmapBase);
+        } else {
+            CFUniCharAddCharacterToBitmap(0x0009, bitmapBase);
+            CFUniCharAddCharacterToBitmap(0x0020, bitmapBase);
+            CFUniCharAddCharacterToBitmap(0x00A0, bitmapBase);
+            CFUniCharAddCharacterToBitmap(0x1680, bitmapBase);
+            CFUniCharAddCharacterToBitmap(0x202F, bitmapBase);
+            CFUniCharAddCharacterToBitmap(0x205F, bitmapBase);
+            CFUniCharAddCharacterToBitmap(0x3000, bitmapBase);
+        }
+
+        for (idx = 0x2000;idx <= 0x200B;idx++) {
+            if (isInverted) {
+                CFUniCharRemoveCharacterFromBitmap(idx, bitmapBase);
+            } else {
+                CFUniCharAddCharacterToBitmap(idx, bitmapBase);
+            }
+        }
+        return kCFUniCharBitmapFilled;
+    }
+    return (isInverted ? kCFUniCharBitmapAll : kCFUniCharBitmapEmpty);
+}
+
+__private_extern__ uint32_t CFUniCharGetNumberOfPlanes(uint32_t charset) {
+    if ((charset == kCFUniCharControlCharacterSet) || (charset == kCFUniCharControlAndFormatterCharacterSet)) {
+        return 15; // 0 to 14
+    } else if (charset < kCFUniCharDecimalDigitCharacterSet) {
+        return 1;
+    } else if (charset == kCFUniCharIllegalCharacterSet) {
+        return 17;
+    } else {
+        uint32_t numPlanes;
+
+        if (NULL == __CFUniCharBitmapDataArray) __CFUniCharLoadBitmapData();
+
+        numPlanes = __CFUniCharBitmapDataArray[__CFUniCharMapExternalSetToInternalIndex(__CFUniCharMapCompatibilitySetID(charset))]._numPlanes;
+
+        return numPlanes;
+    }
+}
+
+// Mapping data loading
+static const void **__CFUniCharMappingTables = NULL;
+
+static CFSpinLock_t __CFUniCharMappingTableLock = CFSpinLockInit;
+
+#if USE_MACHO_SEGMENT
+#define MAPPING_TABLE_FILE "__data"
+#else
+#define MAPPING_TABLE_FILE "CFUnicodeData.mapping"
+#endif
+
+__private_extern__ const void *CFUniCharGetMappingData(uint32_t type) {
+
+    __CFSpinLock(&__CFUniCharMappingTableLock);
+
+    if (NULL == __CFUniCharMappingTables) {
+        const void *bytes;
+        const void *bodyBase;
+        int headerSize;
+        int idx, count;
+
+        if (!__CFUniCharLoadFile(MAPPING_TABLE_FILE, &bytes)) {
+            __CFSpinUnlock(&__CFUniCharMappingTableLock);
+            return NULL;
+        }
+
+#if defined (__cplusplus)
+		bytes = (uint8_t *)bytes + 4; // Skip Unicode version
+		headerSize = *((uint8_t *)bytes); bytes = (uint8_t *)bytes + sizeof(uint32_t);
+#else
+		bytes += 4; // Skip Unicode version
+		headerSize = *((uint32_t *)bytes); bytes += sizeof(uint32_t);
+#endif //C++        
+        headerSize -= (sizeof(uint32_t) * 2);
+        bodyBase = (char *)bytes + headerSize;
+
+        count = headerSize / sizeof(uint32_t);
+
+        __CFUniCharMappingTables = (const void **)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(const void *) * count, 0);
+
+        for (idx = 0;idx < count;idx++) {
+#if defined (__cplusplus)            
+			__CFUniCharMappingTables[idx] = (char *)bodyBase + *((uint32_t *)bytes); bytes = (uint8_t *)bytes + sizeof(uint32_t);
+#else
+			__CFUniCharMappingTables[idx] = (char *)bodyBase + *((uint32_t *)bytes); bytes += sizeof(uint32_t);
+#endif //C++
+        }
+    }
+
+    __CFSpinUnlock(&__CFUniCharMappingTableLock);
+
+    return __CFUniCharMappingTables[type];
+}
+
+// Case mapping functions
+#define DO_SPECIAL_CASE_MAPPING 1
+
+static uint32_t *__CFUniCharCaseMappingTableCounts = NULL;
+static uint32_t **__CFUniCharCaseMappingTable = NULL;
+static const uint32_t **__CFUniCharCaseMappingExtraTable = NULL;
+
+typedef struct {
+    uint32_t _key;
+    uint32_t _value;
+} __CFUniCharCaseMappings;
+
+/* Binary searches CFStringEncodingUnicodeTo8BitCharMap */
+static uint32_t __CFUniCharGetMappedCase(const __CFUniCharCaseMappings *theTable, uint32_t numElem, UTF32Char character) {
+    const __CFUniCharCaseMappings *p, *q, *divider;
+
+    if ((character < theTable[0]._key) || (character > theTable[numElem-1]._key)) {
+        return 0;
+    }
+    p = theTable;
+    q = p + (numElem-1);
+    while (p <= q) {
+        divider = p + ((q - p) >> 1);	/* divide by 2 */
+        if (character < divider->_key) { q = divider - 1; }
+        else if (character > divider->_key) { p = divider + 1; }
+        else { return divider->_value; }
+    }
+    return 0;
+}
+
+#define NUM_CASE_MAP_DATA (kCFUniCharCaseFold + 1)
+
+static bool __CFUniCharLoadCaseMappingTable(void) {
+    uint32_t *countArray;
+    int idx;
+
+    if (NULL == __CFUniCharMappingTables) (void)CFUniCharGetMappingData(kCFUniCharToLowercase);
+    if (NULL == __CFUniCharMappingTables) return false;
+
+    __CFSpinLock(&__CFUniCharMappingTableLock);
+
+    if (__CFUniCharCaseMappingTableCounts) {
+        __CFSpinUnlock(&__CFUniCharMappingTableLock);
+        return true;
+    }
+
+    countArray = (uint32_t *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(uint32_t) * NUM_CASE_MAP_DATA + sizeof(uint32_t *) * NUM_CASE_MAP_DATA * 2, 0);
+    __CFUniCharCaseMappingTable = (uint32_t **)((char *)countArray + sizeof(uint32_t) * NUM_CASE_MAP_DATA);
+    __CFUniCharCaseMappingExtraTable = (const uint32_t **)__CFUniCharCaseMappingTable + NUM_CASE_MAP_DATA;
+
+    for (idx = 0;idx < NUM_CASE_MAP_DATA;idx++) {
+        countArray[idx] = *((uint32_t *)__CFUniCharMappingTables[idx]) / (sizeof(uint32_t) * 2);
+        __CFUniCharCaseMappingTable[idx] = ((uint32_t *)__CFUniCharMappingTables[idx]) + 1;
+        __CFUniCharCaseMappingExtraTable[idx] = (const uint32_t *)((char *)__CFUniCharCaseMappingTable[idx] + *((uint32_t *)__CFUniCharMappingTables[idx]));
+    }
+
+    __CFUniCharCaseMappingTableCounts = countArray;
+
+    __CFSpinUnlock(&__CFUniCharMappingTableLock);
+    return true;
+}
+
+#if __CF_BIG_ENDIAN__
+#define TURKISH_LANG_CODE	(0x7472) // tr
+#define LITHUANIAN_LANG_CODE	(0x6C74) // lt
+#define AZERI_LANG_CODE		(0x617A) // az
+#else
+#define TURKISH_LANG_CODE	(0x7274) // tr
+#define LITHUANIAN_LANG_CODE	(0x746C) // lt
+#define AZERI_LANG_CODE		(0x7A61) // az
+#endif
+
+CFIndex CFUniCharMapCaseTo(UTF32Char theChar, UTF16Char *convertedChar, CFIndex maxLength, uint32_t ctype, uint32_t flags, const uint8_t *langCode) {
+    __CFUniCharBitmapData *data;
+    uint8_t planeNo = (theChar >> 16) & 0xFF;
+
+caseFoldRetry:
+
+#if DO_SPECIAL_CASE_MAPPING
+    if (flags & kCFUniCharCaseMapFinalSigma) {
+        if (theChar == 0x03A3) { // Final sigma
+            *convertedChar = (ctype == kCFUniCharToLowercase ? 0x03C2 : 0x03A3);
+            return 1;
+        }
+    }
+
+    if (langCode) {
+        switch (*(uint16_t *)langCode) {
+            case LITHUANIAN_LANG_CODE:
+                if (theChar == 0x0307 && (flags & kCFUniCharCaseMapAfter_i)) {
+                    return 0;
+                } else if (ctype == kCFUniCharToLowercase) {
+                    if (flags & kCFUniCharCaseMapMoreAbove) {
+                        switch (theChar) {
+                            case 0x0049: // LATIN CAPITAL LETTER I
+                                *(convertedChar++) = 0x0069;
+                                *(convertedChar++) = 0x0307;
+                                return 2;
+
+                            case 0x004A: // LATIN CAPITAL LETTER J
+                                *(convertedChar++) = 0x006A;
+                                *(convertedChar++) = 0x0307;
+                                return 2;
+
+                            case 0x012E: // LATIN CAPITAL LETTER I WITH OGONEK
+                                *(convertedChar++) = 0x012F;
+                                *(convertedChar++) = 0x0307;
+                                return 2;
+
+                            default: break;
+                        }
+                    }
+                    switch (theChar) {
+                        case 0x00CC: // LATIN CAPITAL LETTER I WITH GRAVE
+                            *(convertedChar++) = 0x0069;
+                            *(convertedChar++) = 0x0307;
+                            *(convertedChar++) = 0x0300;
+                            return 3;
+
+                        case 0x00CD: // LATIN CAPITAL LETTER I WITH ACUTE
+                            *(convertedChar++) = 0x0069;
+                            *(convertedChar++) = 0x0307;
+                            *(convertedChar++) = 0x0301;
+                            return 3;
+
+                        case 0x0128: // LATIN CAPITAL LETTER I WITH TILDE
+                            *(convertedChar++) = 0x0069;
+                            *(convertedChar++) = 0x0307;
+                            *(convertedChar++) = 0x0303;
+                            return 3;
+
+                        default: break;
+                    }
+                }
+            break;
+
+            case TURKISH_LANG_CODE:
+            case AZERI_LANG_CODE:
+                if ((theChar == 0x0049) || (theChar == 0x0131)) { // LATIN CAPITAL LETTER I & LATIN SMALL LETTER DOTLESS I
+                    *convertedChar = (((ctype == kCFUniCharToLowercase) || (ctype == kCFUniCharCaseFold))  ? ((kCFUniCharCaseMapMoreAbove & flags) ? 0x0069 : 0x0131) : 0x0049);
+                    return 1;
+                } else if ((theChar == 0x0069) || (theChar == 0x0130)) { // LATIN SMALL LETTER I & LATIN CAPITAL LETTER I WITH DOT ABOVE
+                    *convertedChar = (((ctype == kCFUniCharToLowercase) || (ctype == kCFUniCharCaseFold)) ? 0x0069 : 0x0130);
+                    return 1;
+                } else if (theChar == 0x0307 && (kCFUniCharCaseMapAfter_i & flags)) { // COMBINING DOT ABOVE AFTER_i
+                    if (ctype == kCFUniCharToLowercase) {
+                        return 0;
+                    } else {
+                        *convertedChar = 0x0307;
+                        return 1;
+                    }
+                }
+                break;
+
+            default: break;
+        }
+    }
+#endif /* DO_SPECIAL_CASE_MAPPING */
+
+    if (NULL == __CFUniCharBitmapDataArray) __CFUniCharLoadBitmapData();
+
+    data = __CFUniCharBitmapDataArray + __CFUniCharMapExternalSetToInternalIndex(__CFUniCharMapCompatibilitySetID(ctype + kCFUniCharHasNonSelfLowercaseCharacterSet));
+
+    if (planeNo < data->_numPlanes && data->_planes[planeNo] && CFUniCharIsMemberOfBitmap(theChar, data->_planes[planeNo]) && (__CFUniCharCaseMappingTableCounts || __CFUniCharLoadCaseMappingTable())) {
+        uint32_t value = __CFUniCharGetMappedCase((const __CFUniCharCaseMappings *)__CFUniCharCaseMappingTable[ctype], __CFUniCharCaseMappingTableCounts[ctype], theChar);
+
+        if (!value && ctype == kCFUniCharToTitlecase) {
+            value = __CFUniCharGetMappedCase((const __CFUniCharCaseMappings *)__CFUniCharCaseMappingTable[kCFUniCharToUppercase], __CFUniCharCaseMappingTableCounts[kCFUniCharToUppercase], theChar);
+            if (value) ctype = kCFUniCharToUppercase;
+        }
+
+        if (value) {
+            CFIndex count = CFUniCharConvertFlagToCount(value);
+
+            if (count == 1) {
+                if (value & kCFUniCharNonBmpFlag) {
+                    if (maxLength > 1) {
+                        value = (value & 0xFFFFFF) - 0x10000;
+                        *(convertedChar++) = (UTF16Char)(value >> 10) + 0xD800UL;
+                        *(convertedChar++) = (UTF16Char)(value & 0x3FF) + 0xDC00UL;
+                        return 2;
+                    }
+                } else {
+                    *convertedChar = (UTF16Char)value;
+                    return 1;
+                }
+            } else if (count < maxLength) {
+                const uint32_t *extraMapping = __CFUniCharCaseMappingExtraTable[ctype] + (value & 0xFFFFFF);
+
+                if (value & kCFUniCharNonBmpFlag) {
+                    CFIndex copiedLen = 0;
+
+                    while (count-- > 0) {
+                        value = *(extraMapping++);
+                        if (value > 0xFFFF) {
+                            if (copiedLen + 2 >= maxLength) break;
+                            value = (value & 0xFFFFFF) - 0x10000;
+                            convertedChar[copiedLen++] = (UTF16Char)(value >> 10) + 0xD800UL;
+                            convertedChar[copiedLen++] = (UTF16Char)(value & 0x3FF) + 0xDC00UL;
+                        } else {
+                            if (copiedLen + 1 >= maxLength) break;
+                            convertedChar[copiedLen++] = value;
+                        }
+                    }
+                    if (!count) return copiedLen;
+                } else {
+                    CFIndex idx;
+
+                    for (idx = 0;idx < count;idx++) *(convertedChar++) = (UTF16Char)*(extraMapping++);
+                    return count;
+                }
+            }
+        }
+    } else if (ctype == kCFUniCharCaseFold) {
+        ctype = kCFUniCharToLowercase;
+        goto caseFoldRetry;
+    }
+
+    if (theChar > 0xFFFF) { // non-BMP
+        theChar = (theChar & 0xFFFFFF) - 0x10000;
+        *(convertedChar++) = (UTF16Char)(theChar >> 10) + 0xD800UL;
+        *(convertedChar++) = (UTF16Char)(theChar & 0x3FF) + 0xDC00UL;
+        return 2;
+    } else {
+        *convertedChar = theChar;
+        return 1;
+    }
+}
+
+CFIndex CFUniCharMapTo(UniChar theChar, UniChar *convertedChar, CFIndex maxLength, uint16_t ctype, uint32_t flags) {
+    if (ctype == kCFUniCharCaseFold + 1) { // kCFUniCharDecompose
+        if (CFUniCharIsDecomposableCharacter(theChar, false)) {
+            UTF32Char buffer[MAX_DECOMPOSED_LENGTH];
+            CFIndex usedLength = CFUniCharDecomposeCharacter(theChar, buffer, MAX_DECOMPOSED_LENGTH);
+            CFIndex idx;
+
+            for (idx = 0;idx < usedLength;idx++) *(convertedChar++) = buffer[idx];
+            return usedLength;
+        } else {
+            *convertedChar = theChar;
+            return 1;
+        }
+    } else {
+        return CFUniCharMapCaseTo(theChar, convertedChar, maxLength, ctype, flags, NULL);
+    }
+}
+
+CF_INLINE bool __CFUniCharIsMoreAbove(UTF16Char *buffer, CFIndex length) {
+    UTF32Char currentChar;
+    uint32_t property;
+
+    while (length-- > 0) {
+        currentChar = *(buffer)++;
+        if (CFUniCharIsSurrogateHighCharacter(currentChar) && (length > 0) && CFUniCharIsSurrogateLowCharacter(*(buffer + 1))) {
+            currentChar = CFUniCharGetLongCharacterForSurrogatePair(currentChar, *(buffer++));
+            --length;
+        }
+        if (!CFUniCharIsMemberOf(currentChar, kCFUniCharNonBaseCharacterSet)) break;
+
+        property = CFUniCharGetCombiningPropertyForCharacter(currentChar, (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (currentChar >> 16) & 0xFF));
+
+        if (property == 230) return true; // Above priority
+    }
+    return false;
+}
+
+CF_INLINE bool __CFUniCharIsAfter_i(UTF16Char *buffer, CFIndex length) {
+    UTF32Char currentChar = 0;
+    uint32_t property;
+    UTF32Char decomposed[MAX_DECOMPOSED_LENGTH];
+    CFIndex decompLength;
+    CFIndex idx;
+
+    if (length < 1) return 0;
+
+    buffer += length;
+    while (length-- > 1) {
+        currentChar = *(--buffer);
+        if (CFUniCharIsSurrogateLowCharacter(currentChar)) {
+            if ((length > 1) && CFUniCharIsSurrogateHighCharacter(*(buffer - 1))) {
+                currentChar = CFUniCharGetLongCharacterForSurrogatePair(*(--buffer), currentChar);
+                --length;
+            } else {
+                break;
+            }
+        }
+        if (!CFUniCharIsMemberOf(currentChar, kCFUniCharNonBaseCharacterSet)) break;
+
+        property = CFUniCharGetCombiningPropertyForCharacter(currentChar, (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (currentChar >> 16) & 0xFF));
+
+        if (property == 230) return false; // Above priority
+    }
+    if (length == 0) {
+        currentChar = *(--buffer);
+    } else if (CFUniCharIsSurrogateLowCharacter(currentChar) && CFUniCharIsSurrogateHighCharacter(*(--buffer))) {
+        currentChar = CFUniCharGetLongCharacterForSurrogatePair(*buffer, currentChar);
+    }
+
+    decompLength = CFUniCharDecomposeCharacter(currentChar, decomposed, MAX_DECOMPOSED_LENGTH);
+    currentChar = *decomposed;
+
+
+    for (idx = 1;idx < decompLength;idx++) {
+        currentChar = decomposed[idx];
+        property = CFUniCharGetCombiningPropertyForCharacter(currentChar, (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, (currentChar >> 16) & 0xFF));
+
+        if (property == 230) return false; // Above priority
+    }
+    return true;
+}
+
+__private_extern__ uint32_t CFUniCharGetConditionalCaseMappingFlags(UTF32Char theChar, UTF16Char *buffer, CFIndex currentIndex, CFIndex length, uint32_t type, const uint8_t *langCode, uint32_t lastFlags) {
+    if (theChar == 0x03A3) { // GREEK CAPITAL LETTER SIGMA
+        if ((type == kCFUniCharToLowercase) && (currentIndex > 0)) {
+            UTF16Char *start = buffer;
+            UTF16Char *end = buffer + length;
+            UTF32Char otherChar;
+
+            // First check if we're after a cased character
+            buffer += (currentIndex - 1);
+            while (start <= buffer) {
+                otherChar = *(buffer--);
+                if (CFUniCharIsSurrogateLowCharacter(otherChar) && (start <= buffer) && CFUniCharIsSurrogateHighCharacter(*buffer)) {
+                    otherChar = CFUniCharGetLongCharacterForSurrogatePair(*(buffer--), otherChar);
+                }
+                if (!CFUniCharIsMemberOf(otherChar, kCFUniCharCaseIgnorableCharacterSet)) {
+                    if (!CFUniCharIsMemberOf(otherChar, kCFUniCharUppercaseLetterCharacterSet) && !CFUniCharIsMemberOf(otherChar, kCFUniCharLowercaseLetterCharacterSet)) return 0; // Uppercase set contains titlecase
+                    break;
+                }
+            }
+
+            // Next check if we're before a cased character
+            buffer = start + currentIndex + 1;
+            while (buffer < end) {
+                otherChar = *(buffer++);
+                if (CFUniCharIsSurrogateHighCharacter(otherChar) && (buffer < end) && CFUniCharIsSurrogateLowCharacter(*buffer)) {
+                    otherChar = CFUniCharGetLongCharacterForSurrogatePair(otherChar, *(buffer++));
+                }
+                if (!CFUniCharIsMemberOf(otherChar, kCFUniCharCaseIgnorableCharacterSet)) {
+                    if (CFUniCharIsMemberOf(otherChar, kCFUniCharUppercaseLetterCharacterSet) || CFUniCharIsMemberOf(otherChar, kCFUniCharLowercaseLetterCharacterSet)) return 0; // Uppercase set contains titlecase
+                    break;
+                }
+            }
+            return kCFUniCharCaseMapFinalSigma;
+        }
+    } else if (langCode) {
+        if (*((const uint16_t *)langCode) == LITHUANIAN_LANG_CODE) {
+            if ((theChar == 0x0307) && ((kCFUniCharCaseMapAfter_i|kCFUniCharCaseMapMoreAbove) & lastFlags) == (kCFUniCharCaseMapAfter_i|kCFUniCharCaseMapMoreAbove)) {
+                return (__CFUniCharIsAfter_i(buffer, currentIndex) ? kCFUniCharCaseMapAfter_i : 0);
+            } else if (type == kCFUniCharToLowercase) {
+                if ((theChar == 0x0049) || (theChar == 0x004A) || (theChar == 0x012E)) {
+                    return (__CFUniCharIsMoreAbove(buffer + (++currentIndex), length - currentIndex) ? kCFUniCharCaseMapMoreAbove : 0);
+                }
+            } else if ((theChar == 'i') || (theChar == 'j')) {
+                return (__CFUniCharIsMoreAbove(buffer + (++currentIndex), length - currentIndex) ? (kCFUniCharCaseMapAfter_i|kCFUniCharCaseMapMoreAbove) : 0);
+            }
+        } else if ((*((const uint16_t *)langCode) == TURKISH_LANG_CODE) || (*((const uint16_t *)langCode) == AZERI_LANG_CODE)) {
+            if (type == kCFUniCharToLowercase) {
+                if (theChar == 0x0307) {
+                    return (kCFUniCharCaseMapMoreAbove & lastFlags ? kCFUniCharCaseMapAfter_i : 0);
+                } else if (theChar == 0x0049) {
+                    return (((++currentIndex < length) && (buffer[currentIndex] == 0x0307)) ? kCFUniCharCaseMapMoreAbove : 0);
+                }
+            }
+        }
+    }
+    return 0;
+}
+
+// Unicode property database
+static __CFUniCharBitmapData *__CFUniCharUnicodePropertyTable = NULL;
+static int __CFUniCharUnicodePropertyTableCount = 0;
+
+static CFSpinLock_t __CFUniCharPropTableLock = CFSpinLockInit;
+
+#if USE_MACHO_SEGMENT
+#define PROP_DB_FILE "__properties"
+#else
+#define PROP_DB_FILE "CFUniCharPropertyDatabase.data"
+#endif
+
+const void *CFUniCharGetUnicodePropertyDataForPlane(uint32_t propertyType, uint32_t plane) {
+
+    __CFSpinLock(&__CFUniCharPropTableLock);
+
+    if (NULL == __CFUniCharUnicodePropertyTable) {
+        __CFUniCharBitmapData *table;
+        const void *bytes;
+        const void *bodyBase;
+        const void *planeBase;
+        int headerSize;
+        int idx, count;
+        int planeIndex, planeCount;
+        int planeSize;
+
+        if (!__CFUniCharLoadFile(PROP_DB_FILE, &bytes)) {
+            __CFSpinUnlock(&__CFUniCharPropTableLock);
+            return NULL;
+        }
+
+#if defined (__cplusplus)
+		bytes = (uint8_t*)bytes + 4; // Skip Unicode version
+		headerSize = CFSwapInt32BigToHost(*((uint32_t *)bytes)); bytes = (uint8_t *)bytes + sizeof(uint32_t);
+#else
+		bytes += 4; // Skip Unicode version
+		headerSize = CFSwapInt32BigToHost(*((uint32_t *)bytes)); bytes += sizeof(uint32_t);
+#endif //C++
+		
+        headerSize -= (sizeof(uint32_t) * 2);
+        bodyBase = (char *)bytes + headerSize;
+
+        count = headerSize / sizeof(uint32_t);
+        __CFUniCharUnicodePropertyTableCount = count;
+
+        table = (__CFUniCharBitmapData *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(__CFUniCharBitmapData) * count, 0);
+
+        for (idx = 0;idx < count;idx++) {
+            planeCount = *((const uint8_t *)bodyBase);
+            planeBase = (char *)bodyBase + planeCount + (planeCount % 4 ? 4 - (planeCount % 4) : 0);
+            table[idx]._planes = (const uint8_t **)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(const void *) * planeCount, 0);
+
+            for (planeIndex = 0;planeIndex < planeCount;planeIndex++) {
+                if ((planeSize = ((const uint8_t *)bodyBase)[planeIndex + 1])) {
+                    table[idx]._planes[planeIndex] = (const uint8_t *)planeBase;
+#if defined (__cplusplus)   
+					planeBase = (char*)planeBase + (planeSize * 256);
+#else
+					planeBase += (planeSize * 256);
+#endif //C++
+                } else {
+                    table[idx]._planes[planeIndex] = NULL;
+                }
+            }
+
+            table[idx]._numPlanes = planeCount;
+#if defined (__cplusplus)   
+			bodyBase = (const uint8_t *)bodyBase + (CFSwapInt32BigToHost(*(uint32_t *)bytes));
+			((uint32_t *&)bytes) ++;
+#else
+			bodyBase += (CFSwapInt32BigToHost(*((uint32_t *)bytes++)));
+#endif //C++
+        }
+
+        __CFUniCharUnicodePropertyTable = table;
+    }
+
+    __CFSpinUnlock(&__CFUniCharPropTableLock);
+
+    return (plane < __CFUniCharUnicodePropertyTable[propertyType]._numPlanes ? __CFUniCharUnicodePropertyTable[propertyType]._planes[plane] : NULL);
+}
+
+__private_extern__ uint32_t CFUniCharGetNumberOfPlanesForUnicodePropertyData(uint32_t propertyType) {
+    (void)CFUniCharGetUnicodePropertyDataForPlane(propertyType, 0);
+    return __CFUniCharUnicodePropertyTable[propertyType]._numPlanes;
+}
+
+__private_extern__ uint32_t CFUniCharGetUnicodeProperty(UTF32Char character, uint32_t propertyType) {
+    if (propertyType == kCFUniCharCombiningProperty) {
+        return CFUniCharGetCombiningPropertyForCharacter(character, (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(propertyType, (character >> 16) & 0xFF));
+    } else if (propertyType == kCFUniCharBidiProperty) {
+        return CFUniCharGetBidiPropertyForCharacter(character, (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(propertyType, (character >> 16) & 0xFF));
+    } else {
+        return 0;
+    }
+}
+
+
+
+/*
+    The UTF8 conversion in the following function is derived from ConvertUTF.c
+*/
+/*
+ * Copyright 2001 Unicode, Inc.
+ * 
+ * Disclaimer
+ * 
+ * This source code is provided as is by Unicode, Inc. No claims are
+ * made as to fitness for any particular purpose. No warranties of any
+ * kind are expressed or implied. The recipient agrees to determine
+ * applicability of information provided. If this file has been
+ * purchased on magnetic or optical media from Unicode, Inc., the
+ * sole remedy for any claim will be exchange of defective media
+ * within 90 days of receipt.
+ * 
+ * Limitations on Rights to Redistribute This Code
+ * 
+ * Unicode, Inc. hereby grants the right to freely use the information
+ * supplied in this file in the creation of products supporting the
+ * Unicode Standard, and to make copies of this file in any form
+ * for internal or external distribution as long as this notice
+ * remains attached.
+ */
+#define UNI_REPLACEMENT_CHAR (0x0000FFFDUL)
+
+bool CFUniCharFillDestinationBuffer(const UTF32Char *src, CFIndex srcLength, void **dst, CFIndex dstLength, CFIndex *filledLength, uint32_t dstFormat) {
+    UTF32Char currentChar;
+    CFIndex usedLength = *filledLength;
+
+    if (dstFormat == kCFUniCharUTF16Format) {
+        UTF16Char *dstBuffer = (UTF16Char *)*dst;
+
+        while (srcLength-- > 0) {
+            currentChar = *(src++);
+
+            if (currentChar > 0xFFFF) { // Non-BMP
+                usedLength += 2;
+                if (dstLength) {
+                    if (usedLength > dstLength) return false;
+                    currentChar -= 0x10000;
+                    *(dstBuffer++) = (UTF16Char)((currentChar >> 10) + 0xD800UL);
+                    *(dstBuffer++) = (UTF16Char)((currentChar & 0x3FF) + 0xDC00UL);
+                }
+            } else {
+                ++usedLength;
+                if (dstLength) {
+                    if (usedLength > dstLength) return false;
+                    *(dstBuffer++) = (UTF16Char)currentChar;
+                }
+            }
+        }
+
+        *dst = dstBuffer;
+    } else if (dstFormat == kCFUniCharUTF8Format) {
+        uint8_t *dstBuffer = (uint8_t *)*dst;
+        uint16_t bytesToWrite = 0;
+        const UTF32Char byteMask = 0xBF;
+        const UTF32Char byteMark = 0x80; 
+        static const uint8_t firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+        while (srcLength-- > 0) {
+            currentChar = *(src++);
+
+            /* Figure out how many bytes the result will require */
+            if (currentChar < (UTF32Char)0x80) {
+                bytesToWrite = 1;
+            } else if (currentChar < (UTF32Char)0x800) {
+                bytesToWrite = 2;
+            } else if (currentChar < (UTF32Char)0x10000) {
+                bytesToWrite = 3;
+            } else if (currentChar < (UTF32Char)0x200000) {
+                bytesToWrite = 4;
+            } else {
+                bytesToWrite = 2;
+                currentChar = UNI_REPLACEMENT_CHAR;
+            }
+
+            usedLength += bytesToWrite;
+
+            if (dstLength) {
+                if (usedLength > dstLength) return false;
+
+                dstBuffer += bytesToWrite;
+                switch (bytesToWrite) {	/* note: everything falls through. */
+                    case 4:	*--dstBuffer = (currentChar | byteMark) & byteMask; currentChar >>= 6;
+                    case 3:	*--dstBuffer = (currentChar | byteMark) & byteMask; currentChar >>= 6;
+                    case 2:	*--dstBuffer = (currentChar | byteMark) & byteMask; currentChar >>= 6;
+                    case 1:	*--dstBuffer =  currentChar | firstByteMark[bytesToWrite];
+                }
+                dstBuffer += bytesToWrite;
+            }
+        }
+
+        *dst = dstBuffer;
+    } else {
+        UTF32Char *dstBuffer = (UTF32Char *)*dst;
+
+        while (srcLength-- > 0) {
+            currentChar = *(src++);
+
+            ++usedLength;
+            if (dstLength) {
+                if (usedLength > dstLength) return false;
+                *(dstBuffer++) = currentChar;
+            }
+        }
+
+        *dst = dstBuffer;
+    }
+
+    *filledLength = usedLength;
+
+    return true;
+}
+
+#if DEPLOYMENT_TARGET_WINDOWS || 0
+void __CFUniCharCleanup(void)
+{
+    int	idx;
+    
+    // cleanup memory allocated by __CFUniCharLoadBitmapData()
+    __CFSpinLock(&__CFUniCharBitmapLock);
+    
+    if (__CFUniCharBitmapDataArray != NULL) {
+        for (idx = 0; idx < (int)__CFUniCharNumberOfBitmaps; idx++) {
+            CFAllocatorDeallocate(kCFAllocatorSystemDefault, __CFUniCharBitmapDataArray[idx]._planes);
+            __CFUniCharBitmapDataArray[idx]._planes = NULL;
+        }
+        
+        CFAllocatorDeallocate(kCFAllocatorSystemDefault, __CFUniCharBitmapDataArray);
+        __CFUniCharBitmapDataArray = NULL;
+        __CFUniCharNumberOfBitmaps = 0;
+    }
+    
+    __CFSpinUnlock(&__CFUniCharBitmapLock);
+    
+    // cleanup memory allocated by CFUniCharGetMappingData()
+    __CFSpinLock(&__CFUniCharMappingTableLock);
+    
+    if (__CFUniCharMappingTables != NULL) {
+        CFAllocatorDeallocate(kCFAllocatorSystemDefault, __CFUniCharMappingTables);
+        __CFUniCharMappingTables = NULL;
+    }
+    
+    // cleanup memory allocated by __CFUniCharLoadCaseMappingTable()
+    if (__CFUniCharCaseMappingTableCounts != NULL) {
+        CFAllocatorDeallocate(kCFAllocatorSystemDefault, __CFUniCharCaseMappingTableCounts);
+        __CFUniCharCaseMappingTableCounts = NULL;
+        
+        __CFUniCharCaseMappingTable = NULL;
+        __CFUniCharCaseMappingExtraTable = NULL;
+    }
+    
+    __CFSpinUnlock(&__CFUniCharMappingTableLock);
+    
+    // cleanup memory allocated by CFUniCharGetUnicodePropertyDataForPlane()
+    __CFSpinLock(&__CFUniCharPropTableLock);
+    
+    if (__CFUniCharUnicodePropertyTable != NULL) {
+        for (idx = 0; idx < __CFUniCharUnicodePropertyTableCount; idx++) {
+            CFAllocatorDeallocate(kCFAllocatorSystemDefault, __CFUniCharUnicodePropertyTable[idx]._planes);
+            __CFUniCharUnicodePropertyTable[idx]._planes = NULL;
+        }
+        
+        CFAllocatorDeallocate(kCFAllocatorSystemDefault, __CFUniCharUnicodePropertyTable);
+        __CFUniCharUnicodePropertyTable = NULL;
+        __CFUniCharUnicodePropertyTableCount = 0;
+    }
+    
+    __CFSpinUnlock(&__CFUniCharPropTableLock);
+}
+#endif	// DEPLOYMENT_TARGET_WINDOWS
+
+#undef USE_MACHO_SEGMENT
+
diff --git a/CoreFoundation/CFUniChar.h b/CoreFoundation/CFUniChar.h
new file mode 100644
index 0000000..b1f755a
--- /dev/null
+++ b/CoreFoundation/CFUniChar.h
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFUNICHAR__)
+#define __COREFOUNDATION_CFUNICHAR__ 1
+
+
+#include <CoreFoundation/CFByteOrder.h>
+#include <CoreFoundation/CFBase.h>
+
+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 = (1),
+    kCFUniCharCaseMapAfter_i = (1 << 1),
+    kCFUniCharCaseMapMoreAbove = (1 << 2)
+};
+
+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 < 0xFFFF) { // 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/CoreFoundation/CFUniCharPriv.h b/CoreFoundation/CFUniCharPriv.h
new file mode 100644
index 0000000..6deb2cc
--- /dev/null
+++ b/CoreFoundation/CFUniCharPriv.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFUNICHARPRIV__)
+#define __COREFOUNDATION_CFUNICHARPRIV__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFUniChar.h>
+
+#define kCFUniCharRecursiveDecompositionFlag	(1 << 30)
+#define kCFUniCharNonBmpFlag			(1 << 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/CoreFoundation/CFUniCharPropertyDatabase.data b/CoreFoundation/CFUniCharPropertyDatabase.data
new file mode 100644
index 0000000..6898045
--- /dev/null
+++ b/CoreFoundation/CFUniCharPropertyDatabase.data
Binary files differ
diff --git a/CoreFoundation/CFUnicodeData-B.mapping b/CoreFoundation/CFUnicodeData-B.mapping
new file mode 100644
index 0000000..75e8f3a
--- /dev/null
+++ b/CoreFoundation/CFUnicodeData-B.mapping
Binary files differ
diff --git a/CoreFoundation/CFUnicodeData-L.mapping b/CoreFoundation/CFUnicodeData-L.mapping
new file mode 100644
index 0000000..a41d4db
--- /dev/null
+++ b/CoreFoundation/CFUnicodeData-L.mapping
Binary files differ
diff --git a/CoreFoundation/CFUnicodeDecomposition.c b/CoreFoundation/CFUnicodeDecomposition.c
new file mode 100644
index 0000000..bfd80ab
--- /dev/null
+++ b/CoreFoundation/CFUnicodeDecomposition.c
@@ -0,0 +1,414 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+    Copyright 1999-2002, Apple, Inc. All rights reserved.
+    Responsibility: Aki Inoue
+*/
+
+#include <string.h>
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFCharacterSet.h>
+#include <CoreFoundation/CFUniChar.h>
+#include <CoreFoundation/CFUnicodeDecomposition.h>
+#include "CFInternal.h"
+#include "CFUniCharPriv.h"
+
+// Canonical Decomposition
+static UTF32Char *__CFUniCharDecompositionTable = NULL;
+static uint32_t __CFUniCharDecompositionTableLength = 0;
+static UTF32Char *__CFUniCharMultipleDecompositionTable = NULL;
+
+static const uint8_t *__CFUniCharDecomposableBitmapForBMP = NULL;
+static const uint8_t *__CFUniCharHFSPlusDecomposableBitmapForBMP = NULL;
+
+static CFSpinLock_t __CFUniCharDecompositionTableLock = CFSpinLockInit;
+
+static const uint8_t **__CFUniCharCombiningPriorityTable = NULL;
+static uint8_t __CFUniCharCombiningPriorityTableNumPlane = 0;
+
+static void __CFUniCharLoadDecompositionTable(void) {
+
+    __CFSpinLock(&__CFUniCharDecompositionTableLock);
+
+    if (NULL == __CFUniCharDecompositionTable) {
+        const uint32_t *bytes = (uint32_t *)CFUniCharGetMappingData(kCFUniCharCanonicalDecompMapping);
+
+        if (NULL == bytes) {
+            __CFSpinUnlock(&__CFUniCharDecompositionTableLock);
+            return;
+        }
+
+        __CFUniCharDecompositionTableLength = *(bytes++);
+        __CFUniCharDecompositionTable = (UTF32Char *)bytes;
+        __CFUniCharMultipleDecompositionTable = (UTF32Char *)((intptr_t)bytes + __CFUniCharDecompositionTableLength);
+
+        __CFUniCharDecompositionTableLength /= (sizeof(uint32_t) * 2);
+        __CFUniCharDecomposableBitmapForBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, 0);
+        __CFUniCharHFSPlusDecomposableBitmapForBMP = CFUniCharGetBitmapPtrForPlane(kCFUniCharHFSPlusDecomposableCharacterSet, 0);
+
+        CFIndex idx;
+
+        __CFUniCharCombiningPriorityTableNumPlane = CFUniCharGetNumberOfPlanesForUnicodePropertyData(kCFUniCharCombiningProperty);
+        __CFUniCharCombiningPriorityTable = (const uint8_t **)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(uint8_t *) * __CFUniCharCombiningPriorityTableNumPlane, 0);
+        for (idx = 0;idx < __CFUniCharCombiningPriorityTableNumPlane;idx++) __CFUniCharCombiningPriorityTable[idx] = (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, idx);
+    }
+
+    __CFSpinUnlock(&__CFUniCharDecompositionTableLock);
+}
+
+static CFSpinLock_t __CFUniCharCompatibilityDecompositionTableLock = CFSpinLockInit;
+static UTF32Char *__CFUniCharCompatibilityDecompositionTable = NULL;
+static uint32_t __CFUniCharCompatibilityDecompositionTableLength = 0;
+static UTF32Char *__CFUniCharCompatibilityMultipleDecompositionTable = NULL;
+
+static void __CFUniCharLoadCompatibilityDecompositionTable(void) {
+
+    __CFSpinLock(&__CFUniCharCompatibilityDecompositionTableLock);
+
+    if (NULL == __CFUniCharCompatibilityDecompositionTable) {
+        const uint32_t *bytes = (uint32_t *)CFUniCharGetMappingData(kCFUniCharCompatibilityDecompMapping);
+
+        if (NULL == bytes) {
+            __CFSpinUnlock(&__CFUniCharCompatibilityDecompositionTableLock);
+            return;
+        }
+
+        __CFUniCharCompatibilityDecompositionTableLength = *(bytes++);
+        __CFUniCharCompatibilityDecompositionTable = (UTF32Char *)bytes;
+        __CFUniCharCompatibilityMultipleDecompositionTable = (UTF32Char *)((intptr_t)bytes + __CFUniCharCompatibilityDecompositionTableLength);
+
+        __CFUniCharCompatibilityDecompositionTableLength /= (sizeof(uint32_t) * 2);
+    }
+
+    __CFSpinUnlock(&__CFUniCharCompatibilityDecompositionTableLock);
+}
+
+CF_INLINE bool __CFUniCharIsDecomposableCharacterWithFlag(UTF32Char character, bool isHFSPlus) {
+    return CFUniCharIsMemberOfBitmap(character, (character < 0x10000 ? (isHFSPlus ? __CFUniCharHFSPlusDecomposableBitmapForBMP : __CFUniCharDecomposableBitmapForBMP) : CFUniCharGetBitmapPtrForPlane(kCFUniCharCanonicalDecomposableCharacterSet, ((character >> 16) & 0xFF))));
+}
+
+CF_INLINE uint8_t __CFUniCharGetCombiningPropertyForCharacter(UTF32Char character) { return CFUniCharGetCombiningPropertyForCharacter(character, (((character) >> 16) < __CFUniCharCombiningPriorityTableNumPlane ? __CFUniCharCombiningPriorityTable[(character) >> 16] : NULL)); }
+
+CF_INLINE bool __CFUniCharIsNonBaseCharacter(UTF32Char character) { return ((0 == __CFUniCharGetCombiningPropertyForCharacter(character)) ? false : true); } // the notion of non-base in normalization is characters with non-0 combining class
+
+typedef struct {
+    uint32_t _key;
+    uint32_t _value;
+} __CFUniCharDecomposeMappings;
+
+static uint32_t __CFUniCharGetMappedValue(const __CFUniCharDecomposeMappings *theTable, uint32_t numElem, UTF32Char character) {
+    const __CFUniCharDecomposeMappings *p, *q, *divider;
+
+    if ((character < theTable[0]._key) || (character > theTable[numElem-1]._key)) {
+        return 0;
+    }
+    p = theTable;
+    q = p + (numElem-1);
+    while (p <= q) {
+        divider = p + ((q - p) >> 1);    /* divide by 2 */
+        if (character < divider->_key) { q = divider - 1; }
+        else if (character > divider->_key) { p = divider + 1; }
+        else { return divider->_value; }
+    }
+    return 0;
+}
+
+static void __CFUniCharPrioritySort(UTF32Char *characters, CFIndex length) {
+    UTF32Char *end = characters + length;
+
+    while ((characters < end) && (0 == __CFUniCharGetCombiningPropertyForCharacter(*characters))) ++characters;
+
+    if ((end - characters) > 1) {
+        uint32_t p1, p2;
+        UTF32Char *ch1, *ch2;
+        bool changes = true;
+
+        do {
+            changes = false;
+            ch1 = characters; ch2 = characters + 1;
+            p2 = __CFUniCharGetCombiningPropertyForCharacter(*ch1);
+            while (ch2 < end) {
+                p1 = p2; p2 = __CFUniCharGetCombiningPropertyForCharacter(*ch2);
+                if (p1 > p2) {
+                    UTF32Char tmp = *ch1; *ch1 = *ch2; *ch2 = tmp;
+                    changes = true;
+                }
+                ++ch1; ++ch2;
+            }
+        } while (changes);
+    }
+}
+
+static CFIndex __CFUniCharRecursivelyDecomposeCharacter(UTF32Char character, UTF32Char *convertedChars, CFIndex maxBufferLength) {
+    uint32_t value = __CFUniCharGetMappedValue((const __CFUniCharDecomposeMappings *)__CFUniCharDecompositionTable, __CFUniCharDecompositionTableLength, character);
+    CFIndex length = CFUniCharConvertFlagToCount(value);
+    UTF32Char firstChar = value & 0xFFFFFF;
+    UTF32Char *mappings = (length > 1 ? __CFUniCharMultipleDecompositionTable + firstChar : &firstChar);
+    CFIndex usedLength = 0;
+
+    if (maxBufferLength < length) return 0;
+
+    if (value & kCFUniCharRecursiveDecompositionFlag) {
+        usedLength = __CFUniCharRecursivelyDecomposeCharacter(*mappings, convertedChars, maxBufferLength - length);
+
+        --length; // Decrement for the first char
+        if (!usedLength || usedLength + length > maxBufferLength) return 0;
+        ++mappings;
+        convertedChars += usedLength;
+    }
+
+    usedLength += length;
+
+    while (length--) *(convertedChars++) = *(mappings++);
+
+    return usedLength;
+}
+    
+#define HANGUL_SBASE 0xAC00
+#define HANGUL_LBASE 0x1100
+#define HANGUL_VBASE 0x1161
+#define HANGUL_TBASE 0x11A7
+#define HANGUL_SCOUNT 11172
+#define HANGUL_LCOUNT 19
+#define HANGUL_VCOUNT 21
+#define HANGUL_TCOUNT 28
+#define HANGUL_NCOUNT (HANGUL_VCOUNT * HANGUL_TCOUNT)
+
+CFIndex CFUniCharDecomposeCharacter(UTF32Char character, UTF32Char *convertedChars, CFIndex maxBufferLength) {
+    if (NULL == __CFUniCharDecompositionTable) __CFUniCharLoadDecompositionTable();
+    if (character >= HANGUL_SBASE && character <= (HANGUL_SBASE + HANGUL_SCOUNT)) {
+        CFIndex length;
+
+        character -= HANGUL_SBASE;
+
+        length = (character % HANGUL_TCOUNT ? 3 : 2);
+
+        if (maxBufferLength < length) return 0;
+
+        *(convertedChars++) = character / HANGUL_NCOUNT + HANGUL_LBASE;
+        *(convertedChars++) = (character % HANGUL_NCOUNT) / HANGUL_TCOUNT + HANGUL_VBASE;
+        if (length > 2) *convertedChars = (character % HANGUL_TCOUNT) + HANGUL_TBASE;
+        return length;
+    } else {
+        return __CFUniCharRecursivelyDecomposeCharacter(character, convertedChars, maxBufferLength);
+    }
+}
+
+CF_INLINE bool __CFProcessReorderBuffer(UTF32Char *buffer, CFIndex length, void **dst, CFIndex dstLength, CFIndex *filledLength, uint32_t dstFormat) {
+    if (length > 1) __CFUniCharPrioritySort(buffer, length);
+    return CFUniCharFillDestinationBuffer(buffer, length, dst, dstLength, filledLength, dstFormat);
+}
+
+#define MAX_BUFFER_LENGTH (32)
+bool CFUniCharDecompose(const UTF16Char *src, CFIndex length, CFIndex *consumedLength, void *dst, CFIndex maxLength, CFIndex *filledLength, bool needToReorder, uint32_t dstFormat, bool isHFSPlus) {
+    CFIndex usedLength = 0;
+    CFIndex originalLength = length;
+    UTF32Char buffer[MAX_BUFFER_LENGTH];
+    UTF32Char *decompBuffer = buffer;
+    CFIndex decompBufferSize = MAX_BUFFER_LENGTH;
+    CFIndex decompBufferLen = 0;
+    CFIndex segmentLength = 0;
+    UTF32Char currentChar;
+
+    if (NULL == __CFUniCharDecompositionTable) __CFUniCharLoadDecompositionTable();
+
+    while ((length - segmentLength) > 0) {
+        currentChar = *(src++);
+
+        if (currentChar < 0x80) {
+            if (decompBufferLen > 0) {
+                if (!__CFProcessReorderBuffer(decompBuffer, decompBufferLen, &dst, maxLength, &usedLength, dstFormat)) break;
+                length -= segmentLength;
+                segmentLength = 0;
+                decompBufferLen = 0;
+            }
+
+            if (maxLength > 0) {
+                if (usedLength >= maxLength) break;
+                switch (dstFormat) {
+                case kCFUniCharUTF8Format: *(uint8_t *)dst = currentChar; dst = (uint8_t *)dst + sizeof(uint8_t); break;
+                case kCFUniCharUTF16Format: *(UTF16Char *)dst = currentChar; dst = (uint8_t *)dst + sizeof(UTF16Char); break;
+                case kCFUniCharUTF32Format: *(UTF32Char *)dst = currentChar; dst = (uint8_t *)dst + sizeof(UTF32Char); break;
+                }
+            }
+
+            --length;
+            ++usedLength;
+        } else {
+            if (CFUniCharIsSurrogateLowCharacter(currentChar)) { // Stray surrogagte
+                if (dstFormat != kCFUniCharUTF16Format) break;
+            } else if (CFUniCharIsSurrogateHighCharacter(currentChar)) {
+                if (((length - segmentLength) > 1) && CFUniCharIsSurrogateLowCharacter(*src)) {
+                    currentChar = CFUniCharGetLongCharacterForSurrogatePair(currentChar, *(src++));
+                } else {
+                    if (dstFormat != kCFUniCharUTF16Format) break;
+                }
+            }
+
+            if (needToReorder && __CFUniCharIsNonBaseCharacter(currentChar)) {
+                if ((decompBufferLen + 1) >= decompBufferSize) {
+                    UTF32Char *newBuffer;
+                    
+                    decompBufferSize += MAX_BUFFER_LENGTH;
+                    newBuffer = (UTF32Char *)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(UTF32Char) * decompBufferSize, 0);
+                    memmove(newBuffer, decompBuffer, (decompBufferSize - MAX_BUFFER_LENGTH) * sizeof(UTF32Char));
+                    if (decompBuffer != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, decompBuffer);
+                    decompBuffer = newBuffer;
+                }
+                
+                if (__CFUniCharIsDecomposableCharacterWithFlag(currentChar, isHFSPlus)) { // Vietnamese accent, etc.
+                    decompBufferLen += CFUniCharDecomposeCharacter(currentChar, decompBuffer + decompBufferLen, decompBufferSize - decompBufferLen);
+                } else {
+                    decompBuffer[decompBufferLen++] = currentChar;
+                }
+            } else {
+                if (decompBufferLen > 0) {
+                    if (!__CFProcessReorderBuffer(decompBuffer, decompBufferLen, &dst, maxLength, &usedLength, dstFormat)) break;
+                    length -= segmentLength;
+                    segmentLength = 0;
+                }
+
+                if (__CFUniCharIsDecomposableCharacterWithFlag(currentChar, isHFSPlus)) {
+                    decompBufferLen = CFUniCharDecomposeCharacter(currentChar, decompBuffer, MAX_BUFFER_LENGTH);
+                } else {
+                    decompBufferLen = 1;
+                    *decompBuffer = currentChar;
+                }
+
+                if (!needToReorder || (decompBufferLen == 1)) {
+                    if (!CFUniCharFillDestinationBuffer(decompBuffer, decompBufferLen, &dst, maxLength, &usedLength, dstFormat)) break;
+                    length -= ((currentChar > 0xFFFF) ? 2 : 1);
+                    decompBufferLen = 0;
+                    continue;
+                }
+            }
+
+            segmentLength += ((currentChar > 0xFFFF) ? 2 : 1);
+        }
+    }
+
+    if ((decompBufferLen > 0) && __CFProcessReorderBuffer(decompBuffer, decompBufferLen, &dst, maxLength, &usedLength, dstFormat)) length -= segmentLength;
+
+    if (decompBuffer != buffer) CFAllocatorDeallocate(kCFAllocatorSystemDefault, decompBuffer);
+
+    if (consumedLength) *consumedLength = originalLength - length;
+    if (filledLength) *filledLength = usedLength;
+
+    return ((length > 0) ? false : true);
+}
+
+#define MAX_COMP_DECOMP_LEN (32)
+
+static CFIndex __CFUniCharRecursivelyCompatibilityDecomposeCharacter(UTF32Char character, UTF32Char *convertedChars) {
+    uint32_t value = __CFUniCharGetMappedValue((const __CFUniCharDecomposeMappings *)__CFUniCharCompatibilityDecompositionTable, __CFUniCharCompatibilityDecompositionTableLength, character);
+    CFIndex length = CFUniCharConvertFlagToCount(value);
+    UTF32Char firstChar = value & 0xFFFFFF;
+    const UTF32Char *mappings = (length > 1 ? __CFUniCharCompatibilityMultipleDecompositionTable + firstChar : &firstChar);
+    CFIndex usedLength = length;
+    UTF32Char currentChar;
+    CFIndex currentLength;
+
+    while (length-- > 0) {
+        currentChar = *(mappings++);
+        if (__CFUniCharIsDecomposableCharacterWithFlag(currentChar, false)) {
+            currentLength = __CFUniCharRecursivelyDecomposeCharacter(currentChar, convertedChars, MAX_COMP_DECOMP_LEN - length);
+            convertedChars += currentLength;
+            usedLength += (currentLength - 1);
+        } else if (CFUniCharIsMemberOf(currentChar, kCFUniCharCompatibilityDecomposableCharacterSet)) {
+            currentLength = __CFUniCharRecursivelyCompatibilityDecomposeCharacter(currentChar, convertedChars);
+            convertedChars += currentLength;
+            usedLength += (currentLength - 1);
+        } else {
+            *(convertedChars++) = currentChar;
+        }
+    }
+
+    return usedLength;
+}
+
+CF_INLINE void __CFUniCharMoveBufferFromEnd1(UTF32Char *convertedChars, CFIndex length, CFIndex delta) {
+    const UTF32Char *limit = convertedChars;
+    UTF32Char *dstP;
+
+    convertedChars += length;
+    dstP = convertedChars + delta;
+
+    while (convertedChars > limit) *(--dstP) = *(--convertedChars);
+}
+
+__private_extern__ CFIndex CFUniCharCompatibilityDecompose(UTF32Char *convertedChars, CFIndex length, CFIndex maxBufferLength) {
+    UTF32Char currentChar;
+    UTF32Char buffer[MAX_COMP_DECOMP_LEN];
+    const UTF32Char *bufferP;
+    const UTF32Char *limit = convertedChars + length;
+    CFIndex filledLength;
+
+    if (NULL == __CFUniCharCompatibilityDecompositionTable) __CFUniCharLoadCompatibilityDecompositionTable();
+
+    while (convertedChars < limit) {
+        currentChar = *convertedChars;
+
+        if (CFUniCharIsMemberOf(currentChar, kCFUniCharCompatibilityDecomposableCharacterSet)) {
+            filledLength = __CFUniCharRecursivelyCompatibilityDecomposeCharacter(currentChar, buffer);
+
+            if (filledLength + length - 1 > maxBufferLength) return 0;
+
+            if (filledLength > 1) __CFUniCharMoveBufferFromEnd1(convertedChars + 1, limit - convertedChars - 1, filledLength - 1);
+
+            bufferP = buffer;
+            length += (filledLength - 1);
+            while (filledLength-- > 0) *(convertedChars++) = *(bufferP++);
+        } else {
+            ++convertedChars;
+        }
+    }
+    
+    return length;
+}
+
+CF_EXPORT void CFUniCharPrioritySort(UTF32Char *characters, CFIndex length) {
+    __CFUniCharPrioritySort(characters, length);
+}
+
+#undef MAX_BUFFER_LENGTH
+#undef MAX_COMP_DECOMP_LEN
+#undef HANGUL_SBASE
+#undef HANGUL_LBASE
+#undef HANGUL_VBASE
+#undef HANGUL_TBASE
+#undef HANGUL_SCOUNT
+#undef HANGUL_LCOUNT
+#undef HANGUL_VCOUNT
+#undef HANGUL_TCOUNT
+#undef HANGUL_NCOUNT
+
diff --git a/CoreFoundation/CFUnicodeDecomposition.h b/CoreFoundation/CFUnicodeDecomposition.h
new file mode 100644
index 0000000..85a5caa
--- /dev/null
+++ b/CoreFoundation/CFUnicodeDecomposition.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+ *
+ */
+
+#if !defined(__COREFOUNDATION_CFUNICODEDECOMPOSITION__)
+#define __COREFOUNDATION_CFUNICODEDECOMPOSITION__ 1
+
+#include <CoreFoundation/CFUniChar.h>
+
+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/CoreFoundation/CFUnicodePrecomposition.c b/CoreFoundation/CFUnicodePrecomposition.c
new file mode 100644
index 0000000..9163c79
--- /dev/null
+++ b/CoreFoundation/CFUnicodePrecomposition.c
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Aki Inoue
+*/
+
+#include <string.h>
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFCharacterSet.h>
+#include "CFUniChar.h"
+#include "CFUnicodePrecomposition.h"
+#include "CFInternal.h"
+#include "CFUniCharPriv.h"
+
+// Canonical Precomposition
+static UTF32Char *__CFUniCharPrecompSourceTable = NULL;
+static uint32_t __CFUniCharPrecompositionTableLength = 0;
+static uint16_t *__CFUniCharBMPPrecompDestinationTable = NULL;
+static uint32_t *__CFUniCharNonBMPPrecompDestinationTable = NULL;
+
+static const uint8_t *__CFUniCharNonBaseBitmapForBMP_P = NULL; // Adding _P so the symbol name is different from the one in CFUnicodeDecomposition.c
+static const uint8_t *__CFUniCharCombiningClassForBMP = NULL;
+
+static CFSpinLock_t __CFUniCharPrecompositionTableLock = CFSpinLockInit;
+
+static void __CFUniCharLoadPrecompositionTable(void) {
+
+    __CFSpinLock(&__CFUniCharPrecompositionTableLock);
+
+    if (NULL == __CFUniCharPrecompSourceTable) {
+        const uint32_t *bytes = (const uint32_t *)CFUniCharGetMappingData(kCFUniCharCanonicalPrecompMapping);
+        uint32_t bmpMappingLength;
+
+        if (NULL == bytes) {
+            __CFSpinUnlock(&__CFUniCharPrecompositionTableLock);
+            return;
+        }
+
+        __CFUniCharPrecompositionTableLength = *(bytes++);
+        bmpMappingLength = *(bytes++);
+        __CFUniCharPrecompSourceTable = (UTF32Char *)bytes;
+        __CFUniCharBMPPrecompDestinationTable = (uint16_t *)((intptr_t)bytes + (__CFUniCharPrecompositionTableLength * sizeof(UTF32Char) * 2));
+        __CFUniCharNonBMPPrecompDestinationTable = (uint32_t *)(((intptr_t)__CFUniCharBMPPrecompDestinationTable) + bmpMappingLength);
+
+        __CFUniCharNonBaseBitmapForBMP_P = CFUniCharGetBitmapPtrForPlane(kCFUniCharNonBaseCharacterSet, 0);
+        __CFUniCharCombiningClassForBMP = (const uint8_t *)CFUniCharGetUnicodePropertyDataForPlane(kCFUniCharCombiningProperty, 0);
+    }
+
+    __CFSpinUnlock(&__CFUniCharPrecompositionTableLock);
+}
+
+ // Adding _P so the symbol name is different from the one in CFUnicodeDecomposition.c
+#define __CFUniCharIsNonBaseCharacter	__CFUniCharIsNonBaseCharacter_P
+CF_INLINE bool __CFUniCharIsNonBaseCharacter(UTF32Char character) {
+    return CFUniCharIsMemberOfBitmap(character, (character < 0x10000 ? __CFUniCharNonBaseBitmapForBMP_P : CFUniCharGetBitmapPtrForPlane(kCFUniCharNonBaseCharacterSet, ((character >> 16) & 0xFF))));
+}
+
+typedef struct {
+    UTF16Char _key;
+    UTF16Char _value;
+} __CFUniCharPrecomposeBMPMappings;
+
+static UTF16Char __CFUniCharGetMappedBMPValue(const __CFUniCharPrecomposeBMPMappings *theTable, uint32_t numElem, UTF16Char character) {
+    const __CFUniCharPrecomposeBMPMappings *p, *q, *divider;
+
+    if ((character < theTable[0]._key) || (character > theTable[numElem-1]._key)) {
+        return 0;
+    }
+    p = theTable;
+    q = p + (numElem-1);
+    while (p <= q) {
+        divider = p + ((q - p) >> 1);	/* divide by 2 */
+        if (character < divider->_key) { q = divider - 1; }
+        else if (character > divider->_key) { p = divider + 1; }
+        else { return divider->_value; }
+    }
+    return 0;
+}
+
+typedef struct {
+    UTF32Char _key;
+    uint32_t _value;
+} __CFUniCharPrecomposeMappings;
+
+static uint32_t __CFUniCharGetMappedValue_P(const __CFUniCharPrecomposeMappings *theTable, uint32_t numElem, UTF32Char character) {
+    const __CFUniCharPrecomposeMappings *p, *q, *divider;
+
+    if ((character < theTable[0]._key) || (character > theTable[numElem-1]._key)) {
+        return 0;
+    }
+    p = theTable;
+    q = p + (numElem-1);
+    while (p <= q) {
+        divider = p + ((q - p) >> 1);	/* divide by 2 */
+        if (character < divider->_key) { q = divider - 1; }
+        else if (character > divider->_key) { p = divider + 1; }
+        else { return divider->_value; }
+    }
+    return 0;
+}
+
+__private_extern__
+UTF32Char CFUniCharPrecomposeCharacter(UTF32Char base, UTF32Char combining) {
+    uint32_t value;
+
+    if (NULL == __CFUniCharPrecompSourceTable) __CFUniCharLoadPrecompositionTable();
+
+    if (!(value = __CFUniCharGetMappedValue_P((const __CFUniCharPrecomposeMappings *)__CFUniCharPrecompSourceTable, __CFUniCharPrecompositionTableLength, combining))) return 0xFFFD;
+
+    // We don't have precomposition in non-BMP
+    if (value & kCFUniCharNonBmpFlag) {
+        value = __CFUniCharGetMappedValue_P((const __CFUniCharPrecomposeMappings *)((uint32_t *)__CFUniCharNonBMPPrecompDestinationTable + (value & 0xFFFF)), (value >> 16) & 0x7FFF, base);
+    } else {
+        value = __CFUniCharGetMappedBMPValue((const __CFUniCharPrecomposeBMPMappings *)((uint32_t *)__CFUniCharBMPPrecompDestinationTable + (value & 0xFFFF)), (value >> 16), base);
+    }
+    return (value ? value : 0xFFFD);
+}
+
+#define HANGUL_SBASE 0xAC00
+#define HANGUL_LBASE 0x1100
+#define HANGUL_VBASE 0x1161
+#define HANGUL_TBASE 0x11A7
+#define HANGUL_SCOUNT 11172
+#define HANGUL_LCOUNT 19
+#define HANGUL_VCOUNT 21
+#define HANGUL_TCOUNT 28
+#define HANGUL_NCOUNT (HANGUL_VCOUNT * HANGUL_TCOUNT)
+
+CF_INLINE void __CFUniCharMoveBufferFromEnd0(UTF16Char *convertedChars, CFIndex length, CFIndex delta) {
+    const UTF16Char *limit = convertedChars;
+    UTF16Char *dstP;
+
+    convertedChars += length;
+    dstP = convertedChars + delta;
+
+    while (convertedChars > limit) *(--dstP) = *(--convertedChars);
+}
+
+bool CFUniCharPrecompose(const UTF16Char *characters, CFIndex length, CFIndex *consumedLength, UTF16Char *precomposed, CFIndex maxLength, CFIndex *filledLength) {
+    UTF32Char currentChar = 0, lastChar = 0, precomposedChar = 0xFFFD;
+    CFIndex originalLength = length, usedLength = 0;
+    UTF16Char *currentBase = precomposed;
+    uint8_t currentClass, lastClass = 0;
+    bool currentBaseIsBMP = true;
+    bool isPrecomposed;
+
+    if (NULL == __CFUniCharPrecompSourceTable) __CFUniCharLoadPrecompositionTable();
+
+    while (length > 0) {
+        currentChar = *(characters++);
+        --length;
+
+        if (CFUniCharIsSurrogateHighCharacter(currentChar) && (length > 0) && CFUniCharIsSurrogateLowCharacter(*characters)) {
+            currentChar = CFUniCharGetLongCharacterForSurrogatePair(currentChar, *(characters++));
+            --length;
+        }
+
+        if (lastChar && __CFUniCharIsNonBaseCharacter(currentChar)) {
+            isPrecomposed = (precomposedChar == 0xFFFD ? false : true);
+            if (isPrecomposed) lastChar = precomposedChar;
+
+            currentClass = (currentChar > 0xFFFF ? CFUniCharGetUnicodeProperty(currentChar, kCFUniCharCombiningProperty) : CFUniCharGetCombiningPropertyForCharacter(currentChar, __CFUniCharCombiningClassForBMP));
+
+            if ((lastClass == 0) || (currentClass > lastClass)) {
+                if ((precomposedChar = CFUniCharPrecomposeCharacter(lastChar, currentChar)) == 0xFFFD) {
+                    if (isPrecomposed) precomposedChar = lastChar;
+                    lastClass = currentClass;
+                } else {
+                    continue;
+                }
+            }
+            if (currentChar > 0xFFFF) { // Non-BMP
+                usedLength += 2;
+                if (usedLength > maxLength) break;
+                currentChar -= 0x10000;
+                *(precomposed++) = (UTF16Char)((currentChar >> 10) + 0xD800UL);
+                *(precomposed++) = (UTF16Char)((currentChar & 0x3FF) + 0xDC00UL);
+            } else {
+                ++usedLength;
+                if (usedLength > maxLength) break;
+                *(precomposed++) = (UTF16Char)currentChar;
+            }
+        } else {
+            if ((currentChar >= HANGUL_LBASE) && (currentChar < (HANGUL_LBASE + 0xFF))) { // Hangul Jamo
+                int8_t lIndex = currentChar - HANGUL_LBASE;
+
+                if ((length > 0) && (0 <= lIndex) && (lIndex <= HANGUL_LCOUNT)) {
+                    int16_t vIndex = *characters - HANGUL_VBASE;
+
+                    if ((vIndex >= 0) && (vIndex <= HANGUL_VCOUNT)) {
+                        int16_t tIndex = 0;
+
+                        ++characters; --length;
+
+                        if (length > 0) {
+                            tIndex = *characters - HANGUL_TBASE;
+                            if ((tIndex < 0) || (tIndex > HANGUL_TCOUNT)) {
+                                tIndex = 0;
+                            } else {
+                                ++characters; --length;
+                            }
+                        }
+                        currentChar = (lIndex * HANGUL_VCOUNT + vIndex) * HANGUL_TCOUNT + tIndex + HANGUL_SBASE;
+                    }
+                }
+            }
+
+            if (precomposedChar != 0xFFFD) {
+                if (currentBaseIsBMP) { // Non-BMP
+                    if (lastChar > 0xFFFF) { // Last char was Non-BMP
+                        --usedLength;
+                        memmove(currentBase + 1, currentBase + 2, (precomposed - (currentBase + 2)) * sizeof(UTF16Char));
+                    }
+                    *(currentBase) = (UTF16Char)precomposedChar;
+                } else {
+                    if (lastChar < 0x10000) { // Last char was BMP
+                        ++usedLength;
+                        if (usedLength > maxLength) break;
+                        __CFUniCharMoveBufferFromEnd0(currentBase + 1, precomposed - (currentBase + 1), 1);
+                    }
+                    precomposedChar -= 0x10000;
+                    *currentBase = (UTF16Char)((precomposedChar >> 10) + 0xD800UL);
+                    *(currentBase + 1) = (UTF16Char)((precomposedChar & 0x3FF) + 0xDC00UL);
+                }
+                precomposedChar = 0xFFFD;
+            }
+            currentBase = precomposed;
+
+            lastChar = currentChar;
+            lastClass = 0;
+
+            if (currentChar > 0xFFFF) { // Non-BMP
+                usedLength += 2;
+                if (usedLength > maxLength) break;
+                currentChar -= 0x10000;
+                *(precomposed++) = (UTF16Char)((currentChar >> 10) + 0xD800UL);
+                *(precomposed++) = (UTF16Char)((currentChar & 0x3FF) + 0xDC00UL);
+                currentBaseIsBMP = false;
+            } else {
+                ++usedLength;
+                if (usedLength > maxLength) break;
+                *(precomposed++) = (UTF16Char)currentChar;
+                currentBaseIsBMP = true;
+            }
+        }
+    }
+
+    if (precomposedChar != 0xFFFD) {
+        if (currentChar > 0xFFFF) { // Non-BMP
+            if (lastChar < 0x10000) { // Last char was BMP
+                ++usedLength;
+                if (usedLength > maxLength) {
+                    if (consumedLength) *consumedLength = originalLength - length;
+                    if (filledLength) *filledLength = usedLength;
+                    return false;
+                }
+                __CFUniCharMoveBufferFromEnd0(currentBase + 1, precomposed - (currentBase + 1), 1);
+            }
+            precomposedChar -= 0x10000;
+            *currentBase = (UTF16Char)((precomposedChar >> 10) + 0xD800UL);
+            *(currentBase + 1) = (UTF16Char)((precomposedChar & 0x3FF) + 0xDC00UL);
+        } else {
+            if (lastChar > 0xFFFF) { // Last char was Non-BMP
+                --usedLength;
+                memmove(currentBase + 1, currentBase + 2, (precomposed - (currentBase + 2)) * sizeof(UTF16Char));
+            }
+            *(currentBase) = (UTF16Char)precomposedChar;
+        }
+    }
+
+    if (consumedLength) *consumedLength = originalLength - length;
+    if (filledLength) *filledLength = usedLength;
+
+    return true;
+}
+
+#undef __CFUniCharIsNonBaseCharacter
+#undef HANGUL_SBASE
+#undef HANGUL_LBASE
+#undef HANGUL_VBASE
+#undef HANGUL_TBASE
+#undef HANGUL_SCOUNT
+#undef HANGUL_LCOUNT
+#undef HANGUL_VCOUNT
+#undef HANGUL_TCOUNT
+#undef HANGUL_NCOUNT
+
diff --git a/CoreFoundation/CFUnicodePrecomposition.h b/CoreFoundation/CFUnicodePrecomposition.h
new file mode 100644
index 0000000..6372c63
--- /dev/null
+++ b/CoreFoundation/CFUnicodePrecomposition.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+ *
+ */
+
+#if !defined(__COREFOUNDATION_CFUNICODEPRECOMPOSITION__)
+#define __COREFOUNDATION_CFUNICODEPRECOMPOSITION__ 1
+
+#include <CoreFoundation/CFUniChar.h>
+
+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/CoreFoundation/CFUserNotification.c b/CoreFoundation/CFUserNotification.c
new file mode 100644
index 0000000..7e45cd4
--- /dev/null
+++ b/CoreFoundation/CFUserNotification.c
@@ -0,0 +1,511 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright (c) 2000-2007 Apple Inc.  All rights reserved.
+	Responsibility: Doug Davidson
+*/
+
+#include <CoreFoundation/CFUserNotification.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include "CFInternal.h"
+#include <CoreFoundation/CFMachPort.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+#include <errno.h>
+#if DEPLOYMENT_TARGET_WINDOWS
+#include <process.h>
+#define getpid _getpid
+#define ERR_SUCCESS 0
+#define MACH_RCV_TIMED_OUT 0
+#else
+#include <unistd.h>
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+#include <mach/mach.h>
+#include <mach/error.h>
+#include <bootstrap_priv.h>
+#include <pthread.h>
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS
+
+#define CFUserNotificationLog(alertHeader, alertMessage) CFLog(3, CFSTR("%@:  %@"), alertHeader, alertMessage);
+
+enum {
+    kCFUserNotificationCancelFlag = (1 << 3),
+    kCFUserNotificationUpdateFlag = (1 << 4)
+};
+
+CONST_STRING_DECL(kCFUserNotificationTokenKey, "Token")
+CONST_STRING_DECL(kCFUserNotificationTimeoutKey, "Timeout")
+CONST_STRING_DECL(kCFUserNotificationFlagsKey, "Flags")
+CONST_STRING_DECL(kCFUserNotificationIconPathKey, "IconPath")
+CONST_STRING_DECL(kCFUserNotificationSoundPathKey, "SoundPath")
+CONST_STRING_DECL(kCFUserNotificationLocalizationPathKey, "LocalizationPath")
+CONST_STRING_DECL(kCFUserNotificationAlertSourceKey, "AlertSource")
+CONST_STRING_DECL(kCFUserNotificationTextFieldLabelsKey, "TextFieldTitles")
+CONST_STRING_DECL(kCFUserNotificationCheckBoxLabelsKey, "CheckBoxTitles")
+CONST_STRING_DECL(kCFUserNotificationIconURLKey, "IconURL")
+CONST_STRING_DECL(kCFUserNotificationSoundURLKey, "SoundURL")
+CONST_STRING_DECL(kCFUserNotificationLocalizationURLKey, "LocalizationURL")
+CONST_STRING_DECL(kCFUserNotificationAlertHeaderKey, "AlertHeader")
+CONST_STRING_DECL(kCFUserNotificationAlertMessageKey, "AlertMessage")
+CONST_STRING_DECL(kCFUserNotificationDefaultButtonTitleKey, "DefaultButtonTitle")
+CONST_STRING_DECL(kCFUserNotificationAlternateButtonTitleKey, "AlternateButtonTitle")
+CONST_STRING_DECL(kCFUserNotificationOtherButtonTitleKey, "OtherButtonTitle")
+CONST_STRING_DECL(kCFUserNotificationProgressIndicatorValueKey, "ProgressIndicatorValue")
+CONST_STRING_DECL(kCFUserNotificationSessionIDKey, "SessionID")
+CONST_STRING_DECL(kCFUserNotificationPopUpTitlesKey, "PopUpTitles")
+CONST_STRING_DECL(kCFUserNotificationTextFieldTitlesKey, "TextFieldTitles")
+CONST_STRING_DECL(kCFUserNotificationCheckBoxTitlesKey, "CheckBoxTitles")
+CONST_STRING_DECL(kCFUserNotificationTextFieldValuesKey, "TextFieldValues")
+CONST_STRING_DECL(kCFUserNotificationPopUpSelectionKey, "PopUpSelection")
+CONST_STRING_DECL(kCFUserNotificationKeyboardTypesKey, "KeyboardTypes")
+
+static CFTypeID __kCFUserNotificationTypeID = _kCFRuntimeNotATypeID;
+
+struct __CFUserNotification {
+    CFRuntimeBase _base;
+    SInt32 _replyPort;
+    SInt32 _token;
+    CFTimeInterval _timeout;
+    CFOptionFlags _requestFlags;
+    CFOptionFlags _responseFlags;
+    CFStringRef _sessionID;
+    CFDictionaryRef _responseDictionary;
+#if DEPLOYMENT_TARGET_MACOSX
+    CFMachPortRef _machPort;
+#endif
+    CFUserNotificationCallBack _callout;
+};
+
+static CFStringRef __CFUserNotificationCopyDescription(CFTypeRef cf) {
+    CFMutableStringRef result;
+    result = CFStringCreateMutable(CFGetAllocator(cf), 0);
+    CFStringAppendFormat(result, NULL, CFSTR("<CFUserNotification %p>"), cf);
+    return result;
+}
+
+#define MAX_STRING_LENGTH PATH_MAX
+#define MAX_STRING_COUNT 16
+#define MAX_PORT_NAME_LENGTH 63
+#define NOTIFICATION_PORT_NAME_SUFFIX ".session."
+#define MESSAGE_TIMEOUT 100
+#if DEPLOYMENT_TARGET_MACOSX
+#define NOTIFICATION_PORT_NAME "com.apple.UNCUserNotification"
+#elif DEPLOYMENT_TARGET_WINDOWS
+#define NOTIFICATION_PORT_NAME "com.apple.SBUserNotification"
+#else
+#error Unknown or unspecified DEPLOYMENT_TARGET
+#endif
+
+
+static void __CFUserNotificationDeallocate(CFTypeRef cf);
+
+static const CFRuntimeClass __CFUserNotificationClass = {
+    0,
+    "CFUserNotification",
+    NULL,      // init
+    NULL,      // copy
+    __CFUserNotificationDeallocate,
+    NULL,      // equal
+    NULL,      // hash
+    NULL,      // 
+    __CFUserNotificationCopyDescription
+};
+
+__private_extern__ void __CFUserNotificationInitialize(void) {
+    __kCFUserNotificationTypeID = _CFRuntimeRegisterClass(&__CFUserNotificationClass);
+}
+
+CFTypeID CFUserNotificationGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFUserNotificationTypeID) __CFUserNotificationInitialize();
+    return __kCFUserNotificationTypeID;
+}
+
+static void __CFUserNotificationDeallocate(CFTypeRef cf) {
+    CFUserNotificationRef userNotification = (CFUserNotificationRef)cf;
+#if DEPLOYMENT_TARGET_MACOSX
+    if (userNotification->_machPort) {
+        CFMachPortInvalidate(userNotification->_machPort);
+        CFRelease(userNotification->_machPort);
+    } else if (MACH_PORT_NULL != userNotification->_replyPort) {
+        mach_port_destroy(mach_task_self(), userNotification->_replyPort);
+    }
+#endif
+    if (userNotification->_sessionID) CFRelease(userNotification->_sessionID);
+    if (userNotification->_responseDictionary) CFRelease(userNotification->_responseDictionary);
+}
+
+static void _CFUserNotificationAddToDictionary(const void *key, const void *value, void *context) {
+    if (CFGetTypeID(key) == CFStringGetTypeID()) CFDictionarySetValue((CFMutableDictionaryRef)context, key, value);
+}
+
+static CFDictionaryRef _CFUserNotificationModifiedDictionary(CFAllocatorRef allocator, CFDictionaryRef dictionary, SInt32 token, SInt32 timeout, CFStringRef source) {
+    CFMutableDictionaryRef md = CFDictionaryCreateMutable(allocator, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFNumberRef tokenNumber = CFNumberCreate(allocator, kCFNumberSInt32Type, &token);
+    CFNumberRef timeoutNumber = CFNumberCreate(allocator, kCFNumberSInt32Type, &timeout);
+    CFURLRef url = NULL;
+    CFStringRef path = NULL;
+
+    if (dictionary) CFDictionaryApplyFunction(dictionary, _CFUserNotificationAddToDictionary, md);
+    if (source) CFDictionaryAddValue(md, kCFUserNotificationAlertSourceKey, source);
+    if (tokenNumber) {
+        CFDictionaryAddValue(md, kCFUserNotificationTokenKey, tokenNumber);
+        CFRelease(tokenNumber);
+    }
+    if (timeoutNumber) {
+        CFDictionaryAddValue(md, kCFUserNotificationTimeoutKey, timeoutNumber);
+        CFRelease(timeoutNumber);
+    }
+    
+    url = (CFURLRef)CFDictionaryGetValue(md, kCFUserNotificationIconURLKey);
+    if (url && CFGetTypeID((CFTypeRef)url) == CFURLGetTypeID()) {
+        url = CFURLCopyAbsoluteURL(url);
+        CFDictionaryRemoveValue(md, kCFUserNotificationIconURLKey);
+        path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+        CFDictionaryAddValue(md, kCFUserNotificationIconPathKey, path);
+        CFRelease(url);
+        CFRelease(path);
+    }
+    url = (CFURLRef)CFDictionaryGetValue(md, kCFUserNotificationSoundURLKey);
+    if (url && CFGetTypeID((CFTypeRef)url) == CFURLGetTypeID()) {
+        url = CFURLCopyAbsoluteURL(url);
+        CFDictionaryRemoveValue(md, kCFUserNotificationSoundURLKey);
+        path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+        CFDictionaryAddValue(md, kCFUserNotificationSoundPathKey, path);
+        CFRelease(url);
+        CFRelease(path);
+    }
+    url = (CFURLRef)CFDictionaryGetValue(md, kCFUserNotificationLocalizationURLKey);
+    if (url && CFGetTypeID((CFTypeRef)url) == CFURLGetTypeID()) {
+        url = CFURLCopyAbsoluteURL(url);
+        CFDictionaryRemoveValue(md, kCFUserNotificationLocalizationURLKey);
+        path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+        CFDictionaryAddValue(md, kCFUserNotificationLocalizationPathKey, path);
+        CFRelease(url);
+        CFRelease(path);
+    }
+    return md;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX
+static SInt32 _CFUserNotificationSendRequest(CFAllocatorRef allocator, CFStringRef sessionID, mach_port_t replyPort, SInt32 token, CFTimeInterval timeout, CFOptionFlags flags, CFDictionaryRef dictionary) {
+    CFDictionaryRef modifiedDictionary = NULL;
+    SInt32 retval = ERR_SUCCESS, itimeout = (timeout > 0.0 && timeout < INT_MAX) ? (SInt32)timeout : 0;
+    CFDataRef data;
+    mach_msg_base_t *msg = NULL;
+    mach_port_t bootstrapPort = MACH_PORT_NULL, serverPort = MACH_PORT_NULL;
+    CFIndex size;
+    char namebuffer[MAX_PORT_NAME_LENGTH + 1];
+    strlcpy(namebuffer, NOTIFICATION_PORT_NAME, sizeof(namebuffer));
+    if (sessionID) {
+	char sessionid[MAX_PORT_NAME_LENGTH + 1];
+	CFIndex len = MAX_PORT_NAME_LENGTH - sizeof(NOTIFICATION_PORT_NAME) - sizeof(NOTIFICATION_PORT_NAME_SUFFIX);
+        CFStringGetBytes(sessionID, CFRangeMake(0, CFStringGetLength(sessionID)), kCFStringEncodingUTF8, 0, false, (uint8_t *)sessionid, len, &size);
+	sessionid[len - 1] = '\0';
+	strlcat(namebuffer, NOTIFICATION_PORT_NAME_SUFFIX, sizeof(namebuffer));
+	strlcat(namebuffer, sessionid, sizeof(namebuffer));
+    }
+
+    retval = task_get_bootstrap_port(mach_task_self(), &bootstrapPort);
+    if (ERR_SUCCESS == retval && MACH_PORT_NULL != bootstrapPort) retval = bootstrap_look_up2(bootstrapPort, namebuffer, &serverPort, 0, 0);
+    if (ERR_SUCCESS == retval && MACH_PORT_NULL != serverPort) {
+        modifiedDictionary = _CFUserNotificationModifiedDictionary(allocator, dictionary, token, itimeout, _CFProcessNameString());
+        if (modifiedDictionary) {
+            data = CFPropertyListCreateXMLData(allocator, modifiedDictionary);
+            if (data) {
+                size = sizeof(mach_msg_base_t) + ((CFDataGetLength(data) + 3) & (~0x3));
+                msg = (mach_msg_base_t *)CFAllocatorAllocate(allocator, size, 0);
+                if (__CFOASafe) __CFSetLastAllocationEventName(msg, "CFUserNotification (temp)");
+                if (msg) {
+                    memset(msg, 0, size);
+                    msg->header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE);
+                    msg->header.msgh_size = size;
+                    msg->header.msgh_remote_port = serverPort;
+                    msg->header.msgh_local_port = replyPort;
+                    msg->header.msgh_id = flags;
+                    msg->body.msgh_descriptor_count = 0;
+                    CFDataGetBytes(data, CFRangeMake(0, CFDataGetLength(data)), (uint8_t *)msg + sizeof(mach_msg_base_t));
+                    //CFShow(CFStringCreateWithBytes(kCFAllocatorSystemDefault, (UInt8 *)msg + sizeof(mach_msg_base_t), CFDataGetLength(data), kCFStringEncodingUTF8, false));
+                    retval = mach_msg((mach_msg_header_t *)msg, MACH_SEND_MSG|MACH_SEND_TIMEOUT, size, 0, MACH_PORT_NULL, MESSAGE_TIMEOUT, MACH_PORT_NULL);
+                    CFAllocatorDeallocate(allocator, msg);
+                } else {
+                    retval = unix_err(ENOMEM);
+                }
+                CFRelease(data);
+            } else {
+                retval = unix_err(ENOMEM);
+            }
+            CFRelease(modifiedDictionary);
+        } else {
+            retval = unix_err(ENOMEM);
+        }
+    }
+    return retval;
+}
+#endif
+
+CFUserNotificationRef CFUserNotificationCreate(CFAllocatorRef allocator, CFTimeInterval timeout, CFOptionFlags flags, SInt32 *error, CFDictionaryRef dictionary) {
+    CHECK_FOR_FORK();
+    CFUserNotificationRef userNotification = NULL;
+    SInt32 retval = ERR_SUCCESS;
+    static uint16_t tokenCounter = 0;
+    SInt32 token = ((getpid()<<16) | (tokenCounter++));
+    CFStringRef sessionID = (dictionary ? (CFStringRef)CFDictionaryGetValue(dictionary, kCFUserNotificationSessionIDKey) : NULL);
+#if DEPLOYMENT_TARGET_MACOSX
+    mach_port_t replyPort = MACH_PORT_NULL;
+
+    if (!allocator) allocator = __CFGetDefaultAllocator();
+
+    retval = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &replyPort);
+    if (ERR_SUCCESS == retval && MACH_PORT_NULL != replyPort) retval = _CFUserNotificationSendRequest(allocator, sessionID, replyPort, token, timeout, flags, dictionary);
+#else
+    SInt32 replyPort = 0;
+#endif
+    if (ERR_SUCCESS == retval) {
+        userNotification = (CFUserNotificationRef)_CFRuntimeCreateInstance(allocator, CFUserNotificationGetTypeID(), sizeof(struct __CFUserNotification) - sizeof(CFRuntimeBase), NULL);
+        if (userNotification) {
+            userNotification->_replyPort = replyPort;
+            userNotification->_token = token;
+            userNotification->_timeout = timeout;
+            userNotification->_requestFlags = flags;
+            userNotification->_responseFlags = 0;
+            userNotification->_sessionID = NULL;
+            userNotification->_responseDictionary = NULL;
+#if DEPLOYMENT_TARGET_MACOSX
+            userNotification->_machPort = NULL;
+#endif
+            userNotification->_callout = NULL;
+            if (sessionID) userNotification->_sessionID = CFStringCreateCopy(allocator, sessionID);
+        } else {
+#if DEPLOYMENT_TARGET_MACOSX
+            retval = unix_err(ENOMEM);
+#else
+	    retval = -1;
+#endif
+        }
+    } else {
+        if (dictionary) CFUserNotificationLog(CFDictionaryGetValue(dictionary, kCFUserNotificationAlertHeaderKey), CFDictionaryGetValue(dictionary, kCFUserNotificationAlertMessageKey));
+    }
+#if DEPLOYMENT_TARGET_MACOSX
+    if (ERR_SUCCESS != retval && MACH_PORT_NULL != replyPort) mach_port_destroy(mach_task_self(), replyPort);
+#endif
+    if (error) *error = retval;
+    return userNotification;
+}
+
+#if DEPLOYMENT_TARGET_MACOSX
+static void _CFUserNotificationMachPortCallBack(CFMachPortRef port, void *m, CFIndex size, void *info) {
+    CFUserNotificationRef userNotification = (CFUserNotificationRef)info;
+    mach_msg_base_t *msg = (mach_msg_base_t *)m;
+    CFOptionFlags responseFlags = msg->header.msgh_id;
+    if (msg->header.msgh_size > sizeof(mach_msg_base_t)) {
+        CFDataRef responseData = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)msg + sizeof(mach_msg_base_t), msg->header.msgh_size - sizeof(mach_msg_base_t));
+        if (responseData) {
+            userNotification->_responseDictionary = (CFDictionaryRef)CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, responseData, kCFPropertyListImmutable, NULL);
+            CFRelease(responseData);
+        }
+    }
+    CFMachPortInvalidate(userNotification->_machPort);
+    CFRelease(userNotification->_machPort);
+    userNotification->_machPort = NULL;
+    mach_port_destroy(mach_task_self(), userNotification->_replyPort);
+    userNotification->_replyPort = MACH_PORT_NULL;
+    userNotification->_callout(userNotification, responseFlags);
+}
+#endif
+
+SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags) {
+    CHECK_FOR_FORK();
+    SInt32 retval = ERR_SUCCESS;
+#if DEPLOYMENT_TARGET_MACOSX
+    mach_msg_timeout_t msgtime = (timeout > 0.0 && 1000.0 * timeout < INT_MAX) ? (mach_msg_timeout_t)(1000.0 * timeout) : 0;
+    mach_msg_base_t *msg = NULL;
+    CFIndex size = MAX_STRING_COUNT * MAX_STRING_LENGTH;
+    CFDataRef responseData;
+    
+    if (userNotification && MACH_PORT_NULL != userNotification->_replyPort) {
+        msg = (mach_msg_base_t *)CFAllocatorAllocate(CFGetAllocator(userNotification), size, 0);
+	if (__CFOASafe) __CFSetLastAllocationEventName(msg, "CFUserNotification (temp)");
+        if (msg) {
+            memset(msg, 0, size);
+            msg->header.msgh_size = size;
+            if (msgtime > 0) {
+                retval = mach_msg((mach_msg_header_t *)msg, MACH_RCV_MSG|MACH_RCV_TIMEOUT, 0, size, userNotification->_replyPort, msgtime, MACH_PORT_NULL);
+            } else {
+                retval = mach_msg((mach_msg_header_t *)msg, MACH_RCV_MSG, 0, size, userNotification->_replyPort, 0, MACH_PORT_NULL);
+            }
+            if (ERR_SUCCESS == retval) {
+                if (responseFlags) *responseFlags = msg->header.msgh_id;
+                if (msg->header.msgh_size > sizeof(mach_msg_base_t)) {
+                    responseData = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)msg + sizeof(mach_msg_base_t), msg->header.msgh_size - sizeof(mach_msg_base_t));
+                    if (responseData) {
+                        userNotification->_responseDictionary = (CFDictionaryRef)CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, responseData, kCFPropertyListImmutable, NULL);
+                        CFRelease(responseData);
+                    }
+                }
+                if (userNotification->_machPort) {
+                    CFMachPortInvalidate(userNotification->_machPort);
+                    CFRelease(userNotification->_machPort);
+                    userNotification->_machPort = NULL;
+                }
+                mach_port_destroy(mach_task_self(), userNotification->_replyPort);
+                userNotification->_replyPort = MACH_PORT_NULL;
+            }
+            CFAllocatorDeallocate(CFGetAllocator(userNotification), msg);
+        } else {
+            retval = unix_err(ENOMEM);
+        }
+    }
+#endif
+    return retval;
+}
+
+CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotification, CFStringRef key, CFIndex idx) {
+    CHECK_FOR_FORK();
+    CFStringRef retval = NULL;
+    CFTypeRef value = NULL;
+    if (userNotification && userNotification->_responseDictionary) {
+        value = CFDictionaryGetValue(userNotification->_responseDictionary, key);
+        if (CFGetTypeID(value) == CFStringGetTypeID()) {
+            if (0 == idx) {
+                retval = (CFStringRef)value;
+            }
+        } else if (CFGetTypeID(value) == CFArrayGetTypeID()) {
+            if (0 <= idx && idx < CFArrayGetCount((CFArrayRef)value)) {
+                retval = (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)value, idx);
+            }
+        }
+    }
+    return retval;
+}
+
+CFDictionaryRef CFUserNotificationGetResponseDictionary(CFUserNotificationRef userNotification) {
+    CHECK_FOR_FORK();
+    return userNotification ? userNotification->_responseDictionary : NULL;
+}
+
+SInt32 CFUserNotificationUpdate(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags flags, CFDictionaryRef dictionary) {
+    CHECK_FOR_FORK();
+    SInt32 retval = ERR_SUCCESS;
+#if DEPLOYMENT_TARGET_MACOSX
+    if (userNotification && MACH_PORT_NULL != userNotification->_replyPort) {
+        retval = _CFUserNotificationSendRequest(CFGetAllocator(userNotification), userNotification->_sessionID, userNotification->_replyPort, userNotification->_token, timeout, flags|kCFUserNotificationUpdateFlag, dictionary);
+    }
+#endif
+    return retval;
+}
+
+SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification) {
+    CHECK_FOR_FORK();
+    SInt32 retval = ERR_SUCCESS;
+#if DEPLOYMENT_TARGET_MACOSX
+    if (userNotification && MACH_PORT_NULL != userNotification->_replyPort) {
+        retval = _CFUserNotificationSendRequest(CFGetAllocator(userNotification), userNotification->_sessionID, userNotification->_replyPort, userNotification->_token, 0, kCFUserNotificationCancelFlag, NULL);
+    }
+#endif
+    return retval;
+}
+
+CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource(CFAllocatorRef allocator, CFUserNotificationRef userNotification, CFUserNotificationCallBack callout, CFIndex order) {
+    CHECK_FOR_FORK();
+    CFRunLoopSourceRef source = NULL;
+#if DEPLOYMENT_TARGET_MACOSX
+    if (userNotification && callout && !userNotification->_machPort && MACH_PORT_NULL != userNotification->_replyPort) {
+        CFMachPortContext context = {0, userNotification, NULL, NULL, NULL};
+        userNotification->_machPort = CFMachPortCreateWithPort(CFGetAllocator(userNotification), (mach_port_t)userNotification->_replyPort, _CFUserNotificationMachPortCallBack, &context, false);
+    }
+    if (userNotification && userNotification->_machPort) {
+        source = CFMachPortCreateRunLoopSource(allocator, userNotification->_machPort, order);
+        userNotification->_callout = callout;
+    }
+#endif
+    return source;
+}
+
+SInt32 CFUserNotificationDisplayNotice(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle) {
+    CHECK_FOR_FORK();
+    CFUserNotificationRef userNotification;
+    SInt32 retval = ERR_SUCCESS;
+    CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    if (iconURL) CFDictionaryAddValue(dict, kCFUserNotificationIconURLKey, iconURL);
+    if (soundURL) CFDictionaryAddValue(dict, kCFUserNotificationSoundURLKey, soundURL);
+    if (localizationURL) CFDictionaryAddValue(dict, kCFUserNotificationLocalizationURLKey, localizationURL);
+    if (alertHeader) CFDictionaryAddValue(dict, kCFUserNotificationAlertHeaderKey, alertHeader);
+    if (alertMessage) CFDictionaryAddValue(dict, kCFUserNotificationAlertMessageKey, alertMessage);
+    if (defaultButtonTitle) CFDictionaryAddValue(dict, kCFUserNotificationDefaultButtonTitleKey, defaultButtonTitle);
+    userNotification = CFUserNotificationCreate(kCFAllocatorSystemDefault, timeout, flags, &retval, dict);
+    if (userNotification) CFRelease(userNotification);
+    CFRelease(dict);
+    return retval;
+}
+
+
+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) {
+    CHECK_FOR_FORK();
+    CFUserNotificationRef userNotification;
+    SInt32 retval = ERR_SUCCESS;
+    CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    if (iconURL) CFDictionaryAddValue(dict, kCFUserNotificationIconURLKey, iconURL);
+    if (soundURL) CFDictionaryAddValue(dict, kCFUserNotificationSoundURLKey, soundURL);
+    if (localizationURL) CFDictionaryAddValue(dict, kCFUserNotificationLocalizationURLKey, localizationURL);
+    if (alertHeader) CFDictionaryAddValue(dict, kCFUserNotificationAlertHeaderKey, alertHeader);
+    if (alertMessage) CFDictionaryAddValue(dict, kCFUserNotificationAlertMessageKey, alertMessage);
+    if (defaultButtonTitle) CFDictionaryAddValue(dict, kCFUserNotificationDefaultButtonTitleKey, defaultButtonTitle);
+    if (alternateButtonTitle) CFDictionaryAddValue(dict, kCFUserNotificationAlternateButtonTitleKey, alternateButtonTitle);
+    if (otherButtonTitle) CFDictionaryAddValue(dict, kCFUserNotificationOtherButtonTitleKey, otherButtonTitle);
+    userNotification = CFUserNotificationCreate(kCFAllocatorSystemDefault, timeout, flags, &retval, dict);
+    if (userNotification) {
+        retval = CFUserNotificationReceiveResponse(userNotification, timeout, responseFlags);
+        if (MACH_RCV_TIMED_OUT == retval) {
+            retval = CFUserNotificationCancel(userNotification);
+            if (responseFlags) *responseFlags = kCFUserNotificationCancelResponse;
+        }
+        CFRelease(userNotification);
+    }
+    CFRelease(dict);
+    return retval;
+}
+
+#undef MAX_STRING_LENGTH
+#undef MAX_STRING_COUNT
+#undef NOTIFICATION_PORT_NAME
+#undef MESSAGE_TIMEOUT
+#undef MAX_PORT_NAME_LENGTH
+#undef NOTIFICATION_PORT_NAME_SUFFIX
+
+#endif /* DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS */
diff --git a/CoreFoundation/CFUserNotification.h b/CoreFoundation/CFUserNotification.h
new file mode 100644
index 0000000..8236357
--- /dev/null
+++ b/CoreFoundation/CFUserNotification.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc.  All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFUSERNOTIFICATION__)
+#define __COREFOUNDATION_CFUSERNOTIFICATION__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFRunLoop.h>
+
+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 	= (1 << 5),
+    kCFUserNotificationUseRadioButtonsFlag 	= (1 << 6)
+};
+
+CF_INLINE CFOptionFlags CFUserNotificationCheckBoxChecked(CFIndex i) {return ((CFOptionFlags)(1 << (8 + i)));}
+CF_INLINE CFOptionFlags CFUserNotificationSecureTextField(CFIndex i) {return ((CFOptionFlags)(1 << (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;
+
+#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
+CF_EXPORT
+const CFStringRef kCFUserNotificationPopUpSelectionKey	AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+#endif
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFUSERNOTIFICATION__ */
+
diff --git a/CoreFoundation/CFUtilities.c b/CoreFoundation/CFUtilities.c
new file mode 100644
index 0000000..c170162
--- /dev/null
+++ b/CoreFoundation/CFUtilities.c
@@ -0,0 +1,588 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ * Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>. All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#include "CFPriv.h"
+#include "CFInternal.h"
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFURLAccess.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFTimeZone.h>
+#include <CoreFoundation/CFCalendar.h>
+#if (DEPLOYMENT_TARGET_MACOSX) 
+#include <CoreFoundation/CFLogUtilities.h>
+#include <asl.h>
+#include <sys/uio.h>
+#endif
+#include <math.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#if DEPLOYMENT_TARGET_MACOSX
+    #include <mach/mach.h>
+    #include <pthread.h>
+    #include <mach-o/loader.h>
+    #include <mach-o/dyld.h>
+    #include <crt_externs.h>
+    #include <dlfcn.h>
+    #include <vproc.h>
+    #include <vproc_priv.h>
+    #include <sys/stat.h>
+#include <unistd.h>
+#include <mach/mach.h>
+#include <mach/mach_vm.h>
+#include <stdio.h>
+#endif
+#if DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    #include <string.h>
+    #include <pthread.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+    #include <windows.h>
+    #include <process.h>
+    #define getpid _getpid
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+typedef void* (*THREAD_FUN_TYPE)(void*);
+#endif
+
+/* Comparator is passed the address of the values. */
+/* Binary searches a sorted-increasing array of some type.
+   Return value is either 1) the index of the element desired,
+   if the target value exists in the list, 2) greater than or
+   equal to count, if the element is greater than all the values
+   in the list, or 3) the index of the element greater than the
+   target value.
+
+   For example, a search in the list of integers:
+	2 3 5 7 11 13 17
+
+   For...		Will Return...
+	2		    0
+   	5		    2
+	23		    7
+	1		    0
+	9		    4
+
+   For instance, if you just care about found/not found:
+   index = CFBSearch(list, count, elem);
+   if (count <= index || list[index] != elem) {
+   	* Not found *
+   } else {
+   	* Found *
+   }
+   
+*/
+__private_extern__ CFIndex CFBSearch(const void *element, CFIndex elementSize, const void *list, CFIndex count, CFComparatorFunction comparator, void *context) {
+    const char *ptr = (const char *)list;
+    while (0 < count) {
+        CFIndex half = count / 2;
+        const char *probe = ptr + elementSize * half;
+        CFComparisonResult cr = comparator(element, probe, context);
+	if (0 == cr) return (probe - (const char *)list) / elementSize;
+        ptr = (cr < 0) ? ptr : probe + elementSize;
+        count = (cr < 0) ? half : (half + (count & 1) - 1);
+    }
+    return (ptr - (const char *)list) / elementSize;
+}
+
+
+#define ELF_STEP(B) T1 = (H << 4) + B; T2 = T1 & 0xF0000000; if (T2) T1 ^= (T2 >> 24); T1 &= (~T2); H = T1;
+
+CFHashCode CFHashBytes(uint8_t *bytes, CFIndex length) {
+    /* The ELF hash algorithm, used in the ELF object file format */
+    UInt32 H = 0, T1, T2;
+    SInt32 rem = length;
+    while (3 < rem) {
+	ELF_STEP(bytes[length - rem]);
+	ELF_STEP(bytes[length - rem + 1]);
+	ELF_STEP(bytes[length - rem + 2]);
+	ELF_STEP(bytes[length - rem + 3]);
+	rem -= 4;
+    }
+    switch (rem) {
+    case 3:  ELF_STEP(bytes[length - 3]);
+    case 2:  ELF_STEP(bytes[length - 2]);
+    case 1:  ELF_STEP(bytes[length - 1]);
+    case 0:  ;
+    }
+    return H;
+}
+
+#undef ELF_STEP
+
+
+#if DEPLOYMENT_TARGET_MACOSX
+__private_extern__ uintptr_t __CFFindPointer(uintptr_t ptr, uintptr_t start) {
+    vm_map_t task = mach_task_self();
+    mach_vm_address_t address = start;
+    for (;;) {
+	mach_vm_size_t size = 0;
+	vm_region_basic_info_data_64_t info;
+        mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
+	mach_port_t object_name;
+        kern_return_t ret = mach_vm_region(task, &address, &size, VM_REGION_BASIC_INFO_64, (vm_region_info_t)&info, &count, &object_name);
+        if (KERN_SUCCESS != ret) break;
+	boolean_t scan = (info.protection & VM_PROT_WRITE) ? 1 : 0;
+	if (scan) {
+	    uintptr_t *addr = (uintptr_t *)((uintptr_t)address);
+	    uintptr_t *end = (uintptr_t *)((uintptr_t)address + (uintptr_t)size);
+	    while (addr < end) {
+	        if ((uintptr_t *)start <= addr && *addr == ptr) {
+		    return (uintptr_t)addr;
+	        }
+	        addr++;
+	    }
+	}
+        address += size;
+    }
+    return 0;
+}
+#endif
+
+#if DEPLOYMENT_TARGET_WINDOWS
+typedef struct _args {
+    void *func;
+    void *arg;
+    HANDLE handle;
+};
+
+static unsigned int __stdcall __CFWinThreadFunc(void *arg) {
+    struct _args *args = (struct _args*)arg;
+    ((void (*)(void *))args->func)(args->arg);
+    CloseHandle(args->handle);
+    CFAllocatorDeallocate(kCFAllocatorSystemDefault, arg);
+    _endthreadex(0);
+    return 0;
+}
+#endif
+
+__private_extern__ void *__CFStartSimpleThread(void *func, void *arg) {
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
+    pthread_attr_t attr;
+    pthread_t tid = 0;
+    pthread_attr_init(&attr);
+    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    pthread_attr_setstacksize(&attr, 60 * 1024);	// 60K stack for our internal threads is sufficient
+    _CFMemoryBarrier(); // ensure arg is fully initialized and set in memory
+    pthread_create(&tid, &attr, (THREAD_FUN_TYPE)func, arg);
+    pthread_attr_destroy(&attr);
+//warning CF: we dont actually know that a pthread_t is the same size as void *
+    return (void *)tid;
+#else
+    unsigned tid;
+    struct _args *args = (struct _args*)CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(struct _args), 0);
+    if (__CFOASafe) __CFSetLastAllocationEventName(args, "CFUtilities (thread-args)");
+    HANDLE handle;
+    args->func = func;
+    args->arg = arg;
+    /* The thread is created suspended, because otherwise there would be a race between the assignment below of the handle field, and it's possible use in the thread func above. */
+    args->handle = (HANDLE)_beginthreadex(NULL, 0, __CFWinThreadFunc, args, CREATE_SUSPENDED, &tid);
+    handle = args->handle;
+    ResumeThread(handle);
+    return handle;
+#endif
+}
+
+__private_extern__ CFStringRef _CFCreateLimitedUniqueString() {
+    /* this unique string is only unique to the current host during the current boot */
+    uint64_t tsr = __CFReadTSR();
+    UInt32 tsrh = (UInt32)(tsr >> 32), tsrl = (UInt32)(tsr & (int64_t)0xFFFFFFFF);
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("CFUniqueString-%lu%lu$"), tsrh, tsrl);
+}
+
+
+// Looks for localized version of "nonLocalized" in the SystemVersion bundle
+// If not found, and returnNonLocalizedFlag == true, will return the non localized string (retained of course), otherwise NULL
+// If bundlePtr != NULL, will use *bundlePtr and will return the bundle in there; otherwise bundle is created and released
+
+static CFStringRef _CFCopyLocalizedVersionKey(CFBundleRef *bundlePtr, CFStringRef nonLocalized) {
+    CFStringRef localized = NULL;
+    CFBundleRef locBundle = bundlePtr ? *bundlePtr : NULL;
+    if (!locBundle) {
+        CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, CFSTR("/System/Library/CoreServices/SystemVersion.bundle"), kCFURLPOSIXPathStyle, false);
+        if (url) {
+            locBundle = CFBundleCreate(kCFAllocatorSystemDefault, url);
+            CFRelease(url);
+        }
+    }
+    if (locBundle) {
+	localized = CFBundleCopyLocalizedString(locBundle, nonLocalized, nonLocalized, CFSTR("SystemVersion"));
+	if (bundlePtr) *bundlePtr = locBundle; else CFRelease(locBundle);
+    }
+    return localized ? localized : (CFStringRef)CFRetain(nonLocalized);
+}
+
+static CFDictionaryRef _CFCopyVersionDictionary(CFStringRef path) {
+    CFPropertyListRef plist = NULL;
+    CFDataRef data;
+    CFURLRef url;
+
+    url = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, path, kCFURLPOSIXPathStyle, false);
+    if (url && CFURLCreateDataAndPropertiesFromResource(kCFAllocatorSystemDefault, url, &data, NULL, NULL, NULL)) {
+	plist = CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, data, kCFPropertyListMutableContainers, NULL);
+	CFRelease(data);
+    }
+    if (url) CFRelease(url);
+    
+    if (plist) {
+#if DEPLOYMENT_TARGET_MACOSX
+	CFBundleRef locBundle = NULL;
+	CFStringRef fullVersion, vers, versExtra, build;
+	CFStringRef versionString = _CFCopyLocalizedVersionKey(&locBundle, _kCFSystemVersionProductVersionStringKey);
+	CFStringRef buildString = _CFCopyLocalizedVersionKey(&locBundle, _kCFSystemVersionBuildStringKey);
+	CFStringRef fullVersionString = _CFCopyLocalizedVersionKey(&locBundle, CFSTR("FullVersionString"));
+	if (locBundle) CFRelease(locBundle);
+
+        // Now build the full version string
+        if (CFEqual(fullVersionString, CFSTR("FullVersionString"))) {
+            CFRelease(fullVersionString);
+            fullVersionString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%@ %%@ (%@ %%@)"), versionString, buildString);
+        }
+        vers = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)plist, _kCFSystemVersionProductVersionKey);
+        versExtra = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)plist, _kCFSystemVersionProductVersionExtraKey);
+        if (vers && versExtra) vers = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%@ %@"), vers, versExtra);
+        build = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)plist, _kCFSystemVersionBuildVersionKey);
+        fullVersion = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, fullVersionString, (vers ? vers : CFSTR("?")), build ? build : CFSTR("?"));
+        if (vers && versExtra) CFRelease(vers);
+        
+	CFDictionarySetValue((CFMutableDictionaryRef)plist, _kCFSystemVersionProductVersionStringKey, versionString);
+	CFDictionarySetValue((CFMutableDictionaryRef)plist, _kCFSystemVersionBuildStringKey, buildString);
+	CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR("FullVersionString"), fullVersion);
+ 	CFRelease(versionString);
+	CFRelease(buildString);
+	CFRelease(fullVersionString);
+        CFRelease(fullVersion);
+#endif
+    }    
+    return (CFDictionaryRef)plist;
+}
+
+#if defined (__MACH__) || 0
+CFStringRef CFCopySystemVersionString(void) {
+    CFStringRef versionString;
+    CFDictionaryRef dict = _CFCopyServerVersionDictionary();
+    if (!dict) dict = _CFCopySystemVersionDictionary();
+    versionString = (CFStringRef)CFDictionaryGetValue(dict, CFSTR("FullVersionString"));
+    if (versionString) CFRetain(versionString);
+    CFRelease(dict);
+    return versionString;
+}
+
+// Obsolete: These two functions cache the dictionaries to avoid calling _CFCopyVersionDictionary() more than once per dict desired
+// In fact, they do not cache any more, because the file can change after
+// apps are running in some situations, and apps need the new info.
+// Proper caching and testing to see if the file has changed, without race
+// conditions, would require semi-convoluted use of fstat().
+
+CFDictionaryRef _CFCopySystemVersionDictionary(void) {
+    CFPropertyListRef plist = NULL;
+    plist = _CFCopyVersionDictionary(CFSTR("/System/Library/CoreServices/SystemVersion.plist"));
+    return (CFDictionaryRef)plist;
+}
+
+CFDictionaryRef _CFCopyServerVersionDictionary(void) {
+    CFPropertyListRef plist = NULL;
+    plist = _CFCopyVersionDictionary(CFSTR("/System/Library/CoreServices/ServerVersion.plist"));
+    return (CFDictionaryRef)plist;
+}
+
+CONST_STRING_DECL(_kCFSystemVersionProductNameKey, "ProductName")
+CONST_STRING_DECL(_kCFSystemVersionProductCopyrightKey, "ProductCopyright")
+CONST_STRING_DECL(_kCFSystemVersionProductVersionKey, "ProductVersion")
+CONST_STRING_DECL(_kCFSystemVersionProductVersionExtraKey, "ProductVersionExtra")
+CONST_STRING_DECL(_kCFSystemVersionProductUserVisibleVersionKey, "ProductUserVisibleVersion")
+CONST_STRING_DECL(_kCFSystemVersionBuildVersionKey, "ProductBuildVersion")
+CONST_STRING_DECL(_kCFSystemVersionProductVersionStringKey, "Version")
+CONST_STRING_DECL(_kCFSystemVersionBuildStringKey, "Build")
+
+typedef struct {
+    uint16_t    primaryVersion;
+    uint8_t     secondaryVersion;
+    uint8_t     tertiaryVersion;
+} CFLibraryVersion;
+
+CFLibraryVersion CFGetExecutableLinkedLibraryVersion(CFStringRef libraryName) {
+    CFLibraryVersion ret = {0xFFFF, 0xFF, 0xFF};
+    char library[CFMaxPathSize];	// search specs larger than this are pointless
+    if (!CFStringGetCString(libraryName, library, sizeof(library), kCFStringEncodingUTF8)) return ret;
+    int32_t version = NSVersionOfLinkTimeLibrary(library);
+    if (-1 != version) {
+	ret.primaryVersion = version >> 16;
+	ret.secondaryVersion = (version >> 8) & 0xff;
+	ret.tertiaryVersion = version & 0xff;
+    }
+    return ret;
+}
+
+CFLibraryVersion CFGetExecutingLibraryVersion(CFStringRef libraryName) {
+    CFLibraryVersion ret = {0xFFFF, 0xFF, 0xFF};
+    char library[CFMaxPathSize];	// search specs larger than this are pointless
+    if (!CFStringGetCString(libraryName, library, sizeof(library), kCFStringEncodingUTF8)) return ret;
+    int32_t version = NSVersionOfRunTimeLibrary(library);
+    if (-1 != version) {
+	ret.primaryVersion = version >> 16;
+	ret.secondaryVersion = (version >> 8) & 0xff;
+	ret.tertiaryVersion = version & 0xff;
+    }
+    return ret;
+}
+
+/*
+If
+   (vers != 0xFFFF): We know the version number of the library this app was linked against
+   and (versionInfo[version].VERSIONFIELD != 0xFFFF): And we know what version number started the specified release
+   and ((version == 0) || (versionInfo[version-1].VERSIONFIELD < versionInfo[version].VERSIONFIELD)): And it's distinct from the prev release
+Then
+   If the version the app is linked against is less than the version recorded for the specified release
+   Then stop checking and return false
+   Else stop checking and return YES
+Else
+   Continue checking (the next library)
+*/
+#define checkLibrary(LIBNAME, VERSIONFIELD) \
+    {uint16_t vers = (NSVersionOfLinkTimeLibrary(LIBNAME) >> 16); \
+     if ((vers != 0xFFFF) && (versionInfo[version].VERSIONFIELD != 0xFFFF) && ((version == 0) || (versionInfo[version-1].VERSIONFIELD < versionInfo[version].VERSIONFIELD))) return (results[version] = ((vers < versionInfo[version].VERSIONFIELD) ? false : true)); }
+
+CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version) {
+    // The numbers in the below table should be the numbers for any version of the framework in the release.
+    // When adding new entries to this table for a new build train, it's simplest to use the versions of the
+    // first new versions of projects submitted to the new train. These can later be updated. One thing to watch for is that software updates
+    // for the previous release do not increase numbers beyond the number used for the next release!
+    // For a given train, don't ever use the last versions submitted to the previous train! (This to assure room for software updates.)
+    // If versions are the same as previous release, use 0xFFFF; this will assure the answer is a conservative NO.
+    // NOTE: Also update the CFM check below, perhaps to the previous release... (???)
+    static const struct {
+        uint16_t libSystemVersion;
+        uint16_t cocoaVersion;
+        uint16_t appkitVersion;
+        uint16_t fouVersion;
+        uint16_t cfVersion;
+        uint16_t carbonVersion;
+        uint16_t applicationServicesVersion;
+        uint16_t coreServicesVersion;
+        uint16_t iokitVersion;
+    } versionInfo[] = {
+	{50, 5, 577, 397, 196, 113, 16, 9, 52},		/* CFSystemVersionCheetah (used the last versions) */
+	{55, 7, 620, 425, 226, 122, 16, 10, 67},	/* CFSystemVersionPuma (used the last versions) */
+        {56, 8, 631, 431, 232, 122, 17, 11, 73},	/* CFSystemVersionJaguar */
+        {67, 9, 704, 481, 281, 126, 19, 16, 159},	/* CFSystemVersionPanther */
+        {73, 10, 750, 505, 305, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF},	/* CFSystemVersionTiger */
+        {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF},	/* CFSystemVersionChablis */
+    };
+    static char results[CFSystemVersionMax] = {-2, -2, -2, -2, -2, -2};	/* We cache the results per-release; there are only a few of these... */
+    if (version >= CFSystemVersionMax) return false;	/* Actually, we don't know the answer, and something scary is going on */
+    if (results[version] != -2) return results[version];
+
+    if (_CFIsCFM()) {
+        results[version] = (version <= CFSystemVersionJaguar) ? true : false;
+        return results[version];
+    }
+    
+    checkLibrary("System", libSystemVersion);	// Pretty much everyone links with this
+    checkLibrary("Cocoa", cocoaVersion);
+    checkLibrary("AppKit", appkitVersion);
+    checkLibrary("Foundation", fouVersion);
+    checkLibrary("CoreFoundation", cfVersion);
+    checkLibrary("Carbon", carbonVersion);
+    checkLibrary("ApplicationServices", applicationServicesVersion);
+    checkLibrary("CoreServices", coreServicesVersion);
+    checkLibrary("IOKit", iokitVersion);
+
+    /* If not found, then simply return NO to indicate earlier --- compatibility by default, unfortunately */
+    return false;
+}
+#else
+CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version) {
+    return true;
+}
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+__private_extern__ void *__CFLookupCFNetworkFunction(const char *name) {
+    static void *image = NULL;
+    if (NULL == image) {
+	const char *path = NULL;
+	if (!issetugid()) {
+	    path = getenv("CFNETWORK_LIBRARY_PATH");
+	}
+	if (!path) {
+	    path = "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork";
+	}
+	image = dlopen(path, RTLD_LAZY | RTLD_LOCAL);
+    }
+    void *dyfunc = NULL;
+    if (image) {
+	dyfunc = dlsym(image, name);
+    }
+    return dyfunc;
+}
+#endif //__MACH__
+
+
+#ifndef __CFGetSessionID_defined
+
+__private_extern__ uint32_t __CFGetSessionID(void) {
+    return 0;
+}
+
+#endif
+
+const char *_CFPrintForDebugger(const void *obj) {
+	static char *result = NULL;
+	CFStringRef str;
+	CFIndex cnt = 0;
+
+	free(result);	// Let go of result from previous call.
+	result = NULL;
+	if (obj) {
+		if (CFGetTypeID(obj) == CFStringGetTypeID()) {
+			// Makes Ali marginally happier
+			str = __CFCopyFormattingDescription(obj, NULL);
+			if (!str) str = CFCopyDescription(obj);
+		} else {
+			str = CFCopyDescription(obj);
+		}
+	} else {
+		str = (CFStringRef)CFRetain(CFSTR("(null)"));
+	}
+	
+	if (str != NULL) {
+		CFStringGetBytes(str, CFRangeMake(0, CFStringGetLength(str)), kCFStringEncodingUTF8, 0, FALSE, NULL, 0, &cnt);
+	}
+	result = (char *) malloc(cnt + 2);	// 1 for '\0', 1 for an optional '\n'
+	if (str != NULL) {
+		CFStringGetBytes(str, CFRangeMake(0, CFStringGetLength(str)), kCFStringEncodingUTF8, 0, FALSE, (UInt8 *) result, cnt, &cnt);
+	}
+	result[cnt] = '\0';
+
+	if (str) CFRelease(str);
+	return result;
+}
+
+static void _CFShowToFile(FILE *file, Boolean flush, const void *obj) {
+     CFStringRef str;
+     CFIndex idx, cnt;
+     CFStringInlineBuffer buffer;
+     bool lastNL = false;
+
+     if (obj) {
+	if (CFGetTypeID(obj) == CFStringGetTypeID()) {
+	    // Makes Ali marginally happier
+	    str = __CFCopyFormattingDescription(obj, NULL);
+	    if (!str) str = CFCopyDescription(obj);
+	} else {
+	    str = CFCopyDescription(obj);
+	}
+     } else {
+	str = (CFStringRef)CFRetain(CFSTR("(null)"));
+     }
+     cnt = CFStringGetLength(str);
+
+     // iTunes used OutputDebugStringW(theString);
+
+     CFStringInitInlineBuffer(str, &buffer, CFRangeMake(0, cnt));
+#if DEPLOYMENT_TARGET_WINDOWS
+    TCHAR *accumulatedBuffer = (TCHAR *)malloc((cnt+1) * sizeof(TCHAR));
+#endif
+     for (idx = 0; idx < cnt; idx++) {
+         UniChar ch = __CFStringGetCharacterFromInlineBufferQuick(&buffer, idx);
+
+#if DEPLOYMENT_TARGET_MACOSX
+		 if (ch < 128) {
+             fprintf_l(file, NULL, "%c", ch);
+	     lastNL = (ch == '\n');
+         } else {
+             fprintf_l(file, NULL, "\\u%04x", ch);
+         }
+#elif DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+		 if (ch < 128) {
+             fprintf(file, "%c", ch);
+	     lastNL = (ch == '\n');
+         } else {
+             fprintf(file, "\\u%04x", ch);
+         }
+#endif
+     }
+     if (!lastNL) {
+#if DEPLOYMENT_TARGET_MACOSX
+         fprintf_l(file, NULL, "\n");
+#else
+		 fprintf(file, "\n");
+#endif
+         if (flush) fflush(file);
+     }
+
+     if (str) CFRelease(str);
+}
+
+void CFShow(const void *obj) {
+     _CFShowToFile(stderr, true, obj);
+}
+
+
+
+void CFLog(int32_t lev, CFStringRef format, ...) {
+    CFStringRef result;
+    va_list argList;
+    static CFSpinLock_t lock = CFSpinLockInit;
+
+    va_start(argList, format);
+    result = CFStringCreateWithFormatAndArguments(kCFAllocatorSystemDefault, NULL, format, argList);
+    va_end(argList);
+
+    __CFSpinLock(&lock); 
+    CFTimeZoneRef tz = CFTimeZoneCopySystem();	// specifically choose system time zone for logs
+    CFGregorianDate gdate = CFAbsoluteTimeGetGregorianDate(CFAbsoluteTimeGetCurrent(), tz);
+    CFRelease(tz);
+    gdate.second = gdate.second + 0.0005;
+    // Date format: YYYY '-' MM '-' DD ' ' hh ':' mm ':' ss.fff
+#if DEPLOYMENT_TARGET_WINDOWS
+    printf("%04d-%02d-%02d %02d:%02d:%06.3f %s[%d] CFLog (%d): ", (int)gdate.year, gdate.month, gdate.day, gdate.hour, gdate.minute, gdate.second, *_CFGetProgname(), getpid(), lev);
+#elif DEPLOYMENT_TARGET_LINUX
+	fprintf(stderr, "%04d-%02d-%02d %02d:%02d:%06.3f %s[%d:%x] CFLog: ", (int)gdate.year, gdate.month, gdate.day, gdate.hour, gdate.minute, gdate.second, *_CFGetProgname(), getpid(), (uintptr_t)pthread_self());
+#else
+    fprintf_l(stderr, NULL, "%04d-%02d-%02d %02d:%02d:%06.3f %s[%d:%x] CFLog: ", (int)gdate.year, gdate.month, gdate.day, gdate.hour, gdate.minute, gdate.second, *_CFGetProgname(), getpid(), pthread_mach_thread_np(pthread_self()));
+#endif
+    CFShow(result);
+
+    __CFSpinUnlock(&lock); 
+    CFRelease(result);
+}
+
+
diff --git a/CoreFoundation/CFVersion.c b/CoreFoundation/CFVersion.c
new file mode 100644
index 0000000..eba6031
--- /dev/null
+++ b/CoreFoundation/CFVersion.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+const unsigned char kCFCoreFoundationVersionString[] = "@(#)PROGRAM:CoreFoundation  PROJECT:CoreFoundation-476.17  SYSTEM:Darwin  DEVELOPER:unknown  BUILT:" __DATE__ " " __TIME__ "\n";
+const double kCFCoreFoundationVersionNumber = (double)476.17;
diff --git a/CoreFoundation/CFWindowsMessageQueue.c b/CoreFoundation/CFWindowsMessageQueue.c
new file mode 100644
index 0000000..d28f22b
--- /dev/null
+++ b/CoreFoundation/CFWindowsMessageQueue.c
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2008 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@
+ */
+/*	CFWindowsMessageQueue.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Christopher Kane
+*/
+
+#if DEPLOYMENT_TARGET_WINDOWS
+
+#include "CFWindowsMessageQueue.h"
+#include "CFInternal.h"
+
+extern DWORD __CFRunLoopGetWindowsMessageQueueMask(CFRunLoopRef rl, CFStringRef mode);
+extern void __CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef rl, DWORD mask, CFStringRef mode);
+
+struct __CFWindowsMessageQueue {
+    CFRuntimeBase _base;
+    CFAllocatorRef _allocator;
+    CFSpinLock_t _lock;
+    DWORD _mask;
+    CFRunLoopSourceRef _source;
+    CFMutableArrayRef _runLoops;
+};
+
+/* Bit 3 in the base reserved bits is used for invalid state */
+
+CF_INLINE Boolean __CFWindowsMessageQueueIsValid(CFWindowsMessageQueueRef wmq) {
+    return (Boolean)__CFBitfieldGetValue(((const CFRuntimeBase *)wmq)->_cfinfo[CF_INFO_BITS], 3, 3);
+}
+
+CF_INLINE void __CFWindowsMessageQueueSetValid(CFWindowsMessageQueueRef wmq) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)wmq)->_cfinfo[CF_INFO_BITS], 3, 3, 1);
+}
+
+CF_INLINE void __CFWindowsMessageQueueUnsetValid(CFWindowsMessageQueueRef wmq) {
+    __CFBitfieldSetValue(((CFRuntimeBase *)wmq)->_cfinfo[CF_INFO_BITS], 3, 3, 0);
+}
+
+CF_INLINE void __CFWindowsMessageQueueLock(CFWindowsMessageQueueRef wmq) {
+    __CFSpinLock(&(wmq->_lock));
+}
+
+CF_INLINE void __CFWindowsMessageQueueUnlock(CFWindowsMessageQueueRef wmq) {
+    __CFSpinUnlock(&(wmq->_lock));
+}
+
+static Boolean __CFWindowsMessageQueueEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    CFWindowsMessageQueueRef wmq1 = (CFWindowsMessageQueueRef)cf1;
+    CFWindowsMessageQueueRef wmq2 = (CFWindowsMessageQueueRef)cf2;
+    return (wmq1 == wmq2);
+}
+
+static CFHashCode __CFWindowsMessageQueueHash(CFTypeRef cf) {
+    CFWindowsMessageQueueRef wmq = (CFWindowsMessageQueueRef)cf;
+    return (CFHashCode)wmq;
+}
+
+static CFStringRef __CFWindowsMessageQueueCopyDescription(CFTypeRef cf) {
+/* Some commentary, possibly as out of date as much of the rest of the file was
+#warning CF: this and many other CopyDescription functions are probably
+#warning CF: broken, in that some of these fields being printed out can
+#warning CF: be NULL, when the object is in the invalid state
+*/
+    CFWindowsMessageQueueRef wmq = (CFWindowsMessageQueueRef)cf;
+    CFMutableStringRef result;
+    result = CFStringCreateMutable(CFGetAllocator(wmq), 0);
+    __CFWindowsMessageQueueLock(wmq);
+/* More commentary, which we don't really need to see with every build
+#warning CF: here, and probably everywhere with a per-instance lock,
+#warning CF: the locked state will always be true because we lock,
+#warning CF: and you cannot call description if the object is locked;
+#warning CF: probably should not lock description, and call it unsafe
+*/
+    CFStringAppendFormat(result, NULL, CFSTR("<CFWindowsMessageQueue %p [%p]>{locked = %s, valid = %s, mask = 0x%x,\n    run loops = %@}"), cf, CFGetAllocator(wmq), (wmq->_lock.LockCount ? "Yes" : "No"), (__CFWindowsMessageQueueIsValid(wmq) ? "Yes" : "No"), (UInt32)wmq->_mask, wmq->_runLoops);
+    __CFWindowsMessageQueueUnlock(wmq);
+    return result;
+}
+
+CFAllocatorRef __CFWindowsMessageQueueGetAllocator(CFTypeRef cf) {
+    CFWindowsMessageQueueRef wmq = (CFWindowsMessageQueueRef)cf;
+    return wmq->_allocator;
+}
+
+static void __CFWindowsMessageQueueDeallocate(CFTypeRef cf) {
+    CFWindowsMessageQueueRef wmq = (CFWindowsMessageQueueRef)cf;
+    CFAllocatorRef allocator = CFGetAllocator(wmq);
+    CFAllocatorDeallocate(allocator, wmq);
+    CFRelease(allocator);
+    DeleteCriticalSection(&(wmq->_lock));
+}
+
+static CFTypeID __kCFWindowsMessageQueueTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFWindowsMessageQueueClass = {
+    0,
+    "CFWindowsMessageQueue",
+    NULL,	// init
+    NULL,	// copy
+    __CFWindowsMessageQueueDeallocate,
+    __CFWindowsMessageQueueEqual,
+    __CFWindowsMessageQueueHash,
+    NULL,	//
+    __CFWindowsMessageQueueCopyDescription
+};
+
+__private_extern__ void __CFWindowsMessageQueueInitialize(void) {
+    __kCFWindowsMessageQueueTypeID = _CFRuntimeRegisterClass(&__CFWindowsMessageQueueClass);
+}
+
+CFTypeID CFWindowsMessageQueueGetTypeID(void) {
+    return __kCFWindowsMessageQueueTypeID;
+}
+
+CFWindowsMessageQueueRef CFWindowsMessageQueueCreate(CFAllocatorRef allocator, DWORD mask) {
+    CFWindowsMessageQueueRef memory;
+    UInt32 size = sizeof(struct __CFWindowsMessageQueue) - sizeof(CFRuntimeBase);
+    memory = (CFWindowsMessageQueueRef)_CFRuntimeCreateInstance(allocator, __kCFWindowsMessageQueueTypeID, size, NULL);
+    if (NULL == memory) {
+        return NULL;
+    }
+    __CFWindowsMessageQueueSetValid(memory);
+
+    CF_SPINLOCK_INIT_FOR_STRUCTS(memory->_lock);
+    memory->_mask = mask;   
+    memory->_source = NULL;
+    memory->_runLoops = CFArrayCreateMutable(allocator, 0, NULL);
+    return memory;
+}
+
+void CFWindowsMessageQueueInvalidate(CFWindowsMessageQueueRef wmq) {
+    __CFGenericValidateType(wmq, __kCFWindowsMessageQueueTypeID);
+    CFRetain(wmq);
+    __CFWindowsMessageQueueLock(wmq);
+    if (__CFWindowsMessageQueueIsValid(wmq)) {
+	SInt32 idx;
+	__CFWindowsMessageQueueUnsetValid(wmq);
+	for (idx = CFArrayGetCount(wmq->_runLoops); idx--;) {
+	    CFRunLoopWakeUp((CFRunLoopRef)CFArrayGetValueAtIndex(wmq->_runLoops, idx));
+	}
+	CFRelease(wmq->_runLoops);
+	wmq->_runLoops = NULL;
+	if (NULL != wmq->_source) {
+	    CFRunLoopSourceInvalidate(wmq->_source);
+	    CFRelease(wmq->_source);
+	    wmq->_source = NULL;
+	}
+    }
+    __CFWindowsMessageQueueUnlock(wmq);
+    CFRelease(wmq);
+}
+
+Boolean CFWindowsMessageQueueIsValid(CFWindowsMessageQueueRef wmq) {
+    __CFGenericValidateType(wmq, __kCFWindowsMessageQueueTypeID);
+    return __CFWindowsMessageQueueIsValid(wmq);
+}
+
+DWORD CFWindowsMessageQueueGetMask(CFWindowsMessageQueueRef wmq) {
+    __CFGenericValidateType(wmq, __kCFWindowsMessageQueueTypeID);
+    return wmq->_mask;
+}
+
+static void __CFWindowsMessageQueueSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) {
+    CFWindowsMessageQueueRef wmq = (CFWindowsMessageQueueRef)info;
+    __CFWindowsMessageQueueLock(wmq);
+    if (__CFWindowsMessageQueueIsValid(wmq)) {
+	uint32_t mask;
+	CFArrayAppendValue(wmq->_runLoops, rl);
+	mask = __CFRunLoopGetWindowsMessageQueueMask(rl, mode);
+	mask |= wmq->_mask;
+	__CFRunLoopSetWindowsMessageQueueMask(rl, mask, mode);
+    }
+    __CFWindowsMessageQueueUnlock(wmq);
+}
+
+static void __CFWindowsMessageQueueCancel(void *info, CFRunLoopRef rl, CFStringRef mode) {
+    CFWindowsMessageQueueRef wmq = (CFWindowsMessageQueueRef)info;
+    __CFWindowsMessageQueueLock(wmq);
+#if DEPLOYMENT_TARGET_WINDOWS
+//#warning CF: should fix up run loop modes mask here, if not done
+//#warning CF: previously by the invalidation, where it should also
+//#warning CF: be done
+#else
+#warning CF: should fix up run loop modes mask here, if not done
+#warning CF: previously by the invalidation, where it should also
+#warning CF: be done
+#endif //DEPLOYMENT_TARGET_WINDOWS
+    if (NULL != wmq->_runLoops) {
+	SInt32 idx = CFArrayGetFirstIndexOfValue(wmq->_runLoops, CFRangeMake(0, CFArrayGetCount(wmq->_runLoops)), rl);
+	if (0 <= idx) CFArrayRemoveValueAtIndex(wmq->_runLoops, idx);
+    }
+    __CFWindowsMessageQueueUnlock(wmq);
+}
+
+static void __CFWindowsMessageQueuePerform(void *info) {
+    CFWindowsMessageQueueRef wmq = (CFWindowsMessageQueueRef)info;
+    MSG msg;
+    __CFWindowsMessageQueueLock(wmq);
+    if (!__CFWindowsMessageQueueIsValid(wmq)) {
+	__CFWindowsMessageQueueUnlock(wmq);
+	return;
+    }
+    __CFWindowsMessageQueueUnlock(wmq);
+    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE | PM_NOYIELD)) {
+	TranslateMessage(&msg);
+	DispatchMessage(&msg);
+    }
+}
+
+CFRunLoopSourceRef CFWindowsMessageQueueCreateRunLoopSource(CFAllocatorRef allocator, CFWindowsMessageQueueRef wmq, CFIndex order) {
+    CFRunLoopSourceRef result = NULL;
+    __CFWindowsMessageQueueLock(wmq);
+    if (NULL == wmq->_source) {
+	CFRunLoopSourceContext context;
+	context.version = 0;
+	context.info = (void *)wmq;
+	context.retain = CFRetain;
+	context.release = CFRelease;
+	context.copyDescription = __CFWindowsMessageQueueCopyDescription;
+	context.equal = __CFWindowsMessageQueueEqual;
+	context.hash = __CFWindowsMessageQueueHash;
+	context.schedule = __CFWindowsMessageQueueSchedule;
+	context.cancel = __CFWindowsMessageQueueCancel;
+	context.perform = __CFWindowsMessageQueuePerform;
+	wmq->_source = CFRunLoopSourceCreate(allocator, order, &context);
+    }
+    CFRetain(wmq->_source);	/* This retain is for the receiver */
+    result = wmq->_source;
+    __CFWindowsMessageQueueUnlock(wmq);
+    return result;
+}
+
+#endif
+
diff --git a/CoreFoundation/CFWindowsMessageQueue.h b/CoreFoundation/CFWindowsMessageQueue.h
new file mode 100644
index 0000000..32af78e
--- /dev/null
+++ b/CoreFoundation/CFWindowsMessageQueue.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2008 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@
+ */
+/*	CFWindowsMessageQueue.h
+	Copyright (c) 1999-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFWINDOWSMESSAGEQUEUE__)
+#define __COREFOUNDATION_CFWINDOWSMESSAGEQUEUE__ 1
+
+#if DEPLOYMENT_TARGET_WINDOWS
+
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <windows.h>
+
+
+CF_EXTERN_C_BEGIN
+
+typedef struct __CFWindowsMessageQueue * CFWindowsMessageQueueRef;
+
+CF_EXPORT CFTypeID	CFWindowsMessageQueueGetTypeID(void);
+
+CF_EXPORT CFWindowsMessageQueueRef	CFWindowsMessageQueueCreate(CFAllocatorRef allocator, DWORD mask);
+
+CF_EXPORT DWORD   CFWindowsMessageQueueGetMask(CFWindowsMessageQueueRef wmq);
+CF_EXPORT void    CFWindowsMessageQueueInvalidate(CFWindowsMessageQueueRef wmq);
+CF_EXPORT Boolean CFWindowsMessageQueueIsValid(CFWindowsMessageQueueRef wmq);
+
+CF_EXPORT CFRunLoopSourceRef	CFWindowsMessageQueueCreateRunLoopSource(CFAllocatorRef allocator, CFWindowsMessageQueueRef wmq, CFIndex order);
+
+CF_EXTERN_C_END
+
+#endif /* DEPLOYMENT_TARGET_WINDOWS */
+
+#endif /* ! __COREFOUNDATION_CFWINDOWSMESSAGEQUEUE__ */
+
diff --git a/CoreFoundation/CFXMLInputStream.c b/CoreFoundation/CFXMLInputStream.c
new file mode 100644
index 0000000..c7210b7
--- /dev/null
+++ b/CoreFoundation/CFXMLInputStream.c
@@ -0,0 +1,742 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Chris Parker
+*/
+
+#include "CFXMLInputStream.h"
+#include <CoreFoundation/CFCharacterSet.h>
+#include <string.h>
+#include "CFStringEncodingConverter.h"
+#include "CFUniChar.h"
+
+/* Utility functions used in parsing */
+static Boolean determineEncoding(_CFXMLInputStream *stream) {
+    const uint8_t *bytes = (uint8_t *)CFDataGetBytePtr(stream->data);
+    UInt32 length = CFDataGetLength(stream->data);
+    const uint8_t *idx = 0L, *end = 0L;
+    const uint8_t *base = 0L;
+    char quote = ' ';
+    Boolean useUTF8 = false;
+    
+    // Check for the byte order mark first
+    if (length > 2) {
+        // This clause checks for the unicode byte order mark, or a Unicode sequence lacking the BOM; technically an error, but this check is recommended by the XML spec
+        if ((*bytes == 0xFF && *(bytes+1) == 0xFE) ||*(bytes+1) == 0x00) {
+#if __BIG_ENDIAN__
+            stream->flags |= ENCODING_IS_UNICODE_SWAPPED;
+#else
+            stream->flags |= ENCODING_IS_UNICODE_NATURAL;
+#endif
+            if (*bytes == 0xFF) {
+                stream->currentByte = bytes + 2;
+            }
+            stream->encoding = kCFStringEncodingUnicode;
+            return true;
+        } else if ((*bytes == 0xFE && *(bytes+1) == 0xFF) || *bytes == 0x00) {
+#if __BIG_ENDIAN__
+            stream->flags |= ENCODING_IS_UNICODE_NATURAL;
+#else
+            stream->flags |= ENCODING_IS_UNICODE_SWAPPED;
+#endif
+            if (*bytes == 0xFE) {
+                stream->currentByte = bytes + 2;
+            }
+            stream->encoding = kCFStringEncodingUnicode;
+            return true;
+        } else if(*bytes == 0xEF && *(bytes+1) == 0xBB && *(bytes+2) == 0xBF) {
+            if(*bytes == 0xEF) {
+                stream->currentByte = bytes + 3;
+            }
+            stream->encoding = kCFStringEncodingUTF8;
+            stream->flags |= ENCODING_MATCHES_ASCII;
+            return true;
+        }
+    }
+    // Scan for the <?xml.... ?> opening
+    if (length < 5 || strncmp((char const *) bytes, "<?xml", 5) != 0) {
+        useUTF8 = true;
+    }
+    if (!useUTF8) {
+        idx = bytes + 5;
+        end = bytes + length;
+        // Found "<?xml"; now we scan for "encoding"
+        while (idx < end) {
+            uint8_t ch = *idx;
+            const uint8_t *scan;
+            if ( ch == '?' || ch == '>') {
+                useUTF8 = true;
+                break;
+            }
+            idx ++;
+            scan = idx;
+            if (ch == 'e' && *scan++ == 'n' && *scan++ == 'c' && *scan++ == 'o' && *scan++ == 'd' && *scan++ == 'i' && *scan++ == 'n' && *scan++ == 'g' && *scan++ == '=') {
+                idx = scan;
+                break;
+            }
+        }
+        if (!useUTF8 && idx >= end) {
+            useUTF8 = true;
+        }
+    }
+    if (!useUTF8) {
+        // Found "encoding="; see if we've got an honest-to-goodness encoding name
+        quote = *idx;
+        if (quote != '\'' && quote != '\"') {
+            useUTF8 = true;
+        }
+    }
+    if (!useUTF8) {
+        base = idx + 1; // Move past the quote character
+        idx ++;
+        while (idx < end && *idx != quote) idx ++;
+        if (idx >= end) {
+            useUTF8 = true;
+        }
+    }
+    if (!useUTF8) {
+        UInt32 len = idx - base;
+        if (len == 5 && (*base == 'u' || *base == 'U') && (base[1] == 't' || base[1] == 'T') && (base[2] == 'f' || base[2] == 'F') && (base[3] == '-') && (base[4] == '8')) {
+            useUTF8 = true;
+        } else {
+            CFStringRef encodingName = CFStringCreateWithBytes(stream->allocator, base, len, kCFStringEncodingISOLatin1, false);
+            stream->encoding = CFStringConvertIANACharSetNameToEncoding(encodingName);
+            CFRelease(encodingName);
+        }
+    }
+    if (useUTF8) {
+        stream->encoding = kCFStringEncodingUTF8;
+        stream->flags |= ENCODING_MATCHES_ASCII;
+        return true;
+    } else if (stream->encoding == kCFStringEncodingInvalidId) {
+        return false;
+    } else if (__CFStringEncodingIsSupersetOfASCII(stream->encoding)) {
+        stream->flags |= ENCODING_MATCHES_ASCII;
+    }
+    return true;
+}
+
+CF_INLINE void _fillStringWithCharacters(CFMutableStringRef string, UniChar *characters, CFIndex numChars) {
+    CFStringDelete(string, CFRangeMake(0, CFStringGetLength(string)));
+    if (numChars) {
+        CFStringAppendCharacters(string, characters, numChars);
+    }
+}
+
+__private_extern__ Boolean _openInputStream(_CFXMLInputStream *stream) {
+    if (NULL == stream->data) {
+        return false;
+    } else {
+        stream->currentByte = CFDataGetBytePtr(stream->data);
+        if (determineEncoding(stream)) {
+            stream->flags |= STREAM_OPEN;
+            return true;
+        } else {
+            return false;
+        }
+    }
+}
+
+__private_extern__ void _initializeInputStream(_CFXMLInputStream *stream, CFAllocatorRef alloc, CFURLRef dataSource, CFDataRef xmlData) {
+    stream->data = xmlData ? (CFDataRef)CFRetain(xmlData) : NULL;
+    stream->url = dataSource ? (CFURLRef)CFRetain(dataSource) : NULL;
+    stream->encoding = kCFStringEncodingInvalidId;
+    stream->currentByte = NULL;
+    
+    stream->allocator = (CFAllocatorRef)CFRetain(alloc);
+    stream->charBuffer = NULL;
+    stream->currentChar = NULL;
+    stream->mark = NULL;
+    stream->parserMark = NULL;
+    stream->bufferLength = 0;
+    stream->bufferCapacity = 0;
+    
+    stream->charIndex = 1;
+    stream->lineNum = 1;
+
+    stream->flags = 0;
+    stream->nameSet = NULL;
+    stream->tempString = NULL;
+}
+
+
+__private_extern__ void _freeInputStream(_CFXMLInputStream *stream) {
+    if (stream->data) CFRelease(stream->data);
+    if (stream->url) CFRelease(stream->url);
+    if (stream->charBuffer) CFAllocatorDeallocate(stream->allocator, stream->charBuffer);
+    if (stream->nameSet) CFRelease(stream->nameSet);
+    if (stream->tempString) CFRelease(stream->tempString);
+    CFRelease(stream->allocator);
+}
+
+__private_extern__ CFStringEncoding _inputStreamGetEncoding(_CFXMLInputStream *stream) {
+    return stream->encoding;
+}
+
+__private_extern__ CFIndex _inputStreamCurrentLocation(_CFXMLInputStream *stream) {
+    return stream->charIndex;
+}
+
+__private_extern__ CFIndex _inputStreamCurrentLine(_CFXMLInputStream *stream) {
+    return stream->lineNum;
+}
+
+__private_extern__ Boolean _inputStreamAtEOF(_CFXMLInputStream *stream) {
+    if (!(stream->flags & STREAM_OPEN)) return false;
+    if (stream->currentChar) return false;
+    if (stream->currentByte - CFDataGetBytePtr(stream->data) < CFDataGetLength(stream->data)) return false;
+    return true;
+}
+
+__private_extern__ Boolean _inputStreamComposingErrorOccurred(_CFXMLInputStream *stream) {
+    return stream->flags & ENCODING_COMPOSITION_ERROR;
+}
+
+#define INITIAL_BUFFER_SIZE 64
+static void growCharacterBuffer(_CFXMLInputStream *stream) {
+    if (!stream->charBuffer) {
+        stream->charBuffer = (UniChar *)CFAllocatorAllocate(stream->allocator, INITIAL_BUFFER_SIZE*sizeof(UniChar), 0);
+        stream->bufferCapacity = INITIAL_BUFFER_SIZE;
+    } else {
+        CFIndex currCharDelta = stream->currentChar ? stream->currentChar - stream->charBuffer : -1;
+        CFIndex markDelta = stream->mark ? stream->mark - stream->charBuffer: -1;
+        CFIndex parserMarkDelta = stream->parserMark ? stream->parserMark - stream->charBuffer: -1;
+        UniChar *newBuffer = (UniChar *)CFAllocatorReallocate(stream->allocator, stream->charBuffer, stream->bufferCapacity * 2 * sizeof(UniChar), 0);
+        stream->bufferCapacity *= 2;
+        if (newBuffer != stream->charBuffer) {
+            stream->charBuffer = newBuffer;
+            if (currCharDelta != -1) {
+                stream->currentChar = newBuffer + currCharDelta;
+            }
+            if (markDelta != -1) {
+                stream->mark = newBuffer + markDelta;
+            }
+            if (parserMarkDelta != -1) {
+                stream->parserMark = newBuffer + parserMarkDelta;
+            }
+        }
+    }
+}
+
+static CFIndex loadCharacters(UniChar *base, CFIndex maxLength, _CFXMLInputStream *stream) {
+    const uint8_t *dataEnd = CFDataGetBytePtr(stream->data) + CFDataGetLength(stream->data);
+    if (stream->flags & (ENCODING_IS_UNICODE_NATURAL|ENCODING_IS_UNICODE_SWAPPED) ) {
+        CFIndex charsToTranslate = (dataEnd - stream->currentByte) / sizeof(UniChar);
+        if (charsToTranslate > maxLength) {
+            charsToTranslate = maxLength;
+        }
+        if (stream->flags & ENCODING_IS_UNICODE_NATURAL) {
+            memmove(base, stream->currentByte, charsToTranslate * sizeof(UniChar));
+            stream->currentByte += (charsToTranslate * sizeof(UniChar));
+        } else {
+            CFIndex i;
+            uint8_t *baseBytePtr = (uint8_t *)base;
+            for (i = 0; i < charsToTranslate; i ++) {
+                *(baseBytePtr + 1) = *stream->currentByte;
+                *baseBytePtr = *(stream->currentByte + 1);
+                baseBytePtr += 2;
+                stream->currentByte += 2;
+            }
+        }
+        return charsToTranslate;
+    } else {
+        CFIndex lengthConsumed = 0;
+        CFIndex usedByteLength, usedCharLength;
+        UInt32 conversionResult;
+        if (stream->flags & ENCODING_MATCHES_ASCII) {
+            while (stream->currentByte < dataEnd && lengthConsumed < maxLength) {
+                if (*stream->currentByte > 0x7f) break;
+                *base = *stream->currentByte;
+                base ++;
+                stream->currentByte ++;
+                lengthConsumed ++;
+            }
+            if (stream->currentByte == dataEnd || lengthConsumed == maxLength) {
+                return lengthConsumed;
+            }
+        }
+        conversionResult = CFStringEncodingBytesToUnicode(stream->encoding, 0, stream->currentByte, dataEnd - stream->currentByte, &usedByteLength, base, maxLength-lengthConsumed, &usedCharLength);
+        if(kCFStringEncodingConversionSuccess != conversionResult) {
+            switch(conversionResult) {
+                case kCFStringEncodingConverterUnavailable:
+                case kCFStringEncodingInvalidInputStream:
+                    stream->flags |= ENCODING_COMPOSITION_ERROR;
+                    break;
+                case kCFStringEncodingInsufficientOutputBufferLength:
+                default:
+                    break;
+            }
+        }
+        if (usedByteLength > 0) {
+            stream->currentByte += usedByteLength;
+            lengthConsumed += usedCharLength;
+        }
+        return lengthConsumed;
+    }
+}
+
+// returns number of characters filled
+CF_INLINE CFIndex fillToCapacity(_CFXMLInputStream *stream) {
+    CFIndex numFilled;
+    if (stream->bufferLength >= stream->bufferCapacity) return 0;
+    // Try and fill in the remaining characters
+    numFilled = loadCharacters(stream->charBuffer+stream->bufferLength, stream->bufferCapacity - stream->bufferLength, stream);
+    if (numFilled != 0) {
+        stream->currentChar = stream->charBuffer + stream->bufferLength;
+        stream->bufferLength += numFilled;
+    }
+    return numFilled;
+}
+
+// we are expected to move mark & parserMark relative to any moved characters, set currentChar to the first new character fetched, update bufferLength, and advance currentByte as appropriate.  Does not check for EOF; it is the caller's responsibility to verify this.
+static void fillCharacterBuffer(_CFXMLInputStream *stream) {
+    if (!stream->charBuffer) {
+        growCharacterBuffer(stream);
+    }
+    if (!stream->mark && !stream->parserMark) {
+        // This is the easy case; we can freely overwrite the buffer; if either mark or parserMark is set, we must not remove any characters from those marks and the end of the buffer
+        CFIndex fillLength = stream->bufferCapacity-5; // We leave a few characters at the end, b/c we don't want to reallocate (doubling the amount of memory used) just b/c we're matching a small string near the end of the filled buffer
+        stream->bufferLength = loadCharacters(stream->charBuffer, fillLength, stream);
+        CFAssert(stream->bufferLength != 0, __kCFLogAssertion, "CF internal error: XML parser input stream corruption");
+        stream->currentChar = stream->charBuffer;
+    } else {
+        // We do everything we can not to allocate; first we fill any remaining characters.  If that doesn't work, we try shifting the characters starting at the earlier of mark or parserMark to the beginning of buffer, then filling the newly-freed characters.
+        Boolean done;
+
+        // First try just filling the remaining capacity
+        done = (fillToCapacity(stream) != 0);
+        if (!done) {
+            const UniChar *leftMostMark;
+            if (stream->mark && !stream->parserMark) {
+                leftMostMark = stream->mark;
+            } else if (stream->parserMark && !stream->mark) {
+                leftMostMark = stream->parserMark;
+            } else if (stream->parserMark < stream->mark) {
+                leftMostMark = stream->parserMark;
+            } else {
+                leftMostMark = stream->mark;
+            }
+            if (leftMostMark > stream->charBuffer) {
+                CFIndex delta = leftMostMark - stream->charBuffer;
+                memmove(stream->charBuffer, leftMostMark, (stream->bufferLength - delta) * sizeof(UniChar));
+                stream->bufferLength -= delta;
+                if (stream->mark) {
+                    stream->mark -= delta;
+                }
+                if (stream->parserMark) {
+                    stream->parserMark -= delta;
+                }
+                // Now try to fill the newly-opened space
+                done = (fillToCapacity(stream) != 0);
+                delta = loadCharacters(stream->charBuffer + stream->bufferLength, stream->bufferCapacity - stream->bufferLength, stream);
+            }
+        }
+        if (!done) {
+            // No help for it; now we must allocate
+            growCharacterBuffer(stream);
+            fillToCapacity(stream); // If this doesn't work, we give up.
+        }
+    }
+}
+
+/* The guts of getCharacter() have been separated in order to allow getCharacter() to be small and more easily inline-able. Note that a check late in the 10.3 development cycle indicates that getCharacter() should call getCharacterGuts() less than 2% of the time.  (In 29000 calls, less than 400 called this. Note that a majority of calls have advanceStream set, so that was left in the inline version.  Also note that some calls to getCharacter() were changed to go through the functions _inputStreamGetCharacter() or _inputStreamPeekCharacter(), as the expansion in using the inline version didn't seem worthwhile. See 3275503 for some data supporting this.
+*/
+static Boolean getCharacterGuts(_CFXMLInputStream *stream, UniChar *ch, Boolean advanceStream) {
+    if (stream->currentByte - CFDataGetBytePtr(stream->data) >= CFDataGetLength(stream->data)) {
+        return false; // EOF
+    } else if (!((stream->mark || stream->parserMark) && advanceStream) &&
+               (((stream->flags & ENCODING_MATCHES_ASCII) && *(stream->currentByte) < 0x7F) ||
+                (stream->flags & (ENCODING_IS_UNICODE_NATURAL | ENCODING_IS_UNICODE_SWAPPED)))) {
+        // We can only perform optimizations if neither mark is set (if the mark is set, we must fill the character buffer so we can retrieve the characters later), and the encoding is Unicode, or the encoding matches ASCII and we're looking at a low-byte character.
+        if (stream->flags & ENCODING_MATCHES_ASCII) {
+            *ch = (UniChar)*(stream->currentByte);
+            if (advanceStream) {
+                stream->currentByte ++;
+            }
+        } else if (stream->flags & ENCODING_IS_UNICODE_NATURAL) {
+            *ch = *(UniChar *)(stream->currentByte);
+            if (advanceStream) {
+                stream->currentByte += 2;
+            }
+        } else {
+            // Unicode with swapped bytes
+            *ch = CFSwapInt16(*(UniChar *)(stream->currentByte));
+            if (advanceStream) {
+                stream->currentByte += 2;
+            }
+        }
+    } else {
+        fillCharacterBuffer(stream); // this takes into account markIsSet to make sure and do the right thing
+        if (!stream->charBuffer || !stream->currentChar) {
+            return false;
+        } else {
+            *ch = *(stream->currentChar);
+            if (advanceStream) {
+                stream->currentChar ++;
+                if (stream->currentChar == stream->charBuffer + stream->bufferLength) {
+                    stream->currentChar = NULL;
+                }
+            }
+        }
+    }
+    return true;
+}
+
+/* See comments above getCharacterGuts()
+*/
+CF_INLINE Boolean getCharacter(_CFXMLInputStream *stream, UniChar *ch, Boolean advanceStream) {
+    if (!(stream->flags & STREAM_OPEN)) {
+        return false;
+    } else if (stream->currentChar) {
+        *ch = *stream->currentChar;
+        if (advanceStream) {
+            stream->currentChar ++;
+            if (stream->currentChar == stream->charBuffer + stream->bufferLength) {
+                stream->currentChar = NULL;
+            }
+        }
+    } else {
+        if (!getCharacterGuts(stream, ch, advanceStream)) return false;
+    }
+    if (advanceStream) {
+        UniChar nextChar;
+        stream->charIndex ++;
+        if ((*ch == '\n') || ((*ch == '\r') && (!_inputStreamPeekCharacter(stream, &nextChar) || nextChar != '\n'))) stream->lineNum ++;
+    }
+    return true;
+}
+
+__private_extern__ Boolean _inputStreamPeekCharacter(_CFXMLInputStream *stream, UniChar *ch) {
+    return getCharacter(stream, ch, false);
+}
+
+__private_extern__ Boolean _inputStreamGetCharacter(_CFXMLInputStream *stream, UniChar *ch) {
+    return getCharacter(stream, ch, true);
+}
+
+__private_extern__ Boolean _inputStreamReturnCharacter(_CFXMLInputStream *stream, UniChar ch) {
+    Boolean decrementLineNum = false;
+    if (ch == '\n') {
+        decrementLineNum = true;
+    } else if (ch == '\r') {
+        UniChar nextChar;
+        if (!_inputStreamPeekCharacter(stream, &nextChar) || nextChar != '\n') {
+            decrementLineNum = true;
+        }
+    }
+
+    if (!(stream->flags & STREAM_OPEN)) {
+        return false;
+    } else if (stream->currentChar) {
+        if (stream->currentChar != stream->charBuffer) {
+            stream->currentChar --;
+        } else {
+            // Yuck; we're unlucky and are returning a character _before_ the first character in charBuffer
+            if (stream->bufferLength >= stream->bufferCapacity) {
+                growCharacterBuffer(stream);
+            }
+            memmove(stream->charBuffer + 1, stream->charBuffer, stream->bufferLength * sizeof(UniChar));
+            *stream->charBuffer = ch;
+            stream->bufferLength ++;
+            if (stream->mark) {
+                stream->mark ++;
+            }
+            if (stream->parserMark) {
+                stream->parserMark ++;
+            }
+        }
+    } else if ((stream->mark || stream->parserMark) && stream->bufferLength) {
+        // We've been collecting characters in charBuffer; the only reason stream->currentChar is NULL is that we've processed the last character thusfar translated from data.  That last character is the one being returned.
+        stream->currentChar = stream->charBuffer + stream->bufferLength - 1;
+    } else if (stream->charBuffer) {
+        // We have processed all the meaningful characters from charBuffer and have no reason to preserve them.  We use charBuffer to hold this one character that has been returned to us.
+        *stream->charBuffer = ch;
+        stream->currentChar = stream->charBuffer;
+        stream->bufferLength = 1;
+        if (stream->mark) {
+            stream->mark ++;
+        }
+        if (stream->parserMark) {
+            stream->parserMark ++;
+        } 
+    } else if (stream->currentByte > CFDataGetBytePtr(stream->data)) {
+        // We have no character buffer available, so that means one of two things - either we've never needed a character buffer because all the characters could come directly out of the byte stream, or we've not yet processed the first character.  The former means we can just back up the byte pointer; the latter means Bad Things have happened.
+        if (stream->flags & ENCODING_MATCHES_ASCII) {
+            stream->currentByte --;
+        } else {  // Must be Unicode
+            stream->currentByte -= 2;
+        }
+    } else {
+        return false;
+    }
+    stream->charIndex --;
+    if (decrementLineNum) {
+        stream->lineNum --;
+    }
+    return true;
+}
+
+// Returns the pointer to hold as the mark
+static UniChar *dropMark(_CFXMLInputStream *stream) {
+    if (stream->currentChar) {
+        return stream->currentChar;
+    } else if (stream->mark || stream->parserMark) {
+        return stream->charBuffer + stream->bufferLength;
+    } else {
+        if (!stream->charBuffer) {
+            growCharacterBuffer(stream);
+        }
+        stream->bufferLength = 0; // This will be sufficient to force a fetch into the buffer when the next character is requested
+        return stream->charBuffer;
+    }
+
+}
+
+__private_extern__ void _inputStreamSetMark(_CFXMLInputStream *stream) {
+    CFAssert(stream->mark == NULL, __kCFLogAssertion, "CF internal error: parser input stream malformed");
+    stream->mark = dropMark(stream);
+}
+
+__private_extern__ void _inputStreamClearMark(_CFXMLInputStream *stream) {
+    CFAssert(stream->mark != NULL, __kCFLogAssertion, "CF internal error: parser input stream malformed");
+    stream->mark = NULL;
+}
+
+__private_extern__ void _inputStreamGetCharactersFromMark(_CFXMLInputStream *stream, CFMutableStringRef string) {
+    UniChar *end = stream->currentChar ? stream->currentChar : stream->charBuffer + stream->bufferLength;
+    CFIndex numChars = end - stream->mark;
+    CFAssert(stream->mark, __kCFLogAssertion, "CF internal error: malformed XML input stream");
+    _fillStringWithCharacters(string, stream->mark, numChars);
+}
+
+static void restoreToMark(_CFXMLInputStream *stream, UniChar *mark) {
+    UniChar *end = stream->currentChar ? stream->currentChar : stream->charBuffer + stream->bufferLength;
+    if (end > mark) {
+        CFIndex numChars = end - mark;
+        stream->charIndex -= numChars;
+        stream->currentChar = mark;
+
+        // This is annoying; to keep the line count accurate, if the first character we are returning is a CR, we must decrement the line count iff the next character is NOT a LF
+        if (*(end - 1) == '\r') {
+            UniChar nextChar;
+            if (_inputStreamPeekCharacter(stream, &nextChar) && nextChar == '\n') {
+                end --;
+            }
+        }
+        while (end != mark) {
+            end --;
+            if (*end == '\r') {
+                stream->lineNum --;
+            } else if (*end == '\n') {
+                stream->lineNum --;
+                if (end != mark && *(end - 1) == '\r') {
+                    end --;
+                }
+            }
+        }
+    }
+}
+
+__private_extern__ void _inputStreamBackUpToMark(_CFXMLInputStream *stream) {
+    CFAssert(stream->mark != NULL || stream->charBuffer == NULL, __kCFLogAssertion, "CF internal error: malformed XML input stream");
+    restoreToMark(stream, stream->mark);
+}
+
+CF_INLINE Boolean isWhitespaceChar(UniChar ch) {
+    return (ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t');
+}
+
+__private_extern__ CFIndex _inputStreamSkipWhitespace(_CFXMLInputStream *stream, CFMutableStringRef str) {
+    UniChar ch;
+    CFIndex len = 0;
+    if (str) {
+        stream->parserMark = dropMark(stream);
+    }
+    while (getCharacter(stream, &ch, true) && isWhitespaceChar(ch)) {
+        len ++;
+    }
+    if (!isWhitespaceChar(ch)) {
+        _inputStreamReturnCharacter(stream, ch);
+    }
+    if (str) {
+        _fillStringWithCharacters(str, stream->parserMark, len);
+        stream->parserMark = NULL;
+    }
+    return len;
+}
+
+// false return means EOF was encountered without finding scanChars
+__private_extern__ Boolean _inputStreamScanToCharacters(_CFXMLInputStream *stream, const UniChar *scanChars, CFIndex numChars, CFMutableStringRef str) {
+    Boolean done = false;
+    CFIndex firstRepeatIndex = -1;
+    CFIndex len = 0;
+    stream->parserMark = dropMark(stream);
+    do {
+        UniChar ch;
+        while (_inputStreamGetCharacter(stream, &ch) && ch != scanChars[0]) {
+            len ++;
+        }
+        if (ch != scanChars[0]) {
+            restoreToMark(stream, stream->parserMark);
+            stream->parserMark = NULL;
+            return false;
+        } else {
+            CFIndex i;
+            for (i = 1; i < numChars; i ++) {
+                if (!_inputStreamGetCharacter(stream, &ch)) break;
+                if (ch != scanChars[i]) break;
+            }
+            if (i == numChars) {
+                done = true;
+            } else {
+                if (firstRepeatIndex == -1) {
+                    CFIndex j;
+                    for (j = 1; j < numChars; j ++) {
+                        if (scanChars[0] == scanChars[j]) {
+                            break;
+                        }
+                    }
+                    firstRepeatIndex = j;
+                }
+                _inputStreamReturnCharacter(stream, ch);
+                while (i > firstRepeatIndex) {
+                    i --;
+                    _inputStreamReturnCharacter(stream, scanChars[i]);
+                }
+                len += i;
+            }
+        }
+    } while (!done);
+    if (str) {
+        _fillStringWithCharacters(str, stream->parserMark, len);
+    }
+    stream->parserMark = NULL;
+    return true;
+}
+
+__private_extern__ Boolean _inputStreamMatchString(_CFXMLInputStream *stream, const UniChar *stringToMatch, CFIndex length) {
+    const UniChar *end = stringToMatch+length;
+    const UniChar *sPtr=stringToMatch;
+    stream->parserMark = dropMark(stream);
+    while (sPtr < end) {
+        UniChar ch;
+        if (!_inputStreamGetCharacter(stream, &ch)) break;
+        if (ch != *sPtr) break;
+        sPtr ++;
+    }
+    if (sPtr != end) {
+        restoreToMark(stream, stream->parserMark);
+        stream->parserMark = NULL;
+        return false;
+    } else {
+        stream->parserMark = NULL;
+        return true;
+    }
+}
+
+__private_extern__ Boolean _inputStreamScanQuotedString(_CFXMLInputStream *stream, CFMutableStringRef str) {
+    UniChar ch;
+    if (!_inputStreamPeekCharacter(stream, &ch)) return false;
+    if (ch != '\'' && ch != '\"')  return false;
+
+    _inputStreamGetCharacter(stream, &ch);
+    if (!_inputStreamScanToCharacters(stream, &ch, 1, str)) {
+        return false;
+    }
+    return true;
+}
+
+/*
+ [4]  NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
+ [5]  Name ::= (Letter | '_' | ':') (NameChar)*
+ [7]  Nmtoken ::= (NameChar)+
+ [84] Letter ::= BaseChar | Ideographic
+
+ We don't do this quite right; we rely on the Unicode charsets to do this analysis.  While
+ the productions in the XML spec are based on the Unicode character sets, the definitions
+ differ slightly to avoid those areas where the Unicode standard is still being resolved.
+ At any rate, I'd lay money that using the Unicode charsets, we will be more correct than
+ the vast majority of parsers out there.
+
+ Letter == kCFUniCharLetterCharacterSet
+ Digit == kCFUniCharDecimalDigitCharacterSet
+ CombiningChar == kCFUniCharNonBaseCharacterSet
+ Extender - complex, and not represented by a uniform character set.
+ */
+__private_extern__ Boolean _inputStreamScanXMLName(_CFXMLInputStream *stream, Boolean isNMToken, CFStringRef *str) {
+    UniChar ch;
+    Boolean success = true;
+    stream->parserMark = dropMark(stream);
+    if (!isNMToken) {
+        // Only difference between an NMToken and a Name is Names have a stricter condition on the first character
+        if (!getCharacter(stream, &ch, false)) {
+            success = false;
+        } else if (!CFUniCharIsMemberOf(ch, kCFUniCharLetterCharacterSet) && ch != '_' && ch != ':') {
+            success = false;
+        } else {
+            getCharacter(stream, &ch, true);
+        }
+    }
+    if (success) {
+        while (getCharacter(stream, &ch, true)) {
+            if (!CFUniCharIsMemberOf(ch, kCFUniCharLetterCharacterSet) && !CFUniCharIsMemberOf(ch, kCFUniCharDecimalDigitCharacterSet)  && ch != '.' && ch != '-' && ch != '_' && ch != ':' && !CFUniCharIsMemberOf(ch, kCFUniCharNonBaseCharacterSet)) {
+                _inputStreamReturnCharacter(stream, ch);
+                break;
+            }
+        }
+        if (NULL == stream->currentChar || stream->currentChar == stream->parserMark) {
+            success = false; // Must have processed at least one character
+        }
+    }
+    if (success) {
+        if (str) {
+            if (!stream->nameSet) {
+                stream->nameSet = CFSetCreateMutable(stream->allocator, 0, &kCFTypeSetCallBacks);
+                stream->tempString = CFStringCreateMutableWithExternalCharactersNoCopy(stream->allocator, NULL, 0, 0, kCFAllocatorNull);
+            }
+            CFStringSetExternalCharactersNoCopy(stream->tempString, stream->parserMark, stream->currentChar-stream->parserMark, stream->currentChar-stream->parserMark);
+            if (!CFSetGetValueIfPresent(stream->nameSet, stream->tempString, (const void **)str)) {
+                *str = (CFStringRef)CFStringCreateCopy(stream->allocator, stream->tempString);
+                CFSetAddValue(stream->nameSet, *str);
+                CFRelease(*str);
+            }
+        }
+    } else {
+        restoreToMark(stream, stream->parserMark);
+    }
+    stream->parserMark = NULL;
+    return success;
+}
+
+
diff --git a/CoreFoundation/CFXMLInputStream.h b/CoreFoundation/CFXMLInputStream.h
new file mode 100644
index 0000000..36cf350
--- /dev/null
+++ b/CoreFoundation/CFXMLInputStream.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFXMLINPUTSTREAM__)
+#define __COREFOUNDATION_CFXMLINPUTSTREAM__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include "CFInternal.h"
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFSet.h>
+#include <CoreFoundation/CFXMLNode.h>
+
+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/CoreFoundation/CFXMLNode.c b/CoreFoundation/CFXMLNode.c
new file mode 100644
index 0000000..faa3b75
--- /dev/null
+++ b/CoreFoundation/CFXMLNode.c
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Chris Parker
+*/
+
+#include <CoreFoundation/CFXMLNode.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include "CFInternal.h"
+#include "CFXMLInputStream.h"
+
+CF_INLINE Boolean _nullSafeCFEqual(CFTypeRef cf1, CFTypeRef cf2) {
+    if (cf1 && !cf2) return false;
+    if (cf2 && !cf1) return false;
+    if (cf1) return CFEqual(cf1, cf2);
+    return true;
+}
+
+static Boolean externalIDEqual(CFXMLExternalID *ext1, CFXMLExternalID *ext2) {
+    return _nullSafeCFEqual(ext1->systemID, ext2->systemID) && _nullSafeCFEqual(ext1->publicID, ext2->publicID);
+}
+
+static Boolean __CFXMLNodeEqual(CFTypeRef  cf1, CFTypeRef  cf2) {
+    CFXMLNodeRef desc1 = (CFXMLNodeRef)cf1, desc2 = (CFXMLNodeRef)cf2;
+    if (desc1 == desc2) return true;
+    if (!desc1 || !desc2) return false;
+    if (desc1->dataTypeID != desc2->dataTypeID) return false;
+    if ((desc1->dataString && !desc2->dataString) || (!desc1->dataString && desc2->dataString)) return false;
+    if (desc1->dataString && !CFEqual(desc1->dataString, desc2->dataString)) return false;
+    if ((desc1->additionalData && !desc2->additionalData) || (!desc1->additionalData && desc2->additionalData)) return false;
+    if (!desc1->additionalData) return true;
+    switch (desc1->dataTypeID) {
+        case kCFXMLNodeTypeDocument:{
+            CFURLRef url1, url2;
+            url1 = ((CFXMLDocumentInfo *)desc1->additionalData)->sourceURL;
+            url2 = ((CFXMLDocumentInfo *)desc2->additionalData)->sourceURL;
+            return _nullSafeCFEqual(url1, url2);
+        }
+        case kCFXMLNodeTypeElement: {
+            CFXMLElementInfo *elt1, *elt2;
+            elt1 = (CFXMLElementInfo *)desc1->additionalData;
+            elt2 = (CFXMLElementInfo *)desc2->additionalData;
+            if (elt1->isEmpty != elt2->isEmpty) return false;
+            if (elt1->attributes == elt2->attributes) return true;
+            if (!elt1->attributes) return (CFDictionaryGetCount(elt2->attributes) == 0);
+            if (!elt2->attributes) return (CFDictionaryGetCount(elt1->attributes) == 0);
+            return CFEqual(elt1->attributes, elt2->attributes);
+        }
+        case kCFXMLNodeTypeProcessingInstruction: {
+            CFStringRef str1, str2;
+            str1 = ((CFXMLProcessingInstructionInfo *)desc1->additionalData)->dataString;
+            str2 = ((CFXMLProcessingInstructionInfo *)desc2->additionalData)->dataString;
+            return _nullSafeCFEqual(str1, str2);
+        }
+        case kCFXMLNodeTypeEntity: {
+            CFXMLEntityInfo *data1, *data2;
+            data1 = (CFXMLEntityInfo *)desc1->additionalData;
+            data2 = (CFXMLEntityInfo *)desc2->additionalData;
+            if (data1->entityType != data2->entityType) return false;
+            if (!_nullSafeCFEqual(data1->replacementText, data2->replacementText)) return false;
+            if (!_nullSafeCFEqual(data1->notationName, data2->notationName)) return false;
+            return externalIDEqual(&data1->entityID, &data2->entityID);
+        }
+        case kCFXMLNodeTypeEntityReference: {
+            return ((CFXMLEntityReferenceInfo *)(desc1->additionalData))->entityType == ((CFXMLEntityReferenceInfo *)(desc2->additionalData))->entityType;
+        }
+        case kCFXMLNodeTypeNotation: {
+            CFXMLNotationInfo *data1, *data2;
+            data1 = (CFXMLNotationInfo *)desc1->additionalData;
+            data2 = (CFXMLNotationInfo *)desc2->additionalData;
+            return externalIDEqual(&(data1->externalID), &(data2->externalID));
+        }
+        case kCFXMLNodeTypeDocumentType: {
+            CFXMLDocumentTypeInfo *data1, *data2;
+            data1 = (CFXMLDocumentTypeInfo *)desc1->additionalData;
+            data2 = (CFXMLDocumentTypeInfo *)desc2->additionalData;
+            return externalIDEqual(&(data1->externalID), &(data2->externalID));
+        }
+        case kCFXMLNodeTypeElementTypeDeclaration: {
+            CFXMLElementTypeDeclarationInfo *d1 = (CFXMLElementTypeDeclarationInfo *)desc1->additionalData;
+            CFXMLElementTypeDeclarationInfo *d2 = (CFXMLElementTypeDeclarationInfo *)desc2->additionalData;
+            return _nullSafeCFEqual(d1->contentDescription, d2->contentDescription);
+        }
+        case kCFXMLNodeTypeAttributeListDeclaration: {
+            CFXMLAttributeListDeclarationInfo *attList1 = (CFXMLAttributeListDeclarationInfo *)desc1->additionalData;
+            CFXMLAttributeListDeclarationInfo *attList2 = (CFXMLAttributeListDeclarationInfo *)desc2->additionalData;
+            CFIndex idx;
+            if (attList1->numberOfAttributes != attList2->numberOfAttributes) return false;
+            for (idx = 0; idx < attList1->numberOfAttributes; idx ++) {
+                CFXMLAttributeDeclarationInfo *attr1 = &(attList1->attributes[idx]);
+                CFXMLAttributeDeclarationInfo *attr2 = &(attList2->attributes[idx]);
+                if (!_nullSafeCFEqual(attr1->attributeName, attr2->attributeName)) return false;
+                if (!_nullSafeCFEqual(attr1->typeString, attr2->typeString)) return false;
+                if (!_nullSafeCFEqual(attr1->defaultString, attr2->defaultString)) return false;
+            }
+            return true;
+        }
+        default:
+            return false;
+    }
+    return true;
+}
+
+static CFHashCode __CFXMLNodeHash(CFTypeRef  cf) {
+    CFXMLNodeRef node = (CFXMLNodeRef)cf;
+    if (node->dataString) {
+        return CFHash(node->dataString);
+    }
+    if (node->dataTypeID == kCFXMLNodeTypeDocument) {
+        CFURLRef url = ((CFXMLDocumentInfo *)node->additionalData)->sourceURL;
+        return url ? CFHash(url) : (CFHashCode)cf;
+    } else {
+        CFAssert2(false, __kCFLogAssertion, "%s(): Saw unexpected XML type code %d", __PRETTY_FUNCTION__, node->dataTypeID);
+        return (CFHashCode)cf;
+    }
+}
+
+static CFStringRef __CFXMLNodeCopyDescription(CFTypeRef  cf) {
+    struct __CFXMLNode *node = (struct __CFXMLNode *)cf;
+    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("CFXMLNode %p>{typeID = %d, string = %@}"), cf, node->dataTypeID, node->dataString);
+}
+
+static void __CFXMLNodeDeallocate(CFTypeRef  cf) {
+    struct __CFXMLNode *node = (struct __CFXMLNode *)cf;
+    if (node->dataString) CFRelease(node->dataString);
+    if (node->additionalData) {
+        switch (node->dataTypeID) {
+            case kCFXMLNodeTypeDocument:
+                if (((CFXMLDocumentInfo *)node->additionalData)->sourceURL) {
+                    CFRelease(((CFXMLDocumentInfo *)node->additionalData)->sourceURL);
+                }
+                break;
+            case kCFXMLNodeTypeElement:
+                if (((CFXMLElementInfo *)node->additionalData)->attributes) {
+                    CFRelease(((CFXMLElementInfo *)node->additionalData)->attributes);
+                    CFRelease(((CFXMLElementInfo *)node->additionalData)->attributeOrder);
+                }
+                break;
+            case kCFXMLNodeTypeProcessingInstruction:
+                if (((CFXMLProcessingInstructionInfo *)node->additionalData)->dataString) {
+                    CFRelease(((CFXMLProcessingInstructionInfo *)node->additionalData)->dataString);
+                }
+                break;
+            case kCFXMLNodeTypeEntity:
+            {
+                CFXMLEntityInfo *data = (CFXMLEntityInfo *)node->additionalData;
+                if (data->replacementText) CFRelease(data->replacementText);
+                if (data->entityID.systemID) CFRelease(data->entityID.systemID);
+                if (data->entityID.publicID) CFRelease(data->entityID.publicID);
+                if (data->notationName) CFRelease(data->notationName);
+                break;
+            }
+            case kCFXMLNodeTypeEntityReference:
+            {
+                // Do nothing; additionalData has no structure of its own, with dependent pieces to release.  -- REW, 2/11/2000
+                break;
+            }
+            case kCFXMLNodeTypeDocumentType:
+            case kCFXMLNodeTypeNotation:
+                // We get away with this because CFXMLNotationInfo and CFXMLDocumentTypeInfo have identical formats
+            {
+                CFXMLNotationInfo *data = (CFXMLNotationInfo *)node->additionalData;
+                if (data->externalID.systemID) CFRelease(data->externalID.systemID);
+                if (data->externalID.publicID) CFRelease(data->externalID.publicID);
+                break;
+            }
+            case kCFXMLNodeTypeElementTypeDeclaration:
+                if (((CFXMLElementTypeDeclarationInfo *)node->additionalData)->contentDescription) {
+                    CFRelease(((CFXMLElementTypeDeclarationInfo *)node->additionalData)->contentDescription);
+                }
+                break;
+            case kCFXMLNodeTypeAttributeListDeclaration:
+            {
+                CFXMLAttributeListDeclarationInfo *data = (CFXMLAttributeListDeclarationInfo *)node->additionalData;
+                CFIndex idx;
+                for (idx = 0; idx < data->numberOfAttributes; idx ++) {
+                    CFRelease(data->attributes[idx].attributeName);
+                    CFRelease(data->attributes[idx].typeString);
+                    CFRelease(data->attributes[idx].defaultString);
+                }
+                CFAllocatorDeallocate(CFGetAllocator(node), data->attributes);
+                break;
+            }
+            default:
+                CFAssert1(false, __kCFLogAssertion, "%s(): Encountered unexpected typeID %d (additionalData should be empty)", node->dataTypeID);
+        }
+    }
+}
+
+static CFTypeID __kCFXMLNodeTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFXMLNodeClass = {
+    0,
+    "CFXMLNode",
+    NULL,      // init
+    NULL,      // copy
+    __CFXMLNodeDeallocate,
+    __CFXMLNodeEqual,
+    __CFXMLNodeHash,
+    NULL,      // 
+    __CFXMLNodeCopyDescription
+};
+
+static void __CFXMLNodeInitialize(void) {
+    __kCFXMLNodeTypeID = _CFRuntimeRegisterClass(&__CFXMLNodeClass);
+}
+
+CFTypeID CFXMLNodeGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFXMLNodeTypeID) __CFXMLNodeInitialize();
+    return __kCFXMLNodeTypeID;
+}
+
+CFXMLNodeRef CFXMLNodeCreateCopy(CFAllocatorRef alloc, CFXMLNodeRef origNode) {
+    return CFXMLNodeCreate(alloc, origNode->dataTypeID, origNode->dataString, origNode->additionalData, origNode->version);
+}
+
+static void _copyAddlDataForType(CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, const void *src, void *dest) {
+    switch(xmlType) {
+        case kCFXMLNodeTypeDocument: {
+            CFXMLDocumentInfo *srcData = (CFXMLDocumentInfo *)src;
+            CFXMLDocumentInfo *destData = (CFXMLDocumentInfo *)dest;
+            destData->sourceURL = srcData->sourceURL ? (CFURLRef)CFRetain(srcData->sourceURL) : NULL;
+            destData->encoding = srcData->encoding;
+            break;
+        }
+        case kCFXMLNodeTypeElement: {
+            CFXMLElementInfo *srcData = (CFXMLElementInfo *)src;
+            CFXMLElementInfo *destData = (CFXMLElementInfo *)dest;
+            if (srcData->attributes && CFDictionaryGetCount(srcData->attributes) != 0) {
+                destData->attributes =  (CFDictionaryRef)CFPropertyListCreateDeepCopy(alloc, srcData->attributes, kCFPropertyListImmutable);
+                destData->attributeOrder = (CFArrayRef)CFPropertyListCreateDeepCopy(alloc, srcData->attributeOrder, kCFPropertyListImmutable);
+            } else {
+                destData->attributes = NULL;
+                destData->attributeOrder = NULL;
+            }
+            destData->isEmpty = srcData->isEmpty;
+            break;
+        }
+        case kCFXMLNodeTypeProcessingInstruction: {
+            CFXMLProcessingInstructionInfo *srcData = (CFXMLProcessingInstructionInfo *)src;
+            CFXMLProcessingInstructionInfo *destData = (CFXMLProcessingInstructionInfo *)dest;
+            destData->dataString = srcData->dataString ? (CFStringRef)CFStringCreateCopy(alloc, srcData->dataString) : NULL;
+            break;
+        }
+        case kCFXMLNodeTypeEntity:
+        {
+            CFXMLEntityInfo *sourceData = (CFXMLEntityInfo *)src;
+            CFXMLEntityInfo *destData = (CFXMLEntityInfo *)dest;
+            destData->entityType = sourceData->entityType;
+            destData->replacementText = sourceData->replacementText ? (CFStringRef)CFStringCreateCopy(alloc, sourceData->replacementText) : NULL;
+            destData->entityID.systemID = sourceData->entityID.systemID ? (CFURLRef)CFRetain(sourceData->entityID.systemID) : NULL;
+            destData->entityID.publicID = sourceData->entityID.publicID ? (CFStringRef)CFStringCreateCopy(alloc, sourceData->entityID.publicID) : NULL;
+            destData->notationName = sourceData->notationName ? (CFStringRef)CFStringCreateCopy(alloc, sourceData->notationName) : NULL;
+            break;
+        }
+        case kCFXMLNodeTypeEntityReference:
+        {
+            CFXMLEntityReferenceInfo *srcData = (CFXMLEntityReferenceInfo *)src;
+            CFXMLEntityReferenceInfo *destData = (CFXMLEntityReferenceInfo *)dest;
+            destData->entityType = srcData->entityType;
+            break;
+        }
+        case kCFXMLNodeTypeDocumentType:
+        case kCFXMLNodeTypeNotation:
+        {
+            // We can get away with this because the structures of CFXMLNotationInfo and CFXMLDocumentTypeInfo match.  -- REW, 3/8/2000
+            CFXMLNotationInfo *srcData = (CFXMLNotationInfo *)src;
+            CFXMLNotationInfo *destData = (CFXMLNotationInfo *)dest;
+            destData->externalID.systemID = srcData->externalID.systemID ? (CFURLRef)CFRetain(srcData->externalID.systemID) : NULL;
+            destData->externalID.publicID = srcData->externalID.publicID ? (CFStringRef)CFStringCreateCopy(alloc, srcData->externalID.publicID) : NULL;
+            break;
+        }
+        case kCFXMLNodeTypeElementTypeDeclaration: {
+            CFXMLElementTypeDeclarationInfo *srcData = (CFXMLElementTypeDeclarationInfo *)src;
+            CFXMLElementTypeDeclarationInfo *destData = (CFXMLElementTypeDeclarationInfo *)dest;
+            destData->contentDescription = srcData->contentDescription ? (CFStringRef)CFStringCreateCopy(alloc, srcData->contentDescription) : NULL;
+            break;
+        }
+        case kCFXMLNodeTypeAttributeListDeclaration:
+        {
+            CFXMLAttributeListDeclarationInfo *sourceData = (CFXMLAttributeListDeclarationInfo *)src;
+            CFXMLAttributeListDeclarationInfo *destData = (CFXMLAttributeListDeclarationInfo *)dest;
+            CFIndex idx;
+            destData->numberOfAttributes = sourceData->numberOfAttributes;
+            destData->attributes = sourceData->numberOfAttributes ? (CFXMLAttributeDeclarationInfo *)CFAllocatorAllocate(alloc, sizeof(CFXMLAttributeDeclarationInfo)*sourceData->numberOfAttributes, 0) : NULL;
+            for (idx = 0; idx < sourceData->numberOfAttributes; idx ++) {
+                CFXMLAttributeDeclarationInfo sourceAttr = sourceData->attributes[idx];
+                CFXMLAttributeDeclarationInfo *destAttr = &(destData->attributes[idx]);
+                destAttr->attributeName = (CFStringRef)CFStringCreateCopy(alloc, sourceAttr.attributeName);
+                destAttr->typeString = (CFStringRef)CFStringCreateCopy(alloc, sourceAttr.typeString);
+                destAttr->defaultString = (CFStringRef)CFStringCreateCopy(alloc, sourceAttr.defaultString);
+            }
+            break;
+        }
+        default:
+            CFAssert2(false, __kCFLogAssertion, "%s(): Encountered unexpected typeID %d (additionalData should be empty)", __PRETTY_FUNCTION__, xmlType);
+    }
+}
+
+// Designated initializer; all node creation (except the wonky one created by the parser) should happen here.
+CFXMLNodeRef CFXMLNodeCreate(CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, CFStringRef dataString, const void *additionalData, CFIndex version) {
+    struct __CFXMLNode *node;
+    UInt32 extraSize;
+    // Add assertions checking xmlType against the presence/absence of additionalData & dataString
+    switch (xmlType) {
+        case kCFXMLNodeTypeDocument: extraSize = sizeof(CFXMLDocumentInfo); break;
+        case kCFXMLNodeTypeElement: extraSize = sizeof(CFXMLElementInfo); break;
+        case kCFXMLNodeTypeProcessingInstruction: extraSize = sizeof(CFXMLProcessingInstructionInfo); break;
+        case kCFXMLNodeTypeEntity: extraSize = sizeof(CFXMLEntityInfo); break;
+        case kCFXMLNodeTypeEntityReference: extraSize = sizeof(CFXMLEntityReferenceInfo); break;
+        case kCFXMLNodeTypeDocumentType: extraSize = sizeof(CFXMLDocumentTypeInfo); break;
+        case kCFXMLNodeTypeNotation: extraSize = sizeof(CFXMLNotationInfo); break;
+        case kCFXMLNodeTypeElementTypeDeclaration: extraSize = sizeof(CFXMLElementTypeDeclarationInfo); break;
+        case kCFXMLNodeTypeAttributeListDeclaration: extraSize = sizeof(CFXMLAttributeListDeclarationInfo); break;
+        default: extraSize = 0;
+    }
+
+    node = (struct __CFXMLNode *)_CFRuntimeCreateInstance(alloc, CFXMLNodeGetTypeID(), sizeof(struct __CFXMLNode) + extraSize - sizeof(CFRuntimeBase), NULL);
+    if (node) {
+        alloc = CFGetAllocator(node);
+        node->version = version;
+        node->dataTypeID = xmlType;
+        node->dataString = dataString ? (CFStringRef)CFStringCreateCopy(alloc, dataString) : NULL;
+        if (extraSize != 0) {
+            node->additionalData = (void *)((uint8_t *)node + sizeof(struct __CFXMLNode));
+            _copyAddlDataForType(alloc, xmlType, additionalData, node->additionalData);
+        } else {
+            node->additionalData = NULL;
+        }
+    }
+    return node;
+}
+
+CFXMLNodeTypeCode CFXMLNodeGetTypeCode(CFXMLNodeRef node) {
+    return node->dataTypeID;
+}
+
+CFStringRef CFXMLNodeGetString(CFXMLNodeRef node) {
+    return node->dataString;
+}
+
+const void *CFXMLNodeGetInfoPtr(CFXMLNodeRef node) {
+    return node->additionalData;
+}
+
+CFIndex CFXMLNodeGetVersion(CFXMLNodeRef node) {
+    return node->version;
+}
+
+
diff --git a/CoreFoundation/CFXMLNode.h b/CoreFoundation/CFXMLNode.h
new file mode 100644
index 0000000..0c90149
--- /dev/null
+++ b/CoreFoundation/CFXMLNode.h
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFXMLNODE__)
+#define __COREFOUNDATION_CFXMLNODE__ 1
+
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFTree.h>
+#include <CoreFoundation/CFURL.h>
+
+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.*/
+enum {
+    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 CFIndex CFXMLNodeTypeCode;
+
+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;
+
+enum {
+    kCFXMLEntityTypeParameter,       /* Implies parsed, internal */
+    kCFXMLEntityTypeParsedInternal,
+    kCFXMLEntityTypeParsedExternal,
+    kCFXMLEntityTypeUnparsed,
+    kCFXMLEntityTypeCharacter
+};
+typedef CFIndex CFXMLEntityTypeCode;
+
+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             <currently unused>                   CFXMLDocumentInfo *
+ kCFXMLNodeTypeElement              tag name                             CFXMLElementInfo *
+ kCFXMLNodeTypeAttribute            <currently unused>                   <currently unused>
+ 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     <currently unused>                   <currently unused>
+ 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);
+
+/* 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);
+
+/* Creates a copy of origNode (which may not be NULL). */
+CF_EXPORT
+CFXMLNodeRef CFXMLNodeCreateCopy(CFAllocatorRef alloc, CFXMLNodeRef origNode);
+
+CF_EXPORT
+CFXMLNodeTypeCode CFXMLNodeGetTypeCode(CFXMLNodeRef node);
+
+CF_EXPORT
+CFStringRef CFXMLNodeGetString(CFXMLNodeRef node);
+
+CF_EXPORT
+const void *CFXMLNodeGetInfoPtr(CFXMLNodeRef node);
+
+CF_EXPORT
+CFIndex CFXMLNodeGetVersion(CFXMLNodeRef node);
+
+/* CFXMLTreeRef */
+
+/* Creates a childless, parentless tree from node */
+CF_EXPORT
+CFXMLTreeRef CFXMLTreeCreateWithNode(CFAllocatorRef allocator, CFXMLNodeRef node);
+
+/* Extracts and returns the node stored in xmlTree */
+CF_EXPORT
+CFXMLNodeRef CFXMLTreeGetNode(CFXMLTreeRef xmlTree);
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFXMLNODE__ */
+
diff --git a/CoreFoundation/CFXMLParser.c b/CoreFoundation/CFXMLParser.c
new file mode 100644
index 0000000..59b1071
--- /dev/null
+++ b/CoreFoundation/CFXMLParser.c
@@ -0,0 +1,2070 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Chris Parker
+*/
+
+#include <CoreFoundation/CFXMLParser.h>
+#include <CoreFoundation/CFNumber.h>
+#include "CFXMLInputStream.h"
+#include "CFUniChar.h" 
+#include "CFInternal.h"
+
+struct __CFXMLParser {
+    CFRuntimeBase _cfBase;
+
+    _CFXMLInputStream input;
+    
+    void **stack;
+    void **top;
+    UInt32 capacity;
+
+    struct __CFXMLNode *node;  // Our private node; we use it to report back information
+    CFMutableDictionaryRef argDict;
+    CFMutableArrayRef argArray;
+
+    UInt32 options;
+    CFXMLParserCallBacks callBacks;
+    CFXMLParserContext context;
+
+    CFXMLParserStatusCode status;
+    CFStringRef errorString;
+};
+
+static CFStringRef __CFXMLParserCopyDescription(CFTypeRef cf) {
+    const struct __CFXMLParser *parser = (const struct __CFXMLParser *)cf;
+    return CFStringCreateWithFormat(CFGetAllocator(cf), NULL, CFSTR("<CFXMLParser %p>"), parser);
+}
+
+static void __CFXMLParserDeallocate(CFTypeRef cf) {
+    struct __CFXMLParser *parser = (struct __CFXMLParser *)cf;
+    CFAllocatorRef alloc = CFGetAllocator(parser);
+    _freeInputStream(&(parser->input));
+    if (parser->argDict) CFRelease(parser->argDict);
+    if (parser->argArray) CFRelease(parser->argArray);
+    if (parser->errorString) CFRelease(parser->errorString);
+    if (parser->node) CFRelease(parser->node);
+    CFAllocatorDeallocate(alloc, parser->stack);
+    if (parser->context.info && parser->context.release) {
+        parser->context.release(parser->context.info);
+    }
+}
+
+static CFTypeID __kCFXMLParserTypeID = _kCFRuntimeNotATypeID;
+
+static const CFRuntimeClass __CFXMLParserClass = {
+    0,
+    "CFXMLParser",
+    NULL,      // init
+    NULL,      // copy
+    __CFXMLParserDeallocate,
+    NULL,
+    NULL,
+    NULL,      // 
+    __CFXMLParserCopyDescription
+};
+
+static void __CFXMLParserInitialize(void) {
+    __kCFXMLParserTypeID = _CFRuntimeRegisterClass(&__CFXMLParserClass);
+}
+
+CFTypeID CFXMLParserGetTypeID(void) {
+    if (_kCFRuntimeNotATypeID == __kCFXMLParserTypeID) __CFXMLParserInitialize();
+    return __kCFXMLParserTypeID;
+}
+
+void CFXMLParserGetContext(CFXMLParserRef parser, CFXMLParserContext *context) {
+    CFAssert1(parser != NULL, __kCFLogAssertion, "%s(): NULL parser not permitted", __PRETTY_FUNCTION__);
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    if (context) {
+	context->version = parser->context.version;
+	context->info = parser->context.info;
+	context->retain = parser->context.retain;
+	context->release = parser->context.release;
+	context->copyDescription = parser->context.copyDescription;
+	UNFAULT_CALLBACK(context->retain);
+	UNFAULT_CALLBACK(context->release);
+	UNFAULT_CALLBACK(context->copyDescription);
+    }
+}
+
+void CFXMLParserGetCallBacks(CFXMLParserRef parser, CFXMLParserCallBacks *callBacks) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    if (callBacks) {
+        callBacks->version = parser->callBacks.version;
+        callBacks->createXMLStructure = parser->callBacks.createXMLStructure;
+        callBacks->addChild = parser->callBacks.addChild;
+        callBacks->endXMLStructure = parser->callBacks.endXMLStructure;
+        callBacks->resolveExternalEntity = parser->callBacks.resolveExternalEntity;
+        callBacks->handleError = parser->callBacks.handleError;
+	UNFAULT_CALLBACK(callBacks->createXMLStructure);
+	UNFAULT_CALLBACK(callBacks->addChild);
+	UNFAULT_CALLBACK(callBacks->endXMLStructure);
+	UNFAULT_CALLBACK(callBacks->resolveExternalEntity);
+	UNFAULT_CALLBACK(callBacks->handleError);
+    }
+}
+
+CFURLRef CFXMLParserGetSourceURL(CFXMLParserRef parser) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    return parser->input.url;
+}
+
+/* Returns the character index or line number of the current parse location */
+CFIndex CFXMLParserGetLocation(CFXMLParserRef parser) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    return _inputStreamCurrentLocation(&parser->input);
+}
+
+CFIndex CFXMLParserGetLineNumber(CFXMLParserRef parser) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    return _inputStreamCurrentLine(&parser->input);
+}
+
+/* Returns the top-most object returned by the createXMLStructure callback */
+void *CFXMLParserGetDocument(CFXMLParserRef parser) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    if (parser->capacity > 0)
+        return parser->stack[0];
+    else
+        return NULL;
+}
+
+CFXMLParserStatusCode CFXMLParserGetStatusCode(CFXMLParserRef parser) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    return parser->status;
+}
+
+CFStringRef CFXMLParserCopyErrorDescription(CFXMLParserRef parser) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    return (CFStringRef)CFRetain(parser->errorString);
+}
+
+void CFXMLParserAbort(CFXMLParserRef parser, CFXMLParserStatusCode errorCode, CFStringRef errorDescription) {
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    CFAssert1(errorCode > 0, __kCFLogAssertion, "%s(): errorCode must be greater than zero", __PRETTY_FUNCTION__);
+    CFAssert1(errorDescription != NULL, __kCFLogAssertion, "%s(): errorDescription may not be NULL", __PRETTY_FUNCTION__);
+    __CFGenericValidateType(errorDescription, CFStringGetTypeID());
+
+    parser->status = errorCode;
+    if (parser->errorString) CFRelease(parser->errorString);
+    parser->errorString = (CFStringRef)CFStringCreateCopy(kCFAllocatorSystemDefault, errorDescription);
+}
+
+
+static Boolean parseXML(CFXMLParserRef parser);
+static Boolean parseComment(CFXMLParserRef parser, Boolean report);
+static Boolean parseProcessingInstruction(CFXMLParserRef parser, Boolean report);
+static Boolean parseInlineDTD(CFXMLParserRef parser);
+static Boolean parseDTD(CFXMLParserRef parser);
+static Boolean parsePhysicalEntityReference(CFXMLParserRef parser);
+static Boolean parseCDSect(CFXMLParserRef parser);
+static Boolean parseEntityReference(CFXMLParserRef parser, Boolean report);
+static Boolean parsePCData(CFXMLParserRef parser);
+static Boolean parseWhitespace(CFXMLParserRef parser);
+static Boolean parseAttributeListDeclaration(CFXMLParserRef parser);
+static Boolean parseNotationDeclaration(CFXMLParserRef parser);
+static Boolean parseElementDeclaration(CFXMLParserRef parser);
+static Boolean parseEntityDeclaration(CFXMLParserRef parser);
+static Boolean parseExternalID(CFXMLParserRef parser, Boolean alsoAcceptPublicID, CFXMLExternalID *extID);
+static Boolean parseCloseTag(CFXMLParserRef parser, CFStringRef tag);
+static Boolean parseTagContent(CFXMLParserRef parser);
+static Boolean parseTag(CFXMLParserRef parser);
+static Boolean parseAttributes(CFXMLParserRef parser);
+static Boolean parseAttributeValue(CFXMLParserRef parser, CFMutableStringRef str);
+
+// Utilities; may need to make these accessible to the property list parser to avoid code duplication
+static void _CFReportError(CFXMLParserRef parser, CFXMLParserStatusCode errNum, const char *str);
+static Boolean reportNewLeaf(CFXMLParserRef parser); // Assumes parser->node has been set and is ready to go
+static void pushXMLNode(CFXMLParserRef parser, void *node);
+
+static CFXMLParserRef __CFXMLParserInit(CFAllocatorRef alloc, CFURLRef dataSource, CFOptionFlags options, CFDataRef xmlData, CFIndex version, CFXMLParserCallBacks *callBacks, CFXMLParserContext *context) {
+    struct __CFXMLParser *parser = (struct __CFXMLParser *)_CFRuntimeCreateInstance(alloc, CFXMLParserGetTypeID(), sizeof(struct __CFXMLParser) - sizeof(CFRuntimeBase), NULL);
+    struct __CFXMLNode *node = (struct __CFXMLNode *)_CFRuntimeCreateInstance(alloc, CFXMLNodeGetTypeID(), sizeof(struct __CFXMLNode) - sizeof(CFRuntimeBase), NULL);
+    UniChar *buf;
+    if (parser && node) {
+        alloc = CFGetAllocator(parser);
+        _initializeInputStream(&(parser->input), alloc, dataSource, xmlData);
+        parser->top = parser->stack;
+        parser->stack = NULL;
+        parser->capacity = 0;
+
+        buf = (UniChar *)CFAllocatorAllocate(alloc, 128*sizeof(UniChar), 0);
+        parser->node = node;
+        parser->node->dataString = CFStringCreateMutableWithExternalCharactersNoCopy(alloc, buf, 0, 128, alloc);
+        parser->node->additionalData = NULL;
+        parser->node->version = version;
+        parser->argDict = NULL; // don't create these until necessary
+        parser->argArray = NULL;
+
+        parser->options = options;
+        parser->callBacks = *callBacks;
+
+        FAULT_CALLBACK((void **)&(parser->callBacks.createXMLStructure));
+        FAULT_CALLBACK((void **)&(parser->callBacks.addChild));
+        FAULT_CALLBACK((void **)&(parser->callBacks.endXMLStructure));
+        FAULT_CALLBACK((void **)&(parser->callBacks.resolveExternalEntity));
+        FAULT_CALLBACK((void **)&(parser->callBacks.handleError));
+        
+        if (context) {
+            parser->context = *context;
+            if (parser->context.info && parser->context.retain) {
+                parser->context.retain(parser->context.info);
+            }
+        } else {
+            parser->context.version = 0;
+            parser->context.info = NULL;
+            parser->context.retain = NULL;
+            parser->context.release = NULL;
+            parser->context.copyDescription = NULL;
+        }
+        parser->status = kCFXMLStatusParseNotBegun;
+        parser->errorString = NULL;
+    } else {
+        if (parser) CFRelease(parser);
+        if (node) CFRelease(node);
+        parser = NULL;
+    }
+    return parser;
+}
+
+CFXMLParserRef CFXMLParserCreate(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFXMLParserCallBacks *callBacks, CFXMLParserContext *context) {
+    CFAssert1(xmlData != NULL, __kCFLogAssertion, "%s(): NULL data not permitted", __PRETTY_FUNCTION__);
+    __CFGenericValidateType(xmlData, CFDataGetTypeID());
+    CFAssert1(dataSource == NULL || CFGetTypeID(dataSource) == CFURLGetTypeID(), __kCFLogAssertion, "%s(): dataSource is not a valid CFURL", __PRETTY_FUNCTION__);
+    CFAssert1(callBacks != NULL && callBacks->createXMLStructure != NULL && callBacks->addChild != NULL && callBacks->endXMLStructure != NULL, __kCFLogAssertion, "%s(): callbacks createXMLStructure, addChild, and endXMLStructure must all be non-NULL", __PRETTY_FUNCTION__);
+    CFAssert2(versionOfNodes <= 1, __kCFLogAssertion, "%s(): version number %d is higher than supported by CFXMLParser", __PRETTY_FUNCTION__, versionOfNodes);
+    CFAssert1(versionOfNodes != 0, __kCFLogAssertion, "%s(): version number 0 is no longer supported by CFXMLParser", __PRETTY_FUNCTION__);
+    return __CFXMLParserInit(allocator, dataSource, parseOptions, xmlData, versionOfNodes, callBacks, context);
+}
+
+CFXMLParserRef CFXMLParserCreateWithDataFromURL(CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFXMLParserCallBacks *callBacks, CFXMLParserContext *context) {
+    CFAssert1(dataSource == NULL || CFGetTypeID(dataSource) == CFURLGetTypeID(), __kCFLogAssertion, "%s(): dataSource is not a valid CFURL", __PRETTY_FUNCTION__);
+    CFAssert1(callBacks != NULL && callBacks->createXMLStructure != NULL && callBacks->addChild != NULL && callBacks->endXMLStructure != NULL, __kCFLogAssertion, "%s(): callbacks createXMLStructure, addChild, and endXMLStructure must all be non-NULL", __PRETTY_FUNCTION__);
+    CFAssert2(versionOfNodes <= 1, __kCFLogAssertion, "%s(): version number %d is higher than supported by CFXMLParser", __PRETTY_FUNCTION__, versionOfNodes);
+    CFAssert1(versionOfNodes != 0, __kCFLogAssertion, "%s(): version number 0 is no longer supported by CFXMLParser", __PRETTY_FUNCTION__);
+
+    return __CFXMLParserInit(allocator, dataSource, parseOptions, NULL, versionOfNodes, callBacks, context);
+}
+
+Boolean CFXMLParserParse(CFXMLParserRef parser) {
+    CFXMLDocumentInfo docData;
+    __CFGenericValidateType(parser, CFXMLParserGetTypeID());
+    if (parser->status != kCFXMLStatusParseNotBegun) return false;
+    parser->status = kCFXMLStatusParseInProgress;
+
+    if (!_openInputStream(&parser->input)) {
+        if (!parser->input.data) {
+            // couldn't load URL
+            parser->status = kCFXMLErrorNoData;
+            parser->errorString = CFStringCreateWithFormat(CFGetAllocator(parser), NULL, CFSTR("No data found at %@"), CFURLGetString(parser->input.url));
+        } else {
+            // couldn't figure out the encoding
+            CFAssert(parser->input.encoding == kCFStringEncodingInvalidId, __kCFLogAssertion, "CFXMLParser internal error: input stream could not be opened");
+            parser->status = kCFXMLErrorUnknownEncoding;
+            parser->errorString = CFStringCreateWithCString(CFGetAllocator(parser), "Encountered unknown encoding", kCFStringEncodingASCII);
+        }
+        if (parser->callBacks.handleError) {
+            INVOKE_CALLBACK3(parser->callBacks.handleError, parser, parser->status, parser->context.info);
+        }
+        return false;
+    }
+    
+    // Create the document
+    parser->stack = (void **)CFAllocatorAllocate(CFGetAllocator(parser), 16 * sizeof(void *), 0);
+    parser->capacity = 16;
+    parser->node->dataTypeID = kCFXMLNodeTypeDocument;
+    docData.encoding = _inputStreamGetEncoding(&parser->input);
+    docData.sourceURL = parser->input.url;
+    parser->node->additionalData = &docData;
+    parser->stack[0] = (void *)INVOKE_CALLBACK3(parser->callBacks.createXMLStructure, parser, parser->node, parser->context.info);
+    parser->top = parser->stack;
+    parser->node->additionalData = NULL;
+
+    // Client may have called CFXMLParserAbort() during any callback, so we must always check to see if we have an error status after a callback
+    if (parser->status != kCFXMLStatusParseInProgress) {
+        _CFReportError(parser, parser->status, NULL);
+        return false;
+    }
+    return parseXML(parser);
+}
+
+/* The next several functions are all intended to parse past a particular XML structure.  They expect parser->curr to be set to the first content character of their structure (e.g. parseXMLComment expects parser->curr to be set just past "<!--").  They parse to the end of their structure, calling any necessary callbacks along the way, and advancing parser->curr as they go.  They either return void (not possible for the parse to fail) or they return a Boolean (success/failure).  The calling routines are expected to catch returned Booleans and fail immediately if false is returned. */
+
+// [3]  S ::= (#x20 | #x9 | #xD | #xA)+ 
+static Boolean parseWhitespace(CFXMLParserRef parser) {
+    CFIndex len;
+    Boolean report = !(parser->options & kCFXMLParserSkipWhitespace);
+    len = _inputStreamSkipWhitespace(&parser->input, report ? (CFMutableStringRef)(parser->node->dataString) : NULL);
+    if (report && len) {
+        parser->node->dataTypeID = kCFXMLNodeTypeWhitespace;
+        parser->node->additionalData = NULL;
+        return reportNewLeaf(parser);
+    } else {
+        return true;
+    }
+}
+
+// parser should be just past "<!--"
+static Boolean parseComment(CFXMLParserRef parser, Boolean report) {
+    const UniChar dashes[2] = {'-', '-'};
+    UniChar ch;
+    report = report && (!(parser->options & kCFXMLParserSkipMetaData));
+    if (!_inputStreamScanToCharacters(&parser->input, dashes, 2, report ? (CFMutableStringRef)(parser->node->dataString) : NULL) || !_inputStreamGetCharacter(&parser->input, &ch)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF,"Found unexpected EOF while parsing comment");
+        return false;
+    } else if (ch != '>') {
+        _CFReportError(parser, kCFXMLErrorMalformedComment, "Found \"--\" within a comment");
+        return false;
+    } else if (report) {
+        parser->node->dataTypeID = kCFXMLNodeTypeComment;
+        parser->node->additionalData = NULL;
+        return reportNewLeaf(parser);
+    } else {
+        return true;
+    }
+}
+
+/* 
+[16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
+[17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
+ */
+// parser should be set to the first character after "<?"
+static Boolean parseProcessingInstruction(CFXMLParserRef parser, Boolean report) {
+    const UniChar piTermination[2] = {'?', '>'};
+    CFMutableStringRef str;
+    CFStringRef name;
+    
+    if (!_inputStreamScanXMLName(&parser->input, false, &name)) {
+        _CFReportError(parser, kCFXMLErrorMalformedProcessingInstruction, "Found malformed processing instruction");
+        return false;
+    }
+    _inputStreamSkipWhitespace(&parser->input, NULL);
+    str = (report && *parser->top) ? CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser)) : NULL;
+    if (!_inputStreamScanToCharacters(&parser->input, piTermination, 2, str)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing processing instruction");
+        if (str) CFRelease(str);
+        return false;
+    }
+
+    if (str) {
+        CFXMLProcessingInstructionInfo data;
+        Boolean result;
+        CFStringRef tmp = parser->node->dataString;
+        parser->node->dataTypeID = kCFXMLNodeTypeProcessingInstruction;
+        parser->node->dataString = name;
+        data.dataString = str;
+        parser->node->additionalData = &data;
+        result = reportNewLeaf(parser);
+        parser->node->additionalData = NULL;
+        parser->node->dataString = tmp;
+        CFRelease(str);
+        return result;
+    } else {
+        return true;
+    }
+}
+
+/*
+ [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
+*/
+static const UniChar _DoctypeOpening[7] = {'D', 'O', 'C', 'T', 'Y', 'P', 'E'};
+// first character should be immediately after the "<!"
+static Boolean parseDTD(CFXMLParserRef parser) {
+    UniChar ch;
+    Boolean success, hasExtID = false;
+    CFXMLDocumentTypeInfo docData = {{NULL, NULL}};
+    void *dtdStructure = NULL;
+    CFStringRef name;
+    
+    // First pass "DOCTYPE"
+    success = _inputStreamMatchString(&parser->input, _DoctypeOpening, 7);
+    success = success && _inputStreamSkipWhitespace(&parser->input, NULL) != 0;
+    success = success && _inputStreamScanXMLName(&parser->input, false, &name);
+    if (success) {
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        success = _inputStreamPeekCharacter(&parser->input, &ch);
+    } else {
+        // didn't make it past "DOCTYPE" successfully.
+        _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found malformed DTD");
+        return false;
+    }
+    if (success && ch != '[' && ch != '>') {
+        // ExternalID
+        hasExtID = true;
+        success = parseExternalID(parser, false, &(docData.externalID));
+        if (success)  {
+            _inputStreamSkipWhitespace(&parser->input, NULL);
+            success = _inputStreamPeekCharacter(&parser->input, &ch);
+        }
+    }
+
+    if (!(parser->options & kCFXMLParserSkipMetaData) && *(parser->top)) {
+        CFStringRef tmp = parser->node->dataString;
+        parser->node->dataTypeID = kCFXMLNodeTypeDocumentType;
+        parser->node->dataString = name;
+        parser->node->additionalData = &docData;
+        dtdStructure = (void *)INVOKE_CALLBACK3(parser->callBacks.createXMLStructure, parser, parser->node, parser->context.info);
+        if (dtdStructure && parser->status == kCFXMLStatusParseInProgress) {
+            INVOKE_CALLBACK4(parser->callBacks.addChild, parser, *parser->top, dtdStructure, parser->context.info);
+        }
+        parser->node->additionalData = NULL;
+        parser->node->dataString = tmp;
+        if (parser->status != kCFXMLStatusParseInProgress) {
+            // callback called CFXMLParserAbort()
+            _CFReportError(parser, parser->status, NULL);
+            return false;
+        }
+    } else {
+        dtdStructure = NULL;
+    }
+    if (docData.externalID.publicID) CFRelease(docData.externalID.publicID);
+    if (docData.externalID.systemID) CFRelease(docData.externalID.systemID);
+    pushXMLNode(parser, dtdStructure);
+
+    if (success && ch == '[')  {
+        // inline DTD
+        _inputStreamGetCharacter(&parser->input, &ch);
+        if (!parseInlineDTD(parser)) return false;
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        success = _inputStreamGetCharacter(&parser->input, &ch) && ch == '>';
+    } else if (success && ch == '>') {
+        // End of the DTD
+        _inputStreamGetCharacter(&parser->input, &ch);
+    }
+    if (!success) {
+        if (_inputStreamAtEOF(&parser->input)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing DTD");
+        } else {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found malformed DTD");
+        }
+        return false;
+    }
+
+    parser->top --; // Remove dtdStructure from the stack
+
+    if (success && dtdStructure) {
+        INVOKE_CALLBACK3(parser->callBacks.endXMLStructure, parser, dtdStructure, parser->context.info);
+        if (parser->status != kCFXMLStatusParseInProgress) {
+            _CFReportError(parser, parser->status, NULL);
+            return false;
+        }
+    }
+    return true;
+}
+
+/*
+ [69] PEReference ::= '%' Name ';'
+*/
+static Boolean parsePhysicalEntityReference(CFXMLParserRef parser) {
+    UniChar ch;
+    CFStringRef name;
+    if (!_inputStreamScanXMLName(&parser->input, false, &name)) {
+        _CFReportError(parser, kCFXMLErrorMalformedName, "Found malformed name while parsing physical entity reference");
+        return false;
+    } else if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing physical entity reference");
+        return false;
+    } else if (ch != ';') {
+        _CFReportError(parser, kCFXMLErrorMalformedName, "Found malformed name while parsing physical entity reference");
+        return false;
+    } else if (!(parser->options & kCFXMLParserSkipMetaData) && *(parser->top)) {
+        CFXMLEntityReferenceInfo myData;
+        Boolean result;
+        CFStringRef tmp = parser->node->dataString;
+        parser->node->dataTypeID = kCFXMLNodeTypeEntityReference;
+        parser->node->dataString = name;
+        myData.entityType = kCFXMLEntityTypeParameter;
+        parser->node->additionalData = &myData;
+        result = reportNewLeaf(parser);
+        parser->node->additionalData = NULL;
+        parser->node->dataString = tmp;
+        return result;
+    } else {
+        return true;
+    }
+}
+
+/*
+ [54] AttType ::= StringType | TokenizedType | EnumeratedType
+ [55] StringType ::= 'CDATA'
+ [56] TokenizedType ::= 'ID' | 'IDREF'| 'IDREFS'| 'ENTITY'| 'ENTITIES'| 'NMTOKEN'| 'NMTOKENS'
+ [57] EnumeratedType ::= NotationType | Enumeration
+ [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
+ [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
+*/
+static Boolean parseEnumeration(CFXMLParserRef parser, Boolean useNMTokens) {
+    UniChar ch;
+    Boolean done = false;
+    if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+        return false;
+    } else if (ch != '(') {
+        _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+        return false;
+    }
+    _inputStreamSkipWhitespace(&parser->input, NULL);
+    if (!_inputStreamScanXMLName(&parser->input, useNMTokens, NULL)) {
+        _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+        return false;
+    }
+    while (!done) {
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+            return false;
+        } else if (ch == ')') {
+            done = true;
+        } else if (ch == '|') {
+            _inputStreamSkipWhitespace(&parser->input, NULL);
+            if (!_inputStreamScanXMLName(&parser->input, useNMTokens, NULL)) {
+                _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+                return false;
+            }
+        } else {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+            return false;
+        }
+    }
+    return true;
+}
+
+static Boolean parseAttributeType(CFXMLParserRef parser, CFMutableStringRef str) {
+    Boolean success = false;
+    static const UniChar attTypeStrings[6][8] = {
+    {'C', 'D', 'A', 'T', 'A', '\0', '\0', '\0'},
+    {'I', 'D', 'R', 'E', 'F', 'S', '\0', '\0'},
+    {'E', 'N', 'T', 'I', 'T', 'Y', '\0', '\0'},
+    {'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S'},
+    {'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S'},
+    {'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N'} };
+    if (str) _inputStreamSetMark(&parser->input);
+    if (_inputStreamMatchString(&parser->input, attTypeStrings[0], 5) ||
+        _inputStreamMatchString(&parser->input, attTypeStrings[1], 6) ||
+        _inputStreamMatchString(&parser->input, attTypeStrings[1], 5) ||
+        _inputStreamMatchString(&parser->input, attTypeStrings[1], 2) ||
+        _inputStreamMatchString(&parser->input, attTypeStrings[2], 6) ||
+        _inputStreamMatchString(&parser->input, attTypeStrings[3], 8) ||
+        _inputStreamMatchString(&parser->input, attTypeStrings[4], 8) ||
+        _inputStreamMatchString(&parser->input, attTypeStrings[4], 7)) {
+        success = true;
+    } else if (_inputStreamMatchString(&parser->input, attTypeStrings[5], 8)) {
+        // Notation
+        if (_inputStreamSkipWhitespace(&parser->input, NULL) == 0) {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+            success = false;
+        } else  {
+            success = parseEnumeration(parser, false);
+        }
+    } else {
+        success = parseEnumeration(parser, true);
+    }
+    if (str) {
+        if (success) {
+            _inputStreamGetCharactersFromMark(&parser->input, str);
+        }
+        _inputStreamClearMark(&parser->input);
+    }
+    return success;
+}
+
+/*  [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue) */
+static Boolean parseAttributeDefaultDeclaration(CFXMLParserRef parser, CFMutableStringRef str) {
+    const UniChar strings[3][8] = {
+    {'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D'},
+    {'I', 'M', 'P', 'L', 'I', 'E', 'D', '\0'},
+    {'F', 'I', 'X', 'E', 'D', '\0', '\0', '\0'}};
+    UniChar ch;
+    Boolean success;
+    if (str) _inputStreamSetMark(&parser->input);
+    if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+        success = false;
+    } else if (ch == '#') {
+        if (_inputStreamMatchString(&parser->input, strings[0], 8) ||
+            _inputStreamMatchString(&parser->input, strings[1], 7)) {
+            success = true;
+        } else if (!_inputStreamMatchString(&parser->input, strings[2], 5) || _inputStreamSkipWhitespace(&parser->input, NULL) == 0) {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+            success = false;
+        } else {
+            // we fall through if "#FIXED" was matched, and at least one whitespace character was stripped.
+            success = parseAttributeValue(parser, NULL);
+        }
+    } else {
+        _inputStreamReturnCharacter(&parser->input, ch);
+        success = parseAttributeValue(parser, NULL);
+    }
+    if (str) {
+        if (success) {
+            _inputStreamGetCharactersFromMark(&parser->input, str);
+        }
+        _inputStreamClearMark(&parser->input);
+    }
+    return success;
+}
+
+/*
+ [52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
+ [53] AttDef ::= S Name S AttType S DefaultDecl
+*/
+static Boolean parseAttributeListDeclaration(CFXMLParserRef parser) {
+    const UniChar attList[7] = {'A', 'T', 'T', 'L', 'I', 'S', 'T'};
+    CFXMLAttributeListDeclarationInfo attListData;
+    CFXMLAttributeDeclarationInfo attributeArray[8], *attributes=attributeArray;
+    CFIndex capacity = 8;
+    UniChar ch;
+    Boolean success = true;
+    CFStringRef name;
+    if (!_inputStreamMatchString(&parser->input, attList, 7) ||
+        _inputStreamSkipWhitespace(&parser->input, NULL) == 0 ||
+        !_inputStreamScanXMLName(&parser->input, false, &name)) {
+        _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+        return false;
+    }
+    attListData.numberOfAttributes = 0;
+    if (!(*parser->top) || (parser->options & kCFXMLParserSkipMetaData)) {
+        // Use this to mark that we don't need to collect attribute information to report to the client.  Ultimately, we may want to collect this for our own use (for validation, for instance), but for now, the only reason we would create it would be for the client.  -- REW, 2/9/2000
+        attributes = NULL;
+    }
+    while (_inputStreamPeekCharacter(&parser->input, &ch) && ch != '>' && _inputStreamSkipWhitespace(&parser->input, NULL) != 0) {
+        CFXMLAttributeDeclarationInfo *attribute = NULL;
+        if (_inputStreamPeekCharacter(&parser->input, &ch) && ch == '>')
+            break;
+        if (attributes) {
+            if (capacity == attListData.numberOfAttributes) {
+                capacity = 2*capacity;
+                if (attributes != attributeArray) {
+                    attributes = (CFXMLAttributeDeclarationInfo *)CFAllocatorReallocate(CFGetAllocator(parser), attributes, capacity * sizeof(CFXMLAttributeDeclarationInfo), 0);
+                } else {
+                    attributes = (CFXMLAttributeDeclarationInfo *)CFAllocatorAllocate(CFGetAllocator(parser), capacity * sizeof(CFXMLAttributeDeclarationInfo), 0);
+                }
+            }
+            attribute = &(attributes[attListData.numberOfAttributes]);
+            // Much better if we can somehow create these strings immutable - then if the client (or we ourselves) has to copy them, they will end up multiply-retained, rather than having a new alloc and data copy performed.  -- REW, 2/9/2000
+            attribute->typeString = CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser));
+            attribute->defaultString = CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser));
+        }
+        if (!_inputStreamScanXMLName(&parser->input, false, &(attribute->attributeName)) || (_inputStreamSkipWhitespace(&parser->input, NULL) == 0)) {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+            success = false;
+            break;
+        }
+        if (!parseAttributeType(parser, attribute ? (CFMutableStringRef)attribute->typeString : NULL)) {
+            success = false;
+            break;
+        }
+        if (_inputStreamSkipWhitespace(&parser->input, NULL) == 0) {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+            success = false;
+            break;
+        }
+        if (!parseAttributeDefaultDeclaration(parser, attribute ? (CFMutableStringRef)attribute->defaultString : NULL)) {
+            success = false;
+            break;
+        }
+        attListData.numberOfAttributes ++;
+    }
+    if (success) {
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+            success = false;
+        } else if (ch != '>') {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+            success = false;
+        } else if (attributes) {
+            CFStringRef tmp = parser->node->dataString;
+            parser->node->dataTypeID = kCFXMLNodeTypeAttributeListDeclaration;
+            parser->node->dataString = name;
+            attListData.attributes = attributes;
+            parser->node->additionalData = (void *)&attListData;
+            success = reportNewLeaf(parser);
+            parser->node->additionalData = NULL;
+            parser->node->dataString = tmp;
+        }
+    }
+    if (attributes) {
+        // Free up all that memory
+        CFIndex idx;
+        for (idx = 0; idx < attListData.numberOfAttributes; idx ++) {
+            // Do not release attributeName here; it's a uniqued string from scanXMLName
+            CFRelease(attributes[idx].typeString);
+            CFRelease(attributes[idx].defaultString);
+        }
+        if (attributes != attributeArray) {
+            CFAllocatorDeallocate(CFGetAllocator(parser), attributes);
+        }
+    }
+    return success;
+}
+
+CF_INLINE Boolean parseSystemLiteral(CFXMLParserRef parser, CFXMLExternalID *extID) {
+    Boolean success;
+    if (extID) {
+        CFMutableStringRef urlStr = CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser));
+        if (_inputStreamScanQuotedString(&parser->input, urlStr)) {
+            success = true;
+            extID->systemID = CFURLCreateWithString(CFGetAllocator(parser), urlStr, parser->input.url);
+        } else {
+            extID->systemID = NULL;
+            success = false;
+        }
+        CFRelease(urlStr);
+    } else {
+        success = _inputStreamScanQuotedString(&parser->input, NULL);
+    }
+    return success;
+}
+
+/*
+ [75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral
+ [83] PublicID ::= 'PUBLIC' S PubidLiteral
+ [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
+ [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
+ [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'") 
+*/
+// This does NOT report errors itself; caller can check to see if parser->input is at EOF to determine whether the formatting failed or unexpected EOF occurred.  -- REW, 2/2/2000
+static Boolean parseExternalID(CFXMLParserRef parser, Boolean alsoAcceptPublicID, CFXMLExternalID *extID) {
+    const UniChar publicString[6] = {'P', 'U', 'B', 'L', 'I', 'C'};
+    const UniChar systemString[6] = {'S', 'Y', 'S', 'T', 'E', 'M'};
+    Boolean success;
+    if (extID) {
+        extID->systemID = NULL;
+        extID->publicID = NULL;
+    }
+    if (_inputStreamMatchString(&parser->input, publicString, 6)) {
+        success = _inputStreamSkipWhitespace(&parser->input, NULL) != 0;
+        if (extID) {
+            extID->publicID = CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser));
+            success = success && _inputStreamScanQuotedString(&parser->input, (CFMutableStringRef)extID->publicID);
+        } else {
+            success = success && _inputStreamScanQuotedString(&parser->input, NULL);
+        }
+        if (success) {
+            UniChar ch;
+            if (alsoAcceptPublicID) {
+                _inputStreamSetMark(&parser->input); // In case we need to roll back the parser
+            }
+            if (_inputStreamSkipWhitespace(&parser->input, NULL) == 0
+                || !_inputStreamPeekCharacter(&parser->input, &ch)
+                || (ch != '\'' && ch != '\"')
+                || !parseSystemLiteral(parser, extID)) {
+                success = alsoAcceptPublicID;
+                if (alsoAcceptPublicID) {
+                    _inputStreamBackUpToMark(&parser->input);
+                }
+            } else {
+                success = true;
+            }
+            if (alsoAcceptPublicID) {
+                _inputStreamClearMark(&parser->input);
+            }
+        }
+    } else if (_inputStreamMatchString(&parser->input, systemString, 6)) {
+        success = _inputStreamSkipWhitespace(&parser->input, NULL) != 0 && parseSystemLiteral(parser, extID);
+    } else {
+        success = false;
+    }
+    return success;
+}
+
+/*
+ [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID |  PublicID) S? '>'
+*/
+static Boolean parseNotationDeclaration(CFXMLParserRef parser) {
+    static UniChar notationString[8] = {'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N'};
+    Boolean report = *(parser->top) && !(parser->options & kCFXMLParserSkipMetaData);
+    CFXMLNotationInfo notationData = {{NULL, NULL}};
+    CFStringRef name;
+    Boolean success =
+        _inputStreamMatchString(&parser->input, notationString, 8) &&
+        _inputStreamSkipWhitespace(&parser->input, NULL) != 0 &&
+        _inputStreamScanXMLName(&parser->input, false, report ? &name : NULL) &&
+        _inputStreamSkipWhitespace(&parser->input, NULL) != 0 &&
+        parseExternalID(parser, true, report ? &(notationData.externalID) : NULL);
+
+    if (success) {
+        UniChar ch;
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        success = (_inputStreamGetCharacter(&parser->input, &ch) && ch == '>');
+    }
+    if (!success) {
+        if (_inputStreamAtEOF(&parser->input)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+        } else {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+        }
+    } else if (report) {
+        CFStringRef tmp = parser->node->dataString;
+        parser->node->dataTypeID = kCFXMLNodeTypeNotation;
+        parser->node->dataString = name;
+        parser->node->additionalData = &notationData;
+        success = reportNewLeaf(parser);
+        parser->node->additionalData = NULL;
+        parser->node->dataString = tmp;
+    }
+    if (notationData.externalID.systemID) CFRelease(notationData.externalID.systemID);
+    if (notationData.externalID.publicID) CFRelease(notationData.externalID.publicID);
+    return success;
+}
+
+/*
+ [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?
+ [49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'
+ [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
+*/
+static Boolean parseChoiceOrSequence(CFXMLParserRef parser, Boolean pastParen) {
+    UniChar ch, separator;
+    if (!pastParen) {
+        if (!_inputStreamGetCharacter(&parser->input, &ch) || ch != '(') return false;
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+    }
+    if (!_inputStreamPeekCharacter(&parser->input, &ch)) return false;
+
+    /* Now scanning cp, production [48] */
+    if (ch == '(') {
+        if (!parseChoiceOrSequence(parser, false)) return false;
+    } else {
+        if (!_inputStreamScanXMLName(&parser->input, false, NULL)) return false;
+    }
+    if (!_inputStreamPeekCharacter(&parser->input, &ch)) return false;
+    if (ch == '?' || ch == '*' || ch == '+') _inputStreamGetCharacter(&parser->input, &ch);
+
+    /* Now past cp */
+    _inputStreamSkipWhitespace(&parser->input, NULL);
+    if (!_inputStreamGetCharacter(&parser->input, &ch)) return false;
+    if (ch == ')') return true;
+    if (ch != '|' && ch != ',') return false;
+    separator = ch;
+    while (ch == separator) {
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamPeekCharacter(&parser->input, &ch)) return false;
+        if (ch != '(') {
+            if (!_inputStreamScanXMLName(&parser->input, false, NULL)) return false;
+        } else if (!parseChoiceOrSequence(parser, false)) {
+            return false;
+        }
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) return false;
+    }
+    return ch == ')';
+}
+
+/*
+ [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'
+*/
+static Boolean parseMixedElementContent(CFXMLParserRef parser) {
+    static const UniChar pcdataString[7] = {'#', 'P', 'C', 'D', 'A', 'T', 'A'};
+    UniChar ch;
+    if (!_inputStreamMatchString(&parser->input, pcdataString, 7)) return false;
+    _inputStreamSkipWhitespace(&parser->input, NULL);
+    if (!_inputStreamGetCharacter(&parser->input, &ch) && (ch == ')' || ch == '|')) return false;
+    if (ch == ')') return true;
+
+    while (ch == '|') {
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamScanXMLName(&parser->input, false, NULL)) return false;
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) return false;
+    }
+    if (ch != ')') return false;
+    if (!_inputStreamGetCharacter(&parser->input, &ch) || ch != '*') return false;
+    return true;
+}
+
+/*
+ [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children
+ [47] children ::= (choice | seq) ('?' | '*' | '+')?
+ */
+static Boolean parseElementContentSpec(CFXMLParserRef parser) {
+    static const UniChar eltContentEmpty[5] = {'E', 'M', 'P', 'T', 'Y'};
+    static const UniChar eltContentAny[3] = {'A', 'N', 'Y'};
+    UniChar ch;
+    if (_inputStreamMatchString(&parser->input, eltContentEmpty, 5) || _inputStreamMatchString(&parser->input, eltContentAny, 3)) {
+        return true;
+    } else if (!_inputStreamPeekCharacter(&parser->input, &ch) || ch != '(') {
+        return false;
+    } else {
+        // We want to know if we have a Mixed per production [51].  If we don't, we will need to back up and call the parseChoiceOrSequence function.  So we set the mark now.  -- REW, 2/10/2000
+        _inputStreamGetCharacter(&parser->input, &ch);
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamPeekCharacter(&parser->input, &ch)) return false;
+        if (ch == '#') {
+            // Mixed
+            return parseMixedElementContent(parser);
+        } else {
+            if (parseChoiceOrSequence(parser, true)) {
+                if (_inputStreamPeekCharacter(&parser->input, &ch) && (ch == '*' || ch == '?' || ch == '+')) {
+                    _inputStreamGetCharacter(&parser->input, &ch);
+                }
+                return true;
+            } else {
+                return false;
+            }
+        }
+    }
+}
+
+/*
+ [45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
+ */
+static Boolean parseElementDeclaration(CFXMLParserRef parser) {
+    Boolean report = *(parser->top) && !(parser->options & kCFXMLParserSkipMetaData);
+    Boolean success;
+    static const UniChar eltChars[7] = {'E', 'L', 'E', 'M', 'E', 'N', 'T'};
+    UniChar ch = '>';
+    CFMutableStringRef contentDesc = NULL;
+    CFStringRef name;
+    success = _inputStreamMatchString(&parser->input, eltChars, 7)
+        && _inputStreamSkipWhitespace(&parser->input, NULL) != 0
+        && _inputStreamScanXMLName(&parser->input, false, report ? &name : NULL)
+        && _inputStreamSkipWhitespace(&parser->input, NULL) != 0;
+    if (success) {
+        if (report) _inputStreamSetMark(&parser->input);
+        success = parseElementContentSpec(parser);
+        if (success && report) {
+            contentDesc = CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser));
+            _inputStreamGetCharactersFromMark(&parser->input, contentDesc);
+        }
+        if (report) _inputStreamClearMark(&parser->input);
+        if (success) _inputStreamSkipWhitespace(&parser->input, NULL);
+        success = success && _inputStreamMatchString(&parser->input, &ch, 1);
+    }
+    if (!success) {
+        if (_inputStreamAtEOF(&parser->input)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+        } else {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+        }
+    } else if (report) {
+        CFXMLElementTypeDeclarationInfo eltData;
+        CFStringRef tmp = parser->node->dataString;
+        parser->node->dataTypeID = kCFXMLNodeTypeElementTypeDeclaration;
+        parser->node->dataString = name;
+        eltData.contentDescription = contentDesc;
+        parser->node->additionalData = &eltData;
+        success = reportNewLeaf(parser);
+        parser->node->additionalData = NULL;
+        parser->node->dataString = tmp;
+    }
+    if (contentDesc) CFRelease(contentDesc);
+    return success;
+}
+
+/*
+ [70] EntityDecl ::= GEDecl | PEDecl
+ [71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
+ [72] PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
+ [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)
+ [74] PEDef ::= EntityValue | ExternalID
+ [76] NDataDecl ::= S 'NDATA' S Name
+ [9]  EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' |  "'" ([^%&'] | PEReference | Reference)* "'"
+*/
+static Boolean parseEntityDeclaration(CFXMLParserRef parser) {
+    const UniChar entityStr[6] = {'E', 'N', 'T', 'I', 'T', 'Y'};
+    UniChar ch;
+    Boolean isPEDecl = false;
+    CFXMLEntityInfo entityData;
+    CFStringRef name;
+    Boolean report = *(parser->top) && !(parser->options & kCFXMLParserSkipMetaData);
+    Boolean success =
+        _inputStreamMatchString(&parser->input, entityStr, 6) &&
+        (_inputStreamSkipWhitespace(&parser->input, NULL) != 0) &&
+        _inputStreamPeekCharacter(&parser->input, &ch);
+
+    entityData.replacementText = NULL;
+    entityData.entityID.publicID = NULL;
+    entityData.entityID.systemID = NULL;
+    entityData.notationName = NULL;
+    // We will set entityType immediately before reporting
+
+    if (success && ch == '%') {
+        _inputStreamGetCharacter(&parser->input, &ch);
+        success = _inputStreamSkipWhitespace(&parser->input, NULL) != 0;
+        isPEDecl = true;
+    }
+    success = success && _inputStreamScanXMLName(&parser->input, false, report ? &name : NULL) && (_inputStreamSkipWhitespace(&parser->input, NULL) != 0) && _inputStreamPeekCharacter(&parser->input, &ch);
+    if (success && (ch == '\"' || ch == '\'')) {
+        // EntityValue
+        // This is not quite correct - the string scanned cannot contain '%' or '&' unless it's as part of a valid entity reference -- REW, 2/2/2000
+        if (report) {
+            entityData.replacementText = CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser));
+            success = _inputStreamScanQuotedString(&parser->input, (CFMutableStringRef)entityData.replacementText);
+        } else {
+            success = _inputStreamScanQuotedString(&parser->input, NULL);
+        }
+    } else if (success) {
+        // ExternalID
+        success = parseExternalID(parser, false, report ? &(entityData.entityID) : NULL);
+        if (success && !isPEDecl && _inputStreamSkipWhitespace(&parser->input, NULL) != 0) {
+            // There could be an option NDataDecl
+            // Don't we need to set entityData.notationName? -- REW, 3/6/2000
+            const UniChar nDataStr[5] = {'N', 'D', 'A', 'T', 'A'};
+            if (_inputStreamMatchString(&parser->input, nDataStr, 5)) {
+                success = (_inputStreamSkipWhitespace(&parser->input, NULL) != 0) && _inputStreamScanXMLName(&parser->input, false, NULL);
+            }
+        }
+    }
+    if (success) {
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        success = _inputStreamGetCharacter(&parser->input, &ch) && ch == '>';
+    }
+    if (!success) {
+        if (_inputStreamAtEOF(&parser->input)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+        } else {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+        }
+    } else {
+        CFStringRef tmp = parser->node->dataString;
+        if (isPEDecl) entityData.entityType = kCFXMLEntityTypeParameter;
+        else if (entityData.replacementText) entityData.entityType = kCFXMLEntityTypeParsedInternal;
+        else if (!entityData.notationName) entityData.entityType = kCFXMLEntityTypeParsedExternal;
+        else entityData.entityType = kCFXMLEntityTypeUnparsed;
+        parser->node->dataTypeID = kCFXMLNodeTypeEntity;
+        parser->node->dataString = name;
+        parser->node->additionalData = &entityData;
+        success = reportNewLeaf(parser);
+        parser->node->additionalData = NULL;
+        parser->node->dataString = tmp;
+        if (entityData.replacementText) CFRelease(entityData.replacementText);
+    }
+    if (entityData.entityID.publicID) CFRelease(entityData.entityID.publicID);
+    if (entityData.entityID.systemID) CFRelease(entityData.entityID.systemID);
+    return success;
+}
+
+/*
+ [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
+ [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment 
+*/ 
+// First character should be just past '['
+static Boolean parseInlineDTD(CFXMLParserRef parser) {
+    Boolean success = true;
+    while (success && !_inputStreamAtEOF(&parser->input)) {
+        UniChar ch;
+
+        parseWhitespace(parser);
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) break;
+        if (ch == '%') {
+            // PEReference
+            success = parsePhysicalEntityReference(parser);
+        } else if (ch == '<') {
+            // markupdecl
+            if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+                _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+                return false;
+            }
+            if (ch == '?') {
+                // Processing Instruction
+                success = parseProcessingInstruction(parser, true); // We can safely pass true here, because *parser->top will be NULL if kCFXMLParserSkipMetaData is true
+            } else if (ch == '!') {
+                UniChar dashes[2] = {'-', '-'};
+                if (_inputStreamMatchString(&parser->input, dashes, 2)) {
+                    // Comment
+                    success = parseComment(parser, true);
+                } else {
+                    // elementdecl | AttListDecl | EntityDecl | NotationDecl
+                    if (!_inputStreamPeekCharacter(&parser->input, &ch)) {
+                        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+                        return false;
+                    } else if (ch == 'A') {
+                        // AttListDecl
+                        success = parseAttributeListDeclaration(parser);
+                    } else if (ch == 'N') {
+                        success = parseNotationDeclaration(parser);
+                    } else if (ch == 'E') {
+                        // elementdecl | EntityDecl
+                        _inputStreamGetCharacter(&parser->input, &ch);
+                        if (!_inputStreamPeekCharacter(&parser->input, &ch)) {
+                            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+                            return false;
+                        }
+                        _inputStreamReturnCharacter(&parser->input, 'E');
+                        if (ch == 'L') {
+                            success = parseElementDeclaration(parser);
+                        } else if (ch == 'N') {
+                            success = parseEntityDeclaration(parser);
+                        } else {
+                            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+                            return false;
+                        }
+                    } else {
+                        _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+                        return false;
+                    }                        
+                }
+            } else {
+                _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+                return false;
+            }
+        } else if (ch == ']') {
+            return true;
+        } else {
+            _CFReportError(parser, kCFXMLErrorMalformedDTD, "Found unexpected character while parsing inline DTD");
+            return false;
+        }
+    }
+    if (success) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Found unexpected EOF while parsing inline DTD");
+    }
+    return false;
+}
+
+/*
+[43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
+ */
+static Boolean parseTagContent(CFXMLParserRef parser) {
+    while (!_inputStreamAtEOF(&parser->input)) {
+        UniChar ch;
+        CFIndex numWhitespaceCharacters;
+        
+        _inputStreamSetMark(&parser->input);
+        numWhitespaceCharacters = _inputStreamSkipWhitespace(&parser->input, NULL);
+        // Don't report the whitespace yet; if the first thing we see is character data, we put the whitespace back and report it as part of the character data.
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) break;  // break == report unexpected EOF
+
+        if (ch != '<' && ch != '&') { // CharData
+            // Back off the whitespace; we'll report it with the PCData
+            _inputStreamBackUpToMark(&parser->input);
+            _inputStreamClearMark(&parser->input);
+             if (!parsePCData(parser)) return false;
+             if(_inputStreamComposingErrorOccurred(&parser->input)) {
+                 _CFReportError(parser, kCFXMLErrorEncodingConversionFailure, "Encountered string encoding error");
+                 return false;
+             }
+             continue;
+        }
+
+        // element | Reference | CDSect | PI | Comment
+        // We can safely report any whitespace now
+        if (!(parser->options & kCFXMLParserSkipWhitespace) && numWhitespaceCharacters != 0 && *(parser->top)) {
+            _inputStreamReturnCharacter(&parser->input, ch);
+            _inputStreamGetCharactersFromMark(&parser->input, (CFMutableStringRef)(parser->node->dataString));
+            parser->node->dataTypeID = kCFXMLNodeTypeWhitespace;
+            parser->node->additionalData = NULL;
+            if (!reportNewLeaf(parser)) return false;
+            _inputStreamGetCharacter(&parser->input, &ch);
+        }
+        _inputStreamClearMark(&parser->input);
+        
+        if (ch == '&') {
+            // Reference; for the time being, we don't worry about processing these; just report them as Entity references
+            if (!parseEntityReference(parser, true)) return false;
+            continue;
+        }
+
+        // ch == '<'; element | CDSect | PI | Comment
+        if (!_inputStreamPeekCharacter(&parser->input, &ch)) break;
+        if (ch == '?') { // PI
+            _inputStreamGetCharacter(&parser->input, &ch);
+            if (!parseProcessingInstruction(parser, true))
+                return false;
+        } else if (ch == '/') { // end tag; we're passing outside of content's production
+            _inputStreamReturnCharacter(&parser->input, '<'); // Back off to the '<'
+            return true;
+        } else if (ch != '!') { // element
+            if (!parseTag(parser))  return false;
+        } else {
+            // Comment | CDSect
+            UniChar dashes[3] = {'!', '-', '-'};
+            if (_inputStreamMatchString(&parser->input, dashes, 3)) {
+                // Comment
+                if (!parseComment(parser, true)) return false;
+            } else {
+                // Should have a CDSect; back off the "<!" and call parseCDSect
+                _inputStreamReturnCharacter(&parser->input, '<');
+                if (!parseCDSect(parser)) return false;
+            }
+        }
+    }
+
+    if(_inputStreamComposingErrorOccurred(&parser->input)) {
+        _CFReportError(parser, kCFXMLErrorEncodingConversionFailure, "Encountered string encoding error");
+        return false;
+    }
+    // Only way to get here is if premature EOF was found
+//#warning CF:Include the tag name here
+    _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing tag content");
+    return false;
+}
+
+static Boolean parseCDSect(CFXMLParserRef parser) {
+    const UniChar _CDSectOpening[9] = {'<', '!', '[', 'C', 'D', 'A', 'T', 'A', '['};
+    const UniChar _CDSectClose[3] = {']', ']', '>'};
+    if (!_inputStreamMatchString(&parser->input, _CDSectOpening, 9)) {
+        _CFReportError(parser, kCFXMLErrorMalformedCDSect, "Encountered bad prefix to a presumed CDATA section");
+        return false;
+    }
+    if (!_inputStreamScanToCharacters(&parser->input, _CDSectClose, 3, (CFMutableStringRef)(parser->node->dataString))) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing CDATA section");
+        return false;
+    }
+
+    parser->node->dataTypeID = kCFXMLNodeTypeCDATASection;
+    parser->node->additionalData = NULL;
+    return reportNewLeaf(parser);
+}
+
+/*
+ [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
+*/
+static Boolean validateCharacterReference(CFStringRef str) {
+    Boolean isHex;
+    CFIndex idx, len = CFStringGetLength(str);
+    if (len < 2) return false;
+    if (CFStringGetCharacterAtIndex(str, 0) != '#') return false;
+    if (CFStringGetCharacterAtIndex(str, 1) == 'x') {
+        isHex = true;
+        idx = 2;
+        if (len == 2) return false;
+    } else {
+        isHex = false;
+        idx = 1;
+    }
+
+    while (idx < len) {
+        UniChar ch;
+        ch = CFStringGetCharacterAtIndex(str, idx);
+        idx ++;
+        if (!(ch <= '9' && ch >= '0') &&
+            !(isHex && ((ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')))) {
+            break;
+        }
+    }
+    return (idx == len);
+}
+
+/*
+ [67] Reference ::= EntityRef | CharRef
+ [68] EntityRef ::= '&' Name ';'
+*/
+static Boolean parseEntityReference(CFXMLParserRef parser, Boolean report) {
+    UniChar ch;
+    CFXMLEntityReferenceInfo entData;
+    CFStringRef name = NULL;
+    if (!_inputStreamPeekCharacter(&parser->input, &ch)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing EntityReference");
+        return false;
+    }
+    if (ch == '#') {
+        ch = ';';
+        if (!_inputStreamScanToCharacters(&parser->input, &ch, 1, (CFMutableStringRef)parser->node->dataString)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing EntityReference");
+            return false;
+        } else if (!validateCharacterReference(parser->node->dataString)) {
+            _CFReportError(parser, kCFXMLErrorMalformedCharacterReference, "Encountered illegal character while parsing character reference");
+            return false;
+        }
+        entData.entityType = kCFXMLEntityTypeCharacter;
+        name = parser->node->dataString;
+    } else if (!_inputStreamScanXMLName(&parser->input, false, report ? &name : NULL) || !_inputStreamGetCharacter(&parser->input, &ch) || ch != ';') {
+        if (_inputStreamAtEOF(&parser->input)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing EntityReference");
+            return false;
+        } else {
+            _CFReportError(parser, kCFXMLErrorMalformedName, "Encountered malformed name while parsing EntityReference");
+            return false;
+        }
+    } else {
+        entData.entityType = kCFXMLEntityTypeParsedInternal;
+    }
+    if (report) {
+        CFStringRef tmp = parser->node->dataString;
+        Boolean success;
+        parser->node->dataTypeID = kCFXMLNodeTypeEntityReference;
+        parser->node->dataString = name;
+        parser->node->additionalData = &entData;
+        success = reportNewLeaf(parser);
+        parser->node->additionalData = NULL;
+        parser->node->dataString = tmp;
+        return success;
+    } else {
+        return true;
+    }
+}
+
+#if 0
+// Kept from old entity reference parsing....
+{
+    switch (*(parser->curr)) {
+        case 'l':  // "lt"
+            if (len >= 3 && *(parser->curr+1) == 't' && *(parser->curr+2) == ';') {
+                ch = '<';
+                parser->curr += 3;
+                break;
+            }
+            parser->errorString = CFStringCreateWithFormat(parser->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(parser));
+            return;
+        case 'g': // "gt"
+            if (len >= 3 && *(parser->curr+1) == 't' && *(parser->curr+2) == ';') {
+                ch = '>';
+                parser->curr += 3;
+                break;
+            }
+            parser->errorString = CFStringCreateWithFormat(parser->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(parser));
+            return;
+        case 'a': // "apos" or "amp"
+            if (len < 4) {   // Not enough characters for either conversion
+                parser->errorString = CFStringCreateWithCString(parser->allocator, "Encountered unexpected EOF", kCFStringEncodingASCII);
+                return;
+            }
+            if (*(parser->curr+1) == 'm') {
+                // "amp"
+                if (*(parser->curr+2) == 'p' && *(parser->curr+3) == ';') {
+                    ch = '&';
+                    parser->curr += 4;
+                    break;
+                }
+            } else if (*(parser->curr+1) == 'p') {
+                // "apos"
+                if (len > 4 && *(parser->curr+2) == 'o' && *(parser->curr+3) == 's' && *(parser->curr+4) == ';') {
+                    ch = '\'';
+                    parser->curr += 5;
+                    break;
+                }
+            }
+            parser->errorString = CFStringCreateWithFormat(parser->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(parser));
+            return;
+        case 'q':  // "quote"
+            if (len >= 6 && *(parser->curr+1) == 'u' && *(parser->curr+2) == 'o' && *(parser->curr+3) == 't' && *(parser->curr+4) == 'e' && *(parser->curr+5) == ';') {
+                ch = '\"';
+                parser->curr += 6;
+                break;
+            }
+            parser->errorString = CFStringCreateWithFormat(parser->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(parser));
+            return;
+        case '#':
+        {
+            UniChar num = 0;
+            Boolean isHex = false;
+            if ( len < 4) {  // Not enough characters to make it all fit!  Need at least "&#d;"
+                parser->errorString = CFStringCreateWithCString(parser->allocator, "Encountered unexpected EOF", kCFStringEncodingASCII);
+                return;
+            }
+            parser->curr ++;
+            if (*(parser->curr) == 'x') {
+                isHex = true;
+                parser->curr ++;
+            }
+            while (parser->curr < parser->end) {
+                ch = *(parser->curr);
+                if (ch == ';') {
+                    CFStringAppendCharacters(string, &num, 1);
+                    parser->curr ++;
+                    return;
+                }
+                if (!isHex) num = num*10;
+                else num = num << 4;
+                if (ch <= '9' && ch >= '0') {
+                    num += (ch - '0');
+                } else if (!isHex) {
+                    parser->errorString = CFStringCreateWithFormat(parser->allocator, NULL, CFSTR("Encountered unexpected character %c at line %d"), ch, lineNumber(parser));
+                    return;
+                } else if (ch >= 'a' && ch <= 'f') {
+                    num += 10 + (ch - 'a');
+                } else if (ch >= 'A' && ch <= 'F') {
+                    num += 10 + (ch - 'A');
+                } else {
+                    parser->errorString = CFStringCreateWithFormat(parser->allocator, NULL, CFSTR("Encountered unexpected character %c at line %d"), ch, lineNumber(parser));
+                    return;                    
+                }
+            }
+            parser->errorString = CFStringCreateWithCString(parser->allocator, "Encountered unexpected EOF", kCFStringEncodingASCII);
+            return;
+        }
+        default:
+            parser->errorString = CFStringCreateWithFormat(parser->allocator, NULL, CFSTR("Encountered unknown ampersand-escape sequence at line %d"), lineNumber(parser));
+            return;
+    }
+    CFStringAppendCharacters(string, &ch, 1);
+}
+#endif
+
+/*
+[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
+*/
+static Boolean parsePCData(CFXMLParserRef parser) {
+    UniChar ch;
+    Boolean done = false;
+    _inputStreamSetMark(&parser->input);
+    while (!done && _inputStreamGetCharacter(&parser->input, &ch)) {
+        switch (ch) {
+            case '<': 
+            case '&':
+                _inputStreamReturnCharacter(&parser->input, ch);
+                done = true;
+                break;
+            case ']':
+            {
+                const UniChar endSequence[2] = {']', '>'};
+                if (_inputStreamMatchString(&parser->input, endSequence, 2)) {
+                    _CFReportError(parser, kCFXMLErrorMalformedParsedCharacterData, "Encountered \"]]>\" in parsed character data");
+                    _inputStreamClearMark(&parser->input);
+                    return false;
+                }
+                break;
+            }
+            default:
+                ;
+        }
+    }
+    _inputStreamGetCharactersFromMark(&parser->input, (CFMutableStringRef)(parser->node->dataString));
+    _inputStreamClearMark(&parser->input);
+    parser->node->dataTypeID = kCFXMLNodeTypeText;
+    parser->node->additionalData = NULL;
+    return reportNewLeaf(parser);
+}
+
+/*
+[42] ETag ::= '</' Name S? '>'
+ */
+static Boolean parseCloseTag(CFXMLParserRef parser, CFStringRef tag) {
+    const UniChar beginEndTag[2] = {'<', '/'};
+    Boolean unexpectedEOF = false, mismatch = false;
+    CFStringRef closeTag;
+
+    // We can get away with testing pointer equality between tag & closeTag because scanXMLName guarantees the strings it returns are unique.
+    if (_inputStreamMatchString(&parser->input, beginEndTag, 2) && _inputStreamScanXMLName(&parser->input, false, &closeTag) && closeTag == tag) {
+        
+        UniChar ch;
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+            unexpectedEOF = true;
+        } else if (ch != '>') {
+            mismatch = true;
+        }
+    } else if (_inputStreamAtEOF(&parser->input)) {
+        unexpectedEOF = true;
+    } else {
+        mismatch = true;
+    }
+        
+    if (unexpectedEOF || mismatch) {
+        if (unexpectedEOF) {
+            parser->errorString = CFStringCreateWithFormat(CFGetAllocator(parser), NULL, CFSTR("Encountered unexpected EOF while parsing close tag for <%@>"), tag);
+            parser->status = kCFXMLErrorUnexpectedEOF;
+            if(parser->callBacks.handleError) INVOKE_CALLBACK3(parser->callBacks.handleError, parser, kCFXMLErrorUnexpectedEOF, parser->context.info);
+        } else {
+            parser->errorString = CFStringCreateWithFormat(CFGetAllocator(parser), NULL, CFSTR("Encountered malformed close tag for <%@>"), tag);
+            parser->status = kCFXMLErrorMalformedCloseTag;
+            if(parser->callBacks.handleError) INVOKE_CALLBACK3(parser->callBacks.handleError, parser, kCFXMLErrorMalformedCloseTag, parser->context.info);
+        }
+        return false;
+    }
+    return true;
+}
+
+/*
+ [39] element ::= EmptyElementTag | STag content ETag
+ [40] STag ::= '<' Name (S Attribute)* S? '>'
+ [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
+*/
+static Boolean parseTag(CFXMLParserRef parser) {
+    UniChar ch;
+    void *tag;
+    CFXMLElementInfo data;
+    Boolean success = true;
+    CFStringRef tagName;
+
+    if (!_inputStreamScanXMLName(&parser->input, false, &tagName)) {
+        _CFReportError(parser, kCFXMLErrorMalformedStartTag, "Encountered malformed start tag");
+        return false;
+    }
+
+    _inputStreamSkipWhitespace(&parser->input, NULL);
+    
+    if (!parseAttributes(parser)) return false; // parsed directly into parser->argDict ; parseAttributes consumes any trailing whitespace
+    data.attributes = parser->argDict;
+    data.attributeOrder = parser->argArray;
+    if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF");
+        return false;
+    }
+    if (ch == '/') {
+        data.isEmpty = true;
+        if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+            _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF");
+            return false;
+        }
+    } else {
+        data.isEmpty = false;
+    }
+    if (ch != '>') {
+        _CFReportError(parser, kCFXMLErrorMalformedStartTag, "Encountered malformed start tag");
+        return false;
+    }
+
+    if (*parser->top || parser->top == parser->stack) {
+        CFStringRef oldStr = parser->node->dataString;
+	parser->node->dataTypeID = kCFXMLNodeTypeElement;
+        parser->node->dataString = tagName;
+	parser->node->additionalData = &data;
+        tag = (void *)INVOKE_CALLBACK3(parser->callBacks.createXMLStructure, parser, parser->node, parser->context.info);
+        if (tag && parser->status == kCFXMLStatusParseInProgress) {
+            INVOKE_CALLBACK4(parser->callBacks.addChild, parser, *parser->top, tag, parser->context.info);
+        }
+	parser->node->additionalData = NULL;
+        parser->node->dataString = oldStr;
+        if (parser->status != kCFXMLStatusParseInProgress) {
+            // callback called CFXMLParserAbort()
+            _CFReportError(parser, parser->status, NULL);
+            return false;
+        }
+    } else {
+        tag = NULL;
+    }
+
+    pushXMLNode(parser, tag);
+    if (!data.isEmpty) {
+        success =  parseTagContent(parser);
+        if (success) {
+            success = parseCloseTag(parser, tagName);
+        }
+    }
+    parser->top --;
+
+    if (success && tag) {
+        INVOKE_CALLBACK3(parser->callBacks.endXMLStructure, parser, tag, parser->context.info);
+        if (parser->status != kCFXMLStatusParseInProgress) {
+            _CFReportError(parser, parser->status, NULL);
+            return false;
+        }
+    }
+    return success;
+}
+
+/*
+ [10] AttValue ::= '"' ([^<&"] | Reference)* '"' |  "'" ([^<&'] | Reference)* "'"
+ [67] Reference ::= EntityRef | CharRef
+ [68] EntityRef ::= '&' Name ';'
+ */
+// For the moment, we don't worry about references in the attribute values.
+static Boolean parseAttributeValue(CFXMLParserRef parser, CFMutableStringRef str) {
+    UniChar quote, ch;
+    Boolean success = _inputStreamGetCharacter(&parser->input, &quote);
+    if (!success || (quote != '\'' && quote != '\"')) return false;
+    if (str) _inputStreamSetMark(&parser->input);
+    while (_inputStreamGetCharacter(&parser->input, &ch) && ch != quote) {
+        switch (ch) {
+            case '<': success = false; break;
+            case '&':
+                if (!parseEntityReference(parser, false)) {
+                    success = false;
+                    break;
+                }
+            default:
+                ;
+        }
+    }
+    
+    if (success && _inputStreamAtEOF(&parser->input)) {
+        success = false;
+    }
+    if (str) {
+        if (success) {
+            _inputStreamReturnCharacter(&parser->input, quote);
+            _inputStreamGetCharactersFromMark(&parser->input, str);
+            _inputStreamGetCharacter(&parser->input, &ch);
+        }
+        _inputStreamClearMark(&parser->input);
+    }
+    return success;
+}
+
+/*
+ [40] STag ::= '<' Name (S Attribute)* S? '>'
+ [41] Attribute ::= Name Eq AttValue
+ [25] Eq ::= S? '=' S?
+*/
+
+// Expects parser->curr to be at the first content character; will consume the trailing whitespace.  
+Boolean parseAttributes(CFXMLParserRef parser) {
+    UniChar ch;
+    CFMutableDictionaryRef dict;
+    CFMutableArrayRef array;
+    Boolean failure = false;
+    if (_inputStreamPeekCharacter(&parser->input, &ch) == '>') {
+        if (parser->argDict) {
+            CFDictionaryRemoveAllValues(parser->argDict);
+            CFArrayRemoveAllValues(parser->argArray);
+        }
+        return true;  // No attributes; let caller deal with it
+    }
+    if (!parser->argDict) {
+        parser->argDict = CFDictionaryCreateMutable(CFGetAllocator(parser), 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        parser->argArray = CFArrayCreateMutable(CFGetAllocator(parser), 0, &kCFTypeArrayCallBacks);
+    } else {
+        CFDictionaryRemoveAllValues(parser->argDict);
+        CFArrayRemoveAllValues(parser->argArray);
+    }
+    dict = parser->argDict;
+    array = parser->argArray; 
+    while (!failure && _inputStreamPeekCharacter(&parser->input, &ch) && ch != '>' && ch != '/') {
+        CFStringRef key;
+        CFMutableStringRef value;
+        if (!_inputStreamScanXMLName(&parser->input, false, &key)) {
+            failure = true;
+            break;
+        }
+        if (CFArrayGetFirstIndexOfValue(array, CFRangeMake(0, CFArrayGetCount(array)), key) != kCFNotFound) {
+            _CFReportError(parser, kCFXMLErrorMalformedStartTag, "Found repeated attribute");
+            return false;
+        }
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        if (!_inputStreamGetCharacter(&parser->input, &ch) || ch != '=') { 
+            failure = true;
+            break;
+        }
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+        value = CFStringCreateMutableWithExternalCharactersNoCopy(CFGetAllocator(parser), NULL, 0, 0, CFGetAllocator(parser));
+        if (!parseAttributeValue(parser, value)) {
+            CFRelease(value);
+            failure = true;
+            break;
+        }
+        CFArrayAppendValue(array, key);
+        CFDictionarySetValue(dict, key, value);
+        CFRelease(value);
+        _inputStreamSkipWhitespace(&parser->input, NULL);
+    }
+    if (failure) {
+//#warning CF:Include tag name in this error report
+        _CFReportError(parser, kCFXMLErrorMalformedStartTag, "Found illegal character while parsing element tag");
+        return false;
+    } else if (_inputStreamAtEOF(&parser->input)) {
+        _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing element attributes");
+        return false;
+    } else {
+        return true;
+    }
+}
+
+/*
+ [1]  document ::= prolog element Misc*
+ [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
+ [27] Misc ::= Comment | PI | S
+ [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' 
+
+ We treat XMLDecl as a plain old PI, since PI is part of Misc.  This changes the prolog and document productions to
+ [22-1] prolog ::= Misc* (doctypedecl Misc*)?
+ [1-1] document ::= Misc* (doctypedecl Misc*)? element Misc*
+
+ NOTE: This function assumes parser->stack has a valid top.  I.e. the document pointer has already been created!
+*/
+static Boolean parseXML(CFXMLParserRef parser) {
+    Boolean success = true, sawDTD = false, sawElement = false;
+    UniChar ch;
+    while (success && _inputStreamPeekCharacter(&parser->input, &ch)) {
+        switch (ch) {
+            case ' ':
+            case '\n':
+            case '\t':
+            case '\r':
+                success = parseWhitespace(parser);
+                break;
+            case '<':
+                _inputStreamGetCharacter(&parser->input, &ch);
+                if (!_inputStreamGetCharacter(&parser->input, &ch)) {
+                    _CFReportError(parser, kCFXMLErrorUnexpectedEOF, "Encountered unexpected EOF while parsing top-level document");
+                    return false;
+                }
+                if (ch == '!') {
+                    // Comment or DTD
+                    UniChar dashes[2] = {'-', '-'};
+                    if (_inputStreamMatchString(&parser->input, dashes, 2)) {
+                        // Comment
+                        success = parseComment(parser, true);
+                    } else {
+                        // Should be DTD
+                        if (sawDTD) {
+                            _CFReportError(parser, kCFXMLErrorMalformedDocument, "Encountered a second DTD");
+                            return false;
+                        }
+                        success = parseDTD(parser);
+                        if (success) sawDTD = true;
+                    }
+                } else if (ch == '?') {
+                    // Processing instruction
+                    success = parseProcessingInstruction(parser, true);
+                } else {
+                    // Tag or malformed
+                    if (sawElement) {
+                        _CFReportError(parser, kCFXMLErrorMalformedDocument, "Encountered second top-level element");
+                        return false;
+                    }
+                    _inputStreamReturnCharacter(&parser->input, ch);
+                    success = parseTag(parser);
+                    if (success) sawElement = true;
+                }
+                break;
+            default: {
+                parser->status = kCFXMLErrorMalformedDocument;
+                parser->errorString = ch < 256 ?
+                    CFStringCreateWithFormat(CFGetAllocator(parser), NULL, CFSTR("Encountered unexpected character 0x%x (\'%c\') at top-level"), ch, ch) :
+                    CFStringCreateWithFormat(CFGetAllocator(parser), NULL, CFSTR("Encountered unexpected Unicode character 0x%x at top-level"), ch);
+
+                if (parser->callBacks.handleError) {
+                    INVOKE_CALLBACK3(parser->callBacks.handleError, parser, parser->status, parser->context.info);
+                }
+                return false;
+            }
+        }
+    }
+    
+    if (!success) return false;
+    if (!sawElement) {
+        _CFReportError(parser, kCFXMLErrorElementlessDocument, "No element found in document");
+        return false;
+    }
+    return true;
+}
+
+static void _CFReportError(CFXMLParserRef parser, CFXMLParserStatusCode errNum, const char *str) {
+    if (str) {
+        parser->status = errNum;
+        parser->errorString = CFStringCreateWithCString(CFGetAllocator(parser), str, kCFStringEncodingASCII);
+    }
+    if (parser->callBacks.handleError) {
+        INVOKE_CALLBACK3(parser->callBacks.handleError, parser, errNum, parser->context.info);
+    }
+}
+
+// Assumes parser->node has been set and is ready to go
+static Boolean reportNewLeaf(CFXMLParserRef parser) {
+    void *xmlStruct;
+    if (*(parser->top) == NULL) return true;
+
+    xmlStruct = (void *)INVOKE_CALLBACK3(parser->callBacks.createXMLStructure, parser, parser->node, parser->context.info);
+    if (xmlStruct && parser->status == kCFXMLStatusParseInProgress) {
+        INVOKE_CALLBACK4(parser->callBacks.addChild, parser, *(parser->top), xmlStruct, parser->context.info);
+        if (parser->status == kCFXMLStatusParseInProgress) INVOKE_CALLBACK3(parser->callBacks.endXMLStructure, parser, xmlStruct, parser->context.info);
+    }
+    if (parser->status != kCFXMLStatusParseInProgress) {
+        _CFReportError(parser, parser->status, NULL);
+        return false;
+    }
+    return true;
+}
+
+static void pushXMLNode(CFXMLParserRef parser, void *node) {
+    parser->top ++;
+    if ((unsigned)(parser->top - parser->stack) == parser->capacity) {
+        parser->stack = (void **)CFAllocatorReallocate(CFGetAllocator(parser), parser->stack, 2 * parser->capacity * sizeof(void *), 0);
+        parser->top = parser->stack + parser->capacity;
+        parser->capacity = 2*parser->capacity;
+    }
+    *(parser->top) = node;
+}
+
+/**************************/
+/* Parsing to a CFXMLTree */
+/**************************/
+
+static void *_XMLTreeCreateXMLStructure(CFXMLParserRef parser, CFXMLNodeRef node, void *context) {
+    CFXMLNodeRef myNode = CFXMLNodeCreateCopy(CFGetAllocator(parser), node);
+    CFXMLTreeRef tree = CFXMLTreeCreateWithNode(CFGetAllocator(parser), myNode);
+    CFRelease(myNode);
+    return (void *)tree;
+}
+
+static void _XMLTreeAddChild(CFXMLParserRef parser, void *parent, void *child, void *context) {
+    CFTreeAppendChild((CFTreeRef)parent, (CFTreeRef)child);
+}
+
+static void _XMLTreeEndXMLStructure(CFXMLParserRef parser, void *xmlType, void *context) {
+    CFXMLTreeRef node = (CFXMLTreeRef)xmlType;
+    if (CFTreeGetParent(node))
+        CFRelease((CFXMLTreeRef)xmlType);
+}
+
+CFXMLTreeRef CFXMLTreeCreateWithDataFromURL(CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex version) {
+    CFXMLParserRef parser;
+    CFXMLParserCallBacks callbacks;
+    CFXMLTreeRef result;
+
+    CFAssert1(dataSource == NULL || CFGetTypeID(dataSource) == CFURLGetTypeID(), __kCFLogAssertion, "%s(): dataSource is not a valid CFURL", __PRETTY_FUNCTION__);
+
+    callbacks.createXMLStructure = _XMLTreeCreateXMLStructure;
+    callbacks.addChild = _XMLTreeAddChild;
+    callbacks.endXMLStructure = _XMLTreeEndXMLStructure;
+    callbacks.resolveExternalEntity = NULL;
+    callbacks.handleError = NULL;
+    parser = CFXMLParserCreateWithDataFromURL(allocator, dataSource, parseOptions, version, &callbacks, NULL);
+
+    if (CFXMLParserParse(parser)) {
+        result = (CFXMLTreeRef)CFXMLParserGetDocument(parser);
+    } else {
+        result = (CFXMLTreeRef)CFXMLParserGetDocument(parser);
+        if (result) CFRelease(result);
+        result = NULL;
+    }
+    CFRelease(parser);
+    return result;
+}
+
+CFXMLTreeRef CFXMLTreeCreateFromData(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex parserVersion) {
+    return CFXMLTreeCreateFromDataWithError(allocator, xmlData, dataSource, parseOptions, parserVersion, NULL);
+}
+
+CONST_STRING_DECL(kCFXMLTreeErrorDescription, "kCFXMLTreeErrorDescription");
+CONST_STRING_DECL(kCFXMLTreeErrorLineNumber, "kCFXMLTreeErrorLineNumber");
+CONST_STRING_DECL(kCFXMLTreeErrorLocation, "kCFXMLTreeErrorLocation");
+CONST_STRING_DECL(kCFXMLTreeErrorStatusCode, "kCFXMLTreeErrorStatusCode");
+
+CFXMLTreeRef CFXMLTreeCreateFromDataWithError(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex parserVersion, CFDictionaryRef *errorDict) {
+    CFXMLParserRef parser;
+    CFXMLParserCallBacks callbacks;
+    CFXMLTreeRef result;
+
+    __CFGenericValidateType(xmlData, CFDataGetTypeID());
+    CFAssert1(dataSource == NULL || CFGetTypeID(dataSource) == CFURLGetTypeID(), __kCFLogAssertion, "%s(): dataSource is not a valid CFURL", __PRETTY_FUNCTION__);
+
+    callbacks.createXMLStructure = _XMLTreeCreateXMLStructure;
+    callbacks.addChild = _XMLTreeAddChild;
+    callbacks.endXMLStructure = _XMLTreeEndXMLStructure;
+    callbacks.resolveExternalEntity = NULL;
+    callbacks.handleError = NULL;
+    parser = CFXMLParserCreate(allocator, xmlData, dataSource, parseOptions, parserVersion, &callbacks, NULL);
+
+    if (CFXMLParserParse(parser)) {
+        result = (CFXMLTreeRef)CFXMLParserGetDocument(parser);
+    } else {
+        if (errorDict) {	// collect the error dictionary
+            *errorDict = CFDictionaryCreateMutable(allocator, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+            if (*errorDict) {
+                CFIndex rawnum;
+                CFNumberRef cfnum;
+                CFStringRef errstring;
+                
+                rawnum = CFXMLParserGetLocation(parser);
+                cfnum = CFNumberCreate(allocator, kCFNumberSInt32Type, &rawnum);
+                if(cfnum) {
+                    CFDictionaryAddValue((CFMutableDictionaryRef)*errorDict, kCFXMLTreeErrorLocation, cfnum);
+                    CFRelease(cfnum);                    
+                }
+                
+                rawnum = CFXMLParserGetLineNumber(parser);
+                cfnum = CFNumberCreate(allocator, kCFNumberSInt32Type, &rawnum);
+                if(cfnum) {
+                    CFDictionaryAddValue((CFMutableDictionaryRef)*errorDict, kCFXMLTreeErrorLineNumber, cfnum);
+                    CFRelease(cfnum);                    
+                }
+
+                rawnum = CFXMLParserGetStatusCode(parser);
+                cfnum = CFNumberCreate(allocator, kCFNumberSInt32Type, &rawnum);
+                if(cfnum) {
+                    CFDictionaryAddValue((CFMutableDictionaryRef)*errorDict, kCFXMLTreeErrorStatusCode, cfnum);
+                    CFRelease(cfnum);                    
+                }
+
+                errstring = CFXMLParserCopyErrorDescription(parser);
+                if(errstring) {
+                    CFDictionaryAddValue((CFMutableDictionaryRef)*errorDict, kCFXMLTreeErrorDescription, errstring);
+                    CFRelease(errstring);                    
+                }
+            }
+        }
+        result = (CFXMLTreeRef)CFXMLParserGetDocument(parser);
+        if (result) CFRelease(result);
+        result = NULL;
+    }
+    CFRelease(parser);
+    return result;
+}
+
+/*
+ At the very least we need to do <, >, &, ", and '. In addition, we'll have to do everything else in the string.
+ We should also be handling items that are up over certain values correctly.
+ */
+CFStringRef CFXMLCreateStringByEscapingEntities(CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary) {
+    CFAssert1(string != NULL, __kCFLogAssertion, "%s(): NULL string not permitted.", __PRETTY_FUNCTION__);
+    CFMutableStringRef newString = CFStringCreateMutable(allocator, 0); // unbounded mutable string
+    CFMutableCharacterSetRef startChars = CFCharacterSetCreateMutable(allocator);
+
+    CFStringInlineBuffer inlineBuf;
+    CFIndex idx = 0;
+    CFIndex mark = idx;
+    CFIndex stringLength = CFStringGetLength(string);
+    UniChar uc;
+
+    CFCharacterSetAddCharactersInString(startChars, CFSTR("&<>'\""));
+
+    CFStringInitInlineBuffer(string, &inlineBuf, CFRangeMake(0, stringLength));
+    for(idx = 0; idx < stringLength; idx++) {
+        uc = CFStringGetCharacterFromInlineBuffer(&inlineBuf, idx);
+        if(CFCharacterSetIsCharacterMember(startChars, uc)) {
+            CFStringRef previousSubstring = CFStringCreateWithSubstring(allocator, string, CFRangeMake(mark, idx - mark));
+            CFStringAppend(newString, previousSubstring);
+            CFRelease(previousSubstring);
+            switch(uc) {
+                case '&':
+                    CFStringAppend(newString, CFSTR("&amp;"));
+                    break;
+                case '<':
+                    CFStringAppend(newString, CFSTR("&lt;"));
+                    break;
+                case '>':
+                    CFStringAppend(newString, CFSTR("&gt;"));
+                    break;
+                case '\'':
+                    CFStringAppend(newString, CFSTR("&apos;"));
+                    break;
+                case '"':
+                    CFStringAppend(newString, CFSTR("&quot;"));
+                    break;
+            }
+            mark = idx + 1;
+        }
+    }
+    // Copy the remainder to the output string before returning.
+    CFStringRef remainder = CFStringCreateWithSubstring(allocator, string, CFRangeMake(mark, idx - mark));
+    if (NULL != remainder) {
+        CFStringAppend(newString, remainder);
+        CFRelease(remainder);
+    }
+    
+    CFRelease(startChars);
+    return newString;
+}
+
+CFStringRef CFXMLCreateStringByUnescapingEntities(CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary) {
+    CFAssert1(string != NULL, __kCFLogAssertion, "%s(): NULL string not permitted.", __PRETTY_FUNCTION__);
+
+    CFStringInlineBuffer inlineBuf; /* use this for fast traversal of the string in question */
+    CFStringRef sub;
+    CFIndex lastChunkStart, length = CFStringGetLength(string);
+    CFIndex i, entityStart;
+    UniChar uc;
+    UInt32 entity;
+    int base;
+    CFMutableDictionaryRef fullReplDict = entitiesDictionary ? CFDictionaryCreateMutableCopy(allocator, 0, entitiesDictionary) : CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+    CFDictionaryAddValue(fullReplDict, (const void *)CFSTR("amp"), (const void *)CFSTR("&"));
+    CFDictionaryAddValue(fullReplDict, (const void *)CFSTR("quot"), (const void *)CFSTR("\""));
+    CFDictionaryAddValue(fullReplDict, (const void *)CFSTR("lt"), (const void *)CFSTR("<"));
+    CFDictionaryAddValue(fullReplDict, (const void *)CFSTR("gt"), (const void *)CFSTR(">"));
+    CFDictionaryAddValue(fullReplDict, (const void *)CFSTR("apos"), (const void *)CFSTR("'"));
+
+    CFStringInitInlineBuffer(string, &inlineBuf, CFRangeMake(0, length - 1));
+    CFMutableStringRef newString = CFStringCreateMutable(allocator, 0);
+
+    lastChunkStart = 0;
+    // Scan through the string in its entirety
+    for(i = 0; i < length; ) {
+        uc = CFStringGetCharacterFromInlineBuffer(&inlineBuf, i); i++;	// grab the next character and move i.
+
+        if(uc == '&') {
+            entityStart = i - 1;
+            entity = 0xFFFF;	// set this to a not-Unicode character as sentinel
+                             // we've hit the beginning of an entity. Copy everything from lastChunkStart to this point.
+            if(lastChunkStart < i - 1) {
+                sub = CFStringCreateWithSubstring(allocator, string, CFRangeMake(lastChunkStart, (i - 1) - lastChunkStart));
+                CFStringAppend(newString, sub);
+                CFRelease(sub);
+            }
+
+            uc = CFStringGetCharacterFromInlineBuffer(&inlineBuf, i); i++;	// grab the next character and move i.
+                                                                           // Now we can process the entity reference itself
+            if(uc == '#') {	// this is a numeric entity.
+                base = 10;
+                entity = 0;
+                uc = CFStringGetCharacterFromInlineBuffer(&inlineBuf, i); i++;
+
+                if(uc == 'x') {	// only lowercase x allowed. Translating numeric entity as hexadecimal.
+                    base = 16;
+                    uc = CFStringGetCharacterFromInlineBuffer(&inlineBuf, i); i++;
+                }
+
+                // process the provided digits 'til we're finished
+                while(true) {
+                    if (uc >= '0' && uc <= '9')
+                        entity = entity * base + (uc-'0');
+                    else if (uc >= 'a' && uc <= 'f' && base == 16)
+                        entity = entity * base + (uc-'a'+10);
+                    else if (uc >= 'A' && uc <= 'F' && base == 16)
+                        entity = entity * base + (uc-'A'+10);
+                    else break;
+
+                    if (i < length) {
+                        uc = CFStringGetCharacterFromInlineBuffer(&inlineBuf, i); i++;
+                    }
+                    else
+                        break;
+                }
+            }
+
+            // Scan to the end of the entity
+            while(uc != ';' && i < length) {
+                uc = CFStringGetCharacterFromInlineBuffer(&inlineBuf, i); i++;
+            }
+
+            if(0xFFFF != entity) { // it was numeric, and translated.
+                // Now, output the result fo the entity
+                if(entity >= 0x10000) {
+                    UniChar characters[2] = { ((entity - 0x10000) >> 10) + 0xD800, ((entity - 0x10000) & 0x3ff) + 0xDC00 };
+                    CFStringAppendCharacters(newString, characters, 2);
+                } else {
+                    UniChar character = entity;
+                    CFStringAppendCharacters(newString, &character, 1);
+                }
+            } else {	// it wasn't numeric.
+                sub = CFStringCreateWithSubstring(allocator, string, CFRangeMake(entityStart + 1, (i - entityStart - 2))); // This trims off the & and ; from the string, so we can use it against the dictionary itself.
+                CFStringRef replacementString = (CFStringRef)CFDictionaryGetValue(fullReplDict, sub);
+                if(replacementString) {
+                    CFStringAppend(newString, replacementString);
+                } else {
+                    CFRelease(sub); // let the old substring go, since we didn't find it in the dictionary
+                    sub =  CFStringCreateWithSubstring(allocator, string, CFRangeMake(entityStart, (i - entityStart))); // create a new one, including the & and ;
+                    CFStringAppend(newString, sub); // ...and append that.
+                }
+                CFRelease(sub); // in either case, release the most-recent "sub"
+            }
+
+            // move the lastChunkStart to the beginning of the next chunk.
+            lastChunkStart = i;
+        }
+    }
+    if(lastChunkStart < length) { // we've come out of the loop, let's get the rest of the string and tack it on.
+        sub = CFStringCreateWithSubstring(allocator, string, CFRangeMake(lastChunkStart, i - lastChunkStart));
+        CFStringAppend(newString, sub);
+        CFRelease(sub);
+    }
+
+    CFRelease(fullReplDict);
+
+    return newString;
+}
+
+
diff --git a/CoreFoundation/CFXMLParser.h b/CoreFoundation/CFXMLParser.h
new file mode 100644
index 0000000..591b750
--- /dev/null
+++ b/CoreFoundation/CFXMLParser.h
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_CFXMLPARSER__)
+#define __COREFOUNDATION_CFXMLPARSER__ 1
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFTree.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFXMLNode.h>
+
+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 &lt;.  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 <foo>  <bar> blah </bar></foo>, 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.
+*/
+
+enum {
+    kCFXMLParserValidateDocument = (1 << 0),
+    kCFXMLParserSkipMetaData = (1 << 1),
+    kCFXMLParserReplacePhysicalEntities = (1 << 2),
+    kCFXMLParserSkipWhitespace = (1 << 3),
+    kCFXMLParserResolveExternalEntities = (1 << 4),
+    kCFXMLParserAddImpliedAttributes = (1 << 5),
+    kCFXMLParserAllOptions = 0x00FFFFFF,
+    kCFXMLParserNoOptions = 0
+};
+typedef CFOptionFlags CFXMLParserOptions;
+
+/* This list is expected to grow */
+enum {
+    kCFXMLStatusParseNotBegun = -2,
+    kCFXMLStatusParseInProgress = -1,
+    kCFXMLStatusParseSuccessful = 0,
+    kCFXMLErrorUnexpectedEOF = 1,
+    kCFXMLErrorUnknownEncoding,
+    kCFXMLErrorEncodingConversionFailure,
+    kCFXMLErrorMalformedProcessingInstruction,
+    kCFXMLErrorMalformedDTD,
+    kCFXMLErrorMalformedName,
+    kCFXMLErrorMalformedCDSect,
+    kCFXMLErrorMalformedCloseTag,
+    kCFXMLErrorMalformedStartTag,
+    kCFXMLErrorMalformedDocument,
+    kCFXMLErrorElementlessDocument,
+    kCFXMLErrorMalformedComment,
+    kCFXMLErrorMalformedCharacterReference,
+    kCFXMLErrorMalformedParsedCharacterData,
+    kCFXMLErrorNoData
+};
+typedef CFIndex CFXMLParserStatusCode;
+
+
+/*  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);
+
+/* 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);
+
+/* 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_EXPORT
+void CFXMLParserGetContext(CFXMLParserRef parser, CFXMLParserContext *context);
+
+CF_EXPORT
+void CFXMLParserGetCallBacks(CFXMLParserRef parser, CFXMLParserCallBacks *callBacks);
+
+CF_EXPORT
+CFURLRef CFXMLParserGetSourceURL(CFXMLParserRef parser);
+
+/* Returns the character index of the current parse location */
+CF_EXPORT
+CFIndex CFXMLParserGetLocation(CFXMLParserRef parser);
+
+/* Returns the line number of the current parse location */
+CF_EXPORT
+CFIndex CFXMLParserGetLineNumber(CFXMLParserRef parser);
+
+/* Returns the top-most object returned by the createXMLStructure callback */
+CF_EXPORT
+void *CFXMLParserGetDocument(CFXMLParserRef parser);
+
+/* 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_EXPORT
+CFStringRef CFXMLParserCopyErrorDescription(CFXMLParserRef parser);
+
+/* 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);
+
+/* 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);
+
+/* 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);
+
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+/* Loads the data to be parsed directly from dataSource.  Arguments as above. */
+CF_EXPORT
+CFXMLTreeRef CFXMLTreeCreateWithDataFromURL(CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes);
+
+/* 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);
+
+/* 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) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+CF_EXPORT
+CFStringRef CFXMLCreateStringByUnescapingEntities(CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+
+/* CFXMLTreeCreateFromDataWithError error dictionary key constants. */
+CF_EXPORT const CFStringRef kCFXMLTreeErrorDescription		AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+    /* value is a CFString containing the readable error string. */
+
+CF_EXPORT const CFStringRef kCFXMLTreeErrorLineNumber		AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+    /* value is a CFNumber containing the line on which the error appears. */
+
+CF_EXPORT const CFStringRef kCFXMLTreeErrorLocation		AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+    /* value is a CFNumber containing the byte location at which the error occurred. */
+
+CF_EXPORT const CFStringRef kCFXMLTreeErrorStatusCode		AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+    /* value is a CFNumber containing the error status code. */
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_CFXMLPARSER__ */
+
diff --git a/CoreFoundation/CFXMLPreferencesDomain.c b/CoreFoundation/CFXMLPreferencesDomain.c
new file mode 100644
index 0000000..d1b2ab5
--- /dev/null
+++ b/CoreFoundation/CFXMLPreferencesDomain.c
@@ -0,0 +1,561 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFXMLPreferencesDomain.c
+	Copyright 1998-2002, Apple, Inc. All rights reserved.
+	Responsibility: Chris Parker
+*/
+
+#include <CoreFoundation/CFPreferences.h>
+#include <CoreFoundation/CFURLAccess.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFDate.h>
+#include "CFInternal.h"
+#include <time.h>
+#if DEPLOYMENT_TARGET_MACOSX
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <mach/mach.h>
+#include <mach/mach_syscalls.h>
+#elif DEPLOYMENT_TARGET_WINDOWS
+#include <windows.h>
+#endif
+
+Boolean __CFPreferencesShouldWriteXML(void);
+
+typedef struct {
+    CFMutableDictionaryRef _domainDict; // Current value of the domain dictionary
+    CFMutableArrayRef _dirtyKeys; // The array of keys which must be synchronized
+    CFAbsoluteTime _lastReadTime; // The last time we synchronized with the disk
+    CFSpinLock_t _lock; // Lock for accessing fields in the domain
+    Boolean _isWorldReadable; // HACK - this is because we have no good way to propogate the kCFPreferencesAnyUser information from the upper level CFPreferences routines  REW, 1/13/00
+    char _padding[3];
+} _CFXMLPreferencesDomain;
+
+static void *createXMLDomain(CFAllocatorRef allocator, CFTypeRef context);
+static void freeXMLDomain(CFAllocatorRef allocator, CFTypeRef context, void *tDomain);
+static CFTypeRef fetchXMLValue(CFTypeRef context, void *xmlDomain, CFStringRef key);
+static void writeXMLValue(CFTypeRef context, void *xmlDomain, CFStringRef key, CFTypeRef value);
+static Boolean synchronizeXMLDomain(CFTypeRef context, void *xmlDomain);
+static void getXMLKeysAndValues(CFAllocatorRef alloc, CFTypeRef context, void *xmlDomain, void **buf[], CFIndex *numKeyValuePairs);
+static CFDictionaryRef copyXMLDomainDictionary(CFTypeRef context, void *domain);
+static void setXMLDomainIsWorldReadable(CFTypeRef context, void *domain, Boolean isWorldReadable);
+
+__private_extern__ const _CFPreferencesDomainCallBacks __kCFXMLPropertyListDomainCallBacks = {createXMLDomain, freeXMLDomain, fetchXMLValue, writeXMLValue, synchronizeXMLDomain, getXMLKeysAndValues, copyXMLDomainDictionary, setXMLDomainIsWorldReadable};
+
+// Directly ripped from Foundation....
+static void __CFMilliSleep(uint32_t msecs) {
+#if defined(__svr4__) || defined(__hpux__)
+    sleep((msecs + 900) / 1000);
+#elif DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX
+    struct timespec input;
+    input.tv_sec = msecs / 1000;
+    input.tv_nsec = (msecs - input.tv_sec * 1000) * 1000000;
+    nanosleep(&input, NULL);
+#elif DEPLOYMENT_TARGET_WINDOWS
+    Sleep((msecs + 900) / 1000);
+#else
+#error Dont know how to define sleep for this platform
+#endif
+}
+
+static CFSpinLock_t _propDictLock = CFSpinLockInit; // Annoying that we need this, but otherwise we have a multithreading risk
+
+CF_INLINE CFDictionaryRef URLPropertyDictForPOSIXMode(SInt32 mode) {
+    static CFMutableDictionaryRef _propertyDict = NULL;
+    CFNumberRef num = CFNumberCreate(__CFPreferencesAllocator(), kCFNumberSInt32Type, &mode);
+    __CFSpinLock(&_propDictLock);
+    if (!_propertyDict) {
+        _propertyDict = CFDictionaryCreateMutable(__CFPreferencesAllocator(), 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    }
+    CFDictionarySetValue(_propertyDict, kCFURLFilePOSIXMode, num);
+    CFRelease(num);
+    return _propertyDict;
+}
+
+CF_INLINE void URLPropertyDictRelease(void) {
+    __CFSpinUnlock(&_propDictLock);
+}
+
+// Asssumes caller already knows the directory doesn't exist.
+static Boolean _createDirectory(CFURLRef dirURL, Boolean worldReadable) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(alloc, dirURL);
+    CFBooleanRef val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, parentURL, kCFURLFileExists, NULL);
+    Boolean parentExists = (val && CFBooleanGetValue(val));
+    SInt32 mode;
+    Boolean result;
+    if (val) CFRelease(val);
+    if (!parentExists) {
+        CFStringRef path = CFURLCopyPath(parentURL);
+        if (!CFEqual(path, CFSTR("/"))) {
+            _createDirectory(parentURL, worldReadable);
+            val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, parentURL, kCFURLFileExists, NULL);
+            parentExists = (val && CFBooleanGetValue(val));
+            if (val) CFRelease(val);
+        }
+        CFRelease(path);
+    }
+    if (parentURL) CFRelease(parentURL);
+    if (!parentExists) return false;
+
+#if DEPLOYMENT_TARGET_MACOSX
+    mode = worldReadable ? S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH : S_IRWXU;
+#else
+    mode = 0666;
+#endif
+
+    result = CFURLWriteDataAndPropertiesToResource(dirURL, (CFDataRef)dirURL, URLPropertyDictForPOSIXMode(mode), NULL);
+    URLPropertyDictRelease();
+    return result;
+}
+
+
+/* XML - context is the CFURL where the property list is stored on disk; domain is an _CFXMLPreferencesDomain */
+static void *createXMLDomain(CFAllocatorRef allocator, CFTypeRef context) {
+    _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain*) CFAllocatorAllocate(allocator, sizeof(_CFXMLPreferencesDomain), 0);
+    domain->_lastReadTime = 0.0;
+    domain->_domainDict = NULL;
+    domain->_dirtyKeys = CFArrayCreateMutable(allocator, 0, & kCFTypeArrayCallBacks);
+    const CFSpinLock_t lock = CFSpinLockInit;
+    domain->_lock = lock;
+    domain->_isWorldReadable = false;
+    return domain;
+}
+
+static void freeXMLDomain(CFAllocatorRef allocator, CFTypeRef context, void *tDomain) {
+    _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)tDomain;
+    if (domain->_domainDict) CFRelease(domain->_domainDict);
+    if (domain->_dirtyKeys) CFRelease(domain->_dirtyKeys);
+    CFAllocatorDeallocate(allocator, domain);
+}
+
+// Assumes the domain has already been locked
+static void _loadXMLDomainIfStale(CFURLRef url, _CFXMLPreferencesDomain *domain) {
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    int idx;
+    if (domain->_domainDict) {
+        CFDateRef modDate;
+        CFAbsoluteTime modTime;
+    	CFURLRef testURL = url;
+
+        if (CFDictionaryGetCount(domain->_domainDict) == 0) {
+            // domain never existed; check the parent directory, not the child
+            testURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR(".."), kCFURLPOSIXPathStyle, true, url);
+        }
+
+        modDate = (CFDateRef )CFURLCreatePropertyFromResource(alloc, testURL, kCFURLFileLastModificationTime, NULL);
+        modTime = modDate ? CFDateGetAbsoluteTime(modDate) : 0.0;
+
+        // free before possible return. we can test non-NULL of modDate but don't depend on contents after this.
+        if (testURL != url) CFRelease(testURL);
+        if (modDate) CFRelease(modDate);
+        
+        if (modDate != NULL && modTime < domain->_lastReadTime) {            // We're up-to-date
+            return;
+        }
+    }
+
+	
+    // We're out-of-date; destroy domainDict and reload
+    if (domain->_domainDict) {
+        CFRelease(domain->_domainDict);
+        domain->_domainDict = NULL;
+    }
+
+    // We no longer lock on read; instead, we assume parse failures are because someone else is writing the file, and just try to parse again.  If we fail 3 times in a row, we assume the file is corrupted.  REW, 7/13/99
+
+    for (idx = 0; idx < 3; idx ++) {
+        CFDataRef data;
+        if (!CFURLCreateDataAndPropertiesFromResource(alloc, url, &data, NULL, NULL, NULL) || !data) {
+            // Either a file system error (so we can't read the file), or an empty (or perhaps non-existant) file
+            domain->_domainDict = CFDictionaryCreateMutable(alloc, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+            break;
+        } else {
+            CFTypeRef pList = CFPropertyListCreateFromXMLData(alloc, data, kCFPropertyListImmutable, NULL);
+            CFRelease(data);
+            if (pList && CFGetTypeID(pList) == CFDictionaryGetTypeID()) {
+                domain->_domainDict = CFDictionaryCreateMutableCopy(alloc, 0, (CFDictionaryRef)pList);
+                CFRelease(pList);
+                break;
+            } else if (pList) {
+                CFRelease(pList);
+            }
+            // Assume the file is being written; sleep for a short time (to allow the write to complete) then re-read
+            __CFMilliSleep(150);
+        }
+    }
+    if (!domain->_domainDict) {
+        // Failed to ever load
+        domain->_domainDict = CFDictionaryCreateMutable(alloc, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    }
+    domain->_lastReadTime = CFAbsoluteTimeGetCurrent();
+}
+
+static CFTypeRef fetchXMLValue(CFTypeRef context, void *xmlDomain, CFStringRef key) {
+    _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)xmlDomain;
+    CFTypeRef result;
+ 
+    // Never reload if we've looked at the file system within the last 5 seconds.
+    __CFSpinLock(&domain->_lock);
+    if (domain->_domainDict == NULL) _loadXMLDomainIfStale((CFURLRef )context, domain);
+    result = CFDictionaryGetValue(domain->_domainDict, key);
+    if (result) CFRetain(result); 
+    __CFSpinUnlock(&domain->_lock);
+
+    return result;
+}
+
+
+#if ( DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX ) && !defined(DEPLOYMENT_TARGET_ANDROID)
+#include <grp.h>
+#include <stdio.h>
+#include <sys/fcntl.h>
+
+#define __kCFAdminGroupName       "admin"
+#define __kCFAdminFallbackGroupID 80
+
+/* __CFWriteBytesToFileWithAtomicity is a "safe save" facility. Write the bytes using the specified mode on the file to the provided URL. If the atomic flag is true, try to do it in a fashion that will enable a safe save.
+ */
+static Boolean __CFWriteBytesToFileWithAtomicity(CFURLRef url, const void *bytes, int length, SInt32 mode, Boolean atomic) {
+    int fd = -1;
+    char auxPath[CFMaxPathSize + 16];
+    char cpath[CFMaxPathSize];
+    uid_t owner = getuid();
+    gid_t group = getgid();
+    Boolean writingFileAsRoot = ((getuid() != geteuid()) && (geteuid() == 0));
+    
+    if (!CFURLGetFileSystemRepresentation(url, true, (uint8_t *)cpath, CFMaxPathSize)) {
+        return false;
+    }
+    
+    if (-1 == mode || writingFileAsRoot) {
+        struct stat statBuf;
+        if (0 == stat(cpath, &statBuf)) {
+            mode = statBuf.st_mode;
+            owner = statBuf.st_uid;
+            group = statBuf.st_gid;
+        } else {
+            mode = 0664;
+            if (writingFileAsRoot && (0 == strncmp(cpath, "/Library/Preferences", 20))) {
+                const struct group *grent;
+                owner = geteuid();
+                grent = getgrnam(__kCFAdminGroupName);
+                group = grent ? grent->gr_gid : __kCFAdminFallbackGroupID;
+            }
+        }
+    }
+    
+    if (atomic) {
+        CFURLRef dir = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorSystemDefault, url);
+        CFURLRef tempFile = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, dir, CFSTR("cf#XXXXXX"), false);
+        CFRelease(dir);
+        if (!CFURLGetFileSystemRepresentation(tempFile, true, (uint8_t *)auxPath, CFMaxPathSize)) {
+            CFRelease(tempFile);
+            return false;
+        }
+        CFRelease(tempFile);
+        fd = mkstemp(auxPath);
+    } else {
+        fd = open(cpath, O_WRONLY|O_CREAT|O_TRUNC, mode);
+    }
+    
+    if (fd < 0) return false;
+    
+    if (length && (write(fd, bytes, length) != length || fsync(fd) < 0)) {
+        int saveerr = thread_errno();
+        close(fd);
+        if (atomic)
+            unlink(auxPath);
+        thread_set_errno(saveerr);
+        return false;
+    }
+    
+    close(fd);
+    
+    if (atomic) {
+        // preserve the mode as passed in originally
+        chmod(auxPath, mode);
+                
+        if (0 != rename(auxPath, cpath)) {
+            unlink(auxPath);
+            return false;
+        }
+        
+        // If the file was renamed successfully and we wrote it as root we need to reset the owner & group as they were.
+        if (writingFileAsRoot) {
+            chown(cpath, owner, group);
+        }
+    }
+    return true;
+}
+#endif
+
+// domain should already be locked.
+static Boolean _writeXMLFile(CFURLRef url, CFMutableDictionaryRef dict, Boolean isWorldReadable, Boolean *tryAgain) {
+    Boolean success = false;
+    CFAllocatorRef alloc = __CFPreferencesAllocator();
+    *tryAgain = false;
+    if (CFDictionaryGetCount(dict) == 0) {
+        // Destroy the file
+        CFBooleanRef val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, url, kCFURLFileExists, NULL);
+        if (val && CFBooleanGetValue(val)) {
+            success = CFURLDestroyResource(url, NULL);
+        } else {
+            success = true;
+        }
+        if (val) CFRelease(val);
+    } else {
+        CFPropertyListFormat desiredFormat = __CFPreferencesShouldWriteXML() ? kCFPropertyListXMLFormat_v1_0 : kCFPropertyListBinaryFormat_v1_0;
+        CFWriteStreamRef binStream = CFWriteStreamCreateWithAllocatedBuffers(alloc, alloc);
+        CFWriteStreamOpen(binStream);
+        CFPropertyListWriteToStream(dict, binStream, desiredFormat, NULL);
+        CFWriteStreamClose(binStream);
+        CFDataRef data = (CFDataRef) CFWriteStreamCopyProperty(binStream, kCFStreamPropertyDataWritten);
+        CFRelease(binStream);
+        if (data) {
+            SInt32 mode;
+#if ( DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX ) && !defined(DEPLOYMENT_TARGET_ANDROID)
+            mode = isWorldReadable ? S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH : S_IRUSR|S_IWUSR;
+#else
+	    mode = 0666;
+#endif
+#if ( DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX ) && !defined(DEPLOYMENT_TARGET_ANDROID)
+            {	// Try quick atomic way first, then fallback to slower ways and error cases
+                CFStringRef scheme = CFURLCopyScheme(url);
+                if (!scheme) {
+                    *tryAgain = false;
+                    CFRelease(data);
+                    return false;
+                } else if (CFStringCompare(scheme, CFSTR("file"), 0) == kCFCompareEqualTo) {
+                    SInt32 length = CFDataGetLength(data);
+                    const void *bytes = (0 == length) ? (const void *)"" : CFDataGetBytePtr(data);
+                    Boolean atomicWriteSuccess = __CFWriteBytesToFileWithAtomicity(url, bytes, length, mode, true);
+                    if (atomicWriteSuccess) {
+                        CFRelease(scheme);
+                        *tryAgain = false;
+                        CFRelease(data);
+                        return true;
+                    }
+                    if (!atomicWriteSuccess && thread_errno() == ENOSPC) {
+                        CFRelease(scheme);
+                        *tryAgain = false;
+                        CFRelease(data);
+                        return false;
+                    }
+                }
+                CFRelease(scheme);
+            }
+#endif
+            success = CFURLWriteDataAndPropertiesToResource(url, data, URLPropertyDictForPOSIXMode(mode), NULL);
+            URLPropertyDictRelease();
+            if (success) {
+                CFDataRef readData;
+                if (!CFURLCreateDataAndPropertiesFromResource(alloc, url, &readData, NULL, NULL, NULL) || !CFEqual(readData, data)) {
+                    success = false;
+                    *tryAgain = true;
+                }
+                if (readData) CFRelease(readData);
+            } else {
+                CFBooleanRef val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, url, kCFURLFileExists, NULL);
+                if (!val || !CFBooleanGetValue(val)) {
+                    CFURLRef tmpURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("."), kCFURLPOSIXPathStyle, true, url); // Just "." because url is not a directory URL
+                    CFURLRef parentURL = tmpURL ? CFURLCopyAbsoluteURL(tmpURL) : NULL;
+                    if (tmpURL) CFRelease(tmpURL);
+                    if (val) CFRelease(val);
+                    val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, parentURL, kCFURLFileExists, NULL);
+                    if ((!val || !CFBooleanGetValue(val)) && _createDirectory(parentURL, isWorldReadable)) {
+                        // parent directory didn't exist; now it does; try again to write
+                        success = CFURLWriteDataAndPropertiesToResource(url, data, URLPropertyDictForPOSIXMode(mode), NULL);
+                        URLPropertyDictRelease();
+                        if (success) {
+                            CFDataRef rdData;
+                            if (!CFURLCreateDataAndPropertiesFromResource(alloc, url, &rdData, NULL, NULL, NULL) || !CFEqual(rdData, data)) {
+                                success = false;
+                                *tryAgain = true;
+                            }
+                            if (rdData) CFRelease(rdData);
+                        }
+                        
+                    }
+                    if (parentURL) CFRelease(parentURL);
+                }
+                if (val) CFRelease(val);
+            }
+            CFRelease(data);
+        } else {
+            // ???  This should never happen
+            CFLog(__kCFLogAssertion, CFSTR("Could not generate XML data for property list"));
+            success = false;
+        }
+    }
+    return success;
+}
+
+static void writeXMLValue(CFTypeRef context, void *xmlDomain, CFStringRef key, CFTypeRef value) {
+    _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)xmlDomain;
+    const void *existing = NULL;
+
+    __CFSpinLock(&domain->_lock);
+    if (domain->_domainDict == NULL) {
+        _loadXMLDomainIfStale((CFURLRef )context, domain);
+    }
+
+	// check to see if the value is the same
+	// if (1) the key is present AND value is !NULL and equal to existing, do nothing, or
+	// if (2) the key is not present AND value is NULL, do nothing
+	// these things are no-ops, and should not dirty the domain
+    if (CFDictionaryGetValueIfPresent(domain->_domainDict, key, &existing)) {
+	if (NULL != value && (existing == value || CFEqual(existing, value))) {
+	    __CFSpinUnlock(&domain->_lock);
+	    return;
+	}
+    } else {
+	if (NULL == value) {
+	    __CFSpinUnlock(&domain->_lock);
+	    return;
+	}
+    }
+
+	// We must append first so key gets another retain (in case we're
+	// about to remove it from the dictionary, and that's the sole reference)
+    // This should be a set not an array.
+    if (!CFArrayContainsValue(domain->_dirtyKeys, CFRangeMake(0, CFArrayGetCount(domain->_dirtyKeys)), key)) {
+	CFArrayAppendValue(domain->_dirtyKeys, key);
+    }
+    if (value) {
+        // Must copy for two reasons - we don't want mutable objects in the cache, and we don't want objects allocated from a different allocator in the cache.
+        CFTypeRef newValue = CFPropertyListCreateDeepCopy(__CFPreferencesAllocator(), value, kCFPropertyListImmutable);
+        CFDictionarySetValue(domain->_domainDict, key, newValue);
+        CFRelease(newValue);
+    } else {
+        CFDictionaryRemoveValue(domain->_domainDict, key);
+    }
+    __CFSpinUnlock(&domain->_lock);
+}
+
+static void getXMLKeysAndValues(CFAllocatorRef alloc, CFTypeRef context, void *xmlDomain, void **buf[], CFIndex *numKeyValuePairs) {
+    _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)xmlDomain;
+    CFIndex count;
+    __CFSpinLock(&domain->_lock);
+    if (!domain->_domainDict) {
+        _loadXMLDomainIfStale((CFURLRef )context, domain);
+    }
+    count = CFDictionaryGetCount(domain->_domainDict);
+    if (buf) {
+        void **values;
+        if (count <= *numKeyValuePairs) {
+            values = *buf + count;
+            CFDictionaryGetKeysAndValues(domain->_domainDict, (const void **)*buf, (const void **)values);
+        } else if (alloc != kCFAllocatorNull) {
+	    *buf = (void**) CFAllocatorReallocate(alloc, (*buf ? *buf : NULL), count * 2 * sizeof(void *), 0);
+            if (*buf) {
+                values = *buf + count;
+                CFDictionaryGetKeysAndValues(domain->_domainDict, (const void **)*buf, (const void **)values);
+            }
+        }
+    }
+    *numKeyValuePairs = count;
+    __CFSpinUnlock(&domain->_lock);
+}
+
+static CFDictionaryRef copyXMLDomainDictionary(CFTypeRef context, void *xmlDomain) {
+    _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)xmlDomain;
+    CFDictionaryRef result;
+    
+    __CFSpinLock(&domain->_lock);
+    if(!domain->_domainDict) {
+        _loadXMLDomainIfStale((CFURLRef)context, domain);
+    }
+    
+    result = (CFDictionaryRef)CFPropertyListCreateDeepCopy(__CFPreferencesAllocator(), domain->_domainDict, kCFPropertyListImmutable);
+    
+    __CFSpinUnlock(&domain->_lock);
+    return result;
+}
+
+
+static void setXMLDomainIsWorldReadable(CFTypeRef context, void *domain, Boolean isWorldReadable) {
+    ((_CFXMLPreferencesDomain *)domain)->_isWorldReadable = isWorldReadable;
+}
+
+static Boolean synchronizeXMLDomain(CFTypeRef context, void *xmlDomain) {
+    _CFXMLPreferencesDomain *domain = (_CFXMLPreferencesDomain *)xmlDomain;
+    CFMutableDictionaryRef cachedDict;
+    CFMutableArrayRef changedKeys;
+    SInt32 idx,  count;
+    Boolean success, tryAgain;
+    
+    __CFSpinLock(&domain->_lock);
+    cachedDict = domain->_domainDict;
+    changedKeys = domain->_dirtyKeys;
+    count = CFArrayGetCount(changedKeys);
+    
+    if (count == 0) {
+        // no changes were made to this domain; just remove it from the cache to guarantee it will be taken from disk next access
+        if (cachedDict) {
+            CFRelease(cachedDict);
+            domain->_domainDict = NULL;
+        }
+        __CFSpinUnlock(&domain->_lock);
+        return true;
+    }
+
+    domain->_domainDict = NULL; // This forces a reload.  Note that we now have a retain on cachedDict
+    do {
+        _loadXMLDomainIfStale((CFURLRef )context, domain);
+        // now cachedDict holds our changes; domain->_domainDict has the latest version from the disk
+        for (idx = 0; idx < count; idx ++) {
+            CFStringRef key = (CFStringRef) CFArrayGetValueAtIndex(changedKeys, idx);
+            CFTypeRef value = CFDictionaryGetValue(cachedDict, key);
+            if (value)
+                CFDictionarySetValue(domain->_domainDict, key, value);
+            else
+                CFDictionaryRemoveValue(domain->_domainDict, key);
+        }
+        success = _writeXMLFile((CFURLRef )context, domain->_domainDict, domain->_isWorldReadable, &tryAgain);
+        if (tryAgain) {
+            __CFMilliSleep((((uint32_t)__CFReadTSR() & 0xf) + 1) * 50);
+        }
+    } while (tryAgain);
+    CFRelease(cachedDict);
+    if (success) {
+	CFArrayRemoveAllValues(domain->_dirtyKeys);
+    }
+    domain->_lastReadTime = CFAbsoluteTimeGetCurrent();
+    __CFSpinUnlock(&domain->_lock);
+    return success;
+}
+
+
diff --git a/CoreFoundation/CFXMLTree.c b/CoreFoundation/CFXMLTree.c
new file mode 100644
index 0000000..c5bd915
--- /dev/null
+++ b/CoreFoundation/CFXMLTree.c
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	CFXMLTree.c
+	Copyright 1999-2002, Apple, Inc. All rights reserved.
+	Responsibility: Chris Parker
+*/
+
+#include "CFInternal.h"
+#include <CoreFoundation/CFXMLParser.h>
+
+/*************/
+/* CFXMLTree */
+/*************/
+
+/* Creates a childless node from desc */
+CFXMLTreeRef CFXMLTreeCreateWithNode(CFAllocatorRef allocator, CFXMLNodeRef node) {
+    CFTreeContext treeCtxt;
+    treeCtxt.version = 0;
+    treeCtxt.info = (void *)node;
+    treeCtxt.retain = CFRetain;
+    treeCtxt.release = CFRelease;
+    treeCtxt.copyDescription = CFCopyDescription;
+    return CFTreeCreate(allocator, &treeCtxt);
+}
+
+CFXMLNodeRef CFXMLTreeGetNode(CFXMLTreeRef xmlNode) {
+    CFTreeContext treeContext;
+    treeContext.version = 0;
+    CFTreeGetContext(xmlNode, &treeContext);
+    return (CFXMLNodeRef)treeContext.info;
+}
+
+// We will probably ultimately want to export this under some public API name
+__private_extern__ Boolean CFXMLTreeEqual(CFXMLTreeRef xmlTree1, CFXMLTreeRef xmlTree2) {
+    CFXMLNodeRef node1, node2;
+    CFXMLTreeRef child1, child2;
+    if (CFTreeGetChildCount(xmlTree1) != CFTreeGetChildCount(xmlTree2)) return false;
+    node1 = CFXMLTreeGetNode(xmlTree1);
+    node2 = CFXMLTreeGetNode(xmlTree2);
+    if (!CFEqual(node1, node2)) return false;
+    for (child1 = CFTreeGetFirstChild(xmlTree1), child2 = CFTreeGetFirstChild(xmlTree2); child1 && child2; child1 = CFTreeGetNextSibling(child1), child2 = CFTreeGetNextSibling(child2)) {
+        if (!CFXMLTreeEqual(child1, child2)) return false;
+    }
+    return true;
+}
+
+static void _CFAppendXML(CFMutableStringRef str, CFXMLTreeRef tree);
+static void _CFAppendXMLProlog(CFMutableStringRef str, const CFXMLTreeRef node);
+static void _CFAppendXMLEpilog(CFMutableStringRef str, const CFXMLTreeRef node);
+
+CFDataRef CFXMLTreeCreateXMLData(CFAllocatorRef allocator, CFXMLTreeRef xmlTree) {
+    CFMutableStringRef xmlStr; 
+    CFDataRef result;
+    CFStringEncoding encoding;
+
+    __CFGenericValidateType(xmlTree, CFTreeGetTypeID());
+    
+    xmlStr = CFStringCreateMutable(allocator, 0);
+    _CFAppendXML(xmlStr, xmlTree);
+    if (CFXMLNodeGetTypeCode(CFXMLTreeGetNode(xmlTree)) == kCFXMLNodeTypeDocument) {
+        const CFXMLDocumentInfo *docData = (CFXMLDocumentInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(xmlTree));
+        encoding = docData ? docData->encoding : kCFStringEncodingUTF8;
+    } else {
+        encoding = kCFStringEncodingUTF8;
+    }
+    result = CFStringCreateExternalRepresentation(allocator, xmlStr, encoding, 0);
+    CFRelease(xmlStr);
+    return result;
+}
+
+static void _CFAppendXML(CFMutableStringRef str, CFXMLTreeRef tree) {
+    CFXMLTreeRef child;
+    _CFAppendXMLProlog(str, tree);
+    for (child = CFTreeGetFirstChild(tree); child; child = CFTreeGetNextSibling(child)) {
+        _CFAppendXML(str, child);
+    }
+    _CFAppendXMLEpilog(str, tree);
+}
+
+__private_extern__ void appendQuotedString(CFMutableStringRef str, CFStringRef strToQuote) {
+    char quoteChar = CFStringFindWithOptions(strToQuote, CFSTR("\""), CFRangeMake(0, CFStringGetLength(strToQuote)), 0, NULL) ? '\'' : '\"';
+    CFStringAppendFormat(str, NULL, CFSTR("%c%@%c"), quoteChar, strToQuote, quoteChar);
+}
+
+static void appendExternalID(CFMutableStringRef str, CFXMLExternalID *extID) {
+    if (extID->publicID) {
+        CFStringAppendCString(str, " PUBLIC ", kCFStringEncodingASCII);
+        appendQuotedString(str, extID->publicID);
+        if (extID->systemID) {
+            // Technically, for externalIDs, systemID must not be NULL.  However, by testing for a NULL systemID, we can use this to emit publicIDs, too.  REW, 2/15/2000
+            CFStringAppendCString(str, " ", kCFStringEncodingASCII);
+            appendQuotedString(str, CFURLGetString(extID->systemID));
+        }
+    } else if (extID->systemID) {
+        CFStringAppendCString(str, " SYSTEM ", kCFStringEncodingASCII);
+        appendQuotedString(str, CFURLGetString(extID->systemID));
+    } else {
+        // Should never get here
+    }
+}
+
+static void appendElementProlog(CFMutableStringRef str, CFXMLTreeRef tree) {
+    const CFXMLElementInfo *data = (CFXMLElementInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree));
+    CFStringAppendFormat(str, NULL, CFSTR("<%@"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+    if (data->attributeOrder) {
+        CFIndex i, c = CFArrayGetCount(data->attributeOrder);
+        for (i = 0; i < c; i ++) {
+            CFStringRef attr = (CFStringRef)CFArrayGetValueAtIndex(data->attributeOrder, i);
+            CFStringRef value = (CFStringRef)CFDictionaryGetValue(data->attributes, attr);
+            CFStringAppendFormat(str, NULL, CFSTR(" %@="), attr);
+            appendQuotedString(str, value);
+        }
+    }
+    if (data->isEmpty) {
+        CFStringAppendCString(str, "/>", kCFStringEncodingASCII);
+    } else {
+        CFStringAppendCString(str, ">", kCFStringEncodingASCII);
+    }
+}
+
+/* Although named "prolog", for leafs of the tree, this is the only XML generation function called.  This is why Comments, Processing Instructions, etc. generate their XML during this function.  REW, 2/11/2000 */
+static void _CFAppendXMLProlog(CFMutableStringRef str, const CFXMLTreeRef tree) {
+    switch (CFXMLNodeGetTypeCode(CFXMLTreeGetNode(tree))) {
+        case kCFXMLNodeTypeDocument:
+            break;
+        case kCFXMLNodeTypeElement:
+            appendElementProlog(str, tree);
+            break;
+        case kCFXMLNodeTypeAttribute:
+            // Should never be encountered
+            break;
+        case kCFXMLNodeTypeProcessingInstruction: {
+            CFXMLProcessingInstructionInfo *data = (CFXMLProcessingInstructionInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree));
+            if (data->dataString) {
+                CFStringAppendFormat(str, NULL, CFSTR("<?%@ %@?>"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)), data->dataString);
+            } else {
+                CFStringAppendFormat(str, NULL, CFSTR("<?%@?>"));
+            }
+            break;
+        }
+        case kCFXMLNodeTypeComment:
+            CFStringAppendFormat(str, NULL, CFSTR("<!--%@-->"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            break;
+        case kCFXMLNodeTypeText:
+            CFStringAppend(str, CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            break;
+        case kCFXMLNodeTypeCDATASection:
+            CFStringAppendFormat(str, NULL, CFSTR("<![CDATA[%@]]>"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            break;
+        case kCFXMLNodeTypeDocumentFragment:
+            break;
+        case kCFXMLNodeTypeEntity: {
+            CFXMLEntityInfo *data = (CFXMLEntityInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree));
+            CFStringAppendCString(str, "<!ENTITY ", kCFStringEncodingASCII);
+            if (data->entityType == kCFXMLEntityTypeParameter) {
+                CFStringAppend(str, CFSTR("% "));
+            }
+            CFStringAppend(str, CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            CFStringAppend(str, CFSTR(" "));
+            if (data->replacementText) {
+                appendQuotedString(str, data->replacementText);
+                CFStringAppendCString(str, ">", kCFStringEncodingASCII);
+            } else {
+                appendExternalID(str, &(data->entityID));
+                if (data->notationName) {
+                    CFStringAppendFormat(str, NULL, CFSTR(" NDATA %@"), data->notationName);
+                }
+                CFStringAppendCString(str, ">", kCFStringEncodingASCII);
+            }
+                break;
+        }
+        case kCFXMLNodeTypeEntityReference:
+        {
+            CFXMLEntityTypeCode entityType = ((CFXMLEntityReferenceInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree)))->entityType;
+            if (entityType == kCFXMLEntityTypeParameter) {
+                CFStringAppendFormat(str, NULL, CFSTR("%%%@;"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            } else {
+                CFStringAppendFormat(str, NULL, CFSTR("&%@;"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            }
+            break;
+        }
+        case kCFXMLNodeTypeDocumentType:
+            CFStringAppendCString(str, "<!DOCTYPE ", kCFStringEncodingASCII);
+            CFStringAppend(str, CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            if (CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree))) {
+                CFXMLExternalID *extID = &((CFXMLDocumentTypeInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree)))->externalID;
+                appendExternalID(str, extID);
+            }
+                CFStringAppendCString(str, " [", kCFStringEncodingASCII);
+            break;
+        case kCFXMLNodeTypeWhitespace:
+            CFStringAppend(str, CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            break;
+        case kCFXMLNodeTypeNotation: {
+            CFXMLNotationInfo *data = (CFXMLNotationInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree));
+            CFStringAppendFormat(str, NULL, CFSTR("<!NOTATION %@ "), CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            appendExternalID(str, &(data->externalID));
+                CFStringAppendCString(str, ">", kCFStringEncodingASCII);
+            break;
+        }
+        case kCFXMLNodeTypeElementTypeDeclaration:
+            CFStringAppendFormat(str, NULL, CFSTR("<!ELEMENT %@ %@>"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)), ((CFXMLElementTypeDeclarationInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree)))->contentDescription);
+            break;
+        case kCFXMLNodeTypeAttributeListDeclaration: {
+            CFXMLAttributeListDeclarationInfo *attListData = (CFXMLAttributeListDeclarationInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree));
+            CFIndex idx;
+            CFStringAppendCString(str, "<!ATTLIST ", kCFStringEncodingASCII);
+            CFStringAppend(str, CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+            for (idx = 0; idx < attListData->numberOfAttributes; idx ++) {
+                CFXMLAttributeDeclarationInfo *attr = &(attListData->attributes[idx]);
+                CFStringAppendFormat(str, NULL, CFSTR("\n\t%@ %@ %@"), attr->attributeName, attr->typeString, attr->defaultString);
+            }
+            CFStringAppendCString(str, ">", kCFStringEncodingASCII);
+            break;
+        }
+        default:
+            CFAssert1(false, __kCFLogAssertion, "Encountered unexpected XMLDataTypeID %d", CFXMLNodeGetTypeCode(CFXMLTreeGetNode(tree)));
+    }
+}
+
+static void _CFAppendXMLEpilog(CFMutableStringRef str, const CFXMLTreeRef tree) {
+    CFXMLNodeTypeCode typeID = CFXMLNodeGetTypeCode(CFXMLTreeGetNode(tree));
+    if (typeID == kCFXMLNodeTypeElement) {
+        if (((CFXMLElementInfo *)CFXMLNodeGetInfoPtr(CFXMLTreeGetNode(tree)))->isEmpty) return;
+        CFStringAppendFormat(str, NULL, CFSTR("</%@>"), CFXMLNodeGetString(CFXMLTreeGetNode(tree)));
+    } else if (typeID == kCFXMLNodeTypeDocumentType) {
+        CFIndex len = CFStringGetLength(str);
+        if (CFStringHasSuffix(str, CFSTR(" ["))) {
+            // There were no in-line DTD elements
+            CFStringDelete(str, CFRangeMake(len-2, 2));
+        } else {
+            CFStringAppendCString(str, "]", kCFStringEncodingASCII);
+        }
+        CFStringAppendCString(str, ">", kCFStringEncodingASCII);
+    }
+}
+
+
diff --git a/CoreFoundation/CHANGES b/CoreFoundation/CHANGES
new file mode 100644
index 0000000..db64703
--- /dev/null
+++ b/CoreFoundation/CHANGES
@@ -0,0 +1,40 @@
+                      Changes and What's New in OpenCFLite
+                      ------------------------------------
+
+2009-03-11 v476.17.2
+
+  * Fixed run loop timer support for Linux.
+
+  * Updated pre-compiled ICU to v4.0 for Windows builds.
+
+  * Minor updates to CFRunLoopTimerExample and StringExample examples.
+
+  * Merged in David Cotter's <me@davidcotter.com> CF-Lite project,
+    including his additional CFTest example.
+
+  * Fixed support for writing binary property lists with patch from Stuart
+    Crook <stuart@echus.demon.co.uk>.
+
+2007-02-11 v476.17.1
+
+  * Basic, development-level run loop support for Windows and Linux.
+
+  * Ensure private globals are marked as such on non-Apple GCC
+    compilers.
+
+  * Added DisplayURL, DNSServiceMetaQuery, CFLocalServer and
+    CFRunLoopTimer examples.
+
+  * Added appropriate preprocessor checks for __powerpc__ to handle
+    PowerPC compilers that emit that rather than __ppc__.
+
+  * Windows and Mac OS X build clean-ups.
+
+  * Improved Linux build configuration by respecting '--with' options
+    in preference to the presence of <foo>-config and, in general,
+    improved behavior in cross-compilation scenarios and in error
+    cases.
+
+2007-02-06 v476.17.0
+
+  * Initial release for Windows and Linux
diff --git a/CoreFoundation/CONTRIBUTORS b/CoreFoundation/CONTRIBUTORS
new file mode 100644
index 0000000..2193d4f
--- /dev/null
+++ b/CoreFoundation/CONTRIBUTORS
@@ -0,0 +1,40 @@
+Contributors
+------------
+March 2000: partial port to Linux by Pedro Ivo Tavares (ptavares@iname.com).
+	This was mostly integrated by ckane@apple.com by CoreFoundation-5,
+	but the style was changed, and the hand-crafted Makefile, which is
+	new since this port, tries to take care of some of the things that
+	are needed for Linux (and build a libCoreFoundation.a instead of a
+	CoreFoundation.framework), but ckane does not have a Linux box and
+	can't finish that and test building.
+
+December 2000: port to FreeBSD by Sarwat Khan (sarwat@sarwat.net).
+	Port to FreeBSD, except for RunLoop.subproj items.  Integrated by
+	ckane@apple.com into CoreFoundation-8.  ckane also marginally
+	improved the Linux port in that version.
+
+March 2001: CoreFoundation-9, corresponding to CoreFoundation-197 in
+	Mac OS X, synchronizes Darwin CF with Mac OS X's released CF.
+
+May 2001: CoreFoundation-10, corresponding to CoreFoundation-206.5
+	synchronizes Darwin CF with TOT CoreFoundation.
+
+June 2001: Linux port maintenance by Robert Thompson <rothomp3@mac.com>.
+
+July 2001: Integrated addition of headerdoc for CFBinaryHeap.h from
+	Kevin Van Vechten <kevinvv@uclink4.berkeley.edu>.
+
+Sept 2001: CoreFoundation-14, sync with Mac OS X 10.1
+
+Oct 2001: More header doc (e.g., CFSet.h) and some CFTree implementation
+        from Kevin Van Vechten <kevinvv@uclink4.berkeley.edu>.
+
+Jan 2002: Windows(TM) port changes from Kevin Van Vechten <kevinvv@uclink4.berkeley.edu>.
+
+Feb 2002: Some Windows(TM) port changes from Aleskey Dukhnyakov, Andrew Dzubandovsky,
+	Roman Mukhin, and Sergey Zubarev; Orc Software<daa@orcsoftware.spb.ru>
+
+... years of work ...
+
+JAN 2009: Windows(TM) port changes from Brent Fulgham.  Linux port changes
+	from Grant Erickson.
diff --git a/CoreFoundation/Cocotron/Cocotron.c b/CoreFoundation/Cocotron/Cocotron.c
new file mode 100644
index 0000000..3d29bf8
--- /dev/null
+++ b/CoreFoundation/Cocotron/Cocotron.c
@@ -0,0 +1,46 @@
+
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFRuntime.h>
+#include <malloc.h>
+#include <string.h>
+#if DEPLOYMENT_TARGET_LINUX
+#include <alloca.h>
+#endif
+
+typedef void* SEL;
+typedef void* id;
+
+SEL (*__CFGetObjCSelector)(const char *)=0;
+void* (*__CFGetObjCClass)(const char *)=0;
+extern void* (*__CFSendObjCMsg)(const void*, SEL, ...);
+
+static void __attribute__((constructor)) InitializeFoundation() {
+   static void* hFoundation=0;
+#if defined(__WIN32__)
+   if(!hFoundation) {
+      hFoundation=LoadLibrary("Foundation.1.0.dll");
+
+      __CFGetObjCSelector=GetProcAddress(hFoundation, "sel_registerName");
+      __CFSendObjCMsg=GetProcAddress(hFoundation, "objc_msgSend");
+      __CFGetObjCClass=GetProcAddress(hFoundation, "objc_getClass");
+   }
+#endif
+}
+
+void* __CFISAForTypeID(CFTypeID typeid) {
+   if(!__CFGetObjCClass)
+      return 0;
+
+   const CFRuntimeClass *cls = _CFRuntimeGetClassWithTypeID(typeid);
+   char *name=alloca(strlen(cls->className)+3);
+
+   // build e.g. "NSCFArray" from CFArray
+   strcpy(name, "NS");
+   strcat(name, cls->className);
+   
+   void* ret = __CFGetObjCClass(name);
+   
+   if(!ret)
+      ret=__CFGetObjCClass("NSCFType");
+   return ret;
+}
diff --git a/CoreFoundation/Cocotron/CoreFoundation.xcodeproj/project.pbxproj b/CoreFoundation/Cocotron/CoreFoundation.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..8651b8d
--- /dev/null
+++ b/CoreFoundation/Cocotron/CoreFoundation.xcodeproj/project.pbxproj
@@ -0,0 +1,849 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 45;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
+		C83576B50EDAB96C00E3D27B /* ForFoundationOnly.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576340EDAB96C00E3D27B /* ForFoundationOnly.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576B60EDAB96C00E3D27B /* CFCalendar.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576350EDAB96C00E3D27B /* CFCalendar.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576B70EDAB96C00E3D27B /* CFCharacterSet.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576360EDAB96C00E3D27B /* CFCharacterSet.c */; };
+		C83576B80EDAB96C00E3D27B /* CFDateFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576370EDAB96C00E3D27B /* CFDateFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576B90EDAB96C00E3D27B /* CFUUID.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576380EDAB96C00E3D27B /* CFUUID.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576BA0EDAB96C00E3D27B /* CFSet.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576390EDAB96C00E3D27B /* CFSet.c */; };
+		C83576BB0EDAB96C00E3D27B /* CFBase.h in Headers */ = {isa = PBXBuildFile; fileRef = C835763A0EDAB96C00E3D27B /* CFBase.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576BC0EDAB96C00E3D27B /* CFStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = C835763B0EDAB96C00E3D27B /* CFStorage.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576BD0EDAB96C00E3D27B /* CFUniChar.c in Sources */ = {isa = PBXBuildFile; fileRef = C835763C0EDAB96C00E3D27B /* CFUniChar.c */; };
+		C83576BE0EDAB96C00E3D27B /* CFTree.h in Headers */ = {isa = PBXBuildFile; fileRef = C835763D0EDAB96C00E3D27B /* CFTree.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576BF0EDAB96C00E3D27B /* CFBag.c in Sources */ = {isa = PBXBuildFile; fileRef = C835763E0EDAB96C00E3D27B /* CFBag.c */; };
+		C83576C00EDAB96C00E3D27B /* CFApplicationPreferences.c in Sources */ = {isa = PBXBuildFile; fileRef = C835763F0EDAB96C00E3D27B /* CFApplicationPreferences.c */; };
+		C83576C10EDAB96C00E3D27B /* CFBinaryPList.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576400EDAB96C00E3D27B /* CFBinaryPList.c */; };
+		C83576C20EDAB96C00E3D27B /* CFFileUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576410EDAB96C00E3D27B /* CFFileUtilities.c */; };
+		C83576C30EDAB96C00E3D27B /* CFDictionary.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576420EDAB96C00E3D27B /* CFDictionary.c */; };
+		C83576C40EDAB96C00E3D27B /* CFURLAccess.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576430EDAB96C00E3D27B /* CFURLAccess.c */; };
+		C83576C50EDAB96C00E3D27B /* CFDateFormatter.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576440EDAB96C00E3D27B /* CFDateFormatter.c */; };
+		C83576C60EDAB96C00E3D27B /* CFMachPort.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576450EDAB96C00E3D27B /* CFMachPort.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576C70EDAB96C00E3D27B /* CFDate.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576460EDAB96C00E3D27B /* CFDate.c */; };
+		C83576C80EDAB96C00E3D27B /* CFUnicodePrecomposition.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576470EDAB96C00E3D27B /* CFUnicodePrecomposition.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576C90EDAB96C00E3D27B /* CFXMLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576480EDAB96C00E3D27B /* CFXMLParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576CA0EDAB96C00E3D27B /* CFPropertyList.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576490EDAB96C00E3D27B /* CFPropertyList.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576CB0EDAB96C00E3D27B /* CFBag.h in Headers */ = {isa = PBXBuildFile; fileRef = C835764A0EDAB96C00E3D27B /* CFBag.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576CC0EDAB96C00E3D27B /* CFSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = C835764B0EDAB96C00E3D27B /* CFSocket.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576CD0EDAB96C00E3D27B /* CFData.h in Headers */ = {isa = PBXBuildFile; fileRef = C835764C0EDAB96C00E3D27B /* CFData.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576CE0EDAB96C00E3D27B /* CFRunLoopPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = C835764D0EDAB96C00E3D27B /* CFRunLoopPriv.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576CF0EDAB96C00E3D27B /* CFCharacterSetPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = C835764E0EDAB96C00E3D27B /* CFCharacterSetPriv.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576D00EDAB96C00E3D27B /* CFPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = C835764F0EDAB96C00E3D27B /* CFPriv.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576D10EDAB96C00E3D27B /* CFRunLoop.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576500EDAB96C00E3D27B /* CFRunLoop.c */; };
+		C83576D20EDAB96C00E3D27B /* CFUniChar.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576510EDAB96C00E3D27B /* CFUniChar.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576D30EDAB96C00E3D27B /* CFPlugInCOM.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576520EDAB96C00E3D27B /* CFPlugInCOM.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576D40EDAB96C00E3D27B /* CFError.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576530EDAB96C00E3D27B /* CFError.c */; };
+		C83576D50EDAB96C00E3D27B /* CFRuntime.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576540EDAB96C00E3D27B /* CFRuntime.c */; };
+		C83576D60EDAB96C00E3D27B /* CFSet.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576550EDAB96C00E3D27B /* CFSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576D70EDAB96C00E3D27B /* CFNumberFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576560EDAB96C00E3D27B /* CFNumberFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576D80EDAB96C00E3D27B /* CoreFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576570EDAB96C00E3D27B /* CoreFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576D90EDAB96C00E3D27B /* CFTimeZone.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576580EDAB96C00E3D27B /* CFTimeZone.c */; };
+		C83576DA0EDAB96C00E3D27B /* CFXMLTree.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576590EDAB96C00E3D27B /* CFXMLTree.c */; };
+		C83576DB0EDAB96C00E3D27B /* CFXMLPreferencesDomain.c in Sources */ = {isa = PBXBuildFile; fileRef = C835765A0EDAB96C00E3D27B /* CFXMLPreferencesDomain.c */; };
+		C83576DC0EDAB96C00E3D27B /* CFStorage.c in Sources */ = {isa = PBXBuildFile; fileRef = C835765B0EDAB96C00E3D27B /* CFStorage.c */; };
+		C83576DD0EDAB96C00E3D27B /* CFXMLNode.h in Headers */ = {isa = PBXBuildFile; fileRef = C835765C0EDAB96C00E3D27B /* CFXMLNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576DE0EDAB96C00E3D27B /* CFBundle_BinaryTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = C835765D0EDAB96C00E3D27B /* CFBundle_BinaryTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576DF0EDAB96C00E3D27B /* CFMessagePort.h in Headers */ = {isa = PBXBuildFile; fileRef = C835765E0EDAB96C00E3D27B /* CFMessagePort.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576E00EDAB96C00E3D27B /* auto_stubs.h in Headers */ = {isa = PBXBuildFile; fileRef = C835765F0EDAB96C00E3D27B /* auto_stubs.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576E10EDAB96C00E3D27B /* CFWindowsMessageQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576600EDAB96C00E3D27B /* CFWindowsMessageQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576E20EDAB96C00E3D27B /* CFStreamPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576610EDAB96C00E3D27B /* CFStreamPriv.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576E30EDAB96C00E3D27B /* CFStringEncodingConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576620EDAB96C00E3D27B /* CFStringEncodingConverter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576E40EDAB96C00E3D27B /* CFXMLNode.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576630EDAB96C00E3D27B /* CFXMLNode.c */; };
+		C83576E50EDAB96C00E3D27B /* CFWindowsMessageQueue.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576640EDAB96C00E3D27B /* CFWindowsMessageQueue.c */; };
+		C83576E60EDAB96C00E3D27B /* CFNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576650EDAB96C00E3D27B /* CFNumber.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576E70EDAB96C00E3D27B /* CFVersion.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576660EDAB96C00E3D27B /* CFVersion.c */; };
+		C83576E80EDAB96C00E3D27B /* CFStream.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576670EDAB96C00E3D27B /* CFStream.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576E90EDAB96C00E3D27B /* CFBinaryHeap.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576680EDAB96C00E3D27B /* CFBinaryHeap.c */; };
+		C83576EA0EDAB96C00E3D27B /* CFSocketStream.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576690EDAB96C00E3D27B /* CFSocketStream.c */; };
+		C83576EB0EDAB96C00E3D27B /* CFRunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = C835766A0EDAB96C00E3D27B /* CFRunLoop.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576EC0EDAB96C00E3D27B /* CFDate.h in Headers */ = {isa = PBXBuildFile; fileRef = C835766B0EDAB96C00E3D27B /* CFDate.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576ED0EDAB96C00E3D27B /* CFNumber.c in Sources */ = {isa = PBXBuildFile; fileRef = C835766C0EDAB96C00E3D27B /* CFNumber.c */; };
+		C83576EE0EDAB96C00E3D27B /* CFDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = C835766D0EDAB96C00E3D27B /* CFDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576EF0EDAB96C00E3D27B /* CFBuiltinConverters.c in Sources */ = {isa = PBXBuildFile; fileRef = C835766E0EDAB96C00E3D27B /* CFBuiltinConverters.c */; };
+		C83576F00EDAB96C00E3D27B /* CFStreamInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C835766F0EDAB96C00E3D27B /* CFStreamInternal.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576F10EDAB96C00E3D27B /* CFLocale.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576700EDAB96C00E3D27B /* CFLocale.c */; };
+		C83576F20EDAB96C00E3D27B /* CFPlugIn_Factory.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576710EDAB96C00E3D27B /* CFPlugIn_Factory.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576F30EDAB96C00E3D27B /* CFXMLInputStream.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576720EDAB96C00E3D27B /* CFXMLInputStream.c */; };
+		C83576F40EDAB96C00E3D27B /* CFBundle_Resources.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576730EDAB96C00E3D27B /* CFBundle_Resources.c */; };
+		C83576F50EDAB96C00E3D27B /* CFPlugIn.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576740EDAB96C00E3D27B /* CFPlugIn.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576F60EDAB96C00E3D27B /* CFBinaryHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576750EDAB96C00E3D27B /* CFBinaryHeap.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576F70EDAB96C00E3D27B /* CFURLAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576760EDAB96C00E3D27B /* CFURLAccess.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576F80EDAB96C00E3D27B /* CFPlugIn.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576770EDAB96C00E3D27B /* CFPlugIn.c */; };
+		C83576F90EDAB96C00E3D27B /* CFSystemDirectories.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576780EDAB96C00E3D27B /* CFSystemDirectories.c */; };
+		C83576FA0EDAB96C00E3D27B /* CFStreamAbstract.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576790EDAB96C00E3D27B /* CFStreamAbstract.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576FB0EDAB96C00E3D27B /* CFPlugIn_Factory.c in Sources */ = {isa = PBXBuildFile; fileRef = C835767A0EDAB96C00E3D27B /* CFPlugIn_Factory.c */; };
+		C83576FC0EDAB96C00E3D27B /* CFString.h in Headers */ = {isa = PBXBuildFile; fileRef = C835767B0EDAB96C00E3D27B /* CFString.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576FD0EDAB96C00E3D27B /* CFBundle_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = C835767C0EDAB96C00E3D27B /* CFBundle_Internal.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83576FE0EDAB96C00E3D27B /* CFLocaleIdentifier.c in Sources */ = {isa = PBXBuildFile; fileRef = C835767D0EDAB96C00E3D27B /* CFLocaleIdentifier.c */; };
+		C83576FF0EDAB96C00E3D27B /* CFSortFunctions.c in Sources */ = {isa = PBXBuildFile; fileRef = C835767E0EDAB96C00E3D27B /* CFSortFunctions.c */; };
+		C83577000EDAB96C00E3D27B /* CFUniCharPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = C835767F0EDAB96C00E3D27B /* CFUniCharPriv.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577010EDAB96C00E3D27B /* CFLogUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576800EDAB96C00E3D27B /* CFLogUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577020EDAB96C00E3D27B /* CFXMLInputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576810EDAB96C00E3D27B /* CFXMLInputStream.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577030EDAB96C00E3D27B /* CFStringDefaultEncoding.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576820EDAB96C00E3D27B /* CFStringDefaultEncoding.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577040EDAB96C00E3D27B /* CFData.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576830EDAB96C00E3D27B /* CFData.c */; };
+		C83577050EDAB96C00E3D27B /* CFUnicodePrecomposition.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576840EDAB96C00E3D27B /* CFUnicodePrecomposition.c */; };
+		C83577060EDAB96C00E3D27B /* CFConcreteStreams.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576850EDAB96C00E3D27B /* CFConcreteStreams.c */; };
+		C83577070EDAB96C00E3D27B /* CFUserNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576860EDAB96C00E3D27B /* CFUserNotification.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577080EDAB96C00E3D27B /* CFUnicodeDecomposition.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576870EDAB96C00E3D27B /* CFUnicodeDecomposition.c */; };
+		C83577090EDAB96C00E3D27B /* CFUnicodeDecomposition.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576880EDAB96C00E3D27B /* CFUnicodeDecomposition.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C835770A0EDAB96C00E3D27B /* CFCalendar.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576890EDAB96C00E3D27B /* CFCalendar.c */; };
+		C835770B0EDAB96C00E3D27B /* CFArray.c in Sources */ = {isa = PBXBuildFile; fileRef = C835768A0EDAB96C00E3D27B /* CFArray.c */; };
+		C835770C0EDAB96C00E3D27B /* CFURL.h in Headers */ = {isa = PBXBuildFile; fileRef = C835768B0EDAB96C00E3D27B /* CFURL.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C835770D0EDAB96C00E3D27B /* CFTree.c in Sources */ = {isa = PBXBuildFile; fileRef = C835768C0EDAB96C00E3D27B /* CFTree.c */; };
+		C835770E0EDAB96C00E3D27B /* CFPropertyList.c in Sources */ = {isa = PBXBuildFile; fileRef = C835768D0EDAB96C00E3D27B /* CFPropertyList.c */; };
+		C835770F0EDAB96C00E3D27B /* CFTimeZone.h in Headers */ = {isa = PBXBuildFile; fileRef = C835768E0EDAB96C00E3D27B /* CFTimeZone.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577100EDAB96C00E3D27B /* CFInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C835768F0EDAB96C00E3D27B /* CFInternal.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577110EDAB96C00E3D27B /* CFPlatform.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576900EDAB96C00E3D27B /* CFPlatform.c */; };
+		C83577120EDAB96C00E3D27B /* CFPlugIn_PlugIn.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576910EDAB96C00E3D27B /* CFPlugIn_PlugIn.c */; };
+		C83577130EDAB96C00E3D27B /* CFBase.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576920EDAB96C00E3D27B /* CFBase.c */; };
+		C83577140EDAB96C00E3D27B /* CFBitVector.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576930EDAB96C00E3D27B /* CFBitVector.c */; };
+		C83577150EDAB96C00E3D27B /* CFStream.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576940EDAB96C00E3D27B /* CFStream.c */; };
+		C83577160EDAB96C00E3D27B /* CFPlugIn_Instance.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576950EDAB96C00E3D27B /* CFPlugIn_Instance.c */; };
+		C83577170EDAB96C00E3D27B /* CFBundlePriv.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576960EDAB96C00E3D27B /* CFBundlePriv.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577180EDAB96C00E3D27B /* CFPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576970EDAB96C00E3D27B /* CFPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577190EDAB96C00E3D27B /* Compat.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576980EDAB96C00E3D27B /* Compat.c */; };
+		C835771A0EDAB96C00E3D27B /* CFByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576990EDAB96C00E3D27B /* CFByteOrder.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C835771B0EDAB96C00E3D27B /* CFString.c in Sources */ = {isa = PBXBuildFile; fileRef = C835769A0EDAB96C00E3D27B /* CFString.c */; };
+		C835771C0EDAB96C00E3D27B /* CFError_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C835769B0EDAB96C00E3D27B /* CFError_Private.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C835771D0EDAB96C00E3D27B /* CFPreferences.c in Sources */ = {isa = PBXBuildFile; fileRef = C835769C0EDAB96C00E3D27B /* CFPreferences.c */; };
+		C835771E0EDAB96C00E3D27B /* CFMachPort.c in Sources */ = {isa = PBXBuildFile; fileRef = C835769D0EDAB96C00E3D27B /* CFMachPort.c */; };
+		C835771F0EDAB96C00E3D27B /* CFBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = C835769E0EDAB96C00E3D27B /* CFBundle.c */; };
+		C83577200EDAB96C00E3D27B /* CFNumberFormatter.c in Sources */ = {isa = PBXBuildFile; fileRef = C835769F0EDAB96C00E3D27B /* CFNumberFormatter.c */; };
+		C83577210EDAB96C00E3D27B /* CFStringEncodingConverterPriv.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576A00EDAB96C00E3D27B /* CFStringEncodingConverterPriv.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577220EDAB96C00E3D27B /* CFLocale.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576A10EDAB96C00E3D27B /* CFLocale.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577230EDAB96C00E3D27B /* CFBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576A20EDAB96C00E3D27B /* CFBitVector.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577240EDAB96C00E3D27B /* CFStringEncodingExt.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576A30EDAB96C00E3D27B /* CFStringEncodingExt.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577250EDAB96C00E3D27B /* CFRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576A40EDAB96C00E3D27B /* CFRuntime.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577260EDAB96C00E3D27B /* CFStringUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576A50EDAB96C00E3D27B /* CFStringUtilities.c */; };
+		C83577270EDAB96C00E3D27B /* CFMessagePort.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576A60EDAB96C00E3D27B /* CFMessagePort.c */; };
+		C83577280EDAB96C00E3D27B /* CFURL.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576A70EDAB96C00E3D27B /* CFURL.c */; };
+		C83577290EDAB96C00E3D27B /* CFArray.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576A80EDAB96C00E3D27B /* CFArray.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C835772A0EDAB96C00E3D27B /* CFSocket.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576A90EDAB96C00E3D27B /* CFSocket.c */; };
+		C835772B0EDAB96C00E3D27B /* CFUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576AA0EDAB96C00E3D27B /* CFUtilities.c */; };
+		C835772C0EDAB96C00E3D27B /* CFStringEncodings.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576AB0EDAB96C00E3D27B /* CFStringEncodings.c */; };
+		C835772D0EDAB96C00E3D27B /* CFBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576AC0EDAB96C00E3D27B /* CFBundle.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C835772E0EDAB96C00E3D27B /* CFUUID.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576AD0EDAB96C00E3D27B /* CFUUID.c */; };
+		C835772F0EDAB96C00E3D27B /* CFXMLParser.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576AE0EDAB96C00E3D27B /* CFXMLParser.c */; };
+		C83577300EDAB96C00E3D27B /* CFUserNotification.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576AF0EDAB96C00E3D27B /* CFUserNotification.c */; };
+		C83577310EDAB96C00E3D27B /* CFStringEncodingConverter.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576B00EDAB96C00E3D27B /* CFStringEncodingConverter.c */; };
+		C83577320EDAB96C00E3D27B /* CFStringScanner.c in Sources */ = {isa = PBXBuildFile; fileRef = C83576B10EDAB96C00E3D27B /* CFStringScanner.c */; };
+		C83577330EDAB96C00E3D27B /* CFStringEncodingConverterExt.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576B20EDAB96C00E3D27B /* CFStringEncodingConverterExt.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577340EDAB96C00E3D27B /* CFCharacterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576B30EDAB96C00E3D27B /* CFCharacterSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C83577350EDAB96C00E3D27B /* CFError.h in Headers */ = {isa = PBXBuildFile; fileRef = C83576B40EDAB96C00E3D27B /* CFError.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		C835789C0EDAC64D00E3D27B /* Cocotron.c in Sources */ = {isa = PBXBuildFile; fileRef = C835789A0EDAC64D00E3D27B /* Cocotron.c */; };
+		C83579010EDAD0A100E3D27B /* AvailabilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = C83579000EDAD0A100E3D27B /* AvailabilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
+/* End PBXBuildFile section */
+
+/* Begin PBXBuildRule section */
+		C83575E00EDAB63400E3D27B /* PBXBuildRule */ = {
+			isa = PBXBuildRule;
+			compilerSpec = org.cocotron.1.0.windows.i386.gcc.default;
+			fileType = sourcecode.c;
+			isEditable = 1;
+			outputFiles = (
+			);
+		};
+/* End PBXBuildRule section */
+
+/* Begin PBXFileReference section */
+		0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+		0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
+		1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		8DC2EF5B0486A6940098B216 /* CoreFoundation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CoreFoundation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		C83576340EDAB96C00E3D27B /* ForFoundationOnly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForFoundationOnly.h; sourceTree = "<group>"; };
+		C83576350EDAB96C00E3D27B /* CFCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFCalendar.h; sourceTree = "<group>"; };
+		C83576360EDAB96C00E3D27B /* CFCharacterSet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFCharacterSet.c; sourceTree = "<group>"; };
+		C83576370EDAB96C00E3D27B /* CFDateFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFDateFormatter.h; sourceTree = "<group>"; };
+		C83576380EDAB96C00E3D27B /* CFUUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUUID.h; sourceTree = "<group>"; };
+		C83576390EDAB96C00E3D27B /* CFSet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFSet.c; sourceTree = "<group>"; };
+		C835763A0EDAB96C00E3D27B /* CFBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBase.h; sourceTree = "<group>"; };
+		C835763B0EDAB96C00E3D27B /* CFStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStorage.h; sourceTree = "<group>"; };
+		C835763C0EDAB96C00E3D27B /* CFUniChar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFUniChar.c; sourceTree = "<group>"; };
+		C835763D0EDAB96C00E3D27B /* CFTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFTree.h; sourceTree = "<group>"; };
+		C835763E0EDAB96C00E3D27B /* CFBag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBag.c; sourceTree = "<group>"; };
+		C835763F0EDAB96C00E3D27B /* CFApplicationPreferences.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFApplicationPreferences.c; sourceTree = "<group>"; };
+		C83576400EDAB96C00E3D27B /* CFBinaryPList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBinaryPList.c; sourceTree = "<group>"; };
+		C83576410EDAB96C00E3D27B /* CFFileUtilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFFileUtilities.c; sourceTree = "<group>"; };
+		C83576420EDAB96C00E3D27B /* CFDictionary.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFDictionary.c; sourceTree = "<group>"; };
+		C83576430EDAB96C00E3D27B /* CFURLAccess.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFURLAccess.c; sourceTree = "<group>"; };
+		C83576440EDAB96C00E3D27B /* CFDateFormatter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFDateFormatter.c; sourceTree = "<group>"; };
+		C83576450EDAB96C00E3D27B /* CFMachPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFMachPort.h; sourceTree = "<group>"; };
+		C83576460EDAB96C00E3D27B /* CFDate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFDate.c; sourceTree = "<group>"; };
+		C83576470EDAB96C00E3D27B /* CFUnicodePrecomposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUnicodePrecomposition.h; sourceTree = "<group>"; };
+		C83576480EDAB96C00E3D27B /* CFXMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFXMLParser.h; sourceTree = "<group>"; };
+		C83576490EDAB96C00E3D27B /* CFPropertyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFPropertyList.h; sourceTree = "<group>"; };
+		C835764A0EDAB96C00E3D27B /* CFBag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBag.h; sourceTree = "<group>"; };
+		C835764B0EDAB96C00E3D27B /* CFSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFSocket.h; sourceTree = "<group>"; };
+		C835764C0EDAB96C00E3D27B /* CFData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFData.h; sourceTree = "<group>"; };
+		C835764D0EDAB96C00E3D27B /* CFRunLoopPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFRunLoopPriv.h; sourceTree = "<group>"; };
+		C835764E0EDAB96C00E3D27B /* CFCharacterSetPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFCharacterSetPriv.h; sourceTree = "<group>"; };
+		C835764F0EDAB96C00E3D27B /* CFPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFPriv.h; sourceTree = "<group>"; };
+		C83576500EDAB96C00E3D27B /* CFRunLoop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFRunLoop.c; sourceTree = "<group>"; };
+		C83576510EDAB96C00E3D27B /* CFUniChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUniChar.h; sourceTree = "<group>"; };
+		C83576520EDAB96C00E3D27B /* CFPlugInCOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFPlugInCOM.h; sourceTree = "<group>"; };
+		C83576530EDAB96C00E3D27B /* CFError.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFError.c; sourceTree = "<group>"; };
+		C83576540EDAB96C00E3D27B /* CFRuntime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFRuntime.c; sourceTree = "<group>"; };
+		C83576550EDAB96C00E3D27B /* CFSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFSet.h; sourceTree = "<group>"; };
+		C83576560EDAB96C00E3D27B /* CFNumberFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFNumberFormatter.h; sourceTree = "<group>"; };
+		C83576570EDAB96C00E3D27B /* CoreFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreFoundation.h; sourceTree = "<group>"; };
+		C83576580EDAB96C00E3D27B /* CFTimeZone.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFTimeZone.c; sourceTree = "<group>"; };
+		C83576590EDAB96C00E3D27B /* CFXMLTree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFXMLTree.c; sourceTree = "<group>"; };
+		C835765A0EDAB96C00E3D27B /* CFXMLPreferencesDomain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFXMLPreferencesDomain.c; sourceTree = "<group>"; };
+		C835765B0EDAB96C00E3D27B /* CFStorage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFStorage.c; sourceTree = "<group>"; };
+		C835765C0EDAB96C00E3D27B /* CFXMLNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFXMLNode.h; sourceTree = "<group>"; };
+		C835765D0EDAB96C00E3D27B /* CFBundle_BinaryTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundle_BinaryTypes.h; sourceTree = "<group>"; };
+		C835765E0EDAB96C00E3D27B /* CFMessagePort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFMessagePort.h; sourceTree = "<group>"; };
+		C835765F0EDAB96C00E3D27B /* auto_stubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = auto_stubs.h; sourceTree = "<group>"; };
+		C83576600EDAB96C00E3D27B /* CFWindowsMessageQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFWindowsMessageQueue.h; sourceTree = "<group>"; };
+		C83576610EDAB96C00E3D27B /* CFStreamPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStreamPriv.h; sourceTree = "<group>"; };
+		C83576620EDAB96C00E3D27B /* CFStringEncodingConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringEncodingConverter.h; sourceTree = "<group>"; };
+		C83576630EDAB96C00E3D27B /* CFXMLNode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFXMLNode.c; sourceTree = "<group>"; };
+		C83576640EDAB96C00E3D27B /* CFWindowsMessageQueue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFWindowsMessageQueue.c; sourceTree = "<group>"; };
+		C83576650EDAB96C00E3D27B /* CFNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFNumber.h; sourceTree = "<group>"; };
+		C83576660EDAB96C00E3D27B /* CFVersion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFVersion.c; sourceTree = "<group>"; };
+		C83576670EDAB96C00E3D27B /* CFStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStream.h; sourceTree = "<group>"; };
+		C83576680EDAB96C00E3D27B /* CFBinaryHeap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBinaryHeap.c; sourceTree = "<group>"; };
+		C83576690EDAB96C00E3D27B /* CFSocketStream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFSocketStream.c; sourceTree = "<group>"; };
+		C835766A0EDAB96C00E3D27B /* CFRunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFRunLoop.h; sourceTree = "<group>"; };
+		C835766B0EDAB96C00E3D27B /* CFDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFDate.h; sourceTree = "<group>"; };
+		C835766C0EDAB96C00E3D27B /* CFNumber.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFNumber.c; sourceTree = "<group>"; };
+		C835766D0EDAB96C00E3D27B /* CFDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFDictionary.h; sourceTree = "<group>"; };
+		C835766E0EDAB96C00E3D27B /* CFBuiltinConverters.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBuiltinConverters.c; sourceTree = "<group>"; };
+		C835766F0EDAB96C00E3D27B /* CFStreamInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStreamInternal.h; sourceTree = "<group>"; };
+		C83576700EDAB96C00E3D27B /* CFLocale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFLocale.c; sourceTree = "<group>"; };
+		C83576710EDAB96C00E3D27B /* CFPlugIn_Factory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFPlugIn_Factory.h; sourceTree = "<group>"; };
+		C83576720EDAB96C00E3D27B /* CFXMLInputStream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFXMLInputStream.c; sourceTree = "<group>"; };
+		C83576730EDAB96C00E3D27B /* CFBundle_Resources.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBundle_Resources.c; sourceTree = "<group>"; };
+		C83576740EDAB96C00E3D27B /* CFPlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFPlugIn.h; sourceTree = "<group>"; };
+		C83576750EDAB96C00E3D27B /* CFBinaryHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBinaryHeap.h; sourceTree = "<group>"; };
+		C83576760EDAB96C00E3D27B /* CFURLAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFURLAccess.h; sourceTree = "<group>"; };
+		C83576770EDAB96C00E3D27B /* CFPlugIn.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFPlugIn.c; sourceTree = "<group>"; };
+		C83576780EDAB96C00E3D27B /* CFSystemDirectories.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFSystemDirectories.c; sourceTree = "<group>"; };
+		C83576790EDAB96C00E3D27B /* CFStreamAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStreamAbstract.h; sourceTree = "<group>"; };
+		C835767A0EDAB96C00E3D27B /* CFPlugIn_Factory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFPlugIn_Factory.c; sourceTree = "<group>"; };
+		C835767B0EDAB96C00E3D27B /* CFString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFString.h; sourceTree = "<group>"; };
+		C835767C0EDAB96C00E3D27B /* CFBundle_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundle_Internal.h; sourceTree = "<group>"; };
+		C835767D0EDAB96C00E3D27B /* CFLocaleIdentifier.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFLocaleIdentifier.c; sourceTree = "<group>"; };
+		C835767E0EDAB96C00E3D27B /* CFSortFunctions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFSortFunctions.c; sourceTree = "<group>"; };
+		C835767F0EDAB96C00E3D27B /* CFUniCharPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUniCharPriv.h; sourceTree = "<group>"; };
+		C83576800EDAB96C00E3D27B /* CFLogUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFLogUtilities.h; sourceTree = "<group>"; };
+		C83576810EDAB96C00E3D27B /* CFXMLInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFXMLInputStream.h; sourceTree = "<group>"; };
+		C83576820EDAB96C00E3D27B /* CFStringDefaultEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringDefaultEncoding.h; sourceTree = "<group>"; };
+		C83576830EDAB96C00E3D27B /* CFData.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFData.c; sourceTree = "<group>"; };
+		C83576840EDAB96C00E3D27B /* CFUnicodePrecomposition.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFUnicodePrecomposition.c; sourceTree = "<group>"; };
+		C83576850EDAB96C00E3D27B /* CFConcreteStreams.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFConcreteStreams.c; sourceTree = "<group>"; };
+		C83576860EDAB96C00E3D27B /* CFUserNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUserNotification.h; sourceTree = "<group>"; };
+		C83576870EDAB96C00E3D27B /* CFUnicodeDecomposition.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFUnicodeDecomposition.c; sourceTree = "<group>"; };
+		C83576880EDAB96C00E3D27B /* CFUnicodeDecomposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUnicodeDecomposition.h; sourceTree = "<group>"; };
+		C83576890EDAB96C00E3D27B /* CFCalendar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFCalendar.c; sourceTree = "<group>"; };
+		C835768A0EDAB96C00E3D27B /* CFArray.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 2; path = CFArray.c; sourceTree = "<group>"; };
+		C835768B0EDAB96C00E3D27B /* CFURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFURL.h; sourceTree = "<group>"; };
+		C835768C0EDAB96C00E3D27B /* CFTree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFTree.c; sourceTree = "<group>"; };
+		C835768D0EDAB96C00E3D27B /* CFPropertyList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFPropertyList.c; sourceTree = "<group>"; };
+		C835768E0EDAB96C00E3D27B /* CFTimeZone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFTimeZone.h; sourceTree = "<group>"; };
+		C835768F0EDAB96C00E3D27B /* CFInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFInternal.h; sourceTree = "<group>"; };
+		C83576900EDAB96C00E3D27B /* CFPlatform.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFPlatform.c; sourceTree = "<group>"; };
+		C83576910EDAB96C00E3D27B /* CFPlugIn_PlugIn.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFPlugIn_PlugIn.c; sourceTree = "<group>"; };
+		C83576920EDAB96C00E3D27B /* CFBase.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBase.c; sourceTree = "<group>"; };
+		C83576930EDAB96C00E3D27B /* CFBitVector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBitVector.c; sourceTree = "<group>"; };
+		C83576940EDAB96C00E3D27B /* CFStream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFStream.c; sourceTree = "<group>"; };
+		C83576950EDAB96C00E3D27B /* CFPlugIn_Instance.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFPlugIn_Instance.c; sourceTree = "<group>"; };
+		C83576960EDAB96C00E3D27B /* CFBundlePriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundlePriv.h; sourceTree = "<group>"; };
+		C83576970EDAB96C00E3D27B /* CFPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFPreferences.h; sourceTree = "<group>"; };
+		C83576980EDAB96C00E3D27B /* Compat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Compat.c; sourceTree = "<group>"; };
+		C83576990EDAB96C00E3D27B /* CFByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFByteOrder.h; sourceTree = "<group>"; };
+		C835769A0EDAB96C00E3D27B /* CFString.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFString.c; sourceTree = "<group>"; };
+		C835769B0EDAB96C00E3D27B /* CFError_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFError_Private.h; sourceTree = "<group>"; };
+		C835769C0EDAB96C00E3D27B /* CFPreferences.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFPreferences.c; sourceTree = "<group>"; };
+		C835769D0EDAB96C00E3D27B /* CFMachPort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFMachPort.c; sourceTree = "<group>"; };
+		C835769E0EDAB96C00E3D27B /* CFBundle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFBundle.c; sourceTree = "<group>"; };
+		C835769F0EDAB96C00E3D27B /* CFNumberFormatter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFNumberFormatter.c; sourceTree = "<group>"; };
+		C83576A00EDAB96C00E3D27B /* CFStringEncodingConverterPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringEncodingConverterPriv.h; sourceTree = "<group>"; };
+		C83576A10EDAB96C00E3D27B /* CFLocale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFLocale.h; sourceTree = "<group>"; };
+		C83576A20EDAB96C00E3D27B /* CFBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBitVector.h; sourceTree = "<group>"; };
+		C83576A30EDAB96C00E3D27B /* CFStringEncodingExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringEncodingExt.h; sourceTree = "<group>"; };
+		C83576A40EDAB96C00E3D27B /* CFRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFRuntime.h; sourceTree = "<group>"; };
+		C83576A50EDAB96C00E3D27B /* CFStringUtilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFStringUtilities.c; sourceTree = "<group>"; };
+		C83576A60EDAB96C00E3D27B /* CFMessagePort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFMessagePort.c; sourceTree = "<group>"; };
+		C83576A70EDAB96C00E3D27B /* CFURL.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFURL.c; sourceTree = "<group>"; };
+		C83576A80EDAB96C00E3D27B /* CFArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFArray.h; sourceTree = "<group>"; };
+		C83576A90EDAB96C00E3D27B /* CFSocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFSocket.c; sourceTree = "<group>"; };
+		C83576AA0EDAB96C00E3D27B /* CFUtilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFUtilities.c; sourceTree = "<group>"; };
+		C83576AB0EDAB96C00E3D27B /* CFStringEncodings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFStringEncodings.c; sourceTree = "<group>"; };
+		C83576AC0EDAB96C00E3D27B /* CFBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundle.h; sourceTree = "<group>"; };
+		C83576AD0EDAB96C00E3D27B /* CFUUID.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFUUID.c; sourceTree = "<group>"; };
+		C83576AE0EDAB96C00E3D27B /* CFXMLParser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFXMLParser.c; sourceTree = "<group>"; };
+		C83576AF0EDAB96C00E3D27B /* CFUserNotification.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFUserNotification.c; sourceTree = "<group>"; };
+		C83576B00EDAB96C00E3D27B /* CFStringEncodingConverter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFStringEncodingConverter.c; sourceTree = "<group>"; };
+		C83576B10EDAB96C00E3D27B /* CFStringScanner.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFStringScanner.c; sourceTree = "<group>"; };
+		C83576B20EDAB96C00E3D27B /* CFStringEncodingConverterExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringEncodingConverterExt.h; sourceTree = "<group>"; };
+		C83576B30EDAB96C00E3D27B /* CFCharacterSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFCharacterSet.h; sourceTree = "<group>"; };
+		C83576B40EDAB96C00E3D27B /* CFError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFError.h; sourceTree = "<group>"; };
+		C835789A0EDAC64D00E3D27B /* Cocotron.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Cocotron.c; sourceTree = "<group>"; };
+		C83579000EDAD0A100E3D27B /* AvailabilityMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AvailabilityMacros.h; path = Compatibility/AvailabilityMacros.h; sourceTree = "<group>"; };
+		D2F7E79907B2D74100F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		8DC2EF560486A6940098B216 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		034768DFFF38A50411DB9C8B /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				8DC2EF5B0486A6940098B216 /* CoreFoundation.framework */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		0867D691FE84028FC02AAC07 /* CoreFoundation */ = {
+			isa = PBXGroup;
+			children = (
+				32C88DFF0371C24200C91783 /* Other Sources */,
+				089C1665FE841158C02AAC07 /* Resources */,
+				0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */,
+				034768DFFF38A50411DB9C8B /* Products */,
+			);
+			name = CoreFoundation;
+			sourceTree = "<group>";
+		};
+		0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = {
+			isa = PBXGroup;
+			children = (
+				1058C7B0FEA5585E11CA2CBB /* Linked Frameworks */,
+				1058C7B2FEA5585E11CA2CBB /* Other Frameworks */,
+			);
+			name = "External Frameworks and Libraries";
+			sourceTree = "<group>";
+		};
+		089C1665FE841158C02AAC07 /* Resources */ = {
+			isa = PBXGroup;
+			children = (
+				8DC2EF5A0486A6940098B216 /* Info.plist */,
+			);
+			name = Resources;
+			sourceTree = "<group>";
+		};
+		1058C7B0FEA5585E11CA2CBB /* Linked Frameworks */ = {
+			isa = PBXGroup;
+			children = (
+				1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */,
+			);
+			name = "Linked Frameworks";
+			sourceTree = "<group>";
+		};
+		1058C7B2FEA5585E11CA2CBB /* Other Frameworks */ = {
+			isa = PBXGroup;
+			children = (
+				0867D6A5FE840307C02AAC07 /* AppKit.framework */,
+				D2F7E79907B2D74100F64583 /* CoreData.framework */,
+				0867D69BFE84028FC02AAC07 /* Foundation.framework */,
+			);
+			name = "Other Frameworks";
+			sourceTree = "<group>";
+		};
+		32C88DFF0371C24200C91783 /* Other Sources */ = {
+			isa = PBXGroup;
+			children = (
+				C83576340EDAB96C00E3D27B /* ForFoundationOnly.h */,
+				C83576350EDAB96C00E3D27B /* CFCalendar.h */,
+				C83576360EDAB96C00E3D27B /* CFCharacterSet.c */,
+				C83576370EDAB96C00E3D27B /* CFDateFormatter.h */,
+				C83576380EDAB96C00E3D27B /* CFUUID.h */,
+				C83576390EDAB96C00E3D27B /* CFSet.c */,
+				C835763A0EDAB96C00E3D27B /* CFBase.h */,
+				C835763B0EDAB96C00E3D27B /* CFStorage.h */,
+				C835763C0EDAB96C00E3D27B /* CFUniChar.c */,
+				C835763D0EDAB96C00E3D27B /* CFTree.h */,
+				C835763E0EDAB96C00E3D27B /* CFBag.c */,
+				C835763F0EDAB96C00E3D27B /* CFApplicationPreferences.c */,
+				C83576400EDAB96C00E3D27B /* CFBinaryPList.c */,
+				C83576410EDAB96C00E3D27B /* CFFileUtilities.c */,
+				C83576420EDAB96C00E3D27B /* CFDictionary.c */,
+				C83576430EDAB96C00E3D27B /* CFURLAccess.c */,
+				C83576440EDAB96C00E3D27B /* CFDateFormatter.c */,
+				C83576450EDAB96C00E3D27B /* CFMachPort.h */,
+				C83576460EDAB96C00E3D27B /* CFDate.c */,
+				C83576470EDAB96C00E3D27B /* CFUnicodePrecomposition.h */,
+				C83576480EDAB96C00E3D27B /* CFXMLParser.h */,
+				C83576490EDAB96C00E3D27B /* CFPropertyList.h */,
+				C835764A0EDAB96C00E3D27B /* CFBag.h */,
+				C835764B0EDAB96C00E3D27B /* CFSocket.h */,
+				C835764C0EDAB96C00E3D27B /* CFData.h */,
+				C835764D0EDAB96C00E3D27B /* CFRunLoopPriv.h */,
+				C835764E0EDAB96C00E3D27B /* CFCharacterSetPriv.h */,
+				C835764F0EDAB96C00E3D27B /* CFPriv.h */,
+				C83576500EDAB96C00E3D27B /* CFRunLoop.c */,
+				C83576510EDAB96C00E3D27B /* CFUniChar.h */,
+				C83576520EDAB96C00E3D27B /* CFPlugInCOM.h */,
+				C83576530EDAB96C00E3D27B /* CFError.c */,
+				C83576540EDAB96C00E3D27B /* CFRuntime.c */,
+				C83576550EDAB96C00E3D27B /* CFSet.h */,
+				C83576560EDAB96C00E3D27B /* CFNumberFormatter.h */,
+				C83576570EDAB96C00E3D27B /* CoreFoundation.h */,
+				C83576580EDAB96C00E3D27B /* CFTimeZone.c */,
+				C83576590EDAB96C00E3D27B /* CFXMLTree.c */,
+				C835765A0EDAB96C00E3D27B /* CFXMLPreferencesDomain.c */,
+				C835765B0EDAB96C00E3D27B /* CFStorage.c */,
+				C835765C0EDAB96C00E3D27B /* CFXMLNode.h */,
+				C835765D0EDAB96C00E3D27B /* CFBundle_BinaryTypes.h */,
+				C835765E0EDAB96C00E3D27B /* CFMessagePort.h */,
+				C835765F0EDAB96C00E3D27B /* auto_stubs.h */,
+				C83576600EDAB96C00E3D27B /* CFWindowsMessageQueue.h */,
+				C83576610EDAB96C00E3D27B /* CFStreamPriv.h */,
+				C83576620EDAB96C00E3D27B /* CFStringEncodingConverter.h */,
+				C83576630EDAB96C00E3D27B /* CFXMLNode.c */,
+				C83576640EDAB96C00E3D27B /* CFWindowsMessageQueue.c */,
+				C83576650EDAB96C00E3D27B /* CFNumber.h */,
+				C83576660EDAB96C00E3D27B /* CFVersion.c */,
+				C83576670EDAB96C00E3D27B /* CFStream.h */,
+				C83576680EDAB96C00E3D27B /* CFBinaryHeap.c */,
+				C83576690EDAB96C00E3D27B /* CFSocketStream.c */,
+				C835766A0EDAB96C00E3D27B /* CFRunLoop.h */,
+				C835766B0EDAB96C00E3D27B /* CFDate.h */,
+				C835766C0EDAB96C00E3D27B /* CFNumber.c */,
+				C835766D0EDAB96C00E3D27B /* CFDictionary.h */,
+				C835766E0EDAB96C00E3D27B /* CFBuiltinConverters.c */,
+				C835766F0EDAB96C00E3D27B /* CFStreamInternal.h */,
+				C83576700EDAB96C00E3D27B /* CFLocale.c */,
+				C83576710EDAB96C00E3D27B /* CFPlugIn_Factory.h */,
+				C83576720EDAB96C00E3D27B /* CFXMLInputStream.c */,
+				C83576730EDAB96C00E3D27B /* CFBundle_Resources.c */,
+				C83576740EDAB96C00E3D27B /* CFPlugIn.h */,
+				C83576750EDAB96C00E3D27B /* CFBinaryHeap.h */,
+				C83576760EDAB96C00E3D27B /* CFURLAccess.h */,
+				C83576770EDAB96C00E3D27B /* CFPlugIn.c */,
+				C83576780EDAB96C00E3D27B /* CFSystemDirectories.c */,
+				C83576790EDAB96C00E3D27B /* CFStreamAbstract.h */,
+				C835767A0EDAB96C00E3D27B /* CFPlugIn_Factory.c */,
+				C835767B0EDAB96C00E3D27B /* CFString.h */,
+				C835767C0EDAB96C00E3D27B /* CFBundle_Internal.h */,
+				C835767D0EDAB96C00E3D27B /* CFLocaleIdentifier.c */,
+				C835767E0EDAB96C00E3D27B /* CFSortFunctions.c */,
+				C835767F0EDAB96C00E3D27B /* CFUniCharPriv.h */,
+				C83576800EDAB96C00E3D27B /* CFLogUtilities.h */,
+				C83576810EDAB96C00E3D27B /* CFXMLInputStream.h */,
+				C83576820EDAB96C00E3D27B /* CFStringDefaultEncoding.h */,
+				C83576830EDAB96C00E3D27B /* CFData.c */,
+				C83576840EDAB96C00E3D27B /* CFUnicodePrecomposition.c */,
+				C83576850EDAB96C00E3D27B /* CFConcreteStreams.c */,
+				C83576860EDAB96C00E3D27B /* CFUserNotification.h */,
+				C83576870EDAB96C00E3D27B /* CFUnicodeDecomposition.c */,
+				C83576880EDAB96C00E3D27B /* CFUnicodeDecomposition.h */,
+				C83576890EDAB96C00E3D27B /* CFCalendar.c */,
+				C835768A0EDAB96C00E3D27B /* CFArray.c */,
+				C835768B0EDAB96C00E3D27B /* CFURL.h */,
+				C835768C0EDAB96C00E3D27B /* CFTree.c */,
+				C835768D0EDAB96C00E3D27B /* CFPropertyList.c */,
+				C835768E0EDAB96C00E3D27B /* CFTimeZone.h */,
+				C835768F0EDAB96C00E3D27B /* CFInternal.h */,
+				C83576900EDAB96C00E3D27B /* CFPlatform.c */,
+				C83576910EDAB96C00E3D27B /* CFPlugIn_PlugIn.c */,
+				C83576920EDAB96C00E3D27B /* CFBase.c */,
+				C83576930EDAB96C00E3D27B /* CFBitVector.c */,
+				C83576940EDAB96C00E3D27B /* CFStream.c */,
+				C83576950EDAB96C00E3D27B /* CFPlugIn_Instance.c */,
+				C83576960EDAB96C00E3D27B /* CFBundlePriv.h */,
+				C83576970EDAB96C00E3D27B /* CFPreferences.h */,
+				C83576980EDAB96C00E3D27B /* Compat.c */,
+				C83576990EDAB96C00E3D27B /* CFByteOrder.h */,
+				C835769A0EDAB96C00E3D27B /* CFString.c */,
+				C835769B0EDAB96C00E3D27B /* CFError_Private.h */,
+				C835769C0EDAB96C00E3D27B /* CFPreferences.c */,
+				C835769D0EDAB96C00E3D27B /* CFMachPort.c */,
+				C835769E0EDAB96C00E3D27B /* CFBundle.c */,
+				C835769F0EDAB96C00E3D27B /* CFNumberFormatter.c */,
+				C83576A00EDAB96C00E3D27B /* CFStringEncodingConverterPriv.h */,
+				C83576A10EDAB96C00E3D27B /* CFLocale.h */,
+				C83576A20EDAB96C00E3D27B /* CFBitVector.h */,
+				C83576A30EDAB96C00E3D27B /* CFStringEncodingExt.h */,
+				C83576A40EDAB96C00E3D27B /* CFRuntime.h */,
+				C83576A50EDAB96C00E3D27B /* CFStringUtilities.c */,
+				C83576A60EDAB96C00E3D27B /* CFMessagePort.c */,
+				C83576A70EDAB96C00E3D27B /* CFURL.c */,
+				C83576A80EDAB96C00E3D27B /* CFArray.h */,
+				C83576A90EDAB96C00E3D27B /* CFSocket.c */,
+				C83576AA0EDAB96C00E3D27B /* CFUtilities.c */,
+				C83576AB0EDAB96C00E3D27B /* CFStringEncodings.c */,
+				C83576AC0EDAB96C00E3D27B /* CFBundle.h */,
+				C83576AD0EDAB96C00E3D27B /* CFUUID.c */,
+				C83579000EDAD0A100E3D27B /* AvailabilityMacros.h */,
+				C83576AE0EDAB96C00E3D27B /* CFXMLParser.c */,
+				C83576AF0EDAB96C00E3D27B /* CFUserNotification.c */,
+				C83576B00EDAB96C00E3D27B /* CFStringEncodingConverter.c */,
+				C83576B10EDAB96C00E3D27B /* CFStringScanner.c */,
+				C83576B20EDAB96C00E3D27B /* CFStringEncodingConverterExt.h */,
+				C83576B30EDAB96C00E3D27B /* CFCharacterSet.h */,
+				C83576B40EDAB96C00E3D27B /* CFError.h */,
+				C835789A0EDAC64D00E3D27B /* Cocotron.c */,
+			);
+			name = "Other Sources";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+		8DC2EF500486A6940098B216 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				C83576B50EDAB96C00E3D27B /* ForFoundationOnly.h in Headers */,
+				C83576B60EDAB96C00E3D27B /* CFCalendar.h in Headers */,
+				C83576B80EDAB96C00E3D27B /* CFDateFormatter.h in Headers */,
+				C83576B90EDAB96C00E3D27B /* CFUUID.h in Headers */,
+				C83576BB0EDAB96C00E3D27B /* CFBase.h in Headers */,
+				C83576BC0EDAB96C00E3D27B /* CFStorage.h in Headers */,
+				C83576BE0EDAB96C00E3D27B /* CFTree.h in Headers */,
+				C83576C60EDAB96C00E3D27B /* CFMachPort.h in Headers */,
+				C83576C80EDAB96C00E3D27B /* CFUnicodePrecomposition.h in Headers */,
+				C83576C90EDAB96C00E3D27B /* CFXMLParser.h in Headers */,
+				C83576CA0EDAB96C00E3D27B /* CFPropertyList.h in Headers */,
+				C83576CB0EDAB96C00E3D27B /* CFBag.h in Headers */,
+				C83576CC0EDAB96C00E3D27B /* CFSocket.h in Headers */,
+				C83576CD0EDAB96C00E3D27B /* CFData.h in Headers */,
+				C83576CE0EDAB96C00E3D27B /* CFRunLoopPriv.h in Headers */,
+				C83576CF0EDAB96C00E3D27B /* CFCharacterSetPriv.h in Headers */,
+				C83576D00EDAB96C00E3D27B /* CFPriv.h in Headers */,
+				C83576D20EDAB96C00E3D27B /* CFUniChar.h in Headers */,
+				C83576D30EDAB96C00E3D27B /* CFPlugInCOM.h in Headers */,
+				C83576D60EDAB96C00E3D27B /* CFSet.h in Headers */,
+				C83576D70EDAB96C00E3D27B /* CFNumberFormatter.h in Headers */,
+				C83576D80EDAB96C00E3D27B /* CoreFoundation.h in Headers */,
+				C83576DD0EDAB96C00E3D27B /* CFXMLNode.h in Headers */,
+				C83576DE0EDAB96C00E3D27B /* CFBundle_BinaryTypes.h in Headers */,
+				C83576DF0EDAB96C00E3D27B /* CFMessagePort.h in Headers */,
+				C83576E00EDAB96C00E3D27B /* auto_stubs.h in Headers */,
+				C83576E10EDAB96C00E3D27B /* CFWindowsMessageQueue.h in Headers */,
+				C83576E20EDAB96C00E3D27B /* CFStreamPriv.h in Headers */,
+				C83576E30EDAB96C00E3D27B /* CFStringEncodingConverter.h in Headers */,
+				C83576E60EDAB96C00E3D27B /* CFNumber.h in Headers */,
+				C83576E80EDAB96C00E3D27B /* CFStream.h in Headers */,
+				C83576EB0EDAB96C00E3D27B /* CFRunLoop.h in Headers */,
+				C83576EC0EDAB96C00E3D27B /* CFDate.h in Headers */,
+				C83576EE0EDAB96C00E3D27B /* CFDictionary.h in Headers */,
+				C83576F00EDAB96C00E3D27B /* CFStreamInternal.h in Headers */,
+				C83576F20EDAB96C00E3D27B /* CFPlugIn_Factory.h in Headers */,
+				C83576F50EDAB96C00E3D27B /* CFPlugIn.h in Headers */,
+				C83576F60EDAB96C00E3D27B /* CFBinaryHeap.h in Headers */,
+				C83576F70EDAB96C00E3D27B /* CFURLAccess.h in Headers */,
+				C83576FA0EDAB96C00E3D27B /* CFStreamAbstract.h in Headers */,
+				C83576FC0EDAB96C00E3D27B /* CFString.h in Headers */,
+				C83576FD0EDAB96C00E3D27B /* CFBundle_Internal.h in Headers */,
+				C83577000EDAB96C00E3D27B /* CFUniCharPriv.h in Headers */,
+				C83577010EDAB96C00E3D27B /* CFLogUtilities.h in Headers */,
+				C83577020EDAB96C00E3D27B /* CFXMLInputStream.h in Headers */,
+				C83577030EDAB96C00E3D27B /* CFStringDefaultEncoding.h in Headers */,
+				C83577070EDAB96C00E3D27B /* CFUserNotification.h in Headers */,
+				C83577090EDAB96C00E3D27B /* CFUnicodeDecomposition.h in Headers */,
+				C835770C0EDAB96C00E3D27B /* CFURL.h in Headers */,
+				C835770F0EDAB96C00E3D27B /* CFTimeZone.h in Headers */,
+				C83577100EDAB96C00E3D27B /* CFInternal.h in Headers */,
+				C83577170EDAB96C00E3D27B /* CFBundlePriv.h in Headers */,
+				C83577180EDAB96C00E3D27B /* CFPreferences.h in Headers */,
+				C835771A0EDAB96C00E3D27B /* CFByteOrder.h in Headers */,
+				C835771C0EDAB96C00E3D27B /* CFError_Private.h in Headers */,
+				C83577210EDAB96C00E3D27B /* CFStringEncodingConverterPriv.h in Headers */,
+				C83577220EDAB96C00E3D27B /* CFLocale.h in Headers */,
+				C83577230EDAB96C00E3D27B /* CFBitVector.h in Headers */,
+				C83577240EDAB96C00E3D27B /* CFStringEncodingExt.h in Headers */,
+				C83577250EDAB96C00E3D27B /* CFRuntime.h in Headers */,
+				C83577290EDAB96C00E3D27B /* CFArray.h in Headers */,
+				C835772D0EDAB96C00E3D27B /* CFBundle.h in Headers */,
+				C83577330EDAB96C00E3D27B /* CFStringEncodingConverterExt.h in Headers */,
+				C83577340EDAB96C00E3D27B /* CFCharacterSet.h in Headers */,
+				C83577350EDAB96C00E3D27B /* CFError.h in Headers */,
+				C83579010EDAD0A100E3D27B /* AvailabilityMacros.h in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+		8DC2EF4F0486A6940098B216 /* CoreFoundation-Windows */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "CoreFoundation-Windows" */;
+			buildPhases = (
+				8DC2EF500486A6940098B216 /* Headers */,
+				8DC2EF520486A6940098B216 /* Resources */,
+				8DC2EF540486A6940098B216 /* Sources */,
+				8DC2EF560486A6940098B216 /* Frameworks */,
+			);
+			buildRules = (
+				C83575E00EDAB63400E3D27B /* PBXBuildRule */,
+			);
+			dependencies = (
+			);
+			name = "CoreFoundation-Windows";
+			productInstallPath = "$(HOME)/Library/Frameworks";
+			productName = CoreFoundation;
+			productReference = 8DC2EF5B0486A6940098B216 /* CoreFoundation.framework */;
+			productType = "com.apple.product-type.framework";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		0867D690FE84028FC02AAC07 /* Project object */ = {
+			isa = PBXProject;
+			buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "CoreFoundation" */;
+			compatibilityVersion = "Xcode 3.1";
+			hasScannedForEncodings = 1;
+			mainGroup = 0867D691FE84028FC02AAC07 /* CoreFoundation */;
+			productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				8DC2EF4F0486A6940098B216 /* CoreFoundation-Windows */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		8DC2EF520486A6940098B216 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		8DC2EF540486A6940098B216 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				C83576B70EDAB96C00E3D27B /* CFCharacterSet.c in Sources */,
+				C83576BA0EDAB96C00E3D27B /* CFSet.c in Sources */,
+				C83576BD0EDAB96C00E3D27B /* CFUniChar.c in Sources */,
+				C83576BF0EDAB96C00E3D27B /* CFBag.c in Sources */,
+				C83576C00EDAB96C00E3D27B /* CFApplicationPreferences.c in Sources */,
+				C83576C10EDAB96C00E3D27B /* CFBinaryPList.c in Sources */,
+				C83576C20EDAB96C00E3D27B /* CFFileUtilities.c in Sources */,
+				C83576C30EDAB96C00E3D27B /* CFDictionary.c in Sources */,
+				C83576C40EDAB96C00E3D27B /* CFURLAccess.c in Sources */,
+				C83576C50EDAB96C00E3D27B /* CFDateFormatter.c in Sources */,
+				C83576C70EDAB96C00E3D27B /* CFDate.c in Sources */,
+				C83576D10EDAB96C00E3D27B /* CFRunLoop.c in Sources */,
+				C83576D40EDAB96C00E3D27B /* CFError.c in Sources */,
+				C83576D50EDAB96C00E3D27B /* CFRuntime.c in Sources */,
+				C83576D90EDAB96C00E3D27B /* CFTimeZone.c in Sources */,
+				C83576DA0EDAB96C00E3D27B /* CFXMLTree.c in Sources */,
+				C83576DB0EDAB96C00E3D27B /* CFXMLPreferencesDomain.c in Sources */,
+				C83576DC0EDAB96C00E3D27B /* CFStorage.c in Sources */,
+				C83576E40EDAB96C00E3D27B /* CFXMLNode.c in Sources */,
+				C83576E50EDAB96C00E3D27B /* CFWindowsMessageQueue.c in Sources */,
+				C83576E70EDAB96C00E3D27B /* CFVersion.c in Sources */,
+				C83576E90EDAB96C00E3D27B /* CFBinaryHeap.c in Sources */,
+				C83576EA0EDAB96C00E3D27B /* CFSocketStream.c in Sources */,
+				C83576ED0EDAB96C00E3D27B /* CFNumber.c in Sources */,
+				C83576EF0EDAB96C00E3D27B /* CFBuiltinConverters.c in Sources */,
+				C83576F10EDAB96C00E3D27B /* CFLocale.c in Sources */,
+				C83576F30EDAB96C00E3D27B /* CFXMLInputStream.c in Sources */,
+				C83576F40EDAB96C00E3D27B /* CFBundle_Resources.c in Sources */,
+				C83576F80EDAB96C00E3D27B /* CFPlugIn.c in Sources */,
+				C83576F90EDAB96C00E3D27B /* CFSystemDirectories.c in Sources */,
+				C83576FB0EDAB96C00E3D27B /* CFPlugIn_Factory.c in Sources */,
+				C83576FE0EDAB96C00E3D27B /* CFLocaleIdentifier.c in Sources */,
+				C83576FF0EDAB96C00E3D27B /* CFSortFunctions.c in Sources */,
+				C83577040EDAB96C00E3D27B /* CFData.c in Sources */,
+				C83577050EDAB96C00E3D27B /* CFUnicodePrecomposition.c in Sources */,
+				C83577060EDAB96C00E3D27B /* CFConcreteStreams.c in Sources */,
+				C83577080EDAB96C00E3D27B /* CFUnicodeDecomposition.c in Sources */,
+				C835770A0EDAB96C00E3D27B /* CFCalendar.c in Sources */,
+				C835770B0EDAB96C00E3D27B /* CFArray.c in Sources */,
+				C835770D0EDAB96C00E3D27B /* CFTree.c in Sources */,
+				C835770E0EDAB96C00E3D27B /* CFPropertyList.c in Sources */,
+				C83577110EDAB96C00E3D27B /* CFPlatform.c in Sources */,
+				C83577120EDAB96C00E3D27B /* CFPlugIn_PlugIn.c in Sources */,
+				C83577130EDAB96C00E3D27B /* CFBase.c in Sources */,
+				C83577140EDAB96C00E3D27B /* CFBitVector.c in Sources */,
+				C83577150EDAB96C00E3D27B /* CFStream.c in Sources */,
+				C83577160EDAB96C00E3D27B /* CFPlugIn_Instance.c in Sources */,
+				C83577190EDAB96C00E3D27B /* Compat.c in Sources */,
+				C835771B0EDAB96C00E3D27B /* CFString.c in Sources */,
+				C835771D0EDAB96C00E3D27B /* CFPreferences.c in Sources */,
+				C835771E0EDAB96C00E3D27B /* CFMachPort.c in Sources */,
+				C835771F0EDAB96C00E3D27B /* CFBundle.c in Sources */,
+				C83577200EDAB96C00E3D27B /* CFNumberFormatter.c in Sources */,
+				C83577260EDAB96C00E3D27B /* CFStringUtilities.c in Sources */,
+				C83577270EDAB96C00E3D27B /* CFMessagePort.c in Sources */,
+				C83577280EDAB96C00E3D27B /* CFURL.c in Sources */,
+				C835772A0EDAB96C00E3D27B /* CFSocket.c in Sources */,
+				C835772B0EDAB96C00E3D27B /* CFUtilities.c in Sources */,
+				C835772C0EDAB96C00E3D27B /* CFStringEncodings.c in Sources */,
+				C835772E0EDAB96C00E3D27B /* CFUUID.c in Sources */,
+				C835772F0EDAB96C00E3D27B /* CFXMLParser.c in Sources */,
+				C83577300EDAB96C00E3D27B /* CFUserNotification.c in Sources */,
+				C83577310EDAB96C00E3D27B /* CFStringEncodingConverter.c in Sources */,
+				C83577320EDAB96C00E3D27B /* CFStringScanner.c in Sources */,
+				C835789C0EDAC64D00E3D27B /* Cocotron.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+		1DEB91AE08733DA50010E9CD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				DEPLOYMENT_LOCATION = YES;
+				DEPLOYMENT_POSTPROCESSING = YES;
+				DSTROOT = /;
+				EXECUTABLE_SUFFIX = .1.0.dll;
+				FRAMEWORK_SEARCH_PATHS = /Developer/Cocotron/1.0/Windows/i386/Frameworks;
+				FRAMEWORK_VERSION = A;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"__USE_MINGW_ANSI_STDIO=0",
+					"WINVER=0x500",
+					U_HAVE_INTTYPES_H,
+					"CF_BUILDING_CF=1",
+					"DEPLOYMENT_TARGET_WIN32=1",
+					"COCOTRON=1",
+				);
+				HEADER_SEARCH_PATHS = (
+					.,
+					Compatibility,
+				);
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_MODE_FLAG = "og-w,a+rX";
+				INSTALL_PATH = /Developer/Cocotron/1.0/Windows/i386/Frameworks;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/lib\"",
+				);
+				OTHER_LDFLAGS = (
+					"-Wl,--enable-auto-import",
+					"-shared",
+					"-lmsvcrt",
+					"-lnetapi32",
+					"-lole32",
+					"-lws2_32",
+					"-lkernel32",
+					"-lrpcrt4",
+					"-Wl,--out-implib,$TARGET_BUILD_DIR/CoreFoundation.framework/libCoreFoundation.a",
+					"\"$(SRCROOT)/lib/sicuin.lib\"",
+					"\"$(SRCROOT)/lib/sicuuc.lib\"",
+					"\"$(SRCROOT)/lib/sicudt.lib\"",
+					"-lstdc++",
+				);
+				PRODUCT_NAME = CoreFoundation;
+				SYMROOT = /Developer/Cocotron/1.0/build/CoreFoundation/Windows/i386;
+				WRAPPER_EXTENSION = framework;
+			};
+			name = Debug;
+		};
+		1DEB91AF08733DA50010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				DEPLOYMENT_LOCATION = YES;
+				DEPLOYMENT_POSTPROCESSING = YES;
+				DSTROOT = /;
+				EXECUTABLE_SUFFIX = .1.0.dll;
+				FRAMEWORK_SEARCH_PATHS = /Developer/Cocotron/1.0/Windows/i386/Frameworks;
+				FRAMEWORK_VERSION = A;
+				GCC_MODEL_TUNING = G5;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					U_HAVE_INTTYPES_H,
+					"CF_BUILDING_CF=1",
+					DEPLOYMENT_TARGET_WIN32,
+				);
+				HEADER_SEARCH_PATHS = (
+					.,
+					Compatibility,
+				);
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_MODE_FLAG = "og-w,a+rX";
+				INSTALL_PATH = /Developer/Cocotron/1.0/Windows/i386/Frameworks;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/lib\"",
+				);
+				OTHER_LDFLAGS = (
+					"-Wl,--enable-auto-import",
+					"-shared",
+					"-lmsvcrt",
+					"-lnetapi32",
+					"-lole32",
+					"-lws2_32",
+					"-lkernel32",
+					"-lrpcrt4",
+					"-Wl,--out-implib,$TARGET_BUILD_DIR/CoreFoundation.framework/libCoreFoundation.a",
+				);
+				PRODUCT_NAME = CoreFoundation;
+				SYMROOT = /Developer/Cocotron/1.0/build/CoreFoundation/Windows/i386;
+				WRAPPER_EXTENSION = framework;
+			};
+			name = Release;
+		};
+		1DEB91B208733DA50010E9CD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				GCC_C_LANGUAGE_STANDARD = c99;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				ONLY_ACTIVE_ARCH = YES;
+				PREBINDING = NO;
+			};
+			name = Debug;
+		};
+		1DEB91B308733DA50010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				GCC_C_LANGUAGE_STANDARD = c99;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				PREBINDING = NO;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "CoreFoundation-Windows" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1DEB91AE08733DA50010E9CD /* Debug */,
+				1DEB91AF08733DA50010E9CD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "CoreFoundation" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1DEB91B208733DA50010E9CD /* Debug */,
+				1DEB91B308733DA50010E9CD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
+}
diff --git a/CoreFoundation/CoreFoundation.h b/CoreFoundation/CoreFoundation.h
new file mode 100755
index 0000000..a2cc8f1
--- /dev/null
+++ b/CoreFoundation/CoreFoundation.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(__COREFOUNDATION_COREFOUNDATION__)
+#define __COREFOUNDATION_COREFOUNDATION__ 1
+#define __COREFOUNDATION__ 1
+
+#ifdef WIN32
+// Must include this first, or redeclaration problems.
+#include <winsock2.h>
+#endif
+
+#if !defined(CF_EXCLUDE_CSTD_HEADERS)
+
+#include <sys/types.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <float.h>
+#include <limits.h>
+#include <locale.h>
+#include <math.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#if defined(__STDC_VERSION__) && (199901L <= __STDC_VERSION__)
+
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#endif
+
+#endif
+
+#include <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFBag.h>
+#include <CoreFoundation/CFBinaryHeap.h>
+#include <CoreFoundation/CFBitVector.h>
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFByteOrder.h>
+#include <CoreFoundation/CFCalendar.h>
+#include <CoreFoundation/CFCharacterSet.h>
+#include <CoreFoundation/CFData.h>
+#include <CoreFoundation/CFDate.h>
+#include <CoreFoundation/CFDateFormatter.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFError.h>
+#include <CoreFoundation/CFLocale.h>
+#include <CoreFoundation/CFLogUtilities.h>
+#include <CoreFoundation/CFMachPort.h>
+#include <CoreFoundation/CFMessagePort.h>
+#include <CoreFoundation/CFNumber.h>
+#include <CoreFoundation/CFNumberFormatter.h>
+#include <CoreFoundation/CFPlugIn.h>
+#include <CoreFoundation/CFPreferences.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFRunLoop.h>
+#include <CoreFoundation/CFSet.h>
+#include <CoreFoundation/CFSocket.h>
+#include <CoreFoundation/CFStream.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFStringEncodingExt.h>
+#include <CoreFoundation/CFTimeZone.h>
+#include <CoreFoundation/CFTree.h>
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFURLAccess.h>
+#include <CoreFoundation/CFUUID.h>
+#include <CoreFoundation/CFXMLNode.h>
+#include <CoreFoundation/CFXMLParser.h>
+
+
+#endif /* ! __COREFOUNDATION_COREFOUNDATION__ */
+
diff --git a/CoreFoundation/CoreFoundation.pc.in b/CoreFoundation/CoreFoundation.pc.in
new file mode 100644
index 0000000..eaf8a31
--- /dev/null
+++ b/CoreFoundation/CoreFoundation.pc.in
@@ -0,0 +1,15 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+datarootdir=@datarootdir@
+datadir=@datadir@
+includedir=@includedir@
+
+Name: @PACKAGE_NAME@
+Version: @PACKAGE_VERSION@
+Description: A portable version of Apple's Mac OS X CoreFoundation library.
+URL: http://opencflite.sourceforge.net/
+Requires: icu >= 3.6, uuid
+Cflags: -I${includedir}
+Libs: -L${libdir} -lCoreFoundation
+Libs.private: @LIBS@
diff --git a/CoreFoundation/ForFoundationOnly.h b/CoreFoundation/ForFoundationOnly.h
new file mode 100755
index 0000000..8154e24
--- /dev/null
+++ b/CoreFoundation/ForFoundationOnly.h
@@ -0,0 +1,557 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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-2007, 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 <CoreFoundation/CFBase.h>
+#include <CoreFoundation/CFString.h>
+#include <CoreFoundation/CFArray.h>
+#include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFPriv.h>
+#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFError.h>
+#include <CoreFoundation/CFStringEncodingExt.h>
+#include <limits.h>
+
+// NOTE: miscellaneous declarations are at the end
+
+// ---- CFRuntime material ----------------------------------------
+
+CF_EXTERN_C_BEGIN
+
+#if DEPLOYMENT_TARGET_MACOSX || defined(__APPLE__)
+#include <malloc/malloc.h>
+#endif /* DEPLOYMENT_TARGET_MACOSX */
+
+CF_EXTERN_C_END
+
+// ---- CFBundle material ----------------------------------------
+
+#include <CoreFoundation/CFBundlePriv.h>
+
+CF_EXTERN_C_BEGIN
+
+#if defined(DEPLOYMENT_TARGET_WINDOWS)
+void __CFStringCleanup(void);
+void __CFUniCharCleanup(void);
+void __CFBaseCleanup(void);
+void __CFPreferencesDomainInitialize(void);
+#endif
+
+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 _kCFBundleCFMLoadAsBundleKey;
+CF_EXPORT const CFStringRef _kCFBundleAllowMixedLocalizationsKey;
+CF_EXPORT const CFStringRef _kCFBundleInitialPathKey;
+CF_EXPORT const CFStringRef _kCFBundleResolvedPathKey;
+CF_EXPORT const CFStringRef _kCFBundlePrincipalClassKey;
+
+CF_EXPORT CFArrayRef _CFFindBundleResources(CFBundleRef bundle, CFURLRef bundleURL, CFStringRef subDirName, CFArrayRef searchLanguages, CFStringRef resName, CFArrayRef resTypes, CFIndex limit, UInt8 version);
+
+CF_EXPORT UInt8 _CFBundleLayoutVersion(CFBundleRef bundle);
+
+CF_EXPORT CFArrayRef _CFBundleCopyLanguageSearchListInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt8 *version);
+CF_EXPORT CFArrayRef _CFBundleGetLanguageSearchList(CFBundleRef bundle);
+
+CF_EXPORT Boolean _CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error);
+CF_EXPORT CFErrorRef _CFBundleCreateError(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code);
+
+CF_EXTERN_C_END
+
+
+#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
+// ---- 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;
+//#if DEPLOYMENT_TARGET_WINDOWS
+//CF_EXPORT const _CFPreferencesDomainCallBacks __kCFWindowsRegistryDomainCallBacks;
+//#else
+CF_EXPORT const _CFPreferencesDomainCallBacks __kCFXMLPropertyListDomainCallBacks;
+//#endif
+
+typedef struct __CFPreferencesDomain * CFPreferencesDomainRef;
+
+CF_EXPORT CFPreferencesDomainRef _CFPreferencesDomainCreate(CFTypeRef context, const _CFPreferencesDomainCallBacks *callBacks);
+CF_EXPORT CFPreferencesDomainRef _CFPreferencesStandardDomain(CFStringRef domainName, CFStringRef userName, CFStringRef hostName);
+
+CF_EXPORT CFTypeRef _CFPreferencesDomainCreateValueForKey(CFPreferencesDomainRef domain, CFStringRef key);
+CF_EXPORT void _CFPreferencesDomainSet(CFPreferencesDomainRef domain, CFStringRef key, CFTypeRef value);
+CF_EXPORT Boolean _CFPreferencesDomainSynchronize(CFPreferencesDomainRef domain);
+
+CF_EXPORT 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
+
+#endif
+
+// ---- CFString material ----------------------------------------
+
+
+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_INLINE Boolean __CFStringEncodingIsSupersetOfASCII(CFStringEncoding encoding) {
+    switch (encoding & 0x0000FF00) {
+
+        case 0x100: // Unicode range
+            if (encoding != kCFStringEncodingUTF8) 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 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. The table is always safe to use; calling __CFSetCharToUniCharFunc() updates it.
+*/
+CF_EXPORT Boolean (*__CFCharToUniCharFunc)(UInt32 flags, UInt8 ch, UniChar *unicodeChar);
+CF_EXPORT void __CFSetCharToUniCharFunc(Boolean (*func)(UInt32 flags, UInt8 ch, UniChar *unicodeChar));
+CF_EXPORT UniChar __CFCharToUniCharTable[256];
+
+/* 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 (buf->directBuffer) {
+	if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF;
+        return buf->directBuffer[idx + buf->rangeToBuffer.location];
+    }
+    if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
+	if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF;
+	if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0;
+	buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
+	if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
+	CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
+    }
+    return buf->buffer[idx - buf->bufferedRangeStart];
+}
+
+/* Same as CFStringGetCharacterFromInlineBuffer(), but without the bounds checking (will return garbage or crash)
+*/
+CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferQuick(CFStringInlineBuffer *buf, CFIndex idx) {
+    if (buf->directBuffer) return buf->directBuffer[idx + buf->rangeToBuffer.location];
+    if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
+	if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0;
+	buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
+	if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
+	CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
+    }
+    return buf->buffer[idx - buf->bufferedRangeStart];
+}
+
+
+/* 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);
+
+/* 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);
+
+/* Currently for CFString usage, for handling out-of-memory conditions.
+   The callback might not return; if it does, true indicates the error was potentially dealt with; false means no.
+   Typically true means OK to continue executing.
+*/
+typedef Boolean (*CFBadErrorCallBack)(CFTypeRef obj, CFStringRef domain, CFStringRef msg);
+CF_EXPORT CFBadErrorCallBack _CFGetOutOfMemoryErrorCallBack(void);
+CF_EXPORT void _CFSetOutOfMemoryErrorCallBack(CFBadErrorCallBack callback);
+
+
+
+CF_EXTERN_C_END
+
+
+// ---- Binary plist material ----------------------------------------
+
+typedef const struct __CFKeyedArchiverUID * CFKeyedArchiverUIDRef;
+extern CFTypeID _CFKeyedArchiverUIDGetTypeID(void);
+extern CFKeyedArchiverUIDRef _CFKeyedArchiverUIDCreate(CFAllocatorRef allocator, uint32_t value);
+extern uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid);
+
+
+enum {
+    kCFBinaryPlistMarkerNull = 0x00,
+    kCFBinaryPlistMarkerFalse = 0x08,
+    kCFBinaryPlistMarkerTrue = 0x09,
+    kCFBinaryPlistMarkerFill = 0x0F,
+    kCFBinaryPlistMarkerInt = 0x10,
+    kCFBinaryPlistMarkerReal = 0x20,
+    kCFBinaryPlistMarkerDate = 0x33,
+    kCFBinaryPlistMarkerData = 0x40,
+    kCFBinaryPlistMarkerASCIIString = 0x50,
+    kCFBinaryPlistMarkerUnicode16String = 0x60,
+    kCFBinaryPlistMarkerUID = 0x80,
+    kCFBinaryPlistMarkerArray = 0xA0,
+    kCFBinaryPlistMarkerSet = 0xC0,
+    kCFBinaryPlistMarkerDict = 0xD0
+};
+
+typedef struct {
+    uint8_t	_magic[6];
+    uint8_t	_version[2];
+} CFBinaryPlistHeader;
+
+typedef struct {
+    uint8_t	_unused[6];
+    uint8_t	_offsetIntSize;
+    uint8_t	_objectRefSize;
+    uint64_t	_numObjects;
+    uint64_t	_topObject;
+    uint64_t	_offsetTableOffset;
+} CFBinaryPlistTrailer;
+
+extern bool __CFBinaryPlistGetTopLevelInfo(const uint8_t *databytes, uint64_t datalen, uint8_t *marker, uint64_t *offset, CFBinaryPlistTrailer *trailer);
+extern bool __CFBinaryPlistGetOffsetForValueFromArray2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFIndex idx, uint64_t *offset, CFMutableDictionaryRef objects);
+extern bool __CFBinaryPlistGetOffsetForValueFromDictionary2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFTypeRef key, uint64_t *koffset, uint64_t *voffset, CFMutableDictionaryRef objects);
+extern bool __CFBinaryPlistCreateObject(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFPropertyListRef *plist);
+extern CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream);
+
+
+// ---- Used by property list parsing in Foundation
+
+extern CFTypeRef _CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format);
+
+
+// ---- Miscellaneous material ----------------------------------------
+
+#include <CoreFoundation/CFBag.h>
+#include <CoreFoundation/CFSet.h>
+#include <math.h>
+
+CF_EXTERN_C_BEGIN
+
+CF_EXPORT CFTypeID CFTypeGetTypeID(void);
+
+CF_EXPORT CFTypeRef _CFRetainGC(CFTypeRef cf);
+CF_EXPORT void _CFReleaseGC(CFTypeRef cf);
+
+CF_EXPORT void _CFArraySetCapacity(CFMutableArrayRef array, CFIndex cap);
+CF_EXPORT void _CFBagSetCapacity(CFMutableBagRef bag, CFIndex cap);
+CF_EXPORT void _CFDictionarySetCapacity(CFMutableDictionaryRef dict, CFIndex cap);
+CF_EXPORT void _CFSetSetCapacity(CFMutableSetRef set, CFIndex cap);
+
+CF_EXPORT void CFCharacterSetCompact(CFMutableCharacterSetRef theSet);
+CF_EXPORT void CFCharacterSetFast(CFMutableCharacterSetRef theSet);
+
+CF_EXPORT const void *_CFArrayCheckAndGetValueAtIndex(CFArrayRef array, CFIndex idx);
+CF_EXPORT void _CFArrayReplaceValues(CFMutableArrayRef array, CFRange range, const void **newValues, CFIndex newCount);
+
+
+/* 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;
+}
+
+#if _MSC_VER
+CF_INLINE long rint(double x) {
+   return (long) floor (x + 0.5);
+}
+#endif
+
+CF_INLINE CFHashCode _CFHashDouble(double d) {
+    double dInt;
+    if (d < 0) d = -d;
+    dInt = rint(d);
+    return (CFHashCode)((HASHFACTOR * (CFHashCode)fmod(dInt, (double)ULONG_MAX)) + ((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 CFURLRef _CFURLAlloc(CFAllocatorRef allocator);
+CF_EXPORT void _CFURLInitWithString(CFURLRef url, CFStringRef string, CFURLRef baseURL);
+CF_EXPORT void _CFURLInitFSPath(CFURLRef url, CFStringRef path);
+CF_EXPORT Boolean _CFStringIsLegalURLString(CFStringRef string);
+CF_EXPORT void *__CFURLReservedPtr(CFURLRef  url);
+CF_EXPORT void __CFURLSetReservedPtr(CFURLRef  url, void *ptr);
+CF_EXPORT CFStringEncoding _CFURLGetEncoding(CFURLRef url);
+
+CF_EXPORT Boolean _CFRunLoopFinished(CFRunLoopRef rl, CFStringRef mode);
+
+CF_EXPORT CFIndex _CFStreamInstanceSize(void);
+
+#if DEPLOYMENT_TARGET_MACOSX
+    #if !defined(__CFReadTSR)
+    #include <mach/mach_time.h>
+    #define __CFReadTSR() mach_absolute_time()
+    #endif
+#elif DEPLOYMENT_TARGET_WINDOWS
+CF_INLINE UInt64 __CFReadTSR(void) {
+    LARGE_INTEGER freq;
+    QueryPerformanceCounter(&freq);
+    return freq.QuadPart;
+}
+#elif (DEPLOYMENT_TARGET_LINUX)
+// On Linux, __CFReadTSR (see ForFoundation.h) is implemented on the
+// POSIX RT clock_gettime API using the monotonic clock source. Using
+// the alernative "default" processor timebase solution below has
+// problems in that A) it may not work correctly in a multi-processor
+// case and B) there is no standard API on Linux to get the timebase
+// scalar and no arbitrary way to get it in a fashion consistent across
+// Linux architectures (e.g. /proc/cpuinfo is different on i386 vs.
+// powerpc). See CFDate.c for companion initialization code.
+#include <time.h>
+CF_INLINE UInt64 __CFReadTSR(void) {
+	struct timespec now;
+	clock_gettime(CLOCK_MONOTONIC, &now);
+	return (((UInt64)now.tv_sec * 1000000000) + now.tv_nsec);
+}
+#else
+CF_INLINE UInt64 __CFReadTSR(void) {
+    union {
+		UInt64 time64;
+		UInt32 word[2];
+    } now;
+#if defined(__i386__)
+    /* Read from Pentium and Pentium Pro 64-bit timestamp counter. */
+    /* The counter is set to 0 at processor reset and increments on */
+    /* every clock cycle. */
+    __asm__ volatile("rdtsc" : : : "eax", "edx");
+    __asm__ volatile("movl %%eax,%0" : "=m" (now.word[0]) : : "eax");
+    __asm__ volatile("movl %%edx,%0" : "=m" (now.word[1]) : : "edx");
+#elif defined(__ppc__) || defined(__powerpc__)
+    /* Read from PowerPC 64-bit time base register. */
+    UInt32 t3;
+    do {
+		__asm__ volatile("mftbu %0" : "=r" (now.word[0]));
+		__asm__ volatile("mftb %0" : "=r" (now.word[1]));
+		__asm__ volatile("mftbu %0" : "=r" (t3));
+    } while (now.word[0] != t3);
+#else
+#warning "No known method for reading a time stamp register on this architecture."
+    now.time64 = (uint64_t)0;
+#endif /* defined(__i386__) */
+    return now.time64;
+}
+#endif
+
+#define CF_HAS_NSOBJECT 1
+#define CF_HAS_NSARRAY 1
+#define CF_HAS_NSMUTABLEARRAY 1
+#define CF_HAS_NSDICTIONARY 1
+#define CF_HAS_NSMUTABLEDICTIONARY 1
+#define CF_HAS_NSSET 1
+#define CF_HAS_NSMUTABLESET 1
+#define CF_HAS_NSBATCH2 1
+
+CF_EXTERN_C_END
+
+#endif /* ! __COREFOUNDATION_FORFOUNDATIONONLY__ */
+
diff --git a/CoreFoundation/INSTALL b/CoreFoundation/INSTALL
new file mode 100644
index 0000000..5458714
--- /dev/null
+++ b/CoreFoundation/INSTALL
@@ -0,0 +1,234 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/CoreFoundation/Info.plist b/CoreFoundation/Info.plist
new file mode 100644
index 0000000..d7dfd29
--- /dev/null
+++ b/CoreFoundation/Info.plist
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en_US</string>
+	<key>CFBundleExecutable</key>
+	<string>CFLite</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.CFLite</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>CFLite</string>
+	<key>CFBundlePackageType</key>
+	<string>FMWK</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>476.17</string>
+	<key>CarbonLazyValues</key>
+	<dict>
+		<key>CodeFragmentManager</key>
+		<dict>
+			<key>CoreFoundation</key>
+			<string>CFMPriv_CoreFoundation</string>
+		</dict>
+	</dict>
+</dict>
+</plist>
diff --git a/CoreFoundation/LICENSE b/CoreFoundation/LICENSE
new file mode 100644
index 0000000..fe81a60
--- /dev/null
+++ b/CoreFoundation/LICENSE
@@ -0,0 +1,367 @@
+APPLE PUBLIC SOURCE LICENSE
+Version 2.0 - August 6, 2003
+
+Please read this License carefully before downloading this software.
+By downloading or using this software, you are agreeing to be bound by
+the terms of this License. If you do not or cannot agree to the terms
+of this License, please do not download or use the software.
+
+1. General; Definitions. This License applies to any program or other
+work which Apple Computer, Inc. ("Apple") makes publicly available and
+which contains a notice placed by Apple identifying such program or
+work as "Original Code" and stating that it is subject to the terms of
+this Apple Public Source License version 2.0 ("License"). As used in
+this License:
+
+1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is
+the grantor of rights, (i) claims of patents that are now or hereafter
+acquired, owned by or assigned to Apple and (ii) that cover subject
+matter contained in the Original Code, but only to the extent
+necessary to use, reproduce and/or distribute the Original Code
+without infringement; and (b) in the case where You are the grantor of
+rights, (i) claims of patents that are now or hereafter acquired,
+owned by or assigned to You and (ii) that cover subject matter in Your
+Modifications, taken alone or in combination with Original Code.
+
+1.2 "Contributor" means any person or entity that creates or
+contributes to the creation of Modifications.
+
+1.3 "Covered Code" means the Original Code, Modifications, the
+combination of Original Code and any Modifications, and/or any
+respective portions thereof.
+
+1.4 "Externally Deploy" means: (a) to sublicense, distribute or
+otherwise make Covered Code available, directly or indirectly, to
+anyone other than You; and/or (b) to use Covered Code, alone or as
+part of a Larger Work, in any way to provide a service, including but
+not limited to delivery of content, through electronic communication
+with a client other than You.
+
+1.5 "Larger Work" means a work which combines Covered Code or portions
+thereof with code not governed by the terms of this License.
+
+1.6 "Modifications" mean any addition to, deletion from, and/or change
+to, the substance and/or structure of the Original Code, any previous
+Modifications, the combination of Original Code and any previous
+Modifications, and/or any respective portions thereof. When code is
+released as a series of files, a Modification is: (a) any addition to
+or deletion from the contents of a file containing Covered Code;
+and/or (b) any new file or other representation of computer program
+statements that contains any part of Covered Code.
+
+1.7 "Original Code" means (a) the Source Code of a program or other
+work as originally made available by Apple under this License,
+including the Source Code of any updates or upgrades to such programs
+or works made available by Apple under this License, and that has been
+expressly identified by Apple as such in the header file(s) of such
+work; and (b) the object code compiled from such Source Code and
+originally made available by Apple under this License.
+
+1.8 "Source Code" means the human readable form of a program or other
+work that is suitable for making modifications to it, including all
+modules it contains, plus any associated interface definition files,
+scripts used to control compilation and installation of an executable
+(object code).
+
+1.9 "You" or "Your" means an individual or a legal entity exercising
+rights under this License. For legal entities, "You" or "Your"
+includes any entity which controls, is controlled by, or is under
+common control with, You, where "control" means (a) the power, direct
+or indirect, to cause the direction or management of such entity,
+whether by contract or otherwise, or (b) ownership of fifty percent
+(50%) or more of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Permitted Uses; Conditions & Restrictions. Subject to the terms
+and conditions of this License, Apple hereby grants You, effective on
+the date You accept this License and download the Original Code, a
+world-wide, royalty-free, non-exclusive license, to the extent of
+Apple's Applicable Patent Rights and copyrights covering the Original
+Code, to do the following:
+
+2.1 Unmodified Code. You may use, reproduce, display, perform,
+internally distribute within Your organization, and Externally Deploy
+verbatim, unmodified copies of the Original Code, for commercial or
+non-commercial purposes, provided that in each instance:
+
+(a) You must retain and reproduce in all copies of Original Code the
+copyright and other proprietary notices and disclaimers of Apple as
+they appear in the Original Code, and keep intact all notices in the
+Original Code that refer to this License; and
+
+(b) You must include a copy of this License with every copy of Source
+Code of Covered Code and documentation You distribute or Externally
+Deploy, and You may not offer or impose any terms on such Source Code
+that alter or restrict this License or the recipients' rights
+hereunder, except as permitted under Section 6.
+
+2.2 Modified Code. You may modify Covered Code and use, reproduce,
+display, perform, internally distribute within Your organization, and
+Externally Deploy Your Modifications and Covered Code, for commercial
+or non-commercial purposes, provided that in each instance You also
+meet all of these conditions:
+
+(a) You must satisfy all the conditions of Section 2.1 with respect to
+the Source Code of the Covered Code;
+
+(b) You must duplicate, to the extent it does not already exist, the
+notice in Exhibit A in each file of the Source Code of all Your
+Modifications, and cause the modified files to carry prominent notices
+stating that You changed the files and the date of any change; and
+
+(c) If You Externally Deploy Your Modifications, You must make
+Source Code of all Your Externally Deployed Modifications either
+available to those to whom You have Externally Deployed Your
+Modifications, or publicly available. Source Code of Your Externally
+Deployed Modifications must be released under the terms set forth in
+this License, including the license grants set forth in Section 3
+below, for as long as you Externally Deploy the Covered Code or twelve
+(12) months from the date of initial External Deployment, whichever is
+longer. You should preferably distribute the Source Code of Your
+Externally Deployed Modifications electronically (e.g. download from a
+web site).
+
+2.3 Distribution of Executable Versions. In addition, if You
+Externally Deploy Covered Code (Original Code and/or Modifications) in
+object code, executable form only, You must include a prominent
+notice, in the code itself as well as in related documentation,
+stating that Source Code of the Covered Code is available under the
+terms of this License with information on how and where to obtain such
+Source Code.
+
+2.4 Third Party Rights. You expressly acknowledge and agree that
+although Apple and each Contributor grants the licenses to their
+respective portions of the Covered Code set forth herein, no
+assurances are provided by Apple or any Contributor that the Covered
+Code does not infringe the patent or other intellectual property
+rights of any other entity. Apple and each Contributor disclaim any
+liability to You for claims brought by any other entity based on
+infringement of intellectual property rights or otherwise. As a
+condition to exercising the rights and licenses granted hereunder, You
+hereby assume sole responsibility to secure any other intellectual
+property rights needed, if any. For example, if a third party patent
+license is required to allow You to distribute the Covered Code, it is
+Your responsibility to acquire that license before distributing the
+Covered Code.
+
+3. Your Grants. In consideration of, and as a condition to, the
+licenses granted to You under this License, You hereby grant to any
+person or entity receiving or distributing Covered Code under this
+License a non-exclusive, royalty-free, perpetual, irrevocable license,
+under Your Applicable Patent Rights and other intellectual property
+rights (other than patent) owned or controlled by You, to use,
+reproduce, display, perform, modify, sublicense, distribute and
+Externally Deploy Your Modifications of the same scope and extent as
+Apple's licenses under Sections 2.1 and 2.2 above.
+
+4. Larger Works. You may create a Larger Work by combining Covered
+Code with other code not governed by the terms of this License and
+distribute the Larger Work as a single product. In each such instance,
+You must make sure the requirements of this License are fulfilled for
+the Covered Code or any portion thereof.
+
+5. Limitations on Patent License. Except as expressly stated in
+Section 2, no other patent rights, express or implied, are granted by
+Apple herein. Modifications and/or Larger Works may require additional
+patent licenses from Apple which Apple may grant in its sole
+discretion.
+
+6. Additional Terms. You may choose to offer, and to charge a fee for,
+warranty, support, indemnity or liability obligations and/or other
+rights consistent with the scope of the license granted herein
+("Additional Terms") to one or more recipients of Covered Code.
+However, You may do so only on Your own behalf and as Your sole
+responsibility, and not on behalf of Apple or any Contributor. You
+must obtain the recipient's agreement that any such Additional Terms
+are offered by You alone, and You hereby agree to indemnify, defend
+and hold Apple and every Contributor harmless for any liability
+incurred by or claims asserted against Apple or such Contributor by
+reason of any such Additional Terms.
+
+7. Versions of the License. Apple may publish revised and/or new
+versions of this License from time to time. Each version will be given
+a distinguishing version number. Once Original Code has been published
+under a particular version of this License, You may continue to use it
+under the terms of that version. You may also choose to use such
+Original Code under the terms of any subsequent version of this
+License published by Apple. No one other than Apple has the right to
+modify the terms applicable to Covered Code created under this
+License.
+
+8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in
+part pre-release, untested, or not fully tested works. The Covered
+Code may contain errors that could cause failures or loss of data, and
+may be incomplete or contain inaccuracies. You expressly acknowledge
+and agree that use of the Covered Code, or any portion thereof, is at
+Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND
+WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND
+APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE
+PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM
+ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT
+NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
+MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR
+PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD
+PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST
+INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE
+FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS,
+THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR
+ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO
+ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE
+AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY.
+You acknowledge that the Covered Code is not intended for use in the
+operation of nuclear facilities, aircraft navigation, communication
+systems, or air traffic control machines in which case the failure of
+the Covered Code could lead to death, personal injury, or severe
+physical or environmental damage.
+
+9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
+EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL,
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING
+TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
+ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY,
+TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF
+APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY
+REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY
+TO YOU. In no event shall Apple's total liability to You for all
+damages (other than as may be required by applicable law) under this
+License exceed the amount of fifty dollars ($50.00).
+
+10. Trademarks. This License does not grant any rights to use the
+trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS",
+"QuickTime", "QuickTime Streaming Server" or any other trademarks,
+service marks, logos or trade names belonging to Apple (collectively
+"Apple Marks") or to any trademark, service mark, logo or trade name
+belonging to any Contributor. You agree not to use any Apple Marks in
+or as part of the name of products derived from the Original Code or
+to endorse or promote products derived from the Original Code other
+than as expressly permitted by and in strict compliance at all times
+with Apple's third party trademark usage guidelines which are posted
+at http://www.apple.com/legal/guidelinesfor3rdparties.html.
+
+11. Ownership. Subject to the licenses granted under this License,
+each Contributor retains all rights, title and interest in and to any
+Modifications made by such Contributor. Apple retains all rights,
+title and interest in and to the Original Code and any Modifications
+made by or on behalf of Apple ("Apple Modifications"), and such Apple
+Modifications will not be automatically subject to this License. Apple
+may, at its sole discretion, choose to license such Apple
+Modifications under this License, or on different terms from those
+contained in this License or may choose not to license them at all.
+
+12. Termination.
+
+12.1 Termination. This License and the rights granted hereunder will
+terminate:
+
+(a) automatically without notice from Apple if You fail to comply with
+any term(s) of this License and fail to cure such breach within 30
+days of becoming aware of such breach;
+
+(b) immediately in the event of the circumstances described in Section
+13.5(b); or
+
+(c) automatically without notice from Apple if You, at any time during
+the term of this License, commence an action for patent infringement
+against Apple; provided that Apple did not first commence
+an action for patent infringement against You in that instance.
+
+12.2 Effect of Termination. Upon termination, You agree to immediately
+stop any further use, reproduction, modification, sublicensing and
+distribution of the Covered Code. All sublicenses to the Covered Code
+which have been properly granted prior to termination shall survive
+any termination of this License. Provisions which, by their nature,
+should remain in effect beyond the termination of this License shall
+survive, including but not limited to Sections 3, 5, 8, 9, 10, 11,
+12.2 and 13. No party will be liable to any other for compensation,
+indemnity or damages of any sort solely as a result of terminating
+this License in accordance with its terms, and termination of this
+License will be without prejudice to any other right or remedy of
+any party.
+
+13. Miscellaneous.
+
+13.1 Government End Users. The Covered Code is a "commercial item" as
+defined in FAR 2.101. Government software and technical data rights in
+the Covered Code include only those rights customarily provided to the
+public as defined in this License. This customary commercial license
+in technical data and software is provided in accordance with FAR
+12.211 (Technical Data) and 12.212 (Computer Software) and, for
+Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
+Commercial Items) and 227.7202-3 (Rights in Commercial Computer
+Software or Computer Software Documentation). Accordingly, all U.S.
+Government End Users acquire Covered Code with only those rights set
+forth herein.
+
+13.2 Relationship of Parties. This License will not be construed as
+creating an agency, partnership, joint venture or any other form of
+legal association between or among You, Apple or any Contributor, and
+You will not represent to the contrary, whether expressly, by
+implication, appearance or otherwise.
+
+13.3 Independent Development. Nothing in this License will impair
+Apple's right to acquire, license, develop, have others develop for
+it, market and/or distribute technology or products that perform the
+same or similar functions as, or otherwise compete with,
+Modifications, Larger Works, technology or products that You may
+develop, produce, market or distribute.
+
+13.4 Waiver; Construction. Failure by Apple or any Contributor to
+enforce any provision of this License will not be deemed a waiver of
+future enforcement of that or any other provision. Any law or
+regulation which provides that the language of a contract shall be
+construed against the drafter will not apply to this License.
+
+13.5 Severability. (a) If for any reason a court of competent
+jurisdiction finds any provision of this License, or portion thereof,
+to be unenforceable, that provision of the License will be enforced to
+the maximum extent permissible so as to effect the economic benefits
+and intent of the parties, and the remainder of this License will
+continue in full force and effect. (b) Notwithstanding the foregoing,
+if applicable law prohibits or restricts You from fully and/or
+specifically complying with Sections 2 and/or 3 or prevents the
+enforceability of either of those Sections, this License will
+immediately terminate and You must immediately discontinue any use of
+the Covered Code and destroy all copies of it that are in your
+possession or control.
+
+13.6 Dispute Resolution. Any litigation or other dispute resolution
+between You and Apple relating to this License shall take place in the
+Northern District of California, and You and Apple hereby consent to
+the personal jurisdiction of, and venue in, the state and federal
+courts within that District with respect to this License. The
+application of the United Nations Convention on Contracts for the
+International Sale of Goods is expressly excluded.
+
+13.7 Entire Agreement; Governing Law. This License constitutes the
+entire agreement between the parties with respect to the subject
+matter hereof. This License shall be governed by the laws of the
+United States and the State of California, except that body of
+California law concerning conflicts of law.
+
+Where You are located in the province of Quebec, Canada, the following
+clause applies: The parties hereby confirm that they have requested
+that this License and all related documents be drafted in English. Les
+parties ont exige que le present contrat et tous les documents
+connexes soient rediges en anglais.
+
+EXHIBIT A.
+
+"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
+Reserved.
+
+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."
diff --git a/CoreFoundation/MODULE_LICENSE_APPLE b/CoreFoundation/MODULE_LICENSE_APPLE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/CoreFoundation/MODULE_LICENSE_APPLE
diff --git a/CoreFoundation/Makefile b/CoreFoundation/Makefile
new file mode 100644
index 0000000..632a4d1
--- /dev/null
+++ b/CoreFoundation/Makefile
@@ -0,0 +1,2 @@
+install:
+	DSTBASE="$(DSTROOT)/System/Library/Frameworks" ./BuildCFLite
diff --git a/CoreFoundation/Makefile.am b/CoreFoundation/Makefile.am
new file mode 100644
index 0000000..4c10174
--- /dev/null
+++ b/CoreFoundation/Makefile.am
@@ -0,0 +1,376 @@
+# We need to ensure that the top-level (i.e. source) directory is
+# built before tests and examples, so we explicitly add '.' to the
+# list of subdirectories.l
+
+SUBDIRS				= include compat . tests examples
+
+#
+# We don't want to modify any of the package source to include the
+# configuration header, so we use the compiler to include it as a
+# prefix header. This is likely GCC specific, so we need to probably
+# abstract this further as other deployment targets are supported.
+#
+
+DEFS				+= -include ${CONFIG_HEADER}
+
+#
+# Data file for pkg-config
+#
+
+pkgconfigdir			= ${libdir}/pkgconfig
+pkgconfig_DATA			= CoreFoundation.pc
+
+#
+# Define where we will install and where CoreFoundation can find its
+# Unicode character mappings.
+#
+
+libCoreFoundation_la_datadir	= ${datadir}/CoreFoundation/CharacterSets
+
+libCoreFoundation_la_data_DATA	= CFCharacterSetBitmaps.bitmap		\
+				  CFUniCharPropertyDatabase.data	\
+				  CFUnicodeData-B.mapping		\
+				  CFUnicodeData-L.mapping
+
+CF_COMMON_CPPFLAGS		= $(AM_CPPFLAGS)			\
+				  -DU_SHOW_DRAFT_API=1			\
+				  -DCF_BUILDING_CF=1			\
+				  -D__kCFDataDir=\"${datadir}\" \
+				  -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5	\
+				  -I$(top_srcdir)/include		\
+				  -I$(top_srcdir)/include/mach_support
+
+CF_COMMON_CFLAGS		= $(AM_CFLAGS)
+
+CF_COMMON_LDFLAGS		= $(AM_LDFLAGS)				\
+				  -version-info $(CF_VERSION_INFO)
+
+CF_COMMON_LIBADD		= $(AM_LDADD) compat/libcompat.la 
+
+noinst_HEADERS			= auto_stubs.h				\
+				  CFBundle_BinaryTypes.h		\
+				  CFBundle_Internal.h			\
+				  CFInternal.h				\
+				  CFRunLoopPriv.h			\
+				  CFUniCharPriv.h			\
+				  CFWindowsMessageQueue.h		\
+				  CFXMLInputStream.h
+
+CF_includedir			= ${includedir}/CoreFoundation
+
+CF_include_HEADERS		= CFArray.h				\
+				  CFBag.h				\
+				  CFBase.h				\
+				  CFBinaryHeap.h			\
+				  CFBitVector.h				\
+				  CFBundle.h				\
+				  CFBundlePriv.h			\
+				  CFByteOrder.h				\
+				  CFCalendar.h				\
+				  CFCharacterSet.h			\
+				  CFCharacterSetPriv.h			\
+				  CFData.h				\
+				  CFDateFormatter.h			\
+				  CFDate.h				\
+				  CFDictionary.h			\
+				  CFError.h				\
+				  CFError_Private.h			\
+				  CFLocale.h				\
+				  CFLogUtilities.h			\
+				  CFMachPort.h				\
+				  CFMessagePort.h			\
+				  CFNumberFormatter.h			\
+				  CFNumber.h				\
+				  CFPlugInCOM.h				\
+				  CFPlugIn_Factory.h			\
+				  CFPlugIn.h				\
+				  CFPreferences.h			\
+				  CFPriv.h				\
+				  CFPropertyList.h			\
+				  CFRunLoop.h				\
+				  CFRuntime.h				\
+				  CFSet.h				\
+				  CFSocket.h				\
+				  CFStorage.h				\
+				  CFStreamAbstract.h			\
+				  CFStream.h				\
+				  CFStreamInternal.h			\
+				  CFStreamPriv.h			\
+				  CFStringDefaultEncoding.h		\
+				  CFStringEncodingConverterExt.h	\
+				  CFStringEncodingConverter.h		\
+				  CFStringEncodingConverterPriv.h	\
+				  CFStringEncodingExt.h			\
+				  CFString.h				\
+				  CFTimeZone.h				\
+				  CFTree.h				\
+				  CFUniChar.h				\
+				  CFUnicodeDecomposition.h		\
+				  CFUnicodePrecomposition.h		\
+				  CFURLAccess.h				\
+				  CFURL.h				\
+				  CFUserNotification.h			\
+				  CFUUID.h				\
+				  CFXMLNode.h				\
+				  CFXMLParser.h				\
+				  CoreFoundation.h			\
+				  ForFoundationOnly.h
+
+CF_COMMON_SOURCES		= CFApplicationPreferences.c		\
+				  CFArray.c				\
+				  CFBag.c				\
+				  CFBase.c				\
+				  CFBinaryHeap.c			\
+				  CFBinaryPList.c			\
+				  CFBitVector.c				\
+				  CFBuiltinConverters.c			\
+				  CFBundle.c				\
+				  CFBundle_Resources.c			\
+				  CFCalendar.c				\
+				  CFCharacterSet.c			\
+				  CFConcreteStreams.c			\
+				  CFData.c				\
+				  CFDateFormatter.c			\
+				  CFDate.c				\
+				  CFDictionary.c			\
+				  CFError.c				\
+				  CFFileUtilities.c			\
+				  CFLocaleIdentifier.c			\
+				  CFLocale.c				\
+				  CFMachPort.c				\
+				  CFMessagePort.c			\
+				  CFNumberFormatter.c			\
+				  CFNumber.c				\
+				  CFPlatform.c				\
+				  CFPlugIn_Factory.c			\
+				  CFPlugIn_Instance.c			\
+				  CFPlugIn.c				\
+				  CFPlugIn_PlugIn.c			\
+				  CFPreferences.c			\
+				  CFPropertyList.c			\
+				  CFRunLoop.c				\
+				  CFRuntime.c				\
+				  CFSet.c				\
+				  CFSocket.c				\
+				  CFSocketStream.c			\
+				  CFSortFunctions.c			\
+				  CFStorage.c				\
+				  CFStream.c				\
+				  CFStringEncodingConverter.c		\
+				  CFStringEncodings.c			\
+				  CFString.c				\
+				  CFStringScanner.c			\
+				  CFStringUtilities.c			\
+				  CFSystemDirectories.c			\
+				  CFTimeZone.c				\
+				  CFTree.c				\
+				  CFURL.c				\
+				  CFURLAccess.c				\
+				  CFUUID.c				\
+				  CFUniChar.c				\
+				  CFUnicodeDecomposition.c		\
+				  CFUnicodePrecomposition.c		\
+				  CFUserNotification.c			\
+				  CFUtilities.c				\
+				  CFVersion.c				\
+				  CFWindowsMessageQueue.c		\
+				  CFXMLInputStream.c			\
+				  CFXMLNode.c				\
+				  CFXMLParser.c				\
+				  CFXMLPreferencesDomain.c		\
+				  CFXMLTree.c
+
+#				  Cocotron.c
+
+lib_LTLIBRARIES 			= libCoreFoundation.la
+
+libCoreFoundation_la_CPPFLAGS		= $(CF_COMMON_CPPFLAGS)
+libCoreFoundation_la_CFLAGS		= $(CF_COMMON_CFLAGS)
+libCoreFoundation_la_LDFLAGS		= $(CF_COMMON_LDFLAGS)
+libCoreFoundation_la_LIBADD		= $(CF_COMMON_LIBADD)
+libCoreFoundation_la_SOURCES		= $(CF_COMMON_SOURCES)
+
+#
+# Only generate a debug instance of the library if --enable-debug was
+# passed at configuration time.
+#
+
+if CF_BUILD_DEBUG
+lib_LTLIBRARIES				+= libCoreFoundation_debug.la
+
+libCoreFoundation_debug_la_CPPFLAGS	= $(CF_COMMON_CPPFLAGS) -DDEBUG
+libCoreFoundation_debug_la_CFLAGS	= $(CF_COMMON_CFLAGS)
+libCoreFoundation_debug_la_LDFLAGS	= $(CF_COMMON_LDFLAGS)
+libCoreFoundation_debug_la_LIBADD	= $(CF_COMMON_LIBADD)
+libCoreFoundation_debug_la_SOURCES	= $(CF_COMMON_SOURCES)
+endif
+
+#
+# Only generate a profile instance of the library if --enable-debug was
+# passed at configuration time.
+#
+
+if CF_BUILD_PROFILE
+lib_LTLIBRARIES				+= libCoreFoundation_profile.la
+
+libCoreFoundation_profile_la_CPPFLAGS	= $(CF_COMMON_CPPFLAGS) -DPROFILE
+libCoreFoundation_profile_la_CFLAGS	= $(CF_COMMON_CFLAGS) -pg
+libCoreFoundation_profile_la_LDFLAGS	= $(CF_COMMON_LDFLAGS)
+libCoreFoundation_profile_la_LIBADD	= $(CF_COMMON_LIBADD)
+libCoreFoundation_profile_la_SOURCES	= $(CF_COMMON_SOURCES)
+endif
+
+EXTRA_DIST			= APPLE_LICENSE	\
+				  CHANGES \
+				  CONTRIBUTORS \
+				  INSTALL \
+				  LICENSE \
+				  README \
+				  TODO \
+				  BuildCFLite \
+				  BuildCFLite.windows \
+				  macosx/CFLite.xcodeproj/project.pbxproj \
+				  windows/CFLiteLib.vcproj \
+				  CFLite.sln \
+				  Cocotron/Cocotron.c \
+				  Cocotron/CoreFoundation.xcodeproj/project.pbxproj \
+				  icu/bin/icudt40.dll \
+				  icu/bin/icuin40.dll \
+				  icu/bin/icuuc40.dll \
+				  icu/bin/WHAT_IS_THIS.txt \
+				  icu/lib/icuin.lib \
+				  icu/lib/icuuc.lib \
+				  icu/lib/WHAT_IS_THIS.txt \
+				  icu/unicode/basictz.h \
+				  icu/unicode/brkiter.h \
+				  icu/unicode/calendar.h \
+				  icu/unicode/caniter.h \
+				  icu/unicode/chariter.h \
+				  icu/unicode/choicfmt.h \
+				  icu/unicode/coleitr.h \
+				  icu/unicode/coll.h \
+				  icu/unicode/curramt.h \
+				  icu/unicode/currunit.h \
+				  icu/unicode/datefmt.h \
+				  icu/unicode/dbbi.h \
+				  icu/unicode/dcfmtsym.h \
+				  icu/unicode/decimfmt.h \
+				  icu/unicode/docmain.h \
+				  icu/unicode/dtfmtsym.h \
+				  icu/unicode/dtintrv.h \
+				  icu/unicode/dtitvfmt.h \
+				  icu/unicode/dtitvinf.h \
+				  icu/unicode/dtptngen.h \
+				  icu/unicode/dtrule.h \
+				  icu/unicode/fieldpos.h \
+				  icu/unicode/fmtable.h \
+				  icu/unicode/format.h \
+				  icu/unicode/gregocal.h \
+				  icu/unicode/locid.h \
+				  icu/unicode/measfmt.h \
+				  icu/unicode/measunit.h \
+				  icu/unicode/measure.h \
+				  icu/unicode/msgfmt.h \
+				  icu/unicode/normlzr.h \
+				  icu/unicode/numfmt.h \
+				  icu/unicode/parseerr.h \
+				  icu/unicode/parsepos.h \
+				  icu/unicode/platform.h \
+				  icu/unicode/plurfmt.h \
+				  icu/unicode/plurrule.h \
+				  icu/unicode/ppalmos.h \
+				  icu/unicode/putil.h \
+				  icu/unicode/pwin32.h \
+				  icu/unicode/rbbi.h \
+				  icu/unicode/rbnf.h \
+				  icu/unicode/rbtz.h \
+				  icu/unicode/regex.h \
+				  icu/unicode/rep.h \
+				  icu/unicode/resbund.h \
+				  icu/unicode/schriter.h \
+				  icu/unicode/search.h \
+				  icu/unicode/simpletz.h \
+				  icu/unicode/smpdtfmt.h \
+				  icu/unicode/sortkey.h \
+				  icu/unicode/strenum.h \
+				  icu/unicode/stsearch.h \
+				  icu/unicode/symtable.h \
+				  icu/unicode/tblcoll.h \
+				  icu/unicode/timezone.h \
+				  icu/unicode/translit.h \
+				  icu/unicode/tzrule.h \
+				  icu/unicode/tztrans.h \
+				  icu/unicode/ubidi.h \
+				  icu/unicode/ubrk.h \
+				  icu/unicode/ucal.h \
+				  icu/unicode/ucasemap.h \
+				  icu/unicode/ucat.h \
+				  icu/unicode/uchar.h \
+				  icu/unicode/uchriter.h \
+				  icu/unicode/uclean.h \
+				  icu/unicode/ucnv_cb.h \
+				  icu/unicode/ucnv_err.h \
+				  icu/unicode/ucnv.h \
+				  icu/unicode/ucoleitr.h \
+				  icu/unicode/ucol.h \
+				  icu/unicode/uconfig.h \
+				  icu/unicode/ucsdet.h \
+				  icu/unicode/ucurr.h \
+				  icu/unicode/udata.h \
+				  icu/unicode/udat.h \
+				  icu/unicode/udatpg.h \
+				  icu/unicode/udeprctd.h \
+				  icu/unicode/udraft.h \
+				  icu/unicode/uenum.h \
+				  icu/unicode/uidna.h \
+				  icu/unicode/uintrnal.h \
+				  icu/unicode/uiter.h \
+				  icu/unicode/ulocdata.h \
+				  icu/unicode/uloc.h \
+				  icu/unicode/umachine.h \
+				  icu/unicode/umisc.h \
+				  icu/unicode/umsg.h \
+				  icu/unicode/unifilt.h \
+				  icu/unicode/unifunct.h \
+				  icu/unicode/unimatch.h \
+				  icu/unicode/unirepl.h \
+				  icu/unicode/uniset.h \
+				  icu/unicode/unistr.h \
+				  icu/unicode/unorm.h \
+				  icu/unicode/unum.h \
+				  icu/unicode/uobject.h \
+				  icu/unicode/uobslete.h \
+				  icu/unicode/urbtok.h \
+				  icu/unicode/uregex.h \
+				  icu/unicode/urename.h \
+				  icu/unicode/urep.h \
+				  icu/unicode/ures.h \
+				  icu/unicode/uscript.h \
+				  icu/unicode/usearch.h \
+				  icu/unicode/uset.h \
+				  icu/unicode/usetiter.h \
+				  icu/unicode/ushape.h \
+				  icu/unicode/usprep.h \
+				  icu/unicode/ustdio.h \
+				  icu/unicode/ustream.h \
+				  icu/unicode/ustring.h \
+				  icu/unicode/usystem.h \
+				  icu/unicode/utext.h \
+				  icu/unicode/utf16.h \
+				  icu/unicode/utf32.h \
+				  icu/unicode/utf8.h \
+				  icu/unicode/utf.h \
+				  icu/unicode/utf_old.h \
+				  icu/unicode/utmscale.h \
+				  icu/unicode/utrace.h \
+				  icu/unicode/utrans.h \
+				  icu/unicode/utypes.h \
+				  icu/unicode/uversion.h \
+				  icu/unicode/vtzone.h \
+				  Info.plist \
+				  Makefile \
+				  XCode_Configs/ConfigDebug.xcconfig \
+				  XCode_Configs/Config_Master.xcconfig \
+				  XCode_Configs/ConfigRelease.xcconfig \
+				  ${libCoreFoundation_la_data_DATA}
+
diff --git a/CoreFoundation/Makefile.in b/CoreFoundation/Makefile.in
new file mode 100644
index 0000000..8fc1c46
--- /dev/null
+++ b/CoreFoundation/Makefile.in
@@ -0,0 +1,2935 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# We need to ensure that the top-level (i.e. source) directory is
+# built before tests and examples, so we explicitly add '.' to the
+# list of subdirectories.l
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+
+#
+# Only generate a debug instance of the library if --enable-debug was
+# passed at configuration time.
+#
+@CF_BUILD_DEBUG_TRUE@am__append_1 = libCoreFoundation_debug.la
+
+#
+# Only generate a profile instance of the library if --enable-debug was
+# passed at configuration time.
+#
+@CF_BUILD_PROFILE_TRUE@am__append_2 = libCoreFoundation_profile.la
+subdir = .
+DIST_COMMON = README $(CF_include_HEADERS) $(am__configure_deps) \
+	$(noinst_HEADERS) $(srcdir)/CoreFoundation.pc.in \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(top_srcdir)/configure INSTALL TODO config/compile \
+	config/config.guess config/config.sub config/depcomp \
+	config/install-sh config/ltmain.sh config/missing \
+	config/mkinstalldirs
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES = CoreFoundation.pc
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" \
+	"$(DESTDIR)$(libCoreFoundation_la_datadir)" \
+	"$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(CF_includedir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+am__DEPENDENCIES_1 = compat/libcompat.la
+libCoreFoundation_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am__objects_1 = libCoreFoundation_la-CFApplicationPreferences.lo \
+	libCoreFoundation_la-CFArray.lo libCoreFoundation_la-CFBag.lo \
+	libCoreFoundation_la-CFBase.lo \
+	libCoreFoundation_la-CFBinaryHeap.lo \
+	libCoreFoundation_la-CFBinaryPList.lo \
+	libCoreFoundation_la-CFBitVector.lo \
+	libCoreFoundation_la-CFBuiltinConverters.lo \
+	libCoreFoundation_la-CFBundle.lo \
+	libCoreFoundation_la-CFBundle_Resources.lo \
+	libCoreFoundation_la-CFCalendar.lo \
+	libCoreFoundation_la-CFCharacterSet.lo \
+	libCoreFoundation_la-CFConcreteStreams.lo \
+	libCoreFoundation_la-CFData.lo \
+	libCoreFoundation_la-CFDateFormatter.lo \
+	libCoreFoundation_la-CFDate.lo \
+	libCoreFoundation_la-CFDictionary.lo \
+	libCoreFoundation_la-CFError.lo \
+	libCoreFoundation_la-CFFileUtilities.lo \
+	libCoreFoundation_la-CFLocaleIdentifier.lo \
+	libCoreFoundation_la-CFLocale.lo \
+	libCoreFoundation_la-CFMachPort.lo \
+	libCoreFoundation_la-CFMessagePort.lo \
+	libCoreFoundation_la-CFNumberFormatter.lo \
+	libCoreFoundation_la-CFNumber.lo \
+	libCoreFoundation_la-CFPlatform.lo \
+	libCoreFoundation_la-CFPlugIn_Factory.lo \
+	libCoreFoundation_la-CFPlugIn_Instance.lo \
+	libCoreFoundation_la-CFPlugIn.lo \
+	libCoreFoundation_la-CFPlugIn_PlugIn.lo \
+	libCoreFoundation_la-CFPreferences.lo \
+	libCoreFoundation_la-CFPropertyList.lo \
+	libCoreFoundation_la-CFRunLoop.lo \
+	libCoreFoundation_la-CFRuntime.lo \
+	libCoreFoundation_la-CFSet.lo libCoreFoundation_la-CFSocket.lo \
+	libCoreFoundation_la-CFSocketStream.lo \
+	libCoreFoundation_la-CFSortFunctions.lo \
+	libCoreFoundation_la-CFStorage.lo \
+	libCoreFoundation_la-CFStream.lo \
+	libCoreFoundation_la-CFStringEncodingConverter.lo \
+	libCoreFoundation_la-CFStringEncodings.lo \
+	libCoreFoundation_la-CFString.lo \
+	libCoreFoundation_la-CFStringScanner.lo \
+	libCoreFoundation_la-CFStringUtilities.lo \
+	libCoreFoundation_la-CFSystemDirectories.lo \
+	libCoreFoundation_la-CFTimeZone.lo \
+	libCoreFoundation_la-CFTree.lo libCoreFoundation_la-CFURL.lo \
+	libCoreFoundation_la-CFURLAccess.lo \
+	libCoreFoundation_la-CFUUID.lo \
+	libCoreFoundation_la-CFUniChar.lo \
+	libCoreFoundation_la-CFUnicodeDecomposition.lo \
+	libCoreFoundation_la-CFUnicodePrecomposition.lo \
+	libCoreFoundation_la-CFUserNotification.lo \
+	libCoreFoundation_la-CFUtilities.lo \
+	libCoreFoundation_la-CFVersion.lo \
+	libCoreFoundation_la-CFWindowsMessageQueue.lo \
+	libCoreFoundation_la-CFXMLInputStream.lo \
+	libCoreFoundation_la-CFXMLNode.lo \
+	libCoreFoundation_la-CFXMLParser.lo \
+	libCoreFoundation_la-CFXMLPreferencesDomain.lo \
+	libCoreFoundation_la-CFXMLTree.lo
+am_libCoreFoundation_la_OBJECTS = $(am__objects_1)
+libCoreFoundation_la_OBJECTS = $(am_libCoreFoundation_la_OBJECTS)
+libCoreFoundation_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(libCoreFoundation_la_CFLAGS) $(CFLAGS) \
+	$(libCoreFoundation_la_LDFLAGS) $(LDFLAGS) -o $@
+@CF_BUILD_DEBUG_TRUE@libCoreFoundation_debug_la_DEPENDENCIES =  \
+@CF_BUILD_DEBUG_TRUE@	$(am__DEPENDENCIES_1)
+am__libCoreFoundation_debug_la_SOURCES_DIST =  \
+	CFApplicationPreferences.c CFArray.c CFBag.c CFBase.c \
+	CFBinaryHeap.c CFBinaryPList.c CFBitVector.c \
+	CFBuiltinConverters.c CFBundle.c CFBundle_Resources.c \
+	CFCalendar.c CFCharacterSet.c CFConcreteStreams.c CFData.c \
+	CFDateFormatter.c CFDate.c CFDictionary.c CFError.c \
+	CFFileUtilities.c CFLocaleIdentifier.c CFLocale.c CFMachPort.c \
+	CFMessagePort.c CFNumberFormatter.c CFNumber.c CFPlatform.c \
+	CFPlugIn_Factory.c CFPlugIn_Instance.c CFPlugIn.c \
+	CFPlugIn_PlugIn.c CFPreferences.c CFPropertyList.c CFRunLoop.c \
+	CFRuntime.c CFSet.c CFSocket.c CFSocketStream.c \
+	CFSortFunctions.c CFStorage.c CFStream.c \
+	CFStringEncodingConverter.c CFStringEncodings.c CFString.c \
+	CFStringScanner.c CFStringUtilities.c CFSystemDirectories.c \
+	CFTimeZone.c CFTree.c CFURL.c CFURLAccess.c CFUUID.c \
+	CFUniChar.c CFUnicodeDecomposition.c CFUnicodePrecomposition.c \
+	CFUserNotification.c CFUtilities.c CFVersion.c \
+	CFWindowsMessageQueue.c CFXMLInputStream.c CFXMLNode.c \
+	CFXMLParser.c CFXMLPreferencesDomain.c CFXMLTree.c
+am__objects_2 =  \
+	libCoreFoundation_debug_la-CFApplicationPreferences.lo \
+	libCoreFoundation_debug_la-CFArray.lo \
+	libCoreFoundation_debug_la-CFBag.lo \
+	libCoreFoundation_debug_la-CFBase.lo \
+	libCoreFoundation_debug_la-CFBinaryHeap.lo \
+	libCoreFoundation_debug_la-CFBinaryPList.lo \
+	libCoreFoundation_debug_la-CFBitVector.lo \
+	libCoreFoundation_debug_la-CFBuiltinConverters.lo \
+	libCoreFoundation_debug_la-CFBundle.lo \
+	libCoreFoundation_debug_la-CFBundle_Resources.lo \
+	libCoreFoundation_debug_la-CFCalendar.lo \
+	libCoreFoundation_debug_la-CFCharacterSet.lo \
+	libCoreFoundation_debug_la-CFConcreteStreams.lo \
+	libCoreFoundation_debug_la-CFData.lo \
+	libCoreFoundation_debug_la-CFDateFormatter.lo \
+	libCoreFoundation_debug_la-CFDate.lo \
+	libCoreFoundation_debug_la-CFDictionary.lo \
+	libCoreFoundation_debug_la-CFError.lo \
+	libCoreFoundation_debug_la-CFFileUtilities.lo \
+	libCoreFoundation_debug_la-CFLocaleIdentifier.lo \
+	libCoreFoundation_debug_la-CFLocale.lo \
+	libCoreFoundation_debug_la-CFMachPort.lo \
+	libCoreFoundation_debug_la-CFMessagePort.lo \
+	libCoreFoundation_debug_la-CFNumberFormatter.lo \
+	libCoreFoundation_debug_la-CFNumber.lo \
+	libCoreFoundation_debug_la-CFPlatform.lo \
+	libCoreFoundation_debug_la-CFPlugIn_Factory.lo \
+	libCoreFoundation_debug_la-CFPlugIn_Instance.lo \
+	libCoreFoundation_debug_la-CFPlugIn.lo \
+	libCoreFoundation_debug_la-CFPlugIn_PlugIn.lo \
+	libCoreFoundation_debug_la-CFPreferences.lo \
+	libCoreFoundation_debug_la-CFPropertyList.lo \
+	libCoreFoundation_debug_la-CFRunLoop.lo \
+	libCoreFoundation_debug_la-CFRuntime.lo \
+	libCoreFoundation_debug_la-CFSet.lo \
+	libCoreFoundation_debug_la-CFSocket.lo \
+	libCoreFoundation_debug_la-CFSocketStream.lo \
+	libCoreFoundation_debug_la-CFSortFunctions.lo \
+	libCoreFoundation_debug_la-CFStorage.lo \
+	libCoreFoundation_debug_la-CFStream.lo \
+	libCoreFoundation_debug_la-CFStringEncodingConverter.lo \
+	libCoreFoundation_debug_la-CFStringEncodings.lo \
+	libCoreFoundation_debug_la-CFString.lo \
+	libCoreFoundation_debug_la-CFStringScanner.lo \
+	libCoreFoundation_debug_la-CFStringUtilities.lo \
+	libCoreFoundation_debug_la-CFSystemDirectories.lo \
+	libCoreFoundation_debug_la-CFTimeZone.lo \
+	libCoreFoundation_debug_la-CFTree.lo \
+	libCoreFoundation_debug_la-CFURL.lo \
+	libCoreFoundation_debug_la-CFURLAccess.lo \
+	libCoreFoundation_debug_la-CFUUID.lo \
+	libCoreFoundation_debug_la-CFUniChar.lo \
+	libCoreFoundation_debug_la-CFUnicodeDecomposition.lo \
+	libCoreFoundation_debug_la-CFUnicodePrecomposition.lo \
+	libCoreFoundation_debug_la-CFUserNotification.lo \
+	libCoreFoundation_debug_la-CFUtilities.lo \
+	libCoreFoundation_debug_la-CFVersion.lo \
+	libCoreFoundation_debug_la-CFWindowsMessageQueue.lo \
+	libCoreFoundation_debug_la-CFXMLInputStream.lo \
+	libCoreFoundation_debug_la-CFXMLNode.lo \
+	libCoreFoundation_debug_la-CFXMLParser.lo \
+	libCoreFoundation_debug_la-CFXMLPreferencesDomain.lo \
+	libCoreFoundation_debug_la-CFXMLTree.lo
+@CF_BUILD_DEBUG_TRUE@am_libCoreFoundation_debug_la_OBJECTS =  \
+@CF_BUILD_DEBUG_TRUE@	$(am__objects_2)
+libCoreFoundation_debug_la_OBJECTS =  \
+	$(am_libCoreFoundation_debug_la_OBJECTS)
+libCoreFoundation_debug_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) \
+	$(libCoreFoundation_debug_la_LDFLAGS) $(LDFLAGS) -o $@
+@CF_BUILD_DEBUG_TRUE@am_libCoreFoundation_debug_la_rpath = -rpath \
+@CF_BUILD_DEBUG_TRUE@	$(libdir)
+@CF_BUILD_PROFILE_TRUE@libCoreFoundation_profile_la_DEPENDENCIES =  \
+@CF_BUILD_PROFILE_TRUE@	$(am__DEPENDENCIES_1)
+am__libCoreFoundation_profile_la_SOURCES_DIST =  \
+	CFApplicationPreferences.c CFArray.c CFBag.c CFBase.c \
+	CFBinaryHeap.c CFBinaryPList.c CFBitVector.c \
+	CFBuiltinConverters.c CFBundle.c CFBundle_Resources.c \
+	CFCalendar.c CFCharacterSet.c CFConcreteStreams.c CFData.c \
+	CFDateFormatter.c CFDate.c CFDictionary.c CFError.c \
+	CFFileUtilities.c CFLocaleIdentifier.c CFLocale.c CFMachPort.c \
+	CFMessagePort.c CFNumberFormatter.c CFNumber.c CFPlatform.c \
+	CFPlugIn_Factory.c CFPlugIn_Instance.c CFPlugIn.c \
+	CFPlugIn_PlugIn.c CFPreferences.c CFPropertyList.c CFRunLoop.c \
+	CFRuntime.c CFSet.c CFSocket.c CFSocketStream.c \
+	CFSortFunctions.c CFStorage.c CFStream.c \
+	CFStringEncodingConverter.c CFStringEncodings.c CFString.c \
+	CFStringScanner.c CFStringUtilities.c CFSystemDirectories.c \
+	CFTimeZone.c CFTree.c CFURL.c CFURLAccess.c CFUUID.c \
+	CFUniChar.c CFUnicodeDecomposition.c CFUnicodePrecomposition.c \
+	CFUserNotification.c CFUtilities.c CFVersion.c \
+	CFWindowsMessageQueue.c CFXMLInputStream.c CFXMLNode.c \
+	CFXMLParser.c CFXMLPreferencesDomain.c CFXMLTree.c
+am__objects_3 =  \
+	libCoreFoundation_profile_la-CFApplicationPreferences.lo \
+	libCoreFoundation_profile_la-CFArray.lo \
+	libCoreFoundation_profile_la-CFBag.lo \
+	libCoreFoundation_profile_la-CFBase.lo \
+	libCoreFoundation_profile_la-CFBinaryHeap.lo \
+	libCoreFoundation_profile_la-CFBinaryPList.lo \
+	libCoreFoundation_profile_la-CFBitVector.lo \
+	libCoreFoundation_profile_la-CFBuiltinConverters.lo \
+	libCoreFoundation_profile_la-CFBundle.lo \
+	libCoreFoundation_profile_la-CFBundle_Resources.lo \
+	libCoreFoundation_profile_la-CFCalendar.lo \
+	libCoreFoundation_profile_la-CFCharacterSet.lo \
+	libCoreFoundation_profile_la-CFConcreteStreams.lo \
+	libCoreFoundation_profile_la-CFData.lo \
+	libCoreFoundation_profile_la-CFDateFormatter.lo \
+	libCoreFoundation_profile_la-CFDate.lo \
+	libCoreFoundation_profile_la-CFDictionary.lo \
+	libCoreFoundation_profile_la-CFError.lo \
+	libCoreFoundation_profile_la-CFFileUtilities.lo \
+	libCoreFoundation_profile_la-CFLocaleIdentifier.lo \
+	libCoreFoundation_profile_la-CFLocale.lo \
+	libCoreFoundation_profile_la-CFMachPort.lo \
+	libCoreFoundation_profile_la-CFMessagePort.lo \
+	libCoreFoundation_profile_la-CFNumberFormatter.lo \
+	libCoreFoundation_profile_la-CFNumber.lo \
+	libCoreFoundation_profile_la-CFPlatform.lo \
+	libCoreFoundation_profile_la-CFPlugIn_Factory.lo \
+	libCoreFoundation_profile_la-CFPlugIn_Instance.lo \
+	libCoreFoundation_profile_la-CFPlugIn.lo \
+	libCoreFoundation_profile_la-CFPlugIn_PlugIn.lo \
+	libCoreFoundation_profile_la-CFPreferences.lo \
+	libCoreFoundation_profile_la-CFPropertyList.lo \
+	libCoreFoundation_profile_la-CFRunLoop.lo \
+	libCoreFoundation_profile_la-CFRuntime.lo \
+	libCoreFoundation_profile_la-CFSet.lo \
+	libCoreFoundation_profile_la-CFSocket.lo \
+	libCoreFoundation_profile_la-CFSocketStream.lo \
+	libCoreFoundation_profile_la-CFSortFunctions.lo \
+	libCoreFoundation_profile_la-CFStorage.lo \
+	libCoreFoundation_profile_la-CFStream.lo \
+	libCoreFoundation_profile_la-CFStringEncodingConverter.lo \
+	libCoreFoundation_profile_la-CFStringEncodings.lo \
+	libCoreFoundation_profile_la-CFString.lo \
+	libCoreFoundation_profile_la-CFStringScanner.lo \
+	libCoreFoundation_profile_la-CFStringUtilities.lo \
+	libCoreFoundation_profile_la-CFSystemDirectories.lo \
+	libCoreFoundation_profile_la-CFTimeZone.lo \
+	libCoreFoundation_profile_la-CFTree.lo \
+	libCoreFoundation_profile_la-CFURL.lo \
+	libCoreFoundation_profile_la-CFURLAccess.lo \
+	libCoreFoundation_profile_la-CFUUID.lo \
+	libCoreFoundation_profile_la-CFUniChar.lo \
+	libCoreFoundation_profile_la-CFUnicodeDecomposition.lo \
+	libCoreFoundation_profile_la-CFUnicodePrecomposition.lo \
+	libCoreFoundation_profile_la-CFUserNotification.lo \
+	libCoreFoundation_profile_la-CFUtilities.lo \
+	libCoreFoundation_profile_la-CFVersion.lo \
+	libCoreFoundation_profile_la-CFWindowsMessageQueue.lo \
+	libCoreFoundation_profile_la-CFXMLInputStream.lo \
+	libCoreFoundation_profile_la-CFXMLNode.lo \
+	libCoreFoundation_profile_la-CFXMLParser.lo \
+	libCoreFoundation_profile_la-CFXMLPreferencesDomain.lo \
+	libCoreFoundation_profile_la-CFXMLTree.lo
+@CF_BUILD_PROFILE_TRUE@am_libCoreFoundation_profile_la_OBJECTS =  \
+@CF_BUILD_PROFILE_TRUE@	$(am__objects_3)
+libCoreFoundation_profile_la_OBJECTS =  \
+	$(am_libCoreFoundation_profile_la_OBJECTS)
+libCoreFoundation_profile_la_LINK = $(LIBTOOL) --tag=CC \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+	$(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) \
+	$(libCoreFoundation_profile_la_LDFLAGS) $(LDFLAGS) -o $@
+@CF_BUILD_PROFILE_TRUE@am_libCoreFoundation_profile_la_rpath = -rpath \
+@CF_BUILD_PROFILE_TRUE@	$(libdir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(libCoreFoundation_la_SOURCES) \
+	$(libCoreFoundation_debug_la_SOURCES) \
+	$(libCoreFoundation_profile_la_SOURCES)
+DIST_SOURCES = $(libCoreFoundation_la_SOURCES) \
+	$(am__libCoreFoundation_debug_la_SOURCES_DIST) \
+	$(am__libCoreFoundation_profile_la_SOURCES_DIST)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+libCoreFoundation_la_dataDATA_INSTALL = $(INSTALL_DATA)
+pkgconfigDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(libCoreFoundation_la_data_DATA) $(pkgconfig_DATA)
+CF_includeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(CF_include_HEADERS) $(noinst_HEADERS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d $(distdir) \
+    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr $(distdir); }; }
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+
+#
+# We don't want to modify any of the package source to include the
+# configuration header, so we use the compiler to include it as a
+# prefix header. This is likely GCC specific, so we need to probably
+# abstract this further as other deployment targets are supported.
+#
+DEFS = @DEFS@ -include ${CONFIG_HEADER}
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = include compat . tests examples
+
+#
+# Data file for pkg-config
+#
+pkgconfigdir = ${libdir}/pkgconfig
+pkgconfig_DATA = CoreFoundation.pc
+
+#
+# Define where we will install and where CoreFoundation can find its
+# Unicode character mappings.
+#
+libCoreFoundation_la_datadir = ${datadir}/CoreFoundation/CharacterSets
+libCoreFoundation_la_data_DATA = CFCharacterSetBitmaps.bitmap		\
+				  CFUniCharPropertyDatabase.data	\
+				  CFUnicodeData-B.mapping		\
+				  CFUnicodeData-L.mapping
+
+CF_COMMON_CPPFLAGS = $(AM_CPPFLAGS)			\
+				  -DU_SHOW_DRAFT_API=1			\
+				  -DCF_BUILDING_CF=1			\
+				  -D__kCFDataDir=\"${datadir}\" \
+				  -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5	\
+				  -I$(top_srcdir)/include		\
+				  -I$(top_srcdir)/include/mach_support
+
+CF_COMMON_CFLAGS = $(AM_CFLAGS)
+CF_COMMON_LDFLAGS = $(AM_LDFLAGS)				\
+				  -version-info $(CF_VERSION_INFO)
+
+CF_COMMON_LIBADD = $(AM_LDADD) compat/libcompat.la 
+noinst_HEADERS = auto_stubs.h				\
+				  CFBundle_BinaryTypes.h		\
+				  CFBundle_Internal.h			\
+				  CFInternal.h				\
+				  CFRunLoopPriv.h			\
+				  CFUniCharPriv.h			\
+				  CFWindowsMessageQueue.h		\
+				  CFXMLInputStream.h
+
+CF_includedir = ${includedir}/CoreFoundation
+CF_include_HEADERS = CFArray.h				\
+				  CFBag.h				\
+				  CFBase.h				\
+				  CFBinaryHeap.h			\
+				  CFBitVector.h				\
+				  CFBundle.h				\
+				  CFBundlePriv.h			\
+				  CFByteOrder.h				\
+				  CFCalendar.h				\
+				  CFCharacterSet.h			\
+				  CFCharacterSetPriv.h			\
+				  CFData.h				\
+				  CFDateFormatter.h			\
+				  CFDate.h				\
+				  CFDictionary.h			\
+				  CFError.h				\
+				  CFError_Private.h			\
+				  CFLocale.h				\
+				  CFLogUtilities.h			\
+				  CFMachPort.h				\
+				  CFMessagePort.h			\
+				  CFNumberFormatter.h			\
+				  CFNumber.h				\
+				  CFPlugInCOM.h				\
+				  CFPlugIn_Factory.h			\
+				  CFPlugIn.h				\
+				  CFPreferences.h			\
+				  CFPriv.h				\
+				  CFPropertyList.h			\
+				  CFRunLoop.h				\
+				  CFRuntime.h				\
+				  CFSet.h				\
+				  CFSocket.h				\
+				  CFStorage.h				\
+				  CFStreamAbstract.h			\
+				  CFStream.h				\
+				  CFStreamInternal.h			\
+				  CFStreamPriv.h			\
+				  CFStringDefaultEncoding.h		\
+				  CFStringEncodingConverterExt.h	\
+				  CFStringEncodingConverter.h		\
+				  CFStringEncodingConverterPriv.h	\
+				  CFStringEncodingExt.h			\
+				  CFString.h				\
+				  CFTimeZone.h				\
+				  CFTree.h				\
+				  CFUniChar.h				\
+				  CFUnicodeDecomposition.h		\
+				  CFUnicodePrecomposition.h		\
+				  CFURLAccess.h				\
+				  CFURL.h				\
+				  CFUserNotification.h			\
+				  CFUUID.h				\
+				  CFXMLNode.h				\
+				  CFXMLParser.h				\
+				  CoreFoundation.h			\
+				  ForFoundationOnly.h
+
+CF_COMMON_SOURCES = CFApplicationPreferences.c		\
+				  CFArray.c				\
+				  CFBag.c				\
+				  CFBase.c				\
+				  CFBinaryHeap.c			\
+				  CFBinaryPList.c			\
+				  CFBitVector.c				\
+				  CFBuiltinConverters.c			\
+				  CFBundle.c				\
+				  CFBundle_Resources.c			\
+				  CFCalendar.c				\
+				  CFCharacterSet.c			\
+				  CFConcreteStreams.c			\
+				  CFData.c				\
+				  CFDateFormatter.c			\
+				  CFDate.c				\
+				  CFDictionary.c			\
+				  CFError.c				\
+				  CFFileUtilities.c			\
+				  CFLocaleIdentifier.c			\
+				  CFLocale.c				\
+				  CFMachPort.c				\
+				  CFMessagePort.c			\
+				  CFNumberFormatter.c			\
+				  CFNumber.c				\
+				  CFPlatform.c				\
+				  CFPlugIn_Factory.c			\
+				  CFPlugIn_Instance.c			\
+				  CFPlugIn.c				\
+				  CFPlugIn_PlugIn.c			\
+				  CFPreferences.c			\
+				  CFPropertyList.c			\
+				  CFRunLoop.c				\
+				  CFRuntime.c				\
+				  CFSet.c				\
+				  CFSocket.c				\
+				  CFSocketStream.c			\
+				  CFSortFunctions.c			\
+				  CFStorage.c				\
+				  CFStream.c				\
+				  CFStringEncodingConverter.c		\
+				  CFStringEncodings.c			\
+				  CFString.c				\
+				  CFStringScanner.c			\
+				  CFStringUtilities.c			\
+				  CFSystemDirectories.c			\
+				  CFTimeZone.c				\
+				  CFTree.c				\
+				  CFURL.c				\
+				  CFURLAccess.c				\
+				  CFUUID.c				\
+				  CFUniChar.c				\
+				  CFUnicodeDecomposition.c		\
+				  CFUnicodePrecomposition.c		\
+				  CFUserNotification.c			\
+				  CFUtilities.c				\
+				  CFVersion.c				\
+				  CFWindowsMessageQueue.c		\
+				  CFXMLInputStream.c			\
+				  CFXMLNode.c				\
+				  CFXMLParser.c				\
+				  CFXMLPreferencesDomain.c		\
+				  CFXMLTree.c
+
+
+#				  Cocotron.c
+lib_LTLIBRARIES = libCoreFoundation.la $(am__append_1) $(am__append_2)
+libCoreFoundation_la_CPPFLAGS = $(CF_COMMON_CPPFLAGS)
+libCoreFoundation_la_CFLAGS = $(CF_COMMON_CFLAGS)
+libCoreFoundation_la_LDFLAGS = $(CF_COMMON_LDFLAGS)
+libCoreFoundation_la_LIBADD = $(CF_COMMON_LIBADD)
+libCoreFoundation_la_SOURCES = $(CF_COMMON_SOURCES)
+@CF_BUILD_DEBUG_TRUE@libCoreFoundation_debug_la_CPPFLAGS = $(CF_COMMON_CPPFLAGS) -DDEBUG
+@CF_BUILD_DEBUG_TRUE@libCoreFoundation_debug_la_CFLAGS = $(CF_COMMON_CFLAGS)
+@CF_BUILD_DEBUG_TRUE@libCoreFoundation_debug_la_LDFLAGS = $(CF_COMMON_LDFLAGS)
+@CF_BUILD_DEBUG_TRUE@libCoreFoundation_debug_la_LIBADD = $(CF_COMMON_LIBADD)
+@CF_BUILD_DEBUG_TRUE@libCoreFoundation_debug_la_SOURCES = $(CF_COMMON_SOURCES)
+@CF_BUILD_PROFILE_TRUE@libCoreFoundation_profile_la_CPPFLAGS = $(CF_COMMON_CPPFLAGS) -DPROFILE
+@CF_BUILD_PROFILE_TRUE@libCoreFoundation_profile_la_CFLAGS = $(CF_COMMON_CFLAGS) -pg
+@CF_BUILD_PROFILE_TRUE@libCoreFoundation_profile_la_LDFLAGS = $(CF_COMMON_LDFLAGS)
+@CF_BUILD_PROFILE_TRUE@libCoreFoundation_profile_la_LIBADD = $(CF_COMMON_LIBADD)
+@CF_BUILD_PROFILE_TRUE@libCoreFoundation_profile_la_SOURCES = $(CF_COMMON_SOURCES)
+EXTRA_DIST = APPLE_LICENSE	\
+				  CHANGES \
+				  CONTRIBUTORS \
+				  INSTALL \
+				  LICENSE \
+				  README \
+				  TODO \
+				  BuildCFLite \
+				  BuildCFLite.windows \
+				  macosx/CFLite.xcodeproj/project.pbxproj \
+				  windows/CFLiteLib.vcproj \
+				  CFLite.sln \
+				  Cocotron/Cocotron.c \
+				  Cocotron/CoreFoundation.xcodeproj/project.pbxproj \
+				  icu/bin/icudt40.dll \
+				  icu/bin/icuin40.dll \
+				  icu/bin/icuuc40.dll \
+				  icu/bin/WHAT_IS_THIS.txt \
+				  icu/lib/icuin.lib \
+				  icu/lib/icuuc.lib \
+				  icu/lib/WHAT_IS_THIS.txt \
+				  icu/unicode/basictz.h \
+				  icu/unicode/brkiter.h \
+				  icu/unicode/calendar.h \
+				  icu/unicode/caniter.h \
+				  icu/unicode/chariter.h \
+				  icu/unicode/choicfmt.h \
+				  icu/unicode/coleitr.h \
+				  icu/unicode/coll.h \
+				  icu/unicode/curramt.h \
+				  icu/unicode/currunit.h \
+				  icu/unicode/datefmt.h \
+				  icu/unicode/dbbi.h \
+				  icu/unicode/dcfmtsym.h \
+				  icu/unicode/decimfmt.h \
+				  icu/unicode/docmain.h \
+				  icu/unicode/dtfmtsym.h \
+				  icu/unicode/dtintrv.h \
+				  icu/unicode/dtitvfmt.h \
+				  icu/unicode/dtitvinf.h \
+				  icu/unicode/dtptngen.h \
+				  icu/unicode/dtrule.h \
+				  icu/unicode/fieldpos.h \
+				  icu/unicode/fmtable.h \
+				  icu/unicode/format.h \
+				  icu/unicode/gregocal.h \
+				  icu/unicode/locid.h \
+				  icu/unicode/measfmt.h \
+				  icu/unicode/measunit.h \
+				  icu/unicode/measure.h \
+				  icu/unicode/msgfmt.h \
+				  icu/unicode/normlzr.h \
+				  icu/unicode/numfmt.h \
+				  icu/unicode/parseerr.h \
+				  icu/unicode/parsepos.h \
+				  icu/unicode/platform.h \
+				  icu/unicode/plurfmt.h \
+				  icu/unicode/plurrule.h \
+				  icu/unicode/ppalmos.h \
+				  icu/unicode/putil.h \
+				  icu/unicode/pwin32.h \
+				  icu/unicode/rbbi.h \
+				  icu/unicode/rbnf.h \
+				  icu/unicode/rbtz.h \
+				  icu/unicode/regex.h \
+				  icu/unicode/rep.h \
+				  icu/unicode/resbund.h \
+				  icu/unicode/schriter.h \
+				  icu/unicode/search.h \
+				  icu/unicode/simpletz.h \
+				  icu/unicode/smpdtfmt.h \
+				  icu/unicode/sortkey.h \
+				  icu/unicode/strenum.h \
+				  icu/unicode/stsearch.h \
+				  icu/unicode/symtable.h \
+				  icu/unicode/tblcoll.h \
+				  icu/unicode/timezone.h \
+				  icu/unicode/translit.h \
+				  icu/unicode/tzrule.h \
+				  icu/unicode/tztrans.h \
+				  icu/unicode/ubidi.h \
+				  icu/unicode/ubrk.h \
+				  icu/unicode/ucal.h \
+				  icu/unicode/ucasemap.h \
+				  icu/unicode/ucat.h \
+				  icu/unicode/uchar.h \
+				  icu/unicode/uchriter.h \
+				  icu/unicode/uclean.h \
+				  icu/unicode/ucnv_cb.h \
+				  icu/unicode/ucnv_err.h \
+				  icu/unicode/ucnv.h \
+				  icu/unicode/ucoleitr.h \
+				  icu/unicode/ucol.h \
+				  icu/unicode/uconfig.h \
+				  icu/unicode/ucsdet.h \
+				  icu/unicode/ucurr.h \
+				  icu/unicode/udata.h \
+				  icu/unicode/udat.h \
+				  icu/unicode/udatpg.h \
+				  icu/unicode/udeprctd.h \
+				  icu/unicode/udraft.h \
+				  icu/unicode/uenum.h \
+				  icu/unicode/uidna.h \
+				  icu/unicode/uintrnal.h \
+				  icu/unicode/uiter.h \
+				  icu/unicode/ulocdata.h \
+				  icu/unicode/uloc.h \
+				  icu/unicode/umachine.h \
+				  icu/unicode/umisc.h \
+				  icu/unicode/umsg.h \
+				  icu/unicode/unifilt.h \
+				  icu/unicode/unifunct.h \
+				  icu/unicode/unimatch.h \
+				  icu/unicode/unirepl.h \
+				  icu/unicode/uniset.h \
+				  icu/unicode/unistr.h \
+				  icu/unicode/unorm.h \
+				  icu/unicode/unum.h \
+				  icu/unicode/uobject.h \
+				  icu/unicode/uobslete.h \
+				  icu/unicode/urbtok.h \
+				  icu/unicode/uregex.h \
+				  icu/unicode/urename.h \
+				  icu/unicode/urep.h \
+				  icu/unicode/ures.h \
+				  icu/unicode/uscript.h \
+				  icu/unicode/usearch.h \
+				  icu/unicode/uset.h \
+				  icu/unicode/usetiter.h \
+				  icu/unicode/ushape.h \
+				  icu/unicode/usprep.h \
+				  icu/unicode/ustdio.h \
+				  icu/unicode/ustream.h \
+				  icu/unicode/ustring.h \
+				  icu/unicode/usystem.h \
+				  icu/unicode/utext.h \
+				  icu/unicode/utf16.h \
+				  icu/unicode/utf32.h \
+				  icu/unicode/utf8.h \
+				  icu/unicode/utf.h \
+				  icu/unicode/utf_old.h \
+				  icu/unicode/utmscale.h \
+				  icu/unicode/utrace.h \
+				  icu/unicode/utrans.h \
+				  icu/unicode/utypes.h \
+				  icu/unicode/uversion.h \
+				  icu/unicode/vtzone.h \
+				  Info.plist \
+				  Makefile \
+				  XCode_Configs/ConfigDebug.xcconfig \
+				  XCode_Configs/Config_Master.xcconfig \
+				  XCode_Configs/ConfigRelease.xcconfig \
+				  ${libCoreFoundation_la_data_DATA}
+
+all: all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+am--refresh:
+	@:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
+	      cd $(srcdir) && $(AUTOMAKE) --foreign  \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    echo ' $(SHELL) ./config.status'; \
+	    $(SHELL) ./config.status;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+CoreFoundation.pc: $(top_builddir)/config.status $(srcdir)/CoreFoundation.pc.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-libLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+	done
+
+clean-libLTLIBRARIES:
+	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libCoreFoundation.la: $(libCoreFoundation_la_OBJECTS) $(libCoreFoundation_la_DEPENDENCIES) 
+	$(libCoreFoundation_la_LINK) -rpath $(libdir) $(libCoreFoundation_la_OBJECTS) $(libCoreFoundation_la_LIBADD) $(LIBS)
+libCoreFoundation_debug.la: $(libCoreFoundation_debug_la_OBJECTS) $(libCoreFoundation_debug_la_DEPENDENCIES) 
+	$(libCoreFoundation_debug_la_LINK) $(am_libCoreFoundation_debug_la_rpath) $(libCoreFoundation_debug_la_OBJECTS) $(libCoreFoundation_debug_la_LIBADD) $(LIBS)
+libCoreFoundation_profile.la: $(libCoreFoundation_profile_la_OBJECTS) $(libCoreFoundation_profile_la_DEPENDENCIES) 
+	$(libCoreFoundation_profile_la_LINK) $(am_libCoreFoundation_profile_la_rpath) $(libCoreFoundation_profile_la_OBJECTS) $(libCoreFoundation_profile_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFApplicationPreferences.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFArray.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBag.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBase.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBinaryHeap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBinaryPList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBitVector.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBuiltinConverters.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBundle.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFBundle_Resources.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFCalendar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFCharacterSet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFConcreteStreams.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFData.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFDate.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFDateFormatter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFDictionary.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFError.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFFileUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFLocale.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFLocaleIdentifier.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFMachPort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFMessagePort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFNumber.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFNumberFormatter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFPlatform.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Factory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Instance.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_PlugIn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFPreferences.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFPropertyList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFRunLoop.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFRuntime.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFSet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFSocket.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFSocketStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFSortFunctions.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFStorage.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFString.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodingConverter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodings.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFStringScanner.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFStringUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFSystemDirectories.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFTimeZone.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFTree.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFURL.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFURLAccess.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFUUID.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFUniChar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFUnicodeDecomposition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFUnicodePrecomposition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFUserNotification.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFVersion.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFWindowsMessageQueue.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFXMLInputStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFXMLNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFXMLParser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFXMLPreferencesDomain.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_debug_la-CFXMLTree.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFApplicationPreferences.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFArray.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBag.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBase.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBinaryHeap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBinaryPList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBitVector.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBuiltinConverters.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBundle.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFBundle_Resources.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFCalendar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFCharacterSet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFConcreteStreams.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFData.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFDate.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFDateFormatter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFDictionary.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFError.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFFileUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFLocale.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFLocaleIdentifier.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFMachPort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFMessagePort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFNumber.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFNumberFormatter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFPlatform.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFPlugIn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFPlugIn_Factory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFPlugIn_Instance.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFPlugIn_PlugIn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFPreferences.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFPropertyList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFRunLoop.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFRuntime.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFSet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFSocket.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFSocketStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFSortFunctions.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFStorage.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFString.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFStringEncodingConverter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFStringEncodings.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFStringScanner.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFStringUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFSystemDirectories.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFTimeZone.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFTree.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFURL.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFURLAccess.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFUUID.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFUniChar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFUnicodeDecomposition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFUnicodePrecomposition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFUserNotification.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFVersion.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFWindowsMessageQueue.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFXMLInputStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFXMLNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFXMLParser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFXMLPreferencesDomain.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_la-CFXMLTree.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFApplicationPreferences.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFArray.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBag.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBase.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBinaryHeap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBinaryPList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBitVector.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBuiltinConverters.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBundle.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFBundle_Resources.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFCalendar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFCharacterSet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFConcreteStreams.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFData.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFDate.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFDateFormatter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFDictionary.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFError.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFFileUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFLocale.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFLocaleIdentifier.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFMachPort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFMessagePort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFNumber.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFNumberFormatter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFPlatform.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Factory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Instance.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_PlugIn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFPreferences.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFPropertyList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFRunLoop.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFRuntime.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFSet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFSocket.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFSocketStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFSortFunctions.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFStorage.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFString.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodingConverter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodings.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFStringScanner.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFStringUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFSystemDirectories.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFTimeZone.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFTree.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFURL.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFURLAccess.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFUUID.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFUniChar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFUnicodeDecomposition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFUnicodePrecomposition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFUserNotification.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFUtilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFVersion.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFWindowsMessageQueue.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFXMLInputStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFXMLNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFXMLParser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFXMLPreferencesDomain.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libCoreFoundation_profile_la-CFXMLTree.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+libCoreFoundation_la-CFApplicationPreferences.lo: CFApplicationPreferences.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFApplicationPreferences.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFApplicationPreferences.Tpo -c -o libCoreFoundation_la-CFApplicationPreferences.lo `test -f 'CFApplicationPreferences.c' || echo '$(srcdir)/'`CFApplicationPreferences.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFApplicationPreferences.Tpo $(DEPDIR)/libCoreFoundation_la-CFApplicationPreferences.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFApplicationPreferences.c' object='libCoreFoundation_la-CFApplicationPreferences.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFApplicationPreferences.lo `test -f 'CFApplicationPreferences.c' || echo '$(srcdir)/'`CFApplicationPreferences.c
+
+libCoreFoundation_la-CFArray.lo: CFArray.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFArray.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFArray.Tpo -c -o libCoreFoundation_la-CFArray.lo `test -f 'CFArray.c' || echo '$(srcdir)/'`CFArray.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFArray.Tpo $(DEPDIR)/libCoreFoundation_la-CFArray.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFArray.c' object='libCoreFoundation_la-CFArray.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFArray.lo `test -f 'CFArray.c' || echo '$(srcdir)/'`CFArray.c
+
+libCoreFoundation_la-CFBag.lo: CFBag.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBag.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBag.Tpo -c -o libCoreFoundation_la-CFBag.lo `test -f 'CFBag.c' || echo '$(srcdir)/'`CFBag.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBag.Tpo $(DEPDIR)/libCoreFoundation_la-CFBag.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBag.c' object='libCoreFoundation_la-CFBag.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBag.lo `test -f 'CFBag.c' || echo '$(srcdir)/'`CFBag.c
+
+libCoreFoundation_la-CFBase.lo: CFBase.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBase.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBase.Tpo -c -o libCoreFoundation_la-CFBase.lo `test -f 'CFBase.c' || echo '$(srcdir)/'`CFBase.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBase.Tpo $(DEPDIR)/libCoreFoundation_la-CFBase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBase.c' object='libCoreFoundation_la-CFBase.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBase.lo `test -f 'CFBase.c' || echo '$(srcdir)/'`CFBase.c
+
+libCoreFoundation_la-CFBinaryHeap.lo: CFBinaryHeap.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBinaryHeap.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBinaryHeap.Tpo -c -o libCoreFoundation_la-CFBinaryHeap.lo `test -f 'CFBinaryHeap.c' || echo '$(srcdir)/'`CFBinaryHeap.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBinaryHeap.Tpo $(DEPDIR)/libCoreFoundation_la-CFBinaryHeap.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBinaryHeap.c' object='libCoreFoundation_la-CFBinaryHeap.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBinaryHeap.lo `test -f 'CFBinaryHeap.c' || echo '$(srcdir)/'`CFBinaryHeap.c
+
+libCoreFoundation_la-CFBinaryPList.lo: CFBinaryPList.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBinaryPList.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBinaryPList.Tpo -c -o libCoreFoundation_la-CFBinaryPList.lo `test -f 'CFBinaryPList.c' || echo '$(srcdir)/'`CFBinaryPList.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBinaryPList.Tpo $(DEPDIR)/libCoreFoundation_la-CFBinaryPList.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBinaryPList.c' object='libCoreFoundation_la-CFBinaryPList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBinaryPList.lo `test -f 'CFBinaryPList.c' || echo '$(srcdir)/'`CFBinaryPList.c
+
+libCoreFoundation_la-CFBitVector.lo: CFBitVector.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBitVector.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBitVector.Tpo -c -o libCoreFoundation_la-CFBitVector.lo `test -f 'CFBitVector.c' || echo '$(srcdir)/'`CFBitVector.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBitVector.Tpo $(DEPDIR)/libCoreFoundation_la-CFBitVector.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBitVector.c' object='libCoreFoundation_la-CFBitVector.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBitVector.lo `test -f 'CFBitVector.c' || echo '$(srcdir)/'`CFBitVector.c
+
+libCoreFoundation_la-CFBuiltinConverters.lo: CFBuiltinConverters.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBuiltinConverters.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBuiltinConverters.Tpo -c -o libCoreFoundation_la-CFBuiltinConverters.lo `test -f 'CFBuiltinConverters.c' || echo '$(srcdir)/'`CFBuiltinConverters.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBuiltinConverters.Tpo $(DEPDIR)/libCoreFoundation_la-CFBuiltinConverters.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBuiltinConverters.c' object='libCoreFoundation_la-CFBuiltinConverters.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBuiltinConverters.lo `test -f 'CFBuiltinConverters.c' || echo '$(srcdir)/'`CFBuiltinConverters.c
+
+libCoreFoundation_la-CFBundle.lo: CFBundle.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBundle.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBundle.Tpo -c -o libCoreFoundation_la-CFBundle.lo `test -f 'CFBundle.c' || echo '$(srcdir)/'`CFBundle.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBundle.Tpo $(DEPDIR)/libCoreFoundation_la-CFBundle.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBundle.c' object='libCoreFoundation_la-CFBundle.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBundle.lo `test -f 'CFBundle.c' || echo '$(srcdir)/'`CFBundle.c
+
+libCoreFoundation_la-CFBundle_Resources.lo: CFBundle_Resources.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFBundle_Resources.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFBundle_Resources.Tpo -c -o libCoreFoundation_la-CFBundle_Resources.lo `test -f 'CFBundle_Resources.c' || echo '$(srcdir)/'`CFBundle_Resources.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFBundle_Resources.Tpo $(DEPDIR)/libCoreFoundation_la-CFBundle_Resources.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBundle_Resources.c' object='libCoreFoundation_la-CFBundle_Resources.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFBundle_Resources.lo `test -f 'CFBundle_Resources.c' || echo '$(srcdir)/'`CFBundle_Resources.c
+
+libCoreFoundation_la-CFCalendar.lo: CFCalendar.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFCalendar.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFCalendar.Tpo -c -o libCoreFoundation_la-CFCalendar.lo `test -f 'CFCalendar.c' || echo '$(srcdir)/'`CFCalendar.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFCalendar.Tpo $(DEPDIR)/libCoreFoundation_la-CFCalendar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFCalendar.c' object='libCoreFoundation_la-CFCalendar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFCalendar.lo `test -f 'CFCalendar.c' || echo '$(srcdir)/'`CFCalendar.c
+
+libCoreFoundation_la-CFCharacterSet.lo: CFCharacterSet.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFCharacterSet.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFCharacterSet.Tpo -c -o libCoreFoundation_la-CFCharacterSet.lo `test -f 'CFCharacterSet.c' || echo '$(srcdir)/'`CFCharacterSet.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFCharacterSet.Tpo $(DEPDIR)/libCoreFoundation_la-CFCharacterSet.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFCharacterSet.c' object='libCoreFoundation_la-CFCharacterSet.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFCharacterSet.lo `test -f 'CFCharacterSet.c' || echo '$(srcdir)/'`CFCharacterSet.c
+
+libCoreFoundation_la-CFConcreteStreams.lo: CFConcreteStreams.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFConcreteStreams.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFConcreteStreams.Tpo -c -o libCoreFoundation_la-CFConcreteStreams.lo `test -f 'CFConcreteStreams.c' || echo '$(srcdir)/'`CFConcreteStreams.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFConcreteStreams.Tpo $(DEPDIR)/libCoreFoundation_la-CFConcreteStreams.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFConcreteStreams.c' object='libCoreFoundation_la-CFConcreteStreams.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFConcreteStreams.lo `test -f 'CFConcreteStreams.c' || echo '$(srcdir)/'`CFConcreteStreams.c
+
+libCoreFoundation_la-CFData.lo: CFData.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFData.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFData.Tpo -c -o libCoreFoundation_la-CFData.lo `test -f 'CFData.c' || echo '$(srcdir)/'`CFData.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFData.Tpo $(DEPDIR)/libCoreFoundation_la-CFData.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFData.c' object='libCoreFoundation_la-CFData.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFData.lo `test -f 'CFData.c' || echo '$(srcdir)/'`CFData.c
+
+libCoreFoundation_la-CFDateFormatter.lo: CFDateFormatter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFDateFormatter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFDateFormatter.Tpo -c -o libCoreFoundation_la-CFDateFormatter.lo `test -f 'CFDateFormatter.c' || echo '$(srcdir)/'`CFDateFormatter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFDateFormatter.Tpo $(DEPDIR)/libCoreFoundation_la-CFDateFormatter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDateFormatter.c' object='libCoreFoundation_la-CFDateFormatter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFDateFormatter.lo `test -f 'CFDateFormatter.c' || echo '$(srcdir)/'`CFDateFormatter.c
+
+libCoreFoundation_la-CFDate.lo: CFDate.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFDate.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFDate.Tpo -c -o libCoreFoundation_la-CFDate.lo `test -f 'CFDate.c' || echo '$(srcdir)/'`CFDate.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFDate.Tpo $(DEPDIR)/libCoreFoundation_la-CFDate.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDate.c' object='libCoreFoundation_la-CFDate.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFDate.lo `test -f 'CFDate.c' || echo '$(srcdir)/'`CFDate.c
+
+libCoreFoundation_la-CFDictionary.lo: CFDictionary.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFDictionary.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFDictionary.Tpo -c -o libCoreFoundation_la-CFDictionary.lo `test -f 'CFDictionary.c' || echo '$(srcdir)/'`CFDictionary.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFDictionary.Tpo $(DEPDIR)/libCoreFoundation_la-CFDictionary.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDictionary.c' object='libCoreFoundation_la-CFDictionary.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFDictionary.lo `test -f 'CFDictionary.c' || echo '$(srcdir)/'`CFDictionary.c
+
+libCoreFoundation_la-CFError.lo: CFError.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFError.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFError.Tpo -c -o libCoreFoundation_la-CFError.lo `test -f 'CFError.c' || echo '$(srcdir)/'`CFError.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFError.Tpo $(DEPDIR)/libCoreFoundation_la-CFError.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFError.c' object='libCoreFoundation_la-CFError.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFError.lo `test -f 'CFError.c' || echo '$(srcdir)/'`CFError.c
+
+libCoreFoundation_la-CFFileUtilities.lo: CFFileUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFFileUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFFileUtilities.Tpo -c -o libCoreFoundation_la-CFFileUtilities.lo `test -f 'CFFileUtilities.c' || echo '$(srcdir)/'`CFFileUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFFileUtilities.Tpo $(DEPDIR)/libCoreFoundation_la-CFFileUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFFileUtilities.c' object='libCoreFoundation_la-CFFileUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFFileUtilities.lo `test -f 'CFFileUtilities.c' || echo '$(srcdir)/'`CFFileUtilities.c
+
+libCoreFoundation_la-CFLocaleIdentifier.lo: CFLocaleIdentifier.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFLocaleIdentifier.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFLocaleIdentifier.Tpo -c -o libCoreFoundation_la-CFLocaleIdentifier.lo `test -f 'CFLocaleIdentifier.c' || echo '$(srcdir)/'`CFLocaleIdentifier.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFLocaleIdentifier.Tpo $(DEPDIR)/libCoreFoundation_la-CFLocaleIdentifier.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFLocaleIdentifier.c' object='libCoreFoundation_la-CFLocaleIdentifier.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFLocaleIdentifier.lo `test -f 'CFLocaleIdentifier.c' || echo '$(srcdir)/'`CFLocaleIdentifier.c
+
+libCoreFoundation_la-CFLocale.lo: CFLocale.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFLocale.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFLocale.Tpo -c -o libCoreFoundation_la-CFLocale.lo `test -f 'CFLocale.c' || echo '$(srcdir)/'`CFLocale.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFLocale.Tpo $(DEPDIR)/libCoreFoundation_la-CFLocale.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFLocale.c' object='libCoreFoundation_la-CFLocale.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFLocale.lo `test -f 'CFLocale.c' || echo '$(srcdir)/'`CFLocale.c
+
+libCoreFoundation_la-CFMachPort.lo: CFMachPort.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFMachPort.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFMachPort.Tpo -c -o libCoreFoundation_la-CFMachPort.lo `test -f 'CFMachPort.c' || echo '$(srcdir)/'`CFMachPort.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFMachPort.Tpo $(DEPDIR)/libCoreFoundation_la-CFMachPort.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFMachPort.c' object='libCoreFoundation_la-CFMachPort.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFMachPort.lo `test -f 'CFMachPort.c' || echo '$(srcdir)/'`CFMachPort.c
+
+libCoreFoundation_la-CFMessagePort.lo: CFMessagePort.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFMessagePort.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFMessagePort.Tpo -c -o libCoreFoundation_la-CFMessagePort.lo `test -f 'CFMessagePort.c' || echo '$(srcdir)/'`CFMessagePort.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFMessagePort.Tpo $(DEPDIR)/libCoreFoundation_la-CFMessagePort.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFMessagePort.c' object='libCoreFoundation_la-CFMessagePort.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFMessagePort.lo `test -f 'CFMessagePort.c' || echo '$(srcdir)/'`CFMessagePort.c
+
+libCoreFoundation_la-CFNumberFormatter.lo: CFNumberFormatter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFNumberFormatter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFNumberFormatter.Tpo -c -o libCoreFoundation_la-CFNumberFormatter.lo `test -f 'CFNumberFormatter.c' || echo '$(srcdir)/'`CFNumberFormatter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFNumberFormatter.Tpo $(DEPDIR)/libCoreFoundation_la-CFNumberFormatter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFNumberFormatter.c' object='libCoreFoundation_la-CFNumberFormatter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFNumberFormatter.lo `test -f 'CFNumberFormatter.c' || echo '$(srcdir)/'`CFNumberFormatter.c
+
+libCoreFoundation_la-CFNumber.lo: CFNumber.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFNumber.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFNumber.Tpo -c -o libCoreFoundation_la-CFNumber.lo `test -f 'CFNumber.c' || echo '$(srcdir)/'`CFNumber.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFNumber.Tpo $(DEPDIR)/libCoreFoundation_la-CFNumber.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFNumber.c' object='libCoreFoundation_la-CFNumber.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFNumber.lo `test -f 'CFNumber.c' || echo '$(srcdir)/'`CFNumber.c
+
+libCoreFoundation_la-CFPlatform.lo: CFPlatform.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFPlatform.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFPlatform.Tpo -c -o libCoreFoundation_la-CFPlatform.lo `test -f 'CFPlatform.c' || echo '$(srcdir)/'`CFPlatform.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFPlatform.Tpo $(DEPDIR)/libCoreFoundation_la-CFPlatform.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlatform.c' object='libCoreFoundation_la-CFPlatform.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFPlatform.lo `test -f 'CFPlatform.c' || echo '$(srcdir)/'`CFPlatform.c
+
+libCoreFoundation_la-CFPlugIn_Factory.lo: CFPlugIn_Factory.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFPlugIn_Factory.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFPlugIn_Factory.Tpo -c -o libCoreFoundation_la-CFPlugIn_Factory.lo `test -f 'CFPlugIn_Factory.c' || echo '$(srcdir)/'`CFPlugIn_Factory.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFPlugIn_Factory.Tpo $(DEPDIR)/libCoreFoundation_la-CFPlugIn_Factory.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_Factory.c' object='libCoreFoundation_la-CFPlugIn_Factory.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFPlugIn_Factory.lo `test -f 'CFPlugIn_Factory.c' || echo '$(srcdir)/'`CFPlugIn_Factory.c
+
+libCoreFoundation_la-CFPlugIn_Instance.lo: CFPlugIn_Instance.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFPlugIn_Instance.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFPlugIn_Instance.Tpo -c -o libCoreFoundation_la-CFPlugIn_Instance.lo `test -f 'CFPlugIn_Instance.c' || echo '$(srcdir)/'`CFPlugIn_Instance.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFPlugIn_Instance.Tpo $(DEPDIR)/libCoreFoundation_la-CFPlugIn_Instance.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_Instance.c' object='libCoreFoundation_la-CFPlugIn_Instance.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFPlugIn_Instance.lo `test -f 'CFPlugIn_Instance.c' || echo '$(srcdir)/'`CFPlugIn_Instance.c
+
+libCoreFoundation_la-CFPlugIn.lo: CFPlugIn.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFPlugIn.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFPlugIn.Tpo -c -o libCoreFoundation_la-CFPlugIn.lo `test -f 'CFPlugIn.c' || echo '$(srcdir)/'`CFPlugIn.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFPlugIn.Tpo $(DEPDIR)/libCoreFoundation_la-CFPlugIn.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn.c' object='libCoreFoundation_la-CFPlugIn.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFPlugIn.lo `test -f 'CFPlugIn.c' || echo '$(srcdir)/'`CFPlugIn.c
+
+libCoreFoundation_la-CFPlugIn_PlugIn.lo: CFPlugIn_PlugIn.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFPlugIn_PlugIn.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFPlugIn_PlugIn.Tpo -c -o libCoreFoundation_la-CFPlugIn_PlugIn.lo `test -f 'CFPlugIn_PlugIn.c' || echo '$(srcdir)/'`CFPlugIn_PlugIn.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFPlugIn_PlugIn.Tpo $(DEPDIR)/libCoreFoundation_la-CFPlugIn_PlugIn.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_PlugIn.c' object='libCoreFoundation_la-CFPlugIn_PlugIn.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFPlugIn_PlugIn.lo `test -f 'CFPlugIn_PlugIn.c' || echo '$(srcdir)/'`CFPlugIn_PlugIn.c
+
+libCoreFoundation_la-CFPreferences.lo: CFPreferences.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFPreferences.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFPreferences.Tpo -c -o libCoreFoundation_la-CFPreferences.lo `test -f 'CFPreferences.c' || echo '$(srcdir)/'`CFPreferences.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFPreferences.Tpo $(DEPDIR)/libCoreFoundation_la-CFPreferences.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPreferences.c' object='libCoreFoundation_la-CFPreferences.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFPreferences.lo `test -f 'CFPreferences.c' || echo '$(srcdir)/'`CFPreferences.c
+
+libCoreFoundation_la-CFPropertyList.lo: CFPropertyList.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFPropertyList.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFPropertyList.Tpo -c -o libCoreFoundation_la-CFPropertyList.lo `test -f 'CFPropertyList.c' || echo '$(srcdir)/'`CFPropertyList.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFPropertyList.Tpo $(DEPDIR)/libCoreFoundation_la-CFPropertyList.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPropertyList.c' object='libCoreFoundation_la-CFPropertyList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFPropertyList.lo `test -f 'CFPropertyList.c' || echo '$(srcdir)/'`CFPropertyList.c
+
+libCoreFoundation_la-CFRunLoop.lo: CFRunLoop.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFRunLoop.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFRunLoop.Tpo -c -o libCoreFoundation_la-CFRunLoop.lo `test -f 'CFRunLoop.c' || echo '$(srcdir)/'`CFRunLoop.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFRunLoop.Tpo $(DEPDIR)/libCoreFoundation_la-CFRunLoop.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFRunLoop.c' object='libCoreFoundation_la-CFRunLoop.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFRunLoop.lo `test -f 'CFRunLoop.c' || echo '$(srcdir)/'`CFRunLoop.c
+
+libCoreFoundation_la-CFRuntime.lo: CFRuntime.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFRuntime.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFRuntime.Tpo -c -o libCoreFoundation_la-CFRuntime.lo `test -f 'CFRuntime.c' || echo '$(srcdir)/'`CFRuntime.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFRuntime.Tpo $(DEPDIR)/libCoreFoundation_la-CFRuntime.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFRuntime.c' object='libCoreFoundation_la-CFRuntime.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFRuntime.lo `test -f 'CFRuntime.c' || echo '$(srcdir)/'`CFRuntime.c
+
+libCoreFoundation_la-CFSet.lo: CFSet.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFSet.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFSet.Tpo -c -o libCoreFoundation_la-CFSet.lo `test -f 'CFSet.c' || echo '$(srcdir)/'`CFSet.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFSet.Tpo $(DEPDIR)/libCoreFoundation_la-CFSet.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSet.c' object='libCoreFoundation_la-CFSet.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFSet.lo `test -f 'CFSet.c' || echo '$(srcdir)/'`CFSet.c
+
+libCoreFoundation_la-CFSocket.lo: CFSocket.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFSocket.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFSocket.Tpo -c -o libCoreFoundation_la-CFSocket.lo `test -f 'CFSocket.c' || echo '$(srcdir)/'`CFSocket.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFSocket.Tpo $(DEPDIR)/libCoreFoundation_la-CFSocket.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSocket.c' object='libCoreFoundation_la-CFSocket.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFSocket.lo `test -f 'CFSocket.c' || echo '$(srcdir)/'`CFSocket.c
+
+libCoreFoundation_la-CFSocketStream.lo: CFSocketStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFSocketStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFSocketStream.Tpo -c -o libCoreFoundation_la-CFSocketStream.lo `test -f 'CFSocketStream.c' || echo '$(srcdir)/'`CFSocketStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFSocketStream.Tpo $(DEPDIR)/libCoreFoundation_la-CFSocketStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSocketStream.c' object='libCoreFoundation_la-CFSocketStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFSocketStream.lo `test -f 'CFSocketStream.c' || echo '$(srcdir)/'`CFSocketStream.c
+
+libCoreFoundation_la-CFSortFunctions.lo: CFSortFunctions.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFSortFunctions.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFSortFunctions.Tpo -c -o libCoreFoundation_la-CFSortFunctions.lo `test -f 'CFSortFunctions.c' || echo '$(srcdir)/'`CFSortFunctions.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFSortFunctions.Tpo $(DEPDIR)/libCoreFoundation_la-CFSortFunctions.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSortFunctions.c' object='libCoreFoundation_la-CFSortFunctions.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFSortFunctions.lo `test -f 'CFSortFunctions.c' || echo '$(srcdir)/'`CFSortFunctions.c
+
+libCoreFoundation_la-CFStorage.lo: CFStorage.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFStorage.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFStorage.Tpo -c -o libCoreFoundation_la-CFStorage.lo `test -f 'CFStorage.c' || echo '$(srcdir)/'`CFStorage.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFStorage.Tpo $(DEPDIR)/libCoreFoundation_la-CFStorage.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStorage.c' object='libCoreFoundation_la-CFStorage.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFStorage.lo `test -f 'CFStorage.c' || echo '$(srcdir)/'`CFStorage.c
+
+libCoreFoundation_la-CFStream.lo: CFStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFStream.Tpo -c -o libCoreFoundation_la-CFStream.lo `test -f 'CFStream.c' || echo '$(srcdir)/'`CFStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFStream.Tpo $(DEPDIR)/libCoreFoundation_la-CFStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStream.c' object='libCoreFoundation_la-CFStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFStream.lo `test -f 'CFStream.c' || echo '$(srcdir)/'`CFStream.c
+
+libCoreFoundation_la-CFStringEncodingConverter.lo: CFStringEncodingConverter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFStringEncodingConverter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFStringEncodingConverter.Tpo -c -o libCoreFoundation_la-CFStringEncodingConverter.lo `test -f 'CFStringEncodingConverter.c' || echo '$(srcdir)/'`CFStringEncodingConverter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFStringEncodingConverter.Tpo $(DEPDIR)/libCoreFoundation_la-CFStringEncodingConverter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringEncodingConverter.c' object='libCoreFoundation_la-CFStringEncodingConverter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFStringEncodingConverter.lo `test -f 'CFStringEncodingConverter.c' || echo '$(srcdir)/'`CFStringEncodingConverter.c
+
+libCoreFoundation_la-CFStringEncodings.lo: CFStringEncodings.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFStringEncodings.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFStringEncodings.Tpo -c -o libCoreFoundation_la-CFStringEncodings.lo `test -f 'CFStringEncodings.c' || echo '$(srcdir)/'`CFStringEncodings.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFStringEncodings.Tpo $(DEPDIR)/libCoreFoundation_la-CFStringEncodings.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringEncodings.c' object='libCoreFoundation_la-CFStringEncodings.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFStringEncodings.lo `test -f 'CFStringEncodings.c' || echo '$(srcdir)/'`CFStringEncodings.c
+
+libCoreFoundation_la-CFString.lo: CFString.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFString.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFString.Tpo -c -o libCoreFoundation_la-CFString.lo `test -f 'CFString.c' || echo '$(srcdir)/'`CFString.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFString.Tpo $(DEPDIR)/libCoreFoundation_la-CFString.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFString.c' object='libCoreFoundation_la-CFString.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFString.lo `test -f 'CFString.c' || echo '$(srcdir)/'`CFString.c
+
+libCoreFoundation_la-CFStringScanner.lo: CFStringScanner.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFStringScanner.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFStringScanner.Tpo -c -o libCoreFoundation_la-CFStringScanner.lo `test -f 'CFStringScanner.c' || echo '$(srcdir)/'`CFStringScanner.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFStringScanner.Tpo $(DEPDIR)/libCoreFoundation_la-CFStringScanner.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringScanner.c' object='libCoreFoundation_la-CFStringScanner.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFStringScanner.lo `test -f 'CFStringScanner.c' || echo '$(srcdir)/'`CFStringScanner.c
+
+libCoreFoundation_la-CFStringUtilities.lo: CFStringUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFStringUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFStringUtilities.Tpo -c -o libCoreFoundation_la-CFStringUtilities.lo `test -f 'CFStringUtilities.c' || echo '$(srcdir)/'`CFStringUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFStringUtilities.Tpo $(DEPDIR)/libCoreFoundation_la-CFStringUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringUtilities.c' object='libCoreFoundation_la-CFStringUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFStringUtilities.lo `test -f 'CFStringUtilities.c' || echo '$(srcdir)/'`CFStringUtilities.c
+
+libCoreFoundation_la-CFSystemDirectories.lo: CFSystemDirectories.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFSystemDirectories.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFSystemDirectories.Tpo -c -o libCoreFoundation_la-CFSystemDirectories.lo `test -f 'CFSystemDirectories.c' || echo '$(srcdir)/'`CFSystemDirectories.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFSystemDirectories.Tpo $(DEPDIR)/libCoreFoundation_la-CFSystemDirectories.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSystemDirectories.c' object='libCoreFoundation_la-CFSystemDirectories.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFSystemDirectories.lo `test -f 'CFSystemDirectories.c' || echo '$(srcdir)/'`CFSystemDirectories.c
+
+libCoreFoundation_la-CFTimeZone.lo: CFTimeZone.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFTimeZone.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFTimeZone.Tpo -c -o libCoreFoundation_la-CFTimeZone.lo `test -f 'CFTimeZone.c' || echo '$(srcdir)/'`CFTimeZone.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFTimeZone.Tpo $(DEPDIR)/libCoreFoundation_la-CFTimeZone.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFTimeZone.c' object='libCoreFoundation_la-CFTimeZone.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFTimeZone.lo `test -f 'CFTimeZone.c' || echo '$(srcdir)/'`CFTimeZone.c
+
+libCoreFoundation_la-CFTree.lo: CFTree.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFTree.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFTree.Tpo -c -o libCoreFoundation_la-CFTree.lo `test -f 'CFTree.c' || echo '$(srcdir)/'`CFTree.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFTree.Tpo $(DEPDIR)/libCoreFoundation_la-CFTree.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFTree.c' object='libCoreFoundation_la-CFTree.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFTree.lo `test -f 'CFTree.c' || echo '$(srcdir)/'`CFTree.c
+
+libCoreFoundation_la-CFURL.lo: CFURL.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFURL.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFURL.Tpo -c -o libCoreFoundation_la-CFURL.lo `test -f 'CFURL.c' || echo '$(srcdir)/'`CFURL.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFURL.Tpo $(DEPDIR)/libCoreFoundation_la-CFURL.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFURL.c' object='libCoreFoundation_la-CFURL.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFURL.lo `test -f 'CFURL.c' || echo '$(srcdir)/'`CFURL.c
+
+libCoreFoundation_la-CFURLAccess.lo: CFURLAccess.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFURLAccess.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFURLAccess.Tpo -c -o libCoreFoundation_la-CFURLAccess.lo `test -f 'CFURLAccess.c' || echo '$(srcdir)/'`CFURLAccess.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFURLAccess.Tpo $(DEPDIR)/libCoreFoundation_la-CFURLAccess.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFURLAccess.c' object='libCoreFoundation_la-CFURLAccess.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFURLAccess.lo `test -f 'CFURLAccess.c' || echo '$(srcdir)/'`CFURLAccess.c
+
+libCoreFoundation_la-CFUUID.lo: CFUUID.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFUUID.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFUUID.Tpo -c -o libCoreFoundation_la-CFUUID.lo `test -f 'CFUUID.c' || echo '$(srcdir)/'`CFUUID.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFUUID.Tpo $(DEPDIR)/libCoreFoundation_la-CFUUID.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUUID.c' object='libCoreFoundation_la-CFUUID.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFUUID.lo `test -f 'CFUUID.c' || echo '$(srcdir)/'`CFUUID.c
+
+libCoreFoundation_la-CFUniChar.lo: CFUniChar.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFUniChar.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFUniChar.Tpo -c -o libCoreFoundation_la-CFUniChar.lo `test -f 'CFUniChar.c' || echo '$(srcdir)/'`CFUniChar.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFUniChar.Tpo $(DEPDIR)/libCoreFoundation_la-CFUniChar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUniChar.c' object='libCoreFoundation_la-CFUniChar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFUniChar.lo `test -f 'CFUniChar.c' || echo '$(srcdir)/'`CFUniChar.c
+
+libCoreFoundation_la-CFUnicodeDecomposition.lo: CFUnicodeDecomposition.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFUnicodeDecomposition.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFUnicodeDecomposition.Tpo -c -o libCoreFoundation_la-CFUnicodeDecomposition.lo `test -f 'CFUnicodeDecomposition.c' || echo '$(srcdir)/'`CFUnicodeDecomposition.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFUnicodeDecomposition.Tpo $(DEPDIR)/libCoreFoundation_la-CFUnicodeDecomposition.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUnicodeDecomposition.c' object='libCoreFoundation_la-CFUnicodeDecomposition.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFUnicodeDecomposition.lo `test -f 'CFUnicodeDecomposition.c' || echo '$(srcdir)/'`CFUnicodeDecomposition.c
+
+libCoreFoundation_la-CFUnicodePrecomposition.lo: CFUnicodePrecomposition.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFUnicodePrecomposition.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFUnicodePrecomposition.Tpo -c -o libCoreFoundation_la-CFUnicodePrecomposition.lo `test -f 'CFUnicodePrecomposition.c' || echo '$(srcdir)/'`CFUnicodePrecomposition.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFUnicodePrecomposition.Tpo $(DEPDIR)/libCoreFoundation_la-CFUnicodePrecomposition.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUnicodePrecomposition.c' object='libCoreFoundation_la-CFUnicodePrecomposition.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFUnicodePrecomposition.lo `test -f 'CFUnicodePrecomposition.c' || echo '$(srcdir)/'`CFUnicodePrecomposition.c
+
+libCoreFoundation_la-CFUserNotification.lo: CFUserNotification.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFUserNotification.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFUserNotification.Tpo -c -o libCoreFoundation_la-CFUserNotification.lo `test -f 'CFUserNotification.c' || echo '$(srcdir)/'`CFUserNotification.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFUserNotification.Tpo $(DEPDIR)/libCoreFoundation_la-CFUserNotification.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUserNotification.c' object='libCoreFoundation_la-CFUserNotification.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFUserNotification.lo `test -f 'CFUserNotification.c' || echo '$(srcdir)/'`CFUserNotification.c
+
+libCoreFoundation_la-CFUtilities.lo: CFUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFUtilities.Tpo -c -o libCoreFoundation_la-CFUtilities.lo `test -f 'CFUtilities.c' || echo '$(srcdir)/'`CFUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFUtilities.Tpo $(DEPDIR)/libCoreFoundation_la-CFUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUtilities.c' object='libCoreFoundation_la-CFUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFUtilities.lo `test -f 'CFUtilities.c' || echo '$(srcdir)/'`CFUtilities.c
+
+libCoreFoundation_la-CFVersion.lo: CFVersion.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFVersion.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFVersion.Tpo -c -o libCoreFoundation_la-CFVersion.lo `test -f 'CFVersion.c' || echo '$(srcdir)/'`CFVersion.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFVersion.Tpo $(DEPDIR)/libCoreFoundation_la-CFVersion.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFVersion.c' object='libCoreFoundation_la-CFVersion.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFVersion.lo `test -f 'CFVersion.c' || echo '$(srcdir)/'`CFVersion.c
+
+libCoreFoundation_la-CFWindowsMessageQueue.lo: CFWindowsMessageQueue.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFWindowsMessageQueue.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFWindowsMessageQueue.Tpo -c -o libCoreFoundation_la-CFWindowsMessageQueue.lo `test -f 'CFWindowsMessageQueue.c' || echo '$(srcdir)/'`CFWindowsMessageQueue.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFWindowsMessageQueue.Tpo $(DEPDIR)/libCoreFoundation_la-CFWindowsMessageQueue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFWindowsMessageQueue.c' object='libCoreFoundation_la-CFWindowsMessageQueue.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFWindowsMessageQueue.lo `test -f 'CFWindowsMessageQueue.c' || echo '$(srcdir)/'`CFWindowsMessageQueue.c
+
+libCoreFoundation_la-CFXMLInputStream.lo: CFXMLInputStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFXMLInputStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFXMLInputStream.Tpo -c -o libCoreFoundation_la-CFXMLInputStream.lo `test -f 'CFXMLInputStream.c' || echo '$(srcdir)/'`CFXMLInputStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFXMLInputStream.Tpo $(DEPDIR)/libCoreFoundation_la-CFXMLInputStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLInputStream.c' object='libCoreFoundation_la-CFXMLInputStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFXMLInputStream.lo `test -f 'CFXMLInputStream.c' || echo '$(srcdir)/'`CFXMLInputStream.c
+
+libCoreFoundation_la-CFXMLNode.lo: CFXMLNode.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFXMLNode.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFXMLNode.Tpo -c -o libCoreFoundation_la-CFXMLNode.lo `test -f 'CFXMLNode.c' || echo '$(srcdir)/'`CFXMLNode.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFXMLNode.Tpo $(DEPDIR)/libCoreFoundation_la-CFXMLNode.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLNode.c' object='libCoreFoundation_la-CFXMLNode.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFXMLNode.lo `test -f 'CFXMLNode.c' || echo '$(srcdir)/'`CFXMLNode.c
+
+libCoreFoundation_la-CFXMLParser.lo: CFXMLParser.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFXMLParser.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFXMLParser.Tpo -c -o libCoreFoundation_la-CFXMLParser.lo `test -f 'CFXMLParser.c' || echo '$(srcdir)/'`CFXMLParser.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFXMLParser.Tpo $(DEPDIR)/libCoreFoundation_la-CFXMLParser.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLParser.c' object='libCoreFoundation_la-CFXMLParser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFXMLParser.lo `test -f 'CFXMLParser.c' || echo '$(srcdir)/'`CFXMLParser.c
+
+libCoreFoundation_la-CFXMLPreferencesDomain.lo: CFXMLPreferencesDomain.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFXMLPreferencesDomain.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFXMLPreferencesDomain.Tpo -c -o libCoreFoundation_la-CFXMLPreferencesDomain.lo `test -f 'CFXMLPreferencesDomain.c' || echo '$(srcdir)/'`CFXMLPreferencesDomain.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFXMLPreferencesDomain.Tpo $(DEPDIR)/libCoreFoundation_la-CFXMLPreferencesDomain.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLPreferencesDomain.c' object='libCoreFoundation_la-CFXMLPreferencesDomain.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFXMLPreferencesDomain.lo `test -f 'CFXMLPreferencesDomain.c' || echo '$(srcdir)/'`CFXMLPreferencesDomain.c
+
+libCoreFoundation_la-CFXMLTree.lo: CFXMLTree.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_la-CFXMLTree.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_la-CFXMLTree.Tpo -c -o libCoreFoundation_la-CFXMLTree.lo `test -f 'CFXMLTree.c' || echo '$(srcdir)/'`CFXMLTree.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_la-CFXMLTree.Tpo $(DEPDIR)/libCoreFoundation_la-CFXMLTree.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLTree.c' object='libCoreFoundation_la-CFXMLTree.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_la-CFXMLTree.lo `test -f 'CFXMLTree.c' || echo '$(srcdir)/'`CFXMLTree.c
+
+libCoreFoundation_debug_la-CFApplicationPreferences.lo: CFApplicationPreferences.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFApplicationPreferences.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFApplicationPreferences.Tpo -c -o libCoreFoundation_debug_la-CFApplicationPreferences.lo `test -f 'CFApplicationPreferences.c' || echo '$(srcdir)/'`CFApplicationPreferences.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFApplicationPreferences.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFApplicationPreferences.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFApplicationPreferences.c' object='libCoreFoundation_debug_la-CFApplicationPreferences.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFApplicationPreferences.lo `test -f 'CFApplicationPreferences.c' || echo '$(srcdir)/'`CFApplicationPreferences.c
+
+libCoreFoundation_debug_la-CFArray.lo: CFArray.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFArray.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFArray.Tpo -c -o libCoreFoundation_debug_la-CFArray.lo `test -f 'CFArray.c' || echo '$(srcdir)/'`CFArray.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFArray.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFArray.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFArray.c' object='libCoreFoundation_debug_la-CFArray.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFArray.lo `test -f 'CFArray.c' || echo '$(srcdir)/'`CFArray.c
+
+libCoreFoundation_debug_la-CFBag.lo: CFBag.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBag.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBag.Tpo -c -o libCoreFoundation_debug_la-CFBag.lo `test -f 'CFBag.c' || echo '$(srcdir)/'`CFBag.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBag.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBag.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBag.c' object='libCoreFoundation_debug_la-CFBag.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBag.lo `test -f 'CFBag.c' || echo '$(srcdir)/'`CFBag.c
+
+libCoreFoundation_debug_la-CFBase.lo: CFBase.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBase.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBase.Tpo -c -o libCoreFoundation_debug_la-CFBase.lo `test -f 'CFBase.c' || echo '$(srcdir)/'`CFBase.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBase.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBase.c' object='libCoreFoundation_debug_la-CFBase.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBase.lo `test -f 'CFBase.c' || echo '$(srcdir)/'`CFBase.c
+
+libCoreFoundation_debug_la-CFBinaryHeap.lo: CFBinaryHeap.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBinaryHeap.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBinaryHeap.Tpo -c -o libCoreFoundation_debug_la-CFBinaryHeap.lo `test -f 'CFBinaryHeap.c' || echo '$(srcdir)/'`CFBinaryHeap.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBinaryHeap.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBinaryHeap.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBinaryHeap.c' object='libCoreFoundation_debug_la-CFBinaryHeap.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBinaryHeap.lo `test -f 'CFBinaryHeap.c' || echo '$(srcdir)/'`CFBinaryHeap.c
+
+libCoreFoundation_debug_la-CFBinaryPList.lo: CFBinaryPList.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBinaryPList.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBinaryPList.Tpo -c -o libCoreFoundation_debug_la-CFBinaryPList.lo `test -f 'CFBinaryPList.c' || echo '$(srcdir)/'`CFBinaryPList.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBinaryPList.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBinaryPList.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBinaryPList.c' object='libCoreFoundation_debug_la-CFBinaryPList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBinaryPList.lo `test -f 'CFBinaryPList.c' || echo '$(srcdir)/'`CFBinaryPList.c
+
+libCoreFoundation_debug_la-CFBitVector.lo: CFBitVector.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBitVector.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBitVector.Tpo -c -o libCoreFoundation_debug_la-CFBitVector.lo `test -f 'CFBitVector.c' || echo '$(srcdir)/'`CFBitVector.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBitVector.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBitVector.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBitVector.c' object='libCoreFoundation_debug_la-CFBitVector.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBitVector.lo `test -f 'CFBitVector.c' || echo '$(srcdir)/'`CFBitVector.c
+
+libCoreFoundation_debug_la-CFBuiltinConverters.lo: CFBuiltinConverters.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBuiltinConverters.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBuiltinConverters.Tpo -c -o libCoreFoundation_debug_la-CFBuiltinConverters.lo `test -f 'CFBuiltinConverters.c' || echo '$(srcdir)/'`CFBuiltinConverters.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBuiltinConverters.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBuiltinConverters.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBuiltinConverters.c' object='libCoreFoundation_debug_la-CFBuiltinConverters.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBuiltinConverters.lo `test -f 'CFBuiltinConverters.c' || echo '$(srcdir)/'`CFBuiltinConverters.c
+
+libCoreFoundation_debug_la-CFBundle.lo: CFBundle.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBundle.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBundle.Tpo -c -o libCoreFoundation_debug_la-CFBundle.lo `test -f 'CFBundle.c' || echo '$(srcdir)/'`CFBundle.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBundle.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBundle.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBundle.c' object='libCoreFoundation_debug_la-CFBundle.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBundle.lo `test -f 'CFBundle.c' || echo '$(srcdir)/'`CFBundle.c
+
+libCoreFoundation_debug_la-CFBundle_Resources.lo: CFBundle_Resources.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFBundle_Resources.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFBundle_Resources.Tpo -c -o libCoreFoundation_debug_la-CFBundle_Resources.lo `test -f 'CFBundle_Resources.c' || echo '$(srcdir)/'`CFBundle_Resources.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFBundle_Resources.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFBundle_Resources.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBundle_Resources.c' object='libCoreFoundation_debug_la-CFBundle_Resources.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFBundle_Resources.lo `test -f 'CFBundle_Resources.c' || echo '$(srcdir)/'`CFBundle_Resources.c
+
+libCoreFoundation_debug_la-CFCalendar.lo: CFCalendar.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFCalendar.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFCalendar.Tpo -c -o libCoreFoundation_debug_la-CFCalendar.lo `test -f 'CFCalendar.c' || echo '$(srcdir)/'`CFCalendar.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFCalendar.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFCalendar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFCalendar.c' object='libCoreFoundation_debug_la-CFCalendar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFCalendar.lo `test -f 'CFCalendar.c' || echo '$(srcdir)/'`CFCalendar.c
+
+libCoreFoundation_debug_la-CFCharacterSet.lo: CFCharacterSet.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFCharacterSet.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFCharacterSet.Tpo -c -o libCoreFoundation_debug_la-CFCharacterSet.lo `test -f 'CFCharacterSet.c' || echo '$(srcdir)/'`CFCharacterSet.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFCharacterSet.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFCharacterSet.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFCharacterSet.c' object='libCoreFoundation_debug_la-CFCharacterSet.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFCharacterSet.lo `test -f 'CFCharacterSet.c' || echo '$(srcdir)/'`CFCharacterSet.c
+
+libCoreFoundation_debug_la-CFConcreteStreams.lo: CFConcreteStreams.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFConcreteStreams.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFConcreteStreams.Tpo -c -o libCoreFoundation_debug_la-CFConcreteStreams.lo `test -f 'CFConcreteStreams.c' || echo '$(srcdir)/'`CFConcreteStreams.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFConcreteStreams.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFConcreteStreams.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFConcreteStreams.c' object='libCoreFoundation_debug_la-CFConcreteStreams.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFConcreteStreams.lo `test -f 'CFConcreteStreams.c' || echo '$(srcdir)/'`CFConcreteStreams.c
+
+libCoreFoundation_debug_la-CFData.lo: CFData.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFData.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFData.Tpo -c -o libCoreFoundation_debug_la-CFData.lo `test -f 'CFData.c' || echo '$(srcdir)/'`CFData.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFData.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFData.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFData.c' object='libCoreFoundation_debug_la-CFData.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFData.lo `test -f 'CFData.c' || echo '$(srcdir)/'`CFData.c
+
+libCoreFoundation_debug_la-CFDateFormatter.lo: CFDateFormatter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFDateFormatter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFDateFormatter.Tpo -c -o libCoreFoundation_debug_la-CFDateFormatter.lo `test -f 'CFDateFormatter.c' || echo '$(srcdir)/'`CFDateFormatter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFDateFormatter.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFDateFormatter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDateFormatter.c' object='libCoreFoundation_debug_la-CFDateFormatter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFDateFormatter.lo `test -f 'CFDateFormatter.c' || echo '$(srcdir)/'`CFDateFormatter.c
+
+libCoreFoundation_debug_la-CFDate.lo: CFDate.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFDate.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFDate.Tpo -c -o libCoreFoundation_debug_la-CFDate.lo `test -f 'CFDate.c' || echo '$(srcdir)/'`CFDate.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFDate.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFDate.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDate.c' object='libCoreFoundation_debug_la-CFDate.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFDate.lo `test -f 'CFDate.c' || echo '$(srcdir)/'`CFDate.c
+
+libCoreFoundation_debug_la-CFDictionary.lo: CFDictionary.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFDictionary.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFDictionary.Tpo -c -o libCoreFoundation_debug_la-CFDictionary.lo `test -f 'CFDictionary.c' || echo '$(srcdir)/'`CFDictionary.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFDictionary.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFDictionary.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDictionary.c' object='libCoreFoundation_debug_la-CFDictionary.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFDictionary.lo `test -f 'CFDictionary.c' || echo '$(srcdir)/'`CFDictionary.c
+
+libCoreFoundation_debug_la-CFError.lo: CFError.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFError.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFError.Tpo -c -o libCoreFoundation_debug_la-CFError.lo `test -f 'CFError.c' || echo '$(srcdir)/'`CFError.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFError.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFError.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFError.c' object='libCoreFoundation_debug_la-CFError.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFError.lo `test -f 'CFError.c' || echo '$(srcdir)/'`CFError.c
+
+libCoreFoundation_debug_la-CFFileUtilities.lo: CFFileUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFFileUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFFileUtilities.Tpo -c -o libCoreFoundation_debug_la-CFFileUtilities.lo `test -f 'CFFileUtilities.c' || echo '$(srcdir)/'`CFFileUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFFileUtilities.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFFileUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFFileUtilities.c' object='libCoreFoundation_debug_la-CFFileUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFFileUtilities.lo `test -f 'CFFileUtilities.c' || echo '$(srcdir)/'`CFFileUtilities.c
+
+libCoreFoundation_debug_la-CFLocaleIdentifier.lo: CFLocaleIdentifier.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFLocaleIdentifier.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFLocaleIdentifier.Tpo -c -o libCoreFoundation_debug_la-CFLocaleIdentifier.lo `test -f 'CFLocaleIdentifier.c' || echo '$(srcdir)/'`CFLocaleIdentifier.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFLocaleIdentifier.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFLocaleIdentifier.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFLocaleIdentifier.c' object='libCoreFoundation_debug_la-CFLocaleIdentifier.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFLocaleIdentifier.lo `test -f 'CFLocaleIdentifier.c' || echo '$(srcdir)/'`CFLocaleIdentifier.c
+
+libCoreFoundation_debug_la-CFLocale.lo: CFLocale.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFLocale.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFLocale.Tpo -c -o libCoreFoundation_debug_la-CFLocale.lo `test -f 'CFLocale.c' || echo '$(srcdir)/'`CFLocale.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFLocale.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFLocale.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFLocale.c' object='libCoreFoundation_debug_la-CFLocale.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFLocale.lo `test -f 'CFLocale.c' || echo '$(srcdir)/'`CFLocale.c
+
+libCoreFoundation_debug_la-CFMachPort.lo: CFMachPort.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFMachPort.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFMachPort.Tpo -c -o libCoreFoundation_debug_la-CFMachPort.lo `test -f 'CFMachPort.c' || echo '$(srcdir)/'`CFMachPort.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFMachPort.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFMachPort.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFMachPort.c' object='libCoreFoundation_debug_la-CFMachPort.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFMachPort.lo `test -f 'CFMachPort.c' || echo '$(srcdir)/'`CFMachPort.c
+
+libCoreFoundation_debug_la-CFMessagePort.lo: CFMessagePort.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFMessagePort.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFMessagePort.Tpo -c -o libCoreFoundation_debug_la-CFMessagePort.lo `test -f 'CFMessagePort.c' || echo '$(srcdir)/'`CFMessagePort.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFMessagePort.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFMessagePort.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFMessagePort.c' object='libCoreFoundation_debug_la-CFMessagePort.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFMessagePort.lo `test -f 'CFMessagePort.c' || echo '$(srcdir)/'`CFMessagePort.c
+
+libCoreFoundation_debug_la-CFNumberFormatter.lo: CFNumberFormatter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFNumberFormatter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFNumberFormatter.Tpo -c -o libCoreFoundation_debug_la-CFNumberFormatter.lo `test -f 'CFNumberFormatter.c' || echo '$(srcdir)/'`CFNumberFormatter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFNumberFormatter.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFNumberFormatter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFNumberFormatter.c' object='libCoreFoundation_debug_la-CFNumberFormatter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFNumberFormatter.lo `test -f 'CFNumberFormatter.c' || echo '$(srcdir)/'`CFNumberFormatter.c
+
+libCoreFoundation_debug_la-CFNumber.lo: CFNumber.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFNumber.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFNumber.Tpo -c -o libCoreFoundation_debug_la-CFNumber.lo `test -f 'CFNumber.c' || echo '$(srcdir)/'`CFNumber.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFNumber.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFNumber.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFNumber.c' object='libCoreFoundation_debug_la-CFNumber.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFNumber.lo `test -f 'CFNumber.c' || echo '$(srcdir)/'`CFNumber.c
+
+libCoreFoundation_debug_la-CFPlatform.lo: CFPlatform.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFPlatform.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFPlatform.Tpo -c -o libCoreFoundation_debug_la-CFPlatform.lo `test -f 'CFPlatform.c' || echo '$(srcdir)/'`CFPlatform.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFPlatform.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFPlatform.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlatform.c' object='libCoreFoundation_debug_la-CFPlatform.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFPlatform.lo `test -f 'CFPlatform.c' || echo '$(srcdir)/'`CFPlatform.c
+
+libCoreFoundation_debug_la-CFPlugIn_Factory.lo: CFPlugIn_Factory.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFPlugIn_Factory.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Factory.Tpo -c -o libCoreFoundation_debug_la-CFPlugIn_Factory.lo `test -f 'CFPlugIn_Factory.c' || echo '$(srcdir)/'`CFPlugIn_Factory.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Factory.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Factory.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_Factory.c' object='libCoreFoundation_debug_la-CFPlugIn_Factory.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFPlugIn_Factory.lo `test -f 'CFPlugIn_Factory.c' || echo '$(srcdir)/'`CFPlugIn_Factory.c
+
+libCoreFoundation_debug_la-CFPlugIn_Instance.lo: CFPlugIn_Instance.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFPlugIn_Instance.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Instance.Tpo -c -o libCoreFoundation_debug_la-CFPlugIn_Instance.lo `test -f 'CFPlugIn_Instance.c' || echo '$(srcdir)/'`CFPlugIn_Instance.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Instance.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_Instance.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_Instance.c' object='libCoreFoundation_debug_la-CFPlugIn_Instance.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFPlugIn_Instance.lo `test -f 'CFPlugIn_Instance.c' || echo '$(srcdir)/'`CFPlugIn_Instance.c
+
+libCoreFoundation_debug_la-CFPlugIn.lo: CFPlugIn.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFPlugIn.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn.Tpo -c -o libCoreFoundation_debug_la-CFPlugIn.lo `test -f 'CFPlugIn.c' || echo '$(srcdir)/'`CFPlugIn.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn.c' object='libCoreFoundation_debug_la-CFPlugIn.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFPlugIn.lo `test -f 'CFPlugIn.c' || echo '$(srcdir)/'`CFPlugIn.c
+
+libCoreFoundation_debug_la-CFPlugIn_PlugIn.lo: CFPlugIn_PlugIn.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFPlugIn_PlugIn.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_PlugIn.Tpo -c -o libCoreFoundation_debug_la-CFPlugIn_PlugIn.lo `test -f 'CFPlugIn_PlugIn.c' || echo '$(srcdir)/'`CFPlugIn_PlugIn.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_PlugIn.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFPlugIn_PlugIn.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_PlugIn.c' object='libCoreFoundation_debug_la-CFPlugIn_PlugIn.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFPlugIn_PlugIn.lo `test -f 'CFPlugIn_PlugIn.c' || echo '$(srcdir)/'`CFPlugIn_PlugIn.c
+
+libCoreFoundation_debug_la-CFPreferences.lo: CFPreferences.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFPreferences.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFPreferences.Tpo -c -o libCoreFoundation_debug_la-CFPreferences.lo `test -f 'CFPreferences.c' || echo '$(srcdir)/'`CFPreferences.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFPreferences.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFPreferences.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPreferences.c' object='libCoreFoundation_debug_la-CFPreferences.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFPreferences.lo `test -f 'CFPreferences.c' || echo '$(srcdir)/'`CFPreferences.c
+
+libCoreFoundation_debug_la-CFPropertyList.lo: CFPropertyList.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFPropertyList.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFPropertyList.Tpo -c -o libCoreFoundation_debug_la-CFPropertyList.lo `test -f 'CFPropertyList.c' || echo '$(srcdir)/'`CFPropertyList.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFPropertyList.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFPropertyList.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPropertyList.c' object='libCoreFoundation_debug_la-CFPropertyList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFPropertyList.lo `test -f 'CFPropertyList.c' || echo '$(srcdir)/'`CFPropertyList.c
+
+libCoreFoundation_debug_la-CFRunLoop.lo: CFRunLoop.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFRunLoop.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFRunLoop.Tpo -c -o libCoreFoundation_debug_la-CFRunLoop.lo `test -f 'CFRunLoop.c' || echo '$(srcdir)/'`CFRunLoop.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFRunLoop.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFRunLoop.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFRunLoop.c' object='libCoreFoundation_debug_la-CFRunLoop.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFRunLoop.lo `test -f 'CFRunLoop.c' || echo '$(srcdir)/'`CFRunLoop.c
+
+libCoreFoundation_debug_la-CFRuntime.lo: CFRuntime.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFRuntime.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFRuntime.Tpo -c -o libCoreFoundation_debug_la-CFRuntime.lo `test -f 'CFRuntime.c' || echo '$(srcdir)/'`CFRuntime.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFRuntime.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFRuntime.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFRuntime.c' object='libCoreFoundation_debug_la-CFRuntime.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFRuntime.lo `test -f 'CFRuntime.c' || echo '$(srcdir)/'`CFRuntime.c
+
+libCoreFoundation_debug_la-CFSet.lo: CFSet.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFSet.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFSet.Tpo -c -o libCoreFoundation_debug_la-CFSet.lo `test -f 'CFSet.c' || echo '$(srcdir)/'`CFSet.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFSet.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFSet.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSet.c' object='libCoreFoundation_debug_la-CFSet.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFSet.lo `test -f 'CFSet.c' || echo '$(srcdir)/'`CFSet.c
+
+libCoreFoundation_debug_la-CFSocket.lo: CFSocket.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFSocket.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFSocket.Tpo -c -o libCoreFoundation_debug_la-CFSocket.lo `test -f 'CFSocket.c' || echo '$(srcdir)/'`CFSocket.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFSocket.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFSocket.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSocket.c' object='libCoreFoundation_debug_la-CFSocket.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFSocket.lo `test -f 'CFSocket.c' || echo '$(srcdir)/'`CFSocket.c
+
+libCoreFoundation_debug_la-CFSocketStream.lo: CFSocketStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFSocketStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFSocketStream.Tpo -c -o libCoreFoundation_debug_la-CFSocketStream.lo `test -f 'CFSocketStream.c' || echo '$(srcdir)/'`CFSocketStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFSocketStream.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFSocketStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSocketStream.c' object='libCoreFoundation_debug_la-CFSocketStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFSocketStream.lo `test -f 'CFSocketStream.c' || echo '$(srcdir)/'`CFSocketStream.c
+
+libCoreFoundation_debug_la-CFSortFunctions.lo: CFSortFunctions.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFSortFunctions.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFSortFunctions.Tpo -c -o libCoreFoundation_debug_la-CFSortFunctions.lo `test -f 'CFSortFunctions.c' || echo '$(srcdir)/'`CFSortFunctions.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFSortFunctions.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFSortFunctions.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSortFunctions.c' object='libCoreFoundation_debug_la-CFSortFunctions.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFSortFunctions.lo `test -f 'CFSortFunctions.c' || echo '$(srcdir)/'`CFSortFunctions.c
+
+libCoreFoundation_debug_la-CFStorage.lo: CFStorage.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFStorage.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFStorage.Tpo -c -o libCoreFoundation_debug_la-CFStorage.lo `test -f 'CFStorage.c' || echo '$(srcdir)/'`CFStorage.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFStorage.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFStorage.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStorage.c' object='libCoreFoundation_debug_la-CFStorage.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFStorage.lo `test -f 'CFStorage.c' || echo '$(srcdir)/'`CFStorage.c
+
+libCoreFoundation_debug_la-CFStream.lo: CFStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFStream.Tpo -c -o libCoreFoundation_debug_la-CFStream.lo `test -f 'CFStream.c' || echo '$(srcdir)/'`CFStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFStream.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStream.c' object='libCoreFoundation_debug_la-CFStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFStream.lo `test -f 'CFStream.c' || echo '$(srcdir)/'`CFStream.c
+
+libCoreFoundation_debug_la-CFStringEncodingConverter.lo: CFStringEncodingConverter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFStringEncodingConverter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodingConverter.Tpo -c -o libCoreFoundation_debug_la-CFStringEncodingConverter.lo `test -f 'CFStringEncodingConverter.c' || echo '$(srcdir)/'`CFStringEncodingConverter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodingConverter.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodingConverter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringEncodingConverter.c' object='libCoreFoundation_debug_la-CFStringEncodingConverter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFStringEncodingConverter.lo `test -f 'CFStringEncodingConverter.c' || echo '$(srcdir)/'`CFStringEncodingConverter.c
+
+libCoreFoundation_debug_la-CFStringEncodings.lo: CFStringEncodings.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFStringEncodings.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodings.Tpo -c -o libCoreFoundation_debug_la-CFStringEncodings.lo `test -f 'CFStringEncodings.c' || echo '$(srcdir)/'`CFStringEncodings.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodings.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFStringEncodings.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringEncodings.c' object='libCoreFoundation_debug_la-CFStringEncodings.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFStringEncodings.lo `test -f 'CFStringEncodings.c' || echo '$(srcdir)/'`CFStringEncodings.c
+
+libCoreFoundation_debug_la-CFString.lo: CFString.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFString.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFString.Tpo -c -o libCoreFoundation_debug_la-CFString.lo `test -f 'CFString.c' || echo '$(srcdir)/'`CFString.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFString.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFString.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFString.c' object='libCoreFoundation_debug_la-CFString.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFString.lo `test -f 'CFString.c' || echo '$(srcdir)/'`CFString.c
+
+libCoreFoundation_debug_la-CFStringScanner.lo: CFStringScanner.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFStringScanner.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFStringScanner.Tpo -c -o libCoreFoundation_debug_la-CFStringScanner.lo `test -f 'CFStringScanner.c' || echo '$(srcdir)/'`CFStringScanner.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFStringScanner.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFStringScanner.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringScanner.c' object='libCoreFoundation_debug_la-CFStringScanner.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFStringScanner.lo `test -f 'CFStringScanner.c' || echo '$(srcdir)/'`CFStringScanner.c
+
+libCoreFoundation_debug_la-CFStringUtilities.lo: CFStringUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFStringUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFStringUtilities.Tpo -c -o libCoreFoundation_debug_la-CFStringUtilities.lo `test -f 'CFStringUtilities.c' || echo '$(srcdir)/'`CFStringUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFStringUtilities.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFStringUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringUtilities.c' object='libCoreFoundation_debug_la-CFStringUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFStringUtilities.lo `test -f 'CFStringUtilities.c' || echo '$(srcdir)/'`CFStringUtilities.c
+
+libCoreFoundation_debug_la-CFSystemDirectories.lo: CFSystemDirectories.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFSystemDirectories.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFSystemDirectories.Tpo -c -o libCoreFoundation_debug_la-CFSystemDirectories.lo `test -f 'CFSystemDirectories.c' || echo '$(srcdir)/'`CFSystemDirectories.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFSystemDirectories.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFSystemDirectories.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSystemDirectories.c' object='libCoreFoundation_debug_la-CFSystemDirectories.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFSystemDirectories.lo `test -f 'CFSystemDirectories.c' || echo '$(srcdir)/'`CFSystemDirectories.c
+
+libCoreFoundation_debug_la-CFTimeZone.lo: CFTimeZone.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFTimeZone.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFTimeZone.Tpo -c -o libCoreFoundation_debug_la-CFTimeZone.lo `test -f 'CFTimeZone.c' || echo '$(srcdir)/'`CFTimeZone.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFTimeZone.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFTimeZone.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFTimeZone.c' object='libCoreFoundation_debug_la-CFTimeZone.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFTimeZone.lo `test -f 'CFTimeZone.c' || echo '$(srcdir)/'`CFTimeZone.c
+
+libCoreFoundation_debug_la-CFTree.lo: CFTree.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFTree.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFTree.Tpo -c -o libCoreFoundation_debug_la-CFTree.lo `test -f 'CFTree.c' || echo '$(srcdir)/'`CFTree.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFTree.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFTree.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFTree.c' object='libCoreFoundation_debug_la-CFTree.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFTree.lo `test -f 'CFTree.c' || echo '$(srcdir)/'`CFTree.c
+
+libCoreFoundation_debug_la-CFURL.lo: CFURL.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFURL.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFURL.Tpo -c -o libCoreFoundation_debug_la-CFURL.lo `test -f 'CFURL.c' || echo '$(srcdir)/'`CFURL.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFURL.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFURL.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFURL.c' object='libCoreFoundation_debug_la-CFURL.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFURL.lo `test -f 'CFURL.c' || echo '$(srcdir)/'`CFURL.c
+
+libCoreFoundation_debug_la-CFURLAccess.lo: CFURLAccess.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFURLAccess.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFURLAccess.Tpo -c -o libCoreFoundation_debug_la-CFURLAccess.lo `test -f 'CFURLAccess.c' || echo '$(srcdir)/'`CFURLAccess.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFURLAccess.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFURLAccess.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFURLAccess.c' object='libCoreFoundation_debug_la-CFURLAccess.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFURLAccess.lo `test -f 'CFURLAccess.c' || echo '$(srcdir)/'`CFURLAccess.c
+
+libCoreFoundation_debug_la-CFUUID.lo: CFUUID.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFUUID.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFUUID.Tpo -c -o libCoreFoundation_debug_la-CFUUID.lo `test -f 'CFUUID.c' || echo '$(srcdir)/'`CFUUID.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFUUID.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFUUID.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUUID.c' object='libCoreFoundation_debug_la-CFUUID.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFUUID.lo `test -f 'CFUUID.c' || echo '$(srcdir)/'`CFUUID.c
+
+libCoreFoundation_debug_la-CFUniChar.lo: CFUniChar.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFUniChar.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFUniChar.Tpo -c -o libCoreFoundation_debug_la-CFUniChar.lo `test -f 'CFUniChar.c' || echo '$(srcdir)/'`CFUniChar.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFUniChar.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFUniChar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUniChar.c' object='libCoreFoundation_debug_la-CFUniChar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFUniChar.lo `test -f 'CFUniChar.c' || echo '$(srcdir)/'`CFUniChar.c
+
+libCoreFoundation_debug_la-CFUnicodeDecomposition.lo: CFUnicodeDecomposition.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFUnicodeDecomposition.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFUnicodeDecomposition.Tpo -c -o libCoreFoundation_debug_la-CFUnicodeDecomposition.lo `test -f 'CFUnicodeDecomposition.c' || echo '$(srcdir)/'`CFUnicodeDecomposition.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFUnicodeDecomposition.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFUnicodeDecomposition.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUnicodeDecomposition.c' object='libCoreFoundation_debug_la-CFUnicodeDecomposition.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFUnicodeDecomposition.lo `test -f 'CFUnicodeDecomposition.c' || echo '$(srcdir)/'`CFUnicodeDecomposition.c
+
+libCoreFoundation_debug_la-CFUnicodePrecomposition.lo: CFUnicodePrecomposition.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFUnicodePrecomposition.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFUnicodePrecomposition.Tpo -c -o libCoreFoundation_debug_la-CFUnicodePrecomposition.lo `test -f 'CFUnicodePrecomposition.c' || echo '$(srcdir)/'`CFUnicodePrecomposition.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFUnicodePrecomposition.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFUnicodePrecomposition.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUnicodePrecomposition.c' object='libCoreFoundation_debug_la-CFUnicodePrecomposition.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFUnicodePrecomposition.lo `test -f 'CFUnicodePrecomposition.c' || echo '$(srcdir)/'`CFUnicodePrecomposition.c
+
+libCoreFoundation_debug_la-CFUserNotification.lo: CFUserNotification.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFUserNotification.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFUserNotification.Tpo -c -o libCoreFoundation_debug_la-CFUserNotification.lo `test -f 'CFUserNotification.c' || echo '$(srcdir)/'`CFUserNotification.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFUserNotification.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFUserNotification.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUserNotification.c' object='libCoreFoundation_debug_la-CFUserNotification.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFUserNotification.lo `test -f 'CFUserNotification.c' || echo '$(srcdir)/'`CFUserNotification.c
+
+libCoreFoundation_debug_la-CFUtilities.lo: CFUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFUtilities.Tpo -c -o libCoreFoundation_debug_la-CFUtilities.lo `test -f 'CFUtilities.c' || echo '$(srcdir)/'`CFUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFUtilities.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUtilities.c' object='libCoreFoundation_debug_la-CFUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFUtilities.lo `test -f 'CFUtilities.c' || echo '$(srcdir)/'`CFUtilities.c
+
+libCoreFoundation_debug_la-CFVersion.lo: CFVersion.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFVersion.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFVersion.Tpo -c -o libCoreFoundation_debug_la-CFVersion.lo `test -f 'CFVersion.c' || echo '$(srcdir)/'`CFVersion.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFVersion.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFVersion.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFVersion.c' object='libCoreFoundation_debug_la-CFVersion.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFVersion.lo `test -f 'CFVersion.c' || echo '$(srcdir)/'`CFVersion.c
+
+libCoreFoundation_debug_la-CFWindowsMessageQueue.lo: CFWindowsMessageQueue.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFWindowsMessageQueue.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFWindowsMessageQueue.Tpo -c -o libCoreFoundation_debug_la-CFWindowsMessageQueue.lo `test -f 'CFWindowsMessageQueue.c' || echo '$(srcdir)/'`CFWindowsMessageQueue.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFWindowsMessageQueue.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFWindowsMessageQueue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFWindowsMessageQueue.c' object='libCoreFoundation_debug_la-CFWindowsMessageQueue.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFWindowsMessageQueue.lo `test -f 'CFWindowsMessageQueue.c' || echo '$(srcdir)/'`CFWindowsMessageQueue.c
+
+libCoreFoundation_debug_la-CFXMLInputStream.lo: CFXMLInputStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFXMLInputStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFXMLInputStream.Tpo -c -o libCoreFoundation_debug_la-CFXMLInputStream.lo `test -f 'CFXMLInputStream.c' || echo '$(srcdir)/'`CFXMLInputStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFXMLInputStream.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFXMLInputStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLInputStream.c' object='libCoreFoundation_debug_la-CFXMLInputStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFXMLInputStream.lo `test -f 'CFXMLInputStream.c' || echo '$(srcdir)/'`CFXMLInputStream.c
+
+libCoreFoundation_debug_la-CFXMLNode.lo: CFXMLNode.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFXMLNode.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFXMLNode.Tpo -c -o libCoreFoundation_debug_la-CFXMLNode.lo `test -f 'CFXMLNode.c' || echo '$(srcdir)/'`CFXMLNode.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFXMLNode.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFXMLNode.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLNode.c' object='libCoreFoundation_debug_la-CFXMLNode.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFXMLNode.lo `test -f 'CFXMLNode.c' || echo '$(srcdir)/'`CFXMLNode.c
+
+libCoreFoundation_debug_la-CFXMLParser.lo: CFXMLParser.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFXMLParser.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFXMLParser.Tpo -c -o libCoreFoundation_debug_la-CFXMLParser.lo `test -f 'CFXMLParser.c' || echo '$(srcdir)/'`CFXMLParser.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFXMLParser.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFXMLParser.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLParser.c' object='libCoreFoundation_debug_la-CFXMLParser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFXMLParser.lo `test -f 'CFXMLParser.c' || echo '$(srcdir)/'`CFXMLParser.c
+
+libCoreFoundation_debug_la-CFXMLPreferencesDomain.lo: CFXMLPreferencesDomain.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFXMLPreferencesDomain.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFXMLPreferencesDomain.Tpo -c -o libCoreFoundation_debug_la-CFXMLPreferencesDomain.lo `test -f 'CFXMLPreferencesDomain.c' || echo '$(srcdir)/'`CFXMLPreferencesDomain.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFXMLPreferencesDomain.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFXMLPreferencesDomain.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLPreferencesDomain.c' object='libCoreFoundation_debug_la-CFXMLPreferencesDomain.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFXMLPreferencesDomain.lo `test -f 'CFXMLPreferencesDomain.c' || echo '$(srcdir)/'`CFXMLPreferencesDomain.c
+
+libCoreFoundation_debug_la-CFXMLTree.lo: CFXMLTree.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_debug_la-CFXMLTree.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_debug_la-CFXMLTree.Tpo -c -o libCoreFoundation_debug_la-CFXMLTree.lo `test -f 'CFXMLTree.c' || echo '$(srcdir)/'`CFXMLTree.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_debug_la-CFXMLTree.Tpo $(DEPDIR)/libCoreFoundation_debug_la-CFXMLTree.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLTree.c' object='libCoreFoundation_debug_la-CFXMLTree.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_debug_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_debug_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_debug_la-CFXMLTree.lo `test -f 'CFXMLTree.c' || echo '$(srcdir)/'`CFXMLTree.c
+
+libCoreFoundation_profile_la-CFApplicationPreferences.lo: CFApplicationPreferences.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFApplicationPreferences.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFApplicationPreferences.Tpo -c -o libCoreFoundation_profile_la-CFApplicationPreferences.lo `test -f 'CFApplicationPreferences.c' || echo '$(srcdir)/'`CFApplicationPreferences.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFApplicationPreferences.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFApplicationPreferences.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFApplicationPreferences.c' object='libCoreFoundation_profile_la-CFApplicationPreferences.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFApplicationPreferences.lo `test -f 'CFApplicationPreferences.c' || echo '$(srcdir)/'`CFApplicationPreferences.c
+
+libCoreFoundation_profile_la-CFArray.lo: CFArray.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFArray.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFArray.Tpo -c -o libCoreFoundation_profile_la-CFArray.lo `test -f 'CFArray.c' || echo '$(srcdir)/'`CFArray.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFArray.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFArray.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFArray.c' object='libCoreFoundation_profile_la-CFArray.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFArray.lo `test -f 'CFArray.c' || echo '$(srcdir)/'`CFArray.c
+
+libCoreFoundation_profile_la-CFBag.lo: CFBag.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBag.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBag.Tpo -c -o libCoreFoundation_profile_la-CFBag.lo `test -f 'CFBag.c' || echo '$(srcdir)/'`CFBag.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBag.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBag.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBag.c' object='libCoreFoundation_profile_la-CFBag.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBag.lo `test -f 'CFBag.c' || echo '$(srcdir)/'`CFBag.c
+
+libCoreFoundation_profile_la-CFBase.lo: CFBase.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBase.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBase.Tpo -c -o libCoreFoundation_profile_la-CFBase.lo `test -f 'CFBase.c' || echo '$(srcdir)/'`CFBase.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBase.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBase.c' object='libCoreFoundation_profile_la-CFBase.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBase.lo `test -f 'CFBase.c' || echo '$(srcdir)/'`CFBase.c
+
+libCoreFoundation_profile_la-CFBinaryHeap.lo: CFBinaryHeap.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBinaryHeap.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBinaryHeap.Tpo -c -o libCoreFoundation_profile_la-CFBinaryHeap.lo `test -f 'CFBinaryHeap.c' || echo '$(srcdir)/'`CFBinaryHeap.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBinaryHeap.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBinaryHeap.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBinaryHeap.c' object='libCoreFoundation_profile_la-CFBinaryHeap.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBinaryHeap.lo `test -f 'CFBinaryHeap.c' || echo '$(srcdir)/'`CFBinaryHeap.c
+
+libCoreFoundation_profile_la-CFBinaryPList.lo: CFBinaryPList.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBinaryPList.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBinaryPList.Tpo -c -o libCoreFoundation_profile_la-CFBinaryPList.lo `test -f 'CFBinaryPList.c' || echo '$(srcdir)/'`CFBinaryPList.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBinaryPList.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBinaryPList.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBinaryPList.c' object='libCoreFoundation_profile_la-CFBinaryPList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBinaryPList.lo `test -f 'CFBinaryPList.c' || echo '$(srcdir)/'`CFBinaryPList.c
+
+libCoreFoundation_profile_la-CFBitVector.lo: CFBitVector.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBitVector.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBitVector.Tpo -c -o libCoreFoundation_profile_la-CFBitVector.lo `test -f 'CFBitVector.c' || echo '$(srcdir)/'`CFBitVector.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBitVector.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBitVector.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBitVector.c' object='libCoreFoundation_profile_la-CFBitVector.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBitVector.lo `test -f 'CFBitVector.c' || echo '$(srcdir)/'`CFBitVector.c
+
+libCoreFoundation_profile_la-CFBuiltinConverters.lo: CFBuiltinConverters.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBuiltinConverters.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBuiltinConverters.Tpo -c -o libCoreFoundation_profile_la-CFBuiltinConverters.lo `test -f 'CFBuiltinConverters.c' || echo '$(srcdir)/'`CFBuiltinConverters.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBuiltinConverters.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBuiltinConverters.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBuiltinConverters.c' object='libCoreFoundation_profile_la-CFBuiltinConverters.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBuiltinConverters.lo `test -f 'CFBuiltinConverters.c' || echo '$(srcdir)/'`CFBuiltinConverters.c
+
+libCoreFoundation_profile_la-CFBundle.lo: CFBundle.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBundle.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBundle.Tpo -c -o libCoreFoundation_profile_la-CFBundle.lo `test -f 'CFBundle.c' || echo '$(srcdir)/'`CFBundle.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBundle.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBundle.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBundle.c' object='libCoreFoundation_profile_la-CFBundle.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBundle.lo `test -f 'CFBundle.c' || echo '$(srcdir)/'`CFBundle.c
+
+libCoreFoundation_profile_la-CFBundle_Resources.lo: CFBundle_Resources.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFBundle_Resources.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFBundle_Resources.Tpo -c -o libCoreFoundation_profile_la-CFBundle_Resources.lo `test -f 'CFBundle_Resources.c' || echo '$(srcdir)/'`CFBundle_Resources.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFBundle_Resources.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFBundle_Resources.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFBundle_Resources.c' object='libCoreFoundation_profile_la-CFBundle_Resources.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFBundle_Resources.lo `test -f 'CFBundle_Resources.c' || echo '$(srcdir)/'`CFBundle_Resources.c
+
+libCoreFoundation_profile_la-CFCalendar.lo: CFCalendar.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFCalendar.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFCalendar.Tpo -c -o libCoreFoundation_profile_la-CFCalendar.lo `test -f 'CFCalendar.c' || echo '$(srcdir)/'`CFCalendar.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFCalendar.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFCalendar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFCalendar.c' object='libCoreFoundation_profile_la-CFCalendar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFCalendar.lo `test -f 'CFCalendar.c' || echo '$(srcdir)/'`CFCalendar.c
+
+libCoreFoundation_profile_la-CFCharacterSet.lo: CFCharacterSet.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFCharacterSet.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFCharacterSet.Tpo -c -o libCoreFoundation_profile_la-CFCharacterSet.lo `test -f 'CFCharacterSet.c' || echo '$(srcdir)/'`CFCharacterSet.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFCharacterSet.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFCharacterSet.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFCharacterSet.c' object='libCoreFoundation_profile_la-CFCharacterSet.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFCharacterSet.lo `test -f 'CFCharacterSet.c' || echo '$(srcdir)/'`CFCharacterSet.c
+
+libCoreFoundation_profile_la-CFConcreteStreams.lo: CFConcreteStreams.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFConcreteStreams.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFConcreteStreams.Tpo -c -o libCoreFoundation_profile_la-CFConcreteStreams.lo `test -f 'CFConcreteStreams.c' || echo '$(srcdir)/'`CFConcreteStreams.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFConcreteStreams.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFConcreteStreams.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFConcreteStreams.c' object='libCoreFoundation_profile_la-CFConcreteStreams.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFConcreteStreams.lo `test -f 'CFConcreteStreams.c' || echo '$(srcdir)/'`CFConcreteStreams.c
+
+libCoreFoundation_profile_la-CFData.lo: CFData.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFData.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFData.Tpo -c -o libCoreFoundation_profile_la-CFData.lo `test -f 'CFData.c' || echo '$(srcdir)/'`CFData.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFData.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFData.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFData.c' object='libCoreFoundation_profile_la-CFData.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFData.lo `test -f 'CFData.c' || echo '$(srcdir)/'`CFData.c
+
+libCoreFoundation_profile_la-CFDateFormatter.lo: CFDateFormatter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFDateFormatter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFDateFormatter.Tpo -c -o libCoreFoundation_profile_la-CFDateFormatter.lo `test -f 'CFDateFormatter.c' || echo '$(srcdir)/'`CFDateFormatter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFDateFormatter.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFDateFormatter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDateFormatter.c' object='libCoreFoundation_profile_la-CFDateFormatter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFDateFormatter.lo `test -f 'CFDateFormatter.c' || echo '$(srcdir)/'`CFDateFormatter.c
+
+libCoreFoundation_profile_la-CFDate.lo: CFDate.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFDate.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFDate.Tpo -c -o libCoreFoundation_profile_la-CFDate.lo `test -f 'CFDate.c' || echo '$(srcdir)/'`CFDate.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFDate.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFDate.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDate.c' object='libCoreFoundation_profile_la-CFDate.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFDate.lo `test -f 'CFDate.c' || echo '$(srcdir)/'`CFDate.c
+
+libCoreFoundation_profile_la-CFDictionary.lo: CFDictionary.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFDictionary.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFDictionary.Tpo -c -o libCoreFoundation_profile_la-CFDictionary.lo `test -f 'CFDictionary.c' || echo '$(srcdir)/'`CFDictionary.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFDictionary.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFDictionary.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFDictionary.c' object='libCoreFoundation_profile_la-CFDictionary.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFDictionary.lo `test -f 'CFDictionary.c' || echo '$(srcdir)/'`CFDictionary.c
+
+libCoreFoundation_profile_la-CFError.lo: CFError.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFError.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFError.Tpo -c -o libCoreFoundation_profile_la-CFError.lo `test -f 'CFError.c' || echo '$(srcdir)/'`CFError.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFError.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFError.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFError.c' object='libCoreFoundation_profile_la-CFError.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFError.lo `test -f 'CFError.c' || echo '$(srcdir)/'`CFError.c
+
+libCoreFoundation_profile_la-CFFileUtilities.lo: CFFileUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFFileUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFFileUtilities.Tpo -c -o libCoreFoundation_profile_la-CFFileUtilities.lo `test -f 'CFFileUtilities.c' || echo '$(srcdir)/'`CFFileUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFFileUtilities.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFFileUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFFileUtilities.c' object='libCoreFoundation_profile_la-CFFileUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFFileUtilities.lo `test -f 'CFFileUtilities.c' || echo '$(srcdir)/'`CFFileUtilities.c
+
+libCoreFoundation_profile_la-CFLocaleIdentifier.lo: CFLocaleIdentifier.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFLocaleIdentifier.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFLocaleIdentifier.Tpo -c -o libCoreFoundation_profile_la-CFLocaleIdentifier.lo `test -f 'CFLocaleIdentifier.c' || echo '$(srcdir)/'`CFLocaleIdentifier.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFLocaleIdentifier.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFLocaleIdentifier.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFLocaleIdentifier.c' object='libCoreFoundation_profile_la-CFLocaleIdentifier.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFLocaleIdentifier.lo `test -f 'CFLocaleIdentifier.c' || echo '$(srcdir)/'`CFLocaleIdentifier.c
+
+libCoreFoundation_profile_la-CFLocale.lo: CFLocale.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFLocale.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFLocale.Tpo -c -o libCoreFoundation_profile_la-CFLocale.lo `test -f 'CFLocale.c' || echo '$(srcdir)/'`CFLocale.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFLocale.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFLocale.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFLocale.c' object='libCoreFoundation_profile_la-CFLocale.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFLocale.lo `test -f 'CFLocale.c' || echo '$(srcdir)/'`CFLocale.c
+
+libCoreFoundation_profile_la-CFMachPort.lo: CFMachPort.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFMachPort.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFMachPort.Tpo -c -o libCoreFoundation_profile_la-CFMachPort.lo `test -f 'CFMachPort.c' || echo '$(srcdir)/'`CFMachPort.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFMachPort.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFMachPort.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFMachPort.c' object='libCoreFoundation_profile_la-CFMachPort.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFMachPort.lo `test -f 'CFMachPort.c' || echo '$(srcdir)/'`CFMachPort.c
+
+libCoreFoundation_profile_la-CFMessagePort.lo: CFMessagePort.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFMessagePort.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFMessagePort.Tpo -c -o libCoreFoundation_profile_la-CFMessagePort.lo `test -f 'CFMessagePort.c' || echo '$(srcdir)/'`CFMessagePort.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFMessagePort.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFMessagePort.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFMessagePort.c' object='libCoreFoundation_profile_la-CFMessagePort.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFMessagePort.lo `test -f 'CFMessagePort.c' || echo '$(srcdir)/'`CFMessagePort.c
+
+libCoreFoundation_profile_la-CFNumberFormatter.lo: CFNumberFormatter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFNumberFormatter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFNumberFormatter.Tpo -c -o libCoreFoundation_profile_la-CFNumberFormatter.lo `test -f 'CFNumberFormatter.c' || echo '$(srcdir)/'`CFNumberFormatter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFNumberFormatter.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFNumberFormatter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFNumberFormatter.c' object='libCoreFoundation_profile_la-CFNumberFormatter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFNumberFormatter.lo `test -f 'CFNumberFormatter.c' || echo '$(srcdir)/'`CFNumberFormatter.c
+
+libCoreFoundation_profile_la-CFNumber.lo: CFNumber.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFNumber.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFNumber.Tpo -c -o libCoreFoundation_profile_la-CFNumber.lo `test -f 'CFNumber.c' || echo '$(srcdir)/'`CFNumber.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFNumber.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFNumber.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFNumber.c' object='libCoreFoundation_profile_la-CFNumber.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFNumber.lo `test -f 'CFNumber.c' || echo '$(srcdir)/'`CFNumber.c
+
+libCoreFoundation_profile_la-CFPlatform.lo: CFPlatform.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFPlatform.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFPlatform.Tpo -c -o libCoreFoundation_profile_la-CFPlatform.lo `test -f 'CFPlatform.c' || echo '$(srcdir)/'`CFPlatform.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFPlatform.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFPlatform.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlatform.c' object='libCoreFoundation_profile_la-CFPlatform.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFPlatform.lo `test -f 'CFPlatform.c' || echo '$(srcdir)/'`CFPlatform.c
+
+libCoreFoundation_profile_la-CFPlugIn_Factory.lo: CFPlugIn_Factory.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFPlugIn_Factory.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Factory.Tpo -c -o libCoreFoundation_profile_la-CFPlugIn_Factory.lo `test -f 'CFPlugIn_Factory.c' || echo '$(srcdir)/'`CFPlugIn_Factory.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Factory.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Factory.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_Factory.c' object='libCoreFoundation_profile_la-CFPlugIn_Factory.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFPlugIn_Factory.lo `test -f 'CFPlugIn_Factory.c' || echo '$(srcdir)/'`CFPlugIn_Factory.c
+
+libCoreFoundation_profile_la-CFPlugIn_Instance.lo: CFPlugIn_Instance.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFPlugIn_Instance.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Instance.Tpo -c -o libCoreFoundation_profile_la-CFPlugIn_Instance.lo `test -f 'CFPlugIn_Instance.c' || echo '$(srcdir)/'`CFPlugIn_Instance.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Instance.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_Instance.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_Instance.c' object='libCoreFoundation_profile_la-CFPlugIn_Instance.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFPlugIn_Instance.lo `test -f 'CFPlugIn_Instance.c' || echo '$(srcdir)/'`CFPlugIn_Instance.c
+
+libCoreFoundation_profile_la-CFPlugIn.lo: CFPlugIn.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFPlugIn.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn.Tpo -c -o libCoreFoundation_profile_la-CFPlugIn.lo `test -f 'CFPlugIn.c' || echo '$(srcdir)/'`CFPlugIn.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn.c' object='libCoreFoundation_profile_la-CFPlugIn.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFPlugIn.lo `test -f 'CFPlugIn.c' || echo '$(srcdir)/'`CFPlugIn.c
+
+libCoreFoundation_profile_la-CFPlugIn_PlugIn.lo: CFPlugIn_PlugIn.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFPlugIn_PlugIn.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_PlugIn.Tpo -c -o libCoreFoundation_profile_la-CFPlugIn_PlugIn.lo `test -f 'CFPlugIn_PlugIn.c' || echo '$(srcdir)/'`CFPlugIn_PlugIn.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_PlugIn.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFPlugIn_PlugIn.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPlugIn_PlugIn.c' object='libCoreFoundation_profile_la-CFPlugIn_PlugIn.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFPlugIn_PlugIn.lo `test -f 'CFPlugIn_PlugIn.c' || echo '$(srcdir)/'`CFPlugIn_PlugIn.c
+
+libCoreFoundation_profile_la-CFPreferences.lo: CFPreferences.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFPreferences.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFPreferences.Tpo -c -o libCoreFoundation_profile_la-CFPreferences.lo `test -f 'CFPreferences.c' || echo '$(srcdir)/'`CFPreferences.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFPreferences.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFPreferences.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPreferences.c' object='libCoreFoundation_profile_la-CFPreferences.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFPreferences.lo `test -f 'CFPreferences.c' || echo '$(srcdir)/'`CFPreferences.c
+
+libCoreFoundation_profile_la-CFPropertyList.lo: CFPropertyList.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFPropertyList.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFPropertyList.Tpo -c -o libCoreFoundation_profile_la-CFPropertyList.lo `test -f 'CFPropertyList.c' || echo '$(srcdir)/'`CFPropertyList.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFPropertyList.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFPropertyList.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFPropertyList.c' object='libCoreFoundation_profile_la-CFPropertyList.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFPropertyList.lo `test -f 'CFPropertyList.c' || echo '$(srcdir)/'`CFPropertyList.c
+
+libCoreFoundation_profile_la-CFRunLoop.lo: CFRunLoop.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFRunLoop.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFRunLoop.Tpo -c -o libCoreFoundation_profile_la-CFRunLoop.lo `test -f 'CFRunLoop.c' || echo '$(srcdir)/'`CFRunLoop.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFRunLoop.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFRunLoop.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFRunLoop.c' object='libCoreFoundation_profile_la-CFRunLoop.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFRunLoop.lo `test -f 'CFRunLoop.c' || echo '$(srcdir)/'`CFRunLoop.c
+
+libCoreFoundation_profile_la-CFRuntime.lo: CFRuntime.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFRuntime.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFRuntime.Tpo -c -o libCoreFoundation_profile_la-CFRuntime.lo `test -f 'CFRuntime.c' || echo '$(srcdir)/'`CFRuntime.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFRuntime.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFRuntime.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFRuntime.c' object='libCoreFoundation_profile_la-CFRuntime.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFRuntime.lo `test -f 'CFRuntime.c' || echo '$(srcdir)/'`CFRuntime.c
+
+libCoreFoundation_profile_la-CFSet.lo: CFSet.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFSet.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFSet.Tpo -c -o libCoreFoundation_profile_la-CFSet.lo `test -f 'CFSet.c' || echo '$(srcdir)/'`CFSet.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFSet.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFSet.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSet.c' object='libCoreFoundation_profile_la-CFSet.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFSet.lo `test -f 'CFSet.c' || echo '$(srcdir)/'`CFSet.c
+
+libCoreFoundation_profile_la-CFSocket.lo: CFSocket.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFSocket.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFSocket.Tpo -c -o libCoreFoundation_profile_la-CFSocket.lo `test -f 'CFSocket.c' || echo '$(srcdir)/'`CFSocket.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFSocket.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFSocket.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSocket.c' object='libCoreFoundation_profile_la-CFSocket.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFSocket.lo `test -f 'CFSocket.c' || echo '$(srcdir)/'`CFSocket.c
+
+libCoreFoundation_profile_la-CFSocketStream.lo: CFSocketStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFSocketStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFSocketStream.Tpo -c -o libCoreFoundation_profile_la-CFSocketStream.lo `test -f 'CFSocketStream.c' || echo '$(srcdir)/'`CFSocketStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFSocketStream.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFSocketStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSocketStream.c' object='libCoreFoundation_profile_la-CFSocketStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFSocketStream.lo `test -f 'CFSocketStream.c' || echo '$(srcdir)/'`CFSocketStream.c
+
+libCoreFoundation_profile_la-CFSortFunctions.lo: CFSortFunctions.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFSortFunctions.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFSortFunctions.Tpo -c -o libCoreFoundation_profile_la-CFSortFunctions.lo `test -f 'CFSortFunctions.c' || echo '$(srcdir)/'`CFSortFunctions.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFSortFunctions.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFSortFunctions.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSortFunctions.c' object='libCoreFoundation_profile_la-CFSortFunctions.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFSortFunctions.lo `test -f 'CFSortFunctions.c' || echo '$(srcdir)/'`CFSortFunctions.c
+
+libCoreFoundation_profile_la-CFStorage.lo: CFStorage.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFStorage.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFStorage.Tpo -c -o libCoreFoundation_profile_la-CFStorage.lo `test -f 'CFStorage.c' || echo '$(srcdir)/'`CFStorage.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFStorage.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFStorage.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStorage.c' object='libCoreFoundation_profile_la-CFStorage.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFStorage.lo `test -f 'CFStorage.c' || echo '$(srcdir)/'`CFStorage.c
+
+libCoreFoundation_profile_la-CFStream.lo: CFStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFStream.Tpo -c -o libCoreFoundation_profile_la-CFStream.lo `test -f 'CFStream.c' || echo '$(srcdir)/'`CFStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFStream.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStream.c' object='libCoreFoundation_profile_la-CFStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFStream.lo `test -f 'CFStream.c' || echo '$(srcdir)/'`CFStream.c
+
+libCoreFoundation_profile_la-CFStringEncodingConverter.lo: CFStringEncodingConverter.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFStringEncodingConverter.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodingConverter.Tpo -c -o libCoreFoundation_profile_la-CFStringEncodingConverter.lo `test -f 'CFStringEncodingConverter.c' || echo '$(srcdir)/'`CFStringEncodingConverter.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodingConverter.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodingConverter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringEncodingConverter.c' object='libCoreFoundation_profile_la-CFStringEncodingConverter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFStringEncodingConverter.lo `test -f 'CFStringEncodingConverter.c' || echo '$(srcdir)/'`CFStringEncodingConverter.c
+
+libCoreFoundation_profile_la-CFStringEncodings.lo: CFStringEncodings.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFStringEncodings.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodings.Tpo -c -o libCoreFoundation_profile_la-CFStringEncodings.lo `test -f 'CFStringEncodings.c' || echo '$(srcdir)/'`CFStringEncodings.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodings.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFStringEncodings.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringEncodings.c' object='libCoreFoundation_profile_la-CFStringEncodings.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFStringEncodings.lo `test -f 'CFStringEncodings.c' || echo '$(srcdir)/'`CFStringEncodings.c
+
+libCoreFoundation_profile_la-CFString.lo: CFString.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFString.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFString.Tpo -c -o libCoreFoundation_profile_la-CFString.lo `test -f 'CFString.c' || echo '$(srcdir)/'`CFString.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFString.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFString.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFString.c' object='libCoreFoundation_profile_la-CFString.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFString.lo `test -f 'CFString.c' || echo '$(srcdir)/'`CFString.c
+
+libCoreFoundation_profile_la-CFStringScanner.lo: CFStringScanner.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFStringScanner.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFStringScanner.Tpo -c -o libCoreFoundation_profile_la-CFStringScanner.lo `test -f 'CFStringScanner.c' || echo '$(srcdir)/'`CFStringScanner.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFStringScanner.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFStringScanner.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringScanner.c' object='libCoreFoundation_profile_la-CFStringScanner.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFStringScanner.lo `test -f 'CFStringScanner.c' || echo '$(srcdir)/'`CFStringScanner.c
+
+libCoreFoundation_profile_la-CFStringUtilities.lo: CFStringUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFStringUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFStringUtilities.Tpo -c -o libCoreFoundation_profile_la-CFStringUtilities.lo `test -f 'CFStringUtilities.c' || echo '$(srcdir)/'`CFStringUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFStringUtilities.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFStringUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFStringUtilities.c' object='libCoreFoundation_profile_la-CFStringUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFStringUtilities.lo `test -f 'CFStringUtilities.c' || echo '$(srcdir)/'`CFStringUtilities.c
+
+libCoreFoundation_profile_la-CFSystemDirectories.lo: CFSystemDirectories.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFSystemDirectories.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFSystemDirectories.Tpo -c -o libCoreFoundation_profile_la-CFSystemDirectories.lo `test -f 'CFSystemDirectories.c' || echo '$(srcdir)/'`CFSystemDirectories.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFSystemDirectories.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFSystemDirectories.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFSystemDirectories.c' object='libCoreFoundation_profile_la-CFSystemDirectories.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFSystemDirectories.lo `test -f 'CFSystemDirectories.c' || echo '$(srcdir)/'`CFSystemDirectories.c
+
+libCoreFoundation_profile_la-CFTimeZone.lo: CFTimeZone.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFTimeZone.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFTimeZone.Tpo -c -o libCoreFoundation_profile_la-CFTimeZone.lo `test -f 'CFTimeZone.c' || echo '$(srcdir)/'`CFTimeZone.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFTimeZone.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFTimeZone.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFTimeZone.c' object='libCoreFoundation_profile_la-CFTimeZone.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFTimeZone.lo `test -f 'CFTimeZone.c' || echo '$(srcdir)/'`CFTimeZone.c
+
+libCoreFoundation_profile_la-CFTree.lo: CFTree.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFTree.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFTree.Tpo -c -o libCoreFoundation_profile_la-CFTree.lo `test -f 'CFTree.c' || echo '$(srcdir)/'`CFTree.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFTree.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFTree.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFTree.c' object='libCoreFoundation_profile_la-CFTree.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFTree.lo `test -f 'CFTree.c' || echo '$(srcdir)/'`CFTree.c
+
+libCoreFoundation_profile_la-CFURL.lo: CFURL.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFURL.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFURL.Tpo -c -o libCoreFoundation_profile_la-CFURL.lo `test -f 'CFURL.c' || echo '$(srcdir)/'`CFURL.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFURL.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFURL.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFURL.c' object='libCoreFoundation_profile_la-CFURL.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFURL.lo `test -f 'CFURL.c' || echo '$(srcdir)/'`CFURL.c
+
+libCoreFoundation_profile_la-CFURLAccess.lo: CFURLAccess.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFURLAccess.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFURLAccess.Tpo -c -o libCoreFoundation_profile_la-CFURLAccess.lo `test -f 'CFURLAccess.c' || echo '$(srcdir)/'`CFURLAccess.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFURLAccess.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFURLAccess.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFURLAccess.c' object='libCoreFoundation_profile_la-CFURLAccess.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFURLAccess.lo `test -f 'CFURLAccess.c' || echo '$(srcdir)/'`CFURLAccess.c
+
+libCoreFoundation_profile_la-CFUUID.lo: CFUUID.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFUUID.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFUUID.Tpo -c -o libCoreFoundation_profile_la-CFUUID.lo `test -f 'CFUUID.c' || echo '$(srcdir)/'`CFUUID.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFUUID.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFUUID.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUUID.c' object='libCoreFoundation_profile_la-CFUUID.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFUUID.lo `test -f 'CFUUID.c' || echo '$(srcdir)/'`CFUUID.c
+
+libCoreFoundation_profile_la-CFUniChar.lo: CFUniChar.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFUniChar.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFUniChar.Tpo -c -o libCoreFoundation_profile_la-CFUniChar.lo `test -f 'CFUniChar.c' || echo '$(srcdir)/'`CFUniChar.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFUniChar.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFUniChar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUniChar.c' object='libCoreFoundation_profile_la-CFUniChar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFUniChar.lo `test -f 'CFUniChar.c' || echo '$(srcdir)/'`CFUniChar.c
+
+libCoreFoundation_profile_la-CFUnicodeDecomposition.lo: CFUnicodeDecomposition.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFUnicodeDecomposition.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFUnicodeDecomposition.Tpo -c -o libCoreFoundation_profile_la-CFUnicodeDecomposition.lo `test -f 'CFUnicodeDecomposition.c' || echo '$(srcdir)/'`CFUnicodeDecomposition.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFUnicodeDecomposition.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFUnicodeDecomposition.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUnicodeDecomposition.c' object='libCoreFoundation_profile_la-CFUnicodeDecomposition.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFUnicodeDecomposition.lo `test -f 'CFUnicodeDecomposition.c' || echo '$(srcdir)/'`CFUnicodeDecomposition.c
+
+libCoreFoundation_profile_la-CFUnicodePrecomposition.lo: CFUnicodePrecomposition.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFUnicodePrecomposition.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFUnicodePrecomposition.Tpo -c -o libCoreFoundation_profile_la-CFUnicodePrecomposition.lo `test -f 'CFUnicodePrecomposition.c' || echo '$(srcdir)/'`CFUnicodePrecomposition.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFUnicodePrecomposition.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFUnicodePrecomposition.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUnicodePrecomposition.c' object='libCoreFoundation_profile_la-CFUnicodePrecomposition.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFUnicodePrecomposition.lo `test -f 'CFUnicodePrecomposition.c' || echo '$(srcdir)/'`CFUnicodePrecomposition.c
+
+libCoreFoundation_profile_la-CFUserNotification.lo: CFUserNotification.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFUserNotification.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFUserNotification.Tpo -c -o libCoreFoundation_profile_la-CFUserNotification.lo `test -f 'CFUserNotification.c' || echo '$(srcdir)/'`CFUserNotification.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFUserNotification.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFUserNotification.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUserNotification.c' object='libCoreFoundation_profile_la-CFUserNotification.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFUserNotification.lo `test -f 'CFUserNotification.c' || echo '$(srcdir)/'`CFUserNotification.c
+
+libCoreFoundation_profile_la-CFUtilities.lo: CFUtilities.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFUtilities.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFUtilities.Tpo -c -o libCoreFoundation_profile_la-CFUtilities.lo `test -f 'CFUtilities.c' || echo '$(srcdir)/'`CFUtilities.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFUtilities.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFUtilities.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFUtilities.c' object='libCoreFoundation_profile_la-CFUtilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFUtilities.lo `test -f 'CFUtilities.c' || echo '$(srcdir)/'`CFUtilities.c
+
+libCoreFoundation_profile_la-CFVersion.lo: CFVersion.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFVersion.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFVersion.Tpo -c -o libCoreFoundation_profile_la-CFVersion.lo `test -f 'CFVersion.c' || echo '$(srcdir)/'`CFVersion.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFVersion.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFVersion.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFVersion.c' object='libCoreFoundation_profile_la-CFVersion.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFVersion.lo `test -f 'CFVersion.c' || echo '$(srcdir)/'`CFVersion.c
+
+libCoreFoundation_profile_la-CFWindowsMessageQueue.lo: CFWindowsMessageQueue.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFWindowsMessageQueue.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFWindowsMessageQueue.Tpo -c -o libCoreFoundation_profile_la-CFWindowsMessageQueue.lo `test -f 'CFWindowsMessageQueue.c' || echo '$(srcdir)/'`CFWindowsMessageQueue.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFWindowsMessageQueue.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFWindowsMessageQueue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFWindowsMessageQueue.c' object='libCoreFoundation_profile_la-CFWindowsMessageQueue.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFWindowsMessageQueue.lo `test -f 'CFWindowsMessageQueue.c' || echo '$(srcdir)/'`CFWindowsMessageQueue.c
+
+libCoreFoundation_profile_la-CFXMLInputStream.lo: CFXMLInputStream.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFXMLInputStream.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFXMLInputStream.Tpo -c -o libCoreFoundation_profile_la-CFXMLInputStream.lo `test -f 'CFXMLInputStream.c' || echo '$(srcdir)/'`CFXMLInputStream.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFXMLInputStream.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFXMLInputStream.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLInputStream.c' object='libCoreFoundation_profile_la-CFXMLInputStream.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFXMLInputStream.lo `test -f 'CFXMLInputStream.c' || echo '$(srcdir)/'`CFXMLInputStream.c
+
+libCoreFoundation_profile_la-CFXMLNode.lo: CFXMLNode.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFXMLNode.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFXMLNode.Tpo -c -o libCoreFoundation_profile_la-CFXMLNode.lo `test -f 'CFXMLNode.c' || echo '$(srcdir)/'`CFXMLNode.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFXMLNode.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFXMLNode.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLNode.c' object='libCoreFoundation_profile_la-CFXMLNode.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFXMLNode.lo `test -f 'CFXMLNode.c' || echo '$(srcdir)/'`CFXMLNode.c
+
+libCoreFoundation_profile_la-CFXMLParser.lo: CFXMLParser.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFXMLParser.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFXMLParser.Tpo -c -o libCoreFoundation_profile_la-CFXMLParser.lo `test -f 'CFXMLParser.c' || echo '$(srcdir)/'`CFXMLParser.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFXMLParser.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFXMLParser.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLParser.c' object='libCoreFoundation_profile_la-CFXMLParser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFXMLParser.lo `test -f 'CFXMLParser.c' || echo '$(srcdir)/'`CFXMLParser.c
+
+libCoreFoundation_profile_la-CFXMLPreferencesDomain.lo: CFXMLPreferencesDomain.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFXMLPreferencesDomain.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFXMLPreferencesDomain.Tpo -c -o libCoreFoundation_profile_la-CFXMLPreferencesDomain.lo `test -f 'CFXMLPreferencesDomain.c' || echo '$(srcdir)/'`CFXMLPreferencesDomain.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFXMLPreferencesDomain.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFXMLPreferencesDomain.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLPreferencesDomain.c' object='libCoreFoundation_profile_la-CFXMLPreferencesDomain.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFXMLPreferencesDomain.lo `test -f 'CFXMLPreferencesDomain.c' || echo '$(srcdir)/'`CFXMLPreferencesDomain.c
+
+libCoreFoundation_profile_la-CFXMLTree.lo: CFXMLTree.c
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -MT libCoreFoundation_profile_la-CFXMLTree.lo -MD -MP -MF $(DEPDIR)/libCoreFoundation_profile_la-CFXMLTree.Tpo -c -o libCoreFoundation_profile_la-CFXMLTree.lo `test -f 'CFXMLTree.c' || echo '$(srcdir)/'`CFXMLTree.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libCoreFoundation_profile_la-CFXMLTree.Tpo $(DEPDIR)/libCoreFoundation_profile_la-CFXMLTree.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='CFXMLTree.c' object='libCoreFoundation_profile_la-CFXMLTree.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libCoreFoundation_profile_la_CPPFLAGS) $(CPPFLAGS) $(libCoreFoundation_profile_la_CFLAGS) $(CFLAGS) -c -o libCoreFoundation_profile_la-CFXMLTree.lo `test -f 'CFXMLTree.c' || echo '$(srcdir)/'`CFXMLTree.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+install-libCoreFoundation_la_dataDATA: $(libCoreFoundation_la_data_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(libCoreFoundation_la_datadir)" || $(MKDIR_P) "$(DESTDIR)$(libCoreFoundation_la_datadir)"
+	@list='$(libCoreFoundation_la_data_DATA)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(libCoreFoundation_la_dataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(libCoreFoundation_la_datadir)/$$f'"; \
+	  $(libCoreFoundation_la_dataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(libCoreFoundation_la_datadir)/$$f"; \
+	done
+
+uninstall-libCoreFoundation_la_dataDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(libCoreFoundation_la_data_DATA)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(libCoreFoundation_la_datadir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(libCoreFoundation_la_datadir)/$$f"; \
+	done
+install-pkgconfigDATA: $(pkgconfig_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(pkgconfigDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+	  $(pkgconfigDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+	done
+
+uninstall-pkgconfigDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+	done
+install-CF_includeHEADERS: $(CF_include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(CF_includedir)" || $(MKDIR_P) "$(DESTDIR)$(CF_includedir)"
+	@list='$(CF_include_HEADERS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(CF_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(CF_includedir)/$$f'"; \
+	  $(CF_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(CF_includedir)/$$f"; \
+	done
+
+uninstall-CF_includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(CF_include_HEADERS)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(CF_includedir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(CF_includedir)/$$f"; \
+	done
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	test -d $(distdir) || mkdir $(distdir)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	    distdir=`$(am__cd) $(distdir) && pwd`; \
+	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$top_distdir" \
+	        distdir="$$distdir/$$subdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+	-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r $(distdir)
+dist-gzip: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+
+dist-bzip2: distdir
+	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+	$(am__remove_distdir)
+
+dist-lzma: distdir
+	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+	$(am__remove_distdir)
+
+dist-tarZ: distdir
+	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+	$(am__remove_distdir)
+
+dist-shar: distdir
+	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	$(am__remove_distdir)
+
+dist-zip: distdir
+	-rm -f $(distdir).zip
+	zip -rq $(distdir).zip $(distdir)
+	$(am__remove_distdir)
+
+dist dist-all: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+	case '$(DIST_ARCHIVES)' in \
+	*.tar.gz*) \
+	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+	*.tar.bz2*) \
+	  bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lzma*) \
+	  unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+	*.tar.Z*) \
+	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+	*.shar.gz*) \
+	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+	*.zip*) \
+	  unzip $(distdir).zip ;;\
+	esac
+	chmod -R a-w $(distdir); chmod a+w $(distdir)
+	mkdir $(distdir)/_build
+	mkdir $(distdir)/_inst
+	chmod a-w $(distdir)
+	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+	  && cd $(distdir)/_build \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) check \
+	  && $(MAKE) $(AM_MAKEFLAGS) install \
+	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+	        distuninstallcheck \
+	  && chmod -R a-w "$$dc_install_base" \
+	  && ({ \
+	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
+	  && rm -rf "$$dc_destdir" \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist \
+	  && rm -rf $(DIST_ARCHIVES) \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+	$(am__remove_distdir)
+	@(echo "$(distdir) archives ready for distribution: "; \
+	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+	@cd $(distuninstallcheck_dir) \
+	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+	   || { echo "ERROR: files left after uninstall:" ; \
+	        if test -n "$(DESTDIR)"; then \
+	          echo "  (check DESTDIR support)"; \
+	        fi ; \
+	        $(distuninstallcheck_listfiles) ; \
+	        exit 1; } >&2
+distcleancheck: distclean
+	@if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
+installdirs: installdirs-recursive
+installdirs-am:
+	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libCoreFoundation_la_datadir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(CF_includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-CF_includeHEADERS \
+	install-libCoreFoundation_la_dataDATA install-pkgconfigDATA
+
+install-dvi: install-dvi-recursive
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf $(top_srcdir)/autom4te.cache
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-CF_includeHEADERS \
+	uninstall-libCoreFoundation_la_dataDATA \
+	uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+	install-strip
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am am--refresh check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool ctags ctags-recursive dist \
+	dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \
+	dist-zip distcheck distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags \
+	distcleancheck distdir distuninstallcheck dvi dvi-am html \
+	html-am info info-am install install-CF_includeHEADERS \
+	install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am \
+	install-libCoreFoundation_la_dataDATA install-libLTLIBRARIES \
+	install-man install-pdf install-pdf-am install-pkgconfigDATA \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags tags-recursive uninstall uninstall-CF_includeHEADERS \
+	uninstall-am uninstall-libCoreFoundation_la_dataDATA \
+	uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/README b/CoreFoundation/README
new file mode 100644
index 0000000..c73d1e6
--- /dev/null
+++ b/CoreFoundation/README
@@ -0,0 +1,44 @@
+This is the public Open Source distribution of Apple, Inc.'s
+CoreFoundation framework, sometimes known as "CF-lite"
+because it does not contain every facility available from the
+CoreFoundation framework in Mac OS X.  This distribution is
+refered to as Open CF-lite to distinguish it from the official
+Apple release, and to reflect the Open Source nature of this
+project.
+
+This CoreFoundation corresponds to the Mac OS X 10.5.6 version
+of CF (CF-476.17)
+
+This distribution differs from the official Apple, Inc. release
+in that it is known to build and run on Mac OS X, Windows, and
+Linux.  It would probably be trivial to port to most other
+POSIX-based environments (volunteers welcome!)
+
+The goal of this port is to provide a feature-compatible, cross
+platform version of the official CoreFoundation framework.  In
+general, we do not propose extending functionality beyond the
+official Apple release so that this project can serve as a
+drop-in replacement.
+
+To repeat Apple's statement:
+
+--- What Apple is NOT interested in, with CF-lite:
+* Everybody's little convenience methods. Just because
+  "everybody has to write their own", it does not
+  follow immediately that it is a good idea to add it
+  to the system libraries. It is not a goal of CF to
+  be a "Swiss Army Knife"; that just increases the
+  size of the binaries, and the documentation and
+  maintenance burden. Functions to reverse a string
+  or merge two arrays by taking alternate elements
+  from the two arrays are not compelling.
+
+The current release is known to work on Windows at a sufficient
+level to run the WebKit infrastructure.
+
+Support is available from the discussion groups at http://opencflite.sf.net.
+
+Enjoy!
+
+Brent Fulgham <bfulgham@gmail.com>
+Grant Erickson <gerickson@nuovations.com>
diff --git a/CoreFoundation/TODO b/CoreFoundation/TODO
new file mode 100644
index 0000000..b521eee
--- /dev/null
+++ b/CoreFoundation/TODO
@@ -0,0 +1,28 @@
+--- Open CF-lite to-do list:
+* CFRunLoop tests and implementation for Windows and Linux.
+* Better examples
+* List of projects using Open CF-lite.
+
+--- Original CF-lite to-do list:
+[Note: when it says "Apple has code" below, that usually
+means "Apple has some code it could provide to start an
+effort here", not "Apple has some code in the pipe, don't
+bother with this item". Anyone known to be doing work on
+any of these items will be listed here, including Apple.]
+* Some classes have a fair number of assertions, nearly all
+  related to parameter checking. More assertions are needed
+  nearly everywhere. The assertions that are there have been
+  often found to be valuable -- you just get a message about
+  some bad parameter and there's the bug.
+* More header doc is needed. CFArray.h and CFDictionary.h
+  are models.
+* An exception model, similar to Cocoa Foundation's. Apple
+  has some code for this already, and try/catch model like
+  C++ is simple enough to support; finally blocks a la Java
+  don't seem to be practical within the confines of ANSI C.
+* A CFFileDescriptor is needed which can act as a run loop
+  source. Or maybe it should be CFPipeDescriptor. This is
+  NOT something for general file handling -- just monitoring
+  a file descriptor which is a pipe (for which there are
+  notifications or other async activity).
+
diff --git a/CoreFoundation/XCode_Configs/ConfigDebug.xcconfig b/CoreFoundation/XCode_Configs/ConfigDebug.xcconfig
new file mode 100644
index 0000000..d5adeac
--- /dev/null
+++ b/CoreFoundation/XCode_Configs/ConfigDebug.xcconfig
@@ -0,0 +1,8 @@
+#include "Config_Master.xcconfig"
+
+//ARCHS = ppc64 x86_64
+
+GCC_GENERATE_DEBUGGING_SYMBOLS = YES
+GCC_DEBUGGING_SYMBOLS = default
+GCC_OPTIMIZATION_LEVEL = 0
+GCC_PREPROCESSOR_DEFINITIONS = OSMac_=1 OSWin_=0 DEPLOYMENT_TARGET_MACOSX=1 CF_BUILDING_CF=1 Debug_=1 DEBUG=1 _DEBUG=1 __STDC_LIMIT_MACROS=1
diff --git a/CoreFoundation/XCode_Configs/ConfigRelease.xcconfig b/CoreFoundation/XCode_Configs/ConfigRelease.xcconfig
new file mode 100644
index 0000000..761df47
--- /dev/null
+++ b/CoreFoundation/XCode_Configs/ConfigRelease.xcconfig
@@ -0,0 +1,16 @@
+#include "Config_Master.xcconfig"
+
+//ARCHS = ppc i386
+ARCHS = $(ARCHS_STANDARD_32_64_BIT)
+
+DEPLOYMENT_POSTPROCESSING = YES
+STRIP_INSTALLED_PRODUCT = YES
+STRIP_STYLE = debugging
+COPY_PHASE_STRIP = YES
+
+GCC_GENERATE_DEBUGGING_SYMBOLS = NO
+GCC_DEBUGGING_SYMBOLS = default
+GCC_OPTIMIZATION_LEVEL = s
+
+GCC_WARN_UNINITIALIZED_AUTOS = YES
+GCC_PREPROCESSOR_DEFINITIONS = OSMac_=1 OSWin_=0 DEPLOYMENT_TARGET_MACOSX=1 CF_BUILDING_CF=1 __STDC_LIMIT_MACROS=1
diff --git a/CoreFoundation/XCode_Configs/Config_Master.xcconfig b/CoreFoundation/XCode_Configs/Config_Master.xcconfig
new file mode 100644
index 0000000..5565f38
--- /dev/null
+++ b/CoreFoundation/XCode_Configs/Config_Master.xcconfig
@@ -0,0 +1,69 @@
+
+ARCHS = $(NATIVE_ARCH)
+VALID_ARCHS = ppc64 ppc7400 ppc970 i386 x86_64 ppc
+
+//SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk
+SDKROOT = /Developer/SDKs/MacOSX10.5.sdk
+MACOSX_DEPLOYMENT_TARGET = 10.5
+
+//ALWAYS_SEARCH_USER_PATHS = YES
+PREBINDING = NO
+ZERO_LINK = NO
+GCC_ENABLE_FIX_AND_CONTINUE = NO
+
+INFOPLIST_PREPROCESS = YES
+DEPLOYMENT_POSTPROCESSING = NO
+
+SKIP_INSTALL = YES
+STRIP_INSTALLED_PRODUCT = NO
+STRIP_STYLE = debugging
+COPY_PHASE_STRIP = NO
+DEAD_CODE_STRIPPING = NO
+
+DEBUG_INFORMATION_FORMAT = dwarf
+GCC_GENERATE_DEBUGGING_SYMBOLS = YES
+GCC_DEBUGGING_SYMBOLS = default
+GCC_OPTIMIZATION_LEVEL = 0
+
+GCC_PRECOMPILE_PREFIX_HEADER = YES
+
+// Compile as Obj-C++
+GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp
+
+GCC_SHORT_ENUMS = NO
+//GCC_ONE_BYTE_BOOL = NO
+GCC_ENABLE_PASCAL_STRINGS = YES
+GCC_REUSE_STRINGS = YES
+
+// REQUIRED for C++ symbol exporting
+GCC_SYMBOLS_PRIVATE_EXTERN = NO
+GCC_ENABLE_CPP_RTTI = YES
+GCC_ENABLE_CPP_EXCEPTIONS = YES
+
+GCC_THREADSAFE_STATICS = YES
+
+GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
+GCC_WARN_ABOUT_RETURN_TYPE = YES
+GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
+GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO
+GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
+GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
+GCC_WARN_MISSING_PARENTHESES = YES
+GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
+GCC_WARN_UNUSED_VARIABLE = YES
+GCC_WARN_UNUSED_VALUE = YES
+GCC_WARN_UNINITIALIZED_AUTOS = NO
+GCC_WARN_SHADOW = YES
+GCC_WARN_SIGN_COMPARE = YES
+GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES
+GCC_WARN_UNKNOWN_PRAGMAS = YES
+GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO
+
+LINKER_DISPLAYS_FILES_FOR_UNDEFINED_SYMBOLS = YES
+
+UNICODE_DATA_FILE[arch=i386] = CFUnicodeData-L.mapping
+UNICODE_DATA_FILE[arch=x86_64] = CFUnicodeData-L.mapping
+UNICODE_DATA_FILE[arch=ppc] = CFUnicodeData-B.mapping
+UNICODE_DATA_FILE[arch=ppc64] = CFUnicodeData-B.mapping
+
+GCC_PREPROCESSOR_DEFINITIONS = OSMac_=1 OSWin_=0
\ No newline at end of file
diff --git a/CoreFoundation/aclocal.m4 b/CoreFoundation/aclocal.m4
new file mode 100644
index 0000000..e501440
--- /dev/null
+++ b/CoreFoundation/aclocal.m4
@@ -0,0 +1,9126 @@
+# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(AC_AUTOCONF_VERSION, [2.61],,
+[m4_warning([this file was generated for autoconf 2.61.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool 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 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 56 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+       [m4_default([$3],
+		   [m4_fatal([Libtool version $1 or higher is required],
+		             63)])],
+       [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+  *\ * | *\	*)
+    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+_LT_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    _LT_PATH_MAGIC
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME.  Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+	[m4_ifval([$1], [$1], [$2])])
+    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+    m4_ifval([$4],
+	[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+    lt_dict_add_subkey([lt_decl_dict], [$2],
+	[tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+  [0], [m4_fatal([$0: too few arguments: $#])],
+  [1], [m4_fatal([$0: too few arguments: $#: $1])],
+  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+     m4_quote(m4_if([$2], [],
+		     m4_quote(lt_decl_tag_varnames),
+		  m4_quote(m4_shift($@)))),
+     m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
+m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+     m4_if([$2], [],
+	   m4_quote(lt_decl_varnames),
+	m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+			lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'.  VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly.  In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+#    <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+#    # Some comment about what VAR is for.
+#    visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+					   [description])))[]dnl
+m4_pushdef([_libtool_name],
+    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+    [0], [_libtool_name=[$]$1],
+    [1], [_libtool_name=$lt_[]$1],
+    [2], [_libtool_name=$lt_[]$1],
+    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'.  Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+	dnl If the libtool generation code has been placed in $CONFIG_LT,
+	dnl instead of duplicating it all over again into config.status,
+	dnl then we will have config.status run $CONFIG_LT later, so it
+	dnl needs to know what name is stored there:
+        [AC_CONFIG_COMMANDS([libtool],
+            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+    dnl If the libtool generation code is destined for config.status,
+    dnl expand the accumulated commands and init code now:
+    [AC_CONFIG_COMMANDS([libtool],
+        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\[$]0 --fallback-echo"')dnl "
+  lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+  ;;
+esac
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+cat >"$CONFIG_LT" <<_LTEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate a libtool stub with the current configuration.
+
+lt_cl_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AS_SHELL_SANITIZE
+_AS_PREPARE
+
+exec AS_MESSAGE_FD>&1
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+  echo
+  AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+  -h, --help      print this help, then exit
+  -V, --version   print version number, then exit
+  -q, --quiet     do not print progress messages
+  -d, --debug     don't remove temporary files
+
+Report bugs to <bug-libtool@gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+  case $[1] in
+    --version | --v* | -V )
+      echo "$lt_cl_version"; exit 0 ;;
+    --help | --h* | -h )
+      echo "$lt_cl_help"; exit 0 ;;
+    --debug | --d* | -d )
+      debug=: ;;
+    --quiet | --q* | --silent | --s* | -q )
+      lt_cl_silent=: ;;
+
+    -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+    *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+  esac
+  shift
+done
+
+if $lt_cl_silent; then
+  exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure.  Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+if test "$no_create" != yes; then
+  lt_cl_success=:
+  test "$silent" = yes &&
+    lt_config_lt_args="$lt_config_lt_args --quiet"
+  exec AS_MESSAGE_LOG_FD>/dev/null
+  $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+  exec AS_MESSAGE_LOG_FD>>config.log
+  $lt_cl_success || AS_EXIT(1)
+fi
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars.  Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+  m4_if(_LT_TAG, [C], [
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+  _LT_PROG_LTMAIN
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  _LT_PROG_XSI_SHELLFNS
+
+  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+  [C],			[_LT_LANG(C)],
+  [C++],		[_LT_LANG(CXX)],
+  [Java],		[_LT_LANG(GCJ)],
+  [Fortran 77],		[_LT_LANG(F77)],
+  [Fortran],		[_LT_LANG(FC)],
+  [Windows Resource],	[_LT_LANG(RC)],
+  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+    [_LT_LANG($1)],
+    [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+  [LT_SUPPORTED_TAG([$1])dnl
+  m4_append([_LT_TAGS], [$1 ])dnl
+  m4_define([_LT_LANG_]$1[_enabled], [])dnl
+  _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+  [LT_LANG(CXX)],
+  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+  [LT_LANG(F77)],
+  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+  [LT_LANG(FC)],
+  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+  [LT_LANG(GCJ)],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+    [LT_LANG(GCJ)],
+    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+      [LT_LANG(GCJ)],
+      [m4_ifdef([AC_PROG_GCJ],
+	[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([A][M_PROG_GCJ],
+	[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([LT_PROG_GCJ],
+	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+  [LT_LANG(RC)],
+  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+    AC_CHECK_TOOL([LIPO], [lipo], [:])
+    AC_CHECK_TOOL([OTOOL], [otool], [:])
+    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+    _LT_DECL([], [DSYMUTIL], [1],
+      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+    _LT_DECL([], [NMEDIT], [1],
+      [Tool to change global to local symbols on Mac OS X])
+    _LT_DECL([], [LIPO], [1],
+      [Tool to manipulate fat objects and archives on Mac OS X])
+    _LT_DECL([], [OTOOL], [1],
+      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+    _LT_DECL([], [OTOOL64], [1],
+      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&AS_MESSAGE_LOG_FD
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+	[lt_cv_ld_exported_symbols_list=yes],
+	[lt_cv_ld_exported_symbols_list=no])
+	LDFLAGS="$save_LDFLAGS"
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[012]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on 
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it? 
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]]*)
+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES
+# --------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_automatic, $1)=yes
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+  _LT_TAGVAR(link_all_deplibs, $1)=yes
+  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  if test "$GCC" = "yes"; then
+    output_verbose_link_cmd=echo
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    m4_if([$1], [CXX],
+[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+],[])
+  else
+  _LT_TAGVAR(ld_shlibs, $1)=no
+  fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX
+# -----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+	     [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+	 [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_SHELL_INIT
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[_LT_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+  ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X[$]1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<_LT_EOF
+[$]*
+_LT_EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+  if test "X${echo_test_string+set}" != Xset; then
+    # find a string as large as possible, as long as the shell can cope with it
+    for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+      # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+      if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+	 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+      then
+        break
+      fi
+    done
+  fi
+
+  if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+     echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+     test "X$echo_testing_string" = "X$echo_test_string"; then
+    :
+  else
+    # The Solaris, AIX, and Digital Unix default echo programs unquote
+    # backslashes.  This makes it impossible to quote backslashes using
+    #   echo "$something" | sed 's/\\/\\\\/g'
+    #
+    # So, first we look for a working echo in the user's PATH.
+
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for dir in $PATH /usr/ucb; do
+      IFS="$lt_save_ifs"
+      if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+         test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        ECHO="$dir/echo"
+        break
+      fi
+    done
+    IFS="$lt_save_ifs"
+
+    if test "X$ECHO" = Xecho; then
+      # We didn't find a better echo, so look for alternatives.
+      if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        # This shell has a builtin print -r that does the trick.
+        ECHO='print -r'
+      elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+	   test "X$CONFIG_SHELL" != X/bin/ksh; then
+        # If we have ksh, try running configure again with it.
+        ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+        export ORIGINAL_CONFIG_SHELL
+        CONFIG_SHELL=/bin/ksh
+        export CONFIG_SHELL
+        exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+      else
+        # Try using printf.
+        ECHO='printf %s\n'
+        if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+	   echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	  # Cool, printf works
+	  :
+        elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+	  export CONFIG_SHELL
+	  SHELL="$CONFIG_SHELL"
+	  export SHELL
+	  ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+        elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+        else
+	  # maybe with a smaller string...
+	  prev=:
+
+	  for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+	    if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+	    then
+	      break
+	    fi
+	    prev="$cmd"
+	  done
+
+	  if test "$prev" != 'sed 50q "[$]0"'; then
+	    echo_test_string=`eval $prev`
+	    export echo_test_string
+	    exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+	  else
+	    # Oops.  We lost completely, so just stick with echo.
+	    ECHO=echo
+	  fi
+        fi
+      fi
+    fi
+  fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+   lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(lt_ECHO)
+])
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1],
+    [An echo program that does not interpret backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+  [AS_HELP_STRING([--disable-libtool-lock],
+    [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE="32"
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE="64"
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_i386"
+	    ;;
+	  ppc64-*linux*|powerpc64-*linux*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  ppc*-*linux*|powerpc*-*linux*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[AC_CHECK_TOOL(AR, ar, false)
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1])
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+    [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+    [Commands used to build an old-style archive])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$5], , :, [$5])
+else
+    m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                  [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$4], , :, [$4])
+else
+    m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[	 ]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+	         = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+    [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+    exit (status);
+}]
+_LT_EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_dlunknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+    ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+	  [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	[AC_CHECK_FUNC([dlopen],
+	      [lt_cv_dlopen="dlopen"],
+	  [AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+	    [AC_CHECK_LIB([svld], [dlopen],
+		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+	      [AC_CHECK_LIB([dld], [dld_link],
+		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+	      ])
+	    ])
+	  ])
+	])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+	  lt_cv_dlopen_self, [dnl
+	  _LT_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+	  lt_cv_dlopen_self_static, [dnl
+	  _LT_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+	 [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+	 [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+	 [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+	[Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+         [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+    [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no])
+    fi
+    ;;
+  *)
+    AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+	[], [
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[[4-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[[3-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+       LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+    [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+       [shlibpath_overrides_runpath=yes])])
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsdelf*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='NetBSD ld.elf_so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+ 
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+    [Variables whose values should be saved in libtool wrapper scripts and
+    restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+    [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+    [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+    [[List of archive names.  First name is the real one, the rest are links.
+    The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+    [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [postinstall_cmds], [2],
+    [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+    [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+    [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+    [[As "finish_cmds", except a single script fragment to be evaled but
+    not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+    [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+    [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+    [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="m4_if([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+	 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_ARG_WITH([gnu-ld],
+    [AS_HELP_STRING([--with-gnu-ld],
+	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_DECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd* | netbsdelf*-gnu)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+    [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+    [Command to use when deplibs_check_method == "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
+  AC_SUBST([DUMPBIN])
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+  [lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
+  cat conftest.out >&AS_MESSAGE_LOG_FD
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+	[Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris*)
+  symcode='[[BDRT]]'
+  ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK ['"\
+"     {last_section=section; section=\$ 3};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx]"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+	  cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+const struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_save_LIBS="$LIBS"
+	  lt_save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$lt_save_LIBS"
+	  CFLAGS="$lt_save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+    [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+    [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+    [lt_cv_sys_global_symbol_to_c_name_address], [1],
+    [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+    [Transform the output of nm in a C name address pair when lib prefix is needed])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+m4_if([$1], [CXX], [
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[[4-9]]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	else
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  xlc* | xlC*)
+	    # IBM XL 8.0 on PPC
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd* | netbsdelf*-gnu)
+	;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+	;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      m4_if([$1], [GCJ], [],
+	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc* | ifort*)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      xl*)
+	# IBM XL C 8.0/Fortran 10.1 on PPC
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    rdos*)
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    unicos*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+	[How to pass a linker flag through the compiler])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+	[Additional compiler flags for building library objects])
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+	[Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[[4-9]]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+  ;;
+  cygwin* | mingw*)
+    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  linux* | k*bsd*-gnu)
+    _LT_TAGVAR(link_all_deplibs, $1)=no
+  ;;
+  *)
+    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+], [
+  runpath_var=
+  _LT_TAGVAR(allow_undefined_flag, $1)=
+  _LT_TAGVAR(always_export_symbols, $1)=no
+  _LT_TAGVAR(archive_cmds, $1)=
+  _LT_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_TAGVAR(compiler_needs_object, $1)=no
+  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  _LT_TAGVAR(hardcode_automatic, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+  _LT_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_TAGVAR(inherit_rpath, $1)=no
+  _LT_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_TAGVAR(module_cmds, $1)=
+  _LT_TAGVAR(module_expsym_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_TAGVAR(whole_archive_flag_spec, $1)=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  _LT_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_TAGVAR(ld_shlibs, $1)=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[[3-9]]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=no
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    interix[[3-9]]*)
+      _LT_TAGVAR(hardcode_direct, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	xl[[cC]]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(compiler_needs_object, $1)=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+	case $cc_basename in
+	xlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+	  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd* | netbsdelf*-gnu)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	_LT_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix[[4-9]]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
+
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      _LT_TAGVAR(archive_cmds, $1)=''
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  _LT_TAGVAR(hardcode_direct, $1)=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	  _LT_TAGVAR(hardcode_libdir_separator, $1)=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+	_LT_TAGVAR(link_all_deplibs, $1)=no
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        _LT_SYS_MODULE_PATH_AIX
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 _LT_SYS_MODULE_PATH_AIX
+	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[[45]]*)
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+      # FIXME: Should let the user specify the lib program.
+      _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
+    darwin* | rhapsody*)
+      _LT_DARWIN_LINKER_FEATURES($1)
+      ;;
+
+    dgux*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    freebsd1*)
+      _LT_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
+	_LT_TAGVAR(hardcode_direct, $1)=yes
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  _LT_TAGVAR(hardcode_direct, $1)=no
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	  ;;
+	*)
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        AC_LINK_IFELSE(int foo(void) {},
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+        )
+        LDFLAGS="$save_LDFLAGS"
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(inherit_rpath, $1)=yes
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd* | netbsdelf*-gnu)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	_LT_TAGVAR(hardcode_direct, $1)=yes
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	     ;;
+	   *)
+	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+	  _LT_TAGVAR(hardcode_direct, $1)=no
+        ;;
+	motorola)
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+	;;
+      esac
+    fi
+  fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+    [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_TAGVAR(archive_cmds, $1) in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+	pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+        _LT_TAGVAR(allow_undefined_flag, $1)=
+        if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+        then
+	  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+        else
+	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+        fi
+        _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+    [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+    [enable_shared_with_static_runtimes], [0],
+    [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+    [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+    [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+    [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+    [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+    [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+    [Commands used to build a loadable module if different from building
+    a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+    [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+    [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+    [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+    [Flag to hardcode $libdir into a binary during linking.
+    This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
+    [[If ld is used when linking, flag to hardcode $libdir into a binary
+    during linking.  This must work even if $libdir does not exist]])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+    [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary and the resulting library dependency is
+    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+    [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+    [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+    [Set to "yes" if building a shared library automatically hardcodes DIR
+    into the library and all subsequent libraries and executables linked
+    against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+    [Set to yes if linker adds runtime paths of dependent libraries
+    to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+    [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [fix_srcfile_path], [1],
+    [Fix the shell variable $srcfile for the compiler])
+_LT_TAGDECL([], [always_export_symbols], [0],
+    [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+    [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+    [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+    [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+    [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [file_list_spec], [1],
+    [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl    [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_SYS_DYNAMIC_LINKER($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+  LT_SYS_DLOPEN_SELF
+  _LT_CMD_STRIPLIB
+
+  # Report which library types will actually be built
+  AC_MSG_CHECKING([if libtool supports shared libraries])
+  AC_MSG_RESULT([$can_build_shared])
+
+  AC_MSG_CHECKING([whether to build shared libraries])
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[[4-9]]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  AC_MSG_RESULT([$enable_shared])
+
+  AC_MSG_CHECKING([whether to build static libraries])
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  AC_MSG_RESULT([$enable_static])
+
+  _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_PROG_CXX
+# ------------
+# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
+# compiler, we have our own version here.
+m4_defun([_LT_PROG_CXX],
+[
+pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
+AC_PROG_CXX
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+else
+  _lt_caught_CXX_error=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_CXX
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[AC_REQUIRE([_LT_PROG_CXX])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+    else
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
+
+      LT_PATH_LD
+
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
+
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+	  $GREP 'no-whole-archive' > /dev/null; then
+          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
+
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
+
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
+
+    # PORTME: fill in a description of your system's C++ link characteristics
+    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+    _LT_TAGVAR(ld_shlibs, $1)=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+      aix[[4-9]]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+	    for ld_flag in $LDFLAGS; do
+	      case $ld_flag in
+	      *-brtl*)
+	        aix_use_runtimelinking=yes
+	        break
+	        ;;
+	      esac
+	    done
+	    ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        _LT_TAGVAR(archive_cmds, $1)=''
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[[012]]|aix4.[[012]].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	    # We have reworked collect2
+	    :
+	  else
+	    # We have old collect2
+	    _LT_TAGVAR(hardcode_direct, $1)=unsupported
+	    # It fails to find uninstalled libraries when the uninstalled
+	    # path is not listed in the libpath.  Setting hardcode_minus_L
+	    # to unsupported forces relinking
+	    _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=
+	  fi
+          esac
+          shared_flag='-shared'
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag="$shared_flag "'${wl}-G'
+	  fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	  # chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+          else
+	    if test "$aix_use_runtimelinking" = yes; then
+	      shared_flag='${wl}-G'
+	    else
+	      shared_flag='${wl}-bM:SRE'
+	    fi
+          fi
+        fi
+
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+	# export.
+        _LT_TAGVAR(always_export_symbols, $1)=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          _LT_SYS_MODULE_PATH_AIX
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+	    # Determine the default libpath from the value encoded in an
+	    # empty executable.
+	    _LT_SYS_MODULE_PATH_AIX
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    # Warning - without using the other run time loading flags,
+	    # -berok will link without error, but may produce a broken library.
+	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	    # Exported symbols can be pulled into shared objects from archives
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+	    # This is similar to how AIX traditionally builds its shared
+	    # libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	  # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	  # support --undefined.  This deserves some investigation.  FIXME
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	else
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+	  # FIXME: insert proper C++ library support
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	  ;;
+        esac
+        ;;
+
+      cygwin* | mingw* | pw32*)
+        # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+        # as there is no search path for DLLs.
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+        _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+        _LT_TAGVAR(always_export_symbols, $1)=no
+        _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+        if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+          # If the export-symbols file already is a .def file (1st line
+          # is EXPORTS), use it as is; otherwise, prepend...
+          _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	    cp $export_symbols $output_objdir/$soname.def;
+          else
+	    echo EXPORTS > $output_objdir/$soname.def;
+	    cat $export_symbols >> $output_objdir/$soname.def;
+          fi~
+          $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        else
+          _LT_TAGVAR(ld_shlibs, $1)=no
+        fi
+        ;;
+      darwin* | rhapsody*)
+        _LT_DARWIN_LINKER_FEATURES($1)
+	;;
+
+      dgux*)
+        case $cc_basename in
+          ec++*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          ghcx*)
+	    # Green Hills C++ Compiler
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+        esac
+        ;;
+
+      freebsd[[12]]*)
+        # C++ shared libraries reported to be fairly broken before
+	# switch to ELF
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      freebsd-elf*)
+        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+        ;;
+
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+        ;;
+
+      gnu*)
+        ;;
+
+      hpux9*)
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+				             # but as the default
+				             # location of the library.
+
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            _LT_TAGVAR(ld_shlibs, $1)=no
+            ;;
+          aCC*)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              _LT_TAGVAR(ld_shlibs, $1)=no
+            fi
+            ;;
+        esac
+        ;;
+
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            _LT_TAGVAR(hardcode_direct, $1)=no
+            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+            ;;
+          *)
+            _LT_TAGVAR(hardcode_direct, $1)=yes
+            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+					         # but as the default
+					         # location of the library.
+            ;;
+        esac
+
+        case $cc_basename in
+          CC*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          aCC*)
+	    case $host_cpu in
+	      hppa*64*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      ia64*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      *)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	    esac
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test $with_gnu_ld = no; then
+	        case $host_cpu in
+	          hppa*64*)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          ia64*)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          *)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	        esac
+	      fi
+	    else
+	      # FIXME: insert proper C++ library support
+	      _LT_TAGVAR(ld_shlibs, $1)=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      interix[[3-9]]*)
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+	# Instead, shared libraries are loaded at an image base (0x10000000 by
+	# default) and relocated if they conflict, which is a slow very memory
+	# consuming and fragmenting process.  To avoid this, we pick a random,
+	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+	    # SGI C++
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test "$with_gnu_ld" = no; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	      else
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+	      fi
+	    fi
+	    _LT_TAGVAR(link_all_deplibs, $1)=yes
+	    ;;
+        esac
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(inherit_rpath, $1)=yes
+        ;;
+
+      linux* | k*bsd*-gnu)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    with_gnu_ld=yes
+	    # version 8.0 and above of icpc choke on multiply defined symbols
+	    # if we add $predep_objects and $postdep_objects, however 7.1 and
+	    # earlier do not add the objects themselves.
+	    case `$CC -V 2>&1` in
+	      *"Version 7."*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	      *)  # Version 8.0 or newer
+	        tmp_idyn=
+	        case $host_cpu in
+		  ia64*) tmp_idyn=' -i_dynamic';;
+		esac
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	    esac
+	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+	    case `$CC -V` in
+	    *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
+	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+		$RANLIB $oldlib'
+	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    *) # Version 6 will use weak symbols
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    esac
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+	  cxx*)
+	    # Compaq C++
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+	    runpath_var=LD_RUN_PATH
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  xl*)
+	    # IBM XL 8.0 on PPC, with GNU ld
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    if test "x$supports_anon_versioning" = xyes; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+		echo "local: *; };" >> $output_objdir/$libname.ver~
+		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	    fi
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+	      # Not sure whether something based on
+	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	      # would be better.
+	      output_verbose_link_cmd='echo'
+
+	      # Archives containing C++ object files must be created using
+	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	      # necessary to make sure instantiated templates are included
+	      # in the archive.
+	      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+
+      lynxos*)
+        # FIXME: insert proper C++ library support
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	;;
+
+      m88k*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+	;;
+
+      mvs*)
+        case $cc_basename in
+          cxx*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+	  *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+	esac
+	;;
+
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+	  wlarc=
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	fi
+	# Workaround some broken pre-1.5 toolchains
+	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+	;;
+
+      *nto* | *qnx*)
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+	;;
+
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	;;
+
+      openbsd*)
+	if test -f /usr/libexec/ld.so; then
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  fi
+	  output_verbose_link_cmd=echo
+	else
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Archives containing C++ object files must be created using
+	    # the KAI C++ compiler.
+	    case $host in
+	      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+	      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+	    esac
+	    ;;
+          RCC*)
+	    # Rational C++ 2.4.1
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          cxx*)
+	    case $host in
+	      osf3*)
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+		;;
+	      *)
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	          echo "-hidden">> $lib.exp~
+	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+	          $RM $lib.exp'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+		;;
+	    esac
+
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  *)
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	      case $host in
+	        osf3*)
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	        *)
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	      esac
+
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	      # Commands to make compiler produce verbose output that lists
+	      # what "hidden" libraries, object files and flags are used when
+	      # linking a shared library.
+	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+	    else
+	      # FIXME: insert proper C++ library support
+	      _LT_TAGVAR(ld_shlibs, $1)=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      psos*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      sunos4*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.x
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          lcc*)
+	    # Lucid
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+        esac
+        ;;
+
+      solaris*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	    case $host_os in
+	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	      *)
+		# The compiler driver will combine and reorder linker options,
+		# but understands `-z linker_flag'.
+	        # Supported since Solaris 2.6 (maybe 2.5.1?)
+		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	        ;;
+	    esac
+	    _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+	    output_verbose_link_cmd='echo'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	    ;;
+          gcx*)
+	    # Green Hills C++ Compiler
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	    # The C++ compiler must be used to create the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    # GNU C++ compiler with Solaris linker
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      else
+	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # platform.
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      fi
+
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      case $host_os in
+		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+		*)
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  ;;
+	      esac
+	    fi
+	    ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+      esac
+      ;;
+
+      sysv5* | sco3.2v5* | sco5v6*)
+	# Note: We can NOT use -z defs as we might desire, because we do not
+	# link with -lc, and that would cause any symbols used from libc to
+	# always be unresolved, which means just about no library would
+	# ever link correctly.  If we're not using GNU ld we use -z text
+	# though, which does catch some bad symbols but isn't as heavy-handed
+	# as -z defs.
+	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+	_LT_TAGVAR(link_all_deplibs, $1)=yes
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	runpath_var='LD_RUN_PATH'
+
+	case $cc_basename in
+          CC*)
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	  *)
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+	    # NonStop-UX NCC 3.20
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+        esac
+        ;;
+
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      *)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+    esac
+
+    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+    _LT_TAGVAR(GCC, $1)="$GXX"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+_LT_EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	   else
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	 else
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	 fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+	   _LT_TAGVAR(predep_objects, $1)="$p"
+	 else
+	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+	 fi
+       else
+	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	 else
+	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_TAGVAR(predep_objects,$1)=
+  _LT_TAGVAR(postdep_objects,$1)=
+  _LT_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+    [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+    [Dependencies to place before and after the objects being linked to
+    create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+    [The library search path used internally by the compiler when linking
+    a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_PROG_F77
+# ------------
+# Since AC_PROG_F77 is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_F77],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
+AC_PROG_F77
+if test -z "$F77" || test "X$F77" = "Xno"; then
+  _lt_disable_F77=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_F77
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_F77], [])
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_REQUIRE([_LT_PROG_F77])dnl
+AC_LANG_PUSH(Fortran 77)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${F77-"f77"}
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+  GCC=$G77
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$G77"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_PROG_FC
+# -----------
+# Since AC_PROG_FC is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_FC],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
+AC_PROG_FC
+if test -z "$FC" || test "X$FC" = "Xno"; then
+  _lt_disable_FC=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_FC
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_FC], [])
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_REQUIRE([_LT_PROG_FC])dnl
+AC_LANG_PUSH(Fortran)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${FC-"f95"}
+  compiler=$CC
+  GCC=$ac_cv_fc_compiler_gnu
+
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC="$lt_save_CC"
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+  :
+  _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+    [AC_CHECK_TOOL(GCJ, gcj,)
+      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_XSI_SHELLFNS
+# ---------------------
+# Bourne and XSI compatible variants of some useful shell functions.
+m4_defun([_LT_PROG_XSI_SHELLFNS],
+[case $xsi_shell in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+  func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+  # positional parameters, so assign one to ordinary parameter first.
+  func_stripname_result=${3}
+  func_stripname_result=${func_stripname_result#"${1}"}
+  func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=${1%%=*}
+  func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  case ${1} in
+    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+    *)    func_lo2o_result=${1} ;;
+  esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=$(( $[*] ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=${#1}
+}
+
+_LT_EOF
+    ;;
+  *) # Bourne compatible functions.
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+dnl func_dirname_and_basename
+dnl A portable version of this function is already defined in general.m4sh
+dnl so there is no need for it here.
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+  case ${2} in
+    .*) func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+    *)  func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+  esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[[^=]]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+  func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=`expr "$[@]"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$[1]+=\$[2]"
+}
+_LT_EOF
+    ;;
+  *)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$[1]=\$$[1]\$[2]"
+}
+
+_LT_EOF
+    ;;
+  esac
+])
+
+# Helper functions for option handling.                    -*- Autoconf -*-
+#
+#   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+        _LT_MANGLE_DEFUN([$1], [$2]),
+    [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+	    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+		      [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME.  If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+    [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+  dnl
+  dnl Simply set some default values (i.e off) if boolean options were not
+  dnl specified:
+  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+  ])
+  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+  ])
+  dnl
+  dnl If no reference was made to various pairs of opposing options, then
+  dnl we run the default mode handler for the pair.  For example, if neither
+  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl archives by default:
+  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+  		   [_LT_ENABLE_FAST_INSTALL])
+  ])
+])# _LT_SET_OPTIONS
+
+
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS],      [0], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+
+    _LT_DECL([build_libtool_libs], [enable_shared], [0],
+	[Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
+
+    _LT_DECL([build_old_libs], [enable_static], [0],
+	[Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+	 [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+    [AS_HELP_STRING([--with-pic],
+	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [pic_mode="$withval"],
+    [pic_mode=default])
+
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+		 [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+		 [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+		 [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+		 [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+		 [m4_define([_LTDL_TYPE], [convenience])])
+
+# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
+#
+#   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+#   Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 5 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+       [$#], [2], [[$2]],
+       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+       [$#], 1, [],
+       [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+m4_define([lt_combine],
+[m4_if([$2], [], [],
+  [m4_if([$4], [], [],
+    [lt_join(m4_quote(m4_default([$1], [[, ]])),
+      lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2],
+		   [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]),
+			       [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl
+])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+		 [lt_append([$1], [$2], [$3])$4],
+		 [$5])],
+	  [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+	[$5],
+    [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+  [lt_join(m4_quote(m4_default([$4], [[, ]])),
+           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
+
+# ltversion.m4 -- version numbers			-*- Autoconf -*-
+#
+#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# Generated from ltversion.in.
+
+# serial 2976 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.2.4])
+m4_define([LT_PACKAGE_REVISION], [1.2976])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.2.4'
+macro_revision='1.2976'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
+
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
+#
+#   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 4 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else.  This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_RC],		[AC_DEFUN([AC_LIBTOOL_RC])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.10'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.10.1], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.10.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 8
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 9
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+#serial 3
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[for mf in $CONFIG_FILES; do
+  # Strip MF so we end up with the name of the file.
+  mf=`echo "$mf" | sed -e 's/:.*$//'`
+  # Check whether this is an Automake generated Makefile or not.
+  # We used to match only the files named `Makefile.in', but
+  # some people rename them; so instead we look at the file content.
+  # Grep'ing the first line is not enough: some people post-process
+  # each Makefile.in and add a new line on top of each file to say so.
+  # Grep'ing the whole file is not good either: AIX grep has a line
+  # limit of 2048, but all sed's we know have understand at least 4000.
+  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+    dirpart=`AS_DIRNAME("$mf")`
+  else
+    continue
+  fi
+  # Extract the definition of DEPDIR, am__include, and am__quote
+  # from the Makefile without running `make'.
+  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  am__include=`sed -n 's/^am__include = //p' < "$mf"`
+  test -z "am__include" && continue
+  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n 's/^U = //p' < "$mf"`
+  # Find all dependency output files, they are included files with
+  # $(DEPDIR) in their names.  We invoke sed twice because it is the
+  # simplest approach to changing $(DEPDIR) to its actual value in the
+  # expansion.
+  for file in `sed -n "
+    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+    # Make sure the directory exists.
+    test -f "$dirpart/$file" && continue
+    fdir=`AS_DIRNAME(["$file"])`
+    AS_MKDIR_P([$dirpart/$fdir])
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 13
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.60])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_PROG_INSTALL_SH
+AM_PROG_INSTALL_STRIP
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+              [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+	      		     [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                  [_AM_DEPENDENCIES(CC)],
+                  [define([AC_PROG_CC],
+                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                  [_AM_DEPENDENCIES(CXX)],
+                  [define([AC_PROG_CXX],
+                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                  [_AM_DEPENDENCIES(OBJC)],
+                  [define([AC_PROG_OBJC],
+                          defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
+# From Jim Meyering
+
+# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+AC_DEFUN([AM_MAINTAINER_MODE],
+[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+  dnl maintainer-mode is disabled by default
+  AC_ARG_ENABLE(maintainer-mode,
+[  --enable-maintainer-mode  enable make rules and dependencies not useful
+			  (and sometimes confusing) to the casual installer],
+      USE_MAINTAINER_MODE=$enableval,
+      USE_MAINTAINER_MODE=no)
+  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+  AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
+  MAINT=$MAINTAINER_MODE_TRUE
+  AC_SUBST(MAINT)dnl
+]
+)
+
+AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
+
+# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 3
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+   am__include=include
+   am__quote=
+   _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+      am__include=.include
+      am__quote="\""
+      _am_result=BSD
+   fi
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 5
+
+# AM_PROG_CC_C_O
+# --------------
+# Like AC_PROG_CC_C_O, but changed for automake.
+AC_DEFUN([AM_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC_C_O])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+ac_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+dnl Make sure AC_PROG_CC is never called again, or it will override our
+dnl setting of CC.
+m4_define([AC_PROG_CC],
+          [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 5
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 3
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+#
+# SYNOPSIS
+#
+#   ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+#   This macro figures out how to build C programs using POSIX threads.
+#   It sets the PTHREAD_LIBS output variable to the threads library and
+#   linker flags, and the PTHREAD_CFLAGS output variable to any special
+#   C compiler flags that are needed. (The user can also force certain
+#   compiler flags/libs to be tested by setting these environment
+#   variables.)
+#
+#   Also sets PTHREAD_CC to any special C compiler that is needed for
+#   multi-threaded programs (defaults to the value of CC otherwise).
+#   (This is necessary on AIX to use the special cc_r compiler alias.)
+#
+#   NOTE: You are assumed to not only compile your program with these
+#   flags, but also link it with them as well. e.g. you should link
+#   with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
+#   $LIBS
+#
+#   If you are only building threads programs, you may wish to use
+#   these variables in your default LIBS, CFLAGS, and CC:
+#
+#          LIBS="$PTHREAD_LIBS $LIBS"
+#          CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+#          CC="$PTHREAD_CC"
+#
+#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
+#   constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
+#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+#   ACTION-IF-FOUND is a list of shell commands to run if a threads
+#   library is found, and ACTION-IF-NOT-FOUND is a list of commands to
+#   run it if it is not found. If ACTION-IF-FOUND is not specified, the
+#   default action will define HAVE_PTHREAD.
+#
+#   Please let the authors know if this macro fails on any platform, or
+#   if you have any other suggestions or comments. This macro was based
+#   on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
+#   (with help from M. Frigo), as well as ac_pthread and hb_pthread
+#   macros posted by Alejandro Forero Cuervo to the autoconf macro
+#   repository. We are also grateful for the helpful feedback of
+#   numerous users.
+#
+# LAST MODIFICATION
+#
+#   2006-05-29
+#
+# COPYLEFT
+#
+#   Copyright (c) 2006 Steven G. Johnson <stevenj@alum.mit.edu>
+#
+#   This program 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 2 of the
+#   License, or (at your option) any later version.
+#
+#   This program 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
+#   General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+#   02111-1307, USA.
+#
+#   As a special exception, the respective Autoconf Macro's copyright
+#   owner gives unlimited permission to copy, distribute and modify the
+#   configure scripts that are the output of Autoconf when processing
+#   the Macro. You need not follow the terms of the GNU General Public
+#   License when using or distributing such scripts, even though
+#   portions of the text of the Macro appear in them. The GNU General
+#   Public License (GPL) does govern all other use of the material that
+#   constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the
+#   Autoconf Macro released by the Autoconf Macro Archive. When you
+#   make and distribute a modified version of the Autoconf Macro, you
+#   may extend this special exception to the GPL to apply to your
+#   modified version as well.
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_SAVE
+AC_LANG_C
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test x"$acx_pthread_ok" = xno; then
+                PTHREAD_LIBS=""
+                PTHREAD_CFLAGS=""
+        fi
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try.  Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important.  Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+#       other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+#      doesn't hurt to check since this sometimes defines pthreads too;
+#      also defines -D_REENTRANT)
+#      ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+        *solaris*)
+
+        # On Solaris (at least, for some versions), libc contains stubbed
+        # (non-functional) versions of the pthreads routines, so link-based
+        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
+        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
+        # a function called by this macro, so we could check for that, but
+        # who knows whether they'll stub that too in a future libc.)  So,
+        # we'll just look for -pthreads and -lpthread first:
+
+        acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+        ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+        case $flag in
+                none)
+                AC_MSG_CHECKING([whether pthreads work without any flags])
+                ;;
+
+                -*)
+                AC_MSG_CHECKING([whether pthreads work with $flag])
+                PTHREAD_CFLAGS="$flag"
+                ;;
+
+		pthread-config)
+		AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+		if test x"$acx_pthread_config" = xno; then continue; fi
+		PTHREAD_CFLAGS="`pthread-config --cflags`"
+		PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+		;;
+
+                *)
+                AC_MSG_CHECKING([for the pthreads library -l$flag])
+                PTHREAD_LIBS="-l$flag"
+                ;;
+        esac
+
+        save_LIBS="$LIBS"
+        save_CFLAGS="$CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Check for various functions.  We must include pthread.h,
+        # since some functions may be macros.  (On the Sequent, we
+        # need a special flag -Kthread to make this header compile.)
+        # We check for pthread_join because it is in -lpthread on IRIX
+        # while pthread_create is in libc.  We check for pthread_attr_init
+        # due to DEC craziness with -lpthreads.  We check for
+        # pthread_cleanup_push because it is one of the few pthread
+        # functions on Solaris that doesn't have a non-functional libc stub.
+        # We try pthread_create on general principles.
+        AC_TRY_LINK([#include <pthread.h>],
+                    [pthread_t th; pthread_join(th, 0);
+                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
+                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+                    [acx_pthread_ok=yes])
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test "x$acx_pthread_ok" = xyes; then
+                break;
+        fi
+
+        PTHREAD_LIBS=""
+        PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+	AC_MSG_CHECKING([for joinable pthread attribute])
+	attr_name=unknown
+	for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+	    AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
+                        [attr_name=$attr; break])
+	done
+        AC_MSG_RESULT($attr_name)
+        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+                               [Define to necessary symbol if this constant
+                                uses a non-standard name on your system.])
+        fi
+
+        AC_MSG_CHECKING([if more special flags are required for pthreads])
+        flag=no
+        case "${host_cpu}-${host_os}" in
+            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+        esac
+        AC_MSG_RESULT(${flag})
+        if test "x$flag" != xno; then
+            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+        fi
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        # More AIX lossage: must compile with xlc_r or cc_r
+	if test x"$GCC" != xyes; then
+          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
+        else
+          PTHREAD_CC=$CC
+	fi
+else
+        PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+        :
+else
+        acx_pthread_ok=no
+        $2
+fi
+AC_LANG_RESTORE
+])dnl ACX_PTHREAD
+
+m4_include([m4/acinclude.m4])
diff --git a/CoreFoundation/auto_stubs.h b/CoreFoundation/auto_stubs.h
new file mode 100755
index 0000000..b82e17d
--- /dev/null
+++ b/CoreFoundation/auto_stubs.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ * 
+ * Copyright (c) 2008 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@
+ */
+/*	auto_stubs.h
+	Copyright 2005-2007, Apple Inc. All rights reserved.
+*/
+
+#if !defined(AUTO_STUBS_H)
+#define AUTO_STUBS_H 1
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#if DEPLOYMENT_TARGET_MACOSX
+#include <malloc/malloc.h>
+#endif
+
+#if defined(__GCC__)
+#include <objc/objc.h>
+#endif
+
+/* Stubs for functions in libauto. */
+
+#if !DEPLOYMENT_TARGET_MACOSX
+typedef unsigned long malloc_zone_t;
+typedef unsigned char boolean_t;
+#endif
+
+typedef malloc_zone_t auto_zone_t;
+
+enum { AUTO_TYPE_UNKNOWN = -1, AUTO_UNSCANNED = 1, AUTO_OBJECT = 2, AUTO_MEMORY_SCANNED = 0, AUTO_MEMORY_UNSCANNED = AUTO_UNSCANNED, AUTO_OBJECT_SCANNED = AUTO_OBJECT, AUTO_OBJECT_UNSCANNED = AUTO_OBJECT | AUTO_UNSCANNED };
+typedef unsigned long auto_memory_type_t;
+
+CF_INLINE void *auto_zone(void) { return 0; }
+CF_INLINE void *auto_zone_allocate_object(void *zone, size_t size, auto_memory_type_t type, boolean_t rc, boolean_t clear) { return 0; }
+CF_INLINE const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; }
+CF_INLINE void auto_zone_retain(void *zone, void *ptr) {}
+CF_INLINE unsigned int auto_zone_release(void *zone, void *ptr) { return 0; }
+CF_INLINE unsigned int auto_zone_retain_count(void *zone, const void *ptr) { return 0; }
+CF_INLINE void auto_zone_set_layout_type(void *zone, void *ptr, auto_memory_type_t type) {}
+CF_INLINE void auto_zone_write_barrier_range(void *zone, void *address, size_t size) {}
+CF_INLINE boolean_t auto_zone_is_finalized(void *zone, const void *ptr) { return 0; }
+CF_INLINE size_t auto_zone_size(void *zone, const void *ptr) { return 0; }
+CF_INLINE void auto_register_weak_reference(void *zone, const void *referent, void **referrer, uintptr_t *counter, void **listHead, void **listElement) {}
+CF_INLINE void auto_unregister_weak_reference(void *zone, const void *referent, void **referrer) {}
+CF_INLINE void auto_zone_register_thread(void *zone) {}
+CF_INLINE void auto_zone_unregister_thread(void *zone) {}
+CF_INLINE boolean_t auto_zone_is_valid_pointer(void *zone, const void *ptr) { return 0; }
+CF_INLINE auto_memory_type_t auto_zone_get_layout_type(auto_zone_t *zone, void *ptr) { return AUTO_UNSCANNED; }
+
+#if defined(__OBJC__)
+CF_INLINE void objc_collect_if_needed(unsigned long options) {}
+CF_INLINE Boolean objc_collecting_enabled(void) { return 0; }
+CF_INLINE id objc_allocate_object(Class cls, int extra) { return 0; }
+CF_INLINE id objc_assign_strongCast(id val, id *dest) { return (*dest = val); }
+CF_INLINE id objc_assign_global(id val, id *dest) { return (*dest = val); }
+CF_INLINE id objc_assign_ivar(id val, id dest, unsigned int offset) { id *d = (id *)((char *)dest + offset); return (*d = val); }
+CF_INLINE void *objc_memmove_collectable(void *dst, const void *src, size_t size) { return memmove(dst, src, size); }
+CF_INLINE Boolean objc_is_finalized(void *ptr) { return 0; }
+#endif
+
+#endif /* ! AUTO_STUBS_H */
+
diff --git a/CoreFoundation/compat/Makefile.am b/CoreFoundation/compat/Makefile.am
new file mode 100644
index 0000000..df230c2
--- /dev/null
+++ b/CoreFoundation/compat/Makefile.am
@@ -0,0 +1,6 @@
+noinst_LTLIBRARIES	= libcompat.la
+
+EXTRA_DIST		= dirent.h dirent.c
+
+libcompat_la_SOURCES	=
+libcompat_la_LIBADD	= @LTLIBOBJS@
diff --git a/CoreFoundation/compat/Makefile.in b/CoreFoundation/compat/Makefile.in
new file mode 100644
index 0000000..0c5b23f
--- /dev/null
+++ b/CoreFoundation/compat/Makefile.in
@@ -0,0 +1,464 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = compat
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in flsl.c \
+	gettimeofday.c strlcat.c strlcpy.c
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libcompat_la_DEPENDENCIES = @LTLIBOBJS@
+am_libcompat_la_OBJECTS =
+libcompat_la_OBJECTS = $(am_libcompat_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(libcompat_la_SOURCES)
+DIST_SOURCES = $(libcompat_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libcompat.la
+EXTRA_DIST = dirent.h dirent.c
+libcompat_la_SOURCES = 
+libcompat_la_LIBADD = @LTLIBOBJS@
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  compat/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  compat/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libcompat.la: $(libcompat_la_OBJECTS) $(libcompat_la_DEPENDENCIES) 
+	$(LINK)  $(libcompat_la_OBJECTS) $(libcompat_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/flsl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gettimeofday.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcpy.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf $(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf $(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/compat/dirent.c b/CoreFoundation/compat/dirent.c
new file mode 100644
index 0000000..e8eaf1a
--- /dev/null
+++ b/CoreFoundation/compat/dirent.c
@@ -0,0 +1,106 @@
+/*
+ * The Windows directory handling logic is courtesy of the FreeBSD shttpd sources.
+ */
+/*
+ * Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <errno.h>
+#include <malloc.h>
+#include <stdint.h>
+
+#include <windows.h>
+
+#include "dirent.h"
+
+DIR* opendir (const char *name)
+{
+   DIR* dir = NULL;
+   size_t          base_length;
+   const char* all;
+
+   if (name && name[0]) {
+      base_length = strlen(name);
+      all = strchr("/\\", name[base_length - 1]) ? "*" : "/*";
+
+      if ((dir = (DIR*)malloc(sizeof *dir)) != NULL &&
+          (dir->name = (char*)malloc(base_length + strlen(all) + 1)) != 0) {
+         (void) strcat(strcpy(dir->name, name), all);
+
+         if ((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1) {
+            dir->result.d_name = 0;
+         } else {
+            free(dir->name);
+            free(dir);
+            dir = 0;
+         }
+      } else {
+         free(dir);
+         dir = NULL;
+         errno = ENOMEM;
+      }
+   } else {
+      errno = EINVAL;
+   }
+
+   return (dir);
+}
+
+int closedir (DIR* dir)
+{
+   int result = -1;
+
+   if (dir) {
+      if(dir->handle != -1)
+         result = _findclose(dir->handle);
+
+      free(dir->name);
+      free(dir);
+   }
+
+   if (result == -1)
+      errno = EBADF;
+
+   return (result);
+}
+
+struct dirent* readdir (DIR *dir)
+{
+   struct dirent* result = 0;
+
+   if (dir && dir->handle != -1) {
+      if (!dir->result.d_name ||
+         _findnext(dir->handle, &dir->info) != -1) {
+         result = &dir->result;
+         result->d_name = dir->info.name;
+         result->d_fileno = 1;   // Not real!
+
+         if (dir->info.attrib & FILE_ATTRIBUTE_DIRECTORY)
+            result->d_type = DT_DIR;
+         else
+            result->d_type = DT_UNKNOWN;
+      }
+   } else {
+      errno = EBADF;
+   }
+
+   return (result);
+}
diff --git a/CoreFoundation/compat/dirent.h b/CoreFoundation/compat/dirent.h
new file mode 100644
index 0000000..c3bea75
--- /dev/null
+++ b/CoreFoundation/compat/dirent.h
@@ -0,0 +1,64 @@
+/*
+ * The Windows directory handling logic is courtesy of the FreeBSD shttpd sources.
+ */
+/*
+ * Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined(__COREFOUNDATION_WINDOWS_DIRENT__)
+#define __COREFOUNDATION_WINDOWS_DIRENT__ 1
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <direct.h>
+#include <io.h>
+
+/* POSIX dirent interface */
+struct dirent {
+        char*                   d_name;
+        uint8_t                 d_type;
+        long                    d_fileno;
+};
+
+typedef struct DIR {
+        long                    handle;
+        struct _finddata_t      info;
+        struct dirent           result;
+        char*                   name;
+} DIR;
+
+extern DIR* opendir (const char* name);
+extern struct dirent* readdir (DIR* dir);
+extern int closedir (DIR* dir);
+
+#define	DT_UNKNOWN	     0
+#define	DT_DIR		     4
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __COREFOUNDATION_WINDOWS_DIRENT__ */
diff --git a/CoreFoundation/compat/flsl.c b/CoreFoundation/compat/flsl.c
new file mode 100644
index 0000000..b0f3ac8
--- /dev/null
+++ b/CoreFoundation/compat/flsl.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *      The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+ 
+/*
+ * Find Last Set bit
+ */
+extern int flsl(long mask)
+{
+    int bit;
+ 
+    if (mask == 0)
+        return (0);
+    for (bit = 1; mask != 1; bit++)
+        mask = (unsigned long)mask >> 1;
+    return (bit);
+}
diff --git a/CoreFoundation/compat/gettimeofday.c b/CoreFoundation/compat/gettimeofday.c
new file mode 100644
index 0000000..f46b5f0
--- /dev/null
+++ b/CoreFoundation/compat/gettimeofday.c
@@ -0,0 +1,125 @@
+#if !defined(__GNUC__)
+/* /////////////////////////////////////////////////////////////////////////////
+ * File:    time.c
+ *
+ * Purpose: gettimeofday() for the Win32 platform.
+ *
+ * Created: 1st November 2003
+ * Updated: 22nd April 2008
+ *
+ * Home:    http://synesis.com.au/software/
+ *
+ * Copyright (c) 2003-2008, Matthew Wilson and Synesis Software
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer. 
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the names of Matthew Wilson and Synesis Software nor the names of
+ *   any contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ////////////////////////////////////////////////////////////////////////// */
+
+
+#ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION
+# define _SYNSOFT_VER_C_TIME_MAJOR      2
+# define _SYNSOFT_VER_C_TIME_MINOR      0
+# define _SYNSOFT_VER_C_TIME_REVISION   8
+# define _SYNSOFT_VER_C_TIME_EDIT       20
+#endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */
+
+/* /////////////////////////////////////////////////////////////////////////////
+ * Includes
+ */
+
+/* If we're going to include 'windows.h', then it has to be included first, so
+ * as to put off the defintion of timeval in sys/time.h. Regrettably, the
+ * WinSock header defines it without any conception of sys/time.h. Thanks MS!
+ */
+#ifndef __MWERKS__
+# include <windows.h>
+#endif /* !__MWERKS__ */
+
+#if defined(_MSC_VER)
+#include <winsock2.h>
+#else
+#include <sys/time.h>
+#endif
+
+struct timezone;
+
+#include <windows.h>
+
+/* /////////////////////////////////////////////////////////////////////////////
+ * Helper functions
+ */
+
+/** This function is from the STLSoft libraries */
+extern long FILETIMEToUNIXTime(FILETIME const *ft, long *microseconds)
+{
+#if defined(__COMO__)
+    long long   i;
+#else /* ? compiler */
+    LONGLONG    i;
+#endif /* compiler */
+
+    i = ft->dwHighDateTime;
+    i <<= 32;
+    i |= ft->dwLowDateTime;
+
+#if (   (   defined(__BORLANDC__) && \
+            __BORLANDC__ >= 0x0582) || \
+        defined(__DMC__) || \
+        defined(__COMO__) || \
+        defined(__GNUC__) || \
+        defined(__MWERKS__))
+    i -= 116444736000000000LL;
+#else
+    i -= 116444736000000000L;
+#endif /* compiler */
+    if(NULL != microseconds)
+    {
+        *microseconds = (long)((i % 10000000) / 10);
+    }
+    i /= 10000000;
+
+    return (long)i;
+}
+
+/* /////////////////////////////////////////////////////////////////////////////
+ * API functions
+ */
+
+void gettimeofday(struct timeval *tv, void *dummy)
+{
+    SYSTEMTIME  st;
+    FILETIME    ft;
+
+    ((void)dummy);
+
+    GetSystemTime(&st);
+    (void)SystemTimeToFileTime(&st, &ft);
+
+    tv->tv_sec = FILETIMEToUNIXTime(&ft, &tv->tv_usec);
+}
+
+/* ////////////////////////////////////////////////////////////////////////// */
+#endif
diff --git a/CoreFoundation/compat/strlcat.c b/CoreFoundation/compat/strlcat.c
new file mode 100644
index 0000000..a66136f
--- /dev/null
+++ b/CoreFoundation/compat/strlcat.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left).  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t strlcat(char *dst, const char *src, size_t siz)
+{
+    char *d = dst;
+    const char *s = src;
+    size_t n = siz;
+    size_t dlen;
+
+    /* Find the end of dst and adjust bytes left but don't go past end */
+    while (n-- != 0 && *d != '\0')
+        d++;
+    dlen = d - dst;
+    n = siz - dlen;
+
+    if (n == 0)
+        return(dlen + strlen(s));
+    while (*s != '\0') {
+        if (n != 1) {
+            *d++ = *s;
+            n--;
+        }
+        s++;
+    }
+    *d = '\0';
+
+    return(dlen + (s - src));	/* count does not include NUL */
+}
+
diff --git a/CoreFoundation/compat/strlcpy.c b/CoreFoundation/compat/strlcpy.c
new file mode 100644
index 0000000..17641ea
--- /dev/null
+++ b/CoreFoundation/compat/strlcpy.c
@@ -0,0 +1,50 @@
+/*	$OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t strlcpy(char *dst, const char *src, size_t siz)
+{
+    char *d = dst;
+    const char *s = src;
+    size_t n = siz;
+
+    /* Copy as many bytes as will fit */
+    if (n != 0) {
+        while (--n != 0) {
+            if ((*d++ = *s++) == '\0')
+                break;
+        }
+    }
+
+    /* Not enough room in dst, add NUL and traverse rest of src */
+    if (n == 0) {
+        if (siz != 0)
+            *d = '\0';		/* NUL-terminate dst */
+        while (*s++)
+            ;
+    }
+
+    return(s - src - 1);	/* count does not include NUL */
+}
diff --git a/CoreFoundation/config/compile b/CoreFoundation/config/compile
new file mode 100755
index 0000000..1b1d232
--- /dev/null
+++ b/CoreFoundation/config/compile
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program 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 2, or (at your option)
+# any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+	# configure might choose to run compile as `compile cc -o foo foo.c'.
+	# So we strip `-o arg' only if arg is an object.
+	eat=1
+	case $2 in
+	  *.o | *.obj)
+	    ofile=$2
+	    ;;
+	  *)
+	    set x "$@" -o "$2"
+	    shift
+	    ;;
+	esac
+	;;
+      *.c)
+	cfile=$1
+	set x "$@" "$1"
+	shift
+	;;
+      *)
+	set x "$@" "$1"
+	shift
+	;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no `-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # `.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use `[/.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/CoreFoundation/config/config.guess b/CoreFoundation/config/config.guess
new file mode 100755
index 0000000..f32079a
--- /dev/null
+++ b/CoreFoundation/config/config.guess
@@ -0,0 +1,1526 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
+
+timestamp='2008-01-23'
+
+# This file 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+	for c in cc gcc c89 c99 ; do
+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found ;
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# NetBSD (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	#
+	# Note: NetBSD doesn't particularly care about the vendor
+	# portion of the name.  We always set it to "unknown".
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	case "${UNAME_MACHINE_ARCH}" in
+	    armeb) machine=armeb-unknown ;;
+	    arm*) machine=arm-unknown ;;
+	    sh3el) machine=shl-unknown ;;
+	    sh3eb) machine=sh-unknown ;;
+	    sh5el) machine=sh5le-unknown ;;
+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE_ARCH}" in
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+		eval $set_cc_for_build
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep __ELF__ >/dev/null
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	# Debian GNU/NetBSD machines have a different userland, and
+	# thus, need a distinct triplet. However, they do not need
+	# kernel version information, so it can be replaced with a
+	# suitable tag, in the style of linux-gnu.
+	case "${UNAME_VERSION}" in
+	    Debian*)
+		release='-gnu'
+		;;
+	    *)
+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		;;
+	esac
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit ;;
+    *:OpenBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+	exit ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+	exit ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+	exit ;;
+    macppc:MirBSD:*:*)
+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    alpha:OSF1:*:*)
+	case $UNAME_RELEASE in
+	*4.0)
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+		;;
+	*5.*)
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
+	# According to Compaq, /usr/sbin/psrinfo has been available on
+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+	# covers most systems running today.  This code pipes the CPU
+	# types through head -n 1, so we only detect the type of CPU 0.
+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+	case "$ALPHA_CPU_TYPE" in
+	    "EV4 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV4.5 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "LCA4 (21066/21068)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV5 (21164)")
+		UNAME_MACHINE="alphaev5" ;;
+	    "EV5.6 (21164A)")
+		UNAME_MACHINE="alphaev56" ;;
+	    "EV5.6 (21164PC)")
+		UNAME_MACHINE="alphapca56" ;;
+	    "EV5.7 (21164PC)")
+		UNAME_MACHINE="alphapca57" ;;
+	    "EV6 (21264)")
+		UNAME_MACHINE="alphaev6" ;;
+	    "EV6.7 (21264A)")
+		UNAME_MACHINE="alphaev67" ;;
+	    "EV6.8CB (21264C)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8AL (21264B)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8CX (21264D)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.9A (21264/EV69A)")
+		UNAME_MACHINE="alphaev69" ;;
+	    "EV7 (21364)")
+		UNAME_MACHINE="alphaev7" ;;
+	    "EV7.9 (21364A)")
+		UNAME_MACHINE="alphaev79" ;;
+	esac
+	# A Pn.n version is a patched version.
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-morphos
+	exit ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+	exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+	echo arm-unknown-riscos
+	exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit ;;
+    DRS?6000:unix:4.0:6*)
+	echo sparc-icl-nx6
+	exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+	case `/usr/bin/uname -p` in
+	    sparc) echo sparc-icl-nx7; exit ;;
+	esac ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c &&
+	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+	  SYSTEM_NAME=`$dummy $dummyarg` &&
+	    { echo "$SYSTEM_NAME"; exit; }
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit ;;
+    Motorola:*:4.3:PL8-*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+	echo i386-ibm-aix
+	exit ;;
+    ia64:AIX:*:*)
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+		then
+			echo "$SYSTEM_NAME"
+		else
+			echo rs6000-ibm-aix3.2.5
+		fi
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit ;;
+    *:AIX:*:[456])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit ;;
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+		if [ -x /usr/bin/getconf ]; then
+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+		fi
+		if [ "${HP_ARCH}" = "" ]; then
+		    eval $set_cc_for_build
+		    sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    test -z "$HP_ARCH" && HP_ARCH=hppa
+		fi ;;
+	esac
+	if [ ${HP_ARCH} = "hppa2.0w" ]
+	then
+	    eval $set_cc_for_build
+
+	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+	    # generating 64-bit code.  GNU and HP use different nomenclature:
+	    #
+	    # $ CC_FOR_BUILD=cc ./config.guess
+	    # => hppa2.0w-hp-hpux11.23
+	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+	    # => hppa64-hp-hpux11.23
+
+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+		grep __LP64__ >/dev/null
+	    then
+		HP_ARCH="hppa2.0w"
+	    else
+		HP_ARCH="hppa64"
+	    fi
+	fi
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit ;;
+    3050*:HI-UX:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+		{ echo "$SYSTEM_NAME"; exit; }
+	echo unknown-hitachi-hiuxwe2
+	exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit ;;
+    i*86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    *:UNICOS/mp:*:*)
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:FreeBSD:*:*)
+	case ${UNAME_MACHINE} in
+	    pc98)
+		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    amd64)
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
+	exit ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit ;;
+    *:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit ;;
+    i*:windows32*:*)
+    	# uname -m includes "-pc" on this system.
+    	echo ${UNAME_MACHINE}-mingw32
+	exit ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit ;;
+    *:Interix*:[3456]*)
+    	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    EM64T | authenticamd)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i586-pc-interix
+	exit ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+	echo x86_64-unknown-cygwin
+	exit ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    *:GNU:*:*)
+	# the GNU system
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit ;;
+    *:GNU/*:*:*)
+	# other systems with GNU libc and userland
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	exit ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit ;;
+    arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	else
+	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    cris:Linux:*:*)
+	echo cris-axis-linux-gnu
+	exit ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-gnu
+	exit ;;
+    frv:Linux:*:*)
+    	echo frv-unknown-linux-gnu
+	exit ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    mips:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips
+	#undef mipsel
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mipsel
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	;;
+    mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips64
+	#undef mips64el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mips64el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips64
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	;;
+    or32:Linux:*:*)
+	echo or32-unknown-linux-gnu
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
+	exit ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+	# Look for CPU level
+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
+	  *)    echo hppa-unknown-linux-gnu ;;
+	esac
+	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit ;;
+    sh64*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-gnu
+	exit ;;
+    x86_64:Linux:*:*)
+	echo x86_64-unknown-linux-gnu
+	exit ;;
+    xtensa*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    i*86:Linux:*:*)
+	# The BFD linker knows what the default object file format is, so
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	# Set LC_ALL=C to ensure ld outputs messages in English.
+	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+			 | sed -ne '/supported targets:/!d
+				    s/[ 	][ 	]*/ /g
+				    s/.*supported targets: *//
+				    s/ .*//
+				    p'`
+        case "$ld_supported_targets" in
+	  elf32-i386)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  a.out-i386-linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit ;;
+	  coff-i386)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit ;;
+	  "")
+		# Either a pre-BFD a.out linker (linux-gnuoldld) or
+		# one that does not give us useful --help.
+		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+		exit ;;
+	esac
+	# Determine whether the default compiler is a.out or elf
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <features.h>
+	#ifdef __ELF__
+	# ifdef __GLIBC__
+	#  if __GLIBC__ >= 2
+	LIBC=gnu
+	#  else
+	LIBC=gnulibc1
+	#  endif
+	# else
+	LIBC=gnulibc1
+	# endif
+	#else
+	#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+	LIBC=gnu
+	#else
+	LIBC=gnuaout
+	#endif
+	#endif
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^LIBC/{
+		s: ::g
+		p
+	    }'`"
+	test x"${LIBC}" != x && {
+		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+		exit
+	}
+	test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+	;;
+    i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
+	echo i386-sequent-sysv4
+	exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit ;;
+    i*86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit ;;
+    i*86:syllable:*:*)
+	echo ${UNAME_MACHINE}-pc-syllable
+	exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit ;;
+    i*86:*:5:[678]*)
+    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	exit ;;
+    i*86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+	echo i386-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+	echo m68k-convergent-sysv
+	exit ;;
+    M680?0:D-NIX:5.3:*)
+	echo m68k-diab-dnix
+	exit ;;
+    M68*:*:R3V[5678]*:*)
+	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes@openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit ;;
+    *:*:*:FTX*)
+	# From seanf@swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit ;;
+    i*86:VOS:*:*)
+	# From Paul.Green@stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit ;;
+    *:VOS:*:*)
+	# From Paul.Green@stratus.com.
+	echo hppa1.1-stratus-vos
+	exit ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-unknown-sysv${UNAME_RELEASE}
+	fi
+        exit ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-6:SUPER-UX:*:*)
+	echo sx6-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Darwin:*:*)
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+	exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
+		UNAME_MACHINE=pc
+	fi
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+	exit ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit ;;
+    *:TOPS-10:*:*)
+	echo pdp10-unknown-tops10
+	exit ;;
+    *:TENEX:*:*)
+	echo pdp10-unknown-tenex
+	exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit ;;
+    *:TOPS-20:*:*)
+	echo pdp10-unknown-tops20
+	exit ;;
+    *:ITS:*:*)
+	echo pdp10-unknown-its
+	exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+	exit ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit ;;
+    *:*VMS:*:*)
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms ; exit ;;
+	    I*) echo ia64-dec-vms ; exit ;;
+	    V*) echo vax-dec-vms ; exit ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
+	exit ;;
+    i*86:skyos:*:*)
+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+	exit ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit ;;
+    c34*)
+	echo c34-convex-bsd
+	exit ;;
+    c38*)
+	echo c38-convex-bsd
+	exit ;;
+    c4*)
+	echo c4-convex-bsd
+	exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/CoreFoundation/config/config.sub b/CoreFoundation/config/config.sub
new file mode 100755
index 0000000..6759825
--- /dev/null
+++ b/CoreFoundation/config/config.sub
@@ -0,0 +1,1658 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
+
+timestamp='2008-01-16'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis | -knuth | -cray)
+		os=
+		basic_machine=$1
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-chorusos*)
+		os=-chorusos
+		basic_machine=$1
+		;;
+ 	-chorusrdb)
+ 		os=-chorusrdb
+		basic_machine=$1
+ 		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5v6*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	1750a | 580 \
+	| a29k \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+	| am33_2.0 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| bfin \
+	| c4x | clipper \
+	| d10v | d30v | dlx | dsp16xx \
+	| fido | fr30 | frv \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| ip2k | iq2000 \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | mcore | mep \
+	| mips | mipsbe | mipseb | mipsel | mipsle \
+	| mips16 \
+	| mips64 | mips64el \
+	| mips64vr | mips64vrel \
+	| mips64orion | mips64orionel \
+	| mips64vr4100 | mips64vr4100el \
+	| mips64vr4300 | mips64vr4300el \
+	| mips64vr5000 | mips64vr5000el \
+	| mips64vr5900 | mips64vr5900el \
+	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipstx39 | mipstx39el \
+	| mn10200 | mn10300 \
+	| mt \
+	| msp430 \
+	| nios | nios2 \
+	| ns16k | ns32k \
+	| or32 \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh64 | sh64le \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu | strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
+	| v850 | v850e \
+	| we32k \
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| z8k)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i*86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	580-* \
+	| a29k-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+	| avr-* | avr32-* \
+	| bfin-* | bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | craynv-* | cydra-* \
+	| d10v-* | d30v-* | dlx-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| ip2k-* | iq2000-* \
+	| m32c-* | m32r-* | m32rle-* \
+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* \
+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+	| mips16-* \
+	| mips64-* | mips64el-* \
+	| mips64vr-* | mips64vrel-* \
+	| mips64orion-* | mips64orionel-* \
+	| mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* \
+	| mips64vr5000-* | mips64vr5000el-* \
+	| mips64vr5900-* | mips64vr5900el-* \
+	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64sb1-* | mipsisa64sb1el-* \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
+	| mt-* \
+	| msp430-* \
+	| nios-* | nios2-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tron-* \
+	| v850-* | v850e-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa*-* \
+	| ymp-* \
+	| z8k-*)
+		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amd64)
+		basic_machine=x86_64-pc
+		;;
+	amd64-*)
+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	c90)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | j90)
+		basic_machine=j90-cray
+		os=-unicos
+		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
+	cr16)
+		basic_machine=cr16-unknown
+		os=-elf
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	decsystem10* | dec10*)
+		basic_machine=pdp10-dec
+		os=-tops10
+		;;
+	decsystem20* | dec20*)
+		basic_machine=pdp10-dec
+		os=-tops20
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	go32)
+		basic_machine=i386-pc
+		os=-go32
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i*86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i*86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i*86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i*86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	morphos)
+		basic_machine=powerpc-unknown
+		os=-morphos
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	openrisc | openrisc-*)
+		basic_machine=or32-unknown
+		;;
+	os400)
+		basic_machine=powerpc-ibm
+		os=-os400
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+	pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium | p5 | k5 | k6 | nexgen | viac3)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2 | pentiumiii | pentium3)
+		basic_machine=i686-pc
+		;;
+	pentium4)
+		basic_machine=i786-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium4-*)
+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=power-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+		;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+		;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64)	basic_machine=powerpc64-unknown
+		;;
+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+		basic_machine=powerpc64le-unknown
+		;;
+	ppc64le-* | powerpc64little-*)
+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	rdos)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	s390 | s390-*)
+		basic_machine=s390-ibm
+		;;
+	s390x | s390x-*)
+		basic_machine=s390x-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sb1)
+		basic_machine=mipsisa64sb1-unknown
+		;;
+	sb1el)
+		basic_machine=mipsisa64sb1el-unknown
+		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
+	sparclite-wrs | simso-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=alphaev5-cray
+		os=-unicos
+		;;
+	t90)
+		basic_machine=t90-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	toad1)
+		basic_machine=pdp10-xkl
+		os=-tops20
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	tpf)
+		basic_machine=s390x-ibm
+		os=-tpf
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+		basic_machine=f301-fujitsu
+		;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
+		;;
+	xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp10)
+		# there are many clones, so DEC is not a safe bet
+		basic_machine=pdp10-unknown
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+		basic_machine=sparc-sun
+		;;
+	cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	*-unknown)
+		# Make sure to match an already-canonicalized machine name.
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -openbsd* | -solidbsd* \
+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto-qnx*)
+		;;
+	-nto*)
+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux-dietlibc)
+		os=-linux-dietlibc
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+        -os400*)
+		os=-os400
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-atheos*)
+		os=-atheos
+		;;
+	-syllable*)
+		os=-syllable
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-nova*)
+		os=-rtmk-nova
+		;;
+	-ns2 )
+		os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+        -tpf*)
+		os=-tpf
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+		os=-mint
+		;;
+	-aros*)
+		os=-aros
+		;;
+	-kaos*)
+		os=-kaos
+		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+		os=-elf
+		;;
+        spu-*)
+		os=-elf
+		;;
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+        c4x-* | tic4x-*)
+        	os=-coff
+		;;
+	# This must come before the *-dec entry.
+	pdp10-*)
+		os=-tops20
+		;;
+	pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+        mep-*)
+		os=-elf
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	or32-*)
+		os=-coff
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-haiku)
+		os=-haiku
+		;;
+	*-ibm)
+		os=-aix
+		;;
+    	*-knuth)
+		os=-mmixware
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+	*-gould)
+		os=-sysv
+		;;
+	*-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+	*-sgi)
+		os=-irix
+		;;
+	*-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f30[01]-fujitsu | f700-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-os400*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-tpf*)
+				vendor=ibm
+				;;
+			-vxsim* | -vxworks* | -windiss*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
+			-vos*)
+				vendor=stratus
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/CoreFoundation/config/depcomp b/CoreFoundation/config/depcomp
new file mode 100755
index 0000000..e5f9736
--- /dev/null
+++ b/CoreFoundation/config/depcomp
@@ -0,0 +1,589 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2007-03-29.01
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
+# Foundation, Inc.
+
+# This program 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 2, or (at your option)
+# any later version.
+
+# This program 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> $depfile
+    echo >> $depfile
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> $depfile
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
+    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
+  else
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mechanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no
+  for arg in "$@"; do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  "$@" || exit $?
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+	set fnord "$@"
+	shift
+	shift
+	;;
+    *)
+	set fnord "$@" "$arg"
+	shift
+	shift
+	;;
+    esac
+  done
+  "$@" -E |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
+  echo "	" >> "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/CoreFoundation/config/install-sh b/CoreFoundation/config/install-sh
new file mode 100755
index 0000000..a5897de
--- /dev/null
+++ b/CoreFoundation/config/install-sh
@@ -0,0 +1,519 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2006-12-25.00
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""	$nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+	shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
+
+    -o) chowncmd="$chownprog $2"
+	shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+	shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)	shift
+	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dst_arg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+	echo "$0: $dst_arg: Is a directory" >&2
+	exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
+
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
+
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      if test -z "$dir_arg" || {
+		   # Check for POSIX incompatibilities with -m.
+		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+		   # other-writeable bit of parent directory when it shouldn't.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+	/*) prefix='/';;
+	-*) prefix='./';;
+	*)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+	test -z "$d" && continue
+
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/CoreFoundation/config/ltmain.sh b/CoreFoundation/config/ltmain.sh
new file mode 100755
index 0000000..6d056ec
--- /dev/null
+++ b/CoreFoundation/config/ltmain.sh
@@ -0,0 +1,7880 @@
+# Generated from ltmain.m4sh.
+
+# ltmain.sh (GNU libtool) 2.2.4
+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool 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 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+#     --config             show all configuration variables
+#     --debug              enable verbose shell tracing
+# -n, --dry-run            display commands without modifying any files
+#     --features           display basic configuration information and exit
+#     --mode=MODE          use operation mode MODE
+#     --preserve-dup-deps  don't remove duplicate dependency libraries
+#     --quiet, --silent    don't print informational messages
+#     --tag=TAG            use configuration variables from tag TAG
+# -v, --verbose            print informational messages (default)
+#     --version            print version information
+# -h, --help               print short or long help message
+#
+# MODE must be one of the following:
+#
+#       clean              remove files from the build directory
+#       compile            compile a source file into a libtool object
+#       execute            automatically set library path, then run a program
+#       finish             complete the installation of libtool libraries
+#       install            install libraries or executables
+#       link               create a library or an executable
+#       uninstall          remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+#       host-triplet:	$host
+#       shell:		$SHELL
+#       compiler:		$LTCC
+#       compiler flags:		$LTCFLAGS
+#       linker:		$LD (gnu? $with_gnu_ld)
+#       $progname:		(GNU libtool) 2.2.4 Debian-2.2.4-0ubuntu4
+#       automake:		$automake_version
+#       autoconf:		$autoconf_version
+#
+# Report bugs to <bug-libtool@gnu.org>.
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION="2.2.4 Debian-2.2.4-0ubuntu4"
+TIMESTAMP=""
+package_revision=1.2976
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# NLS nuisances: We save the old values to restore during execute mode.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+          save_$lt_var=\$$lt_var
+          $lt_var=C
+	  export $lt_var
+	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+	fi"
+done
+
+$lt_unset CDPATH
+
+
+
+
+
+: ${CP="cp -f"}
+: ${ECHO="echo"}
+: ${EGREP="/bin/grep -E"}
+: ${FGREP="/bin/grep -F"}
+: ${GREP="/bin/grep"}
+: ${LN_S="ln -s"}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SED="/bin/sed"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" 	$lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+# In the unlikely event $progname began with a '-', it would play havoc with
+# func_echo (imagine progname=-n), so we prepend ./ in that case:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+case $progname in
+  -*) progname=./$progname ;;
+esac
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+  [\\/]*|[A-Za-z]:\\*) ;;
+  *[\\/]*)
+     progdir=$func_dirname_result
+     progdir=`cd "$progdir" && pwd`
+     progpath="$progdir/$progname"
+     ;;
+  *)
+     save_IFS="$IFS"
+     IFS=:
+     for progdir in $PATH; do
+       IFS="$save_IFS"
+       test -x "$progdir/$progname" && break
+     done
+     IFS="$save_IFS"
+     test -n "$progdir" || progdir=`pwd`
+     progpath="$progdir/$progname"
+     ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+  s/$bs4/&\\
+/g
+  s/^$bs2$dollar/$bs&/
+  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+  s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+    $ECHO "$progname${mode+: }$mode: $*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $opt_verbose && func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
+
+    # bash bug again:
+    :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+    func_error ${1+"$@"}
+    func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information."  ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+    $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+    my_directory_path="$1"
+    my_dir_list=
+
+    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+      # Protect directory names starting with `-'
+      case $my_directory_path in
+        -*) my_directory_path="./$my_directory_path" ;;
+      esac
+
+      # While some portion of DIR does not yet exist...
+      while test ! -d "$my_directory_path"; do
+        # ...make a list in topmost first order.  Use a colon delimited
+	# list incase some portion of path contains whitespace.
+        my_dir_list="$my_directory_path:$my_dir_list"
+
+        # If the last portion added has no slash in it, the list is done
+        case $my_directory_path in */*) ;; *) break ;; esac
+
+        # ...otherwise throw away the child directory and loop
+        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
+      done
+      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
+
+      save_mkdir_p_IFS="$IFS"; IFS=':'
+      for my_dir in $my_dir_list; do
+	IFS="$save_mkdir_p_IFS"
+        # mkdir can fail with a `File exist' error if two processes
+        # try to create one of the directories concurrently.  Don't
+        # stop in that case!
+        $MKDIR "$my_dir" 2>/dev/null || :
+      done
+      IFS="$save_mkdir_p_IFS"
+
+      # Bail out if we (or some other process) failed to create a directory.
+      test -d "$my_directory_path" || \
+        func_fatal_error "Failed to create \`$1'"
+    fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$opt_dry_run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+        # Failing that, at least try and use $RANDOM to avoid a race
+        my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+        save_mktempdir_umask=`umask`
+        umask 0077
+        $MKDIR "$my_tmpdir"
+        umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || \
+        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+    fi
+
+    $ECHO "X$my_tmpdir" | $Xsed
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+    case $1 in
+      *[\\\`\"\$]*)
+	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
+      *)
+        func_quote_for_eval_unquoted_result="$1" ;;
+    esac
+
+    case $func_quote_for_eval_unquoted_result in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting, command substitution and and variable
+      # expansion for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+        ;;
+      *)
+        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+    esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    case $1 in
+      *[\\\`\"]*)
+	my_arg=`$ECHO "X$1" | $Xsed \
+	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        my_arg="$1" ;;
+    esac
+
+    case $my_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        my_arg="\"$my_arg\""
+        ;;
+    esac
+
+    func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$my_cmd"
+      my_status=$?
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$lt_user_locale
+	    $my_cmd"
+      my_status=$?
+      eval "$lt_safe_locale"
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
+        s/^# //
+	s/^# *$//
+        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+        p
+     }' < "$progpath"
+     exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+    $SED -n '/^# Usage:/,/# -h/ {
+        s/^# //
+	s/^# *$//
+	s/\$progname/'$progname'/
+	p
+    }' < "$progpath"
+    $ECHO
+    $ECHO "run \`$progname --help | more' for full usage"
+    exit $?
+}
+
+# func_help
+# Echo long help message to standard output and exit.
+func_help ()
+{
+    $SED -n '/^# Usage:/,/# Report bugs to/ {
+        s/^# //
+	s/^# *$//
+	s*\$progname*'$progname'*
+	s*\$host*'"$host"'*
+	s*\$SHELL*'"$SHELL"'*
+	s*\$LTCC*'"$LTCC"'*
+	s*\$LTCFLAGS*'"$LTCFLAGS"'*
+	s*\$LD*'"$LD"'*
+	s/\$with_gnu_ld/'"$with_gnu_ld"'/
+	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
+	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+	p
+     }' < "$progpath"
+    exit $?
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+    func_error "missing argument for $1"
+    exit_cmd=exit
+}
+
+exit_cmd=:
+
+
+
+
+
+# Check that we have a working $ECHO.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell, and then maybe $ECHO will work.
+  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit $EXIT_SUCCESS
+fi
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+# $mode is unset
+nonopt=
+execute_dlfiles=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+opt_dry_run=false
+opt_duplicate_deps=false
+opt_silent=false
+opt_debug=:
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+    func_error ${1+"$@"}
+    func_error "See the $PACKAGE documentation for more information."
+    func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+    re_begincf='^# ### BEGIN LIBTOOL'
+    re_endcf='^# ### END LIBTOOL'
+
+    # Default configuration.
+    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+    done
+
+    exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+    $ECHO "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      $ECHO "enable shared libraries"
+    else
+      $ECHO "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      $ECHO "enable static libraries"
+    else
+      $ECHO "disable static libraries"
+    fi
+
+    exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+  # Global variable:
+  tagname="$1"
+
+  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+  # Validate tagname.
+  case $tagname in
+    *[!-_A-Za-z0-9,/]*)
+      func_fatal_error "invalid tag name: $tagname"
+      ;;
+  esac
+
+  # Don't test for the "default" C tag, as we know it's
+  # there but not specially marked.
+  case $tagname in
+    CC) ;;
+    *)
+      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	taglist="$taglist $tagname"
+
+	# Evaluate the configuration.  Be careful to quote the path
+	# and the sed script, to avoid splitting on whitespace, but
+	# also don't use non-portable quotes within backquotes within
+	# quotes we have to do it in 2 steps:
+	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	eval "$extractedcf"
+      else
+	func_error "ignoring unknown tag $tagname"
+      fi
+      ;;
+  esac
+}
+
+# Parse options once, thoroughly.  This comes as soon as possible in
+# the script to make things like `libtool --version' happen quickly.
+{
+
+  # Shorthand for --mode=foo, only valid as the first argument
+  case $1 in
+  clean|clea|cle|cl)
+    shift; set dummy --mode clean ${1+"$@"}; shift
+    ;;
+  compile|compil|compi|comp|com|co|c)
+    shift; set dummy --mode compile ${1+"$@"}; shift
+    ;;
+  execute|execut|execu|exec|exe|ex|e)
+    shift; set dummy --mode execute ${1+"$@"}; shift
+    ;;
+  finish|finis|fini|fin|fi|f)
+    shift; set dummy --mode finish ${1+"$@"}; shift
+    ;;
+  install|instal|insta|inst|ins|in|i)
+    shift; set dummy --mode install ${1+"$@"}; shift
+    ;;
+  link|lin|li|l)
+    shift; set dummy --mode link ${1+"$@"}; shift
+    ;;
+  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+    shift; set dummy --mode uninstall ${1+"$@"}; shift
+    ;;
+  esac
+
+  # Parse non-mode specific arguments:
+  while test "$#" -gt 0; do
+    opt="$1"
+    shift
+
+    case $opt in
+      --config)		func_config					;;
+
+      --debug)		preserve_args="$preserve_args $opt"
+			func_echo "enabling shell trace mode"
+			opt_debug='set -x'
+			$opt_debug
+			;;
+
+      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			execute_dlfiles="$execute_dlfiles $1"
+			shift
+			;;
+
+      --dry-run | -n)	opt_dry_run=:					;;
+      --features)       func_features					;;
+      --finish)		mode="finish"					;;
+
+      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			case $1 in
+			  # Valid mode arguments:
+			  clean)	;;
+			  compile)	;;
+			  execute)	;;
+			  finish)	;;
+			  install)	;;
+			  link)		;;
+			  relink)	;;
+			  uninstall)	;;
+
+			  # Catch anything else as an error
+			  *) func_error "invalid argument for $opt"
+			     exit_cmd=exit
+			     break
+			     ;;
+		        esac
+
+			mode="$1"
+			shift
+			;;
+
+      --preserve-dup-deps)
+			opt_duplicate_deps=:				;;
+
+      --quiet|--silent)	preserve_args="$preserve_args $opt"
+			opt_silent=:
+			;;
+
+      --verbose| -v)	preserve_args="$preserve_args $opt"
+			opt_silent=false
+			;;
+
+      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			preserve_args="$preserve_args $opt $1"
+			func_enable_tag "$1"	# tagname is set here
+			shift
+			;;
+
+      # Separate optargs to long options:
+      -dlopen=*|--mode=*|--tag=*)
+			func_opt_split "$opt"
+			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
+			shift
+			;;
+
+      -\?|-h)		func_usage					;;
+      --help)		opt_help=:					;;
+      --version)	func_version					;;
+
+      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
+
+      *)		nonopt="$opt"
+			break
+			;;
+    esac
+  done
+
+
+  case $host in
+    *cygwin* | *mingw* | *pw32*)
+      # don't eliminate duplications in $postdeps and $predeps
+      opt_duplicate_compiler_generated_deps=:
+      ;;
+    *)
+      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
+      ;;
+  esac
+
+  # Having warned about all mis-specified options, bail out if
+  # anything was wrong.
+  $exit_cmd $EXIT_FAILURE
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+  if test "$package_revision" != "$macro_revision"; then
+    if test "$VERSION" != "$macro_version"; then
+      if test -z "$macro_version"; then
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      else
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      fi
+    else
+      cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+    fi
+
+    exit $EXIT_MISMATCH
+  fi
+}
+
+
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+$opt_help || {
+  # Sanity checks first:
+  func_check_version_match
+
+  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+    func_fatal_configuration "not configured to build any kind of library"
+  fi
+
+  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+  # Darwin sucks
+  eval std_shrext=\"$shrext_cmds\"
+
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    func_error "unrecognized option \`-dlopen'"
+    $ECHO "$help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+    $SED -e 4q "$1" 2>/dev/null \
+      | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs.  To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway.  Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+    lalib_p=no
+    if test -r "$1" && exec 5<&0 <"$1"; then
+	for lalib_p_l in 1 2 3 4
+	do
+	    read lalib_p_line
+	    case "$lalib_p_line" in
+		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+	    esac
+	done
+	exec 0<&5 5<&-
+    fi
+    test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+    func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+    func_ltwrapper_exec_suffix=
+    case $1 in
+    *.exe) ;;
+    *) func_ltwrapper_exec_suffix=.exe ;;
+    esac
+    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+    func_ltwrapper_scriptname_result=""
+    if func_ltwrapper_executable_p "$1"; then
+	func_dirname_and_basename "$1" "" "."
+	func_stripname '' '.exe' "$func_basename_result"
+	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    fi
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+    $opt_debug
+    save_ifs=$IFS; IFS='~'
+    for cmd in $1; do
+      IFS=$save_ifs
+      eval cmd=\"$cmd\"
+      func_show_eval "$cmd" "${2-:}"
+    done
+    IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)!  Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+    $opt_debug
+    case $1 in
+    */* | *\\*)	. "$1" ;;
+    *)		. "./$1" ;;
+    esac
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    $opt_debug
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+        func_quote_for_eval "$arg"
+	CC_quoted="$CC_quoted $func_quote_for_eval_result"
+      done
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+	for z in $available_tags; do
+	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+	    # Evaluate the configuration.
+	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    CC_quoted=
+	    for arg in $CC; do
+	      # Double-quote args containing other shell metacharacters.
+	      func_quote_for_eval "$arg"
+	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
+	    done
+	    case "$@ " in
+	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
+	      # The compiler in the base compile command matches
+	      # the one in the tagged configuration.
+	      # Assume this is the tagged configuration we want.
+	      tagname=$z
+	      break
+	      ;;
+	    esac
+	  fi
+	done
+	# If $tagname still isn't set, then no tagged configuration
+	# was found and let the user know that the "--tag" command
+	# line option must be used.
+	if test -z "$tagname"; then
+	  func_echo "unable to infer tagged configuration"
+	  func_fatal_error "specify a tag with \`--tag'"
+#	else
+#	  func_verbose "using $tagname tagged configuration"
+	fi
+	;;
+      esac
+    fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+    write_libobj=${1}
+    if test "$build_libtool_libs" = yes; then
+      write_lobj=\'${2}\'
+    else
+      write_lobj=none
+    fi
+
+    if test "$build_old_libs" = yes; then
+      write_oldobj=\'${3}\'
+    else
+      write_oldobj=none
+    fi
+
+    $opt_dry_run || {
+      cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+      $MV "${write_libobj}T" "${write_libobj}"
+    }
+}
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+    $opt_debug
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+    pie_flag=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+	# do not "continue".  Instead, add this to base_compile
+	lastarg="$arg"
+	arg_mode=normal
+	;;
+
+      target )
+	libobj="$arg"
+	arg_mode=normal
+	continue
+	;;
+
+      normal )
+	# Accept any command-line options.
+	case $arg in
+	-o)
+	  test -n "$libobj" && \
+	    func_fatal_error "you cannot specify \`-o' more than once"
+	  arg_mode=target
+	  continue
+	  ;;
+
+	-pie | -fpie | -fPIE)
+          pie_flag="$pie_flag $arg"
+	  continue
+	  ;;
+
+	-shared | -static | -prefer-pic | -prefer-non-pic)
+	  later="$later $arg"
+	  continue
+	  ;;
+
+	-no-suppress)
+	  suppress_opt=no
+	  continue
+	  ;;
+
+	-Xcompiler)
+	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
+	  continue      #  The current "srcfile" will either be retained or
+	  ;;            #  replaced later.  I would guess that would be a bug.
+
+	-Wc,*)
+	  func_stripname '-Wc,' '' "$arg"
+	  args=$func_stripname_result
+	  lastarg=
+	  save_ifs="$IFS"; IFS=','
+	  for arg in $args; do
+	    IFS="$save_ifs"
+	    func_quote_for_eval "$arg"
+	    lastarg="$lastarg $func_quote_for_eval_result"
+	  done
+	  IFS="$save_ifs"
+	  func_stripname ' ' '' "$lastarg"
+	  lastarg=$func_stripname_result
+
+	  # Add the arguments to base_compile.
+	  base_compile="$base_compile $lastarg"
+	  continue
+	  ;;
+
+	*)
+	  # Accept the current argument as the source file.
+	  # The previous "srcfile" becomes the current argument.
+	  #
+	  lastarg="$srcfile"
+	  srcfile="$arg"
+	  ;;
+	esac  #  case $arg
+	;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      func_quote_for_eval "$lastarg"
+      base_compile="$base_compile $func_quote_for_eval_result"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      func_fatal_error "you must specify an argument for -Xcompile"
+      ;;
+    target)
+      func_fatal_error "you must specify a target with \`-o'"
+      ;;
+    *)
+      # Get the name of the library object.
+      test -z "$libobj" && {
+	func_basename "$srcfile"
+	libobj="$func_basename_result"
+      }
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    case $libobj in
+    *.[cCFSifmso] | \
+    *.ada | *.adb | *.ads | *.asm | \
+    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
+      func_xform "$libobj"
+      libobj=$func_xform_result
+      ;;
+    esac
+
+    case $libobj in
+    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+    *)
+      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	continue
+	;;
+
+      -static)
+	build_libtool_libs=no
+	build_old_libs=yes
+	continue
+	;;
+
+      -prefer-pic)
+	pic_mode=yes
+	continue
+	;;
+
+      -prefer-non-pic)
+	pic_mode=no
+	continue
+	;;
+      esac
+    done
+
+    func_quote_for_eval "$libobj"
+    test "X$libobj" != "X$func_quote_for_eval_result" \
+      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
+      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+    func_dirname_and_basename "$obj" "/" ""
+    objname="$func_basename_result"
+    xdir="$func_dirname_result"
+    lobj=${xdir}$objdir/$objname
+
+    test -z "$base_compile" && \
+      func_fatal_help "you must specify a compilation command"
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+	func_echo "Waiting for $lockfile to be removed"
+	sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+	$ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+      removelist="$removelist $output_obj"
+      $ECHO "$srcfile" > "$lockfile"
+    fi
+
+    $opt_dry_run || $RM $removelist
+    removelist="$removelist $lockfile"
+    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    func_quote_for_eval "$srcfile"
+    qsrcfile=$func_quote_for_eval_result
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+	command="$base_compile $qsrcfile $pic_flag"
+      else
+	# Don't build PIC code
+	command="$base_compile $qsrcfile"
+      fi
+
+      func_mkdir_p "$xdir$objdir"
+
+      if test -z "$output_obj"; then
+	# Place PIC objects in $objdir
+	command="$command -o $lobj"
+      fi
+
+      func_show_eval_locale "$command"	\
+          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+	func_show_eval '$MV "$output_obj" "$lobj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+	suppress_output=' >/dev/null 2>&1'
+      fi
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+	# Don't build PIC code
+	command="$base_compile $qsrcfile$pie_flag"
+      else
+	command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+	command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      func_show_eval_locale "$command" \
+        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+	func_show_eval '$MV "$output_obj" "$obj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+    fi
+
+    $opt_dry_run || {
+      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+      # Unlock the critical section if it was locked
+      if test "$need_locks" != no; then
+	removelist=$lockfile
+        $RM "$lockfile"
+      fi
+    }
+
+    exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+test "$mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+    # We need to display help for each of the modes.
+    case $mode in
+      "")
+        # Generic help is extracted from the usage comments
+        # at the start of this file.
+        func_help
+        ;;
+
+      clean)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      compile)
+      $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -no-suppress      do not suppress compiler output for multiple passes
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
+  -shared           do not build a \`.o' file suitable for static linking
+  -static           only build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+        ;;
+
+      execute)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+        ;;
+
+      finish)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+        ;;
+
+      install)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+        ;;
+
+      link)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -shared           only do dynamic linking of libtool libraries
+  -shrext SUFFIX    override the standard shared library file extension
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                    specify library version info [each variable defaults to 0]
+  -weak LIBNAME     declare that the target provides the LIBNAME interface
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+        ;;
+
+      uninstall)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      *)
+        func_fatal_help "invalid operation mode \`$mode'"
+        ;;
+    esac
+
+    $ECHO
+    $ECHO "Try \`$progname --help' for more information about other modes."
+
+    exit $?
+}
+
+  # Now that we've collected a possible --mode arg, show help if necessary
+  $opt_help && func_mode_help
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+    $opt_debug
+    # The first argument is the command name.
+    cmd="$nonopt"
+    test -z "$cmd" && \
+      func_fatal_help "you must specify a COMMAND"
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      test -f "$file" \
+	|| func_fatal_help "\`$file' is not a file"
+
+      dir=
+      case $file in
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+	# Read the libtool library.
+	dlname=
+	library_names=
+	func_source "$file"
+
+	# Skip this library if it cannot be dlopened.
+	if test -z "$dlname"; then
+	  # Warn if it was a shared library.
+	  test -n "$library_names" && \
+	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	  continue
+	fi
+
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+
+	if test -f "$dir/$objdir/$dlname"; then
+	  dir="$dir/$objdir"
+	else
+	  if test ! -f "$dir/$dlname"; then
+	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	  fi
+	fi
+	;;
+
+      *.lo)
+	# Just add the directory containing the .lo file.
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+	;;
+
+      *)
+	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	continue
+	;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+	eval "$shlibpath_var=\"\$dir\""
+      else
+	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -*) ;;
+      *)
+	# Do a test to see if this is really a libtool program.
+	if func_ltwrapper_script_p "$file"; then
+	  func_source "$file"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	elif func_ltwrapper_executable_p "$file"; then
+	  func_ltwrapper_scriptname "$file"
+	  func_source "$func_ltwrapper_scriptname_result"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	fi
+	;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      func_quote_for_eval "$file"
+      args="$args $func_quote_for_eval_result"
+    done
+
+    if test "X$opt_dry_run" = Xfalse; then
+      if test -n "$shlibpath_var"; then
+	# Export the shlibpath_var.
+	eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+	eval "if test \"\${save_$lt_var+set}\" = set; then
+                $lt_var=\$save_$lt_var; export $lt_var
+	      else
+		$lt_unset $lt_var
+	      fi"
+      done
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	$ECHO "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+    $opt_debug
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+	libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+	if test -n "$finish_cmds"; then
+	  # Do each command in the finish commands.
+	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+	fi
+	if test -n "$finish_eval"; then
+	  # Do the single finish_eval.
+	  eval cmds=\"$finish_eval\"
+	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
+       $cmds"
+	fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    $opt_silent && exit $EXIT_SUCCESS
+
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    $ECHO "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      $ECHO "   $libdir"
+    done
+    $ECHO
+    $ECHO "If you ever happen to want to link against installed libraries"
+    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
+    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    $ECHO "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      $ECHO "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
+      $ECHO "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      $ECHO "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      $ECHO "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    $ECHO
+
+    $ECHO "See any operating system documentation about shared libraries for"
+    case $host in
+      solaris2.[6789]|solaris2.1[0-9])
+        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+	$ECHO "pages."
+	;;
+      *)
+        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
+        ;;
+    esac
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    exit $EXIT_SUCCESS
+}
+
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+    $opt_debug
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
+      # Aesthetically quote it.
+      func_quote_for_eval "$nonopt"
+      install_prog="$func_quote_for_eval_result "
+      arg=$1
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    func_quote_for_eval "$arg"
+    install_prog="$install_prog$func_quote_for_eval_result"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+	files="$files $dest"
+	dest=$arg
+	continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f)
+	case " $install_prog " in
+	*[\\\ /]cp\ *) ;;
+	*) prev=$arg ;;
+	esac
+	;;
+      -g | -m | -o)
+	prev=$arg
+	;;
+      -s)
+	stripme=" -s"
+	continue
+	;;
+      -*)
+	;;
+      *)
+	# If the previous option needed an argument, then skip it.
+	if test -n "$prev"; then
+	  prev=
+	else
+	  dest=$arg
+	  continue
+	fi
+	;;
+      esac
+
+      # Aesthetically quote the argument.
+      func_quote_for_eval "$arg"
+      install_prog="$install_prog $func_quote_for_eval_result"
+    done
+
+    test -z "$install_prog" && \
+      func_fatal_help "you must specify an install program"
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prev' option requires an argument"
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+	func_fatal_help "no file or destination specified"
+      else
+	func_fatal_help "you must specify a destination"
+      fi
+    fi
+
+    # Strip any trailing slash from the destination.
+    func_stripname '' '/' "$dest"
+    dest=$func_stripname_result
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      func_dirname_and_basename "$dest" "" "."
+      destdir="$func_dirname_result"
+      destname="$func_basename_result"
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files; shift
+      test "$#" -gt 1 && \
+	func_fatal_help "\`$dest' is not a directory"
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+	case $file in
+	*.lo) ;;
+	*)
+	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  ;;
+	esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+	# Do the static libraries later.
+	staticlibs="$staticlibs $file"
+	;;
+
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$file' is not a valid libtool archive"
+
+	library_names=
+	old_library=
+	relink_command=
+	func_source "$file"
+
+	# Add the libdir to current_libdirs if it is the destination.
+	if test "X$destdir" = "X$libdir"; then
+	  case "$current_libdirs " in
+	  *" $libdir "*) ;;
+	  *) current_libdirs="$current_libdirs $libdir" ;;
+	  esac
+	else
+	  # Note the libdir as a future libdir.
+	  case "$future_libdirs " in
+	  *" $libdir "*) ;;
+	  *) future_libdirs="$future_libdirs $libdir" ;;
+	  esac
+	fi
+
+	func_dirname "$file" "/" ""
+	dir="$func_dirname_result"
+	dir="$dir$objdir"
+
+	if test -n "$relink_command"; then
+	  # Determine the prefix the user has applied to our future dir.
+	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
+
+	  # Don't allow the user to place us outside of our expected
+	  # location b/c this prevents finding dependent libraries that
+	  # are installed to the same prefix.
+	  # At present, this check doesn't affect windows .dll's that
+	  # are installed into $libdir/../bin (currently, that works fine)
+	  # but it's something to keep an eye on.
+	  test "$inst_prefix_dir" = "$destdir" && \
+	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+	  if test -n "$inst_prefix_dir"; then
+	    # Stick the inst_prefix_dir data into the link command.
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+	  else
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
+	  fi
+
+	  func_warning "relinking \`$file'"
+	  func_show_eval "$relink_command" \
+	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	fi
+
+	# See the names of the shared library.
+	set dummy $library_names; shift
+	if test -n "$1"; then
+	  realname="$1"
+	  shift
+
+	  srcname="$realname"
+	  test -n "$relink_command" && srcname="$realname"T
+
+	  # Install the shared library and build the symlinks.
+	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
+	      'exit $?'
+	  tstripme="$stripme"
+	  case $host_os in
+	  cygwin* | mingw* | pw32*)
+	    case $realname in
+	    *.dll.a)
+	      tstripme=""
+	      ;;
+	    esac
+	    ;;
+	  esac
+	  if test -n "$tstripme" && test -n "$striplib"; then
+	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
+	  fi
+
+	  if test "$#" -gt 0; then
+	    # Delete the old symlinks, and create new ones.
+	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
+	    # so we also need to try rm && ln -s.
+	    for linkname
+	    do
+	      test "$linkname" != "$realname" \
+		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+	    done
+	  fi
+
+	  # Do each command in the postinstall commands.
+	  lib="$destdir/$realname"
+	  func_execute_cmds "$postinstall_cmds" 'exit $?'
+	fi
+
+	# Install the pseudo-library for information purposes.
+	func_basename "$file"
+	name="$func_basename_result"
+	instname="$dir/$name"i
+	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+	# Maybe install the static library, too.
+	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+	;;
+
+      *.lo)
+	# Install (i.e. copy) a libtool object.
+
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Deduce the name of the destination old-style object file.
+	case $destfile in
+	*.lo)
+	  func_lo2o "$destfile"
+	  staticdest=$func_lo2o_result
+	  ;;
+	*.$objext)
+	  staticdest="$destfile"
+	  destfile=
+	  ;;
+	*)
+	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  ;;
+	esac
+
+	# Install the libtool object if requested.
+	test -n "$destfile" && \
+	  func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+	# Install the old object if enabled.
+	if test "$build_old_libs" = yes; then
+	  # Deduce the name of the old-style object file.
+	  func_lo2o "$file"
+	  staticobj=$func_lo2o_result
+	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+	fi
+	exit $EXIT_SUCCESS
+	;;
+
+      *)
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# If the file is missing, and there is a .exe on the end, strip it
+	# because it is most likely a libtool script we actually want to
+	# install
+	stripped_ext=""
+	case $file in
+	  *.exe)
+	    if test ! -f "$file"; then
+	      func_stripname '' '.exe' "$file"
+	      file=$func_stripname_result
+	      stripped_ext=".exe"
+	    fi
+	    ;;
+	esac
+
+	# Do a test to see if this is really a libtool program.
+	case $host in
+	*cygwin*|*mingw*)
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      wrapper=$func_ltwrapper_scriptname_result
+	    else
+	      func_stripname '' '.exe' "$file"
+	      wrapper=$func_stripname_result
+	    fi
+	    ;;
+	*)
+	    wrapper=$file
+	    ;;
+	esac
+	if func_ltwrapper_script_p "$wrapper"; then
+	  notinst_deplibs=
+	  relink_command=
+
+	  func_source "$wrapper"
+
+	  # Check the variables that should have been set.
+	  test -z "$generated_by_libtool_version" && \
+	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+	  finalize=yes
+	  for lib in $notinst_deplibs; do
+	    # Check to see that each library is installed.
+	    libdir=
+	    if test -f "$lib"; then
+	      func_source "$lib"
+	    fi
+	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    if test -n "$libdir" && test ! -f "$libfile"; then
+	      func_warning "\`$lib' has not been installed in \`$libdir'"
+	      finalize=no
+	    fi
+	  done
+
+	  relink_command=
+	  func_source "$wrapper"
+
+	  outputname=
+	  if test "$fast_install" = no && test -n "$relink_command"; then
+	    $opt_dry_run || {
+	      if test "$finalize" = yes; then
+	        tmpdir=`func_mktempdir`
+		func_basename "$file$stripped_ext"
+		file="$func_basename_result"
+	        outputname="$tmpdir/$file"
+	        # Replace the output file specification.
+	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+	        $opt_silent || {
+	          func_quote_for_expand "$relink_command"
+		  eval "func_echo $func_quote_for_expand_result"
+	        }
+	        if eval "$relink_command"; then :
+	          else
+		  func_error "error: relink \`$file' with the above command before installing it"
+		  $opt_dry_run || ${RM}r "$tmpdir"
+		  continue
+	        fi
+	        file="$outputname"
+	      else
+	        func_warning "cannot relink \`$file'"
+	      fi
+	    }
+	  else
+	    # Install the binary that we compiled earlier.
+	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+	  fi
+	fi
+
+	# remove .exe since cygwin /usr/bin/install will append another
+	# one anyway
+	case $install_prog,$host in
+	*/usr/bin/install*,*cygwin*)
+	  case $file:$destfile in
+	  *.exe:*.exe)
+	    # this is ok
+	    ;;
+	  *.exe:*)
+	    destfile=$destfile.exe
+	    ;;
+	  *:*.exe)
+	    func_stripname '' '.exe' "$destfile"
+	    destfile=$func_stripname_result
+	    ;;
+	  esac
+	  ;;
+	esac
+	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+	$opt_dry_run || if test -n "$outputname"; then
+	  ${RM}r "$tmpdir"
+	fi
+	;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      func_basename "$file"
+      name="$func_basename_result"
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+	func_show_eval "$old_striplib $oldlib" 'exit $?'
+      fi
+
+      # Do each command in the postinstall commands.
+      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+    done
+
+    test -n "$future_libdirs" && \
+      func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      $opt_dry_run && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+    $opt_debug
+    my_outputname="$1"
+    my_originator="$2"
+    my_pic_p="${3-no}"
+    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    my_dlsyms=
+
+    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+      if test -n "$NM" && test -n "$global_symbol_pipe"; then
+	my_dlsyms="${my_outputname}S.c"
+      else
+	func_error "not configured to extract global symbols from dlpreopened files"
+      fi
+    fi
+
+    if test -n "$my_dlsyms"; then
+      case $my_dlsyms in
+      "") ;;
+      *.c)
+	# Discover the nlist of each of the dlfiles.
+	nlist="$output_objdir/${my_outputname}.nm"
+
+	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+	# Parse the name list into a source file.
+	func_verbose "creating $output_objdir/$my_dlsyms"
+
+	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+	if test "$dlself" = yes; then
+	  func_verbose "generating symbol list for \`$output'"
+
+	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+	  # Add our own program objects to the symbol list.
+	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	  for progfile in $progfiles; do
+	    func_verbose "extracting global C symbols from \`$progfile'"
+	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
+	  done
+
+	  if test -n "$exclude_expsyms"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  if test -n "$export_symbols_regex"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  # Prepare the list of exported symbols
+	  if test -z "$export_symbols"; then
+	    export_symbols="$output_objdir/$outputname.exp"
+	    $opt_dry_run || {
+	      $RM $export_symbols
+	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      case $host in
+	      *cygwin* | *mingw* )
+                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+	        ;;
+	      esac
+	    }
+	  else
+	    $opt_dry_run || {
+	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	      case $host in
+	        *cygwin | *mingw* )
+	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+	          ;;
+	      esac
+	    }
+	  fi
+	fi
+
+	for dlprefile in $dlprefiles; do
+	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_basename "$dlprefile"
+	  name="$func_basename_result"
+	  $opt_dry_run || {
+	    eval '$ECHO ": $name " >> "$nlist"'
+	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+	  }
+	done
+
+	$opt_dry_run || {
+	  # Make sure we have at least an empty file.
+	  test -f "$nlist" || : > "$nlist"
+
+	  if test -n "$exclude_expsyms"; then
+	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+	    $MV "$nlist"T "$nlist"
+	  fi
+
+	  # Try sorting and uniquifying the output.
+	  if $GREP -v "^: " < "$nlist" |
+	      if sort -k 3 </dev/null >/dev/null 2>&1; then
+		sort -k 3
+	      else
+		sort +2
+	      fi |
+	      uniq > "$nlist"S; then
+	    :
+	  else
+	    $GREP -v "^: " < "$nlist" > "$nlist"S
+	  fi
+
+	  if test -f "$nlist"S; then
+	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+	  else
+	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
+	  fi
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols.  */
+typedef struct {
+  const char *name;
+  void *address;
+} lt_dlsymlist;
+"
+	  case $host in
+	  *cygwin* | *mingw* )
+	    $ECHO >> "$output_objdir/$my_dlsyms" "\
+/* DATA imports from DLLs on WIN32 con't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs.  */"
+	    lt_dlsym_const= ;;
+	  *osf5*)
+	    echo >> "$output_objdir/$my_dlsyms" "\
+/* This system does not cope well with relocations in const data */"
+	    lt_dlsym_const= ;;
+	  *)
+	    lt_dlsym_const=const ;;
+	  esac
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+extern $lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+$lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+  { \"$my_originator\", (void *) 0 },"
+
+	  case $need_lib_prefix in
+	  no)
+	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  *)
+	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  esac
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+	} # !$opt_dry_run
+
+	pic_flag_for_symtable=
+	case "$compile_command " in
+	*" -static "*) ;;
+	*)
+	  case $host in
+	  # compiling the symbol table file with pic_flag works around
+	  # a FreeBSD bug that causes programs to crash when -lm is
+	  # linked before any other PIC object.  But we must not use
+	  # pic_flag when linking with -static.  The problem exists in
+	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+	  *-*-hpux*)
+	    pic_flag_for_symtable=" $pic_flag"  ;;
+	  *)
+	    if test "X$my_pic_p" != Xno; then
+	      pic_flag_for_symtable=" $pic_flag"
+	    fi
+	    ;;
+	  esac
+	  ;;
+	esac
+	symtab_cflags=
+	for arg in $LTCFLAGS; do
+	  case $arg in
+	  -pie | -fpie | -fPIE) ;;
+	  *) symtab_cflags="$symtab_cflags $arg" ;;
+	  esac
+	done
+
+	# Now compile the dynamic symbol file.
+	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+	# Clean up the generated files.
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+	# Transform the symbol file into the correct name.
+	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	case $host in
+	*cygwin* | *mingw* )
+	  if test -f "$output_objdir/$my_outputname.def"; then
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	  else
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  fi
+	  ;;
+	*)
+	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  ;;
+	esac
+	;;
+      *)
+	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	;;
+      esac
+    else
+      # We keep going just in case the user didn't refer to
+      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+      # really was required.
+
+      # Nullify the symbol file.
+      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+    fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+  $opt_debug
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+      win32_nmres=`eval $NM -f posix -A $1 |
+	$SED -n -e '
+	    1,100{
+		/ I /{
+		    s,.*,import,
+		    p
+		    q
+		}
+	    }'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $ECHO "$win32_libid_type"
+}
+
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    $opt_debug
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+    fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    $opt_debug
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	*) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      func_basename "$my_xlib"
+      my_xlib="$func_basename_result"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+	*" $my_xlib_u "*)
+	  func_arith $extracted_serial + 1
+	  extracted_serial=$func_arith_result
+	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
+	*) break ;;
+	esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
+
+      func_mkdir_p "$my_xdir"
+
+      case $host in
+      *-darwin*)
+	func_verbose "Extracting $my_xabs"
+	# Do not bother doing anything if just a dry run
+	$opt_dry_run || {
+	  darwin_orig_dir=`pwd`
+	  cd $my_xdir || exit $?
+	  darwin_archive=$my_xabs
+	  darwin_curdir=`pwd`
+	  darwin_base_archive=`basename "$darwin_archive"`
+	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+	  if test -n "$darwin_arches"; then
+	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+	    darwin_arch=
+	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+	    for darwin_arch in  $darwin_arches ; do
+	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	      cd "$darwin_curdir"
+	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	    done # $darwin_arches
+            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_file=
+	    darwin_files=
+	    for darwin_file in $darwin_filelist; do
+	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+	      $LIPO -create -output "$darwin_file" $darwin_files
+	    done # $darwin_filelist
+	    $RM -rf unfat-$$
+	    cd "$darwin_orig_dir"
+	  else
+	    cd $darwin_orig_dir
+	    func_extract_an_archive "$my_xdir" "$my_xabs"
+	  fi # $darwin_arches
+	} # !$opt_dry_run
+	;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+	;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+    done
+
+    func_extract_archives_result="$my_oldobjs"
+}
+
+
+
+# func_emit_wrapper arg
+#
+# emit a libtool wrapper script on stdout
+# don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variable
+# set therein.
+#
+# arg is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take.  If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the '.lib' directory.  This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+	func_emit_wrapper_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_arg1=$1
+	fi
+
+	$ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    ECHO=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$ECHO works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$ECHO will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+	$ECHO "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+  done
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
+  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+    # special case for '.'
+    if test \"\$thisdir\" = \".\"; then
+      thisdir=\`pwd\`
+    fi
+    # remove .libs from thisdir
+    case \"\$thisdir\" in
+    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
+    $objdir )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+	if test "$fast_install" = yes; then
+	  $ECHO "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" ||
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $MKDIR \"\$progdir\"
+    else
+      $RM \"\$progdir/\$file\"
+    fi"
+
+	  $ECHO "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+	$ECHO \"\$relink_command_output\" >&2
+	$RM \"\$progdir/\$file\"
+	exit 1
+      fi
+    fi
+
+    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $RM \"\$progdir/\$program\";
+      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $RM \"\$progdir/\$file\"
+  fi"
+	else
+	  $ECHO "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+	fi
+
+	$ECHO "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+	# Export our shlibpath_var if we have one.
+	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	  $ECHO "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+	fi
+
+	# fixup the dll searchpath if we need to.
+	if test -n "$dllsearchpath"; then
+	  $ECHO "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+	fi
+
+	$ECHO "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+	case $host in
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2*)
+	  $ECHO "\
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+	  ;;
+
+	*)
+	  $ECHO "\
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+	  ;;
+	esac
+	$ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+    fi
+  else
+    # The program doesn't exist.
+    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+}
+# end: func_emit_wrapper
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+	cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+
+   Currently, it simply execs the wrapper *script* "$SHELL $output",
+   but could eventually absorb all of the scripts functionality and
+   exec $objdir/$outputname directly.
+*/
+EOF
+	    cat <<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+# define setmode _setmode
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+#  include <io.h>
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+#ifdef _MSC_VER
+# define S_IXUSR _S_IEXEC
+# define stat _stat
+# ifndef _INTPTR_T_DEFINED
+#  define intptr_t int
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifdef __CYGWIN__
+# define FOPEN_WB "wb"
+#endif
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#undef LTWRAPPER_DEBUGPRINTF
+#if defined DEBUGWRAPPER
+# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
+static void
+ltwrapper_debugprintf (const char *fmt, ...)
+{
+    va_list args;
+    va_start (args, fmt);
+    (void) vfprintf (stderr, fmt, args);
+    va_end (args);
+}
+#else
+# define LTWRAPPER_DEBUGPRINTF(args)
+#endif
+
+const char *program_name = NULL;
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+
+static const char *script_text =
+EOF
+
+	    func_emit_wrapper yes |
+	        $SED -e 's/\([\\"]\)/\\\1/g' \
+	             -e 's/^/  "/' -e 's/$/\\n"/'
+	    echo ";"
+
+	    cat <<EOF
+const char * MAGIC_EXE = "$magic_exe";
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  char *tmp_pathspec;
+  char *actual_cwrapper_path;
+  char *shwrapper_name;
+  intptr_t rval = 127;
+  FILE *shwrapper;
+
+  const char *dumpscript_opt = "--lt-dump-script";
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
+
+  /* very simple arg parsing; don't want to rely on getopt */
+  for (i = 1; i < argc; i++)
+    {
+      if (strcmp (argv[i], dumpscript_opt) == 0)
+	{
+EOF
+	    case "$host" in
+	      *mingw* | *cygwin* )
+		# make stdout use "unix" line endings
+		echo "          setmode(1,_O_BINARY);"
+		;;
+	      esac
+
+	    cat <<EOF
+	  printf ("%s", script_text);
+	  return 0;
+	}
+    }
+
+  newargz = XMALLOC (char *, argc + 2);
+EOF
+
+	    if test -n "$TARGETSHELL" ; then
+	      # no path translation at all
+	      lt_newargv0=$TARGETSHELL
+	    else
+	      case "$host" in
+		*mingw* )
+		  # awkward: cmd appends spaces to result
+		  lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+		  lt_newargv0=`( cmd //c echo $SHELL | $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo $SHELL`
+		  case $lt_newargv0 in
+		    *.exe | *.EXE) ;;
+		    *) lt_newargv0=$lt_newargv0.exe ;;
+		  esac
+		  ;;
+		* ) lt_newargv0=$SHELL ;;
+	      esac
+	    fi
+
+		cat <<EOF
+  newargz[0] = (char *) xstrdup ("$lt_newargv0");
+EOF
+
+	    cat <<"EOF"
+  tmp_pathspec = find_executable (argv[0]);
+  if (tmp_pathspec == NULL)
+    lt_fatal ("Couldn't find %s", argv[0]);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
+			  tmp_pathspec));
+
+  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
+			  actual_cwrapper_path));
+  XFREE (tmp_pathspec);
+
+  shwrapper_name = (char *) xstrdup (base_name (actual_cwrapper_path));
+  strendzap (actual_cwrapper_path, shwrapper_name);
+
+  /* shwrapper_name transforms */
+  strendzap (shwrapper_name, ".exe");
+  tmp_pathspec = XMALLOC (char, (strlen (shwrapper_name) +
+				 strlen ("_ltshwrapperTMP") + 1));
+  strcpy (tmp_pathspec, shwrapper_name);
+  strcat (tmp_pathspec, "_ltshwrapperTMP");
+  XFREE (shwrapper_name);
+  shwrapper_name = tmp_pathspec;
+  tmp_pathspec = 0;
+  LTWRAPPER_DEBUGPRINTF (("(main) libtool shell wrapper name: %s\n",
+			  shwrapper_name));
+EOF
+
+	    cat <<EOF
+  newargz[1] =
+    XMALLOC (char, (strlen (actual_cwrapper_path) +
+		    strlen ("$objdir") + 1 + strlen (shwrapper_name) + 1));
+  strcpy (newargz[1], actual_cwrapper_path);
+  strcat (newargz[1], "$objdir");
+  strcat (newargz[1], "/");
+  strcat (newargz[1], shwrapper_name);
+EOF
+
+
+	    case $host_os in
+	      mingw*)
+	    cat <<"EOF"
+  {
+    char* p;
+    while ((p = strchr (newargz[1], '\\')) != NULL)
+      {
+	*p = '/';
+      }
+  }
+EOF
+	    ;;
+	    esac
+
+	    cat <<"EOF"
+  XFREE (shwrapper_name);
+  XFREE (actual_cwrapper_path);
+
+  /* always write in binary mode */
+  if ((shwrapper = fopen (newargz[1], FOPEN_WB)) == 0)
+    {
+      lt_fatal ("Could not open %s for writing", newargz[1]);
+    }
+  fprintf (shwrapper, "%s", script_text);
+  fclose (shwrapper);
+
+  make_executable (newargz[1]);
+
+  for (i = 1; i < argc; i++)
+    newargz[i + 1] = xstrdup (argv[i]);
+  newargz[argc + 1] = NULL;
+
+  for (i = 0; i < argc + 1; i++)
+    {
+      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, newargz[i]));
+    }
+
+EOF
+
+	    case $host_os in
+	      mingw*)
+		cat <<EOF
+  /* execv doesn't actually work on mingw as expected on unix */
+  rval = _spawnv (_P_WAIT, "$lt_newargv0", (const char * const *) newargz);
+  if (rval == -1)
+    {
+      /* failed to start process */
+      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"$lt_newargv0\": errno = %d\n", errno));
+      return 127;
+    }
+  return rval;
+}
+EOF
+		;;
+	      *)
+		cat <<EOF
+  execv ("$lt_newargv0", newargz);
+  return rval; /* =127, but avoids unused variable warning */
+}
+EOF
+		;;
+	    esac
+
+	    cat <<"EOF"
+
+void *
+xmalloc (size_t num)
+{
+  void *p = (void *) malloc (num);
+  if (!p)
+    lt_fatal ("Memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+			  string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable (const char *path)
+{
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0)
+      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+    return 1;
+  else
+    return 0;
+}
+
+int
+make_executable (const char *path)
+{
+  int rval = 0;
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if (stat (path, &st) >= 0)
+    {
+      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+    }
+  return rval;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise
+   Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+  int has_slash = 0;
+  const char *p;
+  const char *p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char *concat_name;
+
+  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
+			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable (concat_name))
+	return concat_name;
+      XFREE (concat_name);
+    }
+  else
+    {
+#endif
+      if (IS_DIR_SEPARATOR (wrapper[0]))
+	{
+	  concat_name = xstrdup (wrapper);
+	  if (check_executable (concat_name))
+	    return concat_name;
+	  XFREE (concat_name);
+	}
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+    }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+      {
+	has_slash = 1;
+	break;
+      }
+  if (!has_slash)
+    {
+      /* no slashes; search PATH */
+      const char *path = getenv ("PATH");
+      if (path != NULL)
+	{
+	  for (p = path; *p; p = p_next)
+	    {
+	      const char *q;
+	      size_t p_len;
+	      for (q = p; *q; q++)
+		if (IS_PATH_SEPARATOR (*q))
+		  break;
+	      p_len = q - p;
+	      p_next = (*q == '\0' ? q : q + 1);
+	      if (p_len == 0)
+		{
+		  /* empty path: current directory */
+		  if (getcwd (tmp, LT_PATHMAX) == NULL)
+		    lt_fatal ("getcwd failed");
+		  tmp_len = strlen (tmp);
+		  concat_name =
+		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, tmp, tmp_len);
+		  concat_name[tmp_len] = '/';
+		  strcpy (concat_name + tmp_len + 1, wrapper);
+		}
+	      else
+		{
+		  concat_name =
+		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, p, p_len);
+		  concat_name[p_len] = '/';
+		  strcpy (concat_name + p_len + 1, wrapper);
+		}
+	      if (check_executable (concat_name))
+		return concat_name;
+	      XFREE (concat_name);
+	    }
+	}
+      /* not found in PATH; assume curdir */
+    }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal ("getcwd failed");
+  tmp_len = strlen (tmp);
+  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable (concat_name))
+    return concat_name;
+  XFREE (concat_name);
+  return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+  return xstrdup (pathspec);
+#else
+  char buf[LT_PATHMAX];
+  struct stat s;
+  char *tmp_pathspec = xstrdup (pathspec);
+  char *p;
+  int has_symlinks = 0;
+  while (strlen (tmp_pathspec) && !has_symlinks)
+    {
+      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
+			      tmp_pathspec));
+      if (lstat (tmp_pathspec, &s) == 0)
+	{
+	  if (S_ISLNK (s.st_mode) != 0)
+	    {
+	      has_symlinks = 1;
+	      break;
+	    }
+
+	  /* search backwards for last DIR_SEPARATOR */
+	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    p--;
+	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    {
+	      /* no more DIR_SEPARATORS left */
+	      break;
+	    }
+	  *p = '\0';
+	}
+      else
+	{
+	  char *errstr = strerror (errno);
+	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
+	}
+    }
+  XFREE (tmp_pathspec);
+
+  if (!has_symlinks)
+    {
+      return xstrdup (pathspec);
+    }
+
+  tmp_pathspec = realpath (pathspec, buf);
+  if (tmp_pathspec == 0)
+    {
+      lt_fatal ("Could not follow symlinks for %s", pathspec);
+    }
+  return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert (str != NULL);
+  assert (pat != NULL);
+
+  len = strlen (str);
+  patlen = strlen (pat);
+
+  if (patlen <= len)
+    {
+      str += len - patlen;
+      if (strcmp (str, pat) == 0)
+	*str = '\0';
+    }
+  return str;
+}
+
+static void
+lt_error_core (int exit_status, const char *mode,
+	       const char *message, va_list ap)
+{
+  fprintf (stderr, "%s: %s: ", program_name, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+  va_end (ap);
+}
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_mode_link arg...
+func_mode_link ()
+{
+    $opt_debug
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args=$nonopt
+    base_compile="$nonopt $@"
+    compile_command=$nonopt
+    finalize_command=$nonopt
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+    new_inherited_linker_flags=
+
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+    weak_libs=
+    single_module="${wl}-single_module"
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	break
+	;;
+      -all-static | -static | -static-libtool-libs)
+	case $arg in
+	-all-static)
+	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	    func_warning "complete static linking is impossible in this configuration"
+	  fi
+	  if test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	-static)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=built
+	  ;;
+	-static-libtool-libs)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	esac
+	build_libtool_libs=no
+	build_old_libs=yes
+	break
+	;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      func_quote_for_eval "$arg"
+      qarg=$func_quote_for_eval_unquoted_result
+      func_append libtool_args " $func_quote_for_eval_result"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+	case $prev in
+	output)
+	  func_append compile_command " @OUTPUT@"
+	  func_append finalize_command " @OUTPUT@"
+	  ;;
+	esac
+
+	case $prev in
+	dlfiles|dlprefiles)
+	  if test "$preload" = no; then
+	    # Add the symbol object into the linking commands.
+	    func_append compile_command " @SYMFILE@"
+	    func_append finalize_command " @SYMFILE@"
+	    preload=yes
+	  fi
+	  case $arg in
+	  *.la | *.lo) ;;  # We handle these cases below.
+	  force)
+	    if test "$dlself" = no; then
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  self)
+	    if test "$prev" = dlprefiles; then
+	      dlself=yes
+	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	      dlself=yes
+	    else
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  *)
+	    if test "$prev" = dlfiles; then
+	      dlfiles="$dlfiles $arg"
+	    else
+	      dlprefiles="$dlprefiles $arg"
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  esac
+	  ;;
+	expsyms)
+	  export_symbols="$arg"
+	  test -f "$arg" \
+	    || func_fatal_error "symbol file \`$arg' does not exist"
+	  prev=
+	  continue
+	  ;;
+	expsyms_regex)
+	  export_symbols_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	framework)
+	  case $host in
+	    *-*-darwin*)
+	      case "$deplibs " in
+		*" $qarg.ltframework "*) ;;
+		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+		   ;;
+	      esac
+	      ;;
+	  esac
+	  prev=
+	  continue
+	  ;;
+	inst_prefix)
+	  inst_prefix_dir="$arg"
+	  prev=
+	  continue
+	  ;;
+	objectlist)
+	  if test -f "$arg"; then
+	    save_arg=$arg
+	    moreargs=
+	    for fil in `cat "$save_arg"`
+	    do
+#	      moreargs="$moreargs $fil"
+	      arg=$fil
+	      # A libtool-controlled object.
+
+	      # Check to see that this really is a libtool object.
+	      if func_lalib_unsafe_p "$arg"; then
+		pic_object=
+		non_pic_object=
+
+		# Read the .lo file
+		func_source "$arg"
+
+		if test -z "$pic_object" ||
+		   test -z "$non_pic_object" ||
+		   test "$pic_object" = none &&
+		   test "$non_pic_object" = none; then
+		  func_fatal_error "cannot find name of object for \`$arg'"
+		fi
+
+		# Extract subdirectory from the argument.
+		func_dirname "$arg" "/" ""
+		xdir="$func_dirname_result"
+
+		if test "$pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  pic_object="$xdir$pic_object"
+
+		  if test "$prev" = dlfiles; then
+		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		      dlfiles="$dlfiles $pic_object"
+		      prev=
+		      continue
+		    else
+		      # If libtool objects are unsupported, then we need to preload.
+		      prev=dlprefiles
+		    fi
+		  fi
+
+		  # CHECK ME:  I think I busted this.  -Ossama
+		  if test "$prev" = dlprefiles; then
+		    # Preload the old-style object.
+		    dlprefiles="$dlprefiles $pic_object"
+		    prev=
+		  fi
+
+		  # A PIC object.
+		  func_append libobjs " $pic_object"
+		  arg="$pic_object"
+		fi
+
+		# Non-PIC object.
+		if test "$non_pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  non_pic_object="$xdir$non_pic_object"
+
+		  # A standard non-PIC object
+		  func_append non_pic_objects " $non_pic_object"
+		  if test -z "$pic_object" || test "$pic_object" = none ; then
+		    arg="$non_pic_object"
+		  fi
+		else
+		  # If the PIC object exists, use it instead.
+		  # $xdir was prepended to $pic_object above.
+		  non_pic_object="$pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+		fi
+	      else
+		# Only an error if not doing a dry-run.
+		if $opt_dry_run; then
+		  # Extract subdirectory from the argument.
+		  func_dirname "$arg" "/" ""
+		  xdir="$func_dirname_result"
+
+		  func_lo2o "$arg"
+		  pic_object=$xdir$objdir/$func_lo2o_result
+		  non_pic_object=$xdir$func_lo2o_result
+		  func_append libobjs " $pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+	        else
+		  func_fatal_error "\`$arg' is not a valid libtool object"
+		fi
+	      fi
+	    done
+	  else
+	    func_fatal_error "link input file \`$arg' does not exist"
+	  fi
+	  arg=$save_arg
+	  prev=
+	  continue
+	  ;;
+	precious_regex)
+	  precious_files_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	release)
+	  release="-$arg"
+	  prev=
+	  continue
+	  ;;
+	rpath | xrpath)
+	  # We need an absolute path.
+	  case $arg in
+	  [\\/]* | [A-Za-z]:[\\/]*) ;;
+	  *)
+	    func_fatal_error "only absolute run-paths are allowed"
+	    ;;
+	  esac
+	  if test "$prev" = rpath; then
+	    case "$rpath " in
+	    *" $arg "*) ;;
+	    *) rpath="$rpath $arg" ;;
+	    esac
+	  else
+	    case "$xrpath " in
+	    *" $arg "*) ;;
+	    *) xrpath="$xrpath $arg" ;;
+	    esac
+	  fi
+	  prev=
+	  continue
+	  ;;
+	shrext)
+	  shrext_cmds="$arg"
+	  prev=
+	  continue
+	  ;;
+	weak)
+	  weak_libs="$weak_libs $arg"
+	  prev=
+	  continue
+	  ;;
+	xcclinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xcompiler)
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xlinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $wl$qarg"
+	  prev=
+	  func_append compile_command " $wl$qarg"
+	  func_append finalize_command " $wl$qarg"
+	  continue
+	  ;;
+	*)
+	  eval "$prev=\"\$arg\""
+	  prev=
+	  continue
+	  ;;
+	esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+	if test -n "$link_static_flag"; then
+	  # See comment for -static flag below, for more details.
+	  func_append compile_command " $link_static_flag"
+	  func_append finalize_command " $link_static_flag"
+	fi
+	continue
+	;;
+
+      -allow-undefined)
+	# FIXME: remove this flag sometime in the future.
+	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	;;
+
+      -avoid-version)
+	avoid_version=yes
+	continue
+	;;
+
+      -dlopen)
+	prev=dlfiles
+	continue
+	;;
+
+      -dlpreopen)
+	prev=dlprefiles
+	continue
+	;;
+
+      -export-dynamic)
+	export_dynamic=yes
+	continue
+	;;
+
+      -export-symbols | -export-symbols-regex)
+	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	  func_fatal_error "more than one -exported-symbols argument is not allowed"
+	fi
+	if test "X$arg" = "X-export-symbols"; then
+	  prev=expsyms
+	else
+	  prev=expsyms_regex
+	fi
+	continue
+	;;
+
+      -framework)
+	prev=framework
+	continue
+	;;
+
+      -inst-prefix-dir)
+	prev=inst_prefix
+	continue
+	;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+	case $with_gcc/$host in
+	no/*-*-irix* | /*-*-irix*)
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  ;;
+	esac
+	continue
+	;;
+
+      -L*)
+	func_stripname '-L' '' "$arg"
+	dir=$func_stripname_result
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  absdir=`cd "$dir" && pwd`
+	  test -z "$absdir" && \
+	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
+	  dir="$absdir"
+	  ;;
+	esac
+	case "$deplibs " in
+	*" -L$dir "*) ;;
+	*)
+	  deplibs="$deplibs -L$dir"
+	  lib_search_path="$lib_search_path $dir"
+	  ;;
+	esac
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$dir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$dir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+	continue
+	;;
+
+      -l*)
+	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
+	    # These systems don't actually have a C or math library (as such)
+	    continue
+	    ;;
+	  *-*-os2*)
+	    # These systems don't actually have a C library (as such)
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C and math libraries are in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    continue
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  esac
+	elif test "X$arg" = "X-lc_r"; then
+	 case $host in
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	   # Do not include libc_r directly, use -pthread flag.
+	   continue
+	   ;;
+	 esac
+	fi
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
+      -module)
+	module=yes
+	continue
+	;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      # Darwin uses the -arch flag to determine output architecture.
+      -model|-arch|-isysroot)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	prev=xcompiler
+	continue
+	;;
+
+      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	case "$new_inherited_linker_flags " in
+	    *" $arg "*) ;;
+	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
+	esac
+	continue
+	;;
+
+      -multi_module)
+	single_module="${wl}-multi_module"
+	continue
+	;;
+
+      -no-fast-install)
+	fast_install=no
+	continue
+	;;
+
+      -no-install)
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
+	  # The PATH hackery in wrapper scripts is required on Windows
+	  # and Darwin in order for the loader to find any dlls it needs.
+	  func_warning "\`-no-install' is ignored for $host"
+	  func_warning "assuming \`-no-fast-install' instead"
+	  fast_install=no
+	  ;;
+	*) no_install=yes ;;
+	esac
+	continue
+	;;
+
+      -no-undefined)
+	allow_undefined=no
+	continue
+	;;
+
+      -objectlist)
+	prev=objectlist
+	continue
+	;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+	prev=precious_regex
+	continue
+	;;
+
+      -release)
+	prev=release
+	continue
+	;;
+
+      -rpath)
+	prev=rpath
+	continue
+	;;
+
+      -R)
+	prev=xrpath
+	continue
+	;;
+
+      -R*)
+	func_stripname '-R' '' "$arg"
+	dir=$func_stripname_result
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  func_fatal_error "only absolute run-paths are allowed"
+	  ;;
+	esac
+	case "$xrpath " in
+	*" $dir "*) ;;
+	*) xrpath="$xrpath $dir" ;;
+	esac
+	continue
+	;;
+
+      -shared)
+	# The effects of -shared are defined in a previous loop.
+	continue
+	;;
+
+      -shrext)
+	prev=shrext
+	continue
+	;;
+
+      -static | -static-libtool-libs)
+	# The effects of -static are defined in a previous loop.
+	# We used to do the same as -all-static on platforms that
+	# didn't have a PIC flag, but the assumption that the effects
+	# would be equivalent was wrong.  It would break on at least
+	# Digital Unix and AIX.
+	continue
+	;;
+
+      -thread-safe)
+	thread_safe=yes
+	continue
+	;;
+
+      -version-info)
+	prev=vinfo
+	continue
+	;;
+
+      -version-number)
+	prev=vinfo
+	vinfo_number=yes
+	continue
+	;;
+
+      -weak)
+        prev=weak
+	continue
+	;;
+
+      -Wc,*)
+	func_stripname '-Wc,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Wl,*)
+	func_stripname '-Wl,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+	  linker_flags="$linker_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Xcompiler)
+	prev=xcompiler
+	continue
+	;;
+
+      -Xlinker)
+	prev=xlinker
+	continue
+	;;
+
+      -XCClinker)
+	prev=xcclinker
+	continue
+	;;
+
+      # -msg_* for osf cc
+      -msg_*)
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+      # -r[0-9][0-9]* specifies the processor on the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+      # +DA*, +DD* enable 64-bit mode on the HP compiler
+      # -q* pass through compiler args for the IBM compiler
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -F/path gives path to uninstalled frameworks, gcc on darwin
+      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+        func_append compile_command " $arg"
+        func_append finalize_command " $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      # Some other compiler flag.
+      -* | +*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      *.$objext)
+	# A standard object.
+	objs="$objs $arg"
+	;;
+
+      *.lo)
+	# A libtool-controlled object.
+
+	# Check to see that this really is a libtool object.
+	if func_lalib_unsafe_p "$arg"; then
+	  pic_object=
+	  non_pic_object=
+
+	  # Read the .lo file
+	  func_source "$arg"
+
+	  if test -z "$pic_object" ||
+	     test -z "$non_pic_object" ||
+	     test "$pic_object" = none &&
+	     test "$non_pic_object" = none; then
+	    func_fatal_error "cannot find name of object for \`$arg'"
+	  fi
+
+	  # Extract subdirectory from the argument.
+	  func_dirname "$arg" "/" ""
+	  xdir="$func_dirname_result"
+
+	  if test "$pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    pic_object="$xdir$pic_object"
+
+	    if test "$prev" = dlfiles; then
+	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		dlfiles="$dlfiles $pic_object"
+		prev=
+		continue
+	      else
+		# If libtool objects are unsupported, then we need to preload.
+		prev=dlprefiles
+	      fi
+	    fi
+
+	    # CHECK ME:  I think I busted this.  -Ossama
+	    if test "$prev" = dlprefiles; then
+	      # Preload the old-style object.
+	      dlprefiles="$dlprefiles $pic_object"
+	      prev=
+	    fi
+
+	    # A PIC object.
+	    func_append libobjs " $pic_object"
+	    arg="$pic_object"
+	  fi
+
+	  # Non-PIC object.
+	  if test "$non_pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    non_pic_object="$xdir$non_pic_object"
+
+	    # A standard non-PIC object
+	    func_append non_pic_objects " $non_pic_object"
+	    if test -z "$pic_object" || test "$pic_object" = none ; then
+	      arg="$non_pic_object"
+	    fi
+	  else
+	    # If the PIC object exists, use it instead.
+	    # $xdir was prepended to $pic_object above.
+	    non_pic_object="$pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  fi
+	else
+	  # Only an error if not doing a dry-run.
+	  if $opt_dry_run; then
+	    # Extract subdirectory from the argument.
+	    func_dirname "$arg" "/" ""
+	    xdir="$func_dirname_result"
+
+	    func_lo2o "$arg"
+	    pic_object=$xdir$objdir/$func_lo2o_result
+	    non_pic_object=$xdir$func_lo2o_result
+	    func_append libobjs " $pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  else
+	    func_fatal_error "\`$arg' is not a valid libtool object"
+	  fi
+	fi
+	;;
+
+      *.$libext)
+	# An archive.
+	deplibs="$deplibs $arg"
+	old_deplibs="$old_deplibs $arg"
+	continue
+	;;
+
+      *.la)
+	# A libtool-controlled library.
+
+	if test "$prev" = dlfiles; then
+	  # This library was specified with -dlopen.
+	  dlfiles="$dlfiles $arg"
+	  prev=
+	elif test "$prev" = dlprefiles; then
+	  # The library was specified with -dlpreopen.
+	  dlprefiles="$dlprefiles $arg"
+	  prev=
+	else
+	  deplibs="$deplibs $arg"
+	fi
+	continue
+	;;
+
+      # Some other compiler argument.
+      *)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+      fi
+    done # argument parsing loop
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prevarg' option requires an argument"
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      func_append compile_command " $arg"
+      func_append finalize_command " $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    func_basename "$output"
+    outputname="$func_basename_result"
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    func_dirname "$output" "/" ""
+    output_objdir="$func_dirname_result$objdir"
+    # Create the object directory.
+    func_mkdir_p "$output_objdir"
+
+    # Determine the type of output
+    case $output in
+    "")
+      func_fatal_help "you must specify an output file"
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if $opt_duplicate_deps ; then
+	case "$libs " in
+	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if $opt_duplicate_compiler_generated_deps; then
+	for pre_post_dep in $predeps $postdeps; do
+	  case "$pre_post_deps " in
+	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+	  esac
+	  pre_post_deps="$pre_post_deps $pre_post_dep"
+	done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
+
+    case $linkmode in
+    lib)
+	passes="conv dlpreopen link"
+	for file in $dlfiles $dlprefiles; do
+	  case $file in
+	  *.la) ;;
+	  *)
+	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    ;;
+	  esac
+	done
+	;;
+    prog)
+	compile_deplibs=
+	finalize_deplibs=
+	alldeplibs=no
+	newdlfiles=
+	newdlprefiles=
+	passes="conv scan dlopen dlpreopen link"
+	;;
+    *)  passes="conv"
+	;;
+    esac
+
+    for pass in $passes; do
+      # The preopen pass in lib mode reverses $deplibs; put it back here
+      # so that -L comes before libs that need it for instance...
+      if test "$linkmode,$pass" = "lib,link"; then
+	## FIXME: Find the place where the list is rebuilt in the wrong
+	##        order, and fix it there properly
+        tmp_deplibs=
+	for deplib in $deplibs; do
+	  tmp_deplibs="$deplib $tmp_deplibs"
+	done
+	deplibs="$tmp_deplibs"
+      fi
+
+      if test "$linkmode,$pass" = "lib,link" ||
+	 test "$linkmode,$pass" = "prog,scan"; then
+	libs="$deplibs"
+	deplibs=
+      fi
+      if test "$linkmode" = prog; then
+	case $pass in
+	dlopen) libs="$dlfiles" ;;
+	dlpreopen) libs="$dlprefiles" ;;
+	link)
+	  libs="$deplibs %DEPLIBS%"
+	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+	  ;;
+	esac
+      fi
+      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+	# Collect and forward deplibs of preopened libtool libs
+	for lib in $dlprefiles; do
+	  # Ignore non-libtool-libs
+	  dependency_libs=
+	  case $lib in
+	  *.la)	func_source "$lib" ;;
+	  esac
+
+	  # Collect preopened libtool deplibs, except any this library
+	  # has declared as weak libs
+	  for deplib in $dependency_libs; do
+            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
+	    case " $weak_libs " in
+	    *" $deplib_base "*) ;;
+	    *) deplibs="$deplibs $deplib" ;;
+	    esac
+	  done
+	done
+	libs="$dlprefiles"
+      fi
+      if test "$pass" = dlopen; then
+	# Collect dlpreopened libraries
+	save_deplibs="$deplibs"
+	deplibs=
+      fi
+
+      for deplib in $libs; do
+	lib=
+	found=no
+	case $deplib in
+	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    compiler_flags="$compiler_flags $deplib"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-l*)
+	  if test "$linkmode" != lib && test "$linkmode" != prog; then
+	    func_warning "\`-l' is ignored for archives/objects"
+	    continue
+	  fi
+	  func_stripname '-l' '' "$deplib"
+	  name=$func_stripname_result
+	  if test "$linkmode" = lib; then
+	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+	  else
+	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+	  fi
+	  for searchdir in $searchdirs; do
+	    for search_ext in .la $std_shrext .so .a; do
+	      # Search the libtool library
+	      lib="$searchdir/lib${name}${search_ext}"
+	      if test -f "$lib"; then
+		if test "$search_ext" = ".la"; then
+		  found=yes
+		else
+		  found=no
+		fi
+		break 2
+	      fi
+	    done
+	  done
+	  if test "$found" != yes; then
+	    # deplib doesn't seem to be a libtool library
+	    if test "$linkmode,$pass" = "prog,link"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
+	  else # deplib is a libtool library
+	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+	    # We need to do some special things here, and not later.
+	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      case " $predeps $postdeps " in
+	      *" $deplib "*)
+		if func_lalib_p "$lib"; then
+		  library_names=
+		  old_library=
+		  func_source "$lib"
+		  for l in $old_library $library_names; do
+		    ll="$l"
+		  done
+		  if test "X$ll" = "X$old_library" ; then # only static version available
+		    found=no
+		    func_dirname "$lib" "" "."
+		    ladir="$func_dirname_result"
+		    lib=$ladir/$old_library
+		    if test "$linkmode,$pass" = "prog,link"; then
+		      compile_deplibs="$deplib $compile_deplibs"
+		      finalize_deplibs="$deplib $finalize_deplibs"
+		    else
+		      deplibs="$deplib $deplibs"
+		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		    fi
+		    continue
+		  fi
+		fi
+		;;
+	      *) ;;
+	      esac
+	    fi
+	  fi
+	  ;; # -l
+	*.ltframework)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    deplibs="$deplib $deplibs"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-L*)
+	  case $linkmode in
+	  lib)
+	    deplibs="$deplib $deplibs"
+	    test "$pass" = conv && continue
+	    newdependency_libs="$deplib $newdependency_libs"
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  prog)
+	    if test "$pass" = conv; then
+	      deplibs="$deplib $deplibs"
+	      continue
+	    fi
+	    if test "$pass" = scan; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  *)
+	    func_warning "\`-L' is ignored for archives/objects"
+	    ;;
+	  esac # linkmode
+	  continue
+	  ;; # -L
+	-R*)
+	  if test "$pass" = link; then
+	    func_stripname '-R' '' "$deplib"
+	    dir=$func_stripname_result
+	    # Make sure the xrpath contains only unique directories.
+	    case "$xrpath " in
+	    *" $dir "*) ;;
+	    *) xrpath="$xrpath $dir" ;;
+	    esac
+	  fi
+	  deplibs="$deplib $deplibs"
+	  continue
+	  ;;
+	*.la) lib="$deplib" ;;
+	*.$libext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	    continue
+	  fi
+	  case $linkmode in
+	  lib)
+	    # Linking convenience modules into shared libraries is allowed,
+	    # but linking other static libraries is non-portable.
+	    case " $dlpreconveniencelibs " in
+	    *" $deplib "*) ;;
+	    *)
+	      valid_a_lib=no
+	      case $deplibs_check_method in
+		match_pattern*)
+		  set dummy $deplibs_check_method; shift
+		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
+		    | $EGREP "$match_pattern_regex" > /dev/null; then
+		    valid_a_lib=yes
+		  fi
+		;;
+		pass_all)
+		  valid_a_lib=yes
+		;;
+	      esac
+	      if test "$valid_a_lib" != yes; then
+		$ECHO
+		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
+		$ECHO "*** that it is just a static archive that I should not use here."
+	      else
+		$ECHO
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      fi
+	      ;;
+	    esac
+	    continue
+	    ;;
+	  prog)
+	    if test "$pass" != link; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    continue
+	    ;;
+	  esac # linkmode
+	  ;; # *.$libext
+	*.lo | *.$objext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	  elif test "$linkmode" = prog; then
+	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	      # If there is no dlopen support or we're linking statically,
+	      # we need to preload.
+	      newdlprefiles="$newdlprefiles $deplib"
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      newdlfiles="$newdlfiles $deplib"
+	    fi
+	  fi
+	  continue
+	  ;;
+	%DEPLIBS%)
+	  alldeplibs=yes
+	  continue
+	  ;;
+	esac # case $deplib
+
+	if test "$found" = yes || test -f "$lib"; then :
+	else
+	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+	fi
+
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$lib" \
+	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+	func_dirname "$lib" "" "."
+	ladir="$func_dirname_result"
+
+	dlname=
+	dlopen=
+	dlpreopen=
+	libdir=
+	library_names=
+	old_library=
+	inherited_linker_flags=
+	# If the library was installed with an old release of libtool,
+	# it will not redefine variables installed, or shouldnotlink
+	installed=yes
+	shouldnotlink=no
+	avoidtemprpath=
+
+
+	# Read the .la file
+	func_source "$lib"
+
+	# Convert "-framework foo" to "foo.ltframework"
+	if test -n "$inherited_linker_flags"; then
+	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
+	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+	    case " $new_inherited_linker_flags " in
+	      *" $tmp_inherited_linker_flag "*) ;;
+	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
+	    esac
+	  done
+	fi
+	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	if test "$linkmode,$pass" = "lib,link" ||
+	   test "$linkmode,$pass" = "prog,scan" ||
+	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+	fi
+
+	if test "$pass" = conv; then
+	  # Only check for convenience libraries
+	  deplibs="$lib $deplibs"
+	  if test -z "$libdir"; then
+	    if test -z "$old_library"; then
+	      func_fatal_error "cannot find name of link library for \`$lib'"
+	    fi
+	    # It is a libtool convenience library, so add in its objects.
+	    convenience="$convenience $ladir/$objdir/$old_library"
+	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
+	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
+	    func_fatal_error "\`$lib' is not a convenience library"
+	  fi
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    deplibs="$deplib $deplibs"
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+	  continue
+	fi # $pass = conv
+
+
+	# Get the name of the library we link against.
+	linklib=
+	for l in $old_library $library_names; do
+	  linklib="$l"
+	done
+	if test -z "$linklib"; then
+	  func_fatal_error "cannot find name of link library for \`$lib'"
+	fi
+
+	# This library was specified with -dlopen.
+	if test "$pass" = dlopen; then
+	  if test -z "$libdir"; then
+	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+	  fi
+	  if test -z "$dlname" ||
+	     test "$dlopen_support" != yes ||
+	     test "$build_libtool_libs" = no; then
+	    # If there is no dlname, no dlopen support or we're linking
+	    # statically, we need to preload.  We also need to preload any
+	    # dependent libraries so libltdl's deplib preloader doesn't
+	    # bomb out in the load deplibs phase.
+	    dlprefiles="$dlprefiles $lib $dependency_libs"
+	  else
+	    newdlfiles="$newdlfiles $lib"
+	  fi
+	  continue
+	fi # $pass = dlopen
+
+	# We need an absolute path.
+	case $ladir in
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	*)
+	  abs_ladir=`cd "$ladir" && pwd`
+	  if test -z "$abs_ladir"; then
+	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "passing it literally to the linker, although it might fail"
+	    abs_ladir="$ladir"
+	  fi
+	  ;;
+	esac
+	func_basename "$lib"
+	laname="$func_basename_result"
+
+	# Find the relevant object directory and library name.
+	if test "X$installed" = Xyes; then
+	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    func_warning "library \`$lib' was moved."
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    libdir="$abs_ladir"
+	  else
+	    dir="$libdir"
+	    absdir="$libdir"
+	  fi
+	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	else
+	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  else
+	    dir="$ladir/$objdir"
+	    absdir="$abs_ladir/$objdir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  fi
+	fi # $installed = yes
+	func_stripname 'lib' '.la' "$laname"
+	name=$func_stripname_result
+
+	# This library was specified with -dlpreopen.
+	if test "$pass" = dlpreopen; then
+	  if test -z "$libdir" && test "$linkmode" = prog; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	  fi
+	  # Prefer using a static library (so that no silly _DYNAMIC symbols
+	  # are required to link).
+	  if test -n "$old_library"; then
+	    newdlprefiles="$newdlprefiles $dir/$old_library"
+	    # Keep a list of preopened convenience libraries to check
+	    # that they are being used correctly in the link pass.
+	    test -z "$libdir" && \
+		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
+	  # Otherwise, use the dlname, so that lt_dlopen finds it.
+	  elif test -n "$dlname"; then
+	    newdlprefiles="$newdlprefiles $dir/$dlname"
+	  else
+	    newdlprefiles="$newdlprefiles $dir/$linklib"
+	  fi
+	fi # $pass = dlpreopen
+
+	if test -z "$libdir"; then
+	  # Link the convenience library
+	  if test "$linkmode" = lib; then
+	    deplibs="$dir/$old_library $deplibs"
+	  elif test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$dir/$old_library $compile_deplibs"
+	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
+	  else
+	    deplibs="$lib $deplibs" # used for prog,scan pass
+	  fi
+	  continue
+	fi
+
+
+	if test "$linkmode" = prog && test "$pass" != link; then
+	  newlib_search_path="$newlib_search_path $ladir"
+	  deplibs="$lib $deplibs"
+
+	  linkalldeplibs=no
+	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
+	     test "$build_libtool_libs" = no; then
+	    linkalldeplibs=yes
+	  fi
+
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    case $deplib in
+	    -L*) func_stripname '-L' '' "$deplib"
+	         newlib_search_path="$newlib_search_path $func_stripname_result"
+		 ;;
+	    esac
+	    # Need to link against all dependency_libs?
+	    if test "$linkalldeplibs" = yes; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      # Need to hardcode shared library paths
+	      # or/and link against static libraries
+	      newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done # for deplib
+	  continue
+	fi # $linkmode = prog...
+
+	if test "$linkmode,$pass" = "prog,link"; then
+	  if test -n "$library_names" &&
+	     { { test "$prefer_static_libs" = no ||
+	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	       test -z "$old_library"; }; then
+	    # We need to hardcode the library path
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	      # Make sure the rpath contains only unique directories.
+	      case "$temp_rpath:" in
+	      *"$absdir:"*) ;;
+	      *) temp_rpath="$temp_rpath$absdir:" ;;
+	      esac
+	    fi
+
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi # $linkmode,$pass = prog,link...
+
+	  if test "$alldeplibs" = yes &&
+	     { test "$deplibs_check_method" = pass_all ||
+	       { test "$build_libtool_libs" = yes &&
+		 test -n "$library_names"; }; }; then
+	    # We only need to search for static libraries
+	    continue
+	  fi
+	fi
+
+	link_static=no # Whether the deplib will be linked statically
+	use_static_libs=$prefer_static_libs
+	if test "$use_static_libs" = built && test "$installed" = yes; then
+	  use_static_libs=no
+	fi
+	if test -n "$library_names" &&
+	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	  case $host in
+	  *cygwin* | *mingw*)
+	      # No point in relinking DLLs because paths are not encoded
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=no
+	    ;;
+	  *)
+	    if test "$installed" = no; then
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=yes
+	    fi
+	    ;;
+	  esac
+	  # This is a shared library
+
+	  # Warn about portability, can't link against -module's on some
+	  # systems (darwin).  Don't bleat about dlopened modules though!
+	  dlopenmodule=""
+	  for dlpremoduletest in $dlprefiles; do
+	    if test "X$dlpremoduletest" = "X$lib"; then
+	      dlopenmodule="$dlpremoduletest"
+	      break
+	    fi
+	  done
+	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	    $ECHO
+	    if test "$linkmode" = prog; then
+	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
+	    else
+	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+	    fi
+	    $ECHO "*** $linklib is not portable!"
+	  fi
+	  if test "$linkmode" = lib &&
+	     test "$hardcode_into_libs" = yes; then
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi
+
+	  if test -n "$old_archive_from_expsyms_cmds"; then
+	    # figure out the soname
+	    set dummy $library_names
+	    shift
+	    realname="$1"
+	    shift
+	    libname=`eval "\\$ECHO \"$libname_spec\""`
+	    # use dlname if we got it. it's perfectly good, no?
+	    if test -n "$dlname"; then
+	      soname="$dlname"
+	    elif test -n "$soname_spec"; then
+	      # bleh windows
+	      case $host in
+	      *cygwin* | mingw*)
+	        func_arith $current - $age
+		major=$func_arith_result
+		versuffix="-$major"
+		;;
+	      esac
+	      eval soname=\"$soname_spec\"
+	    else
+	      soname="$realname"
+	    fi
+
+	    # Make a new name for the extract_expsyms_cmds to use
+	    soroot="$soname"
+	    func_basename "$soroot"
+	    soname="$func_basename_result"
+	    func_stripname 'lib' '.dll' "$soname"
+	    newlib=libimp-$func_stripname_result.a
+
+	    # If the library has no export list, then create one now
+	    if test -f "$output_objdir/$soname-def"; then :
+	    else
+	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+	    fi
+
+	    # Create $newlib
+	    if test -f "$output_objdir/$newlib"; then :; else
+	      func_verbose "generating import library for \`$soname'"
+	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+	    fi
+	    # make sure the library variables are pointing to the new library
+	    dir=$output_objdir
+	    linklib=$newlib
+	  fi # test -n "$old_archive_from_expsyms_cmds"
+
+	  if test "$linkmode" = prog || test "$mode" != relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    lib_linked=yes
+	    case $hardcode_action in
+	    immediate | unsupported)
+	      if test "$hardcode_direct" = no; then
+		add="$dir/$linklib"
+		case $host in
+		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+		    *-*-unixware7*) add_dir="-L$dir" ;;
+		  *-*-darwin* )
+		    # if the lib is a (non-dlopened) module then we can not
+		    # link against it, someone is ignoring the earlier warnings
+		    if /usr/bin/file -L $add 2> /dev/null |
+			 $GREP ": [^:]* bundle" >/dev/null ; then
+		      if test "X$dlopenmodule" != "X$lib"; then
+			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
+			if test -z "$old_library" ; then
+			  $ECHO
+			  $ECHO "*** And there doesn't seem to be a static archive available"
+			  $ECHO "*** The link will probably fail, sorry"
+			else
+			  add="$dir/$old_library"
+			fi
+		      elif test -n "$old_library"; then
+			add="$dir/$old_library"
+		      fi
+		    fi
+		esac
+	      elif test "$hardcode_minus_L" = no; then
+		case $host in
+		*-*-sunos*) add_shlibpath="$dir" ;;
+		esac
+		add_dir="-L$dir"
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = no; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    relink)
+	      if test "$hardcode_direct" = yes &&
+	         test "$hardcode_direct_absolute" = no; then
+		add="$dir/$linklib"
+	      elif test "$hardcode_minus_L" = yes; then
+		add_dir="-L$dir"
+		# Try looking first in the location we're being installed to.
+		if test -n "$inst_prefix_dir"; then
+		  case $libdir in
+		    [\\/]*)
+		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		      ;;
+		  esac
+		fi
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = yes; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    *) lib_linked=no ;;
+	    esac
+
+	    if test "$lib_linked" != yes; then
+	      func_fatal_configuration "unsupported hardcode properties"
+	    fi
+
+	    if test -n "$add_shlibpath"; then
+	      case :$compile_shlibpath: in
+	      *":$add_shlibpath:"*) ;;
+	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+	      esac
+	    fi
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	      if test "$hardcode_direct" != yes &&
+		 test "$hardcode_minus_L" != yes &&
+		 test "$hardcode_shlibpath_var" = yes; then
+		case :$finalize_shlibpath: in
+		*":$libdir:"*) ;;
+		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+		esac
+	      fi
+	    fi
+	  fi
+
+	  if test "$linkmode" = prog || test "$mode" = relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    # Finalize command for both is simple: just hardcode it.
+	    if test "$hardcode_direct" = yes &&
+	       test "$hardcode_direct_absolute" = no; then
+	      add="$libdir/$linklib"
+	    elif test "$hardcode_minus_L" = yes; then
+	      add_dir="-L$libdir"
+	      add="-l$name"
+	    elif test "$hardcode_shlibpath_var" = yes; then
+	      case :$finalize_shlibpath: in
+	      *":$libdir:"*) ;;
+	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+	      esac
+	      add="-l$name"
+	    elif test "$hardcode_automatic" = yes; then
+	      if test -n "$inst_prefix_dir" &&
+		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
+		add="$inst_prefix_dir$libdir/$linklib"
+	      else
+		add="$libdir/$linklib"
+	      fi
+	    else
+	      # We cannot seem to hardcode it, guess we'll fake it.
+	      add_dir="-L$libdir"
+	      # Try looking first in the location we're being installed to.
+	      if test -n "$inst_prefix_dir"; then
+		case $libdir in
+		  [\\/]*)
+		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		    ;;
+		esac
+	      fi
+	      add="-l$name"
+	    fi
+
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	    fi
+	  fi
+	elif test "$linkmode" = prog; then
+	  # Here we assume that one of hardcode_direct or hardcode_minus_L
+	  # is not unsupported.  This is valid on all known static and
+	  # shared platforms.
+	  if test "$hardcode_direct" != unsupported; then
+	    test -n "$old_library" && linklib="$old_library"
+	    compile_deplibs="$dir/$linklib $compile_deplibs"
+	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
+	  else
+	    compile_deplibs="-l$name -L$dir $compile_deplibs"
+	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+	  fi
+	elif test "$build_libtool_libs" = yes; then
+	  # Not a shared library
+	  if test "$deplibs_check_method" != pass_all; then
+	    # We're trying link a shared library against a static one
+	    # but the system doesn't support it.
+
+	    # Just print a warning and add the library to dependency_libs so
+	    # that the program can be linked against the static library.
+	    $ECHO
+	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** I have the capability to make that library automatically link in when"
+	    $ECHO "*** you link to this library.  But I can only do this if you have a"
+	    $ECHO "*** shared version of the library, which you do not appear to have."
+	    if test "$module" = yes; then
+	      $ECHO "*** But as you try to build a module library, libtool will still create "
+	      $ECHO "*** a static module, that should work as long as the dlopening application"
+	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
+	      if test -z "$global_symbol_pipe"; then
+		$ECHO
+		$ECHO "*** However, this would only work if libtool was able to extract symbol"
+		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		$ECHO "*** not find such a program.  So, this module is probably useless."
+		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	      fi
+	      if test "$build_old_libs" = no; then
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  else
+	    deplibs="$dir/$old_library $deplibs"
+	    link_static=yes
+	  fi
+	fi # link shared/static library?
+
+	if test "$linkmode" = lib; then
+	  if test -n "$dependency_libs" &&
+	     { test "$hardcode_into_libs" != yes ||
+	       test "$build_old_libs" = yes ||
+	       test "$link_static" = yes; }; then
+	    # Extract -R from dependency_libs
+	    temp_deplibs=
+	    for libdir in $dependency_libs; do
+	      case $libdir in
+	      -R*) func_stripname '-R' '' "$libdir"
+	           temp_xrpath=$func_stripname_result
+		   case " $xrpath " in
+		   *" $temp_xrpath "*) ;;
+		   *) xrpath="$xrpath $temp_xrpath";;
+		   esac;;
+	      *) temp_deplibs="$temp_deplibs $libdir";;
+	      esac
+	    done
+	    dependency_libs="$temp_deplibs"
+	  fi
+
+	  newlib_search_path="$newlib_search_path $absdir"
+	  # Link against this library
+	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  # ... and its dependency_libs
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    newdependency_libs="$deplib $newdependency_libs"
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+
+	  if test "$link_all_deplibs" != no; then
+	    # Add the search paths of all dependency libraries
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      -L*) path="$deplib" ;;
+	      *.la)
+	        func_dirname "$deplib" "" "."
+		dir="$func_dirname_result"
+		# We need an absolute path.
+		case $dir in
+		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		*)
+		  absdir=`cd "$dir" && pwd`
+		  if test -z "$absdir"; then
+		    func_warning "cannot determine absolute directory name of \`$dir'"
+		    absdir="$dir"
+		  fi
+		  ;;
+		esac
+		if $GREP "^installed=no" $deplib > /dev/null; then
+		case $host in
+		*-*-darwin*)
+		  depdepl=
+		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names" ; then
+		    for tmp in $deplibrary_names ; do
+		      depdepl=$tmp
+		    done
+		    if test -f "$absdir/$objdir/$depdepl" ; then
+		      depdepl="$absdir/$objdir/$depdepl"
+		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+                      if test -z "$darwin_install_name"; then
+                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                      fi
+		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
+		      path=
+		    fi
+		  fi
+		  ;;
+		*)
+		  path="-L$absdir/$objdir"
+		  ;;
+		esac
+		else
+		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  test -z "$libdir" && \
+		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  test "$absdir" != "$libdir" && \
+		    func_warning "\`$deplib' seems to be moved"
+
+		  path="-L$absdir"
+		fi
+		;;
+	      esac
+	      case " $deplibs " in
+	      *" $path "*) ;;
+	      *) deplibs="$path $deplibs" ;;
+	      esac
+	    done
+	  fi # link_all_deplibs != no
+	fi # linkmode = lib
+      done # for deplib in $libs
+      if test "$pass" = link; then
+	if test "$linkmode" = "prog"; then
+	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+	else
+	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	fi
+      fi
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+	# Link the dlpreopened libraries before other libraries
+	for deplib in $save_deplibs; do
+	  deplibs="$deplib $deplibs"
+	done
+      fi
+      if test "$pass" != dlopen; then
+	if test "$pass" != conv; then
+	  # Make sure lib_search_path contains only unique directories.
+	  lib_search_path=
+	  for dir in $newlib_search_path; do
+	    case "$lib_search_path " in
+	    *" $dir "*) ;;
+	    *) lib_search_path="$lib_search_path $dir" ;;
+	    esac
+	  done
+	  newlib_search_path=
+	fi
+
+	if test "$linkmode,$pass" != "prog,link"; then
+	  vars="deplibs"
+	else
+	  vars="compile_deplibs finalize_deplibs"
+	fi
+	for var in $vars dependency_libs; do
+	  # Add libraries to $var in reverse order
+	  eval tmp_libs=\"\$$var\"
+	  new_libs=
+	  for deplib in $tmp_libs; do
+	    # FIXME: Pedantically, this is the right thing to do, so
+	    #        that some nasty dependency loop isn't accidentally
+	    #        broken:
+	    #new_libs="$deplib $new_libs"
+	    # Pragmatically, this seems to cause very few problems in
+	    # practice:
+	    case $deplib in
+	    -L*) new_libs="$deplib $new_libs" ;;
+	    -R*) ;;
+	    *)
+	      # And here is the reason: when a library appears more
+	      # than once as an explicit dependence of a library, or
+	      # is implicitly linked in more than once by the
+	      # compiler, it is considered special, and multiple
+	      # occurrences thereof are not removed.  Compare this
+	      # with having the same library being listed as a
+	      # dependency of multiple other libraries: in this case,
+	      # we know (pedantically, we assume) the library does not
+	      # need to be listed more than once, so we keep only the
+	      # last copy.  This is not always right, but it is rare
+	      # enough that we require users that really mean to play
+	      # such unportable linking tricks to link the library
+	      # using -Wl,-lname, so that libtool does not consider it
+	      # for duplicate removal.
+	      case " $specialdeplibs " in
+	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
+	      *)
+		case " $new_libs " in
+		*" $deplib "*) ;;
+		*) new_libs="$deplib $new_libs" ;;
+		esac
+		;;
+	      esac
+	      ;;
+	    esac
+	  done
+	  tmp_libs=
+	  for deplib in $new_libs; do
+	    case $deplib in
+	    -L*)
+	      case " $tmp_libs " in
+	      *" $deplib "*) ;;
+	      *) tmp_libs="$tmp_libs $deplib" ;;
+	      esac
+	      ;;
+	    *) tmp_libs="$tmp_libs $deplib" ;;
+	    esac
+	  done
+	  eval $var=\"$tmp_libs\"
+	done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+	case " $predeps $postdeps $compiler_lib_search_path " in
+	*" $i "*)
+	  i=""
+	  ;;
+	esac
+	if test -n "$i" ; then
+	  tmp_libs="$tmp_libs $i"
+	fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+    fi
+    if test "$linkmode" = prog || test "$linkmode" = lib; then
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for archives"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for archives"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for archives"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info/-version-number' is ignored for archives"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for archives"
+
+      test -n "$export_symbols$export_symbols_regex" && \
+	func_warning "\`-export-symbols' is ignored for archives"
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+	func_stripname 'lib' '.la' "$outputname"
+	name=$func_stripname_result
+	eval shared_ext=\"$shrext_cmds\"
+	eval libname=\"$libname_spec\"
+	;;
+      *)
+	test "$module" = no && \
+	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+	if test "$need_lib_prefix" != no; then
+	  # Add the "lib" prefix for modules if required
+	  func_stripname '' '.la' "$outputname"
+	  name=$func_stripname_result
+	  eval shared_ext=\"$shrext_cmds\"
+	  eval libname=\"$libname_spec\"
+	else
+	  func_stripname '' '.la' "$outputname"
+	  libname=$func_stripname_result
+	fi
+	;;
+      esac
+
+      if test -n "$objs"; then
+	if test "$deplibs_check_method" != pass_all; then
+	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	else
+	  $ECHO
+	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+	  $ECHO "*** objects $objs is not portable!"
+	  libobjs="$libobjs $objs"
+	fi
+      fi
+
+      test "$dlself" != no && \
+	func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+      set dummy $rpath
+      shift
+      test "$#" -gt 1 && \
+	func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+      install_libdir="$1"
+
+      oldlibs=
+      if test -z "$rpath"; then
+	if test "$build_libtool_libs" = yes; then
+	  # Building a libtool convenience library.
+	  # Some compilers have problems with a `.al' extension so
+	  # convenience libraries should have the same extension an
+	  # archive normally would.
+	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
+	  build_libtool_libs=convenience
+	  build_old_libs=yes
+	fi
+
+	test -n "$vinfo" && \
+	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+	test -n "$release" && \
+	  func_warning "\`-release' is ignored for convenience libraries"
+      else
+
+	# Parse the version information argument.
+	save_ifs="$IFS"; IFS=':'
+	set dummy $vinfo 0 0 0
+	shift
+	IFS="$save_ifs"
+
+	test -n "$7" && \
+	  func_fatal_help "too many parameters to \`-version-info'"
+
+	# convert absolute version numbers to libtool ages
+	# this retains compatibility with .la files and attempts
+	# to make the code below a bit more comprehensible
+
+	case $vinfo_number in
+	yes)
+	  number_major="$1"
+	  number_minor="$2"
+	  number_revision="$3"
+	  #
+	  # There are really only two kinds -- those that
+	  # use the current revision as the major version
+	  # and those that subtract age and use age as
+	  # a minor version.  But, then there is irix
+	  # which has an extra 1 added just for fun
+	  #
+	  case $version_type in
+	  darwin|linux|osf|windows|none)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_revision"
+	    ;;
+	  freebsd-aout|freebsd-elf|sunos)
+	    current="$number_major"
+	    revision="$number_minor"
+	    age="0"
+	    ;;
+	  irix|nonstopux)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_minor"
+	    lt_irix_increment=no
+	    ;;
+	  *)
+	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
+	    ;;
+	  esac
+	  ;;
+	no)
+	  current="$1"
+	  revision="$2"
+	  age="$3"
+	  ;;
+	esac
+
+	# Check that each of the things are valid numbers.
+	case $current in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "CURRENT \`$current' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $revision in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "REVISION \`$revision' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $age in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "AGE \`$age' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	if test "$age" -gt "$current"; then
+	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	fi
+
+	# Calculate the version variables.
+	major=
+	versuffix=
+	verstring=
+	case $version_type in
+	none) ;;
+
+	darwin)
+	  # Like Linux, but with the current version available in
+	  # verstring for coding it into the library header
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  # Darwin ld doesn't like 0 for these options...
+	  func_arith $current + 1
+	  minor_current=$func_arith_result
+	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+	  ;;
+
+	freebsd-aout)
+	  major=".$current"
+	  versuffix=".$current.$revision";
+	  ;;
+
+	freebsd-elf)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	irix | nonstopux)
+	  if test "X$lt_irix_increment" = "Xno"; then
+	    func_arith $current - $age
+	  else
+	    func_arith $current - $age + 1
+	  fi
+	  major=$func_arith_result
+
+	  case $version_type in
+	    nonstopux) verstring_prefix=nonstopux ;;
+	    *)         verstring_prefix=sgi ;;
+	  esac
+	  verstring="$verstring_prefix$major.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$revision
+	  while test "$loop" -ne 0; do
+	    func_arith $revision - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring_prefix$major.$iface:$verstring"
+	  done
+
+	  # Before this point, $major must not contain `.'.
+	  major=.$major
+	  versuffix="$major.$revision"
+	  ;;
+
+	linux)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  ;;
+
+	osf)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=".$current.$age.$revision"
+	  verstring="$current.$age.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$age
+	  while test "$loop" -ne 0; do
+	    func_arith $current - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring:${iface}.0"
+	  done
+
+	  # Make executables depend on our current version.
+	  verstring="$verstring:${current}.0"
+	  ;;
+
+	qnx)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	sunos)
+	  major=".$current"
+	  versuffix=".$current.$revision"
+	  ;;
+
+	windows)
+	  # Use '-' rather than '.', since we only want one
+	  # extension on DOS 8.3 filesystems.
+	  func_arith $current - $age
+	  major=$func_arith_result
+	  versuffix="-$major"
+	  ;;
+
+	*)
+	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  ;;
+	esac
+
+	# Clear the version info if we defaulted, and they specified a release.
+	if test -z "$vinfo" && test -n "$release"; then
+	  major=
+	  case $version_type in
+	  darwin)
+	    # we can't check for "0.0" in archive_cmds due to quoting
+	    # problems, so we reset it completely
+	    verstring=
+	    ;;
+	  *)
+	    verstring="0.0"
+	    ;;
+	  esac
+	  if test "$need_version" = no; then
+	    versuffix=
+	  else
+	    versuffix=".0.0"
+	  fi
+	fi
+
+	# Remove version info from name if versioning should be avoided
+	if test "$avoid_version" = yes && test "$need_version" = no; then
+	  major=
+	  versuffix=
+	  verstring=""
+	fi
+
+	# Check to see if the archive will have undefined symbols.
+	if test "$allow_undefined" = yes; then
+	  if test "$allow_undefined_flag" = unsupported; then
+	    func_warning "undefined symbols not allowed in $host shared libraries"
+	    build_libtool_libs=no
+	    build_old_libs=yes
+	  fi
+	else
+	  # Don't allow undefined symbols.
+	  allow_undefined_flag="$no_undefined_flag"
+	fi
+
+      fi
+
+      func_generate_dlsyms "$libname" "$libname" "yes"
+      libobjs="$libobjs $symfileobj"
+      test "X$libobjs" = "X " && libobjs=
+
+      if test "$mode" != relink; then
+	# Remove our outputs, but don't remove object files since they
+	# may have been created when compiling PIC objects.
+	removelist=
+	tempremovelist=`$ECHO "$output_objdir/*"`
+	for p in $tempremovelist; do
+	  case $p in
+	    *.$objext)
+	       ;;
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+	       if test "X$precious_files_regex" != "X"; then
+		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+		 then
+		   continue
+		 fi
+	       fi
+	       removelist="$removelist $p"
+	       ;;
+	    *) ;;
+	  esac
+	done
+	test -n "$removelist" && \
+	  func_show_eval "${RM}r \$removelist"
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+	oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+	# Transform .lo files to .o files.
+	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      #for path in $notinst_path; do
+      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
+      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
+      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
+      #done
+
+      if test -n "$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	temp_xrpath=
+	for libdir in $xrpath; do
+	  temp_xrpath="$temp_xrpath -R$libdir"
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	  dependency_libs="$temp_xrpath $dependency_libs"
+	fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+	case " $dlprefiles $dlfiles " in
+	*" $lib "*) ;;
+	*) dlfiles="$dlfiles $lib" ;;
+	esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+	case "$dlprefiles " in
+	*" $lib "*) ;;
+	*) dlprefiles="$dlprefiles $lib" ;;
+	esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+	if test -n "$rpath"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
+	    # these systems don't actually have a c library (as such)!
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C library is in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    ;;
+	  *-*-netbsd*)
+	    # Don't link with libc until the a.out ld.so is fixed.
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    ;;
+	  *)
+	    # Add libc to deplibs on all other systems if necessary.
+	    if test "$build_libtool_need_lc" = "yes"; then
+	      deplibs="$deplibs -lc"
+	    fi
+	    ;;
+	  esac
+	fi
+
+	# Transform deplibs into only deplibs that can be linked in shared.
+	name_save=$name
+	libname_save=$libname
+	release_save=$release
+	versuffix_save=$versuffix
+	major_save=$major
+	# I'm not sure if I'm treating the release correctly.  I think
+	# release should show up in the -l (ie -lgmp5) so we don't want to
+	# add it in twice.  Is that correct?
+	release=""
+	versuffix=""
+	major=""
+	newdeplibs=
+	droppeddeps=no
+	case $deplibs_check_method in
+	pass_all)
+	  # Don't check for shared/static.  Everything works.
+	  # This might be a little naive.  We might want to check
+	  # whether the library exists or not.  But this is on
+	  # osf3 & osf4 and I'm not really sure... Just
+	  # implementing what was already the behavior.
+	  newdeplibs=$deplibs
+	  ;;
+	test_compile)
+	  # This code stresses the "libraries are programs" paradigm to its
+	  # limits. Maybe even breaks it.  We compile a program, linking it
+	  # against the deplibs as a proxy for the library.  Then we can check
+	  # whether they linked in statically or dynamically with ldd.
+	  $opt_dry_run || $RM conftest.c
+	  cat > conftest.c <<EOF
+	  int main() { return 0; }
+EOF
+	  $opt_dry_run || $RM conftest
+	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+	    ldd_output=`ldd conftest`
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  case " $predeps $postdeps " in
+		  *" $i "*)
+		    newdeplibs="$newdeplibs $i"
+		    i=""
+		    ;;
+		  esac
+		fi
+		if test -n "$i" ; then
+		  libname=`eval "\\$ECHO \"$libname_spec\""`
+		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		  set dummy $deplib_matches; shift
+		  deplib_match=$1
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    newdeplibs="$newdeplibs $i"
+		  else
+		    droppeddeps=yes
+		    $ECHO
+		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		    $ECHO "*** I have the capability to make that library automatically link in when"
+		    $ECHO "*** you link to this library.  But I can only do this if you have a"
+		    $ECHO "*** shared version of the library, which I believe you do not have"
+		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
+		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
+		  fi
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  else
+	    # Error occurred in the first compile.  Let's try to salvage
+	    # the situation: Compile a separate program for each library.
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		$opt_dry_run || $RM conftest
+		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+		  ldd_output=`ldd conftest`
+		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		    case " $predeps $postdeps " in
+		    *" $i "*)
+		      newdeplibs="$newdeplibs $i"
+		      i=""
+		      ;;
+		    esac
+		  fi
+		  if test -n "$i" ; then
+		    libname=`eval "\\$ECHO \"$libname_spec\""`
+		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		    set dummy $deplib_matches; shift
+		    deplib_match=$1
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		      newdeplibs="$newdeplibs $i"
+		    else
+		      droppeddeps=yes
+		      $ECHO
+		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		      $ECHO "*** I have the capability to make that library automatically link in when"
+		      $ECHO "*** you link to this library.  But I can only do this if you have a"
+		      $ECHO "*** shared version of the library, which you do not appear to have"
+		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
+		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
+		    fi
+		  fi
+		else
+		  droppeddeps=yes
+		  $ECHO
+		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
+		  $ECHO "*** make it link in!  You will probably need to install it or some"
+		  $ECHO "*** library that it depends on before this library will be fully"
+		  $ECHO "*** functional.  Installing it before continuing would be even better."
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  fi
+	  ;;
+	file_magic*)
+	  set dummy $deplibs_check_method; shift
+	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		      # Follow soft links.
+		      if ls -lLd "$potent_lib" 2>/dev/null |
+			 $GREP " -> " >/dev/null; then
+			continue
+		      fi
+		      # The statement above tries to avoid entering an
+		      # endless loop below, in case of cyclic links.
+		      # We might still enter an endless loop, since a link
+		      # loop can be closed while we follow links,
+		      # but so what?
+		      potlib="$potent_lib"
+		      while test -h "$potlib" 2>/dev/null; do
+			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			case $potliblink in
+			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+			esac
+		      done
+		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+			 $SED -e 10q |
+			 $EGREP "$file_magic_regex" > /dev/null; then
+			newdeplibs="$newdeplibs $a_deplib"
+			a_deplib=""
+			break 2
+		      fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a file magic. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	match_pattern*)
+	  set dummy $deplibs_check_method; shift
+	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
+		       $EGREP "$match_pattern_regex" > /dev/null; then
+		      newdeplibs="$newdeplibs $a_deplib"
+		      a_deplib=""
+		      break 2
+		    fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	none | unknown | *)
+	  newdeplibs=""
+	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
+	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
+	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    for i in $predeps $postdeps ; do
+	      # can't use Xsed below, because $i might contain '/'
+	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
+	    done
+	  fi
+	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
+	     $GREP . >/dev/null; then
+	    $ECHO
+	    if test "X$deplibs_check_method" = "Xnone"; then
+	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
+	    else
+	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
+	    fi
+	    $ECHO "*** All declared inter-library dependencies are being dropped."
+	    droppeddeps=yes
+	  fi
+	  ;;
+	esac
+	versuffix=$versuffix_save
+	major=$major_save
+	release=$release_save
+	libname=$libname_save
+	name=$name_save
+
+	case $host in
+	*-*-rhapsody* | *-*-darwin1.[012])
+	  # On Rhapsody replace the C library with the System framework
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	  ;;
+	esac
+
+	if test "$droppeddeps" = yes; then
+	  if test "$module" = yes; then
+	    $ECHO
+	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
+	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
+	    $ECHO "*** a static module, that should work as long as the dlopening"
+	    $ECHO "*** application is linked with the -dlopen flag."
+	    if test -z "$global_symbol_pipe"; then
+	      $ECHO
+	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
+	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      $ECHO "*** not find such a program.  So, this module is probably useless."
+	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	    fi
+	    if test "$build_old_libs" = no; then
+	      oldlibs="$output_objdir/$libname.$libext"
+	      build_libtool_libs=module
+	      build_old_libs=yes
+	    else
+	      build_libtool_libs=no
+	    fi
+	  else
+	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
+	    $ECHO "*** automatically added whenever a program is linked with this library"
+	    $ECHO "*** or is declared to -dlopen it."
+
+	    if test "$allow_undefined" = no; then
+	      $ECHO
+	      $ECHO "*** Since this library must not contain undefined symbols,"
+	      $ECHO "*** because either the platform does not support them or"
+	      $ECHO "*** it was explicitly requested with -no-undefined,"
+	      $ECHO "*** libtool will only create a static version of it."
+	      if test "$build_old_libs" = no; then
+		oldlibs="$output_objdir/$libname.$libext"
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  fi
+	fi
+	# Done checking deplibs!
+	deplibs=$newdeplibs
+      fi
+      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+      case $host in
+	*-*-darwin*)
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  ;;
+      esac
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      deplibs="$new_libs"
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+	if test "$hardcode_into_libs" = yes; then
+	  # Hardcode the library paths
+	  hardcode_libdirs=
+	  dep_rpath=
+	  rpath="$finalize_rpath"
+	  test "$mode" != relink && rpath="$compile_rpath$rpath"
+	  for libdir in $rpath; do
+	    if test -n "$hardcode_libdir_flag_spec"; then
+	      if test -n "$hardcode_libdir_separator"; then
+		if test -z "$hardcode_libdirs"; then
+		  hardcode_libdirs="$libdir"
+		else
+		  # Just accumulate the unique libdirs.
+		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		    ;;
+		  *)
+		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		    ;;
+		  esac
+		fi
+	      else
+		eval flag=\"$hardcode_libdir_flag_spec\"
+		dep_rpath="$dep_rpath $flag"
+	      fi
+	    elif test -n "$runpath_var"; then
+	      case "$perm_rpath " in
+	      *" $libdir "*) ;;
+	      *) perm_rpath="$perm_rpath $libdir" ;;
+	      esac
+	    fi
+	  done
+	  # Substitute the hardcoded libdirs into the rpath.
+	  if test -n "$hardcode_libdir_separator" &&
+	     test -n "$hardcode_libdirs"; then
+	    libdir="$hardcode_libdirs"
+	    if test -n "$hardcode_libdir_flag_spec_ld"; then
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+	    else
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+	    fi
+	  fi
+	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
+	    # We should set the runpath_var.
+	    rpath=
+	    for dir in $perm_rpath; do
+	      rpath="$rpath$dir:"
+	    done
+	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+	  fi
+	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+	fi
+
+	shlibpath="$finalize_shlibpath"
+	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	if test -n "$shlibpath"; then
+	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+	fi
+
+	# Get the real and link names of the library.
+	eval shared_ext=\"$shrext_cmds\"
+	eval library_names=\"$library_names_spec\"
+	set dummy $library_names
+	shift
+	realname="$1"
+	shift
+
+	if test -n "$soname_spec"; then
+	  eval soname=\"$soname_spec\"
+	else
+	  soname="$realname"
+	fi
+	if test -z "$dlname"; then
+	  dlname=$soname
+	fi
+
+	lib="$output_objdir/$realname"
+	linknames=
+	for link
+	do
+	  linknames="$linknames $link"
+	done
+
+	# Use standard objects if they are pic
+	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	test "X$libobjs" = "X " && libobjs=
+
+	delfiles=
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+	  export_symbols="$output_objdir/$libname.uexp"
+	  delfiles="$delfiles $export_symbols"
+	fi
+
+	orig_export_symbols=
+	case $host_os in
+	cygwin* | mingw*)
+	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+	    # exporting using user supplied symfile
+	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	      # and it's NOT already a .def file. Must figure out
+	      # which of the given symbols are data symbols and tag
+	      # them as such. So, trigger use of export_symbols_cmds.
+	      # export_symbols gets reassigned inside the "prepare
+	      # the list of exported symbols" if statement, so the
+	      # include_expsyms logic still works.
+	      orig_export_symbols="$export_symbols"
+	      export_symbols=
+	      always_export_symbols=yes
+	    fi
+	  fi
+	  ;;
+	esac
+
+	# Prepare the list of exported symbols
+	if test -z "$export_symbols"; then
+	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for \`$libname.la'"
+	    export_symbols="$output_objdir/$libname.exp"
+	    $opt_dry_run || $RM $export_symbols
+	    cmds=$export_symbols_cmds
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      eval cmd=\"$cmd\"
+	      func_len " $cmd"
+	      len=$func_len_result
+	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+		func_show_eval "$cmd" 'exit $?'
+		skipped_export=false
+	      else
+		# The command line is too long to execute in one step.
+		func_verbose "using reloadable object file for export list..."
+		skipped_export=:
+		# Break out early, otherwise skipped_export may be
+		# set to false by a later but shorter cmd.
+		break
+	      fi
+	    done
+	    IFS="$save_ifs"
+	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+	fi
+
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  tmp_export_symbols="$export_symbols"
+	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	fi
+
+	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	  # The given exports_symbols file has to be filtered, so filter it.
+	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # though. Also, the filter scales superlinearly with the number of
+	  # global variables. join(1) would be nice here, but unfortunately
+	  # isn't a blessed tool.
+	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	  export_symbols=$output_objdir/$libname.def
+	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	fi
+
+	tmp_deplibs=
+	for test_deplib in $deplibs; do
+	  case " $convenience " in
+	  *" $test_deplib "*) ;;
+	  *)
+	    tmp_deplibs="$tmp_deplibs $test_deplib"
+	    ;;
+	  esac
+	done
+	deplibs="$tmp_deplibs"
+
+	if test -n "$convenience"; then
+	  if test -n "$whole_archive_flag_spec" &&
+	    test "$compiler_needs_object" = yes &&
+	    test -z "$libobjs"; then
+	    # extract the archives, so we have objects to list.
+	    # TODO: could optimize this to just extract one archive.
+	    whole_archive_flag_spec=
+	  fi
+	  if test -n "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  else
+	    gentop="$output_objdir/${outputname}x"
+	    generated="$generated $gentop"
+
+	    func_extract_archives $gentop $convenience
+	    libobjs="$libobjs $func_extract_archives_result"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	fi
+
+	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	  eval flag=\"$thread_safe_flag_spec\"
+	  linker_flags="$linker_flags $flag"
+	fi
+
+	# Make a backup of the uninstalled library when relinking
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+	fi
+
+	# Do each of the archive commands.
+	if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	    eval test_cmds=\"$module_expsym_cmds\"
+	    cmds=$module_expsym_cmds
+	  else
+	    eval test_cmds=\"$module_cmds\"
+	    cmds=$module_cmds
+	  fi
+	else
+	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	    eval test_cmds=\"$archive_expsym_cmds\"
+	    cmds=$archive_expsym_cmds
+	  else
+	    eval test_cmds=\"$archive_cmds\"
+	    cmds=$archive_cmds
+	  fi
+	fi
+
+	if test "X$skipped_export" != "X:" &&
+	   func_len " $test_cmds" &&
+	   len=$func_len_result &&
+	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  :
+	else
+	  # The command line is too long to link in one step, link piecewise
+	  # or, if using GNU ld and skipped_export is not :, use a linker
+	  # script.
+
+	  # Save the value of $output and $libobjs because we want to
+	  # use them later.  If we have whole_archive_flag_spec, we
+	  # want to use save_libobjs as it was before
+	  # whole_archive_flag_spec was expanded, because we can't
+	  # assume the linker understands whole_archive_flag_spec.
+	  # This may have to be revisited, in case too many
+	  # convenience libraries get linked in and end up exceeding
+	  # the spec.
+	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	  fi
+	  save_output=$output
+	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
+
+	  # Clear the reloadable object creation command queue and
+	  # initialize k to one.
+	  test_cmds=
+	  concat_cmds=
+	  objlist=
+	  last_robj=
+	  k=1
+
+	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+	    output=${output_objdir}/${output_la}.lnkscript
+	    func_verbose "creating GNU ld script: $output"
+	    $ECHO 'INPUT (' > $output
+	    for obj in $save_libobjs
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    $ECHO ')' >> $output
+	    delfiles="$delfiles $output"
+	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+	    output=${output_objdir}/${output_la}.lnk
+	    func_verbose "creating linker input file list: $output"
+	    : > $output
+	    set x $save_libobjs
+	    shift
+	    firstobj=
+	    if test "$compiler_needs_object" = yes; then
+	      firstobj="$1 "
+	      shift
+	    fi
+	    for obj
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    delfiles="$delfiles $output"
+	    output=$firstobj\"$file_list_spec$output\"
+	  else
+	    if test -n "$save_libobjs"; then
+	      func_verbose "creating reloadable object files..."
+	      output=$output_objdir/$output_la-${k}.$objext
+	      eval test_cmds=\"$reload_cmds\"
+	      func_len " $test_cmds"
+	      len0=$func_len_result
+	      len=$len0
+
+	      # Loop over the list of objects to be linked.
+	      for obj in $save_libobjs
+	      do
+		func_len " $obj"
+		func_arith $len + $func_len_result
+		len=$func_arith_result
+		if test "X$objlist" = X ||
+		   test "$len" -lt "$max_cmd_len"; then
+		  func_append objlist " $obj"
+		else
+		  # The command $test_cmds is almost too long, add a
+		  # command to the queue.
+		  if test "$k" -eq 1 ; then
+		    # The first file doesn't have a previous command to add.
+		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+		  else
+		    # All subsequent reloadable object files will link in
+		    # the last one created.
+		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
+		  fi
+		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  func_arith $k + 1
+		  k=$func_arith_result
+		  output=$output_objdir/$output_la-${k}.$objext
+		  objlist=$obj
+		  func_len " $last_robj"
+		  func_arith $len0 + $func_len_result
+		  len=$func_arith_result
+		fi
+	      done
+	      # Handle the remaining objects by creating one last
+	      # reloadable object file.  All subsequent reloadable object
+	      # files will link in the last one created.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+	      if test -n "$last_robj"; then
+	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	      fi
+	      delfiles="$delfiles $output"
+
+	    else
+	      output=
+	    fi
+
+	    if ${skipped_export-false}; then
+	      func_verbose "generating symbol list for \`$libname.la'"
+	      export_symbols="$output_objdir/$libname.exp"
+	      $opt_dry_run || $RM $export_symbols
+	      libobjs=$output
+	      # Append the command to create the export file.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+	      if test -n "$last_robj"; then
+		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+	      fi
+	    fi
+
+	    test -n "$save_libobjs" &&
+	      func_verbose "creating a temporary reloadable object file: $output"
+
+	    # Loop through the commands generated above and execute them.
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $concat_cmds; do
+	      IFS="$save_ifs"
+	      $opt_silent || {
+		  func_quote_for_expand "$cmd"
+		  eval "func_echo $func_quote_for_expand_result"
+	      }
+	      $opt_dry_run || eval "$cmd" || {
+		lt_exit=$?
+
+		# Restore the uninstalled library and exit
+		if test "$mode" = relink; then
+		  ( cd "$output_objdir" && \
+		    $RM "${realname}T" && \
+		    $MV "${realname}U" "$realname" )
+		fi
+
+		exit $lt_exit
+	      }
+	    done
+	    IFS="$save_ifs"
+
+	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+
+          if ${skipped_export-false}; then
+	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	      tmp_export_symbols="$export_symbols"
+	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	    fi
+
+	    if test -n "$orig_export_symbols"; then
+	      # The given exports_symbols file has to be filtered, so filter it.
+	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # though. Also, the filter scales superlinearly with the number of
+	      # global variables. join(1) would be nice here, but unfortunately
+	      # isn't a blessed tool.
+	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	      export_symbols=$output_objdir/$libname.def
+	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	    fi
+	  fi
+
+	  libobjs=$output
+	  # Restore the value of output.
+	  output=$save_output
+
+	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	  # Expand the library linking commands again to reset the
+	  # value of $libobjs for piecewise linking.
+
+	  # Do each of the archive commands.
+	  if test "$module" = yes && test -n "$module_cmds" ; then
+	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	      cmds=$module_expsym_cmds
+	    else
+	      cmds=$module_cmds
+	    fi
+	  else
+	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	      cmds=$archive_expsym_cmds
+	    else
+	      cmds=$archive_cmds
+	    fi
+	  fi
+	fi
+
+	if test -n "$delfiles"; then
+	  # Append the command to remove temporary files to $cmds.
+	  eval cmds=\"\$cmds~\$RM $delfiles\"
+	fi
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  libobjs="$libobjs $func_extract_archives_result"
+	  test "X$libobjs" = "X " && libobjs=
+	fi
+
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  eval cmd=\"$cmd\"
+	  $opt_silent || {
+	    func_quote_for_expand "$cmd"
+	    eval "func_echo $func_quote_for_expand_result"
+	  }
+	  $opt_dry_run || eval "$cmd" || {
+	    lt_exit=$?
+
+	    # Restore the uninstalled library and exit
+	    if test "$mode" = relink; then
+	      ( cd "$output_objdir" && \
+	        $RM "${realname}T" && \
+		$MV "${realname}U" "$realname" )
+	    fi
+
+	    exit $lt_exit
+	  }
+	done
+	IFS="$save_ifs"
+
+	# Restore the uninstalled library and exit
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+	  if test -n "$convenience"; then
+	    if test -z "$whole_archive_flag_spec"; then
+	      func_show_eval '${RM}r "$gentop"'
+	    fi
+	  fi
+
+	  exit $EXIT_SUCCESS
+	fi
+
+	# Create links to the real library.
+	for linkname in $linknames; do
+	  if test "$realname" != "$linkname"; then
+	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+	  fi
+	done
+
+	# If -module or -export-dynamic was specified, set the dlname.
+	if test "$module" = yes || test "$export_dynamic" = yes; then
+	  # On all known operating systems, these are identical.
+	  dlname="$soname"
+	fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for objects"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for objects"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for objects"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for objects"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for objects"
+
+      case $output in
+      *.lo)
+	test -n "$objs$old_deplibs" && \
+	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+	libobj=$output
+	func_lo2o "$libobj"
+	obj=$func_lo2o_result
+	;;
+      *)
+	libobj=
+	obj="$output"
+	;;
+      esac
+
+      # Delete the old objects.
+      $opt_dry_run || $RM $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
+      wl=
+
+      if test -n "$convenience"; then
+	if test -n "$whole_archive_flag_spec"; then
+	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
+	else
+	  gentop="$output_objdir/${obj}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $convenience
+	  reload_conv_objs="$reload_objs $func_extract_archives_result"
+	fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      func_execute_cmds "$reload_cmds" 'exit $?'
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	# Create an invalid libtool object if no PIC, so that we don't
+	# accidentally link it into a program.
+	# $show "echo timestamp > $libobj"
+	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+	exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+	# Only do commands if we really have different PIC objects.
+	reload_objs="$libobjs $reload_conv_objs"
+	output="$libobj"
+	func_execute_cmds "$reload_cmds" 'exit $?'
+      fi
+
+      if test -n "$gentop"; then
+	func_show_eval '${RM}r "$gentop"'
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+	*cygwin*) func_stripname '' '.exe' "$output"
+	          output=$func_stripname_result.exe;;
+      esac
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for programs"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for programs"
+
+      test "$preload" = yes \
+        && test "$dlopen_support" = unknown \
+	&& test "$dlopen_self" = unknown \
+	&& test "$dlopen_self_static" = unknown && \
+	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+	# On Rhapsody replace the C library is the System framework
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	;;
+      esac
+
+      case $host in
+      *-*-darwin*)
+	# Don't allow lazy linking, it breaks C++ global constructors
+	# But is supposedly fixed on 10.4 or later (yay!).
+	if test "$tagname" = CXX ; then
+	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+	    10.[0123])
+	      compile_command="$compile_command ${wl}-bind_at_load"
+	      finalize_command="$finalize_command ${wl}-bind_at_load"
+	    ;;
+	  esac
+	fi
+	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $compile_deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $compile_deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	for libdir in $rpath $xrpath; do
+	  # This is the magic to use -rpath.
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) perm_rpath="$perm_rpath $libdir" ;;
+	  esac
+	fi
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$libdir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$libdir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$finalize_perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+	  esac
+	fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+	# Transform all the library objects into standard objects.
+	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+      # template prelinking step
+      if test -n "$prelink_cmds"; then
+	func_execute_cmds "$prelink_cmds" 'exit $?'
+      fi
+
+      wrappers_required=yes
+      case $host in
+      *cygwin* | *mingw* )
+        if test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      *)
+        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      esac
+      if test "$wrappers_required" = no; then
+	# Replace the output file specification.
+	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	link_command="$compile_command$compile_rpath"
+
+	# We have no uninstalled library dependencies, so finalize right now.
+	exit_status=0
+	func_show_eval "$link_command" 'exit_status=$?'
+
+	# Delete the generated files.
+	if test -f "$output_objdir/${outputname}S.${objext}"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	fi
+
+	exit $exit_status
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+	if test -n "$perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+	if test -n "$finalize_perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $finalize_perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+      fi
+
+      if test "$no_install" = yes; then
+	# We don't need to create a wrapper script.
+	link_command="$compile_var$compile_command$compile_rpath"
+	# Replace the output file specification.
+	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	# Delete the old output file.
+	$opt_dry_run || $RM $output
+	# Link the executable and exit
+	func_show_eval "$link_command" 'exit $?'
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+	# Fast installation is not supported
+	link_command="$compile_var$compile_command$compile_rpath"
+	relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+	func_warning "this platform does not like uninstalled shared libraries"
+	func_warning "\`$output' will be relinked during installation"
+      else
+	if test "$fast_install" != no; then
+	  link_command="$finalize_var$compile_command$finalize_rpath"
+	  if test "$fast_install" = yes; then
+	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	  else
+	    # fast_install is set to needless
+	    relink_command=
+	  fi
+	else
+	  link_command="$compile_var$compile_command$compile_rpath"
+	  relink_command="$finalize_var$finalize_command$finalize_rpath"
+	fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      func_show_eval "$link_command" 'exit $?'
+
+      # Now create the wrapper script.
+      func_verbose "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+	# Preserve any variables that may affect compiler behavior
+	for var in $variables_saved_for_relink; do
+	  if eval test -z \"\${$var+set}\"; then
+	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	  elif eval var_value=\$$var; test -z "$var_value"; then
+	    relink_command="$var=; export $var; $relink_command"
+	  else
+	    func_quote_for_eval "$var_value"
+	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	  fi
+	done
+	relink_command="(cd `pwd`; $relink_command)"
+	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $ECHO for shipping.
+      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
+	case $progpath in
+	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+	esac
+	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if not in dry run mode.
+      $opt_dry_run || {
+	# win32 will think the script is a binary if it has
+	# a .exe suffix, so we strip it off here.
+	case $output in
+	  *.exe) func_stripname '' '.exe' "$output"
+	         output=$func_stripname_result ;;
+	esac
+	# test for cygwin because mv fails w/o .exe extensions
+	case $host in
+	  *cygwin*)
+	    exeext=.exe
+	    func_stripname '' '.exe' "$outputname"
+	    outputname=$func_stripname_result ;;
+	  *) exeext= ;;
+	esac
+	case $host in
+	  *cygwin* | *mingw* )
+	    func_dirname_and_basename "$output" "" "."
+	    output_name=$func_basename_result
+	    output_path=$func_dirname_result
+	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
+	    cwrapper="$output_path/$output_name.exe"
+	    $RM $cwrappersource $cwrapper
+	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_cwrapperexe_src > $cwrappersource
+
+	    # we should really use a build-platform specific compiler
+	    # here, but OTOH, the wrappers (shell script and this C one)
+	    # are only useful if you want to execute the "real" binary.
+	    # Since the "real" binary is built for $host, then this
+	    # wrapper might as well be built for $host, too.
+	    $opt_dry_run || {
+	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+	      $STRIP $cwrapper
+	    }
+
+	    # Now, create the wrapper script for func_source use:
+	    func_ltwrapper_scriptname $cwrapper
+	    $RM $func_ltwrapper_scriptname_result
+	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+	    $opt_dry_run || {
+	      # note: this script will not be executed, so do not chmod.
+	      if test "x$build" = "x$host" ; then
+		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+	      else
+		func_emit_wrapper no > $func_ltwrapper_scriptname_result
+	      fi
+	    }
+	  ;;
+	  * )
+	    $RM $output
+	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_wrapper no > $output
+	    chmod +x $output
+	  ;;
+	esac
+      }
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+	oldobjs="$libobjs_save $symfileobj"
+	addlibs="$convenience"
+	build_libtool_libs=no
+      else
+	if test "$build_libtool_libs" = module; then
+	  oldobjs="$libobjs_save"
+	  build_libtool_libs=no
+	else
+	  oldobjs="$old_deplibs $non_pic_objects"
+	  if test "$preload" = yes && test -f "$symfileobj"; then
+	    oldobjs="$oldobjs $symfileobj"
+	  fi
+	fi
+	addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+	gentop="$output_objdir/${outputname}x"
+	generated="$generated $gentop"
+
+	func_extract_archives $gentop $addlibs
+	oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+	cmds=$old_archive_from_new_cmds
+      else
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  oldobjs="$oldobjs $func_extract_archives_result"
+	fi
+
+	# POSIX demands no paths to be encoded in archives.  We have
+	# to avoid creating archives with duplicate basenames if we
+	# might have to extract them afterwards, e.g., when creating a
+	# static archive out of a convenience library, or when linking
+	# the entirety of a libtool archive into another (currently
+	# not supported by libtool).
+	if (for obj in $oldobjs
+	    do
+	      func_basename "$obj"
+	      $ECHO "$func_basename_result"
+	    done | sort | sort -uc >/dev/null 2>&1); then
+	  :
+	else
+	  $ECHO "copying selected object files to avoid basename conflicts..."
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+	  func_mkdir_p "$gentop"
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  counter=1
+	  for obj in $save_oldobjs
+	  do
+	    func_basename "$obj"
+	    objbase="$func_basename_result"
+	    case " $oldobjs " in
+	    " ") oldobjs=$obj ;;
+	    *[\ /]"$objbase "*)
+	      while :; do
+		# Make sure we don't pick an alternate name that also
+		# overlaps.
+		newobj=lt$counter-$objbase
+		func_arith $counter + 1
+		counter=$func_arith_result
+		case " $oldobjs " in
+		*[\ /]"$newobj "*) ;;
+		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
+		esac
+	      done
+	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+	      oldobjs="$oldobjs $gentop/$newobj"
+	      ;;
+	    *) oldobjs="$oldobjs $obj" ;;
+	    esac
+	  done
+	fi
+	eval cmds=\"$old_archive_cmds\"
+
+	func_len " $cmds"
+	len=$func_len_result
+	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  cmds=$old_archive_cmds
+	else
+	  # the command line is too long to link in one step, link in parts
+	  func_verbose "using piecewise archive linking..."
+	  save_RANLIB=$RANLIB
+	  RANLIB=:
+	  objlist=
+	  concat_cmds=
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  # Is there a better way of finding the last object in the list?
+	  for obj in $save_oldobjs
+	  do
+	    last_oldobj=$obj
+	  done
+	  eval test_cmds=\"$old_archive_cmds\"
+	  func_len " $test_cmds"
+	  len0=$func_len_result
+	  len=$len0
+	  for obj in $save_oldobjs
+	  do
+	    func_len " $obj"
+	    func_arith $len + $func_len_result
+	    len=$func_arith_result
+	    func_append objlist " $obj"
+	    if test "$len" -lt "$max_cmd_len"; then
+	      :
+	    else
+	      # the above command should be used before it gets too long
+	      oldobjs=$objlist
+	      if test "$obj" = "$last_oldobj" ; then
+		RANLIB=$save_RANLIB
+	      fi
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      objlist=
+	      len=$len0
+	    fi
+	  done
+	  RANLIB=$save_RANLIB
+	  oldobjs=$objlist
+	  if test "X$oldobjs" = "X" ; then
+	    eval cmds=\"\$concat_cmds\"
+	  else
+	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+	  fi
+	fi
+      fi
+      func_execute_cmds "$cmds" 'exit $?'
+    done
+
+    test -n "$generated" && \
+      func_show_eval "${RM}r$generated"
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      func_verbose "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+	if eval test -z \"\${$var+set}\"; then
+	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	elif eval var_value=\$$var; test -z "$var_value"; then
+	  relink_command="$var=; export $var; $relink_command"
+	else
+	  func_quote_for_eval "$var_value"
+	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+	relink_command=
+      fi
+
+      # Only create the output if not a dry run.
+      $opt_dry_run || {
+	for installed in no yes; do
+	  if test "$installed" = yes; then
+	    if test -z "$install_libdir"; then
+	      break
+	    fi
+	    output="$output_objdir/$outputname"i
+	    # Replace all uninstalled libtool libraries with the installed ones
+	    newdependency_libs=
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      *.la)
+		func_basename "$deplib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		newdependency_libs="$newdependency_libs $libdir/$name"
+		;;
+	      *) newdependency_libs="$newdependency_libs $deplib" ;;
+	      esac
+	    done
+	    dependency_libs="$newdependency_libs"
+	    newdlfiles=
+
+	    for lib in $dlfiles; do
+	      case $lib in
+	      *.la)
+	        func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlfiles="$newdlfiles $libdir/$name"
+		;;
+	      *) newdlfiles="$newdlfiles $lib" ;;
+	      esac
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+	      *.la)
+		# Only pass preopened files to the pseudo-archive (for
+		# eventual linking with the app. that links it) if we
+		# didn't already link the preopened objects directly into
+		# the library:
+		func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlprefiles="$newdlprefiles $libdir/$name"
+		;;
+	      esac
+	    done
+	    dlprefiles="$newdlprefiles"
+	  else
+	    newdlfiles=
+	    for lib in $dlfiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlfiles="$newdlfiles $abs"
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlprefiles="$newdlprefiles $abs"
+	    done
+	    dlprefiles="$newdlprefiles"
+	  fi
+	  $RM $output
+	  # place dlname in correct position for cygwin
+	  tdlname=$dlname
+	  case $host,$output,$installed,$module,$dlname in
+	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+	  esac
+	  $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+	  if test "$installed" = no && test "$need_relink" = yes; then
+	    $ECHO >> $output "\
+relink_command=\"$relink_command\""
+	  fi
+	done
+      }
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+}
+
+{ test "$mode" = link || test "$mode" = relink; } &&
+    func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+    $opt_debug
+    RM="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) RM="$RM $arg"; rmforce=yes ;;
+      -*) RM="$RM $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    test -z "$RM" && \
+      func_fatal_help "you must specify an RM program"
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      func_dirname "$file" "" "."
+      dir="$func_dirname_result"
+      if test "X$dir" = X.; then
+	objdir="$origobjdir"
+      else
+	objdir="$dir/$origobjdir"
+      fi
+      func_basename "$file"
+      name="$func_basename_result"
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+	case " $rmdirs " in
+	  *" $objdir "*) ;;
+	  *) rmdirs="$rmdirs $objdir" ;;
+	esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if { test -L "$file"; } >/dev/null 2>&1 ||
+	 { test -h "$file"; } >/dev/null 2>&1 ||
+	 test -f "$file"; then
+	:
+      elif test -d "$file"; then
+	exit_status=1
+	continue
+      elif test "$rmforce" = yes; then
+	continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+	# Possibly a libtool archive, so verify it.
+	if func_lalib_p "$file"; then
+	  func_source $dir/$name
+
+	  # Delete the libtool libraries and symlinks.
+	  for n in $library_names; do
+	    rmfiles="$rmfiles $objdir/$n"
+	  done
+	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+	  case "$mode" in
+	  clean)
+	    case "  $library_names " in
+	    # "  " in the beginning catches empty $dlname
+	    *" $dlname "*) ;;
+	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
+	    esac
+	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+	    ;;
+	  uninstall)
+	    if test -n "$library_names"; then
+	      # Do each command in the postuninstall commands.
+	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+
+	    if test -n "$old_library"; then
+	      # Do each command in the old_postuninstall commands.
+	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+	    # FIXME: should reinstall the best remaining shared library.
+	    ;;
+	  esac
+	fi
+	;;
+
+      *.lo)
+	# Possibly a libtool object, so verify it.
+	if func_lalib_p "$file"; then
+
+	  # Read the .lo file
+	  func_source $dir/$name
+
+	  # Add PIC object to the list of files to remove.
+	  if test -n "$pic_object" &&
+	     test "$pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$pic_object"
+	  fi
+
+	  # Add non-PIC object to the list of files to remove.
+	  if test -n "$non_pic_object" &&
+	     test "$non_pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$non_pic_object"
+	  fi
+	fi
+	;;
+
+      *)
+	if test "$mode" = clean ; then
+	  noexename=$name
+	  case $file in
+	  *.exe)
+	    func_stripname '' '.exe' "$file"
+	    file=$func_stripname_result
+	    func_stripname '' '.exe' "$name"
+	    noexename=$func_stripname_result
+	    # $file with .exe has already been added to rmfiles,
+	    # add $file without .exe
+	    rmfiles="$rmfiles $file"
+	    ;;
+	  esac
+	  # Do a test to see if this is a libtool program.
+	  if func_ltwrapper_p "$file"; then
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      relink_command=
+	      func_source $func_ltwrapper_scriptname_result
+	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
+	    else
+	      relink_command=
+	      func_source $dir/$noexename
+	    fi
+
+	    # note $name still contains .exe if it was in $file originally
+	    # as does the version of $file that was added into $rmfiles
+	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	      rmfiles="$rmfiles $objdir/lt-$name"
+	    fi
+	    if test "X$noexename" != "X$name" ; then
+	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+	    fi
+	  fi
+	fi
+	;;
+      esac
+      func_show_eval "$RM $rmfiles" 'exit_status=1'
+    done
+    objdir="$origobjdir"
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+	func_show_eval "rmdir $dir >/dev/null 2>&1"
+      fi
+    done
+
+    exit $exit_status
+}
+
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+    func_mode_uninstall ${1+"$@"}
+
+test -z "$mode" && {
+  help="$generic_help"
+  func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+  func_fatal_help "invalid operation mode \`$mode'"
+
+if test -n "$exec_cmd"; then
+  eval exec "$exec_cmd"
+  exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/CoreFoundation/config/missing b/CoreFoundation/config/missing
new file mode 100755
index 0000000..1c8ff70
--- /dev/null
+++ b/CoreFoundation/config/missing
@@ -0,0 +1,367 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2006-05-10.23
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+#   Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program 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 2, or (at your option)
+# any later version.
+
+# This program 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  autom4te     touch the output file, or create a stub one
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case $1 in
+  lex|yacc)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $1 in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case $f in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  autom4te)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo "#! /bin/sh"
+	echo "# Created by GNU Automake missing as a replacement of"
+	echo "#  $ $@"
+	echo "exit 0"
+	chmod +x $file
+	exit 1
+    fi
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f y.tab.h; then
+	echo >y.tab.h
+    fi
+    if test ! -f y.tab.c; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f lex.yy.c; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+	 you modified a dependency of a manual page.  You may need the
+	 \`Help2man' package in order for those modifications to take
+	 effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo ".ab help2man is required to generate this page"
+	exit 1
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '
+	/^@setfilename/{
+	  s/.* \([^ ]*\) *$/\1/
+	  p
+	  q
+	}' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+	case $firstarg in
+	*o*)
+	    firstarg=`echo "$firstarg" | sed s/o//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+	case $firstarg in
+	*h*)
+	    firstarg=`echo "$firstarg" | sed s/h//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/CoreFoundation/config/mkinstalldirs b/CoreFoundation/config/mkinstalldirs
new file mode 100755
index 0000000..ef7e16f
--- /dev/null
+++ b/CoreFoundation/config/mkinstalldirs
@@ -0,0 +1,161 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+
+scriptversion=2006-05-11.19
+
+# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+nl='
+'
+IFS=" ""	$nl"
+errstatus=0
+dirmode=
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <bug-automake@gnu.org>."
+
+# process command line arguments
+while test $# -gt 0 ; do
+  case $1 in
+    -h | --help | --h*)         # -h for help
+      echo "$usage"
+      exit $?
+      ;;
+    -m)                         # -m PERM arg
+      shift
+      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+      dirmode=$1
+      shift
+      ;;
+    --version)
+      echo "$0 $scriptversion"
+      exit $?
+      ;;
+    --)                         # stop option processing
+      shift
+      break
+      ;;
+    -*)                         # unknown option
+      echo "$usage" 1>&2
+      exit 1
+      ;;
+    *)                          # first non-opt arg
+      break
+      ;;
+  esac
+done
+
+for file
+do
+  if test -d "$file"; then
+    shift
+  else
+    break
+  fi
+done
+
+case $# in
+  0) exit 0 ;;
+esac
+
+# Solaris 8's mkdir -p isn't thread-safe.  If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error.  This is a problem when calling mkinstalldirs
+# from a parallel make.  We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
+case $dirmode in
+  '')
+    if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+      echo "mkdir -p -- $*"
+      exec mkdir -p -- "$@"
+    else
+      # On NextStep and OpenStep, the `mkdir' command does not
+      # recognize any option.  It will interpret all options as
+      # directories to create, and then abort because `.' already
+      # exists.
+      test -d ./-p && rmdir ./-p
+      test -d ./--version && rmdir ./--version
+    fi
+    ;;
+  *)
+    if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+       test ! -d ./--version; then
+      echo "mkdir -m $dirmode -p -- $*"
+      exec mkdir -m "$dirmode" -p -- "$@"
+    else
+      # Clean up after NextStep and OpenStep mkdir.
+      for d in ./-m ./-p ./--version "./$dirmode";
+      do
+        test -d $d && rmdir $d
+      done
+    fi
+    ;;
+esac
+
+for file
+do
+  case $file in
+    /*) pathcomp=/ ;;
+    *)  pathcomp= ;;
+  esac
+  oIFS=$IFS
+  IFS=/
+  set fnord $file
+  shift
+  IFS=$oIFS
+
+  for d
+  do
+    test "x$d" = x && continue
+
+    pathcomp=$pathcomp$d
+    case $pathcomp in
+      -*) pathcomp=./$pathcomp ;;
+    esac
+
+    if test ! -d "$pathcomp"; then
+      echo "mkdir $pathcomp"
+
+      mkdir "$pathcomp" || lasterr=$?
+
+      if test ! -d "$pathcomp"; then
+	errstatus=$lasterr
+      else
+	if test ! -z "$dirmode"; then
+	  echo "chmod $dirmode $pathcomp"
+	  lasterr=
+	  chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+	  if test ! -z "$lasterr"; then
+	    errstatus=$lasterr
+	  fi
+	fi
+      fi
+    fi
+
+    pathcomp=$pathcomp/
+  done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/CoreFoundation/configure b/CoreFoundation/configure
new file mode 100755
index 0000000..496ad6a
--- /dev/null
+++ b/CoreFoundation/configure
@@ -0,0 +1,34923 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.61 for CoreFoundation 476.17.2.
+#
+# Report bugs to <bfulgham@users.sourceforge.net>.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+  if (eval ":") 2>/dev/null; then
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+
+  if test $as_have_required = yes && 	 (eval ":
+(as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=\$LINENO
+  as_lineno_2=\$LINENO
+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+  :
+else
+  as_candidate_shells=
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  case $as_dir in
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+	   done;;
+       esac
+done
+IFS=$as_save_IFS
+
+
+      for as_shell in $as_candidate_shells $SHELL; do
+	 # Try only shells that exist, to save several forks.
+	 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		{ ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+  CONFIG_SHELL=$as_shell
+	       as_have_required=yes
+	       if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+  (exit $1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+  break
+fi
+
+fi
+
+      done
+
+      if test "x$CONFIG_SHELL" != x; then
+  for as_var in BASH_ENV ENV
+        do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+        done
+        export CONFIG_SHELL
+        exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+    if test $as_have_required = no; then
+  echo This script requires a shell more modern than all the
+      echo shells that I found on your system.  Please install a
+      echo modern shell, or manually run the script under such a
+      echo shell if you do have one.
+      { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+  echo No shell found that supports shell functions.
+  echo Please tell autoconf@gnu.org about your system,
+  echo including any error possibly output before this
+  echo message
+}
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+    as_ln_s='cp -p'
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+        test -d "$1/.";
+      else
+	case $1 in
+        -*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','`
+  ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<_LT_EOF
+$*
+_LT_EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+  if test "X${echo_test_string+set}" != Xset; then
+    # find a string as large as possible, as long as the shell can cope with it
+    for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+      # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+      if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+	 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+      then
+        break
+      fi
+    done
+  fi
+
+  if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+     echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+     test "X$echo_testing_string" = "X$echo_test_string"; then
+    :
+  else
+    # The Solaris, AIX, and Digital Unix default echo programs unquote
+    # backslashes.  This makes it impossible to quote backslashes using
+    #   echo "$something" | sed 's/\\/\\\\/g'
+    #
+    # So, first we look for a working echo in the user's PATH.
+
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for dir in $PATH /usr/ucb; do
+      IFS="$lt_save_ifs"
+      if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+         test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        ECHO="$dir/echo"
+        break
+      fi
+    done
+    IFS="$lt_save_ifs"
+
+    if test "X$ECHO" = Xecho; then
+      # We didn't find a better echo, so look for alternatives.
+      if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        # This shell has a builtin print -r that does the trick.
+        ECHO='print -r'
+      elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+	   test "X$CONFIG_SHELL" != X/bin/ksh; then
+        # If we have ksh, try running configure again with it.
+        ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+        export ORIGINAL_CONFIG_SHELL
+        CONFIG_SHELL=/bin/ksh
+        export CONFIG_SHELL
+        exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+      else
+        # Try using printf.
+        ECHO='printf %s\n'
+        if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+	   echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	  # Cool, printf works
+	  :
+        elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+	  export CONFIG_SHELL
+	  SHELL="$CONFIG_SHELL"
+	  export SHELL
+	  ECHO="$CONFIG_SHELL $0 --fallback-echo"
+        elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  ECHO="$CONFIG_SHELL $0 --fallback-echo"
+        else
+	  # maybe with a smaller string...
+	  prev=:
+
+	  for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+	    if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+	    then
+	      break
+	    fi
+	    prev="$cmd"
+	  done
+
+	  if test "$prev" != 'sed 50q "$0"'; then
+	    echo_test_string=`eval $prev`
+	    export echo_test_string
+	    exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+	  else
+	    # Oops.  We lost completely, so just stick with echo.
+	    ECHO=echo
+	  fi
+        fi
+      fi
+    fi
+  fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+   lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+
+exec 7<&0 </dev/null 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Identity of this package.
+PACKAGE_NAME='CoreFoundation'
+PACKAGE_TARNAME='opencflite'
+PACKAGE_VERSION='476.17.2'
+PACKAGE_STRING='CoreFoundation 476.17.2'
+PACKAGE_BUGREPORT='bfulgham@users.sourceforge.net'
+
+ac_unique_file="CoreFoundation.h"
+ac_config_libobj_dir=compat
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL
+PATH_SEPARATOR
+PACKAGE_NAME
+PACKAGE_TARNAME
+PACKAGE_VERSION
+PACKAGE_STRING
+PACKAGE_BUGREPORT
+exec_prefix
+prefix
+program_transform_name
+bindir
+sbindir
+libexecdir
+datarootdir
+datadir
+sysconfdir
+sharedstatedir
+localstatedir
+includedir
+oldincludedir
+docdir
+infodir
+htmldir
+dvidir
+pdfdir
+psdir
+libdir
+localedir
+mandir
+DEFS
+ECHO_C
+ECHO_N
+ECHO_T
+LIBS
+build_alias
+host_alias
+target_alias
+CF_VERSION_INFO
+INSTALL_PROGRAM
+INSTALL_SCRIPT
+INSTALL_DATA
+am__isrc
+CYGPATH_W
+PACKAGE
+VERSION
+ACLOCAL
+AUTOCONF
+AUTOMAKE
+AUTOHEADER
+MAKEINFO
+install_sh
+STRIP
+INSTALL_STRIP_PROGRAM
+mkdir_p
+AWK
+SET_MAKE
+am__leading_dot
+AMTAR
+am__tar
+am__untar
+MAINTAINER_MODE_TRUE
+MAINTAINER_MODE_FALSE
+MAINT
+build
+build_cpu
+build_vendor
+build_os
+host
+host_cpu
+host_vendor
+host_os
+CC
+CFLAGS
+LDFLAGS
+CPPFLAGS
+ac_ct_CC
+EXEEXT
+OBJEXT
+DEPDIR
+am__include
+am__quote
+AMDEP_TRUE
+AMDEP_FALSE
+AMDEPBACKSLASH
+CCDEPMODE
+am__fastdepCC_TRUE
+am__fastdepCC_FALSE
+CXX
+CXXFLAGS
+ac_ct_CXX
+CXXDEPMODE
+am__fastdepCXX_TRUE
+am__fastdepCXX_FALSE
+CPP
+LIBTOOL
+SED
+GREP
+EGREP
+FGREP
+LD
+DUMPBIN
+ac_ct_DUMPBIN
+NM
+LN_S
+AR
+RANLIB
+lt_ECHO
+DSYMUTIL
+NMEDIT
+LIPO
+OTOOL
+OTOOL64
+CXXCPP
+CMP
+AS
+DLLTOOL
+OBJDUMP
+CF_BUILD_DEBUG_TRUE
+CF_BUILD_DEBUG_FALSE
+CF_BUILD_PROFILE_TRUE
+CF_BUILD_PROFILE_FALSE
+CF_BUILD_TESTS_TRUE
+CF_BUILD_TESTS_FALSE
+PKG_CONFIG
+ICU_CONFIG
+ICU_CPPFLAGS
+ICU_LDFLAGS
+ICU_LIBS
+UUID_CONFIG
+UUID_CPPFLAGS
+UUID_LDFLAGS
+UUID_LIBS
+acx_pthread_config
+PTHREAD_CC
+PTHREAD_LIBS
+PTHREAD_CFLAGS
+ALLOCA
+LIBOBJS
+LTLIBOBJS'
+ac_subst_files=''
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CXX
+CXXFLAGS
+CCC
+CPP
+CXXCPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)	ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
+    eval enable_$ac_feature=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
+    eval enable_$ac_feature=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
+    eval with_$ac_package=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
+    eval with_$ac_package=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  { echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute directory names.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; }
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  { echo "$as_me: error: Working directory cannot be determined" >&2
+   { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  { echo "$as_me: error: pwd does not report name of working directory" >&2
+   { (exit 1); exit 1; }; }
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$0" ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$0" : 'X\(//\)[^/]' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$0" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
+   { (exit 1); exit 1; }; }
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures CoreFoundation 476.17.2 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+			  [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+			  [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR           user executables [EPREFIX/bin]
+  --sbindir=DIR          system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR       program executables [EPREFIX/libexec]
+  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
+  --libdir=DIR           object code libraries [EPREFIX/lib]
+  --includedir=DIR       C header files [PREFIX/include]
+  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
+  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR          info documentation [DATAROOTDIR/info]
+  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR           man documentation [DATAROOTDIR/man]
+  --docdir=DIR           documentation root [DATAROOTDIR/doc/opencflite]
+  --htmldir=DIR          html documentation [DOCDIR]
+  --dvidir=DIR           dvi documentation [DOCDIR]
+  --pdfdir=DIR           pdf documentation [DOCDIR]
+  --psdir=DIR            ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of CoreFoundation 476.17.2:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-maintainer-mode  enable make rules and dependencies not useful
+			  (and sometimes confusing) to the casual installer
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-shared[=PKGS]  build shared libraries [default=yes]
+  --enable-static[=PKGS]  build static libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+  --disable-debug         Disable the generation of a debug library instance
+                          [default=no].
+  --disable-profile       Disable the generation of a profile library instance
+                          [default=no].
+  --disable-tests         Disable building of tests and examples [default=no].
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-pic              try to use only PIC/non-PIC objects [default=use
+                          both]
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-icu=DIR          Specify location of the International Components for
+                          Unicode (ICU) headers and libraries.
+  --with-icu-includes=DIR Specify location of International Components for
+                          Unicode (ICU) headers.
+  --with-icu-libs=DIR     Specify location of International Components for
+                          Unicode (ICU) libraries.
+  --with-uuid=DIR         Specify location of Universally Unique Identifier
+                          (UUID) headers and libraries.
+  --with-uuid-includes=DIR
+                          Specify location of Universally Unique Identifier
+                          (UUID) headers.
+  --with-uuid-libs=DIR    Specify location of Universally Unique Identifier
+                          (UUID) libraries.
+  --with-tz-default=FILE  Specify the location of the default local time zone
+                          data file on the target system
+                          [default=/etc/localtime].
+  --with-tz-data=DIR      Specify the location of the time zone data files on
+                          the target system [default=/usr/share/zoneinfo].
+  --with-tz-includes=DIR  Specify location of Time Zone (tzcode) headers
+                          [default=/usr/include].
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  CPP         C preprocessor
+  CXXCPP      C++ preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <bfulgham@users.sourceforge.net>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" || continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+CoreFoundation configure 476.17.2
+generated by GNU Autoconf 2.61
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by CoreFoundation $as_me 476.17.2, which was
+generated by GNU Autoconf 2.61.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  echo "PATH: $as_dir"
+done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    2)
+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+	ac_must_keep_next=false # Got value, back to normal.
+      else
+	case $ac_arg in
+	  *=* | --config-cache | -C | -disable-* | --disable-* \
+	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+	  | -with-* | --with-* | -without-* | --without-* | --x)
+	    case "$ac_configure_args0 " in
+	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+	    esac
+	    ;;
+	  -* ) ac_must_keep_next=true ;;
+	esac
+      fi
+      ac_configure_args="$ac_configure_args '$ac_arg'"
+      ;;
+    esac
+  done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      echo "$as_me: caught signal $ac_signal"
+    echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -n "$CONFIG_SITE"; then
+  set x "$CONFIG_SITE"
+elif test "x$prefix" != xNONE; then
+  set x "$prefix/share/config.site" "$prefix/etc/config.site"
+else
+  set x "$ac_default_prefix/share/config.site" \
+	"$ac_default_prefix/etc/config.site"
+fi
+shift
+for ac_site_file
+do
+  if test -r "$ac_site_file"; then
+    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+	{ echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	{ echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
+echo "$as_me:   former value:  $ac_old_val" >&2;}
+	{ echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
+echo "$as_me:   current value: $ac_new_val" >&2;}
+	ac_cache_corrupted=:
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+#
+# Interface number, revision and age of the library interface passed to
+# libtool when the library is linked.
+#
+CF_VERSION_INFO=476:17:2
+
+
+#
+# Check the sanity of thes source directory by checking for the
+# presence of a key watch file
+#
+
+
+#
+# Tell autoconf where to find auxilliary build tools (e.g. config.guess,
+# install-sh, missing, etc.)
+#
+ac_aux_dir=
+for ac_dir in config "$srcdir"/config; do
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in config \"$srcdir\"/config" >&5
+echo "$as_me: error: cannot find install-sh or install.sh in config \"$srcdir\"/config" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+
+#
+# Tell autoconf where to find auxilliary M4 macros
+#
+
+
+#
+# Tell autoconf what file the package is using to aggregate C preprocessor
+# defines.
+#
+ac_config_headers="$ac_config_headers include/config.h"
+
+
+#
+# Tell autoconf where to find source files for interfaces that are missing
+# in the target environment (see AC_REPLACE_FUNCS below).
+#
+
+
+#
+# Initialize automake for the package, specifying the minimum automake
+# version allowed and that we are not an official GNU package, but
+# rather a non-GNU package leveraging automake.
+#
+am__api_version='1.10'
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	  if test $ac_prog = install &&
+	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # AIX install.  It has an incompatible calling convention.
+	    :
+	  elif test $ac_prog = install &&
+	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # program-specific install script used by HP pwplus--don't use.
+	    :
+	  else
+	    ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	    break 3
+	  fi
+	fi
+      done
+    done
+    ;;
+esac
+done
+IFS=$as_save_IFS
+
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5
+echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      { { echo "$as_me:$LINENO: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&5
+echo "$as_me: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&2;}
+   { (exit 1); exit 1; }; }
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
+Check your system clock" >&5
+echo "$as_me: error: newly created file is older than distributed files!
+Check your system clock" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.  echo might interpret backslashes.
+# By default was `s,x,x', remove it if useless.
+cat <<\_ACEOF >conftest.sed
+s/[\\$]/&&/g;s/;s,x,x,$//
+_ACEOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm -f conftest.sed
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
+echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
+echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in mkdir gmkdir; do
+	 for ac_exec_ext in '' $ac_executable_extensions; do
+	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+	     'mkdir (GNU coreutils) '* | \
+	     'mkdir (coreutils) '* | \
+	     'mkdir (fileutils) '4.1*)
+	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+	       break 3;;
+	   esac
+	 done
+       done
+done
+IFS=$as_save_IFS
+
+fi
+
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    test -d ./--version && rmdir ./--version
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5
+echo "${ECHO_T}$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { echo "$as_me:$LINENO: result: $AWK" >&5
+echo "${ECHO_T}$AWK" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; }
+set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+  SET_MAKE=
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='opencflite'
+ VERSION='476.17.2'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+
+#
+# Enable maintainer mode to prevent the package from constantly trying
+# to rebuild configure, Makefile.in, etc. Rebuilding such files rarely,
+# if ever, needs to be done "in the field".
+#
+{ echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6; }
+    # Check whether --enable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+  enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
+else
+  USE_MAINTAINER_MODE=no
+fi
+
+  { echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
+echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6; }
+   if test $USE_MAINTAINER_MODE = yes; then
+  MAINTAINER_MODE_TRUE=
+  MAINTAINER_MODE_FALSE='#'
+else
+  MAINTAINER_MODE_TRUE='#'
+  MAINTAINER_MODE_FALSE=
+fi
+
+  MAINT=$MAINTAINER_MODE_TRUE
+
+
+
+#
+# Figure out what the canonical build, host and target tuples are.
+#
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+{ echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
+if test "${ac_cv_build+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+echo "$as_me: error: invalid value of canonical build" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
+if test "${ac_cv_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+echo "$as_me: error: invalid value of canonical host" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+
+{ echo "$as_me:$LINENO: checking for supported deployment target" >&5
+echo $ECHO_N "checking for supported deployment target... $ECHO_C" >&6; }
+
+case ${host_os} in
+	*darwin*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_MACOSX=1 ${CPPFLAGS}"
+		deployment_target="Mac OS X"
+		;;
+
+	*freebsd*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_FREEBSD=1 ${CPPFLAGS}"
+		deployment_target="FreeBSD"
+		;;
+
+	*linux*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_LINUX=1 ${CPPFLAGS}"
+		deployment_target="Linux"
+		;;
+
+	*mingw*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_WINDOWS=1 ${CPPFLAGS}"
+		deployment_target="Windows"
+		;;
+
+	*)
+		{ echo "$as_me:$LINENO: result: failed" >&5
+echo "${ECHO_T}failed" >&6; }
+		{ { echo "$as_me:$LINENO: error: Unsupported deployment target ${host_os}" >&5
+echo "$as_me: error: Unsupported deployment target ${host_os}" >&2;}
+   { (exit 1); exit 1; }; };
+		;;
+esac
+
+{ echo "$as_me:$LINENO: result: ${deployment_target}" >&5
+echo "${ECHO_T}${deployment_target}" >&6; }
+
+#
+# Checks for programs
+#
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+#
+# List of possible output files, starting from the most likely.
+# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
+# only as a last resort.  b.out is created by i960 compilers.
+ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
+#
+# The IRIX 6 linker writes into existing files which may not be
+# executable, retaining their permissions.  Remove them first so a
+# subsequent execution test works.
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+
+{ echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6; }
+if test -z "$ac_file"; then
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+  fi
+fi
+{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6; }
+
+{ echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  break;;
+    * ) break;;
+  esac
+done
+else
+  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+{ echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_c89=$ac_arg
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6; } ;;
+  xno)
+    { echo "$as_me:$LINENO: result: unsupported" >&5
+echo "${ECHO_T}unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+   am__include=include
+   am__quote=
+   _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+      am__include=.include
+      am__quote="\""
+      _am_result=BSD
+   fi
+fi
+
+
+{ echo "$as_me:$LINENO: result: $_am_result" >&5
+echo "${ECHO_T}$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC"   am_compiler_list=
+
+{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for C++ compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
+GXX=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CXXFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CXX"  am_compiler_list=
+
+{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define _BSD_SOURCE 1
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define _GNU_SOURCE 1
+_ACEOF
+
+
+if test "x$CC" != xcc; then
+  { echo "$as_me:$LINENO: checking whether $CC and cc understand -c and -o together" >&5
+echo $ECHO_N "checking whether $CC and cc understand -c and -o together... $ECHO_C" >&6; }
+else
+  { echo "$as_me:$LINENO: checking whether cc understands -c and -o together" >&5
+echo $ECHO_N "checking whether cc understands -c and -o together... $ECHO_C" >&6; }
+fi
+set dummy $CC; ac_cc=`echo $2 |
+		      sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+rm -f conftest2.*
+if { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+   test -f conftest2.$ac_objext && { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); };
+then
+  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+  if test "x$CC" != xcc; then
+    # Test first that cc exists at all.
+    if { ac_try='cc -c conftest.$ac_ext >&5'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+      ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+      rm -f conftest2.*
+      if { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 test -f conftest2.$ac_objext && { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); };
+      then
+	# cc works too.
+	:
+      else
+	# cc exists but doesn't like -o.
+	eval ac_cv_prog_cc_${ac_cc}_c_o=no
+      fi
+    fi
+  fi
+else
+  eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+
+fi
+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_MINUS_C_MINUS_O 1
+_ACEOF
+
+fi
+
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+ac_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	  if test $ac_prog = install &&
+	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # AIX install.  It has an incompatible calling convention.
+	    :
+	  elif test $ac_prog = install &&
+	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # program-specific install script used by HP pwplus--don't use.
+	    :
+	  else
+	    ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	    break 3
+	  fi
+	fi
+      done
+    done
+    ;;
+esac
+done
+IFS=$as_save_IFS
+
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+case `pwd` in
+  *\ * | *\	*)
+    { echo "$as_me:$LINENO: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.2.4'
+macro_revision='1.2976'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+{ echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
+echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6; }
+if test "${ac_cv_path_SED+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" | sed 99q >conftest.sed
+     $as_unset ac_script || ac_script=
+     # Extract the first word of "sed gsed" to use in msg output
+if test -z "$SED"; then
+set dummy sed gsed; ac_prog_name=$2
+if test "${ac_cv_path_SED+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_SED_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in sed gsed; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+    # Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_SED_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+SED="$ac_cv_path_SED"
+if test -z "$SED"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in \$PATH" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in \$PATH" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_SED" >&5
+echo "${ECHO_T}$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # Extract the first word of "grep ggrep" to use in msg output
+if test -z "$GREP"; then
+set dummy grep ggrep; ac_prog_name=$2
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_GREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in grep ggrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+    # Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_GREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+GREP="$ac_cv_path_GREP"
+if test -z "$GREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     # Extract the first word of "egrep" to use in msg output
+if test -z "$EGREP"; then
+set dummy egrep; ac_prog_name=$2
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_EGREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in egrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+    # Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_EGREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+EGREP="$ac_cv_path_EGREP"
+if test -z "$EGREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+
+   fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ echo "$as_me:$LINENO: checking for fgrep" >&5
+echo $ECHO_N "checking for fgrep... $ECHO_C" >&6; }
+if test "${ac_cv_path_FGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+   then ac_cv_path_FGREP="$GREP -F"
+   else
+     # Extract the first word of "fgrep" to use in msg output
+if test -z "$FGREP"; then
+set dummy fgrep; ac_prog_name=$2
+if test "${ac_cv_path_FGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_FGREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in fgrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+    # Check for GNU ac_path_FGREP and select it if it is found.
+  # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'FGREP' >> "conftest.nl"
+    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_FGREP="$ac_path_FGREP"
+      ac_path_FGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_FGREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+FGREP="$ac_cv_path_FGREP"
+if test -z "$FGREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_FGREP=$FGREP
+fi
+
+
+   fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_FGREP" >&5
+echo "${ECHO_T}$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { echo "$as_me:$LINENO: checking for ld used by $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; }
+else
+  { echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+   { (exit 1); exit 1; }; }
+{ echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ echo "$as_me:$LINENO: checking for BSD- or MS-compatible name lister (nm)" >&5
+echo $ECHO_N "checking for BSD- or MS-compatible name lister (nm)... $ECHO_C" >&6; }
+if test "${lt_cv_path_NM+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
+echo "${ECHO_T}$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_DUMPBIN+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$DUMPBIN"; then
+  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+  { echo "$as_me:$LINENO: result: $DUMPBIN" >&5
+echo "${ECHO_T}$DUMPBIN" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$DUMPBIN" && break
+  done
+fi
+if test -z "$DUMPBIN"; then
+  ac_ct_DUMPBIN=$DUMPBIN
+  for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DUMPBIN"; then
+  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_DUMPBIN" >&5
+echo "${ECHO_T}$ac_ct_DUMPBIN" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_DUMPBIN" && break
+done
+
+  if test "x$ac_ct_DUMPBIN" = x; then
+    DUMPBIN=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    DUMPBIN=$ac_ct_DUMPBIN
+  fi
+fi
+
+
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ echo "$as_me:$LINENO: checking the name lister ($NM) interface" >&5
+echo $ECHO_N "checking the name lister ($NM) interface... $ECHO_C" >&6; }
+if test "${lt_cv_nm_interface+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:5353: $ac_compile\"" >&5)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:5356: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:5359: output\"" >&5)
+  cat conftest.out >&5
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_nm_interface" >&5
+echo "${ECHO_T}$lt_cv_nm_interface" >&6; }
+
+{ echo "$as_me:$LINENO: checking whether ln -s works" >&5
+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no, using $LN_S" >&5
+echo "${ECHO_T}no, using $LN_S" >&6; }
+fi
+
+# find the maximum length of command line arguments
+{ echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
+echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6; }
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+	         = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
+echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { echo "$as_me:$LINENO: result: none" >&5
+echo "${ECHO_T}none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ echo "$as_me:$LINENO: checking whether the shell understands some XSI constructs" >&5
+echo $ECHO_N "checking whether the shell understands some XSI constructs... $ECHO_C" >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+{ echo "$as_me:$LINENO: result: $xsi_shell" >&5
+echo "${ECHO_T}$xsi_shell" >&6; }
+
+
+{ echo "$as_me:$LINENO: checking whether the shell understands \"+=\"" >&5
+echo $ECHO_N "checking whether the shell understands \"+=\"... $ECHO_C" >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+{ echo "$as_me:$LINENO: result: $lt_shell_append" >&5
+echo "${ECHO_T}$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+{ echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
+echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6; }
+if test "${lt_cv_ld_reload_flag+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
+echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+
+
+
+
+
+
+
+
+
+{ echo "$as_me:$LINENO: checking how to recognize dependent libraries" >&5
+echo $ECHO_N "checking how to recognize dependent libraries... $ECHO_C" >&6; }
+if test "${lt_cv_deplibs_check_method+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd* | netbsdelf*-gnu)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
+echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6; }
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_AR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { echo "$as_me:$LINENO: result: $AR" >&5
+echo "${ECHO_T}$AR" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AR="ar"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
+echo "${ECHO_T}$ac_ct_AR" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
+echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6; }
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK '"\
+"     {last_section=section; section=\$ 3};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
+  (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+	  cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+const struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_save_LIBS="$LIBS"
+	  lt_save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+	  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$lt_save_LIBS"
+	  CFLAGS="$lt_save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&5
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { echo "$as_me:$LINENO: result: failed" >&5
+echo "${ECHO_T}failed" >&6; }
+else
+  { echo "$as_me:$LINENO: result: ok" >&5
+echo "${ECHO_T}ok" >&6; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE="32"
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE="64"
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 6470 "configure"' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_i386"
+	    ;;
+	  ppc64-*linux*|powerpc64-*linux*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  ppc*-*linux*|powerpc*-*linux*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
+echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6; }
+if test "${lt_cv_cc_needs_belf+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  lt_cv_cc_needs_belf=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	lt_cv_cc_needs_belf=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
+echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_DSYMUTIL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { echo "$as_me:$LINENO: result: $DSYMUTIL" >&5
+echo "${ECHO_T}$DSYMUTIL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5
+echo "${ECHO_T}$ac_ct_DSYMUTIL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_NMEDIT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { echo "$as_me:$LINENO: result: $NMEDIT" >&5
+echo "${ECHO_T}$NMEDIT" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5
+echo "${ECHO_T}$ac_ct_NMEDIT" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_LIPO+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+  { echo "$as_me:$LINENO: result: $LIPO" >&5
+echo "${ECHO_T}$LIPO" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+  ac_ct_LIPO=$LIPO
+  # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_LIPO"; then
+  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_LIPO="lipo"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_LIPO" >&5
+echo "${ECHO_T}$ac_ct_LIPO" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_LIPO" = x; then
+    LIPO=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    LIPO=$ac_ct_LIPO
+  fi
+else
+  LIPO="$ac_cv_prog_LIPO"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_OTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$OTOOL"; then
+  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+  { echo "$as_me:$LINENO: result: $OTOOL" >&5
+echo "${ECHO_T}$OTOOL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+  ac_ct_OTOOL=$OTOOL
+  # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_OTOOL"; then
+  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL="otool"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_OTOOL" >&5
+echo "${ECHO_T}$ac_ct_OTOOL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL" = x; then
+    OTOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL=$ac_ct_OTOOL
+  fi
+else
+  OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_OTOOL64+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$OTOOL64"; then
+  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+  { echo "$as_me:$LINENO: result: $OTOOL64" >&5
+echo "${ECHO_T}$OTOOL64" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+  ac_ct_OTOOL64=$OTOOL64
+  # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_OTOOL64"; then
+  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_OTOOL64" >&5
+echo "${ECHO_T}$ac_ct_OTOOL64" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL64" = x; then
+    OTOOL64=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL64=$ac_ct_OTOOL64
+  fi
+else
+  OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { echo "$as_me:$LINENO: checking for -single_module linker flag" >&5
+echo $ECHO_N "checking for -single_module linker flag... $ECHO_C" >&6; }
+if test "${lt_cv_apple_cc_single_mod+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&5
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5
+echo "${ECHO_T}$lt_cv_apple_cc_single_mod" >&6; }
+    { echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5
+echo $ECHO_N "checking for -exported_symbols_list linker flag... $ECHO_C" >&6; }
+if test "${lt_cv_ld_exported_symbols_list+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  lt_cv_ld_exported_symbols_list=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	lt_cv_ld_exported_symbols_list=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+	LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5
+echo "${ECHO_T}$lt_cv_ld_exported_symbols_list" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[012])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	10.[012]*)
+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+
+{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in dlfcn.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for C++ compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
+GXX=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CXXFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CXX"  am_compiler_list=
+
+{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
+echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6; }
+if test -z "$CXXCPP"; then
+  if test "${ac_cv_prog_CXXCPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      # Double quotes because CXXCPP needs to be expanded
+    for CXXCPP in "$CXX -E" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ echo "$as_me:$LINENO: result: $CXXCPP" >&5
+echo "${ECHO_T}$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  _lt_caught_CXX_error=yes
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+else
+  _lt_caught_CXX_error=yes
+fi
+
+
+
+
+
+# Set options
+
+
+
+        enable_dlopen=no
+
+
+  enable_win32_dll=no
+
+
+            # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=yes
+fi
+
+
+
+
+
+
+
+
+
+  # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then
+  withval=$with_pic; pic_mode="$withval"
+else
+  pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+  # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+{ echo "$as_me:$LINENO: checking for objdir" >&5
+echo $ECHO_N "checking for objdir... $ECHO_C" >&6; }
+if test "${lt_cv_objdir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
+echo "${ECHO_T}$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
+echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { echo "$as_me:$LINENO: checking for file" >&5
+echo $ECHO_N "checking for file... $ECHO_C" >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+  { echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:8792: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:8796: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+
+
+
+
+
+  lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='-fPIC'
+	;;
+      esac
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      else
+	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc* | ifort*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-KPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fpic'
+	lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      xl*)
+	# IBM XL C 8.0/Fortran 10.1 on PPC
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-qpic'
+	lt_prog_compiler_static='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic='-Kconform_pic'
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
+{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic" >&6; }
+
+
+
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+  { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_pic_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_pic_works=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:9116: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:9120: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_static_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+  { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:9221: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:9225: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+
+
+  { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:9276: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:9280: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+
+
+
+  { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+
+  runpath_var=
+  allow_undefined_flag=
+  always_export_symbols=no
+  archive_cmds=
+  archive_expsym_cmds=
+  compiler_needs_object=no
+  enable_shared_with_static_runtimes=no
+  export_dynamic_flag_spec=
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic=no
+  hardcode_direct=no
+  hardcode_direct_absolute=no
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_flag_spec_ld=
+  hardcode_libdir_separator=
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  inherit_rpath=no
+  link_all_deplibs=unknown
+  module_cmds=
+  module_expsym_cmds=
+  old_archive_from_new_cmds=
+  old_archive_from_expsyms_cmds=
+  thread_safe_flag_spec=
+  whole_archive_flag_spec=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag=unsupported
+	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	xl[cC]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+	case $cc_basename in
+	xlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec=
+	  hardcode_libdir_flag_spec_ld='-rpath $libdir'
+	  archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        ld_shlibs=no
+      fi
+      ;;
+
+    netbsd* | netbsdelf*-gnu)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
+
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_direct_absolute=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      file_list_spec='${wl}-f,'
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L=yes
+	  hardcode_libdir_flag_spec='-L$libdir'
+	  hardcode_libdir_separator=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+	link_all_deplibs=no
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag="-z nodefs"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag=' ${wl}-bernotok'
+	  allow_undefined_flag=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec='$convenience'
+	  archive_cmds_need_lc=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec=' '
+      allow_undefined_flag=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_from_new_cmds='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
+    darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc=no
+  hardcode_direct=no
+  hardcode_automatic=yes
+  hardcode_shlibpath_var=unsupported
+  whole_archive_flag_spec=''
+  link_all_deplibs=yes
+  allow_undefined_flag="$_lt_dar_allow_undefined"
+  if test "$GCC" = "yes"; then
+    output_verbose_link_cmd=echo
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+  else
+  ld_shlibs=no
+  fi
+
+      ;;
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_flag_spec_ld='+b $libdir'
+	hardcode_libdir_separator=:
+	hardcode_direct=yes
+	hardcode_direct_absolute=yes
+	export_dynamic_flag_spec='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct=no
+	  hardcode_shlibpath_var=no
+	  ;;
+	*)
+	  hardcode_direct=yes
+	  hardcode_direct_absolute=yes
+	  export_dynamic_flag_spec='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        cat >conftest.$ac_ext <<_ACEOF
+int foo(void) {}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+      else
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      inherit_rpath=yes
+      link_all_deplibs=yes
+      ;;
+
+    netbsd* | netbsdelf*-gnu)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct=yes
+	hardcode_shlibpath_var=no
+	hardcode_direct_absolute=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_separator=:
+      ;;
+
+    solaris*)
+      no_undefined_flag=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds='$CC -r -o $output$reload_objs'
+	  hardcode_direct=no
+        ;;
+	motorola)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='${wl}-z,text'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='${wl}-z,text'
+      allow_undefined_flag='${wl}-z,nodefs'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      ld_shlibs=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	;;
+      esac
+    fi
+  fi
+
+{ echo "$as_me:$LINENO: result: $ld_shlibs" >&5
+echo "${ECHO_T}$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; }
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl
+	pic_flag=$lt_prog_compiler_pic
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag
+        allow_undefined_flag=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc=no
+        else
+	  archive_cmds_need_lc=yes
+        fi
+        allow_undefined_flag=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      { echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
+echo "${ECHO_T}$archive_cmds_need_lc" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; }
+
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
+  shlibpath_overrides_runpath=yes
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsdelf*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='NetBSD ld.elf_so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+   test -n "$runpath_var" ||
+   test "X$hardcode_automatic" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+{ echo "$as_me:$LINENO: result: $hardcode_action" >&5
+echo "${ECHO_T}$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+   test "$inherit_rpath" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+  if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_dl_dlopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; }
+if test $ac_cv_lib_dl_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+    ;;
+
+  *)
+    { echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6; }
+if test "${ac_cv_func_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define shl_load innocuous_shl_load
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shl_load (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef shl_load
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_shl_load || defined __stub___shl_load
+choke me
+#endif
+
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_func_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_func_shl_load=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6; }
+if test $ac_cv_func_shl_load = yes; then
+  lt_cv_dlopen="shl_load"
+else
+  { echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_dld_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_dld_shl_load=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6; }
+if test $ac_cv_lib_dld_shl_load = yes; then
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+  { echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; }
+if test "${ac_cv_func_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define dlopen innocuous_dlopen
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlopen (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef dlopen
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_dlopen || defined __stub___dlopen
+choke me
+#endif
+
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_func_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_func_dlopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6; }
+if test $ac_cv_func_dlopen = yes; then
+  lt_cv_dlopen="dlopen"
+else
+  { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_dl_dlopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; }
+if test $ac_cv_lib_dl_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_svld_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_svld_dlopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6; }
+if test $ac_cv_lib_svld_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_dld_dld_link=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_dld_dld_link=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6; }
+if test $ac_cv_lib_dld_dld_link = yes; then
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line 12037 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+    exit (status);
+}
+_LT_EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line 12137 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+    exit (status);
+}
+_LT_EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+{ echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+    else
+      { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+    fi
+    ;;
+  *)
+    { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+    ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+  # Report which library types will actually be built
+  { echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6; }
+  { echo "$as_me:$LINENO: result: $can_build_shared" >&5
+echo "${ECHO_T}$can_build_shared" >&6; }
+
+  { echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6; }
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[4-9]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  { echo "$as_me:$LINENO: result: $enable_shared" >&5
+echo "${ECHO_T}$enable_shared" >&6; }
+
+  { echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  { echo "$as_me:$LINENO: result: $enable_static" >&5
+echo "${ECHO_T}$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+compiler_needs_object_CXX=no
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_direct_absolute_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_flag_spec_ld_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+inherit_rpath_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  compiler=$CC
+  compiler_CXX=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+    else
+      lt_prog_compiler_no_builtin_flag_CXX=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { echo "$as_me:$LINENO: checking for ld used by $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; }
+else
+  { echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+   { (exit 1); exit 1; }; }
+{ echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
+
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+	  $GREP 'no-whole-archive' > /dev/null; then
+          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          whole_archive_flag_spec_CXX=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
+
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
+
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
+
+    # PORTME: fill in a description of your system's C++ link characteristics
+    { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+    ld_shlibs_CXX=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+      aix[4-9]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	    for ld_flag in $LDFLAGS; do
+	      case $ld_flag in
+	      *-brtl*)
+	        aix_use_runtimelinking=yes
+	        break
+	        ;;
+	      esac
+	    done
+	    ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        archive_cmds_CXX=''
+        hardcode_direct_CXX=yes
+        hardcode_direct_absolute_CXX=yes
+        hardcode_libdir_separator_CXX=':'
+        link_all_deplibs_CXX=yes
+        file_list_spec_CXX='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[012]|aix4.[012].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	    # We have reworked collect2
+	    :
+	  else
+	    # We have old collect2
+	    hardcode_direct_CXX=unsupported
+	    # It fails to find uninstalled libraries when the uninstalled
+	    # path is not listed in the libpath.  Setting hardcode_minus_L
+	    # to unsupported forces relinking
+	    hardcode_minus_L_CXX=yes
+	    hardcode_libdir_flag_spec_CXX='-L$libdir'
+	    hardcode_libdir_separator_CXX=
+	  fi
+          esac
+          shared_flag='-shared'
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag="$shared_flag "'${wl}-G'
+	  fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	  # chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+          else
+	    if test "$aix_use_runtimelinking" = yes; then
+	      shared_flag='${wl}-G'
+	    else
+	      shared_flag='${wl}-bM:SRE'
+	    fi
+          fi
+        fi
+
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+	# export.
+        always_export_symbols_CXX=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          allow_undefined_flag_CXX='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+	    allow_undefined_flag_CXX="-z nodefs"
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+	    # Determine the default libpath from the value encoded in an
+	    # empty executable.
+	    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    # Warning - without using the other run time loading flags,
+	    # -berok will link without error, but may produce a broken library.
+	    no_undefined_flag_CXX=' ${wl}-bernotok'
+	    allow_undefined_flag_CXX=' ${wl}-berok'
+	    # Exported symbols can be pulled into shared objects from archives
+	    whole_archive_flag_spec_CXX='$convenience'
+	    archive_cmds_need_lc_CXX=yes
+	    # This is similar to how AIX traditionally builds its shared
+	    # libraries.
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	  allow_undefined_flag_CXX=unsupported
+	  # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	  # support --undefined.  This deserves some investigation.  FIXME
+	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	else
+	  ld_shlibs_CXX=no
+	fi
+	;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+	  # FIXME: insert proper C++ library support
+	  ld_shlibs_CXX=no
+	  ;;
+        esac
+        ;;
+
+      cygwin* | mingw* | pw32*)
+        # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+        # as there is no search path for DLLs.
+        hardcode_libdir_flag_spec_CXX='-L$libdir'
+        allow_undefined_flag_CXX=unsupported
+        always_export_symbols_CXX=no
+        enable_shared_with_static_runtimes_CXX=yes
+
+        if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+          archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+          # If the export-symbols file already is a .def file (1st line
+          # is EXPORTS), use it as is; otherwise, prepend...
+          archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	    cp $export_symbols $output_objdir/$soname.def;
+          else
+	    echo EXPORTS > $output_objdir/$soname.def;
+	    cat $export_symbols >> $output_objdir/$soname.def;
+          fi~
+          $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        else
+          ld_shlibs_CXX=no
+        fi
+        ;;
+      darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc_CXX=no
+  hardcode_direct_CXX=no
+  hardcode_automatic_CXX=yes
+  hardcode_shlibpath_var_CXX=unsupported
+  whole_archive_flag_spec_CXX=''
+  link_all_deplibs_CXX=yes
+  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  if test "$GCC" = "yes"; then
+    output_verbose_link_cmd=echo
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+
+  else
+  ld_shlibs_CXX=no
+  fi
+
+	;;
+
+      dgux*)
+        case $cc_basename in
+          ec++*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          ghcx*)
+	    # Green Hills C++ Compiler
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
+
+      freebsd[12]*)
+        # C++ shared libraries reported to be fairly broken before
+	# switch to ELF
+        ld_shlibs_CXX=no
+        ;;
+
+      freebsd-elf*)
+        archive_cmds_need_lc_CXX=no
+        ;;
+
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        ld_shlibs_CXX=yes
+        ;;
+
+      gnu*)
+        ;;
+
+      hpux9*)
+        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        export_dynamic_flag_spec_CXX='${wl}-E'
+        hardcode_direct_CXX=yes
+        hardcode_minus_L_CXX=yes # Not in the search PATH,
+				             # but as the default
+				             # location of the library.
+
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            ld_shlibs_CXX=no
+            ;;
+          aCC*)
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              ld_shlibs_CXX=no
+            fi
+            ;;
+        esac
+        ;;
+
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_separator_CXX=:
+
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+	      export_dynamic_flag_spec_CXX='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            hardcode_direct_CXX=no
+            hardcode_shlibpath_var_CXX=no
+            ;;
+          *)
+            hardcode_direct_CXX=yes
+            hardcode_direct_absolute_CXX=yes
+            hardcode_minus_L_CXX=yes # Not in the search PATH,
+					         # but as the default
+					         # location of the library.
+            ;;
+        esac
+
+        case $cc_basename in
+          CC*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          aCC*)
+	    case $host_cpu in
+	      hppa*64*)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      ia64*)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      *)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	    esac
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test $with_gnu_ld = no; then
+	        case $host_cpu in
+	          hppa*64*)
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          ia64*)
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          *)
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	        esac
+	      fi
+	    else
+	      # FIXME: insert proper C++ library support
+	      ld_shlibs_CXX=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      interix[3-9]*)
+	hardcode_direct_CXX=no
+	hardcode_shlibpath_var_CXX=no
+	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='${wl}-E'
+	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+	# Instead, shared libraries are loaded at an image base (0x10000000 by
+	# default) and relocated if they conflict, which is a slow very memory
+	# consuming and fragmenting process.  To avoid this, we pick a random,
+	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+	    # SGI C++
+	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test "$with_gnu_ld" = no; then
+	        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	      else
+	        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+	      fi
+	    fi
+	    link_all_deplibs_CXX=yes
+	    ;;
+        esac
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        inherit_rpath_CXX=yes
+        ;;
+
+      linux* | k*bsd*-gnu)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	    old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    with_gnu_ld=yes
+	    # version 8.0 and above of icpc choke on multiply defined symbols
+	    # if we add $predep_objects and $postdep_objects, however 7.1 and
+	    # earlier do not add the objects themselves.
+	    case `$CC -V 2>&1` in
+	      *"Version 7."*)
+	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	      *)  # Version 8.0 or newer
+	        tmp_idyn=
+	        case $host_cpu in
+		  ia64*) tmp_idyn=' -i_dynamic';;
+		esac
+	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	    esac
+	    archive_cmds_need_lc_CXX=no
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+	    case `$CC -V` in
+	    *pgCC\ [1-5]* | *pgcpp\ [1-5]*)
+	      prelink_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+	      old_archive_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+		$RANLIB $oldlib'
+	      archive_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      archive_expsym_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    *) # Version 6 will use weak symbols
+	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    esac
+
+	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+	  cxx*)
+	    # Compaq C++
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+	    runpath_var=LD_RUN_PATH
+	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+	    hardcode_libdir_separator_CXX=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  xl*)
+	    # IBM XL 8.0 on PPC, with GNU ld
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    if test "x$supports_anon_versioning" = xyes; then
+	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
+		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+		echo "local: *; };" >> $output_objdir/$libname.ver~
+		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	    fi
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      no_undefined_flag_CXX=' -zdefs'
+	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      hardcode_libdir_flag_spec_CXX='-R$libdir'
+	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	      compiler_needs_object_CXX=yes
+
+	      # Not sure whether something based on
+	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	      # would be better.
+	      output_verbose_link_cmd='echo'
+
+	      # Archives containing C++ object files must be created using
+	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	      # necessary to make sure instantiated templates are included
+	      # in the archive.
+	      old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+
+      lynxos*)
+        # FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+
+      m88k*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+	;;
+
+      mvs*)
+        case $cc_basename in
+          cxx*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+	  *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+	esac
+	;;
+
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	  archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+	  wlarc=
+	  hardcode_libdir_flag_spec_CXX='-R$libdir'
+	  hardcode_direct_CXX=yes
+	  hardcode_shlibpath_var_CXX=no
+	fi
+	# Workaround some broken pre-1.5 toolchains
+	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+	;;
+
+      *nto* | *qnx*)
+        ld_shlibs_CXX=yes
+	;;
+
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+	ld_shlibs_CXX=no
+	;;
+
+      openbsd*)
+	if test -f /usr/libexec/ld.so; then
+	  hardcode_direct_CXX=yes
+	  hardcode_shlibpath_var_CXX=no
+	  hardcode_direct_absolute_CXX=yes
+	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	    export_dynamic_flag_spec_CXX='${wl}-E'
+	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  fi
+	  output_verbose_link_cmd=echo
+	else
+	  ld_shlibs_CXX=no
+	fi
+	;;
+
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    hardcode_libdir_separator_CXX=:
+
+	    # Archives containing C++ object files must be created using
+	    # the KAI C++ compiler.
+	    case $host in
+	      osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
+	      *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
+	    esac
+	    ;;
+          RCC*)
+	    # Rational C++ 2.4.1
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          cxx*)
+	    case $host in
+	      osf3*)
+	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+		;;
+	      *)
+	        allow_undefined_flag_CXX=' -expect_unresolved \*'
+	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	          echo "-hidden">> $lib.exp~
+	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+	          $RM $lib.exp'
+	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+		;;
+	    esac
+
+	    hardcode_libdir_separator_CXX=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  *)
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	      case $host in
+	        osf3*)
+	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	        *)
+	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	      esac
+
+	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	      hardcode_libdir_separator_CXX=:
+
+	      # Commands to make compiler produce verbose output that lists
+	      # what "hidden" libraries, object files and flags are used when
+	      # linking a shared library.
+	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+	    else
+	      # FIXME: insert proper C++ library support
+	      ld_shlibs_CXX=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      psos*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+
+      sunos4*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.x
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          lcc*)
+	    # Lucid
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
+
+      solaris*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+            archive_cmds_need_lc_CXX=yes
+	    no_undefined_flag_CXX=' -zdefs'
+	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	    hardcode_libdir_flag_spec_CXX='-R$libdir'
+	    hardcode_shlibpath_var_CXX=no
+	    case $host_os in
+	      solaris2.[0-5] | solaris2.[0-5].*) ;;
+	      *)
+		# The compiler driver will combine and reorder linker options,
+		# but understands `-z linker_flag'.
+	        # Supported since Solaris 2.6 (maybe 2.5.1?)
+		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+	        ;;
+	    esac
+	    link_all_deplibs_CXX=yes
+
+	    output_verbose_link_cmd='echo'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	    ;;
+          gcx*)
+	    # Green Hills C++ Compiler
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	    # The C++ compiler must be used to create the archive.
+	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    # GNU C++ compiler with Solaris linker
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+	        archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      else
+	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # platform.
+	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      fi
+
+	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	      case $host_os in
+		solaris2.[0-5] | solaris2.[0-5].*) ;;
+		*)
+		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  ;;
+	      esac
+	    fi
+	    ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_CXX='${wl}-z,text'
+      archive_cmds_need_lc_CXX=no
+      hardcode_shlibpath_var_CXX=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+      esac
+      ;;
+
+      sysv5* | sco3.2v5* | sco5v6*)
+	# Note: We can NOT use -z defs as we might desire, because we do not
+	# link with -lc, and that would cause any symbols used from libc to
+	# always be unresolved, which means just about no library would
+	# ever link correctly.  If we're not using GNU ld we use -z text
+	# though, which does catch some bad symbols but isn't as heavy-handed
+	# as -z defs.
+	no_undefined_flag_CXX='${wl}-z,text'
+	allow_undefined_flag_CXX='${wl}-z,nodefs'
+	archive_cmds_need_lc_CXX=no
+	hardcode_shlibpath_var_CXX=no
+	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+	hardcode_libdir_separator_CXX=':'
+	link_all_deplibs_CXX=yes
+	export_dynamic_flag_spec_CXX='${wl}-Bexport'
+	runpath_var='LD_RUN_PATH'
+
+	case $cc_basename in
+          CC*)
+	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	  *)
+	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+	    # NonStop-UX NCC 3.20
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
+
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+
+      *)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+    esac
+
+    { echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
+echo "${ECHO_T}$ld_shlibs_CXX" >&6; }
+    test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+    GCC_CXX="$GXX"
+    LD_CXX="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    # Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+
+cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$compiler_lib_search_path_CXX"; then
+	     compiler_lib_search_path_CXX="${prev}${p}"
+	   else
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$postdeps_CXX"; then
+	   postdeps_CXX="${prev}${p}"
+	 else
+	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	 fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$predep_objects_CXX"; then
+	   predep_objects_CXX="$p"
+	 else
+	   predep_objects_CXX="$predep_objects_CXX $p"
+	 fi
+       else
+	 if test -z "$postdep_objects_CXX"; then
+	   postdep_objects_CXX="$p"
+	 else
+	   postdep_objects_CXX="$postdep_objects_CXX $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  predep_objects_CXX=
+  postdep_objects_CXX=
+  postdeps_CXX=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+ compiler_lib_search_dirs_CXX=
+if test -n "${compiler_lib_search_path_CXX}"; then
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+{ echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
+
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    lt_prog_compiler_wl_CXX='-Wl,'
+    lt_prog_compiler_static_CXX='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_CXX='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_CXX='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_CXX='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      lt_prog_compiler_pic_CXX=
+      ;;
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_CXX=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	;;
+      *)
+	lt_prog_compiler_pic_CXX='-fPIC'
+	;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_CXX='-fPIC -shared'
+      ;;
+    *)
+      lt_prog_compiler_pic_CXX='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[4-9]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  lt_prog_compiler_static_CXX='-Bstatic'
+	else
+	  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      lt_prog_compiler_pic_CXX='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      lt_prog_compiler_pic_CXX='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    lt_prog_compiler_pic_CXX='-fPIC'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-fpic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  xlc* | xlC*)
+	    # IBM XL 8.0 on PPC
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-qpic'
+	    lt_prog_compiler_static_CXX='-qstaticlink'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      lt_prog_compiler_pic_CXX='-KPIC'
+	      lt_prog_compiler_static_CXX='-Bstatic'
+	      lt_prog_compiler_wl_CXX='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    lt_prog_compiler_pic_CXX='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd* | netbsdelf*-gnu)
+	;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        lt_prog_compiler_pic_CXX='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    lt_prog_compiler_wl_CXX='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    lt_prog_compiler_pic_CXX='-pic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	lt_prog_compiler_can_build_shared_CXX=no
+	;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_CXX=
+    ;;
+  *)
+    lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+    ;;
+esac
+{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6; }
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+  { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_pic_works_CXX=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:14140: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:14144: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_CXX=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+    case $lt_prog_compiler_pic_CXX in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+     esac
+else
+    lt_prog_compiler_pic_CXX=
+     lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_static_works_CXX=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_CXX=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_CXX=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+    :
+else
+    lt_prog_compiler_static_CXX=
+fi
+
+
+
+
+    { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:14239: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:14243: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+    { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:14291: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:14295: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+    { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+
+  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[4-9]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    export_symbols_cmds_CXX="$ltdll_cmds"
+  ;;
+  cygwin* | mingw*)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  linux* | k*bsd*-gnu)
+    link_all_deplibs_CXX=no
+  ;;
+  *)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+
+{ echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
+echo "${ECHO_T}$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+with_gnu_ld_CXX=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_CXX=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_CXX in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; }
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_CXX
+	pic_flag=$lt_prog_compiler_pic_CXX
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+        allow_undefined_flag_CXX=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_CXX=no
+        else
+	  archive_cmds_need_lc_CXX=yes
+        fi
+        allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
+       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
+  shlibpath_overrides_runpath=yes
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsdelf*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='NetBSD ld.elf_so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; }
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" ||
+   test -n "$runpath_var_CXX" ||
+   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_CXX" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+     test "$hardcode_minus_L_CXX" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_CXX=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_CXX=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_CXX=unsupported
+fi
+{ echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
+echo "${ECHO_T}$hardcode_action_CXX" >&6; }
+
+if test "$hardcode_action_CXX" = relink ||
+   test "$inherit_rpath_CXX" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+        ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+{ echo "$as_me:$LINENO: checking whether ln -s works" >&5
+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no, using $LN_S" >&5
+echo "${ECHO_T}no, using $LN_S" >&6; }
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+# Extract the first word of "cmp", so it can be a program name with args.
+set dummy cmp; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_CMP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $CMP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CMP="$CMP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_CMP="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CMP=$ac_cv_path_CMP
+if test -n "$CMP"; then
+  { echo "$as_me:$LINENO: result: $CMP" >&5
+echo "${ECHO_T}$CMP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+
+# Support building DLLs on Windows
+enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
+set dummy ${ac_tool_prefix}as; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_AS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AS"; then
+  ac_cv_prog_AS="$AS" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AS="${ac_tool_prefix}as"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+AS=$ac_cv_prog_AS
+if test -n "$AS"; then
+  { echo "$as_me:$LINENO: result: $AS" >&5
+echo "${ECHO_T}$AS" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AS"; then
+  ac_ct_AS=$AS
+  # Extract the first word of "as", so it can be a program name with args.
+set dummy as; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_AS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_AS"; then
+  ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AS="as"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AS=$ac_cv_prog_ac_ct_AS
+if test -n "$ac_ct_AS"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_AS" >&5
+echo "${ECHO_T}$ac_ct_AS" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_AS" = x; then
+    AS="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    AS=$ac_ct_AS
+  fi
+else
+  AS="$ac_cv_prog_AS"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_DLLTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { echo "$as_me:$LINENO: result: $DLLTOOL" >&5
+echo "${ECHO_T}$DLLTOOL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_DLLTOOL" >&5
+echo "${ECHO_T}$ac_ct_DLLTOOL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    DLLTOOL=$ac_ct_DLLTOOL
+  fi
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_OBJDUMP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { echo "$as_me:$LINENO: result: $OBJDUMP" >&5
+echo "${ECHO_T}$OBJDUMP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5
+echo "${ECHO_T}$ac_ct_OBJDUMP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+  ;;
+esac
+
+test -z "$AS" && AS=as
+
+
+
+
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+
+#
+# Checks for language qualifiers and semantics
+#
+
+{ echo "$as_me:$LINENO: checking whether char is unsigned" >&5
+echo $ECHO_N "checking whether char is unsigned... $ECHO_C" >&6; }
+if test "${ac_cv_c_char_unsigned+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((char) -1) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_char_unsigned=no
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_c_char_unsigned=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_char_unsigned" >&5
+echo "${ECHO_T}$ac_cv_c_char_unsigned" >&6; }
+if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define __CHAR_UNSIGNED__ 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; }
+if test "${ac_cv_c_const+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset cs;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *pcpcc;
+  char **ppc;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  pcpcc = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++pcpcc;
+  ppc = (char**) pcpcc;
+  pcpcc = (char const *const *) ppc;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+    if (s) return 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+    if (!foo) return 0;
+  }
+  return !cs[0] && !zero.x;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_const=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_c_const=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6; }
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for inline" >&5
+echo $ECHO_N "checking for inline... $ECHO_C" >&6; }
+if test "${ac_cv_c_inline+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_inline=$ac_kw
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
+echo "${ECHO_T}$ac_cv_c_inline" >&6; }
+
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+{ echo "$as_me:$LINENO: checking for C/C++ restrict keyword" >&5
+echo $ECHO_N "checking for C/C++ restrict keyword... $ECHO_C" >&6; }
+if test "${ac_cv_c_restrict+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_restrict=no
+   # Try the official restrict keyword, then gcc's __restrict, and
+   # the less common variants.
+   for ac_kw in restrict __restrict __restrict__ _Restrict; do
+     cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+typedef int * int_ptr;
+        int foo (int_ptr $ac_kw ip) {
+        return ip[0];
+       }
+int
+main ()
+{
+int s[1];
+        int * $ac_kw t = s;
+        t[0] = 0;
+        return foo(t)
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_restrict=$ac_kw
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+     test "$ac_cv_c_restrict" != no && break
+   done
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_restrict" >&5
+echo "${ECHO_T}$ac_cv_c_restrict" >&6; }
+ case $ac_cv_c_restrict in
+   restrict) ;;
+   no)
+cat >>confdefs.h <<\_ACEOF
+#define restrict
+_ACEOF
+ ;;
+   *)  cat >>confdefs.h <<_ACEOF
+#define restrict $ac_cv_c_restrict
+_ACEOF
+ ;;
+ esac
+
+{ echo "$as_me:$LINENO: checking for working volatile" >&5
+echo $ECHO_N "checking for working volatile... $ECHO_C" >&6; }
+if test "${ac_cv_c_volatile+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+volatile int x;
+int * volatile y = (int *) 0;
+return !x && !y;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_volatile=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_c_volatile=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_volatile" >&5
+echo "${ECHO_T}$ac_cv_c_volatile" >&6; }
+if test $ac_cv_c_volatile = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define volatile
+_ACEOF
+
+fi
+
+
+#
+# Checks for compiler characteristics
+#
+
+# If using GCC specify some additional parameters
+
+test_gcc_flag() {
+    cat >conftest.$ac_ext <<_ACEOF
+int main() {}
+_ACEOF
+    $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
+    ret=$?
+    rm -f conftest.o
+    return $ret
+}
+
+if test "x$GCC" = "xyes" ; then
+    DESIRED_CFLAGS="-Wall -Wmost -pipe -Wno-trigraphs -Wno-parentheses -fexceptions -std=gnu99 -mmacosx-version-min=10.5 -fconstant-cfstrings"
+
+    for flag in $DESIRED_CFLAGS ; do
+        { echo "$as_me:$LINENO: checking whether ${CC} accepts ${flag}" >&5
+echo $ECHO_N "checking whether ${CC} accepts ${flag}... $ECHO_C" >&6; }
+        if test_gcc_flag $flag ; then
+           CFLAGS="$CFLAGS $flag"
+           { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+        else
+           { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+        fi
+    done
+fi
+
+# Check whether the current compiler supports atomic built-ins
+
+{ echo "$as_me:$LINENO: checking for compiler atomic built-ins" >&5
+echo "$as_me: checking for compiler atomic built-ins" >&6;}
+
+{ echo "$as_me:$LINENO: checking whether the target supports __sync_fetch_and_add" >&5
+echo $ECHO_N "checking whether the target supports __sync_fetch_and_add... $ECHO_C" >&6; }
+if test "${cf_cv_have_sync_fetch_and_add+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+			cat >conftest.$ac_ext <<_ACEOF
+
+				/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+
+					int foo = 0;
+					return __sync_fetch_and_add(&foo, 1);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  cf_cv_have_sync_fetch_and_add=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	cf_cv_have_sync_fetch_and_add=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ echo "$as_me:$LINENO: result: $cf_cv_have_sync_fetch_and_add" >&5
+echo "${ECHO_T}$cf_cv_have_sync_fetch_and_add" >&6; }
+
+if test "x${cf_cv_have_sync_fetch_and_add}" != "xno"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE___SYNC_FETCH_AND_ADD 1
+_ACEOF
+
+else
+	{ { echo "$as_me:$LINENO: error: Support for __sync_fetch_and_add is required." >&5
+echo "$as_me: error: Support for __sync_fetch_and_add is required." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+{ echo "$as_me:$LINENO: checking whether the target supports __sync_bool_compare_and_swap" >&5
+echo $ECHO_N "checking whether the target supports __sync_bool_compare_and_swap... $ECHO_C" >&6; }
+if test "${cf_cv_have_sync_bool_compare_and_swap+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+			cat >conftest.$ac_ext <<_ACEOF
+
+				/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+
+					int foo;
+					return __sync_bool_compare_and_swap(&foo, 0, 1);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  cf_cv_have_sync_bool_compare_and_swap=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	cf_cv_have_sync_bool_compare_and_swap=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ echo "$as_me:$LINENO: result: $cf_cv_have_sync_bool_compare_and_swap" >&5
+echo "${ECHO_T}$cf_cv_have_sync_bool_compare_and_swap" >&6; }
+
+if test "x${cf_cv_have_sync_bool_compare_and_swap}" != "xno"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE___SYNC_BOOL_COMPARE_AND_SWAP 1
+_ACEOF
+
+else
+	{ { echo "$as_me:$LINENO: error: Support for __sync_bool_compare_and_swap is required." >&5
+echo "$as_me: error: Support for __sync_bool_compare_and_swap is required." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+{ echo "$as_me:$LINENO: checking whether the target supports __sync_synchronize" >&5
+echo $ECHO_N "checking whether the target supports __sync_synchronize... $ECHO_C" >&6; }
+if test "${cf_cv_have_sync_synchronize+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+			cat >conftest.$ac_ext <<_ACEOF
+
+				/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+
+					__sync_synchronize();
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  cf_cv_have_sync_synchronize=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	cf_cv_have_sync_synchronize=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ echo "$as_me:$LINENO: result: $cf_cv_have_sync_synchronize" >&5
+echo "${ECHO_T}$cf_cv_have_sync_synchronize" >&6; }
+
+if test "x${cf_cv_have_sync_synchronize}" != "xno"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE___SYNC_SYNCHRONIZE 1
+_ACEOF
+
+else
+	{ { echo "$as_me:$LINENO: error: Support for __sync_synchronize is required." >&5
+echo "$as_me: error: Support for __sync_synchronize is required." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+#
+# Check whether or not we should build the package with debug and profile
+# versions of the library
+#
+
+{ echo "$as_me:$LINENO: checking library build options" >&5
+echo "$as_me: checking library build options" >&6;}
+
+{ echo "$as_me:$LINENO: checking whether to build a debug library instance" >&5
+echo $ECHO_N "checking whether to build a debug library instance... $ECHO_C" >&6; }
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then
+  enableval=$enable_debug; build_debug=${enableval}
+else
+  build_debug=yes
+fi
+
+{ echo "$as_me:$LINENO: result: ${build_debug}" >&5
+echo "${ECHO_T}${build_debug}" >&6; }
+ if test "x${build_debug}" = "xyes"; then
+  CF_BUILD_DEBUG_TRUE=
+  CF_BUILD_DEBUG_FALSE='#'
+else
+  CF_BUILD_DEBUG_TRUE='#'
+  CF_BUILD_DEBUG_FALSE=
+fi
+
+
+{ echo "$as_me:$LINENO: checking whether to build a profile library instance" >&5
+echo $ECHO_N "checking whether to build a profile library instance... $ECHO_C" >&6; }
+# Check whether --enable-profile was given.
+if test "${enable_profile+set}" = set; then
+  enableval=$enable_profile; build_profile=${enableval}
+else
+  build_profile=yes
+fi
+
+{ echo "$as_me:$LINENO: result: ${build_profile}" >&5
+echo "${ECHO_T}${build_profile}" >&6; }
+ if test "x${build_profile}" = "xyes"; then
+  CF_BUILD_PROFILE_TRUE=
+  CF_BUILD_PROFILE_FALSE='#'
+else
+  CF_BUILD_PROFILE_TRUE='#'
+  CF_BUILD_PROFILE_FALSE=
+fi
+
+
+{ echo "$as_me:$LINENO: checking whether to build tests and examples" >&5
+echo $ECHO_N "checking whether to build tests and examples... $ECHO_C" >&6; }
+# Check whether --enable-tests was given.
+if test "${enable_tests+set}" = set; then
+  enableval=$enable_tests; build_tests=${enableval}
+else
+  build_tests=yes
+fi
+
+{ echo "$as_me:$LINENO: result: ${build_tests}" >&5
+echo "${ECHO_T}${build_tests}" >&6; }
+ if test "x${build_tests}" = "xyes"; then
+  CF_BUILD_TESTS_TRUE=
+  CF_BUILD_TESTS_FALSE='#'
+else
+  CF_BUILD_TESTS_TRUE='#'
+  CF_BUILD_TESTS_FALSE=
+fi
+
+
+#
+# Checks for libraries
+#
+# We expect that we'll need at minimum:
+#
+#   * dl
+#   * icui18n
+#   * m
+#   * pthread
+#   * uuid
+#
+# and, maybe:
+#
+#   * rt
+#
+
+{ echo "$as_me:$LINENO: checking required package dependencies" >&5
+echo "$as_me: checking required package dependencies" >&6;}
+
+# Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+
+#
+# Sort out where the ICU components are at.
+#
+
+{ echo "$as_me:$LINENO: checking the International Components for Unicode (ICU) package" >&5
+echo "$as_me: checking the International Components for Unicode (ICU) package" >&6;}
+
+# Extract the first word of "icu-config", so it can be a program name with args.
+set dummy icu-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_ICU_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $ICU_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ICU_CONFIG="$ICU_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ICU_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ICU_CONFIG=$ac_cv_path_ICU_CONFIG
+if test -n "$ICU_CONFIG"; then
+  { echo "$as_me:$LINENO: result: $ICU_CONFIG" >&5
+echo "${ECHO_T}$ICU_CONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+
+
+# Check whether --with-icu was given.
+if test "${with_icu+set}" = set; then
+  withval=$with_icu;
+		if test "x${withval}" = "xno"; then
+			{ { echo "$as_me:$LINENO: error: ${PACKAGE_NAME} requires the International Components for Unicode (ICU) package" >&5
+echo "$as_me: error: ${PACKAGE_NAME} requires the International Components for Unicode (ICU) package" >&2;}
+   { (exit 1); exit 1; }; }
+		else
+			icu_dir=${withval}
+		fi
+
+else
+  icu_dir=
+fi
+
+
+# Check whether --with-icu-includes was given.
+if test "${with_icu_includes+set}" = set; then
+  withval=$with_icu_includes; icu_header_dir=${withval}
+else
+  icu_header_dir=
+fi
+
+
+# Check whether --with-icu-libs was given.
+if test "${with_icu_libs+set}" = set; then
+  withval=$with_icu_libs; icu_library_dir=${withval}
+else
+  icu_library_dir=
+fi
+
+
+# We always prefer checking the values of the various '--with-icu-...'
+# options first to using icu-config because the former might be used
+# in a cross-compilation environment on a system that also contains
+# icu-config. In such a case, the user wants what he/she specified
+# rather than what icu-config indicates.
+
+if test "x${icu_dir}" != "x" -o "x${icu_header_dir}" != "x" -o "x${icu_library_dir}" != "x"; then
+	if test "x${icu_dir}" != "x"; then
+		if test -d "${icu_dir}"; then
+			if test -d "${icu_dir}/include"; then
+				ICU_CPPFLAGS="-I${icu_dir}/include"
+			else
+				ICU_CPPFLAGS="-I${icu_dir}"
+			fi
+
+			if test -d "${icu_dir}/lib"; then
+				ICU_LDFLAGS="-L${icu_dir}/lib"
+			else
+				ICU_LDFLAGS="-L${icu_dir}"
+			fi
+		else
+			{ { echo "$as_me:$LINENO: error: No such directory ${icu_dir}" >&5
+echo "$as_me: error: No such directory ${icu_dir}" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+
+	if test "x${icu_header_dir}" != "x"; then
+		if test -d "${icu_header_dir}"; then
+			ICU_CPPFLAGS="-I${icu_header_dir}"
+		else
+			{ { echo "$as_me:$LINENO: error: No such directory ${icu_header_dir}" >&5
+echo "$as_me: error: No such directory ${icu_header_dir}" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+
+	if test "x${icu_library_dir}" != "x"; then
+		if test -d "${icu_library_dir}"; then
+			ICU_LDFLAGS="-L${icu_library_dir}"
+		else
+			{ { echo "$as_me:$LINENO: error: No such directory ${icu_library_dir}" >&5
+echo "$as_me: error: No such directory ${icu_library_dir}" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+
+	# Most ICU libraries have versioned symbols
+	# (e.g. ucal_open_3_8), so the stock AC_CHECK_LIB will not
+	# work here given the way it checks for symbol
+	# availability. Punt and assume the library set normally
+	# reported by icu-config.
+
+	ICU_LIBS="${ICU_LDFLAGS} -licui18n -licuuc -licudata"
+
+elif test "x${ICU_CONFIG}" != "x"; then
+	ICU_CPPFLAGS="`${ICU_CONFIG} --cppflags`"
+	ICU_LDFLAGS="`${ICU_CONFIG} --ldflags`"
+	ICU_LIBS="`${ICU_CONFIG} --ldflags-libsonly`"
+
+elif test "x${PKG_CONFIG}" != "x" -a "${PKG_CONFIG} --exists icu"; then
+	ICU_CPPFLAGS="`${PKG_CONFIG} --cflags icu`"
+	ICU_LDFLAGS="`${PKG_CONFIG} --libs-only-L icu`"
+	ICU_LIBS="`${PKG_CONFIG} --libs-only-l icu`"
+
+else
+	{ { echo "$as_me:$LINENO: error: Cannot find the International Components for Unicode (ICU) package." >&5
+echo "$as_me: error: Cannot find the International Components for Unicode (ICU) package." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+CPPFLAGS="${ICU_CPPFLAGS} ${CPPFLAGS}"
+LDFLAGS="${ICU_LDFLAGS} ${LDFLAGS}"
+LIBS="${ICU_LIBS} ${LIBS}"
+
+
+for ac_header in unicode/putil.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/ucal.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/ucol.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/ucurr.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/ucurr.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/udat.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/ulocdata.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/uloc.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/uloc.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/umsg.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/unum.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unicode/uset.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+#
+# Sort out where the UUID components are at.
+#
+
+{ echo "$as_me:$LINENO: checking Universally Unique Identifier (UUID) package" >&5
+echo "$as_me: checking Universally Unique Identifier (UUID) package" >&6;}
+
+# Extract the first word of "uuid-config", so it can be a program name with args.
+set dummy uuid-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_UUID_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $UUID_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_UUID_CONFIG="$UUID_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_UUID_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+UUID_CONFIG=$ac_cv_path_UUID_CONFIG
+if test -n "$UUID_CONFIG"; then
+  { echo "$as_me:$LINENO: result: $UUID_CONFIG" >&5
+echo "${ECHO_T}$UUID_CONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+
+
+# Check whether --with-uuid was given.
+if test "${with_uuid+set}" = set; then
+  withval=$with_uuid;
+		if test "x${withval}" = "xno"; then
+			{ { echo "$as_me:$LINENO: error: ${PACKAGE_NAME} requires the Universally Unique Identifier (UUID) package" >&5
+echo "$as_me: error: ${PACKAGE_NAME} requires the Universally Unique Identifier (UUID) package" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+		uuid_dir=${withval}
+
+else
+  uuid_dir=
+fi
+
+
+# Check whether --with-uuid-includes was given.
+if test "${with_uuid_includes+set}" = set; then
+  withval=$with_uuid_includes; uuid_header_dir=${withval}
+else
+  uuid_header_dir=
+fi
+
+
+# Check whether --with-uuid-libs was given.
+if test "${with_uuid_libs+set}" = set; then
+  withval=$with_uuid_libs; uuid_library_dir=${withval}
+else
+  uuid_library_dir=
+fi
+
+
+# We always prefer checking the values of the various '--with-uuid-...'
+# options first to using uuid-config because the former might be used
+# in a cross-compilation environment on a system that also contains
+# uuid-config. In such a case, the user wants what he/she specified
+# rather than what uuid-config indicates.
+
+if test "x${uuid_dir}" != "x" -o "x${uuid_header_dir}" != "x" -o "x${uuid_library_dir}" != "x"; then
+	if test "x${uuid_dir}" != "x"; then
+		if test -d "${uuid_dir}"; then
+			if test -d "${uuid_dir}/include"; then
+				UUID_CPPFLAGS="-I${uuid_dir}/include"
+			else
+				UUID_CPPFLAGS="-I${uuid_dir}"
+			fi
+
+			if test -d "${uuid_dir}/lib"; then
+				UUID_LDFLAGS="-L${uuid_dir}/lib"
+			else
+				UUID_LDFLAGS="-L${uuid_dir}"
+			fi
+		else
+			{ { echo "$as_me:$LINENO: error: No such directory ${uuid_dir}" >&5
+echo "$as_me: error: No such directory ${uuid_dir}" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+
+	if test "x${uuid_header_dir}" != "x"; then
+		if test -d "${uuid_header_dir}"; then
+			UUID_CPPFLAGS="-I${uuid_header_dir}"
+		else
+			{ { echo "$as_me:$LINENO: error: No such directory ${uuid_header_dir}" >&5
+echo "$as_me: error: No such directory ${uuid_header_dir}" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+
+	if test "x${uuid_library_dir}" != "x"; then
+		if test -d "${uuid_library_dir}"; then
+			UUID_LDFLAGS="-L${uuid_library_dir}"
+		else
+			{ { echo "$as_me:$LINENO: error: No such directory ${uuid_library_dir}" >&5
+echo "$as_me: error: No such directory ${uuid_library_dir}" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+
+	UUID_saved_libs="${LIBS}"
+	UUID_saved_ldflags="${LDFLAGS}"
+	LDFLAGS="${UUID_LDFLAGS} ${LDFLAGS}"
+	LIBS=""
+
+
+{ echo "$as_me:$LINENO: checking for uuid_compare in -luuid" >&5
+echo $ECHO_N "checking for uuid_compare in -luuid... $ECHO_C" >&6; }
+if test "${ac_cv_lib_uuid_uuid_compare+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-luuid  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char uuid_compare ();
+int
+main ()
+{
+return uuid_compare ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_uuid_uuid_compare=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_uuid_uuid_compare=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_uuid_uuid_compare" >&5
+echo "${ECHO_T}$ac_cv_lib_uuid_uuid_compare" >&6; }
+if test $ac_cv_lib_uuid_uuid_compare = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBUUID 1
+_ACEOF
+
+  LIBS="-luuid $LIBS"
+
+fi
+
+
+	UUID_LIBS="${UUID_LDFLAGS} ${LIBS}"
+	LDFLAGS="${UUID_saved_ldflags}"
+	LIBS="${UUID_saved_libs}"
+	unset UUID_saved_libs
+	unset UUID_saved_ldflags
+
+elif test "x${UUID_CONFIG}" != "x"; then
+	UUID_CPPFLAGS="`${UUID_CONFIG} --cflags`"
+	UUID_LDFLAGS="`${UUID_CONFIG} --ldflags`"
+	UUID_LIBS="`${UUID_CONFIG} --libs`"
+
+elif test "x${PKG_CONFIG}" != "x" -a "${PKG_CONFIG} --exists uuid"; then
+	UUID_CPPFLAGS="`${PKG_CONFIG} --cflags uuid`"
+	UUID_LDFLAGS="`${PKG_CONFIG} --libs-only-L uuid`"
+	UUID_LIBS="`${PKG_CONFIG} --libs-only-l uuid`"
+
+else
+	{ { echo "$as_me:$LINENO: error: Cannot find the Universally Unique Identifier (UUID) package." >&5
+echo "$as_me: error: Cannot find the Universally Unique Identifier (UUID) package." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+CPPFLAGS="${UUID_CPPFLAGS} ${CPPFLAGS}"
+LDFLAGS="${UUID_LDFLAGS} ${LDFLAGS}"
+LIBS="${UUID_LIBS} ${LIBS}"
+
+
+for ac_header in uuid/uuid.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+#
+# Check for POSIX thread support.
+#
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        { echo "$as_me:$LINENO: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
+echo $ECHO_N "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... $ECHO_C" >&6; }
+        cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_join ();
+int
+main ()
+{
+return pthread_join ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  acx_pthread_ok=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+        { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
+echo "${ECHO_T}$acx_pthread_ok" >&6; }
+        if test x"$acx_pthread_ok" = xno; then
+                PTHREAD_LIBS=""
+                PTHREAD_CFLAGS=""
+        fi
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try.  Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important.  Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+#       other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+#      doesn't hurt to check since this sometimes defines pthreads too;
+#      also defines -D_REENTRANT)
+#      ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+        *solaris*)
+
+        # On Solaris (at least, for some versions), libc contains stubbed
+        # (non-functional) versions of the pthreads routines, so link-based
+        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
+        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
+        # a function called by this macro, so we could check for that, but
+        # who knows whether they'll stub that too in a future libc.)  So,
+        # we'll just look for -pthreads and -lpthread first:
+
+        acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+        ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+        case $flag in
+                none)
+                { echo "$as_me:$LINENO: checking whether pthreads work without any flags" >&5
+echo $ECHO_N "checking whether pthreads work without any flags... $ECHO_C" >&6; }
+                ;;
+
+                -*)
+                { echo "$as_me:$LINENO: checking whether pthreads work with $flag" >&5
+echo $ECHO_N "checking whether pthreads work with $flag... $ECHO_C" >&6; }
+                PTHREAD_CFLAGS="$flag"
+                ;;
+
+		pthread-config)
+		# Extract the first word of "pthread-config", so it can be a program name with args.
+set dummy pthread-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_acx_pthread_config+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$acx_pthread_config"; then
+  ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_acx_pthread_config="yes"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
+fi
+fi
+acx_pthread_config=$ac_cv_prog_acx_pthread_config
+if test -n "$acx_pthread_config"; then
+  { echo "$as_me:$LINENO: result: $acx_pthread_config" >&5
+echo "${ECHO_T}$acx_pthread_config" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+		if test x"$acx_pthread_config" = xno; then continue; fi
+		PTHREAD_CFLAGS="`pthread-config --cflags`"
+		PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+		;;
+
+                *)
+                { echo "$as_me:$LINENO: checking for the pthreads library -l$flag" >&5
+echo $ECHO_N "checking for the pthreads library -l$flag... $ECHO_C" >&6; }
+                PTHREAD_LIBS="-l$flag"
+                ;;
+        esac
+
+        save_LIBS="$LIBS"
+        save_CFLAGS="$CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Check for various functions.  We must include pthread.h,
+        # since some functions may be macros.  (On the Sequent, we
+        # need a special flag -Kthread to make this header compile.)
+        # We check for pthread_join because it is in -lpthread on IRIX
+        # while pthread_create is in libc.  We check for pthread_attr_init
+        # due to DEC craziness with -lpthreads.  We check for
+        # pthread_cleanup_push because it is one of the few pthread
+        # functions on Solaris that doesn't have a non-functional libc stub.
+        # We try pthread_create on general principles.
+        cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
+                     pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  acx_pthread_ok=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
+echo "${ECHO_T}$acx_pthread_ok" >&6; }
+        if test "x$acx_pthread_ok" = xyes; then
+                break;
+        fi
+
+        PTHREAD_LIBS=""
+        PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+	{ echo "$as_me:$LINENO: checking for joinable pthread attribute" >&5
+echo $ECHO_N "checking for joinable pthread attribute... $ECHO_C" >&6; }
+	attr_name=unknown
+	for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+	    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <pthread.h>
+int
+main ()
+{
+int attr=$attr; return attr;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  attr_name=$attr; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+	done
+        { echo "$as_me:$LINENO: result: $attr_name" >&5
+echo "${ECHO_T}$attr_name" >&6; }
+        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+
+cat >>confdefs.h <<_ACEOF
+#define PTHREAD_CREATE_JOINABLE $attr_name
+_ACEOF
+
+        fi
+
+        { echo "$as_me:$LINENO: checking if more special flags are required for pthreads" >&5
+echo $ECHO_N "checking if more special flags are required for pthreads... $ECHO_C" >&6; }
+        flag=no
+        case "${host_cpu}-${host_os}" in
+            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+        esac
+        { echo "$as_me:$LINENO: result: ${flag}" >&5
+echo "${ECHO_T}${flag}" >&6; }
+        if test "x$flag" != xno; then
+            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+        fi
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        # More AIX lossage: must compile with xlc_r or cc_r
+	if test x"$GCC" != xyes; then
+          for ac_prog in xlc_r cc_r
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$PTHREAD_CC"; then
+  ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_PTHREAD_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
+if test -n "$PTHREAD_CC"; then
+  { echo "$as_me:$LINENO: result: $PTHREAD_CC" >&5
+echo "${ECHO_T}$PTHREAD_CC" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$PTHREAD_CC" && break
+done
+test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
+
+        else
+          PTHREAD_CC=$CC
+	fi
+else
+        PTHREAD_CC="$CC"
+fi
+
+
+
+
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PTHREAD 1
+_ACEOF
+
+        :
+else
+        acx_pthread_ok=no
+        { { echo "$as_me:$LINENO: error: ${PACKAGE_NAME} requires POSIX threads." >&5
+echo "$as_me: error: ${PACKAGE_NAME} requires POSIX threads." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+CFLAGS="${PTHREAD_CFLAGS} ${CFLAGS}"
+CPPFLAGS="${PTHREAD_CPPFLAGS} ${CPPFLAGS}"
+LDFLAGS="${PTHREAD_LDFLAGS} ${LDFLAGS}"
+LIBS="${PTHREAD_LIBS} ${LIBS}"
+
+#
+# Check for where clock_gettime and friends are located.
+#
+
+
+{ echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6; }
+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lrt  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_rt_clock_gettime=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_rt_clock_gettime=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6; }
+if test $ac_cv_lib_rt_clock_gettime = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBRT 1
+_ACEOF
+
+  LIBS="-lrt $LIBS"
+
+fi
+
+
+#
+# Check for DLFCN support.
+#
+
+{ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_dl_dlopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; }
+if test $ac_cv_lib_dl_dlopen = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
+
+
+for ac_header in dlfcn.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+#
+# Check for math support.
+#
+
+{ echo "$as_me:$LINENO: checking for floor in -lm" >&5
+echo $ECHO_N "checking for floor in -lm... $ECHO_C" >&6; }
+if test "${ac_cv_lib_m_floor+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char floor ();
+int
+main ()
+{
+return floor ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_m_floor=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_m_floor=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_floor" >&5
+echo "${ECHO_T}$ac_cv_lib_m_floor" >&6; }
+if test $ac_cv_lib_m_floor = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBM 1
+_ACEOF
+
+  LIBS="-lm $LIBS"
+
+fi
+
+
+
+for ac_header in math.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+#
+# Check for where the default local time zone data file and time zone
+# data files are/will be located on the target system (this might be
+# different from where they are on the build system).
+#
+
+{ echo "$as_me:$LINENO: checking where to find the default local time zone data file" >&5
+echo $ECHO_N "checking where to find the default local time zone data file... $ECHO_C" >&6; }
+
+# Check whether --with-tz-default was given.
+if test "${with_tz_default+set}" = set; then
+  withval=$with_tz_default; tz_default_file=${withval}
+else
+  tz_default_file="/etc/localtime"
+fi
+
+{ echo "$as_me:$LINENO: result: ${tz_default_file}" >&5
+echo "${ECHO_T}${tz_default_file}" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define TZDEFAULT "${tz_default_file}"
+_ACEOF
+
+
+{ echo "$as_me:$LINENO: checking where to find the time zone data files" >&5
+echo $ECHO_N "checking where to find the time zone data files... $ECHO_C" >&6; }
+
+# Check whether --with-tz-data was given.
+if test "${with_tz_data+set}" = set; then
+  withval=$with_tz_data; tz_data_dir=${withval}
+else
+  tz_data_dir="/usr/share/zoneinfo"
+fi
+
+{ echo "$as_me:$LINENO: result: ${tz_data_dir}" >&5
+echo "${ECHO_T}${tz_data_dir}" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define TZDIR "${tz_data_dir}"
+_ACEOF
+
+
+#
+# Check for tzcode header support.
+#
+# Most systems based on the GNU C library do not have the header from
+# tzcode (see ftp://elsie.nci.nih.gov/pub/), "tzfile.h" installed which is
+# needed. Check if it exists. If it doesn't let the user point us at it.
+#
+
+
+# Check whether --with-tz-includes was given.
+if test "${with_tz_includes+set}" = set; then
+  withval=$with_tz_includes;
+		if test "x${withval}" != "xyes"; then
+			if test -d "${withval}/include"; then
+				TZ_CPPFLAGS="-I${withval}/include"
+			else
+				TZ_CPPFLAGS="-I${withval}"
+			fi
+		fi
+
+fi
+
+
+CPPFLAGS="${TZ_CPPFLAGS} ${CPPFLAGS}"
+
+if test "${ac_cv_header_tzfile_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for tzfile.h" >&5
+echo $ECHO_N "checking for tzfile.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_tzfile_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_tzfile_h" >&5
+echo "${ECHO_T}$ac_cv_header_tzfile_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking tzfile.h usability" >&5
+echo $ECHO_N "checking tzfile.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <tzfile.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking tzfile.h presence" >&5
+echo $ECHO_N "checking tzfile.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <tzfile.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: tzfile.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: tzfile.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tzfile.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: tzfile.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: tzfile.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: tzfile.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tzfile.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: tzfile.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tzfile.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: tzfile.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tzfile.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: tzfile.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tzfile.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: tzfile.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: tzfile.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: tzfile.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for tzfile.h" >&5
+echo $ECHO_N "checking for tzfile.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_tzfile_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_tzfile_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_tzfile_h" >&5
+echo "${ECHO_T}$ac_cv_header_tzfile_h" >&6; }
+
+fi
+if test $ac_cv_header_tzfile_h = yes; then
+  true
+else
+  { { echo "$as_me:$LINENO: error: ${PACKAGE_NAME} requires 'tzfile.h'. Download the latest tzcode package from 'ftp://elsie.nci.nih.gov/pub/' and/or use the '--with-tz-includes=DIR' configuration option." >&5
+echo "$as_me: error: ${PACKAGE_NAME} requires 'tzfile.h'. Download the latest tzcode package from 'ftp://elsie.nci.nih.gov/pub/' and/or use the '--with-tz-includes=DIR' configuration option." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+
+
+#
+# Check for headers
+#
+
+
+
+
+
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5
+echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  { echo "$as_me:$LINENO: checking for library containing opendir" >&5
+echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_search_opendir=$ac_res
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then
+  :
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
+echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+  { echo "$as_me:$LINENO: checking for library containing opendir" >&5
+echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_search_opendir=$ac_res
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then
+  :
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
+echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+{ echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5
+echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdbool_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdbool.h>
+#ifndef bool
+ "error: bool is not defined"
+#endif
+#ifndef false
+ "error: false is not defined"
+#endif
+#if false
+ "error: false is not 0"
+#endif
+#ifndef true
+ "error: true is not defined"
+#endif
+#if true != 1
+ "error: true is not 1"
+#endif
+#ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+#endif
+
+	struct s { _Bool s: 1; _Bool t; } s;
+
+	char a[true == 1 ? 1 : -1];
+	char b[false == 0 ? 1 : -1];
+	char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+	char d[(bool) 0.5 == true ? 1 : -1];
+	bool e = &s;
+	char f[(_Bool) 0.0 == false ? 1 : -1];
+	char g[true];
+	char h[sizeof (_Bool)];
+	char i[sizeof s.t];
+	enum { j = false, k = true, l = false * true, m = true * 256 };
+	_Bool n[m];
+	char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+	char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+#	if defined __xlc__ || defined __GNUC__
+	 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+	    reported by James Lemley on 2005-10-05; see
+	    http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+	    This test is not quite right, since xlc is allowed to
+	    reject this program, as the initializer for xlcbug is
+	    not one of the forms that C requires support for.
+	    However, doing the test right would require a runtime
+	    test, and that would make cross-compilation harder.
+	    Let us hope that IBM fixes the xlc bug, and also adds
+	    support for this kind of constant expression.  In the
+	    meantime, this test will reject xlc, which is OK, since
+	    our stdbool.h substitute should suffice.  We also test
+	    this with GCC, where it should work, to detect more
+	    quickly whether someone messes up the test in the
+	    future.  */
+	 char digs[] = "0123456789";
+	 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+#	endif
+	/* Catch a bug in an HP-UX C compiler.  See
+	   http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+	   http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+	 */
+	_Bool q = true;
+	_Bool *pq = &q;
+
+int
+main ()
+{
+
+	*pq |= q;
+	*pq |= ! q;
+	/* Refer to every declared value, to avoid compiler optimizations.  */
+	return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+		+ !m + !n + !o + !p + !q + !pq);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_stdbool_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_header_stdbool_h=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5
+echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; }
+{ echo "$as_me:$LINENO: checking for _Bool" >&5
+echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; }
+if test "${ac_cv_type__Bool+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef _Bool ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type__Bool=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type__Bool=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
+echo "${ECHO_T}$ac_cv_type__Bool" >&6; }
+if test $ac_cv_type__Bool = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__BOOL 1
+_ACEOF
+
+
+fi
+
+if test $ac_cv_header_stdbool_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_STDBOOL_H 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; }
+if test "${ac_cv_header_time+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_time=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_header_time=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TIME_WITH_SYS_TIME 1
+_ACEOF
+
+fi
+
+
+
+for ac_header in alloca.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in arpa/nameser.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in assert.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in dns_sd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in errno.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in fcntl.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in limits.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in locale.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in malloc.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in malloc/malloc.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in netinet/in.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in objc/objc.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in objc/runtime.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in poll.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in pwd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in semaphore.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in setjmp.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in signal.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in stdarg.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in stdbool.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in stddef.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in stdint.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in stdio.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in stdlib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in string.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in syslog.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in time.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in xlocale.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/cdefs.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/errno.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/fcntl.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/ioctl.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/mman.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/param.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/socket.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/stat.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/time.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/types.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/uio.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+#
+# Checks for types and structures
+#
+
+  { echo "$as_me:$LINENO: checking for int8_t" >&5
+echo $ECHO_N "checking for int8_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_int8_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_int8_t=no
+     for ac_type in 'int8_t' 'int' 'long int' \
+	 'long long int' 'short int' 'signed char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (8 - 2)) - 1) * 2 + 1))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (8 - 2)) - 1) * 2 + 1)
+	         < ($ac_type) (((($ac_type) 1 << (8 - 2)) - 1) * 2 + 2))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	case $ac_type in
+  int8_t) ac_cv_c_int8_t=yes ;;
+  *) ac_cv_c_int8_t=$ac_type ;;
+esac
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_int8_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_int8_t" >&5
+echo "${ECHO_T}$ac_cv_c_int8_t" >&6; }
+  case $ac_cv_c_int8_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<_ACEOF
+#define int8_t $ac_cv_c_int8_t
+_ACEOF
+;;
+  esac
+
+
+  { echo "$as_me:$LINENO: checking for int16_t" >&5
+echo $ECHO_N "checking for int16_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_int16_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_int16_t=no
+     for ac_type in 'int16_t' 'int' 'long int' \
+	 'long long int' 'short int' 'signed char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (16 - 2)) - 1) * 2 + 1))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (16 - 2)) - 1) * 2 + 1)
+	         < ($ac_type) (((($ac_type) 1 << (16 - 2)) - 1) * 2 + 2))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	case $ac_type in
+  int16_t) ac_cv_c_int16_t=yes ;;
+  *) ac_cv_c_int16_t=$ac_type ;;
+esac
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_int16_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_int16_t" >&5
+echo "${ECHO_T}$ac_cv_c_int16_t" >&6; }
+  case $ac_cv_c_int16_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<_ACEOF
+#define int16_t $ac_cv_c_int16_t
+_ACEOF
+;;
+  esac
+
+
+  { echo "$as_me:$LINENO: checking for int32_t" >&5
+echo $ECHO_N "checking for int32_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_int32_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_int32_t=no
+     for ac_type in 'int32_t' 'int' 'long int' \
+	 'long long int' 'short int' 'signed char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 1))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 1)
+	         < ($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 2))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	case $ac_type in
+  int32_t) ac_cv_c_int32_t=yes ;;
+  *) ac_cv_c_int32_t=$ac_type ;;
+esac
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_int32_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_int32_t" >&5
+echo "${ECHO_T}$ac_cv_c_int32_t" >&6; }
+  case $ac_cv_c_int32_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<_ACEOF
+#define int32_t $ac_cv_c_int32_t
+_ACEOF
+;;
+  esac
+
+
+  { echo "$as_me:$LINENO: checking for int64_t" >&5
+echo $ECHO_N "checking for int64_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_int64_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_int64_t=no
+     for ac_type in 'int64_t' 'int' 'long int' \
+	 'long long int' 'short int' 'signed char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (64 - 2)) - 1) * 2 + 1))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (64 - 2)) - 1) * 2 + 1)
+	         < ($ac_type) (((($ac_type) 1 << (64 - 2)) - 1) * 2 + 2))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	case $ac_type in
+  int64_t) ac_cv_c_int64_t=yes ;;
+  *) ac_cv_c_int64_t=$ac_type ;;
+esac
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_int64_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_int64_t" >&5
+echo "${ECHO_T}$ac_cv_c_int64_t" >&6; }
+  case $ac_cv_c_int64_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<_ACEOF
+#define int64_t $ac_cv_c_int64_t
+_ACEOF
+;;
+  esac
+
+{ echo "$as_me:$LINENO: checking for mode_t" >&5
+echo $ECHO_N "checking for mode_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_mode_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef mode_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_mode_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_mode_t=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
+echo "${ECHO_T}$ac_cv_type_mode_t" >&6; }
+if test $ac_cv_type_mode_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define mode_t int
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for off_t" >&5
+echo $ECHO_N "checking for off_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_off_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef off_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_off_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_off_t=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
+echo "${ECHO_T}$ac_cv_type_off_t" >&6; }
+if test $ac_cv_type_off_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define off_t long int
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for pid_t" >&5
+echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_pid_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef pid_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_pid_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_pid_t=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
+echo "${ECHO_T}$ac_cv_type_pid_t" >&6; }
+if test $ac_cv_type_pid_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define pid_t int
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_size_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef size_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_size_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_size_t=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6; }
+if test $ac_cv_type_size_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for ssize_t" >&5
+echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_ssize_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef ssize_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_ssize_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_ssize_t=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5
+echo "${ECHO_T}$ac_cv_type_ssize_t" >&6; }
+if test $ac_cv_type_ssize_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define ssize_t int
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5
+echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6; }
+if test "${ac_cv_type_uid_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "uid_t" >/dev/null 2>&1; then
+  ac_cv_type_uid_t=yes
+else
+  ac_cv_type_uid_t=no
+fi
+rm -f conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5
+echo "${ECHO_T}$ac_cv_type_uid_t" >&6; }
+if test $ac_cv_type_uid_t = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define uid_t int
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define gid_t int
+_ACEOF
+
+fi
+
+
+  { echo "$as_me:$LINENO: checking for uint8_t" >&5
+echo $ECHO_N "checking for uint8_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_uint8_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_uint8_t=no
+     for ac_type in 'uint8_t' 'unsigned int' 'unsigned long int' \
+	 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) -1 >> (8 - 1) == 1)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  case $ac_type in
+  uint8_t) ac_cv_c_uint8_t=yes ;;
+  *) ac_cv_c_uint8_t=$ac_type ;;
+esac
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_uint8_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_uint8_t" >&5
+echo "${ECHO_T}$ac_cv_c_uint8_t" >&6; }
+  case $ac_cv_c_uint8_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<\_ACEOF
+#define _UINT8_T 1
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint8_t $ac_cv_c_uint8_t
+_ACEOF
+;;
+  esac
+
+
+  { echo "$as_me:$LINENO: checking for uint16_t" >&5
+echo $ECHO_N "checking for uint16_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_uint16_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_uint16_t=no
+     for ac_type in 'uint16_t' 'unsigned int' 'unsigned long int' \
+	 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) -1 >> (16 - 1) == 1)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  case $ac_type in
+  uint16_t) ac_cv_c_uint16_t=yes ;;
+  *) ac_cv_c_uint16_t=$ac_type ;;
+esac
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_uint16_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_uint16_t" >&5
+echo "${ECHO_T}$ac_cv_c_uint16_t" >&6; }
+  case $ac_cv_c_uint16_t in #(
+  no|yes) ;; #(
+  *)
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint16_t $ac_cv_c_uint16_t
+_ACEOF
+;;
+  esac
+
+
+  { echo "$as_me:$LINENO: checking for uint32_t" >&5
+echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_uint32_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_uint32_t=no
+     for ac_type in 'uint32_t' 'unsigned int' 'unsigned long int' \
+	 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) -1 >> (32 - 1) == 1)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  case $ac_type in
+  uint32_t) ac_cv_c_uint32_t=yes ;;
+  *) ac_cv_c_uint32_t=$ac_type ;;
+esac
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_uint32_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_uint32_t" >&5
+echo "${ECHO_T}$ac_cv_c_uint32_t" >&6; }
+  case $ac_cv_c_uint32_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<\_ACEOF
+#define _UINT32_T 1
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint32_t $ac_cv_c_uint32_t
+_ACEOF
+;;
+  esac
+
+
+  { echo "$as_me:$LINENO: checking for uint64_t" >&5
+echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6; }
+if test "${ac_cv_c_uint64_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_uint64_t=no
+     for ac_type in 'uint64_t' 'unsigned int' 'unsigned long int' \
+	 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) -1 >> (64 - 1) == 1)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  case $ac_type in
+  uint64_t) ac_cv_c_uint64_t=yes ;;
+  *) ac_cv_c_uint64_t=$ac_type ;;
+esac
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test "$ac_cv_c_uint64_t" != no && break
+     done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_uint64_t" >&5
+echo "${ECHO_T}$ac_cv_c_uint64_t" >&6; }
+  case $ac_cv_c_uint64_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<\_ACEOF
+#define _UINT64_T 1
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint64_t $ac_cv_c_uint64_t
+_ACEOF
+;;
+  esac
+
+{ echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
+echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6; }
+if test "${ac_cv_struct_tm+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <time.h>
+
+int
+main ()
+{
+struct tm tm;
+				     int *p = &tm.tm_sec;
+ 				     return !p;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_struct_tm=time.h
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_struct_tm=sys/time.h
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
+echo "${ECHO_T}$ac_cv_struct_tm" >&6; }
+if test $ac_cv_struct_tm = sys/time.h; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TM_IN_SYS_TIME 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5
+echo $ECHO_N "checking for struct tm.tm_zone... $ECHO_C" >&6; }
+if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_cv_struct_tm>
+
+
+int
+main ()
+{
+static struct tm ac_aggr;
+if (ac_aggr.tm_zone)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_member_struct_tm_tm_zone=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_cv_struct_tm>
+
+
+int
+main ()
+{
+static struct tm ac_aggr;
+if (sizeof ac_aggr.tm_zone)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_member_struct_tm_tm_zone=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_member_struct_tm_tm_zone=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_tm_tm_zone" >&5
+echo "${ECHO_T}$ac_cv_member_struct_tm_tm_zone" >&6; }
+if test $ac_cv_member_struct_tm_tm_zone = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_TM_TM_ZONE 1
+_ACEOF
+
+
+fi
+
+if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TM_ZONE 1
+_ACEOF
+
+else
+  { echo "$as_me:$LINENO: checking whether tzname is declared" >&5
+echo $ECHO_N "checking whether tzname is declared... $ECHO_C" >&6; }
+if test "${ac_cv_have_decl_tzname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <time.h>
+
+int
+main ()
+{
+#ifndef tzname
+  (void) tzname;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_have_decl_tzname=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_have_decl_tzname=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_tzname" >&5
+echo "${ECHO_T}$ac_cv_have_decl_tzname" >&6; }
+if test $ac_cv_have_decl_tzname = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_TZNAME 1
+_ACEOF
+
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_TZNAME 0
+_ACEOF
+
+
+fi
+
+
+  { echo "$as_me:$LINENO: checking for tzname" >&5
+echo $ECHO_N "checking for tzname... $ECHO_C" >&6; }
+if test "${ac_cv_var_tzname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <time.h>
+#if !HAVE_DECL_TZNAME
+extern char *tzname[];
+#endif
+
+int
+main ()
+{
+return tzname[0][0];
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_var_tzname=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_var_tzname=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5
+echo "${ECHO_T}$ac_cv_var_tzname" >&6; }
+  if test $ac_cv_var_tzname = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TZNAME 1
+_ACEOF
+
+  fi
+fi
+
+
+#
+# Checks for library functions
+#
+
+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments.  Useless!
+{ echo "$as_me:$LINENO: checking for working alloca.h" >&5
+echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6; }
+if test "${ac_cv_working_alloca_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+			  if (p) return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_working_alloca_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_working_alloca_h=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5
+echo "${ECHO_T}$ac_cv_working_alloca_h" >&6; }
+if test $ac_cv_working_alloca_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ALLOCA_H 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking for alloca" >&5
+echo $ECHO_N "checking for alloca... $ECHO_C" >&6; }
+if test "${ac_cv_func_alloca_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+#  include <malloc.h>
+#  define alloca _alloca
+# else
+#  ifdef HAVE_ALLOCA_H
+#   include <alloca.h>
+#  else
+#   ifdef _AIX
+ #pragma alloca
+#   else
+#    ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+#    endif
+#   endif
+#  endif
+# endif
+#endif
+
+int
+main ()
+{
+char *p = (char *) alloca (1);
+				    if (p) return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_func_alloca_works=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_func_alloca_works=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5
+echo "${ECHO_T}$ac_cv_func_alloca_works" >&6; }
+
+if test $ac_cv_func_alloca_works = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ALLOCA 1
+_ACEOF
+
+else
+  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+# that cause trouble.  Some versions do not even contain alloca or
+# contain a buggy version.  If you still want to use their alloca,
+# use ar to extract alloca.o from them instead of compiling alloca.c.
+
+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
+
+cat >>confdefs.h <<\_ACEOF
+#define C_ALLOCA 1
+_ACEOF
+
+
+{ echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5
+echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6; }
+if test "${ac_cv_os_cray+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#if defined CRAY && ! defined CRAY2
+webecray
+#else
+wenotbecray
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "webecray" >/dev/null 2>&1; then
+  ac_cv_os_cray=yes
+else
+  ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5
+echo "${ECHO_T}$ac_cv_os_cray" >&6; }
+if test $ac_cv_os_cray = yes; then
+  for ac_func in _getb67 GETB67 getb67; do
+    as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define CRAY_STACKSEG_END $ac_func
+_ACEOF
+
+    break
+fi
+
+  done
+fi
+
+{ echo "$as_me:$LINENO: checking stack direction for C alloca" >&5
+echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6; }
+if test "${ac_cv_c_stack_direction+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_c_stack_direction=0
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+find_stack_direction ()
+{
+  static char *addr = 0;
+  auto char dummy;
+  if (addr == 0)
+    {
+      addr = &dummy;
+      return find_stack_direction ();
+    }
+  else
+    return (&dummy > addr) ? 1 : -1;
+}
+
+int
+main ()
+{
+  return find_stack_direction () < 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_stack_direction=1
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_c_stack_direction=-1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5
+echo "${ECHO_T}$ac_cv_c_stack_direction" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+_ACEOF
+
+
+fi
+
+
+for ac_header in unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+{ echo "$as_me:$LINENO: checking for working chown" >&5
+echo $ECHO_N "checking for working chown... $ECHO_C" >&6; }
+if test "${ac_cv_func_chown_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_chown_works=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <fcntl.h>
+
+int
+main ()
+{
+  char *f = "conftest.chown";
+  struct stat before, after;
+
+  if (creat (f, 0600) < 0)
+    return 1;
+  if (stat (f, &before) < 0)
+    return 1;
+  if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
+    return 1;
+  if (stat (f, &after) < 0)
+    return 1;
+  return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_chown_works=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_chown_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+rm -f conftest.chown
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_chown_works" >&5
+echo "${ECHO_T}$ac_cv_func_chown_works" >&6; }
+if test $ac_cv_func_chown_works = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_CHOWN 1
+_ACEOF
+
+fi
+
+{ echo "$as_me:$LINENO: checking whether closedir returns void" >&5
+echo $ECHO_N "checking whether closedir returns void... $ECHO_C" >&6; }
+if test "${ac_cv_func_closedir_void+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_closedir_void=yes
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header_dirent>
+#ifndef __cplusplus
+int closedir ();
+#endif
+
+int
+main ()
+{
+return closedir (opendir (".")) != 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_closedir_void=no
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_closedir_void=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_closedir_void" >&5
+echo "${ECHO_T}$ac_cv_func_closedir_void" >&6; }
+if test $ac_cv_func_closedir_void = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define CLOSEDIR_VOID 1
+_ACEOF
+
+fi
+
+
+for ac_header in vfork.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_func in fork vfork
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+if test "x$ac_cv_func_fork" = xyes; then
+  { echo "$as_me:$LINENO: checking for working fork" >&5
+echo $ECHO_N "checking for working fork... $ECHO_C" >&6; }
+if test "${ac_cv_func_fork_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_fork_works=cross
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+
+	  /* By Ruediger Kuhlmann. */
+	  return fork () < 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_fork_works=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_fork_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5
+echo "${ECHO_T}$ac_cv_func_fork_works" >&6; }
+
+else
+  ac_cv_func_fork_works=$ac_cv_func_fork
+fi
+if test "x$ac_cv_func_fork_works" = xcross; then
+  case $host in
+    *-*-amigaos* | *-*-msdosdjgpp*)
+      # Override, as these systems have only a dummy fork() stub
+      ac_cv_func_fork_works=no
+      ;;
+    *)
+      ac_cv_func_fork_works=yes
+      ;;
+  esac
+  { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5
+echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;}
+fi
+ac_cv_func_vfork_works=$ac_cv_func_vfork
+if test "x$ac_cv_func_vfork" = xyes; then
+  { echo "$as_me:$LINENO: checking for working vfork" >&5
+echo $ECHO_N "checking for working vfork... $ECHO_C" >&6; }
+if test "${ac_cv_func_vfork_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_vfork_works=cross
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Thanks to Paul Eggert for this test.  */
+$ac_includes_default
+#include <sys/wait.h>
+#ifdef HAVE_VFORK_H
+# include <vfork.h>
+#endif
+/* On some sparc systems, changes by the child to local and incoming
+   argument registers are propagated back to the parent.  The compiler
+   is told about this with #include <vfork.h>, but some compilers
+   (e.g. gcc -O) don't grok <vfork.h>.  Test for this by using a
+   static variable whose address is put into a register that is
+   clobbered by the vfork.  */
+static void
+#ifdef __cplusplus
+sparc_address_test (int arg)
+# else
+sparc_address_test (arg) int arg;
+#endif
+{
+  static pid_t child;
+  if (!child) {
+    child = vfork ();
+    if (child < 0) {
+      perror ("vfork");
+      _exit(2);
+    }
+    if (!child) {
+      arg = getpid();
+      write(-1, "", 0);
+      _exit (arg);
+    }
+  }
+}
+
+int
+main ()
+{
+  pid_t parent = getpid ();
+  pid_t child;
+
+  sparc_address_test (0);
+
+  child = vfork ();
+
+  if (child == 0) {
+    /* Here is another test for sparc vfork register problems.  This
+       test uses lots of local variables, at least as many local
+       variables as main has allocated so far including compiler
+       temporaries.  4 locals are enough for gcc 1.40.3 on a Solaris
+       4.1.3 sparc, but we use 8 to be safe.  A buggy compiler should
+       reuse the register of parent for one of the local variables,
+       since it will think that parent can't possibly be used any more
+       in this routine.  Assigning to the local variable will thus
+       munge parent in the parent process.  */
+    pid_t
+      p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
+      p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
+    /* Convince the compiler that p..p7 are live; otherwise, it might
+       use the same hardware register for all 8 local variables.  */
+    if (p != p1 || p != p2 || p != p3 || p != p4
+	|| p != p5 || p != p6 || p != p7)
+      _exit(1);
+
+    /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
+       from child file descriptors.  If the child closes a descriptor
+       before it execs or exits, this munges the parent's descriptor
+       as well.  Test for this by closing stdout in the child.  */
+    _exit(close(fileno(stdout)) != 0);
+  } else {
+    int status;
+    struct stat st;
+
+    while (wait(&status) != child)
+      ;
+    return (
+	 /* Was there some problem with vforking?  */
+	 child < 0
+
+	 /* Did the child fail?  (This shouldn't happen.)  */
+	 || status
+
+	 /* Did the vfork/compiler bug occur?  */
+	 || parent != getpid()
+
+	 /* Did the file descriptor bug occur?  */
+	 || fstat(fileno(stdout), &st) != 0
+	 );
+  }
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_vfork_works=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_vfork_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5
+echo "${ECHO_T}$ac_cv_func_vfork_works" >&6; }
+
+fi;
+if test "x$ac_cv_func_fork_works" = xcross; then
+  ac_cv_func_vfork_works=$ac_cv_func_vfork
+  { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5
+echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;}
+fi
+
+if test "x$ac_cv_func_vfork_works" = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_WORKING_VFORK 1
+_ACEOF
+
+else
+
+cat >>confdefs.h <<\_ACEOF
+#define vfork fork
+_ACEOF
+
+fi
+if test "x$ac_cv_func_fork_works" = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_WORKING_FORK 1
+_ACEOF
+
+fi
+
+
+
+for ac_header in stdlib.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_func in getpagesize
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+{ echo "$as_me:$LINENO: checking for working mmap" >&5
+echo $ECHO_N "checking for working mmap... $ECHO_C" >&6; }
+if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_mmap_fixed_mapped=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+/* malloc might have been renamed as rpl_malloc. */
+#undef malloc
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+   Here is a matrix of mmap possibilities:
+	mmap private not fixed
+	mmap private fixed at somewhere currently unmapped
+	mmap private fixed at somewhere already mapped
+	mmap shared not fixed
+	mmap shared fixed at somewhere currently unmapped
+	mmap shared fixed at somewhere already mapped
+   For private mappings, we should verify that changes cannot be read()
+   back from the file, nor mmap's back from the file at a different
+   address.  (There have been systems where private was not correctly
+   implemented like the infamous i386 svr4.0, and systems where the
+   VM page cache was not coherent with the file system buffer cache
+   like early versions of FreeBSD and possibly contemporary NetBSD.)
+   For shared mappings, we should conversely verify that changes get
+   propagated back to all the places they're supposed to be.
+
+   Grep wants private fixed already mapped.
+   The main things grep needs to know about mmap are:
+   * does it exist and is it safe to write into the mmap'd area
+   * how to use it (BSD variants)  */
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
+char *malloc ();
+#endif
+
+/* This mess was copied from the GNU getpagesize.h.  */
+#ifndef HAVE_GETPAGESIZE
+/* Assume that all systems that can run configure have sys/param.h.  */
+# ifndef HAVE_SYS_PARAM_H
+#  define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+#  define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+#  ifdef HAVE_SYS_PARAM_H
+#   include <sys/param.h>
+#   ifdef EXEC_PAGESIZE
+#    define getpagesize() EXEC_PAGESIZE
+#   else /* no EXEC_PAGESIZE */
+#    ifdef NBPG
+#     define getpagesize() NBPG * CLSIZE
+#     ifndef CLSIZE
+#      define CLSIZE 1
+#     endif /* no CLSIZE */
+#    else /* no NBPG */
+#     ifdef NBPC
+#      define getpagesize() NBPC
+#     else /* no NBPC */
+#      ifdef PAGESIZE
+#       define getpagesize() PAGESIZE
+#      endif /* PAGESIZE */
+#     endif /* no NBPC */
+#    endif /* no NBPG */
+#   endif /* no EXEC_PAGESIZE */
+#  else /* no HAVE_SYS_PARAM_H */
+#   define getpagesize() 8192	/* punt totally */
+#  endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+int
+main ()
+{
+  char *data, *data2, *data3;
+  int i, pagesize;
+  int fd;
+
+  pagesize = getpagesize ();
+
+  /* First, make a file with some known garbage in it. */
+  data = (char *) malloc (pagesize);
+  if (!data)
+    return 1;
+  for (i = 0; i < pagesize; ++i)
+    *(data + i) = rand ();
+  umask (0);
+  fd = creat ("conftest.mmap", 0600);
+  if (fd < 0)
+    return 1;
+  if (write (fd, data, pagesize) != pagesize)
+    return 1;
+  close (fd);
+
+  /* Next, try to mmap the file at a fixed address which already has
+     something else allocated at it.  If we can, also make sure that
+     we see the same garbage.  */
+  fd = open ("conftest.mmap", O_RDWR);
+  if (fd < 0)
+    return 1;
+  data2 = (char *) malloc (2 * pagesize);
+  if (!data2)
+    return 1;
+  data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1);
+  if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
+		     MAP_PRIVATE | MAP_FIXED, fd, 0L))
+    return 1;
+  for (i = 0; i < pagesize; ++i)
+    if (*(data + i) != *(data2 + i))
+      return 1;
+
+  /* Finally, make sure that changes to the mapped area do not
+     percolate back to the file as seen by read().  (This is a bug on
+     some variants of i386 svr4.0.)  */
+  for (i = 0; i < pagesize; ++i)
+    *(data2 + i) = *(data2 + i) + 1;
+  data3 = (char *) malloc (pagesize);
+  if (!data3)
+    return 1;
+  if (read (fd, data3, pagesize) != pagesize)
+    return 1;
+  for (i = 0; i < pagesize; ++i)
+    if (*(data + i) != *(data3 + i))
+      return 1;
+  close (fd);
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_mmap_fixed_mapped=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5
+echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6; }
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MMAP 1
+_ACEOF
+
+fi
+rm -f conftest.mmap
+
+
+
+for ac_header in sys/select.h sys/socket.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## --------------------------------------------- ##
+## Report this to bfulgham@users.sourceforge.net ##
+## --------------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+{ echo "$as_me:$LINENO: checking types of arguments for select" >&5
+echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; }
+if test "${ac_cv_func_select_args+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
+ for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
+  for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
+int
+main ()
+{
+extern int select ($ac_arg1,
+					    $ac_arg234, $ac_arg234, $ac_arg234,
+					    $ac_arg5);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+ done
+done
+# Provide a safe default value.
+: ${ac_cv_func_select_args='int,int *,struct timeval *'}
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5
+echo "${ECHO_T}$ac_cv_func_select_args" >&6; }
+ac_save_IFS=$IFS; IFS=','
+set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
+IFS=$ac_save_IFS
+shift
+
+cat >>confdefs.h <<_ACEOF
+#define SELECT_TYPE_ARG1 $1
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define SELECT_TYPE_ARG234 ($2)
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define SELECT_TYPE_ARG5 ($3)
+_ACEOF
+
+rm -f conftest*
+
+
+
+for ac_func in getcwd
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in gethostname
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+for ac_func in malloc realloc
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+
+
+for ac_func in memchr memcmp memmove memset
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in mkdir
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in munmap
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in rmdir
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in select
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in setenv
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in socket
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+
+
+for ac_func in getgid getuid getegid geteuid
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in getpid
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in strerror
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+
+
+
+
+
+
+for ac_func in rint strchr strdup strrchr strstr strtod strtol strtoul
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+for ac_func in strncmp strncasecmp
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+for ac_func in ustrncmp ustrncasecmp
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in symlink
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in readlink
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+for ac_func in lstat stat
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+for ac_func in snprintf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+# Figure out how to map strlcat and strlcpy if they don't exist by
+# either simply redefining them or by using a local compatibility
+# implementation.
+#
+# Some caveats are worth mentioning with respect to defining them to
+# strn{cat,cpy}. In particular, strl{cat,cpy}:
+#
+#   1) ALWAYS NULL-terminate if the destination has length.
+#   2) Take the full size of the buffer (not the space left over).
+#   3) Don't NULL-fill the remainder of its destination.
+#   4) Return a size_t size rather than a char * pointer.
+#
+# While CoreFoundation has not been found to rely on any of these
+# differences, it may in the future.
+
+for ac_func in
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  case " $LIBOBJS " in
+  *" $ac_func.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+
+
+
+
+
+for ac_func in strlcat strncat
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+if test "x${ac_cv_func_strlcat}" = "xno"; then
+	{ echo "$as_me:$LINENO: checking how to handle missing strlcat" >&5
+echo $ECHO_N "checking how to handle missing strlcat... $ECHO_C" >&6; }
+	if test "x${ac_cv_func_strncat}" = "xyes"; then
+		{ echo "$as_me:$LINENO: result: mapped to strncat" >&5
+echo "${ECHO_T}mapped to strncat" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define strlcat strncat
+_ACEOF
+
+	else
+		{ echo "$as_me:$LINENO: result: using local implementation" >&5
+echo "${ECHO_T}using local implementation" >&6; }
+
+for ac_func in strlcat
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  case " $LIBOBJS " in
+  *" $ac_func.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+	fi
+fi
+
+
+
+
+
+
+for ac_func in strlcpy strncpy
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+if test "x${ac_cv_func_strlcpy}" = "xno"; then
+	{ echo "$as_me:$LINENO: checking how to handle missing strlcpy" >&5
+echo $ECHO_N "checking how to handle missing strlcpy... $ECHO_C" >&6; }
+	if test "x${ac_cv_func_strncpy}" = "xyes"; then
+		{ echo "$as_me:$LINENO: result: mapped to strncpy" >&5
+echo "${ECHO_T}mapped to strncpy" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define strlcpy strncpy
+_ACEOF
+
+	else
+		{ echo "$as_me:$LINENO: result: using local implementation" >&5
+echo "${ECHO_T}using local implementation" >&6; }
+
+for ac_func in strlcpy
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  case " $LIBOBJS " in
+  *" $ac_func.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+	fi
+fi
+
+
+#
+# Other ibrary functions we might need to provide local compatibility
+# implementations of.
+#
+
+
+for ac_func in flsl gettimeofday
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  case " $LIBOBJS " in
+  *" $ac_func.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
+fi
+done
+
+
+
+#
+# Identify the various makefiles and auto-generated files for the package
+#
+ac_config_files="$ac_config_files CoreFoundation.pc Makefile include/Makefile compat/Makefile tests/Makefile examples/Makefile examples/Allocator/Makefile examples/CFLocalServer/Makefile examples/CFMessagePort/Makefile examples/CFRunLoopTimerExample/Makefile examples/CFTest/Makefile examples/DisplayURL/Makefile examples/DNSServiceMetaQuery/Makefile examples/ReadPListExample/Makefile examples/SimpleWebServer/Makefile examples/StringExample/Makefile examples/WritePListExample/Makefile"
+
+
+#
+# Generate them
+#
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+	"s/'/'\\\\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { echo "$as_me:$LINENO: updating cache $cache_file" >&5
+echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${CF_BUILD_DEBUG_TRUE}" && test -z "${CF_BUILD_DEBUG_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CF_BUILD_DEBUG\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"CF_BUILD_DEBUG\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${CF_BUILD_PROFILE_TRUE}" && test -z "${CF_BUILD_PROFILE_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CF_BUILD_PROFILE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"CF_BUILD_PROFILE\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${CF_BUILD_TESTS_TRUE}" && test -z "${CF_BUILD_TESTS_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CF_BUILD_TESTS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"CF_BUILD_TESTS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+    as_ln_s='cp -p'
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+        test -d "$1/.";
+      else
+	case $1 in
+        -*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by CoreFoundation $as_me 476.17.2, which was
+generated by GNU Autoconf 2.61.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+  -q, --quiet      do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+  --file=FILE[:TEMPLATE]
+		   instantiate the configuration file FILE
+  --header=FILE[:TEMPLATE]
+		   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <bug-autoconf@gnu.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+CoreFoundation config.status 476.17.2
+configured by $0, generated by GNU Autoconf 2.61,
+  with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2006 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value.  By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    echo "$ac_cs_version"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    { echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) { echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+  echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  CONFIG_SHELL=$SHELL
+  export CONFIG_SHELL
+  exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
+enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
+host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
+host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
+host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
+build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
+build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
+build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
+SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
+Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
+GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
+EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
+FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
+LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
+NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
+LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
+exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
+AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
+GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
+SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
+ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
+need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`'
+LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`'
+libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
+version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
+striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`'
+AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`'
+DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`'
+LD_CXX='`$ECHO "X$LD_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds_CXX='`$ECHO "X$old_archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_CXX='`$ECHO "X$compiler_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+GCC_CXX='`$ECHO "X$GCC_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "X$lt_prog_compiler_no_builtin_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_CXX='`$ECHO "X$lt_prog_compiler_wl_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_CXX='`$ECHO "X$lt_prog_compiler_pic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static_CXX='`$ECHO "X$lt_prog_compiler_static_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_CXX='`$ECHO "X$lt_cv_prog_compiler_c_o_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc_CXX='`$ECHO "X$archive_cmds_need_lc_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_CXX='`$ECHO "X$enable_shared_with_static_runtimes_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_CXX='`$ECHO "X$export_dynamic_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec_CXX='`$ECHO "X$whole_archive_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object_CXX='`$ECHO "X$compiler_needs_object_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_CXX='`$ECHO "X$old_archive_from_new_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_CXX='`$ECHO "X$old_archive_from_expsyms_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_CXX='`$ECHO "X$archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds_CXX='`$ECHO "X$archive_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds_CXX='`$ECHO "X$module_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds_CXX='`$ECHO "X$module_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld_CXX='`$ECHO "X$with_gnu_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag_CXX='`$ECHO "X$allow_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag_CXX='`$ECHO "X$no_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_CXX='`$ECHO "X$hardcode_libdir_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld_CXX='`$ECHO "X$hardcode_libdir_flag_spec_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator_CXX='`$ECHO "X$hardcode_libdir_separator_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_CXX='`$ECHO "X$hardcode_direct_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute_CXX='`$ECHO "X$hardcode_direct_absolute_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L_CXX='`$ECHO "X$hardcode_minus_L_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_CXX='`$ECHO "X$hardcode_shlibpath_var_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic_CXX='`$ECHO "X$hardcode_automatic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath_CXX='`$ECHO "X$inherit_rpath_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs_CXX='`$ECHO "X$link_all_deplibs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path_CXX='`$ECHO "X$fix_srcfile_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols_CXX='`$ECHO "X$always_export_symbols_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds_CXX='`$ECHO "X$export_symbols_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms_CXX='`$ECHO "X$exclude_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms_CXX='`$ECHO "X$include_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds_CXX='`$ECHO "X$prelink_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec_CXX='`$ECHO "X$file_list_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action_CXX='`$ECHO "X$hardcode_action_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_CXX='`$ECHO "X$compiler_lib_search_dirs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects_CXX='`$ECHO "X$predep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects_CXX='`$ECHO "X$postdep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+predeps_CXX='`$ECHO "X$predeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps_CXX='`$ECHO "X$postdeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path_CXX='`$ECHO "X$compiler_lib_search_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+deplibs_check_method \
+file_magic_cmd \
+AR \
+AR_FLAGS \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+SHELL \
+ECHO \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_wl \
+lt_prog_compiler_pic \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_flag_spec_ld \
+hardcode_libdir_separator \
+fix_srcfile_path \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_CXX \
+compiler_CXX \
+lt_prog_compiler_no_builtin_flag_CXX \
+lt_prog_compiler_wl_CXX \
+lt_prog_compiler_pic_CXX \
+lt_prog_compiler_static_CXX \
+lt_cv_prog_compiler_c_o_CXX \
+export_dynamic_flag_spec_CXX \
+whole_archive_flag_spec_CXX \
+compiler_needs_object_CXX \
+with_gnu_ld_CXX \
+allow_undefined_flag_CXX \
+no_undefined_flag_CXX \
+hardcode_libdir_flag_spec_CXX \
+hardcode_libdir_flag_spec_ld_CXX \
+hardcode_libdir_separator_CXX \
+fix_srcfile_path_CXX \
+exclude_expsyms_CXX \
+include_expsyms_CXX \
+file_list_spec_CXX \
+compiler_lib_search_dirs_CXX \
+predep_objects_CXX \
+postdep_objects_CXX \
+predeps_CXX \
+postdeps_CXX \
+compiler_lib_search_path_CXX; do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+old_archive_cmds_CXX \
+old_archive_from_new_cmds_CXX \
+old_archive_from_expsyms_cmds_CXX \
+archive_cmds_CXX \
+archive_expsym_cmds_CXX \
+module_cmds_CXX \
+module_expsym_cmds_CXX \
+export_symbols_cmds_CXX \
+prelink_cmds_CXX; do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\$0 --fallback-echo"')  lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
+  ;;
+esac
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'
+
+
+
+
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+    "CoreFoundation.pc") CONFIG_FILES="$CONFIG_FILES CoreFoundation.pc" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
+    "compat/Makefile") CONFIG_FILES="$CONFIG_FILES compat/Makefile" ;;
+    "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
+    "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
+    "examples/Allocator/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Allocator/Makefile" ;;
+    "examples/CFLocalServer/Makefile") CONFIG_FILES="$CONFIG_FILES examples/CFLocalServer/Makefile" ;;
+    "examples/CFMessagePort/Makefile") CONFIG_FILES="$CONFIG_FILES examples/CFMessagePort/Makefile" ;;
+    "examples/CFRunLoopTimerExample/Makefile") CONFIG_FILES="$CONFIG_FILES examples/CFRunLoopTimerExample/Makefile" ;;
+    "examples/CFTest/Makefile") CONFIG_FILES="$CONFIG_FILES examples/CFTest/Makefile" ;;
+    "examples/DisplayURL/Makefile") CONFIG_FILES="$CONFIG_FILES examples/DisplayURL/Makefile" ;;
+    "examples/DNSServiceMetaQuery/Makefile") CONFIG_FILES="$CONFIG_FILES examples/DNSServiceMetaQuery/Makefile" ;;
+    "examples/ReadPListExample/Makefile") CONFIG_FILES="$CONFIG_FILES examples/ReadPListExample/Makefile" ;;
+    "examples/SimpleWebServer/Makefile") CONFIG_FILES="$CONFIG_FILES examples/SimpleWebServer/Makefile" ;;
+    "examples/StringExample/Makefile") CONFIG_FILES="$CONFIG_FILES examples/StringExample/Makefile" ;;
+    "examples/WritePListExample/Makefile") CONFIG_FILES="$CONFIG_FILES examples/WritePListExample/Makefile" ;;
+
+  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} ||
+{
+   echo "$me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
+
+#
+# Set up the sed scripts for CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "$CONFIG_FILES"; then
+
+_ACEOF
+
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+SHELL!$SHELL$ac_delim
+PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
+PACKAGE_NAME!$PACKAGE_NAME$ac_delim
+PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
+PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
+PACKAGE_STRING!$PACKAGE_STRING$ac_delim
+PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
+exec_prefix!$exec_prefix$ac_delim
+prefix!$prefix$ac_delim
+program_transform_name!$program_transform_name$ac_delim
+bindir!$bindir$ac_delim
+sbindir!$sbindir$ac_delim
+libexecdir!$libexecdir$ac_delim
+datarootdir!$datarootdir$ac_delim
+datadir!$datadir$ac_delim
+sysconfdir!$sysconfdir$ac_delim
+sharedstatedir!$sharedstatedir$ac_delim
+localstatedir!$localstatedir$ac_delim
+includedir!$includedir$ac_delim
+oldincludedir!$oldincludedir$ac_delim
+docdir!$docdir$ac_delim
+infodir!$infodir$ac_delim
+htmldir!$htmldir$ac_delim
+dvidir!$dvidir$ac_delim
+pdfdir!$pdfdir$ac_delim
+psdir!$psdir$ac_delim
+libdir!$libdir$ac_delim
+localedir!$localedir$ac_delim
+mandir!$mandir$ac_delim
+DEFS!$DEFS$ac_delim
+ECHO_C!$ECHO_C$ac_delim
+ECHO_N!$ECHO_N$ac_delim
+ECHO_T!$ECHO_T$ac_delim
+LIBS!$LIBS$ac_delim
+build_alias!$build_alias$ac_delim
+host_alias!$host_alias$ac_delim
+target_alias!$target_alias$ac_delim
+CF_VERSION_INFO!$CF_VERSION_INFO$ac_delim
+INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
+INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
+INSTALL_DATA!$INSTALL_DATA$ac_delim
+am__isrc!$am__isrc$ac_delim
+CYGPATH_W!$CYGPATH_W$ac_delim
+PACKAGE!$PACKAGE$ac_delim
+VERSION!$VERSION$ac_delim
+ACLOCAL!$ACLOCAL$ac_delim
+AUTOCONF!$AUTOCONF$ac_delim
+AUTOMAKE!$AUTOMAKE$ac_delim
+AUTOHEADER!$AUTOHEADER$ac_delim
+MAKEINFO!$MAKEINFO$ac_delim
+install_sh!$install_sh$ac_delim
+STRIP!$STRIP$ac_delim
+INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim
+mkdir_p!$mkdir_p$ac_delim
+AWK!$AWK$ac_delim
+SET_MAKE!$SET_MAKE$ac_delim
+am__leading_dot!$am__leading_dot$ac_delim
+AMTAR!$AMTAR$ac_delim
+am__tar!$am__tar$ac_delim
+am__untar!$am__untar$ac_delim
+MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim
+MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim
+MAINT!$MAINT$ac_delim
+build!$build$ac_delim
+build_cpu!$build_cpu$ac_delim
+build_vendor!$build_vendor$ac_delim
+build_os!$build_os$ac_delim
+host!$host$ac_delim
+host_cpu!$host_cpu$ac_delim
+host_vendor!$host_vendor$ac_delim
+host_os!$host_os$ac_delim
+CC!$CC$ac_delim
+CFLAGS!$CFLAGS$ac_delim
+LDFLAGS!$LDFLAGS$ac_delim
+CPPFLAGS!$CPPFLAGS$ac_delim
+ac_ct_CC!$ac_ct_CC$ac_delim
+EXEEXT!$EXEEXT$ac_delim
+OBJEXT!$OBJEXT$ac_delim
+DEPDIR!$DEPDIR$ac_delim
+am__include!$am__include$ac_delim
+am__quote!$am__quote$ac_delim
+AMDEP_TRUE!$AMDEP_TRUE$ac_delim
+AMDEP_FALSE!$AMDEP_FALSE$ac_delim
+AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim
+CCDEPMODE!$CCDEPMODE$ac_delim
+am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim
+am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim
+CXX!$CXX$ac_delim
+CXXFLAGS!$CXXFLAGS$ac_delim
+ac_ct_CXX!$ac_ct_CXX$ac_delim
+CXXDEPMODE!$CXXDEPMODE$ac_delim
+am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim
+am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim
+CPP!$CPP$ac_delim
+LIBTOOL!$LIBTOOL$ac_delim
+SED!$SED$ac_delim
+GREP!$GREP$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+CEOF$ac_eof
+_ACEOF
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+EGREP!$EGREP$ac_delim
+FGREP!$FGREP$ac_delim
+LD!$LD$ac_delim
+DUMPBIN!$DUMPBIN$ac_delim
+ac_ct_DUMPBIN!$ac_ct_DUMPBIN$ac_delim
+NM!$NM$ac_delim
+LN_S!$LN_S$ac_delim
+AR!$AR$ac_delim
+RANLIB!$RANLIB$ac_delim
+lt_ECHO!$lt_ECHO$ac_delim
+DSYMUTIL!$DSYMUTIL$ac_delim
+NMEDIT!$NMEDIT$ac_delim
+LIPO!$LIPO$ac_delim
+OTOOL!$OTOOL$ac_delim
+OTOOL64!$OTOOL64$ac_delim
+CXXCPP!$CXXCPP$ac_delim
+CMP!$CMP$ac_delim
+AS!$AS$ac_delim
+DLLTOOL!$DLLTOOL$ac_delim
+OBJDUMP!$OBJDUMP$ac_delim
+CF_BUILD_DEBUG_TRUE!$CF_BUILD_DEBUG_TRUE$ac_delim
+CF_BUILD_DEBUG_FALSE!$CF_BUILD_DEBUG_FALSE$ac_delim
+CF_BUILD_PROFILE_TRUE!$CF_BUILD_PROFILE_TRUE$ac_delim
+CF_BUILD_PROFILE_FALSE!$CF_BUILD_PROFILE_FALSE$ac_delim
+CF_BUILD_TESTS_TRUE!$CF_BUILD_TESTS_TRUE$ac_delim
+CF_BUILD_TESTS_FALSE!$CF_BUILD_TESTS_FALSE$ac_delim
+PKG_CONFIG!$PKG_CONFIG$ac_delim
+ICU_CONFIG!$ICU_CONFIG$ac_delim
+ICU_CPPFLAGS!$ICU_CPPFLAGS$ac_delim
+ICU_LDFLAGS!$ICU_LDFLAGS$ac_delim
+ICU_LIBS!$ICU_LIBS$ac_delim
+UUID_CONFIG!$UUID_CONFIG$ac_delim
+UUID_CPPFLAGS!$UUID_CPPFLAGS$ac_delim
+UUID_LDFLAGS!$UUID_LDFLAGS$ac_delim
+UUID_LIBS!$UUID_LIBS$ac_delim
+acx_pthread_config!$acx_pthread_config$ac_delim
+PTHREAD_CC!$PTHREAD_CC$ac_delim
+PTHREAD_LIBS!$PTHREAD_LIBS$ac_delim
+PTHREAD_CFLAGS!$PTHREAD_CFLAGS$ac_delim
+ALLOCA!$ALLOCA$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
+LTLIBOBJS!$LTLIBOBJS$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 42; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+:end
+s/|#_!!_#|//g
+CEOF$ac_eof
+_ACEOF
+
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+fi # test -n "$CONFIG_FILES"
+
+
+for ac_tag in  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
+echo "$as_me: error: Invalid tag $ac_tag." >&2;}
+   { (exit 1); exit 1; }; };;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+   { (exit 1); exit 1; }; };;
+      esac
+      ac_file_inputs="$ac_file_inputs $ac_f"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input="Generated from "`IFS=:
+	  echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    fi
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin";;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  { as_dir="$ac_dir"
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+case `sed -n '/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+' $ac_file_inputs` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+    s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF
+  sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s&@configure_input@&$configure_input&;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out"; rm -f "$tmp/out";;
+  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
+  esac
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+_ACEOF
+
+# Transform confdefs.h into a sed script `conftest.defines', that
+# substitutes the proper values into config.h.in to produce config.h.
+rm -f conftest.defines conftest.tail
+# First, append a space to every undef/define line, to ease matching.
+echo 's/$/ /' >conftest.defines
+# Then, protect against being on the right side of a sed subst, or in
+# an unquoted here document, in config.status.  If some macros were
+# called several times there might be several #defines for the same
+# symbol, which is useless.  But do not sort them, since the last
+# AC_DEFINE must be honored.
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
+# NAME is the cpp macro being defined, VALUE is the value it is being given.
+# PARAMS is the parameter list in the macro definition--in most cases, it's
+# just an empty string.
+ac_dA='s,^\\([	 #]*\\)[^	 ]*\\([	 ]*'
+ac_dB='\\)[	 (].*,\\1define\\2'
+ac_dC=' '
+ac_dD=' ,'
+
+uniq confdefs.h |
+  sed -n '
+	t rset
+	:rset
+	s/^[	 ]*#[	 ]*define[	 ][	 ]*//
+	t ok
+	d
+	:ok
+	s/[\\&,]/\\&/g
+	s/^\('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
+	s/^\('"$ac_word_re"'\)[	 ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
+  ' >>conftest.defines
+
+# Remove the space that was appended to ease matching.
+# Then replace #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+# (The regexp can be short, since the line contains either #define or #undef.)
+echo 's/ $//
+s,^[	 #]*u.*,/* & */,' >>conftest.defines
+
+# Break up conftest.defines:
+ac_max_sed_lines=50
+
+# First sed command is:	 sed -f defines.sed $ac_file_inputs >"$tmp/out1"
+# Second one is:	 sed -f defines.sed "$tmp/out1" >"$tmp/out2"
+# Third one will be:	 sed -f defines.sed "$tmp/out2" >"$tmp/out1"
+# et cetera.
+ac_in='$ac_file_inputs'
+ac_out='"$tmp/out1"'
+ac_nxt='"$tmp/out2"'
+
+while :
+do
+  # Write a here document:
+    cat >>$CONFIG_STATUS <<_ACEOF
+    # First, check the format of the line:
+    cat >"\$tmp/defines.sed" <<\\CEOF
+/^[	 ]*#[	 ]*undef[	 ][	 ]*$ac_word_re[	 ]*\$/b def
+/^[	 ]*#[	 ]*define[	 ][	 ]*$ac_word_re[(	 ]/b def
+b
+:def
+_ACEOF
+  sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+    sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
+  ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
+  sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
+  grep . conftest.tail >/dev/null || break
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines conftest.tail
+
+echo "ac_result=$ac_in" >>$CONFIG_STATUS
+cat >>$CONFIG_STATUS <<\_ACEOF
+  if test x"$ac_file" != x-; then
+    echo "/* $configure_input  */" >"$tmp/config.h"
+    cat "$ac_result" >>"$tmp/config.h"
+    if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
+      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f $ac_file
+      mv "$tmp/config.h" $ac_file
+    fi
+  else
+    echo "/* $configure_input  */"
+    cat "$ac_result"
+  fi
+  rm -f "$tmp/out12"
+# Compute $ac_file's index in $config_headers.
+_am_arg=$ac_file
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$_am_arg" : 'X\(//\)[^/]' \| \
+	 X"$_am_arg" : 'X\(//\)$' \| \
+	 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { echo "$as_me:$LINENO: executing $ac_file commands" >&5
+echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
+  # Strip MF so we end up with the name of the file.
+  mf=`echo "$mf" | sed -e 's/:.*$//'`
+  # Check whether this is an Automake generated Makefile or not.
+  # We used to match only the files named `Makefile.in', but
+  # some people rename them; so instead we look at the file content.
+  # Grep'ing the first line is not enough: some people post-process
+  # each Makefile.in and add a new line on top of each file to say so.
+  # Grep'ing the whole file is not good either: AIX grep has a line
+  # limit of 2048, but all sed's we know have understand at least 4000.
+  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+    dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$mf" : 'X\(//\)[^/]' \| \
+	 X"$mf" : 'X\(//\)$' \| \
+	 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  else
+    continue
+  fi
+  # Extract the definition of DEPDIR, am__include, and am__quote
+  # from the Makefile without running `make'.
+  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  am__include=`sed -n 's/^am__include = //p' < "$mf"`
+  test -z "am__include" && continue
+  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n 's/^U = //p' < "$mf"`
+  # Find all dependency output files, they are included files with
+  # $(DEPDIR) in their names.  We invoke sed twice because it is the
+  # simplest approach to changing $(DEPDIR) to its actual value in the
+  # expansion.
+  for file in `sed -n "
+    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+    # Make sure the directory exists.
+    test -f "$dirpart/$file" && continue
+    fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$file" : 'X\(//\)[^/]' \| \
+	 X"$file" : 'X\(//\)$' \| \
+	 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+    { as_dir=$dirpart/$fdir
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+ ;;
+    "libtool":C)
+
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool 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 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="CXX "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that does not interpret backslashes.
+ECHO=$lt_ECHO
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Assembler program.
+AS=$AS
+
+# DLL creation program.
+DLLTOOL=$DLLTOOL
+
+# Object dumper program.
+OBJDUMP=$OBJDUMP
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking.  This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  case $xsi_shell in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+  func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+  # positional parameters, so assign one to ordinary parameter first.
+  func_stripname_result=${3}
+  func_stripname_result=${func_stripname_result#"${1}"}
+  func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=${1%%=*}
+  func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  case ${1} in
+    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+    *)    func_lo2o_result=${1} ;;
+  esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=$(( $* ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=${#1}
+}
+
+_LT_EOF
+    ;;
+  *) # Bourne compatible functions.
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+  case ${2} in
+    .*) func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+    *)  func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+  esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[^=]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+  func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=`expr "$@"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$1+=\$2"
+}
+_LT_EOF
+    ;;
+  *)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$1=\$$1\$2"
+}
+
+_LT_EOF
+    ;;
+  esac
+
+
+  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+
+
+    cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_CXX
+
+# A language specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_CXX
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_CXX
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking.  This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_CXX
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path_CXX
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_CXX
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_CXX
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# ### END LIBTOOL TAG CONFIG: CXX
+_LT_EOF
+
+ ;;
+
+  esac
+done # for ac_tag
+
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || { (exit 1); exit 1; }
+fi
+
+
+{ echo "$as_me:$LINENO:
+
+  Configuration Summary
+  ---------------------
+  Package                     : ${PACKAGE_NAME}
+  Version                     : ${PACKAGE_VERSION}
+  Deployment target           : ${deployment_target}
+  Build shared library        : ${enable_shared}
+  Build static library        : ${enable_static}
+  Build debug library         : ${build_debug}
+  Build profile library       : ${build_profile}
+  Build examples and tests    : ${build_tests}
+  Prefix		      : ${prefix}
+  ICU compile options         : ${ICU_CPPFLAGS}
+  ICU link options            : ${ICU_LDFLAGS}
+  ICU link libraries          : ${ICU_LIBS}
+  POSIX thread compile options: ${PTHREAD_CFLAGS}
+  POSIX thread link options   : ${PTHREAD_LIBS}
+  UUID compile options        : ${UUID_CPPFLAGS}
+  UUID link options           : ${UUID_LDFLAGS}
+  UUID link libraries	      : ${UUID_LIBS}
+  Time Zone compile options   : ${TZ_CPPFLAGS}
+  Time Zone default file      : ${tz_default_file}
+  Time Zone data directory    : ${tz_data_dir}
+  Compiler                    : ${CC}
+  Preprocessor flags          : ${CPPFLAGS}
+  Compile flags               : ${CFLAGS}
+  Link flags                  : ${LDFLAGS}
+  Link libraries              : ${LIBS}
+
+" >&5
+echo "$as_me:
+
+  Configuration Summary
+  ---------------------
+  Package                     : ${PACKAGE_NAME}
+  Version                     : ${PACKAGE_VERSION}
+  Deployment target           : ${deployment_target}
+  Build shared library        : ${enable_shared}
+  Build static library        : ${enable_static}
+  Build debug library         : ${build_debug}
+  Build profile library       : ${build_profile}
+  Build examples and tests    : ${build_tests}
+  Prefix		      : ${prefix}
+  ICU compile options         : ${ICU_CPPFLAGS}
+  ICU link options            : ${ICU_LDFLAGS}
+  ICU link libraries          : ${ICU_LIBS}
+  POSIX thread compile options: ${PTHREAD_CFLAGS}
+  POSIX thread link options   : ${PTHREAD_LIBS}
+  UUID compile options        : ${UUID_CPPFLAGS}
+  UUID link options           : ${UUID_LDFLAGS}
+  UUID link libraries	      : ${UUID_LIBS}
+  Time Zone compile options   : ${TZ_CPPFLAGS}
+  Time Zone default file      : ${tz_default_file}
+  Time Zone data directory    : ${tz_data_dir}
+  Compiler                    : ${CC}
+  Preprocessor flags          : ${CPPFLAGS}
+  Compile flags               : ${CFLAGS}
+  Link flags                  : ${LDFLAGS}
+  Link libraries              : ${LIBS}
+
+" >&6;}
diff --git a/CoreFoundation/configure.ac b/CoreFoundation/configure.ac
new file mode 100644
index 0000000..33b7b99
--- /dev/null
+++ b/CoreFoundation/configure.ac
@@ -0,0 +1,751 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+#
+# Declare autoconf version requirements
+#
+AC_PREREQ(2.61)
+
+#
+# Initialize autoconf for the package
+#
+# Package release version conventions are x.y.z, where x and y track
+# the Apple CoreFoundation release version and z tracks the OpenCFLite
+# release thereof.
+#
+AC_INIT([CoreFoundation],[476.17.2],[bfulgham@users.sourceforge.net],[opencflite])
+
+#
+# Interface number, revision and age of the library interface passed to
+# libtool when the library is linked.
+#
+AC_SUBST(CF_VERSION_INFO, [476:17:2])
+
+#
+# Check the sanity of thes source directory by checking for the
+# presence of a key watch file
+#
+AC_CONFIG_SRCDIR([CoreFoundation.h])
+
+#
+# Tell autoconf where to find auxilliary build tools (e.g. config.guess,
+# install-sh, missing, etc.)
+#
+AC_CONFIG_AUX_DIR([config])
+
+#
+# Tell autoconf where to find auxilliary M4 macros
+#
+AC_CONFIG_MACRO_DIR([m4])
+
+#
+# Tell autoconf what file the package is using to aggregate C preprocessor
+# defines.
+#
+AC_CONFIG_HEADERS([include/config.h])
+
+#
+# Tell autoconf where to find source files for interfaces that are missing
+# in the target environment (see AC_REPLACE_FUNCS below).
+#
+AC_CONFIG_LIBOBJ_DIR([compat])
+
+#
+# Initialize automake for the package, specifying the minimum automake
+# version allowed and that we are not an official GNU package, but
+# rather a non-GNU package leveraging automake.
+#
+AM_INIT_AUTOMAKE([1.9 foreign])
+
+#
+# Enable maintainer mode to prevent the package from constantly trying
+# to rebuild configure, Makefile.in, etc. Rebuilding such files rarely,
+# if ever, needs to be done "in the field".
+#
+AM_MAINTAINER_MODE
+
+#
+# Figure out what the canonical build, host and target tuples are.
+#
+AC_CANONICAL_HOST
+
+AC_MSG_CHECKING([for supported deployment target])
+
+case ${host_os} in
+	*darwin*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_MACOSX=1 ${CPPFLAGS}"
+		deployment_target="Mac OS X"
+		;;
+
+	*freebsd*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_FREEBSD=1 ${CPPFLAGS}"
+		deployment_target="FreeBSD"
+		;;
+
+	*linux*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_LINUX=1 ${CPPFLAGS}"
+		deployment_target="Linux"
+		;;
+
+	*mingw*)
+		CPPFLAGS="-DDEPLOYMENT_TARGET_WINDOWS=1 ${CPPFLAGS}"
+		deployment_target="Windows"
+		;;
+
+	*)
+		AC_MSG_RESULT([failed])
+		AC_MSG_ERROR([Unsupported deployment target ${host_os}]);
+		;;
+esac
+
+AC_MSG_RESULT(${deployment_target})
+
+#
+# Checks for programs
+#
+AC_PROG_CC
+AC_PROG_CXX
+CF_BSD_SOURCE
+AC_GNU_SOURCE
+AM_PROG_CC_C_O
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+AC_PATH_PROG(CMP, cmp)
+
+# Support building DLLs on Windows
+AC_LIBTOOL_WIN32_DLL
+
+#
+# Checks for language qualifiers and semantics
+#
+AC_C_CHAR_UNSIGNED
+AC_C_CONST
+AC_C_INLINE
+AC_C_RESTRICT
+AC_C_VOLATILE
+
+#
+# Checks for compiler characteristics
+#
+
+# If using GCC specify some additional parameters
+
+test_gcc_flag() {
+    AC_LANG_CONFTEST([int main() {}])
+    $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
+    ret=$?
+    rm -f conftest.o
+    return $ret
+}
+
+if test "x$GCC" = "xyes" ; then
+    DESIRED_CFLAGS="-Wall -Wmost -pipe -Wno-trigraphs -Wno-parentheses -fexceptions -std=gnu99 -mmacosx-version-min=10.5 -fconstant-cfstrings"
+
+    for flag in $DESIRED_CFLAGS ; do
+        AC_MSG_CHECKING([whether ${CC} accepts ${flag}])
+        if test_gcc_flag $flag ; then
+           CFLAGS="$CFLAGS $flag"
+           AC_MSG_RESULT([yes])
+        else
+           AC_MSG_RESULT([no])
+        fi
+    done
+fi
+
+# Check whether the current compiler supports atomic built-ins
+
+AC_MSG_NOTICE([checking for compiler atomic built-ins])
+
+AC_CACHE_CHECK([whether the target supports __sync_fetch_and_add],
+	       [cf_cv_have_sync_fetch_and_add],
+	       [
+			AC_LINK_IFELSE([
+				AC_LANG_PROGRAM([[
+				]],[[
+					int foo = 0;
+					return __sync_fetch_and_add(&foo, 1);
+				]])],
+				[cf_cv_have_sync_fetch_and_add=yes],
+				[cf_cv_have_sync_fetch_and_add=no])
+		])
+
+if test "x${cf_cv_have_sync_fetch_and_add}" != "xno"; then
+	AC_DEFINE(HAVE___SYNC_FETCH_AND_ADD, 1,
+		  [Define this if your target compiler supports __sync_fetch_and_add])
+else
+	AC_MSG_ERROR([Support for __sync_fetch_and_add is required.])
+fi
+
+AC_CACHE_CHECK([whether the target supports __sync_bool_compare_and_swap],
+	       [cf_cv_have_sync_bool_compare_and_swap],
+	       [
+			AC_LINK_IFELSE([
+				AC_LANG_PROGRAM([[
+				]],[[
+					int foo;
+					return __sync_bool_compare_and_swap(&foo, 0, 1);
+				]])],
+				[cf_cv_have_sync_bool_compare_and_swap=yes],
+				[cf_cv_have_sync_bool_compare_and_swap=no])
+		])
+
+if test "x${cf_cv_have_sync_bool_compare_and_swap}" != "xno"; then
+	AC_DEFINE(HAVE___SYNC_BOOL_COMPARE_AND_SWAP, 1,
+		  [Define this if your target compiler supports __sync_bool_compare_and_swap])
+else
+	AC_MSG_ERROR([Support for __sync_bool_compare_and_swap is required.])
+fi
+
+AC_CACHE_CHECK([whether the target supports __sync_synchronize],
+	       [cf_cv_have_sync_synchronize],
+	       [
+			AC_LINK_IFELSE([
+				AC_LANG_PROGRAM([[
+				]],[[
+					__sync_synchronize();
+				]])],
+				[cf_cv_have_sync_synchronize=yes],
+				[cf_cv_have_sync_synchronize=no])
+		])
+
+if test "x${cf_cv_have_sync_synchronize}" != "xno"; then
+	AC_DEFINE(HAVE___SYNC_SYNCHRONIZE, 1,
+		  [Define this if your target compiler supports __sync_synchronize])
+else
+	AC_MSG_ERROR([Support for __sync_synchronize is required.])
+fi
+
+#
+# Check whether or not we should build the package with debug and profile
+# versions of the library
+#
+
+AC_MSG_NOTICE([checking library build options])
+
+AC_MSG_CHECKING([whether to build a debug library instance])
+AC_ARG_ENABLE(debug,
+	AS_HELP_STRING([--disable-debug], [Disable the generation of a debug library instance @<:@default=no@:>@.]),
+	[build_debug=${enableval}],
+	[build_debug=yes])
+AC_MSG_RESULT(${build_debug})
+AM_CONDITIONAL([CF_BUILD_DEBUG], [test "x${build_debug}" = "xyes"])
+
+AC_MSG_CHECKING([whether to build a profile library instance])
+AC_ARG_ENABLE(profile,
+	AS_HELP_STRING([--disable-profile], [Disable the generation of a profile library instance @<:@default=no@:>@.]),
+	[build_profile=${enableval}],
+	[build_profile=yes])
+AC_MSG_RESULT(${build_profile})
+AM_CONDITIONAL([CF_BUILD_PROFILE], [test "x${build_profile}" = "xyes"])
+
+AC_MSG_CHECKING([whether to build tests and examples])
+AC_ARG_ENABLE(tests,
+	AS_HELP_STRING([--disable-tests],[Disable building of tests and examples @<:@default=no@:>@.]),
+	[build_tests=${enableval}],
+	[build_tests=yes])
+AC_MSG_RESULT(${build_tests})
+AM_CONDITIONAL([CF_BUILD_TESTS], [test "x${build_tests}" = "xyes"])
+
+#
+# Checks for libraries
+#
+# We expect that we'll need at minimum:
+#
+#   * dl
+#   * icui18n
+#   * m
+#   * pthread
+#   * uuid
+#
+# and, maybe:
+#
+#   * rt
+#
+
+AC_MSG_NOTICE([checking required package dependencies])
+
+AC_PATH_PROG([PKG_CONFIG],[pkg-config])
+
+#
+# Sort out where the ICU components are at.
+#
+
+AC_MSG_NOTICE([checking the International Components for Unicode (ICU) package])
+
+AC_PATH_PROG([ICU_CONFIG],[icu-config])
+
+AC_ARG_WITH(icu,
+	AS_HELP_STRING([--with-icu=DIR],
+		       [Specify location of the International Components for Unicode (ICU) headers and libraries.]),
+	[
+		if test "x${withval}" = "xno"; then
+			AC_MSG_ERROR([${PACKAGE_NAME} requires the International Components for Unicode (ICU) package])
+		else
+			icu_dir=${withval}
+		fi
+	],
+	[icu_dir=])
+AC_ARG_WITH(icu-includes,
+	AS_HELP_STRING([--with-icu-includes=DIR],
+		       [Specify location of International Components for Unicode (ICU) headers.]),
+	[icu_header_dir=${withval}],
+	[icu_header_dir=])
+AC_ARG_WITH(icu-libs,
+	AS_HELP_STRING([--with-icu-libs=DIR],
+		       [Specify location of International Components for Unicode (ICU) libraries.]),
+	[icu_library_dir=${withval}],
+	[icu_library_dir=])
+
+# We always prefer checking the values of the various '--with-icu-...' 
+# options first to using icu-config because the former might be used
+# in a cross-compilation environment on a system that also contains
+# icu-config. In such a case, the user wants what he/she specified
+# rather than what icu-config indicates.
+
+if test "x${icu_dir}" != "x" -o "x${icu_header_dir}" != "x" -o "x${icu_library_dir}" != "x"; then
+	if test "x${icu_dir}" != "x"; then
+		if test -d "${icu_dir}"; then
+			if test -d "${icu_dir}/include"; then
+				ICU_CPPFLAGS="-I${icu_dir}/include"
+			else
+				ICU_CPPFLAGS="-I${icu_dir}"
+			fi
+
+			if test -d "${icu_dir}/lib"; then
+				ICU_LDFLAGS="-L${icu_dir}/lib"
+			else
+				ICU_LDFLAGS="-L${icu_dir}"
+			fi
+		else
+			AC_MSG_ERROR([No such directory ${icu_dir}])
+		fi
+	fi
+
+	if test "x${icu_header_dir}" != "x"; then
+		if test -d "${icu_header_dir}"; then
+			ICU_CPPFLAGS="-I${icu_header_dir}"
+		else
+			AC_MSG_ERROR([No such directory ${icu_header_dir}])
+		fi
+	fi
+
+	if test "x${icu_library_dir}" != "x"; then
+		if test -d "${icu_library_dir}"; then
+			ICU_LDFLAGS="-L${icu_library_dir}"
+		else
+			AC_MSG_ERROR([No such directory ${icu_library_dir}])
+		fi
+	fi
+
+	# Most ICU libraries have versioned symbols
+	# (e.g. ucal_open_3_8), so the stock AC_CHECK_LIB will not
+	# work here given the way it checks for symbol
+	# availability. Punt and assume the library set normally
+	# reported by icu-config.
+
+	ICU_LIBS="${ICU_LDFLAGS} -licui18n -licuuc -licudata"
+
+elif test "x${ICU_CONFIG}" != "x"; then
+	ICU_CPPFLAGS="`${ICU_CONFIG} --cppflags`"
+	ICU_LDFLAGS="`${ICU_CONFIG} --ldflags`"
+	ICU_LIBS="`${ICU_CONFIG} --ldflags-libsonly`"
+
+elif test "x${PKG_CONFIG}" != "x" -a "${PKG_CONFIG} --exists icu"; then
+	ICU_CPPFLAGS="`${PKG_CONFIG} --cflags icu`"
+	ICU_LDFLAGS="`${PKG_CONFIG} --libs-only-L icu`"
+	ICU_LIBS="`${PKG_CONFIG} --libs-only-l icu`"
+
+else
+	AC_MSG_ERROR([Cannot find the International Components for Unicode (ICU) package.])
+fi
+
+AC_SUBST(ICU_CPPFLAGS)
+AC_SUBST(ICU_LDFLAGS)
+AC_SUBST(ICU_LIBS)
+
+CPPFLAGS="${ICU_CPPFLAGS} ${CPPFLAGS}"
+LDFLAGS="${ICU_LDFLAGS} ${LDFLAGS}"
+LIBS="${ICU_LIBS} ${LIBS}"
+
+AC_CHECK_HEADERS([unicode/putil.h])
+AC_CHECK_HEADERS([unicode/ucal.h])
+AC_CHECK_HEADERS([unicode/ucol.h])
+AC_CHECK_HEADERS([unicode/ucurr.h])
+AC_CHECK_HEADERS([unicode/ucurr.h])
+AC_CHECK_HEADERS([unicode/udat.h])
+AC_CHECK_HEADERS([unicode/ulocdata.h])
+AC_CHECK_HEADERS([unicode/uloc.h])
+AC_CHECK_HEADERS([unicode/uloc.h])
+AC_CHECK_HEADERS([unicode/umsg.h])
+AC_CHECK_HEADERS([unicode/unum.h])
+AC_CHECK_HEADERS([unicode/uset.h])
+
+#
+# Sort out where the UUID components are at.
+#
+
+AC_MSG_NOTICE([checking Universally Unique Identifier (UUID) package])
+
+AC_PATH_PROG([UUID_CONFIG],[uuid-config])
+
+AC_ARG_WITH(uuid,
+	AS_HELP_STRING([--with-uuid=DIR],
+		       [Specify location of Universally Unique Identifier (UUID) headers and libraries.]),
+	[
+		if test "x${withval}" = "xno"; then
+			AC_MSG_ERROR([${PACKAGE_NAME} requires the Universally Unique Identifier (UUID) package])
+		fi
+		uuid_dir=${withval}
+	],
+	[uuid_dir=])
+AC_ARG_WITH(uuid-includes,
+	AS_HELP_STRING([--with-uuid-includes=DIR],
+		       [Specify location of Universally Unique Identifier (UUID) headers.]),
+	[uuid_header_dir=${withval}],
+	[uuid_header_dir=])
+AC_ARG_WITH(uuid-libs,
+	AS_HELP_STRING([--with-uuid-libs=DIR],
+		       [Specify location of Universally Unique Identifier (UUID) libraries.]),
+	[uuid_library_dir=${withval}],
+	[uuid_library_dir=])
+
+# We always prefer checking the values of the various '--with-uuid-...' 
+# options first to using uuid-config because the former might be used
+# in a cross-compilation environment on a system that also contains
+# uuid-config. In such a case, the user wants what he/she specified
+# rather than what uuid-config indicates.
+
+if test "x${uuid_dir}" != "x" -o "x${uuid_header_dir}" != "x" -o "x${uuid_library_dir}" != "x"; then
+	if test "x${uuid_dir}" != "x"; then
+		if test -d "${uuid_dir}"; then
+			if test -d "${uuid_dir}/include"; then
+				UUID_CPPFLAGS="-I${uuid_dir}/include"
+			else
+				UUID_CPPFLAGS="-I${uuid_dir}"
+			fi
+
+			if test -d "${uuid_dir}/lib"; then
+				UUID_LDFLAGS="-L${uuid_dir}/lib"
+			else
+				UUID_LDFLAGS="-L${uuid_dir}"
+			fi
+		else
+			AC_MSG_ERROR([No such directory ${uuid_dir}])
+		fi
+	fi
+
+	if test "x${uuid_header_dir}" != "x"; then
+		if test -d "${uuid_header_dir}"; then
+			UUID_CPPFLAGS="-I${uuid_header_dir}"
+		else
+			AC_MSG_ERROR([No such directory ${uuid_header_dir}])
+		fi
+	fi
+
+	if test "x${uuid_library_dir}" != "x"; then
+		if test -d "${uuid_library_dir}"; then
+			UUID_LDFLAGS="-L${uuid_library_dir}"
+		else
+			AC_MSG_ERROR([No such directory ${uuid_library_dir}])
+		fi
+	fi
+
+	UUID_saved_libs="${LIBS}"
+	LIBS=""
+
+		AC_CHECK_LIB(uuid, uuid_compare)
+
+	UUID_LIBS="${UUID_LDFLAGS} ${LIBS}"
+	LIBS="${UUID_saved_libs}"
+	unset UUID_saved_libs
+
+elif test "x${UUID_CONFIG}" != "x"; then
+	UUID_CPPFLAGS="`${UUID_CONFIG} --cflags`"
+	UUID_LDFLAGS="`${UUID_CONFIG} --ldflags`"
+	UUID_LIBS="`${UUID_CONFIG} --libs`"
+
+elif test "x${PKG_CONFIG}" != "x" -a "${PKG_CONFIG} --exists uuid"; then
+	UUID_CPPFLAGS="`${PKG_CONFIG} --cflags uuid`"
+	UUID_LDFLAGS="`${PKG_CONFIG} --libs-only-L uuid`"
+	UUID_LIBS="`${PKG_CONFIG} --libs-only-l uuid`"
+
+else
+	AC_MSG_ERROR([Cannot find the Universally Unique Identifier (UUID) package.])
+fi
+
+AC_SUBST(UUID_CPPFLAGS)
+AC_SUBST(UUID_LDFLAGS)
+AC_SUBST(UUID_LIBS)
+
+CPPFLAGS="${UUID_CPPFLAGS} ${CPPFLAGS}"
+LDFLAGS="${UUID_LDFLAGS} ${LDFLAGS}"
+LIBS="${UUID_LIBS} ${LIBS}"
+
+AC_CHECK_HEADERS([uuid/uuid.h])
+
+#
+# Check for POSIX thread support.
+#
+ACX_PTHREAD([],AC_MSG_ERROR([${PACKAGE_NAME} requires POSIX threads.]))
+
+CFLAGS="${PTHREAD_CFLAGS} ${CFLAGS}"
+CPPFLAGS="${PTHREAD_CPPFLAGS} ${CPPFLAGS}"
+LDFLAGS="${PTHREAD_LDFLAGS} ${LDFLAGS}"
+LIBS="${PTHREAD_LIBS} ${LIBS}"
+
+#
+# Check for where clock_gettime and friends are located.
+#
+
+AC_CHECK_LIB(rt, clock_gettime)
+
+#
+# Check for DLFCN support.
+#
+AC_CHECK_LIB(dl, dlopen)
+
+AC_CHECK_HEADERS([dlfcn.h])
+
+#
+# Check for math support.
+#
+AC_CHECK_LIB(m, floor)
+
+AC_CHECK_HEADERS([math.h])
+
+#
+# Check for where the default local time zone data file and time zone
+# data files are/will be located on the target system (this might be
+# different from where they are on the build system).
+#
+
+AC_MSG_CHECKING([where to find the default local time zone data file])
+AC_ARG_WITH(tz-default,
+	AS_HELP_STRING([--with-tz-default=FILE],
+		       [Specify the location of the default local time zone data file on the target system @<:@default=/etc/localtime@:>@.]),
+	[tz_default_file=${withval}],
+	[tz_default_file="/etc/localtime"])
+AC_MSG_RESULT(${tz_default_file})
+AC_DEFINE_UNQUOTED([TZDEFAULT],["${tz_default_file}"],[Define this to the location of the default local time zone data file (e.g. /etc/localtime) on the target system.])
+
+AC_MSG_CHECKING([where to find the time zone data files])
+AC_ARG_WITH(tz-data,
+	AS_HELP_STRING([--with-tz-data=DIR],
+		       [Specify the location of the time zone data files on the target system @<:@default=/usr/share/zoneinfo@:>@.]),
+	[tz_data_dir=${withval}],
+	[tz_data_dir="/usr/share/zoneinfo"])
+AC_MSG_RESULT(${tz_data_dir})
+AC_DEFINE_UNQUOTED([TZDIR],["${tz_data_dir}"],[Define this to the location of the time zone data files (e.g. /usr/share/zoneinfo) on the target system.])
+
+#
+# Check for tzcode header support.
+#
+# Most systems based on the GNU C library do not have the header from
+# tzcode (see ftp://elsie.nci.nih.gov/pub/), "tzfile.h" installed which is
+# needed. Check if it exists. If it doesn't let the user point us at it.
+#
+
+AC_ARG_WITH(tz-includes,
+	AS_HELP_STRING([--with-tz-includes=DIR],
+		       [Specify location of Time Zone (tzcode) headers @<:@default=/usr/include@:>@.]),
+	[
+		if test "x${withval}" != "xyes"; then
+			if test -d "${withval}/include"; then
+				TZ_CPPFLAGS="-I${withval}/include"
+			else
+				TZ_CPPFLAGS="-I${withval}"
+			fi
+		fi
+	])
+
+CPPFLAGS="${TZ_CPPFLAGS} ${CPPFLAGS}"
+
+AC_CHECK_HEADER([tzfile.h],[true],AC_MSG_ERROR([${PACKAGE_NAME} requires 'tzfile.h'. Download the latest tzcode package from 'ftp://elsie.nci.nih.gov/pub/' and/or use the '--with-tz-includes=DIR' configuration option.]))
+
+#
+# Check for headers
+#
+
+AC_HEADER_DIRENT
+AC_HEADER_STDBOOL
+AC_HEADER_STDC
+AC_HEADER_TIME
+
+AC_CHECK_HEADERS([alloca.h])
+AC_CHECK_HEADERS([arpa/nameser.h])
+AC_CHECK_HEADERS([assert.h])
+AC_CHECK_HEADERS([dns_sd.h])
+AC_CHECK_HEADERS([errno.h])
+AC_CHECK_HEADERS([fcntl.h])
+AC_CHECK_HEADERS([limits.h])
+AC_CHECK_HEADERS([locale.h])
+AC_CHECK_HEADERS([malloc.h])
+AC_CHECK_HEADERS([malloc/malloc.h])
+AC_CHECK_HEADERS([netinet/in.h])
+AC_CHECK_HEADERS([objc/objc.h])
+AC_CHECK_HEADERS([objc/runtime.h])
+AC_CHECK_HEADERS([poll.h])
+AC_CHECK_HEADERS([pwd.h])
+AC_CHECK_HEADERS([semaphore.h])
+AC_CHECK_HEADERS([setjmp.h])
+AC_CHECK_HEADERS([signal.h])
+AC_CHECK_HEADERS([stdarg.h])
+AC_CHECK_HEADERS([stdbool.h])
+AC_CHECK_HEADERS([stddef.h])
+AC_CHECK_HEADERS([stdint.h])
+AC_CHECK_HEADERS([stdio.h])
+AC_CHECK_HEADERS([stdlib.h])
+AC_CHECK_HEADERS([string.h])
+AC_CHECK_HEADERS([syslog.h])
+AC_CHECK_HEADERS([time.h])
+AC_CHECK_HEADERS([unistd.h])
+AC_CHECK_HEADERS([xlocale.h])
+AC_CHECK_HEADERS([sys/cdefs.h])
+AC_CHECK_HEADERS([sys/errno.h])
+AC_CHECK_HEADERS([sys/fcntl.h])
+AC_CHECK_HEADERS([sys/ioctl.h])
+AC_CHECK_HEADERS([sys/mman.h])
+AC_CHECK_HEADERS([sys/param.h])
+AC_CHECK_HEADERS([sys/socket.h])
+AC_CHECK_HEADERS([sys/stat.h])
+AC_CHECK_HEADERS([sys/time.h])
+AC_CHECK_HEADERS([sys/types.h])
+AC_CHECK_HEADERS([sys/uio.h])
+
+#
+# Checks for types and structures
+#
+AC_TYPE_INT8_T
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UID_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_STRUCT_TIMEZONE
+
+#
+# Checks for library functions
+#
+
+AC_FUNC_ALLOCA
+AC_FUNC_CHOWN
+AC_FUNC_CLOSEDIR_VOID
+AC_FUNC_FORK
+AC_FUNC_MMAP
+AC_FUNC_SELECT_ARGTYPES
+
+AC_CHECK_FUNCS([getcwd])
+AC_CHECK_FUNCS([gethostname])
+AC_CHECK_FUNCS([malloc realloc])
+AC_CHECK_FUNCS([memchr memcmp memmove memset])
+AC_CHECK_FUNCS([mkdir])
+AC_CHECK_FUNCS([munmap])
+AC_CHECK_FUNCS([rmdir])
+AC_CHECK_FUNCS([select])
+AC_CHECK_FUNCS([setenv])
+AC_CHECK_FUNCS([socket])
+AC_CHECK_FUNCS([getgid getuid getegid geteuid])
+AC_CHECK_FUNCS([getpid])
+AC_CHECK_FUNCS([strerror])
+AC_CHECK_FUNCS([rint strchr strdup strrchr strstr strtod strtol strtoul])
+AC_CHECK_FUNCS([strncmp strncasecmp])
+AC_CHECK_FUNCS([ustrncmp ustrncasecmp])
+AC_CHECK_FUNCS([symlink])
+AC_CHECK_FUNCS([readlink])
+AC_CHECK_FUNCS([lstat stat])
+AC_CHECK_FUNCS([snprintf])
+
+# Figure out how to map strlcat and strlcpy if they don't exist by
+# either simply redefining them or by using a local compatibility
+# implementation.
+#
+# Some caveats are worth mentioning with respect to defining them to
+# strn{cat,cpy}. In particular, strl{cat,cpy}:
+# 
+#   1) ALWAYS NULL-terminate if the destination has length.
+#   2) Take the full size of the buffer (not the space left over).
+#   3) Don't NULL-fill the remainder of its destination.
+#   4) Return a size_t size rather than a char * pointer.
+#
+# While CoreFoundation has not been found to rely on any of these
+# differences, it may in the future.
+
+CF_REPLACE_STRLN_FUNC([cat])
+CF_REPLACE_STRLN_FUNC([cpy])
+
+#
+# Other ibrary functions we might need to provide local compatibility
+# implementations of.
+#
+AC_REPLACE_FUNCS([flsl gettimeofday])
+
+#
+# Identify the various makefiles and auto-generated files for the package
+#
+AC_CONFIG_FILES([
+CoreFoundation.pc
+Makefile
+include/Makefile
+compat/Makefile
+tests/Makefile
+examples/Makefile
+examples/Allocator/Makefile
+examples/CFLocalServer/Makefile
+examples/CFMessagePort/Makefile
+examples/CFRunLoopTimerExample/Makefile
+examples/CFTest/Makefile
+examples/DisplayURL/Makefile
+examples/DNSServiceMetaQuery/Makefile
+examples/ReadPListExample/Makefile
+examples/SimpleWebServer/Makefile
+examples/StringExample/Makefile
+examples/WritePListExample/Makefile
+])
+
+#
+# Generate them
+#
+AC_OUTPUT
+
+AC_MSG_NOTICE([
+
+  Configuration Summary
+  ---------------------
+  Package                     : ${PACKAGE_NAME}
+  Version                     : ${PACKAGE_VERSION}
+  Deployment target           : ${deployment_target}
+  Build shared library        : ${enable_shared}
+  Build static library        : ${enable_static}
+  Build debug library         : ${build_debug}
+  Build profile library       : ${build_profile}
+  Build examples and tests    : ${build_tests}
+  Prefix		      : ${prefix}
+  ICU compile options         : ${ICU_CPPFLAGS}
+  ICU link options            : ${ICU_LDFLAGS}
+  ICU link libraries          : ${ICU_LIBS}
+  POSIX thread compile options: ${PTHREAD_CFLAGS}
+  POSIX thread link options   : ${PTHREAD_LIBS}
+  UUID compile options        : ${UUID_CPPFLAGS}
+  UUID link options           : ${UUID_LDFLAGS}
+  UUID link libraries	      : ${UUID_LIBS}
+  Time Zone compile options   : ${TZ_CPPFLAGS}
+  Time Zone default file      : ${tz_default_file}
+  Time Zone data directory    : ${tz_data_dir}
+  Compiler                    : ${CC}
+  Preprocessor flags          : ${CPPFLAGS}
+  Compile flags               : ${CFLAGS}
+  Link flags                  : ${LDFLAGS}
+  Link libraries              : ${LIBS}
+
+])
diff --git a/CoreFoundation/examples/Allocator/Allocator.vcproj b/CoreFoundation/examples/Allocator/Allocator.vcproj
new file mode 100755
index 0000000..f95946a
--- /dev/null
+++ b/CoreFoundation/examples/Allocator/Allocator.vcproj
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="AllocatorExample"
+	ProjectGUID="{2A4D3906-539D-4D1E-9C97-47ABD83FD999}"
+	RootNamespace="AllocatorExample"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin\$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;WINDOWS_LEAN_AND_MEAN=1"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CFLite_$(ConfigurationName).lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin\$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\AllocatorExample.c"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCCLCompilerTool"
+					CompileAs="2"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCCLCompilerTool"
+					CompileAs="2"
+				/>
+			</FileConfiguration>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/CoreFoundation/examples/Allocator/AllocatorExample.c b/CoreFoundation/examples/Allocator/AllocatorExample.c
new file mode 100644
index 0000000..aa57e1e
--- /dev/null
+++ b/CoreFoundation/examples/Allocator/AllocatorExample.c
@@ -0,0 +1,352 @@
+/*
+ Simple CFAllocator example program, demonstrating creation and use of custom CFAllocators.
+ Author: Ali Ozer
+ 7/7/99
+
+ Copyright (c) 1999-2004, Apple Computer, Inc., all rights reserved.
+*/
+/*
+ IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
+ consideration of your agreement to the following terms, and your use, installation, 
+ modification or redistribution of this Apple software constitutes acceptance of these 
+ terms.  If you do not agree with these terms, please do not use, install, modify or 
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and subject to these 
+ terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in 
+ this original Apple software (the "Apple Software"), to use, reproduce, modify and 
+ redistribute the Apple Software, with or without modifications, in source and/or binary 
+ forms; provided that if you redistribute the Apple Software in its entirety and without 
+ modifications, you must retain this notice and the following text and disclaimers in all 
+ such redistributions of the Apple Software.  Neither the name, trademarks, service marks 
+ or logos of Apple Computer, Inc. may be used to endorse or promote products derived from 
+ the Apple Software without specific prior written permission from Apple. Except as expressly
+ stated in this notice, no other rights or licenses, express or implied, are granted by Apple
+ herein, including but not limited to any patent rights that may be infringed by your 
+ derivative works or by other works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES, 
+ EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, 
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS 
+ USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL 
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, 
+ REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND 
+ WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR 
+ OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#include <CoreFoundation/CoreFoundation.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+// This function will print the provided arguments (printf style varargs) out to the console.
+// Note that the CFString formatting function accepts "%@" as a way to display CF types.
+// For types other than CFString and CFNumber, the result of %@ is mostly for debugging
+// and can differ between releases and different platforms.
+
+void show(CFStringRef formatString, ...) {
+    CFStringRef resultString;
+    CFDataRef data;
+    va_list argList;
+
+    va_start(argList, formatString);
+    resultString = CFStringCreateWithFormatAndArguments(NULL, NULL, formatString, argList);
+    va_end(argList);
+
+    data = CFStringCreateExternalRepresentation(NULL, resultString, CFStringGetSystemEncoding(), '?');
+
+    if (data != NULL) {
+    	printf ("%.*s\n\n", (int)CFDataGetLength(data), CFDataGetBytePtr(data));
+    	CFRelease(data);
+    }
+       
+    CFRelease(resultString);
+}
+
+
+// "Counting" Allocator
+// A simple custom allocator that will count memory allocations and place guards to check memory corruption.
+
+void verifyMemory(int *ptr) {
+    int size = ptr[0];
+    if (ptr[1] != 0x42424242) abort();
+    if (ptr[2 + size / sizeof(int)] != 0x42424242) abort();
+    if (ptr[2 + size / sizeof(int) + 1] != 0x42424242) abort();
+    if (ptr[2 + size / sizeof(int) + 2] != 0x42424242) abort();
+    if (ptr[2 + size / sizeof(int) + 3] != 0x42424242) abort();
+}
+
+static void *countingRealloc(void *oPtr, CFIndex size, CFOptionFlags hint, void *info) {
+    int *ptr = (int*)oPtr;
+
+    // Round it up to int alignment.
+    size = ((size + sizeof(int) - 1) / sizeof(int)) * sizeof(int);
+
+    if (ptr) {
+        ptr = ptr - 2;	// Get back to the the originally allocated piece
+        verifyMemory(ptr);
+        ptr = (int*)realloc(ptr, size + sizeof(int) * 6);
+    } else {
+        ptr = (int*)malloc(size + sizeof(int) * 6);
+    }
+    ptr[0] = size;	// Doesn't include the guards
+    ptr[1] = 0x42424242;
+    ptr[2 + size / sizeof(int)] = 0x42424242;
+    ptr[2 + size / sizeof(int) + 1] = 0x42424242;
+    ptr[2 + size / sizeof(int) + 2] = 0x42424242;
+    ptr[2 + size / sizeof(int) + 3] = 0x42424242;
+
+    return (void *)(ptr + 2);
+}
+
+static void *countingAlloc(CFIndex size, CFOptionFlags hint, void *info) {
+    (*(int *)info)++;		// Increment count
+    return countingRealloc(NULL, size, hint, info);
+}
+
+static void countingDealloc(void *ptr, void *info) {
+    (*(int *)info)--;		// Decrement count
+    ptr = (int *)ptr - 2;	// Restore pointer to the actual malloc block
+    verifyMemory((int*)ptr);
+    free(ptr);
+}
+
+// Returns info about the number of outstanding allocations
+
+static CFIndex NumOutstandingAllocations(CFAllocatorRef alloc) {
+    CFAllocatorContext context;
+    context.version = 0;
+    CFAllocatorGetContext(alloc, &context);
+    return (*(int *)(context.info));
+}
+
+// Creates a "counting allocator" --- keeps track of number of
+// outstanding allocations and also uses guards to catch out of bound writes
+
+static CFAllocatorRef CreateCountingAllocator(CFAllocatorRef alloc) {
+    CFAllocatorContext context = {0, NULL, NULL, (CFAllocatorReleaseCallBack)free, NULL, countingAlloc, countingRealloc, countingDealloc, NULL};
+    context.info = malloc(sizeof(int));
+    // The info field points to an int which keeps number of allocations/deallocations
+    // The "free" in slot 3 of the context assures the info field is properly freed when the allocator is
+    *(int *)(context.info) = 0;
+    // Create and return the allocator
+    return CFAllocatorCreate(alloc, &context);
+}
+
+
+
+// "Reduced Malloc" Allocator
+// A simple custom allocator that tries to avoid allocations.
+// This allocator will allocate one chunk of memory containing n blocks of a certain size each,
+// and manage these as the memory pool. If larger requests or more requests come in, this
+// allocator will fall back on allocating actual memory.
+// Note: This allocator isn't that great; it's provided as sample code only.
+
+// This struct holds the actual blocks for the memory plus the necessary info
+// (The allocated size of this struct will depend on the desired number of blocks)
+
+typedef struct {
+    CFAllocatorRef allocator;
+    CFIndex size;
+    CFIndex numBlocks;
+    CFIndex firstAvailable;
+    CFIndex numAdditionalAllocations;	// Stats for finding out how much addt'l memory was allocated
+    void *mem[0];
+} rmInfo;
+
+// This function is used to free the above structure when the allocator is deallocated
+
+void rmInfoFree(const void *actualInfo) {
+    rmInfo *info = (rmInfo *)actualInfo;
+    CFAllocatorRef allocator = info->allocator;
+    CFAllocatorDeallocate(allocator, info);
+    CFRelease(allocator);
+}
+
+#define rmNextBlockNum(info, blockNum) *(int *)(((unsigned char *)&(info->mem)) + (blockNum * info->size))
+// #define rmBlock(info, blockNum) ((&(info->mem)) + (blockNum * info->size))
+#define rmBlock(info, blockNum) (((unsigned char *)&(info->mem)) + (blockNum * info->size))
+#define rmBlockNumber(info, ptr) (((unsigned char *)ptr - (unsigned char *)rmBlock(info, 0)) / info->size)
+#define isRMBlock(info, ptr) (ptr >= (void *)rmBlock(info, 0) && ptr <= (void *)rmBlock(info, info->numBlocks))
+
+static void rmMarkBlockAsAvailable(rmInfo *info, CFIndex blockNum) {
+    // Put this block at the head of the available list
+    rmNextBlockNum(info, blockNum) = info->firstAvailable;
+    info->firstAvailable = blockNum;
+}
+
+static void rmMarkFirstAvailableAsUnavailable(rmInfo *info) {
+    // This will only happen for the first block, so take it off the free list and return
+    info->firstAvailable = rmNextBlockNum(info, info->firstAvailable);
+}
+
+// The function pointers for the allocator context
+
+static void *rmRealloc(void *oPtr, CFIndex size, CFOptionFlags hint, void *actualInfo) {
+    rmInfo *info = (rmInfo *)actualInfo;
+    if (isRMBlock(info, oPtr)) {
+	void *ptr;
+        if (size <= info->size) return oPtr;	// Easy case...
+	ptr = CFAllocatorAllocate(info->allocator, size, hint);
+	memmove(ptr, oPtr, info->size);
+	rmMarkBlockAsAvailable(info, rmBlockNumber(info, oPtr));
+	info->numAdditionalAllocations++;
+	return ptr;
+    } else {
+	return CFAllocatorReallocate(info->allocator, oPtr, size, hint);
+    }
+}
+
+static void *rmAlloc(CFIndex size, CFOptionFlags hint, void *actualInfo) {
+    rmInfo *info = (rmInfo *)actualInfo;
+    if ((info->firstAvailable == -1) || (size > info->size)) {
+	// No more available; allocate addt'l memory
+	info->numAdditionalAllocations++;
+        return CFAllocatorAllocate(info->allocator, size, hint);
+    } else {
+	void *ptr = rmBlock(info, info->firstAvailable);
+	rmMarkFirstAvailableAsUnavailable(info);
+        return ptr;
+    }
+}
+
+static void rmDealloc(void *ptr, void *actualInfo) {
+    rmInfo *info = (rmInfo *)actualInfo;
+    if (isRMBlock(info, ptr)) {
+	// It is one of ours, so mark it as available
+	rmMarkBlockAsAvailable(info, rmBlockNumber(info, ptr));
+    } else {
+	// It is not, so directly deallocate
+	info->numAdditionalAllocations--;
+        CFAllocatorDeallocate(info->allocator, ptr);
+    }
+}
+
+static CFIndex NumAdditionalAllocations(CFAllocatorRef alloc) {
+    CFAllocatorContext context;
+    context.version = 0;
+    CFAllocatorGetContext(alloc, &context);
+    return ((rmInfo *)(context.info))->numAdditionalAllocations;
+}
+
+// Creates a "reduced malloc allocator".
+
+static CFAllocatorRef CreateReducedMallocAllocator(CFAllocatorRef alloc, CFIndex size, CFIndex numBlocks) {
+    CFIndex cnt;
+    rmInfo *info;
+    CFAllocatorContext context = {0, NULL, NULL, rmInfoFree, NULL, rmAlloc, rmRealloc, rmDealloc, NULL};
+
+    // Create and initialize the info block and the memory
+    info = (rmInfo*)CFAllocatorAllocate(alloc, (sizeof(rmInfo) + size * numBlocks), 0);
+    info->size = size;
+    info->numBlocks = numBlocks;
+    info->firstAvailable = -1;
+    info->numAdditionalAllocations = 0;
+    for (cnt = 0; cnt < numBlocks; cnt++) rmMarkBlockAsAvailable(info, cnt);
+    // Retain the allocator used to allocate the memory
+    info->allocator = (CFAllocatorRef)((alloc) ? CFRetain(alloc) : CFRetain(CFAllocatorGetDefault()));
+    // And hang on to the info block
+    context.info = info;
+    // Finally, create and return the allocator
+    return CFAllocatorCreate(alloc, &context);
+}
+
+
+
+// Now some example code which uses these allocators
+
+void countingAllocatorExample(void) {
+
+    CFStringRef str1, str2, str3;
+    CFMutableStringRef mStr;
+
+    CFAllocatorRef countingAllocator;
+
+    show(CFSTR("Counting Allocator Test"));
+
+    countingAllocator = CreateCountingAllocator(NULL);
+
+    show(CFSTR("At start, number of allocations: %d"), NumOutstandingAllocations(countingAllocator));
+
+    str1 = CFStringCreateWithCString(countingAllocator, "Hello World", kCFStringEncodingASCII);
+#if defined(__APPLE__)
+    str2 = CFStringCreateWithPascalString(countingAllocator, "\pHello World", kCFStringEncodingASCII);
+#else
+    str2 = CFStringCreateWithCString(countingAllocator, "Hello World", kCFStringEncodingASCII);
+#endif
+    mStr = CFStringCreateMutableCopy(countingAllocator, 0, str1);
+    str3 = CFStringCreateCopy(countingAllocator, mStr);
+
+    show(CFSTR("After creation, number of allocations: %d"), NumOutstandingAllocations(countingAllocator));
+
+    CFStringAppend(mStr, str1);
+    CFStringAppend(mStr, str1);
+    CFStringAppend(mStr, str1);
+
+    show(CFSTR("After mutations, number of allocations: %d"), NumOutstandingAllocations(countingAllocator));
+
+    CFRelease(str1);
+    CFRelease(str2);
+    CFRelease(mStr);
+    CFRelease(str3);
+
+    show(CFSTR("After releasing, number of allocations: %d"), NumOutstandingAllocations(countingAllocator));
+
+    CFRelease(countingAllocator);
+}
+
+
+void reducedMallocAllocatorExample(void) {
+
+    CFStringRef str1, str2, str3;
+    CFMutableStringRef mStr;
+
+    CFAllocatorRef reducedMallocAllocator;
+
+    show(CFSTR("Reduced Malloc Allocator Test"));
+
+    // Create a reduced memory allocator; have it start with 3 blocks of 40 bytes each.
+
+    reducedMallocAllocator = CreateReducedMallocAllocator(NULL, 40, 3);
+
+    show(CFSTR("At start, number of addt'l allocations: %d"), NumAdditionalAllocations(reducedMallocAllocator));
+
+    str1 = CFStringCreateWithCString(reducedMallocAllocator, "Hello World", kCFStringEncodingASCII);
+#if defined(__APPLE__)
+    str2 = CFStringCreateWithPascalString(reducedMallocAllocator, "\pHello World", kCFStringEncodingASCII);
+#else
+    str2 = CFStringCreateWithCString(reducedMallocAllocator, "Hello World", kCFStringEncodingASCII);
+#endif
+    mStr = CFStringCreateMutableCopy(reducedMallocAllocator, 0, str1);
+    str3 = CFStringCreateCopy(reducedMallocAllocator, mStr);
+
+    show(CFSTR("After creation, number of addt'l allocations: %d"), NumAdditionalAllocations(reducedMallocAllocator));
+
+    CFStringAppend(mStr, str1);
+    CFStringAppend(mStr, str1);
+    CFStringAppend(mStr, str1);
+
+    show(CFSTR("After mutations, number of addt'l allocations: %d"), NumAdditionalAllocations(reducedMallocAllocator));
+
+    CFRelease(str1);
+    CFRelease(str2);
+    CFRelease(mStr);
+    CFRelease(str3);
+
+    show(CFSTR("After releasing, number of addt'l allocations: %d"), NumAdditionalAllocations(reducedMallocAllocator));
+
+    CFRelease(reducedMallocAllocator);
+}
+
+
+int main (int argc, const char *argv[]) {
+    countingAllocatorExample();
+    reducedMallocAllocatorExample();
+
+    return 0;
+}
+
+
diff --git a/CoreFoundation/examples/Allocator/Makefile.am b/CoreFoundation/examples/Allocator/Makefile.am
new file mode 100644
index 0000000..fc63a9c
--- /dev/null
+++ b/CoreFoundation/examples/Allocator/Makefile.am
@@ -0,0 +1,22 @@
+AM_CFLAGS			= -I${top_srcdir}/include
+
+EXTRA_DIST			= Allocator.vcproj
+
+if CF_BUILD_TESTS
+check_PROGRAMS			= AllocatorExample
+endif
+
+AllocatorExample_LDADD		= ${top_builddir}/libCoreFoundation.la
+
+AllocatorExample_SOURCES	= AllocatorExample.c
+
+if CF_BUILD_TESTS
+check:
+	${LIBTOOL} --mode execute ./AllocatorExample
+
+gdb:
+	${LIBTOOL} --mode execute ${@} ./AllocatorExample
+
+valgrind:
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./AllocatorExample
+endif
diff --git a/CoreFoundation/examples/Allocator/Makefile.in b/CoreFoundation/examples/Allocator/Makefile.in
new file mode 100644
index 0000000..e6dc134
--- /dev/null
+++ b/CoreFoundation/examples/Allocator/Makefile.in
@@ -0,0 +1,469 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = AllocatorExample$(EXEEXT)
+subdir = examples/Allocator
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_AllocatorExample_OBJECTS = AllocatorExample.$(OBJEXT)
+AllocatorExample_OBJECTS = $(am_AllocatorExample_OBJECTS)
+AllocatorExample_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(AllocatorExample_SOURCES)
+DIST_SOURCES = $(AllocatorExample_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = Allocator.vcproj
+AllocatorExample_LDADD = ${top_builddir}/libCoreFoundation.la
+AllocatorExample_SOURCES = AllocatorExample.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/Allocator/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/Allocator/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+AllocatorExample$(EXEEXT): $(AllocatorExample_OBJECTS) $(AllocatorExample_DEPENDENCIES) 
+	@rm -f AllocatorExample$(EXEEXT)
+	$(LINK) $(AllocatorExample_OBJECTS) $(AllocatorExample_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllocatorExample.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@check:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./AllocatorExample
+
+@CF_BUILD_TESTS_TRUE@gdb:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./AllocatorExample
+
+@CF_BUILD_TESTS_TRUE@valgrind:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./AllocatorExample
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/CFLocalServer/Client.c b/CoreFoundation/examples/CFLocalServer/Client.c
new file mode 100644
index 0000000..b02f408
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/Client.c
@@ -0,0 +1,1023 @@
+/*
+ *    Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>
+ *    Copyright (c) 2009 Brent Fulgham.  All rights reserved.
+ *    All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the BSD-style license (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ */
+
+/*
+    File:       Client.c
+
+    Contains:   Client showing integration of CFSockets and UNIX domain sockets.
+
+    Written by: DTS
+
+    Copyright:  Copyright (c) 2005 by Apple Computer, Inc., All Rights Reserved.
+
+    Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
+                ("Apple") in consideration of your agreement to the following terms, and your
+                use, installation, modification or redistribution of this Apple software
+                constitutes acceptance of these terms.  If you do not agree with these terms,
+                please do not use, install, modify or redistribute this Apple software.
+
+                In consideration of your agreement to abide by the following terms, and subject
+                to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+                copyrights in this original Apple software (the "Apple Software"), to use,
+                reproduce, modify and redistribute the Apple Software, with or without
+                modifications, in source and/or binary forms; provided that if you redistribute
+                the Apple Software in its entirety and without modifications, you must retain
+                this notice and the following text and disclaimers in all such redistributions of
+                the Apple Software.  Neither the name, trademarks, service marks or logos of
+                Apple Computer, Inc. may be used to endorse or promote products derived from the
+                Apple Software without specific prior written permission from Apple.  Except as
+                expressly stated in this notice, no other rights or licenses, express or implied,
+                are granted by Apple herein, including but not limited to any patent rights that
+                may be infringed by your derivative works or by other works in which the Apple
+                Software may be incorporated.
+
+                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
+                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+                COMBINATION WITH YOUR PRODUCTS.
+
+                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    Change History (most recent first):
+
+$Log: Client.c,v $
+Revision 1.2  2005/05/18 13:36:28         
+Fixed various documentation/comment changes.
+
+Revision 1.1  2005/05/17 12:19:13         
+First checked in.
+
+
+*/
+
+/////////////////////////////////////////////////////////////////
+
+// System interfaces
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include <stdlib.h>
+#include <assert.h>
+
+#if defined(WIN32)
+#include <errno.h>
+#define ECANCELED 15
+
+#include <stdio.h>
+#define snprintf _snprintf
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+
+#define PRId32 "d"
+#define PRIu32 "u"
+
+#else
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <signal.h>
+#endif
+
+// Project interfaces
+
+#include "Protocol.h"
+#include "Common.h"
+
+/////////////////////////////////////////////////////////////////
+#pragma mark ***** Connection Abstraction
+
+// A ConnectionRef represents a connection from the client to the server. 
+// The internals of this are opaque to external callers.  All operations on 
+// a connection are done via the routines in this section.
+
+enum {
+    kConnectionStateMagic = 'LCCM'           // Local Client Connection Magic
+};
+
+typedef struct ConnectionState *  ConnectionRef;
+    // Pseudo-opaque reference to the connection.
+
+typedef Boolean (*ConnectionCallbackProcPtr)(
+    ConnectionRef           conn, 
+    const PacketHeader *    packet, 
+    void *                  refCon
+);
+    // When the client enables listening on a connection, it supplies a 
+    // function of this type as a callback.  We call this function in 
+    // the context of the runloop specified by the client when they enable 
+    // listening.
+    //
+    // conn is a reference to the connection.  It will not be NULL.
+    //
+    // packet is a pointer to the packet that arrived, or NULL if we've 
+    // detected that the connection to the server is broken.
+    //
+    // refCon is a value that the client specified when it registered this 
+    // callback.
+    //
+    // If the server sends you a bad packet, you can return false to 
+    // tell the connection management system to shut down the connection.
+
+// ConnectionState is the structure used to track a single connection to 
+// the server.  All fields after fSockFD are only relevant if the client 
+// has enabled listening.
+
+struct ConnectionState {
+    OSType                      fMagic;             // kConnectionStateMagic
+    int                         fSockFD;            // UNIX domain socket to server
+    CFSocketRef                 fSockCF;            // CFSocket wrapper for the above
+    CFRunLoopSourceRef          fRunLoopSource;     // runloop source for the above
+    CFMutableDataRef            fBufferedPackets;   // buffer for incomplete packet data
+    ConnectionCallbackProcPtr   fCallback;          // client's packet callback
+    void *                      fCallbackRefCon;    // refCon for the above.
+};
+
+// Forward declarations.  See the comments associated with the function definition.
+
+static void ConnectionShutdown(ConnectionRef conn);
+static void ConnectionCloseInternal(ConnectionRef conn, Boolean sayGoodbye);
+
+static int ConnectionOpen(ConnectionRef *connPtr)
+    // Opens a connection to the server.
+    //
+    // On entry, connPtr must not be NULL
+    // On entry, *connPtr must be NULL
+    // Returns an errno-style error code
+    // On success, *connPtr will not be NULL
+    // On error, *connPtr will be NULL
+{
+    int                 err;
+    ConnectionRef       conn;
+    Boolean             sayGoodbye;
+#if !defined(_WIN32)
+    int sockType = AF_UNIX;
+#else
+    int sockType = AF_INET;
+#endif
+    
+    assert( connPtr != NULL);
+    assert(*connPtr == NULL);
+    
+    sayGoodbye = false;
+    
+    // Allocate a ConnectionState structure and fill out some basic fields.
+    
+    err = 0;
+    conn = (ConnectionRef) calloc(1, sizeof(*conn));
+    if (conn == NULL) {
+        err = ENOMEM;
+    }
+    if (err == 0) {
+        conn->fMagic  = kConnectionStateMagic;
+        
+        // For clean up to work properly, we must make sure that, if 
+        // the connection record is allocated successfully, we always 
+        // set fSockFD to -1.  So, while the following line is redundant 
+        // in the current code, it's present to press home this point.
+
+        conn->fSockFD = -1;
+    }
+    
+    // Create a UNIX domain socket and connect to the server. 
+    
+    if (err == 0) {
+        conn->fSockFD = socket(sockType, SOCK_STREAM, 0);
+        err = MoreUNIXErrno(conn->fSockFD);
+    }
+    if (err == 0) {
+        struct sockaddr_un connReq;
+
+        connReq.sun_family = AF_UNIX;
+        strcpy(connReq.sun_path, kServerSocketPath);
+
+        err = connect(conn->fSockFD, (struct sockaddr*) &connReq, SUN_LEN(&connReq));
+        err = MoreUNIXErrno(err);
+        
+        sayGoodbye = (err == 0);
+    }
+    
+    // Clean up.
+    
+    if (err != 0) {
+        ConnectionCloseInternal(conn, sayGoodbye);
+        conn = NULL;
+    }
+    *connPtr = conn;
+    
+    assert( (err == 0) == (*connPtr != NULL) );
+    
+    return err;
+}
+
+static int ConnectionSend(ConnectionRef conn, const PacketHeader *packet)
+    // Send a packet to the server.  Use this when you're not expecting a 
+    // reply.
+    //
+    // conn must be a valid connection
+    // packet must be a valid, ready-to-send, packet
+    // Returns an errno-style error code
+{
+    int     err;
+    
+    assert(conn != NULL);
+    assert(conn->fSockFD != -1);            // connection must not be shut down
+    // conn->fSockCF may or may not be NULL; it's OK to send a packet when listening 
+    // because there's no reply; OTOH, you can't do an RPC while listening because 
+    // an unsolicited packet might get mixed up with the RPC reply.
+    
+    assert(packet != NULL);
+    assert(packet->fMagic == kPacketMagic);
+    assert(packet->fSize >= sizeof(PacketHeader));
+    
+    // Simply send the packet down the socket.
+    
+    err = MoreUNIXWrite(conn->fSockFD, packet, packet->fSize, NULL);
+    
+    return err;
+}
+
+static int ConnectionRPC(
+    ConnectionRef           conn, 
+    const PacketHeader *    request, 
+    PacketHeader *          reply, 
+    size_t                  replySize
+)
+    // Perform an RPC (Remote Procedure Call) with the server.  That is, send 
+    // the server a packet and wait for a reply.  You can only use this on 
+    // connections that are not in listening mode.
+    //
+    // conn must be a valid connection
+    //
+    // packet must be a valid, ready-to-send, packet
+    //
+    // reply and replySize specify a buffer where the reply packet is placed;
+    // reply size must not be NULL; replySize must not be less that the 
+    // packet header size (sizeof(PacketHeader)); if the reply packet is bigger 
+    // than replySize, the data that won't fit is discarded; you can detect this 
+    // by looking at reply->fSize
+    //
+    // Returns an errno-style error code
+    // On success, the buffer specified by reply and replySize will contain the 
+    // reply packet; on error, the contents of that buffer is invalid; also, 
+    // if this routine errors the connection is no longer useful (conn is still 
+    // valid, but you can't use it to transmit any more data)
+{
+    int     err;
+    
+    assert(conn != NULL);
+    assert(conn->fSockFD != -1);            // connection must not be shut down
+    assert(conn->fSockCF == NULL);          // RPC and listening are mutually exclusive
+                                            // because unsolicited packet might get mixed up 
+                                            // with the reply
+
+    assert(request != NULL);
+    assert(request->fMagic == kPacketMagic);
+    assert(request->fSize >= sizeof(PacketHeader));
+
+    assert(reply != NULL);
+    assert(replySize >= sizeof(PacketHeader));
+    
+    // Send the request.
+    
+    err = ConnectionSend(conn, request);
+    
+    // Read and validate the reply header.
+    
+    if (err == 0) {
+        err = MoreUNIXRead(conn->fSockFD, reply, sizeof(PacketHeader), NULL);
+    }
+    if ( (err == 0) && (reply->fMagic != kPacketMagic) ) {
+        fprintf(stderr, "ConnectionRPC: Bad magic (%.4s).\n", (char *) &reply->fMagic);
+        err = EINVAL;
+    }
+    if ( (err == 0) && (reply->fType != kPacketTypeReply) ) {
+        fprintf(stderr, "ConnectionRPC: Type wrong (%.4s).\n", (char *) &reply->fType);
+        err = EINVAL;
+    }
+    if ( (err == 0) && (reply->fID != request->fID) ) {
+        fprintf(stderr, "ConnectionRPC: ID mismatch (%" PRId32 ").\n", reply->fID);
+        err = EINVAL;
+    }
+    if ( (err == 0) && ( (reply->fSize < sizeof(PacketHeader)) || (reply->fSize > kPacketMaximumSize) ) ) {
+        fprintf(stderr, "ConnectionRPC: Bogus packet size (%" PRIu32 ").\n", reply->fSize);
+        err = EINVAL;
+    }
+
+    // Read the packet payload that will fit in the reply buffer.
+    
+    if ( (err == 0) && (reply->fSize > sizeof(PacketHeader)) ) {
+        uint32_t  payloadToRead;
+        
+        if (reply->fSize > replySize) {
+            payloadToRead = replySize;
+        } else {
+            payloadToRead = reply->fSize;
+        }
+        payloadToRead -= sizeof(PacketHeader);
+        
+        err = MoreUNIXRead(conn->fSockFD, ((char *) reply) + sizeof(PacketHeader), payloadToRead, NULL);
+    }
+
+    // Discard any remaining packet payload that will fit in the reply buffer.
+    // The addition check in the next line is necessary to avoid the undefined behaviour 
+    // of malloc(0) in the dependent block.
+
+    if ( (err == 0) && (reply->fSize > replySize) ) {
+        uint32_t    payloadToJunk;
+        void *      junkBuf;
+        
+        payloadToJunk = reply->fSize - replySize;
+        
+        junkBuf = malloc(payloadToJunk);
+        if (junkBuf == NULL) {
+            err = ENOMEM;
+        }
+        
+        if (err == 0) { 
+            err = MoreUNIXRead(conn->fSockFD, junkBuf, payloadToJunk, NULL);
+        }
+        
+        free(junkBuf);
+    }
+
+    // Any errors cause us to immediately shut down our connection because we 
+    // we're no longer sure of the state of the channel (that is, did we leave 
+    // half a packet stuck in the pipe).
+    
+    if (err != 0) {
+        ConnectionShutdown(conn);
+    }
+    
+    return err;
+}
+
+static void ConnectionGotData(
+    CFSocketRef             s, 
+    CFSocketCallBackType    type, 
+    CFDataRef               address, 
+    const void *            data, 
+    void *                  info
+)
+    // This is a a CFSocket callback indicating that data has arrived on the 
+    // socket.  It's only called if the user has registered the associated 
+    // connection for listening.  The parameter are as per the CFSocket 
+    // documentation.  As this is a callback of type kCFSocketDataCallBack, 
+    // data contains newly arrived data that CFSocket has already read for us.
+{
+    CFDataRef       newData;
+    ConnectionRef   conn;
+
+	(void)address;
+    assert(s != NULL);
+    assert(type == kCFSocketDataCallBack);
+
+    // Cast data to a CFDataRef, newData.
+    
+    newData = (CFDataRef) data;
+    assert(newData != NULL);
+    assert( CFGetTypeID(newData) == CFDataGetTypeID() );
+    
+    // Cast info to a ConnectionRef.
+    
+    conn = (ConnectionRef) info;
+    assert(conn->fMagic == kConnectionStateMagic);
+    
+    if ( CFDataGetLength(newData) == 0 ) {
+        // End of data stream; the server is dead.
+        
+        fprintf(stderr, "ConnectionGotData: Server died unexpectedly.\n");
+
+        // Tell the client.
+        
+        (void) conn->fCallback(conn, NULL, conn->fCallbackRefCon);
+        
+        // Shut 'er down Clancy, she's pumping mud!
+        
+        ConnectionShutdown(conn);
+    } else {
+        // We have new data from the server.  Appending to our buffer.
+        
+        CFDataAppendBytes(conn->fBufferedPackets, CFDataGetBytePtr(newData), CFDataGetLength(newData));
+        
+        // Now see if there are any complete packets in the buffer; and, 
+        // if so, deliver them to the client.
+        
+        do {
+            PacketHeader *  thisPacket;
+            Boolean         success;
+            
+            if ( CFDataGetLength(conn->fBufferedPackets) < sizeof(PacketHeader) ) {
+                // Not enough data for the packet header; we're done.
+                break;
+            }
+            
+            thisPacket = (PacketHeader *) CFDataGetBytePtr(conn->fBufferedPackets);
+            
+            if ( thisPacket->fMagic != kPacketMagic ) {
+                fprintf(stderr, "ConnectionGotData: Server sent us a packet with bad magic (%.4s).\n", (char *) &thisPacket->fMagic);
+                
+                ConnectionShutdown(conn);
+                break;
+            }
+            
+            if (thisPacket->fSize > kPacketMaximumSize) {
+                fprintf(stderr, "ConnectionGotData: Server sent us a packet that's just too big (%" PRIu32 ").\n", thisPacket->fSize);
+                
+                ConnectionShutdown(conn);
+                break;
+            }
+            
+            if ( CFDataGetLength(conn->fBufferedPackets) < thisPacket->fSize ) {
+                // Not enough data for the packet body; we're done.
+                break;
+            }
+            
+            // Tell the client about the packet.
+
+            success = conn->fCallback(conn, thisPacket, conn->fCallbackRefCon);
+            if ( ! success ) {
+                ConnectionShutdown(conn);
+                break;
+            }
+            
+            // Delete this packet from the front of our packet buffer.  I horror at 
+            // the inefficiency of this, but it is sample code after all.
+            
+            CFDataDeleteBytes(conn->fBufferedPackets, CFRangeMake(0, thisPacket->fSize));
+            
+        } while (true);
+    }
+}
+
+static int ConnectionRegisterListener(
+    ConnectionRef               conn, 
+    CFRunLoopRef                runLoop,
+    CFStringRef                 runLoopMode, 
+    ConnectionCallbackProcPtr   callback, 
+    void *                      refCon
+)
+    // Register a listener to be called when packets arrive.  Once you've done 
+    // this, you can no longer use conn for RPCs.
+    //
+    // conn must be a valid connection
+    //
+    // runLoop and runLoopMode specify the context in which the callback will 
+    // be called; in most cases you specify CFRunLoopGetCurrent() and 
+    // kCFRunLoopDefaultMode
+    //
+    // callback is the function you want to be called when packets arrive; it 
+    // must not be NULL
+    //
+    // refCon is passed to callback
+    //
+    // Returns an errno-style error code
+    // On success, the connection has been converted to a listener and your 
+    // callback will be called from the context of the specific runloop when 
+    // a packet arrives; on error, the connection is no longer useful (conn is 
+    // still valid, but you can't use it to transmit any more data)
+{
+    int             err;
+
+    assert(conn != NULL);
+    assert(runLoop != NULL);
+    assert(runLoopMode != NULL);
+    assert(callback != NULL);
+
+    assert(conn->fSockFD != -1);            // connection must not be shut down
+    assert(conn->fSockCF == NULL);          // can't register twice
+    
+    // Create the packet buffer.
+    
+    err = 0;
+    conn->fBufferedPackets = CFDataCreateMutable(NULL, 0);
+    if (conn->fBufferedPackets == NULL) {
+        err = ENOMEM;
+    }
+    
+    // Add the source to the runloop.
+    
+    if (err == 0) {
+        CFSocketContext context;
+
+        memset(&context, 0, sizeof(context));
+        context.info = conn;
+
+        conn->fSockCF = CFSocketCreateWithNative(
+            NULL, 
+            (CFSocketNativeHandle) conn->fSockFD, 
+            kCFSocketDataCallBack, 
+            ConnectionGotData, 
+            &context
+        );
+        if (conn->fSockCF == NULL) {
+            err = EINVAL;
+        }
+    }
+    if (err == 0) {
+        conn->fRunLoopSource = CFSocketCreateRunLoopSource(NULL, conn->fSockCF, 0);
+        if (conn->fRunLoopSource == NULL) {
+            err = EINVAL;
+        }
+    }
+    if (err == 0) {
+        conn->fCallback = callback;
+        conn->fCallbackRefCon = refCon;
+        
+        CFRunLoopAddSource( runLoop, conn->fRunLoopSource, runLoopMode);
+    }
+
+    // Any failure means the entire connection is dead; again, this is the 
+    // draconian approach to error handling.  But hey, connections are 
+    // (relatively) cheap.
+    
+    if (err != 0) {
+        ConnectionShutdown(conn);
+    }
+    
+    return err;
+}
+
+static void ConnectionShutdown(ConnectionRef conn)
+    // This routine shuts down down the connection to the server 
+    // without saying goodbye; it leaves conn valid.  This routine 
+    // is primarily used internally to the connection abstraction 
+    // where we notice that the connection has failed for some reason. 
+    // It's also called by the client after a successful quit RPC 
+    // because we know that the server has closed its end of the 
+    // connection.
+    //
+    // It's important to nil out the fields as we close them because 
+    // this routine is called if any messaging routine fails.  If it 
+    // doesn't nil out the fields, two bad things might happen:
+    //
+    // o When the connection is eventually closed, ConnectionCloseInternal 
+    //   will try to send a Goodbye, which fails triggering an assert.
+    //
+    // o If ConnectionShutdown is called twice on a particular connection 
+    //   (which happens a lot; this is a belts and braces implementation 
+    //   [that's "belts and suspenders" for the Americans reading this; 
+    //   ever wonder why Monty Python's lumberjacks sing about "suspenders 
+    //   and a bra"?; well look up "suspenders" in a non-American dictionary 
+    //   for a quiet chuckle :-] )
+{
+    int     junk;
+    Boolean hadSockCF;
+
+    assert(conn != NULL);
+    
+    conn->fCallback       = NULL;
+    conn->fCallbackRefCon = NULL;
+
+    if (conn->fRunLoopSource != NULL) {
+        CFRunLoopSourceInvalidate(conn->fRunLoopSource);
+        
+        CFRelease(conn->fRunLoopSource);
+        
+        conn->fRunLoopSource = NULL;
+    }
+    
+    // CFSocket will close conn->fSockFD when we invalidate conn->fSockCF, 
+    // so we remember whether we did this so that, later on, we know 
+    // whether to close the file descriptor ourselves.  We need an extra 
+    // variable because we NULL out fSockCF as we release it, for the reason 
+    // described above.
+    
+    hadSockCF = (conn->fSockCF != NULL);
+    if (conn->fSockCF != NULL) {
+        CFSocketInvalidate(conn->fSockCF);
+        
+        CFRelease(conn->fSockCF);
+        
+        conn->fSockCF = NULL;
+    }
+
+    if (conn->fBufferedPackets != NULL) {
+        CFRelease(conn->fBufferedPackets);
+        conn->fBufferedPackets = NULL;
+    }
+
+    if ( (conn->fSockFD != -1) && ! hadSockCF ) {
+#if !defined(_WIN32)
+        junk = close(conn->fSockFD);
+#else
+        junk = closesocket(conn->fSockFD);
+#endif
+        assert(junk == 0);
+    }
+    // We always set fSockFD to -1 because either we've closed it or 
+    // CFSocket has.
+    conn->fSockFD = -1;
+}
+
+static void ConnectionCloseInternal(ConnectionRef conn, Boolean sayGoodbye)
+    // The core of ConnectionClose.  It's called by ConnectionClose 
+    // and by ConnectionOpen, if it fails for some reason.  This exists 
+    // as a separate routine so that we can add the sayGoodbye parameter, 
+    // which controls whether we send a goodbye packet to the server.  We 
+    // need this because we should always try to say goodbye if we're called 
+    // from ConnectionClose, but if we're called from ConnectionOpen we 
+    // should only try to say goodbye if we successfully connected the 
+    // socket.
+    //
+    // Regardless, the bulk of the work of this routine is done by 
+    // ConnectionShutdown.  This routine exists to a) say goodbye, if 
+    // necessary, and b) free the memory associated with the connection.
+{
+    int     junk;
+    
+    if (conn != NULL) {
+        assert(conn->fMagic == kConnectionStateMagic);
+
+        if ( (conn->fSockFD != -1) && sayGoodbye ) {
+            PacketGoodbye   goodbye;
+
+            InitPacketHeader(&goodbye.fHeader, kPacketTypeGoodbye, sizeof(goodbye), false);
+            snprintf(goodbye.fMessage, sizeof(goodbye.fMessage), "Process %ld signing off", (long) getpid());
+            
+            junk = ConnectionSend(conn, &goodbye.fHeader);
+            assert(junk == 0);
+        }
+        ConnectionShutdown(conn);
+        
+        free(conn);
+    }
+}
+
+static void ConnectionClose(ConnectionRef conn)
+    // Closes the connection.  It's legal to pass conn as NULL, in which 
+    // case this does nothing (kinda like free'ing NULL).
+{
+    ConnectionCloseInternal(conn, true);
+}
+
+/////////////////////////////////////////////////////////////////
+#pragma mark ***** Command Line Tool
+
+// The following routines use the connection abstraction defined above 
+// to implement a simple command line tool that exercises the server.
+
+enum {
+    kResultColumnWidth = 10
+};
+
+static void PrintResult(const char *command, int errNum, const char *arg)
+    // Prints the result of a command.  command is the name of the 
+    // command, errNum is the errno-style error number, and arg 
+    // (if not NULL) is the command argument.
+{
+    if (errNum == 0) {
+        if (arg == NULL) {
+            fprintf(stderr, "%*s\n", kResultColumnWidth, command);
+        } else {
+            fprintf(stderr, "%*s \"%s\"\n", kResultColumnWidth, command, arg);
+        }
+    } else {
+        fprintf(stderr, "%*s failed with error %d\n", kResultColumnWidth, command, errNum);
+    }
+}
+
+static void DoNOP(ConnectionRef conn)
+    // Implements the "nop" command by doing a NOP RPC with the server.
+{
+    int         err;
+    PacketNOP   request;
+    PacketReply reply;
+    
+    InitPacketHeader(&request.fHeader, kPacketTypeNOP, sizeof(request), true);
+    
+    err = ConnectionRPC(conn, &request.fHeader, &reply.fHeader, sizeof(reply));
+    if (err == 0) {
+        err = reply.fErr;
+    }
+    PrintResult("nop", err, NULL);
+}
+
+static void DoWhisper(ConnectionRef conn, const char *message)
+    // Implements the "whisper" command by doing a whisper RPC with the server.
+    //
+    // The server responds to this RPC by printing the message.
+{
+    int             err;
+    PacketWhisper   request;
+    PacketReply     reply;
+    
+    InitPacketHeader(&request.fHeader, kPacketTypeWhisper, sizeof(request), true);
+    snprintf(request.fMessage, sizeof(request.fMessage), "%s", message);
+    
+    err = ConnectionRPC(conn, &request.fHeader, &reply.fHeader, sizeof(reply));
+    if (err == 0) {
+        err = reply.fErr;
+    }
+    PrintResult("whisper", err, message);
+}
+
+static void DoShout(ConnectionRef conn, const char *message)
+    // Implements the "shout" command by sending a shout packet to the server. 
+    // Note that this is /not/ an RPC.
+    //
+    // The server responds to this packet by echoing it to each registered 
+    // listener.
+{
+    int         err;
+    PacketShout request;
+    
+    InitPacketHeader(&request.fHeader, kPacketTypeShout, sizeof(request), false);
+    snprintf(request.fMessage, sizeof(request.fMessage), "%s", message);
+    
+    err = ConnectionSend(conn, &request.fHeader);
+    PrintResult("shout", err, message);
+}
+
+static Boolean GotPacket(ConnectionRef conn, const PacketHeader *packet, void *refCon)
+    // DoListen registers this routine with the connection abstraction layer 
+    // so that it is called when a packet arrives.  For a description of the 
+    // parameters, see the comments next to ConnectionCallbackProcPtr.
+{
+    Boolean         result;
+    CFRunLoopRef    runLoop;
+    
+	(void)conn;
+
+    // When we register this callback, we pass a reference to the runloop 
+    // as the refCon.  Extract that reference here.
+    
+    runLoop = (CFRunLoopRef) refCon;
+    assert(runLoop != NULL);
+    assert( CFGetTypeID(runLoop) == CFRunLoopGetTypeID() );
+    
+    result = true;
+    if (packet == NULL) {
+        // Server connection has gone away.  No need to return false because 
+        // the connection is torn anyway.
+        
+        CFRunLoopStop(runLoop);
+    } else {
+        // We got a packet from the server.  Tell the user about it.
+        
+        switch (packet->fType) {
+            case kPacketTypeShout:
+                if (packet->fSize != sizeof(PacketShout)) {
+                    fprintf(stderr, "GotPacket: Server sent us a Shout with the wrong size (%" PRIu32 ").\n", packet->fSize);
+                    result = false;
+                }
+                
+                if (result && (packet->fID != kPacketIDNone) ) {
+                    fprintf(stderr, "GotPacket: Server sent us a Shout with the wrong size (%" PRId32 ").\n", packet->fID);
+                    result = false;
+                }
+
+                if (result) {
+                    PacketShout * shoutPacket;
+                    
+                    shoutPacket = (PacketShout *) packet;
+                    fprintf(stderr, "%*s heard \"%.*s\"\n", kResultColumnWidth, "", (int) sizeof(shoutPacket->fMessage), shoutPacket->fMessage);                
+                }
+                break;
+            default:   
+                fprintf(stderr, "GotPacket: Server sent us a packet with an unexpected type (%.4s).\n", (char *) &packet->fType);
+                result = false;
+                break;
+        }
+    }
+    
+    return result;
+}
+
+static void DoListen(ConnectionRef conn)
+    // Implements the "listen" command.  First this does a listen RPC 
+    // to tell the server that this connection is now a listener.  Next it 
+    // calls ConnectionRegisterListener to register a packet listener callback 
+    // (GotPacket, above) on the runloop.  It then runs the runloop until its 
+    // stopped (by a SIGINT, via SIGINTRunLoopCallback, below).
+{
+    int             err;
+    PacketListen    request;
+    PacketReply     reply;
+    
+    InitPacketHeader(&request.fHeader, kPacketTypeListen, sizeof(request), true);
+    
+    err = ConnectionRPC(conn, &request.fHeader, &reply.fHeader, sizeof(reply));
+    if (err == 0) {
+        err = reply.fErr;
+    }
+    if (err == 0) {
+        err = ConnectionRegisterListener(
+            conn, 
+            CFRunLoopGetCurrent(), 
+            kCFRunLoopDefaultMode, 
+            GotPacket, 
+            CFRunLoopGetCurrent()
+        );
+    }
+    if (err != 0) {
+        PrintResult("listen", err, NULL);
+    } else {
+        fprintf(stderr, "%*s Press ^C to quit.\n", kResultColumnWidth, "listen");
+
+        CFRunLoopRun();
+    }
+}
+
+static void DoQuit(ConnectionRef conn)
+    // Implements the "quit" command by doing a quit RPC with the server. 
+    // The server responds to this RPC by quitting.  Cleverly, it sends us 
+    // the RPC reply right before quitting.
+{
+    int         err;
+    PacketQuit  request;
+    PacketReply reply;
+    
+    InitPacketHeader(&request.fHeader, kPacketTypeQuit, sizeof(request), true);
+    
+    err = ConnectionRPC(conn, &request.fHeader, &reply.fHeader, sizeof(reply));
+    if (err == 0) {
+        err = reply.fErr;
+    }
+    if (err == 0) {
+        // If the quit is successful, we shut down our end of the connection 
+        // because we know that the server has shut down its end.
+        ConnectionShutdown(conn);
+    }
+    PrintResult("quit", err, NULL);
+}
+
+#if !defined(_WIN32)
+static void SIGINTRunLoopCallback(const siginfo_t *sigInfo, void *refCon)
+    // This routine is called in response to a SIGINT signal. 
+    // It is not, however, a signal handler.  Rather, we 
+    // orchestrate to have it called from the runloop (via 
+    // the magic of InstallSignalToSocket).  It's purpose 
+    // is to stop the runloop when the user types ^C.
+{
+    (void)sigInfo;
+	(void)refCon;
+    
+    // Stop the runloop.  Note that we can get a reference to the runloop by 
+	// calling CFRunLoopGetCurrent because this is called from the runloop.
+    
+    CFRunLoopStop( CFRunLoopGetCurrent() );
+    
+    // Print a bonus newline to ensure that the next command prompt isn't 
+    // printed on the same line as the echoed ^C.
+    
+    fprintf(stderr, "\n");
+}
+#endif
+
+static void PrintUsage(const char *argv0)
+    // Print the program's usage.
+{
+    const char *command;
+    
+    command = strrchr(argv0, '/');
+    if (command == NULL) {
+        command = argv0;
+    } else {
+        command += 1;
+    }
+    fprintf(stderr, "usage: %s command...\n", command);
+    fprintf(stderr, "       commands: nop\n");
+    fprintf(stderr, "                 whisper <message>\n");
+    fprintf(stderr, "                 shout   <message>\n");
+    fprintf(stderr, "                 listen  (must be last)\n");
+    fprintf(stderr, "                 quit\n");
+}
+
+int main (int argc, const char * argv[])
+    // The primary entry point.
+{
+    int             err;
+    ConnectionRef   conn;
+    
+    conn = NULL;
+    
+    // If we get no arguments, just print the usage and fail.
+    
+    err = 0;
+    if (argc == 1) {
+        PrintUsage(argv[0]);
+        err = ECANCELED;
+    }
+    
+#if !defined(_WIN32)
+    // SIGPIPE is evil, so tell the system not to send it to us.
+    
+    if (err == 0) {
+        err = MoreUNIXIgnoreSIGPIPE();
+    }
+
+    // Organise to have SIGINT delivered to a runloop callback.
+    
+    if (err == 0) {
+        sigset_t    justSIGINT;
+        
+        (void) sigemptyset(&justSIGINT);
+        (void) sigaddset(&justSIGINT, SIGINT);
+        
+        err = InstallSignalToSocket(
+            &justSIGINT,
+            CFRunLoopGetCurrent(),
+            kCFRunLoopDefaultMode,
+            SIGINTRunLoopCallback,
+            NULL
+        );
+    }
+#else
+    {
+       WORD versionRequested = MAKEWORD(2, 0);
+       WSADATA wsaData;
+       err = WSAStartup(versionRequested, &wsaData);
+       if (err != 0 || LOBYTE(wsaData.wVersion) != LOBYTE(versionRequested) || HIBYTE(wsaData.wVersion) != HIBYTE(versionRequested)) {
+           WSACleanup();
+           CFLog(0, CFSTR("*** Could not initialize WinSock subsystem!!!"));
+       }
+    }
+#endif
+    
+    // Connect to the server.
+    
+    if (err == 0) {
+        err = ConnectionOpen(&conn);
+    }
+    
+    // Process the command line arguments.  Basically the arguments are a 
+    // sequence of commands, which we process in order.  The logic is 
+    // a little convoluted because some commands have arguments and because 
+    // the "listen" command must come last.
+    
+    if (err == 0) {
+        Boolean printTheUsage;
+        int     argIndex;
+        
+		printTheUsage = false;
+		
+        argIndex = 1;
+        while ( (err == 0) && (argIndex < argc) ) {
+            if ( strcmp(argv[argIndex], "nop") == 0 ) {
+                DoNOP(conn);
+            } else if ( strcmp(argv[argIndex], "whisper") == 0 ) {
+                argIndex += 1;
+                if (argIndex < argc) {
+                    DoWhisper(conn, argv[argIndex]);
+                } else {
+                    printTheUsage = true;
+                    err = ECANCELED;
+                }
+            } else if ( strcmp(argv[argIndex], "shout") == 0 ) {
+                argIndex += 1;
+                if (argIndex < argc) {
+                    DoShout(conn, argv[argIndex]);
+                } else {
+                    printTheUsage = true;
+                    err = ECANCELED;
+                }
+            } else if ( strcmp(argv[argIndex], "listen") == 0 ) {
+                if ( (argIndex + 1) == argc ) {         // if listen is the last argument
+                    DoListen(conn);
+                } else {
+                    printTheUsage = true;
+                    err = ECANCELED;
+                }
+            } else if ( strcmp(argv[argIndex], "quit") == 0 ) {
+                DoQuit(conn);
+            } else {
+                printTheUsage = true;
+                err = ECANCELED;
+            }
+            argIndex += 1;
+        }
+        
+        if (printTheUsage) {
+            PrintUsage(argv[0]);
+        }
+    }
+    
+    // Clean up.
+    
+    ConnectionClose(conn);
+
+    if ( (err != 0) && (err != ECANCELED) ) {
+        fprintf(stderr, "SimpleClientCF: Failed with error %d.\n", err);
+    }
+    
+    return (err == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/CoreFoundation/examples/CFLocalServer/Common.c b/CoreFoundation/examples/CFLocalServer/Common.c
new file mode 100644
index 0000000..fb24c08
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/Common.c
@@ -0,0 +1,642 @@
+/*
+ *    Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>
+ *    Copyright (c) 2009 Brent Fulgham <bfulgham@gmail.com>
+ *    All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the BSD-style license (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ */
+
+/*
+    File:       Common.c
+
+    Contains:   Common code between client and server.
+
+    Written by: DTS
+
+    Copyright:  Copyright (c) 2005 by Apple Computer, Inc., All Rights Reserved.
+
+    Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
+                ("Apple") in consideration of your agreement to the following terms, and your
+                use, installation, modification or redistribution of this Apple software
+                constitutes acceptance of these terms.  If you do not agree with these terms,
+                please do not use, install, modify or redistribute this Apple software.
+
+                In consideration of your agreement to abide by the following terms, and subject
+                to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+                copyrights in this original Apple software (the "Apple Software"), to use,
+                reproduce, modify and redistribute the Apple Software, with or without
+                modifications, in source and/or binary forms; provided that if you redistribute
+                the Apple Software in its entirety and without modifications, you must retain
+                this notice and the following text and disclaimers in all such redistributions of
+                the Apple Software.  Neither the name, trademarks, service marks or logos of
+                Apple Computer, Inc. may be used to endorse or promote products derived from the
+                Apple Software without specific prior written permission from Apple.  Except as
+                expressly stated in this notice, no other rights or licenses, express or implied,
+                are granted by Apple herein, including but not limited to any patent rights that
+                may be infringed by your derivative works or by other works in which the Apple
+                Software may be incorporated.
+
+                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
+                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+                COMBINATION WITH YOUR PRODUCTS.
+
+                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    Change History (most recent first):
+
+$Log: Common.c,v $
+Revision 1.2  2005/06/30 20:22:25         
+Corrected a bug that would causing the packet's fID field to not be initialised in the RPC case.
+
+Revision 1.1  2005/05/17 12:19:17         
+First checked in.
+
+
+*/
+
+/////////////////////////////////////////////////////////////////
+
+// System interfaces
+
+#if defined(WIN32)
+#include <stdio.h>
+#define snprintf _snprintf
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+#include <fcntl.h>
+#include <process.h>
+
+#define SOCK_MAXADDRLEN 255
+#define MAXPATHLEN MAX_PATH
+
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
+
+#define NI_NUMERICHOST 0x02
+#define NI_NUMERICSERV 0x08
+#else
+#include <assert.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/fcntl.h>
+#include <sys/param.h>
+#include <sys/un.h>
+#include <netdb.h>
+#endif
+
+// Our prototypes
+
+#include "Common.h"
+
+/////////////////////////////////////////////////////////////////
+
+extern int MoreUNIXErrno(int result)
+    // See comment in header.
+{
+    int err;
+    
+    err = 0;
+    if (result < 0) {
+#if !defined(_WIN32)
+        err = errno;
+#else
+        err = WSAGetLastError ();
+#endif
+        assert(err != 0);
+    }
+    return err;
+}
+
+#if !defined(_WIN32)
+extern int MoreUNIXIgnoreSIGPIPE(void)
+    // See comment in header.
+{
+	int err;
+	struct sigaction signalState;
+	
+	err = sigaction(SIGPIPE, NULL, &signalState);
+	err = MoreUNIXErrno(err);
+	if (err == 0) {
+		signalState.sa_handler = SIG_IGN;
+		
+		err = sigaction(SIGPIPE, &signalState, NULL);
+		err = MoreUNIXErrno(err);
+	}
+	
+	return err;
+}
+#endif
+
+extern int MoreUNIXRead( int fd,       void *buf, size_t bufSize, size_t *bytesRead   )
+    // See comment in header.
+{
+	int 	err;
+	char *	cursor;
+	size_t	bytesLeft;
+	ssize_t bytesThisTime;
+
+	assert(fd >= 0);
+	assert(buf != NULL);
+	
+	err = 0;
+	bytesLeft = bufSize;
+	cursor = (char *) buf;
+	while ( (err == 0) && (bytesLeft != 0) ) {
+		bytesThisTime = read(fd, cursor, bytesLeft);
+		if (bytesThisTime > 0) {
+			cursor    += bytesThisTime;
+			bytesLeft -= bytesThisTime;
+		} else if (bytesThisTime == 0) {
+			err = EPIPE;
+		} else {
+			assert(bytesThisTime == -1);
+			
+			err = errno;
+			assert(err != 0);
+			if (err == EINTR) {
+				err = 0;		// let's loop again
+			}
+		}
+	}
+	if (bytesRead != NULL) {
+		*bytesRead = bufSize - bytesLeft;
+	}
+	
+	return err;
+}
+
+extern int MoreUNIXWrite(int fd, const void *buf, size_t bufSize, size_t *bytesWritten)
+    // See comment in header.
+{
+	int 	err;
+	char *	cursor;
+	size_t	bytesLeft;
+	ssize_t bytesThisTime;
+	
+	assert(fd >= 0);
+	assert(buf != NULL);
+
+	err = 0;
+	bytesLeft = bufSize;
+	cursor = (char *) buf;
+	while ( (err == 0) && (bytesLeft != 0) ) {
+		bytesThisTime = write(fd, cursor, bytesLeft);
+		if (bytesThisTime > 0) {
+			cursor    += bytesThisTime;
+			bytesLeft -= bytesThisTime;
+		} else if (bytesThisTime == 0) {
+			assert(false);
+			err = EPIPE;
+		} else {
+			assert(bytesThisTime == -1);
+			
+			err = errno;
+			assert(err != 0);
+			if (err == EINTR) {
+				err = 0;		// let's loop again
+			}
+		}
+	}
+	if (bytesWritten != NULL) {
+		*bytesWritten = bufSize - bytesLeft;
+	}
+	
+	return err;
+}
+
+extern int MoreUNIXSetNonBlocking(int fd)
+{
+    int err;
+    int flags;
+ 
+#if defined(_WIN32)
+    unsigned long nonblockopt = 1;
+    flags = ioctlsocket (fd, FIONREAD, 0);
+    err = ioctlsocket (fd, FIONBIO, &nonblockopt);
+#else
+    // According to the man page, F_GETFL can't error!
+    
+    flags = fcntl(fd, F_GETFL, NULL);
+    
+    err = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+#endif
+    err = MoreUNIXErrno(err);
+    
+    return err;
+}
+
+#if !defined(_WIN32)
+static int					gSignalSinkFD   = -1;
+static CFSocketRef			gSignalSourceCF = NULL;
+static SignalSocketCallback	gClientCallback = NULL;
+static void *				gClientCallbackRefCon = NULL;
+
+static void SignalToSocketHandler(int sig, siginfo_t *sigInfo, void *uap)
+    // A signal handler that catches the signal and forwards it 
+    // to the runloop via gSignalSinkFD.  This code is careful to 
+    // only use signal safe routines (except for the asserts, 
+    // of course, but they're compiled out on production builds).
+{
+	ssize_t		junk;
+	
+	(void)uap;
+
+	assert(gSignalSinkFD != -1);
+	
+	assert(sig == sigInfo->si_signo);
+
+	junk = write(gSignalSinkFD, sigInfo, sizeof(*sigInfo));
+	
+	// There's not much I can do if this fails.  Missing a signal 
+	// isn't such a big deal, but writing only a partial siginfo_t 
+	// to the socket would be bad.
+	
+	assert(junk == sizeof(*sigInfo));
+}
+
+static void SignalCFSocketCallback(
+	CFSocketRef				s, 
+	CFSocketCallBackType	type, 
+	CFDataRef				address, 
+	const void *			data, 
+	void *					info
+)
+    // Call in the context of the runloop when data arrives on the 
+    // UNIX domain socket shared with the signal handler.  This 
+    // reads the information about the signal and passes to the client's 
+    // callback.
+{
+	int			err;
+	siginfo_t	sigInfo;
+
+	(void)info;
+
+	assert(gSignalSourceCF != NULL);
+	assert(gClientCallback != NULL);
+	
+	assert(s == gSignalSourceCF);
+	assert(type == kCFSocketReadCallBack);
+	assert(address == NULL);
+	assert(data == NULL);
+
+	err = MoreUNIXRead( CFSocketGetNative(gSignalSourceCF), &sigInfo, sizeof(sigInfo), NULL);
+	if (err == 0) {
+		gClientCallback(&sigInfo, gClientCallbackRefCon);
+	}
+	assert(err == 0);
+}
+
+extern int InstallSignalToSocket(
+	const sigset_t *		sigSet, 
+	CFRunLoopRef			runLoop,
+	CFStringRef				runLoopMode,
+	SignalSocketCallback	callback, 
+	void *					refCon
+)
+    // See comment in header.
+{
+	int		err;
+	int		junk;
+	int		sockets[2];
+	int		signalSourceFD;
+	
+	assert(sigSet != NULL);
+	assert(runLoop != NULL);
+	assert(runLoopMode != NULL);
+	assert(callback != NULL);
+	
+	assert(gSignalSinkFD   == -1);              // don't call me twice
+	assert(gSignalSourceCF == NULL);
+	assert(gClientCallback == NULL);
+	
+	signalSourceFD = -1;
+	
+    // Create a UNIX domain socket pair and assign them to the 
+    // sink (where the signal handler writes the information) and 
+    // source variables (where the runloop callback reads it).  
+    
+	err = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
+	err = MoreUNIXErrno(err);
+	if (err == 0) {
+		gSignalSinkFD  = sockets[0];
+		signalSourceFD = sockets[1];
+	}
+    
+    // We set the signal sink socket to non-blocking because, if the 
+    // socket fills up, there's a possibility we might deadlock with 
+    // ourselves (the signal handler blocks trying to write data to 
+    // a full socket, but the runloop thread can't read data from the 
+    // socket because it has been interrupted by the signal handler).
+    
+    if (err == 0) {
+        err = MoreUNIXSetNonBlocking(gSignalSinkFD);
+    }
+
+    // Wrap the destination socket in a CFSocket, and create a 
+    // runloop source for it.  The associated callback (SignalCFSocketCallback) 
+    // receives information about the signal from the signal handler 
+    // and passes it along to the client's callback, but it's now in the context 
+    // of the runloop.
+    
+	if (err == 0) {
+		gSignalSourceCF = CFSocketCreateWithNative(
+			NULL,
+			signalSourceFD, 
+			kCFSocketCloseOnInvalidate | kCFSocketReadCallBack, 
+			SignalCFSocketCallback, 
+			NULL
+		);
+        if (gSignalSourceCF == NULL) {
+            err = EINVAL;
+        }
+	}
+	if (err == 0) {
+		CFRunLoopSourceRef	rls;
+		int					thisSigNum;
+
+		gClientCallback = callback;
+        gClientCallbackRefCon = refCon;
+		
+		rls = CFSocketCreateRunLoopSource(NULL, gSignalSourceCF, 0);
+        if (rls == NULL) {
+            err = EINVAL;
+        }
+
+		if (err == 0) {
+			CFRunLoopAddSource(runLoop, rls, runLoopMode);
+
+            // For each signal in the set, register our signal handler 
+            // (SignalToSocketHandler).  Specificy SA_SIGINFO so that 
+            // the handler gets lots of yummy signal information.
+            
+			for (thisSigNum = 1; thisSigNum < NSIG; thisSigNum++) {
+				if ( sigismember(sigSet, thisSigNum) ) {
+					struct sigaction newSignalAction;
+					
+					newSignalAction.sa_sigaction = SignalToSocketHandler;
+					newSignalAction.sa_flags = SA_SIGINFO;
+					sigemptyset(&newSignalAction.sa_mask);
+
+					junk = sigaction(thisSigNum, &newSignalAction, NULL);
+					assert(junk == 0);
+					
+					// Error recovery here would be hard.  We'd have to undo 
+					// any previous signal handlers that were installed 
+					// (requiring us to get the previous value and remembering 
+					// it) and then it would also require us to remove the 
+					// run loop source.  All-in-all, not worth the effort 
+					// given the very small chance of an error from sigaction.
+				}
+			}
+		}
+		
+        // We don't need the runloop source from here on, so release our 
+        // reference to it.  It still exists because the runloop knows about it.
+        
+        if (rls != NULL) {
+            CFRelease(rls);
+        }
+	}
+	
+	// Clean up.
+
+	if (err != 0) {
+		gClientCallback = NULL;
+		
+		if (gSignalSourceCF != NULL) {
+			CFSocketInvalidate(gSignalSourceCF);
+			CFRelease(gSignalSourceCF);
+			gSignalSourceCF = NULL;
+		}
+		
+		if (signalSourceFD != -1) {
+			junk = close(signalSourceFD);
+			assert(junk == 0);
+		}
+        
+        if (gSignalSinkFD != -1) {
+            junk = close(gSignalSinkFD);
+            assert(junk == 0);
+            
+            gSignalSinkFD = -1;
+        }
+	}
+	
+	return err;
+}
+#endif
+
+static char * SockAddrToString(int fd, Boolean peer)
+    // Gets either the socket name or the peer name from the socket 
+    // (depending on the peer parameter) and converts it to a human 
+    // readable string.  The caller is responsible for freeing the 
+    // memory.
+{
+    int			err;
+    char *		result;
+    size_t		resultLen;
+	struct sockaddr addr;
+    socklen_t	addrLen;
+    
+    addrLen = sizeof(addr);
+    
+    // Socket name, or peer name?
+    
+    if (peer) {
+        err = getpeername(fd, &addr, &addrLen);
+    } else {
+        err = getsockname(fd, &addr, &addrLen);
+    }
+    
+    // Convert the result to a string.
+    
+    if ( (err == -1) || (addrLen < offsetof(struct sockaddr, sa_data))) {
+        result = strdup("?");
+    } else {
+        char hostStr[NI_MAXHOST];
+        char servStr[NI_MAXSERV];
+        
+        assert(addrLen >= offsetof(struct sockaddr, sa_data));
+
+        err = getnameinfo(
+            &addr, 
+            addrLen, 
+            hostStr, 
+            sizeof(hostStr), 
+            servStr, 
+            sizeof(servStr), 
+            NI_NUMERICHOST | NI_NUMERICSERV
+        );
+        if (err == 0) {
+            // Cool.  getnameinfo did all the heavy lifting, so we just return the results.
+            
+            resultLen = strlen(hostStr) + 1 + strlen(servStr) + 1;
+            result = malloc(resultLen);
+            if (result != NULL) {
+                snprintf(result, resultLen, "%s %s", hostStr, servStr);
+            }
+        } else {
+            // Drat.  getnameinfo isn't helping out with this address, so we have to do it 
+            // all by hand.
+            
+            switch (addr.sa_family) {
+                case AF_UNIX:
+                    {
+                        struct sockaddr_un * unAddr;
+                        
+                        unAddr = (struct sockaddr_un *)&addr;
+                        result = strdup( unAddr->sun_path );
+                    }
+                    break;
+                default:
+                    assert(false);
+                    result = strdup("unrecognised address");
+                    break;
+            };
+        }
+    }
+                
+    return result;
+}
+
+static int
+fdtopath(int fd, char *buffer, size_t size)
+{
+#if HAVE_F_GETPATH            
+	return fcntl(fd, F_GETPATH, buffer);
+#else
+	char procbuf[MAXPATHLEN];
+	int n;
+
+	n = snprintf(procbuf, sizeof(procbuf), "/proc/self/fd/%d", fd);
+
+	if (n > 0) {
+		n = readlink(procbuf, buffer, size);
+		if (n > 0 && n <= size) {
+			buffer[n] = '\0';
+		}
+		return n;
+	} else {
+		return -1;
+	}
+#endif
+}
+
+extern void DebugPrintDescriptorTable(void)
+    // See comment in header.
+{
+    int			err;
+    int			descCount;
+    int			descIndex;
+    char		pathBuf[MAXPATHLEN];
+    int			sockType;
+    socklen_t	sockTypeLen;
+    static const char * kSockTypeToStr[] = {
+        "unknown    ",
+        "SOCK_STREAM",
+        "SOCK_DGRAM ",
+        "SOCK_RAW   ",
+        "SOCK_RDM   ",
+        "SOCK_SEQPACKET"            // not going to see this anyway, so don't need to pad everything else to this long length
+    };
+
+    fprintf(stderr, "Descriptors:\n");
+
+#if !defined(_WIN32)
+    descCount = getdtablesize();
+    for (descIndex = 0; descIndex < descCount; descIndex++) {
+        if ( fcntl(descIndex, F_GETFD, NULL) != -1 ) {
+
+            // Descriptor is active, let's try to find out what it is.
+
+            // See if we can get a file path from it.
+
+			err = fdtopath(descIndex, pathBuf, sizeof(pathBuf));
+
+            if (err != -1) {
+            
+                // If it's a file, print its path.
+                
+                fprintf(stderr, "  %2d file    '%s'\n", descIndex, pathBuf);
+            } else {
+            
+                // See if it's a socket.
+                
+                sockTypeLen = sizeof(sockType);
+                err = getsockopt(descIndex, SOL_SOCKET, SO_TYPE, &sockType, &sockTypeLen);
+                if (err != -1) {
+                    char *  localStr;
+                    char *  peerStr;
+                    const char *  sockTypeStr;
+
+                    // If it's a socket, print the local and remote address.
+                    
+                    localStr = NULL;
+                    peerStr  = NULL;
+                    
+                    localStr = SockAddrToString(descIndex, false);
+                    peerStr  = SockAddrToString(descIndex, true);
+
+                    if ( (sockType < 0) || (sockType > (sizeof(kSockTypeToStr) / sizeof(kSockTypeToStr[0]))) ) {
+                        sockTypeStr = kSockTypeToStr[0];
+                    } else {
+                        sockTypeStr = kSockTypeToStr[sockType];
+                    }
+                    if (sockTypeStr == kSockTypeToStr[0]) {
+                        fprintf(stderr, "  %2d socket  %s (%d) %s -> %s\n", descIndex, sockTypeStr, sockType, localStr, peerStr);
+                    } else {
+                        fprintf(stderr, "  %2d socket  %s %s -> %s\n", descIndex, sockTypeStr, localStr, peerStr);
+                    }
+                    
+                    free(localStr);
+                    free(peerStr);
+                } else {
+
+                    // No idea.
+
+                    fprintf(stderr, "  %2d unknown\n", descIndex);
+                }
+            }
+        }
+    }
+#endif
+}
+
+extern void InitPacketHeader(PacketHeader *packet, OSType packetType, size_t packetSize, Boolean rpc)
+    // See comment in header.
+{
+    static int sNextID = kPacketIDFirst;
+    
+    assert(packet != NULL);
+    assert(packetSize >= sizeof(PacketHeader));
+    
+    packet->fMagic = kPacketMagic;
+    packet->fType  = packetType;
+    if (rpc) {
+        // Increment to the next ID, skipping 0.
+        
+		packet->fID = sNextID;
+        sNextID += 1;
+        if (sNextID == kPacketIDNone) {
+            sNextID = kPacketIDFirst;
+        }
+    } else {
+        packet->fID = kPacketIDNone;
+    }
+    packet->fSize = packetSize;
+}
diff --git a/CoreFoundation/examples/CFLocalServer/Common.h b/CoreFoundation/examples/CFLocalServer/Common.h
new file mode 100644
index 0000000..964c686
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/Common.h
@@ -0,0 +1,153 @@
+/*
+ *    Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>
+ *    Copyright (c) 2009 Brent Fulgham <bfulgham@gmail.com>
+ *    All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the BSD-style license (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ */
+
+/*
+    File:       Common.h
+
+    Contains:   Common code between client and server.
+
+    Written by: DTS
+
+    Copyright:  Copyright (c) 2005 by Apple Computer, Inc., All Rights Reserved.
+
+    Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
+                ("Apple") in consideration of your agreement to the following terms, and your
+                use, installation, modification or redistribution of this Apple software
+                constitutes acceptance of these terms.  If you do not agree with these terms,
+                please do not use, install, modify or redistribute this Apple software.
+
+                In consideration of your agreement to abide by the following terms, and subject
+                to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+                copyrights in this original Apple software (the "Apple Software"), to use,
+                reproduce, modify and redistribute the Apple Software, with or without
+                modifications, in source and/or binary forms; provided that if you redistribute
+                the Apple Software in its entirety and without modifications, you must retain
+                this notice and the following text and disclaimers in all such redistributions of
+                the Apple Software.  Neither the name, trademarks, service marks or logos of
+                Apple Computer, Inc. may be used to endorse or promote products derived from the
+                Apple Software without specific prior written permission from Apple.  Except as
+                expressly stated in this notice, no other rights or licenses, express or implied,
+                are granted by Apple herein, including but not limited to any patent rights that
+                may be infringed by your derivative works or by other works in which the Apple
+                Software may be incorporated.
+
+                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
+                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+                COMBINATION WITH YOUR PRODUCTS.
+
+                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    Change History (most recent first):
+
+$Log: Common.h,v $
+Revision 1.1  2005/05/17 12:19:20         
+First checked in.
+
+
+*/
+
+#ifndef _COMMON_H
+#define _COMMON_H
+
+/////////////////////////////////////////////////////////////////
+
+// System interfaces
+
+#include <signal.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+// Project interfaces
+
+#include "Protocol.h"
+
+#if defined(_WIN32)
+// Windows doesn't understand UNIX sockets by default
+struct sockaddr_un
+{
+   unsigned char sun_len;
+   short sun_family;       // AF_UNIX
+   char  sun_path[108];
+};
+
+#define SUN_LEN(su) \
+   (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
+
+typedef int socklen_t
+typedef long ssize_t;
+#endif /* defined(_WIN32) */
+
+/////////////////////////////////////////////////////////////////
+
+extern int MoreUNIXErrno(int result);
+extern int MoreUNIXIgnoreSIGPIPE(void);
+extern int MoreUNIXRead( int fd,       void *buf, size_t bufSize, size_t *bytesRead   );
+extern int MoreUNIXWrite(int fd, const void *buf, size_t bufSize, size_t *bytesWritten);
+    // The above routines are taken from the MoreIsBetter library.
+
+extern int MoreUNIXSetNonBlocking(int fd);
+    
+#if !defined(_WIN32)
+typedef void (*SignalSocketCallback)(const siginfo_t *sigInfo, void *refCon);
+    // This callback is called when a signal occurs.  It's called in the 
+    // context of the runloop specified when you registered the callback.  
+    // sigInfo describes the signal and refCon is the value you supplied 
+    // when you registered the callback.
+
+extern int InstallSignalToSocket(
+	const sigset_t *		sigSet, 
+	CFRunLoopRef			runLoop,
+	CFStringRef				runLoopMode,
+	SignalSocketCallback	callback, 
+	void *					refCon
+);
+    // A method for routing signals to a runloop-based program. 
+    //
+    // sigSet is the set of signals that you're interested in. 
+    // Use the routines documented in <x-man-page://3/sigsetopts> 
+    // to construct this.
+    //
+    // runLoop and runLoopMode specify how you want the callback 
+    // to be run.  You typically pass CFRunLoopGetCurrent and 
+    // kCFRunLoopDefaultMode.
+    //
+    // callback is the routine you want called, and refCon is an 
+    // uninterpreted value that's passed to that callback.
+    //
+    // The function result is an errno-style error code.
+    //
+    // IMPORTANT:
+    // You can only call this routine once for any given application; 
+    // you must register all of the signals you're interested in at that 
+    // time.  There is no way to deregister.
+
+#endif
+
+extern void DebugPrintDescriptorTable(void);
+    // Prints a nice dump of the file descriptor table to stdout.
+
+extern void InitPacketHeader(PacketHeader *packet, OSType packetType, size_t packetSize, Boolean rpc);
+    // Initialises the PacketHeader structure with the values specified 
+    // in the parameters.  The rpc parameter controls whether the fID 
+    // field is set to kPacketIDNone (rpc false, hence no ID) or an 
+    // incrementing sequence number (rpc true).
+
+#endif
diff --git a/CoreFoundation/examples/CFLocalServer/Makefile.am b/CoreFoundation/examples/CFLocalServer/Makefile.am
new file mode 100644
index 0000000..606639b
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/Makefile.am
@@ -0,0 +1,16 @@
+AM_CFLAGS		= -I${top_srcdir}/include
+
+if CF_BUILD_TESTS
+check_PROGRAMS		= Client Server
+check_LTLIBRARIES	= libCommon.la
+endif
+
+Client_LDADD		= ${top_builddir}/libCoreFoundation.la libCommon.la
+Server_LDADD		= ${top_builddir}/libCoreFoundation.la libCommon.la
+
+Client_SOURCES		= Client.c
+Server_SOURCES		= Server.c
+
+libCommon_la_SOURCES	= Common.c
+
+noinst_HEADERS		= Common.h Protocol.h
diff --git a/CoreFoundation/examples/CFLocalServer/Makefile.in b/CoreFoundation/examples/CFLocalServer/Makefile.in
new file mode 100644
index 0000000..b846d21
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/Makefile.in
@@ -0,0 +1,493 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = Client$(EXEEXT) Server$(EXEEXT)
+subdir = examples/CFLocalServer
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+libCommon_la_LIBADD =
+am_libCommon_la_OBJECTS = Common.lo
+libCommon_la_OBJECTS = $(am_libCommon_la_OBJECTS)
+@CF_BUILD_TESTS_TRUE@am_libCommon_la_rpath =
+am_Client_OBJECTS = Client.$(OBJEXT)
+Client_OBJECTS = $(am_Client_OBJECTS)
+Client_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la \
+	libCommon.la
+am_Server_OBJECTS = Server.$(OBJEXT)
+Server_OBJECTS = $(am_Server_OBJECTS)
+Server_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la \
+	libCommon.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(libCommon_la_SOURCES) $(Client_SOURCES) $(Server_SOURCES)
+DIST_SOURCES = $(libCommon_la_SOURCES) $(Client_SOURCES) \
+	$(Server_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+@CF_BUILD_TESTS_TRUE@check_LTLIBRARIES = libCommon.la
+Client_LDADD = ${top_builddir}/libCoreFoundation.la libCommon.la
+Server_LDADD = ${top_builddir}/libCoreFoundation.la libCommon.la
+Client_SOURCES = Client.c
+Server_SOURCES = Server.c
+libCommon_la_SOURCES = Common.c
+noinst_HEADERS = Common.h Protocol.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/CFLocalServer/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/CFLocalServer/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkLTLIBRARIES:
+	-test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES)
+	@list='$(check_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libCommon.la: $(libCommon_la_OBJECTS) $(libCommon_la_DEPENDENCIES) 
+	$(LINK) $(am_libCommon_la_rpath) $(libCommon_la_OBJECTS) $(libCommon_la_LIBADD) $(LIBS)
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+Client$(EXEEXT): $(Client_OBJECTS) $(Client_DEPENDENCIES) 
+	@rm -f Client$(EXEEXT)
+	$(LINK) $(Client_OBJECTS) $(Client_LDADD) $(LIBS)
+Server$(EXEEXT): $(Server_OBJECTS) $(Server_DEPENDENCIES) 
+	@rm -f Server$(EXEEXT)
+	$(LINK) $(Server_OBJECTS) $(Server_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Client.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Common.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Server.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \
+	clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \
+	clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/CFLocalServer/Protocol.h b/CoreFoundation/examples/CFLocalServer/Protocol.h
new file mode 100644
index 0000000..9092232
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/Protocol.h
@@ -0,0 +1,196 @@
+/*
+ *    Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>
+ *    All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the BSD-style license (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ */
+
+/*
+    File:       Protocol.h
+
+    Contains:   Definition of the communication protocol between client and server.
+
+    Written by: DTS
+
+    Copyright:  Copyright (c) 2005 by Apple Computer, Inc., All Rights Reserved.
+
+    Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
+                ("Apple") in consideration of your agreement to the following terms, and your
+                use, installation, modification or redistribution of this Apple software
+                constitutes acceptance of these terms.  If you do not agree with these terms,
+                please do not use, install, modify or redistribute this Apple software.
+
+                In consideration of your agreement to abide by the following terms, and subject
+                to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+                copyrights in this original Apple software (the "Apple Software"), to use,
+                reproduce, modify and redistribute the Apple Software, with or without
+                modifications, in source and/or binary forms; provided that if you redistribute
+                the Apple Software in its entirety and without modifications, you must retain
+                this notice and the following text and disclaimers in all such redistributions of
+                the Apple Software.  Neither the name, trademarks, service marks or logos of
+                Apple Computer, Inc. may be used to endorse or promote products derived from the
+                Apple Software without specific prior written permission from Apple.  Except as
+                expressly stated in this notice, no other rights or licenses, express or implied,
+                are granted by Apple herein, including but not limited to any patent rights that
+                may be infringed by your derivative works or by other works in which the Apple
+                Software may be incorporated.
+
+                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
+                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+                COMBINATION WITH YOUR PRODUCTS.
+
+                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    Change History (most recent first):
+
+$Log: Protocol.h,v $
+Revision 1.1  2005/05/17 12:19:23         
+First checked in.
+
+
+*/
+
+#ifndef _PROTOCOL_H
+#define _PROTOCOL_H
+
+/////////////////////////////////////////////////////////////////
+
+// System interfaces
+
+#include <CoreFoundation/CoreFoundation.h>
+
+
+/////////////////////////////////////////////////////////////////
+
+// Packet types
+
+enum {
+    kPacketTypeGoodbye = 'GDBY',            // sent by client to server before signing off
+    kPacketTypeNOP     = 'NOOP',            // no operation, test for client/server RPC
+    kPacketTypeReply   = 'RPLY',            // all RPC replies are of this type
+    kPacketTypeWhisper = 'WSPR',            // client/server RPC to print message on server
+    kPacketTypeShout   = 'SHOU',            // sent by client to server, which echoes it to all listening clients
+    kPacketTypeListen  = 'LSTN',            // client/server RPC to register for shouts
+    kPacketTypeQuit    = 'QUIT'             // client/server RPC to tell server to quit
+};
+
+// Well known packet IDs (for the fID field of the packet header).
+// kPacketIDFirst is just a suggestion.  The server doesn't require 
+// that the client use sequential IDs starting from 1; the IDs are 
+// for the client to choose.  However, the use of kPacketIDNone for 
+// some packets (those that don't have a reply) is a hard requirement 
+// in the server.  
+
+enum {
+    kPacketIDNone  = 0,
+    kPacketIDFirst = 1
+};
+
+// kPacketMagic is first four bytes of every packet.  If the packet stream 
+// gets out of sync, this will quickly detect the problem.
+
+enum {
+    kPacketMagic = 'LSPM'               // for Local Server Packet Magic
+};
+
+// kPacketMaximumSize is an arbitrary limit, chosen so that we can detect 
+// if the packet streams get out of sync or if a client goes mad.
+
+enum {  
+    kPacketMaximumSize = 100 * 1024     // just basic sanity checks
+};
+
+// IMPORTANT:
+// The following structures define the packets sent between the client and 
+// the server.  For a network protocol you'd need to worry about byte ordering, 
+// but this isn't a network protocol (it always stays on the same machine) so 
+// I don't have to worry.  However, I do need to worry about having 
+// size invariant types (so that 32- and 64-bit clients and servers are 
+// all compatible) and structure alignment (so that code compiled by different 
+// compilers is compatible).  Size invariant types is easy, and represented 
+// by the structures below.  Alignment is trickier, and I'm mostly just 
+// glossing over the issue right now.
+
+// PacketHeader is the header at the front of every packet.
+
+typedef uint32_t FourCharCode;
+typedef FourCharCode OSType;
+
+struct PacketHeader {
+    OSType          fMagic;             // must be kPacketMagic
+    OSType          fType;              // kPacketTypeGoodbye etc 
+    int32_t         fID;                // kPacketIDNone or some other value
+    uint32_t        fSize;              // includes size of header itself
+};
+typedef struct PacketHeader PacketHeader;
+
+struct PacketGoodbye {                  // reply: n/a
+    PacketHeader    fHeader;            // fType is kPacketTypeGoodbye, fID must be kPacketIDNone
+    char            fMessage[32];       // Just for fun.
+};
+typedef struct PacketGoodbye PacketGoodbye;
+
+struct PacketNOP {                      // reply: PacketReply
+    PacketHeader    fHeader;            // fType is kPacketTypeNOP, fID echoed
+};
+typedef struct PacketNOP PacketNOP;
+
+struct PacketReply {                    // reply: n/a
+    PacketHeader    fHeader;            // fType is kPacketTypeReply, fID is ID of request
+    int32_t         fErr;               // result of operation, errno-style
+};
+typedef struct PacketReply PacketReply;
+
+struct PacketWhisper {                  // reply: PacketReply
+    PacketHeader    fHeader;            // fType is kPacketTypeWhisper, fID echoed
+    char            fMessage[32];       // message to print
+};
+typedef struct PacketWhisper PacketWhisper;
+
+struct PacketShout {                    // reply: none
+    PacketHeader    fHeader;            // fType is kPacketTypeShout, fID must be kPacketIDNone
+    char            fMessage[32];       // message for each of the clients
+};
+typedef struct PacketShout PacketShout;
+
+// Shouts are echoed to anyone who listens, including sender.
+
+struct PacketListen {                   // reply: PacketReply
+    PacketHeader    fHeader;            // fType is kPacketTypeListen, fID echoed
+};
+typedef struct PacketListen PacketListen;
+
+struct PacketQuit {                     // reply: PacketReply
+    PacketHeader    fHeader;            // fType is kPacketTypeQuit, fID echoed
+};
+typedef struct PacketQuit PacketQuit;
+
+// IMPORTANT:
+// The location of the kServerAddress socket file is intimately tied to the 
+// security of the server.  The file should be placed in a directory that's 
+// read access to everyone who needs access to the service, but only write 
+// accessible to the UID that's running the server.  Failure to follow this  
+// guideline may make your server subject to security exploits.
+//
+// To prevent this sort of silliness I require that the socket be created 
+// in a directory owned by the server's user ("com.apple.dts.CFLocalServer") 
+// within a directory that's sticky ("/var/tmp", not "/tmp" because that's 
+// periodically cleaned up). See SafeBindUnixDomainSocket (in "Server.c") for 
+// the details about how I achieve this.
+
+#define kServerSocketPath "/var/tmp/com.apple.dts.CFLocalServer/Socket"
+
+#endif
diff --git a/CoreFoundation/examples/CFLocalServer/README b/CoreFoundation/examples/CFLocalServer/README
new file mode 100644
index 0000000..ef5c692
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/README
@@ -0,0 +1,219 @@
+Read Me About CFLocalServer
+===========================
+1.2
+
+CFLocalServer is a sample that shows how to use UNIX domain sockets to communicate between client and server programs running on the same machine.  This sample was written specifically to show how a daemon can manage communication with multiple clients.  It supports RPC [1] communications (where the client makes a request to server and blocks waiting for a reply) and asynchronous notification (where the server sends messages to all clients).  It wraps each UNIX domain socket in a CFSocket to demonstrate the integration of UNIX domain sockets with a run-loop based program.
+
+CFLocalServer should work on all versions of Mac OS X, but it has been primarily tested on Mac OS X 10.4.x.
+
+[1] Remote Procedure Call
+
+About UNIX Domain Sockets
+-------------------------
+UNIX domain sockets are somewhat like TCP/IP sockets, except that the communication is always local to the computer.  You access UNIX domain sockets using the same BSD sockets API that you'd use for TCP/IP sockets.  The primary difference is the address format.  For TCP/IP sockets, the address structure (that which you pass to bind, connect, and so on) is (struct sockaddr_in), which contains a IP address and port number.  For UNIX domain sockets, the address structure is (struct sockaddr_un), which contains a path.
+
+When the server binds to a UNIX domain socket, the system creates a file system object that represents the socket.  For example, PPP's UNIX domain socket is /var/run/pppconfd.  When you look at this with "ls -l", you'll see the first character of the listing is "s", indicating that this object is a socket.
+
+$ ls -l /var/run/pppconfd 
+srwxrwxrwx  1 root  daemon  0  9 May 12:57 /var/run/pppconfd
+
+Once the server is running, the client can connect to it by simply passing this path to the connect call.  Once the connection is in place, communication proceeds as it would for TCP/IP sockets.
+
+To learn more about UNIX domain sockets, consult any standard UNIX reference.  I particularly recommend "UNIX Network Programming" by Stevens.
+
+Why UNIX Domain Sockets?
+------------------------
+Mac OS X has numerous inter-process communications (IPC) APIs.  When implementing a daemon, the UNIX domain sockets API offers a number of advantages over other IPC mechanisms.
+
+o Compared to TCP/IP, it guarantees that only processes running on your local machine can connect to your server.  You can also get this guarantee with TCP/IP, but it requires extra work.
+
+o Compared to Apple events, it works on all versions of Mac OS X (there are problems using Apple events from a daemon prior to Mac OS X 10.2).  Also, it's a connection-oriented API, so the server automatically learns about the death of a client and it's easy for the server to asynchronously notify the client.
+
+o Compared to Mach messages (and any high-level wrappers, like CFMessagePort), it eliminates any Mach bootstrap port namespace concerns.  Also, when you use Mach messages, you have to do extra work for the server to be notified when a client dies unexpectedly.
+
+o It can be easily integrated into any server architecture, including those based on threads, a runloop (using CFSocket), a select loop, or kqueues.
+
+o It is a well known POSIX API with numerous sources of good documentation.
+
+o Source code based on UNIX domain sockets code is portable to other POSIX platforms.
+
+Packing List
+------------
+The sample contains the following items:
+
+o Read Me About CFLocalServer.txt -- This document.
+o CFLocalServer.xcodeproj -- An Xcode 2.1 project that builds the sample.
+o CFLocalServer.xcode -- An Xcode 1.5 project that builds the sample.
+o Server.c -- Source code for the server.
+o Client.c -- Source code for the client.
+o Protocol.h -- Definitions for the client/server communication protocol.
+o Common.h -- Interface to the common utilities.
+o Common.c -- Implementation of the common utilities.
+o build -- A directory containing pre-built versions of the client and server.
+
+Using the Sample
+----------------
+To try out CFLocalServer, first open a Terminal window, change into the "build" directory, and then run the server.
+
+server$ ./CFLocalServer
+CFLocalServer: Starting up (pid: 2764).
+
+The server will continue running until you tell it to quit by either typing ^C or  sending it a "quit" command from one of the clients.
+
+To start a client, open a new Terminal window, change into the build directory, and then run the client as shown below.
+
+client$ ./CFLocalClient nop
+       nop
+
+The client arguments represent commands to send to the server.  In this case the "nop" command does nothing; it simply tests the RPC path between the client and the server.  If you look at the server window you'll see that the server has printed something like:
+
+0x500da0: NOP
+ClientGotSpace: Client 0x500da0 lifted write-side flow control.
+
+The first line is a record of the "nop" command.  The second is a debugging message which isn't particularly relevant to this example.
+
+The client supports a number of other commands.  You can see a list by running the client with no arguments.
+
+client$ ./CFLocalClient 
+usage: CFLocalClient command...
+       commands: nop
+                 whisper <message>
+                 shout   <message>
+                 listen  (must be last)
+                 quit
+
+The "quit" command tells the server to quit.  The "whisper" command tells the server to print <message>.  The "shout" and "listen" commands are used to demonstrate asynchronous server-to-client notification.  To see this in action, open a third terminal window and run the "listen" command in that.
+
+listener$ ./CFLocalClient listen
+    listen Press ^C to quit.
+
+This starts the client and tells it to listen for messages from the server.  These messages are asynchronous; the server generates the message internally and sends it to all listening clients.
+
+To send an asynchronous notification message, execute the "shout" command on the first client.
+
+$ ./CFLocalClient shout 'Hello Cruel World!'
+     shout "Hello Cruel World!"
+
+On the server you'll see the following, indicating that the server got the "shout" command:
+
+0x501060: Shout   "Hello Cruel World!"
+
+On the listening client you'll see the following:
+
+listener$ ./CFLocalClient listen
+    listen Press ^C to quit.
+           heard "Hello Cruel World!"
+
+You can run multiple listeners, and each will see this message.
+
+If you want to examine the state of the server, you can send it a SIGINFO signal.
+
+client$ kill -INFO 2764
+
+The server will then dump its current state, as shown in the example below.
+
+CFLocalServer State
+-------------------
+Clients:
+  Client 0x500da0:
+    fSockFD            = 8
+    fSockCF            = 0x500f80
+    fRunLoopSource     = 0x500e90
+    fBufferedData      = 0x500df0 (count: 0)
+    fPendingSends      = 0x500e20 (count: 0)
+    fPendingSendOffset = 0
+    fListening         = true
+
+Descriptors:
+   0 file    '/dev/ttyp2'
+   1 file    '/dev/ttyp2'
+   2 file    '/dev/ttyp2'
+   3 socket  SOCK_STREAM ? -> ?
+   4 socket  SOCK_STREAM ? -> ?
+   5 socket  SOCK_DGRAM  ? -> ?
+   6 socket  SOCK_DGRAM  ? -> ?
+   7 socket  SOCK_STREAM /var/tmp/com.apple.dts.CFLocalServer/Socket -> ?
+   8 socket  SOCK_STREAM /var/tmp/com.apple.dts.CFLocalServer/Socket -> ?
+
+Building the Sample
+-------------------
+The sample was built on Mac OS X 10.4.x using Xcode 2.1.  To build the project, open the project and choose Build from the Build menu.  There is nothing inherently 10.4-specific about this sample, and it should work all the way back to Mac OS X 10.1.
+
+How it Works
+------------
+The client and server communicate by exchanging messages, known as packets.  All packets start with a header, with four fields:
+
+o fMagic is always kPacketMagic, which allows me to quickly detect any communications problems
+
+o fType is the packet type; for example, a value of kPacketTypeNOP represents a "nop" command
+
+o fID is a sequence number designed to allow the client to match up requests with replies; kPacketIDNone is used for non-RPC messages; any other value is used for RPC requests; for RPC requests, the server always sends the reply with an fID that matches the fID of the request; currently a client connection can only be used for RPC or for asynchronous messages (not both), so this matching of request and reply is not really needed
+
+o fSize is the overall size of the packet, including the header
+
+Data after the fSize field is packet-type specific.
+
+The client is made up of two logically separate components: the connection abstraction and the command line tool.  The command line tool is simply the UI of the client; it parses arguments and prints results.  It doesn't know anything about UNIX domain sockets.  It does all of its work via the connection abstraction.
+
+The connection abstraction is a set of routines that are called by the command line tool to connect to the server (ConnectionOpen), send RPC requests (ConnectionRPC), and so on.  The connection abstraction is basically a big wrapper around a UNIX domain socket.  ConnectionOpen opens a connection to the server by calling socket <x-man-page://2/socket>, to create the socket, and connect <x-man-page://2/connect>, to connect it.  ConnectionRPC uses write <x-man-page://2/write> to send the request and read <x-man-page://2/read> to receive the response.
+
+The most complex part of the client relates to listening.  This performs two actions.  Firstly, it sends a "listen" command to the server, to tell the server that this client has switched away from RPC mode and is now listening for asynchronous messages.  Secondly, it calls the connection abstraction to schedule this socket with the runloop (ConnectionRegisterListener) and then runs the runloop.  When data arrives, the connection abstraction (ConnectionGotData) is called by CFSocket, and it in turn calls the tool's packet handler (GotPacket).
+
+The server is also divided into two logical components.  The first is the server framework, which is responsible for creating a listening socket, scheduling that socket with the runloop, and running the runloop to accept new connections.  When it gets a new connection (ListeningSocketAcceptCallback), it calls the second layer, client state management, to create (ClientCreate) a new client record (of type ClientState).  This client record tracks the state of the client.  The client state management layer maintains a global set of client records (gClients), one for each connected client.  Once a client has been created, it can do a bunch of different things.
+
+o If the client sends data to the server, CFSocket calls the client state management's socket callback (ClientEvent) with the kCFSocketDataCallBack event.  This calls ClientGotData, which attempts to receive a packet from the client.  If the new data doesn't represent a full packet, the client state management layer buffers the data (in fBufferedData) and waits for more data to arrive.  If the new data does represent a whole packet (or completes a previously buffered packet), the client state management layer processes that packet.
+
+o If the client sends the server any form of a bogus packet, the server destroys the client record (ClientDestroy).
+
+o If the server needs to send data to the client, it places the data in the fPendingSends buffer and then calls the transmission routine (ClientSendPending).  That either sends all of the data, or it fails with an error.  If the error indicates write-side flow control (that is, the client has stopped receiving data and the socket buffer is full, causing write to return EAGAIN), the client state management layer tells CFSocket that it wants to be notified when the flow control is lifted, and returns.  If it gets any other error, it just destroys the client.
+
+o If a flow controlled client starts receiving data again, CFSocket calls the client state management's socket callback (ClientEvent) with the kCFSocketWriteCallBack event.  This calls ClientGotSpace, which tries to send any pending data to the client.
+
+o If the amount of data waiting to be sent to the client exceeds a certain threshold (100 messages, kClientMaximumPendingSends), the server assumes that the client has gone permanently deaf and destroys the client.
+
+o If a client goes away in an orderly fashion, it sends the server a "goodbye" packet.  The server responds by destroying the client.
+
+o If a client dies unexpectedly, CFSocket notifies the client state management layer by telling it that no data is available from the client.  ClientGotData detects this and destroys the client.
+
+Caveats
+-------
+This is a sample of client/server communications using UNIX domain sockets wrapped in CFSockets.  Client/server communication is a critical part of writing a daemon, but it is not the only part.  To write a fully fledged daemon, you must organise to launch the daemon (typically this is done using launchd <x-man-page://8/launchd> on 10.4 and later, or from a startup item on earlier systems) and you must implement proper logging (using ASL <x-man-page://3/asl> on 10.4 and later, or syslog <x-man-page://3/syslog> on earlier systems).
+
+The sample does not support communication between 32- and 64-bit processes.  This is primarily because CFSocket is not supported for 64-bit programs.  However, even if that was addressed, you'd have to modify the sample to ensure that the structures used in the communication were 64-bit invariant.  See the comments in "Protocol.h" for more details.
+
+As it's currently written, the sample is not endian neutral; the server and all its clients must use the same endian flavour.  Thus, for example, on a Developer Transition System, you can't run a native server and connect to it from a PowerPC program being executed by Rosetta.  It would be easy to modify the sample to support this (you just have to decide on a standard endianess, and byte swap the multibyte fields of the structures defined in "Protocol.h"), but I decided against doing this because a) mixed-endian code on the /same machine/ is pretty unusual, and b) it obscures the primary goal of the sample.
+
+In the current architecture, each connection between the client and the server is used either for RPC or for asynchronous notification, but never for both.  If you want a client that does both, you need to open two connections.  This design simplifies the RPC code (it doesn't have to worry about asynchronous notification messages being mixed in with an RPC reply), but it is somewhat wasteful of resources.
+
+The current implementation is not tuned for performance.  For example, the server's packet reception loop will often make unnecessary copies of the packet data.  If you adapt this sample to a performance critical application, you will have to profile the code and optimise its algorithms.
+
+Credits and Version History
+---------------------------
+If you find any problems with this sample, mail <dts@apple.com> and I'll try to fix them up.
+
+1.0 (May 2005) was the first shipping version.
+
+1.1 (Jun 2005) corrected a bug where the packet's fID field wasn't being initialised in the RPC case.
+
+1.2 (Jul 2005) updated to include an Xcode 2.1 project to produce universal binaries; there were no code changes required for it to run correctly on the Developer Transition Systems.
+
+Share and Enjoy.
+
+Apple Developer Technical Support
+Networking, Communications, Hardware
+
+20 Jul 2005
+
+$Log: Read\040Me\040About\040CFLocalServer.txt,v $
+Revision 1.4  2005/07/20 14:24:57         
+Updated to discuss the issues associated with building a universal binary.
+
+Revision 1.3  2005/06/30 20:27:15         
+Updated for version 1.1.
+
+Revision 1.2  2005/05/18 13:36:32         
+Fixed various documentation/comment changes.
+
+Revision 1.1  2005/05/17 12:19:27         
+First checked in.
+
diff --git a/CoreFoundation/examples/CFLocalServer/Server.c b/CoreFoundation/examples/CFLocalServer/Server.c
new file mode 100644
index 0000000..c713392
--- /dev/null
+++ b/CoreFoundation/examples/CFLocalServer/Server.c
@@ -0,0 +1,1501 @@
+/*
+ *    Copyright (c) 2009 Grant Erickson <gerickson@nuovations.com>
+ *    All rights reserved.
+ */
+
+/*
+    File:       Server.c
+
+    Contains:   Server showing integration of CFSockets and UNIX domain sockets.
+
+    Written by: DTS
+
+    Copyright:  Copyright (c) 2005 by Apple Computer, Inc., All Rights Reserved.
+
+    Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
+                ("Apple") in consideration of your agreement to the following terms, and your
+                use, installation, modification or redistribution of this Apple software
+                constitutes acceptance of these terms.  If you do not agree with these terms,
+                please do not use, install, modify or redistribute this Apple software.
+
+                In consideration of your agreement to abide by the following terms, and subject
+                to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+                copyrights in this original Apple software (the "Apple Software"), to use,
+                reproduce, modify and redistribute the Apple Software, with or without
+                modifications, in source and/or binary forms; provided that if you redistribute
+                the Apple Software in its entirety and without modifications, you must retain
+                this notice and the following text and disclaimers in all such redistributions of
+                the Apple Software.  Neither the name, trademarks, service marks or logos of
+                Apple Computer, Inc. may be used to endorse or promote products derived from the
+                Apple Software without specific prior written permission from Apple.  Except as
+                expressly stated in this notice, no other rights or licenses, express or implied,
+                are granted by Apple herein, including but not limited to any patent rights that
+                may be infringed by your derivative works or by other works in which the Apple
+                Software may be incorporated.
+
+                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
+                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+                COMBINATION WITH YOUR PRODUCTS.
+
+                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    Change History (most recent first):
+
+$Log: Server.c,v $
+Revision 1.2  2005/05/18 13:36:39         
+Fixed various documentation/comment changes.
+
+Revision 1.1  2005/05/17 12:19:32         
+First checked in.
+
+
+*/
+
+/////////////////////////////////////////////////////////////////
+
+// System interfaces
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include <stdlib.h>
+#include <assert.h>
+#include <signal.h>
+
+#if defined(WIN32)
+#include <errno.h>
+#define ECANCELED 15
+
+#include <stdio.h>
+#define snprintf _snprintf
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+
+#define PRId32 "d"
+#define PRIu32 "u"
+
+typedef uint16_t mode_t;
+
+#else
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/signal.h>
+#endif
+
+// Project interfaces
+
+#include "Protocol.h"
+#include "Common.h"
+
+/////////////////////////////////////////////////////////////////
+#pragma mark ***** Client State Management
+
+// The server maintains a ClientState structure to track the state of 
+// each client.  This state divides neatly into three groups.
+//
+// o socket -- fSockFD, fSockCF, and fRunLoopSource all represent different 
+//   aspects of the UNIX domain socket that we're using to talk to the client.
+//
+// o incoming -- fBufferedData is a buffer containing any incomplete packets that 
+//   we've received from the client.
+//
+// o outgoing -- fPendingSends and fPendingSendOffset control the packets that 
+//   are waiting to be sent to the client.  This list might get long if the 
+//   client stops listening to us.  Packets will first back up in the UNIX 
+//   domain socket's socket buffer.  Once that fills up we won't be able to 
+//   write to the socket anymore.  We respond to that by buffering the 
+//   packets on the fPendingSends list.  We also tell CFSocket to let us know 
+//   (with a kCFSocketWriteCallBack event) if space becomes available.
+//
+//   At this point one of two things will happen.  Either we'll buffer too 
+//   many packets for the client (kClientMaximumPendingSends) in which case 
+//   we'll kill the client.  Or the client will start receiving packets again, 
+//   which will start to empty the socket buffer.  CFSocket will tells about 
+//   this by sending us a kCFSocketWriteCallBack event, and we'll start 
+//   pulling packets off the fPendingSends list and writing them to the socket.
+
+enum {
+    kClientStateMagic = 'LSCM'               // for Local Server Client Magic
+};
+
+struct ClientState {
+    OSType              fMagic;             // kClientStateMagic
+    int                 fSockFD;            // UNIX domain socket to client
+    CFSocketRef         fSockCF;            // CFSocket wrapper for the above
+    CFRunLoopSourceRef  fRunLoopSource;     // runloop source for the above
+    CFMutableDataRef    fBufferedData;      // buffers data for incomplete incoming packets
+    CFMutableArrayRef   fPendingSends;      // list of packets waiting to be sent
+    size_t              fPendingSendOffset; // offset of next byte to send in first packet on list
+    Boolean             fListening;         // true if this client is a listener
+};
+typedef struct ClientState ClientState;
+
+// To prevent a deaf client from sucking down all of our memory, we limit the 
+// number of packets that we'll buffer for a given client.  If the length of 
+// fPendingSends exceeds kClientMaximumPendingSends, we'll kill the client rather 
+// than queue more data.
+
+enum {
+    kClientMaximumPendingSends = 100
+};
+
+// gClients is a set of all clients we know about.
+
+static CFMutableSetRef gClients = NULL;		// of (ClientState *)
+
+#pragma mark Misc
+
+static Boolean ClientCheckPacketSize(ClientState *client, const PacketHeader *packet, size_t requiredSize)
+    // Checks that a packet that has arrived from a client is of the 
+    // appropriate size.  Returns false, and prints a message, if it isn't.
+{
+    Boolean result;
+    
+    assert(client != NULL);
+    assert(packet != NULL);
+    assert(requiredSize >= sizeof(PacketHeader));
+    
+    result = true;
+    if (packet->fSize != requiredSize) {
+        fprintf(
+            stderr, 
+            "ClientCheckPacketSize: Client %p sent us a '%.4s' of the wrong size (got %" PRIu32 ", wanted %zu).\n", 
+            client, 
+            (char *) &packet->fType, 
+            packet->fSize, 
+            requiredSize
+        );
+        result = false;
+    }
+    return result;
+}
+
+static Boolean ClientCheckPacketID(ClientState *client, const PacketHeader *packet, int32_t requiredID)
+    // Checks that a packet that has arrived from a client has the 
+    // correct ID.  Returns false, and prints a message, if it doesn't.
+{
+    Boolean result;
+
+    assert(client != NULL);
+    assert(packet != NULL);
+    
+    result = true;
+    if (packet->fID != requiredID) {
+        fprintf(
+            stderr, 
+            "ClientCheckPacketID: Client %p sent us a '%.4s' with the wrong ID (got %" PRId32 ", wanted %" PRId32 ").\n", 
+            client, 
+            (char *) &packet->fType, 
+            packet->fID, 
+            requiredID
+        );
+        result = false;
+    }
+    return result;
+}
+
+// Forward declarations
+
+static void ClientGotSpace(ClientState *client);
+static void ClientGotData(ClientState *client, const void *data);
+
+static void ClientEvent(
+    CFSocketRef             s, 
+    CFSocketCallBackType    type, 
+    CFDataRef               address, 
+    const void *            data, 
+    void *                  info
+)
+	// This is the CFSocket event callback for client sockets.  For a description 
+	// of the parameters, see the CFSocket documentation.
+	//
+	// This routine responds to two events, kCFSocketDataCallBack and 
+	// kCFSocketWriteCallBack, dispatching them to ClientGotData and 
+	// ClientGotSpace, respectively.
+{
+	ClientState *	client;
+	
+	(void)address;
+    assert(s != NULL);
+
+    client = (ClientState *) info;
+    assert(client != NULL);
+    assert(client->fMagic == kClientStateMagic);
+    
+    switch (type) {
+        case kCFSocketDataCallBack:
+            ClientGotData(client, data);
+            break;
+        case kCFSocketWriteCallBack:
+            ClientGotSpace(client);
+            break;
+        default:
+            assert(false);
+            break;
+    }
+}
+
+#pragma mark Create/Destroy
+
+static void ClientDestroy(ClientState *client);
+
+static int ClientInitialise(void)
+	// Initialises the client management layer, which simply involves 
+	// creating an empty gClients set.
+{
+	int err;
+	
+	err = 0;
+	gClients = CFSetCreateMutable(NULL, 0, NULL);
+	if (gClients == NULL) {
+		err = ENOMEM;
+	}
+	return err;
+}
+
+static void ClientTerminate(void)
+	// Shuts down the client management layer.  This involves destroying 
+	// any remaining clients and disposing of gClients.
+{
+	CFIndex             clientCount;
+	CFIndex             clientIndex;
+	ClientState **      allClients;
+
+    if (gClients != NULL) {
+		// Can't use CFSetApplyFunction because the ClientDestroy modifies 
+		// the gClients set.
+		
+		clientCount = CFSetGetCount(gClients);
+		
+		allClients = calloc(clientCount, sizeof(ClientState *));
+		if (allClients == NULL) {
+			fprintf(stderr, "CFLocalServer: Could not clean up clients because we couldn't allocate memory.\n");
+		} else {
+			CFSetGetValues(gClients, (const void **) allClients);
+			
+			for (clientIndex = 0; clientIndex < clientCount; clientIndex++) {
+				fprintf(stderr, "CFLocalServer: Client %p killed because we're quitting.\n", allClients[clientIndex]);
+
+				ClientDestroy( allClients[clientIndex] );
+			}
+		}
+
+		free(allClients);
+		
+		CFRelease(gClients);
+		gClients = NULL;
+    }
+}
+
+static int ClientCreate(int clientSockFD, ClientState **clientPtr)
+    // Creates a new client that communicates over clientSockFD. 
+    // If clientPtr is not NULL, it returns a pointer to the 
+    // client state record in *clientPtr.
+    //
+    // clientSockFD must be a valid file descriptor referencing a 
+    // socket that's connected to the client
+    // On input, if clientPtr is not NULL, *clientPtr must be NULL
+    // Returns an errno-style error code
+    // On success, if clientPtr is not NULL, *clientPtr will not be NULL
+    // On success, clientSockFD is owned by the new client; the caller 
+    // need not close it
+    // On error, if clientPtr is not NULL, *clientPtr will be NULL
+    // On error, clientSockFD will have been closed.
+    //
+    // IMPORTANT:
+    // Regardless of whether this routine succeeds or fails, it assumes 
+    // responsibility for clientSockFD.  The caller is never required to 
+    // close it.
+{
+    int             err;
+    int             junk;
+    ClientState *   client;
+    
+    assert( (clientPtr == NULL) || (*clientPtr == NULL) );
+    
+    assert(gClients != NULL);
+    
+    // Create the client state record.
+    
+    err = 0;
+    client = (ClientState *) calloc(1, sizeof(*client));
+    if (client == NULL) {
+        err = ENOMEM;
+    }
+
+    // Fill in the easy fields.  This also prepares us for the clean up 
+    // on failure.
+    
+    if (err == 0) {
+        client->fMagic = kClientStateMagic;
+
+        // For clean up to work properly, we must make sure that, if 
+        // the connection record is allocated successfully, we always 
+        // set fSockFD to the incoming clientSockFD.
+
+        client->fSockFD = clientSockFD;
+        
+        client->fBufferedData = CFDataCreateMutable(NULL, 0);
+        client->fPendingSends = CFArrayCreateMutable(NULL, 0, NULL);
+
+        if ( (client->fBufferedData == NULL) || (client->fPendingSends == NULL) ) {
+            err = ENOMEM;
+        }
+    }
+    
+    // Make the socket non-blocking.  We need to do this because 
+    // otherwise ClientSendPending can get stuck in a write.
+    
+    if (err == 0) {
+        err = MoreUNIXSetNonBlocking(client->fSockFD);
+    }
+    
+    // Wrap the socket in a CFSocket, and create and install the run loop source.
+    
+    if (err == 0) {
+        CFSocketContext context;
+        
+        memset(&context, 0, sizeof(context));
+        context.info = client;
+        
+        client->fSockCF = CFSocketCreateWithNative(
+            NULL, 
+            (CFSocketNativeHandle) client->fSockFD, 
+            kCFSocketDataCallBack + kCFSocketWriteCallBack, 
+            ClientEvent, 
+            &context
+        );
+        if (client->fSockCF == NULL) {
+            err = EINVAL;
+        }
+    }
+
+    if (err == 0) {
+        client->fRunLoopSource = CFSocketCreateRunLoopSource(NULL, client->fSockCF, 0);
+        if (client->fRunLoopSource == NULL) {
+            err = EINVAL;
+        }
+    }
+    if (err == 0) {
+        CFRunLoopAddSource( CFRunLoopGetCurrent(), client->fRunLoopSource, kCFRunLoopDefaultMode);
+        
+        assert( ! CFSetContainsValue(gClients, client) );
+        
+        // It's all good.  Record that this client exists.
+        
+        CFSetAddValue(gClients, client);
+    }
+    
+    // Clean up.
+    
+    if (err != 0) {
+        fprintf(stderr, "ClientCreate: Error %d creating client.\n", err);
+
+        // If client is NULL, we couldn't allocate a client record, therefore 
+        // we had nowhere to record clientSockFD, therefore ClientDestroy won't 
+        // clean it up.  Thus, we have to do it ourselves.
+        
+        if (client == NULL) {
+            junk = close(clientSockFD);
+            assert(junk == 0);
+        } else {
+            ClientDestroy(client);
+        }
+        client = NULL;
+    }
+    if (clientPtr != NULL) {
+        *clientPtr = client;
+    }
+    
+    assert( (clientPtr == NULL) || ((err == 0) == (*clientPtr != NULL)) );
+
+    return err;
+}
+
+static void ClientDestroy(ClientState *client)
+    // Destroys a client.  This is called in a number of different circumstances, 
+    // but these basically boil down to:
+    // 
+    // a) if ClientCreate fails, it's called to destroy the partially-created client, 
+    // b) if some sort of communications error happens, it's called to destroy the 
+    //    client,
+    // c) if the client sends us a goodbye packet, this is called to destroy the client, and 
+    // d) on quit, all clients are destroyed.
+{
+    int     junk;
+    
+    assert(client != NULL);
+    assert(client->fMagic == kClientStateMagic);
+
+    // This following assert is NOT true.  If the client dies before it 
+    // gets fully started (that is, we get an error halfway through 
+    // ClientCreate), ClientDestroy is called to tidy up the mess but 
+    // the client hasn't been added into gClients yet.
+    
+    // assert( CFSetContainsValue(gClients, client) );
+    
+    // Remove the client our record of existant clients.
+    
+    CFSetRemoveValue(gClients, client);
+    
+    // Clean up the runloop source and CFSocket.
+    
+    if (client->fRunLoopSource != NULL) {
+        CFRunLoopSourceInvalidate(client->fRunLoopSource);
+        
+        CFRelease(client->fRunLoopSource);
+    }
+    if (client->fSockCF != NULL) {
+        CFSocketInvalidate(client->fSockCF);
+        
+        CFRelease(client->fSockCF);
+    }
+    
+    // Close the socket itself, but only if we don't have a corresponding 
+    // CFSocket; if a CFSocket was created, it takes over responsibility 
+    // for closing the socket.
+    
+    if ( (client->fSockFD != -1) && (client->fSockCF == NULL) ) {
+        junk = close(client->fSockFD);
+        assert(junk == 0);
+    }
+    
+    // Free any packets waiting to go out to this client.
+    
+    if (client->fPendingSends != NULL) {
+        CFIndex index;
+        CFIndex count;
+
+        count = CFArrayGetCount(client->fPendingSends);
+        for (index = 0; index < count; index++) {
+            free( (void *) CFArrayGetValueAtIndex(client->fPendingSends, index) );
+        }
+        CFRelease(client->fPendingSends);
+    }
+    
+    // Free any buffered data from this client.
+    
+    if (client->fBufferedData != NULL) {
+        CFRelease(client->fBufferedData);
+    }
+    
+    // Free the client state record itself.
+    
+    client->fMagic = 'FRE!';
+    free(client);
+}
+
+#pragma mark Send
+
+static int ClientSendPending(ClientState *client)
+    // This routine attempts to send any packets that are queued in the fSendPending 
+    // array.  It is somewhat complex.  There are three possible final results.
+    //
+    // o It successfully sends all packets in the queue.  In this case it returns 0.
+    //
+    // o The write side of the socket is full (flow controlled).  In this case the 
+    //   function enables the socket write callback (kCFSocketWriteCallBack, using 
+    //   CFSocketEnableCallBacks) and returns 0.  When socket buffer empties a little, 
+    //   CFSocket will send us the kCFSocketWriteCallBack event and we'll resume sending.
+    //
+    // o It fails for some other reasons (for example, the other end of the socket has 
+    //   been closed, causing an EPIPE).  In this case it returns an errno-style error 
+    //   indicating the failure.  The caller typically responds by destroying the client.
+    //
+    // This whole process is further complicated by the possibilty that the socket 
+    // buffer might have enough space for half a packet.  In this case you'll get a 
+    // short write, that is, write will return a positive number less than its nbytes 
+    // parameter.  To handle this case we record the offset into the packet of the first 
+    // byte of unwritten data.  When we go to send a packet, we always send from there. 
+    // When write accepts some data, we bump the offset by that amount.  If that 
+    // completes the send of the packet, we start on next packet, resetting the offset 
+    // back to 0.
+{
+    int                     err;
+    Boolean                 done;
+    const PacketHeader *    thisPacket;
+    ssize_t                 bytesWritten;
+    
+    err = 0;
+    
+    // Keep going until we've sent all pending packets for this client.
+    
+    while ( (err == 0) && (CFArrayGetCount(client->fPendingSends) != 0) ) {
+        thisPacket = (const PacketHeader *) CFArrayGetValueAtIndex(client->fPendingSends, 0);
+        
+        // Try to send this packet by writing it to the socket.
+        
+        done = false;
+        do {
+            bytesWritten = write(
+                client->fSockFD, 
+                ((char *) thisPacket) + client->fPendingSendOffset, 
+                thisPacket->fSize - client->fPendingSendOffset
+            );
+            
+            if (bytesWritten > 0) {
+                // We're written some bytes.  Adjust fPendingSendOffset by 
+                // that amount and see if that completes the packet.
+                
+                client->fPendingSendOffset += bytesWritten;
+                
+                if (client->fPendingSendOffset == thisPacket->fSize) {
+                    // Packet complete.  Delete it from the head of the 
+                    // send list, reset offset back to 0, and let's go 
+                    // deal with the next packet.
+                    
+                    CFArrayRemoveValueAtIndex(client->fPendingSends, 0);
+                    free( (void *) thisPacket);
+                    client->fPendingSendOffset = 0;
+                    done = true;
+                } else {
+                    // Packet still not fully sent.  The send offset has already 
+                    // been updated, so we just loop to try again.
+                }
+            } else if (bytesWritten == -1) {
+                // We got some sort of error.
+                
+                err = errno;
+                switch (err) {
+                    case EINTR:
+                        // Interrupted.  Do nothing, so we loop and retry this 
+                        // send immediately.
+
+                        err = 0;
+                        break;
+                    case EAGAIN:
+                        // Flow controlled.  Break out of the loop with an EAGAIN 
+                        // error; we try again when space becomes available.
+
+                        fprintf(stderr, "ClientSendPending: Client %p write-side flow control.\n", client);
+                        
+                        // Tell the CFSocket that we now /really/ need to be told about 
+                        // write space becoming available.  Without this we'll never 
+                        // recover if the client stops accepting messages temporarily 
+                        // (which causes the socket buffer to fill up and us to get an 
+                        // EAGAIN) and then starts accepting messages again.  At that 
+                        // point the client will drain the socket buffer, but we'll never 
+                        // hear about it because CFSocket doesn't know that we care 
+                        // about write space.  With this call CFSocket knows that we 
+                        // care, and will send us an kCFSocketWriteCallBack event if 
+                        // space becomes available in the socket buffer.
+                        
+                        CFSocketEnableCallBacks(client->fSockCF, kCFSocketWriteCallBack);
+                        break;
+                    default:
+                        // Errored.  Our response is typically draconian: 
+                        // we return the error to our caller, which then kills the client 
+                        // completely.
+                    
+                        fprintf(stderr, "ClientSendPending: Client %p killed because of send error (%d).\n", client, err);
+                        break;
+                }
+            } else {
+                assert(false);
+            }
+        } while ( (err == 0) && ! done );
+    }
+    
+    // As far as the caller is concerned, write-side flow control is not an error.
+    
+    if (err == EAGAIN) {
+        err = 0;
+    }
+    
+    return err;
+}
+
+static Boolean ClientSend(ClientState *client, const PacketHeader *packet)
+    // Called in various places to send a packet to a client.  
+    // This adds it to the send queue and then calls ClientSendPending 
+    // to attempt a send.
+{
+    Boolean         result;
+    PacketHeader *  copiedPacket;
+    
+    assert(client != NULL);
+    assert(packet != NULL);
+    assert(packet->fSize >= sizeof(PacketHeader));
+
+    // If we've buffered kClientMaximumPendingSends already, the client is 
+    // just not reading them.  To avoid us consuming all of our memory buffering 
+    // packets for a deaf client, we just kill the client.
+    
+    result = true;
+    if ( CFArrayGetCount(client->fPendingSends) >= kClientMaximumPendingSends ) {
+        fprintf(stderr, "ClientSend: Client %p killed because of too many outstanding sends.\n", client);
+        
+        result = false;
+    }
+
+    // Copy the packet data, append that copy to the send queue, and then 
+    // give it a kick.
+    //
+    // The memory allocated here will be freed when the packet is succesfully 
+    // sent (SendPending), or the client is destroy.
+    
+    if (result) {
+        copiedPacket = (PacketHeader *) malloc(packet->fSize);
+        result = (copiedPacket != NULL);
+    }
+    if (result) {
+        memcpy(copiedPacket, packet, packet->fSize);
+        
+        CFArrayAppendValue(client->fPendingSends, copiedPacket);
+        
+        result = ( ClientSendPending(client) == 0 );
+    }
+
+    return result;
+}
+
+static Boolean ClientSendReply(ClientState *client, const PacketHeader *request, int errNum)
+    // Send an RPC reply packet to the client.  You must supply request 
+    // because it forms the basis of many of the fields in the reply. 
+    // You also have to supply errNum, which is an errno-style error 
+    // indicating the fate of the request.
+{
+    PacketReply     response;
+
+    assert(client  != NULL);
+    assert(request != NULL);
+
+    InitPacketHeader(&response.fHeader, kPacketTypeReply, sizeof(response), false);
+    // Copy the ID from the request packet, overriding the fID set by InitPacketHeader.
+    response.fHeader.fID    = request->fID;
+    response.fErr = errNum;
+
+    return ClientSend(client, &response.fHeader);
+}
+
+static void ClientGotSpace(ClientState *client)
+	// This routine is called by ClientEvent when it receives the kCFSocketWriteCallBack 
+	// event, indicating that there is space to write in the client's socket buffer. 
+	// It calls ClientSendPending to process any packets that are waiting to be sent.  
+	// In most cases this does nothing because the client send queue is empty.  However, 
+	// if the client goes deaf, so the socket buffer becomes write-side flow controlled, 
+	// packets can back up in the send queue.  When the client starts receiving packets 
+	// again, space becomes available in the socket buffer and CFSocket sends us the 
+	// kCFSocketWriteCallBack.  We respond to that by resuming our sends.
+{
+    int             err;
+	
+	assert(client != NULL);
+    
+    fprintf(stderr, "ClientGotSpace: Client %p lifted write-side flow control.\n", client);
+
+    err = ClientSendPending(client);
+	
+	// If the sending failed for any reason (except flow control, for which 
+	// ClientSendPending mutates the EAGAIN status to a 0) we kill the client.
+	
+    if (err != 0) {
+        ClientDestroy(client);
+    }
+}
+
+#pragma mark Receive
+
+// The receive engine is based around ClientGotData, which is the routine that gets 
+// called when new data arrives, and a variety of packet handlers for processing 
+// specific types of packets and that all have the same form.
+//
+// A packet handle routine takes two parameters, the client and the packet, neither 
+// of which can be NULL, and does the work to process that packet.  This typically 
+// involves checking that the packet is valid, doing the job requested by the packet, 
+// and then, if the packet is for an RPC, sending the reply.
+//
+// If the packet handler returns false, the caller (ClientGotData) assumes that 
+// something was seriously wrong with the packet and kills the connection to the 
+// client.  A packet handler typically does this if the packet itself is malformed; 
+// if the job requested by the packet can't be done (for example, there might not 
+// be enough memory), the packet handler wouldn't return false but would, instead, 
+// send an error status back to the client in the RPC reply.
+
+static Boolean ClientGoodbye(ClientState *client, PacketGoodbye *packet)
+    // A packet handler for the Goodbye packet.  See the large comment above for 
+	// a discussion of the general form of a packet handler.
+	//
+	// A Goodbye packet is sent by the client to indicate to us that it's closing 
+	// its end of the connection.
+{
+    Boolean     result;
+    
+    assert(client != NULL);
+    assert(packet != NULL);
+    
+    result = ClientCheckPacketSize(client, &packet->fHeader, sizeof(PacketGoodbye));
+    if ( result ) {
+        result = ClientCheckPacketID(client, &packet->fHeader, kPacketIDNone);
+    }
+    
+    if (result) {
+        // During reliability print all of the goodbyes proved to be too verbose, 
+        // so I've disabled it for now.
+        
+        if (false) {
+            fprintf(stderr, "%p: Goodbye (%.*s).\n", client, (int) sizeof(packet->fMessage), packet->fMessage);
+        }
+        
+        // Unlike most packet handlers, we return false on success.  This is because 
+		// the Goodbye packet tells us that the client has gone away, and thus we 
+		// need to kill the client.  It turns out that returning false does the job 
+		// without us having to write any special code.
+        
+        result = false;
+    }
+    
+    return result;
+}
+
+static Boolean ClientNOP(ClientState *client, PacketNOP *packet)
+    // A packet handler for the NOP packet.  See the large comment above for 
+	// a discussion of the general form of a packet handler.
+	//
+	// A NOP RPC does nothing; it's used to test client/server connection.
+{
+    Boolean     result;
+    
+    result = ClientCheckPacketSize(client, &packet->fHeader, sizeof(PacketNOP));
+    
+    if (result) {
+        fprintf(stderr, "%p: NOP\n", client);
+        
+        result = ClientSendReply(client, &packet->fHeader, 0);
+    }
+    
+    return result;
+}
+
+static Boolean ClientWhisper(ClientState *client, PacketWhisper *packet)
+    // A packet handler for the Whisper packet.  See the large comment above for 
+	// a discussion of the general form of a packet handler.
+	//
+	// A Whisper RPC causes the server to print the associated message.
+{
+    Boolean result;
+    
+    result = ClientCheckPacketSize(client, &packet->fHeader, sizeof(PacketWhisper));
+    if (result) {
+        fprintf(stderr, "%p: Whisper \"%.*s\"\n", client, (int) sizeof(packet->fMessage), packet->fMessage);
+
+        result = ClientSendReply(client, &packet->fHeader, 0);
+    }
+    
+    return result;
+}
+
+static Boolean ClientShout(ClientState *client, PacketShout *packet)
+    // A packet handler for the Shout packet.  See the large comment above for 
+	// a discussion of the general form of a packet handler.
+	//
+	// A Shout packet causes the server to echo the message (in the form 
+	// of a Shout packet) to every client that has registered as a listener.
+{
+    Boolean     result;
+    Boolean     sendResult;
+    
+    result = ClientCheckPacketSize(client, &packet->fHeader, sizeof(PacketShout));
+    if (result) {
+        result = ClientCheckPacketID(client, &packet->fHeader, kPacketIDNone);
+    }
+	
+	// The Shout packet is good.  Let's echo it to each listener.
+	
+    if (result) {
+        ClientState  ** allClients;
+        CFIndex         clientCount;
+        CFIndex         clientIndex;
+
+        fprintf(stderr, "%p: Shout   \"%.*s\"\n", client, (int) sizeof(packet->fMessage), packet->fMessage);
+        
+        // We make a snapshot of the client list because clients might disappear 
+        // as we talk to them.  That is, the act of talking to the client might 
+        // cause us to notice that the client is dead.
+        
+        clientCount = CFSetGetCount(gClients);
+        
+        allClients = calloc(clientCount, sizeof(ClientState *));
+        if (allClients == NULL) {
+            fprintf(stderr, "ClientShout: Shout from %p failed because we couldn't allocate memory.\n", client);
+        } else {
+            CFSetGetValues(gClients, (const void **) allClients);
+            
+			// Iterate through the array of clients, sending the Shout packet to each.
+			
+            for (clientIndex = 0; clientIndex < clientCount; clientIndex++) {
+                ClientState *  thisClient;
+                
+                thisClient = allClients[clientIndex];
+                if (thisClient->fListening) {
+                    sendResult = ClientSend(thisClient, &packet->fHeader);
+                    
+                    // Fun fun fun.  If we're sending to ourselves, we return the result 
+                    // of the send as our function result, which, if there's a failure, 
+                    // will trigger ClientGotData to clean us up.  OTOH, if we're sending 
+                    // to another client, we're responsible for cleaning up if there's 
+                    // a failure.
+                    
+                    if (thisClient == client) {
+                        result = sendResult;
+                    } else {
+                        if ( ! sendResult ) {
+                            fprintf(stderr, "ClientShout: Shout from %p to %p failed.\n", client, thisClient);
+                            
+                            ClientDestroy(thisClient);
+                        }
+                    }
+                }
+            }
+        }
+
+        free(allClients);
+    }
+    return result;
+}
+
+static Boolean ClientListen(ClientState *client, PacketListen *packet)
+    // A packet handler for the Listen packet.  See the large comment above for 
+	// a discussion of the general form of a packet handler.
+	//
+	// A Listen RPC tells the server that the client wants to hear about shouted 
+	// messages.
+{
+    Boolean     result;
+    
+    result = ClientCheckPacketSize(client, &packet->fHeader, sizeof(PacketListen));
+    if (result) {
+        if (client->fListening) {
+            fprintf(stderr, "ClientListen: Redundant Listen from %p.\n", client);
+        } else {
+            fprintf(stderr, "%p: Listen\n", client);
+        }
+        client->fListening = true;
+        
+        result = ClientSendReply(client, &packet->fHeader, 0);
+    }
+    
+    return result;
+}
+
+static Boolean ClientQuit(ClientState *client, PacketQuit *packet)
+    // A packet handler for the Quit packet.  See the large comment above for 
+	// a discussion of the general form of a packet handler.
+	//
+	// A Quit RPC causes the server to quit.
+{
+    Boolean     result;
+    
+    result = ClientCheckPacketSize(client, &packet->fHeader, sizeof(PacketQuit));
+    if (result) {
+        fprintf(stderr, "%p: Quit\n", client);
+        
+        // Stop the main event loop.
+        
+        CFRunLoopStop( CFRunLoopGetCurrent() );
+        
+        // This reply should go out immediately.  If the client, for some reason, 
+        // is flow controlled, it may not see the response.  But really, that's 
+        // the client's fault (-:
+        
+        result = ClientSendReply(client, &packet->fHeader, 0);
+    }
+    
+    return result;
+}
+
+static void ClientGotData(ClientState *client, const void *data)
+	// This routine is called by ClientEvent when it receives the kCFSocketDataCallBack 
+	// event, indicating that CFSocket has read data from the socket.  The routine 
+	// appends the data to the receive buffer (fBufferedData) and then looks through 
+	// the receive buffer for complete packets.  For each complete packet it finds, 
+	// it calls the packet handler (the various routines above) to process the packet 
+	// and then it deletes the packet from the front of the receive buffer.
+	// 
+	// data is the data read for us by CFSocket.  It's actually a CFDataRef 
+	// but, because we're being called from a generic CFSocket event handler, 
+	// it's of type (const void *).  We have to do the cast here.
+{
+    CFDataRef       newData;
+
+	assert(client != NULL);
+    
+    newData = (CFDataRef) data;
+    assert(newData != NULL);
+    assert( CFGetTypeID(newData) == CFDataGetTypeID() );
+
+    if ( CFDataGetLength(newData) == 0 ) {
+        // A zero length data indicates the end of the data stream; the client is dead 
+		// so we just go and remove our record of it.
+        
+        fprintf(stderr, "ClientGotData: Client %p died unexpectedly.\n", client);
+        
+        ClientDestroy(client);
+    } else {
+
+        // Append the new data to whatever data we have already buffered 
+        // (most likely nothing).
+        
+        CFDataAppendBytes(client->fBufferedData, CFDataGetBytePtr(newData), CFDataGetLength(newData));
+        
+        // Process packets until we run out of complete ones.
+        
+        do {
+            PacketHeader *  thisPacket;
+            Boolean         success;
+            
+            if ( CFDataGetLength(client->fBufferedData) < sizeof(PacketHeader) ) {
+                // Not enough data for the packet header; we're done.
+                break;
+            }
+            
+            thisPacket = (PacketHeader *) CFDataGetBytePtr(client->fBufferedData);
+            
+            if ( thisPacket->fMagic != kPacketMagic ) {
+                fprintf(stderr, "ClientGotData: Client %p sent us a packet with bad magic (%.4s).\n", client, (char *) &thisPacket->fMagic);
+                
+                ClientDestroy(client);
+                break;
+            }
+            
+            if (thisPacket->fSize > kPacketMaximumSize) {
+                fprintf(stderr, "ClientGotData: Client %p sent us a packet that's just too big (%" PRIu32 ").\n", client, thisPacket->fSize);
+                
+                ClientDestroy(client);
+                break;
+            }
+            
+            if ( CFDataGetLength(client->fBufferedData) < thisPacket->fSize ) {
+                // Not enough data for the packet body; we're done.
+                break;
+            }
+			
+			// Dispatch to the appropriate packet handler.
+            
+            switch (thisPacket->fType) {
+                case kPacketTypeGoodbye:
+                    success = ClientGoodbye(client, (PacketGoodbye *) thisPacket);
+                    break;
+                case kPacketTypeNOP:
+                    success = ClientNOP(client, (PacketNOP *) thisPacket);
+                    break;
+                case kPacketTypeWhisper:
+                    success = ClientWhisper(client, (PacketWhisper *) thisPacket);
+                    break;
+                case kPacketTypeShout:
+                    success = ClientShout(client, (PacketShout *) thisPacket);
+                    break;
+                case kPacketTypeListen:
+                    success = ClientListen(client, (PacketListen *) thisPacket);
+                    break;
+                case kPacketTypeQuit:
+                    success = ClientQuit(client, (PacketQuit *) thisPacket);
+                    break;
+                default:
+                    fprintf(stderr, "ClientGotData: Client %p sent us a packet with an unexpected type (%.4s).\n", client, (char *) &thisPacket->fType);
+                    
+                    success = false;
+                    break;                
+            }
+            if ( ! success ) {
+                ClientDestroy(client);
+                break;
+            }
+            
+            // Delete this packet from the front of our packet buffer.
+            
+            CFDataDeleteBytes(client->fBufferedData, CFRangeMake(0, thisPacket->fSize));
+            
+        } while (true);
+    }
+}
+
+/////////////////////////////////////////////////////////////////
+#pragma mark ***** Debug Infrastructure
+
+static void ClientPrintInfo(const void *value, void *context)
+	// Called by PrintServerState to print the state of a particular 
+	// client.  Actually passed as a callback to CFSetApplyFunction, 
+	// which is why the value parameter is a (const void *) rather 
+	// than a (ClientState *).  context is not used in this... context (-;
+{
+    ClientState *  client;
+    static const char * kBoolToStr[2] = { "false", "true" };
+
+	(void)context;
+    client = (ClientState *) value;
+    assert(client != NULL);
+    assert(client->fMagic == kClientStateMagic);
+    
+    fprintf(stderr, "  Client %p:\n", client);
+    fprintf(stderr, "    fSockFD            = %d\n", client->fSockFD);
+    fprintf(stderr, "    fSockCF            = %p\n", client->fSockCF);
+    fprintf(stderr, "    fRunLoopSource     = %p\n", client->fRunLoopSource);
+    fprintf(stderr, "    fBufferedData      = %p (count: %ld)\n", client->fBufferedData, CFDataGetLength(client->fBufferedData));
+    fprintf(stderr, "    fPendingSends      = %p (count: %ld)\n", client->fPendingSends, CFArrayGetCount(client->fPendingSends));
+    fprintf(stderr, "    fPendingSendOffset = %zd\n", client->fPendingSendOffset);
+    fprintf(stderr, "    fListening         = %s\n", kBoolToStr[client->fListening]);    
+}
+
+static void PrintServerState(void)
+	// Called in response to a SIGUSR1.  This prints a bunch of state 
+	// information about the server.  Note that it is not called from a 
+	// signal handler directly, rather from SignalRunLoopCallback which 
+	// is a runloop callback.  So we can do all sorts of things that 
+	// aren't safe in a true signal handler.
+{
+    fprintf(stderr, "CFLocalServer State\n");
+    fprintf(stderr, "-------------------\n");
+    if ( CFSetGetCount(gClients) == 0) {
+        fprintf(stderr, "Clients: none\n");
+    } else {
+        fprintf(stderr, "Clients:\n");
+        CFSetApplyFunction(gClients, ClientPrintInfo, NULL);
+    }
+    fprintf(stderr, "\n");
+	
+    DebugPrintDescriptorTable();
+}
+
+/////////////////////////////////////////////////////////////////
+#pragma mark ***** Server Framework
+
+static void ListeningSocketAcceptCallback(
+    CFSocketRef             s, 
+    CFSocketCallBackType    type, 
+    CFDataRef               address, 
+    const void *            data, 
+    void *                  info
+)
+	// This is the CFSocket event callback for the listening socket.  For a 
+	// description of the parameters, see the CFSocket documentation.
+	//
+	// CFSocket calls this routine when it has accepted a new connection on 
+	// the socket.  in this case data is a pointer to the newly created 
+	// file descriptor that describes the new connection.  This routine 
+	// responds by calling into the client layer to create a new client.
+{
+    (void)s;
+	(void)address;
+	(void)info;
+    
+    assert(type == kCFSocketAcceptCallBack);
+    assert(   (int *) data  != NULL );
+    assert( (*(int *) data) != -1 );
+
+    (void) ClientCreate( (*(int *) data), NULL );
+    
+    // If ClientCreate fails, it cleans up after itself, including 
+    // closing the newly created client socket.  It's even printed 
+    // a happy message (well, an unhappy message).  So we do nothing 
+	// on failure.
+}
+
+#if !defined(_WIN32)
+static void SignalRunLoopCallback(const siginfo_t *sigInfo, void *refCon)
+    // This routine is called in response to a signal (SIGINT 
+	// or SIGUSR1).  It is not, however, a signal handler.  Rather, 
+	// we orchestrate to have it called from the runloop (via 
+    // the magic of InstallSignalToSocket).  It's purpose 
+    // is to a) stop the server when the user types ^C (SIGINT), or 
+	// b) print some information about the server (SIGUSR1).
+{
+	(void)sigInfo;
+	(void)refCon;
+    
+    switch (sigInfo->si_signo) {
+        case SIGUSR1:
+			// Respond to SIGUSR1 by printing some information about the server.
+			
+            PrintServerState();
+            break;
+        case SIGINT:
+			// Respond to SIGINT by stopping the server.
+			
+			// Stop the runloop.  Note that we can get a reference to the runloop by 
+			// calling CFRunLoopGetCurrent because this is called from the runloop.
+			
+			CFRunLoopStop( CFRunLoopGetCurrent() );
+			
+			// Print a bonus newline to ensure that the next command prompt isn't 
+			// printed on the same line as the echoed ^C.
+			
+			fprintf(stderr, "\n");
+            break;
+        default:
+            assert(false);
+            break;
+    }
+}
+#endif
+
+static int SafeBindUnixDomainSocket(int sockFD, const char *socketPath)
+	// This routine is called to safely bind the UNIX domain socket 
+	// specified by sockFD to the path specificed by socketPath.  To avoid 
+	// security problems, socketPath must point it to a sticky directory 
+	// (such as "/var/tmp").  This allows us to create the socket with 
+	// very specific permissions, without us having to worry about a malicious 
+	// process switching stuff out from underneath us.
+	//
+	// For this test program, socketpath is "/var/tmp/com.apple.dts.CFLocalServer/Socket". 
+	// The code calculates parentPath as ""/var/tmp/com.apple.dts.CFLocalServer" 
+	// and grandParentPath as "/var/tmp".  Each ancestor has certain key attributes. 
+	//
+	// o grandParentPath must a sticky directory.  Because it's sticky, we 
+	//   can create a directory within it and know that either a) we created 
+	//   the directory, and no one else can mess with it because it's sticky, 
+	//   or b) the directory exists, in which case we can check it's owner 
+	//   and permissions and, if they are set correctly, know that no one else 
+	//   can mess with it.
+	//
+	// o When we create the parentPath directory within grandParentPath, we set its 
+	//   permissions to make it readable by everyone (so everyone can connect to our 
+	//   server) but writeable only by us (so that only we can create the listening 
+	//   socket).  Because parentPath is set this way, we know that no one else 
+	//   can modify it to produce a security problem.
+	//
+	// IMPORTANT:
+	// This routine is designed to protect against external attack, not against 
+	// being called incorrectly.  It only does minimal checking of socketPath.  
+	// For example, if one of the components of socketPath was "..", the security 
+	// checking done by this routine might be invalid.  Do not pass an untrusted 
+	// socketPath to this routine.
+{
+    int                 err;
+    char *              parentPath;
+    char *              grandParentPath;
+    char *              lastSlash;
+    struct stat         sb;
+    struct sockaddr_un  bindReq;
+#if !defined(_WIN32)
+    static const mode_t kRequiredParentMode = S_IRWXU | (S_IRGRP | S_IXGRP) | (S_IROTH | S_IXOTH); // rwxr-xr-x
+#endif
+
+    parentPath      = NULL;
+    grandParentPath = NULL;
+    
+    // sockaddr_un can only hold a very short path (it's 104 bytes long), 
+    // so we check that limit right up front.  Note the use of >= in the 
+    // check below: we fail if socketPath is exactly 104 chars long because 
+    // that would leave no space for the trailing null character.  Looking at 
+    // the kernel code, I don't think this is strictly necessary (in fact, 
+    // it seems that the kernel code will handle much longer paths than sun_path, 
+    // up to an overall sockaddr size ofSOCK_MAXADDRLEN), but I'm being 
+    // paranoid.
+    
+    err = 0;
+    if (strlen(socketPath) >= sizeof(bindReq.sun_path)) {
+        err = EINVAL;
+    }
+    
+    // Construct parentPath and grandParent path by knocking path components 
+    // off the end.
+    
+    if (err == 0) {
+        parentPath = strdup(socketPath);
+        if (parentPath == NULL) {
+            err = ENOMEM;
+        }
+    }
+    if (err == 0) {
+        lastSlash = strrchr(parentPath, '/');
+        if (lastSlash == NULL) {
+            fprintf(stderr, "SafeBindUnixDomainSocket: Can't get parent for path (%s).\n", socketPath);
+            err = EINVAL;
+        } else {
+            *lastSlash = 0;
+        }
+    }
+    if (err == 0) {
+        grandParentPath = strdup(parentPath);
+        if (grandParentPath == NULL) {
+            err = ENOMEM;
+        }
+    }
+    if (err == 0) {
+        lastSlash = strrchr(grandParentPath, '/');
+        if (lastSlash == NULL) {
+            fprintf(stderr, "SafeBindUnixDomainSocket: Can't get grandparent for path (%s).\n", socketPath);
+            err = EINVAL;
+        } else {
+            *lastSlash = 0;
+        }
+    }
+    
+    // Check that the parent directory is a sticky root-owned directory.  If the 
+    // grandparent directory is sticky, we know that any items in that directory 
+    // that are owned by us can't be substituted by anyone else (that is: deleted, 
+    // moved or renamed, and then replaced by an attacker's item).
+    
+    if (err == 0) {        
+        err = stat(grandParentPath, &sb);
+        err = MoreUNIXErrno(err);
+    }
+#if !defined(_WIN32)
+    if ( (err == 0) && ( ! (sb.st_mode & S_ISVTX) || (sb.st_uid != 0) ) ) {
+        fprintf(stderr, "SafeBindUnixDomainSocket: Grandparent directory (%s) is not a sticky root-owned directory.\n", grandParentPath);
+        err = EINVAL;
+    }
+    
+    // Create the parent directory.  Ignore an EEXIST error because of the 
+    // next check.
+
+    if (err == 0) {
+        err = mkdir(parentPath, kRequiredParentMode);
+        err = MoreUNIXErrno(err);
+        
+        if (err == EEXIST) {
+            err = 0;
+        }
+    }
+#endif
+    
+    // Check that the parent directory is a directory, is owned by us, and 
+    // has the right mode.  This ensures that no one except us can be monkeying 
+    // with its contents.  And we know that no one can substitute a /different/ 
+    // directory underneath us because its parent (grandParentPath) is sticky.
+
+    if (err == 0) {
+        err = stat(parentPath, &sb);
+        err = MoreUNIXErrno(err);
+    }
+#if !defined(_WIN32)
+    if ( (err == 0) && (sb.st_uid != geteuid()) ) {
+        fprintf(stderr, "SafeBindUnixDomainSocket: Parent (%s) is not owned by us.\n", parentPath);
+        err = EINVAL;
+    }
+    if ( (err == 0) && ! S_ISDIR(sb.st_mode) ) {
+        fprintf(stderr, "SafeBindUnixDomainSocket: Parent (%s) is not a directory.\n", parentPath);
+        err = EINVAL;
+    }
+    if ( (err == 0) && ( (sb.st_mode & ACCESSPERMS) != kRequiredParentMode ) ) {
+        fprintf(stderr, "SafeBindUnixDomainSocket: Parent (%s) has wrong permissions.\n", parentPath);
+        err = EINVAL;
+    }
+#endif
+    
+    // If all is well, let's bind our socket.  This involves deleting any existing 
+    // socket and recreating our own.  We know we can do this without worrying 
+    // about substitution because only we have write access to the parent directory.
+
+    if (err == 0) {
+        mode_t              oldUmask;
+
+        // Temporarily set the umask to 0 (the default is 0022) so that the 
+        // socket is created rwxrwxrwx.  This allows any user to connect to 
+        // our socket.
+
+        oldUmask = umask(0);
+
+        // Delete any existing socket.  We delete the socket when we shut down, 
+        // but, if we quit unexpectedly, it could've been left lying around.
+        
+        (void) unlink(socketPath);
+
+        // Bind the socket, allowing other clients to connect.
+        
+        bindReq.sun_family = AF_UNIX;
+        strcpy(bindReq.sun_path, socketPath);
+
+        err = bind(sockFD, (struct sockaddr *) &bindReq, SUN_LEN(&bindReq));
+        err = MoreUNIXErrno(err);
+
+        (void) umask(oldUmask);
+    }
+
+    free(parentPath);
+    free(grandParentPath);
+    
+    return err;
+}
+
+static void PrintUsage(const char *argv0)
+	// Print the program's usage.  Given that it supports no arguments whatsoever, 
+	// this is pretty simple.
+{
+    const char *command;
+    
+    command = strrchr(argv0, '/');
+    if (command == NULL) {
+        command = argv0;
+    } else {
+        command += 1;
+    }
+    fprintf(stderr, "usage: %s\n", command);
+}
+
+int main (int argc, const char * argv[])
+    // The primary entry point.
+{
+    int         err;
+    int         junk;
+    int         listenerFD;
+    int         sockType;
+    CFSocketRef listenerCF;
+    Boolean     didBind;
+
+#if !defined(_WIN32)
+    sockType = AF_UNIX;
+#else
+    sockType = AF_INET;
+#endif
+
+    didBind    = false;
+    listenerFD = -1;
+    listenerCF = NULL;
+
+	// Check the command line arguments (there shouldn't be any).
+	
+    err = 0;
+    if (argc != 1) {
+        PrintUsage(argv[0]);
+        err = ECANCELED;
+    }
+	
+#if !defined(_WIN32)
+	// Ignore SIGPIPE because it's a deeply annoying concept.  If you don't ignore 
+	// SIGPIPE when writing to a UNIX domain socket whose far side has been closed 
+	// will trigger a SIGPIPE, whose default action is to terminate the program.
+	
+    if (err == 0) {
+        fprintf(stderr, "CFLocalServer: Starting up (pid: %ld).\n", (long) getpid());
+    
+        err = MoreUNIXIgnoreSIGPIPE();
+    }
+    
+	// Set up the signal handlers we are interested in.  In this case we redirect 
+	// SIGINT and SIGUSR1 to our runloop.  If either of these signals occurs, we 
+	// end up executing SignalRunLoopCallback.
+	
+    if (err == 0) {
+        sigset_t    interestingSignals;
+        
+        (void) sigemptyset(&interestingSignals);
+        (void) sigaddset(&interestingSignals, SIGINT);
+        (void) sigaddset(&interestingSignals, SIGUSR1);
+        
+        err = InstallSignalToSocket(
+            &interestingSignals,
+            CFRunLoopGetCurrent(),
+            kCFRunLoopDefaultMode,
+            SignalRunLoopCallback,
+            NULL
+        );
+    }
+#else
+    {
+       WORD versionRequested = MAKEWORD(2, 0);
+       WSADATA wsaData;
+       err = WSAStartup(versionRequested, &wsaData);
+       if (err != 0 || LOBYTE(wsaData.wVersion) != LOBYTE(versionRequested) || HIBYTE(wsaData.wVersion) != HIBYTE(versionRequested)) {
+           WSACleanup();
+           CFLog(0, CFSTR("*** Could not initialize WinSock subsystem!!!"));
+       }
+    }
+#endif
+
+	// Create the initial client set.
+	
+    if (err == 0) {
+		err = ClientInitialise();
+    }
+    
+	// Create our listening socket, bind it, and then wrap it in a CFSocket.
+	
+    if (err == 0) {
+        listenerFD = socket(sockType, SOCK_STREAM, 0);
+        err = MoreUNIXErrno(listenerFD);
+    }
+    if (err == 0) {
+        err = SafeBindUnixDomainSocket(listenerFD, kServerSocketPath);
+        didBind = (err == 0);
+    }
+    if (err == 0) {
+        err = listen(listenerFD, 5);
+        err = MoreUNIXErrno(err);
+    }
+    if (err == 0) {
+        listenerCF = CFSocketCreateWithNative(
+            NULL, 
+            (CFSocketNativeHandle) listenerFD, 
+            kCFSocketAcceptCallBack, 
+            ListeningSocketAcceptCallback, 
+            NULL);
+        if (listenerCF == NULL) {
+            err = EINVAL;
+        }
+    }
+    
+	// Schedule the listening socket on our runloop.
+	
+    if (err == 0) {
+        CFRunLoopSourceRef  rls;
+        
+        rls = CFSocketCreateRunLoopSource(NULL, listenerCF, 0);
+        if (rls == NULL) {
+            err = EINVAL;
+        } else {
+            CFRunLoopAddSource( CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
+            
+            // We no longer need this source, so we just release it.
+            
+            CFRelease(rls);
+        }
+    }
+    
+	// Go go gadget server!
+	
+    if (err == 0) {
+        CFRunLoopRun();
+    }
+
+    // Clean up.
+    
+	// Close down any connected clients.
+	
+	ClientTerminate();
+    
+	// Clean up our listenenng socket.
+	
+    if (listenerCF != NULL) {
+        CFSocketInvalidate(listenerCF);
+        
+        CFRelease(listenerCF);
+    }
+
+    // CFSocket will close listenerFD when listenerCF is invalidated, so we 
+    // don't close it if we did the invalidate above.
+
+    if ( (listenerFD != -1) && (listenerCF == NULL) ) {
+#if !defined(_WIN32)
+        junk = close(listenerFD);
+#else
+        junk = closesocket(listenerFD);
+#endif
+        assert(junk == 0);
+    }
+    if (didBind) {
+        (void) unlink(kServerSocketPath);
+    }
+    
+    if (err == 0) {
+        fprintf(stderr, "CFLocalServer: Shutting down.\n");
+    } else if (err != ECANCELED) {
+        fprintf(stderr, "CFLocalServer: Failed with error %d.\n", err);
+    }
+    
+    return (err == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/CoreFoundation/examples/CFMessagePort/Makefile.am b/CoreFoundation/examples/CFMessagePort/Makefile.am
new file mode 100644
index 0000000..840ca61
--- /dev/null
+++ b/CoreFoundation/examples/CFMessagePort/Makefile.am
@@ -0,0 +1,11 @@
+AM_CFLAGS		= -I${top_srcdir}/include
+
+if CF_BUILD_TESTS
+EXTRA_PROGRAMS		= client server
+endif
+
+client_LDADD		= ${top_builddir}/libCoreFoundation.la
+server_LDADD		= ${top_builddir}/libCoreFoundation.la
+
+client_SOURCES		= client.c
+server_SOURCES		= server.c
diff --git a/CoreFoundation/examples/CFMessagePort/Makefile.in b/CoreFoundation/examples/CFMessagePort/Makefile.in
new file mode 100644
index 0000000..8fe949b
--- /dev/null
+++ b/CoreFoundation/examples/CFMessagePort/Makefile.in
@@ -0,0 +1,458 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@EXTRA_PROGRAMS = client$(EXEEXT) server$(EXEEXT)
+subdir = examples/CFMessagePort
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_client_OBJECTS = client.$(OBJEXT)
+client_OBJECTS = $(am_client_OBJECTS)
+client_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+am_server_OBJECTS = server.$(OBJEXT)
+server_OBJECTS = $(am_server_OBJECTS)
+server_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(client_SOURCES) $(server_SOURCES)
+DIST_SOURCES = $(client_SOURCES) $(server_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+client_LDADD = ${top_builddir}/libCoreFoundation.la
+server_LDADD = ${top_builddir}/libCoreFoundation.la
+client_SOURCES = client.c
+server_SOURCES = server.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/CFMessagePort/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/CFMessagePort/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+client$(EXEEXT): $(client_OBJECTS) $(client_DEPENDENCIES) 
+	@rm -f client$(EXEEXT)
+	$(LINK) $(client_OBJECTS) $(client_LDADD) $(LIBS)
+server$(EXEEXT): $(server_OBJECTS) $(server_DEPENDENCIES) 
+	@rm -f server$(EXEEXT)
+	$(LINK) $(server_OBJECTS) $(server_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/CFMessagePort/client.c b/CoreFoundation/examples/CFMessagePort/client.c
new file mode 100644
index 0000000..8ce708c
--- /dev/null
+++ b/CoreFoundation/examples/CFMessagePort/client.c
@@ -0,0 +1,14 @@
+#include <CoreFoundation/CoreFoundation.h>
+
+main() {
+     CFMessagePortRef remote = CFMessagePortCreateRemote(NULL, CFSTR("MyPort"));
+     char *message = "Hello, world!";
+     CFDataRef data, returnData = NULL;
+     data = CFDataCreate(NULL, (const UInt8 *)message, strlen(message)+1);
+     if (kCFMessagePortSuccess == CFMessagePortSendRequest(remote, 0, data, 1, 1, kCFRunLoopDefaultMode, &returnData) && NULL != returnData) {
+         printf("here is our return data: %s\n", CFDataGetBytePtr(returnData));
+         CFRelease(returnData);
+     }
+     CFRelease(data);
+     CFRelease(remote);
+}
diff --git a/CoreFoundation/examples/CFMessagePort/server.c b/CoreFoundation/examples/CFMessagePort/server.c
new file mode 100644
index 0000000..7b7d4a3
--- /dev/null
+++ b/CoreFoundation/examples/CFMessagePort/server.c
@@ -0,0 +1,16 @@
+#include <CoreFoundation/CoreFoundation.h>
+
+CFDataRef myCallBack(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info) {
+     char *message = "Thanks for calling!";
+     CFDataRef returnData = CFDataCreate(NULL, (const UInt8 *)message, strlen(message)+1);
+     printf("here is our received data: %s\n", CFDataGetBytePtr(data));
+     return returnData;  // as stated in header, both data and returnData will be released for us after callback returns
+}
+
+main() {
+     CFMessagePortRef local = CFMessagePortCreateLocal(NULL, CFSTR("MyPort"), myCallBack, NULL, false);
+     CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(NULL, local, 0);
+     CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
+     CFRunLoopRun();    // will not return as long as message port is still valid and source remains on run loop
+     CFRelease(local);
+}
diff --git a/CoreFoundation/examples/CFRunLoopTimerExample/CFRunLoopTimerExample.c b/CoreFoundation/examples/CFRunLoopTimerExample/CFRunLoopTimerExample.c
new file mode 100644
index 0000000..07c0576
--- /dev/null
+++ b/CoreFoundation/examples/CFRunLoopTimerExample/CFRunLoopTimerExample.c
@@ -0,0 +1,469 @@
+/*
+ *    Copyright (c) 2009 Nuovation System Designs, LLC
+ *    All rights reserved.
+ *
+ *    Description:
+ *      This file implements a trivial CFRunLoopTimer example that
+ *      fires N timers every T[n] seconds for up to L seconds.
+ */
+
+/*
+ * Copyright (c) 2003, Steven G. Kargl
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <math.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#if !defined(_WIN32)
+#include <unistd.h>
+#endif
+
+#include <AssertMacros.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+/* Type Definitions */
+
+typedef struct _TimerData {
+	CFIndex				mIndex;
+	double				mInterval;
+	struct {
+		unsigned long	mDid;
+		unsigned long	mShould;
+	} mIterations;
+	CFRunLoopTimerRef	mRef;
+} TimerData;
+
+typedef TimerData ** TimerContainerRef;
+
+/*
+ *  void TimerCallback()
+ *
+ *  Description:
+ *    This routine is the callback handler for a CFRunLoopTimer. It
+ *    simply prints out the time of day--in the current system time
+ *    zone--and the iteration number and then increments the iteration
+ *    number.
+ *
+ *  Input(s):
+ *    timer - A CoreFoundation run loop timer reference to the timer
+ *            associated with this callback.
+ *    info  - A pointer to the callback data associated with this time
+ *            when it was created. In this case, the iteration state.
+ *
+ *  Output(s):
+ *    info  - The callback state with the iteration count incremented by
+ *            one.
+ *
+ *  Returns:
+ *    N/A
+ *
+ */
+static void
+TimerCallback(CFRunLoopTimerRef timer, void *info)
+{
+	TimerData *theData = (TimerData*)info;
+    CFTimeZoneRef tz = NULL;
+    CFGregorianDate theDate;
+
+	(void)timer;
+
+	tz = CFTimeZoneCopySystem();
+	require(tz != NULL, done);
+
+	theDate = CFAbsoluteTimeGetGregorianDate(CFAbsoluteTimeGetCurrent(), tz);
+
+	printf("%04d-%02d-%02d %02d:%02d:%06.3f, timer: %lu, iteration: %lu\n",
+		   theDate.year, theDate.month, theDate.day,
+		   theDate.hour, theDate.minute, theDate.second,
+		   theData->mIndex,
+		   theData->mIterations.mDid++);
+
+	CFRelease(tz);
+
+ done:
+	return;
+}
+
+/*
+ *  TimerContainerRef TimerContainerCreate()
+ *
+ *  Description:
+ *    This routine allocates a timer container capable of storing the
+ *    specified number of timers.
+ *
+ *  Input(s):
+ *    inElements - The size of the timer container to create.
+ *
+ *  Output(s):
+ *    N/A
+ *
+ *  Returns:
+ *    A timer container reference if OK; otherwise, NULL on error.
+ *
+ */
+static TimerContainerRef
+TimerContainerCreate(CFIndex inElements)
+{
+	return ((TimerContainerRef)CFAllocatorAllocate(kCFAllocatorSystemDefault,
+												   inElements *
+												   sizeof(TimerData *),
+												   0));
+}
+
+/*
+ *  TimerData * TimerContainerGet()
+ *
+ *  Description:
+ *    This routine returns the timer data at the specified index from
+ *    the timer container.
+ *
+ *  Input(s):
+ *    inContainer - A reference to the timer container element to
+ *                  return the element from.
+ *    inIndex     - The timer container element to return.
+ *
+ *  Output(s):
+ *    N/A
+ *
+ *  Returns:
+ *    A timer data pointer if OK; otherwise, NULL.
+ *
+ */
+static TimerData *
+TimerContainerGet(TimerContainerRef inContainer, CFIndex inIndex)
+{
+	return (inContainer ? inContainer[inIndex] : NULL);
+}
+
+/*
+ *  void TimerContainerSet()
+ *
+ *  Description:
+ *    This routine sets the timer data at the specified index in
+ *    the timer container.
+ *
+ *  Input(s):
+ *    inContainer - A reference to the timer container element to
+ *                  set the element in.
+ *    inIndex     - The timer container element to set.
+ *    inData      - A pointer to the timer data to set.
+ *
+ *  Output(s):
+ *    N/A
+ *
+ *  Returns:
+ *    A timer data pointer if OK; otherwise, NULL.
+ *
+ */
+static void
+TimerContainerSet(TimerContainerRef inContainer,
+				  CFIndex inIndex,
+				  TimerData *inData)
+{
+	inContainer[inIndex] = inData;
+}
+
+/*
+ *  void TimerContainerDestroy()
+ *
+ *  Description:
+ *    This routine deallocates the resources associated with the
+ *    specified timer container.
+ *
+ *    NOTE: The container owner is responsible for deallocating any
+ *    resources assigned to the container elements.
+ *
+ *  Input(s):
+ *    inContainer - A reference to the timer container to deallocate.
+ *
+ *  Output(s):
+ *    N/A
+ *
+ *  Returns:
+ *    N/A
+ *
+ */
+static void
+TimerContainerDestroy(TimerContainerRef inContainer)
+{
+	CFAllocatorDeallocate(kCFAllocatorSystemDefault, inContainer);
+}
+
+/*
+ *  long local_lround()
+ *
+ *  Description:
+ *    This routine, provided by Steven Kargl (see copyright above)
+ *    rounds the specified value to the nearest integer value,
+ *    rounding away from zero, regardless of the current rounding
+ *    direction.
+ *
+ *    NOTE: This function is implemented rather than just using C99's
+ *    lround because this code MUST work with Microsoft Visual Studio
+ *    2005 and 2008, both of which lack round or lround in their math
+ *    libraries.
+ *
+ *  Input(s):
+ *    x - The value to round.
+ *
+ *  Output(s):
+ *    N/A
+ *
+ *  Returns:
+ *    The rounded value.
+ */
+static
+long local_lround(double x)
+{
+	double t;
+
+	if (x >= 0.0) {
+		t = ceilf(x);
+
+		if (t - x > 0.5)
+			t -= 1.0;
+
+		return (long)t;
+
+	} else {
+		t = ceilf(-x);
+
+		if (t + x > 0.5)
+			t -= 1.0;
+
+		return (long)-t;
+
+	}
+}
+
+/*
+ *  TimerData * TimerDataCreate()
+ *
+ *  Description:
+ *    This routine allocates and initializes timer data, a wrapper
+ *    around a CFRunLoopTimer.
+ *
+ *  Input(s):
+ *    inIndex    - The instance or index of the allocated timer data.
+ *    inLimit    - The maximum amount of time, in seconds, the timer
+ *                 will be allowed to run.
+ *    inInterval - A pointer to a NULL-terminated C string
+ *                 representing the firing interval of the timer as a
+ *                 floating point number.
+ *
+ *  Output(s):
+ *    N/A
+ *
+ *  Returns:
+ *    A pointer to the created timer data on success; otherwise, NULL
+ *    on error.
+ *
+ */
+static TimerData *
+TimerDataCreate(CFIndex inIndex, double inLimit, const char *inInterval)
+{
+	double timerInterval = 0.0;
+	unsigned long timerIterations = 0;
+	char *end = NULL;
+	TimerData *theData = NULL;
+	CFRunLoopTimerRef theTimer = NULL;
+    CFRunLoopTimerContext theContext = { 0, NULL, NULL, NULL, NULL };
+ 
+	/* Parse and validate the timer interval. */
+
+	timerInterval = strtod(inInterval, &end);
+	verify(errno != ERANGE);
+
+	if (errno == ERANGE || timerInterval <= 0) {
+		fprintf(stderr, "Timer %lu interval must be greater than zero.\n",
+				inIndex);
+		goto done;
+	}
+
+	/* Compute the expected number of timer iterations. */
+
+	timerIterations = local_lround(inLimit / timerInterval);
+
+	/* Allocate storage for the timer data. */
+
+	theData = (TimerData*)CFAllocatorAllocate(kCFAllocatorSystemDefault,
+											  sizeof (TimerData),
+											  0);
+	require(theData != NULL, done);
+
+	theContext.info = theData;
+
+	/* Create a CoreFoundation run loop timer. */
+
+	theTimer = CFRunLoopTimerCreate(kCFAllocatorDefault,
+									CFAbsoluteTimeGetCurrent() + timerInterval,
+									timerInterval,
+									0,
+									0,
+									TimerCallback,
+									&theContext);
+	require(theTimer != NULL, fail);
+
+	printf("Will fire timer %lu every %g seconds for %g seconds, "
+		   "up to %lu time%s.\n",
+		   inIndex, timerInterval, inLimit, timerIterations,
+		   timerIterations == 1 ? "" : "s");
+
+	/* Initialize timer data members. */
+
+	theData->mIndex					= inIndex;
+	theData->mInterval				= timerInterval;
+	theData->mIterations.mDid		= 0;
+	theData->mIterations.mShould	= timerIterations;
+	theData->mRef					= theTimer;
+
+ done:
+	return (theData);
+
+ fail:
+	CFAllocatorDeallocate(kCFAllocatorSystemDefault, theData);
+
+	return (NULL);
+}
+
+/*
+ *  void TimerDataDestroy()
+ *
+ *  Description:
+ *    This routine deallocates the resources associated with
+ *    previously-allocated timer data.
+ *
+ *  Input(s):
+ *    inData - A pointer to the timer data to deallocate.
+ *
+ *  Output(s):
+ *    N/A
+ *
+ *  Returns:
+ *    N/A
+ *
+ */
+static void
+TimerDataDestroy(TimerData *inData)
+{
+	verify_action(inData != NULL, return);
+
+	if (inData->mRef != NULL) {
+		CFRunLoopTimerInvalidate(inData->mRef);
+		CFRelease(inData->mRef);
+	}
+
+	CFAllocatorDeallocate(kCFAllocatorSystemDefault, inData);
+}
+
+int
+main(int argc, const char * const argv[])
+{
+	int status = 0;
+	int i, timerCount = 0;
+	double timerLimit = 0;
+	char *end = NULL;
+	TimerData *theTimer;
+	TimerContainerRef timerContainer;
+	CFStringRef theMode = CFSTR("TimerMode");
+
+	/*
+	 * Perform a basic sanity check on usage: at least one timer and a limit.
+	 */
+
+	if (argc < 3) {
+		fprintf(stderr, "Usage: %s <interval 1 / s> [<interval 2 / s> ...] "
+				"<limit / s>\n", argv[0]);
+		goto done;
+	}
+
+	/* Convert and check the specified limit value. */
+
+	timerLimit = strtod(argv[argc - 1], &end);
+	verify(errno != ERANGE);
+
+	if (errno == ERANGE || timerLimit <= 0) {
+		fprintf(stderr, "Timer limit must be greater than zero.\n");
+		goto done;
+	}
+
+	timerCount = argc - 2;
+
+	/*
+	 * Allocate a container for all the timers we are going to
+	 * allocate and run.
+	 */
+
+	timerContainer = TimerContainerCreate(timerCount);
+
+	printf("Will fire a total of %d timer%s for %g seconds.\n",
+		   timerCount, ((timerCount == 1) ? "" : "s"), timerLimit);
+
+	/* Allocate each timer and add it to the container. */
+
+	for (i = 0; i < timerCount; i++) {
+		theTimer = TimerDataCreate(i, timerLimit, argv[i + 1]);
+		require(theTimer != NULL, finish);
+
+		TimerContainerSet(timerContainer, i, theTimer);
+
+		CFRunLoopAddTimer(CFRunLoopGetCurrent(), theTimer->mRef, theMode);
+
+	}
+
+	/* Run the timers */
+
+	CFRunLoopRunInMode(theMode, timerLimit, false);
+	CFRunLoopRun();
+
+	/* Determine the run results and deallocate resources. */
+
+ finish:
+	for (i = 0; i < timerCount; i++) {
+		bool result;
+		theTimer = TimerContainerGet(timerContainer, i);
+
+		result = (theTimer->mIterations.mShould >= theTimer->mIterations.mDid);
+
+		if (!result) {
+			fprintf(stderr,
+					"Timer %lu fired %lu of the expected %lu times.\n",
+					theTimer->mIndex,
+					theTimer->mIterations.mDid,
+					theTimer->mIterations.mShould);
+		}
+
+		status += result;
+
+		TimerDataDestroy(theTimer);
+	}
+
+	TimerContainerDestroy(timerContainer);
+
+ done:
+	return ((status == timerCount) ? EXIT_SUCCESS : EXIT_FAILURE);
+}
diff --git a/CoreFoundation/examples/CFRunLoopTimerExample/CFRunLoopTimerExample.vcproj b/CoreFoundation/examples/CFRunLoopTimerExample/CFRunLoopTimerExample.vcproj
new file mode 100755
index 0000000..90bca4e
--- /dev/null
+++ b/CoreFoundation/examples/CFRunLoopTimerExample/CFRunLoopTimerExample.vcproj
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="CFRunLoopTimerExample"
+	ProjectGUID="{6EC2C74D-B79D-4B8D-B14B-94ED3F08EB28}"
+	RootNamespace="CFRunLoopTimerExample"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="$(SolutionDir)\dist\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;WINDOWS_LEAN_AND_MEAN=1"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CFLite_$(ConfigurationName).lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="$(SolutionDir)\dist\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\CFRunLoopTimerExample.c"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/CoreFoundation/examples/CFRunLoopTimerExample/Makefile.am b/CoreFoundation/examples/CFRunLoopTimerExample/Makefile.am
new file mode 100644
index 0000000..25b8d10
--- /dev/null
+++ b/CoreFoundation/examples/CFRunLoopTimerExample/Makefile.am
@@ -0,0 +1,31 @@
+AM_CFLAGS			= -I${top_srcdir}/include
+
+EXTRA_DIST			= CFRunLoopTimerExample.vcproj
+
+if CF_BUILD_TESTS
+check_PROGRAMS			= CFRunLoopTimerExample
+endif
+
+CFRunLoopTimerExample_LDADD	= ${top_builddir}/libCoreFoundation.la
+
+CFRunLoopTimerExample_SOURCES	= CFRunLoopTimerExample.c
+
+if CF_BUILD_TESTS
+check:
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.25  5.00
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.40  2.30
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00  1.00
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00  0.50
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.10  1.00
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00  2.00
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00 10.00
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.33  1.00
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.50  0.33 4.00
+	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.50  1.00 2.00 8.00
+
+ddd gdb:
+	${LIBTOOL} --mode execute ${@} ./CFRunLoopTimerExample
+
+valgrind:
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./CFRunLoopTimerExample
+endif
diff --git a/CoreFoundation/examples/CFRunLoopTimerExample/Makefile.in b/CoreFoundation/examples/CFRunLoopTimerExample/Makefile.in
new file mode 100644
index 0000000..977cfa5
--- /dev/null
+++ b/CoreFoundation/examples/CFRunLoopTimerExample/Makefile.in
@@ -0,0 +1,479 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = CFRunLoopTimerExample$(EXEEXT)
+subdir = examples/CFRunLoopTimerExample
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_CFRunLoopTimerExample_OBJECTS = CFRunLoopTimerExample.$(OBJEXT)
+CFRunLoopTimerExample_OBJECTS = $(am_CFRunLoopTimerExample_OBJECTS)
+CFRunLoopTimerExample_DEPENDENCIES =  \
+	${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(CFRunLoopTimerExample_SOURCES)
+DIST_SOURCES = $(CFRunLoopTimerExample_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = CFRunLoopTimerExample.vcproj
+CFRunLoopTimerExample_LDADD = ${top_builddir}/libCoreFoundation.la
+CFRunLoopTimerExample_SOURCES = CFRunLoopTimerExample.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/CFRunLoopTimerExample/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/CFRunLoopTimerExample/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+CFRunLoopTimerExample$(EXEEXT): $(CFRunLoopTimerExample_OBJECTS) $(CFRunLoopTimerExample_DEPENDENCIES) 
+	@rm -f CFRunLoopTimerExample$(EXEEXT)
+	$(LINK) $(CFRunLoopTimerExample_OBJECTS) $(CFRunLoopTimerExample_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CFRunLoopTimerExample.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@check:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.25  5.00
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.40  2.30
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00  1.00
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00  0.50
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.10  1.00
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00  2.00
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 1.00 10.00
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.33  1.00
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.50  0.33 4.00
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./CFRunLoopTimerExample 0.50  1.00 2.00 8.00
+
+@CF_BUILD_TESTS_TRUE@ddd gdb:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./CFRunLoopTimerExample
+
+@CF_BUILD_TESTS_TRUE@valgrind:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./CFRunLoopTimerExample
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/CFTest/Chiquitita.xml b/CoreFoundation/examples/CFTest/Chiquitita.xml
new file mode 100644
index 0000000..21fa4bb
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/Chiquitita.xml
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<iKaraoke_x0020_TunePrompter_x0020_Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    <OperatingSystem>Mac</OperatingSystem>
+    <Build>1A18</Build>
+    <Title>Chiquitita</Title>
+    <Artist>ABBA</Artist>
+    <Album>ABBA Gold - Greatest Hits</Album>
+    <AudioFilePath>/Users/davec/Music/iTunes/iTunes Music/ABBA/ABBA Gold - Greatest Hits/11 Chiquitita.mp3</AudioFilePath>
+    <BackgroundPath></BackgroundPath>
+    <Sweeping>true</Sweeping>
+    <Alignment>Center</Alignment>
+    <Placement>Middle</Placement>
+    <LineCount>4</LineCount>
+    <BackgroundVisibility>0.500000</BackgroundVisibility>
+    <BackgroundColor>
+        <A>1.000000</A>
+        <R>0.000000</R>
+        <G>0.000000</G>
+        <B>0.000000</B>
+    </BackgroundColor>
+    <NormalColor>
+        <A>1.000000</A>
+        <R>1.000000</R>
+        <G>1.000000</G>
+        <B>1.000000</B>
+    </NormalColor>
+    <SweepColor>
+        <A>1.000000</A>
+        <R>0.380000</R>
+        <G>0.510000</G>
+        <B>1.000000</B>
+    </SweepColor>
+    <Font>
+        <MacName>LucidaGrande-Bold</MacName>
+        <Name>Lucida Grande</Name>
+        <Style>Bold</Style>
+        <Size>24</Size>
+        <Strikeout>false</Strikeout>
+        <Underline>false</Underline>
+    </Font>
+    <Timecodes>
+        <Time>14145</Time>
+        <SweepTime>1916</SweepTime>
+    </Timecodes>
+    <EditText>Chiquitita, tell me what's wrong
+You're enchained by your own sorrow
+In your eyes 
+there is no hope for tomorrow
+
+How I hate to see you like this
+There is no way you can deny it
+I can see that you're oh so sad, 
+so quiet
+
+Chiquitita, tell me the truth
+I'm a shoulder you can cry on
+Your best friend, 
+I'm the one you must rely on
+
+You were always sure of yourself
+Now I see you've broken a feather
+I hope we can patch it up together
+
+Chiquitita, you and I know
+How the heartaches 
+come and they go 
+and the scars they're leaving
+
+You'll be dancing once again 
+and the pain will end
+You will have no time for grieving
+
+Chiquitita, you and I cry
+But the sun is still in the sky 
+and shining above you
+
+Let me hear you sing once more 
+like you did before
+Sing a new song, Chiquitita
+
+Try once more like 
+you did before
+Sing a new song, Chiquitita
+
+So the walls came tumbling down
+And your love's a blown out candle
+All is gone and it seems 
+too hard to handle
+
+Chiquitita, tell me the truth
+There is no way you can deny it
+I see that you're oh so sad, so quiet
+
+Chiquitita, you and I know
+How the heartaches 
+come and they go 
+and the scars they're leaving
+
+You'll be dancing once again 
+and the pain will end
+You will have no time for grieving
+
+Chiquitita, you and I cry
+But the sun is still in the sky 
+and shining above you
+
+Let me hear you sing once more 
+like you did before
+Sing a new song, Chiquitita
+
+Try once more 
+like you did before
+Sing a new song, Chiquitita
+
+Try once more 
+like you did before
+Sing a new song, Chiquitita</EditText>
+    <SyncText>Chiquitita, tell me what's wrong
+You're enchained by your own sorrow
+In your eyes
+there is no hope for tomorrow
+
+How I hate to see you like this
+There is no way you can deny it
+I can see that you're oh so sad,
+so quiet
+
+Chiquitita, tell me the truth
+I'm a shoulder you can cry on
+Your best friend,
+I'm the one you must rely on
+
+You were always sure of yourself
+Now I see you've broken a feather
+I hope we can patch it up together
+
+Chiquitita, you and I know
+How the heartaches
+come and they go
+and the scars they're leaving
+
+You'll be dancing once again
+and the pain will end
+You will have no time for grieving
+
+Chiquitita, you and I cry
+But the sun is still in the sky
+and shining above you
+
+Let me hear you sing once more
+like you did before
+Sing a new song, Chiquitita
+
+Try once more like
+you did before
+Sing a new song, Chiquitita
+
+So the walls came tumbling down
+And your love's a blown out candle
+All is gone and it seems
+too hard to handle
+
+Chiquitita, tell me the truth
+There is no way you can deny it
+I see that you're oh so sad, so quiet
+
+Chiquitita, you and I know
+How the heartaches
+come and they go
+and the scars they're leaving
+
+You'll be dancing once again
+and the pain will end
+You will have no time for grieving
+
+Chiquitita, you and I cry
+But the sun is still in the sky
+and shining above you
+
+Let me hear you sing once more
+like you did before
+Sing a new song, Chiquitita
+
+Try once more
+like you did before
+Sing a new song, Chiquitita
+
+Try once more
+like you did before
+Sing a new song, Chiquitita
+</SyncText>
+</iKaraoke_x0020_TunePrompter_x0020_Project>
\ No newline at end of file
diff --git a/CoreFoundation/examples/CFTest/Makefile.am b/CoreFoundation/examples/CFTest/Makefile.am
new file mode 100644
index 0000000..1c08c93
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/Makefile.am
@@ -0,0 +1,36 @@
+EXTRA_DIST			= Chiquitita.xml \
+				  test.xml \
+				  mac/CFTest.xcodeproj/project.pbxproj \
+				  win_cw/MyMFCHeaders.pch++ \
+				  win_cw/CFTest.mcp \
+				  win_cw/MyMFCHeaders.h \
+				  win_vs/CFTest.vcproj \
+				  win_vs/CFTest.sln
+
+noinst_HEADERS			= source/shared/CFUtils.h \
+				  source/shared/SuperString.h \
+				  source/main/CFTest.h \
+				  source/main/stdafx.h
+
+if CF_BUILD_TESTS
+EXTRA_PROGRAMS			= CFTest
+endif
+
+CFTest_LDADD			= ${top_builddir}/libCoreFoundation.la
+
+CFTest_CPPFLAGS			= -D_CFTEST_ \
+				  -I${srcdir}/source/shared \
+				  -I${top_srcdir}/include
+
+CFTest_SOURCES			= source/main/main.cpp \
+				  source/main/CFTest.cpp \
+				  source/shared/SuperString.cpp \
+				  source/shared/CFUtils.cpp
+
+if CF_BUILD_TESTS
+ddd gdb: CFTest
+	${LIBTOOL} --mode execute ${@} ./CFTest
+
+valgrind: CFTest
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./CFTest
+endif
diff --git a/CoreFoundation/examples/CFTest/Makefile.in b/CoreFoundation/examples/CFTest/Makefile.in
new file mode 100644
index 0000000..5df8a93
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/Makefile.in
@@ -0,0 +1,539 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@EXTRA_PROGRAMS = CFTest$(EXEEXT)
+subdir = examples/CFTest
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_CFTest_OBJECTS = CFTest-main.$(OBJEXT) CFTest-CFTest.$(OBJEXT) \
+	CFTest-SuperString.$(OBJEXT) CFTest-CFUtils.$(OBJEXT)
+CFTest_OBJECTS = $(am_CFTest_OBJECTS)
+CFTest_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(CFTest_SOURCES)
+DIST_SOURCES = $(CFTest_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = Chiquitita.xml \
+				  test.xml \
+				  mac/CFTest.xcodeproj/project.pbxproj \
+				  win_cw/MyMFCHeaders.pch++ \
+				  win_cw/CFTest.mcp \
+				  win_cw/MyMFCHeaders.h \
+				  win_vs/CFTest.vcproj \
+				  win_vs/CFTest.sln
+
+noinst_HEADERS = source/shared/CFUtils.h \
+				  source/shared/SuperString.h \
+				  source/main/CFTest.h \
+				  source/main/stdafx.h
+
+CFTest_LDADD = ${top_builddir}/libCoreFoundation.la
+CFTest_CPPFLAGS = -D_CFTEST_ \
+				  -I${srcdir}/source/shared \
+				  -I${top_srcdir}/include
+
+CFTest_SOURCES = source/main/main.cpp \
+				  source/main/CFTest.cpp \
+				  source/shared/SuperString.cpp \
+				  source/shared/CFUtils.cpp
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/CFTest/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/CFTest/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+CFTest$(EXEEXT): $(CFTest_OBJECTS) $(CFTest_DEPENDENCIES) 
+	@rm -f CFTest$(EXEEXT)
+	$(CXXLINK) $(CFTest_OBJECTS) $(CFTest_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CFTest-CFTest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CFTest-CFUtils.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CFTest-SuperString.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CFTest-main.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+CFTest-main.o: source/main/main.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-main.o -MD -MP -MF $(DEPDIR)/CFTest-main.Tpo -c -o CFTest-main.o `test -f 'source/main/main.cpp' || echo '$(srcdir)/'`source/main/main.cpp
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-main.Tpo $(DEPDIR)/CFTest-main.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/main/main.cpp' object='CFTest-main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-main.o `test -f 'source/main/main.cpp' || echo '$(srcdir)/'`source/main/main.cpp
+
+CFTest-main.obj: source/main/main.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-main.obj -MD -MP -MF $(DEPDIR)/CFTest-main.Tpo -c -o CFTest-main.obj `if test -f 'source/main/main.cpp'; then $(CYGPATH_W) 'source/main/main.cpp'; else $(CYGPATH_W) '$(srcdir)/source/main/main.cpp'; fi`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-main.Tpo $(DEPDIR)/CFTest-main.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/main/main.cpp' object='CFTest-main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-main.obj `if test -f 'source/main/main.cpp'; then $(CYGPATH_W) 'source/main/main.cpp'; else $(CYGPATH_W) '$(srcdir)/source/main/main.cpp'; fi`
+
+CFTest-CFTest.o: source/main/CFTest.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-CFTest.o -MD -MP -MF $(DEPDIR)/CFTest-CFTest.Tpo -c -o CFTest-CFTest.o `test -f 'source/main/CFTest.cpp' || echo '$(srcdir)/'`source/main/CFTest.cpp
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-CFTest.Tpo $(DEPDIR)/CFTest-CFTest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/main/CFTest.cpp' object='CFTest-CFTest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-CFTest.o `test -f 'source/main/CFTest.cpp' || echo '$(srcdir)/'`source/main/CFTest.cpp
+
+CFTest-CFTest.obj: source/main/CFTest.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-CFTest.obj -MD -MP -MF $(DEPDIR)/CFTest-CFTest.Tpo -c -o CFTest-CFTest.obj `if test -f 'source/main/CFTest.cpp'; then $(CYGPATH_W) 'source/main/CFTest.cpp'; else $(CYGPATH_W) '$(srcdir)/source/main/CFTest.cpp'; fi`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-CFTest.Tpo $(DEPDIR)/CFTest-CFTest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/main/CFTest.cpp' object='CFTest-CFTest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-CFTest.obj `if test -f 'source/main/CFTest.cpp'; then $(CYGPATH_W) 'source/main/CFTest.cpp'; else $(CYGPATH_W) '$(srcdir)/source/main/CFTest.cpp'; fi`
+
+CFTest-SuperString.o: source/shared/SuperString.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-SuperString.o -MD -MP -MF $(DEPDIR)/CFTest-SuperString.Tpo -c -o CFTest-SuperString.o `test -f 'source/shared/SuperString.cpp' || echo '$(srcdir)/'`source/shared/SuperString.cpp
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-SuperString.Tpo $(DEPDIR)/CFTest-SuperString.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/shared/SuperString.cpp' object='CFTest-SuperString.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-SuperString.o `test -f 'source/shared/SuperString.cpp' || echo '$(srcdir)/'`source/shared/SuperString.cpp
+
+CFTest-SuperString.obj: source/shared/SuperString.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-SuperString.obj -MD -MP -MF $(DEPDIR)/CFTest-SuperString.Tpo -c -o CFTest-SuperString.obj `if test -f 'source/shared/SuperString.cpp'; then $(CYGPATH_W) 'source/shared/SuperString.cpp'; else $(CYGPATH_W) '$(srcdir)/source/shared/SuperString.cpp'; fi`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-SuperString.Tpo $(DEPDIR)/CFTest-SuperString.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/shared/SuperString.cpp' object='CFTest-SuperString.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-SuperString.obj `if test -f 'source/shared/SuperString.cpp'; then $(CYGPATH_W) 'source/shared/SuperString.cpp'; else $(CYGPATH_W) '$(srcdir)/source/shared/SuperString.cpp'; fi`
+
+CFTest-CFUtils.o: source/shared/CFUtils.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-CFUtils.o -MD -MP -MF $(DEPDIR)/CFTest-CFUtils.Tpo -c -o CFTest-CFUtils.o `test -f 'source/shared/CFUtils.cpp' || echo '$(srcdir)/'`source/shared/CFUtils.cpp
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-CFUtils.Tpo $(DEPDIR)/CFTest-CFUtils.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/shared/CFUtils.cpp' object='CFTest-CFUtils.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-CFUtils.o `test -f 'source/shared/CFUtils.cpp' || echo '$(srcdir)/'`source/shared/CFUtils.cpp
+
+CFTest-CFUtils.obj: source/shared/CFUtils.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CFTest-CFUtils.obj -MD -MP -MF $(DEPDIR)/CFTest-CFUtils.Tpo -c -o CFTest-CFUtils.obj `if test -f 'source/shared/CFUtils.cpp'; then $(CYGPATH_W) 'source/shared/CFUtils.cpp'; else $(CYGPATH_W) '$(srcdir)/source/shared/CFUtils.cpp'; fi`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/CFTest-CFUtils.Tpo $(DEPDIR)/CFTest-CFUtils.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='source/shared/CFUtils.cpp' object='CFTest-CFUtils.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CFTest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CFTest-CFUtils.obj `if test -f 'source/shared/CFUtils.cpp'; then $(CYGPATH_W) 'source/shared/CFUtils.cpp'; else $(CYGPATH_W) '$(srcdir)/source/shared/CFUtils.cpp'; fi`
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@ddd gdb: CFTest
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./CFTest
+
+@CF_BUILD_TESTS_TRUE@valgrind: CFTest
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./CFTest
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/CFTest/mac/CFTest.xcodeproj/project.pbxproj b/CoreFoundation/examples/CFTest/mac/CFTest.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..06f66b4
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/mac/CFTest.xcodeproj/project.pbxproj
@@ -0,0 +1,233 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 44;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		755536490ED0DDEC00036E92 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 755536480ED0DDEC00036E92 /* ApplicationServices.framework */; };
+		755E31490E1810450069CB0E /* SuperString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 755E31460E1810450069CB0E /* SuperString.cpp */; };
+		755E31640E1813310069CB0E /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 755E31630E1813310069CB0E /* main.cpp */; };
+		75CFC3AB0E181B2900F15957 /* CFTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75CFC3AA0E181B2900F15957 /* CFTest.cpp */; };
+		84F45E710F4BD7D600859B35 /* CFUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F45E6F0F4BD7D600859B35 /* CFUtils.cpp */; };
+		8DD76F790486A8DE00D96B5E /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09AB6884FE841BABC02AAC07 /* CoreFoundation.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+		8DD76F7B0486A8DE00D96B5E /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 8;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+		09AB6884FE841BABC02AAC07 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
+		755535B50ED0DA3D00036E92 /* stdafx.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = stdafx.h; path = ../source/main/stdafx.h; sourceTree = "<group>"; };
+		755536480ED0DDEC00036E92 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = ../../../../../../System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<group>"; };
+		755E31450E1810450069CB0E /* CFTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = CFTest.h; path = ../source/main/CFTest.h; sourceTree = "<group>"; };
+		755E31460E1810450069CB0E /* SuperString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = SuperString.cpp; path = ../source/shared/SuperString.cpp; sourceTree = "<group>"; };
+		755E31470E1810450069CB0E /* SuperString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = SuperString.h; path = ../source/shared/SuperString.h; sourceTree = "<group>"; };
+		755E31630E1813310069CB0E /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = main.cpp; path = ../source/main/main.cpp; sourceTree = "<group>"; };
+		75CFC3AA0E181B2900F15957 /* CFTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = CFTest.cpp; path = ../source/main/CFTest.cpp; sourceTree = "<group>"; };
+		84F45E6F0F4BD7D600859B35 /* CFUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFUtils.cpp; path = ../source/shared/CFUtils.cpp; sourceTree = SOURCE_ROOT; };
+		84F45E700F4BD7D600859B35 /* CFUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFUtils.h; path = ../source/shared/CFUtils.h; sourceTree = SOURCE_ROOT; };
+		8DD76F7E0486A8DE00D96B5E /* CFTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CFTest; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		8DD76F780486A8DE00D96B5E /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				8DD76F790486A8DE00D96B5E /* CoreFoundation.framework in Frameworks */,
+				755536490ED0DDEC00036E92 /* ApplicationServices.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		08FB7794FE84155DC02AAC07 /* CFTest */ = {
+			isa = PBXGroup;
+			children = (
+				08FB7795FE84155DC02AAC07 /* Source */,
+				08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
+				19C28FBDFE9D53C911CA2CBB /* Products */,
+			);
+			name = CFTest;
+			sourceTree = "<group>";
+		};
+		08FB7795FE84155DC02AAC07 /* Source */ = {
+			isa = PBXGroup;
+			children = (
+				755535B50ED0DA3D00036E92 /* stdafx.h */,
+				84F45E6F0F4BD7D600859B35 /* CFUtils.cpp */,
+				84F45E700F4BD7D600859B35 /* CFUtils.h */,
+				755E31470E1810450069CB0E /* SuperString.h */,
+				755E31460E1810450069CB0E /* SuperString.cpp */,
+				755E31450E1810450069CB0E /* CFTest.h */,
+				75CFC3AA0E181B2900F15957 /* CFTest.cpp */,
+				755E31630E1813310069CB0E /* main.cpp */,
+			);
+			name = Source;
+			sourceTree = "<group>";
+		};
+		08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
+			isa = PBXGroup;
+			children = (
+				755536480ED0DDEC00036E92 /* ApplicationServices.framework */,
+				09AB6884FE841BABC02AAC07 /* CoreFoundation.framework */,
+			);
+			name = "External Frameworks and Libraries";
+			sourceTree = "<group>";
+		};
+		19C28FBDFE9D53C911CA2CBB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				8DD76F7E0486A8DE00D96B5E /* CFTest */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		8DD76F740486A8DE00D96B5E /* CFTest */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1DEB924708733DCA0010E9CD /* Build configuration list for PBXNativeTarget "CFTest" */;
+			buildPhases = (
+				8DD76F760486A8DE00D96B5E /* Sources */,
+				8DD76F780486A8DE00D96B5E /* Frameworks */,
+				8DD76F7B0486A8DE00D96B5E /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = CFTest;
+			productInstallPath = "$(HOME)/bin";
+			productName = CFTest;
+			productReference = 8DD76F7E0486A8DE00D96B5E /* CFTest */;
+			productType = "com.apple.product-type.tool";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		08FB7793FE84155DC02AAC07 /* Project object */ = {
+			isa = PBXProject;
+			buildConfigurationList = 1DEB924B08733DCA0010E9CD /* Build configuration list for PBXProject "CFTest" */;
+			compatibilityVersion = "Xcode 3.0";
+			hasScannedForEncodings = 1;
+			mainGroup = 08FB7794FE84155DC02AAC07 /* CFTest */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				8DD76F740486A8DE00D96B5E /* CFTest */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+		8DD76F760486A8DE00D96B5E /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				755E31490E1810450069CB0E /* SuperString.cpp in Sources */,
+				755E31640E1813310069CB0E /* main.cpp in Sources */,
+				75CFC3AB0E181B2900F15957 /* CFTest.cpp in Sources */,
+				84F45E710F4BD7D600859B35 /* CFUtils.cpp in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+		1DEB924808733DCA0010E9CD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Versions/A/Frameworks\"",
+				);
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				PRODUCT_NAME = CFTest;
+				ZERO_LINK = YES;
+			};
+			name = Debug;
+		};
+		1DEB924908733DCA0010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Versions/A/Frameworks\"",
+				);
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PRODUCT_NAME = CFTest;
+			};
+			name = Release;
+		};
+		1DEB924C08733DCA0010E9CD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				GCC_PREPROCESSOR_DEFINITIONS = _CFTEST_;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				PREBINDING = NO;
+				SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
+			};
+			name = Debug;
+		};
+		1DEB924D08733DCA0010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = (
+					ppc,
+					i386,
+				);
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				PREBINDING = NO;
+				SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		1DEB924708733DCA0010E9CD /* Build configuration list for PBXNativeTarget "CFTest" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1DEB924808733DCA0010E9CD /* Debug */,
+				1DEB924908733DCA0010E9CD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1DEB924B08733DCA0010E9CD /* Build configuration list for PBXProject "CFTest" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1DEB924C08733DCA0010E9CD /* Debug */,
+				1DEB924D08733DCA0010E9CD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
diff --git a/CoreFoundation/examples/CFTest/source/main/CFTest.cpp b/CoreFoundation/examples/CFTest/source/main/CFTest.cpp
new file mode 100644
index 0000000..4bf4221
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/main/CFTest.cpp
@@ -0,0 +1,375 @@
+#include "stdafx.h"
+#include "SuperString.h"
+#include <CoreFoundation/CFLocale.h>
+#include <CoreFoundation/CFNumberFormatter.h>
+#include <CoreFoundation/CFDateFormatter.h>
+#include <CoreFoundation/CFCalendar.h>
+#include <CoreFoundation/CFBundle.h>
+#include "CFTest.h"
+
+static SuperString		GetAccentedString()
+{
+	return 	SuperString("%C3%B1%C3%A9%C3%BC%C3%AE", kCFStringEncodingPercentEscapes);
+}
+
+static void	ShowDiacriticSensitiveCompare(bool insensitiveB)
+{
+	SuperString		resultStr;
+
+	g_pref_diacritic_insensitive_searchB = insensitiveB;
+	
+	CCFLog()((CFTypeRef)resultStr.ssprintf("diacritic %ssensitive\n", insensitiveB ? "in" : "").ref());
+	
+	SuperString			str1("NeUi");
+	SuperString			str2(GetAccentedString());
+	
+	bool				diacritic_insensitive_compareB = str1 == str2;
+	
+	CCFLog()((CFTypeRef)resultStr.ssprintf("%s %s %s\n", 
+		   str1.utf8Z(), 
+		   diacritic_insensitive_compareB ? "==" : "!=", 
+		   str2.utf8Z()).ref());
+	
+	if (insensitiveB) {
+		CF_ASSERT(diacritic_insensitive_compareB);
+	} else {
+		CF_ASSERT(!diacritic_insensitive_compareB);
+	}
+}
+
+static void	ShowCompare(const SuperString& str1, const SuperString& str2)
+{
+	SuperString			format("%s %s %s");
+	const char*			ineqZ(str1 < str2 ? "<" : (str2 < str1 ? ">" : "=="));
+
+	format.ssprintf(NULL, str1.utf8Z(), ineqZ, str2.utf8Z());
+	CCFLog(true)(format.ref());
+}
+
+/******************************************************/
+class CParseXML {
+	#define						kLogDuringParse		1
+	CFStringRef					i_keyStr;
+	CFXMLNodeTypeCode			i_lastType;
+	
+	#if kLogDuringParse
+	void	IndentLevel(short levelS) {
+		loop (levelS) {
+			CCFLog()(CFSTR("\t"));
+		}
+	}
+	#endif
+
+	public: 
+	CParseXML() : i_lastType(kCFXMLNodeTypeDocument) { }
+	
+	void operator()(CCFXMLNode& node, short levelS)
+	{
+		CFXMLNodeTypeCode	type = node.GetTypeCode();
+		
+		#if kLogDuringParse
+			if (type == i_lastType) {
+				CCFLog()(CFSTR("\n"));
+			}
+		#endif
+		
+		i_lastType = type;
+		
+		switch (type) {
+				
+			case kCFXMLNodeTypeElement: {
+				i_keyStr = node.GetString();
+				
+				#if kLogDuringParse
+					IndentLevel(levelS);
+					CCFLog()(i_keyStr);
+					
+					if (!node.GetInfoPtr()->attributes) {
+						CCFLog()(CFSTR(": "));
+					}
+				#endif
+				break;
+			}
+				
+			case kCFXMLNodeTypeText: {
+				SuperString			valueStr(node.GetString());
+				
+				#if kLogDuringParse
+					CCFLog()(valueStr.ref());
+				#endif
+				break;
+			}
+		}
+	}
+};
+
+#ifdef __MWERKS__
+static CFGregorianDate			CFGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz)
+{
+	CFGregorianDate		gregDate;
+
+	CFAbsoluteTimeGetGregorianDate_MW(at, tz, &gregDate);
+	return gregDate;
+}
+#else
+	#define		CFGetGregorianDate		CFAbsoluteTimeGetGregorianDate
+#endif
+
+void	CFTest()
+{
+	SuperString		resultStr;
+	
+	if (!IsDefaultEncodingSet()) {
+		SetDefaultEncoding(kCFStringEncodingASCII);
+	}
+	
+	{
+		CCFLog()(CFSTR("------------------Strings---------------\n"));
+		CCFLog()(CFSTR("Hello, World!\n"));
+		ScCFReleaser<CFDataRef>		dataRef(SuperString("yeah baby").CopyDataRef());
+		SuperString					str;
+		
+		str.Set(dataRef);
+		CCFLog()(SuperString("The next line should read <yeah baby>\n").ref());
+		CCFLog(true)(str.ref());
+		
+		SuperString		str1("foscoobyar");
+		SuperString		str2("scooby");
+		
+		resultStr.ssprintf(
+			"\n%s %s %s\n", 
+			str1.utf8Z(), 
+			str1.Contains(str2) ? "contains" : "$$$ Error: does not contain(!?)", 
+			str2.utf8Z());
+		
+		CCFLog()(resultStr.ref());
+		
+		str1.Replace(str2, "o b");
+		CCFLog()(SuperString("The next line should read <foo bar>\n").ref());
+		CCFLog(true)(str1.ref());
+		
+		CCFLog()(CFSTR("------------------Case Insensitive Compare---------------\n"));
+		ShowDiacriticSensitiveCompare(false);
+		CCFLog()(CFSTR("\n"));
+		ShowDiacriticSensitiveCompare(true);
+		
+		{
+			CCFLog()(CFSTR("------------------Inequality---------------\n"));
+			SuperString			catStr("Cat");
+			SuperString			dogStr("Dog");
+			
+			ShowCompare(catStr, dogStr);
+			CF_ASSERT(catStr < dogStr);
+			
+			ShowCompare(dogStr, catStr);
+			CF_ASSERT(dogStr > catStr);
+
+			ShowCompare(catStr, catStr);
+			CF_ASSERT(catStr == catStr);
+		}
+		
+		{
+			CCFLog()(CFSTR("------------------Conversion---------------\n"));
+			SuperString				jStr(GetAccentedString());
+			
+			#if defined(__WIN32__)
+				#define		kConvertEncode		kCFStringEncodingWindowsLatin1
+			#else
+				#define		kConvertEncode		kCFStringEncodingMacRoman
+			#endif
+			
+			ustring				j;
+			CopyCFStringToUString(jStr.ref(), j, kConvertEncode);
+			
+			SuperString			convertedJ;  convertedJ.Set(j, kConvertEncode);
+			
+			CCFLog()(resultStr.ssprintf(
+				"The next line should read <%s>\n%s\n", 
+				jStr.utf8Z(), convertedJ.utf8Z()).ref());
+			
+			CCFLog()(resultStr.ssprintf("conversion: %s\n", convertedJ == jStr ? "Success!" : "$$ FAILED!").ref());
+		}
+	}
+	
+	{
+		CCFLog()(CFSTR("------------------Encoding---------------\n"));
+		CFStringEncoding		encoding = CFStringGetSystemEncoding();
+		
+		CCFLog()(resultStr.ssprintf("Encoding: %s\n", SuperString(CFStringGetNameOfEncoding(encoding)).utf8Z()).ref());
+		CCFLog()(resultStr.ssprintf("IANA charset: %s\n", SuperString(CFStringConvertEncodingToIANACharSetName(encoding)).utf8Z()).ref());
+		
+		#if defined(__WIN32__)
+			UInt32					codePage = CFStringConvertEncodingToWindowsCodepage(encoding);
+			
+			if (encoding == kCFStringEncodingWindowsLatin1) {
+				CF_ASSERT(codePage == kCodePage_WindowsLatin1);
+			}
+			
+			CCFLog()(resultStr.ssprintf("codepage: %ld\n", codePage).ref());
+			CF_ASSERT(CFStringConvertWindowsCodepageToEncoding(codePage) == encoding);
+		#endif		
+	}
+	
+	CCFLog()(CFSTR("------------------Locale---------------\n"));
+	ScCFReleaser<CFLocaleRef>				locale(CFLocaleCopyCurrent());
+	
+	{
+		SuperString				localIdStr(CFLocaleGetIdentifier(locale));
+		
+		CCFLog()(resultStr.ssprintf("Locale ID: %s\n", localIdStr.utf8Z()).ref());
+		
+		CCFDictionary			dictRef(CFLocaleCreateComponentsFromLocaleIdentifier(
+			kCFAllocatorDefault, localIdStr.ref()));
+		
+		dictRef.for_each(CCFLog(true));
+	}
+	
+	{
+		CCFLog()(CFSTR("------------------Preferred Languages---------------\n"));
+		ScCFReleaser<CFArrayRef>	arrayRef(CFLocaleCopyPreferredLanguages());
+		
+		array_for_each(arrayRef, CCFLog(true));
+	}
+	
+	{
+		CCFLog()(CFSTR("------------------Calendar---------------\n"));
+		ScCFReleaser<CFCalendarRef>		calendarRef(CFCalendarCopyCurrent());
+		
+		CCFLog()(resultStr.ssprintf("Calendar ID: %s\n", SuperString(CFCalendarGetIdentifier(calendarRef)).utf8Z()).ref());
+		
+		ScCFReleaser<CFTimeZoneRef>		timeZoneRef(CFCalendarCopyTimeZone(calendarRef));
+		CFAbsoluteTime					absTime(CFAbsoluteTimeGetCurrent());
+		ScCFReleaser<CFDateRef>			dateRef(CFDateCreate(kCFAllocatorDefault, absTime));
+		
+		CCFLog(true)(timeZoneRef.Get());
+		CCFLog(true)(dateRef.Get());
+		
+		CFGregorianDate					gregDate(CFGetGregorianDate(absTime, timeZoneRef));
+		
+//		CFAbsoluteTimeGetGregorianDate_MW(absTime, timeZoneRef, &gregDate);
+		CCFLog()(resultStr.ssprintf("year: %d\nmonth: %d\nday: %d\nhour: %d\nminute: %d\nsecond: %f\n", 
+			   (int)gregDate.year, 
+			   (int)gregDate.month, 
+			   (int)gregDate.day, 
+			   (int)gregDate.hour, 
+			   (int)gregDate.minute, 
+			   (float)gregDate.second).ref());
+		
+		ScCFReleaser<CFDateFormatterRef>	dateFormatterRef(CFDateFormatterCreate(
+			kCFAllocatorDefault, locale, kCFDateFormatterFullStyle, kCFDateFormatterFullStyle));
+		
+		ScCFReleaser<CFStringRef>			dateStr(CFDateFormatterCreateStringWithDate(
+			kCFAllocatorDefault, dateFormatterRef, dateRef));
+		
+		CCFLog()(CFSTR("Make sure time zone is correct in the next line:\n"));
+		CCFLog(true)(dateStr.Get());
+	}
+	
+	{
+		CCFLog()(CFSTR("------------------Numbers---------------\n"));
+		ScCFReleaser<CFNumberFormatterRef>		numFormatRef;
+		ScCFReleaser<CFStringRef>				numStr;
+		float									numF = 123456.789f;
+		ScCFReleaser<CFNumberRef>				numberRef(CFNumberCreate(
+			kCFAllocatorDefault, kCFNumberFloat32Type, &numF));
+		
+		numFormatRef.adopt(CFNumberFormatterCreate(
+			kCFAllocatorDefault, locale, kCFNumberFormatterDecimalStyle));
+		numStr.adopt(CFNumberFormatterCreateStringWithNumber(
+			kCFAllocatorDefault, numFormatRef, numberRef));
+		CCFLog(true)(numStr.Get());
+		
+		numFormatRef.adopt(CFNumberFormatterCreate(
+			kCFAllocatorDefault, locale, kCFNumberFormatterCurrencyStyle));
+		numStr.adopt(CFNumberFormatterCreateStringWithNumber(
+			kCFAllocatorDefault, numFormatRef, numberRef));
+		CCFLog(true)(numStr.Get());
+	}
+	
+	{
+		CCFLog()(CFSTR("------------------Bundle---------------\n"));	
+		
+		ScCFReleaser<CFURLRef>			bundleUrlRef;
+		ScCFReleaser<CFBundleRef>		bundleRef(CFBundleGetMainBundle(), true);
+		
+		if (bundleRef.Get() == NULL) {
+			CCFLog()(CFSTR("$$ Failed getting bundle!\n"));	
+		} else {
+			bundleUrlRef.adopt(CFBundleCopyBundleURL(bundleRef));
+		}
+		
+		if (bundleUrlRef.Get() != NULL) {
+			
+			CCFLog(true)(bundleUrlRef.Get());
+			
+			if (bundleRef.Get() != NULL) {
+				CCFDictionary	dictRef(CFBundleGetInfoDictionary(bundleRef), true);
+				
+				dictRef.for_each(CCFLog(true));
+			}
+			
+				#if defined(__WIN32__)
+					//	you may need to fix this relative URL here
+					SuperString				relPathStr("../../");
+				#else
+					SuperString				relPathStr("../../../");
+				#endif
+				
+			{
+				CCFLog()(CFSTR("------------------plist---------------\n"));
+
+				SuperString				testRelPath("test.xml");	testRelPath.prepend(relPathStr);
+				ScCFReleaser<CFURLRef>	xmlUrlRef(CFURLCreateWithFileSystemPathRelativeToBase(
+					kCFAllocatorDefault, testRelPath.ref(), kCFURLPOSIXPathStyle, false, bundleUrlRef));
+				
+				if (xmlUrlRef.Get()) {
+					CCFDictionary						dictRef;
+					ScCFReleaser<CFURLRef>				absUrlRef(CFURLCopyAbsoluteURL(xmlUrlRef));
+					
+					CCFLog()(resultStr.ssprintf("URL: %s\n", SuperString(CFURLGetString(absUrlRef)).utf8Z()).ref());
+					
+					if (Read_PList(xmlUrlRef, dictRef.ImmutableAddressOf())) {
+						dictRef.for_each(CCFLog(true));
+						
+						SuperString				outRelpath("out.xml");	outRelpath.prepend(relPathStr);
+						ScCFReleaser<CFURLRef>	outXmlUrlRef(CFURLCreateWithFileSystemPathRelativeToBase(
+							kCFAllocatorDefault, outRelpath.ref(), kCFURLPOSIXPathStyle, false, bundleUrlRef));
+						
+						Write_PList(dictRef.Get(), outXmlUrlRef);
+					}
+				} else {
+					CCFLog()(CFSTR("error illegal plist path?\n"));
+				}
+			}
+
+			{
+				CCFLog()(CFSTR("------------------xml---------------\n"));
+
+				SuperString				testRelPath("Chiquitita.xml");	testRelPath.prepend(relPathStr);
+				ScCFReleaser<CFURLRef>	xmlUrlRef(CFURLCreateWithFileSystemPathRelativeToBase(
+					kCFAllocatorDefault, testRelPath.ref(), kCFURLPOSIXPathStyle, false, bundleUrlRef));
+				
+				if (xmlUrlRef.Get()) {
+					CCFXmlTree					xml;
+					ScCFReleaser<CFURLRef>		absUrlRef(CFURLCopyAbsoluteURL(xmlUrlRef));
+					
+					CCFLog()(resultStr.ssprintf("URL: %s\n", SuperString(CFURLGetString(absUrlRef)).utf8Z()).ref());
+					
+					if (Read_XML(xmlUrlRef, xml)) {
+						CCFLog()(CFSTR("XML file read successfully\n"));
+						//xml.for_each(CParseXML());
+					} else {
+						CCFLog()(CFSTR("$$ FAIL reading xml file\n"));
+					}
+				} else {
+					CCFLog()(CFSTR("error illegal xml path?\n"));
+				}
+			}
+		}
+	}
+		
+	/*
+	 bonus points:  CFCharacterSet
+	 */
+	CCFLog()(CFSTR("--------------------------------------\n"));
+}
diff --git a/CoreFoundation/examples/CFTest/source/main/CFTest.h b/CoreFoundation/examples/CFTest/source/main/CFTest.h
new file mode 100755
index 0000000..bb2acf2
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/main/CFTest.h
@@ -0,0 +1 @@
+void	CFTest();
diff --git a/CoreFoundation/examples/CFTest/source/main/main.cpp b/CoreFoundation/examples/CFTest/source/main/main.cpp
new file mode 100644
index 0000000..64578b0
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/main/main.cpp
@@ -0,0 +1,17 @@
+#include "stdafx.h"
+#include "SuperString.h"
+#include "CFTest.h"
+#include "stdio.h"
+
+int		main()
+{
+	CFTest();
+
+	#if defined(__WIN32__)
+		#ifdef __MWERKS__
+			getc(stdin);
+		#endif
+	#endif
+
+	return 0;
+}
\ No newline at end of file
diff --git a/CoreFoundation/examples/CFTest/source/main/stdafx.h b/CoreFoundation/examples/CFTest/source/main/stdafx.h
new file mode 100644
index 0000000..f32c9b9
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/main/stdafx.h
@@ -0,0 +1,17 @@
+/*
+	Add local class declarations to this file.
+*/
+#ifndef _STDAFX
+#define _STDAFX
+
+#ifdef _CFTEST_
+#ifdef __WIN32__
+#include <MacTypes.h>
+#endif
+#endif
+
+#ifdef __MWERKS__
+	#include <afxwin.h>
+#endif
+
+#endif
diff --git a/CoreFoundation/examples/CFTest/source/shared/CFUtils.cpp b/CoreFoundation/examples/CFTest/source/shared/CFUtils.cpp
new file mode 100644
index 0000000..956ac35
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/shared/CFUtils.cpp
@@ -0,0 +1,639 @@
+/*
+ *  CFUtils.cpp
+ *  CFTest
+ *
+ *  Created by David M. Cotter on 7/23/08.
+ *  Copyright 2008 David M. Cotter. All rights reserved.
+ *
+ */
+#include "stdafx.h"
+
+#if defined(_KJAMS_)  && !defined(_KJAMSX_)
+	#include "StringUtils.h"
+	#include "MessageAlert.h"
+#else
+	#ifndef _CFTEST_
+		#include "XConfig.h"
+	#endif
+
+	#include "SuperString.h"
+	#include <CoreFoundation/CFDateFormatter.h>
+	#include <CoreFoundation/CFNumberFormatter.h>
+	#include <CoreFoundation/CFCalendar.h>
+#endif
+
+#ifndef _CFTEST_
+	#if _KJ_MAC_
+		#include "MessageAlert.h"
+	#else
+		#include <XErrorDialogs.h>
+	#endif
+
+	#include "CLocalize.h"
+#endif
+
+void	FilterErr(OSStatus err);
+void	FilterErr(OSStatus err)
+{
+	#ifdef kDEBUG
+		if (err == eofErr) {
+			err = eofErr;
+		}
+	#endif
+}
+
+#if defined(__WIN32__)
+	static	bool	s_setLogB = false;
+#endif
+
+void CCFLog::operator()(CFTypeRef valRef) {
+	#define		USE_CFSHOW		0
+	
+	#if defined(__WIN32__)
+		if (!s_setLogB) {
+			s_setLogB = true;
+		//	CFSetLogFile(CFSTR("CF_Log.txt"), kCFStringEncodingUTF8);
+		}
+	#endif
+
+	#if !USE_CFSHOW
+		SuperString			valStr;	valStr.Set_CFType(valRef);
+		FILE				*log_fileP = stdout;
+		
+		if (i_crB) {
+			valStr.append("\n");
+		}
+		
+		#if defined(__WIN32__)
+			
+			#ifdef __MWERKS__
+				//	console app
+				static	HANDLE	consoleH = NULL;
+				
+				if (!consoleH) {
+					consoleH = GetStdHandle(STD_OUTPUT_HANDLE);
+				}
+				
+				unsigned long	outL;
+				
+				WriteConsoleW(consoleH, valStr.w_str(), valStr.w_strlen(), &outL, NULL);
+				
+				log_fileP = NULL;
+			#else
+				//	GUI APP
+				static	FILE	*s_logP = NULL;
+				
+				if (s_logP == NULL) {
+					(void)fopen_s(&s_logP, kJams_LogFileName, "a");
+				}
+				
+				log_fileP = s_logP;
+			#endif
+	
+		#endif
+		
+		if (log_fileP) {
+			
+			#ifdef _KJAMSX_
+				fprintf(log_fileP, "%s", valStr.utf8Z());
+				fflush(log_fileP);
+			#else
+				#if _CFTEST_
+					fprintf(log_fileP, "%s", valStr.utf8Z());
+					fflush(log_fileP);
+				#else
+					Log(valStr.utf8Z());
+				#endif
+			#endif
+		}
+	#else
+
+		#ifndef __WIN32__
+			fflush(stdout);
+		#endif
+	
+		CFShow(valRef);
+		if (i_crB) {
+			CFShow(CFSTR("\n"));
+		}
+
+		#ifndef __WIN32__
+			fflush(stdout);
+		#endif
+	#endif
+}
+
+void CCFLog::operator()(CFStringRef keyRef, CFTypeRef valRef) {
+	SuperString		keyStr(keyRef);
+	
+	keyStr.append(": ");
+	
+	{
+		bool	wasB = i_crB;
+		i_crB = false;
+		
+		operator()(keyStr.ref());
+		i_crB = wasB;
+	}
+	
+	operator()(valRef);
+}
+
+/*****************************************************************************/
+bool	Read_PList(const CFURLRef &url, CFDictionaryRef *plistP)
+{
+	bool						successB = false;
+	ScCFReleaser<CFDataRef>     xmlData;
+	
+	*plistP = NULL;
+	
+	if (CFURLCreateDataAndPropertiesFromResource(
+		kCFAllocatorDefault, url, xmlData.AddressOf(), NULL, NULL, NULL)
+	) {
+		//Log("created xml from file");
+		
+		*plistP = (CFDictionaryRef)CFPropertyListCreateFromXMLData(
+			kCFAllocatorDefault,
+			xmlData,
+			kCFPropertyListMutableContainersAndLeaves,
+			NULL);
+		
+		successB = *plistP != NULL;
+		
+		if (successB) {
+			//	Log("created plist from xml");
+		} else {
+		//	CCFLog()(CFSTR("FAILED converting xml to plist\n"));
+		}
+	} else {
+		//CCFLog()(CFSTR("FAILED creating xml from file\n"));
+	}
+	
+	return successB;
+}
+
+OSStatus		Write_PList(
+	CFPropertyListRef	plist,
+	CFURLRef			urlRef)
+{
+	OSStatus							err	= noErr;
+	ScCFReleaser<CFDataRef>				xmlData;
+	
+	// Convert the property list into XML data.
+	xmlData.Set(CFPropertyListCreateXMLData(kCFAllocatorDefault, plist));
+	ETRL(xmlData.Get() == NULL, "creating xml data");
+	
+	if (!err) {
+		(void)CFURLWriteDataAndPropertiesToResource (
+			urlRef,		// URL to use
+			xmlData,		// data to write
+			NULL,   
+			&err);
+	}
+	
+	ETRL(err, "writing xml");
+	
+	return err;
+}
+
+OSErr	CFDictionaryCreate(CFMutableDictionaryRef *dictP)
+{
+	OSErr		err = noErr;
+	
+	*dictP = CFDictionaryCreateMutable(
+		kCFAllocatorDefault, 0,
+		&kCFTypeDictionaryKeyCallBacks,
+		&kCFTypeDictionaryValueCallBacks);
+	
+	if (*dictP == NULL) {
+		err = 1;
+	}
+	
+	return err;
+}
+
+OSErr	CFArrayCreate(CFMutableArrayRef *arrayP)
+{
+	OSErr		err = noErr;
+	
+	*arrayP = CFArrayCreateMutable(
+		kCFAllocatorDefault, 0,
+		&kCFTypeArrayCallBacks);
+	
+	if (*arrayP == NULL) {
+		err = 1;
+	}
+	
+	return err;
+}
+
+/********************************************************/
+bool	CCFXmlTree::CreateFromData(CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions)
+{
+	CCFDictionary	dict(NULL, false);
+	CFXMLTreeRef	treeRef = CFXMLTreeCreateFromDataWithError(
+			kCFAllocatorDefault, 
+			xmlData, 
+			dataSource, 
+			parseOptions, 
+			kCFXMLNodeCurrentVersion,
+			dict.ImmutableAddressOf());
+
+	_inherited::adopt(treeRef);
+	
+	if (treeRef == NULL) {
+		CCFLog(true)(dict);
+	}
+
+	return treeRef != NULL;
+}
+
+bool	Read_XML(const CFURLRef url, CCFXmlTree& xml)
+{
+	bool						successB = false;
+	ScCFReleaser<CFDataRef>		xmlData;
+	
+	if (CFURLCreateDataAndPropertiesFromResource(
+		kCFAllocatorDefault, url, xmlData.AddressOf(), NULL, NULL, NULL)
+	) {
+		successB = xml.CreateFromData(xmlData.Get(), url, kCFXMLParserSkipWhitespace | kCFXMLParserReplacePhysicalEntities);
+	}
+	
+	return successB;
+}
+
+/********************************************************/
+CFMutableDictionaryRef		CCFDictionary::Copy()
+{
+	return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, Get());
+}
+
+bool				CCFDictionary::ContainsKey(CFStringRef keyRef) {
+	return !!CFDictionaryContainsKey(Get(), keyRef);
+}
+
+bool				CCFDictionary::ContainsKey(const char *utf8Z) {
+	SuperString		dictKey(uc(utf8Z));
+	
+	return ContainsKey(dictKey.ref());
+}
+
+CFTypeRef	CCFDictionary::GetValue(const char* keyZ)
+{
+	SuperString		keyStr(uc(keyZ));
+
+	return GetValue(keyStr.ref());
+}
+
+CFStringRef			CCFDictionary::GetAs_String	(const char *utf8Z)
+{
+	CFStringRef		stringRef((CFStringRef)GetValue(utf8Z));
+	
+	if (stringRef) {
+		CF_ASSERT(CFGetTypeID(stringRef) == CFStringGetTypeID());
+	}
+
+	return stringRef;
+}
+
+CFDictionaryRef			CCFDictionary::GetAs_Dict	(const char *utf8Z)
+{
+	CFDictionaryRef		dictRef((CFDictionaryRef)GetValue(utf8Z));
+
+	if (dictRef) {
+		CF_ASSERT(CFGetTypeID(dictRef) == CFDictionaryGetTypeID());
+	}
+	
+	return dictRef;
+}
+
+SInt32				CCFDictionary::GetAs_SInt32	(const char *utf8Z)
+{
+	CFNumberRef		valRef((CFNumberRef)GetValue(utf8Z));
+	SInt32			valL = 0;
+
+	if (valRef) {
+		CF_ASSERT(CFGetTypeID(valRef) == CFNumberGetTypeID());
+		CFNumberGetValue(valRef, kCFNumberSInt32Type, &valL);
+	}
+
+	return valL;
+}
+
+SInt16				CCFDictionary::GetAs_SInt16	(const char *utf8Z)
+{
+	CFNumberRef		valRef((CFNumberRef)GetValue(utf8Z));
+	SInt16			valL = 0;
+
+	if (valRef) {
+		CF_ASSERT(CFGetTypeID(valRef) == CFNumberGetTypeID());
+		CFNumberGetValue(valRef, kCFNumberSInt16Type, &valL);
+	}
+
+	return valL;
+}
+
+CFDateRef			CCFDictionary::GetAs_Date	(const char *utf8Z)
+{
+	CFDateRef		dateRef((CFDateRef)GetValue(utf8Z));
+	
+	if (dateRef) {
+		CF_ASSERT(CFGetTypeID(dateRef) == CFDateGetTypeID());
+	}
+
+	return dateRef;
+}
+
+CFArrayRef			CCFDictionary::GetAs_Array	(const char *utf8Z)
+{
+	CFArrayRef			arrayRef((CFArrayRef)GetValue(utf8Z));
+	
+	if (arrayRef) {
+		CF_ASSERT(CFGetTypeID(arrayRef) == CFArrayGetTypeID());
+	}
+	
+	return arrayRef;
+}
+
+OSStatus		CFWriteDataToURL(const CFURLRef urlRef, CFDataRef dataRef)
+{
+	OSStatus	err = noErr;
+
+	(void)CFURLWriteDataAndPropertiesToResource (
+		urlRef,			// URL to use
+		dataRef,		// data to write
+		NULL,			// dictRef meta properties to write
+		&err);
+	
+	return err;
+}
+
+void			CCFDictionary::RemoveValue(CFStringRef key)
+{
+	CFDictionaryRemoveValue(Get(), key);
+}
+
+void			CCFDictionary::RemoveValue(const char *utf8Z)
+{
+	RemoveValue(SuperString(uc(utf8Z)).ref());
+}
+/*****************************************/
+Rect			CCFDictionary::GetAs_Rect		(const char *utf8Z)
+{
+	Rect				frameR; structclr(frameR);
+	CCFDictionary		dict(GetAs_Dict(utf8Z), true);
+	
+	if (dict.Get()) {
+		frameR.left		= dict.GetAs_SInt16(DICT_STR_RECT_LEFT);
+		frameR.right	= dict.GetAs_SInt16(DICT_STR_RECT_RIGHT);
+		frameR.top		= dict.GetAs_SInt16(DICT_STR_RECT_TOP);
+		frameR.bottom	= dict.GetAs_SInt16(DICT_STR_RECT_BOTTOM);
+	}
+	
+	return frameR;
+}
+
+void			CCFDictionary::SetValue(const char *utf8Z, const Rect& frameR)
+{
+	CCFDictionary	dict;
+	
+	dict.SetValue(DICT_STR_RECT_LEFT,	frameR.left);
+	dict.SetValue(DICT_STR_RECT_RIGHT,	frameR.right);
+	dict.SetValue(DICT_STR_RECT_TOP,	frameR.top);
+	dict.SetValue(DICT_STR_RECT_BOTTOM,	frameR.bottom);
+
+	SetValue(utf8Z, dict.Get());
+}
+
+/*****************************************/
+bool				CCFDictionary::GetAs_Bool		(const char *utf8Z)
+{
+	CFBooleanRef		boolRef	= (CFBooleanRef)GetValue(utf8Z);
+	
+	if (boolRef) {
+		CF_ASSERT(CFGetTypeID(boolRef) == CFBooleanGetTypeID());
+	}
+
+	return boolRef == kCFBooleanTrue;
+}
+
+void				CCFDictionary::SetValue			(const char *utf8Z, bool valB)
+{
+	SetValue(utf8Z, valB ? kCFBooleanTrue : kCFBooleanFalse);
+}
+/*****************************************/
+float				CCFDictionary::GetAs_Float		(const char *utf8Z)
+{
+	float				valF = 0;
+	CFNumberRef			valRef((CFNumberRef)GetValue(utf8Z));
+	
+	if (valRef) {
+		CF_ASSERT(CFGetTypeID(valRef) == CFNumberGetTypeID());
+		CFNumberGetValue(valRef, kCFNumberFloatType, &valF);
+	}
+		
+	return valF;
+}
+
+void				CCFDictionary::SetValue			(const char *utf8Z, float valF)
+{
+	ScCFReleaser<CFNumberRef>	numberRef(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &valF));
+
+	SetValue(utf8Z, numberRef.Get());
+}
+
+/*****************************************/
+RGBColor			CCFDictionary::GetAs_Color		(const char *utf8Z)
+{
+	RGBColor			valR		= { 0, 0, 0 };
+	CCFDictionary		dict(GetAs_Dict(utf8Z), true);
+	
+	if (dict.Get()) {
+		valR.red		= (UInt16)GetAs_UInt32(DICT_STR_COLOR_RED);
+		valR.green		= (UInt16)GetAs_UInt32(DICT_STR_COLOR_GREEN);
+		valR.blue		= (UInt16)GetAs_UInt32(DICT_STR_COLOR_BLUE);
+	}
+	
+	return valR;
+}
+
+void				CCFDictionary::SetValue(const char *utf8Z, const RGBColor& value)
+{
+	CCFDictionary		dict;
+	
+	dict.SetValue(DICT_STR_COLOR_RED,	(UInt32)value.red);
+	dict.SetValue(DICT_STR_COLOR_GREEN, (UInt32)value.green);
+	dict.SetValue(DICT_STR_COLOR_BLUE,	(UInt32)value.blue);
+	
+	SetValue(utf8Z, dict.Get());
+}
+/*****************************************/
+
+CFNumberRef			CFNumberCreateWithSInt32(SInt32 valL)
+{
+	return CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &valL);
+}
+
+void				CCFDictionary::SetValue(CFStringRef keyRef, SInt32 value)
+{
+	ScCFReleaser<CFNumberRef>	numberRef(CFNumberCreateWithSInt32(value));
+	
+	SetValue(keyRef, numberRef.Get());
+}
+
+void				CCFDictionary::SetValue(const char *utf8Z, SInt32 value)
+{
+	ScCFReleaser<CFNumberRef>	numberRef(CFNumberCreateWithSInt32(value));
+	
+	SetValue(utf8Z, numberRef.Get());
+}
+
+void				CCFDictionary::SetValue(const char *utf8Z, SInt16 value)
+{
+	ScCFReleaser<CFNumberRef>	numberRef(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &value));
+	
+	SetValue(utf8Z, numberRef.Get());
+}
+
+void				CCFDictionary::SetValue(const char *utf8Z, CFTypeRef val)
+{
+	SuperString		keyStr(uc(utf8Z));
+	
+	SetValue(keyStr.ref(), val);
+}
+ 
+void				CCFDictionary::SetValue(const char *utf8Z, const SuperString& value)
+{
+	SetValue(utf8Z, value.ref());
+}
+
+/**********************************************************************/
+#ifndef __WIN32__
+CFDateRef 		CFDateCreateWithLongDateTime(const LongDateTime &ldt)
+{
+	CFDateRef		dateRef = NULL;
+	
+	if (ldt != 0) {
+		OSStatus		err		= noErr;
+		CFAbsoluteTime	absT;
+		
+		err = UCConvertLongDateTimeToCFAbsoluteTime(ldt, &absT);
+		if (!err) {
+			dateRef = CFDateCreate(kCFAllocatorDefault, absT);
+		}
+	}
+	
+	return dateRef;
+}
+
+LongDateTime	CFDateToLongDateTime(CFDateRef dateRef)
+{
+	LongDateTime		ldt;	structclr(ldt);
+	
+	if (dateRef) {
+		CFAbsoluteTime		absT = CFDateGetAbsoluteTime(dateRef);
+
+		UCConvertCFAbsoluteTimeToLongDateTime(absT, &ldt);
+	}
+
+	return ldt;
+}
+#endif
+
+CFDateRef		CFDateCreateWithGregorian(const CFGregorianDate& gregDate)
+{
+	ScCFReleaser<CFCalendarRef>		calendarRef(CFCalendarCopyCurrent());
+	ScCFReleaser<CFTimeZoneRef>		timeZoneRef(CFCalendarCopyTimeZone(calendarRef));
+	
+	return CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(gregDate, timeZoneRef));
+}
+
+CFStringRef		CFStringCreateWithDate(CFDateRef dateRef, bool showTimeB)
+{
+	ScCFReleaser<CFLocaleRef>			localeRef(CFLocaleCopyCurrent());
+	ScCFReleaser<CFDateFormatterRef>	formatterRef(CFDateFormatterCreate(
+		kCFAllocatorDefault, localeRef, 
+		kCFDateFormatterShortStyle, showTimeB ? kCFDateFormatterShortStyle : kCFDateFormatterNoStyle));
+	CFStringRef							ref(CFDateFormatterCreateStringWithDate(
+		kCFAllocatorDefault, formatterRef, dateRef));
+	
+	return (CFStringRef)CFRetainDebug(ref, false); // don't retain, just track that it's existing refcount
+}
+
+CFStringRef		CFStringCreateWithNumber(CFNumberRef numRef)
+{
+	ScCFReleaser<CFLocaleRef>			localeRef(CFLocaleCopyCurrent());
+	ScCFReleaser<CFNumberFormatterRef>	formatterRef(CFNumberFormatterCreate(
+		kCFAllocatorDefault, localeRef, kCFNumberFormatterNoStyle));
+	CFStringRef							ref(CFNumberFormatterCreateStringWithNumber(
+		kCFAllocatorDefault, formatterRef, numRef));
+
+	return (CFStringRef)CFRetainDebug(ref, false);
+}
+
+/*
+CFStringRef		CFCopyBundleResourcesFSPath()
+{
+	ScCFReleaser<CFBundleRef>		exeRef(CFBundleGetMainBundle(), true);
+	ScCFReleaser<CFURLRef>			exeUrlRef(CFBundleCopyBundleURL(exeRef));
+	SuperString						dirStr(CFURLCopyFileSystemPath(exeUrlRef, kCFURLPlatformPathStyle));
+	
+	dirStr.append(kCFURLPlatformPathSeparator "Contents" kCFURLPlatformPathSeparator "Resources");
+	return dirStr.Retain();
+}
+*/
+
+/**********************************************************************/
+
+#if _KJ_MAC_
+#include "CApp.h"
+
+int		AssertAlert(const char *msgZ, const char *fileZ, long lineL, bool noThrowB)
+{
+	bool	incB = MPTaskIsPreemptive(NULL);
+	
+	if (incB) {
+		++gApp->i_callbackL;
+		noThrowB = true;
+	}
+
+	bool	mainB = gApp->i_callbackL == 0;
+
+	if (incB) {
+		--gApp->i_callbackL;
+	}
+
+	SuperString		formatStr(SSLocalize("Assert Fail: %s, in file: '%s' at line %ld", "eeeks!"));
+	
+	formatStr.ssprintf(NULL, msgZ, fileZ, lineL);
+
+	if (mainB) {
+		MessageAlert(formatStr.utf8Z());
+	} else {
+		PostAlert(formatStr.utf8Z());
+		
+		#ifdef kDEBUG
+		static bool	s_showB = true;
+		if (s_showB) {
+			Debugger();	
+		}
+		#endif
+	}
+	
+	if (!mainB && !noThrowB) {
+		ETX(ERR_Assert_Failed);
+	}
+	
+	return 1;
+}
+#else
+int		AssertAlert(const char *msgZ, const char *fileZ, long lineL, bool noThrowB)
+{
+	SuperString		formatStr("$$$ Assert Fail: %s, in file: '%s' at line %ld\n");
+	
+	formatStr.ssprintf(NULL, msgZ, fileZ, lineL);
+	CCFLog()(formatStr.ref());
+	ReportErr(formatStr.utf8Z(), -1);
+	return 1;
+}
+#endif
diff --git a/CoreFoundation/examples/CFTest/source/shared/CFUtils.h b/CoreFoundation/examples/CFTest/source/shared/CFUtils.h
new file mode 100644
index 0000000..c552223
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/shared/CFUtils.h
@@ -0,0 +1,623 @@
+#ifndef _H_CFUtils
+#define _H_CFUtils
+
+#include <vector>
+#include <map>
+#include <CoreFoundation/CoreFoundation.h>
+
+#ifndef _CFTEST_
+#include "XPlatConditionals.h"
+#endif
+
+#define		loop(_n)				for (long _indexS = 0, _maxS = (_n); _indexS < _maxS; _indexS++)
+#define		loop2(_n)				for (long _index2S = 0, _max2S = (_n); _index2S < _max2S; _index2S++)
+#define		loop_reverse(_n)		for (long _indexS = ((_n) - 1); _indexS >= 0; _indexS--)
+#define		loop_range(_begin, _end)	for (long _indexS = _begin, _maxS = (_end); _indexS < _maxS; _indexS++)
+#define		loop2_range(_begin, _end)	for (long _index2S = _begin, _max2S = (_end); _index2S < _max2S; _index2S++)
+#define		loop_reverse(_n)	for (long _indexS = ((_n) - 1); _indexS >= 0; _indexS--)
+
+#define		CF_ASSERT(_foo)	if (!(_foo)) {					\
+	AssertAlert(#_foo, __FILE__, (long)__LINE__, true);	}
+
+int		AssertAlert(const char *msgZ, const char *fileZ, long lineL, bool noThrowB = false);
+
+#define		kJams_LogFileName		"kJams Log file.txt"
+
+#if _KJ_MAC_
+	#include "Standard.h"
+
+	#ifdef kDEBUG
+		#define		TRACK_RETAINS	1
+	#else
+		#define		TRACK_RETAINS	0
+	#endif
+
+	#if TRACK_RETAINS
+		class	ScTrackRetains {
+			void	*i_dataP;
+			
+			public:
+			ScTrackRetains();
+			~ScTrackRetains();
+		};
+		
+		CFTypeRef	CFRetainDebug(CFTypeRef cf, bool do_itB = true);
+		void		CFReleaseDebug(CFTypeRef cf);
+	#else
+		class	ScTrackRetains {};
+
+		inline CFTypeRef	CFRetainDebug(CFTypeRef cf, bool do_itB = true) {
+			return do_itB ? CFRetain(cf) : cf;
+		}
+
+		#define	CFReleaseDebug(_x)		CFRelease(_x)
+	#endif
+#else
+	
+	void	DebugReport(const char *utf8Z, OSStatus err);
+
+	#define		kKiloByte				1024
+	#define		kKiloBytef				1024.0f
+	#define		kMegaByte				(kKiloByte * kKiloByte)
+	#define		kGigaByte				(kMegaByte * kKiloByte)
+	#define		kTeraByte				(kGigaByte * kKiloByte)
+
+	#ifdef __MWERKS__
+		typedef struct {
+		  short               top;
+		  short               left;
+		  short               bottom;
+		  short               right;
+		} Rect;
+
+		struct RGBColor {
+		  unsigned short      red;                    /*magnitude of red component*/
+		  unsigned short      green;                  /*magnitude of green component*/
+		  unsigned short      blue;                   /*magnitude of blue component*/
+		};
+		typedef struct RGBColor		RGBColor;
+		typedef char *				Ptr;
+		typedef UInt32				OSType;
+		
+		#define __MACTYPES__
+	#else
+		#ifdef _CFTEST_
+			#ifdef __WIN32__
+				#include <QuickDraw.h>
+			#else
+				#include <QD/QuickDraw.h>
+			#endif
+		#else 
+			#include "QuickDraw.h"
+		#endif
+	#endif
+
+	#ifndef _CFTEST_
+		#ifndef _CONSTRUCTOR_
+			#include "XErrors.h"
+		#endif
+	#endif
+
+	#ifndef _H_XErrors
+		#define ERR_(_ERR, FUNC)	if (!_ERR) { _ERR = (FUNC); }
+		#define ERR(FUNC)			ERR_(err, FUNC);
+		#define	ERRL(FUNC, _str)	if (!err) { ERR(FUNC); if (err) { 	LogErr("### Error " _str, err); }}
+		#define	ETRL(_exp, _str)	{ ERRL(_exp, _str); if (err) { return err;} }
+
+		#define BEX_THROW(ERR)		throw ((long) ERR)	
+		#define ETX(EXPR)			{ OSStatus _err = (EXPR); if (_err) BEX_THROW(_err); }
+	#endif
+
+	#define	memclr(p, s)	std::memset(p, 0, s)
+	#define	structclr(p)	memclr(&p, sizeof(p))
+
+	#ifndef _H_BasicTypes
+		typedef std::basic_string<UTF8Char, std::char_traits<UTF8Char>, std::allocator<UTF8Char> > ustring;
+
+		#define uc(_foo) (unsigned char *)(_foo)
+
+		typedef std::vector<char>			CharVec;
+		typedef std::vector<UTF8Char>		UCharVec;
+		typedef std::vector<UTF16Char>		UTF16Vec;
+	#endif
+
+	#define noErr	0
+
+	inline CFTypeRef	CFRetainDebug(CFTypeRef cf, bool do_itB = true) {
+		return do_itB ? CFRetain(cf) : cf;
+	}
+
+	#define	CFReleaseDebug(_x)		CFRelease(_x)
+
+	#if OPT_MACOS
+		#define	COMPILE_FOR_10_4	(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)	//	1	//	defined(__GNUC__)
+	#endif
+
+#endif
+
+#if OPT_MACOS
+	#define		kCFURLPlatformPathStyle			kCFURLPOSIXPathStyle
+	#define		kCFURLPlatformPathSeparator		"/"
+#else
+	#define		kCFURLPlatformPathStyle			kCFURLWindowsPathStyle
+	#define		kCFURLPlatformPathSeparator		"\\"
+#endif
+
+
+/***************************************************************************************/
+typedef std::vector<CFStringRef>	StringRefVec;
+
+static	inline CFRange		CFStrGetRange(CFStringRef ref) {
+	return CFRangeMake(0, CFStringGetLength(ref));
+}
+
+static	inline CFRange		CFArrayGetRange(CFArrayRef ref) {
+	return CFRangeMake(0, CFArrayGetCount(ref));
+}
+
+OSErr	CFDictionaryCreate(CFMutableDictionaryRef *dictP);
+OSErr	CFArrayCreate(CFMutableArrayRef *arrayP);
+
+OSStatus		CFWriteDataToURL(const CFURLRef urlRef, CFDataRef dataRef);
+
+bool			Read_PList(const CFURLRef &url, CFDictionaryRef *plistP);
+OSStatus		Write_PList(
+	CFPropertyListRef	plist,
+	CFURLRef			urlRef);
+
+CFStringRef		CFStringCreateWithDate(CFDateRef dateRef, bool showTimeB = false);
+CFStringRef		CFStringCreateWithNumber(CFNumberRef numRef);
+CFDateRef		CFDateCreateWithGregorian(const CFGregorianDate& gregDate);
+CFNumberRef		CFNumberCreateWithSInt32(SInt32 valL);
+
+CFStringRef		CFCopyBundleResourcesFSPath();
+
+#ifndef __WIN32__
+typedef SInt64                          LongDateTime;
+	CFDateRef 		CFDateCreateWithLongDateTime(const LongDateTime &ldt);
+	LongDateTime	CFDateToLongDateTime(CFDateRef dateRef);
+#endif
+
+/***************************************************************************************/
+
+template <typename T>
+class	ScCFReleaser {
+	T	i_typeRef;
+	
+	public:
+	ScCFReleaser(T typeRef = NULL, bool retainB = false) : i_typeRef(typeRef)	{
+		if (retainB) {
+			Retain();
+		}
+	}
+	
+	~ScCFReleaser() {
+		Release();
+	}
+	
+	CFIndex RetainCount()	{
+		CFIndex		countL = 0;
+		
+		if (i_typeRef) {
+			 countL = CFGetRetainCount(i_typeRef);
+		}
+		
+		return countL;
+	}
+	
+	T	Retain()	{	if (i_typeRef) CFRetainDebug(i_typeRef);	return i_typeRef;	}
+	T	Release()	{
+		CFIndex		countL = RetainCount();
+		
+		if (i_typeRef) {
+			CFReleaseDebug(i_typeRef);
+		}
+
+		if (countL == 1) {
+			i_typeRef = NULL;
+		}
+		
+		return i_typeRef;
+	}
+	
+	T	Get() const		{	return i_typeRef;	}
+	T	Set(T typeRef)	{
+		
+		if (typeRef) {
+			CFRetainDebug(typeRef);
+		}
+		
+		Release();
+		
+		i_typeRef = typeRef;
+		return i_typeRef;
+	}
+	
+	T*	AddressOf()	{	return &i_typeRef;	}
+	
+	operator CFTypeRef()	{	return i_typeRef;	}
+	operator T()			{	return i_typeRef;	}
+	operator T*()			{	return AddressOf();	}
+	
+	T	operator =(T typeRef)	{	return Set(typeRef);	}
+	
+	T	transfer()	{
+		T	ret = i_typeRef;
+		
+		i_typeRef = NULL;
+		return ret;
+	}
+	
+	T	adopt(T typeRef)	{
+		Set(NULL);
+		i_typeRef = typeRef;
+		return i_typeRef;
+	}
+	
+	void	LogCount(const char *nameZ) {	S_LogCount(i_typeRef, nameZ);	}
+};
+
+/***************************************************************************************/
+class	CDictionaryIterator {
+	CFDictionaryRef		i_dict;
+	
+	static	void 	CB_S_Operator(const void *key, const void *value, void *context) {
+		CDictionaryIterator		*thiz = (CDictionaryIterator *)context;
+		
+		thiz->operator()((CFStringRef)key, value);
+	}
+	
+public:
+	CDictionaryIterator(CFDictionaryRef dict) : i_dict(dict) { }
+	
+	void	for_each() {
+		CFDictionaryApplyFunction(i_dict, CB_S_Operator, this);
+	}
+	
+	virtual void	operator()(CFStringRef key, const void *value) {
+		
+	}
+};
+
+template <class Function>
+class CDict_ForEach : public CDictionaryIterator {
+	Function		i_f;
+	
+public: CDict_ForEach(CFDictionaryRef dict, Function f) : CDictionaryIterator(dict), i_f(f) { }
+	
+	void	operator()(CFStringRef keyRef, const void *valRef) {
+		i_f(keyRef, valRef);
+	}
+};
+
+template <class Function>
+inline	void	dict_for_each(CFDictionaryRef dict, Function f)
+{
+	if (dict) {
+		CDict_ForEach<Function>		cdict(dict, f);
+		
+		cdict.for_each();
+	}
+}
+
+#define		CFArrayApplyFunctionToAll(_array, _cb, _data) \
+CFArrayApplyFunction((CFArrayRef)_array, CFArrayGetRange((CFArrayRef)_array), _cb, _data)
+
+class	CArrayIterator {
+	CFArrayRef		i_array;
+	
+	static	void 	CB_S_Operator(const void *value, void *context) {
+		CArrayIterator		*thiz = (CArrayIterator *)context;
+		
+		thiz->operator()(value);
+	}
+	
+public:
+	CArrayIterator(CFArrayRef array) : i_array(array) { }
+	
+	void	for_each() {
+		CFArrayApplyFunctionToAll(i_array, CB_S_Operator, this);
+	}
+	
+	virtual void	operator()(const void *value) { }
+};
+
+template <class Function>
+class CArray_ForEach : public CArrayIterator {
+	Function		i_f;
+	
+public: CArray_ForEach(CFArrayRef dict, Function f) : CArrayIterator(dict), i_f(f) { }
+	
+	void	operator()(CFTypeRef valRef) {
+		i_f(valRef);
+	}
+};
+
+template <class Function>
+inline	void	array_for_each(CFArrayRef array, Function f)
+{
+	if (array) {
+		CArray_ForEach<Function>		carray(array, f);
+		
+		carray.for_each();
+	}
+}
+
+#define		DICT_STR_RECT_LEFT		"Left"
+#define		DICT_STR_RECT_RIGHT		"Right"
+#define		DICT_STR_RECT_TOP		"Top"
+#define		DICT_STR_RECT_BOTTOM	"Bottom"
+
+#define		DICT_STR_COLOR_VALUE	"Value"
+#define		DICT_STR_COLOR_RED		"Red"
+#define		DICT_STR_COLOR_GREEN	"Green"
+#define		DICT_STR_COLOR_BLUE		"Blue"
+
+class SuperString;
+/*****************************************************
+ usage: (same for CCFArray)
+ CCFDictionary		dict;							//	allocate a dictionary
+ CCFDictionary		dict(existingDict);				//	retain existing dictionary (WILL be released in d'tor, transfers ownership)
+ CCFDictionary		dict(existingDict, true);		//	use existing dictionary (will NOT be released, caller responsible for releasing)
+ CCFDictionary		dict(NULL, true);				//	NULL dictionary, ONLY use if next instruction is .[Immutable]AddressOf(), use with legacy C APIs
+ */
+class CCFDictionary : public ScCFReleaser<CFMutableDictionaryRef> {
+	typedef	ScCFReleaser<CFMutableDictionaryRef>	_inherited;
+
+	void	validate() {
+		if (Get() == NULL) {
+			realloc();
+		}
+	}
+
+	public:
+	CCFDictionary(CFDictionaryRef dictRef0 = NULL, bool retainB = false) : 
+		_inherited((CFMutableDictionaryRef)dictRef0, retainB) 
+	{ if (dictRef0 == NULL && retainB == false) {validate();} }
+
+	CFDictionaryRef*	ImmutableAddressOf()	{	return (CFDictionaryRef *)AddressOf();	}
+	operator CFDictionaryRef() const			{	return Get();	}
+
+	void	realloc() {
+		CFMutableDictionaryRef	dictRef = CFDictionaryCreateMutable(
+			kCFAllocatorDefault, 0,
+			&kCFTypeDictionaryKeyCallBacks,
+			&kCFTypeDictionaryValueCallBacks);
+
+		if (dictRef == NULL) {
+			ETX(1);
+		}
+
+		_inherited::adopt(dictRef);
+	};
+	
+	CFMutableDictionaryRef		Copy();
+
+	bool						ContainsKey(CFStringRef keyRef);
+	bool						ContainsKey(const char *utf8Z);
+	
+	bool						empty()	{	return size() == 0;		}
+	CFIndex						size() {
+		return CFDictionaryGetCount(Get());
+	}
+
+	/*********************************************/
+	CFTypeID			GetType(CFStringRef key) {
+		CFTypeID		typeID(CFNullGetTypeID());
+		CFTypeRef		valRef(GetValue(key));
+
+		if (valRef) {
+			typeID = CFGetTypeID(valRef);
+		}
+
+		return typeID;
+	}
+
+	inline CFTypeRef	GetValue(CFStringRef key) {
+		CFTypeRef		typeRef = NULL;
+		
+		if (ContainsKey(key)) {
+			typeRef = CFDictionaryGetValue(Get(), key);
+		}
+		
+		return typeRef;
+	}
+
+	inline CFTypeRef	GetValue(const char* keyZ);
+
+	CFStringRef			GetAs_String	(const char *utf8Z);
+	Rect				GetAs_Rect		(const char *utf8Z);
+	bool				GetAs_Bool		(const char *utf8Z);
+	SInt32				GetAs_SInt32	(const char *utf8Z);
+	UInt32				GetAs_UInt32	(const char *utf8Z)		{	return (UInt32)GetAs_SInt32(utf8Z);	}
+	SInt16				GetAs_SInt16	(const char *utf8Z);
+	float				GetAs_Float		(const char *utf8Z);
+	CFDictionaryRef		GetAs_Dict		(const char *utf8Z);
+	CFArrayRef			GetAs_Array		(const char *utf8Z);
+	CFDateRef			GetAs_Date		(const char *utf8Z);
+	RGBColor			GetAs_Color		(const char *utf8Z);
+	Ptr					GetAs_Ptr		(const char *utf8Z)		{	return (Ptr)GetAs_UInt32(utf8Z);	}
+
+	/*********************************************/
+	void				RemoveValue		(CFStringRef key);
+	void				RemoveValue		(const char *utf8Z);
+	
+	virtual void		SetRealValue(CFTypeRef key, CFTypeRef val) {
+		CFDictionarySetValue(Get(), key, val);
+	}
+
+	inline void		SetValue(CFTypeRef key, CFTypeRef val) {
+		if (key && val) {
+			SetRealValue(key, val);
+		}
+	}
+
+	void				SetValue(CFStringRef ref, SInt32 value);
+
+	void				SetValue(const char *utf8Z, CFTypeRef val);
+
+	void				SetValue(const char *utf8Z, const Rect& frameR);
+	void				SetValue(const char *utf8Z, const char *utf8ValZ);
+	void				SetValue(const char *utf8Z, bool value);
+	void				SetValue(const char *utf8Z, SInt32 value);
+	void				SetValue(const char *utf8Z, UInt32 value)	{	SetValue(utf8Z, (SInt32)value);		}
+	void				SetValue(const char *utf8Z, SInt16 value);
+	void				SetValue(const char *utf8Z, float value);
+	void				SetValue(const char *utf8Z, const SuperString& value);
+	void				SetValue(const char *utf8Z, const RGBColor& value);
+	void				SetValue(const char *utf8Z, Ptr valueP)	{	SetValue(utf8Z, (UInt32)valueP);	}
+
+	/*********************************************/
+	template <class Function>
+	inline	void	for_each(Function f) {
+		dict_for_each(Get(), f);
+	}
+};
+
+class CCFArray : public ScCFReleaser<CFMutableArrayRef> {
+	typedef	ScCFReleaser<CFMutableArrayRef>	_inherited;
+
+	void	validate() {
+		if (Get() == NULL) {
+			realloc();
+		}
+	}
+
+	public:
+	CCFArray(CFArrayRef arrayRef0 = NULL, bool retainB = false) : 
+		_inherited((CFMutableArrayRef)arrayRef0, retainB)
+	{ if (arrayRef0 == NULL && retainB == false) {validate();} }
+	
+	void	realloc() {
+		CFMutableArrayRef	arrayRef = CFArrayCreateMutable(
+			kCFAllocatorDefault, 0,
+			&kCFTypeArrayCallBacks);
+
+		if (arrayRef == NULL) {
+			ETX(1);	//	errCppbad_alloc);
+		}
+
+		_inherited::adopt(arrayRef);
+	};
+	
+	bool				empty()	{	return size() == 0;		}
+	CFIndex				size() {
+		return CFArrayGetCount(Get());
+	}
+
+	CFTypeRef			operator[](CFIndex idx) {
+		return CFArrayGetValueAtIndex(Get(), idx);
+	}
+
+	CFIndex				GetFirstIndexOfValue(CFTypeRef val) {
+		return CFArrayGetFirstIndexOfValue(Get(), CFArrayGetRange(Get()), val);
+	}
+	
+	void				push_back(SInt32 val) {
+		ScCFReleaser<CFNumberRef>	numberRef(CFNumberCreateWithSInt32(val));
+
+		push_back(numberRef);
+	}
+
+	void				push_back(CFTypeRef val) {
+		CFArrayAppendValue(Get(), val);
+	}
+
+	void				insert(CFIndex idx, CFTypeRef val) {
+		CFArrayInsertValueAtIndex(Get(), idx, val);
+	}
+
+	SInt32				GetIndValAs_SInt32(CFIndex idx) 
+	{
+		CFNumberRef			numberRef((CFNumberRef)operator[](idx));
+		SInt32				valL = 0;
+
+		if (numberRef) {
+			CFNumberGetValue(numberRef, kCFNumberSInt32Type, &valL);
+		}
+
+		return valL;
+	}
+	
+	void				set_ind_value(CFIndex idx, CFTypeRef val) {
+		CFArraySetValueAtIndex(Get(), idx, val);
+	}
+
+	template <class Function>
+	inline	void	for_each(Function f) {
+		array_for_each(Get(), f);
+	}
+};
+/*****************************************/
+class CCFXMLNode {	//	does NOT retain OR release
+	CFXMLNodeRef		i_nodeRef;
+
+	public:
+	CCFXMLNode(CFXMLNodeRef nodeRef) : i_nodeRef(nodeRef) { }
+
+	CFXMLNodeTypeCode		GetTypeCode()	{	return CFXMLNodeGetTypeCode(i_nodeRef);	}
+	CFXMLElementInfo*		GetInfoPtr()	{	return (CFXMLElementInfo *)CFXMLNodeGetInfoPtr(i_nodeRef);	}
+	CFStringRef				GetString()		{	return CFXMLNodeGetString(i_nodeRef);	}
+	operator				CFXMLNodeRef()	{	return i_nodeRef;	}
+};
+
+class CCFXmlTree : public ScCFReleaser<CFXMLTreeRef> {
+	typedef	ScCFReleaser<CFXMLTreeRef>	_inherited;
+
+	public:
+	CCFXmlTree(CFXMLTreeRef treeRef0 = NULL, bool retainB = false) : _inherited(treeRef0, retainB) { }
+
+	bool	CreateFromData(CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions = kCFXMLParserSkipWhitespace);
+	
+	CFXMLNodeRef		GetNode()	{	return CFXMLTreeGetNode(Get());	}
+	CFIndex				size() {
+		return CFTreeGetChildCount(Get());
+	}
+
+	CFTypeRef			GetValueAtIndex(CFIndex idx) {
+		return CFTreeGetChildAtIndex(Get(), idx);
+	}
+
+	CFXMLTreeRef		GetChild(CFStringRef childNameRef) {
+		CCFXmlTree	childTree;
+
+		loop (size()) {
+			childTree.Set((CFTreeRef)GetValueAtIndex(_indexS));
+
+			CCFXMLNode	childNode(childTree.GetNode());
+
+			if (::CFStringCompare(childNode.GetString(), childNameRef, kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+				return childTree.Get();
+			}
+		}
+		return NULL;
+	}
+
+	template <class Function>
+	inline	void	for_each(Function f, short levelS = 0) {
+		loop (size()) {
+			CCFXmlTree	xmlTreeNode((CFXMLTreeRef)GetValueAtIndex(_indexS), true);
+			CCFXMLNode	node(xmlTreeNode.GetNode());
+
+			f(node, levelS);
+			xmlTreeNode.for_each(f, levelS + 1);
+		}
+	}
+};
+
+bool		Read_XML(const CFURLRef url, CCFXmlTree& xml);
+
+/*****************************************************/
+//	logging
+class CCFLog {
+	bool	i_crB;
+	
+public: 
+	CCFLog(bool crB = false) : i_crB(crB) { }
+	
+	void operator()(CFTypeRef valRef);
+	//inline void operator()(void const* valRef)	{	operator()((CFTypeRef)valRef);	}
+	void operator()(CFStringRef keyRef, CFTypeRef valRef);
+};
+
+#endif
\ No newline at end of file
diff --git a/CoreFoundation/examples/CFTest/source/shared/SuperString.cpp b/CoreFoundation/examples/CFTest/source/shared/SuperString.cpp
new file mode 100644
index 0000000..b2204d2
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/shared/SuperString.cpp
@@ -0,0 +1,1061 @@
+/*
+ *  SuperString.cpp
+ *  CFTest
+ *
+ *  Created by David M. Cotter on 6/25/08.
+ *  Copyright 2008 David M. Cotter. All rights reserved.
+ *
+ */
+#include "stdafx.h"
+#include "CFUtils.h"
+
+#if _KJ_MAC_
+	#include "CApp.h"
+	#include "StringUtils.h"
+	#include "MessageAlert.h"
+#else
+
+	#include "SuperString.h"
+
+	#ifdef _CFTEST_
+		#include <algorithm>
+	#else
+		#include "CLocalize.h"
+		#include <XErrorDialogs.h>
+	#endif
+#endif
+
+#ifndef __WIN32__
+
+	#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+		enum {
+			kCFCompareDiacriticInsensitive = 128, /* If specified, ignores diacritics (o-umlaut == o) */
+			kCFCompareWidthInsensitive = 256, /* If specified, ignores width differences ('a' == UFF41) */
+			kCFCompareForcedOrdering = 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) */
+		};
+	#endif
+
+#endif
+
+#if _KJ_MAC_
+	ushort		GetSystemVers(void);
+	#define		diacritic_insensitiveB		(gApp && gApp->i_prefs && gApp->i_prefs->i_pref.diacritic_insensitive_searchB)
+#else
+	bool		g_pref_diacritic_insensitive_searchB	= true;
+	#define		diacritic_insensitiveB					g_pref_diacritic_insensitive_searchB
+
+	#ifdef _KJAMSX_
+		unsigned short		GetSystemVers(void);
+	#else
+		static unsigned short		GetSystemVers(void) {
+			return 0x1050;	//	fake it to be OS 10.5
+		}
+	#endif
+#endif
+
+#if _KJ_MAC_
+void			DebugReport(const SuperString& errTypeStr, OSStatus err)
+{
+	#ifdef kDEBUG
+		ReportErr(errTypeStr, err);
+	#else
+		LogErr(errTypeStr.utf8Z(), err);
+	#endif
+}
+
+void		LogErr(const char *utf8Z, OSStatus err, bool crB, bool unixB)
+{
+	if (err && gApp->Logging()) {
+		if (err != eofErr && err != userCanceledErr) {
+			int	i = 1;
+		}
+		
+		SuperString		str;
+		
+		if (unixB) {
+			str.Set(UnixErrStr(uc(utf8Z), err));
+		} else {
+			str.Set(ErrStr(uc(utf8Z), err));
+		}
+		
+		Log(str.utf8Z(), crB);
+	}
+}
+
+void			ReportErr(const SuperString& errTypeStr, OSStatus err, bool unixB)
+{
+	SuperString			errStr;
+	SuperString			str;
+	
+	if (unixB) {
+		errStr.Set(SSLocalize("Unix Error:", "bummer"));
+		str.Set(UnixErrStr(errTypeStr, err));
+	} else {
+		errStr.Set(SSLocalize("Error", "bummer"));
+		str.Set(ErrStr(errTypeStr, err));
+	}
+	
+	MessageAlert(errStr.utf8Z(), str.utf8Z());
+}
+
+#else
+void		LogErr(const char *utf8Z, OSStatus err, bool crB, bool unixB)
+{
+	if (err) {	//	&& gApp->Logging()) {
+		SuperString		keyStr(uc(utf8Z));
+		SuperString		valStr((long)err);
+		CCFLog			logger(crB);
+		
+		logger(keyStr.ref(), valStr.ref());
+	}
+}
+
+void	DebugReport(const char *utf8Z, OSStatus err)
+{
+	#ifdef rDEBUG
+		AlertID(utf8Z, err);
+	#else
+		LogErr(utf8Z, err);
+	#endif
+}
+
+void			ReportErr(const SuperString& errTypeStr, OSStatus err, bool unixB)
+{
+	#ifdef _CFTEST_
+		LogErr(errTypeStr.utf8Z(), err);
+	#else
+		AlertID(errTypeStr.utf8Z(), err);
+	#endif
+}
+
+#endif
+
+CFStringRef			CFStrCreateWithCurAbsTime()
+{
+	CFAbsoluteTime		curTime(CFAbsoluteTimeGetCurrent());
+	UInt64				milliSeconds((UInt64)(curTime * 1000));	//	milliseconds
+	CFDictionaryRef		dictRef(NULL);
+
+	return CFStringCreateWithFormat(kCFAllocatorDefault, dictRef, CFSTR("%qu"), milliSeconds);
+}
+
+char*	strrstr(const char* stringZ, const char* findZ)
+{
+	bool		firstB = true, doneB = false;
+	const char	*nextZ;
+	
+	do {
+		if (firstB) {
+			nextZ = strstr(stringZ, findZ);
+		} else {
+			nextZ = strstr(&stringZ[1], findZ);
+		}
+		
+		doneB = nextZ == NULL;
+		
+		if (!doneB) {
+			stringZ = nextZ;
+		} else if (firstB) {
+			stringZ = NULL;
+		}
+		
+		firstB = false;		
+	} while (!doneB);
+	
+	return const_cast<char *>(stringZ);
+}
+
+const char *		CopyLongToC(long valL)
+{
+	static	char	s_bufAC[256];
+	
+	sprintf(s_bufAC, "%d", valL);
+	return s_bufAC;
+}
+
+float			CStringToFloat(const char *numF)
+{
+	float	valF = 0;
+	
+	sscanf(numF, "%f", &valF);
+	return valF;
+}
+
+SuperString		FormatBytes(UInt64 bytes)
+{
+	char	buf[1024];
+	double	valF	= (double)bytes;
+	char	*labelZ	= "K";
+	
+	if (bytes < kKiloByte) {
+		labelZ	= "b";
+	} else {
+		valF /= kKiloBytef;
+		
+		if (valF < kKiloByte) {
+			labelZ	= "K";
+		} else {
+			valF /= kKiloBytef;
+
+			if (valF < kKiloByte) {
+				labelZ	= "MB";
+			} else {
+				valF /= kKiloBytef;
+
+				if (valF < kKiloByte) {
+					labelZ	= "GB";
+				} else {
+					valF /= kKiloBytef;
+
+					labelZ	= "TB";
+				}
+			}
+		}
+	}
+	
+	sprintf(buf, "%.1f %s", valF, labelZ);
+	return buf;
+}
+
+/********************************************************/
+bool		CFStringIsEmpty(CFStringRef nameRef)
+{
+	return nameRef == NULL || CFStringGetLength(nameRef) == 0;
+}
+
+CFStringEncoding	s_file_encoding = kCFStringEncodingInvalidId;
+
+bool				IsDefaultEncodingSet()
+{
+	return s_file_encoding != kCFStringEncodingInvalidId;
+}
+
+void				SetDefaultEncoding(CFStringEncoding encoding)
+{
+	s_file_encoding = encoding;
+}
+
+static CFStringEncoding	ValidateEncoding(CFStringEncoding encoding = kCFStringEncodingInvalidId)
+{
+	if (encoding == kCFStringEncodingInvalidId) {
+		encoding = s_file_encoding;
+		
+		if (encoding == kCFStringEncodingInvalidId) {
+			s_file_encoding = kCFStringEncodingASCII;
+			CCFLog()(CFSTR("$$$ Default encoding not set!\n"));
+		}
+	}
+	
+	return encoding;
+}
+
+#ifndef _KJAMSX_
+	class Asciify {
+		public: void operator()(char &ch) {
+			if (ch < 32 || ch > 126) ch = '?';
+		}
+	};
+#endif
+
+CFStringRef		CFStringCreateWithC(
+	const char *		bufZ, 
+	CFStringEncoding	encoding)
+{
+	if (bufZ) {
+		encoding = ValidateEncoding(encoding);
+		
+		CFStringRef		cf = NULL;
+		
+		cf = CFStringCreateWithCString(kCFAllocatorDefault, bufZ, encoding);
+		if (!cf) cf = CFStringCreateWithCString(kCFAllocatorDefault, bufZ, kCFStringEncodingWindowsLatin1);
+		if (!cf) cf = CFStringCreateWithCString(kCFAllocatorDefault, bufZ, kCFStringEncodingISOLatin1);
+		if (!cf) cf = CFStringCreateWithCString(kCFAllocatorDefault, bufZ, kCFStringEncodingMacRoman);
+		
+		if (!cf) {
+			#if _KJ_MAC_
+				CharVec			newBuf;
+				
+				newBuf.assign(&bufZ[0], &bufZ[strlen(bufZ)]);
+				std::for_each(newBuf.begin(), newBuf.end(), Asciify());
+				bufZ = &newBuf[0];
+
+				static	CMutex_long		s_incdec;
+
+				if (s_incdec.inc() == 1) {
+					ScCFReleaser<CFStringRef>	encRef(CFStringGetNameOfEncoding(encoding));
+					SuperString					formatStr("Illegal String %s with encoding: [%s], the encoding is: %s\n");
+					
+					formatStr.ssprintf(
+						NULL, 
+						bufZ, 
+						SuperString(encRef.Get()).utf8Z(), 
+						CFStringIsEncodingAvailable(encoding) ? "AVAILABLE" : "NOT available");
+					
+					MessageAlert(formatStr.utf8Z());
+				}
+				
+				s_incdec.dec();
+			#else
+				CF_ASSERT(cf);
+			#endif
+			
+			return NULL;
+		}
+		
+		return (CFStringRef)CFRetainDebug(cf, false);
+	} else {
+		return (CFStringRef)CFRetainDebug(CFSTR(""));
+	}
+}
+
+CFStringRef		CFStringCreateWithCu(
+	const UTF8Char *	bufZ, 
+	CFStringEncoding	encoding)
+{
+	return CFStringCreateWithC((const char *)bufZ, encoding);
+}
+
+ustring		&CopyCFStringToUString(CFStringRef str, ustring &result, CFStringEncoding encoding, bool externalB)
+{
+	result.clear();
+	
+	if (str) {
+		#define						kBufSize		256
+		UTF8Char					utf8Buf[kBufSize];
+		CFRange						cfRange = CFStrGetRange(str);
+		CFIndex						resultSize;
+		CFIndex						numChars;
+		
+		encoding = ValidateEncoding(encoding);
+		
+		while (cfRange.length > 0) {
+			
+			numChars = CFStringGetBytes(
+				str, cfRange, encoding, '?', externalB, 
+				&utf8Buf[0], kBufSize, &resultSize);
+			
+			if (numChars == 0) break;   // Failed to convert anything...
+			
+			result.append(&utf8Buf[0], &utf8Buf[resultSize]);
+			
+			cfRange.location	+= numChars;
+			cfRange.length		-= numChars;
+		}
+	}
+	
+	return result;
+}
+
+std::string		&CopyCFStringToStd(
+	CFStringRef			str, 
+	std::string			&stdstr, 
+	CFStringEncoding	encoding)
+{
+	stdstr.clear();
+	
+	encoding = ValidateEncoding(encoding);
+	
+	if (str) {
+		const char	*charZ = CFStringGetCStringPtr(str, encoding);
+		
+		if (charZ) {
+			stdstr = charZ;
+		} else {
+			ustring		ustr;
+			
+			CopyCFStringToUString(str, ustr, encoding);
+			stdstr.assign(ustr.begin(), ustr.end());
+		}
+	}
+	
+	return stdstr;
+}
+
+std::string		ULong_To_Hex(UInt32 valueL)
+{
+	char			bufAC[16];
+	
+	sprintf(bufAC, "%.8lx", (int)valueL);
+	return bufAC;
+}
+
+UInt32			Hex_To_ULong(const char *hexZ)
+{
+	UInt32	val;
+	
+	sscanf(hexZ, "%lx", &val);
+	return val;
+}
+
+char		*OSTypeToChar(OSType osType, char *bufZ)
+{
+	osType = CFSwapInt32HostToBig(osType);
+	*((OSType *)bufZ) = osType;
+	bufZ[4] = 0;
+	return bufZ;
+}
+
+SuperString		OSTypeToString(OSType osType)
+{
+	SuperString		str;
+	
+	if (osType == (OSType)-1) {
+		str.Set("-");
+	} else {
+		char	bufAC[5];
+		
+		str.Set(OSTypeToChar(osType, bufAC));
+	}
+	
+	return str;
+}
+
+OSType		CharToOSType(const char *bufZ)
+{
+	OSType		osType;
+	short		lenL = strlen(bufZ);
+	
+	osType = *((OSType *)(&bufZ[lenL - 4]));
+	osType = CFSwapInt32BigToHost(osType);
+	return osType;
+}
+
+class SS_ForEach_FindNonDigit {
+	public: bool operator()(UTF8Char uch) {
+		return !isdigit((char)uch);
+	}
+};
+
+bool	SuperString::IsNumeric() const
+{
+	bool		numericB = false;
+	
+	if (!empty()) {
+		ustring&	ustr(const_cast<ustring&>(utf8()));
+		
+		numericB = std::find_if(ustr.begin(), ustr.end(), SS_ForEach_FindNonDigit()) == utf8().end();
+	}
+	
+	return numericB;
+}
+
+class SS_ForEach_Ascii {
+	public: void operator()(char &ch) {
+		if (ch < 32) ch = '?';
+	}
+};
+
+SuperString		&SuperString::Ascii()
+{
+	CharVec		charVec;
+	
+	charVec.assign(std().begin(), std().end());
+	
+	std::for_each(charVec.begin(), charVec.end(), SS_ForEach_Ascii());
+	charVec.push_back(0);
+	Set(&charVec[0]);
+	return *this;
+}
+
+SuperString&	SuperString::format(const char *formatZ0, ...)
+{
+	CharVec		buf(2048);
+	va_list		args;
+	
+	CF_ASSERT(utf8().size() < 1024);
+	va_start(args, formatZ0);
+	
+	ScCFReleaser<CFStringRef>	str((CFStringRef)CFRetainDebug(CFStringCreateWithFormatAndArguments(
+		kCFAllocatorDefault, 
+		NULL, 
+		formatZ0 ? SuperString(uc(formatZ0)).ref() : ref(), 
+		args), false));
+	
+	va_end(args);
+
+	Set(str.Get());
+	return *this;
+}
+
+void	SuperString::Set(CFStringRef myRef, bool retainB)
+{
+	if (i_ref) {
+		CFReleaseDebug(i_ref);
+	}
+	
+	if (myRef == NULL) {
+		myRef = CFSTR("");
+	}
+	
+	i_ref = myRef;
+	
+	if (retainB) {
+		CFRetainDebug(i_ref);
+	}
+	
+	delete i_uni;
+	i_uni	= NULL;
+	
+	delete i_std;
+	i_std	= NULL;
+	
+	delete i_utf8;
+	i_utf8	= NULL;
+
+	delete i_utf32;
+	i_utf32	= NULL;
+	
+	delete i_pstr;
+	i_pstr = NULL;
+
+	#if kDEBUG
+		c_str();
+	#endif
+}
+
+SuperString&		SuperString::Normalize()
+{
+	ScCFReleaser<CFMutableStringRef>	str1;
+
+	str1.Set(CFStringCreateMutableCopy(kCFAllocatorDefault, 0, ref()));
+	
+	CFStringNormalize(str1, kCFStringNormalizationFormD);
+	Set(str1);
+	
+	#ifndef __WIN32__
+		if (GetSystemVers() >= 0x1040) {
+			if (CFStringTransform(str1, NULL, kCFStringTransformStripCombiningMarks, false)) {
+				Set(str1);
+			}
+		}
+
+		if (GetSystemVers() >= 0x1050) {
+		//	CFStringFold(str1, CFOptionFlags theFlags, CFLocaleRef theLocale)
+		}
+	#endif
+
+	return *this;
+}
+	
+void		CFStrReplaceWith(CFMutableStringRef stringRef, CFStringRef replaceStr, CFStringRef withStr)
+{
+	ScCFReleaser<CFArrayRef>	arrayRef;
+	
+	arrayRef.Set(CFStringCreateArrayWithFindResults(
+		NULL, stringRef, replaceStr, CFStrGetRange(stringRef), kCFCompareCaseInsensitive));
+	
+	if (arrayRef.Get()) {
+		CFRange			*rangeRef;
+		
+		loop_reverse (CFArrayGetCount(arrayRef)) {
+			rangeRef = (CFRange *)CFArrayGetValueAtIndex(arrayRef, _indexS);
+			CFStringReplace(stringRef, *rangeRef, withStr);
+		}
+	}
+}
+
+static CFOptionFlags		GetFlags_NormalizeStrings(
+	SuperString&	str1, 
+	SuperString&	str2, 
+	CFOptionFlags	optionFlags = 0
+) {
+	optionFlags |= (CFOptionFlags)(0
+		| kCFCompareNonliteral
+		| kCFCompareLocalized);
+
+	if (diacritic_insensitiveB) {
+		static	bool	s_diacritic_compare_inittedB = false;
+		static	bool	s_has_diacritic_insensitive_compareB;
+		
+		if (!s_diacritic_compare_inittedB) {
+		
+			#ifdef __WIN32__
+				SuperString		str_e("e");
+				UInt32			e_grave(CFSwapInt32HostToBig(0xC3A90000));
+				SuperString		str_e_grave((UInt8*)&e_grave);
+				
+				s_has_diacritic_insensitive_compareB = ::CFStringCompare(
+					str_e.ref(), str_e_grave.ref(), (CFOptionFlags)kCFCompareDiacriticInsensitive)
+					== kCFCompareEqualTo;
+			#else
+				s_has_diacritic_insensitive_compareB = GetSystemVers() >= 0x1050;
+			#endif
+			
+			s_diacritic_compare_inittedB = true;
+		}
+		
+		if (s_has_diacritic_insensitive_compareB) {
+			optionFlags |= (CFOptionFlags)(0
+				| kCFCompareDiacriticInsensitive
+				| kCFCompareWidthInsensitive);
+		} else {
+			str1.Normalize();
+			str2.Normalize();
+		}
+	}
+	
+	return optionFlags;
+}
+
+bool					CFStringContains(CFStringRef inRef, CFStringRef findRef, bool case_sensitiveB)
+{
+	if (inRef == NULL || findRef == NULL) {
+		return false;
+	}
+	
+	SuperString		str1(inRef), str2(findRef);
+	CFOptionFlags	optionFlags = case_sensitiveB ? 0 : kCFCompareCaseInsensitive;
+	
+	optionFlags = GetFlags_NormalizeStrings(str1, str2, optionFlags);
+	
+	return !!CFStringFindWithOptions(str1.ref(), str2.ref(), CFStrGetRange(str1.ref()), optionFlags, NULL);
+}
+
+CFComparisonResult		CFStringCompare(CFStringRef ref1, CFStringRef ref2, bool case_sensitiveB)
+{
+	CFComparisonResult		compareResult = kCFCompareEqualTo;
+	
+	if ((ref1 == NULL) || (ref2 == NULL)) {
+		
+		if ((ref1 == NULL) ^ (ref2 == NULL)) {
+			if (ref1) {
+				compareResult = kCFCompareLessThan;
+			} else {
+				compareResult = kCFCompareGreaterThan;
+			}
+		}
+	} else {
+		SuperString		str1(ref1), str2(ref2);
+		CFOptionFlags	optionFlags = case_sensitiveB ? 0 : kCFCompareCaseInsensitive;
+		
+		optionFlags = GetFlags_NormalizeStrings(str1, str2, optionFlags);
+		compareResult = ::CFStringCompare(str1.ref(), str2.ref(), optionFlags);
+	}
+	
+	return compareResult;
+}
+
+bool		CFStringEqual(CFStringRef str1, CFStringRef str2, bool case_sensitiveB)
+{
+	return CFStringCompare(str1, str2, case_sensitiveB) == kCFCompareEqualTo;
+}
+
+bool		CFStringLess(CFStringRef lhs, CFStringRef rhs, bool case_sensitiveB)
+{
+	bool	lessB = CFStringCompare(lhs, rhs, case_sensitiveB) == kCFCompareLessThan;
+	
+	return lessB;
+}
+
+SuperString		operator+(const SuperString &lhs, SuperString rhs)
+{
+	SuperString		str(lhs);
+	
+	str.append(rhs);
+	return str;
+}
+
+class	CLowerfier {
+	public: void operator()(char& ch) {
+		ch = tolower(ch);
+	}
+};
+
+void	OSType_ToLower(OSType *type)
+{
+	char	*testZ = (char *)type;
+	
+	std::for_each(&testZ[0], &testZ[4], CLowerfier());
+}
+
+SuperString&		SuperString::ToLower()
+{
+	ScCFReleaser<CFMutableStringRef>	capsRef(CFStringCreateMutableCopy(kCFAllocatorDefault, 0, i_ref));
+	
+	CFStringLowercase(capsRef, CFLocaleGetSystem());
+	Set(capsRef);
+	return *this;
+}
+
+bool			SuperString::IsAllCaps()
+{
+	ScCFReleaser<CFMutableStringRef>	capsRef(CFStringCreateMutableCopy(kCFAllocatorDefault, 0, i_ref));
+	
+	CFStringUppercase(capsRef, CFLocaleGetSystem());
+	return CFStringEqual(i_ref, capsRef, true);
+}
+
+OSType		GetExtension(const char *strZ)
+{
+	OSType	ext;
+	short	lenS = strlen(strZ);
+
+	if (lenS >= 4) {
+		ext = CharToOSType(&strZ[lenS - 4]);
+	} else {
+		CharVec		str;	str.reserve(4 + lenS + 2);
+		
+		loop (4) {
+			str.push_back(' ');
+		}
+		
+		loop (lenS) {
+			str.push_back(strZ[_indexS]);
+		}
+
+		str.push_back(0);
+
+		ext = CharToOSType(&str[str.size() - 4]);
+	}
+
+	OSType_ToLower(&ext);
+	return ext;
+}
+
+#if _KJ_MAC_
+void		mt_vsnprintf(char *destZ, size_t sizeL, const char *formatZ, va_list &args)
+{
+	static	CMutex	*S_vsprintMutexP = NULL;
+	
+	if (S_vsprintMutexP == NULL) {
+		S_vsprintMutexP = new CMutex;
+
+		if (S_vsprintMutexP->GetErr()) {
+			fprintf(stdout, "error creating vsprintf mutex");
+		}
+	}
+	
+	{
+		CCritical	sc(S_vsprintMutexP);
+
+		vsnprintf(destZ, sizeL - 1, formatZ, args);
+		destZ[sizeL - 1] = 0;
+	}
+}
+#else
+void		mt_vsnprintf(char *destZ, size_t sizeL, const char *formatZ, va_list &args)
+{
+	vsnprintf(destZ, sizeL - 1, formatZ, args);
+	destZ[sizeL - 1] = 0;
+}
+#endif
+
+
+void	SuperString::Update_utf32() const
+{
+	if (!i_utf32) {
+		i_utf32 = new ww_string;
+		
+		ustring			str;
+		
+		CopyCFStringToUString(i_ref, str, kCFStringEncodingUTF32LE);
+
+		size_t			sizeL(str.size() >> 2);
+		UTF32Char		*utf32A = (UTF32Char *)str.c_str();
+		
+		i_utf32->assign(&utf32A[0], &utf32A[sizeL]);
+	}
+}
+
+SuperString&	SuperString::ww_pop_front(long num_utf32_charsL)
+{
+	ustring			ustr;
+	long			sizeL(utf32().size());
+	
+	if (sizeL <= num_utf32_charsL) {
+		clear();
+	} else {
+		UTF32CharVec	vec(sizeL - num_utf32_charsL);
+		
+		vec.assign(i_utf32->begin() + num_utf32_charsL, i_utf32->end());
+		
+		ScCFReleaser<CFStringRef>	myRef(CFStringCreateWithBytes(
+			kCFAllocatorDefault, (UInt8 *)&vec[0], vec.size() << 2, kCFStringEncodingUTF32LE, false));
+
+		Set(myRef);
+	}
+
+	return *this;
+}
+
+SuperString&	SuperString::ww_resize(long num_utf32_charsL)
+{
+	UTF32CharVec	vec(num_utf32_charsL);
+	
+	vec.assign(i_utf32->begin(), i_utf32->begin() + num_utf32_charsL);
+	
+	ScCFReleaser<CFStringRef>	myRef(CFStringCreateWithBytes(
+		kCFAllocatorDefault, (UInt8 *)&vec[0], vec.size() << 2, kCFStringEncodingUTF32LE, false));
+
+	Set(myRef);
+	return *this;
+}
+
+SuperString&	SuperString::ReplaceTable(SuperStringReplaceRec *recA, long sizeL)
+{
+	ScCFReleaser<CFMutableStringRef>	capsRef(CFStringCreateMutableCopy(kCFAllocatorDefault, 0, i_ref));
+	
+	loop (sizeL) {
+		CFStrReplaceWith(capsRef, SuperString(recA[_indexS].replaceZ).ref(), SuperString(recA[_indexS].withZ).ref());
+	}
+	
+	Set(capsRef);
+	return *this;
+}
+
+SuperStringReplaceRec		s_ampReplacementsA[] = {
+	{	"&lt;",		"<"		},
+	{	"&gt;",		">"		},
+	{	"&quot;",	"\""	},
+	{	"&amp;",	"&"		},
+	{	"&apos;",	"'"		},
+};
+#define		kAmpReplacementSize		(sizeof(s_ampReplacementsA) / sizeof(SuperStringReplaceRec))
+
+SuperString		&SuperString::UnEscapeAmpersands()
+{
+	ReplaceTable(s_ampReplacementsA, kAmpReplacementSize);
+	return *this;
+}
+
+bool	SuperString::Split(const char *splitZ, SuperString *rhsP0, bool from_endB)
+{
+	bool			splitB;
+	
+	if (rhsP0) {
+		rhsP0->clear();
+	}
+	
+	if (from_endB) {
+		splitB = strrstr(utf8Z(), splitZ) != NULL;
+	} else {
+		splitB = strstr(utf8Z(), splitZ) != NULL;
+	}
+	
+	if (splitB) {
+		UCharVec	bufAC;
+		
+		bufAC.assign(utf8().begin(), utf8().end());
+		bufAC.push_back(0);
+		
+		UTF8Char	*chZ;
+		
+		if (from_endB) {
+			chZ	= (UTF8Char *)strrstr((char *)&bufAC[0], (char *)splitZ);
+		} else {
+			chZ	= (UTF8Char *)strstr((char *)&bufAC[0], (char *)splitZ);
+		}
+		
+		SuperString		temp(chZ + strlen(splitZ));
+		*chZ = 0;
+		Set(&bufAC[0]);
+		
+		if (rhsP0) {
+			rhsP0->Set(temp);
+		}
+	}
+	
+	return splitB;
+}
+
+bool	SuperString::rSplit(const char *splitZ, SuperString *lhsP0, bool from_endB)
+{
+	SuperString		rhs;
+	bool			splitB = Split(splitZ, &rhs, from_endB);
+	
+	if (lhsP0) {
+		lhsP0->clear();
+	}
+
+	if (splitB) {
+		if (lhsP0) {
+			lhsP0->Set(*this);
+		}
+		
+		Set(rhs);
+	}
+	
+	return splitB;
+}
+
+
+SuperString&	SuperString::ssprintf(const char *formatZ0, ...)
+{
+	CharVec			buf(64 * kKiloByte);
+	va_list			args;
+	SuperString		formatStr(formatZ0);
+	
+	CF_ASSERT(utf8().size() < 1024);
+	va_start(args, formatZ0);
+	mt_vsnprintf(&buf[0], buf.size(), formatZ0 ? formatStr.utf8Z() : utf8Z(), args);
+	va_end(args);
+	
+	Set(uc(&buf[0]));
+	return *this;
+}
+
+SuperString	&		SuperString::pop_back(UInt32 numCharsL)
+{
+	ustring		ustr(utf8());
+	
+	if (!ustr.empty()) {
+		ustr.resize(ustr.size() - numCharsL);
+		Set(ustr.c_str());
+	}
+	
+	return *this;
+}
+
+#ifdef __WIN32__
+
+	#if defined(__MWERKS__)
+		class CIsZero {
+			public: bool operator()(const wchar_t& ch) {
+				return ch == 0;
+			}
+		};
+
+		static size_t	wcslen(const wchar_t *wcharZ) {
+			const wchar_t*		it(std::find_if(&wcharZ[0], &wcharZ[512], CIsZero()));
+			
+			return std::distance(&wcharZ[0], it);
+		}
+	#endif
+
+	SuperString::SuperString(const wchar_t *wcharZ)
+	{
+		UTF16Vec	vec((UTF16Char *)&wcharZ[0], (UTF16Char *)&wcharZ[wcslen(wcharZ)]);
+
+		SetNULL();
+		Set(vec);
+	}
+#endif
+
+void	SuperString::Set_p(ConstStr255Param strZ, CFStringEncoding encoding)
+{
+	UCharVec		charVec;
+	
+	charVec.assign(&strZ[1], &strZ[strZ[0] + 1]);
+	charVec.push_back(0);
+	Set(&charVec[0], encoding);
+}
+
+OSType&		SuperString::pop_ext(OSType *extP) const {
+	*extP = GetExtension(c_str());
+	return *extP;
+}
+
+void	SuperString::Set_CFType(CFTypeRef cfType)
+{
+	CFTypeID						cfTypeID(CFGetTypeID(cfType));
+	
+	if (cfTypeID == CFStringGetTypeID()) {
+		Set((CFStringRef)cfType);
+	} else {
+		ScCFReleaser<CFStringRef>		descIDRef(CFCopyTypeIDDescription(cfTypeID));
+		ScCFReleaser<CFStringRef>		descRef(CFCopyDescription(cfType));
+		SuperString						descIDStr(descIDRef.Get()), descStr(descRef.Get());
+		SuperString						logStr("Type: <%s>, Value: <%s>");
+		
+		logStr.ssprintf(NULL, descIDStr.utf8Z(), descStr.utf8Z());
+		Set(logStr);
+	}
+}
+
+SuperString&		SuperString::ToUpper()
+{
+	ScCFReleaser<CFMutableStringRef>	capsRef(CFStringCreateMutableCopy(kCFAllocatorDefault, 0, i_ref));
+	
+	CFStringUppercase(capsRef, CFLocaleGetSystem());
+	Set(capsRef);
+	return *this;
+}
+
+char *			CopyFloatToC(float valF, char *bufZ, short precisionS)
+{
+	char	formatAC[32];
+	
+	sprintf(formatAC, "%%.%df", precisionS);
+	sprintf(bufZ, formatAC, valF);
+	return bufZ;
+}
+
+bool			IsSpecialString(SuperString in_key, bool **writtenB = NULL);
+SuperString		&SuperString::Localize()
+{
+	#ifndef _CFTEST_
+	bool						menuB = memcmp("Menu", c_str(), 4) == 0;
+	bool						dlgB = memcmp("dlg", c_str(), 3) == 0;
+	CFStringRef					stringRef = ref();
+	SuperString					key;
+	const char *				dictZ;
+	ScCFReleaser<CFStringRef>	str;
+	bool						specialB = false;
+
+	if (dlgB) {
+		specialB = IsSpecialString(*this);
+		
+		if (specialB) {
+			Split("/", &key, true);
+			key.prepend("dlg/");
+			stringRef = key.ref();
+		}
+
+		dictZ = kLocalized_Dialogs;
+	} else if (menuB) {
+		dictZ = kLocalized_Menus;
+	} else {
+		dictZ = kLocalized_Strings;
+	}
+		
+	*str.AddressOf() = CFStrLocalize(dictZ, stringRef);
+
+	#ifndef kDEBUG
+		if (dlgB) {
+			if (specialB) {
+				if (key == str) {
+					Set(key);
+					Split("/", &key, true);
+					str.Set(key.ref());
+				}
+			} else if (*this == str) {
+				Split("/", &key, true);
+				str.Set(key.ref());
+			}
+		}
+	#endif
+
+	Set(str);
+	#endif
+
+	return *this;
+}
+
+void		IncrementNumberAtEndOfString(SuperString *strP)
+{
+	ustring		ustr(strP->utf8());
+	size_t		startOfNumS = ustr.size();
+	
+	while (isdigit(ustr[startOfNumS - 1])) {
+		startOfNumS--;
+	}
+
+	if (startOfNumS == ustr.size()) {
+		ustr.append(uc(" 1"));
+	} else {
+		int		numberI;
+		char	numAC[32];
+		
+		sscanf((char *)&ustr[startOfNumS], "%d", &numberI);
+		ustr.resize(startOfNumS);
+
+		if (ustr[ustr.size() - 1] != ' ') {
+			ustr.append(uc(" "));
+		}
+
+		sprintf(numAC, "%d", ++numberI);
+		ustr.append(uc(numAC));
+	}
+	
+	strP->Set(ustr);
+}
diff --git a/CoreFoundation/examples/CFTest/source/shared/SuperString.h b/CoreFoundation/examples/CFTest/source/shared/SuperString.h
new file mode 100644
index 0000000..252f57a
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/source/shared/SuperString.h
@@ -0,0 +1,781 @@
+#ifndef _H_SuperString
+#define _H_SuperString
+
+#include <string>
+#include <cctype>
+#include "string.h"
+#include <stdarg.h>
+#include "CFUtils.h"
+
+#define	kCodePage_WindowsLatin1				1252
+#define	kCFStringEncodingPercentEscapes		(0xfffffffeU)
+	
+#ifdef __WIN32__	
+	typedef std::vector<wchar_t>	WCharVec;
+#include "Files.h"
+#else
+	#include <Carbon/Carbon.h>
+#endif
+
+#if !_YAAF_
+	#ifndef _CFTEST_
+		#ifndef _CONSTRUCTOR_
+			#include "StringUtils.h"
+		#endif
+	#endif
+#endif
+
+/****************************************************************/
+void		mt_vsnprintf(char *destZ, size_t sizeL, const char *formatZ, va_list &args);
+void		LogErr(const char *strZ, OSStatus err, bool crB = true, bool unixB = false);
+void		ReportErr(const SuperString& errTypeStr, OSStatus err = 0, bool unixB = false);
+
+/****************************************************************/
+
+char *			CopyFloatToC(float valF, char *bufZ, short precisionS = 2);
+float			CStringToFloat(const char *numF);
+char*			strrstr(const char* stringZ, const char* findZ);
+const char *	CopyLongToC(long valL);
+OSType			GetExtension(const char *strZ);
+
+CFStringRef			CFStrCreateWithCurAbsTime();
+bool				CFStringContains(CFStringRef inRef, CFStringRef findRef, bool case_sensitiveB = false);
+CFComparisonResult	CFStringCompare(CFStringRef str1, CFStringRef str2, bool case_sensitiveB = false);
+bool				CFStringEqual(CFStringRef str1, CFStringRef str2, bool case_sensitiveB = false);
+bool				CFStringLess(CFStringRef lhs, CFStringRef rhs, bool case_sensitiveB = false);
+bool				CFStringIsEmpty(CFStringRef nameRef);
+
+void				SetDefaultEncoding(CFStringEncoding encoding);
+bool				IsDefaultEncodingSet();
+
+ustring			&CopyCFStringToUString(
+									   CFStringRef			str, 
+									   ustring				&result, 
+									   CFStringEncoding	encoding	= kCFStringEncodingUTF8, 
+									   bool				externalB	= false);
+
+CFStringRef		CFStringCreateWithC(
+									const char *		bufZ, 
+									CFStringEncoding	encoding = kCFStringEncodingInvalidId);
+
+CFStringRef		CFStringCreateWithCu(
+									 const UTF8Char *	bufZ, 
+									 CFStringEncoding	encoding = kCFStringEncodingUTF8);
+
+std::string		&CopyCFStringToStd(
+								   CFStringRef			str, 
+								   std::string			&stdstr, 
+								   CFStringEncoding	encoding = kCFStringEncodingInvalidId);
+
+void			CFStrReplaceWith(CFMutableStringRef stringRef, CFStringRef replaceStr, CFStringRef withStr);
+
+extern	bool	g_pref_diacritic_insensitive_searchB;
+
+
+/****************************************************************/
+typedef struct {
+	const char	*replaceZ;
+	const char	*withZ;
+} SuperStringReplaceRec;
+
+class	UniString {
+	UTF16Char	i_nullChar;
+	UTF16Vec	*i_charVecP;
+	
+	void		UpdateNamePointer() {
+		if (i_charVecP) {
+			i_charVecP->push_back(0);
+			i_nameP = &(*i_charVecP)[0];
+		} else {
+			i_nameP = &i_nullChar;
+		}
+	}
+	
+public:
+	void	Initialize(CFStringRef cf_name, bool forceBigEndianB = false) {
+		if (cf_name && !CFStringIsEmpty(cf_name)) {
+			ustring		utf16str;
+			
+			CopyCFStringToUString(cf_name, utf16str, forceBigEndianB ? kCFStringEncodingUTF16BE : kCFStringEncodingUTF16);
+			
+			//	divide by 2
+			i_lengthL	= utf16str.size() >> 1;
+			
+			if (i_charVecP == NULL) {
+				i_charVecP = new UTF16Vec();
+			}
+			
+			UTF16Char	*utf16A = (UTF16Char *)utf16str.c_str();
+			
+			i_charVecP->assign(&utf16A[0], &utf16A[i_lengthL]);
+			//			CFStringGetCharacters(cf_name, CFRangeMake(0, i_lengthL), &(*i_charVecP)[0]);
+		} else {
+			delete i_charVecP;
+			i_charVecP = NULL;
+			i_lengthL = 0;
+		}
+		
+		UpdateNamePointer();
+	}
+
+	#if defined(__MWERKS__)
+		typedef long	UniCharCount;
+	#endif
+
+	UniCharCount		i_lengthL;
+	UniChar				*i_nameP;
+	
+	UniString(const UniString &uni)	: i_nameP(NULL), i_charVecP(NULL), i_nullChar(0) {
+		i_lengthL	= uni.i_lengthL;
+		
+		if (i_lengthL) {
+			i_charVecP = new UTF16Vec();
+			i_charVecP->resize(i_lengthL);
+			std::copy(&uni.i_nameP[0], &uni.i_nameP[i_lengthL], &(*i_charVecP)[0]);
+		}
+		
+		UpdateNamePointer();
+	}
+	
+	UniString(CFStringRef cf_name, bool forceBigEndianB = false) : i_nameP(NULL), i_charVecP(NULL), i_nullChar(0) {
+		Initialize(cf_name, forceBigEndianB);
+	}
+	
+	UniString(const char *nameZ = NULL) : i_nameP(NULL), i_charVecP(NULL), i_nullChar(0), i_lengthL(0) {
+		if (nameZ) {
+			ScCFReleaser<CFStringRef>	cf_name(CFStringCreateWithC(nameZ));
+			
+			Initialize(cf_name);
+		}
+	}
+	
+	~UniString() {
+		delete i_charVecP;
+	}
+};
+
+#if defined(__WIN32__)
+	#ifndef __MACTYPES__
+		typedef RECT	Rect;
+		typedef UInt32	OSType;
+	#endif
+#endif
+
+std::string		ULong_To_Hex(UInt32 valueL);
+UInt32			Hex_To_ULong(const char *hexZ);
+OSType			CharToOSType(const char *bufZ);
+
+typedef std::vector<UTF32Char>		UTF32CharVec;
+typedef std::basic_string<UTF32Char, std::char_traits<UTF32Char>, std::allocator<UTF32Char> > ww_string;
+
+class SuperString {
+	CFStringRef				i_ref;
+	mutable std::string		*i_std;
+	mutable UniString		*i_uni;
+	mutable ustring			*i_utf8;
+	mutable ustring			*i_pstr;
+	mutable ww_string		*i_utf32;
+	
+public:
+	const	std::string	&std() const	{	Update_std();	return *i_std;	}
+	const	CFStringRef	&ref() const	{	return i_ref;	}
+	const	UniString	&uni(bool forceBigEndianB = false) const	{	Update_uni(forceBigEndianB);	return *i_uni;	}
+	const	ustring		&utf8() const	{	Update_utf8();	return *i_utf8;	}
+	const	char *		c_str() const  	{	return std().c_str();	}
+	const	char *		utf8Z() const	{	return (const char *)utf8().c_str();	}
+	ConstStr255Param	p_str() const	{	Update_pstr();	return i_pstr->c_str();	}
+	const	ww_string&	utf32() const	{	Update_utf32();	return *i_utf32;		}
+
+	#ifdef __WIN32__
+		LPCWSTR		w_str() const			{	return (LPCWSTR)uni().i_nameP;		}
+		size_t		w_strlen() const		{	return w_size();	}
+	#endif
+	
+	operator const UniString&() const	{	return uni();	}
+	operator const std::string&() const	{	return std();	}
+	//operator const ustring&() const		{	return utf8();	}	causes all sorts of ambiguities
+	operator CFStringRef() const		{	return ref();	}
+	operator const UInt8*() const		{	return utf8().c_str();	}
+
+	/************************************/
+	SuperString&	Truncate(bool activeB, const Rect& frameR);
+	SuperString&	ssprintf(const char *formatZ0, ...);
+	SuperString&	format(const char *formatZ0, ...);
+	
+private:
+	void	SetNULL()
+	{
+		i_ref	= NULL;
+		i_std	= NULL;
+		i_uni	= NULL;
+		i_utf8	= NULL;
+		i_utf32 = NULL;
+		i_pstr	= NULL;
+	}
+	
+public:
+	#ifdef __WIN32__
+		SuperString(const wchar_t *wcharZ);
+
+		SuperString(const WCharVec& wcharVec) {
+			SetNULL();
+			Set(*(UTF16Vec *)&wcharVec);
+		}
+	#endif
+
+	SuperString(const HFSUniStr255 &str) {
+		SetNULL();
+		
+		ScCFReleaser<CFStringRef>	myRef = CFStringCreateWithCharacters(
+			kCFAllocatorDefault, 
+			str.unicode,
+			str.length);
+		
+		Set(myRef);
+	}
+	
+	SuperString(const char *strZ = NULL, CFStringEncoding encoding = kCFStringEncodingInvalidId) {
+		SetNULL();		
+		Set(uc(strZ), encoding);
+	}
+	
+	SuperString(const SuperString &sstr) {
+		SetNULL();
+		Set(sstr.ref());
+	}
+	
+	#ifdef _KJAMS_
+	#ifndef _KJAMSX_
+		void	Set(const CDHMSF msf, kTimeCodeType type = kTimeCode_NORMAL) {
+			char	bufAC[256];
+			
+			Set(CopyMSFToC(msf, bufAC, type));
+		}
+
+		SuperString(const CDHMSF msf, kTimeCodeType type = kTimeCode_NORMAL) {
+			SetNULL();
+			Set(msf, type);
+		}
+	#endif
+	#endif
+
+	/*
+	 FAIL!
+	SuperString(const UInt16* strZ) {
+		SetNULL();
+		
+		ScCFReleaser<CFStringRef>	myRef = strZ 
+			? CFStringCreateWithC((const char *)strZ, kCFStringEncodingUnicode) : 
+			(CFStringRef)CFRetainDebug(CFSTR(""));
+
+		Set(myRef);
+	}
+	*/
+	
+	SuperString(const UInt8 *strZ) {
+		SetNULL();
+		Set(strZ);
+	}
+	
+	SuperString(long valL) {
+		SetNULL();
+		append(valL);
+	}
+	
+	/*
+	 dam!  this causes ambiguation
+	 SuperString(double valF) {
+	 SetNULL();
+	 append((float)valF);
+	 }
+	 */
+	
+	SuperString(const ustring &str) {
+		SetNULL();
+		Set(str.c_str());
+	}
+	
+	SuperString(const std::string &str) {
+		SetNULL();
+		Set(str.c_str());
+	}
+	
+	SuperString(CFStringRef myRef, bool retainB = true) {
+		SetNULL();
+		Set(myRef, retainB);
+	}
+	
+	void	Set_CFType(CFTypeRef cfType);
+	
+	/************************************/
+	void	Set_p(ConstStr255Param strZ, CFStringEncoding encoding = kCFStringEncodingInvalidId);
+	
+	void	Set(const char *strZ) {
+		ScCFReleaser<CFStringRef>	myRef = CFStringCreateWithC(strZ);
+		
+		Set(myRef);
+	}
+	
+	void	Set(const UInt8 *strZ, CFStringEncoding encoding = kCFStringEncodingUTF8) {
+		ScCFReleaser<CFStringRef>	myRef;
+		
+		if (strZ) {
+			if (encoding == kCFStringEncodingPercentEscapes) {
+				Set(strZ, kCFStringEncodingASCII);
+				
+				UnEscape();
+				return;
+			} else {
+				myRef.Set(CFStringCreateWithCu(strZ, encoding));
+			}
+		} else {
+			myRef.Set((CFStringRef)CFRetainDebug(CFSTR("")));
+		}
+		
+		Set(myRef);
+	}
+	
+	void	Escape() {
+		Set(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, ref(), NULL, NULL, kCFStringEncodingUTF8), false);
+	}
+
+	void	UnEscape() {
+		Set(CFURLCreateStringByReplacingPercentEscapes(kCFAllocatorDefault, ref(), CFSTR("")));
+	}
+	
+	void	Set(const ustring& utf8, CFStringEncoding encoding = kCFStringEncodingUTF8) {
+		Set(utf8.c_str(), encoding);
+	}
+	
+	void	Set(const UTF16Vec &vec) {
+		ScCFReleaser<CFStringRef>	myRef = CFStringCreateWithCharacters(kCFAllocatorDefault, &vec[0], vec.size());
+		
+		Set(myRef);
+	}
+	
+	void	assign(const UTF8Char *beginZ, const UTF8Char *endZ, CFStringEncoding encoding = kCFStringEncodingUTF8) {
+		ustring		str(beginZ, endZ);
+		
+		Set(str, encoding);
+	}
+	
+	void	Set(const SuperString &sstr) {
+		if (&sstr != this) {
+			Set(sstr.i_ref);
+		}
+	}
+	
+  	CFStringRef	Retain() const {	CFRetainDebug(i_ref);	return i_ref;	}
+	
+	void	Set(CFStringRef myRef, bool retainB = true);
+	
+	/************************************/
+	~SuperString() {
+		Set((CFStringRef)NULL, false);
+	}
+	
+	void	Release() {
+		CFReleaseDebug(i_ref);
+	}
+	
+	/************************************/
+	void	Update_pstr() const {
+		
+		if (!i_pstr) {
+			i_pstr = new ustring;
+			i_pstr->push_back(0);
+			Update_std();
+			i_pstr->insert(i_pstr->end(), i_std->begin(), i_std->end());
+			(*i_pstr)[0] = i_pstr->size() - 1;
+			
+			delete i_std;
+			i_std	= NULL;
+		}
+	}
+	
+	void	Update_uni(bool forceBigEndianB) const {
+		if (!i_uni) {
+			i_uni = new UniString(i_ref, forceBigEndianB);
+		}
+	}
+	
+	void	Update_std() const {
+		if (!i_std) {
+			i_std = new std::string;
+			CopyCFStringToStd(i_ref, *i_std);
+		}
+	}
+	
+	void	Update_utf32() const;
+	void	Update_utf8() const {
+		if (!i_utf8) {
+			i_utf8 = new ustring;
+			CopyCFStringToUString(i_ref, *i_utf8);
+		}
+	}
+
+	/************************************/
+	void	clear()	{	Set((CFStringRef)NULL);	}
+	
+	bool				Contains(const SuperString& other) const {
+		return strstr(utf8Z(), other.utf8Z()) != NULL;
+	}
+	
+	//	returns number of utf8 bytes (not characters) that match the start of the other string
+	size_t				MatchStart(const SuperString& other, char delimiterCh = 0);
+
+	bool				StartsWith(const SuperString& other) {
+		return MatchStart(other) == other.size();
+	}
+	
+	SuperString&		ReplaceTable(SuperStringReplaceRec *recA, long sizeL);
+	SuperString&		Replace(const SuperString& replaceStr, const SuperString& withStr) {
+		ScCFReleaser<CFMutableStringRef>	newRef(CFStringCreateMutableCopy(NULL, 0, i_ref));
+		
+		CFStrReplaceWith(newRef, replaceStr.ref(), withStr.ref());
+		Set(newRef);
+		return *this;
+	} 
+	
+	SuperString		&UnderScoresToSpaces() {
+		return Replace("_", " ");
+	}
+	
+	//	returns a new string, does not modify original
+	SuperString			md5() const;
+	
+	SuperString&		Scramble();
+	SuperString&		UnScramble();
+	
+	SuperString&		trim();
+
+	#if _KJ_MAC_
+	void			MakeRecoverable(bool old_styleB = false) {
+		ScCFReleaser<CFStringRef>		sc(CFStrCreateRecoverableName(i_ref, false));
+		
+		Set(sc);
+	}
+	
+	SuperString&	Recover() {
+		ScCFReleaser<CFStringRef>		sc(CFStrRecoverName(i_ref));
+		
+		Set(sc);
+		return *this;
+	}
+
+	SuperString&	RecoverCaps(bool titleCaseB = true) {
+		Recover();
+		InterCaps(false, titleCaseB);
+		MakeRecoverable();
+		return *this;
+	}
+	
+	#endif
+	
+	CFDataRef		CopyDataRef() {
+		return CFStringCreateExternalRepresentation(
+			kCFAllocatorDefault, i_ref, kCFStringEncodingUTF8, 0);
+	}
+	
+	void			Set(CFDataRef dataRef) {
+		ScCFReleaser<CFStringRef>	myRef = CFStringCreateFromExternalRepresentation(
+			kCFAllocatorDefault, dataRef, kCFStringEncodingUTF8);
+
+		Set(myRef);
+	}
+	
+	size_t			size() const	{	return utf8().size();		}	//	utf8 chars
+	size_t			w_size() const	{	return uni().i_lengthL;		}	//	utf16 chars
+	size_t			ww_size() const	{	return utf32().size();		}	//	utf32 chars
+	
+	/*
+	 ambiguous
+	 
+	 char			operator[](size_t indexS) {
+	 char	ch = 0;
+	 
+	 if (utf8().size() > indexS) {
+	 ch = utf8().c_str()[indexS];
+	 }
+	 
+	 return ch;
+	 }
+	 */
+	
+	UTF32Char		GetIndChar_ww(size_t indexL = 0) const {
+		UTF32Char		ch = 0;
+		
+		if (indexL >= 0 && indexL < utf32().size()) {
+			ch = utf32()[indexL];
+		}
+		
+		return ch;
+	}
+	
+	UTF8Char		GetIndChar(size_t indexL = 0) const {
+		UTF8Char		ch = 0;
+		
+		if (indexL >= 0 && indexL < utf8().size()) {
+			ch = utf8()[indexL];
+		}
+		
+		return ch;
+	}
+	
+	UTF8Char		GetIndCharR(long indexL = 0) const {
+		return GetIndChar(utf8().size() - (indexL + 1));
+	}
+	
+	SuperString&	ToUpper();
+	SuperString&	ToLower();
+	bool			IsAllCaps();
+	SuperString&	Normalize();
+	SuperString&	InterCaps(bool allow_line_breaksB = false, bool titleCaseB = true);
+	SuperString&	TheToEnd();
+	
+	SuperString&	operator =(const SuperString &other) {	Set(other);	return *this;	}
+	SuperString&	operator =(const char *otherZ) {	Set(otherZ);	return *this;	}
+	
+	bool			operator<(CFStringRef other) const {
+		return CFStringLess(i_ref, other);
+	}
+	
+	bool			operator>(CFStringRef other) const {
+		return CFStringLess(other, i_ref);
+	}
+	
+	bool			operator ==(CFStringRef other) {
+		return CFStringEqual(i_ref, other);
+	}
+	
+	bool			operator ==(CFStringRef other) const {
+		return CFStringEqual(i_ref, other);
+	}
+	
+	bool			operator !=(CFStringRef other)	{
+		return ! operator==(other);
+	}
+	
+	bool			operator ==(const SuperString &other) {
+		return operator==(other.i_ref);
+	}
+	
+	bool			operator ==(const SuperString &other) const {
+		return operator==(other.i_ref);
+	}
+	
+	bool			operator !=(const SuperString &other)	{
+		return ! operator==(other.i_ref);
+	}
+
+	bool			operator !=(SuperString &other)	{
+		return ! operator==(other.i_ref);
+	}
+	
+	bool	IsNumeric() const;
+	bool	empty() const		{	return CFStringIsEmpty(i_ref);	}
+
+/*
+	CFNumberRef		CopyAs_NumberRef()'
+	CFDateRef		CopyAs_DateRef()'
+	CFURLRef		CopyAs_URLRef()'
+
+	UInt32			GetAs_UInt32();
+	UInt16			GetAs_UInt16();
+	SInt16			GetAs_SInt16();
+*/
+
+	OSType	GetAs_OSType() const	{	return CharToOSType(utf8Z());	}
+	SInt32	GetAs_SInt32() const {	return ::atoi(c_str());	}
+	float	GetAs_Float() const	{	return CStringToFloat(c_str());	}
+
+	OSType	GetAsOSType() const	{	return GetAs_OSType();	}
+	long	value_long() const	{	return GetAs_SInt32();	}
+	float	value_float() const	{	return GetAs_Float();	}
+
+	UInt32	hex_to_ulong()		{	return Hex_To_ULong(c_str());	}
+	
+	//	returns *this
+	SuperString&	ww_pop_front(long num_utf32_charsL = 1);
+
+	//	returns the chars popped off the front
+	SuperString		pop_front(size_t numL = 1)	{
+		SuperString			str;
+		
+		if (utf8().size() <= numL) {
+			str.Set(*this);
+			clear();
+		} else {
+			UCharVec	bufAC(numL);
+			
+			std::copy(i_utf8->begin(), i_utf8->begin() + numL, &bufAC[0]);
+			bufAC.push_back(0);
+			
+			str.Set(&bufAC[0]);
+			Set(&(utf8().c_str())[numL]);
+		}
+		
+		return str;
+	}
+	
+	short	count_match(const char *matchZ) {
+		short		countS = 0;
+		const char	*chZ = (const char *)utf8().c_str();
+		
+		do {
+			chZ = strstr(chZ, matchZ);
+			if (chZ) {
+				++countS;
+				++chZ;
+			}
+		} while (chZ);
+		
+		return countS;
+	}
+	
+	bool	rSplit(const char *splitZ, SuperString *lhsP0 = NULL, bool from_endB = false);	
+	bool	Split(const char *splitZ, SuperString *rhsP0 = NULL, bool from_endB = false);
+	
+	SuperString	&pop_back(UInt32 numCharsL = 1);
+	
+	OSType	&pop_ext(OSType *extP) const;
+	
+	OSType	get_ext() const {
+		OSType		ext;
+		
+		pop_ext(&ext);
+		return ext;
+	}
+	
+	SuperString	&pop_ext(SuperString *extP0 = NULL) {
+		ustring				ustr(utf8());
+		const unsigned char	*dotP;
+		
+		dotP = uc(strrchr(utf8Z(), '.'));
+		
+		if (dotP) {
+			if (extP0) {
+				extP0->Set(dotP);
+			}
+			
+			ustr.resize(ustr.size() - strlen((char *)dotP));
+			
+			Set(ustr);
+		}
+		
+		return *this;
+	}
+	
+	/******************************/
+	SuperString		&resize(long num_utf8_charsL) {
+		ustring		ustr(utf8());
+		
+		ustr.resize(num_utf8_charsL);
+		Set(ustr);
+		return *this;
+	}
+
+	SuperString		&ww_resize(long num_utf32_charsL);
+
+	SuperString		&append(const ustring &other) {
+		Set(utf8() + other);
+		return *this;
+	}
+	
+	SuperString		&append(SuperString &other) {
+		return append(other.utf8());
+	}
+	
+	SuperString		&append(CFStringRef myRef) {
+		return append(SuperString(myRef).utf8());
+	}
+	
+	SuperString		&append(const char *other) {
+		return append(SuperString(other).utf8());
+	}
+	
+	SuperString		&append(long valueL)
+	{
+		char	bufAC[32];
+		
+		::sprintf(bufAC, "%ld", valueL);
+		return append(bufAC);
+		//		std::string		strStr;
+		
+		//		return append(NumToCString(valueL, strStr));
+	}
+	
+	SuperString		&UnEscapeAmpersands();
+
+	SuperString		&append(char ch)
+	{
+		char	bufAC[2];
+		
+		bufAC[0] = ch;
+		bufAC[1] = 0;
+		
+		SuperString		appendStr(bufAC, kCFStringEncodingASCII);
+		
+		append(appendStr);
+		return *this;
+	}
+	
+	SuperString		&append(float valueF, short precS = 1)
+	{
+		char	bufAC[32];
+		
+		CopyFloatToC(valueF, bufAC, precS);
+		return append(bufAC);
+	}
+	
+	/****************************/
+	SuperString		&prepend(const ustring &other) {
+		Set(other + utf8());
+		return *this;
+	}
+	
+	SuperString		&prepend(const SuperString &other) {
+		return prepend(other.utf8());
+	}
+	
+	SuperString		&prepend(const char *other) {
+		return prepend(SuperString(other).utf8());
+	}
+	
+	SuperString		&prepend(long valueL) {
+		char	bufAC[32];
+		
+		::sprintf(bufAC, "%.2ld", valueL);
+		return prepend(bufAC);
+	}
+	
+	SuperString		&Ascii();
+	SuperString		&Localize();
+};
+
+SuperString		operator+(const SuperString &lhs, SuperString rhs);
+
+char			*OSTypeToChar(OSType osType, char *bufZ);
+SuperString		OSTypeToString(OSType osType);
+void			IncrementNumberAtEndOfString(SuperString *strP);
+SuperString		FormatBytes(UInt64 bytes);
+
+#if OPT_WINOS
+inline SuperString		SuperString_CreateFrom_UniChar(
+	UniCharCount     sizeL,
+	const UniChar *  nameA)
+{
+	CF_ASSERT(nameA[sizeL] == 0);
+	return SuperString(reinterpret_cast<const wchar_t *>(nameA));
+}
+#endif
+
+#if _KJ_MAC_
+	void			SP_VerifyStringExists(SP_IndexType stringType, SuperString *strP);
+	bool			Dict_Get_Str(CFDictionaryRef dict, const char *keyZ, SuperString *strP);
+	SuperString		Array_GetIndStr(CFArrayRef array, long indexL);
+#endif
+
+typedef std::vector<SuperString>	SStringVec;
+
+#endif
diff --git a/CoreFoundation/examples/CFTest/test.xml b/CoreFoundation/examples/CFTest/test.xml
new file mode 100644
index 0000000..4ae2a7d
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/test.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Application Version</key>
+	<string>1.0d49r27</string>
+	<key>Current Venue</key>
+	<string>Singers</string>
+	<key>Library Search Paths</key>
+	<dict>
+		<key>array</key>
+		<array/>
+	</dict>
+	<key>Major Version</key>
+	<integer>1</integer>
+	<key>Minor Version</key>
+	<integer>7</integer>
+	<key>Next item ID (don't change this!!)</key>
+	<integer>8302</integer>
+	<key>Playlists</key>
+	<array>
+		<dict>
+			<key>Artist</key>
+			<string></string>
+			<key>Ascending</key>
+			<integer>1</integer>
+			<key>Category</key>
+			<string></string>
+			<key>Columns</key>
+			<dict>
+				<key>COLUMNS</key>
+				<array>
+					<integer>1346978632</integer>
+					<integer>1936673092</integer>
+					<integer>1851878757</integer>
+					<integer>1634890867</integer>
+					<integer>1634493037</integer>
+					<integer>1685222510</integer>
+				</array>
+				<key>COLWIDS</key>
+				<array>
+					<integer>80</integer>
+					<integer>66</integer>
+					<integer>246</integer>
+					<integer>167</integer>
+					<integer>167</integer>
+					<integer>80</integer>
+				</array>
+				<key>SORTCOL</key>
+				<integer>1936673092</integer>
+				<key>SORTDIR</key>
+				<array>
+					<integer>1</integer>
+					<integer>1</integer>
+					<integer>1</integer>
+					<integer>1</integer>
+					<integer>1</integer>
+					<integer>1</integer>
+				</array>
+			</dict>
+			<key>Current Playlist Item ID</key>
+			<integer>1</integer>
+			<key>FreeDB Revision</key>
+			<integer>0</integer>
+			<key>FreeDB extended data</key>
+			<string></string>
+			<key>Genre</key>
+			<string></string>
+			<key>Is Category Locked</key>
+			<false/>
+			<key>Name</key>
+			<string>Library</string>
+			<key>Playlist ID</key>
+			<integer>1</integer>
+			<key>Playlist Type</key>
+			<integer>1</integer>
+			<key>Sort By</key>
+			<integer>1936673092</integer>
+			<key>Year</key>
+			<integer>0</integer>
+		</dict>
+	</array>
+</dict>
+</plist>
diff --git a/CoreFoundation/examples/CFTest/win_cw/CFTest.mcp b/CoreFoundation/examples/CFTest/win_cw/CFTest.mcp
new file mode 100644
index 0000000..4334921
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/win_cw/CFTest.mcp
Binary files differ
diff --git a/CoreFoundation/examples/CFTest/win_cw/MyMFCHeaders.h b/CoreFoundation/examples/CFTest/win_cw/MyMFCHeaders.h
new file mode 100644
index 0000000..1d939f1
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/win_cw/MyMFCHeaders.h
@@ -0,0 +1,40 @@
+#ifndef __MYMFCHEADERS_H__

+#define __MYMFCHEADERS_H__

+

+/*

+	Generic header for any MFC configuration:

+

+	To build without precompiled headers, either use your 

+	local stdafx.h or MyMFCHeaders.pch++ as the prefix file.

+

+	This header can be used with debug/release or shared/static runtimes

+	as long as the "x86 CodeGen" / "Runtime configuration" option is

+	set to a value other than "Custom".  Otherwise, use the appropriate

+	MyMFC[DLL][D]Headers.mch for your configuration. 

+*/

+

+/*	All configurations are forced to use __cdecl / x86 multithreaded codegen */

+

+#ifndef _MFC_PCH_CPP

+	#ifdef _DLL

+		#ifdef _DEBUG

+			#define _MFC_PCH_CPP	"MyMFCDLLDHeaders.mch"

+		#else

+			#define _MFC_PCH_CPP	"MyMFCDLLHeaders.mch"

+		#endif

+	#else

+		#ifdef _DEBUG

+			#define _MFC_PCH_CPP	"MyMFCDHeaders.mch"

+		#else

+			#define _MFC_PCH_CPP	"MyMFCHeaders.mch"

+		#endif

+	#endif

+#endif

+

+#define _CFTEST_

+#include _MFC_PCH_CPP

+

+#undef _MFC_PCH_CPP

+

+#endif	/*__MYMFCHEADERS_H__*/

+

diff --git a/CoreFoundation/examples/CFTest/win_cw/MyMFCHeaders.pch++ b/CoreFoundation/examples/CFTest/win_cw/MyMFCHeaders.pch++
new file mode 100644
index 0000000..4bbb9b7
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/win_cw/MyMFCHeaders.pch++
@@ -0,0 +1,48 @@
+

+/*	Rename these files as appropriate (MyMFCHeaders.h must match!) */

+#ifndef _MFC_PCH

+	#ifdef _DLL

+		#ifdef _DEBUG

+			#define _MFC_PCH	"MyMFCDLLDHeaders.mch"

+		#else

+			#define _MFC_PCH	"MyMFCDLLHeaders.mch"

+		#endif

+	#else

+		#ifdef _DEBUG

+			#define _MFC_PCH	"MyMFCDHeaders.mch"

+		#else

+			#define _MFC_PCH	"MyMFCHeaders.mch"

+		#endif

+	#endif

+#endif

+

+#pragma precompile_target _MFC_PCH

+

+/*	Don't include MSL libs before MFC libs */

+#if defined _MSL_USE_DEFAULT_LIBS && !_MSL_USE_DEFAULT_LIBS

+#define _MSL_USER_USE_DEFAULT_LIBS 0

+#else

+#define _MSL_USER_USE_DEFAULT_LIBS 1

+#endif

+#undef _MSL_USE_DEFAULT_LIBS

+#define _MSL_USE_DEFAULT_LIBS	0

+

+/*	Force generic x86 / __cdecl library */

+#define _MSL_CALLINGCONV	_MSL_CALLINGCONV_CDECL

+#define _MSL_CDECL			__cdecl

+

+#include <ansi_prefix.win32.h>

+

+#define _MW_BUILDING_MFC_PCH

+#define _AFX_MONOLITHIC

+#define _AFX_PORTABLE

+#define _AFX_NO_DEBUG_CRT

+

+/* 	There are no longer 3DNow! builds of MFC.  

+	This #pragma ensures you can call the x86 MFC DLL from 3DNow! code. */

+#pragma mmcalls off

+

+#include "stdafx.h"

+

+#pragma mmcalls reset

+

diff --git a/CoreFoundation/examples/CFTest/win_vs/CFTest.sln b/CoreFoundation/examples/CFTest/win_vs/CFTest.sln
new file mode 100644
index 0000000..d6681ef
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/win_vs/CFTest.sln
@@ -0,0 +1,20 @@
+

+Microsoft Visual Studio Solution File, Format Version 10.00

+# Visual C++ Express 2008

+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CFTest", "CFTest.vcproj", "{7E679993-5CED-41C2-B57D-7EB2D765D3D2}"

+EndProject

+Global

+	GlobalSection(SolutionConfigurationPlatforms) = preSolution

+		Debug|Win32 = Debug|Win32

+		Release|Win32 = Release|Win32

+	EndGlobalSection

+	GlobalSection(ProjectConfigurationPlatforms) = postSolution

+		{7E679993-5CED-41C2-B57D-7EB2D765D3D2}.Debug|Win32.ActiveCfg = Debug|Win32

+		{7E679993-5CED-41C2-B57D-7EB2D765D3D2}.Debug|Win32.Build.0 = Debug|Win32

+		{7E679993-5CED-41C2-B57D-7EB2D765D3D2}.Release|Win32.ActiveCfg = Release|Win32

+		{7E679993-5CED-41C2-B57D-7EB2D765D3D2}.Release|Win32.Build.0 = Release|Win32

+	EndGlobalSection

+	GlobalSection(SolutionProperties) = preSolution

+		HideSolutionNode = FALSE

+	EndGlobalSection

+EndGlobal

diff --git a/CoreFoundation/examples/CFTest/win_vs/CFTest.vcproj b/CoreFoundation/examples/CFTest/win_vs/CFTest.vcproj
new file mode 100644
index 0000000..0aa90d7
--- /dev/null
+++ b/CoreFoundation/examples/CFTest/win_vs/CFTest.vcproj
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="Windows-1252"?>

+<VisualStudioProject

+	ProjectType="Visual C++"

+	Version="9.00"

+	Name="CFTest"

+	ProjectGUID="{7E679993-5CED-41C2-B57D-7EB2D765D3D2}"

+	RootNamespace="CFTest"

+	Keyword="Win32Proj"

+	TargetFrameworkVersion="196613"

+	>

+	<Platforms>

+		<Platform

+			Name="Win32"

+		/>

+	</Platforms>

+	<ToolFiles>

+	</ToolFiles>

+	<Configurations>

+		<Configuration

+			Name="Debug|Win32"

+			OutputDirectory="$(SolutionDir)\$(ConfigurationName)"

+			IntermediateDirectory="$(ConfigurationName)"

+			ConfigurationType="1"

+			CharacterSet="1"

+			>

+			<Tool

+				Name="VCPreBuildEventTool"

+			/>

+			<Tool

+				Name="VCCustomBuildTool"

+			/>

+			<Tool

+				Name="VCXMLDataGeneratorTool"

+			/>

+			<Tool

+				Name="VCWebServiceProxyGeneratorTool"

+			/>

+			<Tool

+				Name="VCMIDLTool"

+			/>

+			<Tool

+				Name="VCCLCompilerTool"

+				Optimization="0"

+				AdditionalIncludeDirectories="&quot;$(SolutionDir)..\source\main&quot;;&quot;$(SolutionDir)..\source\shared&quot;;C:\WINDOWS\CoreFoundation\GNUCompatibility;C:\WINDOWS\CoreFoundation;&quot;C:\Program Files\QuickTime SDK\CIncludes&quot;"

+				PreprocessorDefinitions="__WIN32__;WIN32;_DEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_CFTEST_"

+				MinimalRebuild="false"

+				BasicRuntimeChecks="3"

+				RuntimeLibrary="3"

+				UsePrecompiledHeader="1"

+				WarningLevel="3"

+				DebugInformationFormat="4"

+				CallingConvention="0"

+			/>

+			<Tool

+				Name="VCManagedResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCPreLinkEventTool"

+			/>

+			<Tool

+				Name="VCLinkerTool"

+				AdditionalDependencies="comctl32.lib Ws2_32.lib CoreFoundation.lib CVClient.lib QTMLClient.lib QTSClient.lib QTVR.lib"

+				OutputFile="$(OutDir)\..\build\CFTest.exe"

+				LinkIncremental="2"

+				AdditionalLibraryDirectories="C:\WINDOWS\CoreFoundation;&quot;C:\Program Files\QuickTime SDK\Libraries&quot;"

+				IgnoreAllDefaultLibraries="false"

+				IgnoreDefaultLibraryNames="LIBCMT"

+				GenerateDebugInformation="true"

+				ProgramDatabaseFile="$(IntDir)\$(TargetName).pdb"

+				SubSystem="2"

+				EntryPointSymbol="main"

+				TargetMachine="1"

+			/>

+			<Tool

+				Name="VCALinkTool"

+			/>

+			<Tool

+				Name="VCManifestTool"

+			/>

+			<Tool

+				Name="VCXDCMakeTool"

+			/>

+			<Tool

+				Name="VCBscMakeTool"

+			/>

+			<Tool

+				Name="VCFxCopTool"

+			/>

+			<Tool

+				Name="VCAppVerifierTool"

+			/>

+			<Tool

+				Name="VCPostBuildEventTool"

+			/>

+		</Configuration>

+		<Configuration

+			Name="Release|Win32"

+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"

+			IntermediateDirectory="$(ConfigurationName)"

+			ConfigurationType="1"

+			CharacterSet="1"

+			WholeProgramOptimization="1"

+			>

+			<Tool

+				Name="VCPreBuildEventTool"

+			/>

+			<Tool

+				Name="VCCustomBuildTool"

+			/>

+			<Tool

+				Name="VCXMLDataGeneratorTool"

+			/>

+			<Tool

+				Name="VCWebServiceProxyGeneratorTool"

+			/>

+			<Tool

+				Name="VCMIDLTool"

+			/>

+			<Tool

+				Name="VCCLCompilerTool"

+				Optimization="2"

+				EnableIntrinsicFunctions="true"

+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"

+				RuntimeLibrary="2"

+				EnableFunctionLevelLinking="true"

+				UsePrecompiledHeader="2"

+				WarningLevel="3"

+				DebugInformationFormat="3"

+			/>

+			<Tool

+				Name="VCManagedResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCPreLinkEventTool"

+			/>

+			<Tool

+				Name="VCLinkerTool"

+				LinkIncremental="1"

+				GenerateDebugInformation="true"

+				SubSystem="2"

+				OptimizeReferences="2"

+				EnableCOMDATFolding="2"

+				TargetMachine="1"

+			/>

+			<Tool

+				Name="VCALinkTool"

+			/>

+			<Tool

+				Name="VCManifestTool"

+			/>

+			<Tool

+				Name="VCXDCMakeTool"

+			/>

+			<Tool

+				Name="VCBscMakeTool"

+			/>

+			<Tool

+				Name="VCFxCopTool"

+			/>

+			<Tool

+				Name="VCAppVerifierTool"

+			/>

+			<Tool

+				Name="VCPostBuildEventTool"

+			/>

+		</Configuration>

+	</Configurations>

+	<References>

+	</References>

+	<Files>

+		<Filter

+			Name="Sources"

+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"

+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"

+			>

+			<File

+				RelativePath="..\source\main\CFTest.cpp"

+				>

+			</File>

+			<File

+				RelativePath="..\source\main\CFTest.h"

+				>

+			</File>

+			<File

+				RelativePath="..\source\shared\CFUtils.cpp"

+				>

+			</File>

+			<File

+				RelativePath="..\source\shared\CFUtils.h"

+				>

+			</File>

+			<File

+				RelativePath="..\source\main\main.cpp"

+				>

+			</File>

+			<File

+				RelativePath="..\source\main\stdafx.h"

+				>

+			</File>

+			<File

+				RelativePath="..\source\shared\SuperString.cpp"

+				>

+			</File>

+			<File

+				RelativePath="..\source\shared\SuperString.h"

+				>

+			</File>

+		</Filter>

+	</Files>

+	<Globals>

+	</Globals>

+</VisualStudioProject>

diff --git a/CoreFoundation/examples/DNSServiceMetaQuery/DNSServiceMetaQuery.c b/CoreFoundation/examples/DNSServiceMetaQuery/DNSServiceMetaQuery.c
new file mode 100755
index 0000000..f99e7f9
--- /dev/null
+++ b/CoreFoundation/examples/DNSServiceMetaQuery/DNSServiceMetaQuery.c
@@ -0,0 +1,489 @@
+/*
+ * Copyright (c) 2009 Brent Fulgham.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the BSD-style license (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ */
+/*
+    File:  DNSServiceMetaQuery.c
+    
+    Contains:  Sample code which shows how to discover all Bonjour service types
+    being advertised on the local network.
+    
+    Copyright:  (c) Copyright 2004-2005 Apple Computer, Inc. All rights reserved.
+
+    Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
+    ("Apple") in consideration of your agreement to the following terms, and your
+    use, installation, modification or redistribution of this Apple software
+    constitutes acceptance of these terms.  If you do not agree with these terms,
+    please do not use, install, modify or redistribute this Apple software.
+
+    In consideration of your agreement to abide by the following terms, and subject
+    to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+    copyrights in this original Apple software (the "Apple Software"), to use,
+    reproduce, modify and redistribute the Apple Software, with or without
+    modifications, in source and/or binary forms; provided that if you redistribute
+    the Apple Software in its entirety and without modifications, you must retain
+    this notice and the following text and disclaimers in all such redistributions of
+    the Apple Software.  Neither the name, trademarks, service marks or logos of
+    Apple Computer, Inc. may be used to endorse or promote products derived from the
+    Apple Software without specific prior written permission from Apple.  Except as
+    expressly stated in this notice, no other rights or licenses, express or implied,
+    are granted by Apple herein, including but not limited to any patent rights that
+    may be infringed by your derivative works or by other works in which the Apple
+    Software may be incorporated.
+
+    The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
+    WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+    PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+    COMBINATION WITH YOUR PRODUCTS.
+
+    IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+    ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+    OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+    (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+    ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+      
+    Change History (most recent first):
+        1.2   May 13, 2005
+        1.1   December 8, 2004
+        1.0   May 28, 2004
+*/
+
+#if defined(WIN32)
+#include <stdio.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+#include <dns_sd.h>
+#include <Iprtrmib.h>
+#include <Iphlpapi.h>
+
+static char* if_indextoname (DWORD ifIndex, char* nameBuff);
+
+#define usleep(X)  Sleep(((X)+999)/1000)
+#define ns_t_ptr    12
+#define ns_c_in 1
+#else
+#include <dns_sd.h>
+#include <arpa/nameser.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <assert.h>
+#include <unistd.h>
+#endif
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#define MAX_DOMAIN_LABEL 63
+#define MAX_DOMAIN_NAME 255
+#define kServiceMetaQueryName  "_services._dns-sd._udp.local."
+
+typedef struct { unsigned char c[ 64]; } domainlabel;      // One label: length byte and up to 63 characters.
+typedef struct { unsigned char c[256]; } domainname;       // Up to 255 bytes of length-prefixed domainlabels.
+
+typedef struct MyDNSServiceState {
+    DNSServiceRef       service;
+    CFRunLoopSourceRef  source;
+    CFSocketRef         socket;
+} MyDNSServiceState;
+
+
+/* MyConvertDomainLabelToCString() converts a DNS label into a C string.
+A DNS label string is formatted like "\003com".  The converted string
+would look like "com." */
+
+static char*
+MyConvertDomainLabelToCString(const domainlabel *const label, char *ptr)
+{
+    const unsigned char *      src = label->c;      // Domain label we're reading.
+    const unsigned char        len = *src++;        // Read length of this (non-null) label.
+    const unsigned char *const end = src + len;     // Work out where the label ends.
+    
+    assert(label != NULL);
+    assert(ptr   != NULL);
+    
+    if (len > MAX_DOMAIN_LABEL) return(NULL);       // If illegal label, abort.
+    while (src < end) {                             // While we have characters in the label.
+        unsigned char c = *src++;
+        if (c == '.' || c == '\\')                  // If character is a dot or the escape character
+            *ptr++ = '\\';                          // Output escape character.
+        else if (c <= ' ') {                        // If non-printing ascii, output decimal escape sequence.
+            *ptr++ = '\\';
+            *ptr++ = (char)  ('0' + (c / 100)     );
+            *ptr++ = (char)  ('0' + (c /  10) % 10);
+            c      = (unsigned char)('0' + (c      ) % 10);
+        }
+        *ptr++ = (char)c;                           // Copy the character.
+    }
+    *ptr = 0;                                       // Null-terminate the string
+    return(ptr);                                    // and return.
+}
+
+
+/* MyConvertDomainNameToCString() converts a DNS name string into a C string.
+A DNS name string is formated like "\003www\005apple\003com\0".  The converted
+string would look like "www.apple.com".  If the DNS name contains a period "." or
+a backslash "\", then those characters will be escaped with backslash characters,
+as in "\." and "\\".  Note: To guarantee that there will be no possible overrun,
+"ptr" must be at least kDNSServiceMaxDomainName (1005 bytes) */
+
+static char*
+MyConvertDomainNameToCString(const domainname *const name, char *ptr)
+{
+    const unsigned char *src         = name->c;                     // Domain name we're reading.
+    const unsigned char *const max   = name->c + MAX_DOMAIN_NAME;   // Maximum that's valid.
+
+    assert(name != NULL);
+    assert(ptr  != NULL);
+
+    if (*src == 0) *ptr++ = '.';                                    // Special case: For root, just write a dot.
+
+    while (*src) {                                                  // While more characters in the domain name.
+        if (src + 1 + *src >= max) return(NULL);
+        ptr = MyConvertDomainLabelToCString((const domainlabel *)src, ptr);
+        if (!ptr) return(NULL);
+        src += 1 + *src;
+        *ptr++ = '.';                                               // Write the dot after the label.
+    }
+
+    *ptr++ = 0;                                                     // Null-terminate the string
+    return(ptr);                                                    // and return.
+}
+
+
+
+/* The DNSServiceQueryRecord callback returns a DNS PTR record with rdata formatted like:
+
+\005_http\004_tcp\005local\0
+    
+MyGetTypeAndDomain() takes the rdata and splits it up into two C strings which correspond to the
+"type" and "domain" of a service.  These strings could potentially be passed to a function
+like DNSServiceBrowse().  Assuming the example rdata above, this function would return "_http._tcp."
+as the "type", and "local." for the "domain". */
+
+static void
+MyGetTypeAndDomain(const void * rdata, uint16_t rdlen, char * type, char * domain)
+{
+    unsigned char *cursor;
+    unsigned char *start;
+    unsigned char *end;
+
+    assert(rdata  != NULL);
+    assert(rdlen  != 0);
+    assert(type   != NULL);
+    assert(domain != NULL);
+
+    start = (unsigned char*)malloc(rdlen);
+    assert(start != NULL);
+    memcpy(start, rdata, rdlen);
+
+    end = start + rdlen;
+    cursor = start;
+    if ((*cursor == 0) || (*cursor >= 64)) goto exitWithError;
+    cursor += 1 + *cursor;                                       // Move to the start of the second DNS label.
+    if (cursor >= end) goto exitWithError;
+    if ((*cursor == 0) || (*cursor >= 64)) goto exitWithError;
+    cursor += 1 + *cursor;                                       // Move to the start of the thrid DNS label.
+    if (cursor >= end) goto exitWithError;
+    
+    /* Take everything from start of third DNS label until end of DNS name and call that the "domain". */
+    if (MyConvertDomainNameToCString((const domainname *)cursor, domain) == NULL) goto exitWithError;
+    *cursor = 0;                                                 // Set the length byte of the third label to zero.
+
+    /* Take the first two DNS labels and call that the "type". */
+    if (MyConvertDomainNameToCString((const domainname *)start, type) == NULL) goto exitWithError;
+    free(start);
+    return;
+
+exitWithError:
+    fprintf(stderr, "Invalid DNS name string\n");
+    free(start);
+}
+
+
+
+static void
+MyDNSServiceCleanUp(MyDNSServiceState * query)
+{
+    /* Remove the CFRunLoopSource from the current run loop. */
+    CFRunLoopRemoveSource(CFRunLoopGetCurrent(), query->source, kCFRunLoopCommonModes);
+    CFRelease(query->source);
+
+    /* Invalidate the CFSocket. */
+    CFSocketInvalidate(query->socket);
+    CFRelease(query->socket);
+
+    /* Workaround that gives time to CFSocket's select thread so it can remove the socket from its FD set
+    before we close the socket by calling DNSServiceRefDeallocate. <rdar://problem/3585273> */
+    usleep(1000);
+
+    /* Terminate the connection with the mDNSResponder daemon, which cancels the query. */
+    DNSServiceRefDeallocate(query->service);
+}
+
+
+
+/* MySocketReadCallback() gets called when data is available for reading from the Unix domain socket
+connected to the mDNSResponder daemon.  This happens when the mDNSResponder delivers us a response to our query. */
+
+static void
+MySocketReadCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void * data, void * info)
+{
+#if defined(_APPLE_)
+    #pragma unused(s)
+    #pragma unused(type)
+    #pragma unused(address)
+    #pragma unused(data)
+#endif
+
+    DNSServiceErrorType err;
+ 
+    MyDNSServiceState* query = (MyDNSServiceState*)info;  // context passed in to CFSocketCreateWithNative().
+    assert(query != NULL);
+
+    /* Read a reply from the mDNSResponder, which will end up calling MyMetaQueryCallback(). */
+    err= DNSServiceProcessResult(query->service);
+    if (err != kDNSServiceErr_NoError)
+    {
+        fprintf(stderr, "DNSServiceProcessResult returned %d\n", err);
+        
+        /* Terminate the query operation and release the CFRunLoopSource and CFSocket. */
+        MyDNSServiceCleanUp(query);
+        CFRunLoopStop(CFRunLoopGetCurrent());
+    }
+}
+
+
+
+void
+MyDNSServiceAddServiceToRunLoop(MyDNSServiceState* query)
+{
+    CFSocketNativeHandle sock;
+    CFOptionFlags        sockFlags;
+    CFSocketContext      context = { 0, query, NULL, NULL, NULL };  // Use MyDNSServiceState as context data.
+    
+    /* Access the underlying Unix domain socket to communicate with the mDNSResponder daemon. */
+    sock = DNSServiceRefSockFD(query->service);
+    assert(sock != -1);
+    
+    /* Create a CFSocket using the Unix domain socket. */
+    query->socket = CFSocketCreateWithNative(NULL, sock, kCFSocketReadCallBack, MySocketReadCallback, &context);
+    assert(query->socket != NULL);
+    
+    /* Prevent CFSocketInvalidate from closing DNSServiceRef's socket. */
+    sockFlags = CFSocketGetSocketFlags(query->socket);
+    CFSocketSetSocketFlags(query->socket, sockFlags & (~kCFSocketCloseOnInvalidate));
+    
+    /* Create a CFRunLoopSource from the CFSocket. */
+    query->source = CFSocketCreateRunLoopSource(NULL, query->socket, 0);
+    assert(query->source != NULL);
+
+    /* Add the CFRunLoopSource to the current run loop. */
+    CFRunLoopAddSource(CFRunLoopGetCurrent(), query->source, kCFRunLoopCommonModes);
+}
+
+
+static void
+MyConvertInterfaceIndexToName(uint32_t interface, char * interfaceName)
+{
+    assert(interfaceName != NULL);
+    
+    if      (interface == 0)          strcpy(interfaceName,   "all");   // All active network interfaces.
+    else if (interface == 0xFFFFFFFF) strcpy(interfaceName, "local");   // Only available locally on this machine.
+    else if_indextoname(interface, interfaceName);                      // Converts interface index to interface name.
+}
+
+
+static void
+DNSSD_API MyMetaQueryCallback(DNSServiceRef service, DNSServiceFlags flags, uint32_t interfaceID, DNSServiceErrorType error,
+    const char * fullname, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void * rdata, uint32_t ttl, void * context)
+{    
+#if defined(_APPLE_)
+    #pragma unused(service)
+    #pragma unused(rrclass)
+    #pragma unused(ttl)
+    #pragma unused(context)
+#endif
+
+    assert(strcmp(fullname, kServiceMetaQueryName) == 0);
+                    
+    if (error == kDNSServiceErr_NoError) {
+    
+#if defined(_GNUC_)
+        char interfaceName[IF_NAMESIZE] = "";
+        char domain[MAX_DOMAIN_NAME]    = "";
+        char type[MAX_DOMAIN_NAME]      = "";
+#else
+        char interfaceName[MAX_DOMAIN_NAME];
+        char domain[MAX_DOMAIN_NAME];
+        char type[MAX_DOMAIN_NAME];
+
+        memset(interfaceName, 0x00, MAX_DOMAIN_NAME);
+        memset(domain, 0x00, MAX_DOMAIN_NAME);
+        memset(type, 0x00, MAX_DOMAIN_NAME);
+#endif
+        /* Get the type and domain from the discovered PTR record. */
+        MyGetTypeAndDomain(rdata, rdlen, type, domain);        
+
+        /* Convert an interface index into a BSD-style interface name. */
+        MyConvertInterfaceIndexToName(interfaceID, interfaceName);
+        
+        if (flags & kDNSServiceFlagsAdd) {
+            fprintf(stderr, "ADD      %-28s  %-14s %s\n", type, domain, interfaceName);
+        } else {
+            /* REMOVE is only called when a network interface is disabled or if the record
+            expires from the cache.  For network efficiency reasons, clients do not send
+            goodbye packets for meta-query PTR records when deregistering a service.  */
+            fprintf(stderr, "REMOVE   %-28s  %-14s %s\n", type, domain, interfaceName);
+        }
+    } else {
+        fprintf(stderr, "MyQueryRecordCallback returned %d\n", error);
+    }
+}
+
+
+
+static DNSServiceErrorType
+MyDNSServiceMetaQuery(MyDNSServiceState * query, DNSServiceQueryRecordReply callback)
+{
+    DNSServiceErrorType error;
+
+    assert(query    != NULL);
+    assert(callback != NULL);
+
+    /* Issue a Multicast DNS query for the service type meta-query PTR record. */
+    error = DNSServiceQueryRecord(&query->service,
+                                                0,  // no flags
+                                                0,  // all network interfaces
+                            kServiceMetaQueryName,  // meta-query record name
+                                         ns_t_ptr,  // DNS PTR Record
+                                          ns_c_in,  // Internet Class
+                                         callback,  // callback function ptr
+                                            NULL);  // no context
+
+    if (error == kDNSServiceErr_NoError) {
+
+        /* Create a CFRunLoopSource and add it to the run loop to enable asynchronous callbacks. */
+        MyDNSServiceAddServiceToRunLoop(query);
+        
+        fprintf(stderr, "Event       Service Type               Domain      Interface\n");
+        fprintf(stderr, "------------------------------------------------------------\n");
+    }
+
+    return error;
+}
+
+
+
+int
+main (int argc, const char * argv[])
+{
+#if defined(_APPLE_)
+    #pragma unused(argc)
+    #pragma unused(argv)
+#endif
+    
+    MyDNSServiceState query;
+    DNSServiceErrorType error;
+    
+    /* Start the DNS-SD services meta-query, create the CFRunLoopSource, add it to the run loop. */
+    error = MyDNSServiceMetaQuery(&query, (DNSServiceQueryRecordReply)MyMetaQueryCallback);
+    if (error == kDNSServiceErr_NoError) {
+    
+        /* Start the run loop to receive asynchronous callbacks via MyMetaQueryCallback. */
+        CFRunLoopRun();
+        
+        /* Terminate the query operation and release the CFRunLoopSource and CFSocket. */
+        MyDNSServiceCleanUp(&query);
+        
+    } else {
+        fprintf(stderr, "MyDNSServiceMetaQuery returned %d\n", error);
+    }
+
+    return 0;
+}
+
+#if defined(WIN32)
+/*
+ * The following implementation is from Apple's Bonjour implementation.
+ * It's so annoying that this is not provided on user-level Windows OS's
+ * (you have to get server 2008 to have this implemented in the OS.)
+ *
+* Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+static char*
+if_indextoname( DWORD ifIndex, char * nameBuff)
+{
+        PIP_ADAPTER_INFO        pAdapterInfo = NULL;
+        PIP_ADAPTER_INFO        pAdapter = NULL;
+        DWORD                           dwRetVal = 0;
+        char                    *       ifName = NULL;
+        ULONG                           ulOutBufLen = 0;
+
+        if (GetAdaptersInfo( NULL, &ulOutBufLen) != ERROR_BUFFER_OVERFLOW)
+        {
+                goto exit;
+        }
+
+        pAdapterInfo = (IP_ADAPTER_INFO *) malloc(ulOutBufLen);
+
+        if (pAdapterInfo == NULL)
+        {
+                goto exit;
+        }
+
+        dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen );
+
+        if (dwRetVal != NO_ERROR)
+        {
+                goto exit;
+        }
+
+        pAdapter = pAdapterInfo;
+        while (pAdapter)
+        {
+                if (pAdapter->Index == ifIndex)
+                {
+                        // It would be better if we passed in the length of nameBuff to this
+                        // function, so we would have absolute certainty that no buffer
+                        // overflows would occur.  Buffer overflows *shouldn't* occur because
+                        // nameBuff is of size MAX_ADAPTER_NAME_LENGTH.
+                        strcpy( nameBuff, pAdapter->AdapterName );
+                        ifName = nameBuff;
+                        break;
+                }
+
+                pAdapter = pAdapter->Next;
+        }
+
+exit:
+
+        if (pAdapterInfo != NULL)
+        {
+                free( pAdapterInfo );
+                pAdapterInfo = NULL;
+        }
+
+        return ifName;
+}
+#endif
diff --git a/CoreFoundation/examples/DNSServiceMetaQuery/DNSServiceMetaQuery.vcproj b/CoreFoundation/examples/DNSServiceMetaQuery/DNSServiceMetaQuery.vcproj
new file mode 100755
index 0000000..ad4baae
--- /dev/null
+++ b/CoreFoundation/examples/DNSServiceMetaQuery/DNSServiceMetaQuery.vcproj
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="DNSServiceMetaQuery"
+	ProjectGUID="{B5F7F4D9-DCA9-4CCD-8776-D2EAF45E4BE9}"
+	RootNamespace="DNSServiceMetaQuery"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;C:\Program Files\Bonjour SDK\include&quot;;&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;WINDOWS_LEAN_AND_MEAN=1"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="dnssd.lib Iphlpapi.lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;C:\Program Files\Bonjour SDK\lib\win32&quot;;&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;C:\Program Files\Bonjour SDK\include&quot;;&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="dnssd.lib Iphlpapi.lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;C:\Program Files\Bonjour SDK\lib\win32&quot;;&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\DNSServiceMetaQuery.c"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/CoreFoundation/examples/DNSServiceMetaQuery/Makefile.am b/CoreFoundation/examples/DNSServiceMetaQuery/Makefile.am
new file mode 100644
index 0000000..47073b6
--- /dev/null
+++ b/CoreFoundation/examples/DNSServiceMetaQuery/Makefile.am
@@ -0,0 +1,12 @@
+AM_CFLAGS			= -I${top_srcdir}/include
+
+EXTRA_DIST			= DNSServiceMetaQuery.vcproj \
+				  README.txt
+
+if CF_BUILD_TESTS
+EXTRA_PROGRAMS			= DNSServiceMetaQuery
+endif
+
+DNSServiceMetaQuery_LDADD	= ${top_builddir}/libCoreFoundation.la -ldns_sd
+
+DNSServiceMetaQuery_SOURCES	= DNSServiceMetaQuery.c
diff --git a/CoreFoundation/examples/DNSServiceMetaQuery/Makefile.in b/CoreFoundation/examples/DNSServiceMetaQuery/Makefile.in
new file mode 100644
index 0000000..801251f
--- /dev/null
+++ b/CoreFoundation/examples/DNSServiceMetaQuery/Makefile.in
@@ -0,0 +1,453 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@EXTRA_PROGRAMS = DNSServiceMetaQuery$(EXEEXT)
+subdir = examples/DNSServiceMetaQuery
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_DNSServiceMetaQuery_OBJECTS = DNSServiceMetaQuery.$(OBJEXT)
+DNSServiceMetaQuery_OBJECTS = $(am_DNSServiceMetaQuery_OBJECTS)
+DNSServiceMetaQuery_DEPENDENCIES =  \
+	${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(DNSServiceMetaQuery_SOURCES)
+DIST_SOURCES = $(DNSServiceMetaQuery_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = DNSServiceMetaQuery.vcproj \
+				  README.txt
+
+DNSServiceMetaQuery_LDADD = ${top_builddir}/libCoreFoundation.la -ldns_sd
+DNSServiceMetaQuery_SOURCES = DNSServiceMetaQuery.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/DNSServiceMetaQuery/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/DNSServiceMetaQuery/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+DNSServiceMetaQuery$(EXEEXT): $(DNSServiceMetaQuery_OBJECTS) $(DNSServiceMetaQuery_DEPENDENCIES) 
+	@rm -f DNSServiceMetaQuery$(EXEEXT)
+	$(LINK) $(DNSServiceMetaQuery_OBJECTS) $(DNSServiceMetaQuery_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DNSServiceMetaQuery.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/DNSServiceMetaQuery/README.txt b/CoreFoundation/examples/DNSServiceMetaQuery/README.txt
new file mode 100644
index 0000000..e60d5ab
--- /dev/null
+++ b/CoreFoundation/examples/DNSServiceMetaQuery/README.txt
@@ -0,0 +1,29 @@
+DNSServiceMetaQuery is based on the Apple, inc. example:
+http://developer.apple.com/samplecode/DNSServiceMetaQuery/index.html
+
+It has been modified to build using OpenCFLite.
+
+The program shows how to discover every Bonjour service type
+being advertised on the local network.  You must have the
+Bonjour SDK installed (or an equivalent Zeroconf service, such
+as Avahi).  You may need to modify project settings to point
+to the proper location on your system for the necessary
+service discovery API (dns_sd.h).
+
+This sample uses the socket-based DNSServiceDiscovery API to
+discover all service types being advertised on the network.
+Starting in Mac OS X 10.3.4, computers on the network which
+advertise Bonjour services will automatically register an
+additional PTR record with the name "_services._dns-sd._udp.local."
+which points to the service type and domain of the advertised
+service.  For example:
+
+_services._dns-sd._udp.local.  IN  PTR  _ftp._tcp.local.
+
+This sample uses DNSServiceQueryRecord() to send a Multicast
+DNS query for a PTR record named "_services._dns-sd._udp.local.".
+The result of the query will be a PTR record which points to the
+DNS-SD service type and domain.  This sample also shows how to
+parse the resulting PTR record data so that you could potentially
+pass the results to DNSServiceBrowse().
+
diff --git a/CoreFoundation/examples/DisplayURL/DisplayURL.c b/CoreFoundation/examples/DisplayURL/DisplayURL.c
new file mode 100755
index 0000000..ee5edb4
--- /dev/null
+++ b/CoreFoundation/examples/DisplayURL/DisplayURL.c
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2009 Brent Fulgham <bfulgham@gmail.org>.  All rights reserved.
+ *
+ * This source code is a modified version of the example sources released by Apple Inc. under
+ * the BSD-like license (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * This code has been modified to avoid using services unavailable outside the Mac OS X platform.
+ *
+ * The original license information is as follows:
+ */
+/*
+	File:		main.c
+
+	Abstract:	DisplayURL gets the URL for a  volume with FSCopyURLForVolume, displays it, and
+				then uses CFURL routines to parse it into its various components. The output of
+				server based files/folders is similar to the "Server:" information displayed by
+				the "Get Info" window from within the Finder.
+				Example:
+				DisplayURL -u "scheme://user:pass@host:1/path/path2/file.html;params?query#fragment"
+
+	Version:	1.0
+
+	Disclaimer:	IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
+				("Apple") in consideration of your agreement to the following terms, and your
+				use, installation, modification or redistribution of this Apple software
+				constitutes acceptance of these terms.  If you do not agree with these terms,
+				please do not use, install, modify or redistribute this Apple software.
+
+				In consideration of your agreement to abide by the following terms, and subject
+				to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+				copyrights in this original Apple software (the "Apple Software"), to use,
+				reproduce, modify and redistribute the Apple Software, with or without
+				modifications, in source and/or binary forms; provided that if you redistribute
+				the Apple Software in its entirety and without modifications, you must retain
+				this notice and the following text and disclaimers in all such redistributions of
+				the Apple Software.  Neither the name, trademarks, service marks or logos of
+				Apple Computer, Inc. may be used to endorse or promote products derived from the
+				Apple Software without specific prior written permission from Apple.  Except as
+				expressly stated in this notice, no other rights or licenses, express or implied,
+				are granted by Apple herein, including but not limited to any patent rights that
+				may be infringed by your derivative works or by other works in which the Apple
+				Software may be incorporated.
+
+				The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
+				WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+				WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+				PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+				COMBINATION WITH YOUR PRODUCTS.
+
+				IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+				CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+				GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+				ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+				OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+				(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+				ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+	Copyright 2005 Apple Computer, Inc., All Rights Reserved
+*/
+
+#if defined(WIN32)
+#include <stdio.h>
+#else
+#include <unistd.h>
+#endif
+
+#include "AssertMacros.h"
+#if defined(__APPLE__)
+#include <CoreServices/CoreServices.h>
+#else
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+enum
+{
+	kBufferLength = 0x1000	/* 4K */
+};
+
+
+static void usage(void)
+{
+#if defined(__APPLE__)
+	fprintf(stderr, "usage: DisplayURL [-h] [-u <url> | <path>]\n");
+	fprintf(stderr, "       DisplayURL parses a URL into its various components and displays them.\n");
+	fprintf(stderr, "       The URL parsed can be passed in as the -u argument, or can be the URL\n");
+	fprintf(stderr, "       for a file system path location passed in as the <path> argument.\n");
+	fprintf(stderr, "       The usage of the <path> argument should be changed to:\n");
+	fprintf(stderr, "       \"<path> File system path.n\"\n");
+	fprintf(stderr, "       -h       Shows this help message.\n");
+	fprintf(stderr, "       -u <url> The URL to parse.\n");
+	fprintf(stderr, "       <path>   Path to the network file system.\n");
+#else
+	fprintf(stderr, "usage: DisplayURL [-h] [-u <url>]\n");
+	fprintf(stderr, "       DisplayURL parses a URL into its various components and displays them.\n");
+	fprintf(stderr, "       The URL parsed is passed in as the -u argument.\n");
+	fprintf(stderr, "       -h       Shows this help message.\n");
+	fprintf(stderr, "       -u <url> The URL to parse.\n");
+#endif
+}
+
+static void DisplayURLComponent(CFURLRef url, UInt8 *buffer, CFURLComponentType componentType, char *componentTypeStr)
+{
+	CFRange range;
+	CFRange rangeIncludingSeparators;
+	
+	/* now, get the components and display them */
+	range = CFURLGetByteRangeForComponent(url, componentType, &rangeIncludingSeparators);
+	if ( range.location != kCFNotFound )
+	{
+		char componentStr[kBufferLength];
+		char componentIncludingSeparatorsStr[kBufferLength];
+		
+		strncpy(componentStr, (const char *)&buffer[range.location], range.length);
+		componentStr[range.length] = 0;
+		strncpy(componentIncludingSeparatorsStr, (const char *)&buffer[rangeIncludingSeparators.location], rangeIncludingSeparators.length);
+		componentIncludingSeparatorsStr[rangeIncludingSeparators.length] = 0;
+		fprintf(stdout, "%s: \"%s\" including separators: \"%s\"\n", componentTypeStr, componentStr, componentIncludingSeparatorsStr);
+	}
+	else
+	{
+		fprintf(stdout, "%s not found\n", componentTypeStr);
+	}
+}
+
+int main (int argc, char * const argv[])
+{
+	int err;
+	char dot[] = ".";
+#if defined(__APPLE__)
+	FSRef ref;
+	OSStatus result;
+	FSCatalogInfo catalogInfo;
+#elif defined(WIN32)
+	const char* optarg = 0;
+#endif
+#if !defined(WIN32)
+	int ch;
+#endif
+	CFURLRef url;
+	UInt8 buffer[kBufferLength];
+	CFIndex componentLength;
+	
+	err = EXIT_SUCCESS;
+	url = NULL;
+	
+	require_action(argc > 1, command_err, usage());
+
+	/* crack command line args */
+#if defined(WIN32)
+	err = EXIT_FAILURE;
+   if (0 == strcmp("-h", argv[1]))
+   	require_action(err == EXIT_SUCCESS, command_err, usage());
+
+   if (0 == strcmp("-u", argv[1]) && argc == 3)
+   {
+      optarg = argv[2];
+      url = CFURLCreateWithBytes(kCFAllocatorDefault, (UInt8 *)optarg, strlen(optarg), kCFStringEncodingMacRoman, NULL);
+      err = EXIT_SUCCESS;
+   }
+#else
+	while ( ((ch = getopt(argc, argv, "hu:")) != -1) && (err == EXIT_SUCCESS) )
+	{
+		switch (ch)
+		{
+			case 'u':
+				url = CFURLCreateWithBytes(kCFAllocatorDefault, (UInt8 *)optarg, strlen(optarg), kCFStringEncodingMacRoman, NULL);
+				if ( url == NULL )
+				{
+					err = EXIT_FAILURE;
+				}
+				break;
+			case 'h':
+			case '?':
+			default:
+				err = EXIT_FAILURE;
+				break;
+		}
+	}
+#endif
+	
+	if ( !err )
+	{
+		if (argc > 3)
+		{
+			err = EXIT_FAILURE;
+		}
+	}
+	
+	require_action(err == EXIT_SUCCESS, command_err, usage());
+ 
+	/* if we have a URL, then don't create one from the path */
+	if ( url == NULL )
+	{
+#if defined(__APPLE__)
+		/* convert the path to a FSRef */
+		result = FSPathMakeRef((UInt8 *)((argc == 2) ? argv[1] : dot), &ref, NULL);
+		require_noerr_action(result, FSPathMakeRef, err = EXIT_FAILURE);
+		
+		/* get the volume reference in catalogInfo.volume */
+		result = FSGetCatalogInfo(&ref, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL);
+		require_noerr_action(result, FSGetCatalogInfo, err = EXIT_FAILURE);
+		
+		/* get the CFURL for volume */
+		result = FSCopyURLForVolume(catalogInfo.volume, &url);
+		require_noerr_action(result, FSCopyURLForVolume, err = EXIT_FAILURE);
+#else
+      err = EXIT_FAILURE;
+      require_action(err == EXIT_SUCCESS, command_err, usage());
+#endif
+	}
+	
+	/* get the bytes from the URL */
+	componentLength = CFURLGetBytes(url, buffer, kBufferLength);
+	require_action(componentLength != -1, CFURLGetBytes, err = EXIT_FAILURE);
+
+	buffer[componentLength] = 0;
+	fprintf(stdout, "url: \"%s\"\n", buffer);
+	DisplayURLComponent(url, buffer, kCFURLComponentScheme, "kCFURLComponentScheme");
+	DisplayURLComponent(url, buffer, kCFURLComponentNetLocation, "kCFURLComponentNetLocation");
+	DisplayURLComponent(url, buffer, kCFURLComponentPath, "kCFURLComponentPath");
+	DisplayURLComponent(url, buffer, kCFURLComponentResourceSpecifier, "kCFURLComponentResourceSpecifier");
+	DisplayURLComponent(url, buffer, kCFURLComponentUser, "kCFURLComponentUser");
+	DisplayURLComponent(url, buffer, kCFURLComponentPassword, "kCFURLComponentPassword");
+	DisplayURLComponent(url, buffer, kCFURLComponentUserInfo, "kCFURLComponentUserInfo");
+	DisplayURLComponent(url, buffer, kCFURLComponentHost, "kCFURLComponentHost");
+	DisplayURLComponent(url, buffer, kCFURLComponentPort, "kCFURLComponentPort");
+	DisplayURLComponent(url, buffer, kCFURLComponentParameterString, "kCFURLComponentParameterString");
+	DisplayURLComponent(url, buffer, kCFURLComponentQuery, "kCFURLComponentQuery");
+	DisplayURLComponent(url, buffer, kCFURLComponentFragment, "kCFURLComponentFragment");
+
+CFURLGetBytes:
+
+	CFRelease(url);
+	
+#if defined(__APPLE__)
+FSCopyURLForVolume:
+FSGetCatalogInfo:
+FSPathMakeRef:
+#endif
+command_err:
+
+    return ( err );
+}
+
diff --git a/CoreFoundation/examples/DisplayURL/DisplayURL.vcproj b/CoreFoundation/examples/DisplayURL/DisplayURL.vcproj
new file mode 100755
index 0000000..292c1b6
--- /dev/null
+++ b/CoreFoundation/examples/DisplayURL/DisplayURL.vcproj
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="DisplayURL"
+	ProjectGUID="{6816B34F-DE8C-48EC-8F31-11176DA5FE11}"
+	RootNamespace="DisplayURL"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="$(SolutionDir)\dist\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;WINDOWS_LEAN_AND_MEAN=1"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CFLite_$(ConfigurationName).lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="$(SolutionDir)\dist\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\DisplayURL.c"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/CoreFoundation/examples/DisplayURL/Makefile.am b/CoreFoundation/examples/DisplayURL/Makefile.am
new file mode 100644
index 0000000..b8b2097
--- /dev/null
+++ b/CoreFoundation/examples/DisplayURL/Makefile.am
@@ -0,0 +1,29 @@
+AM_CFLAGS		= -I${top_srcdir}/include
+
+EXTRA_DIST		= DisplayURL.vcproj \
+			  README.txt
+
+if CF_BUILD_TESTS
+check_PROGRAMS		= DisplayURL
+endif
+
+DisplayURL_LDADD	= ${top_builddir}/libCoreFoundation.la
+
+DisplayURL_SOURCES	= DisplayURL.c
+
+if CF_BUILD_TESTS
+check:
+	${LIBTOOL} --mode execute ./DisplayURL -u http://www.apple.com/
+	${LIBTOOL} --mode execute ./DisplayURL -u http://developer.apple.com/referencelibrary/GettingStarted/GS_CoreFoundation/index.html
+	${LIBTOOL} --mode execute ./DisplayURL -u http://opencflite.sourceforge.net/
+	${LIBTOOL} --mode execute ./DisplayURL -u http://downloads.sourceforge.net:80/opencflite/opencflite-476.17.0.tar.gz
+	${LIBTOOL} --mode execute ./DisplayURL -u ftp://anonymous:guest@downloads.sourceforge.net:21/opencflite/opencflite-476.17.0.tar.gz
+	${LIBTOOL} --mode execute ./DisplayURL -u file://localhost/var/tmp
+	${LIBTOOL} --mode execute ./DisplayURL -u file:///etc/motd
+
+gdb:
+	${LIBTOOL} --mode execute ${@} ./DisplayURL
+
+valgrind:
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./DisplayURL
+endif
diff --git a/CoreFoundation/examples/DisplayURL/Makefile.in b/CoreFoundation/examples/DisplayURL/Makefile.in
new file mode 100644
index 0000000..868d9be
--- /dev/null
+++ b/CoreFoundation/examples/DisplayURL/Makefile.in
@@ -0,0 +1,477 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = DisplayURL$(EXEEXT)
+subdir = examples/DisplayURL
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_DisplayURL_OBJECTS = DisplayURL.$(OBJEXT)
+DisplayURL_OBJECTS = $(am_DisplayURL_OBJECTS)
+DisplayURL_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(DisplayURL_SOURCES)
+DIST_SOURCES = $(DisplayURL_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = DisplayURL.vcproj \
+			  README.txt
+
+DisplayURL_LDADD = ${top_builddir}/libCoreFoundation.la
+DisplayURL_SOURCES = DisplayURL.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/DisplayURL/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/DisplayURL/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+DisplayURL$(EXEEXT): $(DisplayURL_OBJECTS) $(DisplayURL_DEPENDENCIES) 
+	@rm -f DisplayURL$(EXEEXT)
+	$(LINK) $(DisplayURL_OBJECTS) $(DisplayURL_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisplayURL.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@check:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./DisplayURL -u http://www.apple.com/
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./DisplayURL -u http://developer.apple.com/referencelibrary/GettingStarted/GS_CoreFoundation/index.html
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./DisplayURL -u http://opencflite.sourceforge.net/
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./DisplayURL -u http://downloads.sourceforge.net:80/opencflite/opencflite-476.17.0.tar.gz
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./DisplayURL -u ftp://anonymous:guest@downloads.sourceforge.net:21/opencflite/opencflite-476.17.0.tar.gz
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./DisplayURL -u file://localhost/var/tmp
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./DisplayURL -u file:///etc/motd
+
+@CF_BUILD_TESTS_TRUE@gdb:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./DisplayURL
+
+@CF_BUILD_TESTS_TRUE@valgrind:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./DisplayURL
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/DisplayURL/README.txt b/CoreFoundation/examples/DisplayURL/README.txt
new file mode 100644
index 0000000..b8dfcad
--- /dev/null
+++ b/CoreFoundation/examples/DisplayURL/README.txt
@@ -0,0 +1,31 @@
+DisplayURL is based on the Apple, inc. example:
+http://developer.apple.com/samplecode/DisplayURL/index.html#//apple_ref/doc/uid/DTS10003783
+
+It has been modified to build using OpenCFLite.  Consequently,
+the file system routines are currently disabled.
+
+DisplayURL accepts a URL as an input string, and parses it into
+its various components using CFURL routines.
+
+DisplayURL [-h] [-u <url>]
+        DisplayURL parses a URL's components
+        -h       Shows this help message.
+        -u <url> The URL to parse.
+
+The sample also illustrates how to use the CFURLGetByteRangeForComponent API.  As an example you can see how CFURLGetByteRangeForComponent deconstructs the following URL into its components.
+
+> DisplayURL -u "scheme://user:pass@host:1/path/path2/file.html;params?query#fragment"
+url: "scheme://user:pass@host:1/path/path2/file.html;params?query#fragment"
+kCFURLComponentScheme: "scheme" including separators: "scheme://"
+kCFURLComponentNetLocation: "user:pass@host:1" including separators: "://user:pass@host:1"
+kCFURLComponentPath: "/path/path2/file.html" including separators: "/path/path2/file.html;"
+kCFURLComponentResourceSpecifier: "params?query#fragment" including separators: ";params?query#fragment"
+kCFURLComponentUser: "user" including separators: "://user:"
+kCFURLComponentPassword: "pass" including separators: ":pass@"
+kCFURLComponentUserInfo: "user:pass" including separators: "://user:pass@"
+kCFURLComponentHost: "host" including separators: "@host:"
+kCFURLComponentPort: "1" including separators: ":1"
+kCFURLComponentParameterString: "params" including separators: ";params?"
+kCFURLComponentQuery: "query" including separators: "?query#"
+kCFURLComponentFragment: "fragment" including separators: "#fragment"
+
diff --git a/CoreFoundation/examples/Makefile.am b/CoreFoundation/examples/Makefile.am
new file mode 100644
index 0000000..366a2d1
--- /dev/null
+++ b/CoreFoundation/examples/Makefile.am
@@ -0,0 +1,11 @@
+SUBDIRS			= ReadPListExample	\
+			  WritePListExample	\
+			  StringExample		\
+			  Allocator		\
+			  CFMessagePort		\
+			  DisplayURL		\
+			  DNSServiceMetaQuery	\
+			  CFLocalServer		\
+			  SimpleWebServer	\
+			  CFRunLoopTimerExample	\
+			  CFTest
diff --git a/CoreFoundation/examples/Makefile.in b/CoreFoundation/examples/Makefile.in
new file mode 100644
index 0000000..48c610f
--- /dev/null
+++ b/CoreFoundation/examples/Makefile.in
@@ -0,0 +1,518 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = examples
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = ReadPListExample	\
+			  WritePListExample	\
+			  StringExample		\
+			  Allocator		\
+			  CFMessagePort		\
+			  DisplayURL		\
+			  DNSServiceMetaQuery	\
+			  CFLocalServer		\
+			  SimpleWebServer	\
+			  CFRunLoopTimerExample	\
+			  CFTest
+
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	    distdir=`$(am__cd) $(distdir) && pwd`; \
+	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$top_distdir" \
+	        distdir="$$distdir/$$subdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+	install-strip
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic clean-libtool \
+	ctags ctags-recursive distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/ReadPListExample/Makefile.am b/CoreFoundation/examples/ReadPListExample/Makefile.am
new file mode 100644
index 0000000..d7913aa
--- /dev/null
+++ b/CoreFoundation/examples/ReadPListExample/Makefile.am
@@ -0,0 +1,23 @@
+AM_CXXFLAGS			= -I${top_srcdir}/include
+
+EXTRA_DIST			= schema.xml \
+				  ReadPListExample.vcproj
+
+if CF_BUILD_TESTS
+check_PROGRAMS			= ReadPListExample
+endif
+
+ReadPListExample_LDADD		= ${top_builddir}/libCoreFoundation.la
+
+ReadPListExample_SOURCES	= ReadPListExample.cpp
+
+if CF_BUILD_TESTS
+check:
+	${LIBTOOL} --mode execute ./ReadPListExample ${srcdir}/schema.xml
+
+gdb:
+	${LIBTOOL} --mode execute ${@} ./ReadPListExample
+
+valgrind:
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./ReadPListExample
+endif
diff --git a/CoreFoundation/examples/ReadPListExample/Makefile.in b/CoreFoundation/examples/ReadPListExample/Makefile.in
new file mode 100644
index 0000000..e2056d8
--- /dev/null
+++ b/CoreFoundation/examples/ReadPListExample/Makefile.in
@@ -0,0 +1,471 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = ReadPListExample$(EXEEXT)
+subdir = examples/ReadPListExample
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_ReadPListExample_OBJECTS = ReadPListExample.$(OBJEXT)
+ReadPListExample_OBJECTS = $(am_ReadPListExample_OBJECTS)
+ReadPListExample_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(ReadPListExample_SOURCES)
+DIST_SOURCES = $(ReadPListExample_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CXXFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = schema.xml \
+				  ReadPListExample.vcproj
+
+ReadPListExample_LDADD = ${top_builddir}/libCoreFoundation.la
+ReadPListExample_SOURCES = ReadPListExample.cpp
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/ReadPListExample/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/ReadPListExample/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+ReadPListExample$(EXEEXT): $(ReadPListExample_OBJECTS) $(ReadPListExample_DEPENDENCIES) 
+	@rm -f ReadPListExample$(EXEEXT)
+	$(CXXLINK) $(ReadPListExample_OBJECTS) $(ReadPListExample_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ReadPListExample.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@check:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./ReadPListExample ${srcdir}/schema.xml
+
+@CF_BUILD_TESTS_TRUE@gdb:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./ReadPListExample
+
+@CF_BUILD_TESTS_TRUE@valgrind:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./ReadPListExample
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/ReadPListExample/ReadPListExample.cpp b/CoreFoundation/examples/ReadPListExample/ReadPListExample.cpp
new file mode 100755
index 0000000..d050774
--- /dev/null
+++ b/CoreFoundation/examples/ReadPListExample/ReadPListExample.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ * The original license information is as follows:
+ *
+ */
+
+//
+// Apple's "Read a PList" example program.
+// Taken from http://developer.apple.com/opensource/cflite.html
+//
+
+#include <stdio.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+static void readPropertyListFromFile (const char *path) {
+    CFDataRef data = NULL;
+		
+    FILE* file = fopen (path, "r");
+
+	if (file == NULL) {
+		fprintf(stderr, "Cannot open `%s' for reading.\n", path);
+	} else {
+        int result = fseek (file, 0, SEEK_END);
+        result = ftell (file);
+        rewind (file);
+
+        char* buffer = (char*)calloc (1, result);
+
+        if (buffer != NULL) {
+            int rc = (int)fread (buffer, result, 1, file);
+            if (rc > 0 || !ferror (file)) {
+                data = CFDataCreate (NULL, (const UInt8*)buffer, result);
+            }
+
+            free (buffer);
+        } 
+
+        fclose (file);
+    }
+
+    if (data != NULL) {
+        CFPropertyListRef propertyList = CFPropertyListCreateFromXMLData (NULL, data, kCFPropertyListImmutable, NULL);
+
+        CFShow (CFSTR ("Property list (as read from file):"));
+        CFShow (propertyList);
+
+		CFRelease(data);
+    }
+}
+
+int main (int argc, const char* argv[]) {
+	if (argc != 2) {
+		fprintf(stderr, "Usage: %s <Property List>\n", argv[0]);
+		return 1;
+	}
+
+    readPropertyListFromFile (argv[1]);	
+
+    return 0;
+}
diff --git a/CoreFoundation/examples/ReadPListExample/ReadPListExample.vcproj b/CoreFoundation/examples/ReadPListExample/ReadPListExample.vcproj
new file mode 100755
index 0000000..8e8783f
--- /dev/null
+++ b/CoreFoundation/examples/ReadPListExample/ReadPListExample.vcproj
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ReadPListExample"
+	ProjectGUID="{CDF7218C-AE33-4367-B6F9-5728AE3C7F6E}"
+	RootNamespace="ReadPListExample"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;WINDOWS_LEAN_AND_MEAN=1"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CFLite_$(ConfigurationName).lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\ReadPListExample.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/CoreFoundation/examples/ReadPListExample/schema.xml b/CoreFoundation/examples/ReadPListExample/schema.xml
new file mode 100755
index 0000000..36e3543
--- /dev/null
+++ b/CoreFoundation/examples/ReadPListExample/schema.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>City of Birth</key>
+	<string>Springfield</string>
+	<key>Kids Names</key>
+	<array>
+		<string>John</string>
+		<string>Kyra</string>
+	</array>
+	<key>Name</key>
+	<string>John Doe</string>
+	<key>Pets Names</key>
+	<array/>
+	<key>Picture</key>
+	<data>
+	PEKBpYGlmYFCPA==
+	</data>
+	<key>Year Of Birth</key>
+	<integer>1965</integer>
+</dict>
+</plist>
diff --git a/CoreFoundation/examples/SimpleWebServer/Makefile.am b/CoreFoundation/examples/SimpleWebServer/Makefile.am
new file mode 100644
index 0000000..86fa217
--- /dev/null
+++ b/CoreFoundation/examples/SimpleWebServer/Makefile.am
@@ -0,0 +1,7 @@
+if CF_BUILD_TESTS
+EXTRA_PROGRAMS			= SimpleWebServer
+endif
+
+SimpleWebServer_LDADD		= ${top_builddir}/libCoreFoundation.la
+
+SimpleWebServer_SOURCES		= SimpleWebServer.c
diff --git a/CoreFoundation/examples/SimpleWebServer/Makefile.in b/CoreFoundation/examples/SimpleWebServer/Makefile.in
new file mode 100644
index 0000000..e168673
--- /dev/null
+++ b/CoreFoundation/examples/SimpleWebServer/Makefile.in
@@ -0,0 +1,448 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@EXTRA_PROGRAMS = SimpleWebServer$(EXEEXT)
+subdir = examples/SimpleWebServer
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_SimpleWebServer_OBJECTS = SimpleWebServer.$(OBJEXT)
+SimpleWebServer_OBJECTS = $(am_SimpleWebServer_OBJECTS)
+SimpleWebServer_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(SimpleWebServer_SOURCES)
+DIST_SOURCES = $(SimpleWebServer_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SimpleWebServer_LDADD = ${top_builddir}/libCoreFoundation.la
+SimpleWebServer_SOURCES = SimpleWebServer.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/SimpleWebServer/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/SimpleWebServer/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+SimpleWebServer$(EXEEXT): $(SimpleWebServer_OBJECTS) $(SimpleWebServer_DEPENDENCIES) 
+	@rm -f SimpleWebServer$(EXEEXT)
+	$(LINK) $(SimpleWebServer_OBJECTS) $(SimpleWebServer_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleWebServer.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/SimpleWebServer/SimpleWebServer.c b/CoreFoundation/examples/SimpleWebServer/SimpleWebServer.c
new file mode 100644
index 0000000..e5c4cff
--- /dev/null
+++ b/CoreFoundation/examples/SimpleWebServer/SimpleWebServer.c
@@ -0,0 +1,426 @@
+// webserve.m -- a very simple web server using fork() to handle requests
+
+/* compile with
+cc -g -Wall -o webserve webserve.c
+*/
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !defined(_WIN32)
+#include <unistd.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#define SOCK_CONST_DATA const void*
+#else
+#include <stdio.h>
+#define WIN32_LEAN_AND_MEAN
+#define SOCK_CONST_DATA const char*
+#include <windows.h>
+#include <winsock2.h>
+#include <Iprtrmib.h>
+#include <Iphlpapi.h>
+#include <io.h>
+#define sleep Sleep
+static DWORD getpid() {
+   return GetCurrentProcessId();
+}
+char *strsep(char **stringp, const char *delim);
+#endif
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#define PORT_NUMBER 8080    // set to 80 to listen on the HTTP port
+#define LINEBUFFER_SIZE 8192
+
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+struct clientConn
+{
+   CFWriteStreamRef writeStream;
+   CFSocketNativeHandle listenSocket;
+};
+
+// HTTP request handling
+// these are some of the common HTTP response codes
+#define HTTP_OK         200
+#define HTTP_NOT_FOUND  404
+#define HTTP_ERROR      500
+
+
+// return a string to the browser
+#define returnString(httpResult, string, channel) \
+   returnBuffer((httpResult), (string), (strlen(string)), (channel))
+
+// return a character buffer (not necessarily zero-terminated) to the
+// browser (runs in the child)
+void returnBuffer (int httpResult, const char *content, 
+                   int contentLength, CFWriteStreamRef commChannel)
+{  
+    static const CFStringRef headerFmt = CFSTR("HTTP/1.0 %d blah\r\n");
+    static const CFStringRef contentType = CFSTR("Content-Type: text/html\r\n");
+    static const CFStringRef contentLenFmt = CFSTR("Content-Length: %d\r\n");
+    static const CFStringRef endHeader = CFSTR("\r\n");
+
+    CFStringRef header = 0, contentLengthStr = 0;
+
+    header = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, headerFmt, httpResult);
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(header,CFStringGetFastestEncoding(header)),CFStringGetLength(header));
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(contentType,CFStringGetFastestEncoding(contentType)),CFStringGetLength(contentType));
+
+    contentLengthStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, contentLenFmt, contentLength);
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(contentLengthStr,CFStringGetFastestEncoding(contentLengthStr)),CFStringGetLength(contentLengthStr));
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(endHeader,CFStringGetFastestEncoding(endHeader)),CFStringGetLength(endHeader));
+   
+    CFWriteStreamWrite(commChannel, (const UInt8*)content, contentLength);
+} // returnBuffer
+
+
+// stream back to the browser numbers being counted, with a pause
+// between them.  The user should see the numbers appear every couple
+// of seconds (runs in the child)
+void returnNumbers (int number, CFWriteStreamRef commChannel)
+{
+    static const CFStringRef headerFmt = CFSTR("HTTP/1.0 %d blah\r\n");
+    static const CFStringRef contentType = CFSTR("Content-Type: text/html\r\n");
+    static const CFStringRef endHeader = CFSTR("\r\n");
+    static const CFStringRef dataHeaderFmt = CFSTR("<html><head><title>Numbers</title></head><body><h2>The numbers from %d to %d</h2>\n");
+    static const CFStringRef numberFmt = CFSTR("%d\n");
+    static const CFStringRef done = CFSTR("<hr>Done\n</body></html>\r\n");
+
+    int min = MIN (number, 1);
+    int max = MAX (number, 1);
+
+    CFStringRef header = 0, dataHeader = 0;
+
+    header = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, headerFmt, HTTP_OK);
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(header,CFStringGetFastestEncoding(header)),CFStringGetLength(header));
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(contentType,CFStringGetFastestEncoding(contentType)),CFStringGetLength(contentType));
+    // no content length, dynamic
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(endHeader,CFStringGetFastestEncoding(endHeader)),CFStringGetLength(endHeader));
+
+    dataHeader = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, dataHeaderFmt, min, max);
+    CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(dataHeader,CFStringGetFastestEncoding(dataHeader)),CFStringGetLength(dataHeader));
+
+    for (int i = min; i <= max; i++) {
+        sleep (2);
+        CFStringRef numberStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, numberFmt, i);
+        CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(numberStr,CFStringGetFastestEncoding(numberStr)),CFStringGetLength(numberStr));
+    }
+
+   CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(done,CFStringGetFastestEncoding(done)),CFStringGetLength(done));
+} // returnNumbers
+
+
+// return a file from the file system, relative to where the webserve
+// is running.  Note that this doesn't look for any nasty characters
+// like '..', so this function is a pretty big security hole
+// (runs in the child)
+void returnFile (const char *filename, CFWriteStreamRef commChannel)
+{
+    static const CFStringRef headerFmt = CFSTR("HTTP/1.0 %d blah\r\n");
+    char lineBuffer[LINEBUFFER_SIZE];
+    const char *mimetype = NULL;
+
+    // try to guess the mime type.  IE assumes all non-graphic files
+    // are HTML
+    if (strstr(filename, ".m") != NULL) {
+        mimetype = "text/plain";
+    } else if (strstr(filename, ".h") != NULL) {
+        mimetype = "text/plain";
+    } else if (strstr(filename, ".txt") != NULL) {
+        mimetype = "text/plain";
+    } else if (strstr(filename, ".tgz") != NULL) {
+        mimetype = "application/x-compressed";
+    } else if (strstr(filename, ".html") != NULL) {
+        mimetype = "text/html";
+    } else if (strstr(filename, ".htm") != NULL) {
+        mimetype = "text/html";
+    } else if (strstr(filename, ".mp3") != NULL) {
+        mimetype = "audio/mpeg";
+    }
+
+    FILE *file;
+    file = fopen (filename, "r");
+
+    if (file == NULL) {
+        returnString (HTTP_NOT_FOUND, 
+                      "could not find your file.  Sorry\n.", 
+                      commChannel);
+    } else {
+        CFStringRef header = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, headerFmt, HTTP_OK);
+        CFWriteStreamWrite(commChannel,(const UInt8*)CFStringGetCStringPtr(header,CFStringGetFastestEncoding(header)),CFStringGetLength(header));
+        if (mimetype != NULL) {
+            sprintf (lineBuffer, "Content-Type: %s\r\n", mimetype);
+            CFWriteStreamWrite(commChannel, (const UInt8*)lineBuffer, strlen(lineBuffer));
+       }
+       CFWriteStreamWrite(commChannel, (const UInt8*)"\r\n", 2); // no content length, dynamic
+
+#define BUFFER_SIZE (8 * 1024)
+        char *buffer[BUFFER_SIZE];
+        int result;
+
+        while ((result = fread (buffer, 1, BUFFER_SIZE, file)) > 0) {
+            CFWriteStreamWrite (commChannel, (const  UInt8*)buffer, result);
+        }
+#undef BUFFER_SIZE
+    }
+}
+
+
+// using the method and the request (the path part of the url),
+// generate the data for the user and send it back. (runs in the
+// child)
+void handleRequest (const char *method, 
+                    const char *originalRequest, CFWriteStreamRef commChannel)
+{
+    char* request = strdup (originalRequest);
+
+    // we'll use strsep to split this
+    if (strcmp(method, "GET") != 0) {
+        returnString (HTTP_ERROR, 
+                      "only GETs are supported", commChannel);
+        goto bailout;
+    }
+    
+    char *chunk, *nextString;
+    nextString = request;
+
+    chunk = strsep (&nextString, "/");
+    // urls start with slashes, so chunk is ""
+
+    chunk = strsep (&nextString, "/");  // the leading part of the url
+
+    if (strcmp(chunk, "numbers") == 0) {
+        int number;
+
+        // url of the form /numbers/5 to print numbers from 1 to 5
+        chunk = strsep (&nextString, "/");
+        number = atoi(chunk);
+        returnNumbers (number, commChannel);
+
+    } else if (strcmp(chunk, "file") == 0) {
+        chunk = strsep (&nextString, ""); // get the rest of the string
+        returnFile (chunk, commChannel);
+    } else {
+        returnString (HTTP_NOT_FOUND, 
+                      "could not handle your request.  Sorry\n.",
+                      commChannel);
+    }
+
+bailout:
+    fprintf (stderr, "child %ld handled request '%s'\n", 
+             (long)getpid(), originalRequest);
+
+    free (request);
+}
+
+
+// read the request from the browser, pull apart the elements of the
+// request, and then dispatch it.  (runs in the child)
+void dispatchRequest (CFReadStreamRef readStream, CFStreamEventType eventType, void* clientCallBackInfo)
+{
+    char lineBuffer[LINEBUFFER_SIZE];
+   
+    struct clientConn* pClientConn = ((struct clientConn*)clientCallBackInfo);
+   
+    CFWriteStreamRef writeStream = pClientConn->writeStream;
+    CFSocketNativeHandle listenSocket = pClientConn->listenSocket;
+
+    CFIndex bytesRead = CFReadStreamRead(readStream, (UInt8*)lineBuffer, LINEBUFFER_SIZE);
+   
+    // this is pretty lame in that it only reads the first line and 
+    // assumes that's the request, subsequently ignoring any headers
+    // that might be sent.
+
+   if (bytesRead > 0) {
+        // ok, now figure out what they wanted
+        char *requestElements[3], *nextString, *chunk;
+        int i = 0;
+        nextString = lineBuffer;
+        while (i < 3 && (chunk = strsep (&nextString, " "))) {
+            requestElements[i] = chunk;
+            i++;
+        }
+        if (i != 3) {
+            returnString (HTTP_ERROR, "malformed request", writeStream);
+            goto bailout;
+        }
+        
+        handleRequest (requestElements[0], requestElements[1], writeStream);
+    } else
+        fprintf (stderr, "read an empty request.  exiting\n");
+
+bailout:
+    fflush (stderr);
+    if (writeStream) {
+        CFWriteStreamClose(writeStream);
+        //CFRelease(writeStream);
+    }
+    if (readStream) {
+        CFReadStreamUnscheduleFromRunLoop(readStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+        CFReadStreamSetClient(readStream, kCFStreamEventNone, NULL, NULL);
+        CFReadStreamClose(readStream);
+        CFRelease(readStream);
+    }
+   close(listenSocket);
+   free(pClientConn);
+} // dispatchRequest
+
+
+
+// sit blocking on accept until either it breaks out with a signal
+// (like SIGCHLD) or a new connection comes in.  If it's a new
+// connection, fork off a child to process the request
+static void acceptRequest(CFSocketRef socket, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
+{
+    struct sockaddr_in clientAddr;
+    int port = 0;
+    const char* addr = 0;
+    Boolean didSet = 0;
+   
+    CFSocketNativeHandle listenSocket = *(CFSocketNativeHandle *)data;
+   
+    if (kCFSocketAcceptCallBack != type) {
+        fprintf (stderr, "accept called with incorrect type (%d).  error: %d/%s\n",
+                 type, errno, strerror(errno));
+        return;
+    }
+   
+    memcpy (&clientAddr, (const void*)address, sizeof(clientAddr));
+   
+    port = clientAddr.sin_port;
+    addr = inet_ntoa(clientAddr.sin_addr);
+    
+    fprintf (stderr, "Accepted connection from %s:%d\n", addr, port);
+
+    // child sends output to stderr, so make sure it's drained before moving on
+    fflush (stderr); 
+    
+    CFReadStreamRef readStream = 0;
+    CFWriteStreamRef writeStream = 0;
+    CFStreamCreatePairWithSocket(kCFAllocatorDefault, listenSocket, &readStream, &writeStream);
+    if (!readStream || !writeStream) {
+         fprintf (stderr, "Failed to build I/O streams.  Error: %d/%s\n",
+                  errno, strerror(errno));
+         close(listenSocket);
+         return;
+    }
+   
+    CFStreamClientContext clientContext;
+    memset(&clientContext, 0x00, sizeof(clientContext));
+
+    clientContext.info = malloc(sizeof(clientConn));
+    ((struct clientConn*)clientContext.info)->writeStream = writeStream;
+    ((struct clientConn*)clientContext.info)->listenSocket = listenSocket;
+   
+    didSet = CFReadStreamSetClient(readStream, kCFStreamEventOpenCompleted|kCFStreamEventHasBytesAvailable|kCFStreamEventEndEncountered, (CFReadStreamClientCallBack)&dispatchRequest, &clientContext);
+       
+    if (didSet)
+        CFReadStreamScheduleWithRunLoop(readStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+   
+    CFReadStreamOpen(readStream);
+    CFWriteStreamOpen(writeStream);
+}
+
+
+
+// this is 100% stolen from chatterserver.m
+// start listening on our server port (runs in parent)
+CFSocketRef startListening ()
+{
+    int result = 0;
+    int yes = 1;
+
+    CFDataRef address4 = 0;
+   
+    CFSocketContext socketContext = {0, 0, NULL, NULL, NULL};
+    CFSocketRef listenOn = CFSocketCreate (kCFAllocatorDefault, PF_INET, SOCK_STREAM, IPPROTO_TCP, kCFSocketAcceptCallBack, (CFSocketCallBack)&acceptRequest, &socketContext);   
+    if (!listenOn) {
+        fprintf (stderr, "could not make a socket.  error: %d / %s\n",
+                 errno, strerror(errno));
+        return 0;
+    }
+
+    result = setsockopt (CFSocketGetNative (listenOn), SOL_SOCKET, SO_REUSEADDR, (SOCK_CONST_DATA)&yes, sizeof(yes));
+    if (result == -1) {
+        fprintf (stderr, 
+                 "could not setsockopt to reuse address. %d / %s\n",
+                 errno, strerror(errno));
+        if (listenOn) CFRelease(listenOn);
+        listenOn = 0;
+        return 0;
+    }
+
+    // bind to an address and port
+    struct sockaddr_in address;
+#if !defined(__WIN32__)
+    address.sin_len = sizeof (struct sockaddr_in);
+#endif
+    address.sin_family = AF_INET;
+    address.sin_port = htons (PORT_NUMBER);
+    address.sin_addr.s_addr = htonl (INADDR_ANY);
+    memset (address.sin_zero, 0, sizeof(address.sin_zero));
+   
+    address4 = CFDataCreateWithBytesNoCopy (kCFAllocatorDefault, (const UInt8*)&address, sizeof(address), kCFAllocatorDefault);
+   
+    if (kCFSocketSuccess != CFSocketSetAddress (listenOn, address4)) {
+        fprintf (stderr, "could not bind socket.  error: %d / %s\n",
+                 errno, strerror(errno));
+        if (listenOn) CFRelease(listenOn);
+        listenOn = 0;
+        return 0;
+    }
+    
+    return listenOn;
+}
+
+
+int main (int argc, char *argv[])
+{
+    CFSocketRef listenSocket = 0;
+    CFRunLoopSourceRef source = 0;
+
+    listenSocket = startListening ();
+    if (!listenSocket)
+        return -1;
+   
+    source = CFSocketCreateRunLoopSource(kCFAllocatorDefault, listenSocket, 0);
+   
+    CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
+    CFRelease(source);
+   
+    CFRunLoopRun();
+
+    return (EXIT_SUCCESS);
+}
+
+#if defined(__WIN32__)
+/*
+ * From the BSD sources.  Why isn't this in MSVCRTL?
+ */
+char *strsep(char **stringp, const char *delim) {
+        char *origin, *p;
+        const char *pp;
+
+        if (stringp || !*stringp || !delim || !*delim) {
+                return NULL;
+        }
+
+        for(origin = p = *stringp; *p; p++) {
+                for(pp = delim; *pp; pp++) {
+                        if (*pp == *p) {
+                                *p = 0;
+                                *stringp = *++p ? p : NULL;
+                        }
+                }
+        }
+
+        return origin;
+}
+#endif
diff --git a/CoreFoundation/examples/StringExample/Makefile.am b/CoreFoundation/examples/StringExample/Makefile.am
new file mode 100644
index 0000000..13653ee
--- /dev/null
+++ b/CoreFoundation/examples/StringExample/Makefile.am
@@ -0,0 +1,22 @@
+AM_CFLAGS		= -I${top_srcdir}/include
+
+EXTRA_DIST		= StringExample.vcproj
+
+if CF_BUILD_TESTS
+check_PROGRAMS		= StringExample
+endif
+
+StringExample_LDADD	= ${top_builddir}/libCoreFoundation.la
+
+StringExample_SOURCES	= StringExample.c
+
+if CF_BUILD_TESTS
+check:
+	${LIBTOOL} --mode execute ./StringExample
+
+gdb:
+	${LIBTOOL} --mode execute ${@} ./StringExample
+
+valgrind:
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./StringExample
+endif
diff --git a/CoreFoundation/examples/StringExample/Makefile.in b/CoreFoundation/examples/StringExample/Makefile.in
new file mode 100644
index 0000000..330b93a
--- /dev/null
+++ b/CoreFoundation/examples/StringExample/Makefile.in
@@ -0,0 +1,469 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = StringExample$(EXEEXT)
+subdir = examples/StringExample
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_StringExample_OBJECTS = StringExample.$(OBJEXT)
+StringExample_OBJECTS = $(am_StringExample_OBJECTS)
+StringExample_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(StringExample_SOURCES)
+DIST_SOURCES = $(StringExample_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = StringExample.vcproj
+StringExample_LDADD = ${top_builddir}/libCoreFoundation.la
+StringExample_SOURCES = StringExample.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/StringExample/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/StringExample/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+StringExample$(EXEEXT): $(StringExample_OBJECTS) $(StringExample_DEPENDENCIES) 
+	@rm -f StringExample$(EXEEXT)
+	$(LINK) $(StringExample_OBJECTS) $(StringExample_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StringExample.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@check:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./StringExample
+
+@CF_BUILD_TESTS_TRUE@gdb:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./StringExample
+
+@CF_BUILD_TESTS_TRUE@valgrind:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./StringExample
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/StringExample/StringExample.c b/CoreFoundation/examples/StringExample/StringExample.c
new file mode 100644
index 0000000..4dcad67
--- /dev/null
+++ b/CoreFoundation/examples/StringExample/StringExample.c
@@ -0,0 +1,543 @@
+/*
+ Simple CFString example program.
+ Author: Ali Ozer
+ 4/2/99
+
+ Note: Compile as "gcc -framework CoreFoundation -o stringtest StringExample.c"
+ 
+ Copyright (c) 1999-2004, Apple Computer, Inc., all rights reserved.
+*/
+/*
+ IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
+ consideration of your agreement to the following terms, and your use, installation, 
+ modification or redistribution of this Apple software constitutes acceptance of these 
+ terms.  If you do not agree with these terms, please do not use, install, modify or 
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and subject to these 
+ terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in 
+ this original Apple software (the "Apple Software"), to use, reproduce, modify and 
+ redistribute the Apple Software, with or without modifications, in source and/or binary 
+ forms; provided that if you redistribute the Apple Software in its entirety and without 
+ modifications, you must retain this notice and the following text and disclaimers in all 
+ such redistributions of the Apple Software.  Neither the name, trademarks, service marks 
+ or logos of Apple Computer, Inc. may be used to endorse or promote products derived from 
+ the Apple Software without specific prior written permission from Apple. Except as expressly
+ stated in this notice, no other rights or licenses, express or implied, are granted by Apple
+ herein, including but not limited to any patent rights that may be infringed by your 
+ derivative works or by other works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES, 
+ EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, 
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS 
+ USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL 
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, 
+ REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND 
+ WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR 
+ OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+
+// This function will print the provided arguments (printf style varargs) out to the console.
+// Note that the CFString formatting function accepts "%@" as a way to display CF types.
+// For types other than CFString and CFNumber, the result of %@ is mostly for debugging
+// and can differ between releases and different platforms.
+void show(CFStringRef formatString, ...) {
+    CFStringRef resultString;
+    CFDataRef data;
+    va_list argList;
+
+    va_start(argList, formatString);
+    resultString = CFStringCreateWithFormatAndArguments(NULL, NULL, formatString, argList);
+    va_end(argList);
+
+    data = CFStringCreateExternalRepresentation(NULL, resultString, CFStringGetSystemEncoding(), '?');
+
+    if (data != NULL) {
+        printf ("%.*s\n\n", (int)CFDataGetLength(data), CFDataGetBytePtr(data));
+        CFRelease(data);
+    }
+
+    CFRelease(resultString);
+}
+
+
+void simpleStringExample(void) {
+
+    CFStringRef str;
+    CFDataRef data;
+    char *bytes;
+
+    show(CFSTR("------------------Simple Strings---------------"));
+
+    // Create a simple immutable string from a Pascal string and convert it to Unicode
+#if defined(__APPLE__)
+    str = CFStringCreateWithPascalString(NULL, "\pFoo Bar", kCFStringEncodingASCII);
+#else
+    str = CFStringCreateWithCString(NULL, "Hello World", kCFStringEncodingASCII);
+#endif
+
+    // Create the Unicode representation of the string
+    // "0", lossByte, indicates that if there's a conversion error, fail (and return NULL)
+    data = CFStringCreateExternalRepresentation(NULL, str, kCFStringEncodingUnicode, 0);
+
+    show(CFSTR("String          : %@"), str);
+    show(CFSTR("Unicode data    : %@"), data);
+
+    CFRelease(str);
+ 
+    // Create a string from the Unicode data...
+    str = CFStringCreateFromExternalRepresentation(NULL, data, kCFStringEncodingUnicode);
+
+    show(CFSTR("String Out      : %@"), str);
+
+    CFRelease(str);
+
+    // Create a string for which you already have some allocated contents which you want to 
+    // pass ownership of to the CFString. The last argument, "NULL," indicates that the default allocator
+    // should be used to free the contents when the CFString is freed (or you can pass in CFAllocatorGetDefault()).
+
+    bytes = (char*)CFAllocatorAllocate(CFAllocatorGetDefault(), 6, 0);
+    strcpy(bytes, "Hello");
+
+    str = CFStringCreateWithCStringNoCopy(NULL, bytes, kCFStringEncodingASCII, NULL);
+    CFRelease(str);
+
+#if defined(__APPLE__)
+    // Now create a string with a Pascal string which is not copied, and not freed when the string is
+    // This is an advanced usage; obviously you need to guarantee that the string bytes do not go away
+    // before the CFString does. 
+    str = CFStringCreateWithPascalStringNoCopy(NULL, "\pFoo Bar", kCFStringEncodingASCII, kCFAllocatorNull);
+    CFRelease(str);
+#endif
+}
+
+
+
+void stringGettingContentsAsCStringExample(void) {
+
+    CFStringRef str;
+    CFDataRef data;
+    CFRange rangeToProcess;
+    const char *bytes;
+
+    show(CFSTR("------------------C String Manipulations---------------"));
+
+    // Create some test CFString
+    // Note that in general the string might contain Unicode characters which cannot
+    // be converted to a 8-bit character encoding
+    str = CFStringCreateWithCString(NULL, "Hello World", kCFStringEncodingASCII);
+
+    show(CFSTR("Original String : %@"), str);
+   
+    // First, the fast but unpredictable way to get at the C String contents...
+    // This is O(1), meaning it takes constant time.
+    // This might return NULL!
+    bytes = CFStringGetCStringPtr(str, kCFStringEncodingASCII);
+   
+    // If that fails, you can try to get the contents by copying it out
+    if (bytes == NULL) {
+        char localBuffer[10];
+        Boolean success;
+
+        // This might also fail, either if you provide a buffer that is too small, 
+        // or the string cannot be converted into the specified encoding
+        success = CFStringGetCString(str, localBuffer, 10, kCFStringEncodingASCII);
+    }
+    else
+        show(CFSTR("From CStringPtr : %@"), bytes);   
+    
+    // A pretty simple solution is to use a CFData; this frees you from guessing at the buffer size
+    // But it does allocate a CFData...
+    data = CFStringCreateExternalRepresentation(NULL, str, kCFStringEncodingASCII, 0);
+    if (data) {
+        show(CFSTR("External Rep: %@"), data);   
+        bytes = (const char *)CFDataGetBytePtr(data);
+    }
+
+    // More complicated but efficient solution is to use a fixed size buffer, and put a loop in
+    rangeToProcess = CFRangeMake(0, CFStringGetLength(str));
+
+    while (rangeToProcess.length > 0) {
+        UInt8 localBuffer[100];
+        CFIndex usedBufferLength;
+        CFIndex numChars = CFStringGetBytes(str, rangeToProcess, kCFStringEncodingASCII, 0, FALSE, (UInt8 *)localBuffer, 100, &usedBufferLength);
+
+        if (numChars == 0) break;	// Means we failed to convert anything...
+
+        // Otherwise we converted some stuff; process localBuffer containing usedBufferLength bytes
+        // Note that the bytes in localBuffer are not NULL terminated
+		
+        // Update the remaining range to continue looping
+        rangeToProcess.location += numChars;
+        rangeToProcess.length -= numChars;
+    }
+}
+
+
+void stringGettingAtCharactersExample(void) {
+
+    CFStringRef str;
+    const UniChar *chars;
+
+    show(CFSTR("------------------Character Manipulations---------------"));
+
+    // Create some test CFString
+    str = CFStringCreateWithCString(NULL, "Hello World", kCFStringEncodingASCII);
+
+    show(CFSTR("Original String : %@"), str);
+
+    // The fastest way to get the contents; this might return NULL though
+    // depending on the system, the release, etc, so don't depend on it 
+    // (unless you used CFStringCreateMutableWithExternalCharactersNoCopy())
+    chars = CFStringGetCharactersPtr(str);
+
+    // If that fails, you can try copying the UniChars out
+    // either into some stack buffer or some allocated piece of memory...
+    // Using the former is fine, but you need to know the size; the latter
+    // always works but requires allocating some memory; not too efficient.
+    if (chars == NULL) {
+        CFIndex length = CFStringGetLength(str);
+        UniChar *buffer = (UniChar*)malloc(length * sizeof(UniChar));
+        CFStringGetCharacters(str, CFRangeMake(0, length), buffer);
+        // Process the chars...
+        free(buffer);
+    }
+    else
+        show(CFSTR("Characters      : %@"), str);
+
+    // You can use CFStringGetCharacterAtIndex() to get at the characters one at a time,
+    // but doing a lot of characters this way might get slow...
+    // An option is to use "inline buffer" functionality which mixes the convenience of
+    // one-at-a-time char access with efficiency of bulk access
+    {
+        CFStringInlineBuffer inlineBuffer;
+        CFIndex length = CFStringGetLength(str);
+        CFIndex cnt;
+
+        CFStringInitInlineBuffer(str, &inlineBuffer, CFRangeMake(0, length));
+
+        for (cnt = 0; cnt < length; cnt++) {
+            UniChar ch = CFStringGetCharacterFromInlineBuffer(&inlineBuffer, cnt);
+            // Process character...
+	         (void)ch;   // Dummy processing to prevent compiler warning...
+        }
+    }
+    
+}
+
+
+void stringWithExternalContentsExample(void) {
+#define BufferSize 1000
+    CFMutableStringRef mutStr;
+    UniChar *myBuffer;
+
+    show(CFSTR("------------------External Contents Examples---------------"));
+
+    // Allocate a contents store that is empty (but has space for BufferSize chars)...
+    myBuffer = (UniChar*)malloc(BufferSize * sizeof(UniChar));
+
+    // Now create a mutable CFString which uses this buffer
+    // The 0 and BufferSize indicate the length and capacity (in UniChars)
+    // The kCFAllocatorNull indicates how the CFString should reallocate or free this buffer (in this case, do nothing)
+
+    mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(NULL, myBuffer, 0, BufferSize, kCFAllocatorNull);
+    CFStringAppend(mutStr, CFSTR("Appended string... "));
+    CFStringAppend(mutStr, CFSTR("More stuff... "));
+#if defined(__APPLE__)
+    CFStringAppendPascalString(mutStr, "\pA pascal string. ", kCFStringEncodingASCII);
+#else
+    CFStringAppendCString(mutStr, "A C string. ", kCFStringEncodingASCII);
+#endif
+    CFStringAppendFormat(mutStr, NULL, CFSTR("%d %4.2f %@..."), 42, -3.14, CFSTR("Hello"));
+    
+    show(CFSTR("String: %@"), mutStr);
+
+    CFRelease(mutStr);
+    free(myBuffer);
+
+    // Now create a similar string, but give CFString the ability to reallocate or free the buffer
+    // The last "NULL" argument specifies that the default allocator should be used
+    // Here we provide an initial buffer of 32 characters, but if it grows beyond this, it's OK
+    // (unlike the previous example, where if the string grew beyond 1000, it's an error)
+
+    myBuffer = (UniChar*)CFAllocatorAllocate(CFAllocatorGetDefault(), 32 * sizeof(UniChar), 0);
+    mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(NULL, myBuffer, 0, 32, NULL);
+
+    CFStringAppend(mutStr, CFSTR("Appended string... "));
+    CFStringAppend(mutStr, CFSTR("Appended string... "));
+    CFStringAppend(mutStr, CFSTR("Appended string... "));
+    CFStringAppend(mutStr, CFSTR("Appended string... "));
+    CFStringAppend(mutStr, CFSTR("Appended string... "));
+
+    show(CFSTR("String: %@"), mutStr);
+
+    CFRelease(mutStr);
+    // Here we don't free the buffer, as CFString does that
+}
+
+void stringManipulation(void) {
+   
+   CFMutableStringRef strChange;
+   CFStringRef strOuter, find, replace, find2, replace2, find3, replace3, bigger, smaller, result;
+   CFComparisonResult comp;
+   CFLocaleRef curLocale;
+   
+   show(CFSTR("------------------String Manipulations---------------"));
+   
+   // Create a simple immutable string from a Pascal string and convert it to Unicode
+   strOuter = CFStringCreateWithCString(NULL, "Hello Cruel World", kCFStringEncodingASCII);
+   strChange = CFStringCreateMutableCopy(NULL, CFStringGetLength(strOuter), strOuter);
+   find = CFStringCreateWithCString(NULL, "Cruel", kCFStringEncodingASCII);
+   replace = CFStringCreateWithCString(NULL, "Cool", kCFStringEncodingASCII);
+   find2 = CFStringCreateWithCString(NULL, "Keep", kCFStringEncodingASCII);
+   replace2 = CFStringCreateWithCString(NULL, "Be", kCFStringEncodingASCII);
+   find3 = CFStringCreateWithCString(NULL, "Change.", kCFStringEncodingASCII);
+   replace3 = CFStringCreateWithCString(NULL, "Ball.", kCFStringEncodingASCII);
+
+   bigger  = CFStringCreateWithCString(NULL, "version 2.5", kCFStringEncodingASCII);
+   smaller = CFStringCreateWithCString(NULL, "version 2.0", kCFStringEncodingASCII);
+
+   show(CFSTR("String Outer       : %@"), strOuter);
+   show(CFSTR("String Find        : %@"), find);
+   show(CFSTR("String Replace     : %@"), replace);
+   
+   CFStringFindAndReplace(strChange, find, replace, CFRangeMake(0, CFStringGetLength(strChange)), 0);
+   
+   show(CFSTR("Replaced           : %@"), strChange);
+   
+   CFStringAppendCString(strChange, "!  Keep the change.", kCFStringEncodingASCII);
+   
+   show(CFSTR("Appended           : %@"), strChange);
+   
+   curLocale = CFLocaleCopyCurrent ();
+
+   CFStringUppercase(strChange, curLocale);
+   
+   show(CFSTR("Upper Cased        : %@"), strChange);
+   
+   CFStringLowercase(strChange, curLocale);
+   
+   show(CFSTR("Lower Cased        : %@"), strChange);
+   
+   CFStringCapitalize(strChange, curLocale);
+   
+   show(CFSTR("Capitalized        : %@"), strChange);
+
+   CFStringUppercase(strChange, curLocale);
+   
+   show(CFSTR("Up Cased (again)   : %@"), strChange);
+
+   CFStringFindAndReplace(strChange, find2, replace2, CFRangeMake(0, CFStringGetLength(strChange)), 0);
+
+   show(CFSTR("Replaced?          : %@"), strChange);
+   
+   CFStringFindAndReplace(strChange, find2, replace2, CFRangeMake(0, CFStringGetLength(strChange)), kCFCompareCaseInsensitive);
+   
+   show(CFSTR("Case insensitive   : %@"), strChange);
+   
+   CFStringCapitalize(strChange, curLocale);
+   
+   show(CFSTR("Capitalized        : %@"), strChange);
+
+   CFStringFindAndReplace(strChange, replace2, find2, CFRangeMake(0, CFStringGetLength(strChange)), kCFCompareAnchored);
+   
+   show(CFSTR("Should Be Unchanged: %@"), strChange);
+
+   CFStringFindAndReplace(strChange, find3, replace3, CFRangeMake(0, CFStringGetLength(strChange)), kCFCompareAnchored|kCFCompareBackwards);
+   
+   show(CFSTR("Should Be Changed  : %@"), strChange);
+   
+   show(CFSTR("Which is bigger %@ or %@?"), bigger, smaller);
+   
+   comp = CFStringCompare(bigger, smaller, 0);   
+   result = (comp == kCFCompareGreaterThan) ? bigger : smaller;   
+   show(CFSTR("Base Compare Says  : %@"), result);
+
+   comp = CFStringCompare(bigger, smaller, kCFCompareNumerically);
+   result = (comp == kCFCompareGreaterThan) ? bigger : smaller;   
+   show(CFSTR("Numerical Compare  : %@"), result);
+
+   CFRelease(curLocale);
+   CFRelease(replace);
+   CFRelease(find);
+   CFRelease(replace2);   
+   CFRelease(find2);
+   CFRelease(replace3);   
+   CFRelease(find3);
+   CFRelease(bigger);   
+   CFRelease(smaller);
+   CFRelease(strChange);
+}
+
+Boolean equalValues(CFStringRef number, CFNumberRef expected, CFNumberFormatterStyle style, CFNumberFormatterOptionFlags option)
+{
+   //CFStringRef enLocaleIdentifier = CFSTR("en_US");
+   //CFLocaleRef curLocale = CFLocaleCreate(NULL, enLocaleIdentifier);
+   
+   CFLocaleRef curLocale = CFLocaleCopyCurrent();
+   CFStringRef identifier = CFLocaleGetIdentifier(curLocale);
+   CFNumberFormatterRef fmt;
+   CFNumberRef val;
+
+   show(CFSTR("Make a Number from : %@"), number);
+   
+   fmt = CFNumberFormatterCreate (0, curLocale, style);
+   val = CFNumberFormatterCreateNumberFromString(0, fmt, number, 0, option);
+   
+   show(CFSTR("val=%@, should be=%@\n"), val, expected);
+   
+   if (!val)
+      return false;
+   
+   return (0 == CFNumberCompare(val, expected, 0));
+}
+
+void stringHandling(void) {
+   
+   CFStringRef number;
+   int theValue = 80;
+   double theOtherValue = 123.26;
+   CFNumberRef expected = CFNumberCreate(0, kCFNumberIntType, &theValue);
+
+   show(CFSTR("------------------Number Magic---------------"));
+   show(CFSTR("1.  Integer Parsing"));
+   show(CFSTR("   (a) Decimal Style"));
+
+   number = CFStringCreateWithCString(NULL, "80.0", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterDecimalStyle, kCFNumberFormatterParseIntegersOnly))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (b) Currency Style"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "$80.00", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterCurrencyStyle, kCFNumberFormatterParseIntegersOnly))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (c) Percent Style (does not work for integers)"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "80%", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterPercentStyle, kCFNumberFormatterParseIntegersOnly))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (d) Scientific Notation Style (does not work for integers)"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "8.0E1", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterScientificStyle, kCFNumberFormatterParseIntegersOnly))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (e) Spell-Out Style"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "eighty", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterSpellOutStyle, kCFNumberFormatterParseIntegersOnly))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (f) No Style (decimal)"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "80.0", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterNoStyle, kCFNumberFormatterParseIntegersOnly))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (g) No Style (spell out) (is not expected to work)"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "eighty", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterNoStyle, kCFNumberFormatterParseIntegersOnly))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("2.  Decimal Parsing"));
+   show(CFSTR("   (a) Decimal Style"));
+
+   CFRelease(expected);
+   expected = CFNumberCreate(0, kCFNumberDoubleType, &theOtherValue);
+   
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "123.26", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterDecimalStyle, 0))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (b) Currency Style"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "$123.26", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterCurrencyStyle, 0))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (c) Percent Style"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "123.26%", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterPercentStyle, 0))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (d) Scientific Notation Style"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "1.2326e2", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterScientificStyle, 0))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (e) Spell-Out Style"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "one hundred twenty-three point two six", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterSpellOutStyle, 0))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (f) No Style (decimal)"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "123.26", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterNoStyle, 0))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   show(CFSTR("   (g) No Style (spell-out) (not expected to work)"));
+   CFRelease(number);
+   number = CFStringCreateWithCString(NULL, "one hundred twenty three point two six", kCFStringEncodingASCII);   
+   if (equalValues(number, expected, kCFNumberFormatterNoStyle, 0))
+      show(CFSTR("correct."));
+   else
+      show(CFSTR("WRONG!!!"));
+   
+   CFRelease(number);
+}
+
+int main () {   
+    simpleStringExample();
+    stringGettingContentsAsCStringExample();
+    stringGettingAtCharactersExample();
+    stringWithExternalContentsExample();
+    stringManipulation();
+    stringHandling();
+   
+    return 0;
+}
+
+
diff --git a/CoreFoundation/examples/StringExample/StringExample.vcproj b/CoreFoundation/examples/StringExample/StringExample.vcproj
new file mode 100755
index 0000000..eacd309
--- /dev/null
+++ b/CoreFoundation/examples/StringExample/StringExample.vcproj
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="StringExample"
+	ProjectGUID="{4E98FDA7-54AE-4A8E-847A-8665DEF6BBE1}"
+	RootNamespace="StringExample"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="$(SolutionDir)\dist\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;WINDOWS_LEAN_AND_MEAN=1"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CFLite_$(ConfigurationName).lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)\dist\bin"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="$(SolutionDir)\dist\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\StringExample.c"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/CoreFoundation/examples/WritePListExample/Makefile.am b/CoreFoundation/examples/WritePListExample/Makefile.am
new file mode 100644
index 0000000..fad941d
--- /dev/null
+++ b/CoreFoundation/examples/WritePListExample/Makefile.am
@@ -0,0 +1,24 @@
+AM_CXXFLAGS			= -I${top_srcdir}/include
+
+EXTRA_DIST			= data/expected_schema.xml \
+				  WritePListExample.vcproj
+
+if CF_BUILD_TESTS
+check_PROGRAMS			= WritePListExample
+endif
+
+WritePListExample_LDADD		= ${top_builddir}/libCoreFoundation.la
+
+WritePListExample_SOURCES	= WritePListExample.cpp
+
+if CF_BUILD_TESTS
+check:
+	${LIBTOOL} --mode execute ./WritePListExample
+	${CMP} ${srcdir}/data/expected_schema.xml schema.xml
+
+gdb:
+	${LIBTOOL} --mode execute ${@} ./WritePListExample
+
+valgrind:
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./WritePListExample
+endif
diff --git a/CoreFoundation/examples/WritePListExample/Makefile.in b/CoreFoundation/examples/WritePListExample/Makefile.in
new file mode 100644
index 0000000..e4d82d3
--- /dev/null
+++ b/CoreFoundation/examples/WritePListExample/Makefile.in
@@ -0,0 +1,472 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = WritePListExample$(EXEEXT)
+subdir = examples/WritePListExample
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_WritePListExample_OBJECTS = WritePListExample.$(OBJEXT)
+WritePListExample_OBJECTS = $(am_WritePListExample_OBJECTS)
+WritePListExample_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(WritePListExample_SOURCES)
+DIST_SOURCES = $(WritePListExample_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CXXFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = data/expected_schema.xml \
+				  WritePListExample.vcproj
+
+WritePListExample_LDADD = ${top_builddir}/libCoreFoundation.la
+WritePListExample_SOURCES = WritePListExample.cpp
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  examples/WritePListExample/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  examples/WritePListExample/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+WritePListExample$(EXEEXT): $(WritePListExample_OBJECTS) $(WritePListExample_DEPENDENCIES) 
+	@rm -f WritePListExample$(EXEEXT)
+	$(CXXLINK) $(WritePListExample_OBJECTS) $(WritePListExample_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WritePListExample.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@check:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./WritePListExample
+@CF_BUILD_TESTS_TRUE@	${CMP} ${srcdir}/data/expected_schema.xml schema.xml
+
+@CF_BUILD_TESTS_TRUE@gdb:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./WritePListExample
+
+@CF_BUILD_TESTS_TRUE@valgrind:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./WritePListExample
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/examples/WritePListExample/WritePListExample.cpp b/CoreFoundation/examples/WritePListExample/WritePListExample.cpp
new file mode 100755
index 0000000..705d213
--- /dev/null
+++ b/CoreFoundation/examples/WritePListExample/WritePListExample.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2008-2009 Brent Fulgham.  All rights reserved.
+ *
+ * This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
+ * the terms of the APSL version 2.0 (see below).
+ *
+ * For information about changes from the original Apple source release can be found by reviewing the
+ * source control system for the project at https://sourceforge.net/svn/?group_id=246198.
+ *
+ */
+
+//
+// Apple's "Write a PList" example program.
+// Taken from http://developer.apple.com/opensource/cflite.html
+//
+#include <CoreFoundation/CoreFoundation.h>
+
+void propertyListExample (void);
+void writePropertyListToFile (CFDataRef data);
+
+const char* kFilename = "./schema.xml";
+
+int main (int argc, const char * argv[]) {
+    // Create and save the plist.
+    propertyListExample ();
+
+    return 0;
+}
+
+void propertyListExample (void) {
+    CFMutableDictionaryRef dict;
+    CFNumberRef num;
+    CFArrayRef array;
+    CFDataRef data;
+    #define NumKids 2
+    CFStringRef kidsNames[] = { CFSTR ("John"), CFSTR ("Kyra") };
+    #define NumPets 0
+    int yearOfBirth = 1965;
+    #define NumBytesInPic 10
+    const unsigned char pic[ NumBytesInPic ] = { 0x3c, 0x42, 0x81, 0xa5, 0x81, 0xa5, 0x99, 0x81, 0x42, 0x3c };
+    CFDataRef xmlPropertyListData;
+    CFStringRef xmlAsString;
+
+    // Create and populate a pretty standard mutable dictionary: CFString keys, CF type values.
+    // To be written out as a "propertyList", the tree of CF types can contain only:
+    //   CFDictionary, CFArray, CFString, CFData, CFNumber, and CFDate.
+    // In addition, the keys of the dictionaries should be CFStrings.
+
+    dict = CFDictionaryCreateMutable (NULL, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );
+
+    CFDictionarySetValue (dict, CFSTR ("Name"), CFSTR ("John Doe"));
+
+    CFDictionarySetValue (dict, CFSTR ("City of Birth"), CFSTR ("Springfield"));
+
+    num = CFNumberCreate (NULL, kCFNumberIntType, &yearOfBirth);
+    CFDictionarySetValue (dict, CFSTR ("Year Of Birth"), num);
+    CFRelease (num);
+
+    array = CFArrayCreate (NULL, (const void **)kidsNames, NumKids, &kCFTypeArrayCallBacks); 
+    CFDictionarySetValue (dict, CFSTR ("Kids Names"), array);
+    CFRelease (array);
+
+    array = CFArrayCreate (NULL, NULL, 0, &kCFTypeArrayCallBacks);
+    CFDictionarySetValue (dict, CFSTR ("Pets Names"), array );
+    CFRelease (array);
+
+    data = CFDataCreate (NULL, pic, NumBytesInPic);
+    CFDictionarySetValue (dict, CFSTR ("Picture"), data);
+    CFRelease (data);
+
+    // We now have a dictionary which contains everything we want to know about
+    // John Doe; let's show it first:
+    CFShow (CFSTR ("John Doe info dictionary: "));
+    CFShow (dict);
+
+    // Now create a "property list", which is a flattened, XML version of the
+    // dictionary:
+    xmlPropertyListData = CFPropertyListCreateXMLData (NULL, dict);
+
+   // The return value is a CFData containing the XML file; show the data
+
+    CFShow (CFSTR ("Shown as XML property list (bytes): "));
+    CFShow (xmlPropertyListData);
+
+    // Given CFDatas are shown as ASCII versions of their hex contents, we can also
+    // attempt to show the contents of the XML, assuming it was encoded in UTF8
+    // (This is the case for XML property lists generated by CoreFoundation currently)
+
+    xmlAsString = CFStringCreateFromExternalRepresentation (NULL, xmlPropertyListData, kCFStringEncodingUTF8);
+
+    CFShow (CFSTR ("The XML property list contents: "));
+    CFShow (xmlAsString);
+
+    writePropertyListToFile (xmlPropertyListData);
+
+    CFRelease (dict);
+    CFRelease (xmlAsString);
+    CFRelease (xmlPropertyListData);
+
+    CFStringRef name = CFSTR("Brent");
+    if (CFBundleRef bundle = CFBundleGetMainBundle ())
+       if (CFTypeRef bundleExecutable = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleExecutableKey))
+          if (CFGetTypeID(bundleExecutable) == CFStringGetTypeID())
+             name = reinterpret_cast<CFStringRef>(bundleExecutable);
+
+    int value = 1;
+    CFNumberRef numRef = CFNumberCreate(0, kCFNumberSInt8Type, &value);
+    CFShow (CFSTR ("The number was: "));
+    CFShow (numRef);
+    CFRelease (numRef);
+}
+
+void writePropertyListToFile (CFDataRef data) {
+    CFStringRef errorString;
+
+    CFPropertyListRef propertyList = CFPropertyListCreateFromXMLData (NULL, data, kCFPropertyListMutableContainersAndLeaves, &errorString);
+
+    if (errorString == NULL) {
+        CFStringRef urlString = CFStringCreateWithCString (NULL, kFilename, CFStringGetSystemEncoding ());
+
+        CFURLRef fileURL = CFURLCreateWithFileSystemPath (NULL, urlString, kCFURLPOSIXPathStyle, FALSE);
+
+        CFWriteStreamRef stream = CFWriteStreamCreateWithFile (NULL, fileURL);
+
+        Boolean isOpen = CFWriteStreamOpen (stream);
+
+        CFShow (CFSTR ("Property list (as written to file):"));
+        CFShow (propertyList);
+  
+        CFIndex bytesWritten = CFPropertyListWriteToStream (propertyList, stream, kCFPropertyListXMLFormat_v1_0, NULL);
+
+        CFWriteStreamClose (stream);
+    }
+    else {
+        CFShow (errorString);
+        CFRelease (errorString);
+    }
+
+    CFRelease (propertyList);
+}
diff --git a/CoreFoundation/examples/WritePListExample/WritePListExample.vcproj b/CoreFoundation/examples/WritePListExample/WritePListExample.vcproj
new file mode 100755
index 0000000..6e1bceb
--- /dev/null
+++ b/CoreFoundation/examples/WritePListExample/WritePListExample.vcproj
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="WritePListExample"
+	ProjectGUID="{AD525151-D756-44E6-AEA7-12052F4F43E2}"
+	RootNamespace="WritePListExample"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501;WINDOWS_LEAN_AND_MEAN=1"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CFLite_$(ConfigurationName).lib"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;DEPLOYMENT_TARGET_WIN32;_WIN32_WINNT=0x0501;WINVER=0x0501"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(SolutionDir)\dist\lib&quot;"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\WritePListExample.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/CoreFoundation/examples/WritePListExample/data/expected_schema.xml b/CoreFoundation/examples/WritePListExample/data/expected_schema.xml
new file mode 100755
index 0000000..36e3543
--- /dev/null
+++ b/CoreFoundation/examples/WritePListExample/data/expected_schema.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>City of Birth</key>
+	<string>Springfield</string>
+	<key>Kids Names</key>
+	<array>
+		<string>John</string>
+		<string>Kyra</string>
+	</array>
+	<key>Name</key>
+	<string>John Doe</string>
+	<key>Pets Names</key>
+	<array/>
+	<key>Picture</key>
+	<data>
+	PEKBpYGlmYFCPA==
+	</data>
+	<key>Year Of Birth</key>
+	<integer>1965</integer>
+</dict>
+</plist>
diff --git a/CoreFoundation/icu/bin/WHAT_IS_THIS.txt b/CoreFoundation/icu/bin/WHAT_IS_THIS.txt
new file mode 100755
index 0000000..1e58d30
--- /dev/null
+++ b/CoreFoundation/icu/bin/WHAT_IS_THIS.txt
@@ -0,0 +1,10 @@
+Mac OS X and Linux ship with ICU.  Since WIndows does not, the distribution
+includes the necessary ICU 3.6 link libraries and DLLs to build CFLite.dll.
+
+Note the these are the same DLLs that ship with Safari, and want to link
+against MSVCR80.dll.  You will get an error on startup if you do not
+have this dll in your path.
+
+If you are targeting minw32, you might be better of just building ICU on
+that system (or use the binary ICU distribution).
+
diff --git a/CoreFoundation/icu/bin/icudt40.dll b/CoreFoundation/icu/bin/icudt40.dll
new file mode 100755
index 0000000..ccfd454
--- /dev/null
+++ b/CoreFoundation/icu/bin/icudt40.dll
Binary files differ
diff --git a/CoreFoundation/icu/bin/icuin40.dll b/CoreFoundation/icu/bin/icuin40.dll
new file mode 100755
index 0000000..5ccffea
--- /dev/null
+++ b/CoreFoundation/icu/bin/icuin40.dll
Binary files differ
diff --git a/CoreFoundation/icu/bin/icuuc40.dll b/CoreFoundation/icu/bin/icuuc40.dll
new file mode 100755
index 0000000..97ee22a
--- /dev/null
+++ b/CoreFoundation/icu/bin/icuuc40.dll
Binary files differ
diff --git a/CoreFoundation/icu/lib/WHAT_IS_THIS.txt b/CoreFoundation/icu/lib/WHAT_IS_THIS.txt
new file mode 100755
index 0000000..bfc6705
--- /dev/null
+++ b/CoreFoundation/icu/lib/WHAT_IS_THIS.txt
@@ -0,0 +1,2 @@
+Mac OS X and Linux ship with ICU.  Since WIndows does not, the distribution includes the
+necessary ICU 3.6 link libraries and DLL's to build CFLite.dll.
\ No newline at end of file
diff --git a/CoreFoundation/icu/lib/icuin.lib b/CoreFoundation/icu/lib/icuin.lib
new file mode 100755
index 0000000..aa82fdf
--- /dev/null
+++ b/CoreFoundation/icu/lib/icuin.lib
Binary files differ
diff --git a/CoreFoundation/icu/lib/icuuc.lib b/CoreFoundation/icu/lib/icuuc.lib
new file mode 100755
index 0000000..8c06489
--- /dev/null
+++ b/CoreFoundation/icu/lib/icuuc.lib
Binary files differ
diff --git a/CoreFoundation/icu/unicode/basictz.h b/CoreFoundation/icu/unicode/basictz.h
new file mode 100644
index 0000000..c616a3e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/basictz.h
@@ -0,0 +1,210 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and         *
+* others. All Rights Reserved.                                                *
+*******************************************************************************
+*/
+#ifndef BASICTZ_H
+#define BASICTZ_H
+
+/**
+ * \file 
+ * \brief C++ API: ICU TimeZone base class
+ */
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/timezone.h"
+#include "unicode/tzrule.h"
+#include "unicode/tztrans.h"
+
+U_NAMESPACE_BEGIN
+
+// forward declarations
+class UVector;
+
+/**
+ * <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
+ * This class provides some additional methods to access time zone transitions and rules.
+ * All ICU <code>TimeZone</code> concrete subclasses extend this class.
+ * @stable ICU 4.0
+ */
+class U_I18N_API BasicTimeZone: public TimeZone {
+public:
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~BasicTimeZone();
+
+    /**
+     * Gets the first time zone transition after the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the first transition after the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
+
+    /**
+     * Gets the most recent time zone transition before the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the most recent transition before the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
+
+    /**
+     * Checks if the time zone has equivalent transitions in the time range.
+     * This method returns true when all of transition times, from/to standard
+     * offsets and DST savings used by this time zone match the other in the
+     * time range.
+     * @param tz    The <code>BasicTimeZone</code> object to be compared with.
+     * @param start The start time of the evaluated time range (inclusive)
+     * @param end   The end time of the evaluated time range (inclusive)
+     * @param ignoreDstAmount
+     *              When true, any transitions with only daylight saving amount
+     *              changes will be ignored, except either of them is zero.
+     *              For example, a transition from rawoffset 3:00/dstsavings 1:00
+     *              to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,
+     *              but a transtion from rawoffset 2:00/dstsavings 1:00 to
+     *              rawoffset 3:00/dstsavings 0:00 is included.
+     * @param ec    Output param to filled in with a success or an error.
+     * @return      true if the other time zone has the equivalent transitions in the
+     *              time range.
+     * @stable ICU 4.0
+     */
+    virtual UBool hasEquivalentTransitions(/*const*/ BasicTimeZone& tz, UDate start, UDate end,
+        UBool ignoreDstAmount, UErrorCode& ec) /*const*/;
+
+    /**
+     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
+     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
+     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.
+     * @param status    Receives error status code.
+     * @return The number of <code>TimeZoneRule</code>s representing time transitions.
+     * @stable ICU 4.0
+     */
+    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/ = 0;
+
+    /**
+     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
+     * which represent time transitions for this time zone.  On successful return,
+     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
+     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
+     * instances up to the size specified by trscount.  The results are referencing the
+     * rule instance held by this time zone instance.  Therefore, after this time zone
+     * is destructed, they are no longer available.
+     * @param initial       Receives the initial timezone rule
+     * @param trsrules      Receives the timezone transition rules
+     * @param trscount      On input, specify the size of the array 'transitions' receiving
+     *                      the timezone transition rules.  On output, actual number of
+     *                      rules filled in the array will be set.
+     * @param status        Receives error status code.
+     * @stable ICU 4.0
+     */
+    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
+        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/ = 0;
+
+    /**
+     * Gets the set of time zone rules valid at the specified time.  Some known external time zone
+     * implementations are not capable to handle historic time zone rule changes.  Also some
+     * implementations can only handle certain type of rule definitions.
+     * If this time zone does not use any daylight saving time within about 1 year from the specified
+     * time, only the <code>InitialTimeZone</code> is returned.  Otherwise, the rule for standard
+     * time and daylight saving time transitions are returned in addition to the
+     * <code>InitialTimeZoneRule</code>.  The standard and daylight saving time transition rules are
+     * represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date
+     * rule and <code>DateTimeRule::WALL_TIME</code> for its time rule.  Because daylight saving time
+     * rule is changing time to time in many time zones and also mapping a transition time rule to
+     * different type is lossy transformation, the set of rules returned by this method may be valid
+     * for short period of time.
+     * The time zone rule objects returned by this method is owned by the caller, so the caller is
+     * responsible for deleting them after use.
+     * @param date      The date used for extracting time zone rules.
+     * @param initial   Receives the <code>InitialTimeZone</code>, always not NULL.
+     * @param std       Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.
+     *                  When this time time zone does not observe daylight saving times around the
+     *                  specified date, NULL is set.
+     * @param dst       Receives the <code>AnnualTimeZoneRule</code> for daylight saving time
+     *                  transitions.  When this time zone does not observer daylight saving times
+     *                  around the specified date, NULL is set.
+     * @param status    Receives error status code.
+     * @stable ICU 4.0
+     */
+    virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
+        AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) /*const*/;
+
+
+    /**
+     * The time type option bit flags used by getOffsetFromLocal
+     * @internal
+     */
+    enum {
+        kStandard = 0x01,
+        kDaylight = 0x03,
+        kFormer = 0x04,
+        kLatter = 0x0C
+    };
+
+    /**
+     * Get time zone offsets from local wall time.
+     * @internal
+     */
+    virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,
+        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/;
+
+protected:
+
+    /**
+     * The time type option bit masks used by getOffsetFromLocal
+     * @internal
+     */
+    enum {
+        kStdDstMask = kDaylight,
+        kFormerLatterMask = kLatter
+    };
+
+    /**
+     * Default constructor.
+     * @stable ICU 4.0
+     */
+    BasicTimeZone();
+
+    /**
+     * Construct a timezone with a given ID.
+     * @param id a system time zone ID
+     * @stable ICU 4.0
+     */
+    BasicTimeZone(const UnicodeString &id);
+
+    /**
+     * Copy constructor.
+     * @param source the object to be copied.
+     * @stable ICU 4.0
+     */
+    BasicTimeZone(const BasicTimeZone& source);
+
+    /**
+     * Gets the set of TimeZoneRule instances applicable to the specified time and after.
+     * @param start     The start date used for extracting time zone rules
+     * @param initial   Receives the InitialTimeZone, always not NULL
+     * @param transitionRules   Receives the transition rules, could be NULL
+     * @param status    Receives error status code
+     */
+    void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules,
+        UErrorCode& status) /*const*/;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // BASICTZ_H
+
+//eof
diff --git a/CoreFoundation/icu/unicode/brkiter.h b/CoreFoundation/icu/unicode/brkiter.h
new file mode 100644
index 0000000..7df5f14
--- /dev/null
+++ b/CoreFoundation/icu/unicode/brkiter.h
@@ -0,0 +1,557 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File brkiter.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/18/97    aliu        Added typedef for TextCount.  Made DONE const.
+*   05/07/97    aliu        Fixed DLL declaration.
+*   07/09/97    jfitz       Renamed BreakIterator and interface synced with JDK
+*   08/11/98    helena      Sync-up JDK1.2.
+*   01/13/2000  helena      Added UErrorCode parameter to createXXXInstance methods.
+********************************************************************************
+*/
+
+#ifndef BRKITER_H
+#define BRKITER_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Break Iterator.
+ */
+
+#if UCONFIG_NO_BREAK_ITERATION
+
+U_NAMESPACE_BEGIN
+
+/*
+ * Allow the declaration of APIs with pointers to BreakIterator
+ * even when break iteration is removed from the build.
+ */
+class BreakIterator;
+
+U_NAMESPACE_END
+
+#else
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/chariter.h"
+#include "unicode/locid.h"
+#include "unicode/ubrk.h"
+#include "unicode/strenum.h"
+#include "unicode/utext.h"
+#include "unicode/umisc.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * The BreakIterator class implements methods for finding the location
+ * of boundaries in text. BreakIterator is an abstract base class.
+ * Instances of BreakIterator maintain a current position and scan over
+ * text returning the index of characters where boundaries occur.
+ * <p>
+ * Line boundary analysis determines where a text string can be broken
+ * when line-wrapping. The mechanism correctly handles punctuation and
+ * hyphenated words.
+ * <p>
+ * Sentence boundary analysis allows selection with correct
+ * interpretation of periods within numbers and abbreviations, and
+ * trailing punctuation marks such as quotation marks and parentheses.
+ * <p>
+ * Word boundary analysis is used by search and replace functions, as
+ * well as within text editing applications that allow the user to
+ * select words with a double click. Word selection provides correct
+ * interpretation of punctuation marks within and following
+ * words. Characters that are not part of a word, such as symbols or
+ * punctuation marks, have word-breaks on both sides.
+ * <p>
+ * Character boundary analysis allows users to interact with
+ * characters as they expect to, for example, when moving the cursor
+ * through a text string. Character boundary analysis provides correct
+ * navigation of through character strings, regardless of how the
+ * character is stored.  For example, an accented character might be
+ * stored as a base character and a diacritical mark. What users
+ * consider to be a character can differ between languages.
+ * <p>
+ * The text boundary positions are found according to the rules
+ * described in Unicode Standard Annex #29, Text Boundaries, and
+ * Unicode Standard Annex #14, Line Breaking Properties.  These
+ * are available at http://www.unicode.org/reports/tr14/ and
+ * http://www.unicode.org/reports/tr29/.
+ * <p>
+ * In addition to the C++ API defined in this header file, a
+ * plain C API with equivalent functionality is defined in the
+ * file ubrk.h
+ * <p>
+ * Code snippits illustrating the use of the Break Iterator APIs
+ * are available in the ICU User Guide,
+ * http://icu-project.org/userguide/boundaryAnalysis.html
+ * and in the sample program icu/source/samples/break/break.cpp"
+ *
+ */
+class U_COMMON_API BreakIterator : public UObject {
+public:
+    /**
+     *  destructor
+     *  @stable ICU 2.0
+     */
+    virtual ~BreakIterator();
+
+    /**
+     * Return true if another object is semantically equal to this
+     * one. The other object should be an instance of the same subclass of
+     * BreakIterator. Objects of different subclasses are considered
+     * unequal.
+     * <P>
+     * Return true if this BreakIterator is at the same position in the
+     * same text, and is the same class and type (word, line, etc.) of
+     * BreakIterator, as the argument.  Text is considered the same if
+     * it contains the same characters, it need not be the same
+     * object, and styles are not considered.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const BreakIterator&) const = 0;
+
+    /**
+     * Returns the complement of the result of operator==
+     * @param rhs The BreakIterator to be compared for inequality
+     * @return the complement of the result of operator==
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
+
+    /**
+     * Return a polymorphic copy of this object.  This is an abstract
+     * method which subclasses implement.
+     * @stable ICU 2.0
+     */
+    virtual BreakIterator* clone(void) const = 0;
+
+    /**
+     * Return a polymorphic class ID for this object. Different subclasses
+     * will return distinct unequal values.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+    /**
+     * Return a CharacterIterator over the text being analyzed.
+     * @stable ICU 2.0
+     */
+    virtual CharacterIterator& getText(void) const = 0;
+
+
+    /**
+      *  Get a UText for the text being analyzed.
+      *  The returned UText is a shallow clone of the UText used internally
+      *  by the break iterator implementation.  It can safely be used to
+      *  access the text without impacting any break iterator operations,
+      *  but the underlying text itself must not be altered.
+      *
+      * @param fillIn A UText to be filled in.  If NULL, a new UText will be
+      *           allocated to hold the result.
+      * @param status receives any error codes.
+      * @return   The current UText for this break iterator.  If an input
+      *           UText was provided, it will always be returned.
+      * @stable ICU 3.4
+      */
+     virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
+
+    /**
+     * Change the text over which this operates. The text boundary is
+     * reset to the start.
+     * @param text The UnicodeString used to change the text.
+     * @stable ICU 2.0
+     */
+    virtual void  setText(const UnicodeString &text) = 0;
+
+    /**
+     * Reset the break iterator to operate over the text represented by
+     * the UText.  The iterator position is reset to the start.
+     *
+     * This function makes a shallow clone of the supplied UText.  This means
+     * that the caller is free to immediately close or otherwise reuse the
+     * Utext that was passed as a parameter, but that the underlying text itself
+     * must not be altered while being referenced by the break iterator.
+     *
+     * @param text The UText used to change the text.
+     * @param status receives any error codes.
+     * @stable ICU 3.4
+     */
+    virtual void  setText(UText *text, UErrorCode &status) = 0;
+
+    /**
+     * Change the text over which this operates. The text boundary is
+     * reset to the start.
+     * Note that setText(UText *) provides similar functionality to this function,
+     * and is more efficient.
+     * @param it The CharacterIterator used to change the text.
+     * @stable ICU 2.0
+     */
+    virtual void  adoptText(CharacterIterator* it) = 0;
+
+    enum {
+        /**
+         * DONE is returned by previous() and next() after all valid
+         * boundaries have been returned.
+         * @stable ICU 2.0
+         */
+        DONE = (int32_t)-1
+    };
+
+    /**
+     * Return the index of the first character in the text being scanned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t first(void) = 0;
+
+    /**
+     * Return the index immediately BEYOND the last character in the text being scanned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t last(void) = 0;
+
+    /**
+     * Return the boundary preceding the current boundary.
+     * @return The character index of the previous text boundary or DONE if all
+     * boundaries have been returned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t previous(void) = 0;
+
+    /**
+     * Return the boundary following the current boundary.
+     * @return The character index of the next text boundary or DONE if all
+     * boundaries have been returned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t next(void) = 0;
+
+    /**
+     * Return character index of the current interator position within the text.
+     * @return The boundary most recently returned.
+     * @stable ICU 2.0
+     */
+    virtual int32_t current(void) const = 0;
+
+    /**
+     * Return the first boundary following the specified offset.
+     * The value returned is always greater than the offset or
+     * the value BreakIterator.DONE
+     * @param offset the offset to begin scanning.
+     * @return The first boundary after the specified offset.
+     * @stable ICU 2.0
+     */
+    virtual int32_t following(int32_t offset) = 0;
+
+    /**
+     * Return the first boundary preceding the specified offset.
+     * The value returned is always smaller than the offset or
+     * the value BreakIterator.DONE
+     * @param offset the offset to begin scanning.
+     * @return The first boundary before the specified offset.
+     * @stable ICU 2.0
+     */
+    virtual int32_t preceding(int32_t offset) = 0;
+
+    /**
+     * Return true if the specfied position is a boundary position.
+     * As a side effect, the current position of the iterator is set
+     * to the first boundary position at or following the specified offset.
+     * @param offset the offset to check.
+     * @return True if "offset" is a boundary position.
+     * @stable ICU 2.0
+     */
+    virtual UBool isBoundary(int32_t offset) = 0;
+
+    /**
+     * Return the nth boundary from the current boundary
+     * @param n which boundary to return.  A value of 0
+     * does nothing.  Negative values move to previous boundaries
+     * and positive values move to later boundaries.
+     * @return The index of the nth boundary from the current position, or
+     * DONE if there are fewer than |n| boundaries in the specfied direction.
+     * @stable ICU 2.0
+     */
+    virtual int32_t next(int32_t n) = 0;
+
+    /**
+     * Create BreakIterator for word-breaks using the given locale.
+     * Returns an instance of a BreakIterator implementing word breaks.
+     * WordBreak is useful for word selection (ex. double click)
+     * @param where the locale.
+     * @param status the error code
+     * @return A BreakIterator for word-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createWordInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for line-breaks using specified locale.
+     * Returns an instance of a BreakIterator implementing line breaks. Line
+     * breaks are logically possible line breaks, actual line breaks are
+     * usually determined based on display width.
+     * LineBreak is useful for word wrapping text.
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for line-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createLineInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for character-breaks using specified locale
+     * Returns an instance of a BreakIterator implementing character breaks.
+     * Character breaks are boundaries of combining character sequences.
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for character-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createCharacterInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for sentence-breaks using specified locale
+     * Returns an instance of a BreakIterator implementing sentence breaks.
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for sentence-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.0
+     */
+    static BreakIterator* U_EXPORT2
+    createSentenceInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Create BreakIterator for title-casing breaks using the specified locale
+     * Returns an instance of a BreakIterator implementing title breaks.
+     * The iterator returned locates title boundaries as described for
+     * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
+     * please use Word Boundary iterator.{@link #createWordInstance }
+     *
+     * @param where the locale.
+     * @param status The error code.
+     * @return A BreakIterator for title-breaks.  The UErrorCode& status
+     * parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @stable ICU 2.1
+     */
+    static BreakIterator* U_EXPORT2
+    createTitleInstance(const Locale& where, UErrorCode& status);
+
+    /**
+     * Get the set of Locales for which TextBoundaries are installed.
+     * <p><b>Note:</b> this will not return locales added through the register
+     * call. To see the registered locales too, use the getAvailableLocales
+     * function that returns a StringEnumeration object </p>
+     * @param count the output parameter of number of elements in the locale list
+     * @return available locales
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Get name of the object for the desired Locale, in the desired langauge.
+     * @param objectLocale must be from getAvailableLocales.
+     * @param displayLocale specifies the desired locale for output.
+     * @param name the fill-in parameter of the return value
+     * Uses best match.
+     * @return user-displayable name
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         const Locale& displayLocale,
+                                         UnicodeString& name);
+
+    /**
+     * Get name of the object for the desired Locale, in the langauge of the
+     * default locale.
+     * @param objectLocale must be from getMatchingLocales
+     * @param name the fill-in parameter of the return value
+     * @return user-displayable name
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         UnicodeString& name);
+
+    /**
+     * Thread safe client-buffer-based cloning operation
+     *    Do NOT call delete on a safeclone, since 'new' is not used to create it.
+     * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.
+     * If buffer is not large enough, new memory will be allocated.
+     * @param BufferSize reference to size of allocated space.
+     * If BufferSize == 0, a sufficient size for use in cloning will
+     * be returned ('pre-flighting')
+     * If BufferSize is not enough for a stack-based safe clone,
+     * new memory will be allocated.
+     * @param status to indicate whether the operation went on smoothly or there were errors
+     *  An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were
+     *  necessary.
+     * @return pointer to the new clone
+     *
+     * @stable ICU 2.0
+     */
+    virtual BreakIterator *  createBufferClone(void *stackBuffer,
+                                               int32_t &BufferSize,
+                                               UErrorCode &status) = 0;
+
+    /**
+     *   Determine whether the BreakIterator was created in user memory by
+     *   createBufferClone(), and thus should not be deleted.  Such objects
+     *   must be closed by an explicit call to the destructor (not delete).
+     *  @stable ICU 2.0
+     */
+    inline UBool isBufferClone(void);
+
+#if !UCONFIG_NO_SERVICE
+    /**
+     * Register a new break iterator of the indicated kind, to use in the given locale.
+     * The break iterator will be adopted.  Clones of the iterator will be returned
+     * if a request for a break iterator of the given kind matches or falls back to
+     * this locale.
+     * @param toAdopt the BreakIterator instance to be adopted
+     * @param locale the Locale for which this instance is to be registered
+     * @param kind the type of iterator for which this instance is to be registered
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this instance
+     * @stable ICU 2.4
+     */
+    static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
+                                        const Locale& locale,
+                                        UBreakIteratorType kind,
+                                        UErrorCode& status);
+
+    /**
+     * Unregister a previously-registered BreakIterator using the key returned from the
+     * register call.  Key becomes invalid after a successful call and should not be used again.
+     * The BreakIterator corresponding to the key will be deleted.
+     * @param key the registry key returned by a previous call to registerInstance
+     * @param status the in/out status code, no special meanings are assigned
+     * @return TRUE if the iterator for the key was successfully unregistered
+     * @stable ICU 2.4
+     */
+    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
+
+    /**
+     * Return a StringEnumeration over the locales available at the time of the call,
+     * including registered locales.
+     * @return a StringEnumeration over the locales available at the time of the call
+     * @stable ICU 2.4
+     */
+    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
+#endif
+
+    /**
+     * Returns the locale for this break iterator. Two flavors are available: valid and
+     * actual locale.
+     * @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+    /** Get the locale for this break iterator object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual)
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @internal
+     */
+    const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
+
+ private:
+    static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
+    static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
+    static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
+
+    friend class ICUBreakIteratorFactory;
+    friend class ICUBreakIteratorService;
+
+protected:
+    /** @internal */
+    BreakIterator();
+    /** @internal */
+    UBool fBufferClone;
+    /** @internal */
+    BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
+
+private:
+
+    /** @internal */
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+
+    /**
+     * The assignment operator has no real implementation.
+     * It's provided to make the compiler happy. Do not call.
+     */
+    BreakIterator& operator=(const BreakIterator&);
+};
+
+inline UBool BreakIterator::isBufferClone()
+{
+    return fBufferClone;
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+
+#endif // _BRKITER
+//eof
+
diff --git a/CoreFoundation/icu/unicode/calendar.h b/CoreFoundation/icu/unicode/calendar.h
new file mode 100644
index 0000000..327ad6e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/calendar.h
@@ -0,0 +1,2170 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File CALENDAR.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/22/97    aliu        Expanded and corrected comments and other header
+*                           contents.
+*   05/01/97    aliu        Made equals(), before(), after() arguments const.
+*   05/20/97    aliu        Replaced fAreFieldsSet with fAreFieldsInSync and
+*                           fAreAllFieldsSet.
+*   07/27/98    stephen     Sync up with JDK 1.2
+*   11/15/99    weiv        added YEAR_WOY and DOW_LOCAL
+*                           to EDateFields
+*    8/19/2002  srl         Removed Javaisms
+*   11/07/2003  srl         Update, clean up documentation.
+********************************************************************************
+*/
+
+#ifndef CALENDAR_H
+#define CALENDAR_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Calendar object
+ */
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+#include "unicode/timezone.h"
+#include "unicode/ucal.h"
+#include "unicode/umisc.h"
+
+U_NAMESPACE_BEGIN
+
+class ICUServiceFactory;
+
+/**
+ * @internal
+ */
+typedef int32_t UFieldResolutionTable[12][8];
+
+/**
+ * <code>Calendar</code> is an abstract base class for converting between
+ * a <code>UDate</code> object and a set of integer fields such as
+ * <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>,
+ * and so on. (A <code>UDate</code> object represents a specific instant in
+ * time with millisecond precision. See UDate
+ * for information about the <code>UDate</code> class.)
+ *
+ * <p>
+ * Subclasses of <code>Calendar</code> interpret a <code>UDate</code>
+ * according to the rules of a specific calendar system.
+ * The most commonly used subclass of <code>Calendar</code> is
+ * <code>GregorianCalendar</code>. Other subclasses could represent
+ * the various types of lunar calendars in use in many parts of the world.
+ *
+ * <p>
+ * <b>NOTE</b>: (ICU 2.6) The subclass interface should be considered unstable
+ * - it WILL change.
+ *
+ * <p>
+ * Like other locale-sensitive classes, <code>Calendar</code> provides a
+ * static method, <code>createInstance</code>, for getting a generally useful
+ * object of this type. <code>Calendar</code>'s <code>createInstance</code> method
+ * returns the appropriate <code>Calendar</code> subclass whose
+ * time fields have been initialized with the current date and time:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * Calendar *rightNow = Calendar::createInstance(errCode);
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <p>
+ * A <code>Calendar</code> object can produce all the time field values
+ * needed to implement the date-time formatting for a particular language
+ * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
+ *
+ * <p>
+ * When computing a <code>UDate</code> from time fields, two special circumstances
+ * may arise: there may be insufficient information to compute the
+ * <code>UDate</code> (such as only year and month but no day in the month),
+ * or there may be inconsistent information (such as "Tuesday, July 15, 1996"
+ * -- July 15, 1996 is actually a Monday).
+ *
+ * <p>
+ * <strong>Insufficient information.</strong> The calendar will use default
+ * information to specify the missing fields. This may vary by calendar; for
+ * the Gregorian calendar, the default for a field is the same as that of the
+ * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.
+ *
+ * <p>
+ * <strong>Inconsistent information.</strong> If fields conflict, the calendar
+ * will give preference to fields set more recently. For example, when
+ * determining the day, the calendar will look for one of the following
+ * combinations of fields.  The most recent combination, as determined by the
+ * most recently set single field, will be used.
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * MONTH + DAY_OF_MONTH
+ * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
+ * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
+ * DAY_OF_YEAR
+ * DAY_OF_WEEK + WEEK_OF_YEAR
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * For the time of day:
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * HOUR_OF_DAY
+ * AM_PM + HOUR
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <p>
+ * <strong>Note:</strong> for some non-Gregorian calendars, different
+ * fields may be necessary for complete disambiguation. For example, a full
+ * specification of the historial Arabic astronomical calendar requires year,
+ * month, day-of-month <em>and</em> day-of-week in some cases.
+ *
+ * <p>
+ * <strong>Note:</strong> There are certain possible ambiguities in
+ * interpretation of certain singular times, which are resolved in the
+ * following ways:
+ * <ol>
+ *     <li> 24:00:00 "belongs" to the following day. That is,
+ *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970
+ *
+ *     <li> Although historically not precise, midnight also belongs to "am",
+ *          and noon belongs to "pm", so on the same day,
+ *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm
+ * </ol>
+ *
+ * <p>
+ * The date or time format strings are not part of the definition of a
+ * calendar, as those must be modifiable or overridable by the user at
+ * runtime. Use {@link DateFormat}
+ * to format dates.
+ *
+ * <p>
+ * <code>Calendar</code> provides an API for field "rolling", where fields
+ * can be incremented or decremented, but wrap around. For example, rolling the
+ * month up in the date <code>December 12, <b>1996</b></code> results in
+ * <code>January 12, <b>1996</b></code>.
+ *
+ * <p>
+ * <code>Calendar</code> also provides a date arithmetic function for
+ * adding the specified (signed) amount of time to a particular time field.
+ * For example, subtracting 5 days from the date <code>September 12, 1996</code>
+ * results in <code>September 7, 1996</code>.
+ *
+ * @stable ICU 2.0
+ */
+class U_I18N_API Calendar : public UObject {
+public:
+
+    /**
+     * Field IDs for date and time. Used to specify date/time fields. ERA is calendar
+     * specific. Example ranges given are for illustration only; see specific Calendar
+     * subclasses for actual ranges.
+     * @deprecated ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h
+     */
+    enum EDateFields {
+#ifndef U_HIDE_DEPRECATED_API
+        ERA,                  // Example: 0..1
+        YEAR,                 // Example: 1..big number
+        MONTH,                // Example: 0..11
+        WEEK_OF_YEAR,         // Example: 1..53
+        WEEK_OF_MONTH,        // Example: 1..4
+        DATE,                 // Example: 1..31
+        DAY_OF_YEAR,          // Example: 1..365
+        DAY_OF_WEEK,          // Example: 1..7
+        DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1
+        AM_PM,                // Example: 0..1
+        HOUR,                 // Example: 0..11
+        HOUR_OF_DAY,          // Example: 0..23
+        MINUTE,               // Example: 0..59
+        SECOND,               // Example: 0..59
+        MILLISECOND,          // Example: 0..999
+        ZONE_OFFSET,          // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
+        DST_OFFSET,           // Example: 0 or U_MILLIS_PER_HOUR
+        YEAR_WOY,             // 'Y' Example: 1..big number - Year of Week of Year
+        DOW_LOCAL,            // 'e' Example: 1..7 - Day of Week / Localized
+#ifndef DEPLOYMENT_TARGET_WIN32		
+		EXTENDED_YEAR,
+		JULIAN_DAY,
+		MILLISECONDS_IN_DAY,
+		IS_LEAP_MONTH,
+#endif
+        FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
+#endif /* U_HIDE_DEPRECATED_API */
+    };
+
+    /**
+     * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
+     * who create locale resources for the field of first-day-of-week should be aware of
+     * this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.
+     * @deprecated ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h
+     */
+    enum EDaysOfWeek {
+#ifndef U_HIDE_DEPRECATED_API
+        SUNDAY = 1,
+        MONDAY,
+        TUESDAY,
+        WEDNESDAY,
+        THURSDAY,
+        FRIDAY,
+        SATURDAY
+#endif /* U_HIDE_DEPRECATED_API */
+    };
+
+    /**
+     * Useful constants for month. Note: Calendar month is 0-based.
+     * @deprecated ICU 2.6. Use C enum UCalendarMonths defined in ucal.h
+     */
+    enum EMonths {
+#ifndef U_HIDE_DEPRECATED_API
+        JANUARY,
+        FEBRUARY,
+        MARCH,
+        APRIL,
+        MAY,
+        JUNE,
+        JULY,
+        AUGUST,
+        SEPTEMBER,
+        OCTOBER,
+        NOVEMBER,
+        DECEMBER,
+        UNDECIMBER
+#endif /* U_HIDE_DEPRECATED_API */
+    };
+
+    /**
+     * Useful constants for hour in 12-hour clock. Used in GregorianCalendar.
+     * @deprecated ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h
+     */
+    enum EAmpm {
+#ifndef U_HIDE_DEPRECATED_API
+        AM,
+        PM
+#endif /* U_HIDE_DEPRECATED_API */
+    };
+
+    /**
+     * destructor
+     * @stable ICU 2.0
+     */
+    virtual ~Calendar();
+
+    /**
+     * Create and return a polymorphic copy of this calendar.
+     *
+     * @return    a polymorphic copy of this calendar.
+     * @stable ICU 2.0
+     */
+    virtual Calendar* clone(void) const = 0;
+
+    /**
+     * Creates a Calendar using the default timezone and locale. Clients are responsible
+     * for deleting the object returned.
+     *
+     * @param success  Indicates the success/failure of Calendar creation. Filled in
+     *                 with U_ZERO_ERROR if created successfully, set to a failure result
+     *                 otherwise. U_MISSING_RESOURCE_ERROR will be returned if the resource data
+     *                 requests a calendar type which has not been installed.
+     * @return         A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the given timezone and the default locale.
+     * The Calendar takes ownership of zoneToAdopt; the
+     * client must not delete it.
+     *
+     * @param zoneToAdopt  The given timezone to be adopted.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the given timezone and the default locale.  The TimeZone
+     * is _not_ adopted; the client is still responsible for deleting it.
+     *
+     * @param zone  The timezone.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the default timezone and the given locale.
+     *
+     * @param aLocale  The given locale.
+     * @param success  Indicates the success/failure of Calendar creation. Filled in
+     *                 with U_ZERO_ERROR if created successfully, set to a failure result
+     *                 otherwise.
+     * @return         A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Creates a Calendar using the given timezone and given locale.
+     * The Calendar takes ownership of zoneToAdopt; the
+     * client must not delete it.
+     *
+     * @param zoneToAdopt  The given timezone to be adopted.
+     * @param aLocale      The given locale.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Gets a Calendar using the given timezone and given locale.  The TimeZone
+     * is _not_ adopted; the client is still responsible for deleting it.
+     *
+     * @param zoneToAdopt  The given timezone to be adopted.
+     * @param aLocale      The given locale.
+     * @param success      Indicates the success/failure of Calendar creation. Filled in
+     *                     with U_ZERO_ERROR if created successfully, set to a failure result
+     *                     otherwise.
+     * @return             A Calendar if created successfully. NULL otherwise.
+     * @stable ICU 2.0
+     */
+    static Calendar* U_EXPORT2 createInstance(const TimeZone& zoneToAdopt, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Returns a list of the locales for which Calendars are installed.
+     *
+     * @param count  Number of locales returned.
+     * @return       An array of Locale objects representing the set of locales for which
+     *               Calendars are installed.  The system retains ownership of this list;
+     *               the caller must NOT delete it. Does not include user-registered Calendars.
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70
+     * (derived from the system time).
+     *
+     * @return   The current UTC time in milliseconds.
+     * @stable ICU 2.0
+     */
+    static UDate U_EXPORT2 getNow(void);
+
+    /**
+     * Gets this Calendar's time as milliseconds. May involve recalculation of time due
+     * to previous calls to set time field values. The time specified is non-local UTC
+     * (GMT) time. Although this method is const, this object may actually be changed
+     * (semantically const).
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        The current time in UTC (GMT) time, or zero if the operation
+     *                failed.
+     * @stable ICU 2.0
+     */
+    inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }
+
+    /**
+     * Sets this Calendar's current time with the given UDate. The time specified should
+     * be in non-local UTC (GMT) time.
+     *
+     * @param date  The given UDate in UTC (GMT) time.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }
+
+    /**
+     * Compares the equality of two Calendar objects. Objects of different subclasses
+     * are considered unequal. This comparison is very exacting; two Calendar objects
+     * must be in exactly the same state to be considered equal. To compare based on the
+     * represented time, use equals() instead.
+     *
+     * @param that  The Calendar object to be compared with.
+     * @return      True if the given Calendar is the same as this Calendar; false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Calendar& that) const;
+
+    /**
+     * Compares the inequality of two Calendar objects.
+     *
+     * @param that  The Calendar object to be compared with.
+     * @return      True if the given Calendar is not the same as this Calendar; false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const Calendar& that) const {return !operator==(that);}
+
+    /**
+     * Returns TRUE if the given Calendar object is equivalent to this
+     * one.  An equivalent Calendar will behave exactly as this one
+     * does, but it may be set to a different time.  By contrast, for
+     * the operator==() method to return TRUE, the other Calendar must
+     * be set to the same time.
+     *
+     * @param other the Calendar to be compared with this Calendar
+     * @stable ICU 2.4
+     */
+    virtual UBool isEquivalentTo(const Calendar& other) const;
+
+    /**
+     * Compares the Calendar time, whereas Calendar::operator== compares the equality of
+     * Calendar objects.
+     *
+     * @param when    The Calendar to be compared with this Calendar. Although this is a
+     *                const parameter, the object may be modified physically
+     *                (semantically const).
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        True if the current time of this Calendar is equal to the time of
+     *                Calendar when; false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool equals(const Calendar& when, UErrorCode& status) const;
+
+    /**
+     * Returns true if this Calendar's current time is before "when"'s current time.
+     *
+     * @param when    The Calendar to be compared with this Calendar. Although this is a
+     *                const parameter, the object may be modified physically
+     *                (semantically const).
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        True if the current time of this Calendar is before the time of
+     *                Calendar when; false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool before(const Calendar& when, UErrorCode& status) const;
+
+    /**
+     * Returns true if this Calendar's current time is after "when"'s current time.
+     *
+     * @param when    The Calendar to be compared with this Calendar. Although this is a
+     *                const parameter, the object may be modified physically
+     *                (semantically const).
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return        True if the current time of this Calendar is after the time of
+     *                Calendar when; false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool after(const Calendar& when, UErrorCode& status) const;
+
+    /**
+     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
+     * time field, based on the calendar's rules. For example, to subtract 5 days from
+     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
+     * the month or Calendar::MONTH field, other fields like date might conflict and
+     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
+     * in 02/29/96.
+     *
+     * @param field   Specifies which date field to modify.
+     * @param amount  The amount of time to be added to the field, in the natural unit
+     *                for that field (e.g., days for the day fields, hours for the hour
+     *                field.)
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
+     */
+    virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
+     * time field, based on the calendar's rules. For example, to subtract 5 days from
+     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
+     * the month or Calendar::MONTH field, other fields like date might conflict and
+     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
+     * in 02/29/96.
+     *
+     * @param field   Specifies which date field to modify.
+     * @param amount  The amount of time to be added to the field, in the natural unit
+     *                for that field (e.g., days for the day fields, hours for the hour
+     *                field.)
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.6.
+     */
+    virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
+     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
+     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96. Rolling up always means rolling forward in time; e.g., rolling the year
+     * up on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the
+     * hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range
+     * between 0 and 23, which is zero-based.
+     * <P>
+     * NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.
+     *
+     * @param field   The time field.
+     * @param up      Indicates if the value of the specified time field is to be rolled
+     *                up or rolled down. Use true if rolling up, false otherwise.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, UBool up, UErrorCode& status) instead.
+     */
+    inline void roll(EDateFields field, UBool up, UErrorCode& status);
+
+    /**
+     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
+     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
+     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96. Rolling up always means rolling forward in time; e.g., rolling the year
+     * up on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the
+     * hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range
+     * between 0 and 23, which is zero-based.
+     * <P>
+     * NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.
+     *
+     * @param field   The time field.
+     * @param up      Indicates if the value of the specified time field is to be rolled
+     *                up or rolled down. Use true if rolling up, false otherwise.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.6.
+     */
+    inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
+
+    /**
+     * Time Field Rolling function. Rolls by the given amount on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, +1, status). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96.  Rolling by a positive value always means rolling forward in time;
+     * e.g., rolling the year by +1 on "100 BC" will result in "99 BC", for Gregorian
+     * calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will
+     * roll the hour value in the range between 0 and 23, which is zero-based.
+     * <P>
+     * The only difference between roll() and add() is that roll() does not change
+     * the value of more significant fields when it reaches the minimum or maximum
+     * of its range, whereas add() does.
+     *
+     * @param field   The time field.
+     * @param amount  Indicates amount to roll.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
+     */
+    virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * Time Field Rolling function. Rolls by the given amount on the given
+     * time field. For example, to roll the current date up by one day, call
+     * roll(Calendar::DATE, +1, status). When rolling on the month or
+     * Calendar::MONTH field, other fields like date might conflict and, need to be
+     * changed. For instance, rolling the month up on the date 01/31/96 will result in
+     * 02/29/96.  Rolling by a positive value always means rolling forward in time;
+     * e.g., rolling the year by +1 on "100 BC" will result in "99 BC", for Gregorian
+     * calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will
+     * roll the hour value in the range between 0 and 23, which is zero-based.
+     * <P>
+     * The only difference between roll() and add() is that roll() does not change
+     * the value of more significant fields when it reaches the minimum or maximum
+     * of its range, whereas add() does.
+     *
+     * @param field   The time field.
+     * @param amount  Indicates amount to roll.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @stable ICU 2.6.
+     */
+    virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * Return the difference between the given time and the time this
+     * calendar object is set to.  If this calendar is set
+     * <em>before</em> the given time, the returned value will be
+     * positive.  If this calendar is set <em>after</em> the given
+     * time, the returned value will be negative.  The
+     * <code>field</code> parameter specifies the units of the return
+     * value.  For example, if <code>fieldDifference(when,
+     * Calendar::MONTH)</code> returns 3, then this calendar is set to
+     * 3 months before <code>when</code>, and possibly some addition
+     * time less than one month.
+     *
+     * <p>As a side effect of this call, this calendar is advanced
+     * toward <code>when</code> by the given amount.  That is, calling
+     * this method has the side effect of calling <code>add(field,
+     * n)</code>, where <code>n</code> is the return value.
+     *
+     * <p>Usage: To use this method, call it first with the largest
+     * field of interest, then with progressively smaller fields.  For
+     * example:
+     *
+     * <pre>
+     * int y = cal->fieldDifference(when, Calendar::YEAR, err);
+     * int m = cal->fieldDifference(when, Calendar::MONTH, err);
+     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
+     *
+     * computes the difference between <code>cal</code> and
+     * <code>when</code> in years, months, and days.
+     *
+     * <p>Note: <code>fieldDifference()</code> is
+     * <em>asymmetrical</em>.  That is, in the following code:
+     *
+     * <pre>
+     * cal->setTime(date1, err);
+     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
+     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
+     * cal->setTime(date2, err);
+     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
+     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
+     *
+     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
+     * However, this is not generally the case, because of
+     * irregularities in the underlying calendar system (e.g., the
+     * Gregorian calendar has a varying number of days per month).
+     *
+     * @param when the date to compare this calendar's time to
+     * @param field the field in which to compute the result
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @return the difference, either positive or negative, between
+     * this calendar's time and <code>when</code>, in terms of
+     * <code>field</code>.
+     * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).
+     */
+    virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
+
+    /**
+     * Return the difference between the given time and the time this
+     * calendar object is set to.  If this calendar is set
+     * <em>before</em> the given time, the returned value will be
+     * positive.  If this calendar is set <em>after</em> the given
+     * time, the returned value will be negative.  The
+     * <code>field</code> parameter specifies the units of the return
+     * value.  For example, if <code>fieldDifference(when,
+     * Calendar::MONTH)</code> returns 3, then this calendar is set to
+     * 3 months before <code>when</code>, and possibly some addition
+     * time less than one month.
+     *
+     * <p>As a side effect of this call, this calendar is advanced
+     * toward <code>when</code> by the given amount.  That is, calling
+     * this method has the side effect of calling <code>add(field,
+     * n)</code>, where <code>n</code> is the return value.
+     *
+     * <p>Usage: To use this method, call it first with the largest
+     * field of interest, then with progressively smaller fields.  For
+     * example:
+     *
+     * <pre>
+     * int y = cal->fieldDifference(when, Calendar::YEAR, err);
+     * int m = cal->fieldDifference(when, Calendar::MONTH, err);
+     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
+     *
+     * computes the difference between <code>cal</code> and
+     * <code>when</code> in years, months, and days.
+     *
+     * <p>Note: <code>fieldDifference()</code> is
+     * <em>asymmetrical</em>.  That is, in the following code:
+     *
+     * <pre>
+     * cal->setTime(date1, err);
+     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
+     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
+     * cal->setTime(date2, err);
+     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
+     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
+     *
+     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
+     * However, this is not generally the case, because of
+     * irregularities in the underlying calendar system (e.g., the
+     * Gregorian calendar has a varying number of days per month).
+     *
+     * @param when the date to compare this calendar's time to
+     * @param field the field in which to compute the result
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @return the difference, either positive or negative, between
+     * this calendar's time and <code>when</code>, in terms of
+     * <code>field</code>.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
+
+    /**
+     * Sets the calendar's time zone to be the one passed in. The Calendar takes ownership
+     * of the TimeZone; the caller is no longer responsible for deleting it.  If the
+     * given time zone is NULL, this function has no effect.
+     *
+     * @param value  The given time zone.
+     * @stable ICU 2.0
+     */
+    void adoptTimeZone(TimeZone* value);
+
+    /**
+     * Sets the calendar's time zone to be the same as the one passed in. The TimeZone
+     * passed in is _not_ adopted; the client is still responsible for deleting it.
+     *
+     * @param zone  The given time zone.
+     * @stable ICU 2.0
+     */
+    void setTimeZone(const TimeZone& zone);
+
+    /**
+     * Returns a reference to the time zone owned by this calendar. The returned reference
+     * is only valid until clients make another call to adoptTimeZone or setTimeZone,
+     * or this Calendar is destroyed.
+     *
+     * @return   The time zone object associated with this calendar.
+     * @stable ICU 2.0
+     */
+    const TimeZone& getTimeZone(void) const;
+
+    /**
+     * Returns the time zone owned by this calendar. The caller owns the returned object
+     * and must delete it when done.  After this call, the new time zone associated
+     * with this Calendar is the default TimeZone as returned by TimeZone::createDefault().
+     *
+     * @return   The time zone object which was associated with this calendar.
+     * @stable ICU 2.0
+     */
+    TimeZone* orphanTimeZone(void);
+
+    /**
+     * Queries if the current date for this Calendar is in Daylight Savings Time.
+     *
+     * @param status Fill-in parameter which receives the status of this operation.
+     * @return   True if the current date for this Calendar is in Daylight Savings Time,
+     *           false, otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool inDaylightTime(UErrorCode& status) const = 0;
+
+    /**
+     * Specifies whether or not date/time interpretation is to be lenient. With lenient
+     * interpretation, a date such as "February 942, 1996" will be treated as being
+     * equivalent to the 941st day after February 1, 1996. With strict interpretation,
+     * such dates will cause an error when computing time from the time field values
+     * representing the dates.
+     *
+     * @param lenient  True specifies date/time interpretation to be lenient.
+     *
+     * @see            DateFormat#setLenient
+     * @stable ICU 2.0
+     */
+    void setLenient(UBool lenient);
+
+    /**
+     * Tells whether date/time interpretation is to be lenient.
+     *
+     * @return   True tells that date/time interpretation is to be lenient.
+     * @stable ICU 2.0
+     */
+    UBool isLenient(void) const;
+
+    /**
+     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @param value  The given first day of the week.
+     * @deprecated ICU 2.6. Use setFirstDayOfWeek(UCalendarDaysOfWeek value) instead.
+     */
+    void setFirstDayOfWeek(EDaysOfWeek value);
+
+    /**
+     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @param value  The given first day of the week.
+     * @stable ICU 2.6.
+     */
+    void setFirstDayOfWeek(UCalendarDaysOfWeek value);
+
+    /**
+     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @return   The first day of the week.
+     * @deprecated ICU 2.6 use the overload with error code
+     */
+    EDaysOfWeek getFirstDayOfWeek(void) const;
+
+    /**
+     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
+     *
+     * @param status error code
+     * @return   The first day of the week.
+     * @stable ICU 2.6
+     */
+    UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const;
+
+    /**
+     * Sets what the minimal days required in the first week of the year are; For
+     * example, if the first week is defined as one that contains the first day of the
+     * first month of a year, call the method with value 1. If it must be a full week,
+     * use value 7.
+     *
+     * @param value  The given minimal days required in the first week of the year.
+     * @stable ICU 2.0
+     */
+    void setMinimalDaysInFirstWeek(uint8_t value);
+
+    /**
+     * Gets what the minimal days required in the first week of the year are; e.g., if
+     * the first week is defined as one that contains the first day of the first month
+     * of a year, getMinimalDaysInFirstWeek returns 1. If the minimal days required must
+     * be a full week, getMinimalDaysInFirstWeek returns 7.
+     *
+     * @return   The minimal days required in the first week of the year.
+     * @stable ICU 2.0
+     */
+    uint8_t getMinimalDaysInFirstWeek(void) const;
+
+    /**
+     * Gets the minimum value for the given time field. e.g., for Gregorian
+     * DAY_OF_MONTH, 1.
+     *
+     * @param field  The given time field.
+     * @return       The minimum value for the given time field.
+     * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getMinimum(EDateFields field) const;
+
+    /**
+     * Gets the minimum value for the given time field. e.g., for Gregorian
+     * DAY_OF_MONTH, 1.
+     *
+     * @param field  The given time field.
+     * @return       The minimum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getMinimum(UCalendarDateFields field) const;
+
+    /**
+     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
+     * 31.
+     *
+     * @param field  The given time field.
+     * @return       The maximum value for the given time field.
+     * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getMaximum(EDateFields field) const;
+
+    /**
+     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
+     * 31.
+     *
+     * @param field  The given time field.
+     * @return       The maximum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getMaximum(UCalendarDateFields field) const;
+
+    /**
+     * Gets the highest minimum value for the given field if varies. Otherwise same as
+     * getMinimum(). For Gregorian, no difference.
+     *
+     * @param field  The given time field.
+     * @return       The highest minimum value for the given time field.
+     * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getGreatestMinimum(EDateFields field) const;
+
+    /**
+     * Gets the highest minimum value for the given field if varies. Otherwise same as
+     * getMinimum(). For Gregorian, no difference.
+     *
+     * @param field  The given time field.
+     * @return       The highest minimum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
+
+    /**
+     * Gets the lowest maximum value for the given field if varies. Otherwise same as
+     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
+     *
+     * @param field  The given time field.
+     * @return       The lowest maximum value for the given time field.
+     * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.
+     */
+    virtual int32_t getLeastMaximum(EDateFields field) const;
+
+    /**
+     * Gets the lowest maximum value for the given field if varies. Otherwise same as
+     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
+     *
+     * @param field  The given time field.
+     * @return       The lowest maximum value for the given time field.
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
+
+    /**
+     * Return the minimum value that this field could have, given the current date.
+     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual minimum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the minimum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the minimum of the given field for the current date of this Calendar
+     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field, UErrorCode& status) instead.
+     */
+    int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
+
+    /**
+     * Return the minimum value that this field could have, given the current date.
+     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual minimum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the minimum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the minimum of the given field for the current date of this Calendar
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;
+
+    /**
+     * Return the maximum value that this field could have, given the current date.
+     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
+     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
+     * for some years the actual maximum for MONTH is 12, and for others 13.
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual maximum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the maximum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the maximum of the given field for the current date of this Calendar
+     * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field, UErrorCode& status) instead.
+     */
+    int32_t getActualMaximum(EDateFields field, UErrorCode& status) const;
+
+    /**
+     * Return the maximum value that this field could have, given the current date.
+     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
+     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
+     * for some years the actual maximum for MONTH is 12, and for others 13.
+     *
+     * The version of this function on Calendar uses an iterative algorithm to determine the
+     * actual maximum value for the field.  There is almost always a more efficient way to
+     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar
+     * overrides this function with a more efficient implementation.
+     *
+     * @param field    the field to determine the maximum of
+     * @param status   Fill-in parameter which receives the status of this operation.
+     * @return         the maximum of the given field for the current date of this Calendar
+     * @stable ICU 2.6.
+     */
+    virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
+
+    /**
+     * Gets the value for a given time field. Recalculate the current time field values
+     * if the time value has been changed by a call to setTime(). Return zero for unset
+     * fields if any fields have been explicitly set by a call to set(). To force a
+     * recomputation of all fields regardless of the previous state, call complete().
+     * This method is semantically const, but may alter the object in memory.
+     *
+     * @param field  The given time field.
+     * @param status Fill-in parameter which receives the status of the operation.
+     * @return       The value for the given time field, or zero if the field is unset,
+     *               and set() has been called for any other field.
+     * @deprecated ICU 2.6. Use get(UCalendarDateFields field, UErrorCode& status) instead.
+     */
+    int32_t get(EDateFields field, UErrorCode& status) const;
+
+    /**
+     * Gets the value for a given time field. Recalculate the current time field values
+     * if the time value has been changed by a call to setTime(). Return zero for unset
+     * fields if any fields have been explicitly set by a call to set(). To force a
+     * recomputation of all fields regardless of the previous state, call complete().
+     * This method is semantically const, but may alter the object in memory.
+     *
+     * @param field  The given time field.
+     * @param status Fill-in parameter which receives the status of the operation.
+     * @return       The value for the given time field, or zero if the field is unset,
+     *               and set() has been called for any other field.
+     * @stable ICU 2.6.
+     */
+    int32_t get(UCalendarDateFields field, UErrorCode& status) const;
+
+    /**
+     * Determines if the given time field has a value set. This can affect in the
+     * resolving of time in Calendar. Unset fields have a value of zero, by definition.
+     *
+     * @param field  The given time field.
+     * @return   True if the given time field has a value set; false otherwise.
+     * @deprecated ICU 2.6. Use isSet(UCalendarDateFields field) instead.
+     */
+    UBool isSet(EDateFields field) const;
+
+    /**
+     * Determines if the given time field has a value set. This can affect in the
+     * resolving of time in Calendar. Unset fields have a value of zero, by definition.
+     *
+     * @param field  The given time field.
+     * @return   True if the given time field has a value set; false otherwise.
+     * @stable ICU 2.6.
+     */
+    UBool isSet(UCalendarDateFields field) const;
+
+    /**
+     * Sets the given time field with the given value.
+     *
+     * @param field  The given time field.
+     * @param value  The value to be set for the given time field.
+     * @deprecated ICU 2.6. Use set(UCalendarDateFields field, int32_t value) instead.
+     */
+    void set(EDateFields field, int32_t value);
+
+    /**
+     * Sets the given time field with the given value.
+     *
+     * @param field  The given time field.
+     * @param value  The value to be set for the given time field.
+     * @stable ICU 2.6.
+     */
+    void set(UCalendarDateFields field, int32_t value);
+
+    /**
+     * Sets the values for the fields YEAR, MONTH, and DATE. Other field values are
+     * retained; call clear() first if this is not desired.
+     *
+     * @param year   The value used to set the YEAR time field.
+     * @param month  The value used to set the MONTH time field. Month value is 0-based.
+     *               e.g., 0 for January.
+     * @param date   The value used to set the DATE time field.
+     * @stable ICU 2.0
+     */
+    void set(int32_t year, int32_t month, int32_t date);
+
+    /**
+     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE. Other
+     * field values are retained; call clear() first if this is not desired.
+     *
+     * @param year    The value used to set the YEAR time field.
+     * @param month   The value used to set the MONTH time field. Month value is
+     *                0-based. E.g., 0 for January.
+     * @param date    The value used to set the DATE time field.
+     * @param hour    The value used to set the HOUR_OF_DAY time field.
+     * @param minute  The value used to set the MINUTE time field.
+     * @stable ICU 2.0
+     */
+    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute);
+
+    /**
+     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.
+     * Other field values are retained; call clear() first if this is not desired.
+     *
+     * @param year    The value used to set the YEAR time field.
+     * @param month   The value used to set the MONTH time field. Month value is
+     *                0-based. E.g., 0 for January.
+     * @param date    The value used to set the DATE time field.
+     * @param hour    The value used to set the HOUR_OF_DAY time field.
+     * @param minute  The value used to set the MINUTE time field.
+     * @param second  The value used to set the SECOND time field.
+     * @stable ICU 2.0
+     */
+    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second);
+
+    /**
+     * Clears the values of all the time fields, making them both unset and assigning
+     * them a value of zero. The field values will be determined during the next
+     * resolving of time into time fields.
+     * @stable ICU 2.0
+     */
+    void clear(void);
+
+    /**
+     * Clears the value in the given time field, both making it unset and assigning it a
+     * value of zero. This field value will be determined during the next resolving of
+     * time into time fields.
+     *
+     * @param field  The time field to be cleared.
+     * @deprecated ICU 2.6. Use clear(UCalendarDateFields field) instead.
+     */
+    void clear(EDateFields field);
+
+    /**
+     * Clears the value in the given time field, both making it unset and assigning it a
+     * value of zero. This field value will be determined during the next resolving of
+     * time into time fields.
+     *
+     * @param field  The time field to be cleared.
+     * @stable ICU 2.6.
+     */
+    void clear(UCalendarDateFields field);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual method. This method is to
+     * implement a simple version of RTTI, since not all C++ compilers support genuine
+     * RTTI. Polymorphic operator==() and clone() methods call this method.
+     * <P>
+     * Concrete subclasses of Calendar must implement getDynamicClassID() and also a
+     * static method and data member:
+     *
+     *      static UClassID getStaticClassID() { return (UClassID)&amp;fgClassID; }
+     *      static char fgClassID;
+     *
+     * @return   The class ID for this object. All objects of a given class have the
+     *           same class ID. Objects of other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+    /**
+     * Returns the resource key string used for this calendar type.
+     * For example, prepending "Eras_" to this string could return "Eras_japanese"
+     * or "Eras_gregorian".
+     *
+     * @returns static string, for example, "gregorian" or "japanese"
+     * @internal
+     */
+    virtual const char * getType() const = 0;
+
+protected:
+
+     /**
+      * Constructs a Calendar with the default time zone as returned by
+      * TimeZone::createInstance(), and the default locale.
+      *
+      * @param success  Indicates the status of Calendar object construction. Returns
+      *                 U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+      */
+    Calendar(UErrorCode& success);
+
+    /**
+     * Copy constructor
+     *
+     * @param source    Calendar object to be copied from
+     * @stable ICU 2.0
+     */
+    Calendar(const Calendar& source);
+
+    /**
+     * Default assignment operator
+     *
+     * @param right    Calendar object to be copied
+     * @stable ICU 2.0
+     */
+    Calendar& operator=(const Calendar& right);
+
+    /**
+     * Constructs a Calendar with the given time zone and locale. Clients are no longer
+     * responsible for deleting the given time zone object after it's adopted.
+     *
+     * @param zone     The given time zone.
+     * @param aLocale  The given locale.
+     * @param success  Indicates the status of Calendar object construction. Returns
+     *                 U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Constructs a Calendar with the given time zone and locale.
+     *
+     * @param zone     The given time zone.
+     * @param aLocale  The given locale.
+     * @param success  Indicates the status of Calendar object construction. Returns
+     *                 U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Converts Calendar's time field values to GMT as milliseconds.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    virtual void computeTime(UErrorCode& status);
+
+    /**
+     * Converts GMT as milliseconds to time field values. This allows you to sync up the
+     * time field values with a new time that is set for the calendar.  This method
+     * does NOT recompute the time first; to recompute the time, then the fields, use
+     * the method complete().
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    virtual void computeFields(UErrorCode& status);
+
+    /**
+     * Gets this Calendar's current time as a long.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @return the current time as UTC milliseconds from the epoch.
+     * @stable ICU 2.0
+     */
+    double getTimeInMillis(UErrorCode& status) const;
+
+    /**
+     * Sets this Calendar's current time from the given long value.
+     * @param millis  the new time in UTC milliseconds from the epoch.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    void setTimeInMillis( double millis, UErrorCode& status );
+
+    /**
+     * Recomputes the current time from currently set fields, and then fills in any
+     * unset fields in the time field list.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     * @stable ICU 2.0
+     */
+    void complete(UErrorCode& status);
+
+    /**
+     * Gets the value for a given time field. Subclasses can use this function to get
+     * field values without forcing recomputation of time.
+     *
+     * @param field  The given time field.
+     * @return       The value for the given time field.
+     * @deprecated ICU 2.6. Use internalGet(UCalendarDateFields field) instead.
+     */
+    inline int32_t internalGet(EDateFields field) const {return fFields[field];}
+
+    /**
+     * Gets the value for a given time field. Subclasses can use this function to get
+     * field values without forcing recomputation of time. If the field's stamp is UNSET,
+     * the defaultValue is used.
+     *
+     * @param field  The given time field.
+     * @param defaultValue a default value used if the field is unset.
+     * @return       The value for the given time field.
+     * @internal
+     */
+    inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}
+
+    /**
+     * Gets the value for a given time field. Subclasses can use this function to get
+     * field values without forcing recomputation of time.
+     *
+     * @param field  The given time field.
+     * @return       The value for the given time field.
+     * @internal
+     */
+    inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
+
+    /**
+     * Sets the value for a given time field.  This is a fast internal method for
+     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
+     * flags.
+     *
+     * @param field    The given time field.
+     * @param value    The value for the given time field.
+     * @deprecated ICU 2.6. Use internalSet(UCalendarDateFields field, int32_t value) instead.
+     */
+    void internalSet(EDateFields field, int32_t value);
+
+    /**
+     * Sets the value for a given time field.  This is a fast internal method for
+     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
+     * flags.
+     *
+     * @param field    The given time field.
+     * @param value    The value for the given time field.
+     * @stable ICU 2.6.
+     */
+    inline void internalSet(UCalendarDateFields field, int32_t value);
+
+    /**
+     * Prepare this calendar for computing the actual minimum or maximum.
+     * This method modifies this calendar's fields; it is called on a
+     * temporary calendar.
+     * @internal
+     */
+    virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
+
+    /**
+     * Limit enums. Not in sync with UCalendarLimitType (refers to internal fields).
+     * @internal
+     */
+    enum ELimitType {
+      UCAL_LIMIT_MINIMUM = 0,
+      UCAL_LIMIT_GREATEST_MINIMUM,
+      UCAL_LIMIT_LEAST_MAXIMUM,
+      UCAL_LIMIT_MAXIMUM,
+      UCAL_LIMIT_COUNT
+    };
+
+    /**
+     * Subclass API for defining limits of different types.
+     * Subclasses must implement this method to return limits for the
+     * following fields:
+     *
+     * <pre>UCAL_ERA
+     * UCAL_YEAR
+     * UCAL_MONTH
+     * UCAL_WEEK_OF_YEAR
+     * UCAL_WEEK_OF_MONTH
+     * UCAL_DATE (DAY_OF_MONTH on Java)
+     * UCAL_DAY_OF_YEAR
+     * UCAL_DAY_OF_WEEK_IN_MONTH
+     * UCAL_YEAR_WOY
+     * UCAL_EXTENDED_YEAR</pre>
+     *
+     * @param field one of the above field numbers
+     * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
+     * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
+     * @internal
+     */
+    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;
+
+    /**
+     * Return a limit for a field.
+     * @param field the field, from <code>0..UCAL_MAX_FIELD</code>
+     * @param limitType the type specifier for the limit
+     * @see #ELimitType
+     * @internal
+     */
+    virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;
+
+
+    /**
+     * Return the Julian day number of day before the first day of the
+     * given month in the given extended year.  Subclasses should override
+     * this method to implement their calendar system.
+     * @param eyear the extended year
+     * @param month the zero-based month, or 0 if useMonth is false
+     * @param useMonth if false, compute the day before the first day of
+     * the given year, otherwise, compute the day before the first day of
+     * the given month
+     * @return the Julian day number of the day before the first
+     * day of the given month and year
+     * @internal
+     */
+    virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
+                                                   UBool useMonth) const  = 0;
+
+    /**
+     * Return the number of days in the given month of the given extended
+     * year of this calendar system.  Subclasses should override this
+     * method if they can provide a more correct or more efficient
+     * implementation than the default implementation in Calendar.
+     * @internal
+     */
+    virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const ;
+
+    /**
+     * Return the number of days in the given extended year of this
+     * calendar system.  Subclasses should override this method if they can
+     * provide a more correct or more efficient implementation than the
+     * default implementation in Calendar.
+     * @stable ICU 2.0
+     */
+    virtual int32_t handleGetYearLength(int32_t eyear) const;
+
+
+    /**
+     * Return the extended year defined by the current fields.  This will
+     * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
+     * as UCAL_ERA) specific to the calendar system, depending on which set of
+     * fields is newer.
+     * @return the extended year
+     * @internal
+     */
+    virtual int32_t handleGetExtendedYear() = 0;
+
+    /**
+     * Subclasses may override this.  This method calls
+     * handleGetMonthLength() to obtain the calendar-specific month
+     * length.
+     * @param bestField which field to use to calculate the date
+     * @return julian day specified by calendar fields.
+     * @internal
+     */
+    virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField);
+
+    /**
+     * Subclasses must override this to convert from week fields
+     * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case
+     * where YEAR, EXTENDED_YEAR are not set.
+     * The Calendar implementation assumes yearWoy is in extended gregorian form
+     * @internal
+     * @return the extended year, UCAL_EXTENDED_YEAR
+     */
+    virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
+
+    /**
+     * Compute the Julian day from fields.  Will determine whether to use
+     * the JULIAN_DAY field directly, or other fields.
+     * @return the julian day
+     * @internal
+     */
+    int32_t computeJulianDay();
+
+    /**
+     * Compute the milliseconds in the day from the fields.  This is a
+     * value from 0 to 23:59:59.999 inclusive, unless fields are out of
+     * range, in which case it can be an arbitrary value.  This value
+     * reflects local zone wall time.
+     * @internal
+     */
+    int32_t computeMillisInDay();
+
+    /**
+     * This method can assume EXTENDED_YEAR has been set.
+     * @param millis milliseconds of the date fields
+     * @param millisInDay milliseconds of the time fields; may be out
+     * or range.
+     * @param ec Output param set to failure code on function return
+     *          when this function fails.
+     * @internal
+     */
+    int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec);
+
+
+    /**
+     * Determine the best stamp in a range.
+     * @param start first enum to look at
+     * @param end last enum to look at
+     * @param bestSoFar stamp prior to function call
+     * @return the stamp value of the best stamp
+     * @internal
+     */
+    int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
+
+    /**
+     * Values for field resolution tables
+     * @see #resolveFields
+     * @internal
+     */
+    enum {
+      /** Marker for end of resolve set (row or group). */
+      kResolveSTOP = -1,
+      /** Value to be bitwised "ORed" against resolve table field values for remapping.  Example: (UCAL_DATE | kResolveRemap) in 1st column will cause 'UCAL_DATE' to be returned, but will not examine the value of UCAL_DATE.  */
+      kResolveRemap = 32
+    };
+
+    /**
+     * Precedence table for Dates
+     * @see #resolveFields
+     * @internal
+     */
+    static const UFieldResolutionTable kDatePrecedence[];
+
+    /**
+     * Precedence table for Year
+     * @see #resolveFields
+     * @internal
+     */
+    static const UFieldResolutionTable kYearPrecedence[];
+
+    /**
+     * Precedence table for Day of Week
+     * @see #resolveFields
+     * @internal
+     */
+    static const UFieldResolutionTable kDOWPrecedence[];
+
+    /**
+     * Given a precedence table, return the newest field combination in
+     * the table, or UCAL_FIELD_COUNT if none is found.
+     *
+     * <p>The precedence table is a 3-dimensional array of integers.  It
+     * may be thought of as an array of groups.  Each group is an array of
+     * lines.  Each line is an array of field numbers.  Within a line, if
+     * all fields are set, then the time stamp of the line is taken to be
+     * the stamp of the most recently set field.  If any field of a line is
+     * unset, then the line fails to match.  Within a group, the line with
+     * the newest time stamp is selected.  The first field of the line is
+     * returned to indicate which line matched.
+     *
+     * <p>In some cases, it may be desirable to map a line to field that
+     * whose stamp is NOT examined.  For example, if the best field is
+     * DAY_OF_WEEK then the DAY_OF_WEEK_IN_MONTH algorithm may be used.  In
+     * order to do this, insert the value <code>kResolveRemap | F</code> at
+     * the start of the line, where <code>F</code> is the desired return
+     * field value.  This field will NOT be examined; it only determines
+     * the return value if the other fields in the line are the newest.
+     *
+     * <p>If all lines of a group contain at least one unset field, then no
+     * line will match, and the group as a whole will fail to match.  In
+     * that case, the next group will be processed.  If all groups fail to
+     * match, then UCAL_FIELD_COUNT is returned.
+     * @internal
+     */
+    UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable);
+
+
+    /**
+     * @internal
+     */
+    virtual const UFieldResolutionTable* getFieldResolutionTable() const;
+
+    /**
+     * Return the field that is newer, either defaultField, or
+     * alternateField.  If neither is newer or neither is set, return defaultField.
+     * @internal
+     */
+    UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const;
+
+
+private:
+    /**
+     * Helper function for calculating limits by trial and error
+     * @param field The field being investigated
+     * @param startValue starting (least max) value of field
+     * @param endValue ending (greatest max) value of field
+     * @param status return type
+     * @internal
+     */
+    int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
+
+
+protected:
+    /**
+     * The flag which indicates if the current time is set in the calendar.
+     * @stable ICU 2.0
+     */
+    UBool      fIsTimeSet;
+
+    /**
+     * True if the fields are in sync with the currently set time of this Calendar.
+     * If false, then the next attempt to get the value of a field will
+     * force a recomputation of all fields from the current value of the time
+     * field.
+     * <P>
+     * This should really be named areFieldsInSync, but the old name is retained
+     * for backward compatibility.
+     * @stable ICU 2.0
+     */
+    UBool      fAreFieldsSet;
+
+    /**
+     * True if all of the fields have been set.  This is initially false, and set to
+     * true by computeFields().
+     * @stable ICU 2.0
+     */
+    UBool      fAreAllFieldsSet;
+
+    /**
+     * True if all fields have been virtually set, but have not yet been
+     * computed.  This occurs only in setTimeInMillis().  A calendar set
+     * to this state will compute all fields from the time if it becomes
+     * necessary, but otherwise will delay such computation.
+     * @stable ICU 3.0
+     */
+    UBool fAreFieldsVirtuallySet;
+
+    /**
+     * Get the current time without recomputing.
+     *
+     * @return     the current time without recomputing.
+     * @stable ICU 2.0
+     */
+    UDate        internalGetTime(void) const     { return fTime; }
+
+    /**
+     * Set the current time without affecting flags or fields.
+     *
+     * @param time    The time to be set
+     * @return        the current time without recomputing.
+     * @stable ICU 2.0
+     */
+    void        internalSetTime(UDate time)     { fTime = time; }
+
+    /**
+     * The time fields containing values into which the millis is computed.
+     * @stable ICU 2.0
+     */
+    int32_t     fFields[UCAL_FIELD_COUNT];
+
+    /**
+     * The flags which tell if a specified time field for the calendar is set.
+     * @deprecated ICU 2.8 use (fStamp[n]!=kUnset)
+     */
+    UBool      fIsSet[UCAL_FIELD_COUNT];
+
+    /** Special values of stamp[]
+     * @stable ICU 2.0
+     */
+    enum {
+        kUnset                 = 0,
+        kInternallySet,
+        kMinimumUserStamp
+    };
+
+    /**
+     * Pseudo-time-stamps which specify when each field was set. There
+     * are two special values, UNSET and INTERNALLY_SET. Values from
+     * MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values.
+     * @stable ICU 2.0
+     */
+    int32_t        fStamp[UCAL_FIELD_COUNT];
+
+    /**
+     * Subclasses may override this method to compute several fields
+     * specific to each calendar system.  These are:
+     *
+     * <ul><li>ERA
+     * <li>YEAR
+     * <li>MONTH
+     * <li>DAY_OF_MONTH
+     * <li>DAY_OF_YEAR
+     * <li>EXTENDED_YEAR</ul>
+     *
+     * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which
+     * will be set when this method is called.  Subclasses can also call
+     * the getGregorianXxx() methods to obtain Gregorian calendar
+     * equivalents for the given Julian day.
+     *
+     * <p>In addition, subclasses should compute any subclass-specific
+     * fields, that is, fields from BASE_FIELD_COUNT to
+     * getFieldCount() - 1.
+     *
+     * <p>The default implementation in <code>Calendar</code> implements
+     * a pure proleptic Gregorian calendar.
+     * @internal
+     */
+    virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
+
+    /**
+     * Return the extended year on the Gregorian calendar as computed by
+     * <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianYear() const {
+        return fGregorianYear;
+    }
+
+    /**
+     * Return the month (0-based) on the Gregorian calendar as computed by
+     * <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianMonth() const {
+        return fGregorianMonth;
+    }
+
+    /**
+     * Return the day of year (1-based) on the Gregorian calendar as
+     * computed by <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianDayOfYear() const {
+        return fGregorianDayOfYear;
+    }
+
+    /**
+     * Return the day of month (1-based) on the Gregorian calendar as
+     * computed by <code>computeGregorianFields()</code>.
+     * @internal
+     */
+    int32_t getGregorianDayOfMonth() const {
+      return fGregorianDayOfMonth;
+    }
+
+    /**
+     * Called by computeJulianDay.  Returns the default month (0-based) for the year,
+     * taking year and era into account.  Defaults to 0 for Gregorian, which doesn't care.
+     * @internal
+     * @internal
+     */
+    virtual int32_t getDefaultMonthInYear() ;
+
+
+    /**
+     * Called by computeJulianDay.  Returns the default day (1-based) for the month,
+     * taking currently-set year and era into account.  Defaults to 1 for Gregorian.
+     * @internal
+     */
+    virtual int32_t getDefaultDayInMonth(int32_t /*month*/);
+
+    //-------------------------------------------------------------------------
+    // Protected utility methods for use by subclasses.  These are very handy
+    // for implementing add, roll, and computeFields.
+    //-------------------------------------------------------------------------
+
+    /**
+     * Adjust the specified field so that it is within
+     * the allowable range for the date to which this calendar is set.
+     * For example, in a Gregorian calendar pinning the {@link #UCalendarDateFields DAY_OF_MONTH}
+     * field for a calendar set to April 31 would cause it to be set
+     * to April 30.
+     * <p>
+     * <b>Subclassing:</b>
+     * <br>
+     * This utility method is intended for use by subclasses that need to implement
+     * their own overrides of {@link #roll roll} and {@link #add add}.
+     * <p>
+     * <b>Note:</b>
+     * <code>pinField</code> is implemented in terms of
+     * {@link #getActualMinimum getActualMinimum}
+     * and {@link #getActualMaximum getActualMaximum}.  If either of those methods uses
+     * a slow, iterative algorithm for a particular field, it would be
+     * unwise to attempt to call <code>pinField</code> for that field.  If you
+     * really do need to do so, you should override this method to do
+     * something more efficient for that field.
+     * <p>
+     * @param field The calendar field whose value should be pinned.
+     * @param status Output param set to failure code on function return
+     *          when this function fails.
+     *
+     * @see #getActualMinimum
+     * @see #getActualMaximum
+     * @stable ICU 2.0
+     */
+    virtual void pinField(UCalendarDateFields field, UErrorCode& status);
+
+    /**
+     * Return the week number of a day, within a period. This may be the week number in
+     * a year or the week number in a month. Usually this will be a value >= 1, but if
+     * some initial days of the period are excluded from week 1, because
+     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1, then
+     * the week number will be zero for those
+     * initial days. This method requires the day number and day of week for some
+     * known date in the period in order to determine the day of week
+     * on the desired day.
+     * <p>
+     * <b>Subclassing:</b>
+     * <br>
+     * This method is intended for use by subclasses in implementing their
+     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
+     * It is often useful in {@link #getActualMinimum getActualMinimum} and
+     * {@link #getActualMaximum getActualMaximum} as well.
+     * <p>
+     * This variant is handy for computing the week number of some other
+     * day of a period (often the first or last day of the period) when its day
+     * of the week is not known but the day number and day of week for some other
+     * day in the period (e.g. the current date) <em>is</em> known.
+     * <p>
+     * @param desiredDay    The {@link #UCalendarDateFields DAY_OF_YEAR} or
+     *              {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
+     *              Should be 1 for the first day of the period.
+     *
+     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR}
+     *              or {@link #UCalendarDateFields DAY_OF_MONTH} for a day in the period whose
+     *              {@link #UCalendarDateFields DAY_OF_WEEK} is specified by the
+     *              <code>knownDayOfWeek</code> parameter.
+     *              Should be 1 for first day of period.
+     *
+     * @param dayOfWeek  The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
+     *              corresponding to the <code>knownDayOfPeriod</code> parameter.
+     *              1-based with 1=Sunday.
+     *
+     * @return      The week number (one-based), or zero if the day falls before
+     *              the first week because
+     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
+     *              is more than one.
+     *
+     * @stable ICU 2.8
+     */
+    int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);
+
+
+    /**
+     * Return the week number of a day, within a period. This may be the week number in
+     * a year, or the week number in a month. Usually this will be a value >= 1, but if
+     * some initial days of the period are excluded from week 1, because
+     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1,
+     * then the week number will be zero for those
+     * initial days. This method requires the day of week for the given date in order to
+     * determine the result.
+     * <p>
+     * <b>Subclassing:</b>
+     * <br>
+     * This method is intended for use by subclasses in implementing their
+     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
+     * It is often useful in {@link #getActualMinimum getActualMinimum} and
+     * {@link #getActualMaximum getActualMaximum} as well.
+     * <p>
+     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR} or
+     *                      {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
+     *                      Should be 1 for the first day of the period.
+     *
+     * @param dayOfWeek     The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
+     *                      corresponding to the <code>dayOfPeriod</code> parameter.
+     *                      1-based with 1=Sunday.
+     *
+     * @return      The week number (one-based), or zero if the day falls before
+     *              the first week because
+     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
+     *              is more than one.
+     * @internal
+     */
+    inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
+
+    /**
+     * returns the local DOW, valid range 0..6
+     * @internal
+     */
+    int32_t getLocalDOW();
+
+private:
+
+    /**
+     * The next available value for fStamp[]
+     */
+    int32_t fNextStamp;// = MINIMUM_USER_STAMP;
+
+    /**
+     * The current time set for the calendar.
+     */
+    UDate        fTime;
+
+    /**
+     * @see   #setLenient
+     */
+    UBool      fLenient;
+
+    /**
+     * Time zone affects the time calculation done by Calendar. Calendar subclasses use
+     * the time zone data to produce the local time.
+     */
+    TimeZone*   fZone;
+
+    /**
+     * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. They are
+     * used to figure out the week count for a specific date for a given locale. These
+     * must be set when a Calendar is constructed. For example, in US locale,
+     * firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. They are used to figure
+     * out the week count for a specific date for a given locale. These must be set when
+     * a Calendar is constructed.
+     */
+    UCalendarDaysOfWeek fFirstDayOfWeek;
+    uint8_t     fMinimalDaysInFirstWeek;
+
+    /**
+     * Sets firstDayOfWeek and minimalDaysInFirstWeek. Called at Calendar construction
+     * time.
+     *
+     * @param desiredLocale  The given locale.
+     * @param type           The calendar type identifier, e.g: gregorian, buddhist, etc.
+     * @param success        Indicates the status of setting the week count data from
+     *                       the resource for the given locale. Returns U_ZERO_ERROR if
+     *                       constructed successfully.
+     */
+    void        setWeekCountData(const Locale& desiredLocale, const char *type, UErrorCode& success);
+
+    /**
+     * Recompute the time and update the status fields isTimeSet
+     * and areFieldsSet.  Callers should check isTimeSet and only
+     * call this method if isTimeSet is false.
+     *
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid or restricted by
+     *                leniency, this will be set to an error status.
+     */
+    void updateTime(UErrorCode& status);
+
+    /**
+     * The Gregorian year, as computed by computeGregorianFields() and
+     * returned by getGregorianYear().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianYear;
+
+    /**
+     * The Gregorian month, as computed by computeGregorianFields() and
+     * returned by getGregorianMonth().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianMonth;
+
+    /**
+     * The Gregorian day of the year, as computed by
+     * computeGregorianFields() and returned by getGregorianDayOfYear().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianDayOfYear;
+
+    /**
+     * The Gregorian day of the month, as computed by
+     * computeGregorianFields() and returned by getGregorianDayOfMonth().
+     * @see #computeGregorianFields
+     */
+    int32_t fGregorianDayOfMonth;
+
+    /* calculations */
+
+    /**
+     * Compute the Gregorian calendar year, month, and day of month from
+     * the given Julian day.  These values are not stored in fields, but in
+     * member variables gregorianXxx.  Also compute the DAY_OF_WEEK and
+     * DOW_LOCAL fields.
+     */
+    void computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec);
+
+	protected:
+
+    /**
+     * Compute the Gregorian calendar year, month, and day of month from the
+     * Julian day.  These values are not stored in fields, but in member
+     * variables gregorianXxx.  They are used for time zone computations and by
+     * subclasses that are Gregorian derivatives.  Subclasses may call this
+     * method to perform a Gregorian calendar millis->fields computation.
+     * To perform a Gregorian calendar fields->millis computation, call
+     * computeGregorianMonthStart().
+     * @see #computeGregorianMonthStart
+     */
+    void computeGregorianFields(int32_t julianDay, UErrorCode &ec);
+
+	private:
+
+    /**
+     * Compute the fields WEEK_OF_YEAR, YEAR_WOY, WEEK_OF_MONTH,
+     * DAY_OF_WEEK_IN_MONTH, and DOW_LOCAL from EXTENDED_YEAR, YEAR,
+     * DAY_OF_WEEK, and DAY_OF_YEAR.  The latter fields are computed by the
+     * subclass based on the calendar system.
+     *
+     * <p>The YEAR_WOY field is computed simplistically.  It is equal to YEAR
+     * most of the time, but at the year boundary it may be adjusted to YEAR-1
+     * or YEAR+1 to reflect the overlap of a week into an adjacent year.  In
+     * this case, a simple increment or decrement is performed on YEAR, even
+     * though this may yield an invalid YEAR value.  For instance, if the YEAR
+     * is part of a calendar system with an N-year cycle field CYCLE, then
+     * incrementing the YEAR may involve incrementing CYCLE and setting YEAR
+     * back to 0 or 1.  This is not handled by this code, and in fact cannot be
+     * simply handled without having subclasses define an entire parallel set of
+     * fields for fields larger than or equal to a year.  This additional
+     * complexity is not warranted, since the intention of the YEAR_WOY field is
+     * to support ISO 8601 notation, so it will typically be used with a
+     * proleptic Gregorian calendar, which has no field larger than a year.
+     */
+    void computeWeekFields(UErrorCode &ec);
+
+
+    /**
+     * Ensure that each field is within its valid range by calling {@link
+     * #validateField(int, int&)} on each field that has been set.  This method
+     * should only be called if this calendar is not lenient.
+     * @see #isLenient
+     * @see #validateField(int, int&)
+     * @internal
+     */
+    void validateFields(UErrorCode &status);
+
+    /**
+     * Validate a single field of this calendar.  Subclasses should
+     * override this method to validate any calendar-specific fields.
+     * Generic fields can be handled by
+     * <code>Calendar.validateField()</code>.
+     * @see #validateField(int, int, int, int&)
+     * @internal
+     */
+    virtual void validateField(UCalendarDateFields field, UErrorCode &status);
+
+    /**
+     * Validate a single field of this calendar given its minimum and
+     * maximum allowed value.  If the field is out of range,
+     * <code>U_ILLEGAL_ARGUMENT_ERROR</code> will be set.  Subclasses may
+     * use this method in their implementation of {@link
+     * #validateField(int, int&)}.
+     * @internal
+     */
+    void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
+
+ protected:
+    /**
+     * Convert a quasi Julian date to the day of the week. The Julian date used here is
+     * not a true Julian date, since it is measured from midnight, not noon. Return
+     * value is one-based.
+     *
+     * @param julian  The given Julian date number.
+     * @return   Day number from 1..7 (SUN..SAT).
+     * @internal
+     */
+    static uint8_t julianDayToDayOfWeek(double julian);
+
+ private:
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+
+ public:
+#if !UCONFIG_NO_SERVICE
+    /**
+     * INTERNAL FOR 2.6 --  Registration.
+     */
+
+    /**
+     * Return a StringEnumeration over the locales available at the time of the call,
+     * including registered locales.
+     * @return a StringEnumeration over the locales available at the time of the call
+     * @internal
+     */
+    static StringEnumeration* getAvailableLocales(void);
+
+    /**
+     * Register a new Calendar factory.  The factory will be adopted.
+     * INTERNAL in 2.6
+     * @param toAdopt the factory instance to be adopted
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this factory
+     * @internal
+     */
+    static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);
+
+    /**
+     * Unregister a previously-registered CalendarFactory using the key returned from the
+     * register call.  Key becomes invalid after a successful call and should not be used again.
+     * The CalendarFactory corresponding to the key will be deleted.
+     * INTERNAL in 2.6
+     * @param key the registry key returned by a previous call to registerFactory
+     * @param status the in/out status code, no special meanings are assigned
+     * @return TRUE if the factory for the key was successfully unregistered
+     * @internal
+     */
+    static UBool unregister(URegistryKey key, UErrorCode& status);
+
+    /**
+     * Multiple Calendar Implementation
+     * @internal
+     */
+    friend class CalendarFactory;
+
+    /**
+     * Multiple Calendar Implementation
+     * @internal
+     */
+    friend class CalendarService;
+
+    /**
+     * Multiple Calendar Implementation
+     * @internal
+     */
+    friend class DefaultCalendarFactory;
+#endif /* !UCONFIG_NO_SERVICE */
+
+    /**
+     * @internal
+     * @return TRUE if this calendar has a default century (i.e. 03 -> 2003)
+     */
+    virtual UBool haveDefaultCentury() const = 0;
+
+    /**
+     * @internal
+     * @return the start of the default century, as a UDate
+     */
+    virtual UDate defaultCenturyStart() const = 0;
+    /**
+     * @internal
+     * @return the beginning year of the default century, as a year
+     */
+    virtual int32_t defaultCenturyStartYear() const = 0;
+
+    /** Get the locale for this calendar object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual)
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const;
+
+    /** Get the locale for this calendar object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual)
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @internal
+     */
+    const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
+
+};
+
+// -------------------------------------
+
+inline Calendar*
+Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode)
+{
+    // since the Locale isn't specified, use the default locale
+    return createInstance(zone, Locale::getDefault(), errorCode);
+}
+
+// -------------------------------------
+
+inline void
+Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)
+{
+    roll(field, (int32_t)(up ? +1 : -1), status);
+}
+
+inline void
+Calendar::roll(EDateFields field, UBool up, UErrorCode& status)
+{
+    roll((UCalendarDateFields) field, up, status);
+}
+
+
+// -------------------------------------
+
+/**
+ * Fast method for subclasses.  The caller must maintain fUserSetDSTOffset and
+ * fUserSetZoneOffset, as well as the isSet[] array.
+ */
+
+inline void
+Calendar::internalSet(UCalendarDateFields field, int32_t value)
+{
+    fFields[field] = value;
+    fStamp[field] = kInternallySet;
+    fIsSet[field]     = TRUE; // Remove later
+}
+
+inline int32_t  Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
+{
+  return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);
+}
+
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _CALENDAR
diff --git a/CoreFoundation/icu/unicode/caniter.h b/CoreFoundation/icu/unicode/caniter.h
new file mode 100644
index 0000000..84a6595
--- /dev/null
+++ b/CoreFoundation/icu/unicode/caniter.h
@@ -0,0 +1,201 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 1996-2006, International Business Machines Corporation and    *
+ * others. All Rights Reserved.                                                *
+ *******************************************************************************
+ */
+
+#ifndef CANITER_H
+#define CANITER_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_NORMALIZATION
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+
+/**
+ * \file
+ * \brief C++ API: Canonical Iterator
+ */
+ 
+/** Should permutation skip characters with combining class zero
+ *  Should be either TRUE or FALSE. This is a compile time option
+ *  @stable ICU 2.4
+ */
+#ifndef CANITER_SKIP_ZEROES
+#define CANITER_SKIP_ZEROES TRUE
+#endif
+
+U_NAMESPACE_BEGIN
+
+class Hashtable;
+
+/**
+ * This class allows one to iterate through all the strings that are canonically equivalent to a given
+ * string. For example, here are some sample results:
+Results for: {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+1: \\u0041\\u030A\\u0064\\u0307\\u0327
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+2: \\u0041\\u030A\\u0064\\u0327\\u0307
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
+3: \\u0041\\u030A\\u1E0B\\u0327
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
+4: \\u0041\\u030A\\u1E11\\u0307
+ = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
+5: \\u00C5\\u0064\\u0307\\u0327
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+6: \\u00C5\\u0064\\u0327\\u0307
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
+7: \\u00C5\\u1E0B\\u0327
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
+8: \\u00C5\\u1E11\\u0307
+ = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
+9: \\u212B\\u0064\\u0307\\u0327
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
+10: \\u212B\\u0064\\u0327\\u0307
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
+11: \\u212B\\u1E0B\\u0327
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
+12: \\u212B\\u1E11\\u0307
+ = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
+ *<br>Note: the code is intended for use with small strings, and is not suitable for larger ones,
+ * since it has not been optimized for that situation.
+ * Note, CanonicalIterator is not intended to be subclassed.
+ * @author M. Davis
+ * @author C++ port by V. Weinstein
+ * @stable ICU 2.4
+ */
+class U_COMMON_API CanonicalIterator : public UObject {
+public:
+    /**
+     * Construct a CanonicalIterator object
+     * @param source    string to get results for
+     * @param status    Fill-in parameter which receives the status of this operation.
+     * @stable ICU 2.4
+     */
+    CanonicalIterator(const UnicodeString &source, UErrorCode &status);
+
+    /** Destructor
+     *  Cleans pieces
+     * @stable ICU 2.4
+     */
+    virtual ~CanonicalIterator();
+
+    /**
+     * Gets the NFD form of the current source we are iterating over.
+     * @return gets the source: NOTE: it is the NFD form of source
+     * @stable ICU 2.4
+     */
+    UnicodeString getSource();
+
+    /**
+     * Resets the iterator so that one can start again from the beginning.
+     * @stable ICU 2.4
+     */
+    void reset();
+
+    /**
+     * Get the next canonically equivalent string.
+     * <br><b>Warning: The strings are not guaranteed to be in any particular order.</b>
+     * @return the next string that is canonically equivalent. A bogus string is returned when
+     * the iteration is done.
+     * @stable ICU 2.4
+     */
+    UnicodeString next();
+
+    /**
+     * Set a new source for this iterator. Allows object reuse.
+     * @param newSource     the source string to iterate against. This allows the same iterator to be used
+     *                     while changing the source string, saving object creation.
+     * @param status        Fill-in parameter which receives the status of this operation.
+     * @stable ICU 2.4
+     */
+    void setSource(const UnicodeString &newSource, UErrorCode &status);
+
+    /**
+     * Dumb recursive implementation of permutation.
+     * TODO: optimize
+     * @param source     the string to find permutations for
+     * @param skipZeros  determine if skip zeros
+     * @param result     the results in a set.
+     * @param status       Fill-in parameter which receives the status of this operation.
+     * @internal
+     */
+    static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+private:
+    // ===================== PRIVATES ==============================
+    // private default constructor
+    CanonicalIterator();
+
+
+    /**
+     * Copy constructor. Private for now.
+     * @internal
+     */
+    CanonicalIterator(const CanonicalIterator& other);
+
+    /**
+     * Assignment operator. Private for now.
+     * @internal
+     */
+    CanonicalIterator& operator=(const CanonicalIterator& other);
+
+    // fields
+    UnicodeString source;
+    UBool done;
+
+    // 2 dimensional array holds the pieces of the string with
+    // their different canonically equivalent representations
+    UnicodeString **pieces;
+    int32_t pieces_length;
+    int32_t *pieces_lengths;
+
+    // current is used in iterating to combine pieces
+    int32_t *current;
+    int32_t current_length;
+
+    // transient fields
+    UnicodeString buffer;
+
+    // we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
+    UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
+
+    //Set getEquivalents2(String segment);
+    Hashtable *getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status);
+    //Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
+
+    /**
+     * See if the decomposition of cp2 is at segment starting at segmentPos
+     * (with canonical rearrangment!)
+     * If so, take the remainder, and return the equivalents
+     */
+    //Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
+    Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
+    //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
+
+    void cleanPieces();
+
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_NORMALIZATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/chariter.h b/CoreFoundation/icu/unicode/chariter.h
new file mode 100644
index 0000000..12fc924
--- /dev/null
+++ b/CoreFoundation/icu/unicode/chariter.h
@@ -0,0 +1,716 @@
+/*
+********************************************************************
+*
+*   Copyright (C) 1997-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+********************************************************************
+*/
+
+#ifndef CHARITER_H
+#define CHARITER_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+/**
+ * \file
+ * \brief C++ API: Character Iterator
+ */
+ 
+U_NAMESPACE_BEGIN
+/**
+ * Abstract class that defines an API for forward-only iteration
+ * on text objects.
+ * This is a minimal interface for iteration without random access
+ * or backwards iteration. It is especially useful for wrapping
+ * streams with converters into an object for collation or
+ * normalization.
+ *
+ * <p>Characters can be accessed in two ways: as code units or as
+ * code points.
+ * Unicode code points are 21-bit integers and are the scalar values
+ * of Unicode characters. ICU uses the type UChar32 for them.
+ * Unicode code units are the storage units of a given
+ * Unicode/UCS Transformation Format (a character encoding scheme).
+ * With UTF-16, all code points can be represented with either one
+ * or two code units ("surrogates").
+ * String storage is typically based on code units, while properties
+ * of characters are typically determined using code point values.
+ * Some processes may be designed to work with sequences of code units,
+ * or it may be known that all characters that are important to an
+ * algorithm can be represented with single code units.
+ * Other processes will need to use the code point access functions.</p>
+ *
+ * <p>ForwardCharacterIterator provides nextPostInc() to access
+ * a code unit and advance an internal position into the text object,
+ * similar to a <code>return text[position++]</code>.<br>
+ * It provides next32PostInc() to access a code point and advance an internal
+ * position.</p>
+ *
+ * <p>next32PostInc() assumes that the current position is that of
+ * the beginning of a code point, i.e., of its first code unit.
+ * After next32PostInc(), this will be true again.
+ * In general, access to code units and code points in the same
+ * iteration loop should not be mixed. In UTF-16, if the current position
+ * is on a second code unit (Low Surrogate), then only that code unit
+ * is returned even by next32PostInc().</p>
+ *
+ * <p>For iteration with either function, there are two ways to
+ * check for the end of the iteration. When there are no more
+ * characters in the text object:
+ * <ul>
+ * <li>The hasNext() function returns FALSE.</li>
+ * <li>nextPostInc() and next32PostInc() return DONE
+ *     when one attempts to read beyond the end of the text object.</li>
+ * </ul>
+ *
+ * Example:
+ * \code 
+ * void function1(ForwardCharacterIterator &it) {
+ *     UChar32 c;
+ *     while(it.hasNext()) {
+ *         c=it.next32PostInc();
+ *         // use c
+ *     }
+ * }
+ *
+ * void function1(ForwardCharacterIterator &it) {
+ *     UChar c;
+ *     while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
+ *         // use c
+ *      }
+ *  }
+ * \endcode
+ * </p>
+ *
+ * @stable ICU 2.0
+ */
+class U_COMMON_API ForwardCharacterIterator : public UObject {
+public:
+    /**
+     * Value returned by most of ForwardCharacterIterator's functions
+     * when the iterator has reached the limits of its iteration.
+     * @stable ICU 2.0
+     */
+    enum { DONE = 0xffff };
+    
+    /**
+     * Destructor.  
+     * @stable ICU 2.0
+     */
+    virtual ~ForwardCharacterIterator();
+    
+    /**
+     * Returns true when both iterators refer to the same
+     * character in the same character-storage object.  
+     * @param that The ForwardCharacterIterator to be compared for equality
+     * @return true when both iterators refer to the same
+     * character in the same character-storage object
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
+    
+    /**
+     * Returns true when the iterators refer to different
+     * text-storage objects, or to different characters in the
+     * same text-storage object.  
+     * @param that The ForwardCharacterIterator to be compared for inequality
+     * @return true when the iterators refer to different
+     * text-storage objects, or to different characters in the
+     * same text-storage object
+     * @stable ICU 2.0
+     */
+    inline UBool operator!=(const ForwardCharacterIterator& that) const;
+    
+    /**
+     * Generates a hash code for this iterator.  
+     * @return the hash code.
+     * @stable ICU 2.0
+     */
+    virtual int32_t hashCode(void) const = 0;
+    
+    /**
+     * Returns a UClassID for this ForwardCharacterIterator ("poor man's
+     * RTTI").<P> Despite the fact that this function is public,
+     * DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API! 
+     * @return a UClassID for this ForwardCharacterIterator 
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+    
+    /**
+     * Gets the current code unit for returning and advances to the next code unit
+     * in the iteration range
+     * (toward endIndex()).  If there are
+     * no more code units to return, returns DONE.
+     * @return the current code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         nextPostInc(void) = 0;
+    
+    /**
+     * Gets the current code point for returning and advances to the next code point
+     * in the iteration range
+     * (toward endIndex()).  If there are
+     * no more code points to return, returns DONE.
+     * @return the current code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       next32PostInc(void) = 0;
+    
+    /**
+     * Returns FALSE if there are no more code units or code points
+     * at or after the current position in the iteration range.
+     * This is used with nextPostInc() or next32PostInc() in forward
+     * iteration.
+     * @returns FALSE if there are no more code units or code points
+     * at or after the current position in the iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UBool        hasNext() = 0;
+    
+protected:
+    /** Default constructor to be overridden in the implementing class. @stable ICU 2.0*/
+    ForwardCharacterIterator();
+    
+    /** Copy constructor to be overridden in the implementing class. @stable ICU 2.0*/
+    ForwardCharacterIterator(const ForwardCharacterIterator &other);
+    
+    /**
+     * Assignment operator to be overridden in the implementing class.
+     * @stable ICU 2.0
+     */
+    ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
+};
+
+/**
+ * Abstract class that defines an API for iteration
+ * on text objects.
+ * This is an interface for forward and backward iteration
+ * and random access into a text object.
+ *
+ * <p>The API provides backward compatibility to the Java and older ICU
+ * CharacterIterator classes but extends them significantly:
+ * <ol>
+ * <li>CharacterIterator is now a subclass of ForwardCharacterIterator.</li>
+ * <li>While the old API functions provided forward iteration with
+ *     "pre-increment" semantics, the new one also provides functions
+ *     with "post-increment" semantics. They are more efficient and should
+ *     be the preferred iterator functions for new implementations.
+ *     The backward iteration always had "pre-decrement" semantics, which
+ *     are efficient.</li>
+ * <li>Just like ForwardCharacterIterator, it provides access to
+ *     both code units and code points. Code point access versions are available
+ *     for the old and the new iteration semantics.</li>
+ * <li>There are new functions for setting and moving the current position
+ *     without returning a character, for efficiency.</li>
+ * </ol>
+ *
+ * See ForwardCharacterIterator for examples for using the new forward iteration
+ * functions. For backward iteration, there is also a hasPrevious() function
+ * that can be used analogously to hasNext().
+ * The old functions work as before and are shown below.</p>
+ *
+ * <p>Examples for some of the new functions:</p>
+ *
+ * Forward iteration with hasNext():
+ * \code
+ * void forward1(CharacterIterator &it) {
+ *     UChar32 c;
+ *     for(it.setToStart(); it.hasNext();) {
+ *         c=it.next32PostInc();
+ *         // use c
+ *     }
+ *  }
+ * \endcode
+ * Forward iteration more similar to loops with the old forward iteration,
+ * showing a way to convert simple for() loops:
+ * \code
+ * void forward2(CharacterIterator &it) {
+ *     UChar c;
+ *     for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {
+ *          // use c
+ *      }
+ * }
+ * \endcode
+ * Backward iteration with setToEnd() and hasPrevious():
+ * \code
+ *  void backward1(CharacterIterator &it) {
+ *      UChar32 c;
+ *      for(it.setToEnd(); it.hasPrevious();) {
+ *         c=it.previous32();
+ *          // use c
+ *      }
+ *  }
+ * \endcode
+ * Backward iteration with a more traditional for() loop:
+ * \code
+ * void backward2(CharacterIterator &it) {
+ *     UChar c;
+ *     for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {
+ *         // use c
+ *      }
+ *  }
+ * \endcode
+ *
+ * Example for random access:
+ * \code
+ *  void random(CharacterIterator &it) {
+ *      // set to the third code point from the beginning
+ *      it.move32(3, CharacterIterator::kStart);
+ *      // get a code point from here without moving the position
+ *      UChar32 c=it.current32();
+ *      // get the position
+ *      int32_t pos=it.getIndex();
+ *      // get the previous code unit
+ *      UChar u=it.previous();
+ *      // move back one more code unit
+ *      it.move(-1, CharacterIterator::kCurrent);
+ *      // set the position back to where it was
+ *      // and read the same code point c and move beyond it
+ *      it.setIndex(pos);
+ *      if(c!=it.next32PostInc()) {
+ *          exit(1); // CharacterIterator inconsistent
+ *      }
+ *  }
+ * \endcode
+ *
+ * <p>Examples, especially for the old API:</p>
+ *
+ * Function processing characters, in this example simple output
+ * <pre>
+ * \code
+ *  void processChar( UChar c )
+ *  {
+ *      cout << " " << c;
+ *  }
+ * \endcode
+ * </pre>
+ * Traverse the text from start to finish
+ * <pre> 
+ * \code
+ *  void traverseForward(CharacterIterator& iter)
+ *  {
+ *      for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
+ *          processChar(c);
+ *      }
+ *  }
+ * \endcode
+ * </pre>
+ * Traverse the text backwards, from end to start
+ * <pre>
+ * \code
+ *  void traverseBackward(CharacterIterator& iter)
+ *  {
+ *      for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
+ *          processChar(c);
+ *      }
+ *  }
+ * \endcode
+ * </pre>
+ * Traverse both forward and backward from a given position in the text. 
+ * Calls to notBoundary() in this example represents some additional stopping criteria.
+ * <pre>
+ * \code
+ * void traverseOut(CharacterIterator& iter, int32_t pos)
+ * {
+ *      UChar c;
+ *      for (c = iter.setIndex(pos);
+ *      c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
+ *          c = iter.next()) {}
+ *      int32_t end = iter.getIndex();
+ *      for (c = iter.setIndex(pos);
+ *          c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
+ *          c = iter.previous()) {}
+ *      int32_t start = iter.getIndex() + 1;
+ *  
+ *      cout << "start: " << start << " end: " << end << endl;
+ *      for (c = iter.setIndex(start); iter.getIndex() < end; c = iter.next() ) {
+ *          processChar(c);
+ *     }
+ *  }
+ * \endcode
+ * </pre>
+ * Creating a StringCharacterIterator and calling the test functions
+ * <pre>
+ * \code
+ *  void CharacterIterator_Example( void )
+ *   {
+ *       cout << endl << "===== CharacterIterator_Example: =====" << endl;
+ *       UnicodeString text("Ein kleiner Satz.");
+ *       StringCharacterIterator iterator(text);
+ *       cout << "----- traverseForward: -----------" << endl;
+ *       traverseForward( iterator );
+ *       cout << endl << endl << "----- traverseBackward: ----------" << endl;
+ *       traverseBackward( iterator );
+ *       cout << endl << endl << "----- traverseOut: ---------------" << endl;
+ *       traverseOut( iterator, 7 );
+ *       cout << endl << endl << "-----" << endl;
+ *   }
+ * \endcode
+ * </pre>
+ *
+ * @stable ICU 2.0
+ */
+class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
+public:
+    /**
+     * Origin enumeration for the move() and move32() functions.
+     * @stable ICU 2.0
+     */
+    enum EOrigin { kStart, kCurrent, kEnd };
+
+    /**
+     * Returns a pointer to a new CharacterIterator of the same
+     * concrete class as this one, and referring to the same
+     * character in the same text-storage object as this one.  The
+     * caller is responsible for deleting the new clone.  
+     * @return a pointer to a new CharacterIterator
+     * @stable ICU 2.0
+     */
+    virtual CharacterIterator* clone(void) const = 0;
+
+    /**
+     * Sets the iterator to refer to the first code unit in its
+     * iteration range, and returns that code unit.
+     * This can be used to begin an iteration with next().
+     * @return the first code unit in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar         first(void) = 0;
+
+    /**
+     * Sets the iterator to refer to the first code unit in its
+     * iteration range, returns that code unit, and moves the position
+     * to the second code unit. This is an alternative to setToStart()
+     * for forward iteration with nextPostInc().
+     * @return the first code unit in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar         firstPostInc(void);
+
+    /**
+     * Sets the iterator to refer to the first code point in its
+     * iteration range, and returns that code unit,
+     * This can be used to begin an iteration with next32().
+     * Note that an iteration with next32PostInc(), beginning with,
+     * e.g., setToStart() or firstPostInc(), is more efficient.
+     * @return the first code point in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       first32(void) = 0;
+
+    /**
+     * Sets the iterator to refer to the first code point in its
+     * iteration range, returns that code point, and moves the position
+     * to the second code point. This is an alternative to setToStart()
+     * for forward iteration with next32PostInc().
+     * @return the first code point in its iteration range.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       first32PostInc(void);
+
+    /**
+     * Sets the iterator to refer to the first code unit or code point in its
+     * iteration range. This can be used to begin a forward
+     * iteration with nextPostInc() or next32PostInc().
+     * @return the start position of the iteration range
+     * @stable ICU 2.0
+     */
+    inline int32_t    setToStart();
+
+    /**
+     * Sets the iterator to refer to the last code unit in its
+     * iteration range, and returns that code unit.
+     * This can be used to begin an iteration with previous().
+     * @return the last code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         last(void) = 0;
+        
+    /**
+     * Sets the iterator to refer to the last code point in its
+     * iteration range, and returns that code unit.
+     * This can be used to begin an iteration with previous32().
+     * @return the last code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       last32(void) = 0;
+
+    /**
+     * Sets the iterator to the end of its iteration range, just behind
+     * the last code unit or code point. This can be used to begin a backward
+     * iteration with previous() or previous32().
+     * @return the end position of the iteration range
+     * @stable ICU 2.0
+     */
+    inline int32_t    setToEnd();
+
+    /**
+     * Sets the iterator to refer to the "position"-th code unit
+     * in the text-storage object the iterator refers to, and
+     * returns that code unit.  
+     * @param position the "position"-th code unit in the text-storage object
+     * @return the "position"-th code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         setIndex(int32_t position) = 0;
+
+    /**
+     * Sets the iterator to refer to the beginning of the code point
+     * that contains the "position"-th code unit
+     * in the text-storage object the iterator refers to, and
+     * returns that code point.
+     * The current position is adjusted to the beginning of the code point
+     * (its first code unit).
+     * @param position the "position"-th code unit in the text-storage object
+     * @return the "position"-th code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       setIndex32(int32_t position) = 0;
+
+    /**
+     * Returns the code unit the iterator currently refers to. 
+     * @return the current code unit. 
+     * @stable ICU 2.0
+     */
+    virtual UChar         current(void) const = 0;
+        
+    /**
+     * Returns the code point the iterator currently refers to.  
+     * @return the current code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       current32(void) const = 0;
+        
+    /**
+     * Advances to the next code unit in the iteration range
+     * (toward endIndex()), and returns that code unit.  If there are
+     * no more code units to return, returns DONE.
+     * @return the next code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         next(void) = 0;
+        
+    /**
+     * Advances to the next code point in the iteration range
+     * (toward endIndex()), and returns that code point.  If there are
+     * no more code points to return, returns DONE.
+     * Note that iteration with "pre-increment" semantics is less
+     * efficient than iteration with "post-increment" semantics
+     * that is provided by next32PostInc().
+     * @return the next code point.
+     * @stable ICU 2.0
+     */
+    virtual UChar32       next32(void) = 0;
+        
+    /**
+     * Advances to the previous code unit in the iteration range
+     * (toward startIndex()), and returns that code unit.  If there are
+     * no more code units to return, returns DONE.  
+     * @return the previous code unit.
+     * @stable ICU 2.0
+     */
+    virtual UChar         previous(void) = 0;
+
+    /**
+     * Advances to the previous code point in the iteration range
+     * (toward startIndex()), and returns that code point.  If there are
+     * no more code points to return, returns DONE. 
+     * @return the previous code point. 
+     * @stable ICU 2.0
+     */
+    virtual UChar32       previous32(void) = 0;
+
+    /**
+     * Returns FALSE if there are no more code units or code points
+     * before the current position in the iteration range.
+     * This is used with previous() or previous32() in backward
+     * iteration.
+     * @return FALSE if there are no more code units or code points
+     * before the current position in the iteration range, return TRUE otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool        hasPrevious() = 0;
+
+    /**
+     * Returns the numeric index in the underlying text-storage
+     * object of the character returned by first().  Since it's
+     * possible to create an iterator that iterates across only
+     * part of a text-storage object, this number isn't
+     * necessarily 0.  
+     * @returns the numeric index in the underlying text-storage
+     * object of the character returned by first().
+     * @stable ICU 2.0
+     */
+    inline int32_t       startIndex(void) const;
+        
+    /**
+     * Returns the numeric index in the underlying text-storage
+     * object of the position immediately BEYOND the character
+     * returned by last().  
+     * @return the numeric index in the underlying text-storage
+     * object of the position immediately BEYOND the character
+     * returned by last().
+     * @stable ICU 2.0
+     */
+    inline int32_t       endIndex(void) const;
+        
+    /**
+     * Returns the numeric index in the underlying text-storage
+     * object of the character the iterator currently refers to
+     * (i.e., the character returned by current()).  
+     * @return the numberic index in the text-storage object of 
+     * the character the iterator currently refers to
+     * @stable ICU 2.0
+     */
+    inline int32_t       getIndex(void) const;
+
+    /**
+     * Returns the length of the entire text in the underlying
+     * text-storage object.
+     * @return the length of the entire text in the text-storage object
+     * @stable ICU 2.0
+     */
+    inline int32_t           getLength() const;
+
+    /**
+     * Moves the current position relative to the start or end of the
+     * iteration range, or relative to the current position itself.
+     * The movement is expressed in numbers of code units forward
+     * or backward by specifying a positive or negative delta.
+     * @param delta the position relative to origin. A positive delta means forward;
+     * a negative delta means backward.
+     * @param origin Origin enumeration {kStart, kCurrent, kEnd}
+     * @return the new position
+     * @stable ICU 2.0
+     */
+    virtual int32_t      move(int32_t delta, EOrigin origin) = 0;
+
+    /**
+     * Moves the current position relative to the start or end of the
+     * iteration range, or relative to the current position itself.
+     * The movement is expressed in numbers of code points forward
+     * or backward by specifying a positive or negative delta.
+     * @param delta the position relative to origin. A positive delta means forward;
+     * a negative delta means backward.
+     * @param origin Origin enumeration {kStart, kCurrent, kEnd}
+     * @return the new position
+     * @stable ICU 2.0
+     */
+    virtual int32_t      move32(int32_t delta, EOrigin origin) = 0;
+
+    /**
+     * Copies the text under iteration into the UnicodeString
+     * referred to by "result".  
+     * @param result Receives a copy of the text under iteration.  
+     * @stable ICU 2.0
+     */
+    virtual void            getText(UnicodeString&  result) = 0;
+
+protected:
+    /**
+     * Empty constructor.
+     * @stable ICU 2.0
+     */
+    CharacterIterator();
+
+    /**
+     * Constructor, just setting the length field in this base class.
+     * @stable ICU 2.0
+     */
+    CharacterIterator(int32_t length);
+
+    /**
+     * Constructor, just setting the length and position fields in this base class.
+     * @stable ICU 2.0
+     */
+    CharacterIterator(int32_t length, int32_t position);
+
+    /**
+     * Constructor, just setting the length, start, end, and position fields in this base class.
+     * @stable ICU 2.0
+     */
+    CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
+  
+    /**
+     * Copy constructor.
+     *
+     * @param that The CharacterIterator to be copied
+     * @stable ICU 2.0
+     */
+    CharacterIterator(const CharacterIterator &that);
+
+    /**
+     * Assignment operator.  Sets this CharacterIterator to have the same behavior,
+     * as the one passed in.
+     * @param that The CharacterIterator passed in.
+     * @return the newly set CharacterIterator.
+     * @stable ICU 2.0
+     */
+    CharacterIterator &operator=(const CharacterIterator &that);
+
+    /**
+     * Base class text length field.
+     * Necessary this for correct getText() and hashCode().
+     * @stable ICU 2.0
+     */
+    int32_t textLength;
+
+    /**
+     * Base class field for the current position.
+     * @stable ICU 2.0
+     */
+    int32_t  pos;
+
+    /**
+     * Base class field for the start of the iteration range.
+     * @stable ICU 2.0
+     */
+    int32_t  begin;
+
+    /**
+     * Base class field for the end of the iteration range.
+     * @stable ICU 2.0
+     */
+    int32_t  end;
+};
+
+inline UBool
+ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
+    return !operator==(that);
+}
+
+inline int32_t
+CharacterIterator::setToStart() {
+    return move(0, kStart);
+}
+
+inline int32_t
+CharacterIterator::setToEnd() {
+    return move(0, kEnd);
+}
+
+inline int32_t
+CharacterIterator::startIndex(void) const {
+    return begin;
+}
+
+inline int32_t
+CharacterIterator::endIndex(void) const {
+    return end;
+}
+
+inline int32_t
+CharacterIterator::getIndex(void) const {
+    return pos;
+}
+
+inline int32_t
+CharacterIterator::getLength(void) const {
+    return textLength;
+}
+
+U_NAMESPACE_END
+#endif
diff --git a/CoreFoundation/icu/unicode/choicfmt.h b/CoreFoundation/icu/unicode/choicfmt.h
new file mode 100644
index 0000000..8484648
--- /dev/null
+++ b/CoreFoundation/icu/unicode/choicfmt.h
@@ -0,0 +1,746 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File CHOICFMT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/20/97    helena      Finished first cut of implementation and got rid 
+*                           of nextDouble/previousDouble and replaced with
+*                           boolean array.
+*   4/10/97     aliu        Clean up.  Modified to work on AIX.
+*   8/6/97      nos         Removed overloaded constructor, member var 'buffer'.
+*   07/22/98    stephen     Removed operator!= (implemented in Format)
+********************************************************************************
+*/
+ 
+#ifndef CHOICFMT_H
+#define CHOICFMT_H
+ 
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Choice Format.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/unistr.h"
+#include "unicode/numfmt.h"
+#include "unicode/fieldpos.h"
+#include "unicode/format.h"
+
+U_NAMESPACE_BEGIN
+
+class MessageFormat;
+
+/**
+ * ChoiceFormat converts between ranges of numeric values
+ * and string names for those ranges. A <code>ChoiceFormat</code> splits
+ * the real number line <code>-Inf</code> to <code>+Inf</code> into two
+ * or more contiguous ranges. Each range is mapped to a
+ * string. <code>ChoiceFormat</code> is generally used in a
+ * <code>MessageFormat</code> for displaying grammatically correct
+ * plurals such as &quot;There are 2 files.&quot;</p>
+ * 
+ * <p>There are two methods of defining a <code>ChoiceFormat</code>; both
+ * are equivalent.  The first is by using a string pattern. This is the
+ * preferred method in most cases.  The second method is through direct
+ * specification of the arrays that make up the
+ * <code>ChoiceFormat</code>.</p>
+ * 
+ * <p><strong>Patterns</strong></p>
+ * 
+ * <p>In most cases, the preferred way to define a
+ * <code>ChoiceFormat</code> is with a pattern. Here is an example of a
+ * <code>ChoiceFormat</code> pattern:</p>
+ *
+ * \htmlonly<pre>    0&#x2264;are no files|1&#x2264;is one file|1&lt;are many files</pre>\endhtmlonly
+ * 
+ * <p>or equivalently,</p>
+ * 
+ * \htmlonly<pre>    0#are no files|1#is one file|1&lt;are many files</pre>\endhtmlonly
+ * 
+ * <p>The pattern consists of a number or <em>range specifiers</em>
+ * separated by vertical bars '|' (U+007C). There is no
+ * vertical bar after the last range.  Each range specifier is of the
+ * form:</p>
+ *
+ * \htmlonly<blockquote><em>Number Separator String</em></blockquote>\endhtmlonly
+ * 
+ * <p><em>Number</em> is a floating point number that can be parsed by a
+ * default <code>NumberFormat</code> for the US locale. It gives the
+ * lower limit of this range. The lower limit is either inclusive or
+ * exclusive, depending on the <em>separator</em>. The upper limit is
+ * given by the lower limit of the next range.  The Unicode infinity
+ * sign \htmlonly&#x221E \endhtmlonly (U+221E) is recognized for positive infinity. It may be preceded by
+ * '-' (U+002D) to indicate negative infinity.</p>
+ * 
+ * <p><em>String</em> is the format string for this range, with special
+ * characters enclosed in single quotes (<code>'The #
+ * sign'</code>). Single quotes themselves are indicated by two single
+ * quotes in a row (<code>'o''clock'</code>).</p>
+ * 
+ * <p><em>Separator</em> is one of the following single characters:
+ * 
+ * <ul>
+ *   <li>\htmlonly'&#x2264;' \endhtmlonly (U+2264) or '#' (U+0023)
+ *   indicates that the lower limit given by <em>Number</em> is
+ *   inclusive.  (The two characters are equivalent to ChoiceFormat.)
+ *   This means that the limit value <em>Number</em> belongs to this
+ *   range.  Another way of saying this is that the corresponding
+ *   closure is <code>FALSE</code>.</li>
+ *
+ *   <li>'<' (U+003C) indicates that the lower limit given by
+ *   <em>Number</em> is exclusive.  This means that the value
+ *   <em>Number</em> belongs to the prior range.</li> Another way of
+ *   saying this is that the corresponding closure is
+ *   <code>TRUE</code>.
+ * </ul>
+ * 
+ * <p>See below for more information about closures.</p>
+ * 
+ * <p><strong>Arrays</strong></p>
+ * 
+ * <p>A <code>ChoiceFormat</code> defining <code>n</code> intervals
+ * (<code>n</code> &gt;= 2) is specified by three arrays of
+ * <code>n</code> items:
+ * 
+ * <ul>
+ *   <li><code>double limits[]</code> gives the start of each
+ *     interval. This must be a non-decreasing list of values, none of
+ *     which may be <code>NaN</code>.</li>
+ *   <li><code>UBool closures[]</code> determines whether each limit
+ *     value is contained in the interval below it or in the interval
+ *     above it. If <code>closures[i]</code> is <code>FALSE</code>, then
+ *     <code>limits[i]</code> is a member of interval
+ *     <code>i</code>. Otherwise it is a member of interval
+ *     <code>i+1</code>. If no closures array is specified, this is
+ *     equivalent to having all closures be <code>FALSE</code>. Closures
+ *     allow one to specify half-open, open, or closed intervals.</li>
+ *   <li><code>UnicodeString formats[]</code> gives the string label
+ *     associated with each interval.</li>
+ * </ul>
+ * 
+ * <p><strong>Formatting and Parsing</strong></p>
+ * 
+ * <p>During formatting, a number is converted to a
+ * string. <code>ChoiceFormat</code> accomplishes this by mapping the
+ * number to an interval using the following rule. Given a number
+ * <code>X</code> and and index value <code>j</code> in the range
+ * <code>0..n-1</code>, where <code>n</code> is the number of ranges:</p>
+ * 
+ * \htmlonly<blockquote>\endhtmlonly<code>X</code> matches <code>j</code> if and only if
+ * <code>limit[j] &lt;= X &lt; limit[j+1]</code>
+ * \htmlonly</blockquote>\endhtmlonly
+ * 
+ * <p>(This assumes that all closures are <code>FALSE</code>.  If some
+ * closures are <code>TRUE</code> then the relations must be changed to
+ * <code>&lt;=</code> or <code>&lt;</code> as appropriate.) If there is
+ * no match, then either the first or last index is used, depending on
+ * whether the number is too low or too high. Once a number is mapped to
+ * an interval <code>j</code>, the string <code>formats[j]</code> is
+ * output.</p>
+ * 
+ * <p>During parsing, a string is converted to a
+ * number. <code>ChoiceFormat</code> finds the element
+ * <code>formats[j]</code> equal to the string, and returns
+ * <code>limits[j]</code> as the parsed value.</p>
+ * 
+ * <p><strong>Notes</strong></p>
+ * 
+ * <p>The first limit value does not define a range boundary. For
+ * example, in the pattern \htmlonly&quot;<code>1.0#a|2.0#b</code>&quot;\endhtmlonly, the
+ * intervals are [-Inf, 2.0) and [2.0, +Inf].  It appears that the first
+ * interval should be [1.0, 2.0).  However, since all values that are too
+ * small are mapped to range zero, the first interval is effectively
+ * [-Inf, 2.0).  However, the first limit value <em>is</em> used during
+ * formatting. In this example, <code>parse(&quot;a&quot;)</code> returns
+ * 1.0.</p>
+ * 
+ * <p>There are no gaps between intervals and the entire number line is
+ * covered.  A <code>ChoiceFormat</code> maps <em>all</em> possible
+ * double values to a finite set of intervals.</p>
+ * 
+ * <p>The non-number <code>NaN</code> is mapped to interval zero during
+ * formatting.</p>
+ * 
+ * <p><strong>Examples</strong></p>
+ * 
+ * <p>Here is an example of two arrays that map the number
+ * <code>1..7</code> to the English day of the week abbreviations
+ * <code>Sun..Sat</code>. No closures array is given; this is the same as
+ * specifying all closures to be <code>FALSE</code>.</p>
+ * 
+ * <pre>    {1,2,3,4,5,6,7},
+ *     {&quot;Sun&quot;,&quot;Mon&quot;,&quot;Tue&quot;,&quot;Wed&quot;,&quot;Thur&quot;,&quot;Fri&quot;,&quot;Sat&quot;}</pre>
+ * 
+ * <p>Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1,
+ * +Inf] to three strings. That is, the number line is split into three
+ * ranges: x &lt; 1.0, x = 1.0, and x &gt; 1.0.</p>
+ * 
+ * <pre>    {0, 1, 1},
+ *     {FALSE, FALSE, TRUE},
+ *     {&quot;no files&quot;, &quot;one file&quot;, &quot;many files&quot;}</pre>
+ * 
+ * <p>Here is a simple example that shows formatting and parsing: </p>
+ * 
+ * \code
+ *   #include <unicode/choicfmt.h>
+ *   #include <unicode/unistr.h>
+ *   #include <iostream.h>
+ *   
+ *   int main(int argc, char *argv[]) {
+ *       double limits[] = {1,2,3,4,5,6,7};
+ *       UnicodeString monthNames[] = {
+ *           "Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
+ *       ChoiceFormat fmt(limits, monthNames, 7);
+ *       UnicodeString str;
+ *       char buf[256];
+ *       for (double x = 1.0; x <= 8.0; x += 1.0) {
+ *           fmt.format(x, str);
+ *           str.extract(0, str.length(), buf, 256, "");
+ *           str.truncate(0);
+ *           cout << x << " -> "
+ *                << buf << endl;
+ *       }
+ *       cout << endl;
+ *       return 0;
+ *   }
+ * \endcode
+ * 
+ * <p>Here is a more complex example using a <code>ChoiceFormat</code>
+ * constructed from a pattern together with a
+ * <code>MessageFormat</code>.</p>
+ * 
+ * \code
+ *   #include <unicode/choicfmt.h>
+ *   #include <unicode/msgfmt.h>
+ *   #include <unicode/unistr.h>
+ *   #include <iostream.h>
+ * 
+ *   int main(int argc, char *argv[]) {
+ *       UErrorCode status = U_ZERO_ERROR;
+ *       double filelimits[] = {0,1,2};
+ *       UnicodeString filepart[] =
+ *           {"are no files","is one file","are {0} files"};
+ *       ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3 );
+ *       Format* testFormats[] =
+ *           {fileform, NULL, NumberFormat::createInstance(status)};
+ *       MessageFormat pattform("There {0} on {1}", status );
+ *       pattform.adoptFormats(testFormats, 3);
+ *       Formattable testArgs[] = {0L, "Disk A"};
+ *       FieldPosition fp(0);
+ *       UnicodeString str;
+ *       char buf[256];
+ *       for (int32_t i = 0; i < 4; ++i) {
+ *           Formattable fInt(i);
+ *           testArgs[0] = fInt;
+ *           pattform.format(testArgs, 2, str, fp, status );
+ *           str.extract(0, str.length(), buf, "");
+ *           str.truncate(0);
+ *           cout << "Output for i=" << i << " : " << buf << endl;
+ *       }
+ *       cout << endl;
+ *       return 0;
+ *   }
+ * \endcode
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API ChoiceFormat: public NumberFormat {
+public:
+    /**
+     * Construct a new ChoiceFormat with the limits and the corresponding formats
+     * based on the pattern.
+     *
+     * @param pattern   Pattern used to construct object.
+     * @param status    Output param to receive success code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @stable ICU 2.0
+     */
+    ChoiceFormat(const UnicodeString& pattern,
+                 UErrorCode& status);
+
+
+    /**
+     * Construct a new ChoiceFormat with the given limits and formats.  Copy
+     * the limits and formats instead of adopting them.
+     *
+     * @param limits    Array of limit values.
+     * @param formats   Array of formats.
+     * @param count     Size of 'limits' and 'formats' arrays.
+     * @stable ICU 2.0
+     */
+    
+    ChoiceFormat(const double* limits,
+                 const UnicodeString* formats,
+                 int32_t count );
+
+    /**
+     * Construct a new ChoiceFormat with the given limits and formats.
+     * Copy the limits and formats (instead of adopting them).  By
+     * default, each limit in the array specifies the inclusive lower
+     * bound of its range, and the exclusive upper bound of the previous
+     * range.  However, if the isLimitOpen element corresponding to a
+     * limit is TRUE, then the limit is the exclusive lower bound of its
+     * range, and the inclusive upper bound of the previous range.
+     * @param limits Array of limit values
+     * @param closures Array of booleans specifying whether each
+     * element of 'limits' is open or closed.  If FALSE, then the
+     * corresponding limit is a member of the range above it.  If TRUE,
+     * then the limit belongs to the range below it.
+     * @param formats Array of formats
+     * @param count Size of 'limits', 'closures', and 'formats' arrays
+     * @stable ICU 2.4
+     */
+    ChoiceFormat(const double* limits,
+                 const UBool* closures,
+                 const UnicodeString* formats,
+                 int32_t count);
+
+    /**
+     * Copy constructor.
+     *
+     * @param that   ChoiceFormat object to be copied from
+     * @stable ICU 2.0
+     */
+    ChoiceFormat(const ChoiceFormat& that);
+
+    /**
+     * Assignment operator.
+     *
+     * @param that   ChoiceFormat object to be copied
+     * @stable ICU 2.0
+     */
+    const ChoiceFormat& operator=(const ChoiceFormat& that);
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~ChoiceFormat();
+
+    /**
+     * Clone this Format object polymorphically. The caller owns the
+     * result and should delete it when done.
+     *
+     * @return a copy of this object
+     * @stable ICU 2.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Return true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     *
+     * @param other    ChoiceFormat object to be compared 
+     * @return         true if other is the same as this. 
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Sets the pattern.
+     * @param pattern   The pattern to be applied.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                              UErrorCode& status);
+
+    /**
+     * Sets the pattern.
+     * @param pattern    The pattern to be applied.
+     * @param parseError Struct to recieve information on position 
+     *                   of error if an error is encountered
+     * @param status     Output param set to success/failure code on
+     *                   exit. If the pattern is invalid, this will be
+     *                   set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                             UParseError& parseError,
+                             UErrorCode& status);
+    /**
+     * Gets the pattern.
+     * 
+     * @param pattern    Output param which will recieve the pattern
+     *                   Previous contents are deleted.
+     * @return    A reference to 'pattern'
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toPattern(UnicodeString &pattern) const;
+
+    /**
+     * Set the choices to be used in formatting.
+     *
+     * @param limitsToCopy      Contains the top value that you want
+     *                          parsed with that format,and should be in
+     *                          ascending sorted order. When formatting X,
+     *                          the choice will be the i, where limit[i]
+     *                          &lt;= X &lt; limit[i+1].
+     * @param formatsToCopy     The format strings you want to use for each limit.
+     * @param count             The size of the above arrays.
+     * @stable ICU 2.0
+     */
+    virtual void setChoices(const double* limitsToCopy,
+                            const UnicodeString* formatsToCopy,
+                            int32_t count );    
+
+    /**
+     * Set the choices to be used in formatting.  See class description
+     * for documenatation of the limits, closures, and formats arrays.
+     * @param limits Array of limits
+     * @param closures Array of limit booleans
+     * @param formats Array of format string
+     * @param count The size of the above arrays
+     * @stable ICU 2.4
+     */
+    virtual void setChoices(const double* limits,
+                            const UBool* closures,
+                            const UnicodeString* formats,
+                            int32_t count);
+
+    /**
+     * Get the limits passed in the constructor.
+     *
+     * @param count    The size of the limits arrays
+     * @return the limits.
+     * @stable ICU 2.0
+     */
+    virtual const double* getLimits(int32_t& count) const;
+    
+    /**
+     * Get the limit booleans passed in the constructor.  The caller
+     * must not delete the result.
+     *
+     * @param count   The size of the arrays
+     * @return the closures
+     * @stable ICU 2.4
+     */
+    virtual const UBool* getClosures(int32_t& count) const;
+
+    /**
+     * Get the formats passed in the constructor.
+     *
+     * @param count   The size of the arrays
+     * @return the formats.
+     * @stable ICU 2.0
+     */
+    virtual const UnicodeString* getFormats(int32_t& count) const;
+
+    /**
+     * Format a double or long number using this object's choices.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+    /**
+     * Format a int_32t number using this object's choices.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(int32_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Format an int64_t number using this object's choices.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.8
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Format an array of objects using this object's choices.
+     *
+     * @param objs      The array of objects to be formatted.
+     * @param cnt       The size of objs.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param success   Output param set to success/failure code on
+     *                  exit. 
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable* objs,
+                                  int32_t cnt,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& success) const;
+    /**
+     * Format an object using this object's choices.
+     *
+     *
+     * @param obj       The object to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param set to success/failure code on
+     *                  exit. 
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos, 
+                                  UErrorCode& status) const;
+
+    /**
+     * Redeclared NumberFormat method.
+     *
+     * @param obj       The object to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Output param set to success/failure code on
+     *                  exit. 
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+
+    /**
+     * Redeclared NumberFormat method.
+     * Format a double number. These methods call the NumberFormat
+     * pure virtual format() methods with the default FieldPosition.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(  double number,
+                            UnicodeString& appendTo) const;
+
+    /**
+     * Redeclared NumberFormat method.
+     * Format a long number. These methods call the NumberFormat
+     * pure virtual format() methods with the default FieldPosition.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(  int32_t number,
+                            UnicodeString& appendTo) const;
+
+   /**
+    * Return a long if possible (e.g. within range LONG_MAX,
+    * LONG_MAX], and with no decimals), otherwise a double.  If
+    * IntegerOnly is set, will stop at a decimal point (or equivalent;
+    * e.g. for rational numbers "1 2/3", will stop after the 1).
+    * <P>
+    * If no object can be parsed, parsePosition is unchanged, and NULL is
+    * returned.
+    *
+    * @param text           The text to be parsed.
+    * @param result         Formattable to be set to the parse result.
+    *                       If parse fails, return contents are undefined.
+    * @param parsePosition  The position to start parsing at on input.
+    *                       On output, moved to after the last successfully
+    *                       parse character. On parse failure, does not change.
+    * @see                  NumberFormat::isParseIntegerOnly
+    * @stable ICU 2.0
+    */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       ParsePosition& parsePosition) const;
+    
+    /**
+    * Return a long if possible (e.g. within range LONG_MAX,
+    * LONG_MAX], and with no decimals), otherwise a double.  If
+    * IntegerOnly is set, will stop at a decimal point (or equivalent;
+    * e.g. for rational numbers "1 2/3", will stop after the 1).
+    * <P>
+    * If no object can be parsed, parsePosition is unchanged, and NULL is
+    * returned.
+    *
+    * @param text           The text to be parsed.
+    * @param result         Formattable to be set to the parse result.
+    *                       If parse fails, return contents are undefined.
+    * @param status         Output param with the formatted string.
+    * @see                  NumberFormat::isParseIntegerOnly
+    * @stable ICU 2.0
+    */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       UErrorCode& status) const;
+    
+    
+public:
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     * <pre>
+     * .       Base* polymorphic_pointer = createPolymorphicObject();
+     * .       if (polymorphic_pointer->getDynamicClassID() ==
+     * .           Derived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+private:
+    // static cache management (thread-safe)
+  //  static NumberFormat* getNumberFormat(UErrorCode &status); // call this function to 'check out' a numberformat from the cache.
+  //  static void          releaseNumberFormat(NumberFormat *adopt); // call this function to 'return' the number format to the cache.
+    
+    /**
+     * Converts a string to a double value using a default NumberFormat object
+     * which is static (shared by all ChoiceFormat instances).
+     * @param string the string to be converted with.
+     * @return the converted double number.
+     */
+    static double stod(const UnicodeString& string);
+
+    /**
+     * Converts a double value to a string using a default NumberFormat object
+     * which is static (shared by all ChoiceFormat instances).
+     * @param value the double number to be converted with.
+     * @param string the result string.
+     * @return the converted string.
+     */
+    static UnicodeString& dtos(double value, UnicodeString& string);
+
+    ChoiceFormat(); // default constructor not implemented
+
+    /**
+     * Construct a new ChoiceFormat with the limits and the corresponding formats
+     * based on the pattern.
+     *
+     * @param newPattern   Pattern used to construct object.
+     * @param parseError   Struct to recieve information on position 
+     *                     of error if an error is encountered.
+     * @param status       Output param to receive success code.  If the
+     *                     pattern cannot be parsed, set to failure code.
+     * @stable ICU 2.0
+     */
+    ChoiceFormat(const UnicodeString& newPattern,
+                 UParseError& parseError,
+                 UErrorCode& status);
+
+    friend class MessageFormat;
+    /**
+     * Each ChoiceFormat divides the range -Inf..+Inf into fCount
+     * intervals.  The intervals are:
+     *
+     *         0: fChoiceLimits[0]..fChoiceLimits[1]
+     *         1: fChoiceLimits[1]..fChoiceLimits[2]
+     *        ...
+     *  fCount-2: fChoiceLimits[fCount-2]..fChoiceLimits[fCount-1]
+     *  fCount-1: fChoiceLimits[fCount-1]..+Inf
+     *
+     * Interval 0 is special; during formatting (mapping numbers to
+     * strings), it also contains all numbers less than
+     * fChoiceLimits[0], as well as NaN values.
+     *
+     * Interval i maps to and from string fChoiceFormats[i].  When
+     * parsing (mapping strings to numbers), then intervals map to
+     * their lower limit, that is, interval i maps to fChoiceLimit[i].
+     *
+     * The intervals may be closed, half open, or open.  This affects
+     * formatting but does not affect parsing.  Interval i is affected
+     * by fClosures[i] and fClosures[i+1].  If fClosures[i]
+     * is FALSE, then the value fChoiceLimits[i] is in interval i.
+     * That is, intervals i and i are:
+     *
+     *  i-1:                 ... x < fChoiceLimits[i]
+     *    i: fChoiceLimits[i] <= x ...
+     *
+     * If fClosures[i] is TRUE, then the value fChoiceLimits[i] is
+     * in interval i-1.  That is, intervals i-1 and i are:
+     *
+     *  i-1:                ... x <= fChoiceLimits[i]
+     *    i: fChoiceLimits[i] < x ...
+     *
+     * Because of the nature of interval 0, fClosures[0] has no
+     * effect.
+
+     */
+    double*         fChoiceLimits;
+    UBool*          fClosures;
+    UnicodeString*  fChoiceFormats;
+    int32_t         fCount;
+};
+ 
+inline UnicodeString&
+ChoiceFormat::format(const Formattable& obj,
+                     UnicodeString& appendTo,
+                     UErrorCode& status) const {
+    // Don't use Format:: - use immediate base class only,
+    // in case immediate base modifies behavior later.
+    return NumberFormat::format(obj, appendTo, status);
+}
+
+inline UnicodeString&
+ChoiceFormat::format(double number,
+                     UnicodeString& appendTo) const {
+    return NumberFormat::format(number, appendTo);
+}
+
+inline UnicodeString&
+ChoiceFormat::format(int32_t number,
+                     UnicodeString& appendTo) const {
+    return NumberFormat::format(number, appendTo);
+}
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _CHOICFMT
+//eof
diff --git a/CoreFoundation/icu/unicode/coleitr.h b/CoreFoundation/icu/unicode/coleitr.h
new file mode 100644
index 0000000..4025a41
--- /dev/null
+++ b/CoreFoundation/icu/unicode/coleitr.h
@@ -0,0 +1,400 @@
+/*
+ ******************************************************************************
+ *   Copyright (C) 1997-2008, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ ******************************************************************************
+ */
+
+/**
+ * \file 
+ * \brief C++ API: Collation Element Iterator.
+ */
+
+/**
+* File coleitr.h
+*
+* 
+*
+* Created by: Helena Shih
+*
+* Modification History:
+*
+*  Date       Name        Description
+*
+*  8/18/97    helena      Added internal API documentation.
+* 08/03/98    erm         Synched with 1.2 version CollationElementIterator.java
+* 12/10/99    aliu        Ported Thai collation support from Java.
+* 01/25/01    swquek      Modified into a C++ wrapper calling C APIs (ucoliter.h)
+* 02/19/01    swquek      Removed CollationElementsIterator() since it is 
+*                         private constructor and no calls are made to it
+*/
+
+#ifndef COLEITR_H
+#define COLEITR_H
+
+#include "unicode/utypes.h"
+
+ 
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/uobject.h"
+#include "unicode/tblcoll.h"
+#include "unicode/ucoleitr.h"
+
+/** 
+ * The UCollationElements struct.
+ * For usage in C programs.
+ * @stable ICU 2.0
+ */
+typedef struct UCollationElements UCollationElements;
+
+U_NAMESPACE_BEGIN
+
+/**
+* The CollationElementIterator class is used as an iterator to walk through     
+* each character of an international string. Use the iterator to return the
+* ordering priority of the positioned character. The ordering priority of a 
+* character, which we refer to as a key, defines how a character is collated in 
+* the given collation object.
+* For example, consider the following in Spanish:
+* <pre>
+*        "ca" -> the first key is key('c') and second key is key('a').
+*        "cha" -> the first key is key('ch') and second key is key('a').</pre>
+* And in German,
+* <pre> \htmlonly       "&#x00E6;b"-> the first key is key('a'), the second key is key('e'), and
+*        the third key is key('b'). \endhtmlonly </pre>
+* The key of a character, is an integer composed of primary order(short),
+* secondary order(char), and tertiary order(char). Java strictly defines the 
+* size and signedness of its primitive data types. Therefore, the static
+* functions primaryOrder(), secondaryOrder(), and tertiaryOrder() return 
+* int32_t to ensure the correctness of the key value.
+* <p>Example of the iterator usage: (without error checking)
+* <pre>
+* \code
+*   void CollationElementIterator_Example()
+*   {
+*       UnicodeString str = "This is a test";
+*       UErrorCode success = U_ZERO_ERROR;
+*       RuleBasedCollator* rbc =
+*           (RuleBasedCollator*) RuleBasedCollator::createInstance(success);
+*       CollationElementIterator* c =
+*           rbc->createCollationElementIterator( str );
+*       int32_t order = c->next(success);
+*       c->reset();
+*       order = c->previous(success);
+*       delete c;
+*       delete rbc;
+*   }
+* \endcode
+* </pre>
+* <p>
+* CollationElementIterator::next returns the collation order of the next
+* character based on the comparison level of the collator. 
+* CollationElementIterator::previous returns the collation order of the 
+* previous character based on the comparison level of the collator. 
+* The Collation Element Iterator moves only in one direction between calls to
+* CollationElementIterator::reset. That is, CollationElementIterator::next() 
+* and CollationElementIterator::previous can not be inter-used. Whenever 
+* CollationElementIterator::previous is to be called after 
+* CollationElementIterator::next() or vice versa, 
+* CollationElementIterator::reset has to be called first to reset the status, 
+* shifting pointers to either the end or the start of the string. Hence at the 
+* next call of CollationElementIterator::previous or 
+* CollationElementIterator::next(), the first or last collation order will be 
+* returned. 
+* If a change of direction is done without a CollationElementIterator::reset(), 
+* the result is undefined.
+* The result of a forward iterate (CollationElementIterator::next) and 
+* reversed result of the backward iterate (CollationElementIterator::previous) 
+* on the same string are equivalent, if collation orders with the value 
+* UCOL_IGNORABLE are ignored.
+* Character based on the comparison level of the collator.  A collation order 
+* consists of primary order, secondary order and tertiary order.  The data 
+* type of the collation order is <strong>t_int32</strong>. 
+*
+* Note, CollationElementIterator should not be subclassed.
+* @see     Collator
+* @see     RuleBasedCollator
+* @version 1.8 Jan 16 2001
+*/
+class U_I18N_API CollationElementIterator : public UObject {
+public: 
+
+    // CollationElementIterator public data member ------------------------------
+
+    enum {
+        /**
+         * NULLORDER indicates that an error has occured while processing
+         * @stable ICU 2.0
+         */
+        NULLORDER = (int32_t)0xffffffff
+    };
+
+    // CollationElementIterator public constructor/destructor -------------------
+
+    /**
+    * Copy constructor.
+    *
+    * @param other    the object to be copied from
+    * @stable ICU 2.0
+    */
+    CollationElementIterator(const CollationElementIterator& other);
+
+    /** 
+    * Destructor
+    * @stable ICU 2.0
+    */
+    virtual ~CollationElementIterator();
+
+    // CollationElementIterator public methods ----------------------------------
+
+    /**
+    * Returns true if "other" is the same as "this"
+    *
+    * @param other    the object to be compared
+    * @return         true if "other" is the same as "this"
+    * @stable ICU 2.0
+    */
+    UBool operator==(const CollationElementIterator& other) const;
+
+    /**
+    * Returns true if "other" is not the same as "this".
+    *
+    * @param other    the object to be compared
+    * @return         true if "other" is not the same as "this"
+    * @stable ICU 2.0
+    */
+    UBool operator!=(const CollationElementIterator& other) const;
+
+    /**
+    * Resets the cursor to the beginning of the string.
+    * @stable ICU 2.0
+    */
+    void reset(void);
+
+    /**
+    * Gets the ordering priority of the next character in the string.
+    * @param status the error code status.
+    * @return the next character's ordering. otherwise returns NULLORDER if an 
+    *         error has occured or if the end of string has been reached
+    * @stable ICU 2.0
+    */
+    int32_t next(UErrorCode& status);
+
+    /**
+    * Get the ordering priority of the previous collation element in the string.
+    * @param status the error code status.
+    * @return the previous element's ordering. otherwise returns NULLORDER if an 
+    *         error has occured or if the start of string has been reached
+    * @stable ICU 2.0
+    */
+    int32_t previous(UErrorCode& status);
+
+    /**
+    * Gets the primary order of a collation order.
+    * @param order the collation order
+    * @return the primary order of a collation order.
+    * @stable ICU 2.0
+    */
+    static inline int32_t primaryOrder(int32_t order);
+
+    /**
+    * Gets the secondary order of a collation order.
+    * @param order the collation order
+    * @return the secondary order of a collation order.
+    * @stable ICU 2.0
+    */
+    static inline int32_t secondaryOrder(int32_t order);
+
+    /**
+    * Gets the tertiary order of a collation order.
+    * @param order the collation order
+    * @return the tertiary order of a collation order.
+    * @stable ICU 2.0
+    */
+    static inline int32_t tertiaryOrder(int32_t order);
+
+    /**
+    * Return the maximum length of any expansion sequences that end with the 
+    * specified comparison order.
+    * @param order a collation order returned by previous or next.
+    * @return maximum size of the expansion sequences ending with the collation 
+    *         element or 1 if collation element does not occur at the end of any 
+    *         expansion sequence
+    * @stable ICU 2.0
+    */
+    int32_t getMaxExpansion(int32_t order) const;
+
+    /**
+    * Gets the comparison order in the desired strength. Ignore the other
+    * differences.
+    * @param order The order value
+    * @stable ICU 2.0
+    */
+    int32_t strengthOrder(int32_t order) const;
+
+    /**
+    * Sets the source string.
+    * @param str the source string.
+    * @param status the error code status.
+    * @stable ICU 2.0
+    */
+    void setText(const UnicodeString& str, UErrorCode& status);
+
+    /**
+    * Sets the source string.
+    * @param str the source character iterator.
+    * @param status the error code status.
+    * @stable ICU 2.0
+    */
+    void setText(CharacterIterator& str, UErrorCode& status);
+
+    /**
+    * Checks if a comparison order is ignorable.
+    * @param order the collation order.
+    * @return TRUE if a character is ignorable, FALSE otherwise.
+    * @stable ICU 2.0
+    */
+    static inline UBool isIgnorable(int32_t order);
+
+    /**
+    * Gets the offset of the currently processed character in the source string.
+    * @return the offset of the character.
+    * @stable ICU 2.0
+    */
+    int32_t getOffset(void) const;
+
+    /**
+    * Sets the offset of the currently processed character in the source string.
+    * @param newOffset the new offset.
+    * @param status the error code status.
+    * @return the offset of the character.
+    * @stable ICU 2.0
+    */
+    void setOffset(int32_t newOffset, UErrorCode& status);
+
+    /**
+    * ICU "poor man's RTTI", returns a UClassID for the actual class.
+    *
+    * @stable ICU 2.2
+    */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+    * ICU "poor man's RTTI", returns a UClassID for this class.
+    *
+    * @stable ICU 2.2
+    */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+protected:
+  
+    // CollationElementIterator protected constructors --------------------------
+    /**
+    * @stable ICU 2.0
+    */
+    friend class RuleBasedCollator;
+
+    /**
+    * CollationElementIterator constructor. This takes the source string and the 
+    * collation object. The cursor will walk thru the source string based on the 
+    * predefined collation rules. If the source string is empty, NULLORDER will 
+    * be returned on the calls to next().
+    * @param sourceText    the source string.
+    * @param order         the collation object.
+    * @param status        the error code status.
+    * @stable ICU 2.0
+    */
+    CollationElementIterator(const UnicodeString& sourceText,
+        const RuleBasedCollator* order, UErrorCode& status);
+
+    /**
+    * CollationElementIterator constructor. This takes the source string and the 
+    * collation object.  The cursor will walk thru the source string based on the 
+    * predefined collation rules.  If the source string is empty, NULLORDER will 
+    * be returned on the calls to next().
+    * @param sourceText    the source string.
+    * @param order         the collation object.
+    * @param status        the error code status.
+    * @stable ICU 2.0
+    */
+    CollationElementIterator(const CharacterIterator& sourceText,
+        const RuleBasedCollator* order, UErrorCode& status);
+
+    // CollationElementIterator protected methods -------------------------------
+
+    /**
+    * Assignment operator
+    *
+    * @param other    the object to be copied
+    * @stable ICU 2.0
+    */
+    const CollationElementIterator&
+        operator=(const CollationElementIterator& other);
+
+private:
+    CollationElementIterator(); // default constructor not implemented
+
+    // CollationElementIterator private data members ----------------------------
+
+    /**
+    * Data wrapper for collation elements
+    */
+    UCollationElements *m_data_;
+
+    /**
+    * Indicates if m_data_ belongs to this object.
+    */
+    UBool isDataOwned_;
+
+};
+
+// CollationElementIterator inline method defination --------------------------
+
+/**
+* Get the primary order of a collation order.
+* @param order the collation order
+* @return the primary order of a collation order.
+*/
+inline int32_t CollationElementIterator::primaryOrder(int32_t order)
+{
+    order &= RuleBasedCollator::PRIMARYORDERMASK;
+    return (order >> RuleBasedCollator::PRIMARYORDERSHIFT);
+}
+
+/**
+* Get the secondary order of a collation order.
+* @param order the collation order
+* @return the secondary order of a collation order.
+*/
+inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
+{
+    order = order & RuleBasedCollator::SECONDARYORDERMASK;
+    return (order >> RuleBasedCollator::SECONDARYORDERSHIFT);
+}
+
+/**
+* Get the tertiary order of a collation order.
+* @param order the collation order
+* @return the tertiary order of a collation order.
+*/
+inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
+{
+    return (order &= RuleBasedCollator::TERTIARYORDERMASK);
+}
+
+inline int32_t CollationElementIterator::getMaxExpansion(int32_t order) const
+{
+    return ucol_getMaxExpansion(m_data_, (uint32_t)order);
+}
+
+inline UBool CollationElementIterator::isIgnorable(int32_t order)
+{
+    return (primaryOrder(order) == RuleBasedCollator::PRIMIGNORABLE);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/coll.h b/CoreFoundation/icu/unicode/coll.h
new file mode 100644
index 0000000..5733f58
--- /dev/null
+++ b/CoreFoundation/icu/unicode/coll.h
@@ -0,0 +1,1035 @@
+/*
+******************************************************************************
+*   Copyright (C) 1996-2008, International Business Machines                 *
+*   Corporation and others.  All Rights Reserved.                            *
+******************************************************************************
+*/
+
+/**
+ * \file 
+ * \brief C++ API: Collation Service.
+ */
+ 
+/**
+* File coll.h
+*
+* Created by: Helena Shih
+*
+* Modification History:
+*
+*  Date        Name        Description
+* 02/5/97      aliu        Modified createDefault to load collation data from
+*                          binary files when possible.  Added related methods
+*                          createCollationFromFile, chopLocale, createPathName.
+* 02/11/97     aliu        Added members addToCache, findInCache, and fgCache.
+* 02/12/97     aliu        Modified to create objects from RuleBasedCollator cache.
+*                          Moved cache out of Collation class.
+* 02/13/97     aliu        Moved several methods out of this class and into
+*                          RuleBasedCollator, with modifications.  Modified
+*                          createDefault() to call new RuleBasedCollator(Locale&)
+*                          constructor.  General clean up and documentation.
+* 02/20/97     helena      Added clone, operator==, operator!=, operator=, copy
+*                          constructor and getDynamicClassID.
+* 03/25/97     helena      Updated with platform independent data types.
+* 05/06/97     helena      Added memory allocation error detection.
+* 06/20/97     helena      Java class name change.
+* 09/03/97     helena      Added createCollationKeyValues().
+* 02/10/98     damiba      Added compare() with length as parameter.
+* 04/23/99     stephen     Removed EDecompositionMode, merged with
+*                          Normalizer::EMode.
+* 11/02/99     helena      Collator performance enhancements.  Eliminates the
+*                          UnicodeString construction and special case for NO_OP.
+* 11/23/99     srl         More performance enhancements. Inlining of
+*                          critical accessors.
+* 05/15/00     helena      Added version information API.
+* 01/29/01     synwee      Modified into a C++ wrapper which calls C apis
+*                          (ucoll.h).
+*/
+
+#ifndef COLL_H
+#define COLL_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/uobject.h"
+#include "unicode/ucol.h"
+#include "unicode/normlzr.h"
+#include "unicode/locid.h"
+#include "unicode/uniset.h"
+#include "unicode/umisc.h"
+
+U_NAMESPACE_BEGIN
+
+class StringEnumeration;
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * @stable ICU 2.6
+ */
+class CollatorFactory;
+#endif
+
+/**
+* @stable ICU 2.0
+*/
+class CollationKey;
+
+/**
+* The <code>Collator</code> class performs locale-sensitive string
+* comparison.<br>
+* You use this class to build searching and sorting routines for natural
+* language text.<br>
+* <em>Important: </em>The ICU collation service has been reimplemented
+* in order to achieve better performance and UCA compliance.
+* For details, see the
+* <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm">
+* collation design document</a>.
+* <p>
+* <code>Collator</code> is an abstract base class. Subclasses implement
+* specific collation strategies. One subclass,
+* <code>RuleBasedCollator</code>, is currently provided and is applicable
+* to a wide set of languages. Other subclasses may be created to handle more
+* specialized needs.
+* <p>
+* Like other locale-sensitive classes, you can use the static factory method,
+* <code>createInstance</code>, to obtain the appropriate
+* <code>Collator</code> object for a given locale. You will only need to
+* look at the subclasses of <code>Collator</code> if you need to
+* understand the details of a particular collation strategy or if you need to
+* modify that strategy.
+* <p>
+* The following example shows how to compare two strings using the
+* <code>Collator</code> for the default locale.
+* \htmlonly<blockquote>\endhtmlonly
+* <pre>
+* \code
+* // Compare two strings in the default locale
+* UErrorCode success = U_ZERO_ERROR;
+* Collator* myCollator = Collator::createInstance(success);
+* if (myCollator->compare("abc", "ABC") < 0)
+*   cout << "abc is less than ABC" << endl;
+* else
+*   cout << "abc is greater than or equal to ABC" << endl;
+* \endcode
+* </pre>
+* \htmlonly</blockquote>\endhtmlonly
+* <p>
+* You can set a <code>Collator</code>'s <em>strength</em> property to
+* determine the level of difference considered significant in comparisons.
+* Five strengths are provided: <code>PRIMARY</code>, <code>SECONDARY</code>,
+* <code>TERTIARY</code>, <code>QUATERNARY</code> and <code>IDENTICAL</code>.
+* The exact assignment of strengths to language features is locale dependant.
+* For example, in Czech, "e" and "f" are considered primary differences,
+* while "e" and "\u00EA" are secondary differences, "e" and "E" are tertiary
+* differences and "e" and "e" are identical. The following shows how both case
+* and accents could be ignored for US English.
+* \htmlonly<blockquote>\endhtmlonly
+* <pre>
+* \code
+* //Get the Collator for US English and set its strength to PRIMARY
+* UErrorCode success = U_ZERO_ERROR;
+* Collator* usCollator = Collator::createInstance(Locale::US, success);
+* usCollator->setStrength(Collator::PRIMARY);
+* if (usCollator->compare("abc", "ABC") == 0)
+*     cout << "'abc' and 'ABC' strings are equivalent with strength PRIMARY" << endl;
+* \endcode
+* </pre>
+* \htmlonly</blockquote>\endhtmlonly
+* <p>
+* For comparing strings exactly once, the <code>compare</code> method
+* provides the best performance. When sorting a list of strings however, it
+* is generally necessary to compare each string multiple times. In this case,
+* sort keys provide better performance. The <code>getSortKey</code> methods
+* convert a string to a series of bytes that can be compared bitwise against
+* other sort keys using <code>strcmp()</code>. Sort keys are written as
+* zero-terminated byte strings. They consist of several substrings, one for
+* each collation strength level, that are delimited by 0x01 bytes.
+* If the string code points are appended for UCOL_IDENTICAL, then they are
+* processed for correct code point order comparison and may contain 0x01
+* bytes but not zero bytes.
+* </p>
+* <p>
+* An older set of APIs returns a <code>CollationKey</code> object that wraps
+* the sort key bytes instead of returning the bytes themselves.
+* Its use is deprecated, but it is still available for compatibility with
+* Java.
+* </p>
+* <p>
+* <strong>Note:</strong> <code>Collator</code>s with different Locale,
+* and CollationStrength settings will return different sort
+* orders for the same set of strings. Locales have specific collation rules,
+* and the way in which secondary and tertiary differences are taken into
+* account, for example, will result in a different sorting order for same
+* strings.
+* </p>
+* @see         RuleBasedCollator
+* @see         CollationKey
+* @see         CollationElementIterator
+* @see         Locale
+* @see         Normalizer
+* @version     2.0 11/15/01
+*/
+
+class U_I18N_API Collator : public UObject {
+public:
+
+    // Collator public enums -----------------------------------------------
+
+    /**
+     * Base letter represents a primary difference. Set comparison level to
+     * PRIMARY to ignore secondary and tertiary differences.<br>
+     * Use this to set the strength of a Collator object.<br>
+     * Example of primary difference, "abc" &lt; "abd"
+     *
+     * Diacritical differences on the same base letter represent a secondary
+     * difference. Set comparison level to SECONDARY to ignore tertiary
+     * differences. Use this to set the strength of a Collator object.<br>
+     * Example of secondary difference, "&auml;" >> "a".
+     *
+     * Uppercase and lowercase versions of the same character represents a
+     * tertiary difference.  Set comparison level to TERTIARY to include all
+     * comparison differences. Use this to set the strength of a Collator
+     * object.<br>
+     * Example of tertiary difference, "abc" &lt;&lt;&lt; "ABC".
+     *
+     * Two characters are considered "identical" when they have the same unicode
+     * spellings.<br>
+     * For example, "&auml;" == "&auml;".
+     *
+     * UCollationStrength is also used to determine the strength of sort keys
+     * generated from Collator objects.
+     * @stable ICU 2.0
+     */
+    enum ECollationStrength
+    {
+        PRIMARY    = 0,
+        SECONDARY  = 1,
+        TERTIARY   = 2,
+        QUATERNARY = 3,
+        IDENTICAL  = 15
+    };
+
+    /**
+     * LESS is returned if source string is compared to be less than target
+     * string in the compare() method.
+     * EQUAL is returned if source string is compared to be equal to target
+     * string in the compare() method.
+     * GREATER is returned if source string is compared to be greater than
+     * target string in the compare() method.
+     * @see Collator#compare
+     * @deprecated ICU 2.6. Use C enum UCollationResult defined in ucol.h
+     */
+    enum EComparisonResult
+    {
+        LESS = -1,
+        EQUAL = 0,
+        GREATER = 1
+    };
+
+    // Collator public destructor -----------------------------------------
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~Collator();
+
+    // Collator public methods --------------------------------------------
+
+    /**
+     * Returns true if "other" is the same as "this"
+     * @param other Collator object to be compared
+     * @return true if other is the same as this.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Collator& other) const;
+
+    /**
+     * Returns true if "other" is not the same as "this".
+     * @param other Collator object to be compared
+     * @return true if other is not the same as this.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator!=(const Collator& other) const;
+
+    /**
+     * Makes a shallow copy of the current object.
+     * @return a copy of this object
+     * @stable ICU 2.0
+     */
+    virtual Collator* clone(void) const = 0;
+
+    /**
+     * Creates the Collator object for the current default locale.
+     * The default locale is determined by Locale::getDefault.
+     * The UErrorCode& err parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check the
+     * value of U_SUCCESS(err).  If you wish more detailed information, you can
+     * check for informational error results which still indicate success.
+     * U_USING_FALLBACK_ERROR indicates that a fall back locale was used. For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used. U_USING_DEFAULT_ERROR indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     *
+     * @param err    the error code status.
+     * @return       the collation object of the default locale.(for example, en_US)
+     * @see Locale#getDefault
+     * @stable ICU 2.0
+     */
+    static Collator* U_EXPORT2 createInstance(UErrorCode&  err);
+
+    /**
+     * Gets the table-based collation object for the desired locale. The
+     * resource of the desired locale will be loaded by ResourceLoader.
+     * Locale::ENGLISH is the base collation table and all other languages are
+     * built on top of it with additional language-specific modifications.
+     * The UErrorCode& err parameter is used to return status information to the user.
+     * To check whether the construction succeeded or not, you should check
+     * the value of U_SUCCESS(err).  If you wish more detailed information, you
+     * can check for informational error results which still indicate success.
+     * U_USING_FALLBACK_ERROR indicates that a fall back locale was used.  For
+     * example, 'de_CH' was requested, but nothing was found there, so 'de' was
+     * used.  U_USING_DEFAULT_ERROR indicates that the default locale data was
+     * used; neither the requested locale nor any of its fall back locales
+     * could be found.
+     * The caller owns the returned object and is responsible for deleting it.
+     * @param loc    The locale ID for which to open a collator.
+     * @param err    the error code status.
+     * @return       the created table-based collation object based on the desired
+     *               locale.
+     * @see Locale
+     * @see ResourceLoader
+     * @stable ICU 2.2
+     */
+    static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err);
+
+#ifdef U_USE_COLLATION_OBSOLETE_2_6
+    /**
+     * Create a Collator with a specific version.
+     * This is the same as createInstance(loc, err) except that getVersion() of
+     * the returned object is guaranteed to be the same as the version
+     * parameter.
+     * This is designed to be used to open the same collator for a given
+     * locale even when ICU is updated.
+     * The same locale and version guarantees the same sort keys and
+     * comparison results.
+     * <p>
+     * Note: this API will be removed in a future release.  Use
+     * <tt>createInstance(const Locale&, UErrorCode&) instead.</tt></p>
+     *
+     * @param loc The locale ID for which to open a collator.
+     * @param version The requested collator version.
+     * @param err A reference to a UErrorCode,
+     *            must not indicate a failure before calling this function.
+     * @return A pointer to a Collator, or 0 if an error occurred
+     *         or a collator with the requested version is not available.
+     *
+     * @see getVersion
+     * @obsolete ICU 2.6
+     */
+    static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err);
+#endif
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different strings. Returns information about whether a string is less
+     * than, greater than or equal to another string.
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @return Returns a byte value. GREATER if source is greater
+     * than target; EQUAL if source is equal to target; LESS if source is less
+     * than target
+     * @deprecated ICU 2.6 use the overload with UErrorCode &
+     */
+    virtual EComparisonResult compare(const UnicodeString& source,
+                                      const UnicodeString& target) const;
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different strings. Returns information about whether a string is less
+     * than, greater than or equal to another string.
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @param status possible error code
+     * @return Returns an enum value. UCOL_GREATER if source is greater
+     * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
+     * than target
+     * @stable ICU 2.6
+     */
+    virtual UCollationResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      UErrorCode &status) const = 0;
+
+    /**
+     * Does the same thing as compare but limits the comparison to a specified
+     * length
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @param length the length the comparison is limited to
+     * @return Returns a byte value. GREATER if source (up to the specified
+     *         length) is greater than target; EQUAL if source (up to specified
+     *         length) is equal to target; LESS if source (up to the specified
+     *         length) is less  than target.
+     * @deprecated ICU 2.6 use the overload with UErrorCode &
+     */
+    virtual EComparisonResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      int32_t length) const;
+
+    /**
+     * Does the same thing as compare but limits the comparison to a specified
+     * length
+     * @param source the source string to be compared with.
+     * @param target the string that is to be compared with the source string.
+     * @param length the length the comparison is limited to
+     * @param status possible error code
+     * @return Returns an enum value. UCOL_GREATER if source (up to the specified
+     *         length) is greater than target; UCOL_EQUAL if source (up to specified
+     *         length) is equal to target; UCOL_LESS if source (up to the specified
+     *         length) is less  than target.
+     * @stable ICU 2.6
+     */
+    virtual UCollationResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      int32_t length,
+                                      UErrorCode &status) const = 0;
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different string arrays. Returns information about whether a string array
+     * is less than, greater than or equal to another string array.
+     * @param source the source string array to be compared with.
+     * @param sourceLength the length of the source string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @param target the string that is to be compared with the source string.
+     * @param targetLength the length of the target string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @return Returns a byte value. GREATER if source is greater than target;
+     *         EQUAL if source is equal to target; LESS if source is less than
+     *         target
+     * @deprecated ICU 2.6 use the overload with UErrorCode &
+     */
+    virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
+                                      const UChar* target, int32_t targetLength)
+                                      const;
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different string arrays. Returns information about whether a string array
+     * is less than, greater than or equal to another string array.
+     * @param source the source string array to be compared with.
+     * @param sourceLength the length of the source string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @param target the string that is to be compared with the source string.
+     * @param targetLength the length of the target string array.  If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @param status possible error code
+     * @return Returns an enum value. UCOL_GREATER if source is greater
+     * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
+     * than target
+     * @stable ICU 2.6
+     */
+    virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
+                                      const UChar* target, int32_t targetLength,
+                                      UErrorCode &status) const = 0;
+
+    /**
+     * Transforms the string into a series of characters that can be compared
+     * with CollationKey::compareTo. It is not possible to restore the original
+     * string from the chars in the sort key.  The generated sort key handles
+     * only a limited number of ignorable characters.
+     * <p>Use CollationKey::equals or CollationKey::compare to compare the
+     * generated sort keys.
+     * If the source string is null, a null collation key will be returned.
+     * @param source the source string to be transformed into a sort key.
+     * @param key the collation key to be filled in
+     * @param status the error code status.
+     * @return the collation key of the string based on the collation rules.
+     * @see CollationKey#compare
+     * @deprecated ICU 2.8 Use getSortKey(...) instead
+     */
+    virtual CollationKey& getCollationKey(const UnicodeString&  source,
+                                          CollationKey& key,
+                                          UErrorCode& status) const = 0;
+
+    /**
+     * Transforms the string into a series of characters that can be compared
+     * with CollationKey::compareTo. It is not possible to restore the original
+     * string from the chars in the sort key.  The generated sort key handles
+     * only a limited number of ignorable characters.
+     * <p>Use CollationKey::equals or CollationKey::compare to compare the
+     * generated sort keys.
+     * <p>If the source string is null, a null collation key will be returned.
+     * @param source the source string to be transformed into a sort key.
+     * @param sourceLength length of the collation key
+     * @param key the collation key to be filled in
+     * @param status the error code status.
+     * @return the collation key of the string based on the collation rules.
+     * @see CollationKey#compare
+     * @deprecated ICU 2.8 Use getSortKey(...) instead
+     */
+    virtual CollationKey& getCollationKey(const UChar*source,
+                                          int32_t sourceLength,
+                                          CollationKey& key,
+                                          UErrorCode& status) const = 0;
+    /**
+     * Generates the hash code for the collation object
+     * @stable ICU 2.0
+     */
+    virtual int32_t hashCode(void) const = 0;
+
+    /**
+     * Gets the locale of the Collator
+     *
+     * @param type can be either requested, valid or actual locale. For more
+     *             information see the definition of ULocDataLocaleType in
+     *             uloc.h
+     * @param status the error code status.
+     * @return locale where the collation data lives. If the collator
+     *         was instantiated from rules, locale is empty.
+     * @deprecated ICU 2.8 This API is under consideration for revision
+     * in ICU 3.0.
+     */
+    virtual const Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;
+
+    /**
+     * Convenience method for comparing two strings based on the collation rules.
+     * @param source the source string to be compared with.
+     * @param target the target string to be compared with.
+     * @return true if the first string is greater than the second one,
+     *         according to the collation rules. false, otherwise.
+     * @see Collator#compare
+     * @stable ICU 2.0
+     */
+    UBool greater(const UnicodeString& source, const UnicodeString& target)
+                  const;
+
+    /**
+     * Convenience method for comparing two strings based on the collation rules.
+     * @param source the source string to be compared with.
+     * @param target the target string to be compared with.
+     * @return true if the first string is greater than or equal to the second
+     *         one, according to the collation rules. false, otherwise.
+     * @see Collator#compare
+     * @stable ICU 2.0
+     */
+    UBool greaterOrEqual(const UnicodeString& source,
+                         const UnicodeString& target) const;
+
+    /**
+     * Convenience method for comparing two strings based on the collation rules.
+     * @param source the source string to be compared with.
+     * @param target the target string to be compared with.
+     * @return true if the strings are equal according to the collation rules.
+     *         false, otherwise.
+     * @see Collator#compare
+     * @stable ICU 2.0
+     */
+    UBool equals(const UnicodeString& source, const UnicodeString& target) const;
+
+    /**
+     * Determines the minimum strength that will be use in comparison or
+     * transformation.
+     * <p>E.g. with strength == SECONDARY, the tertiary difference is ignored
+     * <p>E.g. with strength == PRIMARY, the secondary and tertiary difference
+     * are ignored.
+     * @return the current comparison level.
+     * @see Collator#setStrength
+     * @deprecated ICU 2.6 Use getAttribute(UCOL_STRENGTH...) instead
+     */
+    virtual ECollationStrength getStrength(void) const = 0;
+
+    /**
+     * Sets the minimum strength to be used in comparison or transformation.
+     * <p>Example of use:
+     * <pre>
+     *  \code
+     *  UErrorCode status = U_ZERO_ERROR;
+     *  Collator*myCollation = Collator::createInstance(Locale::US, status);
+     *  if (U_FAILURE(status)) return;
+     *  myCollation->setStrength(Collator::PRIMARY);
+     *  // result will be "abc" == "ABC"
+     *  // tertiary differences will be ignored
+     *  Collator::ComparisonResult result = myCollation->compare("abc", "ABC");
+     * \endcode
+     * </pre>
+     * @see Collator#getStrength
+     * @param newStrength the new comparison level.
+     * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead
+     */
+    virtual void setStrength(ECollationStrength newStrength) = 0;
+
+    /**
+     * Get name of the object for the desired Locale, in the desired langauge
+     * @param objectLocale must be from getAvailableLocales
+     * @param displayLocale specifies the desired locale for output
+     * @param name the fill-in parameter of the return value
+     * @return display-able name of the object for the object locale in the
+     *         desired language
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         const Locale& displayLocale,
+                                         UnicodeString& name);
+
+    /**
+    * Get name of the object for the desired Locale, in the langauge of the
+    * default locale.
+    * @param objectLocale must be from getAvailableLocales
+    * @param name the fill-in parameter of the return value
+    * @return name of the object for the desired locale in the default language
+    * @stable ICU 2.0
+    */
+    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
+                                         UnicodeString& name);
+
+    /**
+     * Get the set of Locales for which Collations are installed.
+     *
+     * <p>Note this does not include locales supported by registered collators.
+     * If collators might have been registered, use the overload of getAvailableLocales
+     * that returns a StringEnumeration.</p>
+     *
+     * @param count the output parameter of number of elements in the locale list
+     * @return the list of available locales for which collations are installed
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Return a StringEnumeration over the locales available at the time of the call,
+     * including registered locales.  If a severe error occurs (such as out of memory
+     * condition) this will return null. If there is no locale data, an empty enumeration
+     * will be returned.
+     * @return a StringEnumeration over the locales available at the time of the call
+     * @stable ICU 2.6
+     */
+    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
+
+    /**
+     * Create a string enumerator of all possible keywords that are relevant to
+     * collation. At this point, the only recognized keyword for this
+     * service is "collation".
+     * @param status input-output error code
+     * @return a string enumeration over locale strings. The caller is
+     * responsible for closing the result.
+     * @stable ICU 3.0
+     */
+    static StringEnumeration* U_EXPORT2 getKeywords(UErrorCode& status);
+
+    /**
+     * Given a keyword, create a string enumeration of all values
+     * for that keyword that are currently in use.
+     * @param keyword a particular keyword as enumerated by
+     * ucol_getKeywords. If any other keyword is passed in, status is set
+     * to U_ILLEGAL_ARGUMENT_ERROR.
+     * @param status input-output error code
+     * @return a string enumeration over collation keyword values, or NULL
+     * upon error. The caller is responsible for deleting the result.
+     * @stable ICU 3.0
+     */
+    static StringEnumeration* U_EXPORT2 getKeywordValues(const char *keyword, UErrorCode& status);
+
+    /**
+     * Return the functionally equivalent locale for the given
+     * requested locale, with respect to given keyword, for the
+     * collation service.  If two locales return the same result, then
+     * collators instantiated for these locales will behave
+     * equivalently.  The converse is not always true; two collators
+     * may in fact be equivalent, but return different results, due to
+     * internal details.  The return result has no other meaning than
+     * that stated above, and implies nothing as to the relationship
+     * between the two locales.  This is intended for use by
+     * applications who wish to cache collators, or otherwise reuse
+     * collators when possible.  The functional equivalent may change
+     * over time.  For more information, please see the <a
+     * href="http://icu-project.org/userguide/locale.html#services">
+     * Locales and Services</a> section of the ICU User Guide.
+     * @param keyword a particular keyword as enumerated by
+     * ucol_getKeywords.
+     * @param locale the requested locale
+     * @param isAvailable reference to a fillin parameter that
+     * indicates whether the requested locale was 'available' to the
+     * collation service. A locale is defined as 'available' if it
+     * physically exists within the collation locale data.
+     * @param status reference to input-output error code
+     * @return the functionally equivalent collation locale, or the root
+     * locale upon error.
+     * @stable ICU 3.0
+     */
+    static Locale U_EXPORT2 getFunctionalEquivalent(const char* keyword, const Locale& locale,
+                                          UBool& isAvailable, UErrorCode& status);
+
+#if !UCONFIG_NO_SERVICE
+    /**
+     * Register a new Collator.  The collator will be adopted.
+     * @param toAdopt the Collator instance to be adopted
+     * @param locale the locale with which the collator will be associated
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this collator
+     * @stable ICU 2.6
+     */
+    static URegistryKey U_EXPORT2 registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status);
+
+    /**
+     * Register a new CollatorFactory.  The factory will be adopted.
+     * @param toAdopt the CollatorFactory instance to be adopted
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this collator
+     * @stable ICU 2.6
+     */
+    static URegistryKey U_EXPORT2 registerFactory(CollatorFactory* toAdopt, UErrorCode& status);
+
+    /**
+     * Unregister a previously-registered Collator or CollatorFactory
+     * using the key returned from the register call.  Key becomes
+     * invalid after a successful call and should not be used again.
+     * The object corresponding to the key will be deleted.
+     * @param key the registry key returned by a previous call to registerInstance
+     * @param status the in/out status code, no special meanings are assigned
+     * @return TRUE if the collator for the key was successfully unregistered
+     * @stable ICU 2.6
+     */
+    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
+#endif /* UCONFIG_NO_SERVICE */
+
+    /**
+     * Gets the version information for a Collator.
+     * @param info the version # information, the result will be filled in
+     * @stable ICU 2.0
+     */
+    virtual void getVersion(UVersionInfo info) const = 0;
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual method.
+     * This method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     * @return The class ID for this object. All objects of a given class have
+     *         the same class ID.  Objects of other classes have different class
+     *         IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+    /**
+     * Universal attribute setter
+     * @param attr attribute type
+     * @param value attribute value
+     * @param status to indicate whether the operation went on smoothly or
+     *        there were errors
+     * @stable ICU 2.2
+     */
+    virtual void setAttribute(UColAttribute attr, UColAttributeValue value,
+                              UErrorCode &status) = 0;
+
+    /**
+     * Universal attribute getter
+     * @param attr attribute type
+     * @param status to indicate whether the operation went on smoothly or
+     *        there were errors
+     * @return attribute value
+     * @stable ICU 2.2
+     */
+    virtual UColAttributeValue getAttribute(UColAttribute attr,
+                                            UErrorCode &status) = 0;
+
+    /**
+     * Sets the variable top to a collation element value of a string supplied.
+     * @param varTop one or more (if contraction) UChars to which the variable top should be set
+     * @param len length of variable top string. If -1 it is considered to be zero terminated.
+     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
+     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>
+     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
+     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined
+     * @stable ICU 2.0
+     */
+    virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;
+
+    /**
+     * Sets the variable top to a collation element value of a string supplied.
+     * @param varTop an UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
+     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
+     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>
+     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
+     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined
+     * @stable ICU 2.0
+     */
+    virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status) = 0;
+
+    /**
+     * Sets the variable top to a collation element value supplied. Variable top is set to the upper 16 bits.
+     * Lower 16 bits are ignored.
+     * @param varTop CE value, as returned by setVariableTop or ucol)getVariableTop
+     * @param status error code (not changed by function)
+     * @stable ICU 2.0
+     */
+    virtual void setVariableTop(const uint32_t varTop, UErrorCode &status) = 0;
+
+    /**
+     * Gets the variable top value of a Collator.
+     * Lower 16 bits are undefined and should be ignored.
+     * @param status error code (not changed by function). If error code is set, the return value is undefined.
+     * @stable ICU 2.0
+     */
+    virtual uint32_t getVariableTop(UErrorCode &status) const = 0;
+
+    /**
+     * Get an UnicodeSet that contains all the characters and sequences
+     * tailored in this collator.
+     * @param status      error code of the operation
+     * @return a pointer to a UnicodeSet object containing all the
+     *         code points and sequences that may sort differently than
+     *         in the UCA. The object must be disposed of by using delete
+     * @stable ICU 2.4
+     */
+    virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
+
+
+    /**
+     * Thread safe cloning operation
+     * @return pointer to the new clone, user should remove it.
+     * @stable ICU 2.2
+     */
+    virtual Collator* safeClone(void) = 0;
+
+    /**
+     * Get the sort key as an array of bytes from an UnicodeString.
+     * Sort key byte arrays are zero-terminated and can be compared using
+     * strcmp().
+     * @param source string to be processed.
+     * @param result buffer to store result in. If NULL, number of bytes needed
+     *        will be returned.
+     * @param resultLength length of the result buffer. If if not enough the
+     *        buffer will be filled to capacity.
+     * @return Number of bytes needed for storing the sort key
+     * @stable ICU 2.2
+     */
+    virtual int32_t getSortKey(const UnicodeString& source,
+                              uint8_t* result,
+                              int32_t resultLength) const = 0;
+
+    /**
+     * Get the sort key as an array of bytes from an UChar buffer.
+     * Sort key byte arrays are zero-terminated and can be compared using
+     * strcmp().
+     * @param source string to be processed.
+     * @param sourceLength length of string to be processed.
+     *        If -1, the string is 0 terminated and length will be decided by the
+     *        function.
+     * @param result buffer to store result in. If NULL, number of bytes needed
+     *        will be returned.
+     * @param resultLength length of the result buffer. If if not enough the
+     *        buffer will be filled to capacity.
+     * @return Number of bytes needed for storing the sort key
+     * @stable ICU 2.2
+     */
+    virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,
+                               uint8_t*result, int32_t resultLength) const = 0;
+
+    /**
+     * Produce a bound for a given sortkey and a number of levels.
+     * Return value is always the number of bytes needed, regardless of
+     * whether the result buffer was big enough or even valid.<br>
+     * Resulting bounds can be used to produce a range of strings that are
+     * between upper and lower bounds. For example, if bounds are produced
+     * for a sortkey of string "smith", strings between upper and lower
+     * bounds with one level would include "Smith", "SMITH", "sMiTh".<br>
+     * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER
+     * is produced, strings matched would be as above. However, if bound
+     * produced using UCOL_BOUND_UPPER_LONG is used, the above example will
+     * also match "Smithsonian" and similar.<br>
+     * For more on usage, see example in cintltst/capitst.c in procedure
+     * TestBounds.
+     * Sort keys may be compared using <TT>strcmp</TT>.
+     * @param source The source sortkey.
+     * @param sourceLength The length of source, or -1 if null-terminated.
+     *                     (If an unmodified sortkey is passed, it is always null
+     *                      terminated).
+     * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which
+     *                  produces a lower inclusive bound, UCOL_BOUND_UPPER, that
+     *                  produces upper bound that matches strings of the same length
+     *                  or UCOL_BOUND_UPPER_LONG that matches strings that have the
+     *                  same starting substring as the source string.
+     * @param noOfLevels  Number of levels required in the resulting bound (for most
+     *                    uses, the recommended value is 1). See users guide for
+     *                    explanation on number of levels a sortkey can have.
+     * @param result A pointer to a buffer to receive the resulting sortkey.
+     * @param resultLength The maximum size of result.
+     * @param status Used for returning error code if something went wrong. If the
+     *               number of levels requested is higher than the number of levels
+     *               in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is
+     *               issued.
+     * @return The size needed to fully store the bound.
+     * @see ucol_keyHashCode
+     * @stable ICU 2.1
+     */
+    static int32_t U_EXPORT2 getBound(const uint8_t       *source,
+            int32_t             sourceLength,
+            UColBoundMode       boundType,
+            uint32_t            noOfLevels,
+            uint8_t             *result,
+            int32_t             resultLength,
+            UErrorCode          &status);
+
+
+protected:
+
+    // Collator protected constructors -------------------------------------
+
+    /**
+    * Default constructor.
+    * Constructor is different from the old default Collator constructor.
+    * The task for determing the default collation strength and normalization
+    * mode is left to the child class.
+    * @stable ICU 2.0
+    */
+    Collator();
+
+    /**
+    * Constructor.
+    * Empty constructor, does not handle the arguments.
+    * This constructor is done for backward compatibility with 1.7 and 1.8.
+    * The task for handling the argument collation strength and normalization
+    * mode is left to the child class.
+    * @param collationStrength collation strength
+    * @param decompositionMode
+    * @deprecated ICU 2.4. Subclasses should use the default constructor
+    * instead and handle the strength and normalization mode themselves.
+    */
+    Collator(UCollationStrength collationStrength,
+             UNormalizationMode decompositionMode);
+
+    /**
+    * Copy constructor.
+    * @param other Collator object to be copied from
+    * @stable ICU 2.0
+    */
+    Collator(const Collator& other);
+
+    // Collator protected methods -----------------------------------------
+
+
+   /**
+    * Used internally by registraton to define the requested and valid locales.
+    * @param requestedLocale the requsted locale
+    * @param validLocale the valid locale
+    * @internal
+    */
+    virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale);
+
+public:
+#if !UCONFIG_NO_SERVICE
+    /**
+     * used only by ucol_open, not for public use
+     * @internal
+     */
+    static UCollator* createUCollator(const char* loc, UErrorCode* status);
+#endif
+private:
+    /**
+     * Assignment operator. Private for now.
+     * @internal
+     */
+    Collator& operator=(const Collator& other);
+
+    friend class CFactory;
+    friend class SimpleCFactory;
+    friend class ICUCollatorFactory;
+    friend class ICUCollatorService;
+    static Collator* makeInstance(const Locale& desiredLocale,
+                                  UErrorCode& status);
+
+    // Collator private data members ---------------------------------------
+
+    /*
+    synwee : removed as attributes to be handled by child class
+    UCollationStrength  strength;
+    Normalizer::EMode  decmp;
+    */
+    /* This is useless information */
+/*  static const UVersionInfo fVersion;*/
+};
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * A factory, used with registerFactory, the creates multiple collators and provides
+ * display names for them.  A factory supports some number of locales-- these are the
+ * locales for which it can create collators.  The factory can be visible, in which
+ * case the supported locales will be enumerated by getAvailableLocales, or invisible,
+ * in which they are not.  Invisible locales are still supported, they are just not
+ * listed by getAvailableLocales.
+ * <p>
+ * If standard locale display names are sufficient, Collator instances can
+ * be registered using registerInstance instead.</p>
+ * <p>
+ * Note: if the collators are to be used from C APIs, they must be instances
+ * of RuleBasedCollator.</p>
+ *
+ * @stable ICU 2.6
+ */
+class U_I18N_API CollatorFactory : public UObject {
+public:
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~CollatorFactory();
+
+    /**
+     * Return true if this factory is visible.  Default is true.
+     * If not visible, the locales supported by this factory will not
+     * be listed by getAvailableLocales.
+     * @return true if the factory is visible.
+     * @stable ICU 2.6
+     */
+    virtual UBool visible(void) const;
+
+    /**
+     * Return a collator for the provided locale.  If the locale
+     * is not supported, return NULL.
+     * @param loc the locale identifying the collator to be created.
+     * @return a new collator if the locale is supported, otherwise NULL.
+     * @stable ICU 2.6
+     */
+    virtual Collator* createCollator(const Locale& loc) = 0;
+
+    /**
+     * Return the name of the collator for the objectLocale, localized for the displayLocale.
+     * If objectLocale is not supported, or the factory is not visible, set the result string
+     * to bogus.
+     * @param objectLocale the locale identifying the collator
+     * @param displayLocale the locale for which the display name of the collator should be localized
+     * @param result an output parameter for the display name, set to bogus if not supported.
+     * @return the display name
+     * @stable ICU 2.6
+     */
+    virtual  UnicodeString& getDisplayName(const Locale& objectLocale,
+                                           const Locale& displayLocale,
+                                           UnicodeString& result);
+
+    /**
+     * Return an array of all the locale names directly supported by this factory.
+     * The number of names is returned in count.  This array is owned by the factory.
+     * Its contents must never change.
+     * @param count output parameter for the number of locales supported by the factory
+     * @param status the in/out error code
+     * @return a pointer to an array of count UnicodeStrings.
+     * @stable ICU 2.6
+     */
+    virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) = 0;
+};
+#endif /* UCONFIG_NO_SERVICE */
+
+// Collator inline methods -----------------------------------------------
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/curramt.h b/CoreFoundation/icu/unicode/curramt.h
new file mode 100644
index 0000000..c33e6f1
--- /dev/null
+++ b/CoreFoundation/icu/unicode/curramt.h
@@ -0,0 +1,130 @@
+/*
+**********************************************************************
+* Copyright (c) 2004-2006, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: April 26, 2004
+* Since: ICU 3.0
+**********************************************************************
+*/
+#ifndef __CURRENCYAMOUNT_H__
+#define __CURRENCYAMOUNT_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/measure.h"
+#include "unicode/currunit.h"
+
+/**
+ * \file 
+ * \brief C++ API: Currency Amount Object.
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ *
+ * A currency together with a numeric amount, such as 200 USD.
+ *
+ * @author Alan Liu
+ * @stable ICU 3.0
+ */
+class U_I18N_API CurrencyAmount: public Measure {
+ public:
+    /**
+     * Construct an object with the given numeric amount and the given
+     * ISO currency code.
+     * @param amount a numeric object; amount.isNumeric() must be TRUE
+     * @param isoCode the 3-letter ISO 4217 currency code; must not be
+     * NULL and must have length 3
+     * @param ec input-output error code. If the amount or the isoCode
+     * is invalid, then this will be set to a failing value.
+     * @stable ICU 3.0
+     */
+    CurrencyAmount(const Formattable& amount, const UChar* isoCode,
+                   UErrorCode &ec);
+
+    /**
+     * Construct an object with the given numeric amount and the given
+     * ISO currency code.
+     * @param amount the amount of the given currency
+     * @param isoCode the 3-letter ISO 4217 currency code; must not be
+     * NULL and must have length 3
+     * @param ec input-output error code. If the isoCode is invalid,
+     * then this will be set to a failing value.
+     * @stable ICU 3.0
+     */
+    CurrencyAmount(double amount, const UChar* isoCode,
+                   UErrorCode &ec);
+
+    /**
+     * Copy constructor
+     * @stable ICU 3.0
+     */
+    CurrencyAmount(const CurrencyAmount& other);
+ 
+    /**
+     * Assignment operator
+     * @stable ICU 3.0
+     */
+    CurrencyAmount& operator=(const CurrencyAmount& other);
+
+    /**
+     * Return a polymorphic clone of this object.  The result will
+     * have the same class as returned by getDynamicClassID().
+     * @stable ICU 3.0
+     */
+    virtual UObject* clone() const;
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~CurrencyAmount();
+    
+    /**
+     * Returns a unique class ID for this object POLYMORPHICALLY.
+     * This method implements a simple form of RTTI used by ICU.
+     * @return The class ID for this object. All objects of a given
+     * class have the same class ID.  Objects of other classes have
+     * different class IDs.
+     * @stable ICU 3.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * Returns the class ID for this class. This is used to compare to
+     * the return value of getDynamicClassID().
+     * @return The class ID for all objects of this class.
+     * @stable ICU 3.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * Return the currency unit object of this object.
+     * @stable ICU 3.0
+     */
+    inline const CurrencyUnit& getCurrency() const;
+
+    /**
+     * Return the ISO currency code of this object.
+     * @stable ICU 3.0
+     */
+    inline const UChar* getISOCurrency() const;
+};
+
+inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
+    return (const CurrencyUnit&) getUnit();
+}
+
+inline const UChar* CurrencyAmount::getISOCurrency() const {
+    return getCurrency().getISOCurrency();
+}
+
+U_NAMESPACE_END
+
+#endif // !UCONFIG_NO_FORMATTING
+#endif // __CURRENCYAMOUNT_H__
diff --git a/CoreFoundation/icu/unicode/currunit.h b/CoreFoundation/icu/unicode/currunit.h
new file mode 100644
index 0000000..ecd9411
--- /dev/null
+++ b/CoreFoundation/icu/unicode/currunit.h
@@ -0,0 +1,117 @@
+/*
+**********************************************************************
+* Copyright (c) 2004-2006, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: April 26, 2004
+* Since: ICU 3.0
+**********************************************************************
+*/
+#ifndef __CURRENCYUNIT_H__
+#define __CURRENCYUNIT_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/measunit.h"
+
+/**
+ * \file 
+ * \brief C++ API: Currency Unit Information.
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
+ * yen).  This class is a thin wrapper over a UChar string that
+ * subclasses MeasureUnit, for use with Measure and MeasureFormat.
+ *
+ * @author Alan Liu
+ * @stable ICU 3.0
+ */
+class U_I18N_API CurrencyUnit: public MeasureUnit {
+ public:
+    /**
+     * Construct an object with the given ISO currency code.
+     * @param isoCode the 3-letter ISO 4217 currency code; must not be
+     * NULL and must have length 3
+     * @param ec input-output error code. If the isoCode is invalid,
+     * then this will be set to a failing value.
+     * @stable ICU 3.0
+     */
+    CurrencyUnit(const UChar* isoCode, UErrorCode &ec);
+
+    /**
+     * Copy constructor
+     * @stable ICU 3.0
+     */
+    CurrencyUnit(const CurrencyUnit& other);
+
+    /**
+     * Assignment operator
+     * @stable ICU 3.0
+     */
+    CurrencyUnit& operator=(const CurrencyUnit& other);
+
+    /**
+     * Return a polymorphic clone of this object.  The result will
+     * have the same class as returned by getDynamicClassID().
+     * @stable ICU 3.0
+     */
+    virtual UObject* clone() const;
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~CurrencyUnit();
+
+    /**
+     * Equality operator.  Return true if this object is equal
+     * to the given object.
+     * @stable ICU 3.0
+     */
+    UBool operator==(const UObject& other) const;
+
+    /**
+     * Returns a unique class ID for this object POLYMORPHICALLY.
+     * This method implements a simple form of RTTI used by ICU.
+     * @return The class ID for this object. All objects of a given
+     * class have the same class ID.  Objects of other classes have
+     * different class IDs.
+     * @stable ICU 3.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * Returns the class ID for this class. This is used to compare to
+     * the return value of getDynamicClassID().
+     * @return The class ID for all objects of this class.
+     * @stable ICU 3.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * Return the ISO currency code of this object.
+     * @stable ICU 3.0
+     */
+    inline const UChar* getISOCurrency() const;
+
+ private:
+    /**
+     * The ISO 4217 code of this object.
+     */
+    UChar isoCode[4];
+};
+
+inline const UChar* CurrencyUnit::getISOCurrency() const {
+    return isoCode;
+}
+
+U_NAMESPACE_END
+
+#endif // !UCONFIG_NO_FORMATTING
+#endif // __CURRENCYUNIT_H__
diff --git a/CoreFoundation/icu/unicode/datefmt.h b/CoreFoundation/icu/unicode/datefmt.h
new file mode 100644
index 0000000..7aeab2c
--- /dev/null
+++ b/CoreFoundation/icu/unicode/datefmt.h
@@ -0,0 +1,700 @@
+/*
+ ********************************************************************************
+ *   Copyright (C) 1997-2008, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ ********************************************************************************
+ *
+ * File DATEFMT.H
+ *
+ * Modification History:
+ *
+ *   Date        Name        Description
+ *   02/19/97    aliu        Converted from java.
+ *   04/01/97    aliu        Added support for centuries.
+ *   07/23/98    stephen     JDK 1.2 sync
+ *   11/15/99    weiv        Added support for week of year/day of week formatting
+ ********************************************************************************
+ */
+
+#ifndef DATEFMT_H
+#define DATEFMT_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/udat.h"
+#include "unicode/calendar.h"
+#include "unicode/numfmt.h"
+#include "unicode/format.h"
+#include "unicode/locid.h"
+
+/**
+ * \file 
+ * \brief C++ API: Abstract class for converting dates.
+ */
+
+U_NAMESPACE_BEGIN
+
+class TimeZone;
+
+/**
+ * DateFormat is an abstract class for a family of classes that convert dates and
+ * times from their internal representations to textual form and back again in a
+ * language-independent manner. Converting from the internal representation (milliseconds
+ * since midnight, January 1, 1970) to text is known as "formatting," and converting
+ * from text to millis is known as "parsing."  We currently define only one concrete
+ * subclass of DateFormat: SimpleDateFormat, which can handle pretty much all normal
+ * date formatting and parsing actions.
+ * <P>
+ * DateFormat helps you to format and parse dates for any locale. Your code can
+ * be completely independent of the locale conventions for months, days of the
+ * week, or even the calendar format: lunar vs. solar.
+ * <P>
+ * To format a date for the current Locale, use one of the static factory
+ * methods:
+ * <pre>
+ * \code
+ *      DateFormat* dfmt = DateFormat::createDateInstance();
+ *      UDate myDate = Calendar::getNow();
+ *      UnicodeString myString;
+ *      myString = dfmt->format( myDate, myString );
+ * \endcode
+ * </pre>
+ * If you are formatting multiple numbers, it is more efficient to get the
+ * format and use it multiple times so that the system doesn't have to fetch the
+ * information about the local language and country conventions multiple times.
+ * <pre>
+ * \code
+ *      DateFormat* df = DateFormat::createDateInstance();
+ *      UnicodeString myString;
+ *      UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
+ *      for (int32_t i = 0; i < 3; ++i) {
+ *          myString.remove();
+ *          cout << df->format( myDateArr[i], myString ) << endl;
+ *      }
+ * \endcode
+ * </pre>
+ * To get specific fields of a date, you can use UFieldPosition to
+ * get specific fields.
+ * <pre>
+ * \code
+ *      DateFormat* dfmt = DateFormat::createDateInstance();
+ *      FieldPosition pos(DateFormat::YEAR_FIELD);
+ *      UnicodeString myString;
+ *      myString = dfmt->format( myDate, myString );
+ *      cout << myString << endl;
+ *      cout << pos.getBeginIndex() << "," << pos. getEndIndex() << endl;
+ * \endcode
+ * </pre>
+ * To format a date for a different Locale, specify it in the call to
+ * createDateInstance().
+ * <pre>
+ * \code
+ *       DateFormat* df =
+ *           DateFormat::createDateInstance( DateFormat::SHORT, Locale::getFrance());
+ * \endcode
+ * </pre>
+ * You can use a DateFormat to parse also.
+ * <pre>
+ * \code
+ *       UErrorCode status = U_ZERO_ERROR;
+ *       UDate myDate = df->parse(myString, status);
+ * \endcode
+ * </pre>
+ * Use createDateInstance() to produce the normal date format for that country.
+ * There are other static factory methods available. Use createTimeInstance()
+ * to produce the normal time format for that country. Use createDateTimeInstance()
+ * to produce a DateFormat that formats both date and time. You can pass in
+ * different options to these factory methods to control the length of the
+ * result; from SHORT to MEDIUM to LONG to FULL. The exact result depends on the
+ * locale, but generally:
+ * <ul type=round>
+ *   <li>   SHORT is completely numeric, such as 12/13/52 or 3:30pm
+ *   <li>   MEDIUM is longer, such as Jan 12, 1952
+ *   <li>   LONG is longer, such as January 12, 1952 or 3:30:32pm
+ *   <li>   FULL is pretty completely specified, such as
+ *          Tuesday, April 12, 1952 AD or 3:30:42pm PST.
+ * </ul>
+ * You can also set the time zone on the format if you wish. If you want even
+ * more control over the format or parsing, (or want to give your users more
+ * control), you can try casting the DateFormat you get from the factory methods
+ * to a SimpleDateFormat. This will work for the majority of countries; just
+ * remember to chck getDynamicClassID() before carrying out the cast.
+ * <P>
+ * You can also use forms of the parse and format methods with ParsePosition and
+ * FieldPosition to allow you to
+ * <ul type=round>
+ *   <li>   Progressively parse through pieces of a string.
+ *   <li>   Align any particular field, or find out where it is for selection
+ *          on the screen.
+ * </ul>
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API DateFormat : public Format {
+public:
+
+    /**
+     * Constants for various style patterns. These reflect the order of items in
+     * the DateTimePatterns resource. There are 4 time patterns, 4 date patterns,
+     * and then the date-time pattern. Each block of 4 values in the resource occurs
+     * in the order full, long, medium, short.
+     * @stable ICU 2.4
+     */
+    enum EStyle
+    {
+        kNone   = -1,
+
+        kFull   = 0,
+        kLong   = 1,
+        kMedium = 2,
+        kShort  = 3,
+
+        kDateOffset   = kShort + 1,
+     // kFull   + kDateOffset = 4
+     // kLong   + kDateOffset = 5
+     // kMedium + kDateOffset = 6
+     // kShort  + kDateOffset = 7
+
+        kDateTime             = 8,
+        
+
+        // relative dates
+        kRelative = (1 << 7),
+        
+        kFullRelative = (kFull | kRelative),
+            
+        kLongRelative = kLong | kRelative,
+        
+        kMediumRelative = kMedium | kRelative,
+        
+        kShortRelative = kShort | kRelative,
+        
+
+        kDefault      = kMedium,
+
+
+
+    /**
+     * These constants are provided for backwards compatibility only.
+     * Please use the C++ style constants defined above.
+     */
+        FULL        = kFull,
+        LONG        = kLong,
+        MEDIUM        = kMedium,
+        SHORT        = kShort,
+        DEFAULT        = kDefault,
+        DATE_OFFSET    = kDateOffset,
+        NONE        = kNone,
+        DATE_TIME    = kDateTime
+    };
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~DateFormat();
+
+    /**
+     * Equality operator.  Returns true if the two formats have the same behavior.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format&) const;
+
+    /**
+     * Format an object to produce a string. This method handles Formattable
+     * objects with a UDate type. If a the Formattable object type is not a Date,
+     * then it returns a failing UErrorCode.
+     *
+     * @param obj       The object to format. Must be a Date.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+    /**
+     * Formats a date into a date/time string. This is an abstract method which
+     * concrete subclasses must implement.
+     * <P>
+     * On input, the FieldPosition parameter may have its "field" member filled with
+     * an enum value specifying a field.  On output, the FieldPosition will be filled
+     * in with the text offsets for that field.
+     * <P> For example, given a time text
+     * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
+     * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
+     * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
+     * <P> Notice
+     * that if the same time field appears more than once in a pattern, the status will
+     * be set for the first occurence of that time field. For instance,
+     * formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
+     * using the pattern "h a z (zzzz)" and the alignment field
+     * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
+     * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
+     * occurence of the timezone pattern character 'z'.
+     *
+     * @param cal           Calendar set to the date and time to be formatted
+     *                      into a date/time string.
+     * @param appendTo      Output parameter to receive result.
+     *                      Result is appended to existing contents.
+     * @param fieldPosition On input: an alignment field, if desired (see examples above)
+     *                      On output: the offsets of the alignment field (see examples above)
+     * @return              Reference to 'appendTo' parameter.
+     * @stable ICU 2.1
+     */
+    virtual UnicodeString& format(  Calendar& cal,
+                                    UnicodeString& appendTo,
+                                    FieldPosition& fieldPosition) const = 0;
+
+    /**
+     * Formats a UDate into a date/time string.
+     * <P>
+     * On input, the FieldPosition parameter may have its "field" member filled with
+     * an enum value specifying a field.  On output, the FieldPosition will be filled
+     * in with the text offsets for that field.
+     * <P> For example, given a time text
+     * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
+     * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
+     * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
+     * <P> Notice
+     * that if the same time field appears more than once in a pattern, the status will
+     * be set for the first occurence of that time field. For instance,
+     * formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
+     * using the pattern "h a z (zzzz)" and the alignment field
+     * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
+     * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
+     * occurence of the timezone pattern character 'z'.
+     *
+     * @param date          UDate to be formatted into a date/time string.
+     * @param appendTo      Output parameter to receive result.
+     *                      Result is appended to existing contents.
+     * @param fieldPosition On input: an alignment field, if desired (see examples above)
+     *                      On output: the offsets of the alignment field (see examples above)
+     * @return              Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(  UDate date,
+                            UnicodeString& appendTo,
+                            FieldPosition& fieldPosition) const;
+
+    /**
+     * Formats a UDate into a date/time string. If there is a problem, you won't
+     * know, using this method. Use the overloaded format() method which takes a
+     * FieldPosition& to detect formatting problems.
+     *
+     * @param date      The UDate value to be formatted into a string.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(UDate date, UnicodeString& appendTo) const;
+
+    /**
+     * Redeclared Format method.
+     *
+     * @param obj       The object to be formatted into a string.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+
+    /**
+     * Parse a date/time string.
+     *
+     * @param text      The string to be parsed into a UDate value.
+     * @param status    Output param to be set to success/failure code. If
+     *                  'text' cannot be parsed, it will be set to a failure
+     *                  code.
+     * @result          The parsed UDate value, if successful.
+     * @stable ICU 2.0
+     */
+    virtual UDate parse( const UnicodeString& text,
+                        UErrorCode& status) const;
+
+    /**
+     * Parse a date/time string beginning at the given parse position. For
+     * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
+     * that is equivalent to Date(837039928046).
+     * <P>
+     * By default, parsing is lenient: If the input is not in the form used by
+     * this object's format method but can still be parsed as a date, then the
+     * parse succeeds. Clients may insist on strict adherence to the format by
+     * calling setLenient(false).
+     *
+     * @see DateFormat::setLenient(boolean)
+     *
+     * @param text  The date/time string to be parsed
+     * @param cal   a Calendar set to the date and time to be formatted
+     *              into a date/time string.
+     * @param pos   On input, the position at which to start parsing; on
+     *              output, the position at which parsing terminated, or the
+     *              start position if the parse failed.
+     * @return      A valid UDate if the input could be parsed.
+     * @stable ICU 2.1
+     */
+    virtual void parse( const UnicodeString& text,
+                        Calendar& cal,
+                        ParsePosition& pos) const = 0;
+
+    /**
+     * Parse a date/time string beginning at the given parse position. For
+     * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
+     * that is equivalent to Date(837039928046).
+     * <P>
+     * By default, parsing is lenient: If the input is not in the form used by
+     * this object's format method but can still be parsed as a date, then the
+     * parse succeeds. Clients may insist on strict adherence to the format by
+     * calling setLenient(false).
+     *
+     * @see DateFormat::setLenient(boolean)
+     *
+     * @param text  The date/time string to be parsed
+     * @param pos   On input, the position at which to start parsing; on
+     *              output, the position at which parsing terminated, or the
+     *              start position if the parse failed.
+     * @return      A valid UDate if the input could be parsed.
+     * @stable ICU 2.0
+     */
+    UDate parse( const UnicodeString& text,
+                 ParsePosition& pos) const;
+
+    /**
+     * Parse a string to produce an object. This methods handles parsing of
+     * date/time strings into Formattable objects with UDate types.
+     * <P>
+     * Before calling, set parse_pos.index to the offset you want to start
+     * parsing at in the source. After calling, parse_pos.index is the end of
+     * the text you parsed. If error occurs, index is unchanged.
+     * <P>
+     * When parsing, leading whitespace is discarded (with a successful parse),
+     * while trailing whitespace is left as is.
+     * <P>
+     * See Format::parseObject() for more.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param parse_pos The position to start parsing at. Upon return
+     *                  this param is set to the position after the
+     *                  last character successfully parsed. If the
+     *                  source is not parsed successfully, this param
+     *                  will remain unchanged.
+     * @return          A newly created Formattable* object, or NULL
+     *                  on failure.  The caller owns this and should
+     *                  delete it when done.
+     * @stable ICU 2.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& parse_pos) const;
+
+    /**
+     * Create a default date/time formatter that uses the SHORT style for both
+     * the date and the time.
+     *
+     * @return A date/time formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createInstance(void);
+
+    /**
+     * This is for ICU internal use only. Please do not use.
+     * Create a date/time formatter from skeleton and a given locale.
+     *
+     * Users are encouraged to use the skeleton macros defined in udat.h.
+     * For example, MONTH_WEEKDAY_DAY, which is "MMMMEEEEd",
+     * and which means the pattern should have day, month, and day-of-week 
+     * fields, and follow the long date format defined in date time pattern.
+     * For example, for English, the full pattern should be 
+     * "EEEE, MMMM d".
+     * 
+     * Temporarily, this is an internal API, used by DateIntevalFormat only.
+     * There will be a new set of APIs for the same purpose coming soon.
+     * After which, this API will be replaced.
+     *
+     * @param skeleton  the skeleton on which date format based.
+     * @param locale    the given locale.
+     * @param status    Output param to be set to success/failure code.
+     *                  If it is failure, the returned date formatter will
+     *                  be NULL.
+     * @return          a simple date formatter which the caller owns.
+     * @internal ICU 4.0
+     */
+    static DateFormat* U_EXPORT2 createPatternInstance(
+                                                const UnicodeString& skeleton,
+                                                const Locale& locale,
+                                                UErrorCode& status);
+
+    /**
+     * Creates a time formatter with the given formatting style for the given
+     * locale.
+     *
+     * @param style     The given formatting style. For example,
+     *                  SHORT for "h:mm a" in the US locale.
+     * @param aLocale   The given locale.
+     * @return          A time formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createTimeInstance(EStyle style = kDefault,
+                                          const Locale& aLocale = Locale::getDefault());
+
+    /**
+     * Creates a date formatter with the given formatting style for the given
+     * const locale.
+     *
+     * @param style     The given formatting style. For example,
+     *                  SHORT for "M/d/yy" in the US locale.
+     * @param aLocale   The given locale.
+     * @return          A date formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createDateInstance(EStyle style = kDefault,
+                                          const Locale& aLocale = Locale::getDefault());
+
+    /**
+     * Creates a date/time formatter with the given formatting styles for the
+     * given locale.
+     *
+     * @param dateStyle The given formatting style for the date portion of the result.
+     *                  For example, SHORT for "M/d/yy" in the US locale.
+     * @param timeStyle The given formatting style for the time portion of the result.
+     *                  For example, SHORT for "h:mm a" in the US locale.
+     * @param aLocale   The given locale.
+     * @return          A date/time formatter which the caller owns.
+     * @stable ICU 2.0
+     */
+    static DateFormat* U_EXPORT2 createDateTimeInstance(EStyle dateStyle = kDefault,
+                                              EStyle timeStyle = kDefault,
+                                              const Locale& aLocale = Locale::getDefault());
+
+    /**
+     * Gets the set of locales for which DateFormats are installed.
+     * @param count Filled in with the number of locales in the list that is returned.
+     * @return the set of locales for which DateFormats are installed.  The caller
+     *  does NOT own this list and must not delete it.
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Returns true if the formatter is set for lenient parsing.
+     * @stable ICU 2.0
+     */
+    virtual UBool isLenient(void) const;
+
+    /**
+     * Specify whether or not date/time parsing is to be lenient. With lenient
+     * parsing, the parser may use heuristics to interpret inputs that do not
+     * precisely match this object's format. With strict parsing, inputs must
+     * match this object's format.
+     *
+     * @param lenient  True specifies date/time interpretation to be lenient.
+     * @see Calendar::setLenient
+     * @stable ICU 2.0
+     */
+    virtual void setLenient(UBool lenient);
+
+    /**
+     * Gets the calendar associated with this date/time formatter.
+     * @return the calendar associated with this date/time formatter.
+     * @stable ICU 2.0
+     */
+    virtual const Calendar* getCalendar(void) const;
+
+    /**
+     * Set the calendar to be used by this date format. Initially, the default
+     * calendar for the specified or default locale is used.  The caller should
+     * not delete the Calendar object after it is adopted by this call.
+     * Adopting a new calendar will change to the default symbols.
+     *
+     * @param calendarToAdopt    Calendar object to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptCalendar(Calendar* calendarToAdopt);
+
+    /**
+     * Set the calendar to be used by this date format. Initially, the default
+     * calendar for the specified or default locale is used.
+     *
+     * @param newCalendar Calendar object to be set.
+     * @stable ICU 2.0
+     */
+    virtual void setCalendar(const Calendar& newCalendar);
+
+
+    /**
+     * Gets the number formatter which this date/time formatter uses to format
+     * and parse the numeric portions of the pattern.
+     * @return the number formatter which this date/time formatter uses.
+     * @stable ICU 2.0
+     */
+    virtual const NumberFormat* getNumberFormat(void) const;
+
+    /**
+     * Allows you to set the number formatter.  The caller should
+     * not delete the NumberFormat object after it is adopted by this call.
+     * @param formatToAdopt     NumberFormat object to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptNumberFormat(NumberFormat* formatToAdopt);
+
+    /**
+     * Allows you to set the number formatter.
+     * @param newNumberFormat  NumberFormat object to be set.
+     * @stable ICU 2.0
+     */
+    virtual void setNumberFormat(const NumberFormat& newNumberFormat);
+
+    /**
+     * Returns a reference to the TimeZone used by this DateFormat's calendar.
+     * @return the time zone associated with the calendar of DateFormat.
+     * @stable ICU 2.0
+     */
+    virtual const TimeZone& getTimeZone(void) const;
+
+    /**
+     * Sets the time zone for the calendar of this DateFormat object. The caller
+     * no longer owns the TimeZone object and should not delete it after this call.
+     * @param zoneToAdopt the TimeZone to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptTimeZone(TimeZone* zoneToAdopt);
+
+    /**
+     * Sets the time zone for the calendar of this DateFormat object.
+     * @param zone the new time zone.
+     * @stable ICU 2.0
+     */
+    virtual void setTimeZone(const TimeZone& zone);
+
+protected:
+    /**
+     * Default constructor.  Creates a DateFormat with no Calendar or NumberFormat
+     * associated with it.  This constructor depends on the subclasses to fill in
+     * the calendar and numberFormat fields.
+     * @stable ICU 2.0
+     */
+    DateFormat();
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    DateFormat(const DateFormat&);
+
+    /**
+     * Default assignment operator.
+     * @stable ICU 2.0
+     */
+    DateFormat& operator=(const DateFormat&);
+
+    /**
+     * The calendar that DateFormat uses to produce the time field values needed
+     * to implement date/time formatting. Subclasses should generally initialize
+     * this to the default calendar for the locale associated with this DateFormat.
+     * @stable ICU 2.4
+     */
+    Calendar* fCalendar;
+
+    /**
+     * The number formatter that DateFormat uses to format numbers in dates and
+     * times. Subclasses should generally initialize this to the default number
+     * format for the locale associated with this DateFormat.
+     * @stable ICU 2.4
+     */
+    NumberFormat* fNumberFormat;
+
+private:
+    /**
+     * Gets the date/time formatter with the given formatting styles for the
+     * given locale.
+     * @param dateStyle the given date formatting style.
+     * @param timeStyle the given time formatting style.
+     * @param inLocale the given locale.
+     * @return a date/time formatter, or 0 on failure.
+     */
+    static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, const Locale&);
+
+public:
+    /**
+     * Field selector for FieldPosition for DateFormat fields.
+     * @obsolete ICU 3.4 use UDateFormatField instead, since this API will be
+     * removed in that release
+     */
+    enum EField
+    {
+        // Obsolete; use UDateFormatField instead
+        kEraField = UDAT_ERA_FIELD,
+        kYearField = UDAT_YEAR_FIELD,
+        kMonthField = UDAT_MONTH_FIELD,
+        kDateField = UDAT_DATE_FIELD,
+        kHourOfDay1Field = UDAT_HOUR_OF_DAY1_FIELD,
+        kHourOfDay0Field = UDAT_HOUR_OF_DAY0_FIELD,
+        kMinuteField = UDAT_MINUTE_FIELD,
+        kSecondField = UDAT_SECOND_FIELD,
+        kMillisecondField = UDAT_FRACTIONAL_SECOND_FIELD,
+        kDayOfWeekField = UDAT_DAY_OF_WEEK_FIELD,
+        kDayOfYearField = UDAT_DAY_OF_YEAR_FIELD,
+        kDayOfWeekInMonthField = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
+        kWeekOfYearField = UDAT_WEEK_OF_YEAR_FIELD,
+        kWeekOfMonthField = UDAT_WEEK_OF_MONTH_FIELD,
+        kAmPmField = UDAT_AM_PM_FIELD,
+        kHour1Field = UDAT_HOUR1_FIELD,
+        kHour0Field = UDAT_HOUR0_FIELD,
+        kTimezoneField = UDAT_TIMEZONE_FIELD,
+        kYearWOYField = UDAT_YEAR_WOY_FIELD,
+        kDOWLocalField = UDAT_DOW_LOCAL_FIELD,
+        kExtendedYearField = UDAT_EXTENDED_YEAR_FIELD,
+        kJulianDayField = UDAT_JULIAN_DAY_FIELD,
+        kMillisecondsInDayField = UDAT_MILLISECONDS_IN_DAY_FIELD,
+
+        // Obsolete; use UDateFormatField instead
+        ERA_FIELD = UDAT_ERA_FIELD,
+        YEAR_FIELD = UDAT_YEAR_FIELD,
+        MONTH_FIELD = UDAT_MONTH_FIELD,
+        DATE_FIELD = UDAT_DATE_FIELD,
+        HOUR_OF_DAY1_FIELD = UDAT_HOUR_OF_DAY1_FIELD,
+        HOUR_OF_DAY0_FIELD = UDAT_HOUR_OF_DAY0_FIELD,
+        MINUTE_FIELD = UDAT_MINUTE_FIELD,
+        SECOND_FIELD = UDAT_SECOND_FIELD,
+        MILLISECOND_FIELD = UDAT_FRACTIONAL_SECOND_FIELD,
+        DAY_OF_WEEK_FIELD = UDAT_DAY_OF_WEEK_FIELD,
+        DAY_OF_YEAR_FIELD = UDAT_DAY_OF_YEAR_FIELD,
+        DAY_OF_WEEK_IN_MONTH_FIELD = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
+        WEEK_OF_YEAR_FIELD = UDAT_WEEK_OF_YEAR_FIELD,
+        WEEK_OF_MONTH_FIELD = UDAT_WEEK_OF_MONTH_FIELD,
+        AM_PM_FIELD = UDAT_AM_PM_FIELD,
+        HOUR1_FIELD = UDAT_HOUR1_FIELD,
+        HOUR0_FIELD = UDAT_HOUR0_FIELD,
+        TIMEZONE_FIELD = UDAT_TIMEZONE_FIELD
+    };
+};
+
+inline UnicodeString&
+DateFormat::format(const Formattable& obj,
+                   UnicodeString& appendTo,
+                   UErrorCode& status) const {
+    return Format::format(obj, appendTo, status);
+}
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DATEFMT
+//eof
diff --git a/CoreFoundation/icu/unicode/dbbi.h b/CoreFoundation/icu/unicode/dbbi.h
new file mode 100644
index 0000000..c7984ef
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dbbi.h
@@ -0,0 +1,41 @@
+/*
+**********************************************************************
+*   Copyright (C) 1999-2006 IBM Corp. All rights reserved.
+**********************************************************************
+*   Date        Name        Description
+*   12/1/99    rgillam     Complete port from Java.
+*   01/13/2000 helena      Added UErrorCode to ctors.
+**********************************************************************
+*/
+
+#ifndef DBBI_H
+#define DBBI_H
+
+#include "unicode/rbbi.h"
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+/**
+ * \file
+ * \brief C++ API: Dictionary Based Break Iterator
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * An obsolete subclass of RuleBasedBreakIterator. Handling of dictionary-
+ * based break iteration has been folded into the base class. This class
+ * is deprecated as of ICU 3.6.
+ */
+ 
+#ifndef U_HIDE_DEPRECATED_API
+
+typedef RuleBasedBreakIterator DictionaryBasedBreakIterator;
+
+#endif
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/dcfmtsym.h b/CoreFoundation/icu/unicode/dcfmtsym.h
new file mode 100644
index 0000000..bc5547d
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dcfmtsym.h
@@ -0,0 +1,370 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File DCFMTSYM.H
+*
+* Modification History:
+* 
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/18/97    clhuang     Updated per C++ implementation.
+*   03/27/97    helena      Updated to pass the simple test after code review.
+*   08/26/97    aliu        Added currency/intl currency symbol support.
+*   07/22/98    stephen     Changed to match C++ style 
+*                            currencySymbol -> fCurrencySymbol
+*                            Constants changed from CAPS to kCaps
+*   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes
+*   09/22/00    grhoten     Marked deprecation tags with a pointer to replacement
+*                            functions.
+********************************************************************************
+*/
+ 
+#ifndef DCFMTSYM_H
+#define DCFMTSYM_H
+ 
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+
+/**
+ * \file 
+ * \brief C++ API: Symbols for formatting numbers.
+ */
+
+
+U_NAMESPACE_BEGIN
+
+/**
+ * This class represents the set of symbols needed by DecimalFormat
+ * to format numbers. DecimalFormat creates for itself an instance of
+ * DecimalFormatSymbols from its locale data.  If you need to change any
+ * of these symbols, you can get the DecimalFormatSymbols object from
+ * your DecimalFormat and modify it.
+ * <P>
+ * Here are the special characters used in the parts of the
+ * subpattern, with notes on their usage.
+ * <pre>
+ * \code
+ *        Symbol   Meaning
+ *          0      a digit
+ *          #      a digit, zero shows as absent
+ *          .      placeholder for decimal separator
+ *          ,      placeholder for grouping separator.
+ *          ;      separates formats.
+ *          -      default negative prefix.
+ *          %      divide by 100 and show as percentage
+ *          X      any other characters can be used in the prefix or suffix
+ *          '      used to quote special characters in a prefix or suffix.
+ * \endcode
+ *  </pre>
+ * [Notes]
+ * <P>
+ * If there is no explicit negative subpattern, - is prefixed to the
+ * positive form. That is, "0.00" alone is equivalent to "0.00;-0.00".
+ * <P>
+ * The grouping separator is commonly used for thousands, but in some
+ * countries for ten-thousands. The interval is a constant number of
+ * digits between the grouping characters, such as 100,000,000 or 1,0000,0000.
+ * If you supply a pattern with multiple grouping characters, the interval
+ * between the last one and the end of the integer is the one that is
+ * used. So "#,##,###,####" == "######,####" == "##,####,####".
+ * <P>
+ * This class only handles localized digits where the 10 digits are
+ * contiguous in Unicode, from 0 to 9. Other digits sets (such as
+ * superscripts) would need a different subclass.
+ */
+class U_I18N_API DecimalFormatSymbols : public UObject {
+public:
+    /**
+     * Constants for specifying a number format symbol.
+     * @stable ICU 2.0
+     */
+    enum ENumberFormatSymbol {
+        /** The decimal separator */
+        kDecimalSeparatorSymbol,
+        /** The grouping separator */
+        kGroupingSeparatorSymbol,
+        /** The pattern separator */
+        kPatternSeparatorSymbol,
+        /** The percent sign */
+        kPercentSymbol,
+        /** Zero*/
+        kZeroDigitSymbol,
+        /** Character representing a digit in the pattern */
+        kDigitSymbol,
+        /** The minus sign */
+        kMinusSignSymbol,
+        /** The plus sign */
+        kPlusSignSymbol,
+        /** The currency symbol */
+        kCurrencySymbol,
+        /** The international currency symbol */
+        kIntlCurrencySymbol,
+        /** The monetary separator */
+        kMonetarySeparatorSymbol,
+        /** The exponential symbol */
+        kExponentialSymbol,
+        /** Per mill symbol - replaces kPermillSymbol */
+        kPerMillSymbol,
+        /** Escape padding character */
+        kPadEscapeSymbol,
+        /** Infinity symbol */
+        kInfinitySymbol,
+        /** Nan symbol */
+        kNaNSymbol,
+        /** Significant digit symbol
+         * @stable ICU 3.0 */
+        kSignificantDigitSymbol,
+        /** The monetary grouping separator 
+         * @stable ICU 3.6
+         */
+        kMonetaryGroupingSeparatorSymbol,
+        /** count symbol constants */
+        kFormatSymbolCount
+    };
+
+    /**
+     * Create a DecimalFormatSymbols object for the given locale.
+     *
+     * @param locale    The locale to get symbols for.
+     * @param status    Input/output parameter, set to success or
+     *                  failure code upon return.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
+
+    /**
+     * Create a DecimalFormatSymbols object for the default locale.
+     * This constructor will not fail.  If the resource file data is
+     * not available, it will use hard-coded last-resort data and
+     * set status to U_USING_FALLBACK_ERROR.
+     *
+     * @param status    Input/output parameter, set to success or
+     *                  failure code upon return.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols( UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols(const DecimalFormatSymbols&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.0
+     */
+    DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~DecimalFormatSymbols();
+
+    /**
+     * Return true if another object is semantically equal to this one.
+     *
+     * @param other    the object to be compared with.
+     * @return         true if another object is semantically equal to this one.
+     * @stable ICU 2.0
+     */
+    UBool operator==(const DecimalFormatSymbols& other) const;
+
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the object to be compared with.
+     * @return         true if another object is semantically unequal to this one.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
+
+    /**
+     * Get one of the format symbols by its enum constant.
+     * Each symbol is stored as a string so that graphemes
+     * (characters with modifyer letters) can be used.
+     *
+     * @param symbol    Constant to indicate a number format symbol.
+     * @return    the format symbols by the param 'symbol'
+     * @stable ICU 2.0
+     */
+    inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
+
+    /**
+     * Set one of the format symbols by its enum constant.
+     * Each symbol is stored as a string so that graphemes
+     * (characters with modifyer letters) can be used.
+     *
+     * @param symbol    Constant to indicate a number format symbol.
+     * @param value     value of the format sybmol
+     * @stable ICU 2.0
+     */
+    void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
+
+    /**
+     * Returns the locale for which this object was constructed.
+     * @stable ICU 2.6
+     */
+    inline Locale getLocale() const;
+
+    /**
+     * Returns the locale for this object. Two flavors are available:
+     * valid and actual locale.
+     * @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    DecimalFormatSymbols(); // default constructor not implemented
+
+    /**
+     * Initializes the symbols from the LocaleElements resource bundle.
+     * Note: The organization of LocaleElements badly needs to be
+     * cleaned up.
+     *
+     * @param locale               The locale to get symbols for.
+     * @param success              Input/output parameter, set to success or
+     *                             failure code upon return.
+     * @param useLastResortData    determine if use last resort data
+     */
+    void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
+
+    /**
+     * Initialize the symbols from the given array of UnicodeStrings.
+     * The array must be of the correct size.
+     * 
+     * @param numberElements    the number format symbols
+     * @param numberElementsLength length of numberElements
+     */
+    void initialize(const UChar** numberElements, int32_t *numberElementsStrLen, int32_t numberElementsLength);
+
+    /**
+     * Initialize the symbols with default values.
+     */
+    void initialize();
+
+    void setCurrencyForSymbols();
+
+public:
+    /**
+     * _Internal_ function - more efficient version of getSymbol,
+     * returning a const reference to one of the symbol strings.
+     * The returned reference becomes invalid when the symbol is changed
+     * or when the DecimalFormatSymbols are destroyed.
+     * ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public.
+     *
+     * @param symbol Constant to indicate a number format symbol.
+     * @return the format symbol by the param 'symbol'
+     * @internal
+     */
+    inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
+
+    /**
+     * Returns that pattern stored in currecy info. Internal API for use by NumberFormat API.
+     * @internal
+     */
+    inline const UChar* getCurrencyPattern(void) const;
+
+private:
+    /**
+     * Private symbol strings.
+     * They are either loaded from a resource bundle or otherwise owned.
+     * setSymbol() clones the symbol string.
+     * Readonly aliases can only come from a resource bundle, so that we can always
+     * use fastCopyFrom() with them.
+     *
+     * If DecimalFormatSymbols becomes subclassable and the status of fSymbols changes
+     * from private to protected,
+     * or when fSymbols can be set any other way that allows them to be readonly aliases
+     * to non-resource bundle strings,
+     * then regular UnicodeString copies must be used instead of fastCopyFrom().
+     *
+     * @internal
+     */
+    UnicodeString fSymbols[kFormatSymbolCount];
+
+    /**
+     * Non-symbol variable for getConstSymbol(). Always empty.
+     * @internal
+     */
+    UnicodeString fNoSymbol;
+
+    Locale locale;
+
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+    const UChar* currPattern;
+};
+
+// -------------------------------------
+
+inline UnicodeString
+DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
+    const UnicodeString *strPtr;
+    if(symbol < kFormatSymbolCount) {
+        strPtr = &fSymbols[symbol];
+    } else {
+        strPtr = &fNoSymbol;
+    }
+    return *strPtr;
+}
+
+inline const UnicodeString &
+DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
+    const UnicodeString *strPtr;
+    if(symbol < kFormatSymbolCount) {
+        strPtr = &fSymbols[symbol];
+    } else {
+        strPtr = &fNoSymbol;
+    }
+    return *strPtr;
+}
+
+// -------------------------------------
+
+inline void
+DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
+    if(symbol<kFormatSymbolCount) {
+        fSymbols[symbol]=value;
+    }
+}
+
+// -------------------------------------
+
+inline Locale
+DecimalFormatSymbols::getLocale() const {
+    return locale;
+}
+
+inline const UChar*
+DecimalFormatSymbols::getCurrencyPattern() const {
+    return currPattern;
+}
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DCFMTSYM
+//eof
diff --git a/CoreFoundation/icu/unicode/decimfmt.h b/CoreFoundation/icu/unicode/decimfmt.h
new file mode 100644
index 0000000..1671432
--- /dev/null
+++ b/CoreFoundation/icu/unicode/decimfmt.h
@@ -0,0 +1,1896 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File DECIMFMT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/20/97    clhuang     Updated per C++ implementation.
+*   04/03/97    aliu        Rewrote parsing and formatting completely, and
+*                           cleaned up and debugged.  Actually works now.
+*   04/17/97    aliu        Changed DigitCount to int per code review.
+*   07/10/97    helena      Made ParsePosition a class and get rid of the function
+*                           hiding problems.
+*   09/09/97    aliu        Ported over support for exponential formats.
+*    07/20/98    stephen        Changed documentation
+********************************************************************************
+*/
+ 
+#ifndef DECIMFMT_H
+#define DECIMFMT_H
+ 
+#include "unicode/utypes.h"
+/**
+ * \file 
+ * \brief C++ API: Formats decimal numbers.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/dcfmtsym.h"
+#include "unicode/numfmt.h"
+#include "unicode/locid.h"
+
+U_NAMESPACE_BEGIN
+
+class DigitList;
+class ChoiceFormat;
+
+/**
+ * DecimalFormat is a concrete subclass of NumberFormat that formats decimal
+ * numbers. It has a variety of features designed to make it possible to parse
+ * and format numbers in any locale, including support for Western, Arabic, or
+ * Indic digits.  It also supports different flavors of numbers, including
+ * integers ("123"), fixed-point numbers ("123.4"), scientific notation
+ * ("1.23E4"), percentages ("12%"), and currency amounts ("$123").  All of these
+ * flavors can be easily localized.
+ *
+ * <p>To obtain a NumberFormat for a specific locale (including the default
+ * locale) call one of NumberFormat's factory methods such as
+ * createInstance(). Do not call the DecimalFormat constructors directly, unless
+ * you know what you are doing, since the NumberFormat factory methods may
+ * return subclasses other than DecimalFormat.
+ *
+ * <p><strong>Example Usage</strong>
+ *
+ * \code
+ *     // Normally we would have a GUI with a menu for this
+ *     int32_t locCount;
+ *     const Locale* locales = NumberFormat::getAvailableLocales(locCount);
+ * 
+ *     double myNumber = -1234.56;
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     NumberFormat* form;
+ * 
+ *     // Print out a number with the localized number, currency and percent
+ *     // format for each locale.
+ *     UnicodeString countryName;
+ *     UnicodeString displayName;
+ *     UnicodeString str;
+ *     UnicodeString pattern;
+ *     Formattable fmtable;
+ *     for (int32_t j = 0; j < 3; ++j) {
+ *         cout << endl << "FORMAT " << j << endl;
+ *         for (int32_t i = 0; i < locCount; ++i) {
+ *             if (locales[i].getCountry(countryName).size() == 0) {
+ *                 // skip language-only
+ *                 continue;
+ *             }
+ *             switch (j) {
+ *             case 0:
+ *                 form = NumberFormat::createInstance(locales[i], success ); break;
+ *             case 1:
+ *                 form = NumberFormat::createCurrencyInstance(locales[i], success ); break;
+ *             default:
+ *                 form = NumberFormat::createPercentInstance(locales[i], success ); break;
+ *             }
+ *             if (form) {
+ *                 str.remove();
+ *                 pattern = ((DecimalFormat*)form)->toPattern(pattern);
+ *                 cout << locales[i].getDisplayName(displayName) << ": " << pattern;
+ *                 cout << "  ->  " << form->format(myNumber,str) << endl;
+ *                 form->parse(form->format(myNumber,str), fmtable, success);
+ *                 delete form;  
+ *             }
+ *         }
+ *     }
+ * \endcode
+ *
+ * <p><strong>Patterns</strong>
+ *
+ * <p>A DecimalFormat consists of a <em>pattern</em> and a set of
+ * <em>symbols</em>.  The pattern may be set directly using
+ * applyPattern(), or indirectly using other API methods which
+ * manipulate aspects of the pattern, such as the minimum number of integer
+ * digits.  The symbols are stored in a DecimalFormatSymbols
+ * object.  When using the NumberFormat factory methods, the
+ * pattern and symbols are read from ICU's locale data.
+ * 
+ * <p><strong>Special Pattern Characters</strong>
+ *
+ * <p>Many characters in a pattern are taken literally; they are matched during
+ * parsing and output unchanged during formatting.  Special characters, on the
+ * other hand, stand for other characters, strings, or classes of characters.
+ * For example, the '#' character is replaced by a localized digit.  Often the
+ * replacement character is the same as the pattern character; in the U.S. locale,
+ * the ',' grouping character is replaced by ','.  However, the replacement is
+ * still happening, and if the symbols are modified, the grouping character
+ * changes.  Some special characters affect the behavior of the formatter by
+ * their presence; for example, if the percent character is seen, then the
+ * value is multiplied by 100 before being displayed.
+ *
+ * <p>To insert a special character in a pattern as a literal, that is, without
+ * any special meaning, the character must be quoted.  There are some exceptions to
+ * this which are noted below.
+ *
+ * <p>The characters listed here are used in non-localized patterns.  Localized
+ * patterns use the corresponding characters taken from this formatter's
+ * DecimalFormatSymbols object instead, and these characters lose
+ * their special status.  Two exceptions are the currency sign and quote, which
+ * are not localized.
+ *
+ * <table border=0 cellspacing=3 cellpadding=0>
+ *   <tr bgcolor="#ccccff">
+ *     <td align=left><strong>Symbol</strong>
+ *     <td align=left><strong>Location</strong>
+ *     <td align=left><strong>Localized?</strong>
+ *     <td align=left><strong>Meaning</strong>
+ *   <tr valign=top>
+ *     <td><code>0</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Digit
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>1-9</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>'1' through '9' indicate rounding.
+ *   <tr valign=top>
+ *     <td><code>\htmlonly&#x40;\endhtmlonly</code> <!--doxygen doesn't like @-->
+ *     <td>Number
+ *     <td>No
+ *     <td>Significant digit
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>#</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Digit, zero shows as absent
+ *   <tr valign=top>
+ *     <td><code>.</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Decimal separator or monetary decimal separator
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>-</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Minus sign
+ *   <tr valign=top>
+ *     <td><code>,</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Grouping separator
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>E</code>
+ *     <td>Number
+ *     <td>Yes
+ *     <td>Separates mantissa and exponent in scientific notation.
+ *         <em>Need not be quoted in prefix or suffix.</em>
+ *   <tr valign=top>
+ *     <td><code>+</code>
+ *     <td>Exponent
+ *     <td>Yes
+ *     <td>Prefix positive exponents with localized plus sign.
+ *         <em>Need not be quoted in prefix or suffix.</em>
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>;</code>
+ *     <td>Subpattern boundary
+ *     <td>Yes
+ *     <td>Separates positive and negative subpatterns
+ *   <tr valign=top>
+ *     <td><code>\%</code>
+ *     <td>Prefix or suffix
+ *     <td>Yes
+ *     <td>Multiply by 100 and show as percentage
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>\\u2030</code>
+ *     <td>Prefix or suffix
+ *     <td>Yes
+ *     <td>Multiply by 1000 and show as per mille
+ *   <tr valign=top>
+ *     <td><code>\htmlonly&curren;\endhtmlonly</code> (<code>\\u00A4</code>)
+ *     <td>Prefix or suffix
+ *     <td>No
+ *     <td>Currency sign, replaced by currency symbol.  If
+ *         doubled, replaced by international currency symbol.
+ *         If present in a pattern, the monetary decimal separator
+ *         is used instead of the decimal separator.
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>'</code>
+ *     <td>Prefix or suffix
+ *     <td>No
+ *     <td>Used to quote special characters in a prefix or suffix,
+ *         for example, <code>"'#'#"</code> formats 123 to
+ *         <code>"#123"</code>.  To create a single quote
+ *         itself, use two in a row: <code>"# o''clock"</code>.
+ *   <tr valign=top>
+ *     <td><code>*</code>
+ *     <td>Prefix or suffix boundary
+ *     <td>Yes
+ *     <td>Pad escape, precedes pad character
+ * </table>
+ *
+ * <p>A DecimalFormat pattern contains a postive and negative
+ * subpattern, for example, "#,##0.00;(#,##0.00)".  Each subpattern has a
+ * prefix, a numeric part, and a suffix.  If there is no explicit negative
+ * subpattern, the negative subpattern is the localized minus sign prefixed to the
+ * positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00".  If there
+ * is an explicit negative subpattern, it serves only to specify the negative
+ * prefix and suffix; the number of digits, minimal digits, and other
+ * characteristics are ignored in the negative subpattern. That means that
+ * "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)".
+ *
+ * <p>The prefixes, suffixes, and various symbols used for infinity, digits,
+ * thousands separators, decimal separators, etc. may be set to arbitrary
+ * values, and they will appear properly during formatting.  However, care must
+ * be taken that the symbols and strings do not conflict, or parsing will be
+ * unreliable.  For example, either the positive and negative prefixes or the
+ * suffixes must be distinct for parse() to be able
+ * to distinguish positive from negative values.  Another example is that the
+ * decimal separator and thousands separator should be distinct characters, or
+ * parsing will be impossible.
+ *
+ * <p>The <em>grouping separator</em> is a character that separates clusters of
+ * integer digits to make large numbers more legible.  It commonly used for
+ * thousands, but in some locales it separates ten-thousands.  The <em>grouping
+ * size</em> is the number of digits between the grouping separators, such as 3
+ * for "100,000,000" or 4 for "1 0000 0000". There are actually two different
+ * grouping sizes: One used for the least significant integer digits, the
+ * <em>primary grouping size</em>, and one used for all others, the
+ * <em>secondary grouping size</em>.  In most locales these are the same, but
+ * sometimes they are different. For example, if the primary grouping interval
+ * is 3, and the secondary is 2, then this corresponds to the pattern
+ * "#,##,##0", and the number 123456789 is formatted as "12,34,56,789".  If a
+ * pattern contains multiple grouping separators, the interval between the last
+ * one and the end of the integer defines the primary grouping size, and the
+ * interval between the last two defines the secondary grouping size. All others
+ * are ignored, so "#,##,###,####" == "###,###,####" == "##,#,###,####".
+ *
+ * <p>Illegal patterns, such as "#.#.#" or "#.###,###", will cause
+ * DecimalFormat to set a failing UErrorCode.
+ *
+ * <p><strong>Pattern BNF</strong>
+ *
+ * <pre>
+ * pattern    := subpattern (';' subpattern)?
+ * subpattern := prefix? number exponent? suffix?
+ * number     := (integer ('.' fraction)?) | sigDigits
+ * prefix     := '\\u0000'..'\\uFFFD' - specialCharacters
+ * suffix     := '\\u0000'..'\\uFFFD' - specialCharacters
+ * integer    := '#'* '0'* '0'
+ * fraction   := '0'* '#'*
+ * sigDigits  := '#'* '@' '@'* '#'*
+ * exponent   := 'E' '+'? '0'* '0'
+ * padSpec    := '*' padChar
+ * padChar    := '\\u0000'..'\\uFFFD' - quote
+ * &nbsp;
+ * Notation:
+ *   X*       0 or more instances of X
+ *   X?       0 or 1 instances of X
+ *   X|Y      either X or Y
+ *   C..D     any character from C up to D, inclusive
+ *   S-T      characters in S, except those in T
+ * </pre>
+ * The first subpattern is for positive numbers. The second (optional)
+ * subpattern is for negative numbers.
+ * 
+ * <p>Not indicated in the BNF syntax above:
+ *
+ * <ul><li>The grouping separator ',' can occur inside the integer and
+ * sigDigits elements, between any two pattern characters of that
+ * element, as long as the integer or sigDigits element is not
+ * followed by the exponent element.
+ *
+ * <li>Two grouping intervals are recognized: That between the
+ *     decimal point and the first grouping symbol, and that
+ *     between the first and second grouping symbols. These
+ *     intervals are identical in most locales, but in some
+ *     locales they differ. For example, the pattern
+ *     &quot;#,##,###&quot; formats the number 123456789 as
+ *     &quot;12,34,56,789&quot;.</li>
+ * 
+ * <li>The pad specifier <code>padSpec</code> may appear before the prefix,
+ * after the prefix, before the suffix, after the suffix, or not at all.
+ *
+ * <li>In place of '0', the digits '1' through '9' may be used to
+ * indicate a rounding increment.
+ * </ul>
+ *
+ * <p><strong>Parsing</strong>
+ *
+ * <p>DecimalFormat parses all Unicode characters that represent
+ * decimal digits, as defined by u_charDigitValue().  In addition,
+ * DecimalFormat also recognizes as digits the ten consecutive
+ * characters starting with the localized zero digit defined in the
+ * DecimalFormatSymbols object.  During formatting, the
+ * DecimalFormatSymbols-based digits are output.
+ *
+ * <p>During parsing, grouping separators are ignored.
+ *
+ * <p>If parse(UnicodeString&,Formattable&,ParsePosition&)
+ * fails to parse a string, it leaves the parse position unchanged.
+ * The convenience method parse(UnicodeString&,Formattable&,UErrorCode&)
+ * indicates parse failure by setting a failing
+ * UErrorCode.
+ *
+ * <p><strong>Formatting</strong>
+ *
+ * <p>Formatting is guided by several parameters, all of which can be
+ * specified either using a pattern or using the API.  The following
+ * description applies to formats that do not use <a href="#sci">scientific
+ * notation</a> or <a href="#sigdig">significant digits</a>.
+ *
+ * <ul><li>If the number of actual integer digits exceeds the
+ * <em>maximum integer digits</em>, then only the least significant
+ * digits are shown.  For example, 1997 is formatted as "97" if the
+ * maximum integer digits is set to 2.
+ *
+ * <li>If the number of actual integer digits is less than the
+ * <em>minimum integer digits</em>, then leading zeros are added.  For
+ * example, 1997 is formatted as "01997" if the minimum integer digits
+ * is set to 5.
+ *
+ * <li>If the number of actual fraction digits exceeds the <em>maximum
+ * fraction digits</em>, then half-even rounding it performed to the
+ * maximum fraction digits.  For example, 0.125 is formatted as "0.12"
+ * if the maximum fraction digits is 2.  This behavior can be changed
+ * by specifying a rounding increment and a rounding mode.
+ *
+ * <li>If the number of actual fraction digits is less than the
+ * <em>minimum fraction digits</em>, then trailing zeros are added.
+ * For example, 0.125 is formatted as "0.1250" if the mimimum fraction
+ * digits is set to 4.
+ *
+ * <li>Trailing fractional zeros are not displayed if they occur
+ * <em>j</em> positions after the decimal, where <em>j</em> is less
+ * than the maximum fraction digits. For example, 0.10004 is
+ * formatted as "0.1" if the maximum fraction digits is four or less.
+ * </ul>
+ *
+ * <p><strong>Special Values</strong>
+ *
+ * <p><code>NaN</code> is represented as a single character, typically
+ * <code>\\uFFFD</code>.  This character is determined by the
+ * DecimalFormatSymbols object.  This is the only value for which
+ * the prefixes and suffixes are not used.
+ *
+ * <p>Infinity is represented as a single character, typically
+ * <code>\\u221E</code>, with the positive or negative prefixes and suffixes
+ * applied.  The infinity character is determined by the
+ * DecimalFormatSymbols object.
+ *
+ * <a name="sci"><strong>Scientific Notation</strong></a>
+ *
+ * <p>Numbers in scientific notation are expressed as the product of a mantissa
+ * and a power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>. The
+ * mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0),
+ * but it need not be.  DecimalFormat supports arbitrary mantissas.
+ * DecimalFormat can be instructed to use scientific
+ * notation through the API or through the pattern.  In a pattern, the exponent
+ * character immediately followed by one or more digit characters indicates
+ * scientific notation.  Example: "0.###E0" formats the number 1234 as
+ * "1.234E3".
+ *
+ * <ul>
+ * <li>The number of digit characters after the exponent character gives the
+ * minimum exponent digit count.  There is no maximum.  Negative exponents are
+ * formatted using the localized minus sign, <em>not</em> the prefix and suffix
+ * from the pattern.  This allows patterns such as "0.###E0 m/s".  To prefix
+ * positive exponents with a localized plus sign, specify '+' between the
+ * exponent and the digits: "0.###E+0" will produce formats "1E+1", "1E+0",
+ * "1E-1", etc.  (In localized patterns, use the localized plus sign rather than
+ * '+'.)
+ *
+ * <li>The minimum number of integer digits is achieved by adjusting the
+ * exponent.  Example: 0.00123 formatted with "00.###E0" yields "12.3E-4".  This
+ * only happens if there is no maximum number of integer digits.  If there is a
+ * maximum, then the minimum number of integer digits is fixed at one.
+ *
+ * <li>The maximum number of integer digits, if present, specifies the exponent
+ * grouping.  The most common use of this is to generate <em>engineering
+ * notation</em>, in which the exponent is a multiple of three, e.g.,
+ * "##0.###E0".  The number 12345 is formatted using "##0.####E0" as "12.345E3".
+ *
+ * <li>When using scientific notation, the formatter controls the
+ * digit counts using significant digits logic.  The maximum number of
+ * significant digits limits the total number of integer and fraction
+ * digits that will be shown in the mantissa; it does not affect
+ * parsing.  For example, 12345 formatted with "##0.##E0" is "12.3E3".
+ * See the section on significant digits for more details.
+ *
+ * <li>The number of significant digits shown is determined as
+ * follows: If areSignificantDigitsUsed() returns false, then the
+ * minimum number of significant digits shown is one, and the maximum
+ * number of significant digits shown is the sum of the <em>minimum
+ * integer</em> and <em>maximum fraction</em> digits, and is
+ * unaffected by the maximum integer digits.  If this sum is zero,
+ * then all significant digits are shown.  If
+ * areSignificantDigitsUsed() returns true, then the significant digit
+ * counts are specified by getMinimumSignificantDigits() and
+ * getMaximumSignificantDigits().  In this case, the number of
+ * integer digits is fixed at one, and there is no exponent grouping.
+ *
+ * <li>Exponential patterns may not contain grouping separators.
+ * </ul>
+ *
+ * <a name="sigdig"><strong>Significant Digits</strong></a>
+ *
+ * <code>DecimalFormat</code> has two ways of controlling how many
+ * digits are shows: (a) significant digits counts, or (b) integer and
+ * fraction digit counts.  Integer and fraction digit counts are
+ * described above.  When a formatter is using significant digits
+ * counts, the number of integer and fraction digits is not specified
+ * directly, and the formatter settings for these counts are ignored.
+ * Instead, the formatter uses however many integer and fraction
+ * digits are required to display the specified number of significant
+ * digits.  Examples:
+ *
+ * <table border=0 cellspacing=3 cellpadding=0>
+ *   <tr bgcolor="#ccccff">
+ *     <td align=left>Pattern
+ *     <td align=left>Minimum significant digits
+ *     <td align=left>Maximum significant digits
+ *     <td align=left>Number
+ *     <td align=left>Output of format()
+ *   <tr valign=top>
+ *     <td><code>\@\@\@</code>
+ *     <td>3
+ *     <td>3
+ *     <td>12345
+ *     <td><code>12300</code>
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>\@\@\@</code>
+ *     <td>3
+ *     <td>3
+ *     <td>0.12345
+ *     <td><code>0.123</code>
+ *   <tr valign=top>
+ *     <td><code>\@\@##</code>
+ *     <td>2
+ *     <td>4
+ *     <td>3.14159
+ *     <td><code>3.142</code>
+ *   <tr valign=top bgcolor="#eeeeff">
+ *     <td><code>\@\@##</code>
+ *     <td>2
+ *     <td>4
+ *     <td>1.23004
+ *     <td><code>1.23</code>
+ * </table>
+ *
+ * <ul>
+ * <li>Significant digit counts may be expressed using patterns that
+ * specify a minimum and maximum number of significant digits.  These
+ * are indicated by the <code>'@'</code> and <code>'#'</code>
+ * characters.  The minimum number of significant digits is the number
+ * of <code>'@'</code> characters.  The maximum number of significant
+ * digits is the number of <code>'@'</code> characters plus the number
+ * of <code>'#'</code> characters following on the right.  For
+ * example, the pattern <code>"@@@"</code> indicates exactly 3
+ * significant digits.  The pattern <code>"@##"</code> indicates from
+ * 1 to 3 significant digits.  Trailing zero digits to the right of
+ * the decimal separator are suppressed after the minimum number of
+ * significant digits have been shown.  For example, the pattern
+ * <code>"@##"</code> formats the number 0.1203 as
+ * <code>"0.12"</code>.
+ *
+ * <li>If a pattern uses significant digits, it may not contain a
+ * decimal separator, nor the <code>'0'</code> pattern character.
+ * Patterns such as <code>"@00"</code> or <code>"@.###"</code> are
+ * disallowed.
+ *
+ * <li>Any number of <code>'#'</code> characters may be prepended to
+ * the left of the leftmost <code>'@'</code> character.  These have no
+ * effect on the minimum and maximum significant digits counts, but
+ * may be used to position grouping separators.  For example,
+ * <code>"#,#@#"</code> indicates a minimum of one significant digits,
+ * a maximum of two significant digits, and a grouping size of three.
+ *
+ * <li>In order to enable significant digits formatting, use a pattern
+ * containing the <code>'@'</code> pattern character.  Alternatively,
+ * call setSignificantDigitsUsed(TRUE).
+ *
+ * <li>In order to disable significant digits formatting, use a
+ * pattern that does not contain the <code>'@'</code> pattern
+ * character. Alternatively, call setSignificantDigitsUsed(FALSE).
+ *
+ * <li>The number of significant digits has no effect on parsing.
+ *
+ * <li>Significant digits may be used together with exponential notation. Such
+ * patterns are equivalent to a normal exponential pattern with a minimum and
+ * maximum integer digit count of one, a minimum fraction digit count of
+ * <code>getMinimumSignificantDigits() - 1</code>, and a maximum fraction digit
+ * count of <code>getMaximumSignificantDigits() - 1</code>. For example, the
+ * pattern <code>"@@###E0"</code> is equivalent to <code>"0.0###E0"</code>.
+ *
+ * <li>If signficant digits are in use, then the integer and fraction
+ * digit counts, as set via the API, are ignored.  If significant
+ * digits are not in use, then the signficant digit counts, as set via
+ * the API, are ignored.
+ *
+ * </ul>
+ *
+ * <p><strong>Padding</strong>
+ *
+ * <p>DecimalFormat supports padding the result of
+ * format() to a specific width.  Padding may be specified either
+ * through the API or through the pattern syntax.  In a pattern the pad escape
+ * character, followed by a single pad character, causes padding to be parsed
+ * and formatted.  The pad escape character is '*' in unlocalized patterns, and
+ * can be localized using DecimalFormatSymbols::setSymbol() with a
+ * DecimalFormatSymbols::kPadEscapeSymbol
+ * selector.  For example, <code>"$*x#,##0.00"</code> formats 123 to
+ * <code>"$xx123.00"</code>, and 1234 to <code>"$1,234.00"</code>.
+ *
+ * <ul>
+ * <li>When padding is in effect, the width of the positive subpattern,
+ * including prefix and suffix, determines the format width.  For example, in
+ * the pattern <code>"* #0 o''clock"</code>, the format width is 10.
+ *
+ * <li>The width is counted in 16-bit code units (UChars).
+ *
+ * <li>Some parameters which usually do not matter have meaning when padding is
+ * used, because the pattern width is significant with padding.  In the pattern
+ * "* ##,##,#,##0.##", the format width is 14.  The initial characters "##,##,"
+ * do not affect the grouping size or maximum integer digits, but they do affect
+ * the format width.
+ *
+ * <li>Padding may be inserted at one of four locations: before the prefix,
+ * after the prefix, before the suffix, or after the suffix.  If padding is
+ * specified in any other location, applyPattern()
+ * sets a failing UErrorCode.  If there is no prefix,
+ * before the prefix and after the prefix are equivalent, likewise for the
+ * suffix.
+ *
+ * <li>When specified in a pattern, the 32-bit code point immediately
+ * following the pad escape is the pad character. This may be any character,
+ * including a special pattern character. That is, the pad escape
+ * <em>escapes</em> the following character. If there is no character after
+ * the pad escape, then the pattern is illegal.
+ *
+ * </ul>
+ *
+ * <p><strong>Rounding</strong>
+ *
+ * <p>DecimalFormat supports rounding to a specific increment.  For
+ * example, 1230 rounded to the nearest 50 is 1250.  1.234 rounded to the
+ * nearest 0.65 is 1.3.  The rounding increment may be specified through the API
+ * or in a pattern.  To specify a rounding increment in a pattern, include the
+ * increment in the pattern itself.  "#,#50" specifies a rounding increment of
+ * 50.  "#,##0.05" specifies a rounding increment of 0.05.
+ *
+ * <ul>
+ * <li>Rounding only affects the string produced by formatting.  It does
+ * not affect parsing or change any numerical values.
+ *
+ * <li>A <em>rounding mode</em> determines how values are rounded; see
+ * DecimalFormat::ERoundingMode.  Rounding increments specified in
+ * patterns use the default mode, DecimalFormat::kRoundHalfEven.
+ *
+ * <li>Some locales use rounding in their currency formats to reflect the
+ * smallest currency denomination.
+ *
+ * <li>In a pattern, digits '1' through '9' specify rounding, but otherwise
+ * behave identically to digit '0'.
+ * </ul>
+ *
+ * <p><strong>Synchronization</strong>
+ *
+ * <p>DecimalFormat objects are not synchronized.  Multiple
+ * threads should not access one formatter concurrently.
+ *
+ * <p><strong>Subclassing</strong>
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API DecimalFormat: public NumberFormat {
+public:
+    /**
+     * Rounding mode.
+     * @stable ICU 2.4
+     */
+    enum ERoundingMode {
+        kRoundCeiling,  /**< Round towards positive infinity */
+        kRoundFloor,    /**< Round towards negative infinity */
+        kRoundDown,     /**< Round towards zero */
+        kRoundUp,       /**< Round away from zero */
+        kRoundHalfEven, /**< Round towards the nearest integer, or
+                             towards the nearest even integer if equidistant */
+        kRoundHalfDown, /**< Round towards the nearest integer, or
+                             towards zero if equidistant */
+        kRoundHalfUp    /**< Round towards the nearest integer, or
+                             away from zero if equidistant */
+        // We don't support ROUND_UNNECESSARY
+    };
+
+    /**
+     * Pad position.
+     * @stable ICU 2.4
+     */
+    enum EPadPosition {
+        kPadBeforePrefix,
+        kPadAfterPrefix,
+        kPadBeforeSuffix,
+        kPadAfterSuffix
+    };
+
+    /**
+     * Create a DecimalFormat using the default pattern and symbols
+     * for the default locale. This is a convenient way to obtain a
+     * DecimalFormat when internationalization is not the main concern.
+     * <P>
+     * To obtain standard formats for a given locale, use the factory methods
+     * on NumberFormat such as createInstance. These factories will
+     * return the most appropriate sub-class of NumberFormat for a given
+     * locale.
+     * @param status    Output param set to success/failure code. If the
+     *                  pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(UErrorCode& status);
+
+    /**
+     * Create a DecimalFormat from the given pattern and the symbols
+     * for the default locale. This is a convenient way to obtain a
+     * DecimalFormat when internationalization is not the main concern.
+     * <P>
+     * To obtain standard formats for a given locale, use the factory methods
+     * on NumberFormat such as createInstance. These factories will
+     * return the most appropriate sub-class of NumberFormat for a given
+     * locale.
+     * @param pattern   A non-localized pattern string.
+     * @param status    Output param set to success/failure code. If the
+     *                  pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(const UnicodeString& pattern,
+                  UErrorCode& status);
+
+    /**
+     * Create a DecimalFormat from the given pattern and symbols.
+     * Use this constructor when you need to completely customize the
+     * behavior of the format.
+     * <P>
+     * To obtain standard formats for a given
+     * locale, use the factory methods on NumberFormat such as
+     * createInstance or createCurrencyInstance. If you need only minor adjustments
+     * to a standard format, you can modify the format returned by
+     * a NumberFormat factory method.
+     *
+     * @param pattern           a non-localized pattern string
+     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not
+     *                          delete this object after making this call.
+     * @param status            Output param set to success/failure code. If the
+     *                          pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(  const UnicodeString& pattern,
+                    DecimalFormatSymbols* symbolsToAdopt,
+                    UErrorCode& status);
+
+    /**
+     * Create a DecimalFormat from the given pattern and symbols.
+     * Use this constructor when you need to completely customize the
+     * behavior of the format.
+     * <P>
+     * To obtain standard formats for a given
+     * locale, use the factory methods on NumberFormat such as
+     * createInstance or createCurrencyInstance. If you need only minor adjustments
+     * to a standard format, you can modify the format returned by
+     * a NumberFormat factory method.
+     *
+     * @param pattern           a non-localized pattern string
+     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not
+     *                          delete this object after making this call.
+     * @param parseError        Output param to receive errors occured during parsing 
+     * @param status            Output param set to success/failure code. If the
+     *                          pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(  const UnicodeString& pattern,
+                    DecimalFormatSymbols* symbolsToAdopt,
+                    UParseError& parseError,
+                    UErrorCode& status);
+    /**
+     * Create a DecimalFormat from the given pattern and symbols.
+     * Use this constructor when you need to completely customize the
+     * behavior of the format.
+     * <P>
+     * To obtain standard formats for a given
+     * locale, use the factory methods on NumberFormat such as
+     * createInstance or createCurrencyInstance. If you need only minor adjustments
+     * to a standard format, you can modify the format returned by
+     * a NumberFormat factory method.
+     *
+     * @param pattern           a non-localized pattern string
+     * @param symbols   the set of symbols to be used
+     * @param status            Output param set to success/failure code. If the
+     *                          pattern is invalid this will be set to a failure code.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(  const UnicodeString& pattern,
+                    const DecimalFormatSymbols& symbols,
+                    UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     * 
+     * @param source    the DecimalFormat object to be copied from.
+     * @stable ICU 2.0
+     */
+    DecimalFormat(const DecimalFormat& source);
+
+    /**
+     * Assignment operator.
+     *
+     * @param rhs    the DecimalFormat object to be copied.
+     * @stable ICU 2.0
+     */
+    DecimalFormat& operator=(const DecimalFormat& rhs);
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~DecimalFormat();
+
+    /**
+     * Clone this Format object polymorphically. The caller owns the
+     * result and should delete it when done.
+     *
+     * @return    a polymorphic copy of this DecimalFormat.
+     * @stable ICU 2.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Return true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     *
+     * @param other    the object to be compared with.
+     * @return         true if the given Format objects are semantically equal.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Format a double or long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+    */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+    /**
+     * Format a long number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(int32_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+    /**
+     * Format an int64 number using base-10 representation.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.8
+     */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+
+    /**
+     * Format a Formattable using base-10 representation.
+     *
+     * @param obj       The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Error code indicating success or failure.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+    /**
+     * Redeclared NumberFormat method.
+     * Formats an object to produce a string.
+     *
+     * @param obj       The object to format.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Output parameter filled in with success or failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+
+    /**
+     * Redeclared NumberFormat method.
+     * Format a double number.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(double number,
+                          UnicodeString& appendTo) const;
+
+    /**
+     * Redeclared NumberFormat method.
+     * Format a long number. These methods call the NumberFormat
+     * pure virtual format() methods with the default FieldPosition.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(int32_t number,
+                          UnicodeString& appendTo) const;
+
+    /**
+     * Redeclared NumberFormat method.
+     * Format an int64 number. These methods call the NumberFormat
+     * pure virtual format() methods with the default FieldPosition.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.8
+     */
+    UnicodeString& format(int64_t number,
+                          UnicodeString& appendTo) const;
+   /**
+    * Parse the given string using this object's choices. The method
+    * does string comparisons to try to find an optimal match.
+    * If no object can be parsed, index is unchanged, and NULL is
+    * returned.  The result is returned as the most parsimonious
+    * type of Formattable that will accomodate all of the
+    * necessary precision.  For example, if the result is exactly 12,
+    * it will be returned as a long.  However, if it is 1.5, it will
+    * be returned as a double.
+    *
+    * @param text           The text to be parsed.
+    * @param result         Formattable to be set to the parse result.
+    *                       If parse fails, return contents are undefined.
+    * @param parsePosition  The position to start parsing at on input.
+    *                       On output, moved to after the last successfully
+    *                       parse character. On parse failure, does not change.
+    * @see Formattable
+    * @stable ICU 2.0
+    */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       ParsePosition& parsePosition) const;
+
+    // Declare here again to get rid of function hiding problems.
+    /** 
+     * Parse the given string using this object's choices.
+     *
+     * @param text           The text to be parsed.
+     * @param result         Formattable to be set to the parse result.
+     * @param status    Output parameter filled in with success or failure status.
+     * @stable ICU 2.0
+     */
+    virtual void parse(const UnicodeString& text, 
+                       Formattable& result, 
+                       UErrorCode& status) const;
+
+    /**
+     * Parses text from the given string as a currency amount.  Unlike
+     * the parse() method, this method will attempt to parse a generic
+     * currency name, searching for a match of this object's locale's
+     * currency display names, or for a 3-letter ISO currency code.
+     * This method will fail if this format is not a currency format,
+     * that is, if it does not contain the currency pattern symbol
+     * (U+00A4) in its prefix or suffix.
+     *
+     * @param text the string to parse
+     * @param result output parameter to receive result. This will have
+     * its currency set to the parsed ISO currency code.
+     * @param pos input-output position; on input, the position within
+     * text to match; must have 0 <= pos.getIndex() < text.length();
+     * on output, the position after the last matched character. If
+     * the parse fails, the position in unchanged upon output.
+     * @return a reference to result
+     * @internal
+     */
+    virtual Formattable& parseCurrency(const UnicodeString& text,
+                                       Formattable& result,
+                                       ParsePosition& pos) const;
+
+    /**
+     * Returns the decimal format symbols, which is generally not changed
+     * by the programmer or user.
+     * @return desired DecimalFormatSymbols
+     * @see DecimalFormatSymbols
+     * @stable ICU 2.0
+     */
+    virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;
+
+    /**
+     * Sets the decimal format symbols, which is generally not changed
+     * by the programmer or user.
+     * @param symbolsToAdopt DecimalFormatSymbols to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);
+
+    /**
+     * Sets the decimal format symbols, which is generally not changed
+     * by the programmer or user.
+     * @param symbols DecimalFormatSymbols.
+     * @stable ICU 2.0
+     */
+    virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);
+
+
+    /**
+     * Get the positive prefix.
+     *
+     * @param result    Output param which will receive the positive prefix.
+     * @return          A reference to 'result'.
+     * Examples: +123, $123, sFr123
+     * @stable ICU 2.0
+     */
+    UnicodeString& getPositivePrefix(UnicodeString& result) const;
+
+    /**
+     * Set the positive prefix.
+     *
+     * @param newValue    the new value of the the positive prefix to be set.
+     * Examples: +123, $123, sFr123
+     * @stable ICU 2.0
+     */
+    virtual void setPositivePrefix(const UnicodeString& newValue);
+
+    /**
+     * Get the negative prefix.
+     *
+     * @param result    Output param which will receive the negative prefix.
+     * @return          A reference to 'result'.
+     * Examples: -123, ($123) (with negative suffix), sFr-123
+     * @stable ICU 2.0
+     */
+    UnicodeString& getNegativePrefix(UnicodeString& result) const;
+
+    /**
+     * Set the negative prefix.
+     *
+     * @param newValue    the new value of the the negative prefix to be set.
+     * Examples: -123, ($123) (with negative suffix), sFr-123
+     * @stable ICU 2.0
+     */
+    virtual void setNegativePrefix(const UnicodeString& newValue);
+
+    /**
+     * Get the positive suffix.
+     *
+     * @param result    Output param which will receive the positive suffix.
+     * @return          A reference to 'result'.
+     * Example: 123%
+     * @stable ICU 2.0
+     */
+    UnicodeString& getPositiveSuffix(UnicodeString& result) const;
+
+    /**
+     * Set the positive suffix.
+     *
+     * @param newValue    the new value of the positive suffix to be set.
+     * Example: 123%
+     * @stable ICU 2.0
+     */
+    virtual void setPositiveSuffix(const UnicodeString& newValue);
+
+    /**
+     * Get the negative suffix.
+     *
+     * @param result    Output param which will receive the negative suffix.
+     * @return          A reference to 'result'.
+     * Examples: -123%, ($123) (with positive suffixes)
+     * @stable ICU 2.0
+     */
+    UnicodeString& getNegativeSuffix(UnicodeString& result) const;
+
+    /**
+     * Set the negative suffix.
+     *
+     * @param newValue    the new value of the negative suffix to be set.
+     * Examples: 123%
+     * @stable ICU 2.0
+     */
+    virtual void setNegativeSuffix(const UnicodeString& newValue);
+
+    /**
+     * Get the multiplier for use in percent, permill, etc.
+     * For a percentage, set the suffixes to have "%" and the multiplier to be 100.
+     * (For Arabic, use arabic percent symbol).
+     * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000.
+     *
+     * @return    the multiplier for use in percent, permill, etc.
+     * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
+     * @stable ICU 2.0
+     */
+    int32_t getMultiplier(void) const;
+
+    /**
+     * Set the multiplier for use in percent, permill, etc.
+     * For a percentage, set the suffixes to have "%" and the multiplier to be 100.
+     * (For Arabic, use arabic percent symbol).
+     * For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000.
+     *
+     * @param newValue    the new value of the multiplier for use in percent, permill, etc.
+     * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
+     * @stable ICU 2.0
+     */
+    virtual void setMultiplier(int32_t newValue);
+
+    /**
+     * Get the rounding increment.
+     * @return A positive rounding increment, or 0.0 if rounding
+     * is not in effect.
+     * @see #setRoundingIncrement
+     * @see #getRoundingMode
+     * @see #setRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual double getRoundingIncrement(void) const;
+
+    /**
+     * Set the rounding increment.  This method also controls whether
+     * rounding is enabled.
+     * @param newValue A positive rounding increment, or 0.0 to disable rounding.
+     * Negative increments are equivalent to 0.0.
+     * @see #getRoundingIncrement
+     * @see #getRoundingMode
+     * @see #setRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual void setRoundingIncrement(double newValue);
+
+    /**
+     * Get the rounding mode.
+     * @return A rounding mode
+     * @see #setRoundingIncrement
+     * @see #getRoundingIncrement
+     * @see #setRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual ERoundingMode getRoundingMode(void) const;
+
+    /**
+     * Set the rounding mode.  This has no effect unless the rounding
+     * increment is greater than zero.
+     * @param roundingMode A rounding mode
+     * @see #setRoundingIncrement
+     * @see #getRoundingIncrement
+     * @see #getRoundingMode
+     * @stable ICU 2.0
+     */
+    virtual void setRoundingMode(ERoundingMode roundingMode);
+
+    /**
+     * Get the width to which the output of format() is padded.
+     * The width is counted in 16-bit code units.
+     * @return the format width, or zero if no padding is in effect
+     * @see #setFormatWidth
+     * @see #getPadCharacterString
+     * @see #setPadCharacter
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual int32_t getFormatWidth(void) const;
+
+    /**
+     * Set the width to which the output of format() is padded.
+     * The width is counted in 16-bit code units.
+     * This method also controls whether padding is enabled.
+     * @param width the width to which to pad the result of
+     * format(), or zero to disable padding.  A negative
+     * width is equivalent to 0.
+     * @see #getFormatWidth
+     * @see #getPadCharacterString
+     * @see #setPadCharacter
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual void setFormatWidth(int32_t width);
+
+    /**
+     * Get the pad character used to pad to the format width.  The
+     * default is ' '.
+     * @return a string containing the pad character. This will always
+     * have a length of one 32-bit code point.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #setPadCharacter
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString getPadCharacterString() const;
+
+    /**
+     * Set the character used to pad to the format width.  If padding
+     * is not enabled, then this will take effect if padding is later
+     * enabled.
+     * @param padChar a string containing the pad charcter. If the string
+     * has length 0, then the pad characer is set to ' '.  Otherwise
+     * padChar.char32At(0) will be used as the pad character.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #getPadCharacterString
+     * @see #getPadPosition
+     * @see #setPadPosition
+     * @stable ICU 2.0
+     */
+    virtual void setPadCharacter(const UnicodeString &padChar);
+
+    /**
+     * Get the position at which padding will take place.  This is the location
+     * at which padding will be inserted if the result of format()
+     * is shorter than the format width.
+     * @return the pad position, one of kPadBeforePrefix,
+     * kPadAfterPrefix, kPadBeforeSuffix, or
+     * kPadAfterSuffix.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #setPadCharacter
+     * @see #getPadCharacterString
+     * @see #setPadPosition
+     * @see #EPadPosition
+     * @stable ICU 2.0
+     */
+    virtual EPadPosition getPadPosition(void) const;
+
+    /**
+     * Set the position at which padding will take place.  This is the location
+     * at which padding will be inserted if the result of format()
+     * is shorter than the format width.  This has no effect unless padding is
+     * enabled.
+     * @param padPos the pad position, one of kPadBeforePrefix,
+     * kPadAfterPrefix, kPadBeforeSuffix, or
+     * kPadAfterSuffix.
+     * @see #setFormatWidth
+     * @see #getFormatWidth
+     * @see #setPadCharacter
+     * @see #getPadCharacterString
+     * @see #getPadPosition
+     * @see #EPadPosition
+     * @stable ICU 2.0
+     */
+    virtual void setPadPosition(EPadPosition padPos);
+
+    /**
+     * Return whether or not scientific notation is used.
+     * @return TRUE if this object formats and parses scientific notation
+     * @see #setScientificNotation
+     * @see #getMinimumExponentDigits
+     * @see #setMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual UBool isScientificNotation(void);
+
+    /**
+     * Set whether or not scientific notation is used. When scientific notation
+     * is used, the effective maximum number of integer digits is <= 8.  If the
+     * maximum number of integer digits is set to more than 8, the effective
+     * maximum will be 1.  This allows this call to generate a 'default' scientific
+     * number format without additional changes.
+     * @param useScientific TRUE if this object formats and parses scientific
+     * notation
+     * @see #isScientificNotation
+     * @see #getMinimumExponentDigits
+     * @see #setMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual void setScientificNotation(UBool useScientific);
+
+    /**
+     * Return the minimum exponent digits that will be shown.
+     * @return the minimum exponent digits that will be shown
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #setMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual int8_t getMinimumExponentDigits(void) const;
+
+    /**
+     * Set the minimum exponent digits that will be shown.  This has no
+     * effect unless scientific notation is in use.
+     * @param minExpDig a value >= 1 indicating the fewest exponent digits
+     * that will be shown.  Values less than 1 will be treated as 1.
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #getMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumExponentDigits(int8_t minExpDig);
+
+    /**
+     * Return whether the exponent sign is always shown.
+     * @return TRUE if the exponent is always prefixed with either the
+     * localized minus sign or the localized plus sign, false if only negative
+     * exponents are prefixed with the localized minus sign.
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #setMinimumExponentDigits
+     * @see #getMinimumExponentDigits
+     * @see #setExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual UBool isExponentSignAlwaysShown(void);
+
+    /**
+     * Set whether the exponent sign is always shown.  This has no effect
+     * unless scientific notation is in use.
+     * @param expSignAlways TRUE if the exponent is always prefixed with either
+     * the localized minus sign or the localized plus sign, false if only
+     * negative exponents are prefixed with the localized minus sign.
+     * @see #setScientificNotation
+     * @see #isScientificNotation
+     * @see #setMinimumExponentDigits
+     * @see #getMinimumExponentDigits
+     * @see #isExponentSignAlwaysShown
+     * @stable ICU 2.0
+     */
+    virtual void setExponentSignAlwaysShown(UBool expSignAlways);
+
+    /**
+     * Return the grouping size. Grouping size is the number of digits between
+     * grouping separators in the integer portion of a number.  For example,
+     * in the number "123,456.78", the grouping size is 3.
+     *
+     * @return    the grouping size.
+     * @see setGroupingSize
+     * @see NumberFormat::isGroupingUsed
+     * @see DecimalFormatSymbols::getGroupingSeparator
+     * @stable ICU 2.0
+     */
+    int32_t getGroupingSize(void) const;
+
+    /**
+     * Set the grouping size. Grouping size is the number of digits between
+     * grouping separators in the integer portion of a number.  For example,
+     * in the number "123,456.78", the grouping size is 3.
+     *
+     * @param newValue    the new value of the grouping size.
+     * @see getGroupingSize
+     * @see NumberFormat::setGroupingUsed
+     * @see DecimalFormatSymbols::setGroupingSeparator
+     * @stable ICU 2.0
+     */
+    virtual void setGroupingSize(int32_t newValue);
+
+    /**
+     * Return the secondary grouping size. In some locales one
+     * grouping interval is used for the least significant integer
+     * digits (the primary grouping size), and another is used for all
+     * others (the secondary grouping size).  A formatter supporting a
+     * secondary grouping size will return a positive integer unequal
+     * to the primary grouping size returned by
+     * getGroupingSize().  For example, if the primary
+     * grouping size is 4, and the secondary grouping size is 2, then
+     * the number 123456789 formats as "1,23,45,6789", and the pattern
+     * appears as "#,##,###0".
+     * @return the secondary grouping size, or a value less than
+     * one if there is none
+     * @see setSecondaryGroupingSize
+     * @see NumberFormat::isGroupingUsed
+     * @see DecimalFormatSymbols::getGroupingSeparator
+     * @stable ICU 2.4
+     */
+    int32_t getSecondaryGroupingSize(void) const;
+
+    /**
+     * Set the secondary grouping size. If set to a value less than 1,
+     * then secondary grouping is turned off, and the primary grouping
+     * size is used for all intervals, not just the least significant.
+     *
+     * @param newValue    the new value of the secondary grouping size.
+     * @see getSecondaryGroupingSize
+     * @see NumberFormat#setGroupingUsed
+     * @see DecimalFormatSymbols::setGroupingSeparator
+     * @stable ICU 2.4
+     */
+    virtual void setSecondaryGroupingSize(int32_t newValue);
+
+    /**
+     * Allows you to get the behavior of the decimal separator with integers.
+     * (The decimal separator will always appear with decimals.)
+     *
+     * @return    TRUE if the decimal separator always appear with decimals.
+     * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
+     * @stable ICU 2.0
+     */
+    UBool isDecimalSeparatorAlwaysShown(void) const;
+
+    /**
+     * Allows you to set the behavior of the decimal separator with integers.
+     * (The decimal separator will always appear with decimals.)
+     *
+     * @param newValue    set TRUE if the decimal separator will always appear with decimals.
+     * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
+     * @stable ICU 2.0
+     */
+    virtual void setDecimalSeparatorAlwaysShown(UBool newValue);
+
+    /**
+     * Synthesizes a pattern string that represents the current state
+     * of this Format object.
+     *
+     * @param result    Output param which will receive the pattern.
+     *                  Previous contents are deleted.
+     * @return          A reference to 'result'.
+     * @see applyPattern
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toPattern(UnicodeString& result) const;
+
+    /**
+     * Synthesizes a localized pattern string that represents the current
+     * state of this Format object.
+     *
+     * @param result    Output param which will receive the localized pattern.
+     *                  Previous contents are deleted.
+     * @return          A reference to 'result'.
+     * @see applyPattern
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;
+ 
+    /**
+     * Apply the given pattern to this Format object.  A pattern is a
+     * short-hand specification for the various formatting properties.
+     * These properties can also be changed individually through the
+     * various setter methods.
+     * <P>
+     * There is no limit to integer digits are set
+     * by this routine, since that is the typical end-user desire;
+     * use setMaximumInteger if you want to set a real value.
+     * For negative numbers, use a second pattern, separated by a semicolon
+     * <pre>
+     * .      Example "#,#00.0#" -> 1,234.56
+     * </pre>
+     * This means a minimum of 2 integer digits, 1 fraction digit, and
+     * a maximum of 2 fraction digits.
+     * <pre>
+     * .      Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses.
+     * </pre>
+     * In negative patterns, the minimum and maximum counts are ignored;
+     * these are presumed to be set in the positive pattern.
+     *
+     * @param pattern    The pattern to be applied.
+     * @param parseError Struct to recieve information on position 
+     *                   of error if an error is encountered
+     * @param status     Output param set to success/failure code on
+     *                   exit. If the pattern is invalid, this will be
+     *                   set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                             UParseError& parseError,
+                             UErrorCode& status);
+    /**
+     * Sets the pattern.
+     * @param pattern   The pattern to be applied.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */  
+    virtual void applyPattern(const UnicodeString& pattern,
+                             UErrorCode& status);
+
+    /**
+     * Apply the given pattern to this Format object.  The pattern
+     * is assumed to be in a localized notation. A pattern is a
+     * short-hand specification for the various formatting properties.
+     * These properties can also be changed individually through the
+     * various setter methods.
+     * <P>
+     * There is no limit to integer digits are set
+     * by this routine, since that is the typical end-user desire;
+     * use setMaximumInteger if you want to set a real value.
+     * For negative numbers, use a second pattern, separated by a semicolon
+     * <pre>
+     * .      Example "#,#00.0#" -> 1,234.56
+     * </pre>
+     * This means a minimum of 2 integer digits, 1 fraction digit, and
+     * a maximum of 2 fraction digits.
+     *
+     * Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses.
+     *
+     * In negative patterns, the minimum and maximum counts are ignored;
+     * these are presumed to be set in the positive pattern.
+     *
+     * @param pattern   The localized pattern to be applied.
+     * @param parseError Struct to recieve information on position 
+     *                   of error if an error is encountered
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyLocalizedPattern(const UnicodeString& pattern,
+                                       UParseError& parseError,
+                                       UErrorCode& status);
+
+    /**
+     * Apply the given pattern to this Format object.
+     *
+     * @param pattern   The localized pattern to be applied.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyLocalizedPattern(const UnicodeString& pattern,
+                                       UErrorCode& status);
+
+
+    /**
+     * Sets the maximum number of digits allowed in the integer portion of a
+     * number. This override limits the integer digit count to 309.
+     *
+     * @param newValue    the new value of the maximum number of digits 
+     *                      allowed in the integer portion of a number.
+     * @see NumberFormat#setMaximumIntegerDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMaximumIntegerDigits(int32_t newValue);
+
+    /**
+     * Sets the minimum number of digits allowed in the integer portion of a
+     * number. This override limits the integer digit count to 309.
+     * 
+     * @param newValue    the new value of the minimum number of digits 
+     *                      allowed in the integer portion of a number.
+     * @see NumberFormat#setMinimumIntegerDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumIntegerDigits(int32_t newValue);
+
+    /**
+     * Sets the maximum number of digits allowed in the fraction portion of a
+     * number. This override limits the fraction digit count to 340.
+     *
+     * @param newValue    the new value of the maximum number of digits 
+     *                    allowed in the fraction portion of a number.
+     * @see NumberFormat#setMaximumFractionDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMaximumFractionDigits(int32_t newValue);
+
+    /**
+     * Sets the minimum number of digits allowed in the fraction portion of a
+     * number. This override limits the fraction digit count to 340.
+     *
+     * @param newValue    the new value of the minimum number of digits 
+     *                    allowed in the fraction portion of a number.
+     * @see NumberFormat#setMinimumFractionDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumFractionDigits(int32_t newValue);
+
+    /**
+     * Returns the minimum number of significant digits that will be
+     * displayed. This value has no effect unless areSignificantDigitsUsed()
+     * returns true.
+     * @return the fewest significant digits that will be shown
+     * @stable ICU 3.0
+     */
+    int32_t getMinimumSignificantDigits() const;
+
+    /**
+     * Returns the maximum number of significant digits that will be
+     * displayed. This value has no effect unless areSignificantDigitsUsed()
+     * returns true.
+     * @return the most significant digits that will be shown
+     * @stable ICU 3.0
+     */
+    int32_t getMaximumSignificantDigits() const;
+
+    /**
+     * Sets the minimum number of significant digits that will be
+     * displayed.  If <code>min</code> is less than one then it is set
+     * to one.  If the maximum significant digits count is less than
+     * <code>min</code>, then it is set to <code>min</code>. This
+     * value has no effect unless areSignificantDigits() returns true.
+     * @param min the fewest significant digits to be shown 
+     * @stable ICU 3.0
+     */
+    void setMinimumSignificantDigits(int32_t min);
+
+    /**
+     * Sets the maximum number of significant digits that will be
+     * displayed.  If <code>max</code> is less than one then it is set
+     * to one.  If the minimum significant digits count is greater
+     * than <code>max</code>, then it is set to <code>max</code>.
+     * This value has no effect unless areSignificantDigits() returns
+     * true.
+     * @param max the most significant digits to be shown 
+     * @stable ICU 3.0
+     */
+    void setMaximumSignificantDigits(int32_t max);
+
+    /**
+     * Returns true if significant digits are in use, or false if
+     * integer and fraction digit counts are in use.
+     * @return true if significant digits are in use
+     * @stable ICU 3.0
+     */
+    UBool areSignificantDigitsUsed() const;
+
+    /**
+     * Sets whether significant digits are in use, or integer and
+     * fraction digit counts are in use.
+     * @param useSignificantDigits true to use significant digits, or
+     * false to use integer and fraction digit counts
+     * @stable ICU 3.0
+     */
+    void setSignificantDigitsUsed(UBool useSignificantDigits);
+
+ public:
+    /**
+     * Sets the currency used to display currency
+     * amounts.  This takes effect immediately, if this format is a
+     * currency format.  If this format is not a currency format, then
+     * the currency is used if and when this object becomes a
+     * currency format through the application of a new pattern.
+     * @param theCurrency a 3-letter ISO code indicating new currency
+     * to use.  It need not be null-terminated.  May be the empty
+     * string or NULL to indicate no currency.
+     * @param ec input-output error code
+     * @stable ICU 3.0
+     */
+    virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
+
+    /**
+     * Sets the currency used to display currency amounts.  See
+     * setCurrency(const UChar*, UErrorCode&).
+     * @deprecated ICU 3.0. Use setCurrency(const UChar*, UErrorCode&).
+     */
+    virtual void setCurrency(const UChar* theCurrency);
+
+    /**
+     * The resource tags we use to retrieve decimal format data from
+     * locale resource bundles.
+     * @deprecated ICU 3.4. This string has no public purpose. Please don't use it.
+     */
+    static const char fgNumberPatterns[];
+
+public:
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     * <pre>
+     * .      Base* polymorphic_pointer = createPolymorphicObject();
+     * .      if (polymorphic_pointer->getDynamicClassID() ==
+     * .          Derived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+private:
+    DecimalFormat(); // default constructor not implemented
+
+    int32_t precision(UBool isIntegral) const;
+
+    /**
+     * Do real work of constructing a new DecimalFormat.
+     */
+    void construct(UErrorCode&               status,
+                   UParseError&             parseErr,
+                   const UnicodeString*     pattern = 0,
+                   DecimalFormatSymbols*    symbolsToAdopt = 0
+                   );
+
+    /**
+     * Does the real work of generating a pattern.
+     *
+     * @param result     Output param which will receive the pattern.
+     *                   Previous contents are deleted.
+     * @param localized  TRUE return localized pattern.
+     * @return           A reference to 'result'.
+     */
+    UnicodeString& toPattern(UnicodeString& result, UBool localized) const;
+
+    /**
+     * Does the real work of applying a pattern.
+     * @param pattern    The pattern to be applied.
+     * @param localized  If true, the pattern is localized; else false.
+     * @param parseError Struct to recieve information on position 
+     *                   of error if an error is encountered
+     * @param status     Output param set to success/failure code on
+     *                   exit. If the pattern is invalid, this will be
+     *                   set to a failure result.
+     */
+    void applyPattern(const UnicodeString& pattern,
+                            UBool localized,
+                            UParseError& parseError,
+                            UErrorCode& status);
+    /**
+     * Do the work of formatting a number, either a double or a long.
+     *
+     * @param appendTo       Output parameter to receive result.
+     *                       Result is appended to existing contents.
+     * @param fieldPosition  On input: an alignment field, if desired.
+     *                       On output: the offsets of the alignment field.
+     * @param digits         the digits to be formatted.
+     * @param isInteger      if TRUE format the digits as Integer.
+     * @return               Reference to 'appendTo' parameter.
+     */
+    UnicodeString& subformat(UnicodeString& appendTo,
+                             FieldPosition& fieldPosition,
+                             DigitList& digits,
+                             UBool         isInteger) const;
+
+    void parse(const UnicodeString& text,
+               Formattable& result,
+               ParsePosition& pos,
+               UBool parseCurrency) const;
+
+    enum {
+        fgStatusInfinite,
+        fgStatusLength      // Leave last in list.
+    } StatusFlags;
+
+    UBool subparse(const UnicodeString& text, ParsePosition& parsePosition,
+                   DigitList& digits, UBool* status,
+                   UChar* currency) const;
+
+    int32_t skipPadding(const UnicodeString& text, int32_t position) const;
+
+    int32_t compareAffix(const UnicodeString& input,
+                         int32_t pos,
+                         UBool isNegative,
+                         UBool isPrefix,
+                         UChar* currency) const;
+    
+    static int32_t compareSimpleAffix(const UnicodeString& affix,
+                                      const UnicodeString& input,
+                                      int32_t pos);
+    
+    static int32_t skipRuleWhiteSpace(const UnicodeString& text, int32_t pos);
+    
+    static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);
+    
+    int32_t compareComplexAffix(const UnicodeString& affixPat,
+                                const UnicodeString& input,
+                                int32_t pos,
+                                UChar* currency) const;
+
+    static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);
+
+    static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);
+
+    /**
+     * Get a decimal format symbol.
+     * Returns a const reference to the symbol string.
+     * @internal
+     */
+    inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;
+
+    int32_t appendAffix(UnicodeString& buf, double number,
+                        UBool isNegative, UBool isPrefix) const;
+
+    /**
+     * Append an affix to the given UnicodeString, using quotes if
+     * there are special characters.  Single quotes themselves must be
+     * escaped in either case.
+     */
+    void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix, 
+                            UBool localized) const;
+
+    void appendAffixPattern(UnicodeString& appendTo,
+                            const UnicodeString* affixPattern,
+                            const UnicodeString& expAffix, UBool localized) const;
+
+    void expandAffix(const UnicodeString& pattern,
+                     UnicodeString& affix,
+                     double number,
+                     UBool doFormat) const;
+
+    void expandAffixes();
+    
+    static double round(double a, ERoundingMode mode, UBool isNegative);
+
+    void addPadding(UnicodeString& appendTo,
+                    FieldPosition& fieldPosition,
+                    int32_t prefixLen, int32_t suffixLen) const;
+
+    UBool isGroupingPosition(int32_t pos) const;
+
+    void setCurrencyForSymbols();
+
+    /**
+     * Constants.
+     */
+    //static const int8_t fgMaxDigit; // The largest digit, in this case 9
+
+    /*transient*/ //DigitList* fDigitList;
+
+    UnicodeString           fPositivePrefix;
+    UnicodeString           fPositiveSuffix;
+    UnicodeString           fNegativePrefix;
+    UnicodeString           fNegativeSuffix;
+    UnicodeString*          fPosPrefixPattern;
+    UnicodeString*          fPosSuffixPattern;
+    UnicodeString*          fNegPrefixPattern;
+    UnicodeString*          fNegSuffixPattern;
+
+    /**
+     * Formatter for ChoiceFormat-based currency names.  If this field
+     * is not null, then delegate to it to format currency symbols.
+     * @since ICU 2.6
+     */
+    ChoiceFormat*           fCurrencyChoice;
+
+    int32_t                 fMultiplier;
+    int32_t                 fGroupingSize;
+    int32_t                 fGroupingSize2;
+    UBool                   fDecimalSeparatorAlwaysShown;
+    /*transient*/ UBool     fIsCurrencyFormat;
+    DecimalFormatSymbols*   fSymbols;
+
+    UBool                   fUseSignificantDigits;
+    int32_t                 fMinSignificantDigits;
+    int32_t                 fMaxSignificantDigits;
+
+    UBool                   fUseExponentialNotation;
+    int8_t                  fMinExponentDigits;
+    UBool                   fExponentSignAlwaysShown;
+
+    /* If fRoundingIncrement is NULL, there is no rounding.  Otherwise, round to
+     * fRoundingIncrement.getDouble().  Since this operation may be expensive,
+     * we cache the result in fRoundingDouble.  All methods that update
+     * fRoundingIncrement also update fRoundingDouble. */
+    DigitList*              fRoundingIncrement;
+    /*transient*/ double    fRoundingDouble;
+    ERoundingMode           fRoundingMode;
+
+    UChar32                 fPad;
+    int32_t                 fFormatWidth;
+    EPadPosition            fPadPosition;
+
+protected:
+
+    /**
+     * Returns the currency in effect for this formatter.  Subclasses
+     * should override this method as needed.  Unlike getCurrency(),
+     * this method should never return "".
+     * @result output parameter for null-terminated result, which must
+     * have a capacity of at least 4
+     * @internal
+     */
+    virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
+
+  /** number of integer digits 
+   * @stable ICU 2.4
+   */  
+    static const int32_t  kDoubleIntegerDigits;
+  /** number of fraction digits 
+   * @stable ICU 2.4
+   */  
+    static const int32_t  kDoubleFractionDigits;
+
+    /**
+     * When someone turns on scientific mode, we assume that more than this
+     * number of digits is due to flipping from some other mode that didn't
+     * restrict the maximum, and so we force 1 integer digit.  We don't bother
+     * to track and see if someone is using exponential notation with more than
+     * this number, it wouldn't make sense anyway, and this is just to make sure
+     * that someone turning on scientific mode with default settings doesn't
+     * end up with lots of zeroes.
+     * @stable ICU 2.8
+     */
+    static const int32_t  kMaxScientificIntegerDigits;
+};
+
+inline UnicodeString&
+DecimalFormat::format(const Formattable& obj,
+                      UnicodeString& appendTo,
+                      UErrorCode& status) const {
+    // Don't use Format:: - use immediate base class only,
+    // in case immediate base modifies behavior later.
+    return NumberFormat::format(obj, appendTo, status);
+}
+
+inline UnicodeString&
+DecimalFormat::format(double number,
+                      UnicodeString& appendTo) const {
+    FieldPosition pos(0);
+    return format(number, appendTo, pos);
+}
+
+inline UnicodeString&
+DecimalFormat::format(int32_t number,
+                      UnicodeString& appendTo) const {
+    FieldPosition pos(0);
+    return format((int64_t)number, appendTo, pos);
+}
+
+inline const UnicodeString &
+DecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {
+    return fSymbols->getConstSymbol(symbol);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DECIMFMT
+//eof
diff --git a/CoreFoundation/icu/unicode/docmain.h b/CoreFoundation/icu/unicode/docmain.h
new file mode 100644
index 0000000..973ebea
--- /dev/null
+++ b/CoreFoundation/icu/unicode/docmain.h
@@ -0,0 +1,202 @@
+/********************************************************************
+ * COPYRIGHT: 
+ * Copyright (c) 1997-2007, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *
+ *  FILE NAME: DOCMAIN.h
+ *
+ *   Date          Name        Description
+ *   12/11/2000    Ram        Creation.
+ */
+
+/* This file contains documentation for Doxygen and doesnot have
+ * any significance with respect to C or C++ API
+ */
+
+/*! \mainpage
+ *
+ * \section API API Reference Usage
+ * 
+ * <h3>C++ Programmers:</h3>
+ * <p>Use <a href="hierarchy.html">Class Hierarchy</a> or <a href="classes.html"> Alphabetical List </a>
+ * or <a href="annotated.html"> Compound List</a>
+ * to find the class you are interested in. For example, to find BreakIterator,
+ * you can go to the <a href="classes.html"> Alphabetical List</a>, then click on
+ * "BreakIterator". Once you are at the class, you will find an inheritance
+ * chart, a list of the public members, a detailed description of the class,
+ * then detailed member descriptions.</p>
+ * 
+ * <h3>C Programmers:</h3>
+ * <p>Use <a href="#Module">Module List</a> or <a href="globals.html">File Members</a>
+ * to find a list of all the functions and constants.
+ * For example, to find BreakIterator functions you would click on
+ * <a href="files.html"> File List</a>,
+ * then find "ubrk.h" and click on it. You will find descriptions of Defines,
+ * Typedefs, Enumerations, and Functions, with detailed descriptions below.
+ * If you want to find a specific function, such as ubrk_next(), then click
+ * first on <a href="globals.html"> File Members</a>, then use your browser
+ * Find dialog to search for "ubrk_next()".</p>
+ *
+ *
+ * <h3>API References for Previous Releases</h3>
+ * <p>The API References for each release of ICU are also available as
+ * a zip file from the ICU 
+ * <a href="http://icu-project.org/download/">download page</a>.</p>
+ *
+ * <hr>
+ *
+ * <h2>Architecture (User's Guide)</h2>
+ * <ul>
+ *   <li><a href="http://icu-project.org/userguide/">Introduction</a></li>
+ *   <li><a href="http://icu-project.org/userguide/i18n.html">Internationalization</a></li>
+ *   <li><a href="http://icu-project.org/userguide/design.html">Locale Model</a></li>
+ *   <li><a href="http://icu-project.org/userguide/design.html">Multithreading</a></li>
+ *   <li><a href="http://icu-project.org/userguide/conversion.html">Conversion</a></li>
+ *   <li><a href="http://icu-project.org/userguide/design.html">Error Handling</a></li>
+ * </ul>
+ *
+ * <hr>
+ *\htmlonly <h2><a NAME="Module">Module List</a></h2> \endhtmlonly
+ * <table border="1" cols="3" align="center">
+ *   <tr>
+ *     <td><strong>Module Name</strong></td>
+ *     <td><strong>C</strong></td>
+ *     <td><strong>C++</strong></td>
+ *   </tr>
+ *   <tr>
+ *     <td>Basic Types and Constants</td>
+ *     <td>utypes.h</td>
+ *     <td>utypes.h</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Strings and Character Iteration</td>
+ *     <td>ustring.h, utf.h</td>
+ *     <td>UnicodeString, CharacterIterator</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Unicode Character<br>Properties and Names</td>
+ *     <td>uchar.h</td>
+ *     <td>uchar.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Codepage Conversion</td>
+ *     <td>ucnv.h</td>
+ *     <td>ucnv.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Unicode Text Compression</td>
+ *     <td>ucnv.h <br> (encoding name "SCSU" or "BOCU-1")</td>
+ *     <td>ucnv.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Locales </td>
+ *     <td>uloc.h</a></td>
+ *     <td>Locale</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Resource Bundles</td>
+ *     <td>ures.h</td>
+ *     <td>ResourceBundle</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Normalization</td>
+ *     <td>unorm.h</td>
+ *     <td>Normalizer</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Calendars</td>
+ *     <td>ucal.h</td>
+ *     <td>Calendar</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Date and Time Formatting</td>
+ *     <td>udat.h</td>
+ *     <td>DateFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Message Formatting</td>
+ *     <td>umsg.h</td>
+ *     <td>MessageFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Number Formatting</td>
+ *     <td>unum.h</td>
+ *     <td>NumberFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Number Spellout <br> (Rule Based Number Formatting)</td>
+ *     <td>unum.h <br> (use UNUM_SPELLOUT)</td>
+ *     <td>RuleBasedNumberFormat</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Text Transformation <br> (Transliteration)</td>
+ *     <td>utrans.h</td>
+ *     <td>Transliterator</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Bidirectional Algorithm</td>
+ *     <td>ubidi.h</td>
+ *     <td>ubidi.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Arabic Shaping</td>
+ *     <td>ushape.h</td>
+ *     <td>ushape.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Collation</td>
+ *     <td>ucol.h</td>
+ *     <td>Collator</td>
+ *   </tr>
+ *   <tr>
+ *     <td>String Searching</td>
+ *     <td>usearch.h</td>
+ *     <td>StringSearch</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Text Boundary Analysis <br> (Break Iteration)</td>
+ *     <td>ubrk.h</td>
+ *     <td>BreakIterator</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Unicode Set</td>
+ *     <td>uset.h</td>
+ *     <td>UnicodeSet</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Regular Expressions</td>
+ *     <td>uregex.h</td>
+ *     <td>RegexPattern, RegexMatcher</td>
+ *   </tr>
+ *   <tr>
+ *     <td>StringPrep</td>
+ *     <td>usprep.h</td>
+ *     <td>usprep.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>International Domain Names in Applications</td>
+ *     <td>uidna.h</td>
+ *     <td>uidna.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Universal Time Scale</td>
+ *     <td>utmscale.h</td>
+ *     <td>utmscale.h C API</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Basic Layout Engine Types and Constants</td>
+ *     <td>(no C API)</td>
+ *     <td>LETypes.h</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Complex Text Layout</td>
+ *     <td>(no C API)</td>
+ *     <td>LayoutEngine, ParagraphLayout</td>
+ *   </tr>
+ *   <tr>
+ *     <td>ICU I/O</td>
+ *     <td>ustdio.h</td>
+ *     <td>ustream.h</td>
+ *   </tr>
+ * </table>
+ */
diff --git a/CoreFoundation/icu/unicode/dtfmtsym.h b/CoreFoundation/icu/unicode/dtfmtsym.h
new file mode 100644
index 0000000..8831236
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dtfmtsym.h
@@ -0,0 +1,721 @@
+/*  
+********************************************************************************
+*   Copyright (C) 1997-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File DTFMTSYM.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*    07/21/98    stephen        Added getZoneIndex()
+*                            Changed to match C++ conventions
+********************************************************************************
+*/
+     
+#ifndef DTFMTSYM_H
+#define DTFMTSYM_H
+ 
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/calendar.h"
+#include "unicode/uobject.h"
+#include "unicode/locid.h"
+#include "unicode/ures.h"
+
+/**
+ * \file 
+ * \brief C++ API: Symbols for formatting dates.
+ */
+
+U_NAMESPACE_BEGIN
+
+/* forward declaration */
+class SimpleDateFormat;
+class Hashtable;
+class ZoneStringFormat;
+class SafeZoneStringFormatPtr;
+
+/**
+ * DateFormatSymbols is a public class for encapsulating localizable date-time
+ * formatting data -- including timezone data. DateFormatSymbols is used by
+ * DateFormat and SimpleDateFormat.
+ * <P>
+ * Rather than first creating a DateFormatSymbols to get a date-time formatter
+ * by using a SimpleDateFormat constructor, clients are encouraged to create a
+ * date-time formatter using the getTimeInstance(), getDateInstance(), or
+ * getDateTimeInstance() method in DateFormat. Each of these methods can return a
+ * date/time formatter initialized with a default format pattern along with the
+ * date-time formatting data for a given or default locale. After a formatter is
+ * created, clients may modify the format pattern using the setPattern function
+ * as so desired. For more information on using these formatter factory
+ * functions, see DateFormat.
+ * <P>
+ * If clients decide to create a date-time formatter with a particular format
+ * pattern and locale, they can do so with new SimpleDateFormat(aPattern,
+ * new DateFormatSymbols(aLocale)).  This will load the appropriate date-time
+ * formatting data from the locale.
+ * <P>
+ * DateFormatSymbols objects are clonable. When clients obtain a
+ * DateFormatSymbols object, they can feel free to modify the date-time
+ * formatting data as necessary. For instance, clients can
+ * replace the localized date-time format pattern characters with the ones that
+ * they feel easy to remember. Or they can change the representative cities
+ * originally picked by default to using their favorite ones.
+ * <P>
+ * DateFormatSymbols are not expected to be subclassed. Data for a calendar is
+ * loaded out of resource bundles.  The 'type' parameter indicates the type of
+ * calendar, for example, "gregorian" or "japanese".  If the type is not gregorian
+ * (or NULL, or an empty string) then the type is appended to the resource name,
+ * for example,  'Eras_japanese' instead of 'Eras'.   If the resource 'Eras_japanese' did
+ * not exist (even in root), then this class will fall back to just 'Eras', that is,
+ * Gregorian data.  Therefore, the calendar implementor MUST ensure that the root
+ * locale at least contains any resources that are to be particularized for the
+ * calendar type.
+ */
+class U_I18N_API DateFormatSymbols : public UObject {
+public:
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the default locale, in the default calendar (Gregorian).
+     * <P>
+     * NOTE: This constructor will never fail; if it cannot get resource
+     * data for the default locale, it will return a last-resort object
+     * based on hard-coded strings.
+     *
+     * @param status    Status code.  Failure
+     *                  results if the resources for the default cannot be
+     *                  found or cannot be loaded
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols(UErrorCode& status);
+
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the given locale, in the default calendar (Gregorian).
+     *
+     * @param locale    Locale to load format data from.
+     * @param status    Status code.  Failure
+     *                  results if the resources for the locale cannot be
+     *                  found or cannot be loaded
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols(const Locale& locale,
+                      UErrorCode& status);
+
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the default locale, in the default calendar (Gregorian).
+     * <P>
+     * NOTE: This constructor will never fail; if it cannot get resource
+     * data for the default locale, it will return a last-resort object
+     * based on hard-coded strings.
+     *
+     * @param type      Type of calendar (as returned by Calendar::getType). 
+     *                  Will be used to access the correct set of strings.
+     *                  (NULL or empty string defaults to "gregorian".)
+     * @param status    Status code.  Failure
+     *                  results if the resources for the default cannot be
+     *                  found or cannot be loaded
+     * @internal
+     */
+    DateFormatSymbols(const char *type, UErrorCode& status);
+
+    /**
+     * Construct a DateFormatSymbols object by loading format data from
+     * resources for the given locale, in the default calendar (Gregorian).
+     *
+     * @param locale    Locale to load format data from.
+     * @param type      Type of calendar (as returned by Calendar::getType). 
+     *                  Will be used to access the correct set of strings.
+     *                  (NULL or empty string defaults to "gregorian".)
+     * @param status    Status code.  Failure
+     *                  results if the resources for the locale cannot be
+     *                  found or cannot be loaded
+     * @internal
+     */
+    DateFormatSymbols(const Locale& locale,
+                      const char *type,
+                      UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols(const DateFormatSymbols&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.0
+     */
+    DateFormatSymbols& operator=(const DateFormatSymbols&);
+
+    /**
+     * Destructor. This is nonvirtual because this class is not designed to be
+     * subclassed.
+     * @stable ICU 2.0
+     */
+    virtual ~DateFormatSymbols();
+
+    /**
+     * Return true if another object is semantically equal to this one.
+     *
+     * @param other    the DateFormatSymbols object to be compared with.
+     * @return         true if other is semantically equal to this.
+     * @stable ICU 2.0
+     */
+    UBool operator==(const DateFormatSymbols& other) const;
+
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the DateFormatSymbols object to be compared with.
+     * @return         true if other is semantically unequal to this.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
+
+    /**
+     * Gets abbreviated era strings. For example: "AD" and "BC".
+     *
+     * @param count    Filled in with length of the array.
+     * @return         the era strings.
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getEras(int32_t& count) const;
+
+    /**
+     * Sets abbreviated era strings. For example: "AD" and "BC".
+     * @param eras  Array of era strings (DateFormatSymbols retains ownership.)
+     * @param count Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setEras(const UnicodeString* eras, int32_t count);
+
+    /**
+     * Gets era name strings. For example: "Anno Domini" and "Before Christ".
+     *
+     * @param count    Filled in with length of the array.
+     * @return         the era name strings.
+     * @stable ICU 3.4
+     */
+    const UnicodeString* getEraNames(int32_t& count) const;
+
+    /**
+     * Sets era name strings. For example: "Anno Domini" and "Before Christ".
+     * @param eraNames  Array of era name strings (DateFormatSymbols retains ownership.)
+     * @param count Filled in with length of the array.
+     * @stable ICU 3.6
+     */
+    void setEraNames(const UnicodeString* eraNames, int32_t count);
+
+    /**
+     * Gets narrow era strings. For example: A" and "D".
+     *
+     * @param count    Filled in with length of the array.
+     * @return         the narrow era strings.
+     * @draft ICU 4.2
+     */
+    const UnicodeString* getNarrowEras(int32_t& count) const;
+
+    /**
+     * Sets narrow era strings. For example: "A" and "B".
+     * @param narrowEras  Array of narrow era strings (DateFormatSymbols retains ownership.)
+     * @param count Filled in with length of the array.
+     * @draft ICU 4.2
+     */
+    void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
+
+    /**
+     * Gets month strings. For example: "January", "February", etc.
+     * @param count Filled in with length of the array.
+     * @return the month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getMonths(int32_t& count) const;
+
+    /**
+     * Sets month strings. For example: "January", "February", etc.
+     *
+     * @param months    the new month strings. (not adopted; caller retains ownership)
+     * @param count     Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setMonths(const UnicodeString* months, int32_t count);
+
+    /**
+     * Gets short month strings. For example: "Jan", "Feb", etc.
+     *
+     * @param count Filled in with length of the array.
+     * @return the short month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getShortMonths(int32_t& count) const;
+
+    /**
+     * Sets short month strings. For example: "Jan", "Feb", etc.
+     * @param count        Filled in with length of the array.
+     * @param shortMonths  the new short month strings. (not adopted; caller retains ownership)
+     * @stable ICU 2.0
+     */
+    void setShortMonths(const UnicodeString* shortMonths, int32_t count);
+
+    /**
+     * Selector for date formatting context
+     * @stable ICU 3.6
+     */
+    enum DtContextType {
+         FORMAT,
+         STANDALONE,
+         DT_CONTEXT_COUNT
+    };
+
+    /**
+     * Selector for date formatting width
+     * @stable ICU 3.6
+     */
+    enum DtWidthType {
+         ABBREVIATED,
+         WIDE,
+         NARROW,
+         DT_WIDTH_COUNT
+    };
+
+    /**
+     * Gets month strings by width and context. For example: "January", "February", etc.
+     * @param count Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
+     * @return the month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 3.4
+     */
+    const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets month strings by width and context. For example: "January", "February", etc.
+     *
+     * @param months  The new month strings. (not adopted; caller retains ownership)
+     * @param count   Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
+     * @stable ICU 3.6
+     */
+    void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
+
+    /**
+     * Gets weekday strings. For example: "Sunday", "Monday", etc.
+     * @param count        Filled in with length of the array.
+     * @return the weekday strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getWeekdays(int32_t& count) const;
+
+
+    /**
+     * Sets weekday strings. For example: "Sunday", "Monday", etc.
+     * @param weekdays     the new weekday strings. (not adopted; caller retains ownership)
+     * @param count        Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setWeekdays(const UnicodeString* weekdays, int32_t count);
+
+    /**
+     * Gets short weekday strings. For example: "Sun", "Mon", etc.
+     * @param count        Filled in with length of the array.
+     * @return             the short weekday strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getShortWeekdays(int32_t& count) const;
+
+    /**
+     * Sets short weekday strings. For example: "Sun", "Mon", etc.
+     * @param shortWeekdays  the new short weekday strings. (not adopted; caller retains ownership)
+     * @param count          Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setShortWeekdays(const UnicodeString* shortWeekdays, int32_t count);
+
+    /**
+     * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
+     * @param count   Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW
+     * @return the month strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 3.4
+     */
+    const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
+     * @param weekdays  The new weekday strings. (not adopted; caller retains ownership)
+     * @param count     Filled in with length of the array.
+     * @param context   The formatting context, either FORMAT or STANDALONE
+     * @param width     The width of returned strings, either WIDE, ABBREVIATED, or NARROW
+     * @stable ICU 3.6
+     */
+    void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
+
+    /**
+     * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
+     * @param count Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE or ABBREVIATED. There
+     *                are no NARROW quarters.
+     * @return the quarter strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 3.6
+     */
+    const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
+
+    /**
+     * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
+     *
+     * @param quarters  The new quarter strings. (not adopted; caller retains ownership)
+     * @param count   Filled in with length of the array.
+     * @param context The formatting context, either FORMAT or STANDALONE
+     * @param width   The width of returned strings, either WIDE or ABBREVIATED. There
+     *                are no NARROW quarters.
+     * @stable ICU 3.6
+     */
+    void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
+
+    /**
+     * Gets AM/PM strings. For example: "AM" and "PM".
+     * @param count        Filled in with length of the array.
+     * @return             the weekday strings. (DateFormatSymbols retains ownership.)
+     * @stable ICU 2.0
+     */
+    const UnicodeString* getAmPmStrings(int32_t& count) const;
+
+    /**
+     * Sets ampm strings. For example: "AM" and "PM".
+     * @param ampms        the new ampm strings. (not adopted; caller retains ownership)
+     * @param count        Filled in with length of the array.
+     * @stable ICU 2.0
+     */
+    void setAmPmStrings(const UnicodeString* ampms, int32_t count);
+
+    /**
+     * Gets timezone strings. These strings are stored in a 2-dimensional array.
+     * @param rowCount      Output param to receive number of rows.
+     * @param columnCount   Output param to receive number of columns.
+     * @return              The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
+     * @deprecated ICU 3.6
+     */
+    const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
+
+    /**
+     * Sets timezone strings. These strings are stored in a 2-dimensional array.
+     * @param strings       The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
+     * @param rowCount      The number of rows (count of first index).
+     * @param columnCount   The number of columns (count of second index).
+     * @stable ICU 2.0
+     */
+    void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
+
+    /**
+     * Get the non-localized date-time pattern characters.
+     * @return    the non-localized date-time pattern characters
+     * @stable ICU 2.0
+     */
+    static const UChar * U_EXPORT2 getPatternUChars(void);
+
+    /**
+     * Gets localized date-time pattern characters. For example: 'u', 't', etc.
+     * <p>
+     * Note: ICU no longer provides localized date-time pattern characters for a locale
+     * starting ICU 3.8.  This method returns the non-localized date-time pattern
+     * characters unless user defined localized data is set by setLocalPatternChars.
+     * @param result    Output param which will receive the localized date-time pattern characters.
+     * @return          A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    UnicodeString& getLocalPatternChars(UnicodeString& result) const;
+
+    /**
+     * Sets localized date-time pattern characters. For example: 'u', 't', etc.
+     * @param newLocalPatternChars the new localized date-time
+     * pattern characters.
+     * @stable ICU 2.0
+     */
+    void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
+
+    /**
+     * Returns the locale for this object. Two flavors are available:
+     * valid and actual locale.
+     * @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+
+    friend class SimpleDateFormat;
+    friend class DateFormatSymbolsSingleSetter; // see udat.cpp
+
+    /**
+     * Abbreviated era strings. For example: "AD" and "BC".
+     */
+    UnicodeString*  fEras;
+    int32_t         fErasCount;
+
+    /**
+     * Era name strings. For example: "Anno Domini" and "Before Christ".
+     */
+    UnicodeString*  fEraNames;
+    int32_t         fEraNamesCount;
+
+    /**
+     * Narrow era strings. For example: "A" and "B".
+     */
+    UnicodeString*  fNarrowEras;
+    int32_t         fNarrowErasCount;
+
+    /**
+     * Month strings. For example: "January", "February", etc.
+     */
+    UnicodeString*  fMonths;
+    int32_t         fMonthsCount;
+
+    /**
+     * Short month strings. For example: "Jan", "Feb", etc.
+     */
+    UnicodeString*  fShortMonths;
+    int32_t         fShortMonthsCount;
+
+    /**
+     * Narrow month strings. For example: "J", "F", etc.
+     */
+    UnicodeString*  fNarrowMonths;
+    int32_t         fNarrowMonthsCount;
+
+    /**
+     * Standalone Month strings. For example: "January", "February", etc.
+     */
+    UnicodeString*  fStandaloneMonths;
+    int32_t         fStandaloneMonthsCount;
+
+    /**
+     * Standalone Short month strings. For example: "Jan", "Feb", etc.
+     */
+    UnicodeString*  fStandaloneShortMonths;
+    int32_t         fStandaloneShortMonthsCount;
+
+    /**
+     * Standalone Narrow month strings. For example: "J", "F", etc.
+     */
+    UnicodeString*  fStandaloneNarrowMonths;
+    int32_t         fStandaloneNarrowMonthsCount;
+
+    /**
+     * Weekday strings. For example: "Sunday", "Monday", etc.
+     */
+    UnicodeString*  fWeekdays;
+    int32_t         fWeekdaysCount;
+
+    /**
+     * Short weekday strings. For example: "Sun", "Mon", etc.
+     */
+    UnicodeString*  fShortWeekdays;
+    int32_t         fShortWeekdaysCount;
+
+    /**
+     * Narrow weekday strings. For example: "Sun", "Mon", etc.
+     */
+    UnicodeString*  fNarrowWeekdays;
+    int32_t         fNarrowWeekdaysCount;
+
+    /**
+     * Standalone Weekday strings. For example: "Sunday", "Monday", etc.
+     */
+    UnicodeString*  fStandaloneWeekdays;
+    int32_t         fStandaloneWeekdaysCount;
+
+    /**
+     * Standalone Short weekday strings. For example: "Sun", "Mon", etc.
+     */
+    UnicodeString*  fStandaloneShortWeekdays;
+    int32_t         fStandaloneShortWeekdaysCount;
+
+    /**
+     * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
+     */
+    UnicodeString*  fStandaloneNarrowWeekdays;
+    int32_t         fStandaloneNarrowWeekdaysCount;
+
+    /**
+     * Ampm strings. For example: "AM" and "PM".
+     */
+    UnicodeString*  fAmPms;
+    int32_t         fAmPmsCount;
+
+    /**
+     * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
+     */
+    UnicodeString  *fQuarters;
+    int32_t         fQuartersCount;
+
+    /**
+     * Short quarters. For example: "Q1", "Q2", etc.
+     */
+    UnicodeString  *fShortQuarters;
+    int32_t         fShortQuartersCount;
+
+    /**
+     * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
+     */
+    UnicodeString  *fStandaloneQuarters;
+    int32_t         fStandaloneQuartersCount;
+
+    /**
+     * Standalone short quarter strings. For example: "Q1", "Q2", etc.
+     */
+    UnicodeString  *fStandaloneShortQuarters;
+    int32_t         fStandaloneShortQuartersCount;
+
+    /**
+     * The format data of all the timezones in this locale.
+     */
+    UnicodeString   **fZoneStrings;         // Zone string array set by setZoneStrings
+    UnicodeString   **fLocaleZoneStrings;   // Zone string array created by the locale
+    int32_t         fZoneStringsRowCount;
+    int32_t         fZoneStringsColCount;
+
+    const ZoneStringFormat  *fZoneStringFormat;
+    ZoneStringFormat        *fZSFLocal;         // Local ZoneStringFormat instance
+    SafeZoneStringFormatPtr *fZSFCachePtr;      // Cached ZoneStringFormat
+    Locale                  fZSFLocale;         // Locale used for getting ZoneStringFormat
+
+    /**
+     * Pattern string used for localized time zone GMT format.  For example, "GMT{0}"
+     */
+    UnicodeString   fGmtFormat;
+
+    /**
+     * Pattern strings used for formatting zone offset in a localized time zone GMT string.
+     */
+    UnicodeString  *fGmtHourFormats;
+    int32_t         fGmtHourFormatsCount; 
+
+    enum GMTHourType {
+        GMT_NEGATIVE_HMS = 0,
+        GMT_NEGATIVE_HM,
+        GMT_POSITIVE_HMS,
+        GMT_POSITIVE_HM,
+        GMT_HOUR_COUNT
+    };
+
+    /**
+     * Localized date-time pattern characters. For example: use 'u' as 'y'.
+     */
+    UnicodeString   fLocalPatternChars;
+
+private:
+    /** valid/actual locale information 
+     *  these are always ICU locales, so the length should not be a problem
+     */
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+
+    DateFormatSymbols(); // default constructor not implemented
+
+    /**
+     * Called by the constructors to actually load data from the resources
+     *
+     * @param locale               The locale to get symbols for.
+     * @param type                 Calendar Type (as from Calendar::getType())
+     * @param status               Input/output parameter, set to success or
+     *                             failure code upon return.
+     * @param useLastResortData    determine if use last resort data
+     */
+    void initializeData(const Locale&, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
+
+    /**
+     * Copy or alias an array in another object, as appropriate.
+     *
+     * @param dstArray    the copy destination array.
+     * @param dstCount    fill in with the lenth of 'dstArray'.
+     * @param srcArray    the source array to be copied.
+     * @param srcCount    the length of items to be copied from the 'srcArray'.
+     */
+    static void assignArray(UnicodeString*& dstArray,
+                            int32_t& dstCount,
+                            const UnicodeString* srcArray,
+                            int32_t srcCount);
+
+    /**
+     * Return true if the given arrays' contents are equal, or if the arrays are
+     * identical (pointers are equal).
+     *
+     * @param array1   one array to be compared with.
+     * @param array2   another array to be compared with.
+     * @param count    the length of items to be copied.
+     * @return         true if the given arrays' contents are equal, or if the arrays are
+     *                 identical (pointers are equal).
+     */
+    static UBool arrayCompare(const UnicodeString* array1,
+                             const UnicodeString* array2,
+                             int32_t count);
+
+    /**
+     * Create a copy, in fZoneStrings, of the given zone strings array. The
+     * member variables fZoneStringsRowCount and fZoneStringsColCount should be
+     * set already by the caller.
+     */
+    void createZoneStrings(const UnicodeString *const * otherStrings);
+
+    /**
+     * Delete all the storage owned by this object.
+     */
+    void dispose(void);
+
+    /**
+     * Copy all of the other's data to this.
+     * @param other the object to be copied.
+     */
+    void copyData(const DateFormatSymbols& other);
+
+
+    /**
+     * Returns a ZoneStringFormat, used only by SimpleDateFormat for now.
+     */
+    const ZoneStringFormat* getZoneStringFormat(void) const;
+
+    /**
+     * Create a ZoneStringFormat by locale if not yet availble
+     */
+    void initZoneStringFormat(void);
+    
+    /**
+     * Create zone strings array by locale if not yet available
+     */
+    void initZoneStringsArray(void);
+    
+    /**
+     * Delete just the zone strings.
+     */
+    void disposeZoneStrings(void);
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DTFMTSYM
+//eof
diff --git a/CoreFoundation/icu/unicode/dtintrv.h b/CoreFoundation/icu/unicode/dtintrv.h
new file mode 100644
index 0000000..b55dcd4
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dtintrv.h
@@ -0,0 +1,159 @@
+/*
+*******************************************************************************
+* Copyright (C) 2008, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*
+* File DTINTRV.H 
+*
+*******************************************************************************
+*/
+
+#ifndef __DTINTRV_H__
+#define __DTINTRV_H__
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+
+/**
+ * \file
+ * \brief C++ API: Date Interval data type
+ */
+
+
+U_NAMESPACE_BEGIN
+
+
+/**
+ * This class represents a date interval.
+ * It is a pair of UDate representing from UDate 1 to UDate 2.
+ * @draft ICU 4.0
+**/
+class U_COMMON_API DateInterval : public UObject {
+public:
+
+    /** 
+     * Construct a DateInterval given a from date and a to date.
+     * @param fromDate  The from date in date interval.
+     * @param toDate    The to date in date interval.
+     * @draft ICU 4.0
+     */
+    DateInterval(UDate fromDate, UDate toDate);
+
+    /**
+     * destructor
+     * @draft ICU 4.0
+     */
+    virtual ~DateInterval();
+ 
+    /** 
+     * Get the from date.
+     * @return  the from date in dateInterval.
+     * @draft ICU 4.0
+     */
+    UDate getFromDate() const;
+
+    /** 
+     * Get the to date.
+     * @return  the to date in dateInterval.
+     * @draft ICU 4.0
+     */
+    UDate getToDate() const;
+
+
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @draft ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @draft ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    
+    /**
+     * Copy constructor.
+     * @draft ICU 4.0
+     */
+    DateInterval(const DateInterval& other);
+
+    /**
+     * Default assignment operator
+     * @draft ICU 4.0
+     */
+    DateInterval& operator=(const DateInterval&);
+
+    /**
+     * Equality operator.
+     * @return TRUE if the two DateIntervals are the same
+     * @draft ICU 4.0
+     */
+    virtual UBool operator==(const DateInterval& other) const;
+
+    /**
+     * Non-equality operator
+     * @return TRUE if the two DateIntervals are not the same
+     * @draft ICU 4.0
+     */
+    UBool operator!=(const DateInterval& other) const;
+
+
+    /**
+     * clone this object. 
+     * The caller owns the result and should delete it when done.
+     * @return a cloned DateInterval
+     * @draft ICU 4.0
+     */
+     virtual DateInterval* clone() const;
+
+private:
+    /** 
+     * Default constructor, not implemented.
+     * @draft ICU 4.0
+     */
+    DateInterval();
+
+    UDate fromDate;
+    UDate toDate;
+
+} ;// end class DateInterval
+
+
+inline UDate 
+DateInterval::getFromDate() const { 
+    return fromDate; 
+}
+
+
+inline UDate 
+DateInterval::getToDate() const { 
+    return toDate; 
+}
+
+
+inline UBool 
+DateInterval::operator!=(const DateInterval& other) const { 
+    return ( !operator==(other) );
+}
+
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/dtitvfmt.h b/CoreFoundation/icu/unicode/dtitvfmt.h
new file mode 100644
index 0000000..2384437
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dtitvfmt.h
@@ -0,0 +1,949 @@
+/********************************************************************************
+* Copyright (C) 2008, International Business Machines Corporation and others. All Rights Reserved.
+*******************************************************************************
+*
+* File DTITVFMT.H
+*
+*******************************************************************************
+*/
+
+#ifndef __DTITVFMT_H__
+#define __DTITVFMT_H__
+
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Format and parse date interval in a language-independent manner.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ucal.h"
+#include "unicode/smpdtfmt.h"
+#include "unicode/dtintrv.h"
+#include "unicode/dtitvinf.h"
+
+U_NAMESPACE_BEGIN
+
+
+
+/**
+ * DateIntervalFormat is a class for formatting and parsing date 
+ * intervals in a language-independent manner. 
+ * Date interval formatting is supported in Gregorian calendar only.
+ * And only formatting is supported. Parsing is not supported.
+ *
+ * <P>
+ * Date interval means from one date to another date,
+ * for example, from "Jan 11, 2008" to "Jan 18, 2008".
+ * We introduced class DateInterval to represent it.
+ * DateInterval is a pair of UDate, which is 
+ * the standard milliseconds since 24:00 GMT, Jan 1, 1970.
+ *
+ * <P>
+ * DateIntervalFormat formats a DateInterval into
+ * text as compactly as possible. 
+ * For example, the date interval format from "Jan 11, 2008" to "Jan 18,. 2008"
+ * is "Jan 11-18, 2008" for English.
+ * And it parses text into DateInterval, 
+ * although initially, parsing is not supported. 
+ *
+ * <P>
+ * There is no structural information in date time patterns. 
+ * For any punctuations and string literals inside a date time pattern, 
+ * we do not know whether it is just a separator, or a prefix, or a suffix. 
+ * Without such information, so, it is difficult to generate a sub-pattern 
+ * (or super-pattern) by algorithm.
+ * So, formatting a DateInterval is pattern-driven. It is very
+ * similar to formatting in SimpleDateFormat.
+ * We introduce class DateIntervalInfo to save date interval 
+ * patterns, similar to date time pattern in SimpleDateFormat.
+ *
+ * <P>
+ * Logically, the interval patterns are mappings
+ * from (skeleton, the_largest_different_calendar_field)
+ * to (date_interval_pattern).
+ *
+ * <P>
+ * A skeleton 
+ * <ol>
+ * <li>
+ * only keeps the field pattern letter and ignores all other parts 
+ * in a pattern, such as space, punctuations, and string literals.
+ * </li>
+ * <li>
+ * hides the order of fields. 
+ * </li>
+ * <li>
+ * might hide a field's pattern letter length.
+ * </li>
+ * </ol>
+ *
+ * For those non-digit calendar fields, the pattern letter length is 
+ * important, such as MMM, MMMM, and MMMMM; EEE and EEEE, 
+ * and the field's pattern letter length is honored.
+ *    
+ * For the digit calendar fields,  such as M or MM, d or dd, yy or yyyy, 
+ * the field pattern length is ignored and the best match, which is defined 
+ * in date time patterns, will be returned without honor the field pattern
+ * letter length in skeleton.
+ *
+ * <P>
+ * The calendar fields we support for interval formatting are:
+ * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.
+ * Those calendar fields can be defined in the following order:
+ * year >  month > date > hour (in day) >  minute 
+ *  
+ * The largest different calendar fields between 2 calendars is the
+ * first different calendar field in above order.
+ *
+ * For example: the largest different calendar fields between "Jan 10, 2007" 
+ * and "Feb 20, 2008" is year.
+ *
+ * <P>
+ * For other calendar fields, the compact interval formatting is not
+ * supported. And the interval format will be fall back to fall-back
+ * patterns, which is mostly "{date0} - {date1}".
+ *   
+ * <P>
+ * There is a set of pre-defined static skeleton strings.
+ * There are pre-defined interval patterns for those pre-defined skeletons
+ * in locales' resource files.
+ * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is  "yMMMd",
+ * in  en_US, if the largest different calendar field between date1 and date2 
+ * is "year", the date interval pattern  is "MMM d, yyyy - MMM d, yyyy", 
+ * such as "Jan 10, 2007 - Jan 10, 2008".
+ * If the largest different calendar field between date1 and date2 is "month",
+ * the date interval pattern is "MMM d - MMM d, yyyy",
+ * such as "Jan 10 - Feb 10, 2007".
+ * If the largest different calendar field between date1 and date2 is "day",
+ * the date interval pattern is ""MMM d-d, yyyy", such as "Jan 10-20, 2007".
+ *
+ * For date skeleton, the interval patterns when year, or month, or date is 
+ * different are defined in resource files.
+ * For time skeleton, the interval patterns when am/pm, or hour, or minute is
+ * different are defined in resource files.
+ *
+ * <P>
+ * If a skeleton is not found in a locale's DateIntervalInfo, which means
+ * the interval patterns for the skeleton is not defined in resource file,
+ * the interval pattern will falls back to the interval "fallback" pattern 
+ * defined in resource file.
+ * If the interval "fallback" pattern is not defined, the default fall-back
+ * is "{date0} - {data1}".
+ *
+ * <P>
+ * For the combination of date and time, 
+ * The rule to generate interval patterns are:
+ * <ol>
+ * <li>
+ *    when the year, month, or day differs, falls back to fall-back
+ *    interval pattern, which mostly is the concatenate the two original 
+ *    expressions with a separator between, 
+ *    For example, interval pattern from "Jan 10, 2007 10:10 am" 
+ *    to "Jan 11, 2007 10:10am" is 
+ *    "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am" 
+ * </li>
+ * <li>
+ *    otherwise, present the date followed by the range expression 
+ *    for the time.
+ *    For example, interval pattern from "Jan 10, 2007 10:10 am" 
+ *    to "Jan 10, 2007 11:10am" is "Jan 10, 2007 10:10 am - 11:10am" 
+ * </li>
+ * </ol>
+ *
+ *
+ * <P>
+ * If two dates are the same, the interval pattern is the single date pattern.
+ * For example, interval pattern from "Jan 10, 2007" to "Jan 10, 2007" is 
+ * "Jan 10, 2007".
+ *
+ * Or if the presenting fields between 2 dates have the exact same values,
+ * the interval pattern is the  single date pattern. 
+ * For example, if user only requests year and month,
+ * the interval pattern from "Jan 10, 2007" to "Jan 20, 2007" is "Jan 2007".
+ *
+ * <P>
+ * DateIntervalFormat needs the following information for correct 
+ * formatting: time zone, calendar type, pattern, date format symbols, 
+ * and date interval patterns.
+ * It can be instantiated in 2 ways:
+ * <ol>
+ * <li>
+ *    create an instance using default or given locale plus given skeleton.
+ *    Users are encouraged to created date interval formatter this way and 
+ *    to use the pre-defined skeleton macros, such as
+ *    UDAT_YEAR_NUM_MONTH, which consists the calendar fields and
+ *    the format style. 
+ * </li>
+ * <li>
+ *    create an instance using default or given locale plus given skeleton
+ *    plus a given DateIntervalInfo.
+ *    This factory method is for powerful users who want to provide their own 
+ *    interval patterns. 
+ *    Locale provides the timezone, calendar, and format symbols information.
+ *    Local plus skeleton provides full pattern information.
+ *    DateIntervalInfo provides the date interval patterns.
+ * </li>
+ * </ol>
+ *
+ * <P>
+ * For the calendar field pattern letter, such as G, y, M, d, a, h, H, m, s etc.
+ * DateIntervalFormat uses the same syntax as that of
+ * DateTime format.
+ * 
+ * <P>
+ * Code Sample: general usage
+ * <pre>
+ * \code
+ *   // the date interval object which the DateIntervalFormat formats on
+ *   // and parses into
+ *   DateInterval*  dtInterval = new DateInterval(1000*3600*24, 1000*3600*24*2);
+ *   UErrorCode status = U_ZERO_ERROR;
+ *   DateIntervalFormat* dtIntervalFmt = DateIntervalFormat::createInstance(
+ *                           UDAT_YEAR_MONTH_DAY, 
+ *                           Locale("en", "GB", ""), status);
+ *   UnicodeUnicodeString dateIntervalString;
+ *   FieldPosition pos = 0;
+ *   // formatting
+ *   dtIntervalFmt->format(dtInterval, dateIntervalUnicodeString, pos, status);
+ *   delete dtIntervalFmt;
+ * \endcode
+ * </pre>
+ */
+
+class U_I18N_API DateIntervalFormat : public Format {
+public:
+
+    /**
+     * Construct a DateIntervalFormat from skeleton and  the default locale.
+     *
+     * This is a convenient override of 
+     * createInstance(const UnicodeString& skeleton, const Locale& locale,
+     *                UErrorCode&)  
+     * with the value of locale as default locale.
+     *
+     * @param skeleton  the skeleton on which interval format based.
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @draft ICU 4.0
+     */
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                               const UnicodeString& skeleton,
+                                               UErrorCode& status);
+
+    /**
+     * Construct a DateIntervalFormat from skeleton and a given locale.
+     * <P>
+     * In this factory method, 
+     * the date interval pattern information is load from resource files.
+     * Users are encouraged to created date interval formatter this way and 
+     * to use the pre-defined skeleton macros.
+     *
+     * <P>
+     * There are pre-defined skeletons (defined in udate.h) having predefined 
+     * interval patterns in resource files.
+     * Users are encouraged to use those macros.
+     * For example: 
+     * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status) 
+     *
+     * The given Locale provides the interval patterns.
+     * For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY,
+     * which is "yMMMEEEd",
+     * the interval patterns defined in resource file to above skeleton are:
+     * "EEE, d MMM, yyyy - EEE, d MMM, yyyy" for year differs,
+     * "EEE, d MMM - EEE, d MMM, yyyy" for month differs,
+     * "EEE, d - EEE, d MMM, yyyy" for day differs,
+     * @param skeleton  the skeleton on which interval format based.
+     * @param locale    the given locale
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @draft ICU 4.0
+     */
+
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                               const UnicodeString& skeleton,
+                                               const Locale& locale,
+                                               UErrorCode& status);
+
+    /**
+     * Construct a DateIntervalFormat from skeleton
+     *  DateIntervalInfo, and default locale.
+     *
+     * This is a convenient override of
+     * createInstance(const UnicodeString& skeleton, const Locale& locale, 
+     *                const DateIntervalInfo& dtitvinf, UErrorCode&)
+     * with the locale value as default locale.
+     *
+     * @param skeleton  the skeleton on which interval format based.
+     * @param dtitvinf  the DateIntervalInfo object. 
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @draft ICU 4.0
+     */
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                              const UnicodeString& skeleton,
+                                              const DateIntervalInfo& dtitvinf,
+                                              UErrorCode& status);
+
+    /**
+     * Construct a DateIntervalFormat from skeleton
+     * a DateIntervalInfo, and the given locale.
+     *
+     * <P>
+     * In this factory method, user provides its own date interval pattern
+     * information, instead of using those pre-defined data in resource file. 
+     * This factory method is for powerful users who want to provide their own 
+     * interval patterns. 
+     * <P>
+     * There are pre-defined skeletons (defined in udate.h) having predefined 
+     * interval patterns in resource files.
+     * Users are encouraged to use those macros.
+     * For example: 
+     * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status) 
+     *
+     * The DateIntervalInfo provides the interval patterns.
+     * and the DateIntervalInfo ownership remains to the caller. 
+     *
+     * User are encouraged to set default interval pattern in DateIntervalInfo
+     * as well, if they want to set other interval patterns ( instead of
+     * reading the interval patterns from resource files).
+     * When the corresponding interval pattern for a largest calendar different
+     * field is not found ( if user not set it ), interval format fallback to
+     * the default interval pattern.
+     * If user does not provide default interval pattern, it fallback to
+     * "{date0} - {date1}" 
+     *
+     * @param skeleton  the skeleton on which interval format based.
+     * @param locale    the given locale
+     * @param dtitvinf  the DateIntervalInfo object.
+     * @param status    output param set to success/failure code on exit
+     * @return          a date time interval formatter which the caller owns.
+     * @draft ICU 4.0
+     */
+    static DateIntervalFormat* U_EXPORT2 createInstance(
+                                              const UnicodeString& skeleton,
+                                              const Locale& locale,
+                                              const DateIntervalInfo& dtitvinf,
+                                              UErrorCode& status);
+
+    /**
+     * Destructor.
+     * @draft ICU 4.0
+     */
+    virtual ~DateIntervalFormat();
+
+    /**
+     * Clone this Format object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @draft ICU 4.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Return true if the given Format objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param other    the object to be compared with.
+     * @return         true if the given Format objects are semantically equal.
+     * @draft ICU 4.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Return true if the given Format objects are not semantically equal. 
+     * Objects of different subclasses are considered unequal.
+     * @param other the object to be compared with.
+     * @return      true if the given Format objects are not semantically equal.
+     * @draft ICU 4.0
+     */
+    UBool operator!=(const Format& other) const;
+
+    /**
+     * Format an object to produce a string. This method handles Formattable
+     * objects with a DateInterval type. 
+     * If a the Formattable object type is not a DateInterval,
+     * then it returns a failing UErrorCode.
+     *
+     * @param obj               The object to format. 
+     *                          Must be a DateInterval.
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param fieldPosition     On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            Output param filled with success/failure status.
+     * @return                  Reference to 'appendTo' parameter.
+     * @draft ICU 4.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& fieldPosition,
+                                  UErrorCode& status) const ;
+                                    
+                                    
+
+    /**
+     * Format a DateInterval to produce a string. 
+     *
+     * @param dtInterval        DateInterval to be formatted.
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param fieldPosition     On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            Output param filled with success/failure status.
+     * @return                  Reference to 'appendTo' parameter.
+     * @draft ICU 4.0
+     */
+    UnicodeString& format(const DateInterval* dtInterval,
+                          UnicodeString& appendTo,
+                          FieldPosition& fieldPosition,
+                          UErrorCode& status) const ;
+                                    
+                                    
+    /**
+     * Format 2 Calendars to produce a string. 
+     *
+     * Note: "fromCalendar" and "toCalendar" are not const,
+     * since calendar is not const in  SimpleDateFormat::format(Calendar&),
+     *
+     * @param fromCalendar      calendar set to the from date in date interval
+     *                          to be formatted into date interval string
+     * @param toCalendar        calendar set to the to date in date interval
+     *                          to be formatted into date interval string
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param fieldPosition     On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            Output param filled with success/failure status.
+     *                          Caller needs to make sure it is SUCCESS
+     *                          at the function entrance
+     * @return                  Reference to 'appendTo' parameter.
+     * @draft ICU 4.0
+     */
+    UnicodeString& format(Calendar& fromCalendar,
+                          Calendar& toCalendar,
+                          UnicodeString& appendTo,
+                          FieldPosition& fieldPosition,
+                          UErrorCode& status) const ;
+
+    /**
+     * Date interval parsing is not supported. Please do not use.
+     * <P>
+     * This method should handle parsing of
+     * date time interval strings into Formattable objects with 
+     * DateInterval type, which is a pair of UDate.
+     * <P>
+     * Before calling, set parse_pos.index to the offset you want to start
+     * parsing at in the source. After calling, parse_pos.index is the end of
+     * the text you parsed. If error occurs, index is unchanged.
+     * <P>
+     * When parsing, leading whitespace is discarded (with a successful parse),
+     * while trailing whitespace is left as is.
+     * <P>
+     * See Format::parseObject() for more.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param parse_pos The position to start parsing at. Since no parsing
+     *                  is supported, upon return this param is unchanged.
+     * @return          A newly created Formattable* object, or NULL
+     *                  on failure.  The caller owns this and should
+     *                  delete it when done.
+     * @internal ICU 4.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& parse_pos) const;
+
+
+    /**
+     * Gets the date time interval patterns.
+     * @return the date time interval patterns associated with
+     * this date interval formatter.
+     * @draft ICU 4.0
+     */
+    const DateIntervalInfo* getDateIntervalInfo(void) const;
+
+
+    /**
+     * Set the date time interval patterns. 
+     * @param newIntervalPatterns   the given interval patterns to copy.
+     * @param status          output param set to success/failure code on exit
+     * @draft ICU 4.0
+     */
+    void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
+                             UErrorCode& status);
+
+
+    /**
+     * Gets the date formatter
+     * @return the date formatter associated with this date interval formatter.
+     * @draft ICU 4.0
+     */
+    const DateFormat* getDateFormat(void) const;
+
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @draft ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @draft ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+protected:
+
+    /**
+     * Copy constructor.
+     * @draft ICU 4.0
+     */
+    DateIntervalFormat(const DateIntervalFormat&);
+
+    /**
+     * Assignment operator.
+     * @draft ICU 4.0
+     */
+    DateIntervalFormat& operator=(const DateIntervalFormat&);
+
+private:
+
+    /*
+     * This is for ICU internal use only. Please do not use.
+     * Save the interval pattern information.
+     * Interval pattern consists of 2 single date patterns and the separator.
+     * For example, interval pattern "MMM d - MMM d, yyyy" consists
+     * a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
+     * and a separator "-".
+     * The pattern is divided into 2 parts. For above example,
+     * the first part is "MMM d - ", and the second part is "MMM d, yyyy".
+     * Also, the first date appears in an interval pattern could be 
+     * the earlier date or the later date.
+     * And such information is saved in the interval pattern as well.
+     * @internal ICU 4.0
+     */
+    struct PatternInfo {
+        UnicodeString firstPart;
+        UnicodeString secondPart;
+        /**
+         * Whether the first date in interval pattern is later date or not.
+         * Fallback format set the default ordering.
+         * And for a particular interval pattern, the order can be 
+         * overriden by prefixing the interval pattern with "latestFirst:" or 
+         * "earliestFirst:"
+         * For example, given 2 date, Jan 10, 2007 to Feb 10, 2007.
+         * if the fallback format is "{0} - {1}", 
+         * and the pattern is "d MMM - d MMM yyyy", the interval format is
+         * "10 Jan - 10 Feb, 2007".
+         * If the pattern is "latestFirst:d MMM - d MMM yyyy", 
+         * the interval format is "10 Feb - 10 Jan, 2007"
+         */
+        UBool         laterDateFirst;
+    };
+
+   
+    /**
+     * default constructor 
+     * @internal ICU 4.0
+     */
+    DateIntervalFormat();
+
+    /**
+     * Construct a DateIntervalFormat from DateFormat,
+     * a DateIntervalInfo, and skeleton.
+     * DateFormat provides the timezone, calendar,
+     * full pattern, and date format symbols information.
+     * It should be a SimpleDateFormat object which 
+     * has a pattern in it.
+     * the DateIntervalInfo provides the interval patterns.
+     *
+     * Note: the DateIntervalFormat takes ownership of both 
+     * DateFormat and DateIntervalInfo objects. 
+     * Caller should not delete them.
+     *
+     * @param dtfmt     the SimpleDateFormat object to be adopted.
+     * @param dtitvinf  the DateIntervalInfo object to be adopted.
+     * @param skeleton  the skeleton of the date formatter
+     * @param status    output param set to success/failure code on exit
+     * @internal ICU 4.0
+     */
+    DateIntervalFormat(DateFormat* dtfmt, DateIntervalInfo* dtItvInfo,
+                       const UnicodeString* skeleton, UErrorCode& status);
+
+    
+    /**
+     * Construct a DateIntervalFormat from DateFormat
+     * and a DateIntervalInfo.
+     *
+     * It is a wrapper of the constructor.
+     *
+     * @param dtfmt     the DateFormat object to be adopted.
+     * @param dtitvinf  the DateIntervalInfo object to be adopted.
+     * @param skeleton  the skeleton of this formatter.
+     * @param status    Output param set to success/failure code.
+     * @return          a date time interval formatter which the caller owns.
+     * @internal ICU 4.0
+     */
+    static DateIntervalFormat* U_EXPORT2 create(DateFormat* dtfmt,
+                                                DateIntervalInfo* dtitvinf,
+                                                const UnicodeString* skeleton,
+                                                UErrorCode& status);
+
+
+    /**
+     *  Below are for generating interval patterns locale to the formatter 
+     */
+
+
+    /**
+     * Format 2 Calendars using fall-back interval pattern
+     *
+     * The full pattern used in this fall-back format is the
+     * full pattern of the date formatter.
+     *
+     * @param fromCalendar      calendar set to the from date in date interval
+     *                          to be formatted into date interval string
+     * @param toCalendar        calendar set to the to date in date interval
+     *                          to be formatted into date interval string
+     * @param appendTo          Output parameter to receive result.
+     *                          Result is appended to existing contents.
+     * @param pos               On input: an alignment field, if desired.
+     *                          On output: the offsets of the alignment field.
+     * @param status            output param set to success/failure code on exit
+     * @return                  Reference to 'appendTo' parameter.
+     * @internal ICU 4.0
+     */
+    UnicodeString& fallbackFormat(Calendar& fromCalendar,
+                                  Calendar& toCalendar,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+
+
+    /** 
+     * Initialize interval patterns locale to this formatter
+     * 
+     * This code is a bit complicated since 
+     * 1. the interval patterns saved in resource bundle files are interval
+     *    patterns based on date or time only.
+     *    It does not have interval patterns based on both date and time.
+     *    Interval patterns on both date and time are algorithm generated.
+     *
+     *    For example, it has interval patterns on skeleton "dMy" and "hm",
+     *    but it does not have interval patterns on skeleton "dMyhm".
+     *    
+     *    The rule to generate interval patterns for both date and time skeleton are
+     *    1) when the year, month, or day differs, concatenate the two original 
+     *    expressions with a separator between, 
+     *    For example, interval pattern from "Jan 10, 2007 10:10 am" 
+     *    to "Jan 11, 2007 10:10am" is 
+     *    "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am" 
+     *
+     *    2) otherwise, present the date followed by the range expression 
+     *    for the time.
+     *    For example, interval pattern from "Jan 10, 2007 10:10 am" 
+     *    to "Jan 10, 2007 11:10am" is 
+     *    "Jan 10, 2007 10:10 am - 11:10am" 
+     *
+     * 2. even a pattern does not request a certain calendar field,
+     *    the interval pattern needs to include such field if such fields are
+     *    different between 2 dates.
+     *    For example, a pattern/skeleton is "hm", but the interval pattern 
+     *    includes year, month, and date when year, month, and date differs.
+     * 
+     *
+     * @param status    output param set to success/failure code on exit
+     * @internal ICU 4.0 
+     */
+    void initializePattern(UErrorCode& status); 
+                              
+
+
+    /**
+     * Set fall back interval pattern given a calendar field,
+     * a skeleton, and a date time pattern generator.
+     * @param field      the largest different calendar field
+     * @param skeleton   a skeleton
+     * @param dtpng      date time pattern generator
+     * @param status     output param set to success/failure code on exit
+     * @internal ICU 4.0 
+     */
+    void setFallbackPattern(UCalendarDateFields field, 
+                            const UnicodeString& skeleton,
+                            DateTimePatternGenerator* dtpng,
+                            UErrorCode& status);
+                            
+
+
+    /** 
+     * get separated date and time skeleton from a combined skeleton.
+     *
+     * The difference between date skeleton and normalizedDateSkeleton are:
+     * 1. both 'y' and 'd' are appeared only once in normalizeDateSkeleton
+     * 2. 'E' and 'EE' are normalized into 'EEE'
+     * 3. 'MM' is normalized into 'M'
+     *
+     ** the difference between time skeleton and normalizedTimeSkeleton are:
+     * 1. both 'H' and 'h' are normalized as 'h' in normalized time skeleton,
+     * 2. 'a' is omitted in normalized time skeleton.
+     * 3. there is only one appearance for 'h', 'm','v', 'z' in normalized time
+     *    skeleton
+     *
+     *
+     *  @param skeleton               given combined skeleton.
+     *  @param date                   Output parameter for date only skeleton.
+     *  @param normalizedDate         Output parameter for normalized date only
+     *
+     *  @param time                   Output parameter for time only skeleton.
+     *  @param normalizedTime         Output parameter for normalized time only
+     *                                skeleton.
+     *
+     * @internal ICU 4.0 
+     */
+    static void  U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
+                                    UnicodeString& date,
+                                    UnicodeString& normalizedDate,
+                                    UnicodeString& time,
+                                    UnicodeString& normalizedTime);
+
+
+
+    /**
+     * Generate date or time interval pattern from resource,
+     * and set them into the interval pattern locale to this formatter.
+     *
+     * It needs to handle the following: 
+     * 1. need to adjust field width.
+     *    For example, the interval patterns saved in DateIntervalInfo
+     *    includes "dMMMy", but not "dMMMMy".
+     *    Need to get interval patterns for dMMMMy from dMMMy.
+     *    Another example, the interval patterns saved in DateIntervalInfo
+     *    includes "hmv", but not "hmz".
+     *    Need to get interval patterns for "hmz' from 'hmv'
+     *
+     * 2. there might be no pattern for 'y' differ for skeleton "Md",
+     *    in order to get interval patterns for 'y' differ,
+     *    need to look for it from skeleton 'yMd'
+     *
+     * @param dateSkeleton   normalized date skeleton
+     * @param timeSkeleton   normalized time skeleton
+     * @return               whether the resource is found for the skeleton.
+     *                       TRUE if interval pattern found for the skeleton,
+     *                       FALSE otherwise.
+     * @internal ICU 4.0
+     */
+    UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton, 
+                                 const UnicodeString& timeSkeleton);
+                                   
+
+
+
+    /**
+     * Generate interval pattern from existing resource
+     *
+     * It not only save the interval patterns,
+     * but also return the extended skeleton and its best match skeleton.
+     *
+     * @param field           largest different calendar field
+     * @param skeleton        skeleton
+     * @param bestSkeleton    the best match skeleton which has interval pattern
+     *                        defined in resource
+     * @param differenceInfo  the difference between skeleton and best skeleton
+     *         0 means the best matched skeleton is the same as input skeleton
+     *         1 means the fields are the same, but field width are different
+     *         2 means the only difference between fields are v/z,
+     *        -1 means there are other fields difference 
+     *
+     * @param extendedSkeleton      extended skeleton
+     * @param extendedBestSkeleton  extended best match skeleton
+     * @return                      whether the interval pattern is found 
+     *                              through extending skeleton or not.
+     *                              TRUE if interval pattern is found by
+     *                              extending skeleton, FALSE otherwise.
+     * @internal ICU 4.0
+     */
+    UBool setIntervalPattern(UCalendarDateFields field, 
+                             const UnicodeString* skeleton, 
+                             const UnicodeString* bestSkeleton, 
+                             int8_t differenceInfo, 
+                             UnicodeString* extendedSkeleton = NULL,
+                             UnicodeString* extendedBestSkeleton = NULL);
+
+    /**
+     * Adjust field width in best match interval pattern to match
+     * the field width in input skeleton.
+     *
+     * TODO (xji) make a general solution
+     * The adjusting rule can be:
+     * 1. always adjust
+     * 2. never adjust
+     * 3. default adjust, which means adjust according to the following rules
+     * 3.1 always adjust string, such as MMM and MMMM
+     * 3.2 never adjust between string and numeric, such as MM and MMM
+     * 3.3 always adjust year
+     * 3.4 do not adjust 'd', 'h', or 'm' if h presents
+     * 3.5 do not adjust 'M' if it is numeric(?)
+     *
+     * Since date interval format is well-formed format,
+     * date and time skeletons are normalized previously,
+     * till this stage, the adjust here is only "adjust strings, such as MMM
+     * and MMMM, EEE and EEEE.
+     *
+     * @param inputSkeleton            the input skeleton
+     * @param bestMatchSkeleton        the best match skeleton
+     * @param bestMatchIntervalpattern the best match interval pattern
+     * @param differenceInfo           the difference between 2 skeletons
+     *                                 1 means only field width differs
+     *                                 2 means v/z exchange
+     * @param adjustedIntervalPattern  adjusted interval pattern
+     * @internal ICU 4.0
+     */
+    static void U_EXPORT2 adjustFieldWidth(
+                            const UnicodeString& inputSkeleton,
+                            const UnicodeString& bestMatchSkeleton,
+                            const UnicodeString& bestMatchIntervalPattern,
+                            int8_t differenceInfo,
+                            UnicodeString& adjustedIntervalPattern);
+
+    /**
+     * Concat a single date pattern with a time interval pattern,
+     * set it into the intervalPatterns, while field is time field.
+     * This is used to handle time interval patterns on skeleton with
+     * both time and date. Present the date followed by 
+     * the range expression for the time.
+     * @param format         date and time format
+     * @param formatLen      format string length
+     * @param datePattern    date pattern
+     * @param field          time calendar field: AM_PM, HOUR, MINUTE
+     * @param status         output param set to success/failure code on exit
+     * @internal ICU 4.0 
+     */
+    void concatSingleDate2TimeInterval(const UChar* format,
+                                       int32_t formatLen,
+                                       const UnicodeString& datePattern,
+                                       UCalendarDateFields field,
+                                       UErrorCode& status); 
+
+    /**
+     * check whether a calendar field present in a skeleton.
+     * @param field      calendar field need to check
+     * @param skeleton   given skeleton on which to check the calendar field
+     * @return           true if field present in a skeleton.
+     * @internal ICU 4.0 
+     */
+    static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field, 
+                                                 const UnicodeString& skeleton);
+
+
+    /**
+     * Split interval patterns into 2 part.
+     * @param intervalPattern  interval pattern
+     * @return the index in interval pattern which split the pattern into 2 part
+     * @internal ICU 4.0
+     */
+    static int32_t  U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
+
+
+    /**
+     * Break interval patterns as 2 part and save them into pattern info.
+     * @param field            calendar field
+     * @param intervalPattern  interval pattern
+     * @internal ICU 4.0
+     */
+    void setIntervalPattern(UCalendarDateFields field,
+                            const UnicodeString& intervalPattern);
+
+
+    /**
+     * Break interval patterns as 2 part and save them into pattern info.
+     * @param field            calendar field
+     * @param intervalPattern  interval pattern
+     * @param laterDateFirst   whether later date appear first in interval pattern
+     * @internal ICU 4.0
+     */
+    void setIntervalPattern(UCalendarDateFields field,
+                            const UnicodeString& intervalPattern,
+                            UBool laterDateFirst);
+
+
+    /**
+     * Set pattern information.
+     *
+     * @param field            calendar field
+     * @param firstPart        the first part in interval pattern
+     * @param secondPart       the second part in interval pattern
+     * @param laterDateFirst   whether the first date in intervalPattern
+     *                         is earlier date or later date
+     * @internal ICU 4.0
+     */
+    void setPatternInfo(UCalendarDateFields field,
+                        const UnicodeString* firstPart,
+                        const UnicodeString* secondpart,
+                        UBool laterDateFirst);
+
+
+    // from calendar field to pattern letter
+    static const UChar fgCalendarFieldToPatternLetter[];
+
+
+    /**
+     * The interval patterns for this locale.
+     */
+    DateIntervalInfo*     fInfo;
+
+    /**
+     * The DateFormat object used to format single pattern
+     */
+    SimpleDateFormat*     fDateFormat;
+
+    /**
+     * The 2 calendars with the from and to date.
+     * could re-use the calendar in fDateFormat,
+     * but keeping 2 calendars make it clear and clean.
+     */
+    Calendar* fFromCalendar;
+    Calendar* fToCalendar;
+
+    /**
+     * Following are interval information relavent (locale) to this formatter.
+     */
+    UnicodeString fSkeleton;
+    PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
+};
+ 
+
+
+ 
+
+
+inline UBool 
+DateIntervalFormat::operator!=(const Format& other) const  {
+    return !operator==(other); 
+}
+ 
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _DTITVFMT_H__
+//eof
diff --git a/CoreFoundation/icu/unicode/dtitvinf.h b/CoreFoundation/icu/unicode/dtitvinf.h
new file mode 100644
index 0000000..07a8dbd
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dtitvinf.h
@@ -0,0 +1,528 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 2008, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ *
+ * File DTITVINF.H
+ *
+ *******************************************************************************
+ */
+
+#ifndef __DTITVINF_H__
+#define __DTITVINF_H__
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Date/Time interval patterns for formatting date/time interval
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/udat.h"
+#include "unicode/locid.h"
+#include "unicode/ucal.h"
+#include "unicode/dtptngen.h"
+//#include "dtitv_impl.h"
+
+/**
+ * @internal ICU 4.0
+ */
+ 
+union UHashTok;
+
+
+U_NAMESPACE_BEGIN
+
+U_CDECL_BEGIN 
+
+/**
+ * @internal ICU 4.0
+ */
+static UBool U_CALLCONV hashTableValueComparator(UHashTok val1, UHashTok val2) ;
+
+U_CDECL_END 
+
+
+/**
+ * DateIntervalInfo is a public class for encapsulating localizable
+ * date time interval patterns. It is used by DateIntervalFormat.
+ *
+ * <P>
+ * For most users, ordinary use of DateIntervalFormat does not need to create
+ * DateIntervalInfo object directly.
+ * DateIntervalFormat will take care of it when creating a date interval
+ * formatter when user pass in skeleton and locale.
+ *
+ * <P>
+ * For power users, who want to create their own date interval patterns,
+ * or want to re-set date interval patterns, they could do so by
+ * directly creating DateIntervalInfo and manupulating it.
+ *
+ * <P>
+ * Logically, the interval patterns are mappings
+ * from (skeleton, the_largest_different_calendar_field)
+ * to (date_interval_pattern).
+ *
+ * <P>
+ * A skeleton 
+ * <ol>
+ * <li>
+ * only keeps the field pattern letter and ignores all other parts 
+ * in a pattern, such as space, punctuations, and string literals.
+ * <li>
+ * hides the order of fields. 
+ * <li>
+ * might hide a field's pattern letter length.
+ *
+ * For those non-digit calendar fields, the pattern letter length is 
+ * important, such as MMM, MMMM, and MMMMM; EEE and EEEE, 
+ * and the field's pattern letter length is honored.
+ *    
+ * For the digit calendar fields,  such as M or MM, d or dd, yy or yyyy, 
+ * the field pattern length is ignored and the best match, which is defined 
+ * in date time patterns, will be returned without honor the field pattern
+ * letter length in skeleton.
+ * </ol>
+ *
+ * <P>
+ * The calendar fields we support for interval formatting are:
+ * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.
+ * Those calendar fields can be defined in the following order:
+ * year >  month > date > am-pm > hour >  minute 
+ *  
+ * The largest different calendar fields between 2 calendars is the
+ * first different calendar field in above order.
+ *
+ * For example: the largest different calendar fields between "Jan 10, 2007" 
+ * and "Feb 20, 2008" is year.
+ *   
+ * <P>
+ * There is a set of pre-defined static skeleton strings.
+ * There are pre-defined interval patterns for those pre-defined skeletons
+ * in locales' resource files.
+ * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is  "yMMMd",
+ * in  en_US, if the largest different calendar field between date1 and date2 
+ * is "year", the date interval pattern  is "MMM d, yyyy - MMM d, yyyy", 
+ * such as "Jan 10, 2007 - Jan 10, 2008".
+ * If the largest different calendar field between date1 and date2 is "month",
+ * the date interval pattern is "MMM d - MMM d, yyyy",
+ * such as "Jan 10 - Feb 10, 2007".
+ * If the largest different calendar field between date1 and date2 is "day",
+ * the date interval pattern is ""MMM d-d, yyyy", such as "Jan 10-20, 2007".
+ *
+ * For date skeleton, the interval patterns when year, or month, or date is 
+ * different are defined in resource files.
+ * For time skeleton, the interval patterns when am/pm, or hour, or minute is
+ * different are defined in resource files.
+ *
+ *
+ * <P>
+ * There are 2 dates in interval pattern. For most locales, the first date
+ * in an interval pattern is the earlier date. There might be a locale in which
+ * the first date in an interval pattern is the later date.
+ * We use fallback format for the default order for the locale.
+ * For example, if the fallback format is "{0} - {1}", it means
+ * the first date in the interval pattern for this locale is earlier date.
+ * If the fallback format is "{1} - {0}", it means the first date is the 
+ * later date.
+ * For a particular interval pattern, the default order can be overriden
+ * by prefixing "latestFirst:" or "earliestFirst:" to the interval pattern.
+ * For example, if the fallback format is "{0}-{1}",
+ * but for skeleton "yMMMd", the interval pattern when day is different is 
+ * "latestFirst:d-d MMM yy", it means by default, the first date in interval
+ * pattern is the earlier date. But for skeleton "yMMMd", when day is different,
+ * the first date in "d-d MMM yy" is the later date.
+ * 
+ * <P>
+ * The recommended way to create a DateIntervalFormat object is to pass in 
+ * the locale. 
+ * By using a Locale parameter, the DateIntervalFormat object is 
+ * initialized with the pre-defined interval patterns for a given or 
+ * default locale.
+ * <P>
+ * Users can also create DateIntervalFormat object 
+ * by supplying their own interval patterns.
+ * It provides flexibility for power users.
+ *
+ * <P>
+ * After a DateIntervalInfo object is created, clients may modify
+ * the interval patterns using setIntervalPattern function as so desired.
+ * Currently, users can only set interval patterns when the following 
+ * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, 
+ * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE.
+ * Interval patterns when other calendar fields are different is not supported.
+ * <P>
+ * DateIntervalInfo objects are cloneable. 
+ * When clients obtain a DateIntervalInfo object, 
+ * they can feel free to modify it as necessary.
+ * <P>
+ * DateIntervalInfo are not expected to be subclassed. 
+ * Data for a calendar is loaded out of resource bundles. 
+ * To ICU 4.0, date interval patterns are only supported in Gregorian calendar. 
+ * @draft ICU 4.0
+**/
+
+class U_I18N_API DateIntervalInfo : public UObject {
+public:
+    /**
+     * Default constructor.
+     * It does not initialize any interval patterns except
+     * that it initialize default fall-back pattern as "{0} - {1}",
+     * which can be reset by setFallbackIntervalPattern().
+     * It should be followed by setFallbackIntervalPattern() and 
+     * setIntervalPattern(), 
+     * and is recommended to be used only for power users who
+     * wants to create their own interval patterns and use them to create
+     * date interval formatter.
+     * @param status   output param set to success/failure code on exit
+     * @internal ICU 4.0
+     */
+    DateIntervalInfo(UErrorCode& status);
+
+
+    /** 
+     * Construct DateIntervalInfo for the given locale,
+     * @param locale  the interval patterns are loaded from the Gregorian 
+     *                calendar data in this locale.
+     * @param status  output param set to success/failure code on exit
+     * @draft ICU 4.0
+     */
+    DateIntervalInfo(const Locale& locale, UErrorCode& status);
+
+
+    /**
+     * Copy constructor.
+     * @draft ICU 4.0
+     */
+    DateIntervalInfo(const DateIntervalInfo&);
+
+    /**
+     * Assignment operator
+     * @draft ICU 4.0
+     */
+    DateIntervalInfo& operator=(const DateIntervalInfo&);
+
+    /**
+     * Clone this object polymorphically.
+     * The caller owns the result and should delete it when done.
+     * @return   a copy of the object
+     * @draft    ICU4.0
+     */
+    virtual DateIntervalInfo* clone(void) const;
+
+    /**
+     * Destructor.
+     * It is virtual to be safe, but it is not designed to be subclassed.
+     * @draft ICU 4.0
+     */
+    virtual ~DateIntervalInfo();
+
+
+    /**
+     * Return true if another object is semantically equal to this one.
+     *
+     * @param other    the DateIntervalInfo object to be compared with.
+     * @return         true if other is semantically equal to this.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const DateIntervalInfo& other) const;
+
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the DateIntervalInfo object to be compared with.
+     * @return         true if other is semantically unequal to this.
+     * @stable ICU 4.0
+     */
+    UBool operator!=(const DateIntervalInfo& other) const;
+
+
+
+    /** 
+     * Provides a way for client to build interval patterns.
+     * User could construct DateIntervalInfo by providing a list of skeletons
+     * and their patterns.
+     * <P>
+     * For example:
+     * <pre>
+     * UErrorCode status = U_ZERO_ERROR;
+     * DateIntervalInfo dIntervalInfo = new DateIntervalInfo();
+     * dIntervalInfo->setFallbackIntervalPattern("{0} ~ {1}");
+     * dIntervalInfo->setIntervalPattern("yMd", UCAL_YEAR, "'from' yyyy-M-d 'to' yyyy-M-d", status); 
+     * dIntervalInfo->setIntervalPattern("yMMMd", UCAL_MONTH, "'from' yyyy MMM d 'to' MMM d", status);
+     * dIntervalInfo->setIntervalPattern("yMMMd", UCAL_DAY, "yyyy MMM d-d", status, status);
+     * </pre>
+     *
+     * Restriction: 
+     * Currently, users can only set interval patterns when the following 
+     * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, 
+     * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE.
+     * Interval patterns when other calendar fields are different are 
+     * not supported.
+     *
+     * @param skeleton         the skeleton on which interval pattern based
+     * @param lrgDiffCalUnit   the largest different calendar unit.
+     * @param intervalPattern  the interval pattern on the largest different
+     *                         calendar unit.
+     *                         For example, if lrgDiffCalUnit is 
+     *                         "year", the interval pattern for en_US when year
+     *                         is different could be "'from' yyyy 'to' yyyy".
+     * @param status           output param set to success/failure code on exit
+     * @draft ICU 4.0
+     */
+    void setIntervalPattern(const UnicodeString& skeleton, 
+                            UCalendarDateFields lrgDiffCalUnit, 
+                            const UnicodeString& intervalPattern,
+                            UErrorCode& status);
+
+    /**
+     * Get the interval pattern given skeleton and 
+     * the largest different calendar field.
+     * @param skeleton   the skeleton
+     * @param field      the largest different calendar field
+     * @param result     output param to receive the pattern
+     * @param status     output param set to success/failure code on exit
+     * @return a reference to 'result'
+     * @draft ICU 4.0 
+     */
+    UnicodeString& getIntervalPattern(const UnicodeString& skeleton,
+                                      UCalendarDateFields field,
+                                      UnicodeString& result,
+                                      UErrorCode& status) const; 
+
+    /**
+     * Get the fallback interval pattern.
+     * @param  result   output param to receive the pattern
+     * @return a reference to 'result'
+     * @draft ICU 4.0 
+     */
+    UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;
+
+
+    /**
+     * Re-set the fallback interval pattern.
+     *
+     * In construction, default fallback pattern is set as "{0} - {1}".
+     * And constructor taking locale as parameter will set the
+     * fallback pattern as what defined in the locale resource file.
+     *
+     * This method provides a way for user to replace the fallback pattern.
+     *
+     * @param fallbackPattern  fall-back interval pattern.
+     * @param status           output param set to success/failure code on exit
+     * @draft ICU 4.0 
+     */
+    void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,
+                                    UErrorCode& status);
+
+
+    /** Get default order -- whether the first date in pattern is later date
+                             or not.
+     * return default date ordering in interval pattern. TRUE if the first date
+     *        in pattern is later date, FALSE otherwise.
+     * @draft ICU 4.0 
+     */
+    UBool getDefaultOrder() const;
+
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+
+private:
+    /**
+     * DateIntervalFormat will need access to
+     * getBestSkeleton(), parseSkeleton(), enum IntervalPatternIndex,
+     * and calendarFieldToPatternIndex().
+     *
+     * Instead of making above public,
+     * make DateIntervalFormat a friend of DateIntervalInfo.
+     */
+    friend class DateIntervalFormat;
+
+    friend UBool U_CALLCONV hashTableValueComparator(UHashTok val1, UHashTok val2) ;
+
+    /**
+     * Following is for saving the interval patterns.
+     * We only support interval patterns on
+     * ERA, YEAR, MONTH, DAY, AM_PM, HOUR, and MINUTE
+     */
+    enum IntervalPatternIndex
+    {
+        kIPI_ERA,
+        kIPI_YEAR,
+        kIPI_MONTH,
+        kIPI_DATE,
+        kIPI_AM_PM,
+        kIPI_HOUR,
+        kIPI_MINUTE,
+        kIPI_MAX_INDEX
+    };
+
+    /** 
+     * Initialize the DateIntervalInfo from locale
+     * @param locale   the given locale.
+     * @param status   output param set to success/failure code on exit
+     * @internal ICU 4.0 
+     */
+    void initializeData(const Locale& locale, UErrorCode& status);
+
+
+    /* Set Interval pattern.
+     *
+     * It sets interval pattern into the hash map.
+     *
+     * @param skeleton         skeleton on which the interval pattern based
+     * @param lrgDiffCalUnit   the largest different calendar unit.
+     * @param intervalPattern  the interval pattern on the largest different
+     *                         calendar unit.
+     * @param status           output param set to success/failure code on exit
+     * @internal ICU 4.0
+     */
+    void setIntervalPatternInternally(const UnicodeString& skeleton,
+                                      UCalendarDateFields lrgDiffCalUnit,
+                                      const UnicodeString& intervalPattern,
+                                      UErrorCode& status); 
+
+
+    /**given an input skeleton, get the best match skeleton 
+     * which has pre-defined interval pattern in resource file.
+     * Also return the difference between the input skeleton
+     * and the best match skeleton.
+     *
+     * TODO (xji): set field weight or
+     *             isolate the funtionality in DateTimePatternGenerator
+     * @param  skeleton               input skeleton
+     * @param  bestMatchDistanceInfo  the difference between input skeleton
+     *                                and best match skeleton.
+     *         0, if there is exact match for input skeleton
+     *         1, if there is only field width difference between 
+     *            the best match and the input skeleton
+     *         2, the only field difference is 'v' and 'z'
+     *        -1, if there is calendar field difference between
+     *            the best match and the input skeleton
+     * @return                        best match skeleton
+     * @internal ICU 4.0
+     */
+    const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,
+                                         int8_t& bestMatchDistanceInfo) const;
+
+
+    /**
+     * Parse skeleton, save each field's width.
+     * It is used for looking for best match skeleton,
+     * and adjust pattern field width.
+     * @param skeleton            skeleton to be parsed
+     * @param skeletonFieldWidth  parsed skeleton field width
+     * @internal ICU 4.0
+     */
+    static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton, 
+                                        int32_t* skeletonFieldWidth);
+
+
+    /**
+     * Check whether one field width is numeric while the other is string.
+     *
+     * TODO (xji): make it general
+     *
+     * @param fieldWidth          one field width
+     * @param anotherFieldWidth   another field width
+     * @param patternLetter       pattern letter char
+     * @return true if one field width is numeric and the other is string,
+     *         false otherwise.
+     * @internal ICU 4.0
+     */
+    static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,
+                                         int32_t anotherFieldWidth,
+                                         char patternLetter);
+
+
+    /** 
+     * Convert calendar field to the interval pattern index in 
+     * hash table.
+     *
+     * Since we only support the following calendar fields: 
+     * ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, DAY_OF_WEEK, 
+     * AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE,
+     * We reserve only 4 interval patterns for a skeleton.
+     *
+     * @param field    calendar field
+     * @param status   output param set to success/failure code on exit
+     * @return  interval pattern index in hash table
+     * @internal ICU 4.0
+     */
+    static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(
+                                                      UCalendarDateFields field,
+                                                      UErrorCode& status);
+
+
+    /**
+     * delete hash table (of type fIntervalPatterns).
+     *
+     * @param hTable  hash table to be deleted
+     * @internal ICU 4.0
+     */
+    void deleteHash(Hashtable* hTable);
+
+
+    /**
+     * initialize hash table (of type fIntervalPatterns).
+     *
+     * @param status   output param set to success/failure code on exit
+     * @return         hash table initialized
+     * @internal ICU 4.0
+     */
+    Hashtable* initHash(UErrorCode& status);
+
+
+
+    /**
+     * copy hash table (of type fIntervalPatterns).
+     *
+     * @param source   the source to copy from
+     * @param target   the target to copy to
+     * @param status   output param set to success/failure code on exit
+     * @internal ICU 4.0
+     */
+    void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
+
+
+    // data members
+    // fallback interval pattern 
+    UnicodeString fFallbackIntervalPattern;
+    // default order
+    UBool fFirstDateInPtnIsLaterDate;
+
+    // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>
+    // HashMap( skeleton, pattern[largest_different_field] )
+    Hashtable* fIntervalPatterns;
+
+};// end class DateIntervalInfo
+
+
+inline UBool
+DateIntervalInfo::operator!=(const DateIntervalInfo& other) const {
+    return !operator==(other);
+}
+
+
+U_NAMESPACE_END
+
+#endif
+
+#endif
+
diff --git a/CoreFoundation/icu/unicode/dtptngen.h b/CoreFoundation/icu/unicode/dtptngen.h
new file mode 100644
index 0000000..3055deb
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dtptngen.h
@@ -0,0 +1,422 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*
+* File DTPTNGEN.H
+*
+*******************************************************************************
+*/
+
+#ifndef __DTPTNGEN_H__
+#define __DTPTNGEN_H__
+
+#include "unicode/datefmt.h"
+#include "unicode/locid.h"
+#include "unicode/udat.h"
+#include "unicode/udatpg.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * \file
+ * \brief C++ API: Date/Time Pattern Generator
+ */
+
+
+class Hashtable;
+class FormatParser;
+class DateTimeMatcher;
+class DistanceInfo;
+class PatternMap;
+
+/**
+ * This class provides flexible generation of date format patterns, like "yy-MM-dd". 
+ * The user can build up the generator by adding successive patterns. Once that 
+ * is done, a query can be made using a "skeleton", which is a pattern which just
+ * includes the desired fields and lengths. The generator will return the "best fit" 
+ * pattern corresponding to that skeleton.
+ * <p>The main method people will use is getBestPattern(String skeleton),
+ * since normally this class is pre-built with data from a particular locale. 
+ * However, generators can be built directly from other data as well.
+ * <p><i>Issue: may be useful to also have a function that returns the list of 
+ * fields in a pattern, in order, since we have that internally.
+ * That would be useful for getting the UI order of field elements.</i>
+ * @stable ICU 4.0
+**/
+class U_I18N_API DateTimePatternGenerator : public UObject {
+public:
+    /**
+     * Construct a flexible generator according to default locale.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @stable ICU 4.0
+     */
+    static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status);
+
+    /**
+     * Construct a flexible generator according to data for a given locale.
+     * @param uLocale
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @stable ICU 4.0
+     */
+    static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);
+
+    /**
+     * Create an empty generator, to be constructed with addPattern(...) etc.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @stable ICU 4.0
+     */
+     static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status);
+     
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~DateTimePatternGenerator();
+
+    /**
+     * Clone DateTimePatternGenerator object. Clients are responsible for 
+     * deleting the DateTimePatternGenerator object cloned.
+     * @stable ICU 4.0
+     */
+    DateTimePatternGenerator* clone() const;
+
+     /**
+      * Return true if another object is semantically equal to this one.
+      *
+      * @param other    the DateTimePatternGenerator object to be compared with.
+      * @return         true if other is semantically equal to this.
+      * @stable ICU 4.0
+      */
+    UBool operator==(const DateTimePatternGenerator& other) const;
+    
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the DateTimePatternGenerator object to be compared with.
+     * @return         true if other is semantically unequal to this.
+     * @stable ICU 4.0
+     */
+    UBool operator!=(const DateTimePatternGenerator& other) const;
+
+    /**
+     * Utility to return a unique skeleton from a given pattern. For example,
+     * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd".
+     *
+     * @param pattern   Input pattern, such as "dd/MMM"
+     * @param status  Output param set to success/failure code on exit,
+     *                  which must not indicate a failure before the function call.
+     * @return skeleton such as "MMMdd"
+     * @stable ICU 4.0
+     */
+    UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status);
+
+    /**
+     * Utility to return a unique base skeleton from a given pattern. This is
+     * the same as the skeleton, except that differences in length are minimized
+     * so as to only preserve the difference between string and numeric form. So
+     * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd"
+     * (notice the single d).
+     *
+     * @param pattern  Input pattern, such as "dd/MMM"
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return base skeleton, such as "Md"
+     * @stable ICU 4.0
+     */
+    UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);
+
+    /**
+     * Adds a pattern to the generator. If the pattern has the same skeleton as
+     * an existing pattern, and the override parameter is set, then the previous
+     * value is overriden. Otherwise, the previous value is retained. In either
+     * case, the conflicting status is set and previous vale is stored in 
+     * conflicting pattern.
+     * <p>
+     * Note that single-field patterns (like "MMM") are automatically added, and
+     * don't need to be added explicitly!
+     *
+     * @param pattern   Input pattern, such as "dd/MMM"
+     * @param override  When existing values are to be overridden use true, 
+     *                   otherwise use false.
+     * @param conflictingPattern  Previous pattern with the same skeleton.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return conflicting status.  The value could be UDATPG_NO_CONFLICT, 
+     *                             UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
+     * @stable ICU 4.0
+     */
+    UDateTimePatternConflict addPattern(const UnicodeString& pattern, 
+                                        UBool override, 
+                                        UnicodeString& conflictingPattern,
+                                        UErrorCode& status);
+
+    /**
+     * An AppendItem format is a pattern used to append a field if there is no
+     * good match. For example, suppose that the input skeleton is "GyyyyMMMd",
+     * and there is no matching pattern internally, but there is a pattern
+     * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the
+     * G. The way these two are conjoined is by using the AppendItemFormat for G
+     * (era). So if that value is, say "{0}, {1}" then the final resulting
+     * pattern is "d-MM-yyyy, G".
+     * <p>
+     * There are actually three available variables: {0} is the pattern so far,
+     * {1} is the element we are adding, and {2} is the name of the element.
+     * <p>
+     * This reflects the way that the CLDR data is organized.
+     *
+     * @param field  such as UDATPG_ERA_FIELD.
+     * @param value  pattern, such as "{0}, {1}"
+     * @stable ICU 4.0
+     */
+    void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);
+
+    /**
+     * Getter corresponding to setAppendItemFormat. Values below 0 or at or
+     * above UDATPG_FIELD_COUNT are illegal arguments.
+     *
+     * @param  field  such as UDATPG_ERA_FIELD.
+     * @return append pattern for field
+     * @stable ICU 4.0
+     */
+    const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;
+
+    /**
+     * Sets the names of field, eg "era" in English for ERA. These are only
+     * used if the corresponding AppendItemFormat is used, and if it contains a
+     * {2} variable.
+     * <p>
+     * This reflects the way that the CLDR data is organized.
+     *
+     * @param field   such as UDATPG_ERA_FIELD.
+     * @param value   name of the field
+     * @stable ICU 4.0
+     */
+    void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);
+
+    /**
+     * Getter corresponding to setAppendItemNames. Values below 0 or at or above
+     * UDATPG_FIELD_COUNT are illegal arguments.
+     *
+     * @param field  such as UDATPG_ERA_FIELD.
+     * @return name for field
+     * @stable ICU 4.0
+     */
+    const UnicodeString& getAppendItemName(UDateTimePatternField field) const;
+
+    /**
+     * The date time format is a message format pattern used to compose date and
+     * time patterns. The default value is "{0} {1}", where {0} will be replaced
+     * by the date pattern and {1} will be replaced by the time pattern.
+     * <p>
+     * This is used when the input skeleton contains both date and time fields,
+     * but there is not a close match among the added patterns. For example,
+     * suppose that this object was created by adding "dd-MMM" and "hh:mm", and
+     * its datetimeFormat is the default "{0} {1}". Then if the input skeleton
+     * is "MMMdhmm", there is not an exact match, so the input skeleton is
+     * broken up into two components "MMMd" and "hmm". There are close matches
+     * for those two skeletons, so the result is put together with this pattern,
+     * resulting in "d-MMM h:mm".
+     *
+     * @param dateTimeFormat
+     *            message format pattern, here {0} will be replaced by the date
+     *            pattern and {1} will be replaced by the time pattern.
+     * @stable ICU 4.0
+     */
+    void setDateTimeFormat(const UnicodeString& dateTimeFormat);
+
+    /**
+     * Getter corresponding to setDateTimeFormat.
+     * @return DateTimeFormat.
+     * @stable ICU 4.0
+     */
+    const UnicodeString& getDateTimeFormat() const;
+
+    /**
+     * Return the best pattern matching the input skeleton. It is guaranteed to
+     * have all of the fields in the skeleton.
+     *
+     * @param skeleton
+     *            The skeleton is a pattern containing only the variable fields.
+     *            For example, "MMMdd" and "mmhh" are skeletons.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return bestPattern
+     *            The best pattern found from the given skeleton.
+     * @stable ICU 4.0
+     */
+     UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
+
+
+    /**
+     * Adjusts the field types (width and subtype) of a pattern to match what is
+     * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
+     * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
+     * "dd-MMMM hh:mm". This is used internally to get the best match for the
+     * input skeleton, but can also be used externally.
+     *
+     * @param pattern Input pattern
+     * @param skeleton
+     *            The skeleton is a pattern containing only the variable fields.
+     *            For example, "MMMdd" and "mmhh" are skeletons.
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return pattern adjusted to match the skeleton fields widths and subtypes.
+     * @stable ICU 4.0
+     */
+     UnicodeString replaceFieldTypes(const UnicodeString& pattern, 
+                                     const UnicodeString& skeleton, 
+                                     UErrorCode& status);
+
+    /**
+     * Return a list of all the skeletons (in canonical form) from this class.
+     *
+     * Call getPatternForSkeleton() to get the corresponding pattern.
+     *
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return StringEnumeration with the skeletons.
+     *         The caller must delete the object.
+     * @stable ICU 4.0
+     */
+     StringEnumeration* getSkeletons(UErrorCode& status) const;
+
+     /**
+      * Get the pattern corresponding to a given skeleton.
+      * @param skeleton 
+      * @return pattern corresponding to a given skeleton.
+      * @stable ICU 4.0
+      */
+     const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;
+     
+    /**
+     * Return a list of all the base skeletons (in canonical form) from this class.
+     *
+     * @param status  Output param set to success/failure code on exit,
+     *               which must not indicate a failure before the function call.
+     * @return a StringEnumeration with the base skeletons.
+     *         The caller must delete the object.
+     * @stable ICU 4.0
+     */
+     StringEnumeration* getBaseSkeletons(UErrorCode& status) const;
+     
+     /**
+      * Return a list of redundant patterns are those which if removed, make no 
+      * difference in the resulting getBestPattern values. This method returns a 
+      * list of them, to help check the consistency of the patterns used to build 
+      * this generator.
+      * 
+      * @param status  Output param set to success/failure code on exit,
+      *               which must not indicate a failure before the function call.
+      * @return a StringEnumeration with the redundant pattern.
+      *         The caller must delete the object.
+      * @internal ICU 3.8
+      */
+     StringEnumeration* getRedundants(UErrorCode& status);
+      
+    /**
+     * The decimal value is used in formatting fractions of seconds. If the
+     * skeleton contains fractional seconds, then this is used with the
+     * fractional seconds. For example, suppose that the input pattern is
+     * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and
+     * the decimal string is ",". Then the resulting pattern is modified to be
+     * "H:mm:ss,SSSS"
+     *
+     * @param decimal 
+     * @stable ICU 4.0
+     */
+    void setDecimal(const UnicodeString& decimal);
+
+    /**
+     * Getter corresponding to setDecimal.
+     * @return UnicodeString corresponding to the decimal point
+     * @stable ICU 4.0
+     */
+    const UnicodeString& getDecimal() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+private:
+    /**
+     * Constructor.
+     * @stable ICU 4.0
+     */
+    DateTimePatternGenerator(UErrorCode & status);
+
+    /**
+     * Constructor.
+     * @stable ICU 4.0
+     */
+    DateTimePatternGenerator(const Locale& locale, UErrorCode & status);
+
+    /**
+     * Copy constructor.
+     * @param other DateTimePatternGenerator to copy
+     * @stable ICU 4.0
+     */
+    DateTimePatternGenerator(const DateTimePatternGenerator& other);
+
+    /**
+     * Default assignment operator.
+     * @param other DateTimePatternGenerator to copy
+     * @stable ICU 4.0
+     */
+    DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);
+
+    Locale pLocale;  // pattern locale
+    FormatParser *fp;
+    DateTimeMatcher* dtMatcher;
+    DistanceInfo *distanceInfo;
+    PatternMap *patternMap;
+    UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];
+    UnicodeString appendItemNames[UDATPG_FIELD_COUNT];
+    UnicodeString dateTimeFormat;
+    UnicodeString decimal;
+    DateTimeMatcher *skipMatcher;
+    Hashtable *fAvailableFormatKeyHash;
+    UnicodeString hackPattern;
+    UnicodeString emptyString;
+    UBool chineseMonthHack;
+
+    void initData(const Locale &locale, UErrorCode &status);
+    void addCanonicalItems();
+    void addICUPatterns(const Locale& locale, UErrorCode& status);
+    void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);
+    void addCLDRData(const Locale& locale);
+    void initHashtable(UErrorCode& status);
+    void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);
+    void setDecimalSymbols(const Locale& locale, UErrorCode& status);
+    UnicodeString getCJKPattern(const UnicodeString& patternForm);
+    UDateTimePatternField getAppendFormatNumber(const char* field) const;
+    UDateTimePatternField getAppendNameNumber(const char* field) const;
+    void getAppendName(UDateTimePatternField field, UnicodeString& value);
+    int32_t getCanonicalIndex(const UnicodeString& field);
+    const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields);
+    UnicodeString adjustFieldTypes(const UnicodeString& pattern, UBool fixFractionalSeconds);
+    UnicodeString getBestAppending(int32_t missingFields);
+    int32_t getTopBitNumber(int32_t foundMask);
+    void setAvailableFormat(const UnicodeString &key, UErrorCode& status);
+    UBool isAvailableFormatSet(const UnicodeString &key) const;
+    void copyHashtable(Hashtable *other, UErrorCode &status);
+    UBool isCanonicalItem(const UnicodeString& item) const;
+} ;// end class DateTimePatternGenerator
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/dtrule.h b/CoreFoundation/icu/unicode/dtrule.h
new file mode 100644
index 0000000..c46e618
--- /dev/null
+++ b/CoreFoundation/icu/unicode/dtrule.h
@@ -0,0 +1,250 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and         *
+* others. All Rights Reserved.                                                *
+*******************************************************************************
+*/
+#ifndef DTRULE_H
+#define DTRULE_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Rule for specifying date and time in an year
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+/**
+ * <code>DateTimeRule</code> is a class representing a time in a year by
+ * a rule specified by month, day of month, day of week and
+ * time in the day.
+ * 
+ * @stable ICU 4.0
+ */
+class U_I18N_API DateTimeRule : public UObject {
+public:
+
+    /**
+     * Date rule type constants.
+     * @stable ICU 4.0
+     */
+    enum DateRuleType {
+        DOM = 0,        /**< The exact day of month,
+                             for example, March 11. */
+        DOW,            /**< The Nth occurence of the day of week,
+                             for example, 2nd Sunday in March. */
+        DOW_GEQ_DOM,    /**< The first occurence of the day of week on or after the day of monnth,
+                             for example, first Sunday on or after March 8. */
+        DOW_LEQ_DOM     /**< The last occurence of the day of week on or before the day of month,
+                             for example, first Sunday on or before March 14. */
+    };
+
+    /**
+     * Time rule type constants.
+     * @stable ICU 4.0
+     */
+    enum TimeRuleType {
+        WALL_TIME = 0,  /**< The local wall clock time */
+        STANDARD_TIME,  /**< The local standard time */
+        UTC_TIME        /**< The UTC time */
+    };
+
+    /**
+     * Constructs a <code>DateTimeRule</code> by the day of month and
+     * the time rule.  The date rule type for an instance created by
+     * this constructor is <code>DOM</code>.
+     * 
+     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
+     * @param dayOfMonth    The day of month, 1-based.
+     * @param millisInDay   The milliseconds in the rule date.
+     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *                      or <code>UTC_TIME</code>.
+     * @stable ICU 4.0
+     */
+    DateTimeRule(int32_t month, int32_t dayOfMonth,
+        int32_t millisInDay, TimeRuleType timeType);
+
+    /**
+     * Constructs a <code>DateTimeRule</code> by the day of week and its oridinal
+     * number and the time rule.  The date rule type for an instance created
+     * by this constructor is <code>DOW</code>.
+     * 
+     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>.
+     * @param weekInMonth   The ordinal number of the day of week.  Negative number
+     *                      may be used for specifying a rule date counted from the
+     *                      end of the rule month.
+     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
+     * @param millisInDay   The milliseconds in the rule date.
+     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *                      or <code>UTC_TIME</code>.
+     * @stable ICU 4.0
+     */
+    DateTimeRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
+        int32_t millisInDay, TimeRuleType timeType);
+
+    /**
+     * Constructs a <code>DateTimeRule</code> by the first/last day of week
+     * on or after/before the day of month and the time rule.  The date rule
+     * type for an instance created by this constructor is either
+     * <code>DOM_GEQ_DOM</code> or <code>DOM_LEQ_DOM</code>.
+     * 
+     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
+     * @param dayOfMonth    The day of month, 1-based.
+     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
+     * @param after         true if the rule date is on or after the day of month.
+     * @param millisInDay   The milliseconds in the rule date.
+     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *                      or <code>UTC_TIME</code>.
+     * @stable ICU 4.0
+     */
+    DateTimeRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, UBool after,
+        int32_t millisInDay, TimeRuleType timeType);
+
+    /**
+     * Copy constructor.
+     * @param source    The DateTimeRule object to be copied.
+     * @stable ICU 4.0
+     */
+    DateTimeRule(const DateTimeRule& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    ~DateTimeRule();
+
+    /**
+     * Clone this DateTimeRule object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @stable ICU 4.0
+     */
+    DateTimeRule* clone(void) const;
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    DateTimeRule& operator=(const DateTimeRule& right);
+
+    /**
+     * Return true if the given DateTimeRule objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given DateTimeRule objects are semantically equal.
+     * @stable ICU 4.0
+     */
+    UBool operator==(const DateTimeRule& that) const;
+
+    /**
+     * Return true if the given DateTimeRule objects are semantically unequal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given DateTimeRule objects are semantically unequal.
+     * @stable ICU 4.0
+     */
+    UBool operator!=(const DateTimeRule& that) const;
+
+    /**
+     * Gets the date rule type, such as <code>DOM</code>
+     * @return The date rule type.
+     * @stable ICU 4.0
+     */
+    DateRuleType getDateRuleType(void) const;
+
+    /**
+     * Gets the time rule type
+     * @return The time rule type, either <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
+     *         or <code>UTC_TIME</code>.
+     * @stable ICU 4.0
+     */
+    TimeRuleType getTimeRuleType(void) const;
+
+    /**
+     * Gets the rule month.
+     * @return The rule month.
+     * @stable ICU 4.0
+     */
+    int32_t getRuleMonth(void) const;
+
+    /**
+     * Gets the rule day of month.  When the date rule type
+     * is <code>DOW</code>, the value is always 0.
+     * @return The rule day of month
+     * @stable ICU 4.0
+     */
+    int32_t getRuleDayOfMonth(void) const;
+
+    /**
+     * Gets the rule day of week.  When the date rule type
+     * is <code>DOM</code>, the value is always 0.
+     * @return The rule day of week.
+     * @stable ICU 4.0
+     */
+    int32_t getRuleDayOfWeek(void) const;
+
+    /**
+     * Gets the ordinal number of the occurence of the day of week
+     * in the month.  When the date rule type is not <code>DOW</code>,
+     * the value is always 0.
+     * @return The rule day of week ordinal number in the month.
+     * @stable ICU 4.0
+     */
+    int32_t getRuleWeekInMonth(void) const;
+
+    /**
+     * Gets the rule time in the rule day.
+     * @return The time in the rule day in milliseconds.
+     * @stable ICU 4.0
+     */
+    int32_t getRuleMillisInDay(void) const;
+
+private:
+    int32_t fMonth;
+    int32_t fDayOfMonth;
+    int32_t fDayOfWeek;
+    int32_t fWeekInMonth;
+    int32_t fMillisInDay;
+    DateRuleType fDateRuleType;
+    TimeRuleType fTimeRuleType;
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // DTRULE_H
+//eof
diff --git a/CoreFoundation/icu/unicode/fieldpos.h b/CoreFoundation/icu/unicode/fieldpos.h
new file mode 100644
index 0000000..38a9576
--- /dev/null
+++ b/CoreFoundation/icu/unicode/fieldpos.h
@@ -0,0 +1,291 @@
+/*
+ ********************************************************************************
+ *   Copyright (C) 1997-2006, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ ********************************************************************************
+ *
+ * File FIELDPOS.H
+ *
+ * Modification History:
+ *
+ *   Date        Name        Description
+ *   02/25/97    aliu        Converted from java.
+ *   03/17/97    clhuang     Updated per Format implementation.
+ *    07/17/98    stephen        Added default/copy ctors, and operators =, ==, !=
+ ********************************************************************************
+ */
+
+// *****************************************************************************
+// This file was generated from the java source file FieldPosition.java
+// *****************************************************************************
+ 
+#ifndef FIELDPOS_H
+#define FIELDPOS_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: FieldPosition identifies the fields in a formatted output.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * <code>FieldPosition</code> is a simple class used by <code>Format</code>
+ * and its subclasses to identify fields in formatted output. Fields are
+ * identified by constants, whose names typically end with <code>_FIELD</code>,
+ * defined in the various subclasses of <code>Format</code>. See
+ * <code>ERA_FIELD</code> and its friends in <code>DateFormat</code> for
+ * an example.
+ *
+ * <p>
+ * <code>FieldPosition</code> keeps track of the position of the
+ * field within the formatted output with two indices: the index
+ * of the first character of the field and the index of the last
+ * character of the field.
+ *
+ * <p>
+ * One version of the <code>format</code> method in the various
+ * <code>Format</code> classes requires a <code>FieldPosition</code>
+ * object as an argument. You use this <code>format</code> method
+ * to perform partial formatting or to get information about the
+ * formatted output (such as the position of a field).
+ *
+ * The FieldPosition class is not suitable for subclassing.
+ *
+ * <p>
+ * Below is an example of using <code>FieldPosition</code> to aid
+ * alignment of an array of formatted floating-point numbers on
+ * their decimal points:
+ * <pre>
+ * \code
+ *       double doubleNum[] = {123456789.0, -12345678.9, 1234567.89, -123456.789,
+ *                  12345.6789, -1234.56789, 123.456789, -12.3456789, 1.23456789};
+ *       int dNumSize = (int)(sizeof(doubleNum)/sizeof(double));
+ *       
+ *       UErrorCode status = U_ZERO_ERROR;
+ *       DecimalFormat* fmt = (DecimalFormat*) NumberFormat::createInstance(status);
+ *       fmt->setDecimalSeparatorAlwaysShown(true);
+ *       
+ *       const int tempLen = 20;
+ *       char temp[tempLen];
+ *       
+ *       for (int i=0; i<dNumSize; i++) {
+ *           FieldPosition pos(NumberFormat::INTEGER_FIELD);
+ *           UnicodeString buf;
+ *           char fmtText[tempLen];
+ *           ToCharString(fmt->format(doubleNum[i], buf, pos), fmtText);
+ *           for (int j=0; j<tempLen; j++) temp[j] = ' '; // clear with spaces
+ *           temp[__min(tempLen, tempLen-pos.getEndIndex())] = '\0';
+ *           cout << temp << fmtText   << endl;
+ *       }
+ *       delete fmt;
+ * \endcode
+ * </pre>
+ * <p>
+ * The code will generate the following output:
+ * <pre>
+ * \code
+ *           123,456,789.000
+ *           -12,345,678.900
+ *             1,234,567.880
+ *              -123,456.789
+ *                12,345.678
+ *                -1,234.567
+ *                   123.456
+ *                   -12.345
+ *                     1.234
+ *  \endcode
+ * </pre>
+ */
+class U_I18N_API FieldPosition : public UObject {
+public:
+    /**
+     * DONT_CARE may be specified as the field to indicate that the
+     * caller doesn't need to specify a field.  Do not subclass.
+     */
+    enum { DONT_CARE = -1 };
+
+    /**
+     * Creates a FieldPosition object with a non-specified field.
+     * @stable ICU 2.0
+     */
+    FieldPosition() 
+        : UObject(), fField(DONT_CARE), fBeginIndex(0), fEndIndex(0) {}
+
+    /**
+     * Creates a FieldPosition object for the given field.  Fields are
+     * identified by constants, whose names typically end with _FIELD,
+     * in the various subclasses of Format.
+     *
+     * @see NumberFormat#INTEGER_FIELD
+     * @see NumberFormat#FRACTION_FIELD
+     * @see DateFormat#YEAR_FIELD
+     * @see DateFormat#MONTH_FIELD
+     * @stable ICU 2.0
+     */
+    FieldPosition(int32_t field) 
+        : UObject(), fField(field), fBeginIndex(0), fEndIndex(0) {}
+
+    /**
+     * Copy constructor
+     * @param copy the object to be copied from.
+     * @stable ICU 2.0
+     */
+    FieldPosition(const FieldPosition& copy) 
+        : UObject(copy), fField(copy.fField), fBeginIndex(copy.fBeginIndex), fEndIndex(copy.fEndIndex) {}
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~FieldPosition();
+
+    /**
+     * Assignment operator
+     * @param copy the object to be copied from.
+     * @stable ICU 2.0
+     */
+    FieldPosition&      operator=(const FieldPosition& copy);
+
+    /** 
+     * Equality operator.
+     * @param that    the object to be compared with.
+     * @return        TRUE if the two field positions are equal, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool              operator==(const FieldPosition& that) const;
+
+    /** 
+     * Equality operator.
+     * @param that    the object to be compared with.
+     * @return        TRUE if the two field positions are not equal, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool              operator!=(const FieldPosition& that) const;
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    FieldPosition *clone() const;
+
+    /**
+     * Retrieve the field identifier.
+     * @return    the field identifier.
+     * @stable ICU 2.0
+     */
+    int32_t getField(void) const { return fField; }
+
+    /**
+     * Retrieve the index of the first character in the requested field.
+     * @return    the index of the first character in the requested field.
+     * @stable ICU 2.0
+     */
+    int32_t getBeginIndex(void) const { return fBeginIndex; }
+
+    /**
+     * Retrieve the index of the character following the last character in the
+     * requested field.
+     * @return    the index of the character following the last character in the
+     *            requested field.
+     * @stable ICU 2.0
+     */
+    int32_t getEndIndex(void) const { return fEndIndex; }
+ 
+    /**
+     * Set the field.
+     * @param f    the new value of the field.
+     * @stable ICU 2.0
+     */
+    void setField(int32_t f) { fField = f; }
+
+    /**
+     * Set the begin index.  For use by subclasses of Format.
+     * @param bi    the new value of the begin index
+     * @stable ICU 2.0
+     */
+    void setBeginIndex(int32_t bi) { fBeginIndex = bi; }
+
+    /**
+     * Set the end index.  For use by subclasses of Format.
+     * @param ei    the new value of the end index
+     * @stable ICU 2.0
+     */
+    void setEndIndex(int32_t ei) { fEndIndex = ei; }
+    
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    /**
+     * Input: Desired field to determine start and end offsets for.
+     * The meaning depends on the subclass of Format.
+     */
+    int32_t fField;
+
+    /**
+     * Output: Start offset of field in text.
+     * If the field does not occur in the text, 0 is returned.
+     */
+    int32_t fBeginIndex;
+
+    /**
+     * Output: End offset of field in text.
+     * If the field does not occur in the text, 0 is returned.
+     */
+    int32_t fEndIndex;
+};
+
+inline FieldPosition&
+FieldPosition::operator=(const FieldPosition& copy)
+{
+    fField         = copy.fField;
+    fEndIndex     = copy.fEndIndex;
+    fBeginIndex = copy.fBeginIndex;
+    return *this;
+}
+
+inline UBool
+FieldPosition::operator==(const FieldPosition& copy) const
+{
+    return (fField == copy.fField &&
+        fEndIndex == copy.fEndIndex &&
+        fBeginIndex == copy.fBeginIndex);
+}
+
+inline UBool
+FieldPosition::operator!=(const FieldPosition& copy) const
+{
+    return !operator==(copy);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _FIELDPOS
+//eof
diff --git a/CoreFoundation/icu/unicode/fmtable.h b/CoreFoundation/icu/unicode/fmtable.h
new file mode 100644
index 0000000..94ee328
--- /dev/null
+++ b/CoreFoundation/icu/unicode/fmtable.h
@@ -0,0 +1,591 @@
+/*
+********************************************************************************
+*   Copyright (C) 1997-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+********************************************************************************
+*
+* File FMTABLE.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/29/97    aliu        Creation.
+********************************************************************************
+*/
+#ifndef FMTABLE_H
+#define FMTABLE_H
+
+#include "unicode/utypes.h"
+#include "unicode/unistr.h"
+/**
+ * \file 
+ * \brief C++ API: Formattable is a thin wrapper for primitive numeric types.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Formattable objects can be passed to the Format class or
+ * its subclasses for formatting.  Formattable is a thin wrapper
+ * class which interconverts between the primitive numeric types
+ * (double, long, etc.) as well as UDate and UnicodeString.
+ *
+ * <p>Internally, a Formattable object is a union of primitive types.
+ * As such, it can only store one flavor of data at a time.  To
+ * determine what flavor of data it contains, use the getType method.
+ *
+ * <p>As of ICU 3.0, Formattable may also wrap a UObject pointer,
+ * which it owns.  This allows an instance of any ICU class to be
+ * encapsulated in a Formattable.  For legacy reasons and for
+ * efficiency, primitive numeric types are still stored directly
+ * within a Formattable.
+ *
+ * <p>The Formattable class is not suitable for subclassing.
+ */
+class U_I18N_API Formattable : public UObject {
+public:
+    /**
+     * This enum is only used to let callers distinguish between
+     * the Formattable(UDate) constructor and the Formattable(double)
+     * constructor; the compiler cannot distinguish the signatures,
+     * since UDate is currently typedefed to be either double or long.
+     * If UDate is changed later to be a bonafide class
+     * or struct, then we no longer need this enum.
+     * @stable ICU 2.4
+     */
+    enum ISDATE { kIsDate };
+
+    /**
+     * Default constructor
+     * @stable ICU 2.4
+     */
+    Formattable(); // Type kLong, value 0
+
+    /**
+     * Creates a Formattable object with a UDate instance.
+     * @param d the UDate instance.
+     * @param flag the flag to indicate this is a date. Always set it to kIsDate
+     * @stable ICU 2.0  
+     */
+    Formattable(UDate d, ISDATE flag);
+
+    /**
+     * Creates a Formattable object with a double number.
+     * @param d the double number.
+     * @stable ICU 2.0
+     */
+    Formattable(double d);
+
+    /**
+     * Creates a Formattable object with a long number.
+     * @param l the long number.
+     * @stable ICU 2.0
+     */
+    Formattable(int32_t l);
+
+    /**
+     * Creates a Formattable object with an int64_t number
+     * @param ll the int64_t number.
+     * @stable ICU 2.8
+     */
+    Formattable(int64_t ll);
+
+#if !UCONFIG_NO_CONVERSION
+    /**
+     * Creates a Formattable object with a char string pointer.
+     * Assumes that the char string is null terminated.
+     * @param strToCopy the char string.
+     * @stable ICU 2.0
+     */
+    Formattable(const char* strToCopy);
+#endif
+
+    /**
+     * Creates a Formattable object with a UnicodeString object to copy from.
+     * @param strToCopy the UnicodeString string.
+     * @stable ICU 2.0
+     */
+    Formattable(const UnicodeString& strToCopy);
+
+    /**
+     * Creates a Formattable object with a UnicodeString object to adopt from.
+     * @param strToAdopt the UnicodeString string.
+     * @stable ICU 2.0
+     */
+    Formattable(UnicodeString* strToAdopt);
+
+    /**
+     * Creates a Formattable object with an array of Formattable objects.
+     * @param arrayToCopy the Formattable object array.
+     * @param count the array count.
+     * @stable ICU 2.0
+     */
+    Formattable(const Formattable* arrayToCopy, int32_t count);
+
+    /**
+     * Creates a Formattable object that adopts the given UObject.
+     * @param objectToAdopt the UObject to set this object to
+     * @stable ICU 3.0
+     */
+    Formattable(UObject* objectToAdopt);
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    Formattable(const Formattable&);
+
+    /**
+     * Assignment operator.
+     * @param rhs   The Formattable object to copy into this object.
+     * @stable ICU 2.0
+     */
+    Formattable&    operator=(const Formattable &rhs);
+
+    /**
+     * Equality comparison.
+     * @param other    the object to be compared with.
+     * @return        TRUE if other are equal to this, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool          operator==(const Formattable &other) const;
+    
+    /** 
+     * Equality operator.
+     * @param other    the object to be compared with.
+     * @return        TRUE if other are unequal to this, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool          operator!=(const Formattable& other) const
+      { return !operator==(other); }
+
+    /** 
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual         ~Formattable();
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    Formattable *clone() const;
+
+    /** 
+     * Selector for flavor of data type contained within a
+     * Formattable object.  Formattable is a union of several
+     * different types, and at any time contains exactly one type.
+     * @stable ICU 2.4
+     */
+    enum Type {
+        /**
+         * Selector indicating a UDate value.  Use getDate to retrieve
+         * the value.
+         * @stable ICU 2.4
+         */
+        kDate,
+
+        /**
+         * Selector indicating a double value.  Use getDouble to
+         * retrieve the value.
+         * @stable ICU 2.4
+         */
+        kDouble,
+
+        /**
+         * Selector indicating a 32-bit integer value.  Use getLong to
+         * retrieve the value.
+         * @stable ICU 2.4
+         */
+        kLong,
+
+        /**
+         * Selector indicating a UnicodeString value.  Use getString
+         * to retrieve the value.
+         * @stable ICU 2.4
+         */
+        kString,
+
+        /**
+         * Selector indicating an array of Formattables.  Use getArray
+         * to retrieve the value.
+         * @stable ICU 2.4
+         */
+        kArray,
+
+        /**
+         * Selector indicating a 64-bit integer value.  Use getInt64
+         * to retrieve the value.
+         * @stable ICU 2.8
+         */
+        kInt64,
+
+        /**
+         * Selector indicating a UObject value.  Use getObject to
+         * retrieve the value.
+         * @stable ICU 3.0
+         */
+        kObject
+   };
+
+    /**
+     * Gets the data type of this Formattable object.
+     * @return    the data type of this Formattable object.
+     * @stable ICU 2.0
+     */
+    Type            getType(void) const;
+    
+    /**
+     * Returns TRUE if the data type of this Formattable object
+     * is kDouble, kLong, or kInt64.
+     * @return TRUE if this is a pure numeric object
+     * @stable ICU 3.0
+     */
+    UBool           isNumeric() const;
+    
+    /**
+     * Gets the double value of this object. If this object is not of type
+     * kDouble then the result is undefined.
+     * @return    the double value of this object.
+     * @stable ICU 2.0
+     */ 
+    double          getDouble(void) const { return fValue.fDouble; }
+
+    /**
+     * Gets the double value of this object. If this object is of type
+     * long or int64 then a casting conversion is peformed, with
+     * possible loss of precision.  If the type is kObject and the
+     * object is a Measure, then the result of
+     * getNumber().getDouble(status) is returned.  If this object is
+     * neither a numeric type nor a Measure, then 0 is returned and
+     * the status is set to U_INVALID_FORMAT_ERROR.
+     * @param status the error code
+     * @return the double value of this object.
+     * @stable ICU 3.0
+     */ 
+    double          getDouble(UErrorCode& status) const;
+
+    /**
+     * Gets the long value of this object. If this object is not of type
+     * kLong then the result is undefined.
+     * @return    the long value of this object.
+     * @stable ICU 2.0
+     */ 
+    int32_t         getLong(void) const { return (int32_t)fValue.fInt64; }
+
+    /**
+     * Gets the long value of this object. If the magnitude is too
+     * large to fit in a long, then the maximum or minimum long value,
+     * as appropriate, is returned and the status is set to
+     * U_INVALID_FORMAT_ERROR.  If this object is of type kInt64 and
+     * it fits within a long, then no precision is lost.  If it is of
+     * type kDouble, then a casting conversion is peformed, with
+     * truncation of any fractional part.  If the type is kObject and
+     * the object is a Measure, then the result of
+     * getNumber().getLong(status) is returned.  If this object is
+     * neither a numeric type nor a Measure, then 0 is returned and
+     * the status is set to U_INVALID_FORMAT_ERROR.
+     * @param status the error code
+     * @return    the long value of this object.
+     * @stable ICU 3.0
+     */ 
+    int32_t         getLong(UErrorCode& status) const;
+
+    /**
+     * Gets the int64 value of this object. If this object is not of type
+     * kInt64 then the result is undefined.
+     * @return    the int64 value of this object.
+     * @stable ICU 2.8
+     */ 
+    int64_t         getInt64(void) const { return fValue.fInt64; }
+
+    /**
+     * Gets the int64 value of this object. If this object is of type
+     * kDouble and the magnitude is too large to fit in an int64, then
+     * the maximum or minimum int64 value, as appropriate, is returned
+     * and the status is set to U_INVALID_FORMAT_ERROR.  If the
+     * magnitude fits in an int64, then a casting conversion is
+     * peformed, with truncation of any fractional part.  If the type
+     * is kObject and the object is a Measure, then the result of
+     * getNumber().getDouble(status) is returned.  If this object is
+     * neither a numeric type nor a Measure, then 0 is returned and
+     * the status is set to U_INVALID_FORMAT_ERROR.
+     * @param status the error code
+     * @return    the int64 value of this object.
+     * @stable ICU 3.0
+     */ 
+    int64_t         getInt64(UErrorCode& status) const;
+
+    /**
+     * Gets the Date value of this object. If this object is not of type
+     * kDate then the result is undefined.
+     * @return    the Date value of this object.
+     * @stable ICU 2.0
+     */ 
+    UDate           getDate() const { return fValue.fDate; }
+
+    /**
+     * Gets the Date value of this object.  If the type is not a date,
+     * status is set to U_INVALID_FORMAT_ERROR and the return value is
+     * undefined.
+     * @param status the error code.
+     * @return    the Date value of this object.
+     * @stable ICU 3.0
+     */ 
+     UDate          getDate(UErrorCode& status) const;
+
+    /**
+     * Gets the string value of this object. If this object is not of type
+     * kString then the result is undefined.
+     * @param result    Output param to receive the Date value of this object.
+     * @return          A reference to 'result'.
+     * @stable ICU 2.0
+     */ 
+    UnicodeString&  getString(UnicodeString& result) const
+      { result=*fValue.fString; return result; }
+
+    /**
+     * Gets the string value of this object. If the type is not a
+     * string, status is set to U_INVALID_FORMAT_ERROR and a bogus
+     * string is returned.
+     * @param result    Output param to receive the Date value of this object.
+     * @param status    the error code. 
+     * @return          A reference to 'result'.
+     * @stable ICU 3.0
+     */ 
+    UnicodeString&  getString(UnicodeString& result, UErrorCode& status) const;
+
+    /**
+     * Gets a const reference to the string value of this object. If
+     * this object is not of type kString then the result is
+     * undefined.
+     * @return   a const reference to the string value of this object.
+     * @stable ICU 2.0
+     */
+    inline const UnicodeString& getString(void) const;
+
+    /**
+     * Gets a const reference to the string value of this object.  If
+     * the type is not a string, status is set to
+     * U_INVALID_FORMAT_ERROR and the result is a bogus string.
+     * @param status    the error code.
+     * @return   a const reference to the string value of this object.
+     * @stable ICU 3.0
+     */
+    const UnicodeString& getString(UErrorCode& status) const;
+
+    /**
+     * Gets a reference to the string value of this object. If this
+     * object is not of type kString then the result is undefined.
+     * @return   a reference to the string value of this object.
+     * @stable ICU 2.0
+     */
+    inline UnicodeString& getString(void);
+
+    /**
+     * Gets a reference to the string value of this object. If the
+     * type is not a string, status is set to U_INVALID_FORMAT_ERROR
+     * and the result is a bogus string.
+     * @param status    the error code. 
+     * @return   a reference to the string value of this object.
+     * @stable ICU 3.0
+     */
+    UnicodeString& getString(UErrorCode& status);
+
+    /**
+     * Gets the array value and count of this object. If this object
+     * is not of type kArray then the result is undefined.
+     * @param count    fill-in with the count of this object.
+     * @return         the array value of this object.
+     * @stable ICU 2.0
+     */ 
+    const Formattable* getArray(int32_t& count) const
+      { count=fValue.fArrayAndCount.fCount; return fValue.fArrayAndCount.fArray; }
+
+    /**
+     * Gets the array value and count of this object. If the type is
+     * not an array, status is set to U_INVALID_FORMAT_ERROR, count is
+     * set to 0, and the result is NULL.
+     * @param count    fill-in with the count of this object.
+     * @param status the error code. 
+     * @return         the array value of this object.
+     * @stable ICU 3.0
+     */ 
+    const Formattable* getArray(int32_t& count, UErrorCode& status) const;
+
+    /**
+     * Accesses the specified element in the array value of this
+     * Formattable object. If this object is not of type kArray then
+     * the result is undefined.
+     * @param index the specified index.
+     * @return the accessed element in the array.
+     * @stable ICU 2.0
+     */
+    Formattable&    operator[](int32_t index) { return fValue.fArrayAndCount.fArray[index]; }
+       
+    /**
+     * Returns a pointer to the UObject contained within this
+     * formattable, or NULL if this object does not contain a UObject.
+     * @return a UObject pointer, or NULL
+     * @stable ICU 3.0
+     */
+    const UObject*  getObject() const;
+
+    /**
+     * Sets the double value of this object and changes the type to
+     * kDouble.
+     * @param d    the new double value to be set.
+     * @stable ICU 2.0
+     */ 
+    void            setDouble(double d);
+
+    /**
+     * Sets the long value of this object and changes the type to
+     * kLong.
+     * @param l    the new long value to be set.
+     * @stable ICU 2.0
+     */ 
+    void            setLong(int32_t l);
+
+    /**
+     * Sets the int64 value of this object and changes the type to
+     * kInt64.
+     * @param ll    the new int64 value to be set.
+     * @stable ICU 2.8
+     */ 
+    void            setInt64(int64_t ll);
+
+    /**
+     * Sets the Date value of this object and changes the type to
+     * kDate.
+     * @param d    the new Date value to be set.
+     * @stable ICU 2.0
+     */ 
+    void            setDate(UDate d);
+
+    /**
+     * Sets the string value of this object and changes the type to
+     * kString.
+     * @param stringToCopy    the new string value to be set.
+     * @stable ICU 2.0
+     */ 
+    void            setString(const UnicodeString& stringToCopy);
+
+    /**
+     * Sets the array value and count of this object and changes the
+     * type to kArray.
+     * @param array    the array value.
+     * @param count    the number of array elements to be copied.
+     * @stable ICU 2.0
+     */ 
+    void            setArray(const Formattable* array, int32_t count);
+
+    /**
+     * Sets and adopts the string value and count of this object and
+     * changes the type to kArray.
+     * @param stringToAdopt    the new string value to be adopted.
+     * @stable ICU 2.0
+     */ 
+    void            adoptString(UnicodeString* stringToAdopt);
+
+    /**
+     * Sets and adopts the array value and count of this object and
+     * changes the type to kArray.
+     * @stable ICU 2.0
+     */ 
+    void            adoptArray(Formattable* array, int32_t count);
+       
+    /**
+     * Sets and adopts the UObject value of this object and changes
+     * the type to kObject.  After this call, the caller must not
+     * delete the given object.
+     * @param objectToAdopt the UObject value to be adopted
+     * @stable ICU 3.0
+     */
+    void            adoptObject(UObject* objectToAdopt);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * Deprecated variant of getLong(UErrorCode&).
+     * @param status the error code
+     * @return the long value of this object.
+     * @deprecated ICU 3.0 use getLong(UErrorCode&) instead
+     */ 
+    inline int32_t getLong(UErrorCode* status) const;
+
+private:
+    /**
+     * Cleans up the memory for unwanted values.  For example, the adopted
+     * string or array objects.
+     */
+    void            dispose(void);
+
+    UnicodeString* getBogus() const;
+
+    union {
+        UObject*        fObject;
+        UnicodeString*  fString;
+        double          fDouble;
+        int64_t         fInt64;
+        UDate           fDate;
+        struct {
+          Formattable*  fArray;
+          int32_t       fCount;
+        }               fArrayAndCount;
+    } fValue;
+
+    Type                fType;
+    UnicodeString       fBogus; // Bogus string when it's needed.
+};
+
+inline UDate Formattable::getDate(UErrorCode& status) const {
+    if (fType != kDate) {
+        if (U_SUCCESS(status)) {
+            status = U_INVALID_FORMAT_ERROR;
+        }
+        return 0;
+    }
+    return fValue.fDate;
+}
+
+inline const UnicodeString& Formattable::getString(void) const {
+    return *fValue.fString;
+}
+
+inline UnicodeString& Formattable::getString(void) {
+    return *fValue.fString;
+}
+
+inline int32_t Formattable::getLong(UErrorCode* status) const {
+    return getLong(*status);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif //_FMTABLE
+//eof
+
diff --git a/CoreFoundation/icu/unicode/format.h b/CoreFoundation/icu/unicode/format.h
new file mode 100644
index 0000000..7f17b52
--- /dev/null
+++ b/CoreFoundation/icu/unicode/format.h
@@ -0,0 +1,296 @@
+/*
+********************************************************************************
+* Copyright (C) 1997-2006, International Business Machines Corporation and others.
+* All Rights Reserved.
+********************************************************************************
+*
+* File FORMAT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/17/97    clhuang     Updated per C++ implementation.
+*   03/27/97    helena      Updated to pass the simple test after code review.
+********************************************************************************
+*/
+// *****************************************************************************
+// This file was generated from the java source file Format.java
+// *****************************************************************************
+
+#ifndef FORMAT_H
+#define FORMAT_H
+
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Base class for all formats. 
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/unistr.h"
+#include "unicode/fmtable.h"
+#include "unicode/fieldpos.h"
+#include "unicode/parsepos.h"
+#include "unicode/parseerr.h" 
+#include "unicode/locid.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Base class for all formats.  This is an abstract base class which
+ * specifies the protocol for classes which convert other objects or
+ * values, such as numeric values and dates, and their string
+ * representations.  In some cases these representations may be
+ * localized or contain localized characters or strings.  For example,
+ * a numeric formatter such as DecimalFormat may convert a numeric
+ * value such as 12345 to the string "$12,345".  It may also parse
+ * the string back into a numeric value.  A date and time formatter
+ * like SimpleDateFormat may represent a specific date, encoded
+ * numerically, as a string such as "Wednesday, February 26, 1997 AD".
+ * <P>
+ * Many of the concrete subclasses of Format employ the notion of
+ * a pattern.  A pattern is a string representation of the rules which
+ * govern the interconversion between values and strings.  For example,
+ * a DecimalFormat object may be associated with the pattern
+ * "$#,##0.00;($#,##0.00)", which is a common US English format for
+ * currency values, yielding strings such as "$1,234.45" for 1234.45,
+ * and "($987.65)" for 987.6543.  The specific syntax of a pattern
+ * is defined by each subclass.
+ * <P>
+ * Even though many subclasses use patterns, the notion of a pattern
+ * is not inherent to Format classes in general, and is not part of
+ * the explicit base class protocol.
+ * <P>
+ * Two complex formatting classes bear mentioning.  These are
+ * MessageFormat and ChoiceFormat.  ChoiceFormat is a subclass of
+ * NumberFormat which allows the user to format different number ranges
+ * as strings.  For instance, 0 may be represented as "no files", 1 as
+ * "one file", and any number greater than 1 as "many files".
+ * MessageFormat is a formatter which utilizes other Format objects to
+ * format a string containing with multiple values.  For instance,
+ * A MessageFormat object might produce the string "There are no files
+ * on the disk MyDisk on February 27, 1997." given the arguments 0,
+ * "MyDisk", and the date value of 2/27/97.  See the ChoiceFormat
+ * and MessageFormat headers for further information.
+ * <P>
+ * If formatting is unsuccessful, a failing UErrorCode is returned when
+ * the Format cannot format the type of object, otherwise if there is
+ * something illformed about the the Unicode replacement character
+ * 0xFFFD is returned.
+ * <P>
+ * If there is no match when parsing, a parse failure UErrorCode is
+ * retured for methods which take no ParsePosition.  For the method
+ * that takes a ParsePosition, the index parameter is left unchanged.
+ * <P>
+ * <em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API Format : public UObject {
+public:
+
+    /** Destructor
+     * @stable ICU 2.4
+     */
+    virtual ~Format();
+
+    /**
+     * Return true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     * @param other    the object to be compared with.
+     * @return         Return true if the given Format objects are semantically equal.
+     *                 Objects of different subclasses are considered unequal.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const = 0;
+
+    /**
+     * Return true if the given Format objects are not semantically
+     * equal.
+     * @param other    the object to be compared with.
+     * @return         Return true if the given Format objects are not semantically.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const Format& other) const { return !operator==(other); }
+
+    /**
+     * Clone this object polymorphically.  The caller is responsible
+     * for deleting the result when done.
+     * @return    A copy of the object
+     * @stable ICU 2.0
+     */
+    virtual Format* clone() const = 0;
+
+    /**
+     * Formats an object to produce a string.
+     *
+     * @param obj       The object to format.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Output parameter filled in with success or failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+
+    /**
+     * Format an object to produce a string.  This is a pure virtual method which
+     * subclasses must implement. This method allows polymorphic formatting
+     * of Formattable objects. If a subclass of Format receives a Formattable
+     * object type it doesn't handle (e.g., if a numeric Formattable is passed
+     * to a DateFormat object) then it returns a failing UErrorCode.
+     *
+     * @param obj       The object to format.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const = 0;
+
+    /**
+     * Parse a string to produce an object.  This is a pure virtual
+     * method which subclasses must implement.  This method allows
+     * polymorphic parsing of strings into Formattable objects.
+     * <P>
+     * Before calling, set parse_pos.index to the offset you want to
+     * start parsing at in the source.  After calling, parse_pos.index
+     * is the end of the text you parsed.  If error occurs, index is
+     * unchanged.
+     * <P>
+     * When parsing, leading whitespace is discarded (with successful
+     * parse), while trailing whitespace is left as is.
+     * <P>
+     * Example:
+     * <P>
+     * Parsing "_12_xy" (where _ represents a space) for a number,
+     * with index == 0 will result in the number 12, with
+     * parse_pos.index updated to 3 (just before the second space).
+     * Parsing a second time will result in a failing UErrorCode since
+     * "xy" is not a number, and leave index at 3.
+     * <P>
+     * Subclasses will typically supply specific parse methods that
+     * return different types of values. Since methods can't overload
+     * on return types, these will typically be named "parse", while
+     * this polymorphic method will always be called parseObject.  Any
+     * parse method that does not take a parse_pos should set status
+     * to an error value when no text in the required format is at the
+     * start position.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param parse_pos The position to start parsing at. Upon return
+     *                  this param is set to the position after the
+     *                  last character successfully parsed. If the
+     *                  source is not parsed successfully, this param
+     *                  will remain unchanged.
+     * @stable ICU 2.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& parse_pos) const = 0;
+
+    /**
+     * Parses a string to produce an object. This is a convenience method
+     * which calls the pure virtual parseObject() method, and returns a
+     * failure UErrorCode if the ParsePosition indicates failure.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param status    Output param to be filled with success/failure
+     *                  result code.
+     * @stable ICU 2.0
+     */
+    void parseObject(const UnicodeString& source,
+                     Formattable& result,
+                     UErrorCode& status) const;
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual method.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     * Concrete subclasses of Format must implement getDynamicClassID()
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID() const = 0;
+
+    /** Get the locale for this format object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual) 
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @stable ICU 2.8
+     */
+    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+    /** Get the locale for this format object. You can choose between valid and actual locale.
+     *  @param type type of the locale we're looking for (valid or actual) 
+     *  @param status error code for the operation
+     *  @return the locale
+     *  @internal
+     */
+    const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
+
+ protected:
+    /** @stable ICU 2.8 */
+    void setLocaleIDs(const char* valid, const char* actual);
+
+protected:
+    /**
+     * Default constructor for subclass use only.  Does nothing.
+     * @stable ICU 2.0
+     */
+    Format();
+
+    /**
+     * @stable ICU 2.0
+     */
+    Format(const Format&); // Does nothing; for subclasses only
+
+    /**
+     * @stable ICU 2.0
+     */
+    Format& operator=(const Format&); // Does nothing; for subclasses
+
+       
+    /**
+     * Simple function for initializing a UParseError from a UnicodeString.
+     *
+     * @param pattern The pattern to copy into the parseError
+     * @param pos The position in pattern where the error occured
+     * @param parseError The UParseError object to fill in
+     * @stable ICU 2.4
+     */
+    static void syntaxError(const UnicodeString& pattern,
+                            int32_t pos,
+                            UParseError& parseError);
+
+ private:
+    char actualLocale[ULOC_FULLNAME_CAPACITY];
+    char validLocale[ULOC_FULLNAME_CAPACITY];
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _FORMAT
+//eof
diff --git a/CoreFoundation/icu/unicode/gregocal.h b/CoreFoundation/icu/unicode/gregocal.h
new file mode 100644
index 0000000..f2d1b0b
--- /dev/null
+++ b/CoreFoundation/icu/unicode/gregocal.h
@@ -0,0 +1,823 @@
+/*
+* Copyright (C) 1997-2006, International Business Machines Corporation and others.
+* All Rights Reserved.
+********************************************************************************
+*
+* File GREGOCAL.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/22/97    aliu        Overhauled header.
+*    07/28/98    stephen        Sync with JDK 1.2
+*    09/04/98    stephen        Re-sync with JDK 8/31 putback
+*    09/14/98    stephen        Changed type of kOneDay, kOneWeek to double.
+*                            Fixed bug in roll()
+*   10/15/99    aliu        Fixed j31, incorrect WEEK_OF_YEAR computation.
+*                           Added documentation of WEEK_OF_YEAR computation.
+*   10/15/99    aliu        Fixed j32, cannot set date to Feb 29 2000 AD.
+*                           {JDK bug 4210209 4209272}
+*   11/07/2003  srl         Update, clean up documentation.
+********************************************************************************
+*/
+
+#ifndef GREGOCAL_H
+#define GREGOCAL_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/calendar.h"
+
+/**
+ * \file 
+ * \brief C++ API: Concrete class which provides the standard calendar.
+ */
+
+U_NAMESPACE_BEGIN
+
+/** 
+ * Concrete class which provides the standard calendar used by most of the world.
+ * <P>
+ * The standard (Gregorian) calendar has 2 eras, BC and AD.
+ * <P>
+ * This implementation handles a single discontinuity, which corresponds by default to
+ * the date the Gregorian calendar was originally instituted (October 15, 1582). Not all
+ * countries adopted the Gregorian calendar then, so this cutover date may be changed by
+ * the caller.
+ * <P>
+ * Prior to the institution of the Gregorian Calendar, New Year's Day was March 25. To
+ * avoid confusion, this Calendar always uses January 1. A manual adjustment may be made
+ * if desired for dates that are prior to the Gregorian changeover and which fall
+ * between January 1 and March 24.
+ *
+ * <p>Values calculated for the <code>WEEK_OF_YEAR</code> field range from 1 to
+ * 53.  Week 1 for a year is the first week that contains at least
+ * <code>getMinimalDaysInFirstWeek()</code> days from that year.  It thus
+ * depends on the values of <code>getMinimalDaysInFirstWeek()</code>,
+ * <code>getFirstDayOfWeek()</code>, and the day of the week of January 1.
+ * Weeks between week 1 of one year and week 1 of the following year are
+ * numbered sequentially from 2 to 52 or 53 (as needed).
+ *
+ * <p>For example, January 1, 1998 was a Thursday.  If
+ * <code>getFirstDayOfWeek()</code> is <code>MONDAY</code> and
+ * <code>getMinimalDaysInFirstWeek()</code> is 4 (these are the values
+ * reflecting ISO 8601 and many national standards), then week 1 of 1998 starts
+ * on December 29, 1997, and ends on January 4, 1998.  If, however,
+ * <code>getFirstDayOfWeek()</code> is <code>SUNDAY</code>, then week 1 of 1998
+ * starts on January 4, 1998, and ends on January 10, 1998; the first three days
+ * of 1998 then are part of week 53 of 1997.
+ *
+ * <p>Example for using GregorianCalendar:
+ * <pre>
+ * \code
+ *     // get the supported ids for GMT-08:00 (Pacific Standard Time)
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     const StringEnumeration *ids = TimeZone::createEnumeration(-8 * 60 * 60 * 1000);
+ *     // if no ids were returned, something is wrong. get out.
+ *     if (ids == 0 || ids->count(success) == 0) {
+ *         return;
+ *     }
+ *
+ *     // begin output
+ *     cout << "Current Time" << endl;
+ *
+ *     // create a Pacific Standard Time time zone
+ *     SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids->unext(NULL, success)));
+ *
+ *     // set up rules for daylight savings time
+ *     pdt->setStartRule(Calendar::APRIL, 1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
+ *     pdt->setEndRule(Calendar::OCTOBER, -1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
+ *
+ *     // create a GregorianCalendar with the Pacific Daylight time zone
+ *     // and the current date and time
+ *     Calendar* calendar = new GregorianCalendar( pdt, success );
+ *
+ *     // print out a bunch of interesting things
+ *     cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
+ *     cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
+ *     cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
+ *     cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
+ *     cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
+ *     cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
+ *     cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
+ *     cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
+ *     cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
+ *     cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
+ *     cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
+ *     cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
+ *     cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
+ *     cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
+ *     cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
+ *     cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
+ *     cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl;
+ *     cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl;
+ *
+ *     cout << "Current Time, with hour reset to 3" << endl;
+ *     calendar->clear(Calendar::HOUR_OF_DAY); // so doesn't override
+ *     calendar->set(Calendar::HOUR, 3);
+ *     cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
+ *     cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
+ *     cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
+ *     cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
+ *     cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
+ *     cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
+ *     cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
+ *     cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
+ *     cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
+ *     cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
+ *     cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
+ *     cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
+ *     cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
+ *     cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
+ *     cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
+ *     cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
+ *     cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl; // in hours
+ *     cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl; // in hours
+ *
+ *     if (U_FAILURE(success)) {
+ *         cout << "An error occured. success=" << u_errorName(success) << endl;
+ *     }
+ *
+ *     delete ids;
+ *     delete calendar; // also deletes pdt
+ * \endcode
+ * </pre>
+ * @stable ICU 2.0
+ */
+class U_I18N_API GregorianCalendar: public Calendar {
+public:
+
+    /**
+     * Useful constants for GregorianCalendar and TimeZone.
+     * @stable ICU 2.0
+     */
+    enum EEras {
+        BC,
+        AD
+    };
+
+    /**
+     * Constructs a default GregorianCalendar using the current time in the default time
+     * zone with the default locale.
+     *
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar based on the current time in the given time zone
+     * with the default locale. Clients are no longer responsible for deleting the given
+     * time zone object after it's adopted.
+     *
+     * @param zoneToAdopt     The given timezone.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(TimeZone* zoneToAdopt, UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar based on the current time in the given time zone
+     * with the default locale.
+     *
+     * @param zone     The given timezone.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(const TimeZone& zone, UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar based on the current time in the default time zone
+     * with the given locale.
+     *
+     * @param aLocale  The given locale.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar based on the current time in the given time zone
+     * with the given locale. Clients are no longer responsible for deleting the given
+     * time zone object after it's adopted.
+     *
+     * @param zoneToAdopt     The given timezone.
+     * @param aLocale  The given locale.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar based on the current time in the given time zone
+     * with the given locale.
+     *
+     * @param zone     The given timezone.
+     * @param aLocale  The given locale.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar with the given AD date set in the default time
+     * zone with the default locale.
+     *
+     * @param year     The value used to set the YEAR time field in the calendar.
+     * @param month    The value used to set the MONTH time field in the calendar. Month
+     *                 value is 0-based. e.g., 0 for January.
+     * @param date     The value used to set the DATE time field in the calendar.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(int32_t year, int32_t month, int32_t date, UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar with the given AD date and time set for the
+     * default time zone with the default locale.
+     *
+     * @param year     The value used to set the YEAR time field in the calendar.
+     * @param month    The value used to set the MONTH time field in the calendar. Month
+     *                 value is 0-based. e.g., 0 for January.
+     * @param date     The value used to set the DATE time field in the calendar.
+     * @param hour     The value used to set the HOUR_OF_DAY time field in the calendar.
+     * @param minute   The value used to set the MINUTE time field in the calendar.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, UErrorCode& success);
+
+    /**
+     * Constructs a GregorianCalendar with the given AD date and time set for the
+     * default time zone with the default locale.
+     *
+     * @param year     The value used to set the YEAR time field in the calendar.
+     * @param month    The value used to set the MONTH time field in the calendar. Month
+     *                 value is 0-based. e.g., 0 for January.
+     * @param date     The value used to set the DATE time field in the calendar.
+     * @param hour     The value used to set the HOUR_OF_DAY time field in the calendar.
+     * @param minute   The value used to set the MINUTE time field in the calendar.
+     * @param second   The value used to set the SECOND time field in the calendar.
+     * @param success  Indicates the status of GregorianCalendar object construction.
+     *                 Returns U_ZERO_ERROR if constructed successfully.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode& success);
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~GregorianCalendar();
+
+    /**
+     * Copy constructor
+     * @param source    the object to be copied.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar(const GregorianCalendar& source);
+
+    /**
+     * Default assignment operator
+     * @param right    the object to be copied.
+     * @stable ICU 2.0
+     */
+    GregorianCalendar& operator=(const GregorianCalendar& right);
+
+    /**
+     * Create and return a polymorphic copy of this calendar.
+     * @return    return a polymorphic copy of this calendar.
+     * @stable ICU 2.0
+     */
+    virtual Calendar* clone(void) const;
+
+    /**
+     * Sets the GregorianCalendar change date. This is the point when the switch from
+     * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
+     * 15, 1582. Previous to this time and date will be Julian dates.
+     *
+     * @param date     The given Gregorian cutover date.
+     * @param success  Output param set to success/failure code on exit.
+     * @stable ICU 2.0
+     */
+    void setGregorianChange(UDate date, UErrorCode& success);
+
+    /**
+     * Gets the Gregorian Calendar change date. This is the point when the switch from
+     * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
+     * 15, 1582. Previous to this time and date will be Julian dates.
+     *
+     * @return   The Gregorian cutover time for this calendar.
+     * @stable ICU 2.0
+     */
+    UDate getGregorianChange(void) const;
+
+    /**
+     * Return true if the given year is a leap year. Determination of whether a year is
+     * a leap year is actually very complicated. We do something crude and mostly
+     * correct here, but for a real determination you need a lot of contextual
+     * information. For example, in Sweden, the change from Julian to Gregorian happened
+     * in a complex way resulting in missed leap years and double leap years between
+     * 1700 and 1753. Another example is that after the start of the Julian calendar in
+     * 45 B.C., the leap years did not regularize until 8 A.D. This method ignores these
+     * quirks, and pays attention only to the Julian onset date and the Gregorian
+     * cutover (which can be changed).
+     *
+     * @param year  The given year.
+     * @return      True if the given year is a leap year; false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool isLeapYear(int32_t year) const;
+
+    /**
+     * Returns TRUE if the given Calendar object is equivalent to this
+     * one.  Calendar override.
+     *
+     * @param other the Calendar to be compared with this Calendar   
+     * @stable ICU 2.4
+     */
+    virtual UBool isEquivalentTo(const Calendar& other) const;
+
+    /**
+     * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
+     * For more information, see the documentation for Calendar::roll().
+     *
+     * @param field   The time field.
+     * @param amount  Indicates amount to roll.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
+     */
+    virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
+     * For more information, see the documentation for Calendar::roll().
+     *
+     * @param field   The time field.
+     * @param amount  Indicates amount to roll.
+     * @param status  Output param set to success/failure code on exit. If any value
+     *                previously set in the time field is invalid, this will be set to
+     *                an error status.
+     * @stable ICU 2.6.
+     */
+    virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
+
+    /**
+     * Return the minimum value that this field could have, given the current date.
+     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
+     * @param field    the time field.
+     * @return         the minimum value that this field could have, given the current date.
+     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead.
+     */
+    int32_t getActualMinimum(EDateFields field) const;
+
+    /**
+     * Return the minimum value that this field could have, given the current date.
+     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
+     * @param field    the time field.
+     * @param status
+     * @return         the minimum value that this field could have, given the current date.
+     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead. (Added to ICU 3.0 for signature consistency)
+     */
+    int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
+
+    /**
+     * Return the minimum value that this field could have, given the current date.
+     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
+     * @param field    the time field.
+     * @param status   error result.
+     * @return         the minimum value that this field could have, given the current date.
+     * @stable ICU 3.0
+     */
+    int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const;
+
+    /**
+     * Return the maximum value that this field could have, given the current date.
+     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
+     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
+     * for some years the actual maximum for MONTH is 12, and for others 13.
+     * @param field    the time field.
+     * @return         the maximum value that this field could have, given the current date.
+     * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field) instead.
+     */
+    int32_t getActualMaximum(EDateFields field) const;
+
+    /**
+     * Return the maximum value that this field could have, given the current date.
+     * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
+     * maximum would be 28; for "Feb 3, 1996" it s 29.  Similarly for a Hebrew calendar,
+     * for some years the actual maximum for MONTH is 12, and for others 13.
+     * @param field    the time field.
+     * @param status   returns any errors that may result from this function call.
+     * @return         the maximum value that this field could have, given the current date.
+     * @stable ICU 2.6
+     */
+    virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
+
+    /**
+     * (Overrides Calendar) Return true if the current date for this Calendar is in
+     * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
+     *
+     * @param status Fill-in parameter which receives the status of this operation.
+     * @return   True if the current date for this Calendar is in Daylight Savings Time,
+     *           false, otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool inDaylightTime(UErrorCode& status) const;
+
+public:
+
+    /**
+     * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
+     * override. This method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
+     * this method.
+     *
+     * @return   The class ID for this object. All objects of a given class have the
+     *           same class ID. Objects of other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Return the class ID for this class. This is useful only for comparing to a return
+     * value from getDynamicClassID(). For example:
+     *
+     *      Base* polymorphic_pointer = createPolymorphicObject();
+     *      if (polymorphic_pointer->getDynamicClassID() ==
+     *          Derived::getStaticClassID()) ...
+     *
+     * @return   The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Get the calendar type, "gregorian", for use in DateFormatSymbols.
+     *
+     * @return calendar type
+     * @internal
+     */
+    virtual const char * getType() const;
+
+protected:
+
+    /**
+     * (Overrides Calendar) Converts GMT as milliseconds to time field values.
+     * @param status Fill-in parameter which receives the status of this operation.
+     * @stable ICU 2.0
+     */
+
+ private:
+    GregorianCalendar(); // default constructor not implemented
+
+ protected:
+    /**
+     * Return the ERA.  We need a special method for this because the
+     * default ERA is AD, but a zero (unset) ERA is BC.
+     * @return    the ERA.
+     * @internal
+     */
+    virtual int32_t internalGetEra() const;
+
+    /**
+     * Return the Julian day number of day before the first day of the
+     * given month in the given extended year.  Subclasses should override
+     * this method to implement their calendar system.
+     * @param eyear the extended year
+     * @param month the zero-based month, or 0 if useMonth is false
+     * @param useMonth if false, compute the day before the first day of
+     * the given year, otherwise, compute the day before the first day of
+     * the given month
+     * @return the Julian day number of the day before the first
+     * day of the given month and year
+     * @internal
+     */
+    virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
+                                                   UBool useMonth) const;
+
+    /**
+     * Subclasses may override this.  This method calls
+     * handleGetMonthLength() to obtain the calendar-specific month
+     * length.
+     * @param bestField which field to use to calculate the date 
+     * @return julian day specified by calendar fields.
+     * @internal
+     */
+    virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField)  ;
+
+    /**
+     * Return the number of days in the given month of the given extended
+     * year of this calendar system.  Subclasses should override this
+     * method if they can provide a more correct or more efficient
+     * implementation than the default implementation in Calendar.
+     * @internal
+     */
+    virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;
+
+    /**
+     * Return the number of days in the given extended year of this
+     * calendar system.  Subclasses should override this method if they can
+     * provide a more correct or more efficient implementation than the
+     * default implementation in Calendar.
+     * @stable ICU 2.0
+     */
+    virtual int32_t handleGetYearLength(int32_t eyear) const;
+
+    /**
+     * return the length of the given month.
+     * @param month    the given month.
+     * @return    the length of the given month.
+     * @internal
+     */
+    virtual int32_t monthLength(int32_t month) const;
+
+    /**
+     * return the length of the month according to the given year.
+     * @param month    the given month.
+     * @param year     the given year.
+     * @return         the length of the month
+     * @internal
+     */
+    virtual int32_t monthLength(int32_t month, int32_t year) const;
+    
+    /**
+     * return the length of the given year.
+     * @param year    the given year.
+     * @return        the length of the given year.
+     * @internal
+     */
+    int32_t yearLength(int32_t year) const;
+    
+    /**
+     * return the length of the year field.
+     * @return    the length of the year field
+     * @internal
+     */
+    int32_t yearLength(void) const;
+
+    /**
+     * After adjustments such as add(MONTH), add(YEAR), we don't want the
+     * month to jump around.  E.g., we don't want Jan 31 + 1 month to go to Mar
+     * 3, we want it to go to Feb 28.  Adjustments which might run into this
+     * problem call this method to retain the proper month.
+     * @internal
+     */
+    void pinDayOfMonth(void);
+
+    /**
+     * Return the day number with respect to the epoch.  January 1, 1970 (Gregorian)
+     * is day zero.
+     * @param status Fill-in parameter which receives the status of this operation.
+     * @return       the day number with respect to the epoch.  
+     * @internal
+     */
+    virtual UDate getEpochDay(UErrorCode& status);
+
+    /**
+     * Subclass API for defining limits of different types.
+     * Subclasses must implement this method to return limits for the
+     * following fields:
+     *
+     * <pre>UCAL_ERA
+     * UCAL_YEAR
+     * UCAL_MONTH
+     * UCAL_WEEK_OF_YEAR
+     * UCAL_WEEK_OF_MONTH
+     * UCAL_DATE (DAY_OF_MONTH on Java)
+     * UCAL_DAY_OF_YEAR
+     * UCAL_DAY_OF_WEEK_IN_MONTH
+     * UCAL_YEAR_WOY
+     * UCAL_EXTENDED_YEAR</pre>
+     *
+     * @param field one of the above field numbers
+     * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
+     * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
+     * @internal
+     */
+    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;
+
+    /**
+     * Return the extended year defined by the current fields.  This will
+     * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
+     * as UCAL_ERA) specific to the calendar system, depending on which set of
+     * fields is newer.
+     * @return the extended year
+     * @internal
+     */
+    virtual int32_t handleGetExtendedYear();
+
+    /** 
+     * Subclasses may override this to convert from week fields 
+     * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case
+     * where YEAR, EXTENDED_YEAR are not set.
+     * The Gregorian implementation assumes a yearWoy in gregorian format, according to the current era.
+     * @return the extended year, UCAL_EXTENDED_YEAR
+     * @internal
+     */
+    virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
+
+
+    /**
+     * Subclasses may override this method to compute several fields
+     * specific to each calendar system.  These are:
+     *
+     * <ul><li>ERA
+     * <li>YEAR
+     * <li>MONTH
+     * <li>DAY_OF_MONTH
+     * <li>DAY_OF_YEAR
+     * <li>EXTENDED_YEAR</ul>
+     *
+     * <p>The GregorianCalendar implementation implements
+     * a calendar with the specified Julian/Gregorian cutover date.
+     * @internal
+     */
+    virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
+
+ private:
+    /**
+     * Compute the julian day number of the given year.
+     * @param isGregorian    if true, using Gregorian calendar, otherwise using Julian calendar
+     * @param year           the given year.
+     * @param isLeap         true if the year is a leap year.       
+     * @return 
+     */
+    static double computeJulianDayOfYear(UBool isGregorian, int32_t year,
+                                         UBool& isLeap);
+    
+    /**
+     * Validates the values of the set time fields.  True if they're all valid.
+     * @return    True if the set time fields are all valid.
+     */
+    UBool validateFields(void) const;
+
+    /**
+     * Validates the value of the given time field.  True if it's valid.
+     */
+    UBool boundsCheck(int32_t value, UCalendarDateFields field) const;
+
+    /**
+     * Return the pseudo-time-stamp for two fields, given their
+     * individual pseudo-time-stamps.  If either of the fields
+     * is unset, then the aggregate is unset.  Otherwise, the
+     * aggregate is the later of the two stamps.
+     * @param stamp_a    One given field.
+     * @param stamp_b    Another given field.
+     * @return the pseudo-time-stamp for two fields
+     */
+    int32_t aggregateStamp(int32_t stamp_a, int32_t stamp_b);
+
+    /**
+     * The point at which the Gregorian calendar rules are used, measured in
+     * milliseconds from the standard epoch.  Default is October 15, 1582
+     * (Gregorian) 00:00:00 UTC, that is, October 4, 1582 (Julian) is followed
+     * by October 15, 1582 (Gregorian).  This corresponds to Julian day number
+     * 2299161. This is measured from the standard epoch, not in Julian Days.
+     * @internal
+     */
+    UDate                fGregorianCutover;
+
+    /**
+     * Julian day number of the Gregorian cutover
+     */
+    int32_t             fCutoverJulianDay;
+
+    /**
+     * Midnight, local time (using this Calendar's TimeZone) at or before the
+     * gregorianCutover. This is a pure date value with no time of day or
+     * timezone component.
+     */
+    UDate                 fNormalizedGregorianCutover;// = gregorianCutover;
+
+    /**
+     * The year of the gregorianCutover, with 0 representing
+     * 1 BC, -1 representing 2 BC, etc.
+     */
+    int32_t fGregorianCutoverYear;// = 1582;
+
+    /**
+     * The year of the gregorianCutover, with 0 representing
+     * 1 BC, -1 representing 2 BC, etc.
+     */
+    int32_t fGregorianCutoverJulianDay;// = 2299161;
+
+    /**
+     * Converts time as milliseconds to Julian date. The Julian date used here is not a
+     * true Julian date, since it is measured from midnight, not noon.
+     *
+     * @param millis  The given milliseconds.
+     * @return        The Julian date number.
+     */
+    static double millisToJulianDay(UDate millis);
+
+    /**
+     * Converts Julian date to time as milliseconds. The Julian date used here is not a
+     * true Julian date, since it is measured from midnight, not noon.
+     *
+     * @param julian  The given Julian date number.
+     * @return        Time as milliseconds.
+     */
+    static UDate julianDayToMillis(double julian);
+
+    /**
+     * Used by handleComputeJulianDay() and handleComputeMonthStart().
+     * Temporary field indicating whether the calendar is currently Gregorian as opposed to Julian.
+     */
+    UBool fIsGregorian;
+
+    /**
+     * Used by handleComputeJulianDay() and handleComputeMonthStart().
+     * Temporary field indicating that the sense of the gregorian cutover should be inverted
+     * to handle certain calculations on and around the cutover date.
+     */
+    UBool fInvertGregorian;
+
+
+ public: // internal implementation
+
+    /**
+     * @internal 
+     * @return TRUE if this calendar has the notion of a default century
+     */
+    virtual UBool haveDefaultCentury() const;
+
+    /**
+     * @internal
+     * @return the start of the default century
+     */
+    virtual UDate defaultCenturyStart() const;
+
+    /**
+     * @internal 
+     * @return the beginning year of the default century
+     */
+    virtual int32_t defaultCenturyStartYear() const;
+
+ private:
+    /**
+     * The system maintains a static default century start date.  This is initialized
+     * the first time it is used.  Before then, it is set to SYSTEM_DEFAULT_CENTURY to
+     * indicate an uninitialized state.  Once the system default century date and year
+     * are set, they do not change.
+     */
+    static UDate         fgSystemDefaultCenturyStart;
+
+    /**
+     * See documentation for systemDefaultCenturyStart.
+     */
+    static int32_t          fgSystemDefaultCenturyStartYear;
+
+    /**
+     * Default value that indicates the defaultCenturyStartYear is unitialized
+     */
+    static const int32_t    fgSystemDefaultCenturyYear;
+
+    /**
+     * Default value that indicates the UDate of the beginning of the system default century
+     */
+    static const UDate        fgSystemDefaultCentury;
+
+    /**
+     * Returns the beginning date of the 100-year window that dates with 2-digit years
+     * are considered to fall within.
+     * @return    the beginning date of the 100-year window that dates with 2-digit years
+     *            are considered to fall within.
+     */
+    UDate         internalGetDefaultCenturyStart(void) const;
+
+    /**
+     * Returns the first year of the 100-year window that dates with 2-digit years
+     * are considered to fall within.
+     * @return    the first year of the 100-year window that dates with 2-digit years
+     *            are considered to fall within.
+     */
+    int32_t          internalGetDefaultCenturyStartYear(void) const;
+
+    /**
+     * Initializes the 100-year window that dates with 2-digit years are considered
+     * to fall within so that its start date is 80 years before the current time.
+     */
+    static void  initializeSystemDefaultCentury(void);
+
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _GREGOCAL
+//eof
+
diff --git a/CoreFoundation/icu/unicode/locid.h b/CoreFoundation/icu/unicode/locid.h
new file mode 100644
index 0000000..a3cc23b
--- /dev/null
+++ b/CoreFoundation/icu/unicode/locid.h
@@ -0,0 +1,765 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1996-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File locid.h
+*
+* Created by: Helena Shih
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/11/97    aliu        Changed gLocPath to fgLocPath and added methods to
+*                           get and set it.
+*   04/02/97    aliu        Made operator!= inline; fixed return value of getName().
+*   04/15/97    aliu        Cleanup for AIX/Win32.
+*   04/24/97    aliu        Numerous changes per code review.
+*   08/18/98    stephen     Added tokenizeString(),changed getDisplayName()
+*   09/08/98    stephen     Moved definition of kEmptyString for Mac Port
+*   11/09/99    weiv        Added const char * getName() const;
+*   04/12/00    srl         removing unicodestring api's and cached hash code
+*   08/10/01    grhoten     Change the static Locales to accessor functions
+******************************************************************************
+*/
+
+#ifndef LOCID_H
+#define LOCID_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/putil.h"
+#include "unicode/uloc.h"
+#include "unicode/strenum.h"
+
+/**
+ * \file
+ * \brief C++ API: Locale ID object.
+ */
+
+/**
+ * A <code>Locale</code> object represents a specific geographical, political,
+ * or cultural region. An operation that requires a <code>Locale</code> to perform
+ * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>
+ * to tailor information for the user. For example, displaying a number
+ * is a locale-sensitive operation--the number should be formatted
+ * according to the customs/conventions of the user's native country,
+ * region, or culture.
+ *
+ * The Locale class is not suitable for subclassing.
+ *
+ * <P>
+ * You can create a <code>Locale</code> object using the constructor in
+ * this class:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ *       Locale( const   char*  language,
+ *               const   char*  country,
+ *               const   char*  variant);
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * The first argument to the constructors is a valid <STRONG>ISO
+ * Language Code.</STRONG> These codes are the lower-case two-letter
+ * codes as defined by ISO-639.
+ * You can find a full list of these codes at:
+ * <BR><a href ="http://www.loc.gov/standards/iso639-2/">
+ * http://www.loc.gov/standards/iso639-2/</a>
+ *
+ * <P>
+ * The second argument to the constructors is a valid <STRONG>ISO Country
+ * Code.</STRONG> These codes are the upper-case two-letter codes
+ * as defined by ISO-3166.
+ * You can find a full list of these codes at a number of sites, such as:
+ * <BR><a href="http://www.iso.org/iso/en/prods-services/iso3166ma/index.html">
+ * http://www.iso.org/iso/en/prods-services/iso3166ma/index.html</a>
+ *
+ * <P>
+ * The third constructor requires a third argument--the <STRONG>Variant.</STRONG>
+ * The Variant codes are vendor and browser-specific.
+ * For example, use REVISED for a langauge's revised script orthography, and POSIX for POSIX.
+ * Where there are two variants, separate them with an underscore, and
+ * put the most important one first. For
+ * example, a Traditional Spanish collation might be referenced, with
+ * "ES", "ES", "Traditional_POSIX".
+ *
+ * <P>
+ * Because a <code>Locale</code> object is just an identifier for a region,
+ * no validity check is performed when you construct a <code>Locale</code>.
+ * If you want to see whether particular resources are available for the
+ * <code>Locale</code> you construct, you must query those resources. For
+ * example, ask the <code>NumberFormat</code> for the locales it supports
+ * using its <code>getAvailableLocales</code> method.
+ * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular
+ * locale, you get back the best available match, not necessarily
+ * precisely what you asked for. For more information, look at
+ * <code>ResourceBundle</code>.
+ *
+ * <P>
+ * The <code>Locale</code> class provides a number of convenient constants
+ * that you can use to create <code>Locale</code> objects for commonly used
+ * locales. For example, the following refers to a <code>Locale</code> object
+ * for the United States:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ *       Locale::getUS()
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <P>
+ * Once you've created a <code>Locale</code> you can query it for information about
+ * itself. Use <code>getCountry</code> to get the ISO Country Code and
+ * <code>getLanguage</code> to get the ISO Language Code. You can
+ * use <code>getDisplayCountry</code> to get the
+ * name of the country suitable for displaying to the user. Similarly,
+ * you can use <code>getDisplayLanguage</code> to get the name of
+ * the language suitable for displaying to the user. Interestingly,
+ * the <code>getDisplayXXX</code> methods are themselves locale-sensitive
+ * and have two versions: one that uses the default locale and one
+ * that takes a locale as an argument and displays the name or country in
+ * a language appropriate to that locale.
+ *
+ * <P>
+ * ICU provides a number of classes that perform locale-sensitive
+ * operations. For example, the <code>NumberFormat</code> class formats
+ * numbers, currency, or percentages in a locale-sensitive manner. Classes
+ * such as <code>NumberFormat</code> have a number of convenience methods
+ * for creating a default object of that type. For example, the
+ * <code>NumberFormat</code> class provides these three convenience methods
+ * for creating a default <code>NumberFormat</code> object:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     Locale myLocale;
+ *     NumberFormat *nf;
+ *
+ *     nf = NumberFormat::createInstance( success );          delete nf;
+ *     nf = NumberFormat::createCurrencyInstance( success );  delete nf;
+ *     nf = NumberFormat::createPercentInstance( success );   delete nf;
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * Each of these methods has two variants; one with an explicit locale
+ * and one without; the latter using the default locale.
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ *     nf = NumberFormat::createInstance( myLocale, success );          delete nf;
+ *     nf = NumberFormat::createCurrencyInstance( myLocale, success );  delete nf;
+ *     nf = NumberFormat::createPercentInstance( myLocale, success );   delete nf;
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * A <code>Locale</code> is the mechanism for identifying the kind of object
+ * (<code>NumberFormat</code>) that you would like to get. The locale is
+ * <STRONG>just</STRONG> a mechanism for identifying objects,
+ * <STRONG>not</STRONG> a container for the objects themselves.
+ *
+ * <P>
+ * Each class that performs locale-sensitive operations allows you
+ * to get all the available objects of that type. You can sift
+ * through these objects by language, country, or variant,
+ * and use the display names to present a menu to the user.
+ * For example, you can create a menu of all the collation objects
+ * suitable for a given language. Such classes implement these
+ * three class methods:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ *       static Locale* getAvailableLocales(int32_t& numLocales)
+ *       static UnicodeString& getDisplayName(const Locale&  objectLocale,
+ *                                            const Locale&  displayLocale,
+ *                                            UnicodeString& displayName)
+ *       static UnicodeString& getDisplayName(const Locale&  objectLocale,
+ *                                            UnicodeString& displayName)
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * @stable ICU 2.0
+ * @see ResourceBundle
+ */
+U_NAMESPACE_BEGIN
+class U_COMMON_API Locale : public UObject {
+public:
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getEnglish(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getFrench(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getGerman(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getItalian(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getJapanese(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getKorean(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getChinese(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getSimplifiedChinese(void);
+    /** Useful constant for this language. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getTraditionalChinese(void);
+
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getFrance(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getGermany(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getItaly(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getJapan(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getKorea(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getChina(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getPRC(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getTaiwan(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getUK(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getUS(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getCanada(void);
+    /** Useful constant for this country/region. @stable ICU 2.0 */
+    static const Locale &U_EXPORT2 getCanadaFrench(void);
+
+
+    /**
+     * Construct a default locale object, a Locale for the default locale ID.
+     *
+     * @see getDefault
+     * @see uloc_getDefault
+     * @stable ICU 2.0
+     */
+    Locale();
+
+    /**
+     * Construct a locale from language, country, variant.
+     * If an error occurs, then the constructed object will be "bogus"
+     * (isBogus() will return TRUE).
+     *
+     * @param language Lowercase two-letter or three-letter ISO-639 code.
+     *  This parameter can instead be an ICU style C locale (e.g. "en_US"),
+     *  but the other parameters must not be used.
+     *  This parameter can be NULL; if so,
+     *  the locale is initialized to match the current default locale.
+     *  (This is the same as using the default constructor.)
+     *  Please note: The Java Locale class does NOT accept the form
+     *  'new Locale("en_US")' but only 'new Locale("en","US")'
+     *
+     * @param country  Uppercase two-letter ISO-3166 code. (optional)
+     * @param variant  Uppercase vendor and browser specific code. See class
+     *                 description. (optional)
+     * @param keywordsAndValues A string consisting of keyword/values pairs, such as
+     *                 "collation=phonebook;currency=euro"
+     *
+     * @see getDefault
+     * @see uloc_getDefault
+     * @stable ICU 2.0
+     */
+    Locale( const   char * language,
+            const   char * country  = 0,
+            const   char * variant  = 0,
+            const   char * keywordsAndValues = 0);
+
+    /**
+     * Initializes a Locale object from another Locale object.
+     *
+     * @param other The Locale object being copied in.
+     * @stable ICU 2.0
+     */
+    Locale(const    Locale& other);
+
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~Locale() ;
+
+    /**
+     * Replaces the entire contents of *this with the specified value.
+     *
+     * @param other The Locale object being copied in.
+     * @return      *this
+     * @stable ICU 2.0
+     */
+    Locale& operator=(const Locale& other);
+
+    /**
+     * Checks if two locale keys are the same.
+     *
+     * @param other The locale key object to be compared with this.
+     * @return      True if the two locale keys are the same, false otherwise.
+     * @stable ICU 2.0
+     */
+    UBool   operator==(const    Locale&     other) const;
+
+    /**
+     * Checks if two locale keys are not the same.
+     *
+     * @param other The locale key object to be compared with this.
+     * @return      True if the two locale keys are not the same, false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    UBool   operator!=(const    Locale&     other) const;
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    Locale *clone() const;
+
+    /**
+     * Common methods of getting the current default Locale. Used for the
+     * presentation: menus, dialogs, etc. Generally set once when your applet or
+     * application is initialized, then never reset. (If you do reset the
+     * default locale, you probably want to reload your GUI, so that the change
+     * is reflected in your interface.)
+     *
+     * More advanced programs will allow users to use different locales for
+     * different fields, e.g. in a spreadsheet.
+     *
+     * Note that the initial setting will match the host system.
+     * @return a reference to the Locale object for the default locale ID
+     * @system
+     * @stable ICU 2.0
+     */
+    static const Locale& U_EXPORT2 getDefault(void);
+
+    /**
+     * Sets the default. Normally set once at the beginning of a process,
+     * then never reset.
+     * setDefault() only changes ICU's default locale ID, <strong>not</strong>
+     * the default locale ID of the runtime environment.
+     *
+     * @param newLocale Locale to set to.  If NULL, set to the value obtained
+     *                  from the runtime environement.
+     * @param success The error code.
+     * @system
+     * @stable ICU 2.0
+     */
+    static void U_EXPORT2 setDefault(const Locale& newLocale,
+                                     UErrorCode&   success);
+
+    /**
+     * Creates a locale which has had minimal canonicalization
+     * as per uloc_getName().
+     * @param name The name to create from.  If name is null,
+     *  the default Locale is used.
+     * @return new locale object
+     * @stable ICU 2.0
+     * @see uloc_getName
+     */
+    static Locale U_EXPORT2 createFromName(const char *name);
+
+    /**
+     * Creates a locale from the given string after canonicalizing
+     * the string by calling uloc_canonicalize().
+     * @param name the locale ID to create from.  Must not be NULL.
+     * @return a new locale object corresponding to the given name
+     * @stable ICU 3.0
+     * @see uloc_canonicalize
+     */
+    static Locale U_EXPORT2 createCanonical(const char* name);
+
+    /**
+     * Returns the locale's ISO-639 language code.
+     * @return      An alias to the code
+     * @stable ICU 2.0
+     */
+    inline const char *  getLanguage( ) const;
+
+    /**
+     * Returns the locale's ISO-15924 abbreviation script code.
+     * @return      An alias to the code
+     * @see uscript_getShortName
+     * @see uscript_getCode
+     * @stable ICU 2.8
+     */
+    inline const char *  getScript( ) const;
+
+    /**
+     * Returns the locale's ISO-3166 country code.
+     * @return      An alias to the code
+     * @stable ICU 2.0
+     */
+    inline const char *  getCountry( ) const;
+
+    /**
+     * Returns the locale's variant code.
+     * @return      An alias to the code
+     * @stable ICU 2.0
+     */
+    inline const char *  getVariant( ) const;
+
+    /**
+     * Returns the programmatic name of the entire locale, with the language,
+     * country and variant separated by underbars. If a field is missing, up
+     * to two leading underbars will occur. Example: "en", "de_DE", "en_US_WIN",
+     * "de__POSIX", "fr__MAC", "__MAC", "_MT", "_FR_EURO"
+     * @return      A pointer to "name".
+     * @stable ICU 2.0
+     */
+    inline const char * getName() const;
+
+    /**
+     * Returns the programmatic name of the entire locale as getName would return,
+     * but without keywords.
+     * @return      A pointer to "name".
+     * @see getName
+     * @stable ICU 2.8
+     */
+    const char * getBaseName() const;
+
+
+    /**
+     * Gets the list of keywords for the specified locale.
+     *
+     * @return pointer to StringEnumeration class. Client must dispose of it by calling delete.
+     * @param status Returns any error information while performing this operation.
+     * @stable ICU 2.8
+     */
+    StringEnumeration * createKeywords(UErrorCode &status) const;
+
+    /**
+     * Get the value for a keyword.
+     *
+     * @param keywordName name of the keyword for which we want the value. Case insensitive.
+     * @param status Returns any error information while performing this operation.
+     * @param buffer The buffer to receive the keyword value.
+     * @param bufferCapacity The capacity of receiving buffer
+     * @return the length of keyword value
+     *
+     * @stable ICU 2.8
+     */
+    int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
+
+    /**
+     * returns the locale's three-letter language code, as specified
+     * in ISO draft standard ISO-639-2.
+     * @return      An alias to the code, or NULL
+     * @stable ICU 2.0
+     */
+    const char * getISO3Language() const;
+
+    /**
+     * Fills in "name" with the locale's three-letter ISO-3166 country code.
+     * @return      An alias to the code, or NULL
+     * @stable ICU 2.0
+     */
+    const char * getISO3Country() const;
+
+    /**
+     * Returns the Windows LCID value corresponding to this locale.
+     * This value is stored in the resource data for the locale as a one-to-four-digit
+     * hexadecimal number.  If the resource is missing, in the wrong format, or
+     * there is no Windows LCID value that corresponds to this locale, returns 0.
+     * @stable ICU 2.0
+     */
+    uint32_t        getLCID(void) const;
+
+    /**
+     * Fills in "dispLang" with the name of this locale's language in a format suitable for
+     * user display in the default locale.  For example, if the locale's language code is
+     * "fr" and the default locale's language code is "en", this function would set
+     * dispLang to "French".
+     * @param dispLang  Receives the language's display name.
+     * @return          A reference to "dispLang".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
+
+    /**
+     * Fills in "dispLang" with the name of this locale's language in a format suitable for
+     * user display in the locale specified by "displayLocale".  For example, if the locale's
+     * language code is "en" and displayLocale's language code is "fr", this function would set
+     * dispLang to "Anglais".
+     * @param displayLocale  Specifies the locale to be used to display the name.  In other words,
+     *                  if the locale's language code is "en", passing Locale::getFrench() for
+     *                  displayLocale would result in "Anglais", while passing Locale::getGerman()
+     *                  for displayLocale would result in "Englisch".
+     * @param dispLang  Receives the language's display name.
+     * @return          A reference to "dispLang".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayLanguage( const   Locale&         displayLocale,
+                                                UnicodeString&  dispLang) const;
+
+    /**
+     * Fills in "dispScript" with the name of this locale's script in a format suitable
+     * for user display in the default locale.  For example, if the locale's script code
+     * is "LATN" and the default locale's language code is "en", this function would set
+     * dispScript to "Latin".
+     * @param dispScript    Receives the scripts's display name.
+     * @return              A reference to "dispScript".
+     * @stable ICU 2.8
+     */
+    UnicodeString&  getDisplayScript(          UnicodeString& dispScript) const;
+
+    /**
+     * Fills in "dispScript" with the name of this locale's country in a format suitable
+     * for user display in the locale specified by "displayLocale".  For example, if the locale's
+     * script code is "LATN" and displayLocale's language code is "en", this function would set
+     * dispScript to "Latin".
+     * @param displayLocale      Specifies the locale to be used to display the name.  In other
+     *                      words, if the locale's script code is "LATN", passing
+     *                      Locale::getFrench() for displayLocale would result in "", while
+     *                      passing Locale::getGerman() for displayLocale would result in
+     *                      "".
+     * @param dispScript    Receives the scripts's display name.
+     * @return              A reference to "dispScript".
+     * @stable ICU 2.8
+     */
+    UnicodeString&  getDisplayScript(  const   Locale&         displayLocale,
+                                               UnicodeString&  dispScript) const;
+
+    /**
+     * Fills in "dispCountry" with the name of this locale's country in a format suitable
+     * for user display in the default locale.  For example, if the locale's country code
+     * is "FR" and the default locale's language code is "en", this function would set
+     * dispCountry to "France".
+     * @param dispCountry   Receives the country's display name.
+     * @return              A reference to "dispCountry".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
+
+    /**
+     * Fills in "dispCountry" with the name of this locale's country in a format suitable
+     * for user display in the locale specified by "displayLocale".  For example, if the locale's
+     * country code is "US" and displayLocale's language code is "fr", this function would set
+     * dispCountry to "&Eacute;tats-Unis".
+     * @param displayLocale      Specifies the locale to be used to display the name.  In other
+     *                      words, if the locale's country code is "US", passing
+     *                      Locale::getFrench() for displayLocale would result in "&Eacute;tats-Unis", while
+     *                      passing Locale::getGerman() for displayLocale would result in
+     *                      "Vereinigte Staaten".
+     * @param dispCountry   Receives the country's display name.
+     * @return              A reference to "dispCountry".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayCountry(  const   Locale&         displayLocale,
+                                                UnicodeString&  dispCountry) const;
+
+    /**
+     * Fills in "dispVar" with the name of this locale's variant code in a format suitable
+     * for user display in the default locale.
+     * @param dispVar   Receives the variant's name.
+     * @return          A reference to "dispVar".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
+
+    /**
+     * Fills in "dispVar" with the name of this locale's variant code in a format
+     * suitable for user display in the locale specified by "displayLocale".
+     * @param displayLocale  Specifies the locale to be used to display the name.
+     * @param dispVar   Receives the variant's display name.
+     * @return          A reference to "dispVar".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayVariant(  const   Locale&         displayLocale,
+                                                UnicodeString&  dispVar) const;
+
+    /**
+     * Fills in "name" with the name of this locale in a format suitable for user display
+     * in the default locale.  This function uses getDisplayLanguage(), getDisplayCountry(),
+     * and getDisplayVariant() to do its work, and outputs the display name in the format
+     * "language (country[,variant])".  For example, if the default locale is en_US, then
+     * fr_FR's display name would be "French (France)", and es_MX_Traditional's display name
+     * would be "Spanish (Mexico,Traditional)".
+     * @param name  Receives the locale's display name.
+     * @return      A reference to "name".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayName(         UnicodeString&  name) const;
+
+    /**
+     * Fills in "name" with the name of this locale in a format suitable for user display
+     * in the locale specfied by "displayLocale".  This function uses getDisplayLanguage(),
+     * getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display
+     * name in the format "language (country[,variant])".  For example, if displayLocale is
+     * fr_FR, then en_US's display name would be "Anglais (&Eacute;tats-Unis)", and no_NO_NY's
+     * display name would be "norv&eacute;gien (Norv&egrave;ge,NY)".
+     * @param displayLocale  Specifies the locale to be used to display the name.
+     * @param name      Receives the locale's display name.
+     * @return          A reference to "name".
+     * @stable ICU 2.0
+     */
+    UnicodeString&  getDisplayName( const   Locale&         displayLocale,
+                                            UnicodeString&  name) const;
+
+    /**
+     * Generates a hash code for the locale.
+     * @stable ICU 2.0
+     */
+    int32_t         hashCode(void) const;
+
+    /**
+     * Sets the locale to bogus
+     * A bogus locale represents a non-existing locale associated
+     * with services that can be instantiated from non-locale data
+     * in addition to locale (for example, collation can be
+     * instantiated from a locale and from a rule set).
+     * @stable ICU 2.1
+     */
+    void setToBogus();
+
+    /**
+     * Gets the bogus state. Locale object can be bogus if it doesn't exist
+     * @return FALSE if it is a real locale, TRUE if it is a bogus locale
+     * @stable ICU 2.1
+     */
+    UBool isBogus(void) const;
+
+    /**
+     * Returns a list of all installed locales.
+     * @param count Receives the number of locales in the list.
+     * @return      A pointer to an array of Locale objects.  This array is the list
+     *              of all locales with installed resource files.  The called does NOT
+     *              get ownership of this list, and must NOT delete it.
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+    /**
+     * Gets a list of all available 2-letter country codes defined in ISO 639.  This is a
+     * pointer to an array of pointers to arrays of char.  All of these pointers are
+     * owned by ICU-- do not delete them, and do not write through them.  The array is
+     * terminated with a null pointer.
+     * @return a list of all available country codes
+     * @stable ICU 2.0
+     */
+    static const char* const* U_EXPORT2 getISOCountries();
+
+    /**
+     * Gets a list of all available language codes defined in ISO 639.  This is a pointer
+     * to an array of pointers to arrays of char.  All of these pointers are owned
+     * by ICU-- do not delete them, and do not write through them.  The array is
+     * terminated with a null pointer.
+     * @return a list of all available language codes
+     * @stable ICU 2.0
+     */
+    static const char* const* U_EXPORT2 getISOLanguages();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+protected: /* only protected for testing purposes. DO NOT USE. */
+    /**
+     * Set this from a single POSIX style locale string.
+     * @internal
+     */
+    void setFromPOSIXID(const char *posixID);
+
+private:
+    /**
+     * Initialize the locale object with a new name.
+     * Was deprecated - used in implementation - moved internal
+     *
+     * @param cLocaleID The new locale name.
+     */
+    Locale& init(const char* cLocaleID, UBool canonicalize);
+
+    /*
+     * Internal constructor to allow construction of a locale object with
+     *   NO side effects.   (Default constructor tries to get
+     *   the default locale.)
+     */
+    enum ELocaleType {
+        eBOGUS
+    };
+    Locale(ELocaleType);
+
+    /**
+     * Initialize the locale cache for commonly used locales
+     */
+    static Locale *getLocaleCache(void);
+
+    char language[ULOC_LANG_CAPACITY];
+    char script[ULOC_SCRIPT_CAPACITY];
+    char country[ULOC_COUNTRY_CAPACITY];
+    int32_t variantBegin;
+    char* fullName;
+    char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
+    // name without keywords
+    char* baseName;
+    char baseNameBuffer[ULOC_FULLNAME_CAPACITY];
+
+    UBool fIsBogus;
+
+    static const Locale &getLocale(int locid);
+
+    /**
+     * A friend to allow the default locale to be set by either the C or C++ API.
+     * @internal
+     */
+    friend void locale_set_default_internal(const char *);
+};
+
+inline UBool
+Locale::operator!=(const    Locale&     other) const
+{
+    return !operator==(other);
+}
+
+inline const char *
+Locale::getCountry() const
+{
+    return country;
+}
+
+inline const char *
+Locale::getLanguage() const
+{
+    return language;
+}
+
+inline const char *
+Locale::getScript() const
+{
+    return script;
+}
+
+inline const char *
+Locale::getVariant() const
+{
+    return &fullName[variantBegin];
+}
+
+inline const char *
+Locale::getName() const
+{
+    return fullName;
+}
+
+inline UBool
+Locale::isBogus(void) const {
+    return fIsBogus;
+}
+
+U_NAMESPACE_END
+
+#endif
+
diff --git a/CoreFoundation/icu/unicode/measfmt.h b/CoreFoundation/icu/unicode/measfmt.h
new file mode 100644
index 0000000..a5af55e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/measfmt.h
@@ -0,0 +1,77 @@
+/*
+**********************************************************************
+* Copyright (c) 2004-2006, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: April 20, 2004
+* Since: ICU 3.0
+**********************************************************************
+*/
+#ifndef MEASUREFORMAT_H
+#define MEASUREFORMAT_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/format.h"
+
+/**
+ * \file 
+ * \brief C++ API: Formatter for measure objects.
+ */
+
+U_NAMESPACE_BEGIN
+
+/**
+ * 
+ * A formatter for measure objects.  This is an abstract base class.
+ *
+ * <p>To format or parse a measure object, first create a formatter
+ * object using a MeasureFormat factory method.  Then use that
+ * object's format and parse methods.
+ *
+ * <p>This is an abstract class.
+ *
+ * @see Format
+ * @author Alan Liu
+ * @stable ICU 3.0
+ */
+class U_I18N_API MeasureFormat : public Format {
+
+ public:
+
+    /**
+     * Return a formatter for CurrencyAmount objects in the given
+     * locale.
+     * @param locale desired locale
+     * @param ec input-output error code
+     * @return a formatter object, or NULL upon error
+     * @stable ICU 3.0
+     */
+    static MeasureFormat* U_EXPORT2 createCurrencyFormat(const Locale& locale,
+                                               UErrorCode& ec);
+
+    /**
+     * Return a formatter for CurrencyAmount objects in the default
+     * locale.
+     * @param ec input-output error code
+     * @return a formatter object, or NULL upon error
+     * @stable ICU 3.0
+     */
+    static MeasureFormat* U_EXPORT2 createCurrencyFormat(UErrorCode& ec);
+
+ protected:
+
+    /**
+     * Default constructor.
+     * @stable ICU 3.0
+     */
+    MeasureFormat();
+};
+
+U_NAMESPACE_END
+
+#endif // #if !UCONFIG_NO_FORMATTING
+#endif // #ifndef MEASUREFORMAT_H
diff --git a/CoreFoundation/icu/unicode/measunit.h b/CoreFoundation/icu/unicode/measunit.h
new file mode 100644
index 0000000..9a210e6
--- /dev/null
+++ b/CoreFoundation/icu/unicode/measunit.h
@@ -0,0 +1,71 @@
+/*
+**********************************************************************
+* Copyright (c) 2004-2006, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: April 26, 2004
+* Since: ICU 3.0
+**********************************************************************
+*/
+#ifndef __MEASUREUNIT_H__
+#define __MEASUREUNIT_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/fmtable.h"
+
+/**
+ * \file 
+ * \brief C++ API: A unit for measuring a quantity.
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * A unit such as length, mass, volume, currency, etc.  A unit is
+ * coupled with a numeric amount to produce a Measure.
+ *
+ * <p>This is an abstract class.
+ *
+ * @author Alan Liu
+ * @stable ICU 3.0
+ */
+class U_I18N_API MeasureUnit: public UObject {
+ public:
+    /**
+     * Return a polymorphic clone of this object.  The result will
+     * have the same class as returned by getDynamicClassID().
+     * @stable ICU 3.0
+     */
+    virtual UObject* clone() const = 0;
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~MeasureUnit();
+    
+    /**
+     * Equality operator.  Return true if this object is equal
+     * to the given object.
+     * @stable ICU 3.0
+     */
+    virtual UBool operator==(const UObject& other) const = 0;
+
+ protected:
+    /**
+     * Default constructor.
+     * @stable ICU 3.0
+     */
+    MeasureUnit();
+};
+
+U_NAMESPACE_END
+
+// NOTE: There is no measunit.cpp. For implementation, see measure.cpp. [alan]
+
+#endif // !UCONFIG_NO_FORMATTING
+#endif // __MEASUREUNIT_H__
diff --git a/CoreFoundation/icu/unicode/measure.h b/CoreFoundation/icu/unicode/measure.h
new file mode 100644
index 0000000..6b7a049
--- /dev/null
+++ b/CoreFoundation/icu/unicode/measure.h
@@ -0,0 +1,137 @@
+/*
+**********************************************************************
+* Copyright (c) 2004-2006, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: April 26, 2004
+* Since: ICU 3.0
+**********************************************************************
+*/
+#ifndef __MEASURE_H__
+#define __MEASURE_H__
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: MeasureUnit object.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/fmtable.h"
+
+U_NAMESPACE_BEGIN
+
+class MeasureUnit;
+
+/**
+ * An amount of a specified unit, consisting of a number and a Unit.
+ * For example, a length measure consists of a number and a length
+ * unit, such as feet or meters.  This is an abstract class.
+ * Subclasses specify a concrete Unit type.
+ *
+ * <p>Measure objects are parsed and formatted by subclasses of
+ * MeasureFormat.
+ *
+ * <p>Measure objects are immutable.
+ *
+ * <p>This is an abstract class.
+ *
+ * @author Alan Liu
+ * @stable ICU 3.0
+ */
+class U_I18N_API Measure: public UObject {
+ public:
+    /**
+     * Construct an object with the given numeric amount and the given
+     * unit.  After this call, the caller must not delete the given
+     * unit object.
+     * @param number a numeric object; amount.isNumeric() must be TRUE
+     * @param adoptedUnit the unit object, which must not be NULL
+     * @param ec input-output error code. If the amount or the unit
+     * is invalid, then this will be set to a failing value.
+     * @stable ICU 3.0
+     */
+    Measure(const Formattable& number, MeasureUnit* adoptedUnit,
+            UErrorCode& ec);
+
+    /**
+     * Copy constructor
+     * @stable ICU 3.0
+     */
+    Measure(const Measure& other);
+
+    /**
+     * Assignment operator
+     * @stable ICU 3.0
+     */
+    Measure& operator=(const Measure& other);
+
+    /**
+     * Return a polymorphic clone of this object.  The result will
+     * have the same class as returned by getDynamicClassID().
+     * @stable ICU 3.0
+     */
+    virtual UObject* clone() const = 0;
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~Measure();
+    
+    /**
+     * Equality operator.  Return true if this object is equal
+     * to the given object.
+     * @stable ICU 3.0
+     */
+    UBool operator==(const UObject& other) const;
+
+    /**
+     * Return a reference to the numeric value of this object.  The
+     * numeric value may be of any numeric type supported by
+     * Formattable.
+     * @stable ICU 3.0
+     */
+    inline const Formattable& getNumber() const;
+
+    /**
+     * Return a reference to the unit of this object.
+     * @stable ICU 3.0
+     */
+    inline const MeasureUnit& getUnit() const;
+
+ protected:
+    /**
+     * Default constructor.
+     * @stable ICU 3.0
+     */
+    Measure();
+
+ private:
+    /**
+     * The numeric value of this object, e.g. 2.54 or 100.
+     */
+    Formattable number;
+
+    /**
+     * The unit of this object, e.g., "millimeter" or "JPY".  This is
+     * owned by this object.
+     */
+    MeasureUnit* unit;
+};
+
+inline const Formattable& Measure::getNumber() const {
+    return number;
+}
+
+inline const MeasureUnit& Measure::getUnit() const {
+    return *unit;
+}
+
+U_NAMESPACE_END
+
+#endif // !UCONFIG_NO_FORMATTING
+#endif // __MEASURE_H__
diff --git a/CoreFoundation/icu/unicode/msgfmt.h b/CoreFoundation/icu/unicode/msgfmt.h
new file mode 100644
index 0000000..67e17cf
--- /dev/null
+++ b/CoreFoundation/icu/unicode/msgfmt.h
@@ -0,0 +1,940 @@
+/*
+* Copyright (C) 2007-2008, International Business Machines Corporation and others. All Rights Reserved.
+********************************************************************************
+*
+* File MSGFMT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/20/97    helena      Finished first cut of implementation.
+*   07/22/98    stephen     Removed operator!= (defined in Format)
+*   08/19/2002  srl         Removing Javaisms
+********************************************************************************
+*/
+
+#ifndef MSGFMT_H
+#define MSGFMT_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Formats messages in a language-neutral way.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/format.h"
+#include "unicode/locid.h"
+#include "unicode/parseerr.h"
+#include "unicode/uchar.h"
+
+U_NAMESPACE_BEGIN
+
+class NumberFormat;
+class DateFormat;
+
+/**
+ *
+ * A MessageFormat produces concatenated messages in a
+ * language-neutral way.  It should be used for all string
+ * concatenations that are visible to end users.
+ * <P>
+ * A MessageFormat contains an array of <EM>subformats</EM> arranged
+ * within a <EM>template string</EM>.  Together, the subformats and
+ * template string determine how the MessageFormat will operate during
+ * formatting and parsing.
+ * <P>
+ * Typically, both the subformats and the template string are
+ * specified at once in a <EM>pattern</EM>.  By using different
+ * patterns for different locales, messages may be localized.
+ * <P>
+ * During formatting, the MessageFormat takes an array of arguments
+ * and produces a user-readable string.  Each argument is a
+ * Formattable object; they may be passed in in an array, or as a
+ * single Formattable object which itself contains an array.  Each
+ * argument is matched up with its corresponding subformat, which then
+ * formats it into a string.  The resultant strings are then assembled
+ * within the string template of the MessageFormat to produce the
+ * final output string.
+ * <p>
+ * <strong>Note:</strong>
+ * In ICU 4.0 MessageFormat supports named arguments.  If a named argument
+ * is used, all arguments must be named.  Names start with a character in 
+ * <code>UCHAR_ID_START</code> and continue with characters in 
+ * <code>UCHARID_CONTINUE</code>, in particular they do not start with a digit.
+ * If named arguments are used, {@link #usesNamedArguments()} will return true.
+ * <p>
+ * The other new methods supporting named arguments are 
+ * {@link #getFormatNames(UErrorCode& status)},
+ * {@link #getFormat(const UnicodeString& formatName, UErrorCode& status)}
+ * {@link #setFormat(const UnicodeString& formatName, const Format& format, UErrorCode& status)},
+ * {@link #adoptFormat(const UnicodeString& formatName, Format* formatToAdopt, UErrorCode& status)},
+ * {@link #format(const Formattable* arguments, const UnicodeString *argumentNames, int32_t cnt, UnicodeString& appendTo, FieldPosition& status, int32_t recursionProtection, UErrorCode& success)},
+ * {@link #format(const UnicodeString* argumentNames, const Formattable* arguments, int32_t count, UnicodeString& appendTo,UErrorCode& status)}.
+ * These methods are all compatible with patterns that do not used named arguments-- 
+ * in these cases the keys in the input or output use <code>UnicodeString</code>s 
+ * that name the argument indices, e.g. "0", "1", "2"... etc.
+ * <p>
+ * When named arguments are used, certain methods on MessageFormat that take or
+ * return arrays do not perform any action, since it is not possible to
+ * identify positions in an array using a name.  UErrorCode is set to
+ * U_ARGUMENT_TYPE_MISMATCH if there is a status/success field in the method.
+ * These methods are 
+ * {@link #adoptFormats(Format** newFormats, int32_t count)},
+ * {@link #setFormats(const Format** newFormats,int32_t count)},
+ * {@link #adoptFormat(int32_t n, Format *newFormat)},
+ * {@link #getFormats(int32_t& cnt)},
+ * {@link #format(const Formattable* source,int32_t cnt,UnicodeString& appendTo, FieldPosition& ignore, UErrorCode& success)},
+ * {@link #format(const UnicodeString& pattern,const Formattable* arguments,int32_t cnt,UnicodeString& appendTo,UErrorCode& success)},
+ * {@link #format(const Formattable& source, UnicodeString& appendTo,FieldPosition& ignore, UErrorCode& success)},
+ * {@link #format(const Formattable* arguments, int32_t cnt, UnicodeString& appendTo, FieldPosition& status, int32_t recursionProtection,UErrorCode& success)},
+ * {@link #parse(const UnicodeString& source, ParsePosition& pos,int32_t& count)},
+ * {@link #parse(const UnicodeString& source, int32_t& cnt, UErrorCode& status)}
+ * <p>
+ *
+ * <P>
+ * During parsing, an input string is matched against the string
+ * template of the MessageFormat to produce an array of Formattable
+ * objects.  Plain text of the template string is matched directly
+ * against intput text.  At each position in the template string where
+ * a subformat is located, the subformat is called to parse the
+ * corresponding segment of input text to produce an output argument.
+ * In this way, an array of arguments is created which together
+ * constitute the parse result.
+ * <P>
+ * Parsing may fail or produce unexpected results in a number of
+ * circumstances.
+ * <UL>
+ * <LI>If one of the arguments does not occur in the pattern, it
+ * will be returned as a default Formattable.
+ * <LI>If the format of an argument is loses information, such as with
+ * a choice format where a large number formats to "many", then the
+ * parse may not correspond to the originally formatted argument.
+ * <LI>MessageFormat does not handle ChoiceFormat recursion during
+ * parsing; such parses will fail.
+ * <LI>Parsing will not always find a match (or the correct match) if
+ * some part of the parse is ambiguous.  For example, if the pattern
+ * "{1},{2}" is used with the string arguments {"a,b", "c"}, it will
+ * format as "a,b,c".  When the result is parsed, it will return {"a",
+ * "b,c"}.
+ * <LI>If a single argument is formatted more than once in the string,
+ * then the rightmost subformat in the pattern string will produce the
+ * parse result; prior subformats with the same argument index will
+ * have no effect.
+ * </UL>
+ * Here are some examples of usage:
+ * <P>
+ * Example 1:
+ * <pre>
+ * \code
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     GregorianCalendar cal(success);
+ *     Formattable arguments[] = {
+ *         7L,
+ *         Formattable( (Date) cal.getTime(success), Formattable::kIsDate),
+ *         "a disturbance in the Force"
+ *     };
+ *
+ *     UnicodeString result;
+ *     MessageFormat::format(
+ *          "At {1,time} on {1,date}, there was {2} on planet {0,number}.",
+ *          arguments, 3, result, success );
+ *
+ *     cout << "result: " << result << endl;
+ *     //<output>: At 4:34:20 PM on 23-Mar-98, there was a disturbance
+ *     //             in the Force on planet 7.
+ * \endcode
+ * </pre>
+ * Typically, the message format will come from resources, and the
+ * arguments will be dynamically set at runtime.
+ * <P>
+ * Example 2:
+ * <pre>
+ *  \code
+ *     success = U_ZERO_ERROR;
+ *     Formattable testArgs[] = {3L, "MyDisk"};
+ *
+ *     MessageFormat form(
+ *         "The disk \"{1}\" contains {0} file(s).", success );
+ *
+ *     UnicodeString string;
+ *     FieldPosition fpos = 0;
+ *     cout << "format: " << form.format(testArgs, 2, string, fpos, success ) << endl;
+ *
+ *     // output, with different testArgs:
+ *     // output: The disk "MyDisk" contains 0 file(s).
+ *     // output: The disk "MyDisk" contains 1 file(s).
+ *     // output: The disk "MyDisk" contains 1,273 file(s).
+ *  \endcode
+ *  </pre>
+ *
+ *  The pattern is of the following form.  Legend:
+ *  <pre>
+ * \code
+ *       {optional item}
+ *       (group that may be repeated)*
+ * \endcode
+ *  </pre>
+ *  Do not confuse optional items with items inside quotes braces, such
+ *  as this: "{".  Quoted braces are literals.
+ *  <pre>
+ *  \code
+ *       messageFormatPattern := string ( "{" messageFormatElement "}" string )*
+ *
+ *       messageFormatElement := argumentIndex | argumentName { "," elementFormat }
+ *
+ *       elementFormat := "time" { "," datetimeStyle }
+ *                      | "date" { "," datetimeStyle }
+ *                      | "number" { "," numberStyle }
+ *                      | "choice" "," choiceStyle
+ *
+ *       datetimeStyle := "short"
+ *                      | "medium"
+ *                      | "long"
+ *                      | "full"
+ *                      | dateFormatPattern
+ *
+ *       numberStyle :=   "currency"
+ *                      | "percent"
+ *                      | "integer"
+ *                      | numberFormatPattern
+ *
+ *       choiceStyle :=   choiceFormatPattern
+ * 
+ *       pluralStyle := pluralFormatPattern
+ * \endcode
+ * </pre>
+ * If there is no elementFormat, then the argument must be a string,
+ * which is substituted. If there is no dateTimeStyle or numberStyle,
+ * then the default format is used (e.g.  NumberFormat::createInstance(),
+ * DateFormat::createTimeInstance(DateFormat::kDefault, ...) or DateFormat::createDateInstance(DateFormat::kDefault, ...). For
+ * a ChoiceFormat, the pattern must always be specified, since there
+ * is no default.
+ * <P>
+ * In strings, single quotes can be used to quote syntax characters.
+ * A literal single quote is represented by '', both within and outside
+ * of single-quoted segments.  Inside a
+ * messageFormatElement, quotes are <EM>not</EM> removed. For example,
+ * {1,number,$'#',##} will produce a number format with the pound-sign
+ * quoted, with a result such as: "$#31,45".
+ * <P>
+ * If a pattern is used, then unquoted braces in the pattern, if any,
+ * must match: that is, "ab {0} de" and "ab '}' de" are ok, but "ab
+ * {0'}' de" and "ab } de" are not.
+ * <p>
+ * <dl><dt><b>Warning:</b><dd>The rules for using quotes within message
+ * format patterns unfortunately have shown to be somewhat confusing.
+ * In particular, it isn't always obvious to localizers whether single
+ * quotes need to be doubled or not. Make sure to inform localizers about
+ * the rules, and tell them (for example, by using comments in resource
+ * bundle source files) which strings will be processed by MessageFormat.
+ * Note that localizers may need to use single quotes in translated
+ * strings where the original version doesn't have them.
+ * <br>Note also that the simplest way to avoid the problem is to
+ * use the real apostrophe (single quote) character U+2019 (') for
+ * human-readable text, and to use the ASCII apostrophe (U+0027 ' )
+ * only in program syntax, like quoting in MessageFormat.
+ * See the annotations for U+0027 Apostrophe in The Unicode Standard.</p>
+ * </dl>
+ * <P>
+ * The argumentIndex is a non-negative integer, which corresponds to the
+ * index of the arguments presented in an array to be formatted.  The
+ * first argument has argumentIndex 0.
+ * <P>
+ * It is acceptable to have unused arguments in the array.  With missing
+ * arguments or arguments that are not of the right class for the
+ * specified format, a failing UErrorCode result is set.
+ * <P>
+ * For more sophisticated patterns, you can use a ChoiceFormat to get
+ * output:
+ * <pre>
+ * \code
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     MessageFormat* form("The disk \"{1}\" contains {0}.", success);
+ *     double filelimits[] = {0,1,2};
+ *     UnicodeString filepart[] = {"no files","one file","{0,number} files"};
+ *     ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3);
+ *     form.setFormat(1, *fileform); // NOT zero, see below
+ *
+ *     Formattable testArgs[] = {1273L, "MyDisk"};
+ *
+ *     UnicodeString string;
+ *     FieldPosition fpos = 0;
+ *     cout << form.format(testArgs, 2, string, fpos, success) << endl;
+ *
+ *     // output, with different testArgs
+ *     // output: The disk "MyDisk" contains no files.
+ *     // output: The disk "MyDisk" contains one file.
+ *     // output: The disk "MyDisk" contains 1,273 files.
+ * \endcode
+ * </pre>
+ * You can either do this programmatically, as in the above example,
+ * or by using a pattern (see ChoiceFormat for more information) as in:
+ * <pre>
+ * \code
+ *    form.applyPattern(
+ *      "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.");
+ * \endcode
+ * </pre>
+ * <P>
+ * <EM>Note:</EM> As we see above, the string produced by a ChoiceFormat in
+ * MessageFormat is treated specially; occurences of '{' are used to
+ * indicated subformats, and cause recursion.  If you create both a
+ * MessageFormat and ChoiceFormat programmatically (instead of using
+ * the string patterns), then be careful not to produce a format that
+ * recurses on itself, which will cause an infinite loop.
+ * <P>
+ * <EM>Note:</EM> Subformats are numbered by their order in the pattern.
+ * This is <EM>not</EM> the same as the argumentIndex.
+ * <pre>
+ * \code
+ *    For example: with "abc{2}def{3}ghi{0}...",
+ *
+ *    format0 affects the first variable {2}
+ *    format1 affects the second variable {3}
+ *    format2 affects the second variable {0}
+ * \endcode
+ * </pre>
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API MessageFormat : public Format {
+public:
+    /**
+     * Enum type for kMaxFormat.
+     * @obsolete ICU 3.0.  The 10-argument limit was removed as of ICU 2.6,
+     * rendering this enum type obsolete.
+     */
+    enum EFormatNumber {
+        /**
+         * The maximum number of arguments.
+         * @obsolete ICU 3.0.  The 10-argument limit was removed as of ICU 2.6,
+         * rendering this constant obsolete.
+         */
+        kMaxFormat = 10
+    };
+
+    /**
+     * Constructs a new MessageFormat using the given pattern and the
+     * default locale.
+     *
+     * @param pattern   Pattern used to construct object.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @stable ICU 2.0
+     */
+    MessageFormat(const UnicodeString& pattern,
+                  UErrorCode &status);
+
+    /**
+     * Constructs a new MessageFormat using the given pattern and locale.
+     * @param pattern   Pattern used to construct object.
+     * @param newLocale The locale to use for formatting dates and numbers.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @stable ICU 2.0
+     */
+    MessageFormat(const UnicodeString& pattern,
+                  const Locale& newLocale,
+                        UErrorCode& status);
+    /**
+     * Constructs a new MessageFormat using the given pattern and locale.
+     * @param pattern   Pattern used to construct object.
+     * @param newLocale The locale to use for formatting dates and numbers.
+     * @param parseError Struct to recieve information on position 
+     *                   of error within the pattern.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @stable ICU 2.0
+     */
+    MessageFormat(const UnicodeString& pattern,
+                  const Locale& newLocale,
+                  UParseError& parseError,
+                  UErrorCode& status);
+    /**
+     * Constructs a new MessageFormat from an existing one.
+     * @stable ICU 2.0
+     */
+    MessageFormat(const MessageFormat&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.0
+     */
+    const MessageFormat& operator=(const MessageFormat&);
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~MessageFormat();
+
+    /**
+     * Clones this Format object polymorphically.  The caller owns the
+     * result and should delete it when done.
+     * @stable ICU 2.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Returns true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     * @param other  the object to be compared with.
+     * @return       true if the given Format objects are semantically equal.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Sets the locale. This locale is used for fetching default number or date
+     * format information.
+     * @param theLocale    the new locale value to be set.
+     * @stable ICU 2.0
+     */
+    virtual void setLocale(const Locale& theLocale);
+
+    /**
+     * Gets the locale. This locale is used for fetching default number or date
+     * format information.
+     * @return    the locale of the object.
+     * @stable ICU 2.0
+     */
+    virtual const Locale& getLocale(void) const;
+
+    /**
+     * Applies the given pattern string to this message format.
+     *
+     * @param pattern   The pattern to be applied.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                              UErrorCode& status);
+    /**
+     * Applies the given pattern string to this message format.
+     *
+     * @param pattern    The pattern to be applied.
+     * @param parseError Struct to recieve information on position 
+     *                   of error within pattern.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern,
+                             UParseError& parseError,
+                             UErrorCode& status);
+
+    /**
+     * Returns a pattern that can be used to recreate this object.
+     *
+     * @param appendTo  Output parameter to receive the pattern.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toPattern(UnicodeString& appendTo) const;
+
+    /**
+     * Sets subformats.
+     * See the class description about format numbering.
+     * The caller should not delete the Format objects after this call.
+     * <EM>The array formatsToAdopt is not itself adopted.</EM> Its
+     * ownership is retained by the caller. If the call fails because
+     * memory cannot be allocated, then the formats will be deleted
+     * by this method, and this object will remain unchanged.
+     * 
+     * @stable ICU 2.0
+     * @param formatsToAdopt    the format to be adopted.
+     * @param count             the size of the array.
+     */
+    virtual void adoptFormats(Format** formatsToAdopt, int32_t count);
+
+    /**
+     * Sets subformats.
+     * See the class description about format numbering.
+     * Each item in the array is cloned into the internal array.
+     * If the call fails because memory cannot be allocated, then this
+     * object will remain unchanged.
+     * 
+     * @stable ICU 2.0
+     * @param newFormats the new format to be set.
+     * @param cnt        the size of the array.
+     */
+    virtual void setFormats(const Format** newFormats, int32_t cnt);
+
+
+    /**
+     * Sets one subformat.
+     * See the class description about format numbering.
+     * The caller should not delete the Format object after this call.
+     * If the number is over the number of formats already set,
+     * the item will be deleted and ignored.
+     * @stable ICU 2.0
+     * @param formatNumber     index of the subformat.
+     * @param formatToAdopt    the format to be adopted.
+     */
+    virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt);
+
+    /**
+     * Sets one subformat.
+     * See the class description about format numbering.
+     * If the number is over the number of formats already set,
+     * the item will be ignored.
+     * @param formatNumber     index of the subformat.
+     * @param format    the format to be set.
+     * @stable ICU 2.0
+     */
+    virtual void setFormat(int32_t formatNumber, const Format& format);
+
+    /**
+     * Gets format names. This function returns formatNames in StringEnumerations
+     * which can be used with getFormat() and setFormat() to export formattable 
+     * array from current MessageFormat to another.  It is caller's resposibility 
+     * to delete the returned formatNames.
+     * @param status  output param set to success/failure code.
+     * @draft ICU 4.0
+     */
+    virtual StringEnumeration* getFormatNames(UErrorCode& status);
+    
+    /**
+     * Gets subformat pointer for given format name.   
+     * This function supports both named and numbered
+     * arguments-- if numbered, the formatName is the
+     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
+     * The returned Format object should not be deleted by the caller,
+     * nor should the ponter of other object .  The pointer and its 
+     * contents remain valid only until the next call to any method
+     * of this class is made with this object. 
+     * @param formatName the name or number specifying a format
+     * @param status  output param set to success/failure code.
+     * @draft ICU 4.0
+     */
+    virtual Format* getFormat(const UnicodeString& formatName, UErrorCode& status);
+    
+    /**
+     * Sets one subformat for given format name.
+     * See the class description about format name. 
+     * This function supports both named and numbered
+     * arguments-- if numbered, the formatName is the
+     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
+     * If there is no matched formatName or wrong type,
+     * the item will be ignored.
+     * @param formatName  Name of the subformat.
+     * @param format      the format to be set.
+     * @param status  output param set to success/failure code.
+     * @draft ICU 4.0
+     */
+    virtual void setFormat(const UnicodeString& formatName, const Format& format, UErrorCode& status);
+    
+    /**
+     * Sets one subformat for given format name.
+     * See the class description about format name. 
+     * This function supports both named and numbered
+     * arguments-- if numbered, the formatName is the
+     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
+     * If there is no matched formatName or wrong type,
+     * the item will be ignored.
+     * The caller should not delete the Format object after this call.
+     * @param formatName  Name of the subformat.
+     * @param formatToAdopt  Format to be adopted.
+     * @param status      output param set to success/failure code.
+     * @draft ICU 4.0
+     */
+    virtual void adoptFormat(const UnicodeString& formatName, Format* formatToAdopt, UErrorCode& status);
+
+
+    /**
+     * Gets an array of subformats of this object.  The returned array
+     * should not be deleted by the caller, nor should the pointers
+     * within the array.  The array and its contents remain valid only
+     * until the next call to any method of this class is made with
+     * this object.  See the class description about format numbering.
+     * @param count output parameter to receive the size of the array
+     * @return an array of count Format* objects, or NULL if out of
+     * memory.  Any or all of the array elements may be NULL.
+     * @stable ICU 2.0
+     */
+    virtual const Format** getFormats(int32_t& count) const;
+
+    /**
+     * Formats the given array of arguments into a user-readable string.
+     * Does not take ownership of the Formattable* array or its contents.
+     *
+     * @param source    An array of objects to be formatted.
+     * @param count     The number of elements of 'source'.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param ignore    Not used; inherited from base class API.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(  const Formattable* source,
+                            int32_t count,
+                            UnicodeString& appendTo,
+                            FieldPosition& ignore,
+                            UErrorCode& status) const;
+
+    /**
+     * Formats the given array of arguments into a user-readable string
+     * using the given pattern.
+     *
+     * @param pattern   The pattern.
+     * @param arguments An array of objects to be formatted.
+     * @param count     The number of elements of 'source'.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    static UnicodeString& format(const UnicodeString& pattern,
+                                 const Formattable* arguments,
+                                 int32_t count,
+                                 UnicodeString& appendTo,
+                                 UErrorCode& status);
+
+    /**
+     * Formats the given array of arguments into a user-readable
+     * string.  The array must be stored within a single Formattable
+     * object of type kArray. If the Formattable object type is not of
+     * type kArray, then returns a failing UErrorCode.
+     *
+     * @param obj       A Formattable of type kArray containing
+     *                  arguments to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+    /**
+     * Formats the given array of arguments into a user-readable
+     * string.  The array must be stored within a single Formattable
+     * object of type kArray. If the Formattable object type is not of
+     * type kArray, then returns a failing UErrorCode.
+     *
+     * @param obj       The object to format
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+    
+
+    /**
+     * Formats the given array of arguments into a user-defined argument name
+     * array. This function supports both named and numbered
+     * arguments-- if numbered, the formatName is the
+     * corresponding UnicodeStrings (e.g. "0", "1", "2"...).
+     *
+     * @param argumentNames argument name array
+     * @param arguments An array of objects to be formatted.
+     * @param count     The number of elements of 'argumentNames' and 
+     *                  arguments.  The number of argumentNames and arguments
+     *                  must be the same.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 4.0
+     */
+    UnicodeString& format(const UnicodeString* argumentNames,
+                          const Formattable* arguments,
+                          int32_t count,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+    /**
+     * Parses the given string into an array of output arguments.
+     *
+     * @param source    String to be parsed.
+     * @param pos       On input, starting position for parse. On output,
+     *                  final position after parse.  Unchanged if parse
+     *                  fails.
+     * @param count     Output parameter to receive the number of arguments
+     *                  parsed.
+     * @return an array of parsed arguments.  The caller owns both
+     * the array and its contents.
+     * @stable ICU 2.0
+     */
+    virtual Formattable* parse( const UnicodeString& source,
+                                ParsePosition& pos,
+                                int32_t& count) const;
+
+    /**
+     * Parses the given string into an array of output arguments.
+     *
+     * @param source    String to be parsed.
+     * @param count     Output param to receive size of returned array.
+     * @param status    Input/output error code.  If the
+     *                  pattern cannot be parsed, set to failure code. 
+     *                  If the MessageFormat is named argument, the status is 
+     *                  set to U_ARGUMENT_TYPE_MISMATCH.
+     * @return an array of parsed arguments.  The caller owns both
+     * the array and its contents. Return NULL if status is not U_ZERO_ERROR.
+     * 
+     * @stable ICU 2.0
+     */
+    virtual Formattable* parse( const UnicodeString& source,
+                                int32_t& count,
+                                UErrorCode& status) const;
+
+    /**
+     * Parses the given string into an array of output arguments
+     * stored within a single Formattable of type kArray.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param pos       On input, starting position for parse. On output,
+     *                  final position after parse.  Unchanged if parse
+     *                  fails.
+     * @stable ICU 2.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& pos) const;
+
+    /**
+     * Convert an 'apostrophe-friendly' pattern into a standard
+     * pattern.  Standard patterns treat all apostrophes as
+     * quotes, which is problematic in some languages, e.g. 
+     * French, where apostrophe is commonly used.  This utility
+     * assumes that only an unpaired apostrophe immediately before
+     * a brace is a true quote.  Other unpaired apostrophes are paired,
+     * and the resulting standard pattern string is returned.
+     *
+     * <p><b>Note</b> it is not guaranteed that the returned pattern
+     * is indeed a valid pattern.  The only effect is to convert
+     * between patterns having different quoting semantics.
+     *
+     * @param pattern the 'apostrophe-friendly' patttern to convert
+     * @param status    Input/output error code.  If the pattern
+     *                  cannot be parsed, the failure code is set.
+     * @return the standard equivalent of the original pattern
+     * @stable ICU 3.4
+     */
+    static UnicodeString autoQuoteApostrophe(const UnicodeString& pattern, 
+        UErrorCode& status);
+    
+    /**
+     * Returns true if this MessageFormat uses named arguments,
+     * and false otherwise.  See class description.
+     *
+     * @return true if named arguments are used.
+     * @draft ICU 4.0
+     */
+    UBool usesNamedArguments() const;
+    
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .      Derived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+    
+private:
+
+    Locale              fLocale;
+    UnicodeString       fPattern;
+    Format**            formatAliases; // see getFormats
+    int32_t             formatAliasesCapacity;
+    UProperty           idStart;
+    UProperty           idContinue;
+
+    MessageFormat(); // default constructor not implemented
+
+    /*
+     * A structure representing one subformat of this MessageFormat.
+     * Each subformat has a Format object, an offset into the plain
+     * pattern text fPattern, and an argument number.  The argument
+     * number corresponds to the array of arguments to be formatted.
+     * @internal
+     */
+    class Subformat;
+
+    /**
+     * A MessageFormat contains an array of subformats.  This array
+     * needs to grow dynamically if the MessageFormat is modified.
+     */
+    Subformat* subformats;
+    int32_t    subformatCount;
+    int32_t    subformatCapacity;
+
+    /**
+     * A MessageFormat formats an array of arguments.  Each argument
+     * has an expected type, based on the pattern.  For example, if
+     * the pattern contains the subformat "{3,number,integer}", then
+     * we expect argument 3 to have type Formattable::kLong.  This
+     * array needs to grow dynamically if the MessageFormat is
+     * modified.
+     */
+    Formattable::Type* argTypes;
+    int32_t            argTypeCount;
+    int32_t            argTypeCapacity;
+
+    /**
+      * Is true iff all argument names are non-negative numbers.
+      * 
+      */
+    UBool isArgNumeric;
+
+    // Variable-size array management
+    UBool allocateSubformats(int32_t capacity);
+    UBool allocateArgTypes(int32_t capacity);
+
+    /**
+     * Default Format objects used when no format is specified and a
+     * numeric or date argument is formatted.  These are volatile
+     * cache objects maintained only for performance.  They do not
+     * participate in operator=(), copy constructor(), nor
+     * operator==().
+     */
+    NumberFormat* defaultNumberFormat;
+    DateFormat*   defaultDateFormat;
+
+    /**
+     * Method to retrieve default formats (or NULL on failure).
+     * These are semantically const, but may modify *this.
+     */
+    const NumberFormat* getDefaultNumberFormat(UErrorCode&) const;
+    const DateFormat*   getDefaultDateFormat(UErrorCode&) const;
+
+    /**
+     * Finds the word s, in the keyword list and returns the located index.
+     * @param s the keyword to be searched for.
+     * @param list the list of keywords to be searched with.
+     * @return the index of the list which matches the keyword s.
+     */
+    static int32_t findKeyword( const UnicodeString& s,
+                                const UChar * const *list);
+
+    /**
+     * Formats the array of arguments and copies the result into the
+     * result buffer, updates the field position.
+     *
+     * @param arguments The formattable objects array.
+     * @param cnt       The array count.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Field position status.
+     * @param recursionProtection
+     *                  Initially zero. Bits 0..9 are used to indicate
+     *                  that a parameter has already been seen, to
+     *                  avoid recursion.  Currently unused.
+     * @param success   The error code status.
+     * @return          Reference to 'appendTo' parameter.
+     */
+    UnicodeString&  format( const Formattable* arguments,
+                            int32_t cnt,
+                            UnicodeString& appendTo,
+                            FieldPosition& status,
+                            int32_t recursionProtection,
+                            UErrorCode& success) const;
+    
+    UnicodeString&  format( const Formattable* arguments, 
+                            const UnicodeString *argumentNames,
+                            int32_t cnt,
+                            UnicodeString& appendTo,
+                            FieldPosition& status,
+                            int32_t recursionProtection,
+                            UErrorCode& success) const;
+
+    void             makeFormat(int32_t offsetNumber,
+                                UnicodeString* segments,
+                                UParseError& parseError,
+                                UErrorCode& success);
+
+    /**
+     * Convenience method that ought to be in NumberFormat
+     */
+    NumberFormat* createIntegerFormat(const Locale& locale, UErrorCode& status) const;
+
+    /**
+     * Checks the range of the source text to quote the special
+     * characters, { and ' and copy to target buffer.
+     * @param source
+     * @param start the text offset to start the process of in the source string
+     * @param end the text offset to end the process of in the source string
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     */
+    static void copyAndFixQuotes(const UnicodeString& appendTo, int32_t start, int32_t end, UnicodeString& target);
+
+    /**
+     * Returns array of argument types in the parsed pattern 
+     * for use in C API.  Only for the use of umsg_vformat().  Not
+     * for public consumption.
+     * @param listCount  Output parameter to receive the size of array
+     * @return           The array of formattable types in the pattern
+     * @internal
+     */
+    const Formattable::Type* getArgTypeList(int32_t& listCount) const {
+        listCount = argTypeCount;
+        return argTypes; 
+    }
+    
+    /**
+     * Returns FALSE if the argument name is not legal.
+     * @param  argName   argument name.
+     * @return TRUE if the argument name is legal, otherwise return FALSE.
+     */
+    UBool isLegalArgName(const UnicodeString& argName) const;
+    
+    friend class MessageFormatAdapter; // getFormatTypeList() access
+};
+
+inline UnicodeString&
+MessageFormat::format(const Formattable& obj,
+                      UnicodeString& appendTo,
+                      UErrorCode& status) const {
+    return Format::format(obj, appendTo, status);
+}
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _MSGFMT
+//eof
+
diff --git a/CoreFoundation/icu/unicode/normlzr.h b/CoreFoundation/icu/unicode/normlzr.h
new file mode 100644
index 0000000..7974f1a
--- /dev/null
+++ b/CoreFoundation/icu/unicode/normlzr.h
@@ -0,0 +1,823 @@
+/*
+ ********************************************************************
+ * COPYRIGHT:
+ * Copyright (c) 1996-2006, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ ********************************************************************
+ */
+
+#ifndef NORMLZR_H
+#define NORMLZR_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Unicode Normalization
+ */
+ 
+#if !UCONFIG_NO_NORMALIZATION
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/chariter.h"
+#include "unicode/unorm.h"
+
+
+struct UCharIterator;
+typedef struct UCharIterator UCharIterator; /**< C typedef for struct UCharIterator. @stable ICU 2.1 */
+
+U_NAMESPACE_BEGIN
+/**
+ * The Normalizer class supports the standard normalization forms described in
+ * <a href="http://www.unicode.org/unicode/reports/tr15/" target="unicode">
+ * Unicode Standard Annex #15: Unicode Normalization Forms</a>.
+ *
+ * The Normalizer class consists of two parts:
+ * - static functions that normalize strings or test if strings are normalized
+ * - a Normalizer object is an iterator that takes any kind of text and
+ *   provides iteration over its normalized form
+ *
+ * The Normalizer class is not suitable for subclassing.
+ *
+ * The static functions are basically wrappers around the C implementation,
+ * using UnicodeString instead of UChar*.
+ * For basic information about normalization forms and details about the C API
+ * please see the documentation in unorm.h.
+ *
+ * The iterator API with the Normalizer constructors and the non-static functions
+ * uses a CharacterIterator as input. It is possible to pass a string which
+ * is then internally wrapped in a CharacterIterator.
+ * The input text is not normalized all at once, but incrementally where needed
+ * (providing efficient random access).
+ * This allows to pass in a large text but spend only a small amount of time
+ * normalizing a small part of that text.
+ * However, if the entire text is normalized, then the iterator will be
+ * slower than normalizing the entire text at once and iterating over the result.
+ * A possible use of the Normalizer iterator is also to report an index into the
+ * original text that is close to where the normalized characters come from.
+ *
+ * <em>Important:</em> The iterator API was cleaned up significantly for ICU 2.0.
+ * The earlier implementation reported the getIndex() inconsistently,
+ * and previous() could not be used after setIndex(), next(), first(), and current().
+ *
+ * Normalizer allows to start normalizing from anywhere in the input text by
+ * calling setIndexOnly(), first(), or last().
+ * Without calling any of these, the iterator will start at the beginning of the text.
+ *
+ * At any time, next() returns the next normalized code point (UChar32),
+ * with post-increment semantics (like CharacterIterator::next32PostInc()).
+ * previous() returns the previous normalized code point (UChar32),
+ * with pre-decrement semantics (like CharacterIterator::previous32()).
+ *
+ * current() returns the current code point
+ * (respectively the one at the newly set index) without moving
+ * the getIndex(). Note that if the text at the current position
+ * needs to be normalized, then these functions will do that.
+ * (This is why current() is not const.)
+ * It is more efficient to call setIndexOnly() instead, which does not
+ * normalize.
+ *
+ * getIndex() always refers to the position in the input text where the normalized
+ * code points are returned from. It does not always change with each returned
+ * code point.
+ * The code point that is returned from any of the functions
+ * corresponds to text at or after getIndex(), according to the
+ * function's iteration semantics (post-increment or pre-decrement).
+ *
+ * next() returns a code point from at or after the getIndex()
+ * from before the next() call. After the next() call, the getIndex()
+ * might have moved to where the next code point will be returned from
+ * (from a next() or current() call).
+ * This is semantically equivalent to array access with array[index++]
+ * (post-increment semantics).
+ *
+ * previous() returns a code point from at or after the getIndex()
+ * from after the previous() call.
+ * This is semantically equivalent to array access with array[--index]
+ * (pre-decrement semantics).
+ *
+ * Internally, the Normalizer iterator normalizes a small piece of text
+ * starting at the getIndex() and ending at a following "safe" index.
+ * The normalized results is stored in an internal string buffer, and
+ * the code points are iterated from there.
+ * With multiple iteration calls, this is repeated until the next piece
+ * of text needs to be normalized, and the getIndex() needs to be moved.
+ *
+ * The following "safe" index, the internal buffer, and the secondary
+ * iteration index into that buffer are not exposed on the API.
+ * This also means that it is currently not practical to return to
+ * a particular, arbitrary position in the text because one would need to
+ * know, and be able to set, in addition to the getIndex(), at least also the
+ * current index into the internal buffer.
+ * It is currently only possible to observe when getIndex() changes
+ * (with careful consideration of the iteration semantics),
+ * at which time the internal index will be 0.
+ * For example, if getIndex() is different after next() than before it,
+ * then the internal index is 0 and one can return to this getIndex()
+ * later with setIndexOnly().
+ *
+ * @author Laura Werner, Mark Davis, Markus Scherer
+ * @stable ICU 2.0
+ */
+class U_COMMON_API Normalizer : public UObject {
+public:
+  /**
+   * If DONE is returned from an iteration function that returns a code point,
+   * then there are no more normalization results available.
+   * @stable ICU 2.0
+   */
+  enum {
+      DONE=0xffff
+  };
+
+  // Constructors
+
+  /**
+   * Creates a new <code>Normalizer</code> object for iterating over the
+   * normalized form of a given string.
+   * <p>
+   * @param str   The string to be normalized.  The normalization
+   *              will start at the beginning of the string.
+   *
+   * @param mode  The normalization mode.
+   * @stable ICU 2.0
+   */
+  Normalizer(const UnicodeString& str, UNormalizationMode mode);
+
+  /**
+   * Creates a new <code>Normalizer</code> object for iterating over the
+   * normalized form of a given string.
+   * <p>
+   * @param str   The string to be normalized.  The normalization
+   *              will start at the beginning of the string.
+   *
+   * @param length Length of the string, or -1 if NUL-terminated.
+   * @param mode  The normalization mode.
+   * @stable ICU 2.0
+   */
+  Normalizer(const UChar* str, int32_t length, UNormalizationMode mode);
+
+  /**
+   * Creates a new <code>Normalizer</code> object for iterating over the
+   * normalized form of the given text.
+   * <p>
+   * @param iter  The input text to be normalized.  The normalization
+   *              will start at the beginning of the string.
+   *
+   * @param mode  The normalization mode.
+   * @stable ICU 2.0
+   */
+  Normalizer(const CharacterIterator& iter, UNormalizationMode mode);
+
+  /**
+   * Copy constructor.
+   * @param copy The object to be copied.
+   * @stable ICU 2.0
+   */
+  Normalizer(const Normalizer& copy);
+
+  /**
+   * Destructor
+   * @stable ICU 2.0
+   */
+  virtual ~Normalizer();
+
+
+  //-------------------------------------------------------------------------
+  // Static utility methods
+  //-------------------------------------------------------------------------
+
+  /**
+   * Normalizes a <code>UnicodeString</code> according to the specified normalization mode.
+   * This is a wrapper for unorm_normalize(), using UnicodeString's.
+   *
+   * The <code>options</code> parameter specifies which optional
+   * <code>Normalizer</code> features are to be enabled for this operation.
+   *
+   * @param source    the input string to be normalized.
+   * @param mode      the normalization mode
+   * @param options   the optional features to be enabled (0 for no options)
+   * @param result    The normalized string (on output).
+   * @param status    The error code.
+   * @stable ICU 2.0
+   */
+  static void U_EXPORT2 normalize(const UnicodeString& source,
+                        UNormalizationMode mode, int32_t options,
+                        UnicodeString& result,
+                        UErrorCode &status);
+
+  /**
+   * Compose a <code>UnicodeString</code>.
+   * This is equivalent to normalize() with mode UNORM_NFC or UNORM_NFKC.
+   * This is a wrapper for unorm_normalize(), using UnicodeString's.
+   *
+   * The <code>options</code> parameter specifies which optional
+   * <code>Normalizer</code> features are to be enabled for this operation.
+   *
+   * @param source    the string to be composed.
+   * @param compat    Perform compatibility decomposition before composition.
+   *                  If this argument is <code>FALSE</code>, only canonical
+   *                  decomposition will be performed.
+   * @param options   the optional features to be enabled (0 for no options)
+   * @param result    The composed string (on output).
+   * @param status    The error code.
+   * @stable ICU 2.0
+   */
+  static void U_EXPORT2 compose(const UnicodeString& source,
+                      UBool compat, int32_t options,
+                      UnicodeString& result,
+                      UErrorCode &status);
+
+  /**
+   * Static method to decompose a <code>UnicodeString</code>.
+   * This is equivalent to normalize() with mode UNORM_NFD or UNORM_NFKD.
+   * This is a wrapper for unorm_normalize(), using UnicodeString's.
+   *
+   * The <code>options</code> parameter specifies which optional
+   * <code>Normalizer</code> features are to be enabled for this operation.
+   *
+   * @param source    the string to be decomposed.
+   * @param compat    Perform compatibility decomposition.
+   *                  If this argument is <code>FALSE</code>, only canonical
+   *                  decomposition will be performed.
+   * @param options   the optional features to be enabled (0 for no options)
+   * @param result    The decomposed string (on output).
+   * @param status    The error code.
+   * @stable ICU 2.0
+   */
+  static void U_EXPORT2 decompose(const UnicodeString& source,
+                        UBool compat, int32_t options,
+                        UnicodeString& result,
+                        UErrorCode &status);
+
+  /**
+   * Performing quick check on a string, to quickly determine if the string is
+   * in a particular normalization format.
+   * This is a wrapper for unorm_quickCheck(), using a UnicodeString.
+   *
+   * Three types of result can be returned UNORM_YES, UNORM_NO or
+   * UNORM_MAYBE. Result UNORM_YES indicates that the argument
+   * string is in the desired normalized format, UNORM_NO determines that
+   * argument string is not in the desired normalized format. A
+   * UNORM_MAYBE result indicates that a more thorough check is required,
+   * the user may have to put the string in its normalized form and compare the
+   * results.
+   * @param source       string for determining if it is in a normalized format
+   * @param mode         normalization format
+   * @param status A reference to a UErrorCode to receive any errors
+   * @return UNORM_YES, UNORM_NO or UNORM_MAYBE
+   *
+   * @see isNormalized
+   * @stable ICU 2.0
+   */
+  static inline UNormalizationCheckResult
+  quickCheck(const UnicodeString &source, UNormalizationMode mode, UErrorCode &status);
+
+  /**
+   * Performing quick check on a string; same as the other version of quickCheck
+   * but takes an extra options parameter like most normalization functions.
+   *
+   * @param source       string for determining if it is in a normalized format
+   * @param mode         normalization format
+   * @param options      the optional features to be enabled (0 for no options)
+   * @param status A reference to a UErrorCode to receive any errors
+   * @return UNORM_YES, UNORM_NO or UNORM_MAYBE
+   *
+   * @see isNormalized
+   * @stable ICU 2.6
+   */
+  static inline UNormalizationCheckResult
+  quickCheck(const UnicodeString &source, UNormalizationMode mode, int32_t options, UErrorCode &status);
+
+  /**
+   * Test if a string is in a given normalization form.
+   * This is semantically equivalent to source.equals(normalize(source, mode)) .
+   *
+   * Unlike unorm_quickCheck(), this function returns a definitive result,
+   * never a "maybe".
+   * For NFD, NFKD, and FCD, both functions work exactly the same.
+   * For NFC and NFKC where quickCheck may return "maybe", this function will
+   * perform further tests to arrive at a TRUE/FALSE result.
+   *
+   * @param src        String that is to be tested if it is in a normalization format.
+   * @param mode       Which normalization form to test for.
+   * @param errorCode  ICU error code in/out parameter.
+   *                   Must fulfill U_SUCCESS before the function call.
+   * @return Boolean value indicating whether the source string is in the
+   *         "mode" normalization form.
+   *
+   * @see quickCheck
+   * @stable ICU 2.2
+   */
+  static inline UBool
+  isNormalized(const UnicodeString &src, UNormalizationMode mode, UErrorCode &errorCode);
+
+  /**
+   * Test if a string is in a given normalization form; same as the other version of isNormalized
+   * but takes an extra options parameter like most normalization functions.
+   *
+   * @param src        String that is to be tested if it is in a normalization format.
+   * @param mode       Which normalization form to test for.
+   * @param options      the optional features to be enabled (0 for no options)
+   * @param errorCode  ICU error code in/out parameter.
+   *                   Must fulfill U_SUCCESS before the function call.
+   * @return Boolean value indicating whether the source string is in the
+   *         "mode" normalization form.
+   *
+   * @see quickCheck
+   * @stable ICU 2.6
+   */
+  static inline UBool
+  isNormalized(const UnicodeString &src, UNormalizationMode mode, int32_t options, UErrorCode &errorCode);
+
+  /**
+   * Concatenate normalized strings, making sure that the result is normalized as well.
+   *
+   * If both the left and the right strings are in
+   * the normalization form according to "mode/options",
+   * then the result will be
+   *
+   * \code
+   *     dest=normalize(left+right, mode, options)
+   * \endcode
+   *
+   * For details see unorm_concatenate in unorm.h.
+   *
+   * @param left Left source string.
+   * @param right Right source string.
+   * @param result The output string.
+   * @param mode The normalization mode.
+   * @param options A bit set of normalization options.
+   * @param errorCode ICU error code in/out parameter.
+   *                   Must fulfill U_SUCCESS before the function call.
+   * @return result
+   *
+   * @see unorm_concatenate
+   * @see normalize
+   * @see unorm_next
+   * @see unorm_previous
+   *
+   * @stable ICU 2.1
+   */
+  static UnicodeString &
+  U_EXPORT2 concatenate(UnicodeString &left, UnicodeString &right,
+              UnicodeString &result,
+              UNormalizationMode mode, int32_t options,
+              UErrorCode &errorCode);
+
+  /**
+   * Compare two strings for canonical equivalence.
+   * Further options include case-insensitive comparison and
+   * code point order (as opposed to code unit order).
+   *
+   * Canonical equivalence between two strings is defined as their normalized
+   * forms (NFD or NFC) being identical.
+   * This function compares strings incrementally instead of normalizing
+   * (and optionally case-folding) both strings entirely,
+   * improving performance significantly.
+   *
+   * Bulk normalization is only necessary if the strings do not fulfill the FCD
+   * conditions. Only in this case, and only if the strings are relatively long,
+   * is memory allocated temporarily.
+   * For FCD strings and short non-FCD strings there is no memory allocation.
+   *
+   * Semantically, this is equivalent to
+   *   strcmp[CodePointOrder](NFD(foldCase(s1)), NFD(foldCase(s2)))
+   * where code point order and foldCase are all optional.
+   *
+   * UAX 21 2.5 Caseless Matching specifies that for a canonical caseless match
+   * the case folding must be performed first, then the normalization.
+   *
+   * @param s1 First source string.
+   * @param s2 Second source string.
+   *
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Case-sensitive comparison in code unit order, and the input strings
+   *     are quick-checked for FCD.
+   *
+   *   - UNORM_INPUT_IS_FCD
+   *     Set if the caller knows that both s1 and s2 fulfill the FCD conditions.
+   *     If not set, the function will quickCheck for FCD
+   *     and normalize if necessary.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_COMPARE_IGNORE_CASE
+   *     Set to compare strings case-insensitively using case folding,
+   *     instead of case-sensitively.
+   *     If set, then the following case folding options are used.
+   *
+   *   - Options as used with case-insensitive comparisons, currently:
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *    (see u_strCaseCompare for details)
+   *
+   *   - regular normalization options shifted left by UNORM_COMPARE_NORM_OPTIONS_SHIFT
+   *
+   * @param errorCode ICU error code in/out parameter.
+   *                  Must fulfill U_SUCCESS before the function call.
+   * @return <0 or 0 or >0 as usual for string comparisons
+   *
+   * @see unorm_compare
+   * @see normalize
+   * @see UNORM_FCD
+   * @see u_strCompare
+   * @see u_strCaseCompare
+   *
+   * @stable ICU 2.2
+   */
+  static inline int32_t
+  compare(const UnicodeString &s1, const UnicodeString &s2,
+          uint32_t options,
+          UErrorCode &errorCode);
+
+  //-------------------------------------------------------------------------
+  // Iteration API
+  //-------------------------------------------------------------------------
+
+  /**
+   * Return the current character in the normalized text.
+   * current() may need to normalize some text at getIndex().
+   * The getIndex() is not changed.
+   *
+   * @return the current normalized code point
+   * @stable ICU 2.0
+   */
+  UChar32              current(void);
+
+  /**
+   * Return the first character in the normalized text.
+   * This is equivalent to setIndexOnly(startIndex()) followed by next().
+   * (Post-increment semantics.)
+   *
+   * @return the first normalized code point
+   * @stable ICU 2.0
+   */
+  UChar32              first(void);
+
+  /**
+   * Return the last character in the normalized text.
+   * This is equivalent to setIndexOnly(endIndex()) followed by previous().
+   * (Pre-decrement semantics.)
+   *
+   * @return the last normalized code point
+   * @stable ICU 2.0
+   */
+  UChar32              last(void);
+
+  /**
+   * Return the next character in the normalized text.
+   * (Post-increment semantics.)
+   * If the end of the text has already been reached, DONE is returned.
+   * The DONE value could be confused with a U+FFFF non-character code point
+   * in the text. If this is possible, you can test getIndex()<endIndex()
+   * before calling next(), or (getIndex()<endIndex() || last()!=DONE)
+   * after calling next(). (Calling last() will change the iterator state!)
+   *
+   * The C API unorm_next() is more efficient and does not have this ambiguity.
+   *
+   * @return the next normalized code point
+   * @stable ICU 2.0
+   */
+  UChar32              next(void);
+
+  /**
+   * Return the previous character in the normalized text and decrement.
+   * (Pre-decrement semantics.)
+   * If the beginning of the text has already been reached, DONE is returned.
+   * The DONE value could be confused with a U+FFFF non-character code point
+   * in the text. If this is possible, you can test
+   * (getIndex()>startIndex() || first()!=DONE). (Calling first() will change
+   * the iterator state!)
+   *
+   * The C API unorm_previous() is more efficient and does not have this ambiguity.
+   *
+   * @return the previous normalized code point
+   * @stable ICU 2.0
+   */
+  UChar32              previous(void);
+
+  /**
+   * Set the iteration position in the input text that is being normalized,
+   * without any immediate normalization.
+   * After setIndexOnly(), getIndex() will return the same index that is
+   * specified here.
+   *
+   * @param index the desired index in the input text.
+   * @stable ICU 2.0
+   */
+  void                 setIndexOnly(int32_t index);
+
+  /**
+   * Reset the index to the beginning of the text.
+   * This is equivalent to setIndexOnly(startIndex)).
+   * @stable ICU 2.0
+   */
+  void                reset(void);
+
+  /**
+   * Retrieve the current iteration position in the input text that is
+   * being normalized.
+   *
+   * A following call to next() will return a normalized code point from
+   * the input text at or after this index.
+   *
+   * After a call to previous(), getIndex() will point at or before the
+   * position in the input text where the normalized code point
+   * was returned from with previous().
+   *
+   * @return the current index in the input text
+   * @stable ICU 2.0
+   */
+  int32_t            getIndex(void) const;
+
+  /**
+   * Retrieve the index of the start of the input text. This is the begin index
+   * of the <code>CharacterIterator</code> or the start (i.e. index 0) of the string
+   * over which this <code>Normalizer</code> is iterating.
+   *
+   * @return the smallest index in the input text where the Normalizer operates
+   * @stable ICU 2.0
+   */
+  int32_t            startIndex(void) const;
+
+  /**
+   * Retrieve the index of the end of the input text. This is the end index
+   * of the <code>CharacterIterator</code> or the length of the string
+   * over which this <code>Normalizer</code> is iterating.
+   * This end index is exclusive, i.e., the Normalizer operates only on characters
+   * before this index.
+   *
+   * @return the first index in the input text where the Normalizer does not operate
+   * @stable ICU 2.0
+   */
+  int32_t            endIndex(void) const;
+
+  /**
+   * Returns TRUE when both iterators refer to the same character in the same
+   * input text.
+   *
+   * @param that a Normalizer object to compare this one to
+   * @return comparison result
+   * @stable ICU 2.0
+   */
+  UBool        operator==(const Normalizer& that) const;
+
+  /**
+   * Returns FALSE when both iterators refer to the same character in the same
+   * input text.
+   *
+   * @param that a Normalizer object to compare this one to
+   * @return comparison result
+   * @stable ICU 2.0
+   */
+  inline UBool        operator!=(const Normalizer& that) const;
+
+  /**
+   * Returns a pointer to a new Normalizer that is a clone of this one.
+   * The caller is responsible for deleting the new clone.
+   * @return a pointer to a new Normalizer
+   * @stable ICU 2.0
+   */
+  Normalizer*        clone(void) const;
+
+  /**
+   * Generates a hash code for this iterator.
+   *
+   * @return the hash code
+   * @stable ICU 2.0
+   */
+  int32_t                hashCode(void) const;
+
+  //-------------------------------------------------------------------------
+  // Property access methods
+  //-------------------------------------------------------------------------
+
+  /**
+   * Set the normalization mode for this object.
+   * <p>
+   * <b>Note:</b>If the normalization mode is changed while iterating
+   * over a string, calls to {@link #next() } and {@link #previous() } may
+   * return previously buffers characters in the old normalization mode
+   * until the iteration is able to re-sync at the next base character.
+   * It is safest to call {@link #setIndexOnly }, {@link #reset() },
+   * {@link #setText }, {@link #first() },
+   * {@link #last() }, etc. after calling <code>setMode</code>.
+   * <p>
+   * @param newMode the new mode for this <code>Normalizer</code>.
+   * @see #getUMode
+   * @stable ICU 2.0
+   */
+  void setMode(UNormalizationMode newMode);
+
+  /**
+   * Return the normalization mode for this object.
+   *
+   * This is an unusual name because there used to be a getMode() that
+   * returned a different type.
+   *
+   * @return the mode for this <code>Normalizer</code>
+   * @see #setMode
+   * @stable ICU 2.0
+   */
+  UNormalizationMode getUMode(void) const;
+
+  /**
+   * Set options that affect this <code>Normalizer</code>'s operation.
+   * Options do not change the basic composition or decomposition operation
+   * that is being performed, but they control whether
+   * certain optional portions of the operation are done.
+   * Currently the only available option is obsolete.
+   *
+   * It is possible to specify multiple options that are all turned on or off.
+   *
+   * @param   option  the option(s) whose value is/are to be set.
+   * @param   value   the new setting for the option.  Use <code>TRUE</code> to
+   *                  turn the option(s) on and <code>FALSE</code> to turn it/them off.
+   *
+   * @see #getOption
+   * @stable ICU 2.0
+   */
+  void setOption(int32_t option,
+         UBool value);
+
+  /**
+   * Determine whether an option is turned on or off.
+   * If multiple options are specified, then the result is TRUE if any
+   * of them are set.
+   * <p>
+   * @param option the option(s) that are to be checked
+   * @return TRUE if any of the option(s) are set
+   * @see #setOption
+   * @stable ICU 2.0
+   */
+  UBool getOption(int32_t option) const;
+
+  /**
+   * Set the input text over which this <code>Normalizer</code> will iterate.
+   * The iteration position is set to the beginning.
+   *
+   * @param newText a string that replaces the current input text
+   * @param status a UErrorCode
+   * @stable ICU 2.0
+   */
+  void setText(const UnicodeString& newText,
+           UErrorCode &status);
+
+  /**
+   * Set the input text over which this <code>Normalizer</code> will iterate.
+   * The iteration position is set to the beginning.
+   *
+   * @param newText a CharacterIterator object that replaces the current input text
+   * @param status a UErrorCode
+   * @stable ICU 2.0
+   */
+  void setText(const CharacterIterator& newText,
+           UErrorCode &status);
+
+  /**
+   * Set the input text over which this <code>Normalizer</code> will iterate.
+   * The iteration position is set to the beginning.
+   *
+   * @param newText a string that replaces the current input text
+   * @param length the length of the string, or -1 if NUL-terminated
+   * @param status a UErrorCode
+   * @stable ICU 2.0
+   */
+  void setText(const UChar* newText,
+                    int32_t length,
+            UErrorCode &status);
+  /**
+   * Copies the input text into the UnicodeString argument.
+   *
+   * @param result Receives a copy of the text under iteration.
+   * @stable ICU 2.0
+   */
+  void            getText(UnicodeString&  result);
+
+  /**
+   * ICU "poor man's RTTI", returns a UClassID for this class.
+   * @returns a UClassID for this class.
+   * @stable ICU 2.2
+   */
+  static UClassID U_EXPORT2 getStaticClassID();
+
+  /**
+   * ICU "poor man's RTTI", returns a UClassID for the actual class.
+   * @return a UClassID for the actual class.
+   * @stable ICU 2.2
+   */
+  virtual UClassID getDynamicClassID() const;
+
+private:
+  //-------------------------------------------------------------------------
+  // Private functions
+  //-------------------------------------------------------------------------
+
+  Normalizer(); // default constructor not implemented
+  Normalizer &operator=(const Normalizer &that); // assignment operator not implemented
+
+  // Private utility methods for iteration
+  // For documentation, see the source code
+  UBool nextNormalize();
+  UBool previousNormalize();
+
+  void    init(CharacterIterator *iter);
+  void    clearBuffer(void);
+
+  //-------------------------------------------------------------------------
+  // Private data
+  //-------------------------------------------------------------------------
+
+  UNormalizationMode  fUMode;
+  int32_t             fOptions;
+
+  // The input text and our position in it
+  UCharIterator       *text;
+
+  // The normalization buffer is the result of normalization
+  // of the source in [currentIndex..nextIndex[ .
+  int32_t         currentIndex, nextIndex;
+
+  // A buffer for holding intermediate results
+  UnicodeString       buffer;
+  int32_t         bufferPos;
+
+};
+
+//-------------------------------------------------------------------------
+// Inline implementations
+//-------------------------------------------------------------------------
+
+inline UBool
+Normalizer::operator!= (const Normalizer& other) const
+{ return ! operator==(other); }
+
+inline UNormalizationCheckResult
+Normalizer::quickCheck(const UnicodeString& source,
+                       UNormalizationMode mode,
+                       UErrorCode &status) {
+    if(U_FAILURE(status)) {
+        return UNORM_MAYBE;
+    }
+
+    return unorm_quickCheck(source.getBuffer(), source.length(),
+                            mode, &status);
+}
+
+inline UNormalizationCheckResult
+Normalizer::quickCheck(const UnicodeString& source,
+                       UNormalizationMode mode, int32_t options,
+                       UErrorCode &status) {
+    if(U_FAILURE(status)) {
+        return UNORM_MAYBE;
+    }
+
+    return unorm_quickCheckWithOptions(source.getBuffer(), source.length(),
+                                       mode, options, &status);
+}
+
+inline UBool
+Normalizer::isNormalized(const UnicodeString& source,
+                         UNormalizationMode mode,
+                         UErrorCode &status) {
+    if(U_FAILURE(status)) {
+        return FALSE;
+    }
+
+    return unorm_isNormalized(source.getBuffer(), source.length(),
+                              mode, &status);
+}
+
+inline UBool
+Normalizer::isNormalized(const UnicodeString& source,
+                         UNormalizationMode mode, int32_t options,
+                         UErrorCode &status) {
+    if(U_FAILURE(status)) {
+        return FALSE;
+    }
+
+    return unorm_isNormalizedWithOptions(source.getBuffer(), source.length(),
+                                         mode, options, &status);
+}
+
+inline int32_t
+Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2,
+                    uint32_t options,
+                    UErrorCode &errorCode) {
+  // all argument checking is done in unorm_compare
+  return unorm_compare(s1.getBuffer(), s1.length(),
+                       s2.getBuffer(), s2.length(),
+                       options,
+                       &errorCode);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_NORMALIZATION */
+
+#endif // NORMLZR_H
diff --git a/CoreFoundation/icu/unicode/numfmt.h b/CoreFoundation/icu/unicode/numfmt.h
new file mode 100644
index 0000000..b27ed47
--- /dev/null
+++ b/CoreFoundation/icu/unicode/numfmt.h
@@ -0,0 +1,861 @@
+/*
+********************************************************************************
+* Copyright (C) 1997-2006, International Business Machines Corporation and others.
+* All Rights Reserved.
+********************************************************************************
+*
+* File NUMFMT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   03/18/97    clhuang     Updated per C++ implementation.
+*   04/17/97    aliu        Changed DigitCount to int per code review.
+*    07/20/98    stephen        JDK 1.2 sync up. Added scientific support.
+*                            Changed naming conventions to match C++ guidelines
+*                            Derecated Java style constants (eg, INTEGER_FIELD)
+********************************************************************************
+*/
+
+#ifndef NUMFMT_H
+#define NUMFMT_H
+
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Abstract base class for all number formats.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/unistr.h"
+#include "unicode/format.h"
+#include "unicode/unum.h" // UNumberFormatStyle
+#include "unicode/locid.h"
+
+U_NAMESPACE_BEGIN
+
+#if !UCONFIG_NO_SERVICE
+class NumberFormatFactory;
+class StringEnumeration;
+#endif
+
+/**
+ *
+ * Abstract base class for all number formats.  Provides interface for
+ * formatting and parsing a number.  Also provides methods for
+ * determining which locales have number formats, and what their names
+ * are.
+ * <P>
+ * NumberFormat helps you to format and parse numbers for any locale.
+ * Your code can be completely independent of the locale conventions
+ * for decimal points, thousands-separators, or even the particular
+ * decimal digits used, or whether the number format is even decimal.
+ * <P>
+ * To format a number for the current Locale, use one of the static
+ * factory methods:
+ * <pre>
+ * \code
+ *    double myNumber = 7.0;
+ *    UnicodeString myString;
+ *    UErrorCode success = U_ZERO_ERROR;
+ *    NumberFormat* nf = NumberFormat::createInstance(success)
+ *    nf->format(myNumber, myString);
+ *    cout << " Example 1: " << myString << endl;
+ * \endcode
+ * </pre>
+ * If you are formatting multiple numbers, it is more efficient to get
+ * the format and use it multiple times so that the system doesn't
+ * have to fetch the information about the local language and country
+ * conventions multiple times.
+ * <pre>
+ * \code
+ *     UnicodeString myString;
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     nf = NumberFormat::createInstance( success );
+ *     int32_t a[] = { 123, 3333, -1234567 };
+ *     const int32_t a_len = sizeof(a) / sizeof(a[0]);
+ *     myString.remove();
+ *     for (int32_t i = 0; i < a_len; i++) {
+ *         nf->format(a[i], myString);
+ *         myString += " ; ";
+ *     }
+ *     cout << " Example 2: " << myString << endl;
+ * \endcode
+ * </pre>
+ * To format a number for a different Locale, specify it in the
+ * call to createInstance().
+ * <pre>
+ * \code
+ *     nf = NumberFormat::createInstance( Locale::FRENCH, success );
+ * \endcode
+ * </pre>
+ * You can use a NumberFormat to parse also.
+ * <pre>
+ * \code
+ *    UErrorCode success;
+ *    Formattable result(-999);  // initialized with error code
+ *    nf->parse(myString, result, success);
+ * \endcode
+ * </pre>
+ * Use createInstance to get the normal number format for that country.
+ * There are other static factory methods available.  Use getCurrency
+ * to get the currency number format for that country.  Use getPercent
+ * to get a format for displaying percentages. With this format, a
+ * fraction from 0.53 is displayed as 53%.
+ * <P>
+ * You can also control the display of numbers with such methods as
+ * getMinimumFractionDigits.  If you want even more control over the
+ * format or parsing, or want to give your users more control, you can
+ * try casting the NumberFormat you get from the factory methods to a
+ * DecimalNumberFormat. This will work for the vast majority of
+ * countries; just remember to put it in a try block in case you
+ * encounter an unusual one.
+ * <P>
+ * You can also use forms of the parse and format methods with
+ * ParsePosition and FieldPosition to allow you to:
+ * <ul type=round>
+ *   <li>(a) progressively parse through pieces of a string.
+ *   <li>(b) align the decimal point and other areas.
+ * </ul>
+ * For example, you can align numbers in two ways.
+ * <P>
+ * If you are using a monospaced font with spacing for alignment, you
+ * can pass the FieldPosition in your format call, with field =
+ * INTEGER_FIELD. On output, getEndIndex will be set to the offset
+ * between the last character of the integer and the decimal. Add
+ * (desiredSpaceCount - getEndIndex) spaces at the front of the
+ * string.
+ * <P>
+ * If you are using proportional fonts, instead of padding with
+ * spaces, measure the width of the string in pixels from the start to
+ * getEndIndex.  Then move the pen by (desiredPixelWidth -
+ * widthToAlignmentPoint) before drawing the text.  It also works
+ * where there is no decimal, but possibly additional characters at
+ * the end, e.g. with parentheses in negative numbers: "(12)" for -12.
+ * <p>
+ * <em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ *
+ * @stable ICU 2.0
+ */
+class U_I18N_API NumberFormat : public Format {
+public:
+
+    /**
+     * Alignment Field constants used to construct a FieldPosition object.
+     * Signifies that the position of the integer part or fraction part of
+     * a formatted number should be returned.
+     *
+     * @see FieldPosition
+     * @stable ICU 2.0
+     */
+    enum EAlignmentFields {
+        kIntegerField,
+        kFractionField,
+
+
+    /**
+     * These constants are provided for backwards compatibility only.
+     * Please use the C++ style constants defined above.
+     * @stable ICU 2.0
+     */
+        INTEGER_FIELD        = kIntegerField,
+        FRACTION_FIELD        = kFractionField
+    };
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~NumberFormat();
+
+    /**
+     * Return true if the given Format objects are semantically equal.
+     * Objects of different subclasses are considered unequal.
+     * @return    true if the given Format objects are semantically equal.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Format an object to produce a string.  This method handles
+     * Formattable objects with numeric types. If the Formattable
+     * object type is not a numeric type, then it returns a failing
+     * UErrorCode.
+     *
+     * @param obj       The object to format.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @param status    Output param filled with success/failure status.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(const Formattable& obj,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos,
+                                  UErrorCode& status) const;
+
+    /**
+     * Parse a string to produce an object.  This methods handles
+     * parsing of numeric strings into Formattable objects with numeric
+     * types.
+     * <P>
+     * Before calling, set parse_pos.index to the offset you want to
+     * start parsing at in the source. After calling, parse_pos.index
+     * indicates the position after the successfully parsed text.  If
+     * an error occurs, parse_pos.index is unchanged.
+     * <P>
+     * When parsing, leading whitespace is discarded (with successful
+     * parse), while trailing whitespace is left as is.
+     * <P>
+     * See Format::parseObject() for more.
+     *
+     * @param source    The string to be parsed into an object.
+     * @param result    Formattable to be set to the parse result.
+     *                  If parse fails, return contents are undefined.
+     * @param parse_pos The position to start parsing at. Upon return
+     *                  this param is set to the position after the
+     *                  last character successfully parsed. If the
+     *                  source is not parsed successfully, this param
+     *                  will remain unchanged.
+     * @return          A newly created Formattable* object, or NULL
+     *                  on failure.  The caller owns this and should
+     *                  delete it when done.
+     * @stable ICU 2.0
+     */
+    virtual void parseObject(const UnicodeString& source,
+                             Formattable& result,
+                             ParsePosition& parse_pos) const;
+
+    /**
+     * Format a double number. These methods call the NumberFormat
+     * pure virtual format() methods with the default FieldPosition.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(  double number,
+                            UnicodeString& appendTo) const;
+
+    /**
+     * Format a long number. These methods call the NumberFormat
+     * pure virtual format() methods with the default FieldPosition.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(  int32_t number,
+                            UnicodeString& appendTo) const;
+
+    /**
+     * Format an int64 number. These methods call the NumberFormat
+     * pure virtual format() methods with the default FieldPosition.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.8
+     */
+    UnicodeString& format(  int64_t number,
+                            UnicodeString& appendTo) const;
+
+    /**
+     * Format a double number. Concrete subclasses must implement
+     * these pure virtual methods.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(double number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const = 0;
+    /**
+     * Format a long number. Concrete subclasses must implement
+     * these pure virtual methods.
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+    */
+    virtual UnicodeString& format(int32_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const = 0;
+
+    /**
+     * Format an int64 number. (Not abstract to retain compatibility
+     * with earlier releases, however subclasses should override this
+     * method as it just delegates to format(int32_t number...);
+     *
+     * @param number    The value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       On input: an alignment field, if desired.
+     *                  On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.8
+    */
+    virtual UnicodeString& format(int64_t number,
+                                  UnicodeString& appendTo,
+                                  FieldPosition& pos) const;
+    /**
+     * Redeclared Format method.
+     * @param obj       The object to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Output parameter set to a failure error code
+     *                  when a failure occurs.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+
+   /**
+    * Return a long if possible (e.g. within range LONG_MAX,
+    * LONG_MAX], and with no decimals), otherwise a double.  If
+    * IntegerOnly is set, will stop at a decimal point (or equivalent;
+    * e.g. for rational numbers "1 2/3", will stop after the 1).
+    * <P>
+    * If no object can be parsed, index is unchanged, and NULL is
+    * returned.
+    * <P>
+    * This is a pure virtual which concrete subclasses must implement.
+    *
+    * @param text           The text to be parsed.
+    * @param result         Formattable to be set to the parse result.
+    *                       If parse fails, return contents are undefined.
+    * @param parsePosition  The position to start parsing at on input.
+    *                       On output, moved to after the last successfully
+    *                       parse character. On parse failure, does not change.
+    * @return               A Formattable object of numeric type.  The caller
+    *                       owns this an must delete it.  NULL on failure.
+    * @stable ICU 2.0
+    */
+    virtual void parse(const UnicodeString& text,
+                       Formattable& result,
+                       ParsePosition& parsePosition) const = 0;
+
+    /**
+     * Parse a string as a numeric value, and return a Formattable
+     * numeric object. This method parses integers only if IntegerOnly
+     * is set.
+     *
+     * @param text          The text to be parsed.
+     * @param result        Formattable to be set to the parse result.
+     *                      If parse fails, return contents are undefined.
+     * @param status        Output parameter set to a failure error code
+     *                      when a failure occurs.
+     * @return              A Formattable object of numeric type.  The caller
+     *                      owns this an must delete it.  NULL on failure.
+     * @see                 NumberFormat::isParseIntegerOnly
+     * @stable ICU 2.0
+     */
+    virtual void parse( const UnicodeString& text,
+                        Formattable& result,
+                        UErrorCode& status) const;
+
+    /**
+     * Parses text from the given string as a currency amount.  Unlike
+     * the parse() method, this method will attempt to parse a generic
+     * currency name, searching for a match of this object's locale's
+     * currency display names, or for a 3-letter ISO currency code.
+     * This method will fail if this format is not a currency format,
+     * that is, if it does not contain the currency pattern symbol
+     * (U+00A4) in its prefix or suffix.
+     *
+     * @param text the string to parse
+     * @param result output parameter to receive result. This will have
+     * its currency set to the parsed ISO currency code.
+     * @param pos input-output position; on input, the position within
+     * text to match; must have 0 <= pos.getIndex() < text.length();
+     * on output, the position after the last matched character. If
+     * the parse fails, the position in unchanged upon output.
+     * @return a reference to result
+     * @internal
+     */
+    virtual Formattable& parseCurrency(const UnicodeString& text,
+                                       Formattable& result,
+                                       ParsePosition& pos) const;
+
+    /**
+     * Return true if this format will parse numbers as integers
+     * only.  For example in the English locale, with ParseIntegerOnly
+     * true, the string "1234." would be parsed as the integer value
+     * 1234 and parsing would stop at the "." character.  Of course,
+     * the exact format accepted by the parse operation is locale
+     * dependant and determined by sub-classes of NumberFormat.
+     * @return    true if this format will parse numbers as integers
+     *            only.
+     * @stable ICU 2.0
+     */
+    UBool isParseIntegerOnly(void) const;
+
+    /**
+     * Sets whether or not numbers should be parsed as integers only.
+     * @param value    set True, this format will parse numbers as integers
+     *                 only.
+     * @see isParseIntegerOnly
+     * @stable ICU 2.0
+     */
+    virtual void setParseIntegerOnly(UBool value);
+
+    /**
+     * Returns the default number format for the current default
+     * locale.  The default format is one of the styles provided by
+     * the other factory methods: getNumberInstance,
+     * getCurrencyInstance or getPercentInstance.  Exactly which one
+     * is locale dependant.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);
+
+    /**
+     * Returns the default number format for the specified locale.
+     * The default format is one of the styles provided by the other
+     * factory methods: getNumberInstance, getCurrencyInstance or
+     * getPercentInstance.  Exactly which one is locale dependant.
+     * @param inLocale    the given locale.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,
+                                        UErrorCode&);
+
+    /**
+     * Returns a currency format for the current default locale.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&);
+
+    /**
+     * Returns a currency format for the specified locale.
+     * @param inLocale    the given locale.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createCurrencyInstance(const Locale& inLocale,
+                                                UErrorCode&);
+
+    /**
+     * Returns a percentage format for the current default locale.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&);
+
+    /**
+     * Returns a percentage format for the specified locale.
+     * @param inLocale    the given locale.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createPercentInstance(const Locale& inLocale,
+                                               UErrorCode&);
+
+    /**
+     * Returns a scientific format for the current default locale.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&);
+
+    /**
+     * Returns a scientific format for the specified locale.
+     * @param inLocale    the given locale.
+     * @stable ICU 2.0
+     */
+    static NumberFormat* U_EXPORT2 createScientificInstance(const Locale& inLocale,
+                                                UErrorCode&);
+
+    /**
+     * Get the set of Locales for which NumberFormats are installed.
+     * @param count    Output param to receive the size of the locales
+     * @stable ICU 2.0
+     */
+    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
+
+#if !UCONFIG_NO_SERVICE
+    /**
+     * Register a new NumberFormatFactory.  The factory will be adopted.
+     * @param toAdopt the NumberFormatFactory instance to be adopted
+     * @param status the in/out status code, no special meanings are assigned
+     * @return a registry key that can be used to unregister this factory
+     * @stable ICU 2.6
+     */
+    static URegistryKey U_EXPORT2 registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status);
+
+    /**
+     * Unregister a previously-registered NumberFormatFactory using the key returned from the
+     * register call.  Key becomes invalid after a successful call and should not be used again.
+     * The NumberFormatFactory corresponding to the key will be deleted.
+     * @param key the registry key returned by a previous call to registerFactory
+     * @param status the in/out status code, no special meanings are assigned
+     * @return TRUE if the factory for the key was successfully unregistered
+     * @stable ICU 2.6
+     */
+    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
+
+    /**
+     * Return a StringEnumeration over the locales available at the time of the call,
+     * including registered locales.
+     * @return a StringEnumeration over the locales available at the time of the call
+     * @stable ICU 2.6
+     */
+    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
+#endif /* UCONFIG_NO_SERVICE */
+
+    /**
+     * Returns true if grouping is used in this format. For example,
+     * in the English locale, with grouping on, the number 1234567
+     * might be formatted as "1,234,567". The grouping separator as
+     * well as the size of each group is locale dependant and is
+     * determined by sub-classes of NumberFormat.
+     * @see setGroupingUsed
+     * @stable ICU 2.0
+     */
+    UBool isGroupingUsed(void) const;
+
+    /**
+     * Set whether or not grouping will be used in this format.
+     * @param newValue    True, grouping will be used in this format.
+     * @see getGroupingUsed
+     * @stable ICU 2.0
+     */
+    virtual void setGroupingUsed(UBool newValue);
+
+    /**
+     * Returns the maximum number of digits allowed in the integer portion of a
+     * number.
+     * @return     the maximum number of digits allowed in the integer portion of a
+     *             number.
+     * @see setMaximumIntegerDigits
+     * @stable ICU 2.0
+     */
+    int32_t getMaximumIntegerDigits(void) const;
+
+    /**
+     * Sets the maximum number of digits allowed in the integer portion of a
+     * number. maximumIntegerDigits must be >= minimumIntegerDigits.  If the
+     * new value for maximumIntegerDigits is less than the current value
+     * of minimumIntegerDigits, then minimumIntegerDigits will also be set to
+     * the new value.
+     *
+     * @param newValue    the new value for the maximum number of digits
+     *                    allowed in the integer portion of a number.
+     * @see getMaximumIntegerDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMaximumIntegerDigits(int32_t newValue);
+
+    /**
+     * Returns the minimum number of digits allowed in the integer portion of a
+     * number.
+     * @return    the minimum number of digits allowed in the integer portion of a
+     *            number.
+     * @see setMinimumIntegerDigits
+     * @stable ICU 2.0
+     */
+    int32_t getMinimumIntegerDigits(void) const;
+
+    /**
+     * Sets the minimum number of digits allowed in the integer portion of a
+     * number. minimumIntegerDigits must be &lt;= maximumIntegerDigits.  If the
+     * new value for minimumIntegerDigits exceeds the current value
+     * of maximumIntegerDigits, then maximumIntegerDigits will also be set to
+     * the new value.
+     * @param newValue    the new value to be set.
+     * @see getMinimumIntegerDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumIntegerDigits(int32_t newValue);
+
+    /**
+     * Returns the maximum number of digits allowed in the fraction portion of a
+     * number.
+     * @return    the maximum number of digits allowed in the fraction portion of a
+     *            number.
+     * @see setMaximumFractionDigits
+     * @stable ICU 2.0
+     */
+    int32_t getMaximumFractionDigits(void) const;
+
+    /**
+     * Sets the maximum number of digits allowed in the fraction portion of a
+     * number. maximumFractionDigits must be >= minimumFractionDigits.  If the
+     * new value for maximumFractionDigits is less than the current value
+     * of minimumFractionDigits, then minimumFractionDigits will also be set to
+     * the new value.
+     * @param newValue    the new value to be set.
+     * @see getMaximumFractionDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMaximumFractionDigits(int32_t newValue);
+
+    /**
+     * Returns the minimum number of digits allowed in the fraction portion of a
+     * number.
+     * @return    the minimum number of digits allowed in the fraction portion of a
+     *            number.
+     * @see setMinimumFractionDigits
+     * @stable ICU 2.0
+     */
+    int32_t getMinimumFractionDigits(void) const;
+
+    /**
+     * Sets the minimum number of digits allowed in the fraction portion of a
+     * number. minimumFractionDigits must be &lt;= maximumFractionDigits.   If the
+     * new value for minimumFractionDigits exceeds the current value
+     * of maximumFractionDigits, then maximumIntegerDigits will also be set to
+     * the new value
+     * @param newValue    the new value to be set.
+     * @see getMinimumFractionDigits
+     * @stable ICU 2.0
+     */
+    virtual void setMinimumFractionDigits(int32_t newValue);
+
+    /**
+     * Sets the currency used to display currency
+     * amounts.  This takes effect immediately, if this format is a
+     * currency format.  If this format is not a currency format, then
+     * the currency is used if and when this object becomes a
+     * currency format.
+     * @param theCurrency a 3-letter ISO code indicating new currency
+     * to use.  It need not be null-terminated.  May be the empty
+     * string or NULL to indicate no currency.
+     * @param ec input-output error code
+     * @stable ICU 3.0
+     */
+    virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);
+
+    /**
+     * Gets the currency used to display currency
+     * amounts.  This may be an empty string for some subclasses.
+     * @return a 3-letter null-terminated ISO code indicating
+     * the currency in use, or a pointer to the empty string.
+     * @stable ICU 2.6
+     */
+    const UChar* getCurrency() const;
+
+public:
+
+    /**
+     * Return the class ID for this class.  This is useful for
+     * comparing to a return value from getDynamicClassID(). Note that,
+     * because NumberFormat is an abstract base class, no fully constructed object
+     * will have the class ID returned by NumberFormat::getStaticClassID().
+     * @return The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     * <P>
+     * @return The class ID for this object. All objects of a
+     * given class have the same class ID.  Objects of
+     * other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+protected:
+
+    /**
+     * Default constructor for subclass use only.
+     * @stable ICU 2.0
+     */
+    NumberFormat();
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    NumberFormat(const NumberFormat&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.0
+     */
+    NumberFormat& operator=(const NumberFormat&);
+
+    /**
+     * Returns the currency in effect for this formatter.  Subclasses
+     * should override this method as needed.  Unlike getCurrency(),
+     * this method should never return "".
+     * @result output parameter for null-terminated result, which must
+     * have a capacity of at least 4
+     * @internal
+     */
+    virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;
+
+private:
+
+    enum EStyles {
+        kNumberStyle,
+        kCurrencyStyle,
+        kPercentStyle,
+        kScientificStyle,
+        kStyleCount // ALWAYS LAST ENUM: number of styles
+    };
+
+    /**
+     * Creates the specified decimal format style of the desired locale.
+     * Hook for service registration, uses makeInstance directly if no services
+     * registered.
+     * @param desiredLocale    the given locale.
+     * @param choice           the given style.
+     * @param success          Output param filled with success/failure status.
+     * @return                 A new NumberFormat instance.
+     */
+    static NumberFormat* U_EXPORT2 createInstance(const Locale& desiredLocale, EStyles choice, UErrorCode& success);
+
+    /**
+     * Creates the specified decimal format style of the desired locale.
+     * @param desiredLocale    the given locale.
+     * @param choice           the given style.
+     * @param success          Output param filled with success/failure status.
+     * @return                 A new NumberFormat instance.
+     */
+    static NumberFormat* makeInstance(const Locale& desiredLocale, EStyles choice, UErrorCode& success);
+
+    UBool      fGroupingUsed;
+    int32_t     fMaxIntegerDigits;
+    int32_t     fMinIntegerDigits;
+    int32_t     fMaxFractionDigits;
+    int32_t     fMinFractionDigits;
+    UBool      fParseIntegerOnly;
+
+    // ISO currency code
+    UChar      fCurrency[4];
+
+    friend class ICUNumberFormatFactory; // access to makeInstance, EStyles
+    friend class ICUNumberFormatService;
+};
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * A NumberFormatFactory is used to register new number formats.  The factory
+ * should be able to create any of the predefined formats for each locale it
+ * supports.  When registered, the locales it supports extend or override the
+ * locale already supported by ICU.
+ *
+ * @stable ICU 2.6
+ */
+class U_I18N_API NumberFormatFactory : public UObject {
+public:
+
+    /**
+     * Destructor
+     * @stable ICU 3.0
+     */
+    virtual ~NumberFormatFactory();
+
+    /**
+     * Return true if this factory will be visible.  Default is true.
+     * If not visible, the locales supported by this factory will not
+     * be listed by getAvailableLocales.
+     * @stable ICU 2.6
+     */
+    virtual UBool visible(void) const = 0;
+
+    /**
+     * Return the locale names directly supported by this factory.  The number of names
+     * is returned in count;
+     * @stable ICU 2.6
+     */
+    virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const = 0;
+
+    /**
+     * Return a number format of the appropriate type.  If the locale
+     * is not supported, return null.  If the locale is supported, but
+     * the type is not provided by this service, return null.  Otherwise
+     * return an appropriate instance of NumberFormat.
+     * @stable ICU 2.6
+     */
+    virtual NumberFormat* createFormat(const Locale& loc, UNumberFormatStyle formatType) = 0;
+};
+
+/**
+ * A NumberFormatFactory that supports a single locale.  It can be visible or invisible.
+ * @stable ICU 2.6
+ */
+class U_I18N_API SimpleNumberFormatFactory : public NumberFormatFactory {
+protected:
+    /**
+     * True if the locale supported by this factory is visible.
+     * @stable ICU 2.6
+     */
+    const UBool _visible;
+
+    /**
+     * The locale supported by this factory, as a UnicodeString.
+     * @stable ICU 2.6
+     */
+    UnicodeString _id;
+
+public:
+    /**
+     * @stable ICU 2.6
+     */
+    SimpleNumberFormatFactory(const Locale& locale, UBool visible = TRUE);
+
+    /**
+     * @stable ICU 3.0
+     */
+    virtual ~SimpleNumberFormatFactory();
+
+    /**
+     * @stable ICU 2.6
+     */
+    virtual UBool visible(void) const;
+
+    /**
+     * @stable ICU 2.6
+     */
+    virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const;
+};
+#endif /* #if !UCONFIG_NO_SERVICE */
+
+// -------------------------------------
+
+inline UBool
+NumberFormat::isParseIntegerOnly() const
+{
+    return fParseIntegerOnly;
+}
+
+inline UnicodeString&
+NumberFormat::format(const Formattable& obj,
+                     UnicodeString& appendTo,
+                     UErrorCode& status) const {
+    return Format::format(obj, appendTo, status);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _NUMFMT
+//eof
diff --git a/CoreFoundation/icu/unicode/parseerr.h b/CoreFoundation/icu/unicode/parseerr.h
new file mode 100644
index 0000000..44ff008
--- /dev/null
+++ b/CoreFoundation/icu/unicode/parseerr.h
@@ -0,0 +1,92 @@
+/*
+**********************************************************************
+*   Copyright (C) 1999-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*   Date        Name        Description
+*   03/14/00    aliu        Creation.
+*   06/27/00    aliu        Change from C++ class to C struct
+**********************************************************************
+*/
+#ifndef PARSEERR_H
+#define PARSEERR_H
+
+#include "unicode/utypes.h"
+
+
+/**
+ * \file
+ * \brief C API: Parse Error Information
+ */
+/**
+ * The capacity of the context strings in UParseError.
+ * @stable ICU 2.0
+ */ 
+enum { U_PARSE_CONTEXT_LEN = 16 };
+
+/**
+ * A UParseError struct is used to returned detailed information about
+ * parsing errors.  It is used by ICU parsing engines that parse long
+ * rules, patterns, or programs, where the text being parsed is long
+ * enough that more information than a UErrorCode is needed to
+ * localize the error.
+ *
+ * <p>The line, offset, and context fields are optional; parsing
+ * engines may choose not to use to use them.
+ *
+ * <p>The preContext and postContext strings include some part of the
+ * context surrounding the error.  If the source text is "let for=7"
+ * and "for" is the error (e.g., because it is a reserved word), then
+ * some examples of what a parser might produce are the following:
+ *
+ * <pre>
+ * preContext   postContext
+ * ""           ""            The parser does not support context
+ * "let "       "=7"          Pre- and post-context only
+ * "let "       "for=7"       Pre- and post-context and error text
+ * ""           "for"         Error text only
+ * </pre>
+ *
+ * <p>Examples of engines which use UParseError (or may use it in the
+ * future) are Transliterator, RuleBasedBreakIterator, and
+ * RegexPattern.
+ * 
+ * @stable ICU 2.0
+ */
+typedef struct UParseError {
+
+    /**
+     * The line on which the error occured.  If the parser uses this
+     * field, it sets it to the line number of the source text line on
+     * which the error appears, which will be be a value >= 1.  If the
+     * parse does not support line numbers, the value will be <= 0.
+     * @stable ICU 2.0
+     */
+    int32_t        line;
+
+    /**
+     * The character offset to the error.  If the line field is >= 1,
+     * then this is the offset from the start of the line.  Otherwise,
+     * this is the offset from the start of the text.  If the parser
+     * does not support this field, it will have a value < 0.
+     * @stable ICU 2.0
+     */
+    int32_t        offset;
+
+    /**
+     * Textual context before the error.  Null-terminated.  The empty
+     * string if not supported by parser.
+     * @stable ICU 2.0   
+     */
+    UChar          preContext[U_PARSE_CONTEXT_LEN];
+
+    /**
+     * The error itself and/or textual context after the error.
+     * Null-terminated.  The empty string if not supported by parser.
+     * @stable ICU 2.0   
+     */
+    UChar          postContext[U_PARSE_CONTEXT_LEN];
+
+} UParseError;
+
+#endif
diff --git a/CoreFoundation/icu/unicode/parsepos.h b/CoreFoundation/icu/unicode/parsepos.h
new file mode 100644
index 0000000..cdf49e0
--- /dev/null
+++ b/CoreFoundation/icu/unicode/parsepos.h
@@ -0,0 +1,230 @@
+/*
+* Copyright (C) 1997-2005, International Business Machines Corporation and others. All Rights Reserved.
+*******************************************************************************
+*
+* File PARSEPOS.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   07/09/97    helena      Converted from java.
+*   07/17/98    stephen     Added errorIndex support.
+*   05/11/99    stephen     Cleaned up.
+*******************************************************************************
+*/
+
+#ifndef PARSEPOS_H
+#define PARSEPOS_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * \file
+ * \brief C++ API: Canonical Iterator
+ */
+/** 
+ * <code>ParsePosition</code> is a simple class used by <code>Format</code>
+ * and its subclasses to keep track of the current position during parsing.
+ * The <code>parseObject</code> method in the various <code>Format</code>
+ * classes requires a <code>ParsePosition</code> object as an argument.
+ *
+ * <p>
+ * By design, as you parse through a string with different formats,
+ * you can use the same <code>ParsePosition</code>, since the index parameter
+ * records the current position.
+ *
+ * The ParsePosition class is not suitable for subclassing.
+ *
+ * @version     1.3 10/30/97
+ * @author      Mark Davis, Helena Shih
+ * @see         java.text.Format
+ */
+
+class U_COMMON_API ParsePosition : public UObject {
+public:
+    /**
+     * Default constructor, the index starts with 0 as default.
+     * @stable ICU 2.0
+     */
+    ParsePosition()
+        : UObject(),
+        index(0),
+        errorIndex(-1)
+      {}
+
+    /**
+     * Create a new ParsePosition with the given initial index.
+     * @param newIndex the new text offset.
+     * @stable ICU 2.0
+     */
+    ParsePosition(int32_t newIndex)
+        : UObject(),
+        index(newIndex),
+        errorIndex(-1)
+      {}
+
+    /**
+     * Copy constructor
+     * @param copy the object to be copied from.
+     * @stable ICU 2.0
+     */
+    ParsePosition(const ParsePosition& copy)
+        : UObject(copy),
+        index(copy.index),
+        errorIndex(copy.errorIndex)
+      {}
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~ParsePosition();
+
+    /**
+     * Assignment operator
+     * @stable ICU 2.0
+     */
+    ParsePosition&      operator=(const ParsePosition& copy);
+
+    /**
+     * Equality operator.
+     * @return TRUE if the two parse positions are equal, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool              operator==(const ParsePosition& that) const;
+
+    /**
+     * Equality operator.
+     * @return TRUE if the two parse positions are not equal, FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    UBool              operator!=(const ParsePosition& that) const;
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    ParsePosition *clone() const;
+
+    /**
+     * Retrieve the current parse position.  On input to a parse method, this
+     * is the index of the character at which parsing will begin; on output, it
+     * is the index of the character following the last character parsed.
+     * @return the current index.
+     * @stable ICU 2.0
+     */
+    int32_t getIndex(void) const;
+
+    /**
+     * Set the current parse position.
+     * @param index the new index.
+     * @stable ICU 2.0
+     */
+    void setIndex(int32_t index);
+
+    /**
+     * Set the index at which a parse error occurred.  Formatters
+     * should set this before returning an error code from their
+     * parseObject method.  The default value is -1 if this is not
+     * set.
+     * @stable ICU 2.0
+     */
+    void setErrorIndex(int32_t ei);
+
+    /**
+     * Retrieve the index at which an error occurred, or -1 if the
+     * error index has not been set.
+     * @stable ICU 2.0
+     */
+    int32_t getErrorIndex(void) const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+private:
+    /**
+     * Input: the place you start parsing.
+     * <br>Output: position where the parse stopped.
+     * This is designed to be used serially,
+     * with each call setting index up for the next one.
+     */
+    int32_t index;
+
+    /**
+     * The index at which a parse error occurred.
+     */
+    int32_t errorIndex;
+
+};
+
+inline ParsePosition&
+ParsePosition::operator=(const ParsePosition& copy)
+{
+  index = copy.index;
+  errorIndex = copy.errorIndex;
+  return *this;
+}
+
+inline UBool
+ParsePosition::operator==(const ParsePosition& copy) const
+{
+  if(index != copy.index || errorIndex != copy.errorIndex)
+  return FALSE;
+  else
+  return TRUE;
+}
+
+inline UBool
+ParsePosition::operator!=(const ParsePosition& copy) const
+{
+  return !operator==(copy);
+}
+
+inline int32_t
+ParsePosition::getIndex() const
+{
+  return index;
+}
+
+inline void
+ParsePosition::setIndex(int32_t offset)
+{
+  this->index = offset;
+}
+
+inline int32_t
+ParsePosition::getErrorIndex() const
+{
+  return errorIndex;
+}
+
+inline void
+ParsePosition::setErrorIndex(int32_t ei)
+{
+  this->errorIndex = ei;
+}
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/platform.h b/CoreFoundation/icu/unicode/platform.h
new file mode 100644
index 0000000..34ceaf5
--- /dev/null
+++ b/CoreFoundation/icu/unicode/platform.h
@@ -0,0 +1,393 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1997-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+*  FILE NAME : platform.h
+*
+*   Date        Name        Description
+*   05/13/98    nos         Creation (content moved here from ptypes.h).
+*   03/02/99    stephen     Added AS400 support.
+*   03/30/99    stephen     Added Linux support.
+*   04/13/99    stephen     Reworked for autoconf.
+******************************************************************************
+*/
+
+/**
+ * \file 
+ * \brief Basic types for the platform 
+ */
+
+/* Define the platform we're on. */
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#ifndef U_DARWIN
+#define U_DARWIN
+#endif
+#elif DEPLOYMENT_TARGET_WIN32
+#ifndef U_CYGWIN
+#define U_CYGWIN
+#endif
+#endif
+
+/* Define whether inttypes.h is available */
+#ifndef U_HAVE_INTTYPES_H
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_INTTYPES_H 1
+#else
+#define U_HAVE_INTTYPES_H 0
+#endif
+#endif
+
+/*
+ * Define what support for C++ streams is available.
+ *     If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available
+ * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
+ * one should qualify streams using the std namespace in ICU header
+ * files.
+ *     If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is
+ * available instead (198506 is the date when Stroustrup published
+ * "An Extensible I/O Facility for C++" at the summer USENIX conference).
+ *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
+ * support for them will be silently suppressed in ICU.
+ *
+ */
+
+#ifndef U_IOSTREAM_SOURCE
+#define U_IOSTREAM_SOURCE 199711
+#endif
+
+/* Determines whether specific types are available */
+#ifndef U_HAVE_INT8_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_INT8_T 1
+#else
+#define U_HAVE_INT8_T 0
+#endif
+#endif
+
+#ifndef U_HAVE_UINT8_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_UINT8_T 1
+#else
+#define U_HAVE_UINT8_T 0
+#endif
+#endif
+
+#ifndef U_HAVE_INT16_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_INT16_T 1
+#else
+#define U_HAVE_INT16_T 0
+#endif
+#endif
+
+#ifndef U_HAVE_UINT16_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_UINT16_T 1
+#else
+#define U_HAVE_UINT16_T 0
+#endif
+#endif
+
+#ifndef U_HAVE_INT32_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_INT32_T 1
+#else
+#define U_HAVE_INT32_T 0
+#endif
+#endif
+
+#ifndef U_HAVE_UINT32_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_UINT32_T 1
+#else
+#define U_HAVE_UINT32_T 0
+#endif
+#endif
+
+#ifndef U_HAVE_INT64_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_INT64_T 1
+#else
+#define U_HAVE_INT64_T 0
+#endif
+#endif
+
+#ifndef U_HAVE_UINT64_T
+#ifdef DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_UINT64_T 1
+#else
+#define U_HAVE_UINT64_T 0
+#endif
+#endif
+
+/*===========================================================================*/
+/* Generic data types                                                        */
+/*===========================================================================*/
+
+#include <sys/types.h>
+
+/* If your platform does not have the <inttypes.h> header, you may
+   need to edit the typedefs below. */
+#if U_HAVE_INTTYPES_H
+
+/* autoconf 2.13 sometimes can't properly find the data types in <inttypes.h> */
+/* os/390 needs <inttypes.h>, but it doesn't have int8_t, and it sometimes */
+/* doesn't have uint8_t depending on the OS version. */
+/* So we have this work around. */
+#ifdef OS390
+/* The features header is needed to get (u)int64_t sometimes. */
+#include <features.h>
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+#if !defined(__uint8_t)
+#define __uint8_t 1
+typedef unsigned char uint8_t;
+#endif
+#endif /* OS390 */
+
+#include <inttypes.h>
+
+#else /* U_HAVE_INTTYPES_H */
+
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+
+#if ! U_HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+
+#if ! U_HAVE_INT16_T
+typedef signed short int16_t;
+#endif
+
+#if ! U_HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+
+#if ! U_HAVE_INT32_T
+typedef signed int int32_t;
+#endif
+
+#if ! U_HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+
+#if ! U_HAVE_INT64_T
+    typedef signed long long int64_t;
+/* else we may not have a 64-bit type */
+#endif
+
+#if ! U_HAVE_UINT64_T
+    typedef unsigned long long uint64_t;
+/* else we may not have a 64-bit type */
+#endif
+
+#endif
+
+/*===========================================================================*/
+/* Compiler and environment features                                         */
+/*===========================================================================*/
+
+/* Define whether namespace is supported */
+#ifndef U_HAVE_NAMESPACE
+#define U_HAVE_NAMESPACE 1
+#endif
+
+/* Determines the endianness of the platform
+   It's done this way in case multiple architectures are being built at once.
+   For example, Darwin supports fat binaries, which can be both PPC and x86 based. */
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN)
+#define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
+#else
+#define U_IS_BIG_ENDIAN 0
+#endif
+
+/* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
+#define ICU_USE_THREADS 1
+
+/* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check lock. */
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+#define UMTX_STRONG_MEMORY_MODEL 1
+#endif
+
+#ifndef U_DEBUG
+#define U_DEBUG 0
+#endif
+
+#ifndef U_RELEASE
+#define U_RELEASE 1
+#endif
+
+/* Determine whether to disable renaming or not. This overrides the
+   setting in umachine.h which is for all platforms. */
+#ifndef U_DISABLE_RENAMING
+#if DEPLOYMENT_TARGET_MACOSX
+#define U_DISABLE_RENAMING 1
+#else
+#define U_DISABLE_RENAMING 0
+#endif
+#endif
+
+/* Determine whether to override new and delete. */
+#ifndef U_OVERRIDE_CXX_ALLOCATION
+#if DEPLOYMENT_TARGET_MACOSX
+#define U_OVERRIDE_CXX_ALLOCATION 1
+#else
+#define U_OVERRIDE_CXX_ALLOCATION 0
+#endif
+#endif
+/* Determine whether to override placement new and delete for STL. */
+#ifndef U_HAVE_PLACEMENT_NEW
+#if DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_PLACEMENT_NEW 1
+#else
+#define U_HAVE_PLACEMENT_NEW 0
+#endif
+#endif
+
+/* Determine whether to enable tracing. */
+#ifndef U_ENABLE_TRACING
+#define U_ENABLE_TRACING 1
+#endif
+
+/* Do we allow ICU users to use the draft APIs by default? */
+#ifndef U_DEFAULT_SHOW_DRAFT
+#define U_DEFAULT_SHOW_DRAFT 1
+#endif
+
+/* Define the library suffix in a C syntax. */
+#define U_HAVE_LIB_SUFFIX 0
+#define U_LIB_SUFFIX_C_NAME 
+#define U_LIB_SUFFIX_C_NAME_STRING ""
+
+/*===========================================================================*/
+/* Character data types                                                      */
+/*===========================================================================*/
+
+#if ((defined(OS390) && (!defined(__CHARSET_LIB) || !__CHARSET_LIB))) || defined(OS400)
+#   define U_CHARSET_FAMILY 1
+#endif
+
+/*===========================================================================*/
+/* Information about wchar support                                           */
+/*===========================================================================*/
+
+#define U_HAVE_WCHAR_H      1
+#if DEPLOYMENT_TARGET_MACOSX
+#define U_SIZEOF_WCHAR_T    4
+
+#define U_HAVE_WCSCPY       1
+#else
+#define U_SIZEOF_WCHAR_T    2
+
+#define U_HAVE_WCSCPY       0
+
+/**
+ * \def U_DECLARE_UTF16
+ * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros
+ * instead.
+ * @internal
+ */
+#if 1 || defined(U_CHECK_UTF16_STRING)
+#if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
+    || (defined(__HP_aCC) && __HP_aCC >= 035000) \
+    || (defined(__HP_cc) && __HP_cc >= 111106)
+#define U_DECLARE_UTF16(string) u ## string
+#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
+/* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */
+/* Sun's C compiler has issues with this notation, and it's unreliable. */
+#define U_DECLARE_UTF16(string) U ## string
+#elif U_SIZEOF_WCHAR_T == 2 \
+    && (U_CHARSET_FAMILY == 0 || ((defined(OS390) || defined(OS400)) && defined(__UCS2__)))
+#define U_DECLARE_UTF16(string) L ## string
+#endif
+#endif
+
+#endif
+
+/*===========================================================================*/
+/* Information about POSIX support                                           */
+/*===========================================================================*/
+
+#if DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_NL_LANGINFO          1
+#define U_HAVE_NL_LANGINFO_CODESET  1
+#define U_NL_LANGINFO_CODESET       CODESET
+#else
+#define U_HAVE_NL_LANGINFO          0
+#define U_HAVE_NL_LANGINFO_CODESET  0
+#define U_NL_LANGINFO_CODESET       -1
+#endif
+
+#if 1
+#define U_TZSET         tzset
+#endif
+#if 1
+#define U_TIMEZONE      timezone
+#endif
+#if DEPLOYMENT_TARGET_MACOSX
+#define U_TZNAME        tzname
+#endif
+
+#if DEPLOYMENT_TARGET_MACOSX
+#define U_HAVE_MMAP     1
+#define U_HAVE_POPEN    1
+#else
+#define U_HAVE_MMAP     0
+#define U_HAVE_POPEN    0
+#endif
+
+/*===========================================================================*/
+/* Symbol import-export control                                              */
+/*===========================================================================*/
+
+#if defined(U_DARWIN) && defined(__GNUC__) && (__GNUC__ >= 4)
+#define USE_GCC_VISIBILITY_ATTRIBUTE 1
+#endif
+
+#ifdef USE_GCC_VISIBILITY_ATTRIBUTE
+#define U_EXPORT __attribute__((visibility("default")))
+#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
+   || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 
+#define U_EXPORT __global
+/*#elif defined(__HP_aCC) || defined(__HP_cc)
+#define U_EXPORT __declspec(dllexport)*/
+#else
+#define U_EXPORT
+#endif
+
+/* U_CALLCONV is releated to U_EXPORT2 */
+#define U_EXPORT2
+
+/* cygwin needs to export/import data */
+#ifdef U_CYGWIN
+#define U_IMPORT __declspec(dllimport)
+#else
+#define U_IMPORT 
+#endif
+
+/*===========================================================================*/
+/* Code alignment and C function inlining                                    */
+/*===========================================================================*/
+
+#ifndef U_INLINE
+#   ifdef __cplusplus
+#       define U_INLINE inline
+#   else
+#       define U_INLINE __inline
+#   endif
+#endif
+
+#define U_ALIGN_CODE(n) 
+
+/*===========================================================================*/
+/* Programs used by ICU code                                                 */
+/*===========================================================================*/
+
+#define U_MAKE  "make"
diff --git a/CoreFoundation/icu/unicode/plurfmt.h b/CoreFoundation/icu/unicode/plurfmt.h
new file mode 100644
index 0000000..445db39
--- /dev/null
+++ b/CoreFoundation/icu/unicode/plurfmt.h
@@ -0,0 +1,541 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*
+
+* File PLURFMT.H
+*
+* Modification History:*
+*   Date        Name        Description
+*
+********************************************************************************
+*/
+
+#ifndef PLURFMT
+#define PLURFMT
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: PluralFormat object
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/numfmt.h"
+#include "unicode/plurrule.h"
+
+U_NAMESPACE_BEGIN
+
+class Hashtable;
+
+/**
+ * <p>
+ * <code>PluralFormat</code> supports the creation of internationalized
+ * messages with plural inflection. It is based on <i>plural
+ * selection</i>, i.e. the caller specifies messages for each
+ * plural case that can appear in the users language and the
+ * <code>PluralFormat</code> selects the appropriate message based on
+ * the number.
+ * </p>
+ * <h4>The Problem of Plural Forms in Internationalized Messages</h4>
+ * <p>
+ * Different languages have different ways to inflect
+ * plurals. Creating internationalized messages that include plural
+ * forms is only feasible when the framework is able to handle plural
+ * forms of <i>all</i> languages correctly. <code>ChoiceFormat</code>
+ * doesn't handle this well, because it attaches a number interval to
+ * each message and selects the message whose interval contains a
+ * given number. This can only handle a finite number of
+ * intervals. But in some languages, like Polish, one plural case
+ * applies to infinitely many intervals (e.g., paucal applies to
+ * numbers ending with 2, 3, or 4 except those ending with 12, 13, or
+ * 14). Thus <code>ChoiceFormat</code> is not adequate.
+ * </p><p>
+ * <code>PluralFormat</code> deals with this by breaking the problem
+ * into two parts:
+ * <ul>
+ * <li>It uses <code>PluralRules</code> that can define more complex
+ *     conditions for a plural case than just a single interval. These plural
+ *     rules define both what plural cases exist in a language, and to
+ *     which numbers these cases apply.
+ * <li>It provides predefined plural rules for many locales. Thus, the programmer
+ *     need not worry about the plural cases of a language. On the flip side,
+ *     the localizer does not have to specify the plural cases; he can simply
+ *     use the predefined keywords. The whole plural formatting of messages can
+ *     be done using localized patterns from resource bundles.
+ * </ul>
+ * </p>
+ * <h4>Usage of <code>PluralFormat</code></h4>
+ * <p>
+ * This discussion assumes that you use <code>PluralFormat</code> with
+ * a predefined set of plural rules. You can create one using one of
+ * the constructors that takes a <code>locale</code> object. To
+ * specify the message pattern, you can either pass it to the
+ * constructor or set it explicitly using the
+ * <code>applyPattern()</code> method. The <code>format()</code>
+ * method takes a number object and selects the message of the
+ * matching plural case. This message will be returned.
+ * </p>
+ * <h5>Patterns and Their Interpretation</h5>
+ * <p>
+ * The pattern text defines the message output for each plural case of the
+ * used locale. The pattern is a sequence of
+ * <code><i>caseKeyword</i>{<i>message</i>}</code> clauses, separated by white
+ * space characters. Each clause assigns the message <code><i>message</i></code>
+ * to the plural case identified by <code><i>caseKeyword</i></code>.
+ * </p><p>
+ * You always have to define a message text for the default plural case
+ * "<code>other</code>" which is contained in every rule set. If the plural
+ * rules of the <code>PluralFormat</code> object do not contain a plural case
+ * identified by <code><i>caseKeyword</i></code>, U_DEFAULT_KEYWORD_MISSING
+ * will be set to status.
+ * If you do not specify a message text for a particular plural case, the
+ * message text of the plural case "<code>other</code>" gets assigned to this
+ * plural case. If you specify more than one message for the same plural case,
+ * U_DUPLICATE_KEYWORD will be set to status.
+ * <br/>
+ * Spaces between <code><i>caseKeyword</i></code> and
+ * <code><i>message</i></code>  will be ignored; spaces within
+ * <code><i>message</i></code> will be preserved.
+ * </p><p>
+ * The message text for a particular plural case may contain other message
+ * format patterns. <code>PluralFormat</code> preserves these so that you
+ * can use the strings produced by <code>PluralFormat</code> with other
+ * formatters. If you are using <code>PluralFormat</code> inside a
+ * <code>MessageFormat</code> pattern, <code>MessageFormat</code> will
+ * automatically evaluate the resulting format pattern.<br/>
+ * Thus, curly braces (<code>{</code>, <code>}</code>) are <i>only</i> allowed
+ * in message texts to define a nested format pattern.<br/>
+ * The pound sign (<code>#</code>) will be interpreted as the number placeholder
+ * in the message text, if it is not contained in curly braces (to preserve
+ * <code>NumberFormat</code> patterns). <code>PluralFormat</code> will
+ * replace each of those pound signs by the number passed to the
+ * <code>format()</code> method. It will be formatted using a
+ * <code>NumberFormat</code> for the <code>PluralFormat</code>'s locale. If you
+ * need special number formatting, you have to explicitly specify a
+ * <code>NumberFormat</code> for the <code>PluralFormat</code> to use.
+ * </p>
+ * Example
+ * <pre>
+ * UErrorCode status = U_ZERO_ERROR;
+ * MessageFormat* msgFmt = new MessageFormat(UnicodeString("{0, plural,
+ *   one{{0, number, C''est #,##0.0#  fichier}} other {Ce sont # fichiers}} dans la liste."),
+ *   Locale("fr"), status);
+ * if (U_FAILURE(status)) {
+ *     return;
+ * }
+ * Formattable args1[] = {(int32_t)0};
+ * Formattable args2[] = {(int32_t)3};
+ * FieldPosition ignore(FieldPosition::DONT_CARE);
+ * UnicodeString result;
+ * msgFmt->format(args1, 1, result, ignore, status);
+ * cout << result << endl;
+ * result.remove();
+ * msgFmt->format(args2, 1, result, ignore, status);
+ * cout << result << endl;
+ * </pre>
+ * Produces the output:<br/>
+ * <code>C'est 0,0 fichier dans la liste.</code><br/>
+ * <code>Ce sont 3 fichiers dans la liste."</code>
+ * <p>
+ * <strong>Note:</strong><br/>
+ *   Currently <code>PluralFormat</code>
+ *   does not make use of quotes like <code>MessageFormat</code>.
+ *   If you use plural format strings with <code>MessageFormat</code> and want
+ *   to use a quote sign "<code>'</code>", you have to write "<code>''</code>".
+ *   <code>MessageFormat</code> unquotes this pattern and  passes the unquoted
+ *   pattern to <code>PluralFormat</code>. It's a bit trickier if you use
+ *   nested formats that do quoting. In the example above, we wanted to insert
+ *   "<code>'</code>" in the number format pattern. Since
+ *   <code>NumberFormat</code> supports quotes, we had to insert
+ *   "<code>''</code>". But since <code>MessageFormat</code> unquotes the
+ *   pattern before it gets passed to <code>PluralFormat</code>, we have to
+ *   double these quotes, i.e. write "<code>''''</code>".
+ * </p>
+ * <h4>Defining Custom Plural Rules</h4>
+ * <p>If you need to use <code>PluralFormat</code> with custom rules, you can
+ * create a <code>PluralRules</code> object and pass it to
+ * <code>PluralFormat</code>'s constructor. If you also specify a locale in this
+ * constructor, this locale will be used to format the number in the message
+ * texts.
+ * </p><p>
+ * For more information about <code>PluralRules</code>, see
+ * {@link PluralRules}.
+ * </p>
+ *
+ * ported from Java
+ * @draft ICU 4.0
+ */
+
+class U_I18N_API PluralFormat : public Format {
+public:
+
+    /**
+     * Creates a new <code>PluralFormat</code> for the default locale.
+     * This locale will be used to get the set of plural rules and for standard
+     * number formatting.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(UErrorCode& status);
+
+    /**
+     * Creates a new <code>PluralFormat</code> for a given locale.
+     * @param locale the <code>PluralFormat</code> will be configured with
+     *               rules for this locale. This locale will also be used for
+     *               standard number formatting.
+     * @param status output param set to success/failure code on exit, which
+     *               must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(const Locale& locale, UErrorCode& status);
+
+    /**
+     * Creates a new <code>PluralFormat</code> for a given set of rules.
+     * The standard number formatting will be done using the default locale.
+     * @param rules   defines the behavior of the <code>PluralFormat</code>
+     *                object.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(const PluralRules& rules, UErrorCode& status);
+
+    /**
+     * Creates a new <code>PluralFormat</code> for a given set of rules.
+     * The standard number formatting will be done using the given locale.
+     * @param locale  the default number formatting will be done using this
+     *                locale.
+     * @param rules   defines the behavior of the <code>PluralFormat</code>
+     *                object.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(const Locale& locale, const PluralRules& rules, UErrorCode& status);
+
+    /**
+     * Creates a new <code>PluralFormat</code> for a given pattern string.
+     * The default locale will be used to get the set of plural rules and for
+     * standard number formatting.
+     * @param  pattern the pattern for this <code>PluralFormat</code>.
+     *                 errors are returned to status if the pattern is invalid.
+     * @param status   output param set to success/failure code on exit, which
+     *                 must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(const UnicodeString& pattern, UErrorCode& status);
+
+    /**
+     * Creates a new <code>PluralFormat</code> for a given pattern string and
+     * locale.
+     * The locale will be used to get the set of plural rules and for
+     * standard number formatting.
+     * @param locale   the <code>PluralFormat</code> will be configured with
+     *                 rules for this locale. This locale will also be used for
+     *                 standard number formatting.
+     * @param pattern  the pattern for this <code>PluralFormat</code>.
+     *                 errors are returned to status if the pattern is invalid.
+     * @param status   output param set to success/failure code on exit, which
+     *                 must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(const Locale& locale, const UnicodeString& pattern, UErrorCode& status);
+
+    /**
+     * Creates a new <code>PluralFormat</code> for a given set of rules, a
+     * pattern and a locale.
+     * @param rules    defines the behavior of the <code>PluralFormat</code>
+     *                 object.
+     * @param pattern  the pattern for this <code>PluralFormat</code>.
+     *                 errors are returned to status if the pattern is invalid.
+     * @param status   output param set to success/failure code on exit, which
+     *                 must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(const PluralRules& rules,
+                 const UnicodeString& pattern,
+                 UErrorCode& status);
+
+    /**
+     * Creates a new <code>PluralFormat</code> for a given set of rules, a
+     * pattern and a locale.
+     * @param locale  the <code>PluralFormat</code> will be configured with
+     *                rules for this locale. This locale will also be used for
+     *                standard number formatting.
+     * @param rules   defines the behavior of the <code>PluralFormat</code>
+     *                object.
+     * @param pattern the pattern for this <code>PluralFormat</code>.
+     *                errors are returned to status if the pattern is invalid.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    PluralFormat(const Locale& locale,
+                 const PluralRules& rules,
+                 const UnicodeString& pattern,
+                 UErrorCode& status);
+
+    /**
+      * copy constructor.
+      * @draft ICU 4.0
+      */
+    PluralFormat(const PluralFormat& other);
+
+    /**
+     * Destructor.
+     * @draft ICU 4.0
+     */
+    virtual ~PluralFormat();
+
+    /**
+     * Sets the pattern used by this plural format.
+     * The method parses the pattern and creates a map of format strings
+     * for the plural rules.
+     * Patterns and their interpretation are specified in the class description.
+     *
+     * @param pattern the pattern for this plural format
+     *                errors are returned to status if the pattern is invalid.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    void applyPattern(const UnicodeString& pattern, UErrorCode& status);
+
+    /**
+     * Formats a plural message for a given number.
+     *
+     * @param number  a number for which the plural message should be formatted
+     *                for. If no pattern has been applied to this
+     *                <code>PluralFormat</code> object yet, the formatted number
+     *                will be returned.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @return        the string containing the formatted plural message.
+     * @draft ICU 4.0
+     */
+    UnicodeString format(int32_t number, UErrorCode& status) const;   
+    
+    /**
+     * Formats a plural message for a given number.
+     *
+     * @param number  a number for which the plural message should be formatted
+     *                for. If no pattern has been applied to this
+     *                <code>PluralFormat</code> object yet, the formatted number
+     *                will be returned.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @return        the string containing the formatted plural message.
+     * @draft ICU 4.0
+     */
+    UnicodeString format(double number, UErrorCode& status) const;
+
+    /**
+     * Formats a plural message for a given number.
+     *
+     * @param number   a number for which the plural message should be formatted
+     *                 for. If no pattern has been applied to this
+     *                 <code>PluralFormat</code> object yet, the formatted number
+     *                 will be returned.
+     * @param appendTo output parameter to receive result.
+     *                 result is appended to existing contents.
+     * @param pos      On input: an alignment field, if desired.
+     *                 On output: the offsets of the alignment field.
+     * @param status   output param set to success/failure code on exit, which
+     *                 must not indicate a failure before the function call.
+     * @return         the string containing the formatted plural message.
+     * @draft ICU 4.0
+     */
+    UnicodeString& format(int32_t number,
+                          UnicodeString& appendTo,
+                          FieldPosition& pos,
+                          UErrorCode& status) const;
+    
+    /**
+     * Formats a plural message for a given number.
+     *
+     * @param number   a number for which the plural message should be formatted
+     *                 for. If no pattern has been applied to this
+     *                 <code>PluralFormat</code> object yet, the formatted number
+     *                 will be returned.
+     * @param appendTo output parameter to receive result.
+     *                 result is appended to existing contents.
+     * @param pos      On input: an alignment field, if desired.
+     *                 On output: the offsets of the alignment field.
+     * @param status   output param set to success/failure code on exit, which
+     *                 must not indicate a failure before the function call.
+     * @return         the string containing the formatted plural message.
+     * @draft ICU 4.0
+     */
+    UnicodeString& format(double number,
+                          UnicodeString& appendTo,
+                          FieldPosition& pos,
+                          UErrorCode& status) const;
+
+    /**
+     * Sets the locale used by this <code>PluraFormat</code> object.
+     * Note: Calling this method resets this <code>PluraFormat</code> object,
+     *     i.e., a pattern that was applied previously will be removed,
+     *     and the NumberFormat is set to the default number format for
+     *     the locale.  The resulting format behaves the same as one
+     *     constructed from {@link #PluralFormat(locale)}.
+     * @param locale  the <code>locale</code> to use to configure the formatter.
+     * @param status  output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @draft ICU 4.0
+     */
+    void setLocale(const Locale& locale, UErrorCode& status);
+
+    /**
+      * Sets the number format used by this formatter.  You only need to
+      * call this if you want a different number format than the default
+      * formatter for the locale.
+      * @param format  the number format to use.
+      * @param status  output param set to success/failure code on exit, which
+      *                must not indicate a failure before the function call.
+      * @draft ICU 4.0
+      */
+    void setNumberFormat(const NumberFormat* format, UErrorCode& status);
+
+    /**
+       * Assignment operator
+       *
+       * @param other    the PluralFormat object to copy from.
+       * @draft ICU 4.0
+       */
+    PluralFormat& operator=(const PluralFormat& other);
+
+    /**
+      * Return true if another object is semantically equal to this one.
+      *
+      * @param other    the PluralFormat object to be compared with.
+      * @return         true if other is semantically equal to this.
+      * @draft ICU 4.0
+      */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Return true if another object is semantically unequal to this one.
+     *
+     * @param other    the PluralFormat object to be compared with.
+     * @return         true if other is semantically unequal to this.
+     * @draft ICU 4.0
+     */
+    virtual UBool operator!=(const Format& other) const;
+
+    /**
+     * Clones this Format object polymorphically.  The caller owns the
+     * result and should delete it when done.
+     * @draft ICU 4.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+    * Redeclared Format method.
+    *
+    * @param obj       The object to be formatted into a string.
+    * @param appendTo  output parameter to receive result.
+    *                  Result is appended to existing contents.
+    * @param pos       On input: an alignment field, if desired.
+    *                  On output: the offsets of the alignment field.
+    * @param status    output param filled with success/failure status.
+    * @return          Reference to 'appendTo' parameter.
+    * @draft ICU 4.0
+    */
+   UnicodeString& format(const Formattable& obj,
+                         UnicodeString& appendTo,
+                         FieldPosition& pos,
+                         UErrorCode& status) const;
+
+   /**
+    * Returns the pattern from applyPattern() or constructor().
+    *
+    * @param  appendTo  output parameter to receive result.
+     *                  Result is appended to existing contents.
+    * @return the UnicodeString with inserted pattern.
+    * @draft ICU 4.0
+    */
+   UnicodeString& toPattern(UnicodeString& appendTo);
+
+   /**
+    * This method is not yet supported by <code>PluralFormat</code>.
+    * <P>
+    * Before calling, set parse_pos.index to the offset you want to start
+    * parsing at in the source. After calling, parse_pos.index is the end of
+    * the text you parsed. If error occurs, index is unchanged.
+    * <P>
+    * When parsing, leading whitespace is discarded (with a successful parse),
+    * while trailing whitespace is left as is.
+    * <P>
+    * See Format::parseObject() for more.
+    *
+    * @param source    The string to be parsed into an object.
+    * @param result    Formattable to be set to the parse result.
+    *                  If parse fails, return contents are undefined.
+    * @param parse_pos The position to start parsing at. Upon return
+    *                  this param is set to the position after the
+    *                  last character successfully parsed. If the
+    *                  source is not parsed successfully, this param
+    *                  will remain unchanged.
+    * @draft ICU 4.0
+    */
+   virtual void parseObject(const UnicodeString& source,
+                            Formattable& result,
+                            ParsePosition& parse_pos) const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @draft ICU 4.0
+     *
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @draft ICU 4.0
+     */
+     virtual UClassID getDynamicClassID() const;
+
+private:
+    typedef enum fmtToken {
+        none,
+        tLetter,
+        tNumber,
+        tSpace,
+        tNumberSign,
+        tLeftBrace,
+        tRightBrace
+    }fmtToken;
+
+    Locale  locale;
+    PluralRules* pluralRules;
+    UnicodeString pattern;
+    Hashtable  *fParsedValuesHash;
+    NumberFormat*  numberFormat;
+    NumberFormat*  replacedNumberFormat;
+
+    PluralFormat();   // default constructor not implemented
+    void init(const PluralRules* rules, const Locale& curlocale, UErrorCode& status);
+    UBool inRange(UChar ch, fmtToken& type);
+    UBool checkSufficientDefinition();
+    void parsingFailure();
+    UnicodeString insertFormattedNumber(double number,
+                                        UnicodeString& message,
+                                        UnicodeString& appendTo,
+                                        FieldPosition& pos) const;
+    void copyHashtable(Hashtable *other, UErrorCode& status);
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _PLURFMT
+//eof
diff --git a/CoreFoundation/icu/unicode/plurrule.h b/CoreFoundation/icu/unicode/plurrule.h
new file mode 100644
index 0000000..7c3fedb
--- /dev/null
+++ b/CoreFoundation/icu/unicode/plurrule.h
@@ -0,0 +1,291 @@
+/*
+*******************************************************************************
+* Copyright (C) 2008, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*
+*
+* File PLURRULE.H
+*
+* Modification History:*
+*   Date        Name        Description
+*
+********************************************************************************
+*/
+
+#ifndef PLURRULE
+#define PLURRULE
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: PluralRules object
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/format.h"
+
+U_NAMESPACE_BEGIN
+
+class Hashtable;
+class RuleChain;
+class RuleParser;
+
+/**
+ * Defines rules for mapping positive long values onto a small set of
+ * keywords. Rules are constructed from a text description, consisting
+ * of a series of keywords and conditions.  The {@link #select} method
+ * examines each condition in order and returns the keyword for the
+ * first condition that matches the number.  If none match,
+ * default rule(other) is returned.
+ *
+ * Examples:<pre>
+ *   "one: n is 1; few: n in 2..4"</pre>
+ *  This defines two rules, for 'one' and 'few'.  The condition for
+ *  'one' is "n is 1" which means that the number must be equal to
+ *  1 for this condition to pass.  The condition for 'few' is
+ *  "n in 2..4" which means that the number must be between 2 and
+ *  4 inclusive for this condition to pass.  All other numbers
+ *  are assigned the keyword "other" by the default rule.
+ *  </p><pre>
+ *    "zero: n is 0; one: n is 1; zero: n mod 100 in 1..19"</pre>
+ *  This illustrates that the same keyword can be defined multiple times.
+ *  Each rule is examined in order, and the first keyword whose condition
+ *  passes is the one returned.  Also notes that a modulus is applied
+ *  to n in the last rule.  Thus its condition holds for 119, 219, 319...
+ *  </p><pre>
+ *    "one: n is 1; few: n mod 10 in 2..4 and n mod 100 not in 12..14"</pre>
+ *  This illustrates conjunction and negation.  The condition for 'few'
+ *  has two parts, both of which must be met: "n mod 10 in 2..4" and
+ *  "n mod 100 not in 12..14".  The first part applies a modulus to n
+ *  before the test as in the previous example.  The second part applies
+ *  a different modulus and also uses negation, thus it matches all
+ *  numbers _not_ in 12, 13, 14, 112, 113, 114, 212, 213, 214...
+ *  </p>
+ *  <p>
+ * Syntax:<pre>
+ * rules         = rule (';' rule)*
+ * rule          = keyword ':' condition
+ * keyword       = <identifier>
+ * condition     = and_condition ('or' and_condition)*
+ * and_condition = relation ('and' relation)*
+ * relation      = is_relation | in_relation | within_relation | 'n' <EOL>
+ * is_relation   = expr 'is' ('not')? value
+ * in_relation   = expr ('not')? 'in' range
+ * within_relation = expr ('not')? 'within' range
+ * expr          = 'n' ('mod' value)?
+ * value         = digit+
+ * digit         = 0|1|2|3|4|5|6|7|8|9
+ * range         = value'..'value
+ * </pre></p>
+ * <p>
+ *  The difference between 'in' and 'within' is that 'in' only includes
+ *  integers in the specified range, while 'within' includes all values.</p>
+ *  <p>
+ *  Keywords
+ *  could be defined by users or from ICU locale data. There are 6
+ *  predefined values in ICU - 'zero', 'one', 'two', 'few', 'many' and
+ *  'other'. Callers need to check the value of keyword returned by
+ *  {@link #select} method.
+ *  </p>
+ *
+ * Examples:<pre>
+ * UnicodeString keyword = pl->select(number);
+ * if (keyword== UnicodeString("one") {
+ *     ...
+ * }
+ * else if ( ... )
+ * </pre>
+ */
+class U_I18N_API PluralRules : public UObject {
+public:
+
+    /**
+     * Constructor.
+     * @param status  Output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     *
+     * @draft ICU 4.0
+     */
+    PluralRules(UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     * @draft ICU 4.0
+     */
+    PluralRules(const PluralRules& other);
+
+    /**
+     * Destructor.
+     * @draft ICU 4.0
+     */
+    virtual ~PluralRules();
+
+    /**
+     * Clone
+     * @draft ICU 4.0
+     */
+    PluralRules* clone() const;
+
+    /**
+      * Assignment operator.
+      * @draft ICU 4.0
+      */
+    PluralRules& operator=(const PluralRules&);
+
+    /**
+     * Creates a PluralRules from a description if it is parsable, otherwise
+     * returns null.
+     *
+     * @param description rule description
+     * @param status      Output param set to success/failure code on exit, which
+     *                    must not indicate a failure before the function call.
+     * @return            new PluralRules pointer. NULL if there is an error.
+     * @draft ICU 4.0
+     */
+    static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,
+                                              UErrorCode& status);
+
+    /**
+     * The default rules that accept any number.
+     *
+     * @param status  Output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @return        new PluralRules pointer. NULL if there is an error.
+     * @draft ICU 4.0
+     */
+    static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);
+
+    /**
+     * Provides access to the predefined <code>PluralRules</code> for a given
+     * locale.
+     *
+     * @param locale  The locale for which a <code>PluralRules</code> object is
+     *                returned.
+     * @param status  Output param set to success/failure code on exit, which
+     *                must not indicate a failure before the function call.
+     * @return        The predefined <code>PluralRules</code> object pointer for
+     *                this locale. If there's no predefined rules for this locale,
+     *                the rules for the closest parent in the locale hierarchy
+     *                that has one will  be returned.  The final fallback always
+     *                returns the default 'other' rules.
+     * @draft ICU 4.0
+     */
+    static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);
+    
+    /**
+     * Given a number, returns the keyword of the first rule that applies to
+     * the number.  This function can be used with isKeyword* functions to
+     * determine the keyword for default plural rules.
+     *
+     * @param number  The number for which the rule has to be determined.
+     * @return        The keyword of the selected rule.
+     * @draft ICU 4.0
+     */
+    UnicodeString select(int32_t number) const;
+    
+    /**
+     * Given a number, returns the keyword of the first rule that applies to
+     * the number.  This function can be used with isKeyword* functions to
+     * determine the keyword for default plural rules.
+     *
+     * @param number  The number for which the rule has to be determined.
+     * @return        The keyword of the selected rule.
+     * @draft ICU 4.0
+     */
+    UnicodeString select(double number) const;
+
+    /**
+     * Returns a list of all rule keywords used in this <code>PluralRules</code>
+     * object.  The rule 'other' is always present by default.
+     *
+     * @param status Output param set to success/failure code on exit, which
+     *               must not indicate a failure before the function call.
+     * @return       StringEnumeration with the keywords.
+     *               The caller must delete the object.
+     * @draft ICU 4.0
+     */
+    StringEnumeration* getKeywords(UErrorCode& status) const;
+
+    /**
+     * Returns TRUE if the given keyword is defined in this
+     * <code>PluralRules</code> object.
+     *
+     * @param keyword  the input keyword.
+     * @return         TRUE if the input keyword is defined.
+     *                 Otherwise, return FALSE.
+     * @draft ICU 4.0
+     */
+    UBool isKeyword(const UnicodeString& keyword) const;
+
+
+    /**
+     * Returns keyword for default plural form.
+     *
+     * @return         keyword for default plural form.
+     * @internal 4.0
+     * @draft ICU 4.0
+     */
+    UnicodeString getKeywordOther() const;
+
+    /**
+     * Compares the equality of two PluralRules objects.
+     *
+     * @param other The other PluralRules object to be compared with.
+     * @return      True if the given PluralRules is the same as this
+     *              PluralRules; false otherwise.
+     * @draft ICU 4.0
+     */
+    virtual UBool operator==(const PluralRules& other) const;
+
+    /**
+     * Compares the inequality of two PluralRules objects.
+     *
+     * @param other The PluralRules object to be compared with.
+     * @return      True if the given PluralRules is not the same as this
+     *              PluralRules; false otherwise.
+     * @draft ICU 4.0
+     */
+    UBool operator!=(const PluralRules& other) const  {return !operator==(other);}
+
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @draft ICU 4.0
+     *
+    */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @draft ICU 4.0
+     */
+    virtual UClassID getDynamicClassID() const;
+
+
+private:
+    Hashtable       *fLocaleStringsHash;
+    UnicodeString   mLocaleName;
+    RuleChain       *mRules;
+    RuleParser      *mParser;
+
+    PluralRules();   // default constructor not implemented
+    int32_t getRepeatLimit() const;
+    void parseDescription(UnicodeString& ruleData, RuleChain& rules, UErrorCode &status);
+    void getNextLocale(const UnicodeString& localeData, int32_t* curIndex, UnicodeString& localeName);
+    void addRules(RuleChain& rules);
+    int32_t getNumberValue(const UnicodeString& token) const;
+    UnicodeString getRuleFromResource(const Locale& locale, UErrorCode& status);
+
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _PLURRULE
+//eof
diff --git a/CoreFoundation/icu/unicode/ppalmos.h b/CoreFoundation/icu/unicode/ppalmos.h
new file mode 100755
index 0000000..c15b2ce
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ppalmos.h
@@ -0,0 +1,273 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1997-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+*  FILE NAME : ppalmos.h
+*
+*   Date        Name        Description
+*   05/10/04    Ken Krugler Creation (copied from pwin32.h & modified).
+******************************************************************************
+*/
+
+#ifndef U_PPALMOS_H
+#define U_PPALMOS_H
+
+ /**
+  * \file
+  * \brief Configuration constants for the Palm OS platform
+  */
+  
+/* Define the platform we're on. */
+#ifndef U_PALMOS
+#define U_PALMOS
+#endif
+
+/* _MSC_VER is used to detect the Microsoft compiler. */
+#if defined(_MSC_VER)
+#define U_INT64_IS_LONG_LONG 0
+#else
+#define U_INT64_IS_LONG_LONG 1
+#endif
+
+/* Define whether inttypes.h is available */
+#ifndef U_HAVE_INTTYPES_H
+#define U_HAVE_INTTYPES_H 1
+#endif
+
+/*
+ * Define what support for C++ streams is available.
+ *     If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available
+ * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
+ * one should qualify streams using the std namespace in ICU header
+ * files.
+ *     If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is
+ * available instead (198506 is the date when Stroustrup published
+ * "An Extensible I/O Facility for C++" at the summer USENIX conference).
+ *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
+ * support for them will be silently suppressed in ICU.
+ *
+ */
+
+#ifndef U_IOSTREAM_SOURCE
+#define U_IOSTREAM_SOURCE 199711
+#endif
+
+/* Determines whether specific types are available */
+#ifndef U_HAVE_INT8_T
+#define U_HAVE_INT8_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT8_T
+#define U_HAVE_UINT8_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_INT16_T
+#define U_HAVE_INT16_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT16_T
+#define U_HAVE_UINT16_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_INT32_T
+#define U_HAVE_INT32_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT32_T
+#define U_HAVE_UINT32_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_INT64_T
+#define U_HAVE_INT64_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT64_T
+#define U_HAVE_UINT64_T U_HAVE_INTTYPES_H
+#endif
+
+
+/*===========================================================================*/
+/* Generic data types                                                        */
+/*===========================================================================*/
+
+/* If your platform does not have the <inttypes.h> header, you may
+   need to edit the typedefs below. */
+#if U_HAVE_INTTYPES_H
+#include <inttypes.h>
+#else /* U_HAVE_INTTYPES_H */
+
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+
+#if ! U_HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+
+#if ! U_HAVE_INT16_T
+typedef signed short int16_t;
+#endif
+
+#if ! U_HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+
+#if ! U_HAVE_INT32_T
+typedef signed int int32_t;
+#endif
+
+#if ! U_HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+
+#if ! U_HAVE_INT64_T
+#if U_INT64_IS_LONG_LONG
+    typedef signed long long int64_t;
+#else
+    typedef signed __int64 int64_t;
+#endif
+#endif
+
+#if ! U_HAVE_UINT64_T
+#if U_INT64_IS_LONG_LONG
+    typedef unsigned long long uint64_t;
+#else
+    typedef unsigned __int64 uint64_t;
+#endif
+#endif
+#endif
+
+/*===========================================================================*/
+/* Compiler and environment features                                         */
+/*===========================================================================*/
+
+/* Define whether namespace is supported */
+#ifndef U_HAVE_NAMESPACE
+#define U_HAVE_NAMESPACE 1
+#endif
+
+/* Determines the endianness of the platform */
+#define U_IS_BIG_ENDIAN 0
+
+/* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
+#define ICU_USE_THREADS 1
+
+#ifndef U_DEBUG
+#ifdef _DEBUG
+#define U_DEBUG 1
+#else
+#define U_DEBUG 0
+#endif
+#endif
+
+#ifndef U_RELEASE
+#ifdef NDEBUG
+#define U_RELEASE 1
+#else
+#define U_RELEASE 0
+#endif
+#endif
+
+/* Determine whether to disable renaming or not. This overrides the
+   setting in umachine.h which is for all platforms. */
+#ifndef U_DISABLE_RENAMING
+#define U_DISABLE_RENAMING 0
+#endif
+
+/* Determine whether to override new and delete. */
+#ifndef U_OVERRIDE_CXX_ALLOCATION
+#define U_OVERRIDE_CXX_ALLOCATION 1
+#endif
+/* Determine whether to override placement new and delete for STL. */
+#ifndef U_HAVE_PLACEMENT_NEW
+#define U_HAVE_PLACEMENT_NEW 0
+#endif
+/* Determine whether to override new and delete for MFC. */
+#if !defined(U_HAVE_DEBUG_LOCATION_NEW) && defined(_MSC_VER)
+#define U_HAVE_DEBUG_LOCATION_NEW 0
+#endif
+
+/* Determine whether to enable tracing. */
+#ifndef U_ENABLE_TRACING
+#define U_ENABLE_TRACING 1
+#endif
+
+/* Do we allow ICU users to use the draft APIs by default? */
+#ifndef U_DEFAULT_SHOW_DRAFT
+#define U_DEFAULT_SHOW_DRAFT 1
+#endif
+
+/* Define the library suffix in a C syntax. */
+#define U_HAVE_LIB_SUFFIX 0
+#define U_LIB_SUFFIX_C_NAME 
+#define U_LIB_SUFFIX_C_NAME_STRING ""
+
+/*===========================================================================*/
+/* Information about wchar support                                           */
+/*===========================================================================*/
+
+#define U_HAVE_WCHAR_H 1
+#define U_SIZEOF_WCHAR_T 2
+
+#define U_HAVE_WCSCPY    0
+
+/*===========================================================================*/
+/* Information about POSIX support                                           */
+/*===========================================================================*/
+
+
+/* TODO: Fix Palm OS's determination of a timezone */
+#if 0
+#define U_TZSET         _tzset
+#endif
+#if 0
+#define U_TIMEZONE      _timezone
+#endif
+#if 0
+#define U_TZNAME        _tzname
+#endif
+
+#define U_HAVE_MMAP 0
+#define U_HAVE_POPEN 0
+
+/*===========================================================================*/
+/* Symbol import-export control                                              */
+/*===========================================================================*/
+
+#define U_EXPORT
+#define U_EXPORT2
+#define U_IMPORT
+
+/*===========================================================================*/
+/* Code alignment and C function inlining                                    */
+/*===========================================================================*/
+
+#ifndef U_INLINE
+#   ifdef __cplusplus
+#       define U_INLINE inline
+#   else
+#       define U_INLINE __inline
+#   endif
+#endif
+
+#if defined(_MSC_VER) && defined(_M_IX86)
+#define U_ALIGN_CODE(val)    __asm      align val
+#else
+#define U_ALIGN_CODE(val)
+#endif
+
+
+/*===========================================================================*/
+/* Programs used by ICU code                                                 */
+/*===========================================================================*/
+
+#ifndef U_MAKE
+#define U_MAKE  "nmake"
+#define U_MAKE_IS_NMAKE 1
+#endif
+
+#endif
diff --git a/CoreFoundation/icu/unicode/putil.h b/CoreFoundation/icu/unicode/putil.h
new file mode 100644
index 0000000..3304877
--- /dev/null
+++ b/CoreFoundation/icu/unicode/putil.h
@@ -0,0 +1,184 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1997-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+*  FILE NAME : putil.h
+*
+*   Date        Name        Description
+*   05/14/98    nos         Creation (content moved here from utypes.h).
+*   06/17/99    erm         Added IEEE_754
+*   07/22/98    stephen     Added IEEEremainder, max, min, trunc
+*   08/13/98    stephen     Added isNegativeInfinity, isPositiveInfinity
+*   08/24/98    stephen     Added longBitsFromDouble
+*   03/02/99    stephen     Removed openFile().  Added AS400 support.
+*   04/15/99    stephen     Converted to C
+*   11/15/99    helena      Integrated S/390 changes for IEEE support.
+*   01/11/00    helena      Added u_getVersion.
+******************************************************************************
+*/
+
+#ifndef PUTIL_H
+#define PUTIL_H
+
+#include "unicode/utypes.h"
+ /**
+  * \file
+  * \brief C API: Platform Utilities
+  */
+  
+/* Define this to 1 if your platform supports IEEE 754 floating point,
+   to 0 if it does not. */
+#ifndef IEEE_754
+#   define IEEE_754 1
+#endif
+
+/*==========================================================================*/
+/* Platform utilities                                                       */
+/*==========================================================================*/
+
+/**
+ * Platform utilities isolates the platform dependencies of the
+ * libarary.  For each platform which this code is ported to, these
+ * functions may have to be re-implemented.
+ */
+
+/**
+ * Return the ICU data directory. 
+ * The data directory is where common format ICU data files (.dat files)
+ *   are loaded from.  Note that normal use of the built-in ICU
+ *   facilities does not require loading of an external data file;
+ *   unless you are adding custom data to ICU, the data directory
+ *   does not need to be set.
+ *
+ * The data directory is determined as follows:
+ *    If u_setDataDirectory() has been called, that is it, otherwise
+ *    if the ICU_DATA environment variable is set, use that, otherwise
+ *    If a data directory was specifed at ICU build time
+ *      <code>( #define ICU_DATA_DIR "path" )</code>, use that,
+ *    otherwise no data directory is available.
+ *
+ * @return the data directory, or an empty string ("") if no data directory has
+ *         been specified.
+ *   
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2 u_getDataDirectory(void);
+
+/** 
+ * Set the ICU data directory. 
+ * The data directory is where common format ICU data files (.dat files)
+ *   are loaded from.  Note that normal use of the built-in ICU
+ *   facilities does not require loading of an external data file;
+ *   unless you are adding custom data to ICU, the data directory
+ *   does not need to be set.
+ *
+ * This function should be called at most once in a process, before the
+ * first ICU operation (e.g., u_init()) that will require the loading of an
+ * ICU data file.
+ * This function is not thread-safe. Use it before calling ICU APIs from
+ * multiple threads.
+ *
+ * @param directory The directory to be set.
+ *
+ * @see u_init
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);
+
+/**
+ * Please use ucnv_getDefaultName() instead.
+ * Return the default codepage for this platform and locale.
+ * This function can call setlocale() on Unix platforms. Please read the
+ * platform documentation on setlocale() before calling this function.
+ * @return the default codepage for this platform 
+ * @internal
+ */
+U_INTERNAL const char*  U_EXPORT2 uprv_getDefaultCodepage(void);
+
+/**
+ * Please use uloc_getDefault() instead.
+ * Return the default locale ID string by querying ths system, or
+ *     zero if one cannot be found. 
+ * This function can call setlocale() on Unix platforms. Please read the
+ * platform documentation on setlocale() before calling this function.
+ * @return the default locale ID string
+ * @internal
+ */
+U_INTERNAL const char*  U_EXPORT2 uprv_getDefaultLocaleID(void);
+
+/**
+ * Filesystem file and path separator characters.
+ * Example: '/' and ':' on Unix, '\\' and ';' on Windows.
+ * @stable ICU 2.0
+ */
+#ifdef XP_MAC
+#   define U_FILE_SEP_CHAR ':'
+#   define U_FILE_ALT_SEP_CHAR ':'
+#   define U_PATH_SEP_CHAR ';'
+#   define U_FILE_SEP_STRING ":"
+#   define U_FILE_ALT_SEP_STRING ":"
+#   define U_PATH_SEP_STRING ";"
+#elif defined(U_WINDOWS)
+#   define U_FILE_SEP_CHAR '\\'
+#   define U_FILE_ALT_SEP_CHAR '/'
+#   define U_PATH_SEP_CHAR ';'
+#   define U_FILE_SEP_STRING "\\"
+#   define U_FILE_ALT_SEP_STRING "/"
+#   define U_PATH_SEP_STRING ";"
+#else
+#   define U_FILE_SEP_CHAR '/'
+#   define U_FILE_ALT_SEP_CHAR '/'
+#   define U_PATH_SEP_CHAR ':'
+#   define U_FILE_SEP_STRING "/"
+#   define U_FILE_ALT_SEP_STRING "/"
+#   define U_PATH_SEP_STRING ":"
+#endif
+
+/**
+ * Convert char characters to UChar characters.
+ * This utility function is useful only for "invariant characters"
+ * that are encoded in the platform default encoding.
+ * They are a small, constant subset of the encoding and include
+ * just the latin letters, digits, and some punctuation.
+ * For details, see U_CHARSET_FAMILY.
+ *
+ * @param cs Input string, points to <code>length</code>
+ *           character bytes from a subset of the platform encoding.
+ * @param us Output string, points to memory for <code>length</code>
+ *           Unicode characters.
+ * @param length The number of characters to convert; this may
+ *               include the terminating <code>NUL</code>.
+ *
+ * @see U_CHARSET_FAMILY
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+u_charsToUChars(const char *cs, UChar *us, int32_t length);
+
+/**
+ * Convert UChar characters to char characters.
+ * This utility function is useful only for "invariant characters"
+ * that can be encoded in the platform default encoding.
+ * They are a small, constant subset of the encoding and include
+ * just the latin letters, digits, and some punctuation.
+ * For details, see U_CHARSET_FAMILY.
+ *
+ * @param us Input string, points to <code>length</code>
+ *           Unicode characters that can be encoded with the
+ *           codepage-invariant subset of the platform encoding.
+ * @param cs Output string, points to memory for <code>length</code>
+ *           character bytes.
+ * @param length The number of characters to convert; this may
+ *               include the terminating <code>NUL</code>.
+ *
+ * @see U_CHARSET_FAMILY
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+u_UCharsToChars(const UChar *us, char *cs, int32_t length);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/pwin32.h b/CoreFoundation/icu/unicode/pwin32.h
new file mode 100644
index 0000000..9aad353
--- /dev/null
+++ b/CoreFoundation/icu/unicode/pwin32.h
@@ -0,0 +1,311 @@
+/*
+ ******************************************************************************
+ *
+ *   Copyright (C) 1997-2007, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ *
+ ******************************************************************************
+ *
+ *  FILE NAME : platform.h
+ *
+ *   Date        Name        Description
+ *   05/13/98    nos         Creation (content moved here from ptypes.h).
+ *   03/02/99    stephen     Added AS400 support.
+ *   03/30/99    stephen     Added Linux support.
+ *   04/13/99    stephen     Reworked for autoconf.
+ ******************************************************************************
+ */
+
+ /**
+  * \file
+  * \brief Configuration constants for the Windows platform
+  */
+  
+/* Define the platform we're on. */
+#ifndef U_WINDOWS
+#define U_WINDOWS
+#endif
+
+#if defined(__BORLANDC__)
+#define U_HAVE_PLACEMENT_NEW 0
+#define U_HAVE_INTTYPES_H 1
+#define __STDC_CONSTANT_MACROS
+#endif
+
+/* _MSC_VER is used to detect the Microsoft compiler. */
+#if defined(_MSC_VER)
+#define U_INT64_IS_LONG_LONG 0
+#else
+#define U_INT64_IS_LONG_LONG 1
+#endif
+
+/* Define whether inttypes.h is available */
+#ifndef U_HAVE_INTTYPES_H
+#define U_HAVE_INTTYPES_H 0
+#endif
+
+/*
+ * Define what support for C++ streams is available.
+ *     If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available
+ * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
+ * one should qualify streams using the std namespace in ICU header
+ * files.
+ *     If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is
+ * available instead (198506 is the date when Stroustrup published
+ * "An Extensible I/O Facility for C++" at the summer USENIX conference).
+ *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
+ * support for them will be silently suppressed in ICU.
+ *
+ */
+
+#ifndef U_IOSTREAM_SOURCE
+#define U_IOSTREAM_SOURCE 199711
+#endif
+
+/* Determines whether specific types are available */
+#ifndef U_HAVE_INT8_T
+#define U_HAVE_INT8_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT8_T
+#define U_HAVE_UINT8_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_INT16_T
+#define U_HAVE_INT16_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT16_T
+#define U_HAVE_UINT16_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_INT32_T
+#define U_HAVE_INT32_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT32_T
+#define U_HAVE_UINT32_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_INT64_T
+#define U_HAVE_INT64_T U_HAVE_INTTYPES_H
+#endif
+
+#ifndef U_HAVE_UINT64_T
+#define U_HAVE_UINT64_T U_HAVE_INTTYPES_H
+#endif
+
+/* Define 64 bit limits */
+#if !U_INT64_IS_LONG_LONG
+# ifndef INT64_C
+#  define INT64_C(x) ((int64_t)x)
+# endif
+# ifndef UINT64_C
+#  define UINT64_C(x) ((uint64_t)x)
+# endif
+/* else use the umachine.h definition */
+#endif
+
+/*===========================================================================*/
+/* Generic data types                                                        */
+/*===========================================================================*/
+
+/* If your platform does not have the <inttypes.h> header, you may
+   need to edit the typedefs below. */
+#if U_HAVE_INTTYPES_H
+#include <inttypes.h>
+#else /* U_HAVE_INTTYPES_H */
+
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+
+#if ! U_HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+
+#if ! U_HAVE_INT16_T
+typedef signed short int16_t;
+#endif
+
+#if ! U_HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+
+#if ! U_HAVE_INT32_T
+typedef signed int int32_t;
+#endif
+
+#if ! U_HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+
+#if ! U_HAVE_INT64_T
+#if U_INT64_IS_LONG_LONG
+    typedef signed long long int64_t;
+#else
+    typedef signed __int64 int64_t;
+#endif
+#endif
+
+#if ! U_HAVE_UINT64_T
+#if U_INT64_IS_LONG_LONG
+    typedef unsigned long long uint64_t;
+#else
+    typedef unsigned __int64 uint64_t;
+#endif
+#endif
+#endif
+
+/*===========================================================================*/
+/* Compiler and environment features                                         */
+/*===========================================================================*/
+
+/* Define whether namespace is supported */
+#ifndef U_HAVE_NAMESPACE
+#define U_HAVE_NAMESPACE 1
+#endif
+
+/* Determines the endianness of the platform */
+#define U_IS_BIG_ENDIAN 0
+
+/* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
+#define ICU_USE_THREADS 1
+
+/* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check mutex lock. */
+/*
+Microsoft can define _M_IX86, _M_AMD64 (before Visual Studio 8) or _M_X64 (starting in Visual Studio 8). 
+Intel can define _M_IX86 or _M_X64
+*/
+#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
+#define UMTX_STRONG_MEMORY_MODEL 1
+#endif
+
+#ifndef U_DEBUG
+#ifdef _DEBUG
+#define U_DEBUG 1
+#else
+#define U_DEBUG 0
+#endif
+#endif
+
+#ifndef U_RELEASE
+#ifdef NDEBUG
+#define U_RELEASE 1
+#else
+#define U_RELEASE 0
+#endif
+#endif
+
+/* Determine whether to disable renaming or not. This overrides the
+   setting in umachine.h which is for all platforms. */
+#ifndef U_DISABLE_RENAMING
+#define U_DISABLE_RENAMING 0
+#endif
+
+/* Determine whether to override new and delete. */
+#ifndef U_OVERRIDE_CXX_ALLOCATION
+#define U_OVERRIDE_CXX_ALLOCATION 1
+#endif
+/* Determine whether to override placement new and delete for STL. */
+#ifndef U_HAVE_PLACEMENT_NEW
+#define U_HAVE_PLACEMENT_NEW 1
+#endif
+/* Determine whether to override new and delete for MFC. */
+#if !defined(U_HAVE_DEBUG_LOCATION_NEW) && defined(_MSC_VER)
+#define U_HAVE_DEBUG_LOCATION_NEW 1
+#endif
+
+/* Determine whether to enable tracing. */
+#ifndef U_ENABLE_TRACING
+#define U_ENABLE_TRACING 0
+#endif
+
+/* Do we allow ICU users to use the draft APIs by default? */
+#ifndef U_DEFAULT_SHOW_DRAFT
+#define U_DEFAULT_SHOW_DRAFT 1
+#endif
+
+/* Define the library suffix in a C syntax. */
+#define U_HAVE_LIB_SUFFIX 0
+#define U_LIB_SUFFIX_C_NAME 
+#define U_LIB_SUFFIX_C_NAME_STRING ""
+
+/*===========================================================================*/
+/* Information about wchar support                                           */
+/*===========================================================================*/
+
+#define U_HAVE_WCHAR_H 1
+#define U_SIZEOF_WCHAR_T 2
+
+#define U_HAVE_WCSCPY 1
+
+/**
+ * \def U_DECLARE_UTF16
+ * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros
+ * instead.
+ * @internal
+ */
+#if 1
+#define U_DECLARE_UTF16(string) L ## string
+#endif
+
+/*===========================================================================*/
+/* Information about POSIX support                                           */
+/*===========================================================================*/
+
+#if 1
+#define U_TZSET         _tzset
+#endif
+#if 1
+#define U_TIMEZONE      _timezone
+#endif
+#if 1
+#define U_TZNAME        _tzname
+#endif
+#if 1
+#define U_DAYLIGHT      _daylight
+#endif
+
+#define U_HAVE_MMAP 0
+#define U_HAVE_POPEN 0
+
+/*===========================================================================*/
+/* Symbol import-export control                                              */
+/*===========================================================================*/
+
+#ifdef U_STATIC_IMPLEMENTATION
+#define U_EXPORT
+#else
+#define U_EXPORT __declspec(dllexport)
+#endif
+#define U_EXPORT2 __cdecl
+#define U_IMPORT __declspec(dllimport)
+
+/*===========================================================================*/
+/* Code alignment and C function inlining                                    */
+/*===========================================================================*/
+
+#ifndef U_INLINE
+#   ifdef __cplusplus
+#       define U_INLINE inline
+#   else
+#       define U_INLINE __inline
+#   endif
+#endif
+
+#if defined(_MSC_VER) && defined(_M_IX86) && !defined(_MANAGED)
+#define U_ALIGN_CODE(val)    __asm      align val
+#else
+#define U_ALIGN_CODE(val)
+#endif
+
+
+/*===========================================================================*/
+/* Programs used by ICU code                                                 */
+/*===========================================================================*/
+
+#ifndef U_MAKE
+#define U_MAKE  "nmake"
+#define U_MAKE_IS_NMAKE 1
+#endif
diff --git a/CoreFoundation/icu/unicode/rbbi.h b/CoreFoundation/icu/unicode/rbbi.h
new file mode 100644
index 0000000..90ec6e6
--- /dev/null
+++ b/CoreFoundation/icu/unicode/rbbi.h
@@ -0,0 +1,722 @@
+/*
+***************************************************************************
+*   Copyright (C) 1999-2008 International Business Machines Corporation   *
+*   and others. All rights reserved.                                      *
+***************************************************************************
+
+**********************************************************************
+*   Date        Name        Description
+*   10/22/99    alan        Creation.
+*   11/11/99    rgillam     Complete port from Java.
+**********************************************************************
+*/
+
+#ifndef RBBI_H
+#define RBBI_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C++ API: Rule Based Break Iterator
+ */
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+#include "unicode/brkiter.h"
+#include "unicode/udata.h"
+#include "unicode/parseerr.h"
+#include "unicode/schriter.h"
+#include "unicode/uchriter.h"
+
+
+struct UTrie;
+
+U_NAMESPACE_BEGIN
+
+/** @internal */
+struct RBBIDataHeader;
+class  RuleBasedBreakIteratorTables;
+class  BreakIterator;
+class  RBBIDataWrapper;
+class  UStack;
+class  LanguageBreakEngine;
+class  UnhandledEngine;
+struct RBBIStateTable;
+
+
+
+
+/**
+ *
+ * A subclass of BreakIterator whose behavior is specified using a list of rules.
+ * <p>Instances of this class are most commonly created by the factory methods of
+ *  BreakIterator::createWordInstance(), BreakIterator::createLineInstance(), etc.,
+ *  and then used via the abstract API in class BreakIterator</p>
+ *
+ * <p>See the ICU User Guide for information on Break Iterator Rules.</p>
+ *
+ * <p>This class is not intended to be subclassed.  (Class DictionaryBasedBreakIterator
+ *    is a subclass, but that relationship is effectively internal to the ICU
+ *    implementation.  The subclassing interface to RulesBasedBreakIterator is
+ *    not part of the ICU API, and may not remain stable.</p>
+ *
+ */
+class U_COMMON_API RuleBasedBreakIterator : public BreakIterator {
+
+protected:
+    /**
+     * The UText through which this BreakIterator accesses the text
+     * @internal
+     */
+    UText  *fText;
+
+    /**
+     *   A character iterator that refers to the same text as the UText, above.
+     *   Only included for compatibility with old API, which was based on CharacterIterators.
+     *   Value may be adopted from outside, or one of fSCharIter or fDCharIter, below.
+     */
+    CharacterIterator  *fCharIter;
+
+    /**
+     *   When the input text is provided by a UnicodeString, this will point to
+     *    a characterIterator that wraps that data.  Needed only for the
+     *    implementation of getText(), a backwards compatibility issue.
+     */
+    StringCharacterIterator *fSCharIter;
+
+    /**
+     *  When the input text is provided by a UText, this
+     *    dummy CharacterIterator over an empty string will
+     *    be returned from getText()
+     */
+    UCharCharacterIterator *fDCharIter;
+
+    /**
+     * The rule data for this BreakIterator instance
+     * @internal
+     */
+    RBBIDataWrapper    *fData;
+
+    /** Index of the Rule {tag} values for the most recent match.
+     *  @internal
+    */
+    int32_t             fLastRuleStatusIndex;
+
+    /**
+     * Rule tag value valid flag.
+     * Some iterator operations don't intrinsically set the correct tag value.
+     * This flag lets us lazily compute the value if we are ever asked for it.
+     * @internal
+     */
+    UBool               fLastStatusIndexValid;
+
+    /**
+     * Counter for the number of characters encountered with the "dictionary"
+     *   flag set.
+     * @internal
+     */
+    uint32_t            fDictionaryCharCount;
+
+    /**
+     * When a range of characters is divided up using the dictionary, the break
+     * positions that are discovered are stored here, preventing us from having
+     * to use either the dictionary or the state table again until the iterator
+     * leaves this range of text. Has the most impact for line breaking.
+     * @internal
+     */
+    int32_t*            fCachedBreakPositions;
+
+    /**
+     * The number of elements in fCachedBreakPositions
+     * @internal
+     */
+    int32_t             fNumCachedBreakPositions;
+
+    /**
+     * if fCachedBreakPositions is not null, this indicates which item in the
+     * cache the current iteration position refers to
+     * @internal
+     */
+    int32_t             fPositionInCache;
+    
+    /**
+     *
+     * If present, UStack of LanguageBreakEngine objects that might handle
+     * dictionary characters. Searched from top to bottom to find an object to
+     * handle a given character.
+     * @internal
+     */
+    UStack              *fLanguageBreakEngines;
+    
+    /**
+     *
+     * If present, the special LanguageBreakEngine used for handling
+     * characters that are in the dictionary set, but not handled by any
+     * LangugageBreakEngine.
+     * @internal
+     */
+    UnhandledEngine     *fUnhandledBreakEngine;
+    
+    /**
+     *
+     * The type of the break iterator, or -1 if it has not been set.
+     * @internal
+     */
+    int32_t             fBreakType;
+    
+protected:
+    //=======================================================================
+    // constructors
+    //=======================================================================
+
+    /**
+     * Constant to be used in the constructor
+     * RuleBasedBreakIterator(RBBIDataHeader*, EDontAdopt, UErrorCode &);
+     * which does not adopt the memory indicated by the RBBIDataHeader*
+     * parameter.
+     *
+     * @internal
+     */
+    enum EDontAdopt {
+        kDontAdopt
+    };
+
+    /**
+     * Constructor from a flattened set of RBBI data in malloced memory.
+     *             RulesBasedBreakIterators built from a custom set of rules
+     *             are created via this constructor; the rules are compiled
+     *             into memory, then the break iterator is constructed here.
+     *
+     *             The break iterator adopts the memory, and will
+     *             free it when done.
+     * @internal
+     */
+    RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status);
+
+    /**
+     * Constructor from a flattened set of RBBI data in memory which need not
+     *             be malloced (e.g. it may be a memory-mapped file, etc.).
+     *
+     *             This version does not adopt the memory, and does not
+     *             free it when done.
+     * @internal
+     */
+    RuleBasedBreakIterator(const RBBIDataHeader* data, enum EDontAdopt dontAdopt, UErrorCode &status);
+
+
+    friend class RBBIRuleBuilder;
+    /** @internal */
+    friend class BreakIterator;
+
+
+
+public:
+
+    /** Default constructor.  Creates an empty shell of an iterator, with no
+     *  rules or text to iterate over.   Object can subsequently be assigned to.
+     *  @stable ICU 2.2
+     */
+    RuleBasedBreakIterator();
+
+    /**
+     * Copy constructor.  Will produce a break iterator with the same behavior,
+     * and which iterates over the same text, as the one passed in.
+     * @param that The RuleBasedBreakIterator passed to be copied
+     * @stable ICU 2.0
+     */
+    RuleBasedBreakIterator(const RuleBasedBreakIterator& that);
+
+    /**
+     * Construct a RuleBasedBreakIterator from a set of rules supplied as a string.
+     * @param rules The break rules to be used.
+     * @param parseError  In the event of a syntax error in the rules, provides the location
+     *                    within the rules of the problem.
+     * @param status Information on any errors encountered.
+     * @stable ICU 2.2
+     */
+    RuleBasedBreakIterator( const UnicodeString    &rules,
+                             UParseError           &parseError,
+                             UErrorCode            &status);
+
+
+    /**
+     * This constructor uses the udata interface to create a BreakIterator
+     * whose internal tables live in a memory-mapped file.  "image" is an
+     * ICU UDataMemory handle for the pre-compiled break iterator tables.
+     * @param image handle to the memory image for the break iterator data.
+     *        Ownership of the UDataMemory handle passes to the Break Iterator,
+     *        which will be responsible for closing it when it is no longer needed.
+     * @param status Information on any errors encountered.
+     * @see udata_open
+     * @see #getBinaryRules
+     * @stable ICU 2.8
+     */
+    RuleBasedBreakIterator(UDataMemory* image, UErrorCode &status);
+
+    /**
+     * Destructor
+     *  @stable ICU 2.0
+     */
+    virtual ~RuleBasedBreakIterator();
+
+    /**
+     * Assignment operator.  Sets this iterator to have the same behavior,
+     * and iterate over the same text, as the one passed in.
+     * @param that The RuleBasedBreakItertor passed in
+     * @return the newly created RuleBasedBreakIterator
+     *  @stable ICU 2.0
+     */
+    RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);
+
+    /**
+     * Equality operator.  Returns TRUE if both BreakIterators are of the
+     * same class, have the same behavior, and iterate over the same text.
+     * @param that The BreakIterator to be compared for equality
+     * @return TRUE if both BreakIterators are of the
+     * same class, have the same behavior, and iterate over the same text.
+     *  @stable ICU 2.0
+     */
+    virtual UBool operator==(const BreakIterator& that) const;
+
+    /**
+     * Not-equal operator.  If operator== returns TRUE, this returns FALSE,
+     * and vice versa.
+     * @param that The BreakIterator to be compared for inequality
+     * @return TRUE if both BreakIterators are not same.
+     *  @stable ICU 2.0
+     */
+    UBool operator!=(const BreakIterator& that) const;
+
+    /**
+     * Returns a newly-constructed RuleBasedBreakIterator with the same
+     * behavior, and iterating over the same text, as this one.
+     * Differs from the copy constructor in that it is polymorphic, and
+     * will correctly clone (copy) a derived class.
+     * clone() is thread safe.  Multiple threads may simultaeneously
+     * clone the same source break iterator.
+     * @return a newly-constructed RuleBasedBreakIterator
+     * @stable ICU 2.0
+     */
+    virtual BreakIterator* clone() const;
+
+    /**
+     * Compute a hash code for this BreakIterator
+     * @return A hash code
+     *  @stable ICU 2.0
+     */
+    virtual int32_t hashCode(void) const;
+
+    /**
+     * Returns the description used to create this iterator
+     * @return the description used to create this iterator
+     *  @stable ICU 2.0
+     */
+    virtual const UnicodeString& getRules(void) const;
+
+    //=======================================================================
+    // BreakIterator overrides
+    //=======================================================================
+
+    /**
+     * <p>
+     * Return a CharacterIterator over the text being analyzed.
+     * The returned character iterator is owned by the break iterator, and must
+     * not be deleted by the caller.  Repeated calls to this function may
+     * return the same CharacterIterator.
+     * </p>
+     * <p>
+     * The returned character iterator must not be used concurrently with
+     * the break iterator.  If concurrent operation is needed, clone the
+     * returned character iterator first and operate on the clone.
+     * </p>
+     * <p>
+     * When the break iterator is operating on text supplied via a UText,
+     * this function will fail.  Lacking any way to signal failures, it
+     * returns an CharacterIterator containing no text.
+     * The function getUText() provides similar functionality,
+     * is reliable, and is more efficient.
+     * </p>
+     *
+     * TODO:  deprecate this function?
+     *
+     * @return An iterator over the text being analyzed.
+     * @stable ICU 2.0
+     */
+    virtual  CharacterIterator& getText(void) const;
+
+
+    /**
+      *  Get a UText for the text being analyzed.
+      *  The returned UText is a shallow clone of the UText used internally
+      *  by the break iterator implementation.  It can safely be used to
+      *  access the text without impacting any break iterator operations,
+      *  but the underlying text itself must not be altered.
+      *
+      * @param fillIn A UText to be filled in.  If NULL, a new UText will be
+      *           allocated to hold the result.
+      * @param status receives any error codes.
+      * @return   The current UText for this break iterator.  If an input
+      *           UText was provided, it will always be returned.
+      * @stable ICU 3.4
+      */
+     virtual UText *getUText(UText *fillIn, UErrorCode &status) const;
+
+    /**
+     * Set the iterator to analyze a new piece of text.  This function resets
+     * the current iteration position to the beginning of the text.
+     * @param newText An iterator over the text to analyze.  The BreakIterator
+     * takes ownership of the character iterator.  The caller MUST NOT delete it!
+     *  @stable ICU 2.0
+     */
+    virtual void adoptText(CharacterIterator* newText);
+
+    /**
+     * Set the iterator to analyze a new piece of text.  This function resets
+     * the current iteration position to the beginning of the text.
+     * @param newText The text to analyze.
+     *  @stable ICU 2.0
+     */
+    virtual void setText(const UnicodeString& newText);
+
+    /**
+     * Reset the break iterator to operate over the text represented by
+     * the UText.  The iterator position is reset to the start.
+     *
+     * This function makes a shallow clone of the supplied UText.  This means
+     * that the caller is free to immediately close or otherwise reuse the
+     * Utext that was passed as a parameter, but that the underlying text itself
+     * must not be altered while being referenced by the break iterator.
+     *
+     * @param text    The UText used to change the text.
+     * @param status  Receives any error codes.
+     * @stable ICU 3.4
+     */
+    virtual void  setText(UText *text, UErrorCode &status);
+
+    /**
+     * Sets the current iteration position to the beginning of the text.
+     * @return The offset of the beginning of the text.
+     *  @stable ICU 2.0
+     */
+    virtual int32_t first(void);
+
+    /**
+     * Sets the current iteration position to the end of the text.
+     * @return The text's past-the-end offset.
+     *  @stable ICU 2.0
+     */
+    virtual int32_t last(void);
+
+    /**
+     * Advances the iterator either forward or backward the specified number of steps.
+     * Negative values move backward, and positive values move forward.  This is
+     * equivalent to repeatedly calling next() or previous().
+     * @param n The number of steps to move.  The sign indicates the direction
+     * (negative is backwards, and positive is forwards).
+     * @return The character offset of the boundary position n boundaries away from
+     * the current one.
+     *  @stable ICU 2.0
+     */
+    virtual int32_t next(int32_t n);
+
+    /**
+     * Advances the iterator to the next boundary position.
+     * @return The position of the first boundary after this one.
+     *  @stable ICU 2.0
+     */
+    virtual int32_t next(void);
+
+    /**
+     * Moves the iterator backwards, to the last boundary preceding this one.
+     * @return The position of the last boundary position preceding this one.
+     *  @stable ICU 2.0
+     */
+    virtual int32_t previous(void);
+
+    /**
+     * Sets the iterator to refer to the first boundary position following
+     * the specified position.
+     * @param offset The position from which to begin searching for a break position.
+     * @return The position of the first break after the current position.
+     *  @stable ICU 2.0
+     */
+    virtual int32_t following(int32_t offset);
+
+    /**
+     * Sets the iterator to refer to the last boundary position before the
+     * specified position.
+     * @param offset The position to begin searching for a break from.
+     * @return The position of the last boundary before the starting position.
+     *  @stable ICU 2.0
+     */
+    virtual int32_t preceding(int32_t offset);
+
+    /**
+     * Returns true if the specfied position is a boundary position.  As a side
+     * effect, leaves the iterator pointing to the first boundary position at
+     * or after "offset".
+     * @param offset the offset to check.
+     * @return True if "offset" is a boundary position.
+     *  @stable ICU 2.0
+     */
+    virtual UBool isBoundary(int32_t offset);
+
+    /**
+     * Returns the current iteration position.
+     * @return The current iteration position.
+     * @stable ICU 2.0
+     */
+    virtual int32_t current(void) const;
+
+
+    /**
+     * Return the status tag from the break rule that determined the most recently
+     * returned break position.  For break rules that do not specify a
+     * status, a default value of 0 is returned.  If more than one break rule
+     * would cause a boundary to be located at some position in the text,
+     * the numerically largest of the applicable status values is returned.
+     * <p>
+     * Of the standard types of ICU break iterators, only word break and
+     * line break provide status values.  The values are defined in
+     * the header file ubrk.h.  For Word breaks, the status allows distinguishing between words
+     * that contain alphabetic letters, "words" that appear to be numbers,
+     * punctuation and spaces, words containing ideographic characters, and
+     * more.  For Line Break, the status distinguishes between hard (mandatory) breaks
+     * and soft (potential) break positions.
+     * <p>
+     * <code>getRuleStatus()</code> can be called after obtaining a boundary
+     * position from <code>next()</code>, <code>previous()</code>, or
+     * any other break iterator functions that returns a boundary position.
+     * <p>
+     * When creating custom break rules, one is free to define whatever
+     * status values may be convenient for the application.
+     * <p>
+     * Note: this function is not thread safe.  It should not have been
+     *       declared const, and the const remains only for compatibility
+     *       reasons.  (The function is logically const, but not bit-wise const).
+     * <p>
+     * @return the status from the break rule that determined the most recently
+     * returned break position.
+     *
+     * @see UWordBreak
+     * @stable ICU 2.2
+     */
+    virtual int32_t getRuleStatus() const;
+
+   /**
+    * Get the status (tag) values from the break rule(s) that determined the most
+    * recently returned break position.
+    * <p>
+    * The returned status value(s) are stored into an array provided by the caller.
+    * The values are stored in sorted (ascending) order.
+    * If the capacity of the output array is insufficient to hold the data,
+    *  the output will be truncated to the available length, and a
+    *  U_BUFFER_OVERFLOW_ERROR will be signaled.
+    *
+    * @param fillInVec an array to be filled in with the status values.
+    * @param capacity  the length of the supplied vector.  A length of zero causes
+    *                  the function to return the number of status values, in the
+    *                  normal way, without attemtping to store any values.
+    * @param status    receives error codes.
+    * @return          The number of rule status values from rules that determined
+    *                  the most recent boundary returned by the break iterator.
+    *                  In the event of a U_BUFFER_OVERFLOW_ERROR, the return value
+    *                  is the total number of status values that were available,
+    *                  not the reduced number that were actually returned.
+    * @see getRuleStatus
+    * @stable ICU 3.0
+    */
+    virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.
+     * This method is to implement a simple version of RTTI, since not all
+     * C++ compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Returns the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     *
+     *      Base* polymorphic_pointer = createPolymorphicObject();
+     *      if (polymorphic_pointer->getDynamicClassID() ==
+     *          Derived::getStaticClassID()) ...
+     *
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /*
+     * Create a clone (copy) of this break iterator in memory provided
+     *  by the caller.  The idea is to increase performance by avoiding
+     *  a storage allocation.  Use of this functoin is NOT RECOMMENDED.
+     *  Performance gains are minimal, and correct buffer management is
+     *  tricky.  Use clone() instead.
+     *
+     * @param stackBuffer  The pointer to the memory into which the cloned object
+     *                     should be placed.  If NULL,  allocate heap memory
+     *                     for the cloned object.
+     * @param BufferSize   The size of the buffer.  If zero, return the required
+     *                     buffer size, but do not clone the object.  If the
+     *                     size was too small (but not zero), allocate heap
+     *                     storage for the cloned object.
+     *
+     * @param status       Error status.  U_SAFECLONE_ALLOCATED_WARNING will be
+     *                     returned if the the provided buffer was too small, and
+     *                     the clone was therefore put on the heap.
+     *
+     * @return  Pointer to the clone object.  This may differ from the stackBuffer
+     *          address if the byte alignment of the stack buffer was not suitable
+     *          or if the stackBuffer was too small to hold the clone.
+     * @stable ICU 2.0
+     */
+    virtual BreakIterator *  createBufferClone(void *stackBuffer,
+                                               int32_t &BufferSize,
+                                               UErrorCode &status);
+
+
+    /**
+     * Return the binary form of compiled break rules,
+     * which can then be used to create a new break iterator at some
+     * time in the future.  Creating a break iterator from pre-compiled rules
+     * is much faster than building one from the source form of the
+     * break rules.
+     *
+     * The binary data can only be used with the same version of ICU
+     *  and on the same platform type (processor endian-ness)
+     *
+     * @param length Returns the length of the binary data.  (Out paramter.)
+     *
+     * @return   A pointer to the binary (compiled) rule data.  The storage
+     *           belongs to the RulesBasedBreakIterator object, not the
+     *           caller, and must not be modified or deleted.
+     * @internal
+     */
+    virtual const uint8_t *getBinaryRules(uint32_t &length);
+
+
+protected:
+    //=======================================================================
+    // implementation
+    //=======================================================================
+    /**
+     * Dumps caches and performs other actions associated with a complete change
+     * in text or iteration position.
+     * @internal
+     */
+    virtual void reset(void);
+
+#if 0
+    /**
+      * Return true if the category lookup for this char
+      * indicates that it is in the set of dictionary lookup chars.
+      * This function is intended for use by dictionary based break iterators.
+      * @return true if the category lookup for this char
+      * indicates that it is in the set of dictionary lookup chars.
+      * @internal
+      */
+    virtual UBool isDictionaryChar(UChar32);
+
+    /**
+      * Get the type of the break iterator.
+      * @internal
+      */
+    virtual int32_t getBreakType() const;
+#endif
+
+    /**
+      * Set the type of the break iterator.
+      * @internal
+      */
+    virtual void setBreakType(int32_t type);
+
+    /**
+      * Common initialization function, used by constructors and bufferClone.
+      *   (Also used by DictionaryBasedBreakIterator::createBufferClone().)
+      * @internal
+      */
+    void init();
+
+private:
+
+    /**
+     * This method backs the iterator back up to a "safe position" in the text.
+     * This is a position that we know, without any context, must be a break position.
+     * The various calling methods then iterate forward from this safe position to
+     * the appropriate position to return.  (For more information, see the description
+     * of buildBackwardsStateTable() in RuleBasedBreakIterator.Builder.)
+     * @param statetable state table used of moving backwards
+     * @internal
+     */
+    int32_t handlePrevious(const RBBIStateTable *statetable);
+
+    /**
+     * This method is the actual implementation of the next() method.  All iteration
+     * vectors through here.  This method initializes the state machine to state 1
+     * and advances through the text character by character until we reach the end
+     * of the text or the state machine transitions to state 0.  We update our return
+     * value every time the state machine passes through a possible end state.
+     * @param statetable state table used of moving forwards
+     * @internal
+     */
+    int32_t handleNext(const RBBIStateTable *statetable);
+
+protected:
+
+    /**
+     * This is the function that actually implements dictionary-based
+     * breaking.  Covering at least the range from startPos to endPos,
+     * it checks for dictionary characters, and if it finds them determines
+     * the appropriate object to deal with them. It may cache found breaks in
+     * fCachedBreakPositions as it goes. It may well also look at text outside
+     * the range startPos to endPos.
+     * If going forward, endPos is the normal Unicode break result, and
+     * if goind in reverse, startPos is the normal Unicode break result
+     * @param startPos  The start position of a range of text
+     * @param endPos    The end position of a range of text
+     * @param reverse   The call is for the reverse direction
+     * @internal
+     */
+    int32_t checkDictionary(int32_t startPos, int32_t endPos, UBool reverse);
+
+private:
+
+    /**
+     * This function returns the appropriate LanguageBreakEngine for a
+     * given character c.
+     * @param c         A character in the dictionary set
+     * @internal
+     */
+    const LanguageBreakEngine *getLanguageBreakEngine(UChar32 c);
+
+    /**
+     *  @internal
+     */
+    void makeRuleStatusValid();
+
+};
+
+//------------------------------------------------------------------------------
+//
+//   Inline Functions Definitions ...
+//
+//------------------------------------------------------------------------------
+
+inline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const {
+    return !operator==(that);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/rbnf.h b/CoreFoundation/icu/unicode/rbnf.h
new file mode 100644
index 0000000..030565e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/rbnf.h
@@ -0,0 +1,1049 @@
+/*
+*******************************************************************************
+* Copyright (C) 1997-2006, International Business Machines Corporation and others.
+* All Rights Reserved.
+*******************************************************************************
+*/
+
+#ifndef RBNF_H
+#define RBNF_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Rule Based Number Format
+ */
+
+/**
+ * \def U_HAVE_RBNF
+ * This will be 0 if RBNF support is not included in ICU
+ * and 1 if it is.
+ *
+ * @stable ICU 2.4
+ */
+#if UCONFIG_NO_FORMATTING
+#define U_HAVE_RBNF 0
+#else
+#define U_HAVE_RBNF 1
+
+#include "unicode/coll.h"
+#include "unicode/dcfmtsym.h"
+#include "unicode/fmtable.h"
+#include "unicode/locid.h"
+#include "unicode/numfmt.h"
+#include "unicode/unistr.h"
+#include "unicode/strenum.h"
+
+U_NAMESPACE_BEGIN
+
+class NFRuleSet;
+class LocalizationInfo;
+
+/**
+ * Tags for the predefined rulesets.
+ *
+ * @stable ICU 2.2
+ */
+enum URBNFRuleSetTag {
+    URBNF_SPELLOUT,
+    URBNF_ORDINAL,
+    URBNF_DURATION,
+    URBNF_COUNT
+};
+
+#if UCONFIG_NO_COLLATION
+class Collator;
+#endif
+
+/**
+ * The RuleBasedNumberFormat class formats numbers according to a set of rules. This number formatter is
+ * typically used for spelling out numeric values in words (e.g., 25,3476 as
+ * &quot;twenty-five thousand three hundred seventy-six&quot; or &quot;vingt-cinq mille trois
+ * cents soixante-seize&quot; or
+ * &quot;f&uuml;nfundzwanzigtausenddreihundertsechsundsiebzig&quot;), but can also be used for
+ * other complicated formatting tasks, such as formatting a number of seconds as hours,
+ * minutes and seconds (e.g., 3,730 as &quot;1:02:10&quot;).
+ *
+ * <p>The resources contain three predefined formatters for each locale: spellout, which
+ * spells out a value in words (123 is &quot;one hundred twenty-three&quot;); ordinal, which
+ * appends an ordinal suffix to the end of a numeral (123 is &quot;123rd&quot;); and
+ * duration, which shows a duration in seconds as hours, minutes, and seconds (123 is
+ * &quot;2:03&quot;).&nbsp; The client can also define more specialized <tt>RuleBasedNumberFormat</tt>s
+ * by supplying programmer-defined rule sets.</p>
+ *
+ * <p>The behavior of a <tt>RuleBasedNumberFormat</tt> is specified by a textual description
+ * that is either passed to the constructor as a <tt>String</tt> or loaded from a resource
+ * bundle. In its simplest form, the description consists of a semicolon-delimited list of <em>rules.</em>
+ * Each rule has a string of output text and a value or range of values it is applicable to.
+ * In a typical spellout rule set, the first twenty rules are the words for the numbers from
+ * 0 to 19:</p>
+ *
+ * <pre>zero; one; two; three; four; five; six; seven; eight; nine;
+ * ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen; seventeen; eighteen; nineteen;</pre>
+ *
+ * <p>For larger numbers, we can use the preceding set of rules to format the ones place, and
+ * we only have to supply the words for the multiples of 10:</p>
+ *
+ * <pre> 20: twenty[-&gt;&gt;];
+ * 30: thirty[-&gt;&gt;];
+ * 40: forty[-&gt;&gt;];
+ * 50: fifty[-&gt;&gt;];
+ * 60: sixty[-&gt;&gt;];
+ * 70: seventy[-&gt;&gt;];
+ * 80: eighty[-&gt;&gt;];
+ * 90: ninety[-&gt;&gt;];</pre>
+ *
+ * <p>In these rules, the <em>base value</em> is spelled out explicitly and set off from the
+ * rule's output text with a colon. The rules are in a sorted list, and a rule is applicable
+ * to all numbers from its own base value to one less than the next rule's base value. The
+ * &quot;&gt;&gt;&quot; token is called a <em>substitution</em> and tells the fomatter to
+ * isolate the number's ones digit, format it using this same set of rules, and place the
+ * result at the position of the &quot;&gt;&gt;&quot; token. Text in brackets is omitted if
+ * the number being formatted is an even multiple of 10 (the hyphen is a literal hyphen; 24
+ * is &quot;twenty-four,&quot; not &quot;twenty four&quot;).</p>
+ *
+ * <p>For even larger numbers, we can actually look up several parts of the number in the
+ * list:</p>
+ *
+ * <pre>100: &lt;&lt; hundred[ &gt;&gt;];</pre>
+ *
+ * <p>The &quot;&lt;&lt;&quot; represents a new kind of substitution. The &lt;&lt; isolates
+ * the hundreds digit (and any digits to its left), formats it using this same rule set, and
+ * places the result where the &quot;&lt;&lt;&quot; was. Notice also that the meaning of
+ * &gt;&gt; has changed: it now refers to both the tens and the ones digits. The meaning of
+ * both substitutions depends on the rule's base value. The base value determines the rule's <em>divisor,</em>
+ * which is the highest power of 10 that is less than or equal to the base value (the user
+ * can change this). To fill in the substitutions, the formatter divides the number being
+ * formatted by the divisor. The integral quotient is used to fill in the &lt;&lt;
+ * substitution, and the remainder is used to fill in the &gt;&gt; substitution. The meaning
+ * of the brackets changes similarly: text in brackets is omitted if the value being
+ * formatted is an even multiple of the rule's divisor. The rules are applied recursively, so
+ * if a substitution is filled in with text that includes another substitution, that
+ * substitution is also filled in.</p>
+ *
+ * <p>This rule covers values up to 999, at which point we add another rule:</p>
+ *
+ * <pre>1000: &lt;&lt; thousand[ &gt;&gt;];</pre>
+ *
+ * <p>Again, the meanings of the brackets and substitution tokens shift because the rule's
+ * base value is a higher power of 10, changing the rule's divisor. This rule can actually be
+ * used all the way up to 999,999. This allows us to finish out the rules as follows:</p>
+ *
+ * <pre> 1,000,000: &lt;&lt; million[ &gt;&gt;];
+ * 1,000,000,000: &lt;&lt; billion[ &gt;&gt;];
+ * 1,000,000,000,000: &lt;&lt; trillion[ &gt;&gt;];
+ * 1,000,000,000,000,000: OUT OF RANGE!;</pre>
+ *
+ * <p>Commas, periods, and spaces can be used in the base values to improve legibility and
+ * are ignored by the rule parser. The last rule in the list is customarily treated as an
+ * &quot;overflow rule,&quot; applying to everything from its base value on up, and often (as
+ * in this example) being used to print out an error message or default representation.
+ * Notice also that the size of the major groupings in large numbers is controlled by the
+ * spacing of the rules: because in English we group numbers by thousand, the higher rules
+ * are separated from each other by a factor of 1,000.</p>
+ *
+ * <p>To see how these rules actually work in practice, consider the following example:
+ * Formatting 25,430 with this rule set would work like this:</p>
+ *
+ * <table border="0" width="100%">
+ *   <tr>
+ *     <td><strong>&lt;&lt; thousand &gt;&gt;</strong></td>
+ *     <td>[the rule whose base value is 1,000 is applicable to 25,340]</td>
+ *   </tr>
+ *   <tr>
+ *     <td><strong>twenty-&gt;&gt;</strong> thousand &gt;&gt;</td>
+ *     <td>[25,340 over 1,000 is 25. The rule for 20 applies.]</td>
+ *   </tr>
+ *   <tr>
+ *     <td>twenty-<strong>five</strong> thousand &gt;&gt;</td>
+ *     <td>[25 mod 10 is 5. The rule for 5 is &quot;five.&quot;</td>
+ *   </tr>
+ *   <tr>
+ *     <td>twenty-five thousand <strong>&lt;&lt; hundred &gt;&gt;</strong></td>
+ *     <td>[25,340 mod 1,000 is 340. The rule for 100 applies.]</td>
+ *   </tr>
+ *   <tr>
+ *     <td>twenty-five thousand <strong>three</strong> hundred &gt;&gt;</td>
+ *     <td>[340 over 100 is 3. The rule for 3 is &quot;three.&quot;]</td>
+ *   </tr>
+ *   <tr>
+ *     <td>twenty-five thousand three hundred <strong>forty</strong></td>
+ *     <td>[340 mod 100 is 40. The rule for 40 applies. Since 40 divides
+ *     evenly by 10, the hyphen and substitution in the brackets are omitted.]</td>
+ *   </tr>
+ * </table>
+ *
+ * <p>The above syntax suffices only to format positive integers. To format negative numbers,
+ * we add a special rule:</p>
+ *
+ * <pre>-x: minus &gt;&gt;;</pre>
+ *
+ * <p>This is called a <em>negative-number rule,</em> and is identified by &quot;-x&quot;
+ * where the base value would be. This rule is used to format all negative numbers. the
+ * &gt;&gt; token here means &quot;find the number's absolute value, format it with these
+ * rules, and put the result here.&quot;</p>
+ *
+ * <p>We also add a special rule called a <em>fraction rule </em>for numbers with fractional
+ * parts:</p>
+ *
+ * <pre>x.x: &lt;&lt; point &gt;&gt;;</pre>
+ *
+ * <p>This rule is used for all positive non-integers (negative non-integers pass through the
+ * negative-number rule first and then through this rule). Here, the &lt;&lt; token refers to
+ * the number's integral part, and the &gt;&gt; to the number's fractional part. The
+ * fractional part is formatted as a series of single-digit numbers (e.g., 123.456 would be
+ * formatted as &quot;one hundred twenty-three point four five six&quot;).</p>
+ *
+ * <p>To see how this rule syntax is applied to various languages, examine the resource data.</p>
+ *
+ * <p>There is actually much more flexibility built into the rule language than the
+ * description above shows. A formatter may own multiple rule sets, which can be selected by
+ * the caller, and which can use each other to fill in their substitutions. Substitutions can
+ * also be filled in with digits, using a DecimalFormat object. There is syntax that can be
+ * used to alter a rule's divisor in various ways. And there is provision for much more
+ * flexible fraction handling. A complete description of the rule syntax follows:</p>
+ *
+ * <hr>
+ *
+ * <p>The description of a <tt>RuleBasedNumberFormat</tt>'s behavior consists of one or more <em>rule
+ * sets.</em> Each rule set consists of a name, a colon, and a list of <em>rules.</em> A rule
+ * set name must begin with a % sign. Rule sets with names that begin with a single % sign
+ * are <em>public:</em> the caller can specify that they be used to format and parse numbers.
+ * Rule sets with names that begin with %% are <em>private:</em> they exist only for the use
+ * of other rule sets. If a formatter only has one rule set, the name may be omitted.</p>
+ *
+ * <p>The user can also specify a special &quot;rule set&quot; named <tt>%%lenient-parse</tt>.
+ * The body of <tt>%%lenient-parse</tt> isn't a set of number-formatting rules, but a <tt>RuleBasedCollator</tt>
+ * description which is used to define equivalences for lenient parsing. For more information
+ * on the syntax, see <tt>RuleBasedCollator</tt>. For more information on lenient parsing,
+ * see <tt>setLenientParse()</tt>.  <em>Note:</em> symbols that have syntactic meaning
+ * in collation rules, such as '&amp;', have no particular meaning when appearing outside
+ * of the <tt>lenient-parse</tt> rule set.</p>
+ *
+ * <p>The body of a rule set consists of an ordered, semicolon-delimited list of <em>rules.</em>
+ * Internally, every rule has a base value, a divisor, rule text, and zero, one, or two <em>substitutions.</em>
+ * These parameters are controlled by the description syntax, which consists of a <em>rule
+ * descriptor,</em> a colon, and a <em>rule body.</em></p>
+ *
+ * <p>A rule descriptor can take one of the following forms (text in <em>italics</em> is the
+ * name of a token):</p>
+ *
+ * <table border="0" width="100%">
+ *   <tr>
+ *     <td><em>bv</em>:</td>
+ *     <td><em>bv</em> specifies the rule's base value. <em>bv</em> is a decimal
+ *     number expressed using ASCII digits. <em>bv</em> may contain spaces, period, and commas,
+ *     which are ignored. The rule's divisor is the highest power of 10 less than or equal to
+ *     the base value.</td>
+ *   </tr>
+ *   <tr>
+ *     <td><em>bv</em>/<em>rad</em>:</td>
+ *     <td><em>bv</em> specifies the rule's base value. The rule's divisor is the
+ *     highest power of <em>rad</em> less than or equal to the base value.</td>
+ *   </tr>
+ *   <tr>
+ *     <td><em>bv</em>&gt;:</td>
+ *     <td><em>bv</em> specifies the rule's base value. To calculate the divisor,
+ *     let the radix be 10, and the exponent be the highest exponent of the radix that yields a
+ *     result less than or equal to the base value. Every &gt; character after the base value
+ *     decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix
+ *     raised to the power of the exponent; otherwise, the divisor is 1.</td>
+ *   </tr>
+ *   <tr>
+ *     <td><em>bv</em>/<em>rad</em>&gt;:</td>
+ *     <td><em>bv</em> specifies the rule's base value. To calculate the divisor,
+ *     let the radix be <em>rad</em>, and the exponent be the highest exponent of the radix that
+ *     yields a result less than or equal to the base value. Every &gt; character after the radix
+ *     decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix
+ *     raised to the power of the exponent; otherwise, the divisor is 1.</td>
+ *   </tr>
+ *   <tr>
+ *     <td>-x:</td>
+ *     <td>The rule is a negative-number rule.</td>
+ *   </tr>
+ *   <tr>
+ *     <td>x.x:</td>
+ *     <td>The rule is an <em>improper fraction rule.</em></td>
+ *   </tr>
+ *   <tr>
+ *     <td>0.x:</td>
+ *     <td>The rule is a <em>proper fraction rule.</em></td>
+ *   </tr>
+ *   <tr>
+ *     <td>x.0:</td>
+ *     <td>The rule is a <em>master rule.</em></td>
+ *   </tr>
+ *   <tr>
+ *     <td><em>nothing</em></td>
+ *     <td>If the rule's rule descriptor is left out, the base value is one plus the
+ *     preceding rule's base value (or zero if this is the first rule in the list) in a normal
+ *     rule set.&nbsp; In a fraction rule set, the base value is the same as the preceding rule's
+ *     base value.</td>
+ *   </tr>
+ * </table>
+ *
+ * <p>A rule set may be either a regular rule set or a <em>fraction rule set,</em> depending
+ * on whether it is used to format a number's integral part (or the whole number) or a
+ * number's fractional part. Using a rule set to format a rule's fractional part makes it a
+ * fraction rule set.</p>
+ *
+ * <p>Which rule is used to format a number is defined according to one of the following
+ * algorithms: If the rule set is a regular rule set, do the following:
+ *
+ * <ul>
+ *   <li>If the rule set includes a master rule (and the number was passed in as a <tt>double</tt>),
+ *     use the master rule.&nbsp; (If the number being formatted was passed in as a <tt>long</tt>,
+ *     the master rule is ignored.)</li>
+ *   <li>If the number is negative, use the negative-number rule.</li>
+ *   <li>If the number has a fractional part and is greater than 1, use the improper fraction
+ *     rule.</li>
+ *   <li>If the number has a fractional part and is between 0 and 1, use the proper fraction
+ *     rule.</li>
+ *   <li>Binary-search the rule list for the rule with the highest base value less than or equal
+ *     to the number. If that rule has two substitutions, its base value is not an even multiple
+ *     of its divisor, and the number <em>is</em> an even multiple of the rule's divisor, use the
+ *     rule that precedes it in the rule list. Otherwise, use the rule itself.</li>
+ * </ul>
+ *
+ * <p>If the rule set is a fraction rule set, do the following:
+ *
+ * <ul>
+ *   <li>Ignore negative-number and fraction rules.</li>
+ *   <li>For each rule in the list, multiply the number being formatted (which will always be
+ *     between 0 and 1) by the rule's base value. Keep track of the distance between the result
+ *     the nearest integer.</li>
+ *   <li>Use the rule that produced the result closest to zero in the above calculation. In the
+ *     event of a tie or a direct hit, use the first matching rule encountered. (The idea here is
+ *     to try each rule's base value as a possible denominator of a fraction. Whichever
+ *     denominator produces the fraction closest in value to the number being formatted wins.) If
+ *     the rule following the matching rule has the same base value, use it if the numerator of
+ *     the fraction is anything other than 1; if the numerator is 1, use the original matching
+ *     rule. (This is to allow singular and plural forms of the rule text without a lot of extra
+ *     hassle.)</li>
+ * </ul>
+ *
+ * <p>A rule's body consists of a string of characters terminated by a semicolon. The rule
+ * may include zero, one, or two <em>substitution tokens,</em> and a range of text in
+ * brackets. The brackets denote optional text (and may also include one or both
+ * substitutions). The exact meanings of the substitution tokens, and under what conditions
+ * optional text is omitted, depend on the syntax of the substitution token and the context.
+ * The rest of the text in a rule body is literal text that is output when the rule matches
+ * the number being formatted.</p>
+ *
+ * <p>A substitution token begins and ends with a <em>token character.</em> The token
+ * character and the context together specify a mathematical operation to be performed on the
+ * number being formatted. An optional <em>substitution descriptor </em>specifies how the
+ * value resulting from that operation is used to fill in the substitution. The position of
+ * the substitution token in the rule body specifies the location of the resultant text in
+ * the original rule text.</p>
+ *
+ * <p>The meanings of the substitution token characters are as follows:</p>
+ *
+ * <table border="0" width="100%">
+ *   <tr>
+ *     <td>&gt;&gt;</td>
+ *     <td>in normal rule</td>
+ *     <td>Divide the number by the rule's divisor and format the remainder</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in negative-number rule</td>
+ *     <td>Find the absolute value of the number and format the result</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in fraction or master rule</td>
+ *     <td>Isolate the number's fractional part and format it.</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in rule in fraction rule set</td>
+ *     <td>Not allowed.</td>
+ *   </tr>
+ *   <tr>
+ *     <td>&gt;&gt;&gt;</td>
+ *     <td>in normal rule</td>
+ *     <td>Divide the number by the rule's divisor and format the remainder,
+ *       but bypass the normal rule-selection process and just use the
+ *       rule that precedes this one in this rule list.</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in all other rules</td>
+ *     <td>Not allowed.</td>
+ *   </tr>
+ *   <tr>
+ *     <td>&lt;&lt;</td>
+ *     <td>in normal rule</td>
+ *     <td>Divide the number by the rule's divisor and format the quotient</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in negative-number rule</td>
+ *     <td>Not allowed.</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in fraction or master rule</td>
+ *     <td>Isolate the number's integral part and format it.</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in rule in fraction rule set</td>
+ *     <td>Multiply the number by the rule's base value and format the result.</td>
+ *   </tr>
+ *   <tr>
+ *     <td>==</td>
+ *     <td>in all rule sets</td>
+ *     <td>Format the number unchanged</td>
+ *   </tr>
+ *   <tr>
+ *     <td>[]</td>
+ *     <td>in normal rule</td>
+ *     <td>Omit the optional text if the number is an even multiple of the rule's divisor</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in negative-number rule</td>
+ *     <td>Not allowed.</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in improper-fraction rule</td>
+ *     <td>Omit the optional text if the number is between 0 and 1 (same as specifying both an
+ *     x.x rule and a 0.x rule)</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in master rule</td>
+ *     <td>Omit the optional text if the number is an integer (same as specifying both an x.x
+ *     rule and an x.0 rule)</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in proper-fraction rule</td>
+ *     <td>Not allowed.</td>
+ *   </tr>
+ *   <tr>
+ *     <td></td>
+ *     <td>in rule in fraction rule set</td>
+ *     <td>Omit the optional text if multiplying the number by the rule's base value yields 1.</td>
+ *   </tr>
+ * </table>
+ *
+ * <p>The substitution descriptor (i.e., the text between the token characters) may take one
+ * of three forms:</p>
+ *
+ * <table border="0" width="100%">
+ *   <tr>
+ *     <td>a rule set name</td>
+ *     <td>Perform the mathematical operation on the number, and format the result using the
+ *     named rule set.</td>
+ *   </tr>
+ *   <tr>
+ *     <td>a DecimalFormat pattern</td>
+ *     <td>Perform the mathematical operation on the number, and format the result using a
+ *     DecimalFormat with the specified pattern.&nbsp; The pattern must begin with 0 or #.</td>
+ *   </tr>
+ *   <tr>
+ *     <td>nothing</td>
+ *     <td>Perform the mathematical operation on the number, and format the result using the rule
+ *     set containing the current rule, except:
+ *     <ul>
+ *       <li>You can't have an empty substitution descriptor with a == substitution.</li>
+ *       <li>If you omit the substitution descriptor in a &gt;&gt; substitution in a fraction rule,
+ *         format the result one digit at a time using the rule set containing the current rule.</li>
+ *       <li>If you omit the substitution descriptor in a &lt;&lt; substitution in a rule in a
+ *         fraction rule set, format the result using the default rule set for this formatter.</li>
+ *     </ul>
+ *     </td>
+ *   </tr>
+ * </table>
+ *
+ * <p>Whitespace is ignored between a rule set name and a rule set body, between a rule
+ * descriptor and a rule body, or between rules. If a rule body begins with an apostrophe,
+ * the apostrophe is ignored, but all text after it becomes significant (this is how you can
+ * have a rule's rule text begin with whitespace). There is no escape function: the semicolon
+ * is not allowed in rule set names or in rule text, and the colon is not allowed in rule set
+ * names. The characters beginning a substitution token are always treated as the beginning
+ * of a substitution token.</p>
+ *
+ * <p>See the resource data and the demo program for annotated examples of real rule sets
+ * using these features.</p>
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ *
+ * <p><b>Localizations</b></p>
+ * <p>Constructors are available that allow the specification of localizations for the
+ * public rule sets (and also allow more control over what public rule sets are available).
+ * Localization data is represented as a textual description.  The description represents
+ * an array of arrays of string.  The first element is an array of the public rule set names,
+ * each of these must be one of the public rule set names that appear in the rules.  Only
+ * names in this array will be treated as public rule set names by the API.  Each subsequent
+ * element is an array of localizations of these names.  The first element of one of these
+ * subarrays is the locale name, and the remaining elements are localizations of the
+ * public rule set names, in the same order as they were listed in the first arrray.</p>
+ * <p>In the syntax, angle brackets '<', '>' are used to delimit the arrays, and comma ',' is used
+ * to separate elements of an array.  Whitespace is ignored, unless quoted.</p>
+ * <p>For example:<pre>
+ * < < %foo, %bar, %baz >, 
+ *   < en, Foo, Bar, Baz >, 
+ *   < fr, 'le Foo', 'le Bar', 'le Baz' > 
+ *   < zh, \\u7532, \\u4e59, \\u4e19 > >
+ * </pre></p>
+ * @author Richard Gillam
+ * @see NumberFormat
+ * @see DecimalFormat
+ * @stable ICU 2.0
+ */
+class U_I18N_API RuleBasedNumberFormat : public NumberFormat {
+public:
+
+  //-----------------------------------------------------------------------
+  // constructors
+  //-----------------------------------------------------------------------
+
+    /**
+     * Creates a RuleBasedNumberFormat that behaves according to the description
+     * passed in.  The formatter uses the default locale.
+     * @param rules A description of the formatter's desired behavior.
+     * See the class documentation for a complete explanation of the description
+     * syntax.
+     * @param perror The parse error if an error was encountered.
+     * @param status The status indicating whether the constructor succeeded.
+     * @stable ICU 3.2
+     */
+    RuleBasedNumberFormat(const UnicodeString& rules, UParseError& perror, UErrorCode& status);
+
+    /**
+     * Creates a RuleBasedNumberFormat that behaves according to the description
+     * passed in.  The formatter uses the default locale.  
+     * <p>
+     * The localizations data provides information about the public
+     * rule sets and their localized display names for different
+     * locales. The first element in the list is an array of the names
+     * of the public rule sets.  The first element in this array is
+     * the initial default ruleset.  The remaining elements in the
+     * list are arrays of localizations of the names of the public
+     * rule sets.  Each of these is one longer than the initial array,
+     * with the first String being the ULocale ID, and the remaining
+     * Strings being the localizations of the rule set names, in the
+     * same order as the initial array.  Arrays are NULL-terminated.
+     * @param rules A description of the formatter's desired behavior.
+     * See the class documentation for a complete explanation of the description
+     * syntax.
+     * @param localizations the localization information.
+     * names in the description.  These will be copied by the constructor.
+     * @param perror The parse error if an error was encountered.
+     * @param status The status indicating whether the constructor succeeded.
+     * @stable ICU 3.2
+     */
+    RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,
+                        UParseError& perror, UErrorCode& status);
+
+  /**
+   * Creates a RuleBasedNumberFormat that behaves according to the rules
+   * passed in.  The formatter uses the specified locale to determine the
+   * characters to use when formatting numerals, and to define equivalences
+   * for lenient parsing.
+   * @param rules The formatter rules.
+   * See the class documentation for a complete explanation of the rule
+   * syntax.
+   * @param locale A locale that governs which characters are used for
+   * formatting values in numerals and which characters are equivalent in
+   * lenient parsing.
+   * @param perror The parse error if an error was encountered.
+   * @param status The status indicating whether the constructor succeeded.
+   * @stable ICU 2.0
+   */
+  RuleBasedNumberFormat(const UnicodeString& rules, const Locale& locale,
+                        UParseError& perror, UErrorCode& status);
+
+    /**
+     * Creates a RuleBasedNumberFormat that behaves according to the description
+     * passed in.  The formatter uses the default locale.  
+     * <p>
+     * The localizations data provides information about the public
+     * rule sets and their localized display names for different
+     * locales. The first element in the list is an array of the names
+     * of the public rule sets.  The first element in this array is
+     * the initial default ruleset.  The remaining elements in the
+     * list are arrays of localizations of the names of the public
+     * rule sets.  Each of these is one longer than the initial array,
+     * with the first String being the ULocale ID, and the remaining
+     * Strings being the localizations of the rule set names, in the
+     * same order as the initial array.  Arrays are NULL-terminated.
+     * @param rules A description of the formatter's desired behavior.
+     * See the class documentation for a complete explanation of the description
+     * syntax.
+     * @param localizations a list of localizations for the rule set
+     * names in the description.  These will be copied by the constructor.
+     * @param locale A locale that governs which characters are used for
+     * formatting values in numerals and which characters are equivalent in
+     * lenient parsing.
+     * @param perror The parse error if an error was encountered.
+     * @param status The status indicating whether the constructor succeeded.
+     * @stable ICU 3.2
+     */
+    RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,
+                        const Locale& locale, UParseError& perror, UErrorCode& status);
+
+  /**
+   * Creates a RuleBasedNumberFormat from a predefined ruleset.  The selector
+   * code choosed among three possible predefined formats: spellout, ordinal,
+   * and duration.
+   * @param tag A selector code specifying which kind of formatter to create for that
+   * locale.  There are three legal values: URBNF_SPELLOUT, which creates a formatter that
+   * spells out a value in words in the desired language, URBNF_ORDINAL, which attaches
+   * an ordinal suffix from the desired language to the end of a number (e.g. "123rd"),
+   * and URBNF_DURATION, which formats a duration in seconds as hours, minutes, and seconds.
+   * @param locale The locale for the formatter.
+   * @param status The status indicating whether the constructor succeeded.
+   * @stable ICU 2.0
+   */
+  RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& locale, UErrorCode& status);
+
+  //-----------------------------------------------------------------------
+  // boilerplate
+  //-----------------------------------------------------------------------
+
+  /**
+   * Copy constructor
+   * @param rhs    the object to be copied from.
+   * @stable ICU 2.6
+   */
+  RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs);
+
+  /**
+   * Assignment operator
+   * @param rhs    the object to be copied from.
+   * @stable ICU 2.6
+   */
+  RuleBasedNumberFormat& operator=(const RuleBasedNumberFormat& rhs);
+
+  /**
+   * Release memory allocated for a RuleBasedNumberFormat when you are finished with it.
+   * @stable ICU 2.6
+   */
+  virtual ~RuleBasedNumberFormat();
+
+  /**
+   * Clone this object polymorphically.  The caller is responsible
+   * for deleting the result when done.
+   * @return  A copy of the object.
+   * @stable ICU 2.6
+   */
+  virtual Format* clone(void) const;
+
+  /**
+   * Return true if the given Format objects are semantically equal.
+   * Objects of different subclasses are considered unequal.
+   * @param other    the object to be compared with.
+   * @return        true if the given Format objects are semantically equal.
+   * @stable ICU 2.6
+   */
+  virtual UBool operator==(const Format& other) const;
+
+//-----------------------------------------------------------------------
+// public API functions
+//-----------------------------------------------------------------------
+
+  /**
+   * return the rules that were provided to the RuleBasedNumberFormat.
+   * @return the result String that was passed in
+   * @stable ICU 2.0
+   */
+  virtual UnicodeString getRules() const;
+
+  /**
+   * Return the number of public rule set names.
+   * @return the number of public rule set names.
+   * @stable ICU 2.0
+   */
+  virtual int32_t getNumberOfRuleSetNames() const;
+
+  /**
+   * Return the name of the index'th public ruleSet.  If index is not valid,
+   * the function returns null.
+   * @param index the index of the ruleset
+   * @return the name of the index'th public ruleSet.
+   * @stable ICU 2.0
+   */
+  virtual UnicodeString getRuleSetName(int32_t index) const;
+
+  /**
+   * Return the number of locales for which we have localized rule set display names.
+   * @return the number of locales for which we have localized rule set display names.
+   * @stable ICU 3.2
+   */
+  virtual int32_t getNumberOfRuleSetDisplayNameLocales(void) const;
+
+  /**
+   * Return the index'th display name locale.
+   * @param index the index of the locale
+   * @param status set to a failure code when this function fails
+   * @return the locale
+   * @see #getNumberOfRuleSetDisplayNameLocales
+   * @stable ICU 3.2
+   */
+  virtual Locale getRuleSetDisplayNameLocale(int32_t index, UErrorCode& status) const;
+
+    /**
+     * Return the rule set display names for the provided locale.  These are in the same order
+     * as those returned by getRuleSetName.  The locale is matched against the locales for
+     * which there is display name data, using normal fallback rules.  If no locale matches, 
+     * the default display names are returned.  (These are the internal rule set names minus
+     * the leading '%'.)
+     * @param index the index of the rule set
+     * @param locale the locale (returned by getRuleSetDisplayNameLocales) for which the localized
+     * display name is desired
+     * @return the display name for the given index, which might be bogus if there is an error
+     * @see #getRuleSetName
+     * @stable ICU 3.2
+     */
+  virtual UnicodeString getRuleSetDisplayName(int32_t index, 
+                          const Locale& locale = Locale::getDefault());
+
+    /**
+     * Return the rule set display name for the provided rule set and locale.  
+     * The locale is matched against the locales for which there is display name data, using
+     * normal fallback rules.  If no locale matches, the default display name is returned.
+     * @return the display name for the rule set
+     * @stable ICU 3.2
+     * @see #getRuleSetDisplayName
+     */
+  virtual UnicodeString getRuleSetDisplayName(const UnicodeString& ruleSetName, 
+                          const Locale& locale = Locale::getDefault());
+
+  /**
+   * Formats the specified 32-bit number using the default ruleset.
+   * @param number The number to format.
+   * @param toAppendTo the string that will hold the (appended) result
+   * @param pos the fieldposition
+   * @return A textual representation of the number.
+   * @stable ICU 2.0
+   */
+  virtual UnicodeString& format(int32_t number,
+                                UnicodeString& toAppendTo,
+                                FieldPosition& pos) const;
+
+  /**
+   * Formats the specified 64-bit number using the default ruleset.
+   * @param number The number to format.
+   * @param toAppendTo the string that will hold the (appended) result
+   * @param pos the fieldposition
+   * @return A textual representation of the number.
+   * @stable ICU 2.1
+   */
+  virtual UnicodeString& format(int64_t number,
+                                UnicodeString& toAppendTo,
+                                FieldPosition& pos) const;
+  /**
+   * Formats the specified number using the default ruleset.
+   * @param number The number to format.
+   * @param toAppendTo the string that will hold the (appended) result
+   * @param pos the fieldposition
+   * @return A textual representation of the number.
+   * @stable ICU 2.0
+   */
+  virtual UnicodeString& format(double number,
+                                UnicodeString& toAppendTo,
+                                FieldPosition& pos) const;
+
+  /**
+   * Formats the specified number using the named ruleset.
+   * @param number The number to format.
+   * @param ruleSetName The name of the rule set to format the number with.
+   * This must be the name of a valid public rule set for this formatter.
+   * @param toAppendTo the string that will hold the (appended) result
+   * @param pos the fieldposition
+   * @param status the status
+   * @return A textual representation of the number.
+   * @stable ICU 2.0
+   */
+  virtual UnicodeString& format(int32_t number,
+                                const UnicodeString& ruleSetName,
+                                UnicodeString& toAppendTo,
+                                FieldPosition& pos,
+                                UErrorCode& status) const;
+  /**
+   * Formats the specified 64-bit number using the named ruleset.
+   * @param number The number to format.
+   * @param ruleSetName The name of the rule set to format the number with.
+   * This must be the name of a valid public rule set for this formatter.
+   * @param toAppendTo the string that will hold the (appended) result
+   * @param pos the fieldposition
+   * @param status the status
+   * @return A textual representation of the number.
+   * @stable ICU 2.1
+   */
+  virtual UnicodeString& format(int64_t number,
+                                const UnicodeString& ruleSetName,
+                                UnicodeString& toAppendTo,
+                                FieldPosition& pos,
+                                UErrorCode& status) const;
+  /**
+   * Formats the specified number using the named ruleset.
+   * @param number The number to format.
+   * @param ruleSetName The name of the rule set to format the number with.
+   * This must be the name of a valid public rule set for this formatter.
+   * @param toAppendTo the string that will hold the (appended) result
+   * @param pos the fieldposition
+   * @param status the status
+   * @return A textual representation of the number.
+   * @stable ICU 2.0
+   */
+  virtual UnicodeString& format(double number,
+                                const UnicodeString& ruleSetName,
+                                UnicodeString& toAppendTo,
+                                FieldPosition& pos,
+                                UErrorCode& status) const;
+
+  /**
+   * Formats the specified number using the default ruleset.
+   * @param obj The number to format.
+   * @param toAppendTo the string that will hold the (appended) result
+   * @param pos the fieldposition
+   * @param status the status
+   * @return A textual representation of the number.
+   * @stable ICU 2.0
+   */
+  virtual UnicodeString& format(const Formattable& obj,
+                                UnicodeString& toAppendTo,
+                                FieldPosition& pos,
+                                UErrorCode& status) const;
+  /**
+   * Redeclared Format method.
+   * @param obj    the object to be formatted.
+   * @param result Output param which will receive the formatted string.
+   * @param status Output param set to success/failure code
+   * @return       A reference to 'result'.
+   * @stable ICU 2.0
+   */
+  UnicodeString& format(const Formattable& obj,
+                        UnicodeString& result,
+                        UErrorCode& status) const;
+
+  /**
+   * Redeclared NumberFormat method.
+   * @param number    the double value to be formatted.
+   * @param output    Output param which will receive the formatted string.
+   * @return          A reference to 'output'.
+   * @stable ICU 2.0
+   */
+   UnicodeString& format(double number,
+                         UnicodeString& output) const;
+
+  /**
+   * Redeclared NumberFormat method.
+   * @param number    the long value to be formatted.
+   * @param output    Output param which will receive the formatted string.
+   * @return          A reference to 'output'.
+   * @stable ICU 2.0
+   */
+   UnicodeString& format(int32_t number,
+                         UnicodeString& output) const;
+
+  /**
+   * Parses the specfied string, beginning at the specified position, according
+   * to this formatter's rules.  This will match the string against all of the
+   * formatter's public rule sets and return the value corresponding to the longest
+   * parseable substring.  This function's behavior is affected by the lenient
+   * parse mode.
+   * @param text The string to parse
+   * @param result the result of the parse, either a double or a long.
+   * @param parsePosition On entry, contains the position of the first character
+   * in "text" to examine.  On exit, has been updated to contain the position
+   * of the first character in "text" that wasn't consumed by the parse.
+   * @see #setLenient
+   * @stable ICU 2.0
+   */
+  virtual void parse(const UnicodeString& text,
+                     Formattable& result,
+                     ParsePosition& parsePosition) const;
+
+
+  /**
+   * Redeclared Format method.
+   * @param text   The string to parse
+   * @param result the result of the parse, either a double or a long.
+   * @param status Output param set to failure code when a problem occurs.
+   * @stable ICU 2.0
+   */
+  virtual inline void parse(const UnicodeString& text,
+                      Formattable& result,
+                      UErrorCode& status) const;
+
+#if !UCONFIG_NO_COLLATION
+
+  /**
+   * Turns lenient parse mode on and off.
+   *
+   * When in lenient parse mode, the formatter uses a Collator for parsing the text.
+   * Only primary differences are treated as significant.  This means that case
+   * differences, accent differences, alternate spellings of the same letter
+   * (e.g., ae and a-umlaut in German), ignorable characters, etc. are ignored in
+   * matching the text.  In many cases, numerals will be accepted in place of words
+   * or phrases as well.
+   *
+   * For example, all of the following will correctly parse as 255 in English in
+   * lenient-parse mode:
+   * <br>"two hundred fifty-five"
+   * <br>"two hundred fifty five"
+   * <br>"TWO HUNDRED FIFTY-FIVE"
+   * <br>"twohundredfiftyfive"
+   * <br>"2 hundred fifty-5"
+   *
+   * The Collator used is determined by the locale that was
+   * passed to this object on construction.  The description passed to this object
+   * on construction may supply additional collation rules that are appended to the
+   * end of the default collator for the locale, enabling additional equivalences
+   * (such as adding more ignorable characters or permitting spelled-out version of
+   * symbols; see the demo program for examples).
+   *
+   * It's important to emphasize that even strict parsing is relatively lenient: it
+   * will accept some text that it won't produce as output.  In English, for example,
+   * it will correctly parse "two hundred zero" and "fifteen hundred".
+   *
+   * @param enabled If true, turns lenient-parse mode on; if false, turns it off.
+   * @see RuleBasedCollator
+   * @stable ICU 2.0
+   */
+  virtual void setLenient(UBool enabled);
+
+  /**
+   * Returns true if lenient-parse mode is turned on.  Lenient parsing is off
+   * by default.
+   * @return true if lenient-parse mode is turned on.
+   * @see #setLenient
+   * @stable ICU 2.0
+   */
+  virtual inline UBool isLenient(void) const;
+
+#endif
+
+  /**
+   * Override the default rule set to use.  If ruleSetName is null, reset
+   * to the initial default rule set.  If the rule set is not a public rule set name,
+   * U_ILLEGAL_ARGUMENT_ERROR is returned in status.
+   * @param ruleSetName the name of the rule set, or null to reset the initial default.
+   * @param status set to failure code when a problem occurs.
+   * @stable ICU 2.6
+   */
+  virtual void setDefaultRuleSet(const UnicodeString& ruleSetName, UErrorCode& status);
+
+  /**
+   * Return the name of the current default rule set.  If the current rule set is
+   * not public, returns a bogus (and empty) UnicodeString.
+   * @return the name of the current default rule set
+   * @stable ICU 3.0
+   */
+  virtual UnicodeString getDefaultRuleSetName() const;
+
+public:
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.8
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.8
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+private:
+    RuleBasedNumberFormat(); // default constructor not implemented
+
+    // this will ref the localizations if they are not NULL
+    // caller must deref to get adoption 
+    RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* localizations, 
+              const Locale& locale, UParseError& perror, UErrorCode& status);
+
+    void init(const UnicodeString& rules, LocalizationInfo* localizations, UParseError& perror, UErrorCode& status);
+    void dispose();
+    void stripWhitespace(UnicodeString& src);
+    void initDefaultRuleSet();
+    void format(double number, NFRuleSet& ruleSet);
+    NFRuleSet* findRuleSet(const UnicodeString& name, UErrorCode& status) const;
+
+    /* friend access */
+    friend class NFSubstitution;
+    friend class NFRule;
+    friend class FractionalPartSubstitution;
+
+    inline NFRuleSet * getDefaultRuleSet() const;
+    Collator * getCollator() const;
+    DecimalFormatSymbols * getDecimalFormatSymbols() const;
+
+private:
+    NFRuleSet **ruleSets;
+    NFRuleSet *defaultRuleSet;
+    Locale locale;
+    Collator* collator;
+    DecimalFormatSymbols* decimalFormatSymbols;
+    UBool lenient;
+    UnicodeString* lenientParseRules;
+    LocalizationInfo* localizations;
+};
+
+// ---------------
+
+inline UnicodeString&
+RuleBasedNumberFormat::format(const Formattable& obj,
+                              UnicodeString& result,
+                              UErrorCode& status) const
+{
+    // Don't use Format:: - use immediate base class only,
+    // in case immediate base modifies behavior later.
+    // dlf - the above comment is bogus, if there were a reason to modify
+    // it, it would be virtual, and there's no reason because it is
+    // a one-line macro in NumberFormat anyway, just like this one.
+    return NumberFormat::format(obj, result, status);
+}
+
+inline UnicodeString&
+RuleBasedNumberFormat::format(double number, UnicodeString& output) const {
+    FieldPosition pos(0);
+    return format(number, output, pos);
+}
+
+inline UnicodeString&
+RuleBasedNumberFormat::format(int32_t number, UnicodeString& output) const {
+    FieldPosition pos(0);
+    return format(number, output, pos);
+}
+
+inline void
+RuleBasedNumberFormat::parse(const UnicodeString& text, Formattable& result, UErrorCode& status) const
+{
+    NumberFormat::parse(text, result, status);
+}
+
+#if !UCONFIG_NO_COLLATION
+
+inline UBool
+RuleBasedNumberFormat::isLenient(void) const {
+    return lenient;
+}
+
+#endif
+
+inline NFRuleSet*
+RuleBasedNumberFormat::getDefaultRuleSet() const {
+    return defaultRuleSet;
+}
+
+U_NAMESPACE_END
+
+/* U_HAVE_RBNF */
+#endif
+
+/* RBNF_H */
+#endif
diff --git a/CoreFoundation/icu/unicode/rbtz.h b/CoreFoundation/icu/unicode/rbtz.h
new file mode 100644
index 0000000..78215f3
--- /dev/null
+++ b/CoreFoundation/icu/unicode/rbtz.h
@@ -0,0 +1,361 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and    *
+* others. All Rights Reserved.                                                *
+*******************************************************************************
+*/
+#ifndef RBTZ_H
+#define RBTZ_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Rule based customizable time zone
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/basictz.h"
+#include "unicode/unistr.h"
+
+U_NAMESPACE_BEGIN
+
+// forward declaration
+class UVector;
+struct Transition;
+
+/**
+ * a BasicTimeZone subclass implemented in terms of InitialTimeZoneRule and TimeZoneRule instances
+ * @see BasicTimeZone
+ * @see InitialTimeZoneRule
+ * @see TimeZoneRule
+ */
+class U_I18N_API RuleBasedTimeZone : public BasicTimeZone {
+public:
+    /**
+     * Constructs a <code>RuleBasedTimeZone</code> object with the ID and the
+     * <code>InitialTimeZoneRule</code>.  The input <code>InitialTimeZoneRule</code>
+     * is adopted by this <code>RuleBasedTimeZone</code>, thus the caller must not
+     * delete it.
+     * @param id                The time zone ID.
+     * @param initialRule       The initial time zone rule.
+     * @stable ICU 4.0
+     */
+    RuleBasedTimeZone(const UnicodeString& id, InitialTimeZoneRule* initialRule);
+
+    /**
+     * Copy constructor.
+     * @param source    The RuleBasedTimeZone object to be copied.
+     * @stable ICU 4.0
+     */
+    RuleBasedTimeZone(const RuleBasedTimeZone& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~RuleBasedTimeZone();
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    RuleBasedTimeZone& operator=(const RuleBasedTimeZone& right);
+
+    /**
+     * Return true if the given <code>TimeZone</code> objects are
+     * semantically equal. Objects of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZone</code> objects are
+      *semantically equal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const TimeZone& that) const;
+
+    /**
+     * Return true if the given <code>TimeZone</code> objects are
+     * semantically unequal. Objects of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZone</code> objects are
+     * semantically unequal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator!=(const TimeZone& that) const;
+
+    /**
+     * Adds the <code>TimeZoneRule</code> which represents time transitions.
+     * The <code>TimeZoneRule</code> must have start times, that is, the result
+     * of isTransitionRule() must be true. Otherwise, U_ILLEGAL_ARGUMENT_ERROR
+     * is set to the error code.
+     * The input <code>TimeZoneRule</code> is adopted by this
+     * <code>RuleBasedTimeZone</code> on successful completion of this method,
+     * thus, the caller must not delete it when no error is returned.
+     * After all rules are added, the caller must call complete() method to
+     * make this <code>RuleBasedTimeZone</code> ready to handle common time
+     * zone functions.
+     * @param rule The <code>TimeZoneRule</code>.
+     * @param status Output param to filled in with a success or an error.
+     * @stable ICU 4.0
+     */
+    void addTransitionRule(TimeZoneRule* rule, UErrorCode& status);
+
+    /**
+     * Makes the <code>TimeZoneRule</code> ready to handle actual timezone
+     * calcuation APIs.  This method collects time zone rules specified
+     * by the caller via the constructor and addTransitionRule() and
+     * builds internal structure for making the object ready to support
+     * time zone APIs such as getOffset(), getNextTransition() and others.
+     * @param status Output param to filled in with a success or an error.
+     * @stable ICU 4.0
+     */
+    void complete(UErrorCode& status);
+
+    /**
+     * Clones TimeZone objects polymorphically. Clients are responsible for deleting
+     * the TimeZone object cloned.
+     *
+     * @return   A new copy of this TimeZone object.
+     * @stable ICU 4.0
+     */
+    virtual TimeZone* clone(void) const;
+
+    /**
+     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time in this time zone, taking daylight savings time into
+     * account) as of a particular reference date.  The reference date is used to determine
+     * whether daylight savings time is in effect and needs to be figured into the offset
+     * that is returned (in other words, what is the adjusted GMT offset in this time zone
+     * at this particular date and time?).  For the time zones produced by createTimeZone(),
+     * the reference data is specified according to the Gregorian calendar, and the date
+     * and time fields are local standard time.
+     *
+     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
+     * which returns both the raw and the DST offset for a given time. This method
+     * is retained only for backward compatibility.
+     *
+     * @param era        The reference date's era
+     * @param year       The reference date's year
+     * @param month      The reference date's month (0-based; 0 is January)
+     * @param day        The reference date's day-in-month (1-based)
+     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)
+     * @param millis     The reference date's milliseconds in day, local standard time
+     * @param status     Output param to filled in with a success or an error.
+     * @return           The offset in milliseconds to add to GMT to get local time.
+     * @stable ICU 4.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
+
+    /**
+     * Gets the time zone offset, for current date, modified in case of
+     * daylight savings. This is the offset to add *to* UTC to get local time.
+     *
+     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
+     * which returns both the raw and the DST offset for a given time. This method
+     * is retained only for backward compatibility.
+     *
+     * @param era        The reference date's era
+     * @param year       The reference date's year
+     * @param month      The reference date's month (0-based; 0 is January)
+     * @param day        The reference date's day-in-month (1-based)
+     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)
+     * @param millis     The reference date's milliseconds in day, local standard time
+     * @param monthLength The length of the given month in days.
+     * @param status     Output param to filled in with a success or an error.
+     * @return           The offset in milliseconds to add to GMT to get local time.
+     * @stable ICU 4.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                           uint8_t dayOfWeek, int32_t millis,
+                           int32_t monthLength, UErrorCode& status) const;
+
+    /**
+     * Returns the time zone raw and GMT offset for the given moment
+     * in time.  Upon return, local-millis = GMT-millis + rawOffset +
+     * dstOffset.  All computations are performed in the proleptic
+     * Gregorian calendar.  The default implementation in the TimeZone
+     * class delegates to the 8-argument getOffset().
+     *
+     * @param date moment in time for which to return offsets, in
+     * units of milliseconds from January 1, 1970 0:00 GMT, either GMT
+     * time or local wall time, depending on `local'.
+     * @param local if true, `date' is local wall time; otherwise it
+     * is in GMT time.
+     * @param rawOffset output parameter to receive the raw offset, that
+     * is, the offset not including DST adjustments
+     * @param dstOffset output parameter to receive the DST offset,
+     * that is, the offset to be added to `rawOffset' to obtain the
+     * total offset between local and GMT time. If DST is not in
+     * effect, this value is zero; otherwise it is a positive value,
+     * typically one hour.
+     * @param ec input-output error code
+     * @stable ICU 4.0
+     */
+    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
+                           int32_t& dstOffset, UErrorCode& ec) const;
+
+    /**
+     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @param offsetMillis  The new raw GMT offset for this time zone.
+     * @stable ICU 4.0
+     */
+    virtual void setRawOffset(int32_t offsetMillis);
+
+    /**
+     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @return   The TimeZone's raw GMT offset.
+     * @stable ICU 4.0
+     */
+    virtual int32_t getRawOffset(void) const;
+
+    /**
+     * Queries if this time zone uses daylight savings time.
+     * @return true if this time zone uses daylight savings time,
+     * false, otherwise.
+     * @stable ICU 4.0
+     */
+    virtual UBool useDaylightTime(void) const;
+
+    /**
+     * Queries if the given date is in daylight savings time in
+     * this time zone.
+     * This method is wasteful since it creates a new GregorianCalendar and
+     * deletes it each time it is called. This is a deprecated method
+     * and provided only for Java compatibility.
+     *
+     * @param date the given UDate.
+     * @param status Output param filled in with success/error code.
+     * @return true if the given date is in daylight savings time,
+     * false, otherwise.
+     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
+     */
+    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
+
+    /**
+     * Returns true if this zone has the same rule and offset as another zone.
+     * That is, if this zone differs only in ID, if at all.
+     * @param other the <code>TimeZone</code> object to be compared with
+     * @return true if the given zone is the same as this one,
+     * with the possible exception of the ID
+     * @stable ICU 4.0
+     */
+    virtual UBool hasSameRules(const TimeZone& other) const;
+
+    /**
+     * Gets the first time zone transition after the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the first transition after the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
+
+    /**
+     * Gets the most recent time zone transition before the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the most recent transition before the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
+
+    /**
+     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
+     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
+     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.
+     * @param status    Receives error status code.
+     * @return The number of <code>TimeZoneRule</code>s representing time transitions.
+     * @stable ICU 4.0
+     */
+    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;
+
+    /**
+     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
+     * which represent time transitions for this time zone.  On successful return,
+     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
+     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
+     * instances up to the size specified by trscount.  The results are referencing the
+     * rule instance held by this time zone instance.  Therefore, after this time zone
+     * is destructed, they are no longer available.
+     * @param initial       Receives the initial timezone rule
+     * @param trsrules      Receives the timezone transition rules
+     * @param trscount      On input, specify the size of the array 'transitions' receiving
+     *                      the timezone transition rules.  On output, actual number of
+     *                      rules filled in the array will be set.
+     * @param status        Receives error status code.
+     * @stable ICU 4.0
+     */
+    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
+        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;
+
+    /**
+     * Get time zone offsets from local wall time.
+     * @internal
+     */
+    virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,
+        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/;
+
+private:
+    void deleteRules(void);
+    void deleteTransitions(void);
+    UVector* copyRules(UVector* source);
+    TimeZoneRule* findRuleInFinal(UDate date, UBool local,
+        int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const;
+    UBool findNext(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;
+    UBool findPrev(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;
+    int32_t getLocalDelta(int32_t rawBefore, int32_t dstBefore, int32_t rawAfter, int32_t dstAfter,
+        int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const;
+    UDate getTransitionTime(Transition* transition, UBool local,
+        int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const;
+    void getOffsetInternal(UDate date, UBool local, int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt,
+        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& ec) const;
+
+    InitialTimeZoneRule *fInitialRule;
+    UVector             *fHistoricRules;
+    UVector             *fFinalRules;
+    UVector             *fHistoricTransitions;
+    UBool               fUpToDate;
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // RBTZ_H
+
+//eof
diff --git a/CoreFoundation/icu/unicode/regex.h b/CoreFoundation/icu/unicode/regex.h
new file mode 100644
index 0000000..64b58bb
--- /dev/null
+++ b/CoreFoundation/icu/unicode/regex.h
@@ -0,0 +1,1232 @@
+/*
+**********************************************************************
+*   Copyright (C) 2002-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*   file name:  regex.h
+*   encoding:   US-ASCII
+*   indentation:4
+*
+*   created on: 2002oct22
+*   created by: Andy Heninger
+*
+*   ICU Regular Expressions, API for C++
+*/
+
+#ifndef REGEX_H
+#define REGEX_H
+
+//#define REGEX_DEBUG
+
+/**
+ * \file
+ * \brief  C++ API:  Regular Expressions
+ *
+ * <h2>Regular Expression API</h2>
+ *
+ * <p>The ICU API for processing regular expressions consists of two classes,
+ *  <code>RegexPattern</code> and <code>RegexMatcher</code>.
+ *  <code>RegexPattern</code> objects represent a pre-processed, or compiled
+ *  regular expression.  They are created from a regular expression pattern string,
+ *  and can be used to create <code>RegexMatcher</code> objects for the pattern.</p>
+ *
+ * <p>Class <code>RegexMatcher</code> bundles together a regular expression
+ *  pattern and a target string to which the search pattern will be applied.
+ *  <code>RegexMatcher</code> includes API for doing plain find or search
+ *  operations, for search and replace operations, and for obtaining detailed
+ *  information about bounds of a match. </p>
+ *
+ * <p>Note that by constructing <code>RegexMatcher</code> objects directly from regular
+ * expression pattern strings application code can be simplified and the explicit
+ * need for <code>RegexPattern</code> objects can usually be eliminated.
+ * </p>
+ */
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_REGULAR_EXPRESSIONS
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/parseerr.h"
+
+#include "unicode/uregex.h"
+
+U_NAMESPACE_BEGIN
+
+
+// Forward Declarations...
+
+class RegexMatcher;
+class RegexPattern;
+class UVector;
+class UVector32;
+class UnicodeSet;
+struct REStackFrame;
+struct Regex8BitSet;
+class  RuleBasedBreakIterator;
+class  RegexCImpl;
+
+
+
+
+/**
+ *   RBBIPatternDump   Debug function, displays the compiled form of a pattern.
+ *   @internal
+ */
+#ifdef REGEX_DEBUG
+U_INTERNAL void U_EXPORT2
+    RegexPatternDump(const RegexPattern *pat);
+#else
+    #define RegexPatternDump(pat)
+#endif
+
+
+
+/**
+  * Class <code>RegexPattern</code> represents a compiled regular expression.  It includes
+  * factory methods for creating a RegexPattern object from the source (string) form
+  * of a regular expression, methods for creating RegexMatchers that allow the pattern
+  * to be applied to input text, and a few convenience methods for simple common
+  * uses of regular expressions.
+  *
+  * <p>Class RegexPattern is not intended to be subclassed.</p>
+  *
+  * @stable ICU 2.4
+  */
+class U_I18N_API RegexPattern: public UObject {
+public:
+
+    /**
+     * default constructor.  Create a RegexPattern object that refers to no actual
+     *   pattern.  Not normally needed; RegexPattern objects are usually
+     *   created using the factory method <code>compile()</code>.
+     *
+     * @stable ICU 2.4
+     */
+    RegexPattern();
+
+    /**
+     * Copy Constructor.  Create a new RegexPattern object that is equivalent
+     *                    to the source object.
+     * @param source the pattern object to be copied.
+     * @stable ICU 2.4
+     */
+    RegexPattern(const RegexPattern &source);
+
+    /**
+     * Destructor.  Note that a RegexPattern object must persist so long as any
+     *  RegexMatcher objects that were created from the RegexPattern are active.
+     * @stable ICU 2.4
+     */
+    virtual ~RegexPattern();
+
+    /**
+     * Comparison operator.  Two RegexPattern objects are considered equal if they
+     * were constructed from identical source patterns using the same match flag
+     * settings.
+     * @param that a RegexPattern object to compare with "this".
+     * @return TRUE if the objects are equivalent.
+     * @stable ICU 2.4
+     */
+    UBool           operator==(const RegexPattern& that) const;
+
+    /**
+     * Comparison operator.  Two RegexPattern objects are considered equal if they
+     * were constructed from identical source patterns using the same match flag
+     * settings.
+     * @param that a RegexPattern object to compare with "this".
+     * @return TRUE if the objects are different.
+     * @stable ICU 2.4
+     */
+    inline UBool    operator!=(const RegexPattern& that) const {return ! operator ==(that);};
+
+    /**
+     * Assignment operator.  After assignment, this RegexPattern will behave identically
+     *     to the source object.
+     * @stable ICU 2.4
+     */
+    RegexPattern  &operator =(const RegexPattern &source);
+
+    /**
+     * Create an exact copy of this RegexPattern object.  Since RegexPattern is not
+     * intended to be subclasses, <code>clone()</code> and the copy construction are
+     * equivalent operations.
+     * @return the copy of this RegexPattern
+     * @stable ICU 2.4
+     */
+    virtual RegexPattern  *clone() const;
+
+
+   /**
+    * Compiles the regular expression in string form into a RegexPattern
+    * object.  These compile methods, rather than the constructors, are the usual
+    * way that RegexPattern objects are created.
+    *
+    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher
+    * objects created from the pattern are active.  RegexMatchers keep a pointer
+    * back to their pattern, so premature deletion of the pattern is a
+    * catastrophic error.</p>
+    *
+    * <p>All pattern match mode flags are set to their default values.</p>
+    *
+    * <p>Note that it is often more convenient to construct a RegexMatcher directly
+    *    from a pattern string rather than separately compiling the pattern and
+    *    then creating a RegexMatcher object from the pattern.</p>
+    *
+    * @param regex The regular expression to be compiled.
+    * @param pe    Receives the position (line and column nubers) of any error
+    *              within the regular expression.)
+    * @param status A reference to a UErrorCode to receive any errors.
+    * @return      A regexPattern object for the compiled pattern.
+    *
+    * @stable ICU 2.4
+    */
+    static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,
+        UParseError          &pe,
+        UErrorCode           &status);
+
+   /**
+    * Compiles the regular expression in string form into a RegexPattern
+    * object using the specified match mode flags.  These compile methods,
+    * rather than the constructors, are the usual way that RegexPattern objects
+    * are created.
+    *
+    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher
+    * objects created from the pattern are active.  RegexMatchers keep a pointer
+    * back to their pattern, so premature deletion of the pattern is a
+    * catastrophic error.</p>
+    *
+    * <p>Note that it is often more convenient to construct a RegexMatcher directly
+    *    from a pattern string instead of than separately compiling the pattern and
+    *    then creating a RegexMatcher object from the pattern.</p>
+    *
+    * @param regex The regular expression to be compiled.
+    * @param flags The match mode flags to be used.
+    * @param pe    Receives the position (line and column nubers) of any error
+    *              within the regular expression.)
+    * @param status   A reference to a UErrorCode to receive any errors.
+    * @return      A regexPattern object for the compiled pattern.
+    *
+    * @stable ICU 2.4
+    */
+    static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,
+        uint32_t             flags,
+        UParseError          &pe,
+        UErrorCode           &status);
+
+
+   /**
+    * Compiles the regular expression in string form into a RegexPattern
+    * object using the specified match mode flags.  These compile methods,
+    * rather than the constructors, are the usual way that RegexPattern objects
+    * are created.
+    *
+    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher
+    * objects created from the pattern are active.  RegexMatchers keep a pointer
+    * back to their pattern, so premature deletion of the pattern is a
+    * catastrophic error.</p>
+    *
+    * <p>Note that it is often more convenient to construct a RegexMatcher directly
+    *    from a pattern string instead of than separately compiling the pattern and
+    *    then creating a RegexMatcher object from the pattern.</p>
+    *
+    * @param regex The regular expression to be compiled.
+    * @param flags The match mode flags to be used.
+    * @param status   A reference to a UErrorCode to receive any errors.
+    * @return      A regexPattern object for the compiled pattern.
+    *
+    * @stable ICU 2.6
+    */
+    static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,
+        uint32_t             flags,
+        UErrorCode           &status);
+
+
+   /**
+    * Get the match mode flags that were used when compiling this pattern.
+    * @return  the match mode flags
+    * @stable ICU 2.4
+    */
+    virtual uint32_t flags() const;
+
+   /**
+    * Creates a RegexMatcher that will match the given input against this pattern.  The
+    * RegexMatcher can then be used to perform match, find or replace operations
+    * on the input.  Note that a RegexPattern object must not be deleted while
+    * RegexMatchers created from it still exist and might possibly be used again.
+    * <p>
+    * The matcher will retain a reference to the supplied input string, and all regexp
+    * pattern matching operations happen directly on this original string.  It is
+    * critical that the string not be altered or deleted before use by the regular
+    * expression operations is complete.
+    *
+    * @param input    The input string to which the regular expression will be applied.
+    * @param status   A reference to a UErrorCode to receive any errors.
+    * @return         A RegexMatcher object for this pattern and input.
+    *
+    * @stable ICU 2.4
+    */
+    virtual RegexMatcher *matcher(const UnicodeString &input,
+        UErrorCode          &status) const;
+
+private:
+    /**
+     * Cause a compilation error if an application accidently attempts to
+     *   create a matcher with a (UChar *) string as input rather than
+     *   a UnicodeString.  Avoids a dangling reference to a temporary string.
+     * <p>
+     * To efficiently work with UChar *strings, wrap the data in a UnicodeString
+     * using one of the aliasing constructors, such as
+     * <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
+     *
+     * @internal
+     */
+    RegexMatcher *matcher(const UChar *input,
+        UErrorCode          &status) const;
+public:
+
+
+   /**
+    * Creates a RegexMatcher that will match against this pattern.  The
+    * RegexMatcher can be used to perform match, find or replace operations.
+    * Note that a RegexPattern object must not be deleted while
+    * RegexMatchers created from it still exist and might possibly be used again.
+    *
+    * @param status   A reference to a UErrorCode to receive any errors.
+    * @return      A RegexMatcher object for this pattern and input.
+    *
+    * @stable ICU 2.6
+    */
+    virtual RegexMatcher *matcher(UErrorCode  &status) const;
+
+
+   /**
+    * Test whether a string matches a regular expression.  This convenience function
+    * both compiles the reguluar expression and applies it in a single operation.
+    * Note that if the same pattern needs to be applied repeatedly, this method will be
+    * less efficient than creating and reusing a RegexMatcher object.
+    *
+    * @param regex The regular expression
+    * @param input The string data to be matched
+    * @param pe Receives the position of any syntax errors within the regular expression
+    * @param status A reference to a UErrorCode to receive any errors.
+    * @return True if the regular expression exactly matches the full input string.
+    *
+    * @stable ICU 2.4
+    */
+    static UBool U_EXPORT2 matches(const UnicodeString   &regex,
+        const UnicodeString   &input,
+        UParseError     &pe,
+        UErrorCode      &status);
+
+
+   /**
+    *    Returns the regular expression from which this pattern was compiled.
+    *    @stable ICU 2.4
+    */
+    virtual UnicodeString pattern() const;
+
+
+    /**
+     * Split a string into fields.  Somewhat like split() from Perl.
+     * The pattern matches identify delimiters that separate the input
+     *  into fields.  The input data between the matches becomes the
+     *  fields themselves.
+     * <p>
+     *  For the best performance on split() operations,
+     *  <code>RegexMatcher::split</code> is perferable to this function
+     *
+     * @param input   The string to be split into fields.  The field delimiters
+     *                match the pattern (in the "this" object)
+     * @param dest    An array of UnicodeStrings to receive the results of the split.
+     *                This is an array of actual UnicodeString objects, not an
+     *                array of pointers to strings.  Local (stack based) arrays can
+     *                work well here.
+     * @param destCapacity  The number of elements in the destination array.
+     *                If the number of fields found is less than destCapacity, the
+     *                extra strings in the destination array are not altered.
+     *                If the number of destination strings is less than the number
+     *                of fields, the trailing part of the input string, including any
+     *                field delimiters, is placed in the last destination string.
+     * @param status  A reference to a UErrorCode to receive any errors.
+     * @return        The number of fields into which the input string was split.
+     * @stable ICU 2.4
+     */
+    virtual int32_t  split(const UnicodeString &input,
+        UnicodeString    dest[],
+        int32_t          destCapacity,
+        UErrorCode       &status) const;
+
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.4
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.4
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    //
+    //  Implementation Data
+    //
+    UnicodeString   fPattern;      // The original pattern string.
+    uint32_t        fFlags;        // The flags used when compiling the pattern.
+                                   //
+    UVector32       *fCompiledPat; // The compiled pattern p-code.
+    UnicodeString   fLiteralText;  // Any literal string data from the pattern,
+                                   //   after un-escaping, for use during the match.
+
+    UVector         *fSets;        // Any UnicodeSets referenced from the pattern.
+    Regex8BitSet    *fSets8;       //      (and fast sets for latin-1 range.)
+
+
+    UErrorCode      fDeferredStatus; // status if some prior error has left this
+                                   //  RegexPattern in an unusable state.
+
+    int32_t         fMinMatchLen;  // Minimum Match Length.  All matches will have length
+                                   //   >= this value.  For some patterns, this calculated
+                                   //   value may be less than the true shortest
+                                   //   possible match.
+
+    int32_t         fFrameSize;    // Size of a state stack frame in the
+                                   //   execution engine.
+
+    int32_t         fDataSize;     // The size of the data needed by the pattern that
+                                   //   does not go on the state stack, but has just
+                                   //   a single copy per matcher.
+
+    UVector32       *fGroupMap;    // Map from capture group number to position of
+                                   //   the group's variables in the matcher stack frame.
+
+    int32_t         fMaxCaptureDigits;
+
+    UnicodeSet     **fStaticSets;  // Ptr to static (shared) sets for predefined
+                                   //   regex character classes, e.g. Word.
+
+    Regex8BitSet   *fStaticSets8;  // Ptr to the static (shared) latin-1 only
+                                   //  sets for predefined regex classes.
+
+    int32_t         fStartType;    // Info on how a match must start.
+    int32_t         fInitialStringIdx;     //
+    int32_t         fInitialStringLen;
+    UnicodeSet     *fInitialChars;
+    UChar32         fInitialChar;
+    Regex8BitSet   *fInitialChars8;
+
+    friend class RegexCompile;
+    friend class RegexMatcher;
+    friend class RegexCImpl;
+
+    //
+    //  Implementation Methods
+    //
+    void        init();            // Common initialization, for use by constructors.
+    void        zap();             // Common cleanup
+#ifdef REGEX_DEBUG
+    void        dumpOp(int32_t index) const;
+    friend     void U_EXPORT2 RegexPatternDump(const RegexPattern *);
+#endif
+
+};
+
+
+
+/**
+ *  class RegexMatcher bundles together a reular expression pattern and
+ *  input text to which the expression can be applied.  It includes methods
+ *  for testing for matches, and for find and replace operations.
+ *
+ * <p>Class RegexMatcher is not intended to be subclassed.</p>
+ *
+ * @stable ICU 2.4
+ */
+class U_I18N_API RegexMatcher: public UObject {
+public:
+
+    /**
+      * Construct a RegexMatcher for a regular expression.
+      * This is a convenience method that avoids the need to explicitly create
+      * a RegexPattern object.  Note that if several RegexMatchers need to be
+      * created for the same expression, it will be more efficient to
+      * separately create and cache a RegexPattern object, and use
+      * its matcher() method to create the RegexMatcher objects.
+      *
+      *  @param regexp The Regular Expression to be compiled.
+      *  @param flags  Regular expression options, such as case insensitive matching.
+      *                @see UREGEX_CASE_INSENSITIVE
+      *  @param status Any errors are reported by setting this UErrorCode variable.
+      *  @stable ICU 2.6
+      */
+    RegexMatcher(const UnicodeString &regexp, uint32_t flags, UErrorCode &status);
+
+    /**
+      * Construct a RegexMatcher for a regular expression.
+      * This is a convenience method that avoids the need to explicitly create
+      * a RegexPattern object.  Note that if several RegexMatchers need to be
+      * created for the same expression, it will be more efficient to
+      * separately create and cache a RegexPattern object, and use
+      * its matcher() method to create the RegexMatcher objects.
+      * <p>
+      * The matcher will retain a reference to the supplied input string, and all regexp
+      * pattern matching operations happen directly on the original string.  It is
+      * critical that the string not be altered or deleted before use by the regular
+      * expression operations is complete.
+      *
+      *  @param regexp The Regular Expression to be compiled.
+      *  @param input  The string to match.  The matcher retains a reference to the
+      *                caller's string; mo copy is made.
+      *  @param flags  Regular expression options, such as case insensitive matching.
+      *                @see UREGEX_CASE_INSENSITIVE
+      *  @param status Any errors are reported by setting this UErrorCode variable.
+      *  @stable ICU 2.6
+      */
+    RegexMatcher(const UnicodeString &regexp, const UnicodeString &input,
+        uint32_t flags, UErrorCode &status);
+
+private:
+    /**
+     * Cause a compilation error if an application accidently attempts to
+     *   create a matcher with a (UChar *) string as input rather than
+     *   a UnicodeString.    Avoids a dangling reference to a temporary string.
+     * <p>
+     * To efficiently work with UChar *strings, wrap the data in a UnicodeString
+     * using one of the aliasing constructors, such as
+     * <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
+     *
+     * @internal
+     */
+    RegexMatcher(const UnicodeString &regexp, const UChar *input,
+        uint32_t flags, UErrorCode &status);
+public:
+
+
+   /**
+    *   Destructor.
+    *
+    *  @stable ICU 2.4
+    */
+    virtual ~RegexMatcher();
+
+
+   /**
+    *   Attempts to match the entire input region against the pattern.
+    *    @param   status     A reference to a UErrorCode to receive any errors.
+    *    @return TRUE if there is a match
+    *    @stable ICU 2.4
+    */
+    virtual UBool matches(UErrorCode &status);
+
+   /**
+    *   Resets the matcher, then attempts to match the input beginning 
+    *   at the specified startIndex, and extending to the end of the input.
+    *   The input region is reset to include the entire input string.
+    *   A successful match must extend to the end of the input.
+    *    @param   startIndex The input string index at which to begin matching.
+    *    @param   status     A reference to a UErrorCode to receive any errors.
+    *    @return TRUE if there is a match
+    *    @stable ICU 2.8
+    */
+    virtual UBool matches(int32_t startIndex, UErrorCode &status);
+
+
+
+
+   /**
+    *   Attempts to match the input string, starting from the beginning of the region,
+    *   against the pattern.  Like the matches() method, this function 
+    *   always starts at the beginning of the input region;
+    *   unlike that function, it does not require that the entire region be matched.
+    *
+    *   <p>If the match succeeds then more information can be obtained via the <code>start()</code>,
+    *     <code>end()</code>, and <code>group()</code> functions.</p>
+    *
+    *    @param   status     A reference to a UErrorCode to receive any errors.
+    *    @return  TRUE if there is a match at the start of the input string.
+    *    @stable ICU 2.4
+    */
+    virtual UBool lookingAt(UErrorCode &status);
+
+
+  /**
+    *   Attempts to match the input string, starting from the specified index, against the pattern.
+    *   The match may be of any length, and is not required to extend to the end
+    *   of the input string.  Contrast with match().
+    *
+    *   <p>If the match succeeds then more information can be obtained via the <code>start()</code>,
+    *     <code>end()</code>, and <code>group()</code> functions.</p>
+    *
+    *    @param   startIndex The input string index at which to begin matching.
+    *    @param   status     A reference to a UErrorCode to receive any errors.
+    *    @return  TRUE if there is a match.
+    *    @stable ICU 2.8
+    */
+    virtual UBool lookingAt(int32_t startIndex, UErrorCode &status);
+
+   /**
+    *  Find the next pattern match in the input string.
+    *  The find begins searching the input at the location following the end of
+    *  the previous match, or at the start of the string if there is no previous match.
+    *  If a match is found, <code>start(), end()</code> and <code>group()</code>
+    *  will provide more information regarding the match.
+    *  <p>Note that if the input string is changed by the application,
+    *     use find(startPos, status) instead of find(), because the saved starting
+    *     position may not be valid with the altered input string.</p>
+    *  @return  TRUE if a match is found.
+    *  @stable ICU 2.4
+    */
+    virtual UBool find();
+
+
+   /**
+    *   Resets this RegexMatcher and then attempts to find the next substring of the
+    *   input string that matches the pattern, starting at the specified index.
+    *
+    *   @param   start     the position in the input string to begin the search
+    *   @param   status    A reference to a UErrorCode to receive any errors.
+    *   @return  TRUE if a match is found.
+    *   @stable ICU 2.4
+    */
+    virtual UBool find(int32_t start, UErrorCode &status);
+
+
+   /**
+    *   Returns a string containing the text matched by the previous match.
+    *   If the pattern can match an empty string, an empty string may be returned.
+    *   @param   status      A reference to a UErrorCode to receive any errors.
+    *                        Possible errors are  U_REGEX_INVALID_STATE if no match
+    *                        has been attempted or the last match failed.
+    *   @return  a string containing the matched input text.
+    *   @stable ICU 2.4
+    */
+    virtual UnicodeString group(UErrorCode &status) const;
+
+
+   /**
+    *    Returns a string containing the text captured by the given group
+    *    during the previous match operation.  Group(0) is the entire match.
+    *
+    *    @param groupNum the capture group number
+    *    @param   status     A reference to a UErrorCode to receive any errors.
+    *                        Possible errors are  U_REGEX_INVALID_STATE if no match
+    *                        has been attempted or the last match failed and
+    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number.
+    *    @return the captured text
+    *    @stable ICU 2.4
+    */
+    virtual UnicodeString group(int32_t groupNum, UErrorCode &status) const;
+
+
+   /**
+    *   Returns the number of capturing groups in this matcher's pattern.
+    *   @return the number of capture groups
+    *   @stable ICU 2.4
+    */
+    virtual int32_t groupCount() const;
+
+
+   /**
+    *   Returns the index in the input string of the start of the text matched
+    *   during the previous match operation.
+    *    @param   status      a reference to a UErrorCode to receive any errors.
+    *    @return              The position in the input string of the start of the last match.
+    *    @stable ICU 2.4
+    */
+    virtual int32_t start(UErrorCode &status) const;
+
+
+   /**
+    *   Returns the index in the input string of the start of the text matched by the
+    *    specified capture group during the previous match operation.  Return -1 if
+    *    the capture group exists in the pattern, but was not part of the last match.
+    *
+    *    @param  group       the capture group number
+    *    @param  status      A reference to a UErrorCode to receive any errors.  Possible
+    *                        errors are  U_REGEX_INVALID_STATE if no match has been
+    *                        attempted or the last match failed, and
+    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number
+    *    @return the start position of substring matched by the specified group.
+    *    @stable ICU 2.4
+    */
+    virtual int32_t start(int32_t group, UErrorCode &status) const;
+
+
+   /**
+    *    Returns the index in the input string of the first character following the
+    *    text matched during the previous match operation.
+    *   @param   status      A reference to a UErrorCode to receive any errors.  Possible
+    *                        errors are  U_REGEX_INVALID_STATE if no match has been
+    *                        attempted or the last match failed.
+    *    @return the index of the last character matched, plus one.
+    *   @stable ICU 2.4
+    */
+    virtual int32_t end(UErrorCode &status) const;
+
+
+   /**
+    *    Returns the index in the input string of the character following the
+    *    text matched by the specified capture group during the previous match operation.
+    *    @param group  the capture group number
+    *    @param   status      A reference to a UErrorCode to receive any errors.  Possible
+    *                        errors are  U_REGEX_INVALID_STATE if no match has been
+    *                        attempted or the last match failed and
+    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number
+    *    @return  the index of the first character following the text
+    *              captured by the specifed group during the previous match operation.
+    *              Return -1 if the capture group exists in the pattern but was not part of the match.
+    *    @stable ICU 2.4
+    */
+    virtual int32_t end(int32_t group, UErrorCode &status) const;
+
+
+   /**
+    *   Resets this matcher.  The effect is to remove any memory of previous matches,
+    *       and to cause subsequent find() operations to begin at the beginning of
+    *       the input string.
+    *
+    *   @return this RegexMatcher.
+    *   @stable ICU 2.4
+    */
+    virtual RegexMatcher &reset();
+
+
+   /**
+    *   Resets this matcher, and set the current input position.
+    *   The effect is to remove any memory of previous matches,
+    *       and to cause subsequent find() operations to begin at
+    *       the specified position in the input string.
+    * <p>
+    *   The matcher's region is reset to its default, which is the entire
+    *   input string.
+    * <p>
+    *   An alternative to this function is to set a match region
+    *   beginning at the desired index.
+    *
+    *   @return this RegexMatcher.
+    *   @stable ICU 2.8
+    */
+    virtual RegexMatcher &reset(int32_t index, UErrorCode &status);
+
+
+   /**
+    *   Resets this matcher with a new input string.  This allows instances of RegexMatcher
+    *     to be reused, which is more efficient than creating a new RegexMatcher for
+    *     each input string to be processed.
+    *   @param input The new string on which subsequent pattern matches will operate.
+    *                The matcher retains a reference to the callers string, and operates
+    *                directly on that.  Ownership of the string remains with the caller.
+    *                Because no copy of the string is made, it is essential that the
+    *                caller not delete the string until after regexp operations on it
+    *                are done.
+    *   @return this RegexMatcher.
+    *   @stable ICU 2.4
+    */
+    virtual RegexMatcher &reset(const UnicodeString &input);
+
+private:
+    /**
+     * Cause a compilation error if an application accidently attempts to
+     *   reset a matcher with a (UChar *) string as input rather than
+     *   a UnicodeString.    Avoids a dangling reference to a temporary string.
+     * <p>
+     * To efficiently work with UChar *strings, wrap the data in a UnicodeString
+     * using one of the aliasing constructors, such as
+     * <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>
+     *
+     * @internal
+     */
+    RegexMatcher &reset(const UChar *input);
+public:
+
+   /**
+    *   Returns the input string being matched.  The returned string is not a copy,
+    *   but the live input string.  It should not be altered or deleted.
+    *   @return the input string
+    *   @stable ICU 2.4
+    */
+    virtual const UnicodeString &input() const;
+    
+    
+
+   /** Sets the limits of this matcher's region.
+     * The region is the part of the input string that will be searched to find a match.
+     * Invoking this method resets the matcher, and then sets the region to start
+     * at the index specified by the start parameter and end at the index specified
+     * by the end parameter.
+     *
+     * Depending on the transparency and anchoring being used (see useTransparentBounds
+     * and useAnchoringBounds), certain constructs such as anchors may behave differently
+     * at or around the boundaries of the region
+     *
+     * The function will fail if start is greater than limit, or if either index
+     *  is less than zero or greater than the length of the string being matched.
+     *
+     * @param start  The index to begin searches at.
+     * @param limit  The index to end searches at (exclusive).
+     * @param status A reference to a UErrorCode to receive any errors.
+     * @draft ICU 4.0
+     */
+     virtual RegexMatcher &region(int32_t start, int32_t limit, UErrorCode &status);
+
+
+   /**
+     * Reports the start index of this matcher's region. The searches this matcher
+     * conducts are limited to finding matches within regionStart (inclusive) and
+     * regionEnd (exclusive).
+     *
+     * @return The starting index of this matcher's region.
+     * @draft ICU 4.0
+     */
+     virtual int32_t regionStart() const;
+
+
+    /**
+      * Reports the end (limit) index (exclusive) of this matcher's region. The searches
+      * this matcher conducts are limited to finding matches within regionStart
+      * (inclusive) and regionEnd (exclusive).
+      *
+      * @return The ending point of this matcher's region.
+      * @draft ICU 4.0
+      */
+      virtual int32_t regionEnd() const;
+
+    /**
+      * Queries the transparency of region bounds for this matcher.
+      * See useTransparentBounds for a description of transparent and opaque bounds.
+      * By default, a matcher uses opaque region boundaries.
+      *
+      * @return TRUE if this matcher is using opaque bounds, false if it is not.
+      * @draft ICU 4.0
+      */
+      virtual UBool hasTransparentBounds() const;
+
+    /**
+      * Sets the transparency of region bounds for this matcher.
+      * Invoking this function with an argument of true will set this matcher to use transparent bounds.
+      * If the boolean argument is false, then opaque bounds will be used.
+      *
+      * Using transparent bounds, the boundaries of this matcher's region are transparent
+      * to lookahead, lookbehind, and boundary matching constructs. Those constructs can
+      * see text beyond the boundaries of the region while checking for a match.
+      *
+      * With opaque bounds, no text outside of the matcher's region is visible to lookahead,
+      * lookbehind, and boundary matching constructs.
+      *
+      * By default, a matcher uses opaque bounds.
+      *
+      * @param   b TRUE for transparent bounds; FALSE for opaque bounds
+      * @return  This Matcher;
+      * @draft   ICU 4.0
+      **/
+      virtual RegexMatcher &useTransparentBounds(UBool b);
+
+     
+    /**
+      * Return true if this matcher is using anchoring bounds.
+      * By default, matchers use anchoring region boounds.
+      *
+      * @return TRUE if this matcher is using anchoring bounds.
+      * @draft  ICU 4.0
+      */    
+      virtual UBool hasAnchoringBounds() const;
+
+    /**
+      * Set whether this matcher is using Anchoring Bounds for its region.
+      * With anchoring bounds, pattern anchors such as ^ and $ will match at the start
+      * and end of the region.  Without Anchoring Bounds, anchors will only match at
+      * the positions they would in the complete text.
+      *
+      * Anchoring Bounds are the default for regions.
+      *
+      * @param b TRUE if to enable anchoring bounds; FALSE to disable them.
+      * @return  This Matcher
+      * @draft   ICU 4.0
+      */
+      virtual RegexMatcher &useAnchoringBounds(UBool b);
+
+    /**
+      * Return TRUE if the most recent matching operation touched the
+      *  end of the text being processed.  In this case, additional input text could
+      *  change the results of that match.
+      *
+      *  hitEnd() is defined for both successful and unsuccessful matches.
+      *  In either case hitEnd() will return TRUE if if the end of the text was
+      *  reached at any point during the matching process.
+      *
+      *  @return  TRUE if the most recent match hit the end of input
+      *  @draft   ICU 4.0
+      */
+      virtual UBool hitEnd() const;
+
+    /**
+      * Return TRUE the most recent match succeeded and additional input could cause
+      * it to fail. If this method returns false and a match was found, then more input
+      * might change the match but the match won't be lost. If a match was not found,
+      * then requireEnd has no meaning.
+      *
+      * @return TRUE if more input could cause the most recent match to no longer match.
+      * @draft  ICU 4.0
+      */
+      virtual UBool requireEnd() const;
+
+
+
+
+
+   /**
+    *    Returns the pattern that is interpreted by this matcher.
+    *    @return  the RegexPattern for this RegexMatcher
+    *    @stable ICU 2.4
+    */
+    virtual const RegexPattern &pattern() const;
+
+
+   /**
+    *    Replaces every substring of the input that matches the pattern
+    *    with the given replacement string.  This is a convenience function that
+    *    provides a complete find-and-replace-all operation.
+    *
+    *    This method first resets this matcher. It then scans the input string
+    *    looking for matches of the pattern. Input that is not part of any
+    *    match is left unchanged; each match is replaced in the result by the
+    *    replacement string. The replacement string may contain references to
+    *    capture groups.
+    *
+    *    @param   replacement a string containing the replacement text.
+    *    @param   status      a reference to a UErrorCode to receive any errors.
+    *    @return              a string containing the results of the find and replace.
+    *    @stable ICU 2.4
+    */
+    virtual UnicodeString replaceAll(const UnicodeString &replacement, UErrorCode &status);
+
+
+   /**
+    * Replaces the first substring of the input that matches
+    * the pattern with the replacement string.   This is a convenience
+    * function that provides a complete find-and-replace operation.
+    *
+    * <p>This function first resets this RegexMatcher. It then scans the input string
+    * looking for a match of the pattern. Input that is not part
+    * of the match is appended directly to the result string; the match is replaced
+    * in the result by the replacement string. The replacement string may contain
+    * references to captured groups.</p>
+    *
+    * <p>The state of the matcher (the position at which a subsequent find()
+    *    would begin) after completing a replaceFirst() is not specified.  The
+    *    RegexMatcher should be reset before doing additional find() operations.</p>
+    *
+    *    @param   replacement a string containing the replacement text.
+    *    @param   status      a reference to a UErrorCode to receive any errors.
+    *    @return              a string containing the results of the find and replace.
+    *    @stable ICU 2.4
+    */
+    virtual UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status);
+
+   /**
+    *   Implements a replace operation intended to be used as part of an
+    *   incremental find-and-replace.
+    *
+    *   <p>The input string, starting from the end of the previous replacement and ending at
+    *   the start of the current match, is appended to the destination string.  Then the
+    *   replacement string is appended to the output string,
+    *   including handling any substitutions of captured text.</p>
+    *
+    *   <p>For simple, prepackaged, non-incremental find-and-replace
+    *   operations, see replaceFirst() or replaceAll().</p>
+    *
+    *   @param   dest        A UnicodeString to which the results of the find-and-replace are appended.
+    *   @param   replacement A UnicodeString that provides the text to be substituted for
+    *                        the input text that matched the regexp pattern.  The replacement
+    *                        text may contain references to captured text from the
+    *                        input.
+    *   @param   status      A reference to a UErrorCode to receive any errors.  Possible
+    *                        errors are  U_REGEX_INVALID_STATE if no match has been
+    *                        attempted or the last match failed, and U_INDEX_OUTOFBOUNDS_ERROR
+    *                        if the replacement text specifies a capture group that
+    *                        does not exist in the pattern.
+    *
+    *   @return  this  RegexMatcher
+    *   @stable ICU 2.4
+    *
+    */
+    virtual RegexMatcher &appendReplacement(UnicodeString &dest,
+        const UnicodeString &replacement, UErrorCode &status);
+
+
+   /**
+    * As the final step in a find-and-replace operation, append the remainder
+    * of the input string, starting at the position following the last appendReplacement(),
+    * to the destination string. <code>appendTail()</code> is intended to be invoked after one
+    * or more invocations of the <code>RegexMatcher::appendReplacement()</code>.
+    *
+    *  @param dest A UnicodeString to which the results of the find-and-replace are appended.
+    *  @return  the destination string.
+    *  @stable ICU 2.4
+    */
+    virtual UnicodeString &appendTail(UnicodeString &dest);
+
+
+
+    /**
+     * Split a string into fields.  Somewhat like split() from Perl.
+     * The pattern matches identify delimiters that separate the input
+     *  into fields.  The input data between the matches becomes the
+     *  fields themselves.
+     * <p>
+     *
+     * @param input   The string to be split into fields.  The field delimiters
+     *                match the pattern (in the "this" object).  This matcher
+     *                will be reset to this input string.
+     * @param dest    An array of UnicodeStrings to receive the results of the split.
+     *                This is an array of actual UnicodeString objects, not an
+     *                array of pointers to strings.  Local (stack based) arrays can
+     *                work well here.
+     * @param destCapacity  The number of elements in the destination array.
+     *                If the number of fields found is less than destCapacity, the
+     *                extra strings in the destination array are not altered.
+     *                If the number of destination strings is less than the number
+     *                of fields, the trailing part of the input string, including any
+     *                field delimiters, is placed in the last destination string.
+     * @param status  A reference to a UErrorCode to receive any errors.
+     * @return        The number of fields into which the input string was split.
+     * @stable ICU 2.6
+     */
+    virtual int32_t  split(const UnicodeString &input,
+        UnicodeString    dest[],
+        int32_t          destCapacity,
+        UErrorCode       &status);
+
+  /**
+    *   Set a processing time limit for match operations with this Matcher.
+    *  
+    *   Some patterns, when matching certain strings, can run in exponential time.
+    *   For practical purposes, the match operation may appear to be in an
+    *   infinite loop.
+    *   When a limit is set a match operation will fail with an error if the
+    *   limit is exceeded.
+    *   <p>
+    *   The units of the limit are steps of the match engine.
+    *   Correspondence with actual processor time will depend on the speed
+    *   of the processor and the details of the specific pattern, but will
+    *   typically be on the order of milliseconds.
+    *   <p>
+    *   By default, the matching time is not limited.
+    *   <p>
+    *
+    *   @param   limit       The limit value, or 0 for no limit.
+    *   @param   status      A reference to a UErrorCode to receive any errors.
+    *   @draft ICU 4.0
+    */
+    virtual void setTimeLimit(int32_t limit, UErrorCode &status);
+
+  /**
+    * Get the time limit, if any, for match operations made with this Matcher.
+    *
+    *   @return the maximum allowed time for a match, in units of processing steps.
+    *   @draft ICU 4.0
+    */
+    virtual int32_t getTimeLimit() const;
+
+  /**
+    *  Set the amount of heap storage avaliable for use by the match backtracking stack.
+    *  The matcher is also reset, discarding any results from previous matches.
+    *  <p>
+    *  ICU uses a backtracking regular expression engine, with the backtrack stack
+    *  maintained on the heap.  This function sets the limit to the amount of memory
+    *  that can be used  for this purpose.  A backtracking stack overflow will
+    *  result in an error from the match operation that caused it.
+    *  <p>
+    *  A limit is desirable because a malicious or poorly designed pattern can use
+    *  excessive memory, potentially crashing the process.  A limit is enabled
+    *  by default.
+    *  <p>
+    *  @param limit  The maximum size, in bytes, of the matching backtrack stack.
+    *                A value of zero means no limit.
+    *                The limit must be greater or equal to zero.
+    *
+    *  @param status   A reference to a UErrorCode to receive any errors.
+    *
+    *  @draft ICU 4.0
+    */
+    virtual void setStackLimit(int32_t  limit, UErrorCode &status);
+    
+  /**
+    *  Get the size of the heap storage available for use by the back tracking stack.
+    *
+    *  @return  the maximum backtracking stack size, in bytes, or zero if the
+    *           stack size is unlimited.
+    *  @draft ICU 4.0
+    */
+    virtual int32_t  getStackLimit() const;
+
+
+  /**
+    * Set a callback function for use with this Matcher.
+    * During matching operations the function will be called periodically,
+    * giving the application the opportunity to terminate a long-running
+    * match.
+    *
+    *    @param   callback    A pointer to the user-supplied callback function.
+    *    @param   context     User context pointer.  The value supplied at the
+    *                         time the callback function is set will be saved
+    *                         and passed to the callback each time that it is called.
+    *    @param   status      A reference to a UErrorCode to receive any errors.
+    *  @draft ICU 4.0
+    */
+    virtual void setMatchCallback(URegexMatchCallback     *callback,
+                                  const void              *context,
+                                  UErrorCode              &status);
+
+
+
+  /**
+    *  Get the callback function for this URegularExpression.
+    *
+    *    @param   callback    Out paramater, receives a pointer to the user-supplied 
+    *                         callback function.
+    *    @param   context     Out parameter, receives the user context pointer that
+    *                         was set when uregex_setMatchCallback() was called.
+    *    @param   status      A reference to a UErrorCode to receive any errors.
+    *    @draft ICU 4.0
+    */
+    virtual void getMatchCallback(URegexMatchCallback     *&callback,
+                                  const void              *&context,
+                                  UErrorCode              &status);
+
+
+   /**
+     *   setTrace   Debug function, enable/disable tracing of the matching engine.
+     *              For internal ICU development use only.  DO NO USE!!!!
+     *   @internal
+     */
+    void setTrace(UBool state);
+
+
+    /**
+    * ICU "poor man's RTTI", returns a UClassID for this class.
+    *
+    * @stable ICU 2.2
+    */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+private:
+    // Constructors and other object boilerplate are private.
+    // Instances of RegexMatcher can not be assigned, copied, cloned, etc.
+    RegexMatcher();                  // default constructor not implemented
+    RegexMatcher(const RegexPattern *pat);
+    RegexMatcher(const RegexMatcher &other);
+    RegexMatcher &operator =(const RegexMatcher &rhs);
+    void init(UErrorCode &status);                      // Common initialization
+    void init2(const UnicodeString &s, UErrorCode &e);  // Common initialization, part 2.
+
+    friend class RegexPattern;
+    friend class RegexCImpl;
+public:
+    /** @internal  */
+    void resetPreserveRegion();  // Reset matcher state, but preserve any region.
+private:
+
+    //
+    //  MatchAt   This is the internal interface to the match engine itself.
+    //            Match status comes back in matcher member variables.
+    //
+    void                 MatchAt(int32_t startIdx, UBool toEnd, UErrorCode &status);
+    inline void          backTrack(int32_t &inputIdx, int32_t &patIdx);
+    UBool                isWordBoundary(int32_t pos);         // perform Perl-like  \b test
+    UBool                isUWordBoundary(int32_t pos);        // perform RBBI based \b test
+    REStackFrame        *resetStack();
+    inline REStackFrame *StateSave(REStackFrame *fp, int32_t savePatIdx, UErrorCode &status);
+    void                 IncrementTime(UErrorCode &status);
+
+
+    const RegexPattern  *fPattern;
+    RegexPattern        *fPatternOwned;    // Non-NULL if this matcher owns the pattern, and
+                                           //   should delete it when through.
+
+    const UnicodeString *fInput;           // The text being matched. Is never NULL.
+    int32_t              fFrameSize;       // The size of a frame in the backtrack stack.
+    
+    int32_t              fRegionStart;     // Start of the input region, default = 0.
+    int32_t              fRegionLimit;     // End of input region, default to input.length.
+    
+    int32_t              fAnchorStart;     // Region bounds for anchoring operations (^ or $).
+    int32_t              fAnchorLimit;     //   See useAnchoringBounds
+    
+    int32_t              fLookStart;       // Region bounds for look-ahead/behind and
+    int32_t              fLookLimit;       //   and other boundary tests.  See
+                                           //   useTransparentBounds
+
+    int32_t              fActiveStart;     // Currently active bounds for matching.
+    int32_t              fActiveLimit;     //   Usually is the same as region, but
+                                           //   is changed to fLookStart/Limit when
+                                           //   entering look around regions.
+
+    UBool                fTransparentBounds;  // True if using transparent bounds.
+    UBool                fAnchoringBounds; // True if using anchoring bounds.
+
+    UBool                fMatch;           // True if the last attempted match was successful.
+    int32_t              fMatchStart;      // Position of the start of the most recent match
+    int32_t              fMatchEnd;        // First position after the end of the most recent match
+                                           //   Zero if no previous match, even when a region
+                                           //   is active.
+    int32_t              fLastMatchEnd;    // First position after the end of the previous match,
+                                           //   or -1 if there was no previous match.
+    int32_t              fAppendPosition;  // First position after the end of the previous
+                                           //   appendReplacement().  As described by the
+                                           //   JavaDoc for Java Matcher, where it is called 
+                                           //   "append position"
+    UBool                fHitEnd;          // True if the last match touched the end of input.
+    UBool                fRequireEnd;      // True if the last match required end-of-input
+                                           //    (matched $ or Z)
+
+    UVector32           *fStack;
+    REStackFrame        *fFrame;           // After finding a match, the last active stack frame,
+                                           //   which will contain the capture group results.
+                                           //   NOT valid while match engine is running.
+
+    int32_t             *fData;            // Data area for use by the compiled pattern.
+    int32_t             fSmallData[8];     //   Use this for data if it's enough.
+
+    int32_t             fTimeLimit;        // Max time (in arbitrary steps) to let the
+                                           //   match engine run.  Zero for unlimited.
+    
+    int32_t             fTime;             // Match time, accumulates while matching.
+    int32_t             fTickCounter;      // Low bits counter for time.  Counts down StateSaves.
+                                           //   Kept separately from fTime to keep as much
+                                           //   code as possible out of the inline
+                                           //   StateSave function.
+
+    int32_t             fStackLimit;       // Maximum memory size to use for the backtrack
+                                           //   stack, in bytes.  Zero for unlimited.
+
+    URegexMatchCallback *fCallbackFn;       // Pointer to match progress callback funct.
+                                           //   NULL if there is no callback.
+    const void         *fCallbackContext;  // User Context ptr for callback function.
+
+    UBool               fTraceDebug;       // Set true for debug tracing of match engine.
+
+    UErrorCode          fDeferredStatus;   // Save error state that cannot be immediately
+                                           //   reported, or that permanently disables this matcher.
+
+    RuleBasedBreakIterator  *fWordBreakItr;
+
+
+};
+
+U_NAMESPACE_END
+#endif  // UCONFIG_NO_REGULAR_EXPRESSIONS
+#endif
diff --git a/CoreFoundation/icu/unicode/rep.h b/CoreFoundation/icu/unicode/rep.h
new file mode 100644
index 0000000..3fab6fa
--- /dev/null
+++ b/CoreFoundation/icu/unicode/rep.h
@@ -0,0 +1,259 @@
+/*
+**************************************************************************
+* Copyright (C) 1999-2005, International Business Machines Corporation and
+* others. All Rights Reserved.
+**************************************************************************
+*   Date        Name        Description
+*   11/17/99    aliu        Creation.  Ported from java.  Modified to
+*                           match current UnicodeString API.  Forced
+*                           to use name "handleReplaceBetween" because
+*                           of existing methods in UnicodeString.
+**************************************************************************
+*/
+
+#ifndef REP_H
+#define REP_H
+
+#include "unicode/uobject.h"
+
+/**
+ * \file 
+ * \brief C++ API: Replaceable String
+ */
+ 
+U_NAMESPACE_BEGIN
+
+class UnicodeString;
+
+/**
+ * <code>Replaceable</code> is an abstract base class representing a
+ * string of characters that supports the replacement of a range of
+ * itself with a new string of characters.  It is used by APIs that
+ * change a piece of text while retaining metadata.  Metadata is data
+ * other than the Unicode characters returned by char32At().  One
+ * example of metadata is style attributes; another is an edit
+ * history, marking each character with an author and revision number.
+ *
+ * <p>An implicit aspect of the <code>Replaceable</code> API is that
+ * during a replace operation, new characters take on the metadata of
+ * the old characters.  For example, if the string "the <b>bold</b>
+ * font" has range (4, 8) replaced with "strong", then it becomes "the
+ * <b>strong</b> font".
+ *
+ * <p><code>Replaceable</code> specifies ranges using a start
+ * offset and a limit offset.  The range of characters thus specified
+ * includes the characters at offset start..limit-1.  That is, the
+ * start offset is inclusive, and the limit offset is exclusive.
+ *
+ * <p><code>Replaceable</code> also includes API to access characters
+ * in the string: <code>length()</code>, <code>charAt()</code>,
+ * <code>char32At()</code>, and <code>extractBetween()</code>.
+ *
+ * <p>For a subclass to support metadata, typical behavior of
+ * <code>replace()</code> is the following:
+ * <ul>
+ *   <li>Set the metadata of the new text to the metadata of the first
+ *   character replaced</li>
+ *   <li>If no characters are replaced, use the metadata of the
+ *   previous character</li>
+ *   <li>If there is no previous character (i.e. start == 0), use the
+ *   following character</li>
+ *   <li>If there is no following character (i.e. the replaceable was
+ *   empty), use default metadata.<br>
+ *   <li>If the code point U+FFFF is seen, it should be interpreted as
+ *   a special marker having no metadata<li>
+ *   </li>
+ * </ul>
+ * If this is not the behavior, the subclass should document any differences.
+ * @author Alan Liu
+ * @stable ICU 2.0
+ */
+class U_COMMON_API Replaceable : public UObject {
+
+public:
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~Replaceable();
+
+    /**
+     * Returns the number of 16-bit code units in the text.
+     * @return number of 16-bit code units in text
+     * @stable ICU 1.8
+     */ 
+    inline int32_t length() const;
+
+    /**
+     * Returns the 16-bit code unit at the given offset into the text.
+     * @param offset an integer between 0 and <code>length()</code>-1
+     * inclusive
+     * @return 16-bit code unit of text at given offset
+     * @stable ICU 1.8
+     */
+    inline UChar charAt(int32_t offset) const;
+
+    /**
+     * Returns the 32-bit code point at the given 16-bit offset into
+     * the text.  This assumes the text is stored as 16-bit code units
+     * with surrogate pairs intermixed.  If the offset of a leading or
+     * trailing code unit of a surrogate pair is given, return the
+     * code point of the surrogate pair.
+     *
+     * @param offset an integer between 0 and <code>length()</code>-1
+     * inclusive
+     * @return 32-bit code point of text at given offset
+     * @stable ICU 1.8
+     */
+    inline UChar32 char32At(int32_t offset) const;
+
+    /**
+     * Copies characters in the range [<tt>start</tt>, <tt>limit</tt>) 
+     * into the UnicodeString <tt>target</tt>.
+     * @param start offset of first character which will be copied
+     * @param limit offset immediately following the last character to
+     * be copied
+     * @param target UnicodeString into which to copy characters.
+     * @return A reference to <TT>target</TT>
+     * @stable ICU 2.1
+     */
+    virtual void extractBetween(int32_t start,
+                                int32_t limit,
+                                UnicodeString& target) const = 0;
+
+    /**
+     * Replaces a substring of this object with the given text.  If the
+     * characters being replaced have metadata, the new characters
+     * that replace them should be given the same metadata.
+     *
+     * <p>Subclasses must ensure that if the text between start and
+     * limit is equal to the replacement text, that replace has no
+     * effect. That is, any metadata
+     * should be unaffected. In addition, subclasses are encouraged to
+     * check for initial and trailing identical characters, and make a
+     * smaller replacement if possible. This will preserve as much
+     * metadata as possible.
+     * @param start the beginning index, inclusive; <code>0 <= start
+     * <= limit</code>.
+     * @param limit the ending index, exclusive; <code>start <= limit
+     * <= length()</code>.
+     * @param text the text to replace characters <code>start</code>
+     * to <code>limit - 1</code> 
+     * @stable ICU 2.0
+     */
+    virtual void handleReplaceBetween(int32_t start,
+                                      int32_t limit,
+                                      const UnicodeString& text) = 0;
+    // Note: All other methods in this class take the names of
+    // existing UnicodeString methods.  This method is the exception.
+    // It is named differently because all replace methods of
+    // UnicodeString return a UnicodeString&.  The 'between' is
+    // required in order to conform to the UnicodeString naming
+    // convention; API taking start/length are named <operation>, and
+    // those taking start/limit are named <operationBetween>.  The
+    // 'handle' is added because 'replaceBetween' and
+    // 'doReplaceBetween' are already taken.
+
+    /**
+     * Copies a substring of this object, retaining metadata.
+     * This method is used to duplicate or reorder substrings.
+     * The destination index must not overlap the source range.
+     * 
+     * @param start the beginning index, inclusive; <code>0 <= start <=
+     * limit</code>.
+     * @param limit the ending index, exclusive; <code>start <= limit <=
+     * length()</code>.
+     * @param dest the destination index.  The characters from
+     * <code>start..limit-1</code> will be copied to <code>dest</code>.
+     * Implementations of this method may assume that <code>dest <= start ||
+     * dest >= limit</code>.
+     * @stable ICU 2.0
+     */
+    virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;
+
+    /**
+     * Returns true if this object contains metadata.  If a
+     * Replaceable object has metadata, calls to the Replaceable API
+     * must be made so as to preserve metadata.  If it does not, calls
+     * to the Replaceable API may be optimized to improve performance.
+     * The default implementation returns true.
+     * @return true if this object contains metadata
+     * @stable ICU 2.2
+     */
+    virtual UBool hasMetaData() const;
+
+    /**
+     * Clone this object, an instance of a subclass of Replaceable.
+     * Clones can be used concurrently in multiple threads.
+     * If a subclass does not implement clone(), or if an error occurs,
+     * then NULL is returned.
+     * The clone functions in all subclasses return a pointer to a Replaceable
+     * because some compilers do not support covariant (same-as-this)
+     * return types; cast to the appropriate subclass if necessary.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.6
+     */
+    virtual Replaceable *clone() const;
+
+protected:
+
+    /**
+     * Default constructor.
+     * @stable ICU 2.4
+     */
+    Replaceable();
+
+    /*
+     * Assignment operator not declared. The compiler will provide one
+     * which does nothing since this class does not contain any data members.
+     * API/code coverage may show the assignment operator as present and
+     * untested - ignore.
+     * Subclasses need this assignment operator if they use compiler-provided
+     * assignment operators of their own. An alternative to not declaring one
+     * here would be to declare and empty-implement a protected or public one.
+    Replaceable &Replaceable::operator=(const Replaceable &);
+     */
+
+    /**
+     * Virtual version of length().
+     * @stable ICU 2.4
+     */ 
+    virtual int32_t getLength() const = 0;
+
+    /**
+     * Virtual version of charAt().
+     * @stable ICU 2.4
+     */
+    virtual UChar getCharAt(int32_t offset) const = 0;
+
+    /**
+     * Virtual version of char32At().
+     * @stable ICU 2.4
+     */
+    virtual UChar32 getChar32At(int32_t offset) const = 0;
+};
+
+inline int32_t
+Replaceable::length() const {
+    return getLength();
+}
+
+inline UChar
+Replaceable::charAt(int32_t offset) const {
+    return getCharAt(offset);
+}
+
+inline UChar32
+Replaceable::char32At(int32_t offset) const {
+    return getChar32At(offset);
+}
+
+// There is no rep.cpp, see unistr.cpp for Replaceable function implementations.
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/resbund.h b/CoreFoundation/icu/unicode/resbund.h
new file mode 100644
index 0000000..6d6b991
--- /dev/null
+++ b/CoreFoundation/icu/unicode/resbund.h
@@ -0,0 +1,485 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1996-2007, International Business Machines Corporation
+*   and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File resbund.h
+*
+*   CREATED BY
+*       Richard Gillam
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   2/5/97      aliu        Added scanForLocaleInFile.  Added
+*                           constructor which attempts to read resource bundle
+*                           from a specific file, without searching other files.
+*   2/11/97     aliu        Added UErrorCode return values to constructors.  Fixed
+*                           infinite loops in scanForFile and scanForLocale.
+*                           Modified getRawResourceData to not delete storage
+*                           in localeData and resourceData which it doesn't own.
+*                           Added Mac compatibility #ifdefs for tellp() and
+*                           ios::nocreate.
+*   2/18/97     helena      Updated with 100% documentation coverage.
+*   3/13/97     aliu        Rewrote to load in entire resource bundle and store
+*                           it as a Hashtable of ResourceBundleData objects.
+*                           Added state table to govern parsing of files.
+*                           Modified to load locale index out of new file
+*                           distinct from default.txt.
+*   3/25/97     aliu        Modified to support 2-d arrays, needed for timezone
+*                           data. Added support for custom file suffixes.  Again,
+*                           needed to support timezone data.
+*   4/7/97      aliu        Cleaned up.
+* 03/02/99      stephen     Removed dependency on FILE*.
+* 03/29/99      helena      Merged Bertrand and Stephen's changes.
+* 06/11/99      stephen     Removed parsing of .txt files.
+*                           Reworked to use new binary format.
+*                           Cleaned up.
+* 06/14/99      stephen     Removed methods taking a filename suffix.
+* 11/09/99      weiv        Added getLocale(), fRealLocale, removed fRealLocaleID
+******************************************************************************
+*/
+
+#ifndef RESBUND_H
+#define RESBUND_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/ures.h"
+#include "unicode/unistr.h"
+#include "unicode/locid.h"
+
+/**
+ * \file 
+ * \brief C++ API: Resource Bundle
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * A class representing a collection of resource information pertaining to a given
+ * locale. A resource bundle provides a way of accessing locale- specfic information in
+ * a data file. You create a resource bundle that manages the resources for a given
+ * locale and then ask it for individual resources.
+ * <P>
+ * Resource bundles in ICU4C are currently defined using text files which conform to the following
+ * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt">BNF definition</a>.
+ * More on resource bundle concepts and syntax can be found in the
+ * <a href="http://icu-project.org/userguide/ResourceManagement.html">Users Guide</a>.
+ * <P>
+ *
+ * The ResourceBundle class is not suitable for subclassing.
+ *
+ * @stable ICU 2.0
+ */
+class U_COMMON_API ResourceBundle : public UObject {
+public:
+    /**
+     * Constructor
+     *
+     * @param packageName   The packageName and locale together point to an ICU udata object, 
+     *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
+     *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
+     *                      a package registered with udata_setAppData(). Using a full file or directory
+     *                      pathname for packageName is deprecated.
+     * @param locale  This is the locale this resource bundle is for. To get resources
+     *                for the French locale, for example, you would create a
+     *                ResourceBundle passing Locale::FRENCH for the "locale" parameter,
+     *                and all subsequent calls to that resource bundle will return
+     *                resources that pertain to the French locale. If the caller doesn't
+     *                pass a locale parameter, the default locale for the system (as
+     *                returned by Locale::getDefault()) will be used.
+     * @param err     The Error Code.
+     * The UErrorCode& err parameter is used to return status information to the user. To
+     * check whether the construction succeeded or not, you should check the value of
+     * U_SUCCESS(err). If you wish more detailed information, you can check for
+     * informational error results which still indicate success. U_USING_FALLBACK_WARNING
+     * indicates that a fall back locale was used. For example, 'de_CH' was requested,
+     * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that
+     * the default locale data was used; neither the requested locale nor any of its
+     * fall back locales could be found.
+     * @stable ICU 2.0
+     */
+    ResourceBundle(const UnicodeString&    packageName,
+                   const Locale&           locale,
+                   UErrorCode&              err);
+
+    /**
+     * Construct a resource bundle for the default bundle in the specified package.
+     *
+     * @param packageName   The packageName and locale together point to an ICU udata object, 
+     *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
+     *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
+     *                      a package registered with udata_setAppData(). Using a full file or directory
+     *                      pathname for packageName is deprecated.
+     * @param err A UErrorCode value
+     * @stable ICU 2.0
+     */
+    ResourceBundle(const UnicodeString&    packageName,
+                   UErrorCode&              err);
+
+    /**
+     * Construct a resource bundle for the ICU default bundle.
+     *
+     * @param err A UErrorCode value
+     * @stable ICU 2.0
+     */
+    ResourceBundle(UErrorCode &err);
+
+    /**
+     * Standard constructor, onstructs a resource bundle for the locale-specific
+     * bundle in the specified package.
+     *
+     * @param packageName   The packageName and locale together point to an ICU udata object, 
+     *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
+     *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
+     *                      a package registered with udata_setAppData(). Using a full file or directory
+     *                      pathname for packageName is deprecated.
+     *                      NULL is used to refer to ICU data.
+     * @param locale The locale for which to open a resource bundle.
+     * @param err A UErrorCode value
+     * @stable ICU 2.0
+     */
+    ResourceBundle(const char* packageName,
+                   const Locale& locale,
+                   UErrorCode& err);
+
+    /**
+     * Copy constructor.
+     *
+     * @param original The resource bundle to copy.
+     * @stable ICU 2.0
+     */
+    ResourceBundle(const ResourceBundle &original);
+
+    /**
+     * Constructor from a C UResourceBundle. The resource bundle is
+     * copied and not adopted. ures_close will still need to be used on the
+     * original resource bundle.
+     *
+     * @param res A pointer to the C resource bundle.
+     * @param status A UErrorCode value.
+     * @stable ICU 2.0
+     */
+    ResourceBundle(UResourceBundle *res,
+                   UErrorCode &status);
+
+    /**
+     * Assignment operator.
+     *
+     * @param other The resource bundle to copy.
+     * @stable ICU 2.0
+     */
+    ResourceBundle&
+      operator=(const ResourceBundle& other);
+
+    /** Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~ResourceBundle();
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    ResourceBundle *clone() const;
+
+    /**
+     * Returns the size of a resource. Size for scalar types is always 1, and for vector/table types is
+     * the number of child resources.
+     * @warning Integer array is treated as a scalar type. There are no
+     *          APIs to access individual members of an integer array. It
+     *          is always returned as a whole.
+     *
+     * @return number of resources in a given resource.
+     * @stable ICU 2.0
+     */
+    int32_t
+      getSize(void) const;
+
+    /**
+     * returns a string from a string resource type
+     *
+     * @param status  fills in the outgoing error code
+     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+     *                could be a warning
+     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+     * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
+     * @stable ICU 2.0
+     */
+    UnicodeString
+      getString(UErrorCode& status) const;
+
+    /**
+     * returns a binary data from a resource. Can be used at most primitive resource types (binaries,
+     * strings, ints)
+     *
+     * @param len     fills in the length of resulting byte chunk
+     * @param status  fills in the outgoing error code
+     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+     *                could be a warning
+     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+     * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
+     * @stable ICU 2.0
+     */
+    const uint8_t*
+      getBinary(int32_t& len, UErrorCode& status) const;
+
+
+    /**
+     * returns an integer vector from a resource.
+     *
+     * @param len     fills in the length of resulting integer vector
+     * @param status  fills in the outgoing error code
+     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+     *                could be a warning
+     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+     * @return a pointer to a vector of integers that lives in a memory mapped/DLL file.
+     * @stable ICU 2.0
+     */
+    const int32_t*
+      getIntVector(int32_t& len, UErrorCode& status) const;
+
+    /**
+     * returns an unsigned integer from a resource.
+     * This integer is originally 28 bits.
+     *
+     * @param status  fills in the outgoing error code
+     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+     *                could be a warning
+     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+     * @return an unsigned integer value
+     * @stable ICU 2.0
+     */
+    uint32_t
+      getUInt(UErrorCode& status) const;
+
+    /**
+     * returns a signed integer from a resource.
+     * This integer is originally 28 bit and the sign gets propagated.
+     *
+     * @param status  fills in the outgoing error code
+     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+     *                could be a warning
+     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+     * @return a signed integer value
+     * @stable ICU 2.0
+     */
+    int32_t
+      getInt(UErrorCode& status) const;
+
+    /**
+     * Checks whether the resource has another element to iterate over.
+     *
+     * @return TRUE if there are more elements, FALSE if there is no more elements
+     * @stable ICU 2.0
+     */
+    UBool
+      hasNext(void) const;
+
+    /**
+     * Resets the internal context of a resource so that iteration starts from the first element.
+     *
+     * @stable ICU 2.0
+     */
+    void
+      resetIterator(void);
+
+    /**
+     * Returns the key associated with this resource. Not all the resources have a key - only
+     * those that are members of a table.
+     *
+     * @return a key associated to this resource, or NULL if it doesn't have a key
+     * @stable ICU 2.0
+     */
+    const char*
+      getKey(void) const;
+
+    /**
+     * Gets the locale ID of the resource bundle as a string.
+     * Same as getLocale().getName() .
+     *
+     * @return the locale ID of the resource bundle as a string
+     * @stable ICU 2.0
+     */
+    const char*
+      getName(void) const;
+
+
+    /**
+     * Returns the type of a resource. Available types are defined in enum UResType
+     *
+     * @return type of the given resource.
+     * @stable ICU 2.0
+     */
+    UResType
+      getType(void) const;
+
+    /**
+     * Returns the next resource in a given resource or NULL if there are no more resources
+     *
+     * @param status            fills in the outgoing error code
+     * @return                  ResourceBundle object.
+     * @stable ICU 2.0
+     */
+    ResourceBundle
+      getNext(UErrorCode& status);
+
+    /**
+     * Returns the next string in a resource or NULL if there are no more resources
+     * to iterate over.
+     *
+     * @param status            fills in the outgoing error code
+     * @return an UnicodeString object.
+     * @stable ICU 2.0
+     */
+    UnicodeString
+      getNextString(UErrorCode& status);
+
+    /**
+     * Returns the next string in a resource or NULL if there are no more resources
+     * to iterate over.
+     *
+     * @param key               fill in for key associated with this string
+     * @param status            fills in the outgoing error code
+     * @return an UnicodeString object.
+     * @stable ICU 2.0
+     */
+    UnicodeString
+      getNextString(const char ** key,
+                    UErrorCode& status);
+
+    /**
+     * Returns the resource in a resource at the specified index.
+     *
+     * @param index             an index to the wanted resource.
+     * @param status            fills in the outgoing error code
+     * @return                  ResourceBundle object. If there is an error, resource is invalid.
+     * @stable ICU 2.0
+     */
+    ResourceBundle
+      get(int32_t index,
+          UErrorCode& status) const;
+
+    /**
+     * Returns the string in a given resource at the specified index.
+     *
+     * @param index             an index to the wanted string.
+     * @param status            fills in the outgoing error code
+     * @return                  an UnicodeString object. If there is an error, string is bogus
+     * @stable ICU 2.0
+     */
+    UnicodeString
+      getStringEx(int32_t index,
+                  UErrorCode& status) const;
+
+    /**
+     * Returns a resource in a resource that has a given key. This procedure works only with table
+     * resources.
+     *
+     * @param key               a key associated with the wanted resource
+     * @param status            fills in the outgoing error code.
+     * @return                  ResourceBundle object. If there is an error, resource is invalid.
+     * @stable ICU 2.0
+     */
+    ResourceBundle
+      get(const char* key,
+          UErrorCode& status) const;
+
+    /**
+     * Returns a string in a resource that has a given key. This procedure works only with table
+     * resources.
+     *
+     * @param key               a key associated with the wanted string
+     * @param status            fills in the outgoing error code
+     * @return                  an UnicodeString object. If there is an error, string is bogus
+     * @stable ICU 2.0
+     */
+    UnicodeString
+      getStringEx(const char* key,
+                  UErrorCode& status) const;
+
+    /**
+     * Return the version number associated with this ResourceBundle as a string. Please
+     * use getVersion, as this method is going to be deprecated.
+     *
+     * @return  A version number string as specified in the resource bundle or its parent.
+     *          The caller does not own this string.
+     * @see getVersion
+     * @deprecated ICU 2.8 Use getVersion instead.
+     */
+    const char*
+      getVersionNumber(void) const;
+
+    /**
+     * Return the version number associated with this ResourceBundle as a UVersionInfo array.
+     *
+     * @param versionInfo A UVersionInfo array that is filled with the version number
+     *                    as specified in the resource bundle or its parent.
+     * @stable ICU 2.0
+     */
+    void
+      getVersion(UVersionInfo versionInfo) const;
+
+    /**
+     * Return the Locale associated with this ResourceBundle.
+     *
+     * @return a Locale object
+     * @deprecated ICU 2.8 Use getLocale(ULocDataLocaleType type, UErrorCode &status) overload instead.
+     */
+    const Locale&
+      getLocale(void) const;
+
+    /**
+     * Return the Locale associated with this ResourceBundle.
+     * @param type You can choose between requested, valid and actual
+     *             locale. For description see the definition of
+     *             ULocDataLocaleType in uloc.h
+     * @param status just for catching illegal arguments
+     *
+     * @return a Locale object
+     * @stable ICU 2.8
+     */
+    const Locale
+      getLocale(ULocDataLocaleType type, UErrorCode &status) const;
+    /**
+     * This API implements multilevel fallback
+     * @internal
+     */
+    ResourceBundle
+        getWithFallback(const char* key, UErrorCode& status);
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    ResourceBundle(); // default constructor not implemented
+
+    UResourceBundle *fResource;
+    void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
+    Locale *fLocale;
+
+};
+
+U_NAMESPACE_END
+#endif
diff --git a/CoreFoundation/icu/unicode/schriter.h b/CoreFoundation/icu/unicode/schriter.h
new file mode 100644
index 0000000..d0b5e22
--- /dev/null
+++ b/CoreFoundation/icu/unicode/schriter.h
@@ -0,0 +1,187 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File schriter.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*  05/05/99     stephen     Cleaned up.
+******************************************************************************
+*/
+
+#ifndef SCHRITER_H
+#define SCHRITER_H
+
+#include "unicode/utypes.h"
+#include "unicode/chariter.h"
+#include "unicode/uchriter.h"
+
+/**
+ * \file 
+ * \brief C++ API: String Character Iterator
+ */
+ 
+U_NAMESPACE_BEGIN
+/**
+ * A concrete subclass of CharacterIterator that iterates over the
+ * characters (code units or code points) in a UnicodeString.
+ * It's possible not only to create an
+ * iterator that iterates over an entire UnicodeString, but also to
+ * create one that iterates over only a subrange of a UnicodeString
+ * (iterators over different subranges of the same UnicodeString don't
+ * compare equal).
+ * @see CharacterIterator
+ * @see ForwardCharacterIterator
+ * @stable ICU 2.0
+ */
+class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator {
+public:
+  /**
+   * Create an iterator over the UnicodeString referred to by "textStr".
+   * The UnicodeString object is copied.
+   * The iteration range is the whole string, and the starting position is 0.
+   * @param textStr The unicode string used to create an iterator
+   * @stable ICU 2.0
+   */
+  StringCharacterIterator(const UnicodeString& textStr);
+
+  /**
+   * Create an iterator over the UnicodeString referred to by "textStr".
+   * The iteration range is the whole string, and the starting
+   * position is specified by "textPos".  If "textPos" is outside the valid
+   * iteration range, the behavior of this object is undefined.
+   * @param textStr The unicode string used to create an iterator
+   * @param textPos The starting position of the iteration
+   * @stable ICU 2.0
+   */
+  StringCharacterIterator(const UnicodeString&    textStr,
+              int32_t              textPos);
+
+  /**
+   * Create an iterator over the UnicodeString referred to by "textStr".
+   * The UnicodeString object is copied.
+   * The iteration range begins with the code unit specified by
+   * "textBegin" and ends with the code unit BEFORE the code unit specfied
+   * by "textEnd".  The starting position is specified by "textPos".  If
+   * "textBegin" and "textEnd" don't form a valid range on "text" (i.e.,
+   * textBegin >= textEnd or either is negative or greater than text.size()),
+   * or "textPos" is outside the range defined by "textBegin" and "textEnd",
+   * the behavior of this iterator is undefined.
+   * @param textStr    The unicode string used to create the StringCharacterIterator
+   * @param textBegin  The begin position of the iteration range
+   * @param textEnd    The end position of the iteration range
+   * @param textPos    The starting position of the iteration
+   * @stable ICU 2.0
+   */
+  StringCharacterIterator(const UnicodeString&    textStr,
+              int32_t              textBegin,
+              int32_t              textEnd,
+              int32_t              textPos);
+
+  /**
+   * Copy constructor.  The new iterator iterates over the same range
+   * of the same string as "that", and its initial position is the
+   * same as "that"'s current position.
+   * The UnicodeString object in "that" is copied.
+   * @param that The StringCharacterIterator to be copied
+   * @stable ICU 2.0
+   */
+  StringCharacterIterator(const StringCharacterIterator&  that);
+
+  /**
+   * Destructor.
+   * @stable ICU 2.0
+   */
+  virtual ~StringCharacterIterator();
+
+  /**
+   * Assignment operator.  *this is altered to iterate over the same
+   * range of the same string as "that", and refers to the same
+   * character within that string as "that" does.
+   * @param that The object to be copied.
+   * @return the newly created object.
+   * @stable ICU 2.0
+   */
+  StringCharacterIterator&
+  operator=(const StringCharacterIterator&    that);
+
+  /**
+   * Returns true if the iterators iterate over the same range of the
+   * same string and are pointing at the same character.
+   * @param that The ForwardCharacterIterator to be compared for equality
+   * @return true if the iterators iterate over the same range of the
+   * same string and are pointing at the same character.
+   * @stable ICU 2.0
+   */
+  virtual UBool          operator==(const ForwardCharacterIterator& that) const;
+
+  /**
+   * Returns a new StringCharacterIterator referring to the same
+   * character in the same range of the same string as this one.  The
+   * caller must delete the new iterator.
+   * @return the newly cloned object.
+   * @stable ICU 2.0
+   */
+  virtual CharacterIterator* clone(void) const;
+
+  /**
+   * Sets the iterator to iterate over the provided string.
+   * @param newText The string to be iterated over
+   * @stable ICU 2.0
+   */
+  void setText(const UnicodeString& newText);
+
+  /**
+   * Copies the UnicodeString under iteration into the UnicodeString
+   * referred to by "result".  Even if this iterator iterates across
+   * only a part of this string, the whole string is copied.
+   * @param result Receives a copy of the text under iteration.
+   * @stable ICU 2.0
+   */
+  virtual void            getText(UnicodeString& result);
+
+  /**
+   * Return a class ID for this object (not really public)
+   * @return a class ID for this object.
+   * @stable ICU 2.0
+   */
+  virtual UClassID         getDynamicClassID(void) const;
+
+  /**
+   * Return a class ID for this class (not really public)
+   * @return a class ID for this class
+   * @stable ICU 2.0
+   */
+  static UClassID   U_EXPORT2 getStaticClassID(void);
+
+protected:
+  /**
+   * Default constructor, iteration over empty string.
+   * @stable ICU 2.0
+   */
+  StringCharacterIterator();
+
+  /**
+   * Sets the iterator to iterate over the provided string.
+   * @param newText The string to be iterated over
+   * @param newTextLength The length of the String
+   * @stable ICU 2.0
+   */
+  void setText(const UChar* newText, int32_t newTextLength);
+
+  /**
+   * Copy of the iterated string object.
+   * @stable ICU 2.0
+   */
+  UnicodeString            text;
+
+};
+
+U_NAMESPACE_END
+#endif
diff --git a/CoreFoundation/icu/unicode/search.h b/CoreFoundation/icu/unicode/search.h
new file mode 100644
index 0000000..8b82906
--- /dev/null
+++ b/CoreFoundation/icu/unicode/search.h
@@ -0,0 +1,569 @@
+/*
+**********************************************************************
+*   Copyright (C) 2001-2008 IBM and others. All rights reserved.
+**********************************************************************
+*   Date        Name        Description
+*  03/22/2000   helena      Creation.
+**********************************************************************
+*/
+
+#ifndef SEARCH_H
+#define SEARCH_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: SearchIterator object.
+ */
+ 
+#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/chariter.h"
+#include "unicode/brkiter.h"
+#include "unicode/usearch.h"
+
+/**
+* @stable ICU 2.0
+*/
+struct USearch;
+/**
+* @stable ICU 2.0
+*/
+typedef struct USearch USearch;
+
+U_NAMESPACE_BEGIN
+
+/**
+ *
+ * <tt>SearchIterator</tt> is an abstract base class that provides 
+ * methods to search for a pattern within a text string. Instances of
+ * <tt>SearchIterator</tt> maintain a current position and scans over the 
+ * target text, returning the indices the pattern is matched and the length 
+ * of each match.
+ * <p>
+ * <tt>SearchIterator</tt> defines a protocol for text searching. 
+ * Subclasses provide concrete implementations of various search algorithms. 
+ * For example, <tt>StringSearch</tt> implements language-sensitive pattern 
+ * matching based on the comparison rules defined in a 
+ * <tt>RuleBasedCollator</tt> object. 
+ * <p> 
+ * Other options for searching includes using a BreakIterator to restrict 
+ * the points at which matches are detected.
+ * <p>
+ * <tt>SearchIterator</tt> provides an API that is similar to that of
+ * other text iteration classes such as <tt>BreakIterator</tt>. Using 
+ * this class, it is easy to scan through text looking for all occurances of 
+ * a given pattern. The following example uses a <tt>StringSearch</tt> 
+ * object to find all instances of "fox" in the target string. Any other 
+ * subclass of <tt>SearchIterator</tt> can be used in an identical 
+ * manner.
+ * <pre><code>
+ * UnicodeString target("The quick brown fox jumped over the lazy fox");
+ * UnicodeString pattern("fox");
+ *
+ * SearchIterator *iter  = new StringSearch(pattern, target);
+ * UErrorCode      error = U_ZERO_ERROR;
+ * for (int pos = iter->first(error); pos != USEARCH_DONE; 
+ *                               pos = iter->next(error)) {
+ *     printf("Found match at %d pos, length is %d\n", pos, 
+ *                                             iter.getMatchLength());
+ * }
+ * </code></pre>
+ *
+ * @see StringSearch
+ * @see RuleBasedCollator
+ */
+class U_I18N_API SearchIterator : public UObject {
+
+public:
+
+    // public constructors and destructors -------------------------------
+
+    /** 
+    * Copy constructor that creates a SearchIterator instance with the same 
+    * behavior, and iterating over the same text. 
+    * @param other the SearchIterator instance to be copied.
+    * @stable ICU 2.0
+    */
+    SearchIterator(const SearchIterator &other);
+
+    /**
+     * Destructor. Cleans up the search iterator data struct.
+     * @stable ICU 2.0
+     */
+    virtual ~SearchIterator();
+
+    // public get and set methods ----------------------------------------
+
+    /**
+     * Sets the index to point to the given position, and clears any state 
+     * that's affected.
+     * <p>
+     * This method takes the argument index and sets the position in the text 
+     * string accordingly without checking if the index is pointing to a 
+     * valid starting point to begin searching. 
+     * @param position within the text to be set. If position is less
+     *             than or greater than the text range for searching, 
+     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned
+     * @param status for errors if it occurs
+     * @stable ICU 2.0
+     */
+    virtual void setOffset(int32_t position, UErrorCode &status) = 0;
+
+    /**
+     * Return the current index in the text being searched.
+     * If the iteration has gone past the end of the text
+     * (or past the beginning for a backwards search), USEARCH_DONE
+     * is returned.
+     * @return current index in the text being searched.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getOffset(void) const = 0;
+
+    /**
+    * Sets the text searching attributes located in the enum 
+    * USearchAttribute with values from the enum USearchAttributeValue.
+    * USEARCH_DEFAULT can be used for all attributes for resetting.
+    * @param attribute text attribute (enum USearchAttribute) to be set
+    * @param value text attribute value
+    * @param status for errors if it occurs
+    * @stable ICU 2.0
+    */
+    void setAttribute(USearchAttribute       attribute,
+                      USearchAttributeValue  value,
+                      UErrorCode            &status);
+
+    /**    
+    * Gets the text searching attributes
+    * @param attribute text attribute (enum USearchAttribute) to be retrieve
+    * @return text attribute value
+    * @stable ICU 2.0
+    */
+    USearchAttributeValue getAttribute(USearchAttribute  attribute) const;
+    
+    /**
+    * Returns the index to the match in the text string that was searched.
+    * This call returns a valid result only after a successful call to 
+    * <tt>first</tt>, <tt>next</tt>, <tt>previous</tt>, or <tt>last</tt>.
+    * Just after construction, or after a searching method returns 
+    * <tt>USEARCH_DONE</tt>, this method will return <tt>USEARCH_DONE</tt>.
+    * <p>
+    * Use getMatchedLength to get the matched string length.
+    * @return index of a substring within the text string that is being 
+    *         searched.
+    * @see #first
+    * @see #next
+    * @see #previous
+    * @see #last
+    * @stable ICU 2.0
+    */
+    int32_t getMatchedStart(void) const;
+
+    /**
+     * Returns the length of text in the string which matches the search 
+     * pattern. This call returns a valid result only after a successful call 
+     * to <tt>first</tt>, <tt>next</tt>, <tt>previous</tt>, or <tt>last</tt>.
+     * Just after construction, or after a searching method returns 
+     * <tt>USEARCH_DONE</tt>, this method will return 0.
+     * @return The length of the match in the target text, or 0 if there
+     *         is no match currently.
+     * @see #first
+     * @see #next
+     * @see #previous
+     * @see #last
+     * @stable ICU 2.0
+     */
+    int32_t getMatchedLength(void) const;
+    
+    /**
+     * Returns the text that was matched by the most recent call to 
+     * <tt>first</tt>, <tt>next</tt>, <tt>previous</tt>, or <tt>last</tt>.
+     * If the iterator is not pointing at a valid match (e.g. just after 
+     * construction or after <tt>USEARCH_DONE</tt> has been returned, 
+     * returns an empty string. 
+     * @param result stores the matched string or an empty string if a match
+     *        is not found.
+     * @see #first
+     * @see #next
+     * @see #previous
+     * @see #last
+     * @stable ICU 2.0
+     */
+    void getMatchedText(UnicodeString &result) const;
+    
+    /**
+     * Set the BreakIterator that will be used to restrict the points
+     * at which matches are detected. The user is responsible for deleting 
+     * the breakiterator.
+     * @param breakiter A BreakIterator that will be used to restrict the 
+     *                points at which matches are detected. If a match is 
+     *                found, but the match's start or end index is not a 
+     *                boundary as determined by the <tt>BreakIterator</tt>, 
+     *                the match will be rejected and another will be searched 
+     *                for. If this parameter is <tt>NULL</tt>, no break
+     *                detection is attempted.
+     * @param status for errors if it occurs
+     * @see BreakIterator
+     * @stable ICU 2.0
+     */
+    void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);
+    
+    /**
+     * Returns the BreakIterator that is used to restrict the points at 
+     * which matches are detected.  This will be the same object that was 
+     * passed to the constructor or to <tt>setBreakIterator</tt>.
+     * Note that <tt>NULL</tt> is a legal value; it means that break
+     * detection should not be attempted.
+     * @return BreakIterator used to restrict matchings.
+     * @see #setBreakIterator
+     * @stable ICU 2.0
+     */
+    const BreakIterator * getBreakIterator(void) const;
+
+    /**
+     * Set the string text to be searched. Text iteration will hence begin at 
+     * the start of the text string. This method is useful if you want to 
+     * re-use an iterator to search for the same pattern within a different 
+     * body of text. The user is responsible for deleting the text.
+     * @param text string to be searched.
+     * @param status for errors. If the text length is 0, 
+     *        an U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    virtual void setText(const UnicodeString &text, UErrorCode &status);    
+
+    /**
+     * Set the string text to be searched. Text iteration will hence begin at 
+     * the start of the text string. This method is useful if you want to 
+     * re-use an iterator to search for the same pattern within a different 
+     * body of text.
+     * <p>
+     * Note: No parsing of the text within the <tt>CharacterIterator</tt> 
+     * will be done during searching for this version. The block of text 
+     * in <tt>CharacterIterator</tt> will be used as it is.
+     * The user is responsible for deleting the text.
+     * @param text string iterator to be searched.
+     * @param status for errors if any. If the text length is 0 then an 
+     *        U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    virtual void setText(CharacterIterator &text, UErrorCode &status);
+    
+    /**
+     * Return the string text to be searched.
+     * @return text string to be searched.
+     * @stable ICU 2.0
+     */
+    const UnicodeString & getText(void) const;
+
+    // operator overloading ----------------------------------------------
+
+    /**
+     * Equality operator. 
+     * @param that SearchIterator instance to be compared.
+     * @return TRUE if both BreakIterators are of the same class, have the 
+     *         same behavior, terates over the same text and have the same
+     *         attributes. FALSE otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const SearchIterator &that) const;
+
+    /**
+     * Not-equal operator. 
+     * @param that SearchIterator instance to be compared.
+     * @return FALSE if operator== returns TRUE, and vice versa.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const SearchIterator &that) const;
+
+    // public methods ----------------------------------------------------
+
+    /**
+     * Returns a copy of SearchIterator with the same behavior, and 
+     * iterating over the same text, as this one. Note that all data will be
+     * replicated, except for the text string to be searched.
+     * @return cloned object
+     * @stable ICU 2.0
+     */
+    virtual SearchIterator* safeClone(void) const = 0;
+
+    /**
+     * Returns the first index at which the string text matches the search 
+     * pattern. The iterator is adjusted so that its current index (as 
+     * returned by <tt>getOffset</tt>) is the match position if one 
+     * was found.
+     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+     * the iterator will be adjusted to the index USEARCH_DONE
+     * @param  status for errors if it occurs
+     * @return The character index of the first match, or 
+     *         <tt>USEARCH_DONE</tt> if there are no matches.
+     * @see #getOffset
+     * @stable ICU 2.0
+     */
+    int32_t first(UErrorCode &status);
+
+    /**
+     * Returns the first index greater than <tt>position</tt> at which the 
+     * string text matches the search pattern. The iterator is adjusted so 
+     * that its current index (as returned by <tt>getOffset</tt>) is the 
+     * match position if one was found. If a match is not found, 
+     * <tt>USEARCH_DONE</tt> will be returned and the iterator will be 
+     * adjusted to the index USEARCH_DONE
+     * @param  position where search if to start from. If position is less
+     *             than or greater than the text range for searching, 
+     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned
+     * @param  status for errors if it occurs
+     * @return The character index of the first match following 
+     *         <tt>position</tt>, or <tt>USEARCH_DONE</tt> if there are no 
+     *         matches.
+     * @see #getOffset
+     * @stable ICU 2.0
+     */
+    int32_t following(int32_t position, UErrorCode &status);
+    
+    /**
+     * Returns the last index in the target text at which it matches the 
+     * search pattern. The iterator is adjusted so that its current index 
+     * (as returned by <tt>getOffset</tt>) is the match position if one was 
+     * found.
+     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+     * the iterator will be adjusted to the index USEARCH_DONE.
+     * @param  status for errors if it occurs
+     * @return The index of the first match, or <tt>USEARCH_DONE</tt> if 
+     *         there are no matches.
+     * @see #getOffset
+     * @stable ICU 2.0
+     */
+    int32_t last(UErrorCode &status);
+
+    /**
+     * Returns the first index less than <tt>position</tt> at which the string 
+     * text matches the search pattern. The iterator is adjusted so that its 
+     * current index (as returned by <tt>getOffset</tt>) is the match 
+     * position if one was found. If a match is not found, 
+     * <tt>USEARCH_DONE</tt> will be returned and the iterator will be 
+     * adjusted to the index USEARCH_DONE
+     * @param  position where search is to start from. If position is less
+     *             than or greater than the text range for searching, 
+     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned
+     * @param  status for errors if it occurs
+     * @return The character index of the first match preceding 
+     *         <tt>position</tt>, or <tt>USEARCH_DONE</tt> if there are 
+     *         no matches.
+     * @see #getOffset
+     * @stable ICU 2.0
+     */
+    int32_t preceding(int32_t position, UErrorCode &status);
+
+    /**
+     * Returns the index of the next point at which the text matches the
+     * search pattern, starting from the current position
+     * The iterator is adjusted so that its current index (as returned by 
+     * <tt>getOffset</tt>) is the match position if one was found.
+     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+     * the iterator will be adjusted to a position after the end of the text 
+     * string.
+     * @param  status for errors if it occurs
+     * @return The index of the next match after the current position,
+     *          or <tt>USEARCH_DONE</tt> if there are no more matches.
+     * @see #getOffset
+     * @stable ICU 2.0
+     */
+     int32_t next(UErrorCode &status);
+
+    /**
+     * Returns the index of the previous point at which the string text 
+     * matches the search pattern, starting at the current position.
+     * The iterator is adjusted so that its current index (as returned by 
+     * <tt>getOffset</tt>) is the match position if one was found.
+     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+     * the iterator will be adjusted to the index USEARCH_DONE
+     * @param  status for errors if it occurs
+     * @return The index of the previous match before the current position,
+     *          or <tt>USEARCH_DONE</tt> if there are no more matches.
+     * @see #getOffset
+     * @stable ICU 2.0
+     */
+    int32_t previous(UErrorCode &status);
+
+    /** 
+    * Resets the iteration.
+    * Search will begin at the start of the text string if a forward 
+    * iteration is initiated before a backwards iteration. Otherwise if a 
+    * backwards iteration is initiated before a forwards iteration, the 
+    * search will begin at the end of the text string.    
+    * @stable ICU 2.0
+    */
+    virtual void reset();
+
+protected:
+    // protected data members ---------------------------------------------
+
+    /**
+    * C search data struct
+    * @stable ICU 2.0
+    */
+    USearch *m_search_;
+
+    /**
+    * Break iterator.
+    * Currently the C++ breakiterator does not have getRules etc to reproduce
+    * another in C. Hence we keep the original around and do the verification
+    * at the end of the match. The user is responsible for deleting this
+    * break iterator.
+    * @stable ICU 2.0
+    */
+    BreakIterator *m_breakiterator_;
+    
+    /**
+    * Unicode string version of the search text
+    * @stable ICU 2.0
+    */
+    UnicodeString  m_text_;
+
+    // protected constructors and destructors -----------------------------
+
+    /**
+    * Default constructor.
+    * Initializes data to the default values.
+    * @stable ICU 2.0
+    */
+    SearchIterator();
+
+    /**
+     * Constructor for use by subclasses.
+     * @param text The target text to be searched.
+     * @param breakiter A {@link BreakIterator} that is used to restrict the 
+     *                points at which matches are detected. If 
+     *                <tt>handleNext</tt> or <tt>handlePrev</tt> finds a 
+     *                match, but the match's start or end index is not a 
+     *                boundary as determined by the <tt>BreakIterator</tt>, 
+     *                the match is rejected and <tt>handleNext</tt> or 
+     *                <tt>handlePrev</tt> is called again. If this parameter 
+     *                is <tt>NULL</tt>, no break detection is attempted.  
+     * @see #handleNext
+     * @see #handlePrev
+     * @stable ICU 2.0
+     */
+    SearchIterator(const UnicodeString &text, 
+                         BreakIterator *breakiter = NULL);
+
+    /**
+     * Constructor for use by subclasses.
+     * <p>
+     * Note: No parsing of the text within the <tt>CharacterIterator</tt> 
+     * will be done during searching for this version. The block of text 
+     * in <tt>CharacterIterator</tt> will be used as it is.
+     * @param text The target text to be searched.
+     * @param breakiter A {@link BreakIterator} that is used to restrict the 
+     *                points at which matches are detected. If 
+     *                <tt>handleNext</tt> or <tt>handlePrev</tt> finds a 
+     *                match, but the match's start or end index is not a 
+     *                boundary as determined by the <tt>BreakIterator</tt>, 
+     *                the match is rejected and <tt>handleNext</tt> or 
+     *                <tt>handlePrev</tt> is called again. If this parameter 
+     *                is <tt>NULL</tt>, no break detection is attempted.
+     * @see #handleNext
+     * @see #handlePrev
+     * @stable ICU 2.0
+     */
+    SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
+
+    // protected methods --------------------------------------------------
+
+    /**
+     * Assignment operator. Sets this iterator to have the same behavior,
+     * and iterate over the same text, as the one passed in.
+     * @param that instance to be copied.
+     * @stable ICU 2.0
+     */
+    SearchIterator & operator=(const SearchIterator &that);
+
+    /**
+     * Abstract method which subclasses override to provide the mechanism
+     * for finding the next match in the target text. This allows different
+     * subclasses to provide different search algorithms.
+     * <p>
+     * If a match is found, the implementation should return the index at
+     * which the match starts and should call 
+     * <tt>setMatchLength</tt> with the number of characters 
+     * in the target text that make up the match. If no match is found, the 
+     * method should return USEARCH_DONE.
+     * <p>
+     * @param position The index in the target text at which the search 
+     *                 should start.
+     * @param status for error codes if it occurs.
+     * @return index at which the match starts, else if match is not found 
+     *         USEARCH_DONE is returned
+     * @see #setMatchLength
+     * @stable ICU 2.0
+     */
+    virtual int32_t handleNext(int32_t position, UErrorCode &status) 
+                                                                         = 0;
+
+    /**
+     * Abstract method which subclasses override to provide the mechanism for
+     * finding the previous match in the target text. This allows different
+     * subclasses to provide different search algorithms.
+     * <p>
+     * If a match is found, the implementation should return the index at
+     * which the match starts and should call 
+     * <tt>setMatchLength</tt> with the number of characters 
+     * in the target text that make up the match. If no match is found, the 
+     * method should return USEARCH_DONE.
+     * <p>
+     * @param position The index in the target text at which the search 
+     *                 should start.
+     * @param status for error codes if it occurs.
+     * @return index at which the match starts, else if match is not found 
+     *         USEARCH_DONE is returned
+     * @see #setMatchLength
+     * @stable ICU 2.0
+     */
+     virtual int32_t handlePrev(int32_t position, UErrorCode &status) 
+                                                                         = 0;
+
+    /**
+     * Sets the length of the currently matched string in the text string to
+     * be searched.
+     * Subclasses' <tt>handleNext</tt> and <tt>handlePrev</tt>
+     * methods should call this when they find a match in the target text.
+     * @param length length of the matched text.
+     * @see #handleNext
+     * @see #handlePrev
+     * @stable ICU 2.0
+     */
+    virtual void setMatchLength(int32_t length);
+
+    /**
+     * Sets the offset of the currently matched string in the text string to
+     * be searched.
+     * Subclasses' <tt>handleNext</tt> and <tt>handlePrev</tt>
+     * methods should call this when they find a match in the target text.
+     * @param position start offset of the matched text.
+     * @see #handleNext
+     * @see #handlePrev
+     * @stable ICU 2.0
+     */
+    virtual void setMatchStart(int32_t position);
+
+    /**
+    * sets match not found 
+    * @stable ICU 2.0
+    */
+    void setMatchNotFound();
+};
+
+inline UBool SearchIterator::operator!=(const SearchIterator &that) const
+{
+   return !operator==(that); 
+}
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
+
diff --git a/CoreFoundation/icu/unicode/simpletz.h b/CoreFoundation/icu/unicode/simpletz.h
new file mode 100644
index 0000000..5b85c8d
--- /dev/null
+++ b/CoreFoundation/icu/unicode/simpletz.h
@@ -0,0 +1,927 @@
+/*
+ ********************************************************************************
+ * Copyright (C) 1997-2008, International Business Machines                     *
+ * Corporation and others. All Rights Reserved.                                 *
+ ********************************************************************************
+ *
+ * File SIMPLETZ.H
+ *
+ * Modification History:
+ *
+ *   Date        Name        Description
+ *   04/21/97    aliu        Overhauled header.
+ *   08/10/98    stephen     JDK 1.2 sync
+ *                           Added setStartRule() / setEndRule() overloads
+ *                           Added hasSameRules()
+ *   09/02/98    stephen     Added getOffset(monthLen)
+ *                           Changed getOffset() to take UErrorCode
+ *   07/09/99    stephen     Removed millisPerHour (unused, for HP compiler)
+ *   12/02/99    aliu        Added TimeMode and constructor and setStart/EndRule
+ *                           methods that take TimeMode. Added to docs.
+ ********************************************************************************
+ */
+
+#ifndef SIMPLETZ_H
+#define SIMPLETZ_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: SimpleTimeZone is a concrete subclass of TimeZone.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/basictz.h"
+
+U_NAMESPACE_BEGIN
+
+// forward declaration
+class InitialTimeZoneRule;
+class TimeZoneTransition;
+class AnnualTimeZoneRule;
+
+/**
+ * <code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code>
+ * that represents a time zone for use with a Gregorian calendar. This
+ * class does not handle historical changes.
+ * <P>
+ * When specifying daylight-savings-time begin and end dates, use a negative value for
+ * <code>dayOfWeekInMonth</code> to indicate that <code>SimpleTimeZone</code> should
+ * count from the end of the month backwards. For example, in the U.S., Daylight Savings
+ * Time ends at the last (dayOfWeekInMonth = -1) Sunday in October, at 2 AM in standard
+ * time.
+ *
+ * @see      Calendar
+ * @see      GregorianCalendar
+ * @see      TimeZone
+ * @author   D. Goldsmith, Mark Davis, Chen-Lieh Huang, Alan Liu
+ */
+class U_I18N_API SimpleTimeZone: public BasicTimeZone {
+public:
+
+    /**
+     * TimeMode is used, together with a millisecond offset after
+     * midnight, to specify a rule transition time.  Most rules
+     * transition at a local wall time, that is, according to the
+     * current time in effect, either standard, or DST.  However, some
+     * rules transition at local standard time, and some at a specific
+     * UTC time.  Although it might seem that all times could be
+     * converted to wall time, thus eliminating the need for this
+     * parameter, this is not the case.
+     * @stable ICU 2.0
+     */
+    enum TimeMode {
+        WALL_TIME = 0,
+        STANDARD_TIME,
+        UTC_TIME
+    };
+
+    /**
+     * Copy constructor
+     * @param source the object to be copied.
+     * @stable ICU 2.0
+     */
+    SimpleTimeZone(const SimpleTimeZone& source);
+
+    /**
+     * Default assignment operator
+     * @param right    the object to be copied.
+     * @stable ICU 2.0
+     */
+    SimpleTimeZone& operator=(const SimpleTimeZone& right);
+
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~SimpleTimeZone();
+
+    /**
+     * Returns true if the two TimeZone objects are equal; that is, they have
+     * the same ID, raw GMT offset, and DST rules.
+     *
+     * @param that  The SimpleTimeZone object to be compared with.
+     * @return      True if the given time zone is equal to this time zone; false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const TimeZone& that) const;
+
+    /**
+     * Constructs a SimpleTimeZone with the given raw GMT offset and time zone ID,
+     * and which doesn't observe daylight savings time.  Normally you should use
+     * TimeZone::createInstance() to create a TimeZone instead of creating a
+     * SimpleTimeZone directly with this constructor.
+     *
+     * @param rawOffsetGMT  The given base time zone offset to GMT.
+     * @param ID         The timezone ID which is obtained from
+     *                   TimeZone.getAvailableIDs.
+     * @stable ICU 2.0
+     */
+    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID);
+
+    /**
+     * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID,
+     * and times to start and end daylight savings time. To create a TimeZone that
+     * doesn't observe daylight savings time, don't use this constructor; use
+     * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use
+     * TimeZone.createInstance() to create a TimeZone instead of creating a
+     * SimpleTimeZone directly with this constructor.
+     * <P>
+     * Various types of daylight-savings time rules can be specfied by using different
+     * values for startDay and startDayOfWeek and endDay and endDayOfWeek.  For a
+     * complete explanation of how these parameters work, see the documentation for
+     * setStartRule().
+     *
+     * @param rawOffsetGMT      The new SimpleTimeZone's raw GMT offset
+     * @param ID                The new SimpleTimeZone's time zone ID.
+     * @param savingsStartMonth The daylight savings starting month. Month is
+     *                          0-based. eg, 0 for January.
+     * @param savingsStartDayOfWeekInMonth   The daylight savings starting
+     *                          day-of-week-in-month. See setStartRule() for a
+     *                          complete explanation.
+     * @param savingsStartDayOfWeek The daylight savings starting day-of-week.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsStartTime  The daylight savings starting time, expressed as the
+     *                          number of milliseconds after midnight.
+     * @param savingsEndMonth   The daylight savings ending month. Month is
+     *                          0-based. eg, 0 for January.
+     * @param savingsEndDayOfWeekInMonth     The daylight savings ending day-of-week-in-month.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsEndDayOfWeek The daylight savings ending day-of-week.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsEndTime    The daylight savings ending time, expressed as the
+     *                          number of milliseconds after midnight.
+     * @param status            An UErrorCode to receive the status.
+     * @stable ICU 2.0
+     */
+    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
+        int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
+        int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
+        int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
+        int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
+        UErrorCode& status);
+    /**
+     * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID,
+     * and times to start and end daylight savings time. To create a TimeZone that
+     * doesn't observe daylight savings time, don't use this constructor; use
+     * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use
+     * TimeZone.createInstance() to create a TimeZone instead of creating a
+     * SimpleTimeZone directly with this constructor.
+     * <P>
+     * Various types of daylight-savings time rules can be specfied by using different
+     * values for startDay and startDayOfWeek and endDay and endDayOfWeek.  For a
+     * complete explanation of how these parameters work, see the documentation for
+     * setStartRule().
+     *
+     * @param rawOffsetGMT      The new SimpleTimeZone's raw GMT offset
+     * @param ID                The new SimpleTimeZone's time zone ID.
+     * @param savingsStartMonth The daylight savings starting month. Month is
+     *                          0-based. eg, 0 for January.
+     * @param savingsStartDayOfWeekInMonth   The daylight savings starting
+     *                          day-of-week-in-month. See setStartRule() for a
+     *                          complete explanation.
+     * @param savingsStartDayOfWeek The daylight savings starting day-of-week.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsStartTime  The daylight savings starting time, expressed as the
+     *                          number of milliseconds after midnight.
+     * @param savingsEndMonth   The daylight savings ending month. Month is
+     *                          0-based. eg, 0 for January.
+     * @param savingsEndDayOfWeekInMonth     The daylight savings ending day-of-week-in-month.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsEndDayOfWeek The daylight savings ending day-of-week.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsEndTime    The daylight savings ending time, expressed as the
+     *                          number of milliseconds after midnight.
+     * @param savingsDST        The number of milliseconds added to standard time
+     *                          to get DST time. Default is one hour.
+     * @param status            An UErrorCode to receive the status.
+     * @stable ICU 2.0
+     */
+    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
+        int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
+        int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
+        int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
+        int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
+        int32_t savingsDST, UErrorCode& status);
+
+    /**
+     * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID,
+     * and times to start and end daylight savings time. To create a TimeZone that
+     * doesn't observe daylight savings time, don't use this constructor; use
+     * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use
+     * TimeZone.createInstance() to create a TimeZone instead of creating a
+     * SimpleTimeZone directly with this constructor.
+     * <P>
+     * Various types of daylight-savings time rules can be specfied by using different
+     * values for startDay and startDayOfWeek and endDay and endDayOfWeek.  For a
+     * complete explanation of how these parameters work, see the documentation for
+     * setStartRule().
+     *
+     * @param rawOffsetGMT      The new SimpleTimeZone's raw GMT offset
+     * @param ID                The new SimpleTimeZone's time zone ID.
+     * @param savingsStartMonth The daylight savings starting month. Month is
+     *                          0-based. eg, 0 for January.
+     * @param savingsStartDayOfWeekInMonth   The daylight savings starting
+     *                          day-of-week-in-month. See setStartRule() for a
+     *                          complete explanation.
+     * @param savingsStartDayOfWeek The daylight savings starting day-of-week.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsStartTime  The daylight savings starting time, expressed as the
+     *                          number of milliseconds after midnight.
+     * @param savingsStartTimeMode Whether the start time is local wall time, local
+     *                          standard time, or UTC time. Default is local wall time.
+     * @param savingsEndMonth   The daylight savings ending month. Month is
+     *                          0-based. eg, 0 for January.
+     * @param savingsEndDayOfWeekInMonth     The daylight savings ending day-of-week-in-month.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsEndDayOfWeek The daylight savings ending day-of-week.
+     *                          See setStartRule() for a complete explanation.
+     * @param savingsEndTime    The daylight savings ending time, expressed as the
+     *                          number of milliseconds after midnight.
+     * @param savingsEndTimeMode Whether the end time is local wall time, local
+     *                          standard time, or UTC time. Default is local wall time.
+     * @param savingsDST        The number of milliseconds added to standard time
+     *                          to get DST time. Default is one hour.
+     * @param status            An UErrorCode to receive the status.
+     * @stable ICU 2.0
+     */
+    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
+        int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
+        int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
+        TimeMode savingsStartTimeMode,
+        int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
+        int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,
+        int32_t savingsDST, UErrorCode& status);
+
+    /**
+     * Sets the daylight savings starting year, that is, the year this time zone began
+     * observing its specified daylight savings time rules.  The time zone is considered
+     * not to observe daylight savings time prior to that year; SimpleTimeZone doesn't
+     * support historical daylight-savings-time rules.
+     * @param year the daylight savings starting year.
+     * @stable ICU 2.0
+     */
+    void setStartYear(int32_t year);
+
+    /**
+     * Sets the daylight savings starting rule. For example, in the U.S., Daylight Savings
+     * Time starts at the first Sunday in April, at 2 AM in standard time.
+     * Therefore, you can set the start rule by calling:
+     * setStartRule(TimeFields.APRIL, 1, TimeFields.SUNDAY, 2*60*60*1000);
+     * The dayOfWeekInMonth and dayOfWeek parameters together specify how to calculate
+     * the exact starting date.  Their exact meaning depend on their respective signs,
+     * allowing various types of rules to be constructed, as follows:
+     * <ul>
+     *   <li>If both dayOfWeekInMonth and dayOfWeek are positive, they specify the
+     *       day of week in the month (e.g., (2, WEDNESDAY) is the second Wednesday
+     *       of the month).</li>
+     *   <li>If dayOfWeek is positive and dayOfWeekInMonth is negative, they specify
+     *       the day of week in the month counting backward from the end of the month.
+     *       (e.g., (-1, MONDAY) is the last Monday in the month)</li>
+     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is positive, dayOfWeekInMonth
+     *       specifies the day of the month, regardless of what day of the week it is.
+     *       (e.g., (10, 0) is the tenth day of the month)</li>
+     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is negative, dayOfWeekInMonth
+     *       specifies the day of the month counting backward from the end of the
+     *       month, regardless of what day of the week it is (e.g., (-2, 0) is the
+     *       next-to-last day of the month).</li>
+     *   <li>If dayOfWeek is negative and dayOfWeekInMonth is positive, they specify the
+     *       first specified day of the week on or after the specfied day of the month.
+     *       (e.g., (15, -SUNDAY) is the first Sunday after the 15th of the month
+     *       [or the 15th itself if the 15th is a Sunday].)</li>
+     *   <li>If dayOfWeek and DayOfWeekInMonth are both negative, they specify the
+     *       last specified day of the week on or before the specified day of the month.
+     *       (e.g., (-20, -TUESDAY) is the last Tuesday before the 20th of the month
+     *       [or the 20th itself if the 20th is a Tuesday].)</li>
+     * </ul>
+     * @param month the daylight savings starting month. Month is 0-based.
+     * eg, 0 for January.
+     * @param dayOfWeekInMonth the daylight savings starting
+     * day-of-week-in-month. Please see the member description for an example.
+     * @param dayOfWeek the daylight savings starting day-of-week. Please see
+     * the member description for an example.
+     * @param time the daylight savings starting time. Please see the member
+     * description for an example.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
+                      int32_t time, UErrorCode& status);
+    /**
+     * Sets the daylight savings starting rule. For example, in the U.S., Daylight Savings
+     * Time starts at the first Sunday in April, at 2 AM in standard time.
+     * Therefore, you can set the start rule by calling:
+     * setStartRule(TimeFields.APRIL, 1, TimeFields.SUNDAY, 2*60*60*1000);
+     * The dayOfWeekInMonth and dayOfWeek parameters together specify how to calculate
+     * the exact starting date.  Their exact meaning depend on their respective signs,
+     * allowing various types of rules to be constructed, as follows:
+     * <ul>
+     *   <li>If both dayOfWeekInMonth and dayOfWeek are positive, they specify the
+     *       day of week in the month (e.g., (2, WEDNESDAY) is the second Wednesday
+     *       of the month).</li>
+     *   <li>If dayOfWeek is positive and dayOfWeekInMonth is negative, they specify
+     *       the day of week in the month counting backward from the end of the month.
+     *       (e.g., (-1, MONDAY) is the last Monday in the month)</li>
+     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is positive, dayOfWeekInMonth
+     *       specifies the day of the month, regardless of what day of the week it is.
+     *       (e.g., (10, 0) is the tenth day of the month)</li>
+     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is negative, dayOfWeekInMonth
+     *       specifies the day of the month counting backward from the end of the
+     *       month, regardless of what day of the week it is (e.g., (-2, 0) is the
+     *       next-to-last day of the month).</li>
+     *   <li>If dayOfWeek is negative and dayOfWeekInMonth is positive, they specify the
+     *       first specified day of the week on or after the specfied day of the month.
+     *       (e.g., (15, -SUNDAY) is the first Sunday after the 15th of the month
+     *       [or the 15th itself if the 15th is a Sunday].)</li>
+     *   <li>If dayOfWeek and DayOfWeekInMonth are both negative, they specify the
+     *       last specified day of the week on or before the specified day of the month.
+     *       (e.g., (-20, -TUESDAY) is the last Tuesday before the 20th of the month
+     *       [or the 20th itself if the 20th is a Tuesday].)</li>
+     * </ul>
+     * @param month the daylight savings starting month. Month is 0-based.
+     * eg, 0 for January.
+     * @param dayOfWeekInMonth the daylight savings starting
+     * day-of-week-in-month. Please see the member description for an example.
+     * @param dayOfWeek the daylight savings starting day-of-week. Please see
+     * the member description for an example.
+     * @param time the daylight savings starting time. Please see the member
+     * description for an example.
+     * @param mode whether the time is local wall time, local standard time,
+     * or UTC time. Default is local wall time.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
+                      int32_t time, TimeMode mode, UErrorCode& status);
+
+    /**
+     * Sets the DST start rule to a fixed date within a month.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    The date in that month (1-based).
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST takes effect in local wall time, which is
+     *                      standard time in this case.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
+                      UErrorCode& status);
+    /**
+     * Sets the DST start rule to a fixed date within a month.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    The date in that month (1-based).
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST takes effect in local wall time, which is
+     *                      standard time in this case.
+     * @param mode whether the time is local wall time, local standard time,
+     * or UTC time. Default is local wall time.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
+                      TimeMode mode, UErrorCode& status);
+
+    /**
+     * Sets the DST start rule to a weekday before or after a give date within
+     * a month, e.g., the first Monday on or after the 8th.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    A date within that month (1-based).
+     * @param dayOfWeek     The day of the week on which this rule occurs.
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST takes effect in local wall time, which is
+     *                      standard time in this case.
+     * @param after         If true, this rule selects the first dayOfWeek on
+     *                      or after dayOfMonth.  If false, this rule selects
+     *                      the last dayOfWeek on or before dayOfMonth.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
+                      int32_t time, UBool after, UErrorCode& status);
+    /**
+     * Sets the DST start rule to a weekday before or after a give date within
+     * a month, e.g., the first Monday on or after the 8th.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    A date within that month (1-based).
+     * @param dayOfWeek     The day of the week on which this rule occurs.
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST takes effect in local wall time, which is
+     *                      standard time in this case.
+     * @param mode whether the time is local wall time, local standard time,
+     * or UTC time. Default is local wall time.
+     * @param after         If true, this rule selects the first dayOfWeek on
+     *                      or after dayOfMonth.  If false, this rule selects
+     *                      the last dayOfWeek on or before dayOfMonth.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
+                      int32_t time, TimeMode mode, UBool after, UErrorCode& status);
+
+    /**
+     * Sets the daylight savings ending rule. For example, in the U.S., Daylight
+     * Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time.
+     * Therefore, you can set the end rule by calling:
+     * <pre>
+     * .   setEndRule(TimeFields.OCTOBER, -1, TimeFields.SUNDAY, 2*60*60*1000);
+     * </pre>
+     * Various other types of rules can be specified by manipulating the dayOfWeek
+     * and dayOfWeekInMonth parameters.  For complete details, see the documentation
+     * for setStartRule().
+     *
+     * @param month the daylight savings ending month. Month is 0-based.
+     * eg, 0 for January.
+     * @param dayOfWeekInMonth the daylight savings ending
+     * day-of-week-in-month. See setStartRule() for a complete explanation.
+     * @param dayOfWeek the daylight savings ending day-of-week. See setStartRule()
+     * for a complete explanation.
+     * @param time the daylight savings ending time. Please see the member
+     * description for an example.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
+                    int32_t time, UErrorCode& status);
+
+    /**
+     * Sets the daylight savings ending rule. For example, in the U.S., Daylight
+     * Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time.
+     * Therefore, you can set the end rule by calling:
+     * <pre>
+     * .   setEndRule(TimeFields.OCTOBER, -1, TimeFields.SUNDAY, 2*60*60*1000);
+     * </pre>
+     * Various other types of rules can be specified by manipulating the dayOfWeek
+     * and dayOfWeekInMonth parameters.  For complete details, see the documentation
+     * for setStartRule().
+     *
+     * @param month the daylight savings ending month. Month is 0-based.
+     * eg, 0 for January.
+     * @param dayOfWeekInMonth the daylight savings ending
+     * day-of-week-in-month. See setStartRule() for a complete explanation.
+     * @param dayOfWeek the daylight savings ending day-of-week. See setStartRule()
+     * for a complete explanation.
+     * @param time the daylight savings ending time. Please see the member
+     * description for an example.
+     * @param mode whether the time is local wall time, local standard time,
+     * or UTC time. Default is local wall time.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
+                    int32_t time, TimeMode mode, UErrorCode& status);
+
+    /**
+     * Sets the DST end rule to a fixed date within a month.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    The date in that month (1-based).
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST ends in local wall time, which is daylight
+     *                      time in this case.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
+
+    /**
+     * Sets the DST end rule to a fixed date within a month.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    The date in that month (1-based).
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST ends in local wall time, which is daylight
+     *                      time in this case.
+     * @param mode whether the time is local wall time, local standard time,
+     * or UTC time. Default is local wall time.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
+                    TimeMode mode, UErrorCode& status);
+
+    /**
+     * Sets the DST end rule to a weekday before or after a give date within
+     * a month, e.g., the first Monday on or after the 8th.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    A date within that month (1-based).
+     * @param dayOfWeek     The day of the week on which this rule occurs.
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST ends in local wall time, which is daylight
+     *                      time in this case.
+     * @param after         If true, this rule selects the first dayOfWeek on
+     *                      or after dayOfMonth.  If false, this rule selects
+     *                      the last dayOfWeek on or before dayOfMonth.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
+                    int32_t time, UBool after, UErrorCode& status);
+
+    /**
+     * Sets the DST end rule to a weekday before or after a give date within
+     * a month, e.g., the first Monday on or after the 8th.
+     *
+     * @param month         The month in which this rule occurs (0-based).
+     * @param dayOfMonth    A date within that month (1-based).
+     * @param dayOfWeek     The day of the week on which this rule occurs.
+     * @param time          The time of that day (number of millis after midnight)
+     *                      when DST ends in local wall time, which is daylight
+     *                      time in this case.
+     * @param mode whether the time is local wall time, local standard time,
+     * or UTC time. Default is local wall time.
+     * @param after         If true, this rule selects the first dayOfWeek on
+     *                      or after dayOfMonth.  If false, this rule selects
+     *                      the last dayOfWeek on or before dayOfMonth.
+     * @param status An UErrorCode
+     * @stable ICU 2.0
+     */
+    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
+                    int32_t time, TimeMode mode, UBool after, UErrorCode& status);
+
+    /**
+     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time in this time zone, taking daylight savings time into
+     * account) as of a particular reference date.  The reference date is used to determine
+     * whether daylight savings time is in effect and needs to be figured into the offset
+     * that is returned (in other words, what is the adjusted GMT offset in this time zone
+     * at this particular date and time?).  For the time zones produced by createTimeZone(),
+     * the reference data is specified according to the Gregorian calendar, and the date
+     * and time fields are in GMT, NOT local time.
+     *
+     * @param era        The reference date's era
+     * @param year       The reference date's year
+     * @param month      The reference date's month (0-based; 0 is January)
+     * @param day        The reference date's day-in-month (1-based)
+     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)
+     * @param millis     The reference date's milliseconds in day, UTT (NOT local time).
+     * @param status     An UErrorCode to receive the status.
+     * @return           The offset in milliseconds to add to GMT to get local time.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
+
+    /**
+     * Gets the time zone offset, for current date, modified in case of
+     * daylight savings. This is the offset to add *to* UTC to get local time.
+     * @param era the era of the given date.
+     * @param year the year in the given date.
+     * @param month the month in the given date.
+     * Month is 0-based. e.g., 0 for January.
+     * @param day the day-in-month of the given date.
+     * @param dayOfWeek the day-of-week of the given date.
+     * @param milliseconds the millis in day in <em>standard</em> local time.
+     * @param monthLength the length of the given month in days.
+     * @param status     An UErrorCode to receive the status.
+     * @return the offset to add *to* GMT to get local time.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                           uint8_t dayOfWeek, int32_t milliseconds,
+                           int32_t monthLength, UErrorCode& status) const;
+    /**
+     * Gets the time zone offset, for current date, modified in case of
+     * daylight savings. This is the offset to add *to* UTC to get local time.
+     * @param era the era of the given date.
+     * @param year the year in the given date.
+     * @param month the month in the given date.
+     * Month is 0-based. e.g., 0 for January.
+     * @param day the day-in-month of the given date.
+     * @param dayOfWeek the day-of-week of the given date.
+     * @param milliseconds the millis in day in <em>standard</em> local time.
+     * @param monthLength the length of the given month in days.
+     * @param prevMonthLength length of the previous month in days.
+     * @param status     An UErrorCode to receive the status.
+     * @return the offset to add *to* GMT to get local time.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                              uint8_t dayOfWeek, int32_t milliseconds,
+                              int32_t monthLength, int32_t prevMonthLength,
+                              UErrorCode& status) const;
+
+    /**
+     * Redeclared TimeZone method.  This implementation simply calls
+     * the base class method, which otherwise would be hidden.
+     * @stable ICU 2.8
+     */
+    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
+                           int32_t& dstOffset, UErrorCode& ec) const;
+
+    /**
+     * Get time zone offsets from local wall time.
+     * @internal
+     */
+    virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,
+        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/;
+
+    /**
+     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @return   The TimeZone's raw GMT offset.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getRawOffset(void) const;
+
+    /**
+     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @param offsetMillis  The new raw GMT offset for this time zone.
+     * @stable ICU 2.0
+     */
+    virtual void setRawOffset(int32_t offsetMillis);
+
+    /**
+     * Sets the amount of time in ms that the clock is advanced during DST.
+     * @param millisSavedDuringDST the number of milliseconds the time is
+     * advanced with respect to standard time when the daylight savings rules
+     * are in effect. A positive number, typically one hour (3600000).
+     * @param status  An UErrorCode to receive the status.
+     * @stable ICU 2.0
+     */
+    void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);
+
+    /**
+     * Returns the amount of time in ms that the clock is advanced during DST.
+     * @return the number of milliseconds the time is
+     * advanced with respect to standard time when the daylight savings rules
+     * are in effect. A positive number, typically one hour (3600000).
+     * @stable ICU 2.0
+     */
+    virtual int32_t getDSTSavings(void) const;
+
+    /**
+     * Queries if this TimeZone uses Daylight Savings Time.
+     *
+     * @return   True if this TimeZone uses Daylight Savings Time; false otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool useDaylightTime(void) const;
+
+    /**
+     * Returns true if the given date is within the period when daylight savings time
+     * is in effect; false otherwise.  If the TimeZone doesn't observe daylight savings
+     * time, this functions always returns false.
+     * This method is wasteful since it creates a new GregorianCalendar and
+     * deletes it each time it is called. This is a deprecated method
+     * and provided only for Java compatibility.
+     *
+     * @param date The date to test.
+     * @param status  An UErrorCode to receive the status.
+     * @return true if the given date is in Daylight Savings Time;
+     * false otherwise.
+     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
+     */
+    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
+
+    /**
+     * Return true if this zone has the same rules and offset as another zone.
+     * @param other the TimeZone object to be compared with
+     * @return true if the given zone has the same rules and offset as this one
+     * @stable ICU 2.0
+     */
+    UBool hasSameRules(const TimeZone& other) const;
+
+    /**
+     * Clones TimeZone objects polymorphically. Clients are responsible for deleting
+     * the TimeZone object cloned.
+     *
+     * @return   A new copy of this TimeZone object.
+     * @stable ICU 2.0
+     */
+    virtual TimeZone* clone(void) const;
+
+    /**
+     * Gets the first time zone transition after the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the first transition after the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
+
+    /**
+     * Gets the most recent time zone transition before the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the most recent transition before the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
+
+    /**
+     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
+     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
+     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.
+     * @param status    Receives error status code.
+     * @return The number of <code>TimeZoneRule</code>s representing time transitions.
+     * @stable ICU 4.0
+     */
+    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;
+
+    /**
+     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
+     * which represent time transitions for this time zone.  On successful return,
+     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
+     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
+     * instances up to the size specified by trscount.  The results are referencing the
+     * rule instance held by this time zone instance.  Therefore, after this time zone
+     * is destructed, they are no longer available.
+     * @param initial       Receives the initial timezone rule
+     * @param trsrules      Receives the timezone transition rules
+     * @param trscount      On input, specify the size of the array 'transitions' receiving
+     *                      the timezone transition rules.  On output, actual number of
+     *                      rules filled in the array will be set.
+     * @param status        Receives error status code.
+     * @stable ICU 4.0
+     */
+    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
+        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;
+
+
+public:
+
+    /**
+     * Override TimeZone Returns a unique class ID POLYMORPHICALLY. Pure virtual
+     * override. This method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
+     * this method.
+     *
+     * @return   The class ID for this object. All objects of a given class have the
+     *           same class ID. Objects of other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Return the class ID for this class. This is useful only for comparing to a return
+     * value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       Derived::getStaticClassID()) ...
+     * </pre>
+     * @return   The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+private:
+    /**
+     * Constants specifying values of startMode and endMode.
+     */
+    enum EMode
+    {
+        DOM_MODE = 1,
+        DOW_IN_MONTH_MODE,
+        DOW_GE_DOM_MODE,
+        DOW_LE_DOM_MODE
+    };
+
+    SimpleTimeZone(); // default constructor not implemented
+
+    /**
+     * Internal construction method.
+     * @param rawOffsetGMT    The new SimpleTimeZone's raw GMT offset
+     * @param startMonth      the month DST starts
+     * @param startDay        the day DST starts
+     * @param startDayOfWeek  the DOW DST starts
+     * @param startTime       the time DST starts
+     * @param startTimeMode   Whether the start time is local wall time, local
+     *                        standard time, or UTC time. Default is local wall time.
+     * @param endMonth        the month DST ends
+     * @param endDay          the day DST ends
+     * @param endDayOfWeek    the DOW DST ends
+     * @param endTime         the time DST ends
+     * @param endTimeMode     Whether the end time is local wall time, local
+     *                        standard time, or UTC time. Default is local wall time.
+     * @param savingsDST      The number of milliseconds added to standard time
+     *                        to get DST time. Default is one hour.
+     * @param status          An UErrorCode to receive the status.
+     */
+    void construct(int32_t rawOffsetGMT,
+                   int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
+                   int32_t startTime, TimeMode startTimeMode,
+                   int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
+                   int32_t endTime, TimeMode endTimeMode,
+                   int32_t dstSavings, UErrorCode& status);
+
+    /**
+     * Compare a given date in the year to a rule. Return 1, 0, or -1, depending
+     * on whether the date is after, equal to, or before the rule date. The
+     * millis are compared directly against the ruleMillis, so any
+     * standard-daylight adjustments must be handled by the caller.
+     *
+     * @return  1 if the date is after the rule date, -1 if the date is before
+     *          the rule date, or 0 if the date is equal to the rule date.
+     */
+    static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
+                                 int8_t dayOfMonth,
+                                 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
+                                 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
+                                 int8_t ruleDay, int32_t ruleMillis);
+
+    /**
+     * Given a set of encoded rules in startDay and startDayOfMonth, decode
+     * them and set the startMode appropriately.  Do the same for endDay and
+     * endDayOfMonth.
+     * <P>
+     * Upon entry, the day of week variables may be zero or
+     * negative, in order to indicate special modes.  The day of month
+     * variables may also be negative.
+     * <P>
+     * Upon exit, the mode variables will be
+     * set, and the day of week and day of month variables will be positive.
+     * <P>
+     * This method also recognizes a startDay or endDay of zero as indicating
+     * no DST.
+     */
+    void decodeRules(UErrorCode& status);
+    void decodeStartRule(UErrorCode& status);
+    void decodeEndRule(UErrorCode& status);
+
+    int8_t startMonth, startDay, startDayOfWeek;   // the month, day, DOW, and time DST starts
+    int32_t startTime;
+    TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode
+    int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends
+    int32_t endTime;
+    int32_t startYear;  // the year these DST rules took effect
+    int32_t rawOffset;  // the TimeZone's raw GMT offset
+    UBool useDaylight; // flag indicating whether this TimeZone uses DST
+    static const int8_t STATICMONTHLENGTH[12]; // lengths of the months
+    EMode startMode, endMode;   // flags indicating what kind of rules the DST rules are
+
+    /**
+     * A positive value indicating the amount of time saved during DST in ms.
+     * Typically one hour; sometimes 30 minutes.
+     */
+    int32_t dstSavings;
+
+    /* Private for BasicTimeZone implementation */
+    void initTransitionRules(UErrorCode& status);
+    void clearTransitionRules(void);
+    void deleteTransitionRules(void);
+    UBool   transitionRulesInitialized;
+    InitialTimeZoneRule*    initialRule;
+    TimeZoneTransition*     firstTransition;
+    AnnualTimeZoneRule*     stdRule;
+    AnnualTimeZoneRule*     dstRule;
+};
+
+inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
+                                         int32_t dayOfWeek,
+                                         int32_t time, UErrorCode& status) {
+    setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
+}
+
+inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
+                                         int32_t time,
+                                         UErrorCode& status) {
+    setStartRule(month, dayOfMonth, time, WALL_TIME, status);
+}
+
+inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
+                                         int32_t dayOfWeek,
+                                         int32_t time, UBool after, UErrorCode& status) {
+    setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
+}
+
+inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
+                                       int32_t dayOfWeek,
+                                       int32_t time, UErrorCode& status) {
+    setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
+}
+
+inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
+                                       int32_t time, UErrorCode& status) {
+    setEndRule(month, dayOfMonth, time, WALL_TIME, status);
+}
+
+inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
+                                       int32_t time, UBool after, UErrorCode& status) {
+    setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
+}
+
+inline void
+SimpleTimeZone::getOffset(UDate date, UBool local, int32_t& rawOffsetRef,
+                          int32_t& dstOffsetRef, UErrorCode& ec) const {
+    TimeZone::getOffset(date, local, rawOffsetRef, dstOffsetRef, ec);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _SIMPLETZ
diff --git a/CoreFoundation/icu/unicode/smpdtfmt.h b/CoreFoundation/icu/unicode/smpdtfmt.h
new file mode 100644
index 0000000..a68d9d3
--- /dev/null
+++ b/CoreFoundation/icu/unicode/smpdtfmt.h
@@ -0,0 +1,959 @@
+/*
+* Copyright (C) 1997-2008, International Business Machines Corporation and others. All Rights Reserved.
+*******************************************************************************
+*
+* File SMPDTFMT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/19/97    aliu        Converted from java.
+*   07/09/97    helena      Make ParsePosition into a class.
+*   07/21/98    stephen     Added GMT_PLUS, GMT_MINUS
+*                            Changed setTwoDigitStartDate to set2DigitYearStart
+*                            Changed getTwoDigitStartDate to get2DigitYearStart
+*                            Removed subParseLong
+*                            Removed getZoneIndex (added in DateFormatSymbols)
+*   06/14/99    stephen     Removed fgTimeZoneDataSuffix
+*   10/14/99    aliu        Updated class doc to describe 2-digit year parsing
+*                           {j28 4182066}.
+*******************************************************************************
+*/
+
+#ifndef SMPDTFMT_H
+#define SMPDTFMT_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Format and parse dates in a language-independent manner.
+ */
+ 
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/datefmt.h"
+
+U_NAMESPACE_BEGIN
+
+class DateFormatSymbols;
+class DateFormat;
+class MessageFormat;
+
+/**
+ *
+ * SimpleDateFormat is a concrete class for formatting and parsing dates in a
+ * language-independent manner. It allows for formatting (millis -> text),
+ * parsing (text -> millis), and normalization. Formats/Parses a date or time,
+ * which is the standard milliseconds since 24:00 GMT, Jan 1, 1970.
+ * <P>
+ * Clients are encouraged to create a date-time formatter using DateFormat::getInstance(),
+ * getDateInstance(), getDateInstance(), or getDateTimeInstance() rather than
+ * explicitly constructing an instance of SimpleDateFormat.  This way, the client
+ * is guaranteed to get an appropriate formatting pattern for whatever locale the
+ * program is running in.  However, if the client needs something more unusual than
+ * the default patterns in the locales, he can construct a SimpleDateFormat directly
+ * and give it an appropriate pattern (or use one of the factory methods on DateFormat
+ * and modify the pattern after the fact with toPattern() and applyPattern().
+ * <P>
+ * Date/Time format syntax:
+ * <P>
+ * The date/time format is specified by means of a string time pattern. In this
+ * pattern, all ASCII letters are reserved as pattern letters, which are defined
+ * as the following:
+ * <pre>
+ * \code
+ * Symbol   Meaning                 Presentation        Example
+ * ------   -------                 ------------        -------
+ * G        era designator          (Text)              AD
+ * y        year                    (Number)            1996
+ * Y        year (week of year)     (Number)            1997
+ * u        extended year           (Number)            4601
+ * Q        Quarter                 (Text & Number)     Q2 & 02
+ * M        month in year           (Text & Number)     July & 07
+ * d        day in month            (Number)            10
+ * h        hour in am/pm (1~12)    (Number)            12
+ * H        hour in day (0~23)      (Number)            0
+ * m        minute in hour          (Number)            30
+ * s        second in minute        (Number)            55
+ * S        fractional second       (Number)            978
+ * E        day of week             (Text)              Tuesday
+ * e        day of week (local 1~7) (Text & Number)     Tues & 2
+ * D        day in year             (Number)            189
+ * F        day of week in month    (Number)            2 (2nd Wed in July)
+ * w        week in year            (Number)            27
+ * W        week in month           (Number)            2
+ * a        am/pm marker            (Text)              PM
+ * k        hour in day (1~24)      (Number)            24
+ * K        hour in am/pm (0~11)    (Number)            0
+ * z        time zone               (Time)              Pacific Standard Time
+ * Z        time zone (RFC 822)     (Number)            -0800
+ * v        time zone (generic)     (Text)              Pacific Time
+ * V        time zone (abreviation) (Text)              PT
+ * VVVV     time zone (location)    (Text)              United States (Los Angeles)
+ * g        Julian day              (Number)            2451334
+ * A        milliseconds in day     (Number)            69540000
+ * q        stand alone quarter     (Text & Number)     Q2 & 02
+ * L        stand alone month       (Text & Number)     July & 07
+ * c        stand alone day of week (Text & Number)     Tuesday & 2
+ * '        escape for text         (Delimiter)         'Date='
+ * ''       single quote            (Literal)           'o''clock'
+ * \endcode
+ * </pre>
+ * The count of pattern letters determine the format.
+ * <P>
+ * (Text): 4 or more, use full form, &lt;4, use short or abbreviated form if it
+ * exists. (e.g., "EEEE" produces "Monday", "EEE" produces "Mon")
+ * <P>
+ * (Number): the minimum number of digits. Shorter numbers are zero-padded to
+ * this amount (e.g. if "m" produces "6", "mm" produces "06"). Year is handled
+ * specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits.
+ * (e.g., if "yyyy" produces "1997", "yy" produces "97".)
+ * Unlike other fields, fractional seconds are padded on the right with zero.
+ * <P>
+ * (Text & Number): 3 or over, use text, otherwise use number.  (e.g., "M" produces "1",
+ * "MM" produces "01", "MMM" produces "Jan", and "MMMM" produces "January".)
+ * <P>
+ * Any characters in the pattern that are not in the ranges of ['a'..'z'] and
+ * ['A'..'Z'] will be treated as quoted text. For instance, characters
+ * like ':', '.', ' ', '#' and '@' will appear in the resulting time text
+ * even they are not embraced within single quotes.
+ * <P>
+ * A pattern containing any invalid pattern letter will result in a failing
+ * UErrorCode result during formatting or parsing.
+ * <P>
+ * Examples using the US locale:
+ * <pre>
+ * \code
+ *    Format Pattern                         Result
+ *    --------------                         -------
+ *    "yyyy.MM.dd G 'at' HH:mm:ss vvvv" ->>  1996.07.10 AD at 15:08:56 Pacific Time
+ *    "EEE, MMM d, ''yy"                ->>  Wed, July 10, '96
+ *    "h:mm a"                          ->>  12:08 PM
+ *    "hh 'o''clock' a, zzzz"           ->>  12 o'clock PM, Pacific Daylight Time
+ *    "K:mm a, vvv"                     ->>  0:00 PM, PT
+ *    "yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM
+ * \endcode
+ * </pre>
+ * Code Sample:
+ * <pre>
+ * \code
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
+ *     pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000);
+ *     pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000);
+ *
+ *     // Format the current time.
+ *     SimpleDateFormat* formatter
+ *         = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz", success );
+ *     GregorianCalendar cal(success);
+ *     UDate currentTime_1 = cal.getTime(success);
+ *     FieldPosition fp(0);
+ *     UnicodeString dateString;
+ *     formatter->format( currentTime_1, dateString, fp );
+ *     cout << "result: " << dateString << endl;
+ *
+ *     // Parse the previous string back into a Date.
+ *     ParsePosition pp(0);
+ *     UDate currentTime_2 = formatter->parse(dateString, pp );
+ * \endcode
+ * </pre>
+ * In the above example, the time value "currentTime_2" obtained from parsing
+ * will be equal to currentTime_1. However, they may not be equal if the am/pm
+ * marker 'a' is left out from the format pattern while the "hour in am/pm"
+ * pattern symbol is used. This information loss can happen when formatting the
+ * time in PM.
+ *
+ * <p>
+ * When parsing a date string using the abbreviated year pattern ("y" or "yy"),
+ * SimpleDateFormat must interpret the abbreviated year
+ * relative to some century.  It does this by adjusting dates to be
+ * within 80 years before and 20 years after the time the SimpleDateFormat
+ * instance is created. For example, using a pattern of "MM/dd/yy" and a
+ * SimpleDateFormat instance created on Jan 1, 1997,  the string
+ * "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64"
+ * would be interpreted as May 4, 1964.
+ * During parsing, only strings consisting of exactly two digits, as defined by
+ * <code>Unicode::isDigit()</code>, will be parsed into the default century.
+ * Any other numeric string, such as a one digit string, a three or more digit
+ * string, or a two digit string that isn't all digits (for example, "-1"), is
+ * interpreted literally.  So "01/02/3" or "01/02/003" are parsed, using the
+ * same pattern, as Jan 2, 3 AD.  Likewise, "01/02/-3" is parsed as Jan 2, 4 BC.
+ *
+ * <p>
+ * If the year pattern has more than two 'y' characters, the year is
+ * interpreted literally, regardless of the number of digits.  So using the
+ * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
+ *
+ * <p>
+ * When numeric fields abut one another directly, with no intervening delimiter
+ * characters, they constitute a run of abutting numeric fields.  Such runs are
+ * parsed specially.  For example, the format "HHmmss" parses the input text
+ * "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to
+ * parse "1234".  In other words, the leftmost field of the run is flexible,
+ * while the others keep a fixed width.  If the parse fails anywhere in the run,
+ * then the leftmost field is shortened by one character, and the entire run is
+ * parsed again. This is repeated until either the parse succeeds or the
+ * leftmost field is one character in length.  If the parse still fails at that
+ * point, the parse of the run fails.
+ *
+ * <P>
+ * For time zones that have no names, SimpleDateFormat uses strings GMT+hours:minutes or
+ * GMT-hours:minutes.
+ * <P>
+ * The calendar defines what is the first day of the week, the first week of the
+ * year, whether hours are zero based or not (0 vs 12 or 24), and the timezone.
+ * There is one common number format to handle all the numbers; the digit count
+ * is handled programmatically according to the pattern.
+ *
+ * <p><em>User subclasses are not supported.</em> While clients may write
+ * subclasses, such code will not necessarily work and will not be
+ * guaranteed to work stably from release to release.
+ */
+class U_I18N_API SimpleDateFormat: public DateFormat {
+public:
+    /**
+     * Construct a SimpleDateFormat using the default pattern for the default
+     * locale.
+     * <P>
+     * [Note:] Not all locales support SimpleDateFormat; for full generality,
+     * use the factory methods in the DateFormat class.
+     * @param status    Output param set to success/failure code.
+     * @stable ICU 2.0
+     */
+    SimpleDateFormat(UErrorCode& status);
+
+    /**
+     * Construct a SimpleDateFormat using the given pattern and the default locale.
+     * The locale is used to obtain the symbols used in formatting (e.g., the
+     * names of the months), but not to provide the pattern.
+     * <P>
+     * [Note:] Not all locales support SimpleDateFormat; for full generality,
+     * use the factory methods in the DateFormat class.
+     * @param pattern    the pattern for the format.
+     * @param status     Output param set to success/failure code.
+     * @stable ICU 2.0
+     */
+    SimpleDateFormat(const UnicodeString& pattern,
+                     UErrorCode& status);
+
+    /**
+     * Construct a SimpleDateFormat using the given pattern and locale.
+     * The locale is used to obtain the symbols used in formatting (e.g., the
+     * names of the months), but not to provide the pattern.
+     * <P>
+     * [Note:] Not all locales support SimpleDateFormat; for full generality,
+     * use the factory methods in the DateFormat class.
+     * @param pattern    the pattern for the format.
+     * @param locale     the given locale.
+     * @param status     Output param set to success/failure code.
+     * @stable ICU 2.0
+     */
+    SimpleDateFormat(const UnicodeString& pattern,
+                     const Locale& locale,
+                     UErrorCode& status);
+
+    /**
+     * Construct a SimpleDateFormat using the given pattern and locale-specific
+     * symbol data.  The formatter takes ownership of the DateFormatSymbols object;
+     * the caller is no longer responsible for deleting it.
+     * @param pattern           the given pattern for the format.
+     * @param formatDataToAdopt the symbols to be adopted.
+     * @param status            Output param set to success/faulure code.
+     * @stable ICU 2.0
+     */
+    SimpleDateFormat(const UnicodeString& pattern,
+                     DateFormatSymbols* formatDataToAdopt,
+                     UErrorCode& status);
+
+    /**
+     * Construct a SimpleDateFormat using the given pattern and locale-specific
+     * symbol data.  The DateFormatSymbols object is NOT adopted; the caller
+     * remains responsible for deleting it.
+     * @param pattern           the given pattern for the format.
+     * @param formatData        the formatting symbols to be use.
+     * @param status            Output param set to success/faulure code.
+     * @stable ICU 2.0
+     */
+    SimpleDateFormat(const UnicodeString& pattern,
+                     const DateFormatSymbols& formatData,
+                     UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.0
+     */
+    SimpleDateFormat(const SimpleDateFormat&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.0
+     */
+    SimpleDateFormat& operator=(const SimpleDateFormat&);
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~SimpleDateFormat();
+
+    /**
+     * Clone this Format object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @stable ICU 2.0
+     */
+    virtual Format* clone(void) const;
+
+    /**
+     * Return true if the given Format objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param other    the object to be compared with.
+     * @return         true if the given Format objects are semantically equal.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Format& other) const;
+
+    /**
+     * Format a date or time, which is the standard millis since 24:00 GMT, Jan
+     * 1, 1970. Overrides DateFormat pure virtual method.
+     * <P>
+     * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
+     * 1996.07.10 AD at 15:08:56 PDT
+     *
+     * @param cal       Calendar set to the date and time to be formatted
+     *                  into a date/time string.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       The formatting position. On input: an alignment field,
+     *                  if desired. On output: the offsets of the alignment field.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.1
+     */
+    virtual UnicodeString& format(  Calendar& cal,
+                                    UnicodeString& appendTo,
+                                    FieldPosition& pos) const;
+
+    /**
+     * Format a date or time, which is the standard millis since 24:00 GMT, Jan
+     * 1, 1970. Overrides DateFormat pure virtual method.
+     * <P>
+     * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
+     * 1996.07.10 AD at 15:08:56 PDT
+     *
+     * @param obj       A Formattable containing the date-time value to be formatted
+     *                  into a date-time string.  If the type of the Formattable
+     *                  is a numeric type, it is treated as if it were an
+     *                  instance of Date.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param pos       The formatting position. On input: an alignment field,
+     *                  if desired. On output: the offsets of the alignment field.
+     * @param status    Output param set to success/faulure code.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& format(  const Formattable& obj,
+                                    UnicodeString& appendTo,
+                                    FieldPosition& pos,
+                                    UErrorCode& status) const;
+
+    /**
+     * Redeclared DateFormat method.
+     * @param date          the Date value to be formatted.
+     * @param appendTo      Output parameter to receive result.
+     *                      Result is appended to existing contents.
+     * @param fieldPosition The formatting position. On input: an alignment field,
+     *                      if desired. On output: the offsets of the alignment field.
+     * @return              Reference to 'appendTo' parameter.
+     * @stable ICU 2.1
+     */
+    UnicodeString& format(UDate date,
+                          UnicodeString& appendTo,
+                          FieldPosition& fieldPosition) const;
+
+    /**
+     * Redeclared DateFormat method.
+     * @param obj       Object to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param status    Input/output success/failure code.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(const Formattable& obj,
+                          UnicodeString& appendTo,
+                          UErrorCode& status) const;
+
+    /**
+     * Redeclared DateFormat method.
+     * @param date      Date value to be formatted.
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @return          Reference to 'appendTo' parameter.
+     * @stable ICU 2.0
+     */
+    UnicodeString& format(UDate date, UnicodeString& appendTo) const;
+
+    /**
+     * Parse a date/time string beginning at the given parse position. For
+     * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
+     * that is equivalent to Date(837039928046).
+     * <P>
+     * By default, parsing is lenient: If the input is not in the form used by
+     * this object's format method but can still be parsed as a date, then the
+     * parse succeeds. Clients may insist on strict adherence to the format by
+     * calling setLenient(false).
+     *
+     * @param text  The date/time string to be parsed
+     * @param cal   a Calendar set to the date and time to be formatted
+     *              into a date/time string.
+     * @param pos   On input, the position at which to start parsing; on
+     *              output, the position at which parsing terminated, or the
+     *              start position if the parse failed.
+     * @return      A valid UDate if the input could be parsed.
+     * @stable ICU 2.1
+     */
+    virtual void parse( const UnicodeString& text,
+                        Calendar& cal,
+                        ParsePosition& pos) const;
+
+    /**
+     * Parse a date/time string starting at the given parse position. For
+     * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
+     * that is equivalent to Date(837039928046).
+     * <P>
+     * By default, parsing is lenient: If the input is not in the form used by
+     * this object's format method but can still be parsed as a date, then the
+     * parse succeeds. Clients may insist on strict adherence to the format by
+     * calling setLenient(false).
+     *
+     * @see DateFormat::setLenient(boolean)
+     *
+     * @param text  The date/time string to be parsed
+     * @param pos   On input, the position at which to start parsing; on
+     *              output, the position at which parsing terminated, or the
+     *              start position if the parse failed.
+     * @return      A valid UDate if the input could be parsed.
+     * @stable ICU 2.0
+     */
+    UDate parse( const UnicodeString& text,
+                 ParsePosition& pos) const;
+
+
+    /**
+     * Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT"
+     * will be parsed into a UDate that is equivalent to Date(837039928046).
+     * Parsing begins at the beginning of the string and proceeds as far as
+     * possible.  Assuming no parse errors were encountered, this function
+     * doesn't return any information about how much of the string was consumed
+     * by the parsing.  If you need that information, use the version of
+     * parse() that takes a ParsePosition.
+     *
+     * @param text  The date/time string to be parsed
+     * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
+     *              an error value if there was a parse error.
+     * @return      A valid UDate if the input could be parsed.
+     * @stable ICU 2.0
+     */
+    virtual UDate parse( const UnicodeString& text,
+                        UErrorCode& status) const;
+
+    /**
+     * Set the start UDate used to interpret two-digit year strings.
+     * When dates are parsed having 2-digit year strings, they are placed within
+     * a assumed range of 100 years starting on the two digit start date.  For
+     * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or
+     * some other year.  SimpleDateFormat chooses a year so that the resultant
+     * date is on or after the two digit start date and within 100 years of the
+     * two digit start date.
+     * <P>
+     * By default, the two digit start date is set to 80 years before the current
+     * time at which a SimpleDateFormat object is created.
+     * @param d      start UDate used to interpret two-digit year strings.
+     * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
+     *               an error value if there was a parse error.
+     * @stable ICU 2.0
+     */
+    virtual void set2DigitYearStart(UDate d, UErrorCode& status);
+
+    /**
+     * Get the start UDate used to interpret two-digit year strings.
+     * When dates are parsed having 2-digit year strings, they are placed within
+     * a assumed range of 100 years starting on the two digit start date.  For
+     * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or
+     * some other year.  SimpleDateFormat chooses a year so that the resultant
+     * date is on or after the two digit start date and within 100 years of the
+     * two digit start date.
+     * <P>
+     * By default, the two digit start date is set to 80 years before the current
+     * time at which a SimpleDateFormat object is created.
+     * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
+     *               an error value if there was a parse error.
+     * @stable ICU 2.0
+     */
+    UDate get2DigitYearStart(UErrorCode& status) const;
+
+    /**
+     * Return a pattern string describing this date format.
+     * @param result Output param to receive the pattern.
+     * @return       A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toPattern(UnicodeString& result) const;
+
+    /**
+     * Return a localized pattern string describing this date format.
+     * In most cases, this will return the same thing as toPattern(),
+     * but a locale can specify characters to use in pattern descriptions
+     * in place of the ones described in this class's class documentation.
+     * (Presumably, letters that would be more mnemonic in that locale's
+     * language.)  This function would produce a pattern using those
+     * letters.
+     *
+     * @param result    Receives the localized pattern.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @return          A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toLocalizedPattern(UnicodeString& result,
+                                              UErrorCode& status) const;
+
+    /**
+     * Apply the given unlocalized pattern string to this date format.
+     * (i.e., after this call, this formatter will format dates according to
+     * the new pattern)
+     *
+     * @param pattern   The pattern to be applied.
+     * @stable ICU 2.0
+     */
+    virtual void applyPattern(const UnicodeString& pattern);
+
+    /**
+     * Apply the given localized pattern string to this date format.
+     * (see toLocalizedPattern() for more information on localized patterns.)
+     *
+     * @param pattern   The localized pattern to be applied.
+     * @param status    Output param set to success/failure code on
+     *                  exit. If the pattern is invalid, this will be
+     *                  set to a failure result.
+     * @stable ICU 2.0
+     */
+    virtual void applyLocalizedPattern(const UnicodeString& pattern,
+                                       UErrorCode& status);
+
+    /**
+     * Gets the date/time formatting symbols (this is an object carrying
+     * the various strings and other symbols used in formatting: e.g., month
+     * names and abbreviations, time zone names, AM/PM strings, etc.)
+     * @return a copy of the date-time formatting data associated
+     * with this date-time formatter.
+     * @stable ICU 2.0
+     */
+    virtual const DateFormatSymbols* getDateFormatSymbols(void) const;
+
+    /**
+     * Set the date/time formatting symbols.  The caller no longer owns the
+     * DateFormatSymbols object and should not delete it after making this call.
+     * @param newFormatSymbols the given date-time formatting symbols to copy.
+     * @stable ICU 2.0
+     */
+    virtual void adoptDateFormatSymbols(DateFormatSymbols* newFormatSymbols);
+
+    /**
+     * Set the date/time formatting data.
+     * @param newFormatSymbols the given date-time formatting symbols to copy.
+     * @stable ICU 2.0
+     */
+    virtual void setDateFormatSymbols(const DateFormatSymbols& newFormatSymbols);
+
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Set the calendar to be used by this date format. Initially, the default
+     * calendar for the specified or default locale is used.  The caller should
+     * not delete the Calendar object after it is adopted by this call.
+     * Adopting a new calendar will change to the default symbols.
+     *
+     * @param calendarToAdopt    Calendar object to be adopted.
+     * @stable ICU 2.0
+     */
+    virtual void adoptCalendar(Calendar* calendarToAdopt);
+
+    /**
+     * This is for ICU internal use only. Please do not use.
+     * Check whether the 'field' is smaller than all the fields covered in
+     * pattern, return TRUE if it is. The sequence of calendar field, 
+     * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
+     * @param field    the calendar field need to check against
+     * @return         TRUE if the 'field' is smaller than all the fields 
+     *                 covered in pattern. FALSE otherwise.
+     * @internal ICU 4.0
+     */
+    UBool isFieldUnitIgnored(UCalendarDateFields field) const;
+
+
+    /**
+     * This is for ICU internal use only. Please do not use.
+     * Check whether the 'field' is smaller than all the fields covered in
+     * pattern, return TRUE if it is. The sequence of calendar field, 
+     * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
+     * @param pattern  the pattern to check against
+     * @param field    the calendar field need to check against
+     * @return         TRUE if the 'field' is smaller than all the fields 
+     *                 covered in pattern. FALSE otherwise.
+     * @internal ICU 4.0
+     */
+    static UBool isFieldUnitIgnored(const UnicodeString& pattern, 
+                                    UCalendarDateFields field);
+
+
+
+    /**
+     * This is for ICU internal use only. Please do not use.
+     * Get the locale of this simple date formatter.
+     * It is used in DateIntervalFormat.
+     *
+     * @return   locale in this simple date formatter
+     * @internal ICU 4.0
+     */
+    const Locale& getSmpFmtLocale(void) const;
+
+
+private:
+    friend class DateFormat;
+
+    void initializeDefaultCentury(void);
+
+    SimpleDateFormat(); // default constructor not implemented
+
+    /**
+     * Used by the DateFormat factory methods to construct a SimpleDateFormat.
+     * @param timeStyle the time style.
+     * @param dateStyle the date style.
+     * @param locale    the given locale.
+     * @param status    Output param set to success/failure code on
+     *                  exit.
+     */
+    SimpleDateFormat(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);
+
+    /**
+     * Construct a SimpleDateFormat for the given locale.  If no resource data
+     * is available, create an object of last resort, using hard-coded strings.
+     * This is an internal method, called by DateFormat.  It should never fail.
+     * @param locale    the given locale.
+     * @param status    Output param set to success/failure code on
+     *                  exit.
+     */
+    SimpleDateFormat(const Locale& locale, UErrorCode& status); // Use default pattern
+
+    /**
+     * Called by format() to format a single field.
+     *
+     * @param appendTo  Output parameter to receive result.
+     *                  Result is appended to existing contents.
+     * @param ch        The format character we encountered in the pattern.
+     * @param count     Number of characters in the current pattern symbol (e.g.,
+     *                  "yyyy" in the pattern would result in a call to this function
+     *                  with ch equal to 'y' and count equal to 4)
+     * @param pos       The FieldPosition being filled in by the format() call.  If
+     *                  this function is formatting the field specfied by pos, it
+     *                  will fill in pos with the beginning and ending offsets of the
+     *                  field.
+     * @param status    Receives a status code, which will be U_ZERO_ERROR if the operation
+     *                  succeeds.
+     */
+    void subFormat(             UnicodeString &appendTo,
+                                UChar ch,
+                                int32_t count,
+                                FieldPosition& pos,
+                                Calendar& cal,
+                                UErrorCode& status) const; // in case of illegal argument
+
+    /**
+     * Used by subFormat() to format a numeric value.
+     * Appends to toAppendTo a string representation of "value"
+     * having a number of digits between "minDigits" and
+     * "maxDigits".  Uses the DateFormat's NumberFormat.
+     *
+     * @param appendTo  Output parameter to receive result.
+     *                  Formatted number is appended to existing contents.
+     * @param value     Value to format.
+     * @param minDigits Minimum number of digits the result should have
+     * @param maxDigits Maximum number of digits the result should have
+     */
+    void zeroPaddingNumber(          UnicodeString &appendTo,
+                                     int32_t value,
+                                     int32_t minDigits,
+                                     int32_t maxDigits) const;
+
+    /**
+     * Return true if the given format character, occuring count
+     * times, represents a numeric field.
+     */
+    static UBool isNumeric(UChar formatChar, int32_t count);
+
+    /**
+     * initializes fCalendar from parameters.  Returns fCalendar as a convenience.
+     * @param adoptZone  Zone to be adopted, or NULL for TimeZone::createDefault().
+     * @param locale Locale of the calendar
+     * @param status Error code
+     * @return the newly constructed fCalendar
+     */
+    Calendar *initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status);
+
+    /**
+     * initializes fSymbols from parameters.
+     * @param locale Locale of the symbols
+     * @param calendar Alias to Calendar that will be used.
+     * @param status Error code
+     */
+    void initializeSymbols(const Locale& locale, Calendar* calendar, UErrorCode& status);
+
+    /**
+     * Called by several of the constructors to load pattern data and formatting symbols
+     * out of a resource bundle and initialize the locale based on it.
+     * @param timeStyle     The time style, as passed to DateFormat::createDateInstance().
+     * @param dateStyle     The date style, as passed to DateFormat::createTimeInstance().
+     * @param locale        The locale to load the patterns from.
+     * @param status        Filled in with an error code if loading the data from the
+     *                      resources fails.
+     */
+    void construct(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);
+
+    /**
+     * Called by construct() and the various constructors to set up the SimpleDateFormat's
+     * Calendar and NumberFormat objects.
+     * @param locale    The locale for which we want a Calendar and a NumberFormat.
+     * @param statuc    Filled in with an error code if creating either subobject fails.
+     */
+    void initialize(const Locale& locale, UErrorCode& status);
+
+    /**
+     * Private code-size reduction function used by subParse.
+     * @param text the time text being parsed.
+     * @param start where to start parsing.
+     * @param field the date field being parsed.
+     * @param stringArray the string array to parsed.
+     * @param stringArrayCount the size of the array.
+     * @param cal a Calendar set to the date and time to be formatted
+     *            into a date/time string.
+     * @return the new start position if matching succeeded; a negative number
+     * indicating matching failure, otherwise.
+     */
+    int32_t matchString(const UnicodeString& text, int32_t start, UCalendarDateFields field,
+                        const UnicodeString* stringArray, int32_t stringArrayCount, Calendar& cal) const;
+
+    /**
+     * Private code-size reduction function used by subParse.
+     * @param text the time text being parsed.
+     * @param start where to start parsing.
+     * @param field the date field being parsed.
+     * @param stringArray the string array to parsed.
+     * @param stringArrayCount the size of the array.
+     * @param cal a Calendar set to the date and time to be formatted
+     *            into a date/time string.
+     * @return the new start position if matching succeeded; a negative number
+     * indicating matching failure, otherwise.
+     */
+    int32_t matchQuarterString(const UnicodeString& text, int32_t start, UCalendarDateFields field,
+                               const UnicodeString* stringArray, int32_t stringArrayCount, Calendar& cal) const;
+
+    /**
+     * Private member function that converts the parsed date strings into
+     * timeFields. Returns -start (for ParsePosition) if failed.
+     * @param text the time text to be parsed.
+     * @param start where to start parsing.
+     * @param ch the pattern character for the date field text to be parsed.
+     * @param count the count of a pattern character.
+     * @param obeyCount if true then the count is strictly obeyed.
+     * @param ambiguousYear If true then the two-digit year == the default start year.
+     * @param cal a Calendar set to the date and time to be formatted
+     *            into a date/time string.
+     * @return the new start position if matching succeeded; a negative number
+     * indicating matching failure, otherwise.
+     */
+    int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,
+                     UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], Calendar& cal) const;
+
+    void parseInt(const UnicodeString& text,
+                  Formattable& number,
+                  ParsePosition& pos,
+                  UBool allowNegative) const;
+
+    void parseInt(const UnicodeString& text,
+                  Formattable& number,
+                  int32_t maxDigits,
+                  ParsePosition& pos,
+                  UBool allowNegative) const;
+
+    /**
+     * Translate a pattern, mapping each character in the from string to the
+     * corresponding character in the to string. Return an error if the original
+     * pattern contains an unmapped character, or if a quote is unmatched.
+     * Quoted (single quotes only) material is not translated.
+     * @param originalPattern   the original pattern.
+     * @param translatedPattern Output param to receive the translited pattern.
+     * @param from              the characters to be translited from.
+     * @param to                the characters to be translited to.
+     * @param status            Receives a status code, which will be U_ZERO_ERROR
+     *                          if the operation succeeds.
+     */
+    static void translatePattern(const UnicodeString& originalPattern,
+                                UnicodeString& translatedPattern,
+                                const UnicodeString& from,
+                                const UnicodeString& to,
+                                UErrorCode& status);
+
+    /**
+     * Sets the starting date of the 100-year window that dates with 2-digit years
+     * are considered to fall within.
+     * @param startDate the start date
+     * @param status    Receives a status code, which will be U_ZERO_ERROR
+     *                  if the operation succeeds.
+     */
+    void         parseAmbiguousDatesAsAfter(UDate startDate, UErrorCode& status);
+    
+    /**
+     * Private methods for formatting/parsing GMT string
+     */
+    void appendGMT(UnicodeString &appendTo, Calendar& cal, UErrorCode& status) const;
+    void formatGMTDefault(UnicodeString &appendTo, int32_t offset) const;
+    int32_t parseGMT(const UnicodeString &text, ParsePosition &pos) const;
+    int32_t parseGMTDefault(const UnicodeString &text, ParsePosition &pos) const;
+    UBool isDefaultGMTFormat() const;
+
+    void formatRFC822TZ(UnicodeString &appendTo, int32_t offset) const;
+
+    /**
+     * Initialize MessageFormat instances used for GMT formatting/parsing
+     */
+    void initGMTFormatters(UErrorCode &status);
+
+    /**
+     * Used to map pattern characters to Calendar field identifiers.
+     */
+    static const UCalendarDateFields fgPatternIndexToCalendarField[];
+
+    /**
+     * Map index into pattern character string to DateFormat field number
+     */
+    static const UDateFormatField fgPatternIndexToDateFormatField[];
+
+    /**
+     * Used to map Calendar field to field level.
+     * The larger the level, the smaller the field unit.
+     * For example, UCAL_ERA level is 0, UCAL_YEAR level is 10,
+     * UCAL_MONTH level is 20.
+     */
+    static const int32_t fgCalendarFieldToLevel[];
+    static const int32_t fgPatternCharToLevel[];
+
+    /**
+     * The formatting pattern for this formatter.
+     */
+    UnicodeString       fPattern;
+
+    /**
+     * The original locale used (for reloading symbols)
+     */
+    Locale              fLocale;
+
+    /**
+     * A pointer to an object containing the strings to use in formatting (e.g.,
+     * month and day names, AM and PM strings, time zone names, etc.)
+     */
+    DateFormatSymbols*  fSymbols;   // Owned
+
+    /**
+     * If dates have ambiguous years, we map them into the century starting
+     * at defaultCenturyStart, which may be any date.  If defaultCenturyStart is
+     * set to SYSTEM_DEFAULT_CENTURY, which it is by default, then the system
+     * values are used.  The instance values defaultCenturyStart and
+     * defaultCenturyStartYear are only used if explicitly set by the user
+     * through the API method parseAmbiguousDatesAsAfter().
+     */
+    UDate                fDefaultCenturyStart;
+
+    /**
+     * See documentation for defaultCenturyStart.
+     */
+    /*transient*/ int32_t   fDefaultCenturyStartYear;
+
+    enum ParsedTZType {
+        TZTYPE_UNK,
+        TZTYPE_STD,
+        TZTYPE_DST
+    };
+
+    ParsedTZType tztype; // here to avoid api change
+
+    /*
+     * MessageFormat instances used for localized GMT format
+     */
+    MessageFormat   **fGMTFormatters;
+
+    UBool fHaveDefaultCentury;
+};
+
+inline UDate
+SimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const
+{
+    return fDefaultCenturyStart;
+}
+
+inline UnicodeString&
+SimpleDateFormat::format(const Formattable& obj,
+                         UnicodeString& appendTo,
+                         UErrorCode& status) const {
+    // Don't use Format:: - use immediate base class only,
+    // in case immediate base modifies behavior later.
+    return DateFormat::format(obj, appendTo, status);
+}
+
+inline UnicodeString&
+SimpleDateFormat::format(UDate date,
+                         UnicodeString& appendTo,
+                         FieldPosition& fieldPosition) const {
+    // Don't use Format:: - use immediate base class only,
+    // in case immediate base modifies behavior later.
+    return DateFormat::format(date, appendTo, fieldPosition);
+}
+
+inline UnicodeString&
+SimpleDateFormat::format(UDate date, UnicodeString& appendTo) const {
+    return DateFormat::format(date, appendTo);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // _SMPDTFMT
+//eof
diff --git a/CoreFoundation/icu/unicode/sortkey.h b/CoreFoundation/icu/unicode/sortkey.h
new file mode 100644
index 0000000..ef202dd
--- /dev/null
+++ b/CoreFoundation/icu/unicode/sortkey.h
@@ -0,0 +1,324 @@
+/*
+ *****************************************************************************
+ * Copyright (C) 1996-2006, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ *****************************************************************************
+ *
+ * File sortkey.h
+ *
+ * Created by: Helena Shih
+ *
+ * Modification History:
+ *
+ *  Date         Name          Description
+ *
+ *  6/20/97     helena      Java class name change.
+ *  8/18/97     helena      Added internal API documentation.
+ *  6/26/98     erm         Changed to use byte arrays and memcmp.
+ *****************************************************************************
+ */
+
+#ifndef SORTKEY_H
+#define SORTKEY_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Keys for comparing strings multiple times. 
+ */
+ 
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/coll.h"
+
+U_NAMESPACE_BEGIN
+
+/* forward declaration */
+class RuleBasedCollator;
+
+/**
+ *
+ * Collation keys are generated by the Collator class.  Use the CollationKey objects
+ * instead of Collator to compare strings multiple times.  A CollationKey
+ * preprocesses the comparison information from the Collator object to
+ * make the comparison faster.  If you are not going to comparing strings
+ * multiple times, then using the Collator object is generally faster,
+ * since it only processes as much of the string as needed to make a
+ * comparison.
+ * <p> For example (with strength == tertiary)
+ * <p>When comparing "Abernathy" to "Baggins-Smythworthy", Collator
+ * only needs to process a couple of characters, while a comparison
+ * with CollationKeys will process all of the characters.  On the other hand,
+ * if you are doing a sort of a number of fields, it is much faster to use
+ * CollationKeys, since you will be comparing strings multiple times.
+ * <p>Typical use of CollationKeys are in databases, where you store a CollationKey
+ * in a hidden field, and use it for sorting or indexing.
+ *
+ * <p>Example of use:
+ * <pre>
+ * \code
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     Collator* myCollator = Collator::createInstance(success);
+ *     CollationKey* keys = new CollationKey [3];
+ *     myCollator->getCollationKey("Tom", keys[0], success );
+ *     myCollator->getCollationKey("Dick", keys[1], success );
+ *     myCollator->getCollationKey("Harry", keys[2], success );
+ *
+ *     // Inside body of sort routine, compare keys this way:
+ *     CollationKey tmp;
+ *     if(keys[0].compareTo( keys[1] ) > 0 ) {
+ *         tmp = keys[0]; keys[0] = keys[1]; keys[1] = tmp;
+ *     }
+ *     //...
+ * \endcode
+ * </pre>
+ * <p>Because Collator::compare()'s algorithm is complex, it is faster to sort
+ * long lists of words by retrieving collation keys with Collator::getCollationKey().
+ * You can then cache the collation keys and compare them using CollationKey::compareTo().
+ * <p>
+ * <strong>Note:</strong> <code>Collator</code>s with different Locale,
+ * CollationStrength and DecompositionMode settings will return different
+ * CollationKeys for the same set of strings. Locales have specific
+ * collation rules, and the way in which secondary and tertiary differences
+ * are taken into account, for example, will result in different CollationKeys
+ * for same strings.
+ * <p>
+
+ * @see          Collator
+ * @see          RuleBasedCollator
+ * @version      1.3 12/18/96
+ * @author       Helena Shih
+ * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+ */
+class U_I18N_API CollationKey : public UObject {
+public:
+    /**
+    * This creates an empty collation key based on the null string.  An empty
+    * collation key contains no sorting information.  When comparing two empty
+    * collation keys, the result is Collator::EQUAL.  Comparing empty collation key
+    * with non-empty collation key is always Collator::LESS.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    CollationKey();
+
+
+    /**
+    * Creates a collation key based on the collation key values.
+    * @param values the collation key values
+    * @param count number of collation key values, including trailing nulls.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    CollationKey(const  uint8_t*    values,
+                int32_t     count);
+
+    /**
+    * Copy constructor.
+    * @param other    the object to be copied.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    CollationKey(const CollationKey& other);
+
+    /**
+    * Sort key destructor.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    virtual ~CollationKey();
+
+    /**
+    * Assignment operator
+    * @param other    the object to be copied.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    const   CollationKey&   operator=(const CollationKey& other);
+
+    /**
+    * Compare if two collation keys are the same.
+    * @param source the collation key to compare to.
+    * @return Returns true if two collation keys are equal, false otherwise.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    UBool                   operator==(const CollationKey& source) const;
+
+    /**
+    * Compare if two collation keys are not the same.
+    * @param source the collation key to compare to.
+    * @return Returns TRUE if two collation keys are different, FALSE otherwise.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    UBool                   operator!=(const CollationKey& source) const;
+
+
+    /**
+    * Test to see if the key is in an invalid state. The key will be in an
+    * invalid state if it couldn't allocate memory for some operation.
+    * @return Returns TRUE if the key is in an invalid, FALSE otherwise.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    UBool                   isBogus(void) const;
+
+    /**
+    * Returns a pointer to the collation key values. The storage is owned
+    * by the collation key and the pointer will become invalid if the key
+    * is deleted.
+    * @param count the output parameter of number of collation key values,
+    * including any trailing nulls.
+    * @return a pointer to the collation key values.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    const    uint8_t*       getByteArray(int32_t& count) const;
+
+#ifdef U_USE_COLLATION_KEY_DEPRECATES
+    /**
+    * Extracts the collation key values into a new array. The caller owns
+    * this storage and should free it.
+    * @param count the output parameter of number of collation key values,
+    * including any trailing nulls.
+    * @obsolete ICU 2.6. Use getByteArray instead since this API will be removed in that release.
+    */
+    uint8_t*                toByteArray(int32_t& count) const;
+#endif
+
+    /**
+    * Convenience method which does a string(bit-wise) comparison of the
+    * two collation keys.
+    * @param target target collation key to be compared with
+    * @return Returns Collator::LESS if sourceKey &lt; targetKey,
+    * Collator::GREATER if sourceKey > targetKey and Collator::EQUAL
+    * otherwise.
+    * @deprecated ICU 2.6 use the overload with error code
+    */
+    Collator::EComparisonResult compareTo(const CollationKey& target) const;
+
+    /**
+    * Convenience method which does a string(bit-wise) comparison of the
+    * two collation keys.
+    * @param target target collation key to be compared with
+    * @param status error code
+    * @return Returns UCOL_LESS if sourceKey &lt; targetKey,
+    * UCOL_GREATER if sourceKey > targetKey and UCOL_EQUAL
+    * otherwise.
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;
+
+    /**
+    * Creates an integer that is unique to the collation key.  NOTE: this
+    * is not the same as String.hashCode.
+    * <p>Example of use:
+    * <pre>
+    * .    UErrorCode status = U_ZERO_ERROR;
+    * .    Collator *myCollation = Collator::createInstance(Locale::US, status);
+    * .    if (U_FAILURE(status)) return;
+    * .    CollationKey key1, key2;
+    * .    UErrorCode status1 = U_ZERO_ERROR, status2 = U_ZERO_ERROR;
+    * .    myCollation->getCollationKey("abc", key1, status1);
+    * .    if (U_FAILURE(status1)) { delete myCollation; return; }
+    * .    myCollation->getCollationKey("ABC", key2, status2);
+    * .    if (U_FAILURE(status2)) { delete myCollation; return; }
+    * .    // key1.hashCode() != key2.hashCode()
+    * </pre>
+    * @return the hash value based on the string's collation order.
+    * @see UnicodeString#hashCode
+    * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+    */
+    int32_t                 hashCode(void) const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     * @deprecated ICU 2.8 Use Collator::getSortKey(...) instead
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+    /**
+    * Returns an array of the collation key values as 16-bit integers.
+    * The caller owns the storage and must delete it.
+    * @param values Output param of the collation key values.
+    * @param count output parameter of the number of collation key values
+    * @return a pointer to an array of 16-bit collation key values.
+    */
+    void adopt(uint8_t *values, int32_t count);
+
+    /*
+    * Creates a collation key with a string.
+    */
+
+    /**
+    * If this CollationKey has capacity less than newSize,
+    * its internal capacity will be increased to newSize.
+    * @param newSize minimum size this CollationKey has to have
+    * @return this CollationKey
+    */
+    CollationKey&           ensureCapacity(int32_t newSize);
+    /**
+    * Set the CollationKey to a "bogus" or invalid state
+    * @return this CollationKey
+    */
+    CollationKey&           setToBogus(void);
+    /**
+    * Resets this CollationKey to an empty state
+    * @return this CollationKey
+    */
+    CollationKey&           reset(void);
+    
+    /**
+    * Allow private access to RuleBasedCollator
+    */
+    friend  class           RuleBasedCollator;
+    /**
+    * Bogus status
+    */
+    UBool                   fBogus;
+    /**
+    * Size of fBytes used to store the sortkey. i.e. up till the 
+    * null-termination.
+    */
+    int32_t                 fCount;
+    /**
+    * Full size of the fBytes
+    */
+    int32_t                 fCapacity;
+    /**
+    * Unique hash value of this CollationKey
+    */
+    int32_t                 fHashCode;
+    /**
+    * Array to store the sortkey
+    */
+    uint8_t*                fBytes;
+
+};
+
+inline UBool
+CollationKey::operator!=(const CollationKey& other) const
+{
+    return !(*this == other);
+}
+
+inline UBool
+CollationKey::isBogus() const
+{
+    return fBogus;
+}
+
+inline const uint8_t*
+CollationKey::getByteArray(int32_t &count) const
+{
+    count = fCount;
+    return fBytes;
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/strenum.h b/CoreFoundation/icu/unicode/strenum.h
new file mode 100644
index 0000000..ce42195
--- /dev/null
+++ b/CoreFoundation/icu/unicode/strenum.h
@@ -0,0 +1,271 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2002-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*/
+
+#ifndef STRENUM_H
+#define STRENUM_H
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+
+/**
+ * \file 
+ * \brief C++ API: String Enumeration
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * Base class for 'pure' C++ implementations of uenum api.  Adds a
+ * method that returns the next UnicodeString since in C++ this can
+ * be a common storage format for strings.
+ *
+ * <p>The model is that the enumeration is over strings maintained by
+ * a 'service.'  At any point, the service might change, invalidating
+ * the enumerator (though this is expected to be rare).  The iterator
+ * returns an error if this has occurred.  Lack of the error is no
+ * guarantee that the service didn't change immediately after the
+ * call, so the returned string still might not be 'valid' on
+ * subsequent use.</p>
+ *
+ * <p>Strings may take the form of const char*, const UChar*, or const
+ * UnicodeString*.  The type you get is determine by the variant of
+ * 'next' that you call.  In general the StringEnumeration is
+ * optimized for one of these types, but all StringEnumerations can
+ * return all types.  Returned strings are each terminated with a NUL.
+ * Depending on the service data, they might also include embedded NUL
+ * characters, so API is provided to optionally return the true
+ * length, counting the embedded NULs but not counting the terminating
+ * NUL.</p>
+ *
+ * <p>The pointers returned by next, unext, and snext become invalid
+ * upon any subsequent call to the enumeration's destructor, next,
+ * unext, snext, or reset.</p>
+ *
+ * ICU 2.8 adds some default implementations and helper functions
+ * for subclasses.
+ *
+ * @stable ICU 2.4 
+ */
+class U_COMMON_API StringEnumeration : public UObject { 
+public:
+    /**
+     * Destructor.
+     * @stable ICU 2.4
+     */
+    virtual ~StringEnumeration();
+
+    /**
+     * Clone this object, an instance of a subclass of StringEnumeration.
+     * Clones can be used concurrently in multiple threads.
+     * If a subclass does not implement clone(), or if an error occurs,
+     * then NULL is returned.
+     * The clone functions in all subclasses return a base class pointer
+     * because some compilers do not support covariant (same-as-this)
+     * return types; cast to the appropriate subclass if necessary.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    virtual StringEnumeration *clone() const;
+
+    /**
+     * <p>Return the number of elements that the iterator traverses.  If
+     * the iterator is out of sync with its service, status is set to
+     * U_ENUM_OUT_OF_SYNC_ERROR, and the return value is zero.</p>
+     *
+     * <p>The return value will not change except possibly as a result of
+     * a subsequent call to reset, or if the iterator becomes out of sync.</p>
+     *
+     * <p>This is a convenience function. It can end up being very
+     * expensive as all the items might have to be pre-fetched
+     * (depending on the storage format of the data being
+     * traversed).</p>
+     *
+     * @param status the error code.
+     * @return number of elements in the iterator.
+     *
+     * @stable ICU 2.4 */
+    virtual int32_t count(UErrorCode& status) const = 0;
+
+    /**
+     * <p>Returns the next element as a NUL-terminated char*.  If there
+     * are no more elements, returns NULL.  If the resultLength pointer
+     * is not NULL, the length of the string (not counting the
+     * terminating NUL) is returned at that address.  If an error
+     * status is returned, the value at resultLength is undefined.</p>
+     *
+     * <p>The returned pointer is owned by this iterator and must not be
+     * deleted by the caller.  The pointer is valid until the next call
+     * to next, unext, snext, reset, or the enumerator's destructor.</p>
+     *
+     * <p>If the iterator is out of sync with its service, status is set
+     * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>
+     *
+     * <p>If the native service string is a UChar* string, it is
+     * converted to char* with the invariant converter.  If the
+     * conversion fails (because a character cannot be converted) then
+     * status is set to U_INVARIANT_CONVERSION_ERROR and the return
+     * value is undefined (though not NULL).</p>
+     *
+     * Starting with ICU 2.8, the default implementation calls snext()
+     * and handles the conversion.
+     *
+     * @param status the error code.
+     * @param resultLength a pointer to receive the length, can be NULL.
+     * @return a pointer to the string, or NULL.
+     *
+     * @stable ICU 2.4 
+     */
+    virtual const char* next(int32_t *resultLength, UErrorCode& status);
+
+    /**
+     * <p>Returns the next element as a NUL-terminated UChar*.  If there
+     * are no more elements, returns NULL.  If the resultLength pointer
+     * is not NULL, the length of the string (not counting the
+     * terminating NUL) is returned at that address.  If an error
+     * status is returned, the value at resultLength is undefined.</p>
+     *
+     * <p>The returned pointer is owned by this iterator and must not be
+     * deleted by the caller.  The pointer is valid until the next call
+     * to next, unext, snext, reset, or the enumerator's destructor.</p>
+     *
+     * <p>If the iterator is out of sync with its service, status is set
+     * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>
+     *
+     * Starting with ICU 2.8, the default implementation calls snext()
+     * and handles the conversion.
+     *
+     * @param status the error code.
+     * @param resultLength a ponter to receive the length, can be NULL.
+     * @return a pointer to the string, or NULL.
+     *
+     * @stable ICU 2.4 
+     */
+    virtual const UChar* unext(int32_t *resultLength, UErrorCode& status);
+
+    /**
+     * <p>Returns the next element a UnicodeString*.  If there are no
+     * more elements, returns NULL.</p>
+     *
+     * <p>The returned pointer is owned by this iterator and must not be
+     * deleted by the caller.  The pointer is valid until the next call
+     * to next, unext, snext, reset, or the enumerator's destructor.</p>
+     *
+     * <p>If the iterator is out of sync with its service, status is set
+     * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>
+     *
+     * @param status the error code.
+     * @return a pointer to the string, or NULL.
+     *
+     * @stable ICU 2.4 
+     */
+    virtual const UnicodeString* snext(UErrorCode& status) = 0;
+
+    /**
+     * <p>Resets the iterator.  This re-establishes sync with the
+     * service and rewinds the iterator to start at the first
+     * element.</p>
+     *
+     * <p>Previous pointers returned by next, unext, or snext become
+     * invalid, and the value returned by count might change.</p>
+     *
+     * @param status the error code.
+     *
+     * @stable ICU 2.4 
+     */
+    virtual void reset(UErrorCode& status) = 0;
+
+    /**
+     * Compares this enumeration to other to check if both are equal
+     *
+     * @param that The other string enumeration to compare this object to
+     * @return TRUE if the enumerations are equal. FALSE if not.
+     * @stable ICU 3.6 
+     */
+    virtual UBool operator==(const StringEnumeration& that)const;
+    /**
+     * Compares this enumeration to other to check if both are not equal
+     *
+     * @param that The other string enumeration to compare this object to
+     * @return TRUE if the enumerations are equal. FALSE if not.
+     * @stable ICU 3.6 
+     */
+    virtual UBool operator!=(const StringEnumeration& that)const;
+
+protected:
+    /**
+     * UnicodeString field for use with default implementations and subclasses.
+     * @stable ICU 2.8
+     */
+    UnicodeString unistr;
+    /**
+     * char * default buffer for use with default implementations and subclasses.
+     * @stable ICU 2.8
+     */
+    char charsBuffer[32];
+    /**
+     * char * buffer for use with default implementations and subclasses.
+     * Allocated in constructor and in ensureCharsCapacity().
+     * @stable ICU 2.8
+     */
+    char *chars;
+    /**
+     * Capacity of chars, for use with default implementations and subclasses.
+     * @stable ICU 2.8
+     */
+    int32_t charsCapacity;
+
+    /**
+     * Default constructor for use with default implementations and subclasses.
+     * @stable ICU 2.8
+     */
+    StringEnumeration();
+
+    /**
+     * Ensures that chars is at least as large as the requested capacity.
+     * For use with default implementations and subclasses.
+     *
+     * @param capacity Requested capacity.
+     * @param status ICU in/out error code.
+     * @stable ICU 2.8
+     */
+    void ensureCharsCapacity(int32_t capacity, UErrorCode &status);
+
+    /**
+     * Converts s to Unicode and sets unistr to the result.
+     * For use with default implementations and subclasses,
+     * especially for implementations of snext() in terms of next().
+     * This is provided with a helper function instead of a default implementation
+     * of snext() to avoid potential infinite loops between next() and snext().
+     *
+     * For example:
+     * \code
+     * const UnicodeString* snext(UErrorCode& status) {
+     *   int32_t resultLength=0;
+     *   const char *s=next(&resultLength, status);
+     *   return setChars(s, resultLength, status);
+     * }
+     * \endcode
+     *
+     * @param s String to be converted to Unicode.
+     * @param length Length of the string.
+     * @param status ICU in/out error code.
+     * @return A pointer to unistr.
+     * @stable ICU 2.8
+     */
+    UnicodeString *setChars(const char *s, int32_t length, UErrorCode &status);
+};
+
+U_NAMESPACE_END
+
+/* STRENUM_H */
+#endif
diff --git a/CoreFoundation/icu/unicode/stsearch.h b/CoreFoundation/icu/unicode/stsearch.h
new file mode 100644
index 0000000..8499752
--- /dev/null
+++ b/CoreFoundation/icu/unicode/stsearch.h
@@ -0,0 +1,518 @@
+/*
+**********************************************************************
+*   Copyright (C) 2001-2008 IBM and others. All rights reserved.
+**********************************************************************
+*   Date        Name        Description
+*  03/22/2000   helena      Creation.
+**********************************************************************
+*/
+
+#ifndef STSEARCH_H
+#define STSEARCH_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Service for searching text based on RuleBasedCollator.
+ */
+ 
+#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
+
+#include "unicode/tblcoll.h"
+#include "unicode/coleitr.h"
+#include "unicode/search.h"
+
+U_NAMESPACE_BEGIN
+
+/** 
+ *
+ * <tt>StringSearch</tt> is a <tt>SearchIterator</tt> that provides
+ * language-sensitive text searching based on the comparison rules defined
+ * in a {@link RuleBasedCollator} object.
+ * StringSearch ensures that language eccentricity can be 
+ * handled, e.g. for the German collator, characters &szlig; and SS will be matched 
+ * if case is chosen to be ignored.
+ * See the <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm">
+ * "ICU Collation Design Document"</a> for more information.
+ * <p> 
+ * The algorithm implemented is a modified form of the Boyer Moore's search.
+ * For more information  see 
+ * <a href="http://icu-project.org/docs/papers/efficient_text_searching_in_java.html">
+ * "Efficient Text Searching in Java"</a>, published in <i>Java Report</i> 
+ * in February, 1999, for further information on the algorithm.
+ * <p>
+ * There are 2 match options for selection:<br>
+ * Let S' be the sub-string of a text string S between the offsets start and 
+ * end <start, end>.
+ * <br>
+ * A pattern string P matches a text string S at the offsets <start, end> 
+ * if
+ * <pre> 
+ * option 1. Some canonical equivalent of P matches some canonical equivalent 
+ *           of S'
+ * option 2. P matches S' and if P starts or ends with a combining mark, 
+ *           there exists no non-ignorable combining mark before or after S? 
+ *           in S respectively. 
+ * </pre>
+ * Option 2. will be the default.
+ * <p>
+ * This search has APIs similar to that of other text iteration mechanisms 
+ * such as the break iterators in <tt>BreakIterator</tt>. Using these 
+ * APIs, it is easy to scan through text looking for all occurances of 
+ * a given pattern. This search iterator allows changing of direction by 
+ * calling a <tt>reset</tt> followed by a <tt>next</tt> or <tt>previous</tt>. 
+ * Though a direction change can occur without calling <tt>reset</tt> first,  
+ * this operation comes with some speed penalty.
+ * Match results in the forward direction will match the result matches in 
+ * the backwards direction in the reverse order
+ * <p>
+ * <tt>SearchIterator</tt> provides APIs to specify the starting position 
+ * within the text string to be searched, e.g. <tt>setOffset</tt>,
+ * <tt>preceding</tt> and <tt>following</tt>. Since the 
+ * starting position will be set as it is specified, please take note that 
+ * there are some danger points which the search may render incorrect 
+ * results:
+ * <ul>
+ * <li> The midst of a substring that requires normalization.
+ * <li> If the following match is to be found, the position should not be the
+ *      second character which requires to be swapped with the preceding 
+ *      character. Vice versa, if the preceding match is to be found, 
+ *      position to search from should not be the first character which 
+ *      requires to be swapped with the next character. E.g certain Thai and
+ *      Lao characters require swapping.
+ * <li> If a following pattern match is to be found, any position within a 
+ *      contracting sequence except the first will fail. Vice versa if a 
+ *      preceding pattern match is to be found, a invalid starting point 
+ *      would be any character within a contracting sequence except the last.
+ * </ul>
+ * <p>
+ * A breakiterator can be used if only matches at logical breaks are desired.
+ * Using a breakiterator will only give you results that exactly matches the
+ * boundaries given by the breakiterator. For instance the pattern "e" will
+ * not be found in the string "\u00e9" if a character break iterator is used.
+ * <p>
+ * Options are provided to handle overlapping matches. 
+ * E.g. In English, overlapping matches produces the result 0 and 2 
+ * for the pattern "abab" in the text "ababab", where else mutually 
+ * exclusive matches only produce the result of 0.
+ * <p>
+ * Though collator attributes will be taken into consideration while 
+ * performing matches, there are no APIs here for setting and getting the 
+ * attributes. These attributes can be set by getting the collator
+ * from <tt>getCollator</tt> and using the APIs in <tt>coll.h</tt>.
+ * Lastly to update StringSearch to the new collator attributes, 
+ * reset() has to be called.
+ * <p> 
+ * Restriction: <br>
+ * Currently there are no composite characters that consists of a
+ * character with combining class > 0 before a character with combining 
+ * class == 0. However, if such a character exists in the future,  
+ * StringSearch does not guarantee the results for option 1.
+ * <p>
+ * Consult the <tt>SearchIterator</tt> documentation for information on
+ * and examples of how to use instances of this class to implement text
+ * searching.
+ * <pre><code>
+ * UnicodeString target("The quick brown fox jumps over the lazy dog.");
+ * UnicodeString pattern("fox");
+ *
+ * UErrorCode      error = U_ZERO_ERROR;
+ * StringSearch iter(pattern, target, Locale::getUS(), NULL, status);
+ * for (int pos = iter.first(error);
+ *      pos != USEARCH_DONE; 
+ *      pos = iter.next(error))
+ * {
+ *     printf("Found match at %d pos, length is %d\n", pos, 
+ *                                             iter.getMatchLength());
+ * }
+ * </code></pre>
+ * <p>
+ * Note, StringSearch is not to be subclassed.
+ * </p>
+ * @see SearchIterator
+ * @see RuleBasedCollator
+ * @since ICU 2.0
+ */
+
+class U_I18N_API StringSearch : public SearchIterator
+{
+public:
+
+    // public constructors and destructors --------------------------------
+
+    /**
+     * Creating a <tt>StringSearch</tt> instance using the argument locale 
+     * language rule set. A collator will be created in the process, which 
+     * will be owned by this instance and will be deleted during 
+     * destruction
+     * @param pattern The text for which this object will search.
+     * @param text    The text in which to search for the pattern.
+     * @param locale  A locale which defines the language-sensitive 
+     *                comparison rules used to determine whether text in the 
+     *                pattern and target matches. 
+     * @param breakiter A <tt>BreakIterator</tt> object used to constrain 
+     *                the matches that are found. Matches whose start and end 
+     *                indices in the target text are not boundaries as 
+     *                determined by the <tt>BreakIterator</tt> are 
+     *                ignored. If this behavior is not desired, 
+     *                <tt>NULL</tt> can be passed in instead.
+     * @param status  for errors if any. If pattern or text is NULL, or if
+     *               either the length of pattern or text is 0 then an 
+     *               U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    StringSearch(const UnicodeString &pattern, const UnicodeString &text,
+                 const Locale        &locale,       
+                       BreakIterator *breakiter,
+                       UErrorCode    &status);
+
+    /**
+     * Creating a <tt>StringSearch</tt> instance using the argument collator 
+     * language rule set. Note, user retains the ownership of this collator, 
+     * it does not get destroyed during this instance's destruction.
+     * @param pattern The text for which this object will search.
+     * @param text    The text in which to search for the pattern.
+     * @param coll    A <tt>RuleBasedCollator</tt> object which defines 
+     *                the language-sensitive comparison rules used to 
+     *                determine whether text in the pattern and target 
+     *                matches. User is responsible for the clearing of this
+     *                object.
+     * @param breakiter A <tt>BreakIterator</tt> object used to constrain 
+     *                the matches that are found. Matches whose start and end 
+     *                indices in the target text are not boundaries as 
+     *                determined by the <tt>BreakIterator</tt> are 
+     *                ignored. If this behavior is not desired, 
+     *                <tt>NULL</tt> can be passed in instead.
+     * @param status for errors if any. If either the length of pattern or 
+     *               text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    StringSearch(const UnicodeString     &pattern, 
+                 const UnicodeString     &text,
+                       RuleBasedCollator *coll,       
+                       BreakIterator     *breakiter,
+                       UErrorCode        &status);
+
+    /**
+     * Creating a <tt>StringSearch</tt> instance using the argument locale 
+     * language rule set. A collator will be created in the process, which 
+     * will be owned by this instance and will be deleted during 
+     * destruction
+     * <p>
+     * Note: No parsing of the text within the <tt>CharacterIterator</tt> 
+     * will be done during searching for this version. The block of text 
+     * in <tt>CharacterIterator</tt> will be used as it is.
+     * @param pattern The text for which this object will search.
+     * @param text    The text iterator in which to search for the pattern.
+     * @param locale  A locale which defines the language-sensitive 
+     *                comparison rules used to determine whether text in the 
+     *                pattern and target matches. User is responsible for 
+     *                the clearing of this object.
+     * @param breakiter A <tt>BreakIterator</tt> object used to constrain 
+     *                the matches that are found. Matches whose start and end 
+     *                indices in the target text are not boundaries as 
+     *                determined by the <tt>BreakIterator</tt> are 
+     *                ignored. If this behavior is not desired, 
+     *                <tt>NULL</tt> can be passed in instead.
+     * @param status for errors if any. If either the length of pattern or 
+     *               text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    StringSearch(const UnicodeString &pattern, CharacterIterator &text,
+                 const Locale        &locale, 
+                       BreakIterator *breakiter,
+                       UErrorCode    &status);
+
+    /**
+     * Creating a <tt>StringSearch</tt> instance using the argument collator 
+     * language rule set. Note, user retains the ownership of this collator, 
+     * it does not get destroyed during this instance's destruction.
+     * <p>
+     * Note: No parsing of the text within the <tt>CharacterIterator</tt> 
+     * will be done during searching for this version. The block of text 
+     * in <tt>CharacterIterator</tt> will be used as it is.
+     * @param pattern The text for which this object will search.
+     * @param text    The text in which to search for the pattern.
+     * @param coll    A <tt>RuleBasedCollator</tt> object which defines 
+     *                the language-sensitive comparison rules used to 
+     *                determine whether text in the pattern and target 
+     *                matches. User is responsible for the clearing of this
+     *                object.
+     * @param breakiter A <tt>BreakIterator</tt> object used to constrain 
+     *                the matches that are found. Matches whose start and end 
+     *                indices in the target text are not boundaries as 
+     *                determined by the <tt>BreakIterator</tt> are 
+     *                ignored. If this behavior is not desired, 
+     *                <tt>NULL</tt> can be passed in instead.
+     * @param status for errors if any. If either the length of pattern or 
+     *               text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    StringSearch(const UnicodeString     &pattern, CharacterIterator &text,
+                       RuleBasedCollator *coll, 
+                       BreakIterator     *breakiter,
+                       UErrorCode        &status);
+
+    /**
+     * Copy constructor that creates a StringSearch instance with the same 
+     * behavior, and iterating over the same text.
+     * @param that StringSearch instance to be copied.
+     * @stable ICU 2.0
+     */
+    StringSearch(const StringSearch &that);
+
+    /**
+    * Destructor. Cleans up the search iterator data struct.
+    * If a collator is created in the constructor, it will be destroyed here.
+    * @stable ICU 2.0
+    */
+    virtual ~StringSearch(void);
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    StringSearch *clone() const;
+
+    // operator overloading ---------------------------------------------
+
+    /**
+     * Assignment operator. Sets this iterator to have the same behavior,
+     * and iterate over the same text, as the one passed in.
+     * @param that instance to be copied.
+     * @stable ICU 2.0
+     */
+    StringSearch & operator=(const StringSearch &that);
+
+    /**
+     * Equality operator. 
+     * @param that instance to be compared.
+     * @return TRUE if both instances have the same attributes, 
+     *         breakiterators, collators and iterate over the same text 
+     *         while looking for the same pattern.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const SearchIterator &that) const;
+
+    // public get and set methods ----------------------------------------
+
+    /**
+     * Sets the index to point to the given position, and clears any state 
+     * that's affected.
+     * <p>
+     * This method takes the argument index and sets the position in the text 
+     * string accordingly without checking if the index is pointing to a 
+     * valid starting point to begin searching. 
+     * @param position within the text to be set. If position is less
+     *          than or greater than the text range for searching, 
+     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned
+     * @param status for errors if it occurs
+     * @stable ICU 2.0
+     */
+    virtual void setOffset(int32_t position, UErrorCode &status);
+
+    /**
+     * Return the current index in the text being searched.
+     * If the iteration has gone past the end of the text
+     * (or past the beginning for a backwards search), USEARCH_DONE
+     * is returned.
+     * @return current index in the text being searched.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getOffset(void) const;
+
+    /**
+     * Set the target text to be searched.
+     * Text iteration will hence begin at the start of the text string. 
+     * This method is 
+     * useful if you want to re-use an iterator to search for the same 
+     * pattern within a different body of text.
+     * @param text text string to be searched
+     * @param status for errors if any. If the text length is 0 then an 
+     *        U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    virtual void setText(const UnicodeString &text, UErrorCode &status);
+    
+    /**
+     * Set the target text to be searched.
+     * Text iteration will hence begin at the start of the text string. 
+     * This method is 
+     * useful if you want to re-use an iterator to search for the same 
+     * pattern within a different body of text.
+     * Note: No parsing of the text within the <tt>CharacterIterator</tt> 
+     * will be done during searching for this version. The block of text 
+     * in <tt>CharacterIterator</tt> will be used as it is.
+     * @param text text string to be searched
+     * @param status for errors if any. If the text length is 0 then an 
+     *        U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    virtual void setText(CharacterIterator &text, UErrorCode &status);
+
+    /**
+     * Gets the collator used for the language rules.
+     * <p>
+     * Caller may modify but <b>must not</b> delete the <tt>RuleBasedCollator</tt>!
+     * Modifications to this collator will affect the original collator passed in to 
+     * the <tt>StringSearch></tt> constructor or to setCollator, if any.
+     * @return collator used for string search
+     * @stable ICU 2.0
+     */
+    RuleBasedCollator * getCollator() const;
+    
+    /**
+     * Sets the collator used for the language rules. User retains the 
+     * ownership of this collator, thus the responsibility of deletion lies 
+     * with the user. This method causes internal data such as Boyer-Moore 
+     * shift tables to be recalculated, but the iterator's position is 
+     * unchanged.
+     * @param coll    collator 
+     * @param status  for errors if any
+     * @stable ICU 2.0
+     */
+    void setCollator(RuleBasedCollator *coll, UErrorCode &status);
+    
+    /**
+     * Sets the pattern used for matching.
+     * Internal data like the Boyer Moore table will be recalculated, but 
+     * the iterator's position is unchanged.
+     * @param pattern search pattern to be found
+     * @param status for errors if any. If the pattern length is 0 then an 
+     *               U_ILLEGAL_ARGUMENT_ERROR is returned.
+     * @stable ICU 2.0
+     */
+    void setPattern(const UnicodeString &pattern, UErrorCode &status);
+    
+    /**
+     * Gets the search pattern.
+     * @return pattern used for matching
+     * @stable ICU 2.0
+     */
+    const UnicodeString & getPattern() const;
+
+    // public methods ----------------------------------------------------
+
+    /** 
+     * Reset the iteration.
+     * Search will begin at the start of the text string if a forward 
+     * iteration is initiated before a backwards iteration. Otherwise if 
+     * a backwards iteration is initiated before a forwards iteration, the 
+     * search will begin at the end of the text string.
+     * @stable ICU 2.0
+     */
+    virtual void reset();
+
+    /**
+     * Returns a copy of StringSearch with the same behavior, and 
+     * iterating over the same text, as this one. Note that all data will be
+     * replicated, except for the user-specified collator and the
+     * breakiterator.
+     * @return cloned object
+     * @stable ICU 2.0
+     */
+    virtual SearchIterator * safeClone(void) const;
+    
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+protected:
+
+    // protected method -------------------------------------------------
+
+    /**
+     * Search forward for matching text, starting at a given location.
+     * Clients should not call this method directly; instead they should 
+     * call {@link SearchIterator#next }.
+     * <p>
+     * If a match is found, this method returns the index at which the match
+     * starts and calls {@link SearchIterator#setMatchLength } with the number 
+     * of characters in the target text that make up the match. If no match 
+     * is found, the method returns <tt>USEARCH_DONE</tt>.
+     * <p>
+     * The <tt>StringSearch</tt> is adjusted so that its current index 
+     * (as returned by {@link #getOffset }) is the match position if one was 
+     * found.
+     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+     * the <tt>StringSearch</tt> will be adjusted to the index USEARCH_DONE.
+     * @param position The index in the target text at which the search 
+     *                 starts
+     * @param status for errors if any occurs
+     * @return The index at which the matched text in the target starts, or 
+     *         USEARCH_DONE if no match was found.
+     * @stable ICU 2.0
+     */
+    virtual int32_t handleNext(int32_t position, UErrorCode &status);
+
+    /**
+     * Search backward for matching text, starting at a given location.
+     * Clients should not call this method directly; instead they should call
+     * <tt>SearchIterator.previous()</tt>, which this method overrides.
+     * <p>
+     * If a match is found, this method returns the index at which the match
+     * starts and calls {@link SearchIterator#setMatchLength } with the number 
+     * of characters in the target text that make up the match. If no match 
+     * is found, the method returns <tt>USEARCH_DONE</tt>.
+     * <p>
+     * The <tt>StringSearch</tt> is adjusted so that its current index 
+     * (as returned by {@link #getOffset }) is the match position if one was 
+     * found.
+     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+     * the <tt>StringSearch</tt> will be adjusted to the index USEARCH_DONE.
+     * @param position The index in the target text at which the search 
+     *                 starts.
+     * @param status for errors if any occurs
+     * @return The index at which the matched text in the target starts, or 
+     *         USEARCH_DONE if no match was found.
+     * @stable ICU 2.0
+     */
+    virtual int32_t handlePrev(int32_t position, UErrorCode &status);
+    
+private :
+    StringSearch(); // default constructor not implemented
+
+    // private data members ----------------------------------------------
+
+    /**
+    * RuleBasedCollator, contains exactly the same UCollator * in m_strsrch_
+    * @stable ICU 2.0
+    */
+    RuleBasedCollator  m_collator_;
+    /**
+    * Pattern text
+    * @stable ICU 2.0
+    */
+    UnicodeString      m_pattern_;
+    /**
+    * String search struct data
+    * @stable ICU 2.0
+    */
+    UStringSearch     *m_strsrch_;
+
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
+
diff --git a/CoreFoundation/icu/unicode/symtable.h b/CoreFoundation/icu/unicode/symtable.h
new file mode 100644
index 0000000..428f8bf
--- /dev/null
+++ b/CoreFoundation/icu/unicode/symtable.h
@@ -0,0 +1,112 @@
+/*
+**********************************************************************
+*   Copyright (c) 2000-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*   Date        Name        Description
+*   02/04/00    aliu        Creation.
+**********************************************************************
+*/
+#ifndef SYMTABLE_H
+#define SYMTABLE_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+
+/**
+ * \file 
+ * \brief C++ API: An interface that defines both lookup protocol and parsing of
+ * symbolic names.
+ */
+ 
+U_NAMESPACE_BEGIN
+
+class ParsePosition;
+class UnicodeFunctor;
+class UnicodeSet;
+class UnicodeString;
+
+/**
+ * An interface that defines both lookup protocol and parsing of
+ * symbolic names.
+ *
+ * <p>A symbol table maintains two kinds of mappings.  The first is
+ * between symbolic names and their values.  For example, if the
+ * variable with the name "start" is set to the value "alpha"
+ * (perhaps, though not necessarily, through an expression such as
+ * "$start=alpha"), then the call lookup("start") will return the
+ * char[] array ['a', 'l', 'p', 'h', 'a'].
+ *
+ * <p>The second kind of mapping is between character values and
+ * UnicodeMatcher objects.  This is used by RuleBasedTransliterator,
+ * which uses characters in the private use area to represent objects
+ * such as UnicodeSets.  If U+E015 is mapped to the UnicodeSet [a-z],
+ * then lookupMatcher(0xE015) will return the UnicodeSet [a-z].
+ *
+ * <p>Finally, a symbol table defines parsing behavior for symbolic
+ * names.  All symbolic names start with the SYMBOL_REF character.
+ * When a parser encounters this character, it calls parseReference()
+ * with the position immediately following the SYMBOL_REF.  The symbol
+ * table parses the name, if there is one, and returns it.
+ *
+ * @stable ICU 2.8
+ */
+class U_COMMON_API SymbolTable /* not : public UObject because this is an interface/mixin class */ {
+public:
+
+    /**
+     * The character preceding a symbol reference name.
+     * @stable ICU 2.8
+     */
+    enum { SYMBOL_REF = 0x0024 /*$*/ };
+
+    /**
+     * Destructor.
+     * @stable ICU 2.8
+     */
+    virtual ~SymbolTable();
+
+    /**
+     * Lookup the characters associated with this string and return it.
+     * Return <tt>NULL</tt> if no such name exists.  The resultant
+     * string may have length zero.
+     * @param s the symbolic name to lookup
+     * @return a string containing the name's value, or <tt>NULL</tt> if
+     * there is no mapping for s.
+     * @stable ICU 2.8
+     */
+    virtual const UnicodeString* lookup(const UnicodeString& s) const = 0;
+
+    /**
+     * Lookup the UnicodeMatcher associated with the given character, and
+     * return it.  Return <tt>NULL</tt> if not found.
+     * @param ch a 32-bit code point from 0 to 0x10FFFF inclusive.
+     * @return the UnicodeMatcher object represented by the given
+     * character, or NULL if there is no mapping for ch.
+     * @stable ICU 2.8
+     */
+    virtual const UnicodeFunctor* lookupMatcher(UChar32 ch) const = 0;
+
+    /**
+     * Parse a symbol reference name from the given string, starting
+     * at the given position.  If no valid symbol reference name is
+     * found, return the empty string and leave pos unchanged.  That is, if the
+     * character at pos cannot start a name, or if pos is at or after
+     * text.length(), then return an empty string.  This indicates an
+     * isolated SYMBOL_REF character.
+     * @param text the text to parse for the name
+     * @param pos on entry, the index of the first character to parse.
+     * This is the character following the SYMBOL_REF character.  On
+     * exit, the index after the last parsed character.  If the parse
+     * failed, pos is unchanged on exit.
+     * @param limit the index after the last character to be parsed.
+     * @return the parsed name, or an empty string if there is no
+     * valid symbolic name at the given position.
+     * @stable ICU 2.8
+     */
+    virtual UnicodeString parseReference(const UnicodeString& text,
+                                         ParsePosition& pos, int32_t limit) const = 0;
+};
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/tblcoll.h b/CoreFoundation/icu/unicode/tblcoll.h
new file mode 100644
index 0000000..2fdd63b
--- /dev/null
+++ b/CoreFoundation/icu/unicode/tblcoll.h
@@ -0,0 +1,926 @@
+/*
+******************************************************************************
+* Copyright (C) 1996-2008, International Business Machines Corporation and
+* others. All Rights Reserved.
+******************************************************************************
+*/
+
+/**
+ * \file 
+ * \brief C++ API: RuleBasedCollator class provides the simple implementation of Collator.
+ */
+
+/**
+* File tblcoll.h
+*
+* Created by: Helena Shih
+*
+* Modification History:
+*
+*  Date        Name        Description
+*  2/5/97      aliu        Added streamIn and streamOut methods.  Added
+*                          constructor which reads RuleBasedCollator object from
+*                          a binary file.  Added writeToFile method which streams
+*                          RuleBasedCollator out to a binary file.  The streamIn
+*                          and streamOut methods use istream and ostream objects
+*                          in binary mode.
+*  2/12/97     aliu        Modified to use TableCollationData sub-object to
+*                          hold invariant data.
+*  2/13/97     aliu        Moved several methods into this class from Collation.
+*                          Added a private RuleBasedCollator(Locale&) constructor,
+*                          to be used by Collator::createDefault().  General
+*                          clean up.
+*  2/20/97     helena      Added clone, operator==, operator!=, operator=, and copy
+*                          constructor and getDynamicClassID.
+*  3/5/97      aliu        Modified constructFromFile() to add parameter
+*                          specifying whether or not binary loading is to be
+*                          attempted.  This is required for dynamic rule loading.
+* 05/07/97     helena      Added memory allocation error detection.
+*  6/17/97     helena      Added IDENTICAL strength for compare, changed getRules to
+*                          use MergeCollation::getPattern.
+*  6/20/97     helena      Java class name change.
+*  8/18/97     helena      Added internal API documentation.
+* 09/03/97     helena      Added createCollationKeyValues().
+* 02/10/98     damiba      Added compare with "length" parameter
+* 08/05/98     erm         Synched with 1.2 version of RuleBasedCollator.java
+* 04/23/99     stephen     Removed EDecompositionMode, merged with
+*                          Normalizer::EMode
+* 06/14/99     stephen     Removed kResourceBundleSuffix
+* 11/02/99     helena      Collator performance enhancements.  Eliminates the
+*                          UnicodeString construction and special case for NO_OP.
+* 11/23/99     srl         More performance enhancements. Updates to NormalizerIterator
+*                          internal state management.
+* 12/15/99     aliu        Update to support Thai collation.  Move NormalizerIterator
+*                          to implementation file.
+* 01/29/01     synwee      Modified into a C++ wrapper which calls C API
+*                          (ucol.h)
+*/
+
+#ifndef TBLCOLL_H
+#define TBLCOLL_H
+
+#include "unicode/utypes.h"
+
+ 
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/coll.h"
+#include "unicode/ucol.h"
+#include "unicode/sortkey.h"
+#include "unicode/normlzr.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+* @stable ICU 2.0
+*/
+class StringSearch;
+/**
+* @stable ICU 2.0
+*/
+class CollationElementIterator;
+
+/**
+ * The RuleBasedCollator class provides the simple implementation of
+ * Collator, using data-driven tables. The user can create a customized
+ * table-based collation.
+ * <P>
+ * <em>Important: </em>The ICU collation service has been reimplemented 
+ * in order to achieve better performance and UCA compliance. 
+ * For details, see the 
+ * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm">
+ * collation design document</a>.
+ * <p>
+ * RuleBasedCollator is a thin C++ wrapper over the C implementation.
+ * <p>
+ * For more information about the collation service see 
+ * <a href="http://icu-project.org/userguide/Collate_Intro.html">the users guide</a>.
+ * <p>
+ * Collation service provides correct sorting orders for most locales supported in ICU. 
+ * If specific data for a locale is not available, the orders eventually falls back
+ * to the <a href="http://www.unicode.org/unicode/reports/tr10/">UCA sort order</a>. 
+ * <p>
+ * Sort ordering may be customized by providing your own set of rules. For more on
+ * this subject see the <a href="http://icu-project.org/userguide/Collate_Customization.html">
+ * Collation customization</a> section of the users guide.
+ * <p>
+ * Note, RuleBasedCollator is not to be subclassed.
+ * @see        Collator
+ * @version    2.0 11/15/2001
+ */
+class U_I18N_API RuleBasedCollator : public Collator
+{
+public:
+
+  // constructor -------------------------------------------------------------
+
+    /**
+     * RuleBasedCollator constructor. This takes the table rules and builds a
+     * collation table out of them. Please see RuleBasedCollator class
+     * description for more details on the collation rule syntax.
+     * @param rules the collation rules to build the collation table from.
+     * @param status reporting a success or an error.
+     * @see Locale
+     * @stable ICU 2.0
+     */
+    RuleBasedCollator(const UnicodeString& rules, UErrorCode& status);
+
+    /**
+     * RuleBasedCollator constructor. This takes the table rules and builds a
+     * collation table out of them. Please see RuleBasedCollator class
+     * description for more details on the collation rule syntax.
+     * @param rules the collation rules to build the collation table from.
+     * @param collationStrength default strength for comparison
+     * @param status reporting a success or an error.
+     * @see Locale
+     * @stable ICU 2.0
+     */
+    RuleBasedCollator(const UnicodeString& rules,
+                       ECollationStrength collationStrength,
+                       UErrorCode& status);
+
+    /**
+     * RuleBasedCollator constructor. This takes the table rules and builds a
+     * collation table out of them. Please see RuleBasedCollator class
+     * description for more details on the collation rule syntax.
+     * @param rules the collation rules to build the collation table from.
+     * @param decompositionMode the normalisation mode
+     * @param status reporting a success or an error.
+     * @see Locale
+     * @stable ICU 2.0
+     */
+    RuleBasedCollator(const UnicodeString& rules,
+                    UColAttributeValue decompositionMode,
+                    UErrorCode& status);
+
+    /**
+     * RuleBasedCollator constructor. This takes the table rules and builds a
+     * collation table out of them. Please see RuleBasedCollator class
+     * description for more details on the collation rule syntax.
+     * @param rules the collation rules to build the collation table from.
+     * @param collationStrength default strength for comparison
+     * @param decompositionMode the normalisation mode
+     * @param status reporting a success or an error.
+     * @see Locale
+     * @stable ICU 2.0
+     */
+    RuleBasedCollator(const UnicodeString& rules,
+                    ECollationStrength collationStrength,
+                    UColAttributeValue decompositionMode,
+                    UErrorCode& status);
+
+    /**
+     * Copy constructor.
+     * @param other the RuleBasedCollator object to be copied
+     * @see Locale
+     * @stable ICU 2.0
+     */
+    RuleBasedCollator(const RuleBasedCollator& other);
+
+
+    /** Opens a collator from a collator binary image created using
+    *  cloneBinary. Binary image used in instantiation of the 
+    *  collator remains owned by the user and should stay around for 
+    *  the lifetime of the collator. The API also takes a base collator
+    *  which usualy should be UCA.
+    *  @param bin binary image owned by the user and required through the
+    *             lifetime of the collator
+    *  @param length size of the image. If negative, the API will try to
+    *                figure out the length of the image
+    *  @param base fallback collator, usually UCA. Base is required to be
+    *              present through the lifetime of the collator. Currently 
+    *              it cannot be NULL.
+    *  @param status for catching errors
+    *  @return newly created collator
+    *  @see cloneBinary
+    *  @stable ICU 3.4
+    */
+    RuleBasedCollator(const uint8_t *bin, int32_t length, 
+                    const RuleBasedCollator *base, 
+                    UErrorCode &status);
+    // destructor --------------------------------------------------------------
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~RuleBasedCollator();
+
+    // public methods ----------------------------------------------------------
+
+    /**
+     * Assignment operator.
+     * @param other other RuleBasedCollator object to compare with.
+     * @stable ICU 2.0
+     */
+    RuleBasedCollator& operator=(const RuleBasedCollator& other);
+
+    /**
+     * Returns true if argument is the same as this object.
+     * @param other Collator object to be compared.
+     * @return true if arguments is the same as this object.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const Collator& other) const;
+
+    /**
+     * Returns true if argument is not the same as this object.
+     * @param other Collator object to be compared
+     * @return returns true if argument is not the same as this object.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator!=(const Collator& other) const;
+
+    /**
+     * Makes a deep copy of the object.
+     * The caller owns the returned object.
+     * @return the cloned object.
+     * @stable ICU 2.0
+     */
+    virtual Collator* clone(void) const;
+
+    /**
+     * Creates a collation element iterator for the source string. The caller of
+     * this method is responsible for the memory management of the return
+     * pointer.
+     * @param source the string over which the CollationElementIterator will
+     *        iterate.
+     * @return the collation element iterator of the source string using this as
+     *         the based Collator.
+     * @stable ICU 2.2
+     */
+    virtual CollationElementIterator* createCollationElementIterator(
+                                           const UnicodeString& source) const;
+
+    /**
+     * Creates a collation element iterator for the source. The caller of this
+     * method is responsible for the memory management of the returned pointer.
+     * @param source the CharacterIterator which produces the characters over
+     *        which the CollationElementItgerator will iterate.
+     * @return the collation element iterator of the source using this as the
+     *         based Collator.
+     * @stable ICU 2.2
+     */
+    virtual CollationElementIterator* createCollationElementIterator(
+                                         const CharacterIterator& source) const;
+
+    /**
+     * Compares a range of character data stored in two different strings based
+     * on the collation rules. Returns information about whether a string is
+     * less than, greater than or equal to another string in a language.
+     * This can be overriden in a subclass.
+     * @param source the source string.
+     * @param target the target string to be compared with the source string.
+     * @return the comparison result. GREATER if the source string is greater
+     *         than the target string, LESS if the source is less than the
+     *         target. Otherwise, returns EQUAL.
+     * @deprecated ICU 2.6 Use overload with UErrorCode&
+     */
+    virtual EComparisonResult compare(const UnicodeString& source,
+                                      const UnicodeString& target) const;
+
+
+    /**
+    * The comparison function compares the character data stored in two
+    * different strings. Returns information about whether a string is less 
+    * than, greater than or equal to another string.
+    * @param source the source string to be compared with.
+    * @param target the string that is to be compared with the source string.
+    * @param status possible error code
+    * @return Returns an enum value. UCOL_GREATER if source is greater
+    * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
+    * than target
+    * @stable ICU 2.6
+    **/
+    virtual UCollationResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      UErrorCode &status) const;
+
+    /**
+     * Compares a range of character data stored in two different strings based
+     * on the collation rules up to the specified length. Returns information
+     * about whether a string is less than, greater than or equal to another
+     * string in a language. This can be overriden in a subclass.
+     * @param source the source string.
+     * @param target the target string to be compared with the source string.
+     * @param length compares up to the specified length
+     * @return the comparison result. GREATER if the source string is greater
+     *         than the target string, LESS if the source is less than the
+     *         target. Otherwise, returns EQUAL.
+     * @deprecated ICU 2.6 Use overload with UErrorCode&
+     */
+    virtual EComparisonResult compare(const UnicodeString& source,
+                                      const UnicodeString&  target,
+                                      int32_t length) const;
+
+    /**
+    * Does the same thing as compare but limits the comparison to a specified 
+    * length
+    * @param source the source string to be compared with.
+    * @param target the string that is to be compared with the source string.
+    * @param length the length the comparison is limited to
+    * @param status possible error code
+    * @return Returns an enum value. UCOL_GREATER if source (up to the specified 
+    *         length) is greater than target; UCOL_EQUAL if source (up to specified 
+    *         length) is equal to target; UCOL_LESS if source (up to the specified 
+    *         length) is less  than target.
+    * @stable ICU 2.6
+    */
+    virtual UCollationResult compare(const UnicodeString& source,
+                                      const UnicodeString& target,
+                                      int32_t length,
+                                      UErrorCode &status) const;
+
+    /**
+     * The comparison function compares the character data stored in two
+     * different string arrays. Returns information about whether a string array
+     * is less than, greater than or equal to another string array.
+     * <p>Example of use:
+     * <pre>
+     * .       UChar ABC[] = {0x41, 0x42, 0x43, 0};  // = "ABC"
+     * .       UChar abc[] = {0x61, 0x62, 0x63, 0};  // = "abc"
+     * .       UErrorCode status = U_ZERO_ERROR;
+     * .       Collator *myCollation =
+     * .                         Collator::createInstance(Locale::US, status);
+     * .       if (U_FAILURE(status)) return;
+     * .       myCollation->setStrength(Collator::PRIMARY);
+     * .       // result would be Collator::EQUAL ("abc" == "ABC")
+     * .       // (no primary difference between "abc" and "ABC")
+     * .       Collator::EComparisonResult result =
+     * .                             myCollation->compare(abc, 3, ABC, 3);
+     * .       myCollation->setStrength(Collator::TERTIARY);
+     * .       // result would be Collator::LESS ("abc" &lt;&lt;&lt; "ABC")
+     * .       // (with tertiary difference between "abc" and "ABC")
+     * .       result =  myCollation->compare(abc, 3, ABC, 3);
+     * </pre>
+     * @param source the source string array to be compared with.
+     * @param sourceLength the length of the source string array. If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @param target the string that is to be compared with the source string.
+     * @param targetLength the length of the target string array. If this value
+     *        is equal to -1, the string array is null-terminated.
+     * @return Returns a byte value. GREATER if source is greater than target;
+     *         EQUAL if source is equal to target; LESS if source is less than
+     *         target
+     * @deprecated ICU 2.6 Use overload with UErrorCode&
+     */
+    virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
+                                      const UChar* target, int32_t targetLength)
+                                      const;
+
+    /**
+    * The comparison function compares the character data stored in two
+    * different string arrays. Returns information about whether a string array 
+    * is less than, greater than or equal to another string array.
+    * @param source the source string array to be compared with.
+    * @param sourceLength the length of the source string array.  If this value
+    *        is equal to -1, the string array is null-terminated.
+    * @param target the string that is to be compared with the source string.
+    * @param targetLength the length of the target string array.  If this value
+    *        is equal to -1, the string array is null-terminated.
+    * @param status possible error code
+    * @return Returns an enum value. UCOL_GREATER if source is greater
+    * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less
+    * than target
+    * @stable ICU 2.6
+    */
+    virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
+                                      const UChar* target, int32_t targetLength,
+                                      UErrorCode &status) const;
+
+    /**
+    * Transforms a specified region of the string into a series of characters
+    * that can be compared with CollationKey.compare. Use a CollationKey when
+    * you need to do repeated comparisions on the same string. For a single
+    * comparison the compare method will be faster.
+    * @param source the source string.
+    * @param key the transformed key of the source string.
+    * @param status the error code status.
+    * @return the transformed key.
+    * @see CollationKey
+    * @deprecated ICU 2.8 Use getSortKey(...) instead
+    */
+    virtual CollationKey& getCollationKey(const UnicodeString& source,
+                                          CollationKey& key,
+                                          UErrorCode& status) const;
+
+    /**
+    * Transforms a specified region of the string into a series of characters
+    * that can be compared with CollationKey.compare. Use a CollationKey when
+    * you need to do repeated comparisions on the same string. For a single
+    * comparison the compare method will be faster.
+    * @param source the source string.
+    * @param sourceLength the length of the source string.
+    * @param key the transformed key of the source string.
+    * @param status the error code status.
+    * @return the transformed key.
+    * @see CollationKey
+    * @deprecated ICU 2.8 Use getSortKey(...) instead
+    */
+    virtual CollationKey& getCollationKey(const UChar *source,
+                                          int32_t sourceLength,
+                                          CollationKey& key,
+                                          UErrorCode& status) const;
+
+    /**
+     * Generates the hash code for the rule-based collation object.
+     * @return the hash code.
+     * @stable ICU 2.0
+     */
+    virtual int32_t hashCode(void) const;
+
+    /**
+    * Gets the locale of the Collator
+    * @param type can be either requested, valid or actual locale. For more
+    *             information see the definition of ULocDataLocaleType in
+    *             uloc.h
+    * @param status the error code status.
+    * @return locale where the collation data lives. If the collator
+    *         was instantiated from rules, locale is empty.
+    * @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback
+    */
+    virtual const Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+
+    /**
+     * Gets the table-based rules for the collation object.
+     * @return returns the collation rules that the table collation object was
+     *         created from.
+     * @stable ICU 2.0
+     */
+    const UnicodeString& getRules(void) const;
+
+    /**
+     * Gets the version information for a Collator.
+     * @param info the version # information, the result will be filled in
+     * @stable ICU 2.0
+     */
+    virtual void getVersion(UVersionInfo info) const;
+
+    /**
+     * Return the maximum length of any expansion sequences that end with the
+     * specified comparison order.
+     * @param order a collation order returned by previous or next.
+     * @return maximum size of the expansion sequences ending with the collation
+     *         element or 1 if collation element does not occur at the end of
+     *         any expansion sequence
+     * @see CollationElementIterator#getMaxExpansion
+     * @stable ICU 2.0
+     */
+    int32_t getMaxExpansion(int32_t order) const;
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     * @return The class ID for this object. All objects of a given class have
+     *         the same class ID. Objects of other classes have different class
+     *         IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+    /**
+     * Returns the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * Base* polymorphic_pointer = createPolymorphicObject();
+     * if (polymorphic_pointer->getDynamicClassID() ==
+     *                                          Derived::getStaticClassID()) ...
+     * </pre>
+     * @return The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns the binary format of the class's rules. The format is that of
+     * .col files.
+     * @param length Returns the length of the data, in bytes
+     * @param status the error code status.
+     * @return memory, owned by the caller, of size 'length' bytes.
+     * @stable ICU 2.2
+     */
+    uint8_t *cloneRuleData(int32_t &length, UErrorCode &status);
+
+
+    /** Creates a binary image of a collator. This binary image can be stored and 
+    *  later used to instantiate a collator using ucol_openBinary.
+    *  This API supports preflighting.
+    *  @param buffer a fill-in buffer to receive the binary image
+    *  @param capacity capacity of the destination buffer
+    *  @param status for catching errors
+    *  @return size of the image
+    *  @see ucol_openBinary
+    *  @stable ICU 3.4
+    */
+    int32_t cloneBinary(uint8_t *buffer, int32_t capacity, UErrorCode &status);
+
+    /**
+     * Returns current rules. Delta defines whether full rules are returned or
+     * just the tailoring.
+     * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
+     * @param buffer UnicodeString to store the result rules
+     * @stable ICU 2.2
+     */
+    void getRules(UColRuleOption delta, UnicodeString &buffer);
+
+    /**
+     * Universal attribute setter
+     * @param attr attribute type
+     * @param value attribute value
+     * @param status to indicate whether the operation went on smoothly or there were errors
+     * @stable ICU 2.2
+     */
+    virtual void setAttribute(UColAttribute attr, UColAttributeValue value,
+                              UErrorCode &status);
+
+    /**
+     * Universal attribute getter.
+     * @param attr attribute type
+     * @param status to indicate whether the operation went on smoothly or there were errors
+     * @return attribute value
+     * @stable ICU 2.2
+     */
+    virtual UColAttributeValue getAttribute(UColAttribute attr,
+                                            UErrorCode &status);
+
+    /**
+     * Sets the variable top to a collation element value of a string supplied.
+     * @param varTop one or more (if contraction) UChars to which the variable top should be set
+     * @param len length of variable top string. If -1 it is considered to be zero terminated.
+     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
+     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>
+     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
+     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined
+     * @stable ICU 2.0
+     */
+    virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status);
+
+    /**
+     * Sets the variable top to a collation element value of a string supplied.
+     * @param varTop an UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set
+     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>
+     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>
+     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
+     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined
+     * @stable ICU 2.0
+     */
+    virtual uint32_t setVariableTop(const UnicodeString varTop, UErrorCode &status);
+
+    /**
+     * Sets the variable top to a collation element value supplied. Variable top is set to the upper 16 bits.
+     * Lower 16 bits are ignored.
+     * @param varTop CE value, as returned by setVariableTop or ucol)getVariableTop
+     * @param status error code (not changed by function)
+     * @stable ICU 2.0
+     */
+    virtual void setVariableTop(const uint32_t varTop, UErrorCode &status);
+
+    /**
+     * Gets the variable top value of a Collator.
+     * Lower 16 bits are undefined and should be ignored.
+     * @param status error code (not changed by function). If error code is set, the return value is undefined.
+     * @stable ICU 2.0
+     */
+    virtual uint32_t getVariableTop(UErrorCode &status) const;
+
+    /**
+     * Get an UnicodeSet that contains all the characters and sequences tailored in 
+     * this collator.
+     * @param status      error code of the operation
+     * @return a pointer to a UnicodeSet object containing all the 
+     *         code points and sequences that may sort differently than
+     *         in the UCA. The object must be disposed of by using delete
+     * @stable ICU 2.4
+     */
+    virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
+
+    /**
+     * Thread safe cloning operation.
+     * @return pointer to the new clone, user should remove it.
+     * @stable ICU 2.2
+     */
+    virtual Collator* safeClone(void);
+
+    /**
+     * Get the sort key as an array of bytes from an UnicodeString.
+     * @param source string to be processed.
+     * @param result buffer to store result in. If NULL, number of bytes needed
+     *        will be returned.
+     * @param resultLength length of the result buffer. If if not enough the
+     *        buffer will be filled to capacity.
+     * @return Number of bytes needed for storing the sort key
+     * @stable ICU 2.0
+     */
+    virtual int32_t getSortKey(const UnicodeString& source, uint8_t *result,
+                               int32_t resultLength) const;
+
+    /**
+     * Get the sort key as an array of bytes from an UChar buffer.
+     * @param source string to be processed.
+     * @param sourceLength length of string to be processed. If -1, the string
+     *        is 0 terminated and length will be decided by the function.
+     * @param result buffer to store result in. If NULL, number of bytes needed
+     *        will be returned.
+     * @param resultLength length of the result buffer. If if not enough the
+     *        buffer will be filled to capacity.
+     * @return Number of bytes needed for storing the sort key
+     * @stable ICU 2.2
+     */
+    virtual int32_t getSortKey(const UChar *source, int32_t sourceLength,
+                               uint8_t *result, int32_t resultLength) const;
+
+    /**
+    * Determines the minimum strength that will be use in comparison or
+    * transformation.
+    * <p>E.g. with strength == SECONDARY, the tertiary difference is ignored
+    * <p>E.g. with strength == PRIMARY, the secondary and tertiary difference
+    * are ignored.
+    * @return the current comparison level.
+    * @see RuleBasedCollator#setStrength
+    * @deprecated ICU 2.6 Use getAttribute(UCOL_STRENGTH...) instead
+    */
+    virtual ECollationStrength getStrength(void) const;
+
+    /**
+    * Sets the minimum strength to be used in comparison or transformation.
+    * @see RuleBasedCollator#getStrength
+    * @param newStrength the new comparison level.
+    * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead
+    */
+    virtual void setStrength(ECollationStrength newStrength);
+
+private:
+
+    // private static constants -----------------------------------------------
+
+    enum {
+        /* need look up in .commit() */
+        CHARINDEX = 0x70000000,
+        /* Expand index follows */
+        EXPANDCHARINDEX = 0x7E000000,
+        /* contract indexes follows */
+        CONTRACTCHARINDEX = 0x7F000000,
+        /* unmapped character values */
+        UNMAPPED = 0xFFFFFFFF,
+        /* primary strength increment */
+        PRIMARYORDERINCREMENT = 0x00010000,
+        /* secondary strength increment */
+        SECONDARYORDERINCREMENT = 0x00000100,
+        /* tertiary strength increment */
+        TERTIARYORDERINCREMENT = 0x00000001,
+        /* mask off anything but primary order */
+        PRIMARYORDERMASK = 0xffff0000,
+        /* mask off anything but secondary order */
+        SECONDARYORDERMASK = 0x0000ff00,
+        /* mask off anything but tertiary order */
+        TERTIARYORDERMASK = 0x000000ff,
+        /* mask off ignorable char order */
+        IGNORABLEMASK = 0x0000ffff,
+        /* use only the primary difference */
+        PRIMARYDIFFERENCEONLY = 0xffff0000,
+        /* use only the primary and secondary difference */
+        SECONDARYDIFFERENCEONLY = 0xffffff00,
+        /* primary order shift */
+        PRIMARYORDERSHIFT = 16,
+        /* secondary order shift */
+        SECONDARYORDERSHIFT = 8,
+        /* starting value for collation elements */
+        COLELEMENTSTART = 0x02020202,
+        /* testing mask for primary low element */
+        PRIMARYLOWZEROMASK = 0x00FF0000,
+        /* reseting value for secondaries and tertiaries */
+        RESETSECONDARYTERTIARY = 0x00000202,
+        /* reseting value for tertiaries */
+        RESETTERTIARY = 0x00000002,
+
+        PRIMIGNORABLE = 0x0202
+    };
+
+    // private data members ---------------------------------------------------
+
+    UBool dataIsOwned;
+
+    UBool isWriteThroughAlias;
+
+    /**
+    * c struct for collation. All initialisation for it has to be done through
+    * setUCollator().
+    */
+    UCollator *ucollator;
+
+    /**
+    * Rule UnicodeString
+    */
+    UnicodeString urulestring;
+
+    // friend classes --------------------------------------------------------
+
+    /**
+    * Used to iterate over collation elements in a character source.
+    */
+    friend class CollationElementIterator;
+
+    /**
+    * Collator ONLY needs access to RuleBasedCollator(const Locale&,
+    *                                                       UErrorCode&)
+    */
+    friend class Collator;
+
+    /**
+    * Searching over collation elements in a character source
+    */
+    friend class StringSearch;
+
+    // private constructors --------------------------------------------------
+
+    /**
+     * Default constructor
+     */
+    RuleBasedCollator();
+
+    /**
+     * RuleBasedCollator constructor. This constructor takes a locale. The
+     * only caller of this class should be Collator::createInstance(). If
+     * createInstance() happens to know that the requested locale's collation is
+     * implemented as a RuleBasedCollator, it can then call this constructor.
+     * OTHERWISE IT SHOULDN'T, since this constructor ALWAYS RETURNS A VALID
+     * COLLATION TABLE. It does this by falling back to defaults.
+     * @param desiredLocale locale used
+     * @param status error code status
+     */
+    RuleBasedCollator(const Locale& desiredLocale, UErrorCode& status);
+
+    /**
+     * common constructor implementation
+     *
+     * @param rules the collation rules to build the collation table from.
+     * @param collationStrength default strength for comparison
+     * @param decompositionMode the normalisation mode
+     * @param status reporting a success or an error.
+     */
+    void
+    construct(const UnicodeString& rules,
+              UColAttributeValue collationStrength,
+              UColAttributeValue decompositionMode,
+              UErrorCode& status);
+
+    // private methods -------------------------------------------------------
+
+    /**
+    * Creates the c struct for ucollator
+    * @param locale desired locale
+    * @param status error status
+    */
+    void setUCollator(const Locale& locale, UErrorCode& status);
+
+    /**
+    * Creates the c struct for ucollator
+    * @param locale desired locale name
+    * @param status error status
+    */
+    void setUCollator(const char* locale, UErrorCode& status);
+
+    /**
+    * Creates the c struct for ucollator. This used internally by StringSearch.
+    * Hence the responsibility of cleaning up the ucollator is not done by
+    * this RuleBasedCollator. The isDataOwned flag is set to FALSE.
+    * @param collator new ucollator data
+    * @param rules corresponding collation rules
+    */
+    void setUCollator(UCollator *collator);
+
+public:
+    /**
+    * Get UCollator data struct. Used only by StringSearch & intltest.
+    * @return UCollator data struct
+    * @internal
+    */
+    const UCollator * getUCollator();
+
+protected:
+   /**
+    * Used internally by registraton to define the requested and valid locales.
+    * @param requestedLocale the requsted locale
+    * @param validLocale the valid locale
+    * @param actualLocale the actual locale
+    * @internal
+    */
+    virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale);
+
+private:
+
+    // if not owned and not a write through alias, copy the ucollator
+    void checkOwned(void);
+
+    // utility to init rule string used by checkOwned and construct
+    void setRuleStringFromCollator();
+
+    /**
+    * Converts C's UCollationResult to EComparisonResult
+    * @param result member of the enum UComparisonResult
+    * @return EComparisonResult equivalent of UCollationResult
+    * @deprecated ICU 2.6. We will not need it.
+    */
+    Collator::EComparisonResult getEComparisonResult(
+                                            const UCollationResult &result) const;
+
+    /**
+    * Converts C's UCollationStrength to ECollationStrength
+    * @param strength member of the enum UCollationStrength
+    * @return ECollationStrength equivalent of UCollationStrength
+    */
+    Collator::ECollationStrength getECollationStrength(
+                                        const UCollationStrength &strength) const;
+
+    /**
+    * Converts C++'s ECollationStrength to UCollationStrength
+    * @param strength member of the enum ECollationStrength
+    * @return UCollationStrength equivalent of ECollationStrength
+    */
+    UCollationStrength getUCollationStrength(
+      const Collator::ECollationStrength &strength) const;
+};
+
+// inline method implementation ---------------------------------------------
+
+inline void RuleBasedCollator::setUCollator(const Locale &locale,
+                                               UErrorCode &status)
+{
+    setUCollator(locale.getName(), status);
+}
+
+
+inline void RuleBasedCollator::setUCollator(UCollator     *collator)
+{
+
+    if (ucollator && dataIsOwned) {
+        ucol_close(ucollator);
+    }
+    ucollator   = collator;
+    dataIsOwned = FALSE;
+    isWriteThroughAlias = TRUE;
+    setRuleStringFromCollator();
+}
+
+inline const UCollator * RuleBasedCollator::getUCollator()
+{
+    return ucollator;
+}
+
+inline Collator::EComparisonResult RuleBasedCollator::getEComparisonResult(
+                                           const UCollationResult &result) const
+{
+    switch (result)
+    {
+    case UCOL_LESS :
+        return Collator::LESS;
+    case UCOL_EQUAL :
+        return Collator::EQUAL;
+    default :
+        return Collator::GREATER;
+    }
+}
+
+inline Collator::ECollationStrength RuleBasedCollator::getECollationStrength(
+                                       const UCollationStrength &strength) const
+{
+    switch (strength)
+    {
+    case UCOL_PRIMARY :
+        return Collator::PRIMARY;
+    case UCOL_SECONDARY :
+        return Collator::SECONDARY;
+    case UCOL_TERTIARY :
+        return Collator::TERTIARY;
+    case UCOL_QUATERNARY :
+        return Collator::QUATERNARY;
+    default :
+        return Collator::IDENTICAL;
+    }
+}
+
+inline UCollationStrength RuleBasedCollator::getUCollationStrength(
+                             const Collator::ECollationStrength &strength) const
+{
+    switch (strength)
+    {
+    case Collator::PRIMARY :
+        return UCOL_PRIMARY;
+    case Collator::SECONDARY :
+        return UCOL_SECONDARY;
+    case Collator::TERTIARY :
+        return UCOL_TERTIARY;
+    case Collator::QUATERNARY :
+        return UCOL_QUATERNARY;
+    default :
+        return UCOL_IDENTICAL;
+    }
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/timezone.h b/CoreFoundation/icu/unicode/timezone.h
new file mode 100644
index 0000000..1b9118b
--- /dev/null
+++ b/CoreFoundation/icu/unicode/timezone.h
@@ -0,0 +1,803 @@
+/*************************************************************************
+* Copyright (c) 1997-2008, International Business Machines Corporation
+* and others. All Rights Reserved.
+**************************************************************************
+*
+* File TIMEZONE.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/21/97    aliu        Overhauled header.
+*   07/09/97    helena      Changed createInstance to createDefault.
+*   08/06/97    aliu        Removed dependency on internal header for Hashtable.
+*   08/10/98    stephen        Changed getDisplayName() API conventions to match
+*   08/19/98    stephen        Changed createTimeZone() to never return 0
+*   09/02/98    stephen        Sync to JDK 1.2 8/31
+*                            - Added getOffset(... monthlen ...)
+*                            - Added hasSameRules()
+*   09/15/98    stephen        Added getStaticClassID
+*   12/03/99    aliu        Moved data out of static table into icudata.dll.
+*                           Hashtable replaced by new static data structures.
+*   12/14/99    aliu        Made GMT public.
+*   08/15/01    grhoten     Made GMT private and added the getGMT() function
+**************************************************************************
+*/
+
+#ifndef TIMEZONE_H
+#define TIMEZONE_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: TimeZone object
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/ures.h"
+
+U_NAMESPACE_BEGIN
+
+class StringEnumeration;
+
+/**
+ *
+ * <code>TimeZone</code> represents a time zone offset, and also figures out daylight
+ * savings.
+ *
+ * <p>
+ * Typically, you get a <code>TimeZone</code> using <code>createDefault</code>
+ * which creates a <code>TimeZone</code> based on the time zone where the program
+ * is running. For example, for a program running in Japan, <code>createDefault</code>
+ * creates a <code>TimeZone</code> object based on Japanese Standard Time.
+ *
+ * <p>
+ * You can also get a <code>TimeZone</code> using <code>createTimeZone</code> along
+ * with a time zone ID. For instance, the time zone ID for the Pacific
+ * Standard Time zone is "PST". So, you can get a PST <code>TimeZone</code> object
+ * with:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * TimeZone *tz = TimeZone::createTimeZone("PST");
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * You can use <code>getAvailableIDs</code> method to iterate through
+ * all the supported time zone IDs. You can then choose a
+ * supported ID to get a <code>TimeZone</code>.
+ * If the time zone you want is not represented by one of the
+ * supported IDs, then you can create a custom time zone ID with
+ * the following syntax:
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * GMT[+|-]hh[[:]mm]
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * For example, you might specify GMT+14:00 as a custom
+ * time zone ID.  The <code>TimeZone</code> that is returned
+ * when you specify a custom time zone ID does not include
+ * daylight savings time.
+ *
+ * TimeZone is an abstract class representing a time zone.  A TimeZone is needed for
+ * Calendar to produce local time for a particular time zone.  A TimeZone comprises
+ * three basic pieces of information:
+ * <ul>
+ *    <li>A time zone offset; that, is the number of milliseconds to add or subtract
+ *      from a time expressed in terms of GMT to convert it to the same time in that
+ *      time zone (without taking daylight savings time into account).</li>
+ *    <li>Logic necessary to take daylight savings time into account if daylight savings
+ *      time is observed in that time zone (e.g., the days and hours on which daylight
+ *      savings time begins and ends).</li>
+ *    <li>An ID.  This is a text string that uniquely identifies the time zone.</li>
+ * </ul>
+ *
+ * (Only the ID is actually implemented in TimeZone; subclasses of TimeZone may handle
+ * daylight savings time and GMT offset in different ways.  Currently we only have one
+ * TimeZone subclass: SimpleTimeZone.)
+ * <P>
+ * The TimeZone class contains a static list containing a TimeZone object for every
+ * combination of GMT offset and daylight-savings time rules currently in use in the
+ * world, each with a unique ID.  Each ID consists of a region (usually a continent or
+ * ocean) and a city in that region, separated by a slash, (for example, Pacific
+ * Standard Time is "America/Los_Angeles.")  Because older versions of this class used
+ * three- or four-letter abbreviations instead, there is also a table that maps the older
+ * abbreviations to the newer ones (for example, "PST" maps to "America/LosAngeles").
+ * Anywhere the API requires an ID, you can use either form.
+ * <P>
+ * To create a new TimeZone, you call the factory function TimeZone::createTimeZone()
+ * and pass it a time zone ID.  You can use the createEnumeration() function to
+ * obtain a list of all the time zone IDs recognized by createTimeZone().
+ * <P>
+ * You can also use TimeZone::createDefault() to create a TimeZone.  This function uses
+ * platform-specific APIs to produce a TimeZone for the time zone corresponding to
+ * the client's computer's physical location.  For example, if you're in Japan (assuming
+ * your machine is set up correctly), TimeZone::createDefault() will return a TimeZone
+ * for Japanese Standard Time ("Asia/Tokyo").
+ */
+class U_I18N_API TimeZone : public UObject {
+public:
+    /**
+     * @stable ICU 2.0
+     */
+    virtual ~TimeZone();
+
+    /**
+     * The GMT time zone has a raw offset of zero and does not use daylight
+     * savings time. This is a commonly used time zone.
+     * @return the GMT time zone.
+     * @stable ICU 2.0
+     */
+    static const TimeZone* U_EXPORT2 getGMT(void);
+
+    /**
+     * Creates a <code>TimeZone</code> for the given ID.
+     * @param ID the ID for a <code>TimeZone</code>, either an abbreviation such as
+     * "PST", a full name such as "America/Los_Angeles", or a custom ID
+     * such as "GMT-8:00".
+     * @return the specified <code>TimeZone</code>, or the GMT zone if the given ID
+     * cannot be understood.  Return result guaranteed to be non-null.  If you
+     * require that the specific zone asked for be returned, check the ID of the
+     * return result.
+     * @stable ICU 2.0
+     */
+    static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);
+
+    /**
+     * Returns an enumeration over all recognized time zone IDs. (i.e.,
+     * all strings that createTimeZone() accepts)
+     *
+     * @return an enumeration object, owned by the caller.
+     * @stable ICU 2.4
+     */
+    static StringEnumeration* U_EXPORT2 createEnumeration();
+
+    /**
+     * Returns an enumeration over time zone IDs with a given raw
+     * offset from GMT.  There may be several times zones with the
+     * same GMT offset that differ in the way they handle daylight
+     * savings time.  For example, the state of Arizona doesn't
+     * observe daylight savings time.  If you ask for the time zone
+     * IDs corresponding to GMT-7:00, you'll get back an enumeration
+     * over two time zone IDs: "America/Denver," which corresponds to
+     * Mountain Standard Time in the winter and Mountain Daylight Time
+     * in the summer, and "America/Phoenix", which corresponds to
+     * Mountain Standard Time year-round, even in the summer.
+     *
+     * @param rawOffset an offset from GMT in milliseconds, ignoring
+     * the effect of daylight savings time, if any
+     * @return an enumeration object, owned by the caller
+     * @stable ICU 2.4
+     */
+    static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);
+
+    /**
+     * Returns an enumeration over time zone IDs associated with the
+     * given country.  Some zones are affiliated with no country
+     * (e.g., "UTC"); these may also be retrieved, as a group.
+     *
+     * @param country The ISO 3166 two-letter country code, or NULL to
+     * retrieve zones not affiliated with any country.
+     * @return an enumeration object, owned by the caller
+     * @stable ICU 2.4
+     */
+    static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);
+
+#ifdef U_USE_TIMEZONE_OBSOLETE_2_8
+    /**
+     * Returns a list of time zone IDs, one for each time zone with a given GMT offset.
+     * The return value is a list because there may be several times zones with the same
+     * GMT offset that differ in the way they handle daylight savings time.  For example,
+     * the state of Arizona doesn't observe Daylight Savings time.  So if you ask for
+     * the time zone IDs corresponding to GMT-7:00, you'll get back two time zone IDs:
+     * "America/Denver," which corresponds to Mountain Standard Time in the winter and
+     * Mountain Daylight Time in the summer, and "America/Phoenix", which corresponds to
+     * Mountain Standard Time year-round, even in the summer.
+     * <P>
+     * The caller owns the list that is returned, but does not own the strings contained
+     * in that list.  Delete the array with uprv_free(), but DON'T delete the elements in the array.
+     *
+     * <p>NOTE: uprv_free() is declared in the private header source/common/cmemory.h.
+     *
+     * @param rawOffset  An offset from GMT in milliseconds.
+     * @param numIDs     Receives the number of items in the array that is returned.
+     * @return           An array of UnicodeString pointers, where each UnicodeString is
+     *                   a time zone ID for a time zone with the given GMT offset.  If
+     *                   there is no timezone that matches the GMT offset
+     *                   specified, NULL is returned.
+     * @obsolete ICU 2.8.  Use createEnumeration(int32_t) instead since this API will be removed in that release.
+     */
+    static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
+
+    /**
+     * Returns a list of time zone IDs associated with the given
+     * country.  Some zones are affiliated with no country (e.g.,
+     * "UTC"); these may also be retrieved, as a group.
+     *
+     * <P>The caller owns the list that is returned, but does not own
+     * the strings contained in that list.  Delete the array with uprv_free(), but
+     * <b>DON'T</b> delete the elements in the array.
+     *
+     * <p>NOTE: uprv_free() is declared in the private header source/common/cmemory.h.
+     *
+     * @param country The ISO 3166 two-letter country code, or NULL to
+     * retrieve zones not affiliated with any country.
+     * @param numIDs Receives the number of items in the array that is
+     * returned.
+     * @return An array of UnicodeString pointers, where each
+     * UnicodeString is a time zone ID for a time zone with the given
+     * country.  If there is no timezone that matches the country
+     * specified, NULL is returned.
+     * @obsolete ICU 2.8.  Use createEnumeration(const char*) instead since this API will be removed in that release.
+     */
+    static const UnicodeString** createAvailableIDs(const char* country,
+                                                          int32_t& numIDs);
+
+    /**
+     * Returns a list of all time zone IDs supported by the TimeZone class (i.e., all
+     * IDs that it's legal to pass to createTimeZone()).  The caller owns the list that
+     * is returned, but does not own the strings contained in that list.  Delete the array with uprv_free(),
+     * but DON'T delete the elements in the array.
+     *
+     * <p>NOTE: uprv_free() is declared in the private header source/common/cmemory.h.
+     *
+     * @param numIDs  Receives the number of zone IDs returned.
+     * @return        An array of UnicodeString pointers, where each is a time zone ID
+     *                supported by the TimeZone class.
+     * @obsolete ICU 2.8.  Use createEnumeration(void) instead since this API will be removed in that release.
+     */
+    static const UnicodeString** createAvailableIDs(int32_t& numIDs);
+#endif
+
+    /**
+     * Returns the number of IDs in the equivalency group that
+     * includes the given ID.  An equivalency group contains zones
+     * that have the same GMT offset and rules.
+     *
+     * <p>The returned count includes the given ID; it is always >= 1.
+     * The given ID must be a system time zone.  If it is not, returns
+     * zero.
+     * @param id a system time zone ID
+     * @return the number of zones in the equivalency group containing
+     * 'id', or zero if 'id' is not a valid system ID
+     * @see #getEquivalentID
+     * @stable ICU 2.0
+     */
+    static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);
+
+    /**
+     * Returns an ID in the equivalency group that
+     * includes the given ID.  An equivalency group contains zones
+     * that have the same GMT offset and rules.
+     *
+     * <p>The given index must be in the range 0..n-1, where n is the
+     * value returned by <code>countEquivalentIDs(id)</code>.  For
+     * some value of 'index', the returned value will be equal to the
+     * given id.  If the given id is not a valid system time zone, or
+     * if 'index' is out of range, then returns an empty string.
+     * @param id a system time zone ID
+     * @param index a value from 0 to n-1, where n is the value
+     * returned by <code>countEquivalentIDs(id)</code>
+     * @return the ID of the index-th zone in the equivalency group
+     * containing 'id', or an empty string if 'id' is not a valid
+     * system ID or 'index' is out of range
+     * @see #countEquivalentIDs
+     * @stable ICU 2.0
+     */
+    static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,
+                                               int32_t index);
+
+    /**
+     * Creates a new copy of the default TimeZone for this host. Unless the default time
+     * zone has already been set using adoptDefault() or setDefault(), the default is
+     * determined by querying the system using methods in TPlatformUtilities. If the
+     * system routines fail, or if they specify a TimeZone or TimeZone offset which is not
+     * recognized, the TimeZone indicated by the ID kLastResortID is instantiated
+     * and made the default.
+     *
+     * @return   A default TimeZone. Clients are responsible for deleting the time zone
+     *           object returned.
+     * @stable ICU 2.0
+     */
+    static TimeZone* U_EXPORT2 createDefault(void);
+
+    /**
+     * Sets the default time zone (i.e., what's returned by createDefault()) to be the
+     * specified time zone.  If NULL is specified for the time zone, the default time
+     * zone is set to the default host time zone.  This call adopts the TimeZone object
+     * passed in; the clent is no longer responsible for deleting it.
+     *
+     * @param zone  A pointer to the new TimeZone object to use as the default.
+     * @stable ICU 2.0
+     */
+    static void U_EXPORT2 adoptDefault(TimeZone* zone);
+
+    /**
+     * Same as adoptDefault(), except that the TimeZone object passed in is NOT adopted;
+     * the caller remains responsible for deleting it.
+     *
+     * @param zone  The given timezone.
+     * @system
+     */
+    static void U_EXPORT2 setDefault(const TimeZone& zone);
+
+    /**
+     * Returns the timezone data version currently used by ICU.
+     * @param status Output param to filled in with a success or an error.
+     * @return the version string, such as "2007f"
+     * @stable ICU 4.0
+     */
+    static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status);
+
+    /**
+     * Returns the canonical system timezone ID or the normalized
+     * custom time zone ID for the given time zone ID.
+     * @param id            The input timezone ID to be canonicalized.
+     * @param canonicalID   Receives the canonical system timezone ID
+     *                      or the custom timezone ID in normalized format.
+     * @param status        Recevies the status.  When the given timezone ID
+     *                      is neither a known system time zone ID nor a
+     *                      valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR
+     *                      is set.
+     * @return A reference to the result.
+     * @draft ICU 4.0
+     */
+    static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
+        UnicodeString& canonicalID, UErrorCode& status);
+
+    /**
+     * Returns the canonical system timezone ID or the normalized
+     * custom time zone ID for the given time zone ID.
+     * @param id            The input timezone ID to be canonicalized.
+     * @param canonicalID   Receives the canonical system timezone ID
+     *                      or the custom timezone ID in normalized format.
+     * @param isSystemID    Receives if the given ID is a known system
+     *                      timezone ID.
+     * @param status        Recevies the status.  When the given timezone ID
+     *                      is neither a known system time zone ID nor a
+     *                      valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR
+     *                      is set.
+     * @return A reference to the result.
+     * @draft ICU 4.0
+     */
+    static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
+        UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status);
+
+    /**
+     * Returns true if the two TimeZones are equal.  (The TimeZone version only compares
+     * IDs, but subclasses are expected to also compare the fields they add.)
+     *
+     * @param that  The TimeZone object to be compared with.
+     * @return      True if the given TimeZone is equal to this TimeZone; false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const TimeZone& that) const;
+
+    /**
+     * Returns true if the two TimeZones are NOT equal; that is, if operator==() returns
+     * false.
+     *
+     * @param that  The TimeZone object to be compared with.
+     * @return      True if the given TimeZone is not equal to this TimeZone; false
+     *              otherwise.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const TimeZone& that) const {return !operator==(that);}
+
+    /**
+     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time in this time zone, taking daylight savings time into
+     * account) as of a particular reference date.  The reference date is used to determine
+     * whether daylight savings time is in effect and needs to be figured into the offset
+     * that is returned (in other words, what is the adjusted GMT offset in this time zone
+     * at this particular date and time?).  For the time zones produced by createTimeZone(),
+     * the reference data is specified according to the Gregorian calendar, and the date
+     * and time fields are local standard time.
+     *
+     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
+     * which returns both the raw and the DST offset for a given time. This method
+     * is retained only for backward compatibility.
+     *
+     * @param era        The reference date's era
+     * @param year       The reference date's year
+     * @param month      The reference date's month (0-based; 0 is January)
+     * @param day        The reference date's day-in-month (1-based)
+     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)
+     * @param millis     The reference date's milliseconds in day, local standard time
+     * @param status     Output param to filled in with a success or an error.
+     * @return           The offset in milliseconds to add to GMT to get local time.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
+
+    /**
+     * Gets the time zone offset, for current date, modified in case of
+     * daylight savings. This is the offset to add *to* UTC to get local time.
+     *
+     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
+     * which returns both the raw and the DST offset for a given time. This method
+     * is retained only for backward compatibility.
+     *
+     * @param era the era of the given date.
+     * @param year the year in the given date.
+     * @param month the month in the given date.
+     * Month is 0-based. e.g., 0 for January.
+     * @param day the day-in-month of the given date.
+     * @param dayOfWeek the day-of-week of the given date.
+     * @param milliseconds the millis in day in <em>standard</em> local time.
+     * @param monthLength the length of the given month in days.
+     * @param status     Output param to filled in with a success or an error.
+     * @return the offset to add *to* GMT to get local time.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                           uint8_t dayOfWeek, int32_t milliseconds,
+                           int32_t monthLength, UErrorCode& status) const = 0;
+
+    /**
+     * Returns the time zone raw and GMT offset for the given moment
+     * in time.  Upon return, local-millis = GMT-millis + rawOffset +
+     * dstOffset.  All computations are performed in the proleptic
+     * Gregorian calendar.  The default implementation in the TimeZone
+     * class delegates to the 8-argument getOffset().
+     *
+     * @param date moment in time for which to return offsets, in
+     * units of milliseconds from January 1, 1970 0:00 GMT, either GMT
+     * time or local wall time, depending on `local'.
+     * @param local if true, `date' is local wall time; otherwise it
+     * is in GMT time.
+     * @param rawOffset output parameter to receive the raw offset, that
+     * is, the offset not including DST adjustments
+     * @param dstOffset output parameter to receive the DST offset,
+     * that is, the offset to be added to `rawOffset' to obtain the
+     * total offset between local and GMT time. If DST is not in
+     * effect, this value is zero; otherwise it is a positive value,
+     * typically one hour.
+     * @param ec input-output error code
+     *
+     * @stable ICU 2.8
+     */
+    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
+                           int32_t& dstOffset, UErrorCode& ec) const;
+
+    /**
+     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @param offsetMillis  The new raw GMT offset for this time zone.
+     * @stable ICU 2.0
+     */
+    virtual void setRawOffset(int32_t offsetMillis) = 0;
+
+    /**
+     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @return   The TimeZone's raw GMT offset.
+     * @stable ICU 2.0
+     */
+    virtual int32_t getRawOffset(void) const = 0;
+
+    /**
+     * Fills in "ID" with the TimeZone's ID.
+     *
+     * @param ID  Receives this TimeZone's ID.
+     * @return    A reference to 'ID'
+     * @stable ICU 2.0
+     */
+    UnicodeString& getID(UnicodeString& ID) const;
+
+    /**
+     * Sets the TimeZone's ID to the specified value.  This doesn't affect any other
+     * fields (for example, if you say<
+     * blockquote><pre>
+     * .     TimeZone* foo = TimeZone::createTimeZone("America/New_York");
+     * .     foo.setID("America/Los_Angeles");
+     * </pre>\htmlonly</blockquote>\endhtmlonly
+     * the time zone's GMT offset and daylight-savings rules don't change to those for
+     * Los Angeles.  They're still those for New York.  Only the ID has changed.)
+     *
+     * @param ID  The new timezone ID.
+     * @stable ICU 2.0
+     */
+    void setID(const UnicodeString& ID);
+
+    /**
+     * Enum for use with getDisplayName
+     * @stable ICU 2.4
+     */
+    enum EDisplayType {
+        /**
+         * Selector for short display name
+         * @stable ICU 2.4
+         */
+        SHORT = 1,
+        /**
+         * Selector for long display name
+         * @stable ICU 2.4
+         */
+        LONG
+    };
+
+    /**
+     * Returns a name of this time zone suitable for presentation to the user
+     * in the default locale.
+     * This method returns the long name, not including daylight savings.
+     * If the display name is not available for the locale,
+     * then this method returns a string in the format
+     * <code>GMT[+-]hh:mm</code>.
+     * @param result the human-readable name of this time zone in the default locale.
+     * @return       A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    UnicodeString& getDisplayName(UnicodeString& result) const;
+
+    /**
+     * Returns a name of this time zone suitable for presentation to the user
+     * in the specified locale.
+     * This method returns the long name, not including daylight savings.
+     * If the display name is not available for the locale,
+     * then this method returns a string in the format
+     * <code>GMT[+-]hh:mm</code>.
+     * @param locale the locale in which to supply the display name.
+     * @param result the human-readable name of this time zone in the given locale
+     *               or in the default locale if the given locale is not recognized.
+     * @return       A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
+
+    /**
+     * Returns a name of this time zone suitable for presentation to the user
+     * in the default locale.
+     * If the display name is not available for the locale,
+     * then this method returns a string in the format
+     * <code>GMT[+-]hh:mm</code>.
+     * @param daylight if true, return the daylight savings name.
+     * @param style either <code>LONG</code> or <code>SHORT</code>
+     * @param result the human-readable name of this time zone in the default locale.
+     * @return       A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
+
+    /**
+     * Returns a name of this time zone suitable for presentation to the user
+     * in the specified locale.
+     * If the display name is not available for the locale,
+     * then this method returns a string in the format
+     * <code>GMT[+-]hh:mm</code>.
+     * @param daylight if true, return the daylight savings name.
+     * @param style either <code>LONG</code> or <code>SHORT</code>
+     * @param locale the locale in which to supply the display name.
+     * @param result the human-readable name of this time zone in the given locale
+     *               or in the default locale if the given locale is not recognized.
+     * @return       A refence to 'result'.
+     * @stable ICU 2.0
+     */
+    UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
+
+    /**
+     * Queries if this time zone uses daylight savings time.
+     * @return true if this time zone uses daylight savings time,
+     * false, otherwise.
+     * @stable ICU 2.0
+     */
+    virtual UBool useDaylightTime(void) const = 0;
+
+    /**
+     * Queries if the given date is in daylight savings time in
+     * this time zone.
+     * This method is wasteful since it creates a new GregorianCalendar and
+     * deletes it each time it is called. This is a deprecated method
+     * and provided only for Java compatibility.
+     *
+     * @param date the given UDate.
+     * @param status Output param filled in with success/error code.
+     * @return true if the given date is in daylight savings time,
+     * false, otherwise.
+     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
+     */
+    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
+
+    /**
+     * Returns true if this zone has the same rule and offset as another zone.
+     * That is, if this zone differs only in ID, if at all.
+     * @param other the <code>TimeZone</code> object to be compared with
+     * @return true if the given zone is the same as this one,
+     * with the possible exception of the ID
+     * @stable ICU 2.0
+     */
+    virtual UBool hasSameRules(const TimeZone& other) const;
+
+    /**
+     * Clones TimeZone objects polymorphically. Clients are responsible for deleting
+     * the TimeZone object cloned.
+     *
+     * @return   A new copy of this TimeZone object.
+     * @stable ICU 2.0
+     */
+    virtual TimeZone* clone(void) const = 0;
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().
+     * @return The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. This method is to
+     * implement a simple version of RTTI, since not all C++ compilers support genuine
+     * RTTI. Polymorphic operator==() and clone() methods call this method.
+     * <P>
+     * Concrete subclasses of TimeZone must use the UOBJECT_DEFINE_RTTI_IMPLEMENTATION
+     *  macro from uobject.h in their implementation to provide correct RTTI information.
+     * @return   The class ID for this object. All objects of a given class have the
+     *           same class ID. Objects of other classes have different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+    
+    /**
+     * Returns the amount of time to be added to local standard time
+     * to get local wall clock time.
+     * <p>
+     * The default implementation always returns 3600000 milliseconds
+     * (i.e., one hour) if this time zone observes Daylight Saving
+     * Time. Otherwise, 0 (zero) is returned.
+     * <p>
+     * If an underlying TimeZone implementation subclass supports
+     * historical Daylight Saving Time changes, this method returns
+     * the known latest daylight saving value.
+     *
+     * @return the amount of saving time in milliseconds
+     * @stable ICU 3.6
+     */
+    virtual int32_t getDSTSavings() const;
+
+protected:
+
+    /**
+     * Default constructor.  ID is initialized to the empty string.
+     * @stable ICU 2.0
+     */
+    TimeZone();
+
+    /**
+     * Construct a timezone with a given ID.
+     * @param id a system time zone ID
+     * @stable ICU 2.0
+     */
+    TimeZone(const UnicodeString &id);
+
+    /**
+     * Copy constructor.
+     * @param source the object to be copied.
+     * @stable ICU 2.0
+     */
+    TimeZone(const TimeZone& source);
+
+    /**
+     * Default assignment operator.
+     * @param right the object to be copied.
+     * @stable ICU 2.0
+     */
+    TimeZone& operator=(const TimeZone& right);
+
+    /**
+     * Utility function. For internally loading rule data.
+     * @param top Top resource bundle for tz data
+     * @param ruleid ID of rule to load
+     * @param oldbundle Old bundle to reuse or NULL
+     * @param status Status parameter
+     * @return either a new bundle or *oldbundle
+     * @internal
+     */
+    static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
+
+private:
+    friend class ZoneMeta;
+
+
+    static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
+
+    /**
+     * Resolve a link in Olson tzdata.  When the given id is known and it's not a link,
+     * the id itself is returned.  When the given id is known and it is a link, then
+     * dereferenced zone id is returned.  When the given id is unknown, then it returns
+     * empty string.
+     * @param linkTo Input zone id string
+     * @param linkFrom Receives the dereferenced zone id string
+     * @return The reference to the result (linkFrom)
+     */
+    static UnicodeString& dereferOlsonLink(const UnicodeString& linkTo, UnicodeString& linkFrom);
+
+    /**
+     * Parses the given custom time zone identifier
+     * @param id id A string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or
+     * GMT[+-]hh.
+     * @param sign Receves parsed sign, 1 for positive, -1 for negative.
+     * @param hour Receives parsed hour field
+     * @param minute Receives parsed minute field
+     * @param second Receives parsed second field
+     * @return Returns TRUE when the given custom id is valid.
+     */
+    static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,
+        int32_t& min, int32_t& sec);
+
+    /**
+     * Parse a custom time zone identifier and return the normalized
+     * custom time zone identifier for the given custom id string.
+     * @param id a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or
+     * GMT[+-]hh.
+     * @param normalized Receives the normalized custom ID
+     * @param status Receives the status.  When the input ID string is invalid,
+     * U_ILLEGAL_ARGUMENT_ERROR is set.
+     * @return The normalized custom id string.
+    */
+    static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized,
+        UErrorCode& status);
+
+    /**
+     * Returns the normalized custome timezone ID for the given offset fields.
+     * @param hour offset hours
+     * @param min offset minutes
+     * @param sec offset seconds
+     * @param netative sign of the offset, TRUE for negative offset.
+     * @param id Receves the format result (normalized custom ID)
+     * @return The reference to id
+     */
+    static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec,
+        UBool negative, UnicodeString& id);
+
+    /**
+     * Responsible for setting up DEFAULT_ZONE.  Uses routines in TPlatformUtilities
+     * (i.e., platform-specific calls) to get the current system time zone.  Failing
+     * that, uses the platform-specific default time zone.  Failing that, uses GMT.
+     */
+    static void             initDefault(void);
+
+    // See source file for documentation
+    /**
+     * Lookup the given name in our system zone table.  If found,
+     * instantiate a new zone of that name and return it.  If not
+     * found, return 0.
+     * @param name tthe given name of a system time zone.
+     * @return the timezone indicated by the 'name'.
+     */
+    static TimeZone*        createSystemTimeZone(const UnicodeString& name);
+
+    UnicodeString           fID;    // this time zone's ID
+};
+
+
+// -------------------------------------
+
+inline UnicodeString&
+TimeZone::getID(UnicodeString& ID) const
+{
+    ID = fID;
+    return ID;
+}
+
+// -------------------------------------
+
+inline void
+TimeZone::setID(const UnicodeString& ID)
+{
+    fID = ID;
+}
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif //_TIMEZONE
+//eof
diff --git a/CoreFoundation/icu/unicode/translit.h b/CoreFoundation/icu/unicode/translit.h
new file mode 100644
index 0000000..bfff344
--- /dev/null
+++ b/CoreFoundation/icu/unicode/translit.h
@@ -0,0 +1,1323 @@
+/*
+**********************************************************************
+* Copyright (C) 1999-2008, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+*   Date        Name        Description
+*   11/17/99    aliu        Creation.
+**********************************************************************
+*/
+#ifndef TRANSLIT_H
+#define TRANSLIT_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Tranforms text from one format to another.
+ */
+ 
+#if !UCONFIG_NO_TRANSLITERATION
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/parseerr.h"
+#include "unicode/utrans.h" // UTransPosition, UTransDirection
+#include "unicode/strenum.h"
+
+U_NAMESPACE_BEGIN
+
+class UnicodeFilter;
+class UnicodeSet;
+class CompoundTransliterator;
+class TransliteratorParser;
+class NormalizationTransliterator;
+class TransliteratorIDParser;
+
+/**
+ *
+ * <code>Transliterator</code> is an abstract class that
+ * transliterates text from one format to another.  The most common
+ * kind of transliterator is a script, or alphabet, transliterator.
+ * For example, a Russian to Latin transliterator changes Russian text
+ * written in Cyrillic characters to phonetically equivalent Latin
+ * characters.  It does not <em>translate</em> Russian to English!
+ * Transliteration, unlike translation, operates on characters, without
+ * reference to the meanings of words and sentences.
+ *
+ * <p>Although script conversion is its most common use, a
+ * transliterator can actually perform a more general class of tasks.
+ * In fact, <code>Transliterator</code> defines a very general API
+ * which specifies only that a segment of the input text is replaced
+ * by new text.  The particulars of this conversion are determined
+ * entirely by subclasses of <code>Transliterator</code>.
+ *
+ * <p><b>Transliterators are stateless</b>
+ *
+ * <p><code>Transliterator</code> objects are <em>stateless</em>; they
+ * retain no information between calls to
+ * <code>transliterate()</code>.  (However, this does <em>not</em>
+ * mean that threads may share transliterators without synchronizing
+ * them.  Transliterators are not immutable, so they must be
+ * synchronized when shared between threads.)  This might seem to
+ * limit the complexity of the transliteration operation.  In
+ * practice, subclasses perform complex transliterations by delaying
+ * the replacement of text until it is known that no other
+ * replacements are possible.  In other words, although the
+ * <code>Transliterator</code> objects are stateless, the source text
+ * itself embodies all the needed information, and delayed operation
+ * allows arbitrary complexity.
+ *
+ * <p><b>Batch transliteration</b>
+ *
+ * <p>The simplest way to perform transliteration is all at once, on a
+ * string of existing text.  This is referred to as <em>batch</em>
+ * transliteration.  For example, given a string <code>input</code>
+ * and a transliterator <code>t</code>, the call
+ *
+ * \htmlonly<blockquote>\endhtmlonly<code>String result = t.transliterate(input);
+ * </code>\htmlonly</blockquote>\endhtmlonly
+ *
+ * will transliterate it and return the result.  Other methods allow
+ * the client to specify a substring to be transliterated and to use
+ * {@link Replaceable } objects instead of strings, in order to
+ * preserve out-of-band information (such as text styles).
+ *
+ * <p><b>Keyboard transliteration</b>
+ *
+ * <p>Somewhat more involved is <em>keyboard</em>, or incremental
+ * transliteration.  This is the transliteration of text that is
+ * arriving from some source (typically the user's keyboard) one
+ * character at a time, or in some other piecemeal fashion.
+ *
+ * <p>In keyboard transliteration, a <code>Replaceable</code> buffer
+ * stores the text.  As text is inserted, as much as possible is
+ * transliterated on the fly.  This means a GUI that displays the
+ * contents of the buffer may show text being modified as each new
+ * character arrives.
+ *
+ * <p>Consider the simple <code>RuleBasedTransliterator</code>:
+ *
+ * \htmlonly<blockquote>\endhtmlonly<code>
+ * th&gt;{theta}<br>
+ * t&gt;{tau}
+ * </code>\htmlonly</blockquote>\endhtmlonly
+ *
+ * When the user types 't', nothing will happen, since the
+ * transliterator is waiting to see if the next character is 'h'.  To
+ * remedy this, we introduce the notion of a cursor, marked by a '|'
+ * in the output string:
+ *
+ * \htmlonly<blockquote>\endhtmlonly<code>
+ * t&gt;|{tau}<br>
+ * {tau}h&gt;{theta}
+ * </code>\htmlonly</blockquote>\endhtmlonly
+ *
+ * Now when the user types 't', tau appears, and if the next character
+ * is 'h', the tau changes to a theta.  This is accomplished by
+ * maintaining a cursor position (independent of the insertion point,
+ * and invisible in the GUI) across calls to
+ * <code>transliterate()</code>.  Typically, the cursor will
+ * be coincident with the insertion point, but in a case like the one
+ * above, it will precede the insertion point.
+ *
+ * <p>Keyboard transliteration methods maintain a set of three indices
+ * that are updated with each call to
+ * <code>transliterate()</code>, including the cursor, start,
+ * and limit.  Since these indices are changed by the method, they are
+ * passed in an <code>int[]</code> array. The <code>START</code> index
+ * marks the beginning of the substring that the transliterator will
+ * look at.  It is advanced as text becomes committed (but it is not
+ * the committed index; that's the <code>CURSOR</code>).  The
+ * <code>CURSOR</code> index, described above, marks the point at
+ * which the transliterator last stopped, either because it reached
+ * the end, or because it required more characters to disambiguate
+ * between possible inputs.  The <code>CURSOR</code> can also be
+ * explicitly set by rules in a <code>RuleBasedTransliterator</code>.
+ * Any characters before the <code>CURSOR</code> index are frozen;
+ * future keyboard transliteration calls within this input sequence
+ * will not change them.  New text is inserted at the
+ * <code>LIMIT</code> index, which marks the end of the substring that
+ * the transliterator looks at.
+ *
+ * <p>Because keyboard transliteration assumes that more characters
+ * are to arrive, it is conservative in its operation.  It only
+ * transliterates when it can do so unambiguously.  Otherwise it waits
+ * for more characters to arrive.  When the client code knows that no
+ * more characters are forthcoming, perhaps because the user has
+ * performed some input termination operation, then it should call
+ * <code>finishTransliteration()</code> to complete any
+ * pending transliterations.
+ *
+ * <p><b>Inverses</b>
+ *
+ * <p>Pairs of transliterators may be inverses of one another.  For
+ * example, if transliterator <b>A</b> transliterates characters by
+ * incrementing their Unicode value (so "abc" -> "def"), and
+ * transliterator <b>B</b> decrements character values, then <b>A</b>
+ * is an inverse of <b>B</b> and vice versa.  If we compose <b>A</b>
+ * with <b>B</b> in a compound transliterator, the result is the
+ * indentity transliterator, that is, a transliterator that does not
+ * change its input text.
+ *
+ * The <code>Transliterator</code> method <code>getInverse()</code>
+ * returns a transliterator's inverse, if one exists, or
+ * <code>null</code> otherwise.  However, the result of
+ * <code>getInverse()</code> usually will <em>not</em> be a true
+ * mathematical inverse.  This is because true inverse transliterators
+ * are difficult to formulate.  For example, consider two
+ * transliterators: <b>AB</b>, which transliterates the character 'A'
+ * to 'B', and <b>BA</b>, which transliterates 'B' to 'A'.  It might
+ * seem that these are exact inverses, since
+ *
+ * \htmlonly<blockquote>\endhtmlonly"A" x <b>AB</b> -> "B"<br>
+ * "B" x <b>BA</b> -> "A"\htmlonly</blockquote>\endhtmlonly
+ *
+ * where 'x' represents transliteration.  However,
+ *
+ * \htmlonly<blockquote>\endhtmlonly"ABCD" x <b>AB</b> -> "BBCD"<br>
+ * "BBCD" x <b>BA</b> -> "AACD"\htmlonly</blockquote>\endhtmlonly
+ *
+ * so <b>AB</b> composed with <b>BA</b> is not the
+ * identity. Nonetheless, <b>BA</b> may be usefully considered to be
+ * <b>AB</b>'s inverse, and it is on this basis that
+ * <b>AB</b><code>.getInverse()</code> could legitimately return
+ * <b>BA</b>.
+ *
+ * <p><b>IDs and display names</b>
+ *
+ * <p>A transliterator is designated by a short identifier string or
+ * <em>ID</em>.  IDs follow the format <em>source-destination</em>,
+ * where <em>source</em> describes the entity being replaced, and
+ * <em>destination</em> describes the entity replacing
+ * <em>source</em>.  The entities may be the names of scripts,
+ * particular sequences of characters, or whatever else it is that the
+ * transliterator converts to or from.  For example, a transliterator
+ * from Russian to Latin might be named "Russian-Latin".  A
+ * transliterator from keyboard escape sequences to Latin-1 characters
+ * might be named "KeyboardEscape-Latin1".  By convention, system
+ * entity names are in English, with the initial letters of words
+ * capitalized; user entity names may follow any format so long as
+ * they do not contain dashes.
+ *
+ * <p>In addition to programmatic IDs, transliterator objects have
+ * display names for presentation in user interfaces, returned by
+ * {@link #getDisplayName }.
+ *
+ * <p><b>Factory methods and registration</b>
+ *
+ * <p>In general, client code should use the factory method
+ * {@link #createInstance } to obtain an instance of a
+ * transliterator given its ID.  Valid IDs may be enumerated using
+ * <code>getAvailableIDs()</code>.  Since transliterators are mutable,
+ * multiple calls to {@link #createInstance } with the same ID will
+ * return distinct objects.
+ *
+ * <p>In addition to the system transliterators registered at startup,
+ * user transliterators may be registered by calling
+ * <code>registerInstance()</code> at run time.  A registered instance
+ * acts a template; future calls to {@link #createInstance } with the ID
+ * of the registered object return clones of that object.  Thus any
+ * object passed to <tt>registerInstance()</tt> must implement
+ * <tt>clone()</tt> propertly.  To register a transliterator subclass
+ * without instantiating it (until it is needed), users may call
+ * {@link #registerFactory }.  In this case, the objects are
+ * instantiated by invoking the zero-argument public constructor of
+ * the class.
+ *
+ * <p><b>Subclassing</b>
+ *
+ * Subclasses must implement the abstract method
+ * <code>handleTransliterate()</code>.  <p>Subclasses should override
+ * the <code>transliterate()</code> method taking a
+ * <code>Replaceable</code> and the <code>transliterate()</code>
+ * method taking a <code>String</code> and <code>StringBuffer</code>
+ * if the performance of these methods can be improved over the
+ * performance obtained by the default implementations in this class.
+ *
+ * @author Alan Liu
+ * @stable ICU 2.0
+ */
+class U_I18N_API Transliterator : public UObject {
+
+private:
+
+    /**
+     * Programmatic name, e.g., "Latin-Arabic".
+     */
+    UnicodeString ID;
+
+    /**
+     * This transliterator's filter.  Any character for which
+     * <tt>filter.contains()</tt> returns <tt>false</tt> will not be
+     * altered by this transliterator.  If <tt>filter</tt> is
+     * <tt>null</tt> then no filtering is applied.
+     */
+    UnicodeFilter* filter;
+
+    int32_t maximumContextLength;
+
+ public:
+
+    /**
+     * A context integer or pointer for a factory function, passed by
+     * value.
+     * @stable ICU 2.4
+     */
+    union Token {
+        /**
+         * This token, interpreted as a 32-bit integer.
+         * @stable ICU 2.4
+         */
+        int32_t integer;
+        /**
+         * This token, interpreted as a native pointer.
+         * @stable ICU 2.4
+         */
+        void*   pointer;
+    };
+
+    /**
+     * Return a token containing an integer.
+     * @return a token containing an integer.
+     * @internal
+     */
+    inline static Token integerToken(int32_t);
+
+    /**
+     * Return a token containing a pointer.
+     * @return a token containing a pointer.
+     * @internal
+     */
+    inline static Token pointerToken(void*);
+
+    /**
+     * A function that creates and returns a Transliterator.  When
+     * invoked, it will be passed the ID string that is being
+     * instantiated, together with the context pointer that was passed
+     * in when the factory function was first registered.  Many
+     * factory functions will ignore both parameters, however,
+     * functions that are registered to more than one ID may use the
+     * ID or the context parameter to parameterize the transliterator
+     * they create.
+     * @param ID      the string identifier for this transliterator
+     * @param context a context pointer that will be stored and
+     *                later passed to the factory function when an ID matching
+     *                the registration ID is being instantiated with this factory.
+     * @stable ICU 2.4
+     */
+    typedef Transliterator* (U_EXPORT2 *Factory)(const UnicodeString& ID, Token context);
+
+protected:
+
+    /**
+     * Default constructor.
+     * @param ID the string identifier for this transliterator
+     * @param adoptedFilter the filter.  Any character for which
+     * <tt>filter.contains()</tt> returns <tt>false</tt> will not be
+     * altered by this transliterator.  If <tt>filter</tt> is
+     * <tt>null</tt> then no filtering is applied.
+     * @stable ICU 2.4
+     */
+    Transliterator(const UnicodeString& ID, UnicodeFilter* adoptedFilter);
+
+    /**
+     * Copy constructor.
+     * @stable ICU 2.4
+     */
+    Transliterator(const Transliterator&);
+
+    /**
+     * Assignment operator.
+     * @stable ICU 2.4
+     */
+    Transliterator& operator=(const Transliterator&);
+
+    /**
+     * Create a transliterator from a basic ID.  This is an ID
+     * containing only the forward direction source, target, and
+     * variant.
+     * @param id a basic ID of the form S-T or S-T/V.
+     * @param canon canonical ID to assign to the object, or
+     * NULL to leave the ID unchanged
+     * @return a newly created Transliterator or null if the ID is
+     * invalid.
+     * @stable ICU 2.4
+     */
+    static Transliterator* createBasicInstance(const UnicodeString& id,
+                                               const UnicodeString* canon);
+
+    friend class TransliteratorParser; // for parseID()
+    friend class TransliteratorIDParser; // for createBasicInstance()
+    friend class TransliteratorAlias; // for setID()
+
+public:
+
+    /**
+     * Destructor.
+     * @stable ICU 2.0
+     */
+    virtual ~Transliterator();
+
+    /**
+     * Implements Cloneable.
+     * All subclasses are encouraged to implement this method if it is
+     * possible and reasonable to do so.  Subclasses that are to be
+     * registered with the system using <tt>registerInstance()</tt>
+     * are required to implement this method.  If a subclass does not
+     * implement clone() properly and is registered with the system
+     * using registerInstance(), then the default clone() implementation
+     * will return null, and calls to createInstance() will fail.
+     *
+     * @return a copy of the object.
+     * @see #registerInstance
+     * @stable ICU 2.0
+     */
+    virtual Transliterator* clone() const;
+
+    /**
+     * Transliterates a segment of a string, with optional filtering.
+     *
+     * @param text the string to be transliterated
+     * @param start the beginning index, inclusive; <code>0 <= start
+     * <= limit</code>.
+     * @param limit the ending index, exclusive; <code>start <= limit
+     * <= text.length()</code>.
+     * @return The new limit index.  The text previously occupying <code>[start,
+     * limit)</code> has been transliterated, possibly to a string of a different
+     * length, at <code>[start, </code><em>new-limit</em><code>)</code>, where
+     * <em>new-limit</em> is the return value. If the input offsets are out of bounds,
+     * the returned value is -1 and the input string remains unchanged.
+     * @stable ICU 2.0
+     */
+    virtual int32_t transliterate(Replaceable& text,
+                                  int32_t start, int32_t limit) const;
+
+    /**
+     * Transliterates an entire string in place. Convenience method.
+     * @param text the string to be transliterated
+     * @stable ICU 2.0
+     */
+    virtual void transliterate(Replaceable& text) const;
+
+    /**
+     * Transliterates the portion of the text buffer that can be
+     * transliterated unambiguosly after new text has been inserted,
+     * typically as a result of a keyboard event.  The new text in
+     * <code>insertion</code> will be inserted into <code>text</code>
+     * at <code>index.limit</code>, advancing
+     * <code>index.limit</code> by <code>insertion.length()</code>.
+     * Then the transliterator will try to transliterate characters of
+     * <code>text</code> between <code>index.cursor</code> and
+     * <code>index.limit</code>.  Characters before
+     * <code>index.cursor</code> will not be changed.
+     *
+     * <p>Upon return, values in <code>index</code> will be updated.
+     * <code>index.start</code> will be advanced to the first
+     * character that future calls to this method will read.
+     * <code>index.cursor</code> and <code>index.limit</code> will
+     * be adjusted to delimit the range of text that future calls to
+     * this method may change.
+     *
+     * <p>Typical usage of this method begins with an initial call
+     * with <code>index.start</code> and <code>index.limit</code>
+     * set to indicate the portion of <code>text</code> to be
+     * transliterated, and <code>index.cursor == index.start</code>.
+     * Thereafter, <code>index</code> can be used without
+     * modification in future calls, provided that all changes to
+     * <code>text</code> are made via this method.
+     *
+     * <p>This method assumes that future calls may be made that will
+     * insert new text into the buffer.  As a result, it only performs
+     * unambiguous transliterations.  After the last call to this
+     * method, there may be untransliterated text that is waiting for
+     * more input to resolve an ambiguity.  In order to perform these
+     * pending transliterations, clients should call {@link
+     * #finishTransliteration } after the last call to this
+     * method has been made.
+     *
+     * @param text the buffer holding transliterated and untransliterated text
+     * @param index an array of three integers.
+     *
+     * <ul><li><code>index.start</code>: the beginning index,
+     * inclusive; <code>0 <= index.start <= index.limit</code>.
+     *
+     * <li><code>index.limit</code>: the ending index, exclusive;
+     * <code>index.start <= index.limit <= text.length()</code>.
+     * <code>insertion</code> is inserted at
+     * <code>index.limit</code>.
+     *
+     * <li><code>index.cursor</code>: the next character to be
+     * considered for transliteration; <code>index.start <=
+     * index.cursor <= index.limit</code>.  Characters before
+     * <code>index.cursor</code> will not be changed by future calls
+     * to this method.</ul>
+     *
+     * @param insertion text to be inserted and possibly
+     * transliterated into the translation buffer at
+     * <code>index.limit</code>.  If <code>null</code> then no text
+     * is inserted.
+     * @param status    Output param to filled in with a success or an error.
+     * @see #handleTransliterate
+     * @exception IllegalArgumentException if <code>index</code>
+     * is invalid
+     * @see UTransPosition
+     * @stable ICU 2.0
+     */
+    virtual void transliterate(Replaceable& text, UTransPosition& index,
+                               const UnicodeString& insertion,
+                               UErrorCode& status) const;
+
+    /**
+     * Transliterates the portion of the text buffer that can be
+     * transliterated unambiguosly after a new character has been
+     * inserted, typically as a result of a keyboard event.  This is a
+     * convenience method; see {@link
+     * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const}
+     * for details.
+     * @param text the buffer holding transliterated and
+     * untransliterated text
+     * @param index an array of three integers.  See {@link
+     * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const }.
+     * @param insertion text to be inserted and possibly
+     * transliterated into the translation buffer at
+     * <code>index.limit</code>.
+     * @param status    Output param to filled in with a success or an error.
+     * @see #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const
+     * @stable ICU 2.0
+     */
+    virtual void transliterate(Replaceable& text, UTransPosition& index,
+                               UChar32 insertion,
+                               UErrorCode& status) const;
+
+    /**
+     * Transliterates the portion of the text buffer that can be
+     * transliterated unambiguosly.  This is a convenience method; see
+     * {@link
+     * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const }
+     * for details.
+     * @param text the buffer holding transliterated and
+     * untransliterated text
+     * @param index an array of three integers.  See {@link
+     * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const }.
+     * @param status    Output param to filled in with a success or an error.
+     * @see #transliterate(Replaceable, int[], String)
+     * @stable ICU 2.0
+     */
+    virtual void transliterate(Replaceable& text, UTransPosition& index,
+                               UErrorCode& status) const;
+
+    /**
+     * Finishes any pending transliterations that were waiting for
+     * more characters.  Clients should call this method as the last
+     * call after a sequence of one or more calls to
+     * <code>transliterate()</code>.
+     * @param text the buffer holding transliterated and
+     * untransliterated text.
+     * @param index the array of indices previously passed to {@link
+     * #transliterate }
+     * @stable ICU 2.0
+     */
+    virtual void finishTransliteration(Replaceable& text,
+                                       UTransPosition& index) const;
+
+private:
+
+    /**
+     * This internal method does incremental transliteration.  If the
+     * 'insertion' is non-null then we append it to 'text' before
+     * proceeding.  This method calls through to the pure virtual
+     * framework method handleTransliterate() to do the actual
+     * work.
+     * @param text the buffer holding transliterated and
+     * untransliterated text
+     * @param index an array of three integers.  See {@link
+     * #transliterate(Replaceable, int[], String)}.
+     * @param insertion text to be inserted and possibly
+     * transliterated into the translation buffer at
+     * <code>index.limit</code>.
+     * @param status    Output param to filled in with a success or an error.
+     */
+    void _transliterate(Replaceable& text,
+                        UTransPosition& index,
+                        const UnicodeString* insertion,
+                        UErrorCode &status) const;
+
+protected:
+
+    /**
+     * Abstract method that concrete subclasses define to implement
+     * their transliteration algorithm.  This method handles both
+     * incremental and non-incremental transliteration.  Let
+     * <code>originalStart</code> refer to the value of
+     * <code>pos.start</code> upon entry.
+     *
+     * <ul>
+     *  <li>If <code>incremental</code> is false, then this method
+     *  should transliterate all characters between
+     *  <code>pos.start</code> and <code>pos.limit</code>. Upon return
+     *  <code>pos.start</code> must == <code> pos.limit</code>.</li>
+     *
+     *  <li>If <code>incremental</code> is true, then this method
+     *  should transliterate all characters between
+     *  <code>pos.start</code> and <code>pos.limit</code> that can be
+     *  unambiguously transliterated, regardless of future insertions
+     *  of text at <code>pos.limit</code>.  Upon return,
+     *  <code>pos.start</code> should be in the range
+     *  [<code>originalStart</code>, <code>pos.limit</code>).
+     *  <code>pos.start</code> should be positioned such that
+     *  characters [<code>originalStart</code>, <code>
+     *  pos.start</code>) will not be changed in the future by this
+     *  transliterator and characters [<code>pos.start</code>,
+     *  <code>pos.limit</code>) are unchanged.</li>
+     * </ul>
+     *
+     * <p>Implementations of this method should also obey the
+     * following invariants:</p>
+     *
+     * <ul>
+     *  <li> <code>pos.limit</code> and <code>pos.contextLimit</code>
+     *  should be updated to reflect changes in length of the text
+     *  between <code>pos.start</code> and <code>pos.limit</code>. The
+     *  difference <code> pos.contextLimit - pos.limit</code> should
+     *  not change.</li>
+     *
+     *  <li><code>pos.contextStart</code> should not change.</li>
+     *
+     *  <li>Upon return, neither <code>pos.start</code> nor
+     *  <code>pos.limit</code> should be less than
+     *  <code>originalStart</code>.</li>
+     *
+     *  <li>Text before <code>originalStart</code> and text after
+     *  <code>pos.limit</code> should not change.</li>
+     *
+     *  <li>Text before <code>pos.contextStart</code> and text after
+     *  <code> pos.contextLimit</code> should be ignored.</li>
+     * </ul>
+     *
+     * <p>Subclasses may safely assume that all characters in
+     * [<code>pos.start</code>, <code>pos.limit</code>) are filtered.
+     * In other words, the filter has already been applied by the time
+     * this method is called.  See
+     * <code>filteredTransliterate()</code>.
+     *
+     * <p>This method is <b>not</b> for public consumption.  Calling
+     * this method directly will transliterate
+     * [<code>pos.start</code>, <code>pos.limit</code>) without
+     * applying the filter. End user code should call <code>
+     * transliterate()</code> instead of this method. Subclass code
+     * and wrapping transliterators should call
+     * <code>filteredTransliterate()</code> instead of this method.<p>
+     *
+     * @param text the buffer holding transliterated and
+     * untransliterated text
+     *
+     * @param pos the indices indicating the start, limit, context
+     * start, and context limit of the text.
+     *
+     * @param incremental if true, assume more text may be inserted at
+     * <code>pos.limit</code> and act accordingly.  Otherwise,
+     * transliterate all text between <code>pos.start</code> and
+     * <code>pos.limit</code> and move <code>pos.start</code> up to
+     * <code>pos.limit</code>.
+     *
+     * @see #transliterate
+     * @stable ICU 2.4
+     */
+    virtual void handleTransliterate(Replaceable& text,
+                                     UTransPosition& pos,
+                                     UBool incremental) const = 0;
+
+public:
+    /**
+     * Transliterate a substring of text, as specified by index, taking filters
+     * into account.  This method is for subclasses that need to delegate to
+     * another transliterator, such as CompoundTransliterator.
+     * @param text the text to be transliterated
+     * @param index the position indices
+     * @param incremental if TRUE, then assume more characters may be inserted
+     * at index.limit, and postpone processing to accomodate future incoming
+     * characters
+     * @stable ICU 2.4
+     */
+    virtual void filteredTransliterate(Replaceable& text,
+                                       UTransPosition& index,
+                                       UBool incremental) const;
+
+private:
+
+    /**
+     * Top-level transliteration method, handling filtering, incremental and
+     * non-incremental transliteration, and rollback.  All transliteration
+     * public API methods eventually call this method with a rollback argument
+     * of TRUE.  Other entities may call this method but rollback should be
+     * FALSE.
+     *
+     * <p>If this transliterator has a filter, break up the input text into runs
+     * of unfiltered characters.  Pass each run to
+     * <subclass>.handleTransliterate().
+     *
+     * <p>In incremental mode, if rollback is TRUE, perform a special
+     * incremental procedure in which several passes are made over the input
+     * text, adding one character at a time, and committing successful
+     * transliterations as they occur.  Unsuccessful transliterations are rolled
+     * back and retried with additional characters to give correct results.
+     *
+     * @param text the text to be transliterated
+     * @param index the position indices
+     * @param incremental if TRUE, then assume more characters may be inserted
+     * at index.limit, and postpone processing to accomodate future incoming
+     * characters
+     * @param rollback if TRUE and if incremental is TRUE, then perform special
+     * incremental processing, as described above, and undo partial
+     * transliterations where necessary.  If incremental is FALSE then this
+     * parameter is ignored.
+     */
+    virtual void filteredTransliterate(Replaceable& text,
+                                       UTransPosition& index,
+                                       UBool incremental,
+                                       UBool rollback) const;
+
+public:
+
+    /**
+     * Returns the length of the longest context required by this transliterator.
+     * This is <em>preceding</em> context.  The default implementation supplied
+     * by <code>Transliterator</code> returns zero; subclasses
+     * that use preceding context should override this method to return the
+     * correct value.  For example, if a transliterator translates "ddd" (where
+     * d is any digit) to "555" when preceded by "(ddd)", then the preceding
+     * context length is 5, the length of "(ddd)".
+     *
+     * @return The maximum number of preceding context characters this
+     * transliterator needs to examine
+     * @stable ICU 2.0
+     */
+    int32_t getMaximumContextLength(void) const;
+
+protected:
+
+    /**
+     * Method for subclasses to use to set the maximum context length.
+     * @param maxContextLength the new value to be set.
+     * @see #getMaximumContextLength
+     * @stable ICU 2.4
+     */
+    void setMaximumContextLength(int32_t maxContextLength);
+
+public:
+
+    /**
+     * Returns a programmatic identifier for this transliterator.
+     * If this identifier is passed to <code>createInstance()</code>, it
+     * will return this object, if it has been registered.
+     * @return a programmatic identifier for this transliterator.
+     * @see #registerInstance
+     * @see #registerFactory
+     * @see #getAvailableIDs
+     * @stable ICU 2.0
+     */
+    virtual const UnicodeString& getID(void) const;
+
+    /**
+     * Returns a name for this transliterator that is appropriate for
+     * display to the user in the default locale.  See {@link
+     * #getDisplayName } for details.
+     * @param ID     the string identifier for this transliterator
+     * @param result Output param to receive the display name
+     * @return       A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const UnicodeString& ID,
+                                         UnicodeString& result);
+
+    /**
+     * Returns a name for this transliterator that is appropriate for
+     * display to the user in the given locale.  This name is taken
+     * from the locale resource data in the standard manner of the
+     * <code>java.text</code> package.
+     *
+     * <p>If no localized names exist in the system resource bundles,
+     * a name is synthesized using a localized
+     * <code>MessageFormat</code> pattern from the resource data.  The
+     * arguments to this pattern are an integer followed by one or two
+     * strings.  The integer is the number of strings, either 1 or 2.
+     * The strings are formed by splitting the ID for this
+     * transliterator at the first '-'.  If there is no '-', then the
+     * entire ID forms the only string.
+     * @param ID       the string identifier for this transliterator
+     * @param inLocale the Locale in which the display name should be
+     *                 localized.
+     * @param result   Output param to receive the display name
+     * @return         A reference to 'result'.
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getDisplayName(const UnicodeString& ID,
+                                         const Locale& inLocale,
+                                         UnicodeString& result);
+
+    /**
+     * Returns the filter used by this transliterator, or <tt>NULL</tt>
+     * if this transliterator uses no filter.
+     * @return the filter used by this transliterator, or <tt>NULL</tt>
+     *         if this transliterator uses no filter.
+     * @stable ICU 2.0
+     */
+    const UnicodeFilter* getFilter(void) const;
+
+    /**
+     * Returns the filter used by this transliterator, or <tt>NULL</tt> if this
+     * transliterator uses no filter.  The caller must eventually delete the
+     * result.  After this call, this transliterator's filter is set to
+     * <tt>NULL</tt>.
+     * @return the filter used by this transliterator, or <tt>NULL</tt> if this
+     *         transliterator uses no filter.
+     * @stable ICU 2.4
+     */
+    UnicodeFilter* orphanFilter(void);
+
+    /**
+     * Changes the filter used by this transliterator.  If the filter
+     * is set to <tt>null</tt> then no filtering will occur.
+     *
+     * <p>Callers must take care if a transliterator is in use by
+     * multiple threads.  The filter should not be changed by one
+     * thread while another thread may be transliterating.
+     * @param adoptedFilter the new filter to be adopted.
+     * @stable ICU 2.0
+     */
+    void adoptFilter(UnicodeFilter* adoptedFilter);
+
+    /**
+     * Returns this transliterator's inverse.  See the class
+     * documentation for details.  This implementation simply inverts
+     * the two entities in the ID and attempts to retrieve the
+     * resulting transliterator.  That is, if <code>getID()</code>
+     * returns "A-B", then this method will return the result of
+     * <code>createInstance("B-A")</code>, or <code>null</code> if that
+     * call fails.
+     *
+     * <p>Subclasses with knowledge of their inverse may wish to
+     * override this method.
+     *
+     * @param status Output param to filled in with a success or an error.
+     * @return a transliterator that is an inverse, not necessarily
+     * exact, of this transliterator, or <code>null</code> if no such
+     * transliterator is registered.
+     * @see #registerInstance
+     * @stable ICU 2.0
+     */
+    Transliterator* createInverse(UErrorCode& status) const;
+
+    /**
+     * Returns a <code>Transliterator</code> object given its ID.
+     * The ID must be either a system transliterator ID or a ID registered
+     * using <code>registerInstance()</code>.
+     *
+     * @param ID a valid ID, as enumerated by <code>getAvailableIDs()</code>
+     * @param dir        either FORWARD or REVERSE.
+     * @param parseError Struct to recieve information on position
+     *                   of error if an error is encountered
+     * @param status     Output param to filled in with a success or an error.
+     * @return A <code>Transliterator</code> object with the given ID
+     * @see #registerInstance
+     * @see #getAvailableIDs
+     * @see #getID
+     * @stable ICU 2.0
+     */
+    static Transliterator* U_EXPORT2 createInstance(const UnicodeString& ID,
+                                          UTransDirection dir,
+                                          UParseError& parseError,
+                                          UErrorCode& status);
+
+    /**
+     * Returns a <code>Transliterator</code> object given its ID.
+     * The ID must be either a system transliterator ID or a ID registered
+     * using <code>registerInstance()</code>.
+     * @param ID a valid ID, as enumerated by <code>getAvailableIDs()</code>
+     * @param dir        either FORWARD or REVERSE.
+     * @param status     Output param to filled in with a success or an error.
+     * @return A <code>Transliterator</code> object with the given ID
+     * @stable ICU 2.0
+     */
+    static Transliterator* U_EXPORT2 createInstance(const UnicodeString& ID,
+                                          UTransDirection dir,
+                                          UErrorCode& status);
+
+    /**
+     * Returns a <code>Transliterator</code> object constructed from
+     * the given rule string.  This will be a RuleBasedTransliterator,
+     * if the rule string contains only rules, or a
+     * CompoundTransliterator, if it contains ID blocks, or a
+     * NullTransliterator, if it contains ID blocks which parse as
+     * empty for the given direction.
+     * @param ID            the id for the transliterator.
+     * @param rules         rules, separated by ';'
+     * @param dir           either FORWARD or REVERSE.
+     * @param parseError    Struct to recieve information on position
+     *                      of error if an error is encountered
+     * @param status        Output param set to success/failure code.
+     * @stable ICU 2.0
+     */
+    static Transliterator* U_EXPORT2 createFromRules(const UnicodeString& ID,
+                                           const UnicodeString& rules,
+                                           UTransDirection dir,
+                                           UParseError& parseError,
+                                           UErrorCode& status);
+
+    /**
+     * Create a rule string that can be passed to createFromRules()
+     * to recreate this transliterator.
+     * @param result the string to receive the rules.  Previous
+     * contents will be deleted.
+     * @param escapeUnprintable if TRUE then convert unprintable
+     * character to their hex escape representations, \\uxxxx or
+     * \\Uxxxxxxxx.  Unprintable characters are those other than
+     * U+000A, U+0020..U+007E.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toRules(UnicodeString& result,
+                                   UBool escapeUnprintable) const;
+
+    /**
+     * Return the number of elements that make up this transliterator.
+     * For example, if the transliterator "NFD;Jamo-Latin;Latin-Greek"
+     * were created, the return value of this method would be 3.
+     *
+     * <p>If this transliterator is not composed of other
+     * transliterators, then this method returns 1.
+     * @return the number of transliterators that compose this
+     * transliterator, or 1 if this transliterator is not composed of
+     * multiple transliterators
+     * @stable ICU 3.0
+     */
+    int32_t countElements() const;
+
+    /**
+     * Return an element that makes up this transliterator.  For
+     * example, if the transliterator "NFD;Jamo-Latin;Latin-Greek"
+     * were created, the return value of this method would be one
+     * of the three transliterator objects that make up that
+     * transliterator: [NFD, Jamo-Latin, Latin-Greek].
+     *
+     * <p>If this transliterator is not composed of other
+     * transliterators, then this method will return a reference to
+     * this transliterator when given the index 0.
+     * @param index a value from 0..countElements()-1 indicating the
+     * transliterator to return
+     * @param ec input-output error code
+     * @return one of the transliterators that makes up this
+     * transliterator, if this transliterator is made up of multiple
+     * transliterators, otherwise a reference to this object if given
+     * an index of 0
+     * @stable ICU 3.0
+     */
+    const Transliterator& getElement(int32_t index, UErrorCode& ec) const;
+
+    /**
+     * Returns the set of all characters that may be modified in the
+     * input text by this Transliterator.  This incorporates this
+     * object's current filter; if the filter is changed, the return
+     * value of this function will change.  The default implementation
+     * returns an empty set.  Some subclasses may override {@link
+     * #handleGetSourceSet } to return a more precise result.  The
+     * return result is approximate in any case and is intended for
+     * use by tests, tools, or utilities.
+     * @param result receives result set; previous contents lost
+     * @return a reference to result
+     * @see #getTargetSet
+     * @see #handleGetSourceSet
+     * @stable ICU 2.4
+     */
+    UnicodeSet& getSourceSet(UnicodeSet& result) const;
+
+    /**
+     * Framework method that returns the set of all characters that
+     * may be modified in the input text by this Transliterator,
+     * ignoring the effect of this object's filter.  The base class
+     * implementation returns the empty set.  Subclasses that wish to
+     * implement this should override this method.
+     * @return the set of characters that this transliterator may
+     * modify.  The set may be modified, so subclasses should return a
+     * newly-created object.
+     * @param result receives result set; previous contents lost
+     * @see #getSourceSet
+     * @see #getTargetSet
+     * @stable ICU 2.4
+     */
+    virtual void handleGetSourceSet(UnicodeSet& result) const;
+
+    /**
+     * Returns the set of all characters that may be generated as
+     * replacement text by this transliterator.  The default
+     * implementation returns the empty set.  Some subclasses may
+     * override this method to return a more precise result.  The
+     * return result is approximate in any case and is intended for
+     * use by tests, tools, or utilities requiring such
+     * meta-information.
+     * @param result receives result set; previous contents lost
+     * @return a reference to result
+     * @see #getTargetSet
+     * @stable ICU 2.4
+     */
+    virtual UnicodeSet& getTargetSet(UnicodeSet& result) const;
+
+public:
+
+    /**
+     * Registers a factory function that creates transliterators of
+     * a given ID.
+     * @param id the ID being registered
+     * @param factory a function pointer that will be copied and
+     * called later when the given ID is passed to createInstance()
+     * @param context a context pointer that will be stored and
+     * later passed to the factory function when an ID matching
+     * the registration ID is being instantiated with this factory.
+     * @stable ICU 2.0
+     */
+    static void U_EXPORT2 registerFactory(const UnicodeString& id,
+                                Factory factory,
+                                Token context);
+
+    /**
+     * Registers an instance <tt>obj</tt> of a subclass of
+     * <code>Transliterator</code> with the system.  When
+     * <tt>createInstance()</tt> is called with an ID string that is
+     * equal to <tt>obj->getID()</tt>, then <tt>obj->clone()</tt> is
+     * returned.
+     *
+     * After this call the Transliterator class owns the adoptedObj
+     * and will delete it.
+     *
+     * @param adoptedObj an instance of subclass of
+     * <code>Transliterator</code> that defines <tt>clone()</tt>
+     * @see #createInstance
+     * @see #registerFactory
+     * @see #unregister
+     * @stable ICU 2.0
+     */
+    static void U_EXPORT2 registerInstance(Transliterator* adoptedObj);
+
+    /**
+     * Registers an ID string as an alias of another ID string.
+     * That is, after calling this function, <tt>createInstance(aliasID)</tt>
+     * will return the same thing as <tt>createInstance(realID)</tt>.
+     * This is generally used to create shorter, more mnemonic aliases
+     * for long compound IDs.
+     *
+     * @param aliasID The new ID being registered.
+     * @param realID The ID that the new ID is to be an alias for.
+     * This can be a compound ID and can include filters and should
+     * refer to transliterators that have already been registered with
+     * the framework, although this isn't checked.
+     * @stable ICU 3.6
+     */
+     static void U_EXPORT2 registerAlias(const UnicodeString& aliasID,
+                                         const UnicodeString& realID);
+
+protected:
+
+    /**
+     * @internal
+     * @param id the ID being registered
+     * @param factory a function pointer that will be copied and
+     * called later when the given ID is passed to createInstance()
+     * @param context a context pointer that will be stored and
+     * later passed to the factory function when an ID matching
+     * the registration ID is being instantiated with this factory.
+     */
+    static void _registerFactory(const UnicodeString& id,
+                                 Factory factory,
+                                 Token context);
+
+    /**
+     * @internal
+     */
+    static void _registerInstance(Transliterator* adoptedObj);
+
+    /**
+     * @internal
+     */
+    static void _registerAlias(const UnicodeString& aliasID, const UnicodeString& realID);
+
+    /**
+     * Register two targets as being inverses of one another.  For
+     * example, calling registerSpecialInverse("NFC", "NFD", true) causes
+     * Transliterator to form the following inverse relationships:
+     *
+     * <pre>NFC => NFD
+     * Any-NFC => Any-NFD
+     * NFD => NFC
+     * Any-NFD => Any-NFC</pre>
+     *
+     * (Without the special inverse registration, the inverse of NFC
+     * would be NFC-Any.)  Note that NFD is shorthand for Any-NFD, but
+     * that the presence or absence of "Any-" is preserved.
+     *
+     * <p>The relationship is symmetrical; registering (a, b) is
+     * equivalent to registering (b, a).
+     *
+     * <p>The relevant IDs must still be registered separately as
+     * factories or classes.
+     *
+     * <p>Only the targets are specified.  Special inverses always
+     * have the form Any-Target1 <=> Any-Target2.  The target should
+     * have canonical casing (the casing desired to be produced when
+     * an inverse is formed) and should contain no whitespace or other
+     * extraneous characters.
+     *
+     * @param target the target against which to register the inverse
+     * @param inverseTarget the inverse of target, that is
+     * Any-target.getInverse() => Any-inverseTarget
+     * @param bidirectional if true, register the reverse relation
+     * as well, that is, Any-inverseTarget.getInverse() => Any-target
+     * @internal
+     */
+    static void _registerSpecialInverse(const UnicodeString& target,
+                                        const UnicodeString& inverseTarget,
+                                        UBool bidirectional);
+
+public:
+
+    /**
+     * Unregisters a transliterator or class.  This may be either
+     * a system transliterator or a user transliterator or class.
+     * Any attempt to construct an unregistered transliterator based
+     * on its ID will fail.
+     *
+     * @param ID the ID of the transliterator or class
+     * @return the <code>Object</code> that was registered with
+     * <code>ID</code>, or <code>null</code> if none was
+     * @see #registerInstance
+     * @see #registerFactory
+     * @stable ICU 2.0
+     */
+    static void U_EXPORT2 unregister(const UnicodeString& ID);
+
+public:
+
+    /**
+     * Return a StringEnumeration over the IDs available at the time of the
+     * call, including user-registered IDs.
+     * @param ec input-output error code
+     * @return a newly-created StringEnumeration over the transliterators
+     * available at the time of the call. The caller should delete this object
+     * when done using it.
+     * @stable ICU 3.0
+     */
+    static StringEnumeration* U_EXPORT2 getAvailableIDs(UErrorCode& ec);
+
+    /**
+     * Return the number of registered source specifiers.
+     * @return the number of registered source specifiers.
+     * @stable ICU 2.0
+     */
+    static int32_t U_EXPORT2 countAvailableSources(void);
+
+    /**
+     * Return a registered source specifier.
+     * @param index which specifier to return, from 0 to n-1, where
+     * n = countAvailableSources()
+     * @param result fill-in paramter to receive the source specifier.
+     * If index is out of range, result will be empty.
+     * @return reference to result
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getAvailableSource(int32_t index,
+                                             UnicodeString& result);
+
+    /**
+     * Return the number of registered target specifiers for a given
+     * source specifier.
+     * @param source the given source specifier.
+     * @return the number of registered target specifiers for a given
+     *         source specifier.
+     * @stable ICU 2.0
+     */
+    static int32_t U_EXPORT2 countAvailableTargets(const UnicodeString& source);
+
+    /**
+     * Return a registered target specifier for a given source.
+     * @param index which specifier to return, from 0 to n-1, where
+     * n = countAvailableTargets(source)
+     * @param source the source specifier
+     * @param result fill-in paramter to receive the target specifier.
+     * If source is invalid or if index is out of range, result will
+     * be empty.
+     * @return reference to result
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getAvailableTarget(int32_t index,
+                                             const UnicodeString& source,
+                                             UnicodeString& result);
+
+    /**
+     * Return the number of registered variant specifiers for a given
+     * source-target pair.
+     * @param source    the source specifiers.
+     * @param target    the target specifiers.
+     * @stable ICU 2.0
+     */
+    static int32_t U_EXPORT2 countAvailableVariants(const UnicodeString& source,
+                                          const UnicodeString& target);
+
+    /**
+     * Return a registered variant specifier for a given source-target
+     * pair.
+     * @param index which specifier to return, from 0 to n-1, where
+     * n = countAvailableVariants(source, target)
+     * @param source the source specifier
+     * @param target the target specifier
+     * @param result fill-in paramter to receive the variant
+     * specifier.  If source is invalid or if target is invalid or if
+     * index is out of range, result will be empty.
+     * @return reference to result
+     * @stable ICU 2.0
+     */
+    static UnicodeString& U_EXPORT2 getAvailableVariant(int32_t index,
+                                              const UnicodeString& source,
+                                              const UnicodeString& target,
+                                              UnicodeString& result);
+
+protected:
+
+    /**
+     * Non-mutexed internal method
+     * @internal
+     */
+    static int32_t _countAvailableSources(void);
+
+    /**
+     * Non-mutexed internal method
+     * @internal
+     */
+    static UnicodeString& _getAvailableSource(int32_t index,
+                                              UnicodeString& result);
+
+    /**
+     * Non-mutexed internal method
+     * @internal
+     */
+    static int32_t _countAvailableTargets(const UnicodeString& source);
+
+    /**
+     * Non-mutexed internal method
+     * @internal
+     */
+    static UnicodeString& _getAvailableTarget(int32_t index,
+                                              const UnicodeString& source,
+                                              UnicodeString& result);
+
+    /**
+     * Non-mutexed internal method
+     * @internal
+     */
+    static int32_t _countAvailableVariants(const UnicodeString& source,
+                                           const UnicodeString& target);
+
+    /**
+     * Non-mutexed internal method
+     * @internal
+     */
+    static UnicodeString& _getAvailableVariant(int32_t index,
+                                               const UnicodeString& source,
+                                               const UnicodeString& target,
+                                               UnicodeString& result);
+
+protected:
+
+    /**
+     * Set the ID of this transliterators.  Subclasses shouldn't do
+     * this, unless the underlying script behavior has changed.
+     * @param id the new id t to be set.
+     * @stable ICU 2.4
+     */
+    void setID(const UnicodeString& id);
+
+public:
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().
+     * Note that Transliterator is an abstract base class, and therefor
+     * no fully constructed object will  have a dynamic
+     * UCLassID that equals the UClassID returned from
+     * TRansliterator::getStaticClassID().
+     * @return       The class ID for class Transliterator.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID <b>polymorphically</b>.  This method
+     * is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * <p>Concrete subclasses of Transliterator must use the
+     *    UOBJECT_DEFINE_RTTI_IMPLEMENTATION macro from
+     *    uobject.h to provide the RTTI functions.
+     *
+     * @return The class ID for this object. All objects of a given
+     * class have the same class ID.  Objects of other classes have
+     * different class IDs.
+     * @stable ICU 2.0
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+private:
+    static UBool initializeRegistry(UErrorCode &status);
+
+public:
+    /**
+     * Return the number of IDs currently registered with the system.
+     * To retrieve the actual IDs, call getAvailableID(i) with
+     * i from 0 to countAvailableIDs() - 1.
+     * @return the number of IDs currently registered with the system.
+     * @obsolete ICU 3.4 use getAvailableIDs() instead
+     */
+    static int32_t U_EXPORT2 countAvailableIDs(void);
+
+    /**
+     * Return the index-th available ID.  index must be between 0
+     * and countAvailableIDs() - 1, inclusive.  If index is out of
+     * range, the result of getAvailableID(0) is returned.
+     * @param index the given ID index.
+     * @return      the index-th available ID.  index must be between 0
+     *              and countAvailableIDs() - 1, inclusive.  If index is out of
+     *              range, the result of getAvailableID(0) is returned.
+     * @obsolete ICU 3.4 use getAvailableIDs() instead; this function
+     * is not thread safe, since it returns a reference to storage that
+     * may become invalid if another thread calls unregister
+     */
+    static const UnicodeString& U_EXPORT2 getAvailableID(int32_t index);
+};
+
+inline int32_t Transliterator::getMaximumContextLength(void) const {
+    return maximumContextLength;
+}
+
+inline void Transliterator::setID(const UnicodeString& id) {
+    ID = id;
+    // NUL-terminate the ID string, which is a non-aliased copy.
+    ID.append((UChar)0);
+    ID.truncate(ID.length()-1);
+}
+
+inline Transliterator::Token Transliterator::integerToken(int32_t i) {
+    Token t;
+    t.integer = i;
+    return t;
+}
+
+inline Transliterator::Token Transliterator::pointerToken(void* p) {
+    Token t;
+    t.pointer = p;
+    return t;
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_TRANSLITERATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/tzrule.h b/CoreFoundation/icu/unicode/tzrule.h
new file mode 100644
index 0000000..95ad1d0
--- /dev/null
+++ b/CoreFoundation/icu/unicode/tzrule.h
@@ -0,0 +1,828 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and    *
+* others. All Rights Reserved.                                                *
+*******************************************************************************
+*/
+#ifndef TZRULE_H
+#define TZRULE_H
+
+/**
+ * \file 
+ * \brief C++ API: Time zone rule classes
+ */
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "unicode/dtrule.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * <code>TimeZoneRule</code> is a class representing a rule for time zone.
+ * <code>TimeZoneRule</code> has a set of time zone attributes, such as zone name,
+ * raw offset (UTC offset for standard time) and daylight saving time offset.
+ * 
+ * @stable ICU 4.0
+ */
+class U_I18N_API TimeZoneRule : public UObject {
+public:
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~TimeZoneRule();
+
+    /**
+     * Clone this TimeZoneRule object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return  A copy of the object.
+     * @stable ICU 4.0
+     */
+    virtual TimeZoneRule* clone(void) const = 0;
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const TimeZoneRule& that) const;
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator!=(const TimeZoneRule& that) const;
+
+    /**
+     * Fills in "name" with the name of this time zone.
+     * @param name  Receives the name of this time zone.
+     * @return  A reference to "name"
+     * @stable ICU 4.0
+     */
+    UnicodeString& getName(UnicodeString& name) const;
+
+    /**
+     * Gets the standard time offset.
+     * @return  The standard time offset from UTC in milliseconds.
+     * @stable ICU 4.0
+     */
+    int32_t getRawOffset(void) const;
+
+    /**
+     * Gets the amount of daylight saving delta time from the standard time.
+     * @return  The amount of daylight saving offset used by this rule
+     *          in milliseconds.
+     * @stable ICU 4.0
+     */
+    int32_t getDSTSavings(void) const;
+
+    /**
+     * Returns if this rule represents the same rule and offsets as another.
+     * When two <code>TimeZoneRule</code> objects differ only its names, this method
+     * returns true.
+     * @param other The <code>TimeZoneRule</code> object to be compared with.
+     * @return  true if the other <code>TimeZoneRule</code> is the same as this one.
+     * @stable ICU 4.0
+     */
+    virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
+
+    /**
+     * Gets the very first time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the very first time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
+
+    /**
+     * Gets the final time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the final time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
+
+    /**
+     * Gets the first time when this rule takes effect after the specified time.
+     * @param base              The first start time after this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The first time when this rule takes effect after
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const = 0;
+
+    /**
+     * Gets the most recent time when this rule takes effect before the specified time.
+     * @param base              The most recent time before this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The most recent time when this rule takes effect before
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const = 0;
+
+protected:
+
+    /**
+     * Constructs a <code>TimeZoneRule</code> with the name, the GMT offset of its
+     * standard time and the amount of daylight saving offset adjustment.
+     * @param name          The time zone name.
+     * @param rawOffset     The UTC offset of its standard time in milliseconds.
+     * @param dstSavings    The amount of daylight saving offset adjustment in milliseconds.
+     *                      If this ia a rule for standard time, the value of this argument is 0.
+     * @stable ICU 4.0
+     */
+    TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
+
+    /**
+     * Copy constructor.
+     * @param source    The TimeZoneRule object to be copied.
+     * @stable ICU 4.0
+     */
+    TimeZoneRule(const TimeZoneRule& source);
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    TimeZoneRule& operator=(const TimeZoneRule& right);
+
+private:
+    UnicodeString fName; // time name
+    int32_t fRawOffset;  // UTC offset of the standard time in milliseconds
+    int32_t fDSTSavings; // DST saving amount in milliseconds
+};
+
+/**
+ * <code>InitialTimeZoneRule</code> represents a time zone rule
+ * representing a time zone effective from the beginning and
+ * has no actual start times.
+ * @stable ICU 4.0
+ */
+class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
+public:
+    /**
+     * Constructs an <code>InitialTimeZoneRule</code> with the name, the GMT offset of its
+     * standard time and the amount of daylight saving offset adjustment.
+     * @param name          The time zone name.
+     * @param rawOffset     The UTC offset of its standard time in milliseconds.
+     * @param dstSavings    The amount of daylight saving offset adjustment in milliseconds.
+     *                      If this ia a rule for standard time, the value of this argument is 0.
+     * @stable ICU 4.0
+     */
+    InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
+
+    /**
+     * Copy constructor.
+     * @param source    The InitialTimeZoneRule object to be copied.
+     * @stable ICU 4.0
+     */
+    InitialTimeZoneRule(const InitialTimeZoneRule& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~InitialTimeZoneRule();
+
+    /**
+     * Clone this InitialTimeZoneRule object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @stable ICU 4.0
+     */
+    virtual InitialTimeZoneRule* clone(void) const;
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const TimeZoneRule& that) const;
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator!=(const TimeZoneRule& that) const;
+
+    /**
+     * Gets the time when this rule takes effect in the given year.
+     * @param year              The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the start time in the year.
+     * @return  true if this rule takes effect in the year and the result is set to
+     *          "result".
+     * @stable ICU 4.0
+     */
+    UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Returns if this rule represents the same rule and offsets as another.
+     * When two <code>TimeZoneRule</code> objects differ only its names, this method
+     * returns true.
+     * @param that  The <code>TimeZoneRule</code> object to be compared with.
+     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.
+     * @stable ICU 4.0
+     */
+    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
+
+    /**
+     * Gets the very first time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the very first time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Gets the final time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the final time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Gets the first time when this rule takes effect after the specified time.
+     * @param base              The first start time after this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The first time when this rule takes effect after
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const;
+
+    /**
+     * Gets the most recent time when this rule takes effect before the specified time.
+     * @param base              The most recent time before this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The most recent time when this rule takes effect before
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const;
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+/**
+ * <code>AnnualTimeZoneRule</code> is a class used for representing a time zone
+ * rule which takes effect annually.  The calenday system used for the rule is
+ * is based on Gregorian calendar
+ * 
+ * @stable ICU 4.0
+ */
+class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
+public:
+    /**
+     * The constant representing the maximum year used for designating
+     * a rule is permanent.
+     */
+    static const int32_t MAX_YEAR;
+
+    /**
+     * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its
+     * standard time, the amount of daylight saving offset adjustment, the annual start
+     * time rule and the start/until years.  The input DateTimeRule is copied by this
+     * constructor, so the caller remains responsible for deleting the object.
+     * @param name          The time zone name.
+     * @param rawOffset     The GMT offset of its standard time in milliseconds.
+     * @param dstSavings    The amount of daylight saving offset adjustment in
+     *                      milliseconds.  If this ia a rule for standard time,
+     *                      the value of this argument is 0.
+     * @param dateTimeRule  The start date/time rule repeated annually.
+     * @param startYear     The first year when this rule takes effect.
+     * @param endYear       The last year when this rule takes effect.  If this
+     *                      rule is effective forever in future, specify MAX_YEAR.
+     * @stable ICU 4.0
+     */
+    AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
+            const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
+
+    /**
+     * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its
+     * standard time, the amount of daylight saving offset adjustment, the annual start
+     * time rule and the start/until years.  The input DateTimeRule object is adopted
+     * by this object, therefore, the caller must not delete the object.
+     * @param name          The time zone name.
+     * @param rawOffset     The GMT offset of its standard time in milliseconds.
+     * @param dstSavings    The amount of daylight saving offset adjustment in
+     *                      milliseconds.  If this ia a rule for standard time,
+     *                      the value of this argument is 0.
+     * @param dateTimeRule  The start date/time rule repeated annually.
+     * @param startYear     The first year when this rule takes effect.
+     * @param endYear       The last year when this rule takes effect.  If this
+     *                      rule is effective forever in future, specify MAX_YEAR.
+     * @stable ICU 4.0
+     */
+    AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
+            DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
+
+    /**
+     * Copy constructor.
+     * @param source    The AnnualTimeZoneRule object to be copied.
+     * @stable ICU 4.0
+     */
+    AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~AnnualTimeZoneRule();
+
+    /**
+     * Clone this AnnualTimeZoneRule object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @stable ICU 4.0
+     */
+    virtual AnnualTimeZoneRule* clone(void) const;
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const TimeZoneRule& that) const;
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator!=(const TimeZoneRule& that) const;
+
+    /**
+     * Gets the start date/time rule used by this rule.
+     * @return  The <code>AnnualDateTimeRule</code> which represents the start date/time
+     *          rule used by this time zone rule.
+     * @stable ICU 4.0
+     */
+    const DateTimeRule* getRule(void) const;
+
+    /**
+     * Gets the first year when this rule takes effect.
+     * @return  The start year of this rule.  The year is in Gregorian calendar
+     *          with 0 == 1 BCE, -1 == 2 BCE, etc.
+     * @stable ICU 4.0
+     */
+    int32_t getStartYear(void) const;
+
+    /**
+     * Gets the end year when this rule takes effect.
+     * @return  The end year of this rule (inclusive). The year is in Gregorian calendar
+     *          with 0 == 1 BCE, -1 == 2 BCE, etc.
+     * @stable ICU 4.0
+     */
+    int32_t getEndYear(void) const;
+
+    /**
+     * Gets the time when this rule takes effect in the given year.
+     * @param year              The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the start time in the year.
+     * @return  true if this rule takes effect in the year and the result is set to
+     *          "result".
+     * @stable ICU 4.0
+     */
+    UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Returns if this rule represents the same rule and offsets as another.
+     * When two <code>TimeZoneRule</code> objects differ only its names, this method
+     * returns true.
+     * @param that  The <code>TimeZoneRule</code> object to be compared with.
+     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.
+     * @stable ICU 4.0
+     */
+    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
+
+    /**
+     * Gets the very first time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the very first time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Gets the final time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the final time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Gets the first time when this rule takes effect after the specified time.
+     * @param base              The first start time after this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The first time when this rule takes effect after
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const;
+
+    /**
+     * Gets the most recent time when this rule takes effect before the specified time.
+     * @param base              The most recent time before this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The most recent time when this rule takes effect before
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const;
+
+
+private:
+    DateTimeRule* fDateTimeRule;
+    int32_t fStartYear;
+    int32_t fEndYear;
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+/**
+ * <code>TimeArrayTimeZoneRule</code> represents a time zone rule whose start times are
+ * defined by an array of milliseconds since the standard base time.
+ * 
+ * @stable ICU 4.0
+ */
+class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
+public:
+    /**
+     * Constructs a <code>TimeArrayTimeZoneRule</code> with the name, the GMT offset of its
+     * standard time, the amount of daylight saving offset adjustment and
+     * the array of times when this rule takes effect.
+     * @param name          The time zone name.
+     * @param rawOffset     The UTC offset of its standard time in milliseconds.
+     * @param dstSavings    The amount of daylight saving offset adjustment in
+     *                      milliseconds.  If this ia a rule for standard time,
+     *                      the value of this argument is 0.
+     * @param startTimes    The array start times in milliseconds since the base time
+     *                      (January 1, 1970, 00:00:00).
+     * @param numStartTimes The number of elements in the parameter "startTimes"
+     * @param timeRuleType  The time type of the start times, which is one of
+     *                      <code>DataTimeRule::WALL_TIME</code>, <code>STANDARD_TIME</code>
+     *                      and <code>UTC_TIME</code>.
+     * @stable ICU 4.0
+     */
+    TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
+        const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
+
+    /**
+     * Copy constructor.
+     * @param source    The TimeArrayTimeZoneRule object to be copied.
+     * @stable ICU 4.0
+     */
+    TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~TimeArrayTimeZoneRule();
+
+    /**
+     * Clone this TimeArrayTimeZoneRule object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return    A copy of the object.
+     * @stable ICU 4.0
+     */
+    virtual TimeArrayTimeZoneRule* clone(void) const;
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const TimeZoneRule& that) const;
+
+    /**
+     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator!=(const TimeZoneRule& that) const;
+
+    /**
+     * Gets the time type of the start times used by this rule.  The return value
+     * is either <code>DateTimeRule::WALL_TIME</code> or <code>STANDARD_TIME</code>
+     * or <code>UTC_TIME</code>.
+     * 
+     * @return The time type used of the start times used by this rule.
+     * @stable ICU 4.0
+     */
+    DateTimeRule::TimeRuleType getTimeType(void) const;
+
+    /**
+     * Gets a start time at the index stored in this rule.
+     * @param index     The index of start times
+     * @param result    Receives the start time at the index
+     * @return  true if the index is within the valid range and
+     *          and the result is set.  When false, the output
+     *          parameger "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    UBool getStartTimeAt(int32_t index, UDate& result) const;
+
+    /**
+     * Returns the number of start times stored in this rule
+     * @return The number of start times.
+     * @stable ICU 4.0
+     */
+    int32_t countStartTimes(void) const;
+
+    /**
+     * Returns if this rule represents the same rule and offsets as another.
+     * When two <code>TimeZoneRule</code> objects differ only its names, this method
+     * returns true.
+     * @param that  The <code>TimeZoneRule</code> object to be compared with.
+     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.
+     * @stable ICU 4.0
+     */
+    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
+
+    /**
+     * Gets the very first time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the very first time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Gets the final time when this rule takes effect.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param result            Receives the final time when this rule takes effect.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
+
+    /**
+     * Gets the first time when this rule takes effect after the specified time.
+     * @param base              The first start time after this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The first time when this rule takes effect after
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const;
+
+    /**
+     * Gets the most recent time when this rule takes effect before the specified time.
+     * @param base              The most recent time before this base time will be returned.
+     * @param prevRawOffset     The standard time offset from UTC before this rule
+     *                          takes effect in milliseconds.
+     * @param prevDSTSavings    The amount of daylight saving offset from the
+     *                          standard time.
+     * @param inclusive         Whether the base time is inclusive or not.
+     * @param result            Receives The most recent time when this rule takes effect before
+     *                          the specified base time.
+     * @return  true if the start time is available.  When false is returned, output parameter
+     *          "result" is unchanged.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
+        UBool inclusive, UDate& result) const;
+
+
+private:
+    enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
+    UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
+    UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
+
+    DateTimeRule::TimeRuleType  fTimeRuleType;
+    int32_t fNumStartTimes;
+    UDate*  fStartTimes;
+    UDate   fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // TZRULE_H
+
+//eof
diff --git a/CoreFoundation/icu/unicode/tztrans.h b/CoreFoundation/icu/unicode/tztrans.h
new file mode 100644
index 0000000..12f85d6
--- /dev/null
+++ b/CoreFoundation/icu/unicode/tztrans.h
@@ -0,0 +1,195 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and         *
+* others. All Rights Reserved.                                                *
+*******************************************************************************
+*/
+#ifndef TZTRANS_H
+#define TZTRANS_H
+
+/**
+ * \file 
+ * \brief C++ API: Time zone transition
+ */
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+
+U_NAMESPACE_BEGIN
+
+// Forward declaration
+class TimeZoneRule;
+
+/**
+ * <code>TimeZoneTransition</code> is a class representing a time zone transition.
+ * An instance has a time of transition and rules for both before and after the transition.
+ * @stable ICU 4.0
+ */
+class U_I18N_API TimeZoneTransition : public UObject {
+public:
+    /**
+     * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after
+     * the transition.
+     * 
+     * @param time  The time of transition in milliseconds since the base time.
+     * @param from  The time zone rule used before the transition.
+     * @param to    The time zone rule used after the transition.
+     * @stable ICU 4.0
+     */
+    TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to);
+
+    /**
+     * Constructs an empty <code>TimeZoneTransition</code>
+     * @stable ICU 4.0
+     */
+    TimeZoneTransition();
+
+    /**
+     * Copy constructor.
+     * @param source    The TimeZoneTransition object to be copied.
+     * @stable ICU 4.0
+     */
+    TimeZoneTransition(const TimeZoneTransition& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    ~TimeZoneTransition();
+
+    /**
+     * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
+     * should delete it when done.
+     * @return  A copy of the object.
+     * @stable ICU 4.0
+     */
+    TimeZoneTransition* clone(void) const;
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    TimeZoneTransition& operator=(const TimeZoneTransition& right);
+
+    /**
+     * Return true if the given TimeZoneTransition objects are semantically equal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given TimeZoneTransition objects are semantically equal.
+     * @stable ICU 4.0
+     */
+    UBool operator==(const TimeZoneTransition& that) const;
+
+    /**
+     * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
+     * of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given TimeZoneTransition objects are semantically unequal.
+     * @stable ICU 4.0
+     */
+    UBool operator!=(const TimeZoneTransition& that) const;
+
+    /**
+     * Returns the time of transition in milliseconds.
+     * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
+     * @stable ICU 4.0
+     */
+    UDate getTime(void) const;
+
+    /**
+     * Sets the time of transition in milliseconds.
+     * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
+     * @stable ICU 4.0
+     */
+    void setTime(UDate time);
+
+    /**
+     * Returns the rule used before the transition.
+     * @return The time zone rule used after the transition.
+     * @stable ICU 4.0
+     */
+    const TimeZoneRule* getFrom(void) const;
+
+    /**
+     * Sets the rule used before the transition.  The caller remains
+     * responsible for deleting the <code>TimeZoneRule</code> object.
+     * @param from The time zone rule used before the transition.
+     * @stable ICU 4.0
+     */
+    void setFrom(const TimeZoneRule& from);
+
+    /**
+     * Adopts the rule used before the transition.  The caller must
+     * not delete the <code>TimeZoneRule</code> object passed in.
+     * @param from The time zone rule used before the transition.
+     * @stable ICU 4.0
+     */
+    void adoptFrom(TimeZoneRule* from);
+
+    /**
+     * Sets the rule used after the transition.  The caller remains
+     * responsible for deleting the <code>TimeZoneRule</code> object.
+     * @param to The time zone rule used after the transition.
+     * @stable ICU 4.0
+     */
+    void setTo(const TimeZoneRule& to);
+
+    /**
+     * Adopts the rule used after the transition.  The caller must
+     * not delete the <code>TimeZoneRule</code> object passed in.
+     * @param to The time zone rule used after the transition.
+     * @stable ICU 4.0
+     */
+    void adoptTo(TimeZoneRule* to);
+
+    /**
+     * Returns the rule used after the transition.
+     * @return The time zone rule used after the transition.
+     * @stable ICU 4.0
+     */
+    const TimeZoneRule* getTo(void) const;
+
+private:
+    UDate   fTime;
+    TimeZoneRule*   fFrom;
+    TimeZoneRule*   fTo;
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // TZTRANS_H
+
+//eof
diff --git a/CoreFoundation/icu/unicode/ubidi.h b/CoreFoundation/icu/unicode/ubidi.h
new file mode 100644
index 0000000..25f22b9
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ubidi.h
@@ -0,0 +1,2013 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1999-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*   file name:  ubidi.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999jul27
+*   created by: Markus W. Scherer, updated by Matitiahu Allouche
+*/
+
+#ifndef UBIDI_H
+#define UBIDI_H
+
+#include "unicode/utypes.h"
+#include "unicode/uchar.h"
+
+/**
+ *\file
+ * \brief C API: Bidi algorithm
+ *
+ * <h2>Bidi algorithm for ICU</h2>
+ *
+ * This is an implementation of the Unicode Bidirectional algorithm.
+ * The algorithm is defined in the
+ * <a href="http://www.unicode.org/unicode/reports/tr9/">Unicode Standard Annex #9</a>,
+ * version 13, also described in The Unicode Standard, Version 4.0 .<p>
+ *
+ * Note: Libraries that perform a bidirectional algorithm and
+ * reorder strings accordingly are sometimes called "Storage Layout Engines".
+ * ICU's Bidi and shaping (u_shapeArabic()) APIs can be used at the core of such
+ * "Storage Layout Engines".
+ *
+ * <h3>General remarks about the API:</h3>
+ *
+ * In functions with an error code parameter,
+ * the <code>pErrorCode</code> pointer must be valid
+ * and the value that it points to must not indicate a failure before
+ * the function call. Otherwise, the function returns immediately.
+ * After the function call, the value indicates success or failure.<p>
+ *
+ * The &quot;limit&quot; of a sequence of characters is the position just after their
+ * last character, i.e., one more than that position.<p>
+ *
+ * Some of the API functions provide access to &quot;runs&quot;.
+ * Such a &quot;run&quot; is defined as a sequence of characters
+ * that are at the same embedding level
+ * after performing the Bidi algorithm.<p>
+ *
+ * @author Markus W. Scherer
+ * @version 1.0
+ *
+ *
+ * <h4> Sample code for the ICU Bidi API </h4>
+ *
+ * <h5>Rendering a paragraph with the ICU Bidi API</h5>
+ *
+ * This is (hypothetical) sample code that illustrates
+ * how the ICU Bidi API could be used to render a paragraph of text.
+ * Rendering code depends highly on the graphics system,
+ * therefore this sample code must make a lot of assumptions,
+ * which may or may not match any existing graphics system's properties.
+ *
+ * <p>The basic assumptions are:</p>
+ * <ul>
+ * <li>Rendering is done from left to right on a horizontal line.</li>
+ * <li>A run of single-style, unidirectional text can be rendered at once.</li>
+ * <li>Such a run of text is passed to the graphics system with
+ *     characters (code units) in logical order.</li>
+ * <li>The line-breaking algorithm is very complicated
+ *     and Locale-dependent -
+ *     and therefore its implementation omitted from this sample code.</li>
+ * </ul>
+ *
+ * <pre>
+ * \code
+ *#include "unicode/ubidi.h"
+ *
+ *typedef enum {
+ *     styleNormal=0, styleSelected=1,
+ *     styleBold=2, styleItalics=4,
+ *     styleSuper=8, styleSub=16
+ *} Style;
+ *
+ *typedef struct { int32_t limit; Style style; } StyleRun;
+ *
+ *int getTextWidth(const UChar *text, int32_t start, int32_t limit,
+ *                  const StyleRun *styleRuns, int styleRunCount);
+ *
+ * // set *pLimit and *pStyleRunLimit for a line
+ * // from text[start] and from styleRuns[styleRunStart]
+ * // using ubidi_getLogicalRun(para, ...)
+ *void getLineBreak(const UChar *text, int32_t start, int32_t *pLimit,
+ *                  UBiDi *para,
+ *                  const StyleRun *styleRuns, int styleRunStart, int *pStyleRunLimit,
+ *                  int *pLineWidth);
+ *
+ * // render runs on a line sequentially, always from left to right
+ *
+ * // prepare rendering a new line
+ * void startLine(UBiDiDirection textDirection, int lineWidth);
+ *
+ * // render a run of text and advance to the right by the run width
+ * // the text[start..limit-1] is always in logical order
+ * void renderRun(const UChar *text, int32_t start, int32_t limit,
+ *               UBiDiDirection textDirection, Style style);
+ *
+ * // We could compute a cross-product
+ * // from the style runs with the directional runs
+ * // and then reorder it.
+ * // Instead, here we iterate over each run type
+ * // and render the intersections -
+ * // with shortcuts in simple (and common) cases.
+ * // renderParagraph() is the main function.
+ *
+ * // render a directional run with
+ * // (possibly) multiple style runs intersecting with it
+ * void renderDirectionalRun(const UChar *text,
+ *                           int32_t start, int32_t limit,
+ *                           UBiDiDirection direction,
+ *                           const StyleRun *styleRuns, int styleRunCount) {
+ *     int i;
+ *
+ *     // iterate over style runs
+ *     if(direction==UBIDI_LTR) {
+ *         int styleLimit;
+ *
+ *         for(i=0; i<styleRunCount; ++i) {
+ *             styleLimit=styleRun[i].limit;
+ *             if(start<styleLimit) {
+ *                 if(styleLimit>limit) { styleLimit=limit; }
+ *                 renderRun(text, start, styleLimit,
+ *                           direction, styleRun[i].style);
+ *                 if(styleLimit==limit) { break; }
+ *                 start=styleLimit;
+ *             }
+ *         }
+ *     } else {
+ *         int styleStart;
+ *
+ *         for(i=styleRunCount-1; i>=0; --i) {
+ *             if(i>0) {
+ *                 styleStart=styleRun[i-1].limit;
+ *             } else {
+ *                 styleStart=0;
+ *             }
+ *             if(limit>=styleStart) {
+ *                 if(styleStart<start) { styleStart=start; }
+ *                 renderRun(text, styleStart, limit,
+ *                           direction, styleRun[i].style);
+ *                 if(styleStart==start) { break; }
+ *                 limit=styleStart;
+ *             }
+ *         }
+ *     }
+ * }
+ *
+ * // the line object represents text[start..limit-1]
+ * void renderLine(UBiDi *line, const UChar *text,
+ *                 int32_t start, int32_t limit,
+ *                 const StyleRun *styleRuns, int styleRunCount) {
+ *     UBiDiDirection direction=ubidi_getDirection(line);
+ *     if(direction!=UBIDI_MIXED) {
+ *         // unidirectional
+ *         if(styleRunCount<=1) {
+ *             renderRun(text, start, limit, direction, styleRuns[0].style);
+ *         } else {
+ *             renderDirectionalRun(text, start, limit,
+ *                                  direction, styleRuns, styleRunCount);
+ *         }
+ *     } else {
+ *         // mixed-directional
+ *         int32_t count, i, length;
+ *         UBiDiLevel level;
+ *
+ *         count=ubidi_countRuns(para, pErrorCode);
+ *         if(U_SUCCESS(*pErrorCode)) {
+ *             if(styleRunCount<=1) {
+ *                 Style style=styleRuns[0].style;
+ *
+ *                 // iterate over directional runs
+ *                for(i=0; i<count; ++i) {
+ *                    direction=ubidi_getVisualRun(para, i, &start, &length);
+ *                     renderRun(text, start, start+length, direction, style);
+ *                }
+ *             } else {
+ *                 int32_t j;
+ *
+ *                 // iterate over both directional and style runs
+ *                 for(i=0; i<count; ++i) {
+ *                     direction=ubidi_getVisualRun(line, i, &start, &length);
+ *                     renderDirectionalRun(text, start, start+length,
+ *                                          direction, styleRuns, styleRunCount);
+ *                 }
+ *             }
+ *         }
+ *     }
+ * }
+ *
+ *void renderParagraph(const UChar *text, int32_t length,
+ *                     UBiDiDirection textDirection,
+ *                      const StyleRun *styleRuns, int styleRunCount,
+ *                      int lineWidth,
+ *                      UErrorCode *pErrorCode) {
+ *     UBiDi *para;
+ *
+ *     if(pErrorCode==NULL || U_FAILURE(*pErrorCode) || length<=0) {
+ *         return;
+ *     }
+ *
+ *     para=ubidi_openSized(length, 0, pErrorCode);
+ *     if(para==NULL) { return; }
+ *
+ *     ubidi_setPara(para, text, length,
+ *                   textDirection ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR,
+ *                   NULL, pErrorCode);
+ *     if(U_SUCCESS(*pErrorCode)) {
+ *         UBiDiLevel paraLevel=1&ubidi_getParaLevel(para);
+ *         StyleRun styleRun={ length, styleNormal };
+ *         int width;
+ *
+ *         if(styleRuns==NULL || styleRunCount<=0) {
+ *            styleRunCount=1;
+ *             styleRuns=&styleRun;
+ *         }
+ *
+ *        // assume styleRuns[styleRunCount-1].limit>=length
+ *
+ *         width=getTextWidth(text, 0, length, styleRuns, styleRunCount);
+ *         if(width<=lineWidth) {
+ *             // everything fits onto one line
+ *
+ *            // prepare rendering a new line from either left or right
+ *             startLine(paraLevel, width);
+ *
+ *             renderLine(para, text, 0, length,
+ *                        styleRuns, styleRunCount);
+ *         } else {
+ *             UBiDi *line;
+ *
+ *             // we need to render several lines
+ *             line=ubidi_openSized(length, 0, pErrorCode);
+ *             if(line!=NULL) {
+ *                 int32_t start=0, limit;
+ *                 int styleRunStart=0, styleRunLimit;
+ *
+ *                 for(;;) {
+ *                     limit=length;
+ *                     styleRunLimit=styleRunCount;
+ *                     getLineBreak(text, start, &limit, para,
+ *                                  styleRuns, styleRunStart, &styleRunLimit,
+ *                                 &width);
+ *                     ubidi_setLine(para, start, limit, line, pErrorCode);
+ *                     if(U_SUCCESS(*pErrorCode)) {
+ *                         // prepare rendering a new line
+ *                         // from either left or right
+ *                         startLine(paraLevel, width);
+ *
+ *                         renderLine(line, text, start, limit,
+ *                                    styleRuns+styleRunStart,
+ *                                    styleRunLimit-styleRunStart);
+ *                     }
+ *                     if(limit==length) { break; }
+ *                     start=limit;
+ *                     styleRunStart=styleRunLimit-1;
+ *                     if(start>=styleRuns[styleRunStart].limit) {
+ *                         ++styleRunStart;
+ *                     }
+ *                 }
+ *
+ *                 ubidi_close(line);
+ *             }
+ *        }
+ *    }
+ *
+ *     ubidi_close(para);
+ *}
+ *\endcode
+ * </pre>
+ */
+
+/*DOCXX_TAG*/
+/*@{*/
+
+/**
+ * UBiDiLevel is the type of the level values in this
+ * Bidi implementation.
+ * It holds an embedding level and indicates the visual direction
+ * by its bit&nbsp;0 (even/odd value).<p>
+ *
+ * It can also hold non-level values for the
+ * <code>paraLevel</code> and <code>embeddingLevels</code>
+ * arguments of <code>ubidi_setPara()</code>; there:
+ * <ul>
+ * <li>bit&nbsp;7 of an <code>embeddingLevels[]</code>
+ * value indicates whether the using application is
+ * specifying the level of a character to <i>override</i> whatever the
+ * Bidi implementation would resolve it to.</li>
+ * <li><code>paraLevel</code> can be set to the
+ * pseudo-level values <code>UBIDI_DEFAULT_LTR</code>
+ * and <code>UBIDI_DEFAULT_RTL</code>.</li>
+ * </ul>
+ *
+ * @see ubidi_setPara
+ *
+ * <p>The related constants are not real, valid level values.
+ * <code>UBIDI_DEFAULT_XXX</code> can be used to specify
+ * a default for the paragraph level for
+ * when the <code>ubidi_setPara()</code> function
+ * shall determine it but there is no
+ * strongly typed character in the input.<p>
+ *
+ * Note that the value for <code>UBIDI_DEFAULT_LTR</code> is even
+ * and the one for <code>UBIDI_DEFAULT_RTL</code> is odd,
+ * just like with normal LTR and RTL level values -
+ * these special values are designed that way. Also, the implementation
+ * assumes that UBIDI_MAX_EXPLICIT_LEVEL is odd.
+ *
+ * @see UBIDI_DEFAULT_LTR
+ * @see UBIDI_DEFAULT_RTL
+ * @see UBIDI_LEVEL_OVERRIDE
+ * @see UBIDI_MAX_EXPLICIT_LEVEL
+ * @stable ICU 2.0
+ */
+typedef uint8_t UBiDiLevel;
+
+/** Paragraph level setting.<p>
+ *
+ * Constant indicating that the base direction depends on the first strong
+ * directional character in the text according to the Unicode Bidirectional
+ * Algorithm. If no strong directional character is present,
+ * then set the paragraph level to 0 (left-to-right).<p>
+ *
+ * If this value is used in conjunction with reordering modes
+ * <code>UBIDI_REORDER_INVERSE_LIKE_DIRECT</code> or
+ * <code>UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the text to reorder
+ * is assumed to be visual LTR, and the text after reordering is required
+ * to be the corresponding logical string with appropriate contextual
+ * direction. The direction of the result string will be RTL if either
+ * the righmost or leftmost strong character of the source text is RTL
+ * or Arabic Letter, the direction will be LTR otherwise.<p>
+ *
+ * If reordering option <code>UBIDI_OPTION_INSERT_MARKS</code> is set, an RLM may
+ * be added at the beginning of the result string to ensure round trip
+ * (that the result string, when reordered back to visual, will produce
+ * the original source text).
+ * @see UBIDI_REORDER_INVERSE_LIKE_DIRECT
+ * @see UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
+ * @stable ICU 2.0
+ */
+#define UBIDI_DEFAULT_LTR 0xfe
+
+/** Paragraph level setting.<p>
+ *
+ * Constant indicating that the base direction depends on the first strong
+ * directional character in the text according to the Unicode Bidirectional
+ * Algorithm. If no strong directional character is present,
+ * then set the paragraph level to 1 (right-to-left).<p>
+ *
+ * If this value is used in conjunction with reordering modes
+ * <code>UBIDI_REORDER_INVERSE_LIKE_DIRECT</code> or
+ * <code>UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the text to reorder
+ * is assumed to be visual LTR, and the text after reordering is required
+ * to be the corresponding logical string with appropriate contextual
+ * direction. The direction of the result string will be RTL if either
+ * the righmost or leftmost strong character of the source text is RTL
+ * or Arabic Letter, or if the text contains no strong character;
+ * the direction will be LTR otherwise.<p>
+ *
+ * If reordering option <code>UBIDI_OPTION_INSERT_MARKS</code> is set, an RLM may
+ * be added at the beginning of the result string to ensure round trip
+ * (that the result string, when reordered back to visual, will produce
+ * the original source text).
+ * @see UBIDI_REORDER_INVERSE_LIKE_DIRECT
+ * @see UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
+ * @stable ICU 2.0
+ */
+#define UBIDI_DEFAULT_RTL 0xff
+
+/**
+ * Maximum explicit embedding level.
+ * (The maximum resolved level can be up to <code>UBIDI_MAX_EXPLICIT_LEVEL+1</code>).
+ * @stable ICU 2.0
+ */
+#define UBIDI_MAX_EXPLICIT_LEVEL 61
+
+/** Bit flag for level input.
+ *  Overrides directional properties.
+ * @stable ICU 2.0
+ */
+#define UBIDI_LEVEL_OVERRIDE 0x80
+
+/**
+ * Special value which can be returned by the mapping functions when a logical
+ * index has no corresponding visual index or vice-versa. This may happen
+ * for the logical-to-visual mapping of a Bidi control when option
+ * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> is specified. This can also happen
+ * for the visual-to-logical mapping of a Bidi mark (LRM or RLM) inserted
+ * by option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
+ * @see ubidi_getVisualIndex
+ * @see ubidi_getVisualMap
+ * @see ubidi_getLogicalIndex
+ * @see ubidi_getLogicalMap
+ * @stable ICU 3.6
+ */
+#define UBIDI_MAP_NOWHERE   (-1)
+
+/**
+ * <code>UBiDiDirection</code> values indicate the text direction.
+ * @stable ICU 2.0
+ */
+enum UBiDiDirection {
+    /** All left-to-right text. This is a 0 value. @stable ICU 2.0 */
+    UBIDI_LTR,
+    /** All right-to-left text. This is a 1 value. @stable ICU 2.0 */
+    UBIDI_RTL,
+    /** Mixed-directional text. @stable ICU 2.0 */
+    UBIDI_MIXED
+};
+
+/** @stable ICU 2.0 */
+typedef enum UBiDiDirection UBiDiDirection;
+
+/**
+ * Forward declaration of the <code>UBiDi</code> structure for the declaration of
+ * the API functions. Its fields are implementation-specific.<p>
+ * This structure holds information about a paragraph (or multiple paragraphs)
+ * of text with Bidi-algorithm-related details, or about one line of
+ * such a paragraph.<p>
+ * Reordering can be done on a line, or on one or more paragraphs which are
+ * then interpreted each as one single line.
+ * @stable ICU 2.0
+ */
+struct UBiDi;
+
+/** @stable ICU 2.0 */
+typedef struct UBiDi UBiDi;
+
+/**
+ * Allocate a <code>UBiDi</code> structure.
+ * Such an object is initially empty. It is assigned
+ * the Bidi properties of a piece of text containing one or more paragraphs
+ * by <code>ubidi_setPara()</code>
+ * or the Bidi properties of a line within a paragraph by
+ * <code>ubidi_setLine()</code>.<p>
+ * This object can be reused for as long as it is not deallocated
+ * by calling <code>ubidi_close()</code>.<p>
+ * <code>ubidi_setPara()</code> and <code>ubidi_setLine()</code> will allocate
+ * additional memory for internal structures as necessary.
+ *
+ * @return An empty <code>UBiDi</code> object.
+ * @stable ICU 2.0
+ */
+U_STABLE UBiDi * U_EXPORT2
+ubidi_open(void);
+
+/**
+ * Allocate a <code>UBiDi</code> structure with preallocated memory
+ * for internal structures.
+ * This function provides a <code>UBiDi</code> object like <code>ubidi_open()</code>
+ * with no arguments, but it also preallocates memory for internal structures
+ * according to the sizings supplied by the caller.<p>
+ * Subsequent functions will not allocate any more memory, and are thus
+ * guaranteed not to fail because of lack of memory.<p>
+ * The preallocation can be limited to some of the internal memory
+ * by setting some values to 0 here. That means that if, e.g.,
+ * <code>maxRunCount</code> cannot be reasonably predetermined and should not
+ * be set to <code>maxLength</code> (the only failproof value) to avoid
+ * wasting memory, then <code>maxRunCount</code> could be set to 0 here
+ * and the internal structures that are associated with it will be allocated
+ * on demand, just like with <code>ubidi_open()</code>.
+ *
+ * @param maxLength is the maximum text or line length that internal memory
+ *        will be preallocated for. An attempt to associate this object with a
+ *        longer text will fail, unless this value is 0, which leaves the allocation
+ *        up to the implementation.
+ *
+ * @param maxRunCount is the maximum anticipated number of same-level runs
+ *        that internal memory will be preallocated for. An attempt to access
+ *        visual runs on an object that was not preallocated for as many runs
+ *        as the text was actually resolved to will fail,
+ *        unless this value is 0, which leaves the allocation up to the implementation.<br><br>
+ *        The number of runs depends on the actual text and maybe anywhere between
+ *        1 and <code>maxLength</code>. It is typically small.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return An empty <code>UBiDi</code> object with preallocated memory.
+ * @stable ICU 2.0
+ */
+U_STABLE UBiDi * U_EXPORT2
+ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
+
+/**
+ * <code>ubidi_close()</code> must be called to free the memory
+ * associated with a UBiDi object.<p>
+ *
+ * <strong>Important: </strong>
+ * A parent <code>UBiDi</code> object must not be destroyed or reused if
+ * it still has children.
+ * If a <code>UBiDi</code> object has become the <i>child</i>
+ * of another one (its <i>parent</i>) by calling
+ * <code>ubidi_setLine()</code>, then the child object must
+ * be destroyed (closed) or reused (by calling
+ * <code>ubidi_setPara()</code> or <code>ubidi_setLine()</code>)
+ * before the parent object.
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ *
+ * @see ubidi_setPara
+ * @see ubidi_setLine
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_close(UBiDi *pBiDi);
+
+/**
+ * Modify the operation of the Bidi algorithm such that it
+ * approximates an "inverse Bidi" algorithm. This function
+ * must be called before <code>ubidi_setPara()</code>.
+ *
+ * <p>The normal operation of the Bidi algorithm as described
+ * in the Unicode Technical Report is to take text stored in logical
+ * (keyboard, typing) order and to determine the reordering of it for visual
+ * rendering.
+ * Some legacy systems store text in visual order, and for operations
+ * with standard, Unicode-based algorithms, the text needs to be transformed
+ * to logical order. This is effectively the inverse algorithm of the
+ * described Bidi algorithm. Note that there is no standard algorithm for
+ * this "inverse Bidi" and that the current implementation provides only an
+ * approximation of "inverse Bidi".</p>
+ *
+ * <p>With <code>isInverse</code> set to <code>TRUE</code>,
+ * this function changes the behavior of some of the subsequent functions
+ * in a way that they can be used for the inverse Bidi algorithm.
+ * Specifically, runs of text with numeric characters will be treated in a
+ * special way and may need to be surrounded with LRM characters when they are
+ * written in reordered sequence.</p>
+ *
+ * <p>Output runs should be retrieved using <code>ubidi_getVisualRun()</code>.
+ * Since the actual input for "inverse Bidi" is visually ordered text and
+ * <code>ubidi_getVisualRun()</code> gets the reordered runs, these are actually
+ * the runs of the logically ordered output.</p>
+ *
+ * <p>Calling this function with argument <code>isInverse</code> set to
+ * <code>TRUE</code> is equivalent to calling
+ * <code>ubidi_setReorderingMode</code> with argument
+ * <code>reorderingMode</code>
+ * set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.<br>
+ * Calling this function with argument <code>isInverse</code> set to
+ * <code>FALSE</code> is equivalent to calling
+ * <code>ubidi_setReorderingMode</code> with argument
+ * <code>reorderingMode</code>
+ * set to <code>#UBIDI_REORDER_DEFAULT</code>.
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ *
+ * @param isInverse specifies "forward" or "inverse" Bidi operation.
+ *
+ * @see ubidi_setPara
+ * @see ubidi_writeReordered
+ * @see ubidi_setReorderingMode
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
+
+/**
+ * Is this Bidi object set to perform the inverse Bidi algorithm?
+ * <p>Note: calling this function after setting the reordering mode with
+ * <code>ubidi_setReorderingMode</code> will return <code>TRUE</code> if the
+ * reordering mode was set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>,
+ * <code>FALSE</code> for all other values.</p>
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ * @return TRUE if the Bidi object is set to perform the inverse Bidi algorithm
+ * by handling numbers as L.
+ *
+ * @see ubidi_setInverse
+ * @see ubidi_setReorderingMode
+ * @stable ICU 2.0
+ */
+
+U_STABLE UBool U_EXPORT2
+ubidi_isInverse(UBiDi *pBiDi);
+
+/**
+ * Specify whether block separators must be allocated level zero,
+ * so that successive paragraphs will progress from left to right.
+ * This function must be called before <code>ubidi_setPara()</code>.
+ * Paragraph separators (B) may appear in the text.  Setting them to level zero
+ * means that all paragraph separators (including one possibly appearing
+ * in the last text position) are kept in the reordered text after the text
+ * that they follow in the source text.
+ * When this feature is not enabled, a paragraph separator at the last
+ * position of the text before reordering will go to the first position
+ * of the reordered text when the paragraph level is odd.
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ *
+ * @param orderParagraphsLTR specifies whether paragraph separators (B) must
+ * receive level 0, so that successive paragraphs progress from left to right.
+ *
+ * @see ubidi_setPara
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
+
+/**
+ * Is this Bidi object set to allocate level 0 to block separators so that
+ * successive paragraphs progress from left to right?
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ * @return TRUE if the Bidi object is set to allocate level 0 to block
+ *         separators.
+ *
+ * @see ubidi_orderParagraphsLTR
+ * @stable ICU 3.4
+ */
+U_STABLE UBool U_EXPORT2
+ubidi_isOrderParagraphsLTR(UBiDi *pBiDi);
+
+/**
+ * <code>UBiDiReorderingMode</code> values indicate which variant of the Bidi
+ * algorithm to use.
+ *
+ * @see ubidi_setReorderingMode
+ * @stable ICU 3.6
+ */
+typedef enum UBiDiReorderingMode {
+    /** Regular Logical to Visual Bidi algorithm according to Unicode.
+      * This is a 0 value.
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_DEFAULT = 0,
+    /** Logical to Visual algorithm which handles numbers in a way which
+      * mimicks the behavior of Windows XP.
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_NUMBERS_SPECIAL,
+    /** Logical to Visual algorithm grouping numbers with adjacent R characters
+      * (reversible algorithm).
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_GROUP_NUMBERS_WITH_R,
+    /** Reorder runs only to transform a Logical LTR string to the Logical RTL
+      * string with the same display, or vice-versa.<br>
+      * If this mode is set together with option
+      * <code>#UBIDI_OPTION_INSERT_MARKS</code>, some Bidi controls in the source
+      * text may be removed and other controls may be added to produce the
+      * minimum combination which has the required display.
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_RUNS_ONLY,
+    /** Visual to Logical algorithm which handles numbers like L
+      * (same algorithm as selected by <code>ubidi_setInverse(TRUE)</code>.
+      * @see ubidi_setInverse
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_INVERSE_NUMBERS_AS_L,
+    /** Visual to Logical algorithm equivalent to the regular Logical to Visual
+      * algorithm.
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_INVERSE_LIKE_DIRECT,
+    /** Inverse Bidi (Visual to Logical) algorithm for the
+      * <code>UBIDI_REORDER_NUMBERS_SPECIAL</code> Bidi algorithm.
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL,
+    /** Number of values for reordering mode.
+      * @stable ICU 3.6 */
+    UBIDI_REORDER_COUNT
+} UBiDiReorderingMode;
+
+/**
+ * Modify the operation of the Bidi algorithm such that it implements some
+ * variant to the basic Bidi algorithm or approximates an "inverse Bidi"
+ * algorithm, depending on different values of the "reordering mode".
+ * This function must be called before <code>ubidi_setPara()</code>, and stays
+ * in effect until called again with a different argument.
+ *
+ * <p>The normal operation of the Bidi algorithm as described
+ * in the Unicode Standard Annex #9 is to take text stored in logical
+ * (keyboard, typing) order and to determine how to reorder it for visual
+ * rendering.</p>
+ *
+ * <p>With the reordering mode set to a value other than
+ * <code>#UBIDI_REORDER_DEFAULT</code>, this function changes the behavior of
+ * some of the subsequent functions in a way such that they implement an
+ * inverse Bidi algorithm or some other algorithm variants.</p>
+ *
+ * <p>Some legacy systems store text in visual order, and for operations
+ * with standard, Unicode-based algorithms, the text needs to be transformed
+ * into logical order. This is effectively the inverse algorithm of the
+ * described Bidi algorithm. Note that there is no standard algorithm for
+ * this "inverse Bidi", so a number of variants are implemented here.</p>
+ *
+ * <p>In other cases, it may be desirable to emulate some variant of the
+ * Logical to Visual algorithm (e.g. one used in MS Windows), or perform a
+ * Logical to Logical transformation.</p>
+ *
+ * <ul>
+ * <li>When the reordering mode is set to <code>#UBIDI_REORDER_DEFAULT</code>,
+ * the standard Bidi Logical to Visual algorithm is applied.</li>
+ *
+ * <li>When the reordering mode is set to
+ * <code>#UBIDI_REORDER_NUMBERS_SPECIAL</code>,
+ * the algorithm used to perform Bidi transformations when calling
+ * <code>ubidi_setPara</code> should approximate the algorithm used in
+ * Microsoft Windows XP rather than strictly conform to the Unicode Bidi
+ * algorithm.
+ * <br>
+ * The differences between the basic algorithm and the algorithm addressed
+ * by this option are as follows:
+ * <ul>
+ *   <li>Within text at an even embedding level, the sequence "123AB"
+ *   (where AB represent R or AL letters) is transformed to "123BA" by the
+ *   Unicode algorithm and to "BA123" by the Windows algorithm.</li>
+ *   <li>Arabic-Indic numbers (AN) are handled by the Windows algorithm just
+ *   like regular numbers (EN).</li>
+ * </ul></li>
+ *
+ * <li>When the reordering mode is set to
+ * <code>#UBIDI_REORDER_GROUP_NUMBERS_WITH_R</code>,
+ * numbers located between LTR text and RTL text are associated with the RTL
+ * text. For instance, an LTR paragraph with content "abc 123 DEF" (where
+ * upper case letters represent RTL characters) will be transformed to
+ * "abc FED 123" (and not "abc 123 FED"), "DEF 123 abc" will be transformed
+ * to "123 FED abc" and "123 FED abc" will be transformed to "DEF 123 abc".
+ * This makes the algorithm reversible and makes it useful when round trip
+ * (from visual to logical and back to visual) must be achieved without
+ * adding LRM characters. However, this is a variation from the standard
+ * Unicode Bidi algorithm.<br>
+ * The source text should not contain Bidi control characters other than LRM
+ * or RLM.</li>
+ *
+ * <li>When the reordering mode is set to
+ * <code>#UBIDI_REORDER_RUNS_ONLY</code>,
+ * a "Logical to Logical" transformation must be performed:
+ * <ul>
+ * <li>If the default text level of the source text (argument <code>paraLevel</code>
+ * in <code>ubidi_setPara</code>) is even, the source text will be handled as
+ * LTR logical text and will be transformed to the RTL logical text which has
+ * the same LTR visual display.</li>
+ * <li>If the default level of the source text is odd, the source text
+ * will be handled as RTL logical text and will be transformed to the
+ * LTR logical text which has the same LTR visual display.</li>
+ * </ul>
+ * This mode may be needed when logical text which is basically Arabic or
+ * Hebrew, with possible included numbers or phrases in English, has to be
+ * displayed as if it had an even embedding level (this can happen if the
+ * displaying application treats all text as if it was basically LTR).
+ * <br>
+ * This mode may also be needed in the reverse case, when logical text which is
+ * basically English, with possible included phrases in Arabic or Hebrew, has to
+ * be displayed as if it had an odd embedding level.
+ * <br>
+ * Both cases could be handled by adding LRE or RLE at the head of the text,
+ * if the display subsystem supports these formatting controls. If it does not,
+ * the problem may be handled by transforming the source text in this mode
+ * before displaying it, so that it will be displayed properly.<br>
+ * The source text should not contain Bidi control characters other than LRM
+ * or RLM.</li>
+ *
+ * <li>When the reordering mode is set to
+ * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>, an "inverse Bidi" algorithm
+ * is applied.
+ * Runs of text with numeric characters will be treated like LTR letters and
+ * may need to be surrounded with LRM characters when they are written in
+ * reordered sequence (the option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> can
+ * be used with function <code>ubidi_writeReordered</code> to this end. This
+ * mode is equivalent to calling <code>ubidi_setInverse()</code> with
+ * argument <code>isInverse</code> set to <code>TRUE</code>.</li>
+ *
+ * <li>When the reordering mode is set to
+ * <code>#UBIDI_REORDER_INVERSE_LIKE_DIRECT</code>, the "direct" Logical to Visual
+ * Bidi algorithm is used as an approximation of an "inverse Bidi" algorithm.
+ * This mode is similar to mode <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>
+ * but is closer to the regular Bidi algorithm.
+ * <br>
+ * For example, an LTR paragraph with the content "FED 123 456 CBA" (where
+ * upper case represents RTL characters) will be transformed to
+ * "ABC 456 123 DEF", as opposed to "DEF 123 456 ABC"
+ * with mode <code>UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.<br>
+ * When used in conjunction with option
+ * <code>#UBIDI_OPTION_INSERT_MARKS</code>, this mode generally
+ * adds Bidi marks to the output significantly more sparingly than mode
+ * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> with option
+ * <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls to
+ * <code>ubidi_writeReordered</code>.</li>
+ *
+ * <li>When the reordering mode is set to
+ * <code>#UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the Logical to Visual
+ * Bidi algorithm used in Windows XP is used as an approximation of an
+ * "inverse Bidi" algorithm.
+ * <br>
+ * For example, an LTR paragraph with the content "abc FED123" (where
+ * upper case represents RTL characters) will be transformed to
+ * "abc 123DEF.</li>
+ * </ul>
+ *
+ * <p>In all the reordering modes specifying an "inverse Bidi" algorithm
+ * (i.e. those with a name starting with <code>UBIDI_REORDER_INVERSE</code>),
+ * output runs should be retrieved using
+ * <code>ubidi_getVisualRun()</code>, and the output text with
+ * <code>ubidi_writeReordered()</code>. The caller should keep in mind that in
+ * "inverse Bidi" modes the input is actually visually ordered text and
+ * reordered output returned by <code>ubidi_getVisualRun()</code> or
+ * <code>ubidi_writeReordered()</code> are actually runs or character string
+ * of logically ordered output.<br>
+ * For all the "inverse Bidi" modes, the source text should not contain
+ * Bidi control characters other than LRM or RLM.</p>
+ *
+ * <p>Note that option <code>#UBIDI_OUTPUT_REVERSE</code> of
+ * <code>ubidi_writeReordered</code> has no useful meaning and should not be
+ * used in conjunction with any value of the reordering mode specifying
+ * "inverse Bidi" or with value <code>UBIDI_REORDER_RUNS_ONLY</code>.
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ * @param reorderingMode specifies the required variant of the Bidi algorithm.
+ *
+ * @see UBiDiReorderingMode
+ * @see ubidi_setInverse
+ * @see ubidi_setPara
+ * @see ubidi_writeReordered
+ * @stable ICU 3.6
+ */
+U_STABLE void U_EXPORT2
+ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
+
+/**
+ * What is the requested reordering mode for a given Bidi object?
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ * @return the current reordering mode of the Bidi object
+ * @see ubidi_setReorderingMode
+ * @stable ICU 3.6
+ */
+U_STABLE UBiDiReorderingMode U_EXPORT2
+ubidi_getReorderingMode(UBiDi *pBiDi);
+
+/**
+ * <code>UBiDiReorderingOption</code> values indicate which options are
+ * specified to affect the Bidi algorithm.
+ *
+ * @see ubidi_setReorderingOptions
+ * @stable ICU 3.6
+ */
+typedef enum UBiDiReorderingOption {
+    /**
+     * option value for <code>ubidi_setReorderingOptions</code>:
+     * disable all the options which can be set with this function
+     * @see ubidi_setReorderingOptions
+     * @stable ICU 3.6
+     */
+    UBIDI_OPTION_DEFAULT = 0,
+
+    /**
+     * option bit for <code>ubidi_setReorderingOptions</code>:
+     * insert Bidi marks (LRM or RLM) when needed to ensure correct result of
+     * a reordering to a Logical order
+     *
+     * <p>This option must be set or reset before calling
+     * <code>ubidi_setPara</code>.</p>
+     *
+     * <p>This option is significant only with reordering modes which generate
+     * a result with Logical order, specifically:</p>
+     * <ul>
+     *   <li><code>#UBIDI_REORDER_RUNS_ONLY</code></li>
+     *   <li><code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code></li>
+     *   <li><code>#UBIDI_REORDER_INVERSE_LIKE_DIRECT</code></li>
+     *   <li><code>#UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code></li>
+     * </ul>
+     *
+     * <p>If this option is set in conjunction with reordering mode
+     * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> or with calling
+     * <code>ubidi_setInverse(TRUE)</code>, it implies
+     * option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code>
+     * in calls to function <code>ubidi_writeReordered()</code>.</p>
+     *
+     * <p>For other reordering modes, a minimum number of LRM or RLM characters
+     * will be added to the source text after reordering it so as to ensure
+     * round trip, i.e. when applying the inverse reordering mode on the
+     * resulting logical text with removal of Bidi marks
+     * (option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> set before calling
+     * <code>ubidi_setPara()</code> or option <code>#UBIDI_REMOVE_BIDI_CONTROLS</code>
+     * in <code>ubidi_writeReordered</code>), the result will be identical to the
+     * source text in the first transformation.
+     *
+     * <p>This option will be ignored if specified together with option
+     * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>. It inhibits option
+     * <code>UBIDI_REMOVE_BIDI_CONTROLS</code> in calls to function
+     * <code>ubidi_writeReordered()</code> and it implies option
+     * <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls to function
+     * <code>ubidi_writeReordered()</code> if the reordering mode is
+     * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.</p>
+     *
+     * @see ubidi_setReorderingMode
+     * @see ubidi_setReorderingOptions
+     * @stable ICU 3.6
+     */
+    UBIDI_OPTION_INSERT_MARKS = 1,
+
+    /**
+     * option bit for <code>ubidi_setReorderingOptions</code>:
+     * remove Bidi control characters
+     *
+     * <p>This option must be set or reset before calling
+     * <code>ubidi_setPara</code>.</p>
+     *
+     * <p>This option nullifies option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
+     * It inhibits option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls
+     * to function <code>ubidi_writeReordered()</code> and it implies option
+     * <code>#UBIDI_REMOVE_BIDI_CONTROLS</code> in calls to that function.</p>
+     *
+     * @see ubidi_setReorderingMode
+     * @see ubidi_setReorderingOptions
+     * @stable ICU 3.6
+     */
+    UBIDI_OPTION_REMOVE_CONTROLS = 2,
+
+    /**
+     * option bit for <code>ubidi_setReorderingOptions</code>:
+     * process the output as part of a stream to be continued
+     *
+     * <p>This option must be set or reset before calling
+     * <code>ubidi_setPara</code>.</p>
+     *
+     * <p>This option specifies that the caller is interested in processing large
+     * text object in parts.
+     * The results of the successive calls are expected to be concatenated by the
+     * caller. Only the call for the last part will have this option bit off.</p>
+     *
+     * <p>When this option bit is on, <code>ubidi_setPara()</code> may process
+     * less than the full source text in order to truncate the text at a meaningful
+     * boundary. The caller should call <code>ubidi_getProcessedLength()</code>
+     * immediately after calling <code>ubidi_setPara()</code> in order to
+     * determine how much of the source text has been processed.
+     * Source text beyond that length should be resubmitted in following calls to
+     * <code>ubidi_setPara</code>. The processed length may be less than
+     * the length of the source text if a character preceding the last character of
+     * the source text constitutes a reasonable boundary (like a block separator)
+     * for text to be continued.<br>
+     * If the last character of the source text constitutes a reasonable
+     * boundary, the whole text will be processed at once.<br>
+     * If nowhere in the source text there exists
+     * such a reasonable boundary, the processed length will be zero.<br>
+     * The caller should check for such an occurrence and do one of the following:
+     * <ul><li>submit a larger amount of text with a better chance to include
+     *         a reasonable boundary.</li>
+     *     <li>resubmit the same text after turning off option
+     *         <code>UBIDI_OPTION_STREAMING</code>.</li></ul>
+     * In all cases, this option should be turned off before processing the last
+     * part of the text.</p>
+     *
+     * <p>When the <code>UBIDI_OPTION_STREAMING</code> option is used,
+     * it is recommended to call <code>ubidi_orderParagraphsLTR()</code> with
+     * argument <code>orderParagraphsLTR</code> set to <code>TRUE</code> before
+     * calling <code>ubidi_setPara</code> so that later paragraphs may be
+     * concatenated to previous paragraphs on the right.</p>
+     *
+     * @see ubidi_setReorderingMode
+     * @see ubidi_setReorderingOptions
+     * @see ubidi_getProcessedLength
+     * @see ubidi_orderParagraphsLTR
+     * @stable ICU 3.6
+     */
+    UBIDI_OPTION_STREAMING = 4
+} UBiDiReorderingOption;
+
+/**
+ * Specify which of the reordering options
+ * should be applied during Bidi transformations.
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ * @param reorderingOptions is a combination of zero or more of the following
+ * options:
+ * <code>#UBIDI_OPTION_DEFAULT</code>, <code>#UBIDI_OPTION_INSERT_MARKS</code>,
+ * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>, <code>#UBIDI_OPTION_STREAMING</code>.
+ *
+ * @see ubidi_getReorderingOptions
+ * @stable ICU 3.6
+ */
+U_STABLE void U_EXPORT2
+ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
+
+/**
+ * What are the reordering options applied to a given Bidi object?
+ *
+ * @param pBiDi is a <code>UBiDi</code> object.
+ * @return the current reordering options of the Bidi object
+ * @see ubidi_setReorderingOptions
+ * @stable ICU 3.6
+ */
+U_STABLE uint32_t U_EXPORT2
+ubidi_getReorderingOptions(UBiDi *pBiDi);
+
+/**
+ * Perform the Unicode Bidi algorithm. It is defined in the
+ * <a href="http://www.unicode.org/unicode/reports/tr9/">Unicode Standard Anned #9</a>,
+ * version 13,
+ * also described in The Unicode Standard, Version 4.0 .<p>
+ *
+ * This function takes a piece of plain text containing one or more paragraphs,
+ * with or without externally specified embedding levels from <i>styled</i>
+ * text and computes the left-right-directionality of each character.<p>
+ *
+ * If the entire text is all of the same directionality, then
+ * the function may not perform all the steps described by the algorithm,
+ * i.e., some levels may not be the same as if all steps were performed.
+ * This is not relevant for unidirectional text.<br>
+ * For example, in pure LTR text with numbers the numbers would get
+ * a resolved level of 2 higher than the surrounding text according to
+ * the algorithm. This implementation may set all resolved levels to
+ * the same value in such a case.<p>
+ *
+ * The text can be composed of multiple paragraphs. Occurrence of a block
+ * separator in the text terminates a paragraph, and whatever comes next starts
+ * a new paragraph. The exception to this rule is when a Carriage Return (CR)
+ * is followed by a Line Feed (LF). Both CR and LF are block separators, but
+ * in that case, the pair of characters is considered as terminating the
+ * preceding paragraph, and a new paragraph will be started by a character
+ * coming after the LF.
+ *
+ * @param pBiDi A <code>UBiDi</code> object allocated with <code>ubidi_open()</code>
+ *        which will be set to contain the reordering information,
+ *        especially the resolved levels for all the characters in <code>text</code>.
+ *
+ * @param text is a pointer to the text that the Bidi algorithm will be performed on.
+ *        This pointer is stored in the UBiDi object and can be retrieved
+ *        with <code>ubidi_getText()</code>.<br>
+ *        <strong>Note:</strong> the text must be (at least) <code>length</code> long.
+ *
+ * @param length is the length of the text; if <code>length==-1</code> then
+ *        the text must be zero-terminated.
+ *
+ * @param paraLevel specifies the default level for the text;
+ *        it is typically 0 (LTR) or 1 (RTL).
+ *        If the function shall determine the paragraph level from the text,
+ *        then <code>paraLevel</code> can be set to
+ *        either <code>#UBIDI_DEFAULT_LTR</code>
+ *        or <code>#UBIDI_DEFAULT_RTL</code>; if the text contains multiple
+ *        paragraphs, the paragraph level shall be determined separately for
+ *        each paragraph; if a paragraph does not include any strongly typed
+ *        character, then the desired default is used (0 for LTR or 1 for RTL).
+ *        Any other value between 0 and <code>#UBIDI_MAX_EXPLICIT_LEVEL</code>
+ *        is also valid, with odd levels indicating RTL.
+ *
+ * @param embeddingLevels (in) may be used to preset the embedding and override levels,
+ *        ignoring characters like LRE and PDF in the text.
+ *        A level overrides the directional property of its corresponding
+ *        (same index) character if the level has the
+ *        <code>#UBIDI_LEVEL_OVERRIDE</code> bit set.<br><br>
+ *        Except for that bit, it must be
+ *        <code>paraLevel<=embeddingLevels[]<=UBIDI_MAX_EXPLICIT_LEVEL</code>,
+ *        with one exception: a level of zero may be specified for a paragraph
+ *        separator even if <code>paraLevel>0</code> when multiple paragraphs
+ *        are submitted in the same call to <code>ubidi_setPara()</code>.<br><br>
+ *        <strong>Caution: </strong>A copy of this pointer, not of the levels,
+ *        will be stored in the <code>UBiDi</code> object;
+ *        the <code>embeddingLevels</code> array must not be
+ *        deallocated before the <code>UBiDi</code> structure is destroyed or reused,
+ *        and the <code>embeddingLevels</code>
+ *        should not be modified to avoid unexpected results on subsequent Bidi operations.
+ *        However, the <code>ubidi_setPara()</code> and
+ *        <code>ubidi_setLine()</code> functions may modify some or all of the levels.<br><br>
+ *        After the <code>UBiDi</code> object is reused or destroyed, the caller
+ *        must take care of the deallocation of the <code>embeddingLevels</code> array.<br><br>
+ *        <strong>Note:</strong> the <code>embeddingLevels</code> array must be
+ *        at least <code>length</code> long.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
+              UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
+              UErrorCode *pErrorCode);
+
+/**
+ * <code>ubidi_setLine()</code> sets a <code>UBiDi</code> to
+ * contain the reordering information, especially the resolved levels,
+ * for all the characters in a line of text. This line of text is
+ * specified by referring to a <code>UBiDi</code> object representing
+ * this information for a piece of text containing one or more paragraphs,
+ * and by specifying a range of indexes in this text.<p>
+ * In the new line object, the indexes will range from 0 to <code>limit-start-1</code>.<p>
+ *
+ * This is used after calling <code>ubidi_setPara()</code>
+ * for a piece of text, and after line-breaking on that text.
+ * It is not necessary if each paragraph is treated as a single line.<p>
+ *
+ * After line-breaking, rules (L1) and (L2) for the treatment of
+ * trailing WS and for reordering are performed on
+ * a <code>UBiDi</code> object that represents a line.<p>
+ *
+ * <strong>Important: </strong><code>pLineBiDi</code> shares data with
+ * <code>pParaBiDi</code>.
+ * You must destroy or reuse <code>pLineBiDi</code> before <code>pParaBiDi</code>.
+ * In other words, you must destroy or reuse the <code>UBiDi</code> object for a line
+ * before the object for its parent paragraph.<p>
+ *
+ * The text pointer that was stored in <code>pParaBiDi</code> is also copied,
+ * and <code>start</code> is added to it so that it points to the beginning of the
+ * line for this object.
+ *
+ * @param pParaBiDi is the parent paragraph object. It must have been set
+ * by a successful call to ubidi_setPara.
+ *
+ * @param start is the line's first index into the text.
+ *
+ * @param limit is just behind the line's last index into the text
+ *        (its last index +1).<br>
+ *        It must be <code>0<=start<limit<=</code>containing paragraph limit.
+ *        If the specified line crosses a paragraph boundary, the function
+ *        will terminate with error code U_ILLEGAL_ARGUMENT_ERROR.
+ *
+ * @param pLineBiDi is the object that will now represent a line of the text.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @see ubidi_setPara
+ * @see ubidi_getProcessedLength
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_setLine(const UBiDi *pParaBiDi,
+              int32_t start, int32_t limit,
+              UBiDi *pLineBiDi,
+              UErrorCode *pErrorCode);
+
+/**
+ * Get the directionality of the text.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @return a value of <code>UBIDI_LTR</code>, <code>UBIDI_RTL</code>
+ *         or <code>UBIDI_MIXED</code>
+ *         that indicates if the entire text
+ *         represented by this object is unidirectional,
+ *         and which direction, or if it is mixed-directional.
+ *
+ * @see UBiDiDirection
+ * @stable ICU 2.0
+ */
+U_STABLE UBiDiDirection U_EXPORT2
+ubidi_getDirection(const UBiDi *pBiDi);
+
+/**
+ * Get the pointer to the text.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @return The pointer to the text that the UBiDi object was created for.
+ *
+ * @see ubidi_setPara
+ * @see ubidi_setLine
+ * @stable ICU 2.0
+ */
+U_STABLE const UChar * U_EXPORT2
+ubidi_getText(const UBiDi *pBiDi);
+
+/**
+ * Get the length of the text.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @return The length of the text that the UBiDi object was created for.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_getLength(const UBiDi *pBiDi);
+
+/**
+ * Get the paragraph level of the text.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @return The paragraph level. If there are multiple paragraphs, their
+ *         level may vary if the required paraLevel is UBIDI_DEFAULT_LTR or
+ *         UBIDI_DEFAULT_RTL.  In that case, the level of the first paragraph
+ *         is returned.
+ *
+ * @see UBiDiLevel
+ * @see ubidi_getParagraph
+ * @see ubidi_getParagraphByIndex
+ * @stable ICU 2.0
+ */
+U_STABLE UBiDiLevel U_EXPORT2
+ubidi_getParaLevel(const UBiDi *pBiDi);
+
+/**
+ * Get the number of paragraphs.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @return The number of paragraphs.
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_countParagraphs(UBiDi *pBiDi);
+
+/**
+ * Get a paragraph, given a position within the text.
+ * This function returns information about a paragraph.<br>
+ * Note: if the paragraph index is known, it is more efficient to
+ * retrieve the paragraph information using ubidi_getParagraphByIndex().<p>
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param charIndex is the index of a character within the text, in the
+ *        range <code>[0..ubidi_getProcessedLength(pBiDi)-1]</code>.
+ *
+ * @param pParaStart will receive the index of the first character of the
+ *        paragraph in the text.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @param pParaLimit will receive the limit of the paragraph.
+ *        The l-value that you point to here may be the
+ *        same expression (variable) as the one for
+ *        <code>charIndex</code>.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @param pParaLevel will receive the level of the paragraph.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return The index of the paragraph containing the specified position.
+ *
+ * @see ubidi_getProcessedLength
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
+                   int32_t *pParaLimit, UBiDiLevel *pParaLevel,
+                   UErrorCode *pErrorCode);
+
+/**
+ * Get a paragraph, given the index of this paragraph.
+ *
+ * This function returns information about a paragraph.<p>
+ *
+ * @param pBiDi is the paragraph <code>UBiDi</code> object.
+ *
+ * @param paraIndex is the number of the paragraph, in the
+ *        range <code>[0..ubidi_countParagraphs(pBiDi)-1]</code>.
+ *
+ * @param pParaStart will receive the index of the first character of the
+ *        paragraph in the text.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @param pParaLimit will receive the limit of the paragraph.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @param pParaLevel will receive the level of the paragraph.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
+                          int32_t *pParaStart, int32_t *pParaLimit,
+                          UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
+
+/**
+ * Get the level for one character.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param charIndex the index of a character. It must be in the range
+ *         [0..ubidi_getProcessedLength(pBiDi)].
+ *
+ * @return The level for the character at charIndex (0 if charIndex is not
+ *         in the valid range).
+ *
+ * @see UBiDiLevel
+ * @see ubidi_getProcessedLength
+ * @stable ICU 2.0
+ */
+U_STABLE UBiDiLevel U_EXPORT2
+ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
+
+/**
+ * Get an array of levels for each character.<p>
+ *
+ * Note that this function may allocate memory under some
+ * circumstances, unlike <code>ubidi_getLevelAt()</code>.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object, whose
+ *        text length must be strictly positive.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return The levels array for the text,
+ *         or <code>NULL</code> if an error occurs.
+ *
+ * @see UBiDiLevel
+ * @see ubidi_getProcessedLength
+ * @stable ICU 2.0
+ */
+U_STABLE const UBiDiLevel * U_EXPORT2
+ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
+
+/**
+ * Get a logical run.
+ * This function returns information about a run and is used
+ * to retrieve runs in logical order.<p>
+ * This is especially useful for line-breaking on a paragraph.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param logicalPosition is a logical position within the source text.
+ *
+ * @param pLogicalLimit will receive the limit of the corresponding run.
+ *        The l-value that you point to here may be the
+ *        same expression (variable) as the one for
+ *        <code>logicalPosition</code>.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @param pLevel will receive the level of the corresponding run.
+ *        This pointer can be <code>NULL</code> if this
+ *        value is not necessary.
+ *
+ * @see ubidi_getProcessedLength
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
+                    int32_t *pLogicalLimit, UBiDiLevel *pLevel);
+
+/**
+ * Get the number of runs.
+ * This function may invoke the actual reordering on the
+ * <code>UBiDi</code> object, after <code>ubidi_setPara()</code>
+ * may have resolved only the levels of the text. Therefore,
+ * <code>ubidi_countRuns()</code> may have to allocate memory,
+ * and may fail doing so.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return The number of runs.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
+
+/**
+ * Get one run's logical start, length, and directionality,
+ * which can be 0 for LTR or 1 for RTL.
+ * In an RTL run, the character at the logical start is
+ * visually on the right of the displayed run.
+ * The length is the number of characters in the run.<p>
+ * <code>ubidi_countRuns()</code> should be called
+ * before the runs are retrieved.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param runIndex is the number of the run in visual order, in the
+ *        range <code>[0..ubidi_countRuns(pBiDi)-1]</code>.
+ *
+ * @param pLogicalStart is the first logical character index in the text.
+ *        The pointer may be <code>NULL</code> if this index is not needed.
+ *
+ * @param pLength is the number of characters (at least one) in the run.
+ *        The pointer may be <code>NULL</code> if this is not needed.
+ *
+ * @return the directionality of the run,
+ *         <code>UBIDI_LTR==0</code> or <code>UBIDI_RTL==1</code>,
+ *         never <code>UBIDI_MIXED</code>.
+ *
+ * @see ubidi_countRuns
+ *
+ * Example:
+ * <pre>
+ * \code
+ * int32_t i, count=ubidi_countRuns(pBiDi),
+ *         logicalStart, visualIndex=0, length;
+ * for(i=0; i<count; ++i) {
+ *    if(UBIDI_LTR==ubidi_getVisualRun(pBiDi, i, &logicalStart, &length)) {
+ *         do { // LTR
+ *             show_char(text[logicalStart++], visualIndex++);
+ *         } while(--length>0);
+ *     } else {
+ *         logicalStart+=length;  // logicalLimit
+ *         do { // RTL
+ *             show_char(text[--logicalStart], visualIndex++);
+ *         } while(--length>0);
+ *     }
+ * }
+ *\endcode
+ * </pre>
+ *
+ * Note that in right-to-left runs, code like this places
+ * second surrogates before first ones (which is generally a bad idea)
+ * and combining characters before base characters.
+ * <p>
+ * Use of <code>ubidi_writeReordered()</code>, optionally with the
+ * <code>#UBIDI_KEEP_BASE_COMBINING</code> option, can be considered in order
+ * to avoid these issues.
+ * @stable ICU 2.0
+ */
+U_STABLE UBiDiDirection U_EXPORT2
+ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
+                   int32_t *pLogicalStart, int32_t *pLength);
+
+/**
+ * Get the visual position from a logical text position.
+ * If such a mapping is used many times on the same
+ * <code>UBiDi</code> object, then calling
+ * <code>ubidi_getLogicalMap()</code> is more efficient.<p>
+ *
+ * The value returned may be <code>#UBIDI_MAP_NOWHERE</code> if there is no
+ * visual position because the corresponding text character is a Bidi control
+ * removed from output by the option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>.
+ * <p>
+ * When the visual output is altered by using options of
+ * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
+ * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
+ * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the visual position returned may not
+ * be correct. It is advised to use, when possible, reordering options
+ * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
+ * <p>
+ * Note that in right-to-left runs, this mapping places
+ * second surrogates before first ones (which is generally a bad idea)
+ * and combining characters before base characters.
+ * Use of <code>ubidi_writeReordered()</code>, optionally with the
+ * <code>#UBIDI_KEEP_BASE_COMBINING</code> option can be considered instead
+ * of using the mapping, in order to avoid these issues.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param logicalIndex is the index of a character in the text.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return The visual position of this character.
+ *
+ * @see ubidi_getLogicalMap
+ * @see ubidi_getLogicalIndex
+ * @see ubidi_getProcessedLength
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
+
+/**
+ * Get the logical text position from a visual position.
+ * If such a mapping is used many times on the same
+ * <code>UBiDi</code> object, then calling
+ * <code>ubidi_getVisualMap()</code> is more efficient.<p>
+ *
+ * The value returned may be <code>#UBIDI_MAP_NOWHERE</code> if there is no
+ * logical position because the corresponding text character is a Bidi mark
+ * inserted in the output by option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
+ * <p>
+ * This is the inverse function to <code>ubidi_getVisualIndex()</code>.
+ * <p>
+ * When the visual output is altered by using options of
+ * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
+ * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
+ * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the logical position returned may not
+ * be correct. It is advised to use, when possible, reordering options
+ * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param visualIndex is the visual position of a character.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return The index of this character in the text.
+ *
+ * @see ubidi_getVisualMap
+ * @see ubidi_getVisualIndex
+ * @see ubidi_getResultLength
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
+
+/**
+ * Get a logical-to-visual index map (array) for the characters in the UBiDi
+ * (paragraph or line) object.
+ * <p>
+ * Some values in the map may be <code>#UBIDI_MAP_NOWHERE</code> if the
+ * corresponding text characters are Bidi controls removed from the visual
+ * output by the option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>.
+ * <p>
+ * When the visual output is altered by using options of
+ * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
+ * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
+ * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the visual positions returned may not
+ * be correct. It is advised to use, when possible, reordering options
+ * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
+ * <p>
+ * Note that in right-to-left runs, this mapping places
+ * second surrogates before first ones (which is generally a bad idea)
+ * and combining characters before base characters.
+ * Use of <code>ubidi_writeReordered()</code>, optionally with the
+ * <code>#UBIDI_KEEP_BASE_COMBINING</code> option can be considered instead
+ * of using the mapping, in order to avoid these issues.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param indexMap is a pointer to an array of <code>ubidi_getProcessedLength()</code>
+ *        indexes which will reflect the reordering of the characters.
+ *        If option <code>#UBIDI_OPTION_INSERT_MARKS</code> is set, the number
+ *        of elements allocated in <code>indexMap</code> must be no less than
+ *        <code>ubidi_getResultLength()</code>.
+ *        The array does not need to be initialized.<br><br>
+ *        The index map will result in <code>indexMap[logicalIndex]==visualIndex</code>.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @see ubidi_getVisualMap
+ * @see ubidi_getVisualIndex
+ * @see ubidi_getProcessedLength
+ * @see ubidi_getResultLength
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
+
+/**
+ * Get a visual-to-logical index map (array) for the characters in the UBiDi
+ * (paragraph or line) object.
+ * <p>
+ * Some values in the map may be <code>#UBIDI_MAP_NOWHERE</code> if the
+ * corresponding text characters are Bidi marks inserted in the visual output
+ * by the option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
+ * <p>
+ * When the visual output is altered by using options of
+ * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
+ * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
+ * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the logical positions returned may not
+ * be correct. It is advised to use, when possible, reordering options
+ * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
+ *
+ * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
+ *
+ * @param indexMap is a pointer to an array of <code>ubidi_getResultLength()</code>
+ *        indexes which will reflect the reordering of the characters.
+ *        If option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> is set, the number
+ *        of elements allocated in <code>indexMap</code> must be no less than
+ *        <code>ubidi_getProcessedLength()</code>.
+ *        The array does not need to be initialized.<br><br>
+ *        The index map will result in <code>indexMap[visualIndex]==logicalIndex</code>.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @see ubidi_getLogicalMap
+ * @see ubidi_getLogicalIndex
+ * @see ubidi_getProcessedLength
+ * @see ubidi_getResultLength
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
+
+/**
+ * This is a convenience function that does not use a UBiDi object.
+ * It is intended to be used for when an application has determined the levels
+ * of objects (character sequences) and just needs to have them reordered (L2).
+ * This is equivalent to using <code>ubidi_getLogicalMap()</code> on a
+ * <code>UBiDi</code> object.
+ *
+ * @param levels is an array with <code>length</code> levels that have been determined by
+ *        the application.
+ *
+ * @param length is the number of levels in the array, or, semantically,
+ *        the number of objects to be reordered.
+ *        It must be <code>length>0</code>.
+ *
+ * @param indexMap is a pointer to an array of <code>length</code>
+ *        indexes which will reflect the reordering of the characters.
+ *        The array does not need to be initialized.<p>
+ *        The index map will result in <code>indexMap[logicalIndex]==visualIndex</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
+
+/**
+ * This is a convenience function that does not use a UBiDi object.
+ * It is intended to be used for when an application has determined the levels
+ * of objects (character sequences) and just needs to have them reordered (L2).
+ * This is equivalent to using <code>ubidi_getVisualMap()</code> on a
+ * <code>UBiDi</code> object.
+ *
+ * @param levels is an array with <code>length</code> levels that have been determined by
+ *        the application.
+ *
+ * @param length is the number of levels in the array, or, semantically,
+ *        the number of objects to be reordered.
+ *        It must be <code>length>0</code>.
+ *
+ * @param indexMap is a pointer to an array of <code>length</code>
+ *        indexes which will reflect the reordering of the characters.
+ *        The array does not need to be initialized.<p>
+ *        The index map will result in <code>indexMap[visualIndex]==logicalIndex</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
+
+/**
+ * Invert an index map.
+ * The index mapping of the first map is inverted and written to
+ * the second one.
+ *
+ * @param srcMap is an array with <code>length</code> elements
+ *        which defines the original mapping from a source array containing
+ *        <code>length</code> elements to a destination array.
+ *        Some elements of the source array may have no mapping in the
+ *        destination array. In that case, their value will be
+ *        the special value <code>UBIDI_MAP_NOWHERE</code>.
+ *        All elements must be >=0 or equal to <code>UBIDI_MAP_NOWHERE</code>.
+ *        Some elements may have a value >= <code>length</code>, if the
+ *        destination array has more elements than the source array.
+ *        There must be no duplicate indexes (two or more elements with the
+ *        same value except <code>UBIDI_MAP_NOWHERE</code>).
+ *
+ * @param destMap is an array with a number of elements equal to 1 + the highest
+ *        value in <code>srcMap</code>.
+ *        <code>destMap</code> will be filled with the inverse mapping.
+ *        If element with index i in <code>srcMap</code> has a value k different
+ *        from <code>UBIDI_MAP_NOWHERE</code>, this means that element i of
+ *        the source array maps to element k in the destination array.
+ *        The inverse map will have value i in its k-th element.
+ *        For all elements of the destination array which do not map to
+ *        an element in the source array, the corresponding element in the
+ *        inverse map will have a value equal to <code>UBIDI_MAP_NOWHERE</code>.
+ *
+ * @param length is the length of each array.
+ * @see UBIDI_MAP_NOWHERE
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
+
+/** option flags for ubidi_writeReordered() */
+
+/**
+ * option bit for ubidi_writeReordered():
+ * keep combining characters after their base characters in RTL runs
+ *
+ * @see ubidi_writeReordered
+ * @stable ICU 2.0
+ */
+#define UBIDI_KEEP_BASE_COMBINING       1
+
+/**
+ * option bit for ubidi_writeReordered():
+ * replace characters with the "mirrored" property in RTL runs
+ * by their mirror-image mappings
+ *
+ * @see ubidi_writeReordered
+ * @stable ICU 2.0
+ */
+#define UBIDI_DO_MIRRORING              2
+
+/**
+ * option bit for ubidi_writeReordered():
+ * surround the run with LRMs if necessary;
+ * this is part of the approximate "inverse Bidi" algorithm
+ *
+ * <p>This option does not imply corresponding adjustment of the index
+ * mappings.</p>
+ *
+ * @see ubidi_setInverse
+ * @see ubidi_writeReordered
+ * @stable ICU 2.0
+ */
+#define UBIDI_INSERT_LRM_FOR_NUMERIC    4
+
+/**
+ * option bit for ubidi_writeReordered():
+ * remove Bidi control characters
+ * (this does not affect #UBIDI_INSERT_LRM_FOR_NUMERIC)
+ *
+ * <p>This option does not imply corresponding adjustment of the index
+ * mappings.</p>
+ *
+ * @see ubidi_writeReordered
+ * @stable ICU 2.0
+ */
+#define UBIDI_REMOVE_BIDI_CONTROLS      8
+
+/**
+ * option bit for ubidi_writeReordered():
+ * write the output in reverse order
+ *
+ * <p>This has the same effect as calling <code>ubidi_writeReordered()</code>
+ * first without this option, and then calling
+ * <code>ubidi_writeReverse()</code> without mirroring.
+ * Doing this in the same step is faster and avoids a temporary buffer.
+ * An example for using this option is output to a character terminal that
+ * is designed for RTL scripts and stores text in reverse order.</p>
+ *
+ * @see ubidi_writeReordered
+ * @stable ICU 2.0
+ */
+#define UBIDI_OUTPUT_REVERSE            16
+
+/**
+ * Get the length of the source text processed by the last call to
+ * <code>ubidi_setPara()</code>. This length may be different from the length
+ * of the source text if option <code>#UBIDI_OPTION_STREAMING</code>
+ * has been set.
+ * <br>
+ * Note that whenever the length of the text affects the execution or the
+ * result of a function, it is the processed length which must be considered,
+ * except for <code>ubidi_setPara</code> (which receives unprocessed source
+ * text) and <code>ubidi_getLength</code> (which returns the original length
+ * of the source text).<br>
+ * In particular, the processed length is the one to consider in the following
+ * cases:
+ * <ul>
+ * <li>maximum value of the <code>limit</code> argument of
+ * <code>ubidi_setLine</code></li>
+ * <li>maximum value of the <code>charIndex</code> argument of
+ * <code>ubidi_getParagraph</code></li>
+ * <li>maximum value of the <code>charIndex</code> argument of
+ * <code>ubidi_getLevelAt</code></li>
+ * <li>number of elements in the array returned by <code>ubidi_getLevels</code></li>
+ * <li>maximum value of the <code>logicalStart</code> argument of
+ * <code>ubidi_getLogicalRun</code></li>
+ * <li>maximum value of the <code>logicalIndex</code> argument of
+ * <code>ubidi_getVisualIndex</code></li>
+ * <li>number of elements filled in the <code>*indexMap</code> argument of
+ * <code>ubidi_getLogicalMap</code></li>
+ * <li>length of text processed by <code>ubidi_writeReordered</code></li>
+ * </ul>
+ *
+ * @param pBiDi is the paragraph <code>UBiDi</code> object.
+ *
+ * @return The length of the part of the source text processed by
+ *         the last call to <code>ubidi_setPara</code>.
+ * @see ubidi_setPara
+ * @see UBIDI_OPTION_STREAMING
+ * @stable ICU 3.6
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_getProcessedLength(const UBiDi *pBiDi);
+
+/**
+ * Get the length of the reordered text resulting from the last call to
+ * <code>ubidi_setPara()</code>. This length may be different from the length
+ * of the source text if option <code>#UBIDI_OPTION_INSERT_MARKS</code>
+ * or option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> has been set.
+ * <br>
+ * This resulting length is the one to consider in the following cases:
+ * <ul>
+ * <li>maximum value of the <code>visualIndex</code> argument of
+ * <code>ubidi_getLogicalIndex</code></li>
+ * <li>number of elements of the <code>*indexMap</code> argument of
+ * <code>ubidi_getVisualMap</code></li>
+ * </ul>
+ * Note that this length stays identical to the source text length if
+ * Bidi marks are inserted or removed using option bits of
+ * <code>ubidi_writeReordered</code>, or if option
+ * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> has been set.
+ *
+ * @param pBiDi is the paragraph <code>UBiDi</code> object.
+ *
+ * @return The length of the reordered text resulting from
+ *         the last call to <code>ubidi_setPara</code>.
+ * @see ubidi_setPara
+ * @see UBIDI_OPTION_INSERT_MARKS
+ * @see UBIDI_OPTION_REMOVE_CONTROLS
+ * @stable ICU 3.6
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_getResultLength(const UBiDi *pBiDi);
+
+U_CDECL_BEGIN
+/**
+ * value returned by <code>UBiDiClassCallback</code> callbacks when
+ * there is no need to override the standard Bidi class for a given code point.
+ * @see UBiDiClassCallback
+ * @stable ICU 3.6
+ */
+#define U_BIDI_CLASS_DEFAULT  U_CHAR_DIRECTION_COUNT
+
+/**
+ * Callback type declaration for overriding default Bidi class values with
+ * custom ones.
+ * <p>Usually, the function pointer will be propagated to a <code>UBiDi</code>
+ * object by calling the <code>ubidi_setClassCallback()</code> function;
+ * then the callback will be invoked by the UBA implementation any time the
+ * class of a character is to be determined.</p>
+ *
+ * @param context is a pointer to the callback private data.
+ *
+ * @param c       is the code point to get a Bidi class for.
+ *
+ * @return The directional property / Bidi class for the given code point
+ *         <code>c</code> if the default class has been overridden, or
+ *         <code>#U_BIDI_CLASS_DEFAULT</code> if the standard Bidi class value
+ *         for <code>c</code> is to be used.
+ * @see ubidi_setClassCallback
+ * @see ubidi_getClassCallback
+ * @stable ICU 3.6
+ */
+typedef UCharDirection U_CALLCONV
+UBiDiClassCallback(const void *context, UChar32 c);
+
+U_CDECL_END
+
+/**
+ * Retrieve the Bidi class for a given code point.
+ * <p>If a <code>#UBiDiClassCallback</code> callback is defined and returns a
+ * value other than <code>#U_BIDI_CLASS_DEFAULT</code>, that value is used;
+ * otherwise the default class determination mechanism is invoked.</p>
+ *
+ * @param pBiDi is the paragraph <code>UBiDi</code> object.
+ *
+ * @param c     is the code point whose Bidi class must be retrieved.
+ *
+ * @return The Bidi class for character <code>c</code> based
+ *         on the given <code>pBiDi</code> instance.
+ * @see UBiDiClassCallback
+ * @stable ICU 3.6
+ */
+U_STABLE UCharDirection U_EXPORT2
+ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
+
+/**
+ * Set the callback function and callback data used by the UBA
+ * implementation for Bidi class determination.
+ * <p>This may be useful for assigning Bidi classes to PUA characters, or
+ * for special application needs. For instance, an application may want to
+ * handle all spaces like L or R characters (according to the base direction)
+ * when creating the visual ordering of logical lines which are part of a report
+ * organized in columns: there should not be interaction between adjacent
+ * cells.<p>
+ *
+ * @param pBiDi is the paragraph <code>UBiDi</code> object.
+ *
+ * @param newFn is the new callback function pointer.
+ *
+ * @param newContext is the new callback context pointer. This can be NULL.
+ *
+ * @param oldFn fillin: Returns the old callback function pointer. This can be
+ *                      NULL.
+ *
+ * @param oldContext fillin: Returns the old callback's context. This can be
+ *                           NULL.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @see ubidi_getClassCallback
+ * @stable ICU 3.6
+ */
+U_STABLE void U_EXPORT2
+ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
+                       const void *newContext, UBiDiClassCallback **oldFn,
+                       const void **oldContext, UErrorCode *pErrorCode);
+
+/**
+ * Get the current callback function used for Bidi class determination.
+ *
+ * @param pBiDi is the paragraph <code>UBiDi</code> object.
+ *
+ * @param fn fillin: Returns the callback function pointer.
+ *
+ * @param context fillin: Returns the callback's private context.
+ *
+ * @see ubidi_setClassCallback
+ * @stable ICU 3.6
+ */
+U_STABLE void U_EXPORT2
+ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
+
+/**
+ * Take a <code>UBiDi</code> object containing the reordering
+ * information for a piece of text (one or more paragraphs) set by
+ * <code>ubidi_setPara()</code> or for a line of text set by
+ * <code>ubidi_setLine()</code> and write a reordered string to the
+ * destination buffer.
+ *
+ * This function preserves the integrity of characters with multiple
+ * code units and (optionally) combining characters.
+ * Characters in RTL runs can be replaced by mirror-image characters
+ * in the destination buffer. Note that "real" mirroring has
+ * to be done in a rendering engine by glyph selection
+ * and that for many "mirrored" characters there are no
+ * Unicode characters as mirror-image equivalents.
+ * There are also options to insert or remove Bidi control
+ * characters; see the description of the <code>destSize</code>
+ * and <code>options</code> parameters and of the option bit flags.
+ *
+ * @param pBiDi A pointer to a <code>UBiDi</code> object that
+ *              is set by <code>ubidi_setPara()</code> or
+ *              <code>ubidi_setLine()</code> and contains the reordering
+ *              information for the text that it was defined for,
+ *              as well as a pointer to that text.<br><br>
+ *              The text was aliased (only the pointer was stored
+ *              without copying the contents) and must not have been modified
+ *              since the <code>ubidi_setPara()</code> call.
+ *
+ * @param dest A pointer to where the reordered text is to be copied.
+ *             The source text and <code>dest[destSize]</code>
+ *             must not overlap.
+ *
+ * @param destSize The size of the <code>dest</code> buffer,
+ *                 in number of UChars.
+ *                 If the <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>
+ *                 option is set, then the destination length could be
+ *                 as large as
+ *                 <code>ubidi_getLength(pBiDi)+2*ubidi_countRuns(pBiDi)</code>.
+ *                 If the <code>UBIDI_REMOVE_BIDI_CONTROLS</code> option
+ *                 is set, then the destination length may be less than
+ *                 <code>ubidi_getLength(pBiDi)</code>.
+ *                 If none of these options is set, then the destination length
+ *                 will be exactly <code>ubidi_getProcessedLength(pBiDi)</code>.
+ *
+ * @param options A bit set of options for the reordering that control
+ *                how the reordered text is written.
+ *                The options include mirroring the characters on a code
+ *                point basis and inserting LRM characters, which is used
+ *                especially for transforming visually stored text
+ *                to logically stored text (although this is still an
+ *                imperfect implementation of an "inverse Bidi" algorithm
+ *                because it uses the "forward Bidi" algorithm at its core).
+ *                The available options are:
+ *                <code>#UBIDI_DO_MIRRORING</code>,
+ *                <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
+ *                <code>#UBIDI_KEEP_BASE_COMBINING</code>,
+ *                <code>#UBIDI_OUTPUT_REVERSE</code>,
+ *                <code>#UBIDI_REMOVE_BIDI_CONTROLS</code>
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return The length of the output string.
+ *
+ * @see ubidi_getProcessedLength
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_writeReordered(UBiDi *pBiDi,
+                     UChar *dest, int32_t destSize,
+                     uint16_t options,
+                     UErrorCode *pErrorCode);
+
+/**
+ * Reverse a Right-To-Left run of Unicode text.
+ *
+ * This function preserves the integrity of characters with multiple
+ * code units and (optionally) combining characters.
+ * Characters can be replaced by mirror-image characters
+ * in the destination buffer. Note that "real" mirroring has
+ * to be done in a rendering engine by glyph selection
+ * and that for many "mirrored" characters there are no
+ * Unicode characters as mirror-image equivalents.
+ * There are also options to insert or remove Bidi control
+ * characters.
+ *
+ * This function is the implementation for reversing RTL runs as part
+ * of <code>ubidi_writeReordered()</code>. For detailed descriptions
+ * of the parameters, see there.
+ * Since no Bidi controls are inserted here, the output string length
+ * will never exceed <code>srcLength</code>.
+ *
+ * @see ubidi_writeReordered
+ *
+ * @param src A pointer to the RTL run text.
+ *
+ * @param srcLength The length of the RTL run.
+ *
+ * @param dest A pointer to where the reordered text is to be copied.
+ *             <code>src[srcLength]</code> and <code>dest[destSize]</code>
+ *             must not overlap.
+ *
+ * @param destSize The size of the <code>dest</code> buffer,
+ *                 in number of UChars.
+ *                 If the <code>UBIDI_REMOVE_BIDI_CONTROLS</code> option
+ *                 is set, then the destination length may be less than
+ *                 <code>srcLength</code>.
+ *                 If this option is not set, then the destination length
+ *                 will be exactly <code>srcLength</code>.
+ *
+ * @param options A bit set of options for the reordering that control
+ *                how the reordered text is written.
+ *                See the <code>options</code> parameter in <code>ubidi_writeReordered()</code>.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value.
+ *
+ * @return The length of the output string.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubidi_writeReverse(const UChar *src, int32_t srcLength,
+                   UChar *dest, int32_t destSize,
+                   uint16_t options,
+                   UErrorCode *pErrorCode);
+
+/*#define BIDI_SAMPLE_CODE*/
+/*@}*/
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ubrk.h b/CoreFoundation/icu/unicode/ubrk.h
new file mode 100644
index 0000000..d57ba37
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ubrk.h
@@ -0,0 +1,482 @@
+/*
+******************************************************************************
+* Copyright (C) 1996-2007, International Business Machines Corporation and others.
+* All Rights Reserved.
+******************************************************************************
+*/
+
+#ifndef UBRK_H
+#define UBRK_H
+
+#include "unicode/utypes.h"
+#include "unicode/uloc.h"
+#include "unicode/utext.h"
+
+/**
+ * A text-break iterator.
+ *  For usage in C programs.
+ */
+#ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
+#   define UBRK_TYPEDEF_UBREAK_ITERATOR
+    /**
+     *  Opaque type representing an ICU Break iterator object.
+     *  @stable ICU 2.0
+     */
+    typedef void UBreakIterator;
+#endif
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+#include "unicode/parseerr.h"
+
+/**
+ * \file
+ * \brief C API: BreakIterator
+ *
+ * <h2> BreakIterator C API </h2>
+ *
+ * The BreakIterator C API defines  methods for finding the location
+ * of boundaries in text. Pointer to a UBreakIterator maintain a
+ * current position and scan over text returning the index of characters
+ * where boundaries occur.
+ * <p>
+ * Line boundary analysis determines where a text string can be broken
+ * when line-wrapping. The mechanism correctly handles punctuation and
+ * hyphenated words.
+ * <p>
+ * Sentence boundary analysis allows selection with correct
+ * interpretation of periods within numbers and abbreviations, and
+ * trailing punctuation marks such as quotation marks and parentheses.
+ * <p>
+ * Word boundary analysis is used by search and replace functions, as
+ * well as within text editing applications that allow the user to
+ * select words with a double click. Word selection provides correct
+ * interpretation of punctuation marks within and following
+ * words. Characters that are not part of a word, such as symbols or
+ * punctuation marks, have word-breaks on both sides.
+ * <p>
+ * Character boundary analysis allows users to interact with
+ * characters as they expect to, for example, when moving the cursor
+ * through a text string. Character boundary analysis provides correct
+ * navigation of through character strings, regardless of how the
+ * character is stored.  For example, an accented character might be
+ * stored as a base character and a diacritical mark. What users
+ * consider to be a character can differ between languages.
+ * <p>
+ * Title boundary analysis locates all positions,
+ * typically starts of words, that should be set to Title Case
+ * when title casing the text.
+ * <p>
+ * The text boundary positions are found according to the rules
+ * described in Unicode Standard Annex #29, Text Boundaries, and
+ * Unicode Standard Annex #14, Line Breaking Properties.  These
+ * are available at http://www.unicode.org/reports/tr14/ and
+ * http://www.unicode.org/reports/tr29/.
+ * <p>
+ * In addition to the plain C API defined in this header file, an
+ * object oriented C++ API with equivalent functionality is defined in the
+ * file brkiter.h.
+ * <p>
+ * Code snippits illustrating the use of the Break Iterator APIs
+ * are available in the ICU User Guide,
+ * http://icu-project.org/userguide/boundaryAnalysis.html
+ * and in the sample program icu/source/samples/break/break.cpp"
+ */
+
+/** The possible types of text boundaries.  @stable ICU 2.0 */
+typedef enum UBreakIteratorType {
+  /** Character breaks  @stable ICU 2.0 */
+  UBRK_CHARACTER = 0,
+  /** Word breaks @stable ICU 2.0 */
+  UBRK_WORD = 1,
+  /** Line breaks @stable ICU 2.0 */
+  UBRK_LINE = 2,
+  /** Sentence breaks @stable ICU 2.0 */
+  UBRK_SENTENCE = 3,
+
+#ifndef U_HIDE_DEPRECATED_API
+  /**
+   * Title Case breaks
+   * The iterator created using this type locates title boundaries as described for
+   * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
+   * please use Word Boundary iterator.
+   *
+   * @deprecated ICU 2.8 Use the word break iterator for titlecasing for Unicode 4 and later.
+   */
+  UBRK_TITLE = 4,
+#endif /* U_HIDE_DEPRECATED_API */
+  UBRK_COUNT = 5
+} UBreakIteratorType;
+
+/** Value indicating all text boundaries have been returned.
+ *  @stable ICU 2.0
+ */
+#define UBRK_DONE ((int32_t) -1)
+
+
+/**
+ *  Enum constants for the word break tags returned by
+ *  getRuleStatus().  A range of values is defined for each category of
+ *  word, to allow for further subdivisions of a category in future releases.
+ *  Applications should check for tag values falling within the range, rather
+ *  than for single individual values.
+ *  @stable ICU 2.2
+*/
+typedef enum UWordBreak {
+    /** Tag value for "words" that do not fit into any of other categories.
+     *  Includes spaces and most punctuation. */
+    UBRK_WORD_NONE           = 0,
+    /** Upper bound for tags for uncategorized words. */
+    UBRK_WORD_NONE_LIMIT     = 100,
+    /** Tag value for words that appear to be numbers, lower limit.    */
+    UBRK_WORD_NUMBER         = 100,
+    /** Tag value for words that appear to be numbers, upper limit.    */
+    UBRK_WORD_NUMBER_LIMIT   = 200,
+    /** Tag value for words that contain letters, excluding
+     *  hiragana, katakana or ideographic characters, lower limit.    */
+    UBRK_WORD_LETTER         = 200,
+    /** Tag value for words containing letters, upper limit  */
+    UBRK_WORD_LETTER_LIMIT   = 300,
+    /** Tag value for words containing kana characters, lower limit */
+    UBRK_WORD_KANA           = 300,
+    /** Tag value for words containing kana characters, upper limit */
+    UBRK_WORD_KANA_LIMIT     = 400,
+    /** Tag value for words containing ideographic characters, lower limit */
+    UBRK_WORD_IDEO           = 400,
+    /** Tag value for words containing ideographic characters, upper limit */
+    UBRK_WORD_IDEO_LIMIT     = 500
+} UWordBreak;
+
+/**
+ *  Enum constants for the line break tags returned by getRuleStatus().
+ *  A range of values is defined for each category of
+ *  word, to allow for further subdivisions of a category in future releases.
+ *  Applications should check for tag values falling within the range, rather
+ *  than for single individual values.
+ *  @stable ICU 2.8
+*/
+typedef enum ULineBreakTag {
+    /** Tag value for soft line breaks, positions at which a line break
+      *  is acceptable but not required                */
+    UBRK_LINE_SOFT            = 0,
+    /** Upper bound for soft line breaks.              */
+    UBRK_LINE_SOFT_LIMIT      = 100,
+    /** Tag value for a hard, or mandatory line break  */
+    UBRK_LINE_HARD            = 100,
+    /** Upper bound for hard line breaks.              */
+    UBRK_LINE_HARD_LIMIT      = 200
+} ULineBreakTag;
+
+
+
+/**
+ *  Enum constants for the sentence break tags returned by getRuleStatus().
+ *  A range of values is defined for each category of
+ *  sentence, to allow for further subdivisions of a category in future releases.
+ *  Applications should check for tag values falling within the range, rather
+ *  than for single individual values.
+ *  @stable ICU 2.8
+*/
+typedef enum USentenceBreakTag {
+    /** Tag value for for sentences  ending with a sentence terminator
+      * ('.', '?', '!', etc.) character, possibly followed by a
+      * hard separator (CR, LF, PS, etc.)
+      */
+    UBRK_SENTENCE_TERM       = 0,
+    /** Upper bound for tags for sentences ended by sentence terminators.    */
+    UBRK_SENTENCE_TERM_LIMIT = 100,
+    /** Tag value for for sentences that do not contain an ending
+      * sentence terminator ('.', '?', '!', etc.) character, but
+      * are ended only by a hard separator (CR, LF, PS, etc.) or end of input.
+      */
+    UBRK_SENTENCE_SEP        = 100,
+    /** Upper bound for tags for sentences ended by a separator.              */
+    UBRK_SENTENCE_SEP_LIMIT  = 200
+    /** Tag value for a hard, or mandatory line break  */
+} USentenceBreakTag;
+
+
+/**
+ * Open a new UBreakIterator for locating text boundaries for a specified locale.
+ * A UBreakIterator may be used for detecting character, line, word,
+ * and sentence breaks in text.
+ * @param type The type of UBreakIterator to open: one of UBRK_CHARACTER, UBRK_WORD,
+ * UBRK_LINE, UBRK_SENTENCE
+ * @param locale The locale specifying the text-breaking conventions.
+ * @param text The text to be iterated over.
+ * @param textLength The number of characters in text, or -1 if null-terminated.
+ * @param status A UErrorCode to receive any errors.
+ * @return A UBreakIterator for the specified locale.
+ * @see ubrk_openRules
+ * @stable ICU 2.0
+ */
+U_STABLE UBreakIterator* U_EXPORT2
+ubrk_open(UBreakIteratorType type,
+      const char *locale,
+      const UChar *text,
+      int32_t textLength,
+      UErrorCode *status);
+
+/**
+ * Open a new UBreakIterator for locating text boundaries using specified breaking rules.
+ * The rule syntax is ... (TBD)
+ * @param rules A set of rules specifying the text breaking conventions.
+ * @param rulesLength The number of characters in rules, or -1 if null-terminated.
+ * @param text The text to be iterated over.  May be null, in which case ubrk_setText() is
+ *        used to specify the text to be iterated.
+ * @param textLength The number of characters in text, or -1 if null-terminated.
+ * @param parseErr   Receives position and context information for any syntax errors
+ *                   detected while parsing the rules.
+ * @param status A UErrorCode to receive any errors.
+ * @return A UBreakIterator for the specified rules.
+ * @see ubrk_open
+ * @stable ICU 2.2
+ */
+U_STABLE UBreakIterator* U_EXPORT2
+ubrk_openRules(const UChar     *rules,
+               int32_t         rulesLength,
+               const UChar     *text,
+               int32_t          textLength,
+               UParseError     *parseErr,
+               UErrorCode      *status);
+
+/**
+ * Thread safe cloning operation
+ * @param bi iterator to be cloned
+ * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.
+ *  If buffer is not large enough, new memory will be allocated.
+ *  Clients can use the U_BRK_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.
+ * @param pBufferSize pointer to size of allocated space.
+ *  If *pBufferSize == 0, a sufficient size for use in cloning will
+ *  be returned ('pre-flighting')
+ *  If *pBufferSize is not enough for a stack-based safe clone,
+ *  new memory will be allocated.
+ * @param status to indicate whether the operation went on smoothly or there were errors
+ *  An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary.
+ * @return pointer to the new clone
+ * @stable ICU 2.0
+ */
+U_STABLE UBreakIterator * U_EXPORT2
+ubrk_safeClone(
+          const UBreakIterator *bi,
+          void *stackBuffer,
+          int32_t *pBufferSize,
+          UErrorCode *status);
+
+/**
+  * A recommended size (in bytes) for the memory buffer to be passed to ubrk_saveClone().
+  * @stable ICU 2.0
+  */
+#define U_BRK_SAFECLONE_BUFFERSIZE 512
+
+/**
+* Close a UBreakIterator.
+* Once closed, a UBreakIterator may no longer be used.
+* @param bi The break iterator to close.
+ * @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2
+ubrk_close(UBreakIterator *bi);
+
+/**
+ * Sets an existing iterator to point to a new piece of text
+ * @param bi The iterator to use
+ * @param text The text to be set
+ * @param textLength The length of the text
+ * @param status The error code
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ubrk_setText(UBreakIterator* bi,
+             const UChar*    text,
+             int32_t         textLength,
+             UErrorCode*     status);
+
+
+/**
+ * Sets an existing iterator to point to a new piece of text
+ * @param bi The iterator to use
+ * @param text The text to be set.
+ *             This function makes a shallow clone of the supplied UText.  This means
+ *             that the caller is free to immediately close or otherwise reuse the
+ *             UText that was passed as a parameter, but that the underlying text itself
+ *             must not be altered while being referenced by the break iterator.
+ * @param status The error code
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+ubrk_setUText(UBreakIterator* bi,
+             UText*          text,
+             UErrorCode*     status);
+
+
+
+/**
+ * Determine the most recently-returned text boundary.
+ *
+ * @param bi The break iterator to use.
+ * @return The character index most recently returned by \ref ubrk_next, \ref ubrk_previous,
+ * \ref ubrk_first, or \ref ubrk_last.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubrk_current(const UBreakIterator *bi);
+
+/**
+ * Determine the text boundary following the current text boundary.
+ *
+ * @param bi The break iterator to use.
+ * @return The character index of the next text boundary, or UBRK_DONE
+ * if all text boundaries have been returned.
+ * @see ubrk_previous
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubrk_next(UBreakIterator *bi);
+
+/**
+ * Determine the text boundary preceding the current text boundary.
+ *
+ * @param bi The break iterator to use.
+ * @return The character index of the preceding text boundary, or UBRK_DONE
+ * if all text boundaries have been returned.
+ * @see ubrk_next
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubrk_previous(UBreakIterator *bi);
+
+/**
+ * Determine the index of the first character in the text being scanned.
+ * This is not always the same as index 0 of the text.
+ * @param bi The break iterator to use.
+ * @return The character index of the first character in the text being scanned.
+ * @see ubrk_last
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubrk_first(UBreakIterator *bi);
+
+/**
+ * Determine the index immediately <EM>beyond</EM> the last character in the text being
+ * scanned.
+ * This is not the same as the last character.
+ * @param bi The break iterator to use.
+ * @return The character offset immediately <EM>beyond</EM> the last character in the
+ * text being scanned.
+ * @see ubrk_first
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubrk_last(UBreakIterator *bi);
+
+/**
+ * Determine the text boundary preceding the specified offset.
+ * The value returned is always smaller than offset, or UBRK_DONE.
+ * @param bi The break iterator to use.
+ * @param offset The offset to begin scanning.
+ * @return The text boundary preceding offset, or UBRK_DONE.
+ * @see ubrk_following
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubrk_preceding(UBreakIterator *bi,
+           int32_t offset);
+
+/**
+ * Determine the text boundary following the specified offset.
+ * The value returned is always greater than offset, or UBRK_DONE.
+ * @param bi The break iterator to use.
+ * @param offset The offset to begin scanning.
+ * @return The text boundary following offset, or UBRK_DONE.
+ * @see ubrk_preceding
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ubrk_following(UBreakIterator *bi,
+           int32_t offset);
+
+/**
+* Get a locale for which text breaking information is available.
+* A UBreakIterator in a locale returned by this function will perform the correct
+* text breaking for the locale.
+* @param index The index of the desired locale.
+* @return A locale for which number text breaking information is available, or 0 if none.
+* @see ubrk_countAvailable
+* @stable ICU 2.0
+*/
+U_STABLE const char* U_EXPORT2
+ubrk_getAvailable(int32_t index);
+
+/**
+* Determine how many locales have text breaking information available.
+* This function is most useful as determining the loop ending condition for
+* calls to \ref ubrk_getAvailable.
+* @return The number of locales for which text breaking information is available.
+* @see ubrk_getAvailable
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2
+ubrk_countAvailable(void);
+
+
+/**
+* Returns true if the specfied position is a boundary position.  As a side
+* effect, leaves the iterator pointing to the first boundary position at
+* or after "offset".
+* @param bi The break iterator to use.
+* @param offset the offset to check.
+* @return True if "offset" is a boundary position.
+* @stable ICU 2.0
+*/
+U_STABLE  UBool U_EXPORT2
+ubrk_isBoundary(UBreakIterator *bi, int32_t offset);
+
+/**
+ * Return the status from the break rule that determined the most recently
+ * returned break position.  The values appear in the rule source
+ * within brackets, {123}, for example.  For rules that do not specify a
+ * status, a default value of 0 is returned.
+ * <p>
+ * For word break iterators, the possible values are defined in enum UWordBreak.
+ * @stable ICU 2.2
+ */
+U_STABLE  int32_t U_EXPORT2
+ubrk_getRuleStatus(UBreakIterator *bi);
+
+/**
+ * Get the statuses from the break rules that determined the most recently
+ * returned break position.  The values appear in the rule source
+ * within brackets, {123}, for example.  The default status value for rules
+ * that do not explicitly provide one is zero.
+ * <p>
+ * For word break iterators, the possible values are defined in enum UWordBreak.
+ * @param bi        The break iterator to use
+ * @param fillInVec an array to be filled in with the status values.
+ * @param capacity  the length of the supplied vector.  A length of zero causes
+ *                  the function to return the number of status values, in the
+ *                  normal way, without attemtping to store any values.
+ * @param status    receives error codes.
+ * @return          The number of rule status values from rules that determined
+ *                  the most recent boundary returned by the break iterator.
+ * @stable ICU 3.0
+ */
+U_STABLE  int32_t U_EXPORT2
+ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status);
+
+/**
+ * Return the locale of the break iterator. You can choose between the valid and
+ * the actual locale.
+ * @param bi break iterator
+ * @param type locale type (valid or actual)
+ * @param status error code
+ * @return locale string
+ * @stable ICU 2.8
+ */
+U_STABLE const char* U_EXPORT2
+ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status);
+
+
+#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ucal.h b/CoreFoundation/icu/unicode/ucal.h
new file mode 100644
index 0000000..4332a66
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucal.h
@@ -0,0 +1,1128 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 1996-2008, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ */
+
+#ifndef UCAL_H
+#define UCAL_H
+
+#include "unicode/utypes.h"
+#include "unicode/uenum.h"
+#include "unicode/uloc.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+/**
+ * \file
+ * \brief C API: Calendar
+ *
+ * <h2>Calendar C API</h2>
+ *
+ * UCalendar C API is used  for converting between a <code>UDate</code> object
+ * and a set of integer fields such as <code>UCAL_YEAR</code>, <code>UCAL_MONTH</code>,
+ * <code>UCAL_DAY</code>, <code>UCAL_HOUR</code>, and so on.
+ * (A <code>UDate</code> object represents a specific instant in
+ * time with millisecond precision. See UDate
+ * for information about the <code>UDate</code> .)
+ *
+ * <p>
+ * Types of <code>UCalendar</code> interpret a <code>UDate</code>
+ * according to the rules of a specific calendar system. The U_STABLE
+ * provides the enum UCalendarType with UCAL_TRADITIONAL and
+ * UCAL_GREGORIAN.
+ * <p>
+ * Like other locale-sensitive C API, calendar API  provides a
+ * function, <code>ucal_open()</code>, which returns a pointer to
+ * <code>UCalendar</code> whose time fields have been initialized
+ * with the current date and time. We need to specify the type of
+ * calendar to be opened and the  timezoneId.
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code
+ * UCalendar *caldef;
+ * UChar *tzId;
+ * UErrorCode status;
+ * tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) );
+ * u_uastrcpy(tzId, "PST");
+ * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status);
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <p>
+ * A <code>UCalendar</code> object can produce all the time field values
+ * needed to implement the date-time formatting for a particular language
+ * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
+ *
+ * <p>
+ * When computing a <code>UDate</code> from time fields, two special circumstances
+ * may arise: there may be insufficient information to compute the
+ * <code>UDate</code> (such as only year and month but no day in the month),
+ * or there may be inconsistent information (such as "Tuesday, July 15, 1996"
+ * -- July 15, 1996 is actually a Monday).
+ *
+ * <p>
+ * <strong>Insufficient information.</strong> The calendar will use default
+ * information to specify the missing fields. This may vary by calendar; for
+ * the Gregorian calendar, the default for a field is the same as that of the
+ * start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc.
+ *
+ * <p>
+ * <strong>Inconsistent information.</strong> If fields conflict, the calendar
+ * will give preference to fields set more recently. For example, when
+ * determining the day, the calendar will look for one of the following
+ * combinations of fields.  The most recent combination, as determined by the
+ * most recently set single field, will be used.
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code
+ * UCAL_MONTH + UCAL_DAY_OF_MONTH
+ * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK
+ * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK
+ * UCAL_DAY_OF_YEAR
+ * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * For the time of day:
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code
+ * UCAL_HOUR_OF_DAY
+ * UCAL_AM_PM + UCAL_HOUR
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <p>
+ * <strong>Note:</strong> for some non-Gregorian calendars, different
+ * fields may be necessary for complete disambiguation. For example, a full
+ * specification of the historial Arabic astronomical calendar requires year,
+ * month, day-of-month <em>and</em> day-of-week in some cases.
+ *
+ * <p>
+ * <strong>Note:</strong> There are certain possible ambiguities in
+ * interpretation of certain singular times, which are resolved in the
+ * following ways:
+ * <ol>
+ *     <li> 24:00:00 "belongs" to the following day. That is,
+ *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970
+ *
+ *     <li> Although historically not precise, midnight also belongs to "am",
+ *          and noon belongs to "pm", so on the same day,
+ *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm
+ * </ol>
+ *
+ * <p>
+ * The date or time format strings are not part of the definition of a
+ * calendar, as those must be modifiable or overridable by the user at
+ * runtime. Use {@link DateFormat}
+ * to format dates.
+ *
+ * <p>
+ * <code>Calendar</code> provides an API for field "rolling", where fields
+ * can be incremented or decremented, but wrap around. For example, rolling the
+ * month up in the date <code>December 12, <b>1996</b></code> results in
+ * <code>January 12, <b>1996</b></code>.
+ *
+ * <p>
+ * <code>Calendar</code> also provides a date arithmetic function for
+ * adding the specified (signed) amount of time to a particular time field.
+ * For example, subtracting 5 days from the date <code>September 12, 1996</code>
+ * results in <code>September 7, 1996</code>.
+ *
+ * @stable ICU 2.0
+ */
+
+/** A calendar.
+ *  For usage in C programs.
+ * @stable ICU 2.0
+ */
+typedef void* UCalendar;
+
+/** Possible types of UCalendars 
+ * @stable ICU 2.0
+ */
+enum UCalendarType {
+  /** A traditional calendar for the locale */
+  UCAL_TRADITIONAL,
+  /** The Gregorian calendar */
+  UCAL_GREGORIAN
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarType UCalendarType;
+
+/** Possible fields in a UCalendar 
+ * @stable ICU 2.0
+ */
+enum UCalendarDateFields {
+  /** 
+   * Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar. 
+   * This is a calendar-specific value.
+   * @stable ICU 2.6 
+   */
+  UCAL_ERA,
+
+  /**
+   * Field number indicating the year. This is a calendar-specific value.
+   * @stable ICU 2.6 
+   */
+  UCAL_YEAR,
+
+  /**
+   * Field number indicating the month. This is a calendar-specific value. 
+   * The first month of the year is
+   * <code>JANUARY</code>; the last depends on the number of months in a year.
+   * @see #UCAL_JANUARY
+   * @see #UCAL_FEBRUARY
+   * @see #UCAL_MARCH
+   * @see #UCAL_APRIL
+   * @see #UCAL_MAY
+   * @see #UCAL_JUNE
+   * @see #UCAL_JULY
+   * @see #UCAL_AUGUST
+   * @see #UCAL_SEPTEMBER
+   * @see #UCAL_OCTOBER
+   * @see #UCAL_NOVEMBER
+   * @see #UCAL_DECEMBER
+   * @see #UCAL_UNDECIMBER
+   * @stable ICU 2.6 
+   */
+  UCAL_MONTH,
+
+  /**
+   * Field number indicating the
+   * week number within the current year.  The first week of the year, as
+   * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>
+   * attributes, has value 1.  Subclasses define
+   * the value of <code>UCAL_WEEK_OF_YEAR</code> for days before the first week of
+   * the year.
+   * @see ucal_getAttribute
+   * @see ucal_setAttribute
+   * @stable ICU 2.6 
+   */
+  UCAL_WEEK_OF_YEAR,
+
+ /**
+   * Field number indicating the
+   * week number within the current month.  The first week of the month, as
+   * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>
+   * attributes, has value 1.  Subclasses define
+   * the value of <code>WEEK_OF_MONTH</code> for days before the first week of
+   * the month.
+   * @see ucal_getAttribute
+   * @see ucal_setAttribute
+   * @see #UCAL_FIRST_DAY_OF_WEEK
+   * @see #UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
+   * @stable ICU 2.6 
+   */
+  UCAL_WEEK_OF_MONTH,
+
+ /**
+   * Field number indicating the
+   * day of the month. This is a synonym for <code>DAY_OF_MONTH</code>.
+   * The first day of the month has value 1.
+   * @see #UCAL_DAY_OF_MONTH
+   * @stable ICU 2.6 
+   */
+  UCAL_DATE,
+
+ /**
+   * Field number indicating the day
+   * number within the current year.  The first day of the year has value 1.
+   * @stable ICU 2.6 
+   */
+  UCAL_DAY_OF_YEAR,
+
+ /**
+   * Field number indicating the day
+   * of the week.  This field takes values <code>SUNDAY</code>,
+   * <code>MONDAY</code>, <code>TUESDAY</code>, <code>WEDNESDAY</code>,
+   * <code>THURSDAY</code>, <code>FRIDAY</code>, and <code>SATURDAY</code>.
+   * @see #UCAL_SUNDAY
+   * @see #UCAL_MONDAY
+   * @see #UCAL_TUESDAY
+   * @see #UCAL_WEDNESDAY
+   * @see #UCAL_THURSDAY
+   * @see #UCAL_FRIDAY
+   * @see #UCAL_SATURDAY
+   * @stable ICU 2.6 
+   */
+  UCAL_DAY_OF_WEEK,
+
+ /**
+   * Field number indicating the
+   * ordinal number of the day of the week within the current month. Together
+   * with the <code>DAY_OF_WEEK</code> field, this uniquely specifies a day
+   * within a month.  Unlike <code>WEEK_OF_MONTH</code> and
+   * <code>WEEK_OF_YEAR</code>, this field's value does <em>not</em> depend on
+   * <code>getFirstDayOfWeek()</code> or
+   * <code>getMinimalDaysInFirstWeek()</code>.  <code>DAY_OF_MONTH 1</code>
+   * through <code>7</code> always correspond to <code>DAY_OF_WEEK_IN_MONTH
+   * 1</code>; <code>8</code> through <code>15</code> correspond to
+   * <code>DAY_OF_WEEK_IN_MONTH 2</code>, and so on.
+   * <code>DAY_OF_WEEK_IN_MONTH 0</code> indicates the week before
+   * <code>DAY_OF_WEEK_IN_MONTH 1</code>.  Negative values count back from the
+   * end of the month, so the last Sunday of a month is specified as
+   * <code>DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1</code>.  Because
+   * negative values count backward they will usually be aligned differently
+   * within the month than positive values.  For example, if a month has 31
+   * days, <code>DAY_OF_WEEK_IN_MONTH -1</code> will overlap
+   * <code>DAY_OF_WEEK_IN_MONTH 5</code> and the end of <code>4</code>.
+   * @see #UCAL_DAY_OF_WEEK
+   * @see #UCAL_WEEK_OF_MONTH
+   * @stable ICU 2.6 
+   */
+  UCAL_DAY_OF_WEEK_IN_MONTH,
+
+ /**
+   * Field number indicating
+   * whether the <code>HOUR</code> is before or after noon.
+   * E.g., at 10:04:15.250 PM the <code>AM_PM</code> is <code>PM</code>.
+   * @see #UCAL_AM
+   * @see #UCAL_PM
+   * @see #UCAL_HOUR
+   * @stable ICU 2.6 
+   */
+  UCAL_AM_PM,
+
+ /**
+   * Field number indicating the
+   * hour of the morning or afternoon. <code>HOUR</code> is used for the 12-hour
+   * clock.
+   * E.g., at 10:04:15.250 PM the <code>HOUR</code> is 10.
+   * @see #UCAL_AM_PM
+   * @see #UCAL_HOUR_OF_DAY
+   * @stable ICU 2.6 
+   */
+  UCAL_HOUR,
+
+ /**
+   * Field number indicating the
+   * hour of the day. <code>HOUR_OF_DAY</code> is used for the 24-hour clock.
+   * E.g., at 10:04:15.250 PM the <code>HOUR_OF_DAY</code> is 22.
+   * @see #UCAL_HOUR
+   * @stable ICU 2.6 
+   */
+  UCAL_HOUR_OF_DAY,
+
+ /**
+   * Field number indicating the
+   * minute within the hour.
+   * E.g., at 10:04:15.250 PM the <code>UCAL_MINUTE</code> is 4.
+   * @stable ICU 2.6 
+   */
+  UCAL_MINUTE,
+
+ /**
+   * Field number indicating the
+   * second within the minute.
+   * E.g., at 10:04:15.250 PM the <code>UCAL_SECOND</code> is 15.
+   * @stable ICU 2.6 
+   */
+  UCAL_SECOND,
+
+ /**
+   * Field number indicating the
+   * millisecond within the second.
+   * E.g., at 10:04:15.250 PM the <code>UCAL_MILLISECOND</code> is 250.
+   * @stable ICU 2.6 
+   */
+  UCAL_MILLISECOND,
+
+ /**
+   * Field number indicating the
+   * raw offset from GMT in milliseconds.
+   * @stable ICU 2.6 
+   */
+  UCAL_ZONE_OFFSET,
+
+ /**
+   * Field number indicating the
+   * daylight savings offset in milliseconds.
+   * @stable ICU 2.6 
+   */
+  UCAL_DST_OFFSET,
+  
+ /**
+   * Field number 
+   * indicating the extended year corresponding to the
+   * <code>UCAL_WEEK_OF_YEAR</code> field.  This may be one greater or less
+   * than the value of <code>UCAL_EXTENDED_YEAR</code>.
+   * @stable ICU 2.6
+   */
+  UCAL_YEAR_WOY,
+
+ /**
+   * Field number 
+   * indicating the localized day of week.  This will be a value from 1
+   * to 7 inclusive, with 1 being the localized first day of the week.
+   * @stable ICU 2.6
+   */
+  UCAL_DOW_LOCAL,
+
+  /**
+   * Year of this calendar system, encompassing all supra-year fields. For example, 
+   * in Gregorian/Julian calendars, positive Extended Year values indicate years AD,
+   *  1 BC = 0 extended, 2 BC = -1 extended, and so on. 
+   * @stable ICU 2.8 
+   */
+  UCAL_EXTENDED_YEAR,
+
+ /**
+   * Field number 
+   * indicating the modified Julian day number.  This is different from
+   * the conventional Julian day number in two regards.  First, it
+   * demarcates days at local zone midnight, rather than noon GMT.
+   * Second, it is a local number; that is, it depends on the local time
+   * zone.  It can be thought of as a single number that encompasses all
+   * the date-related fields.
+   * @stable ICU 2.8
+   */
+  UCAL_JULIAN_DAY, 
+
+  /**
+   * Ranges from 0 to 23:59:59.999 (regardless of DST).  This field behaves <em>exactly</em> 
+   * like a composite of all time-related fields, not including the zone fields.  As such, 
+   * it also reflects discontinuities of those fields on DST transition days.  On a day
+   * of DST onset, it will jump forward.  On a day of DST cessation, it will jump 
+   * backward.  This reflects the fact that it must be combined with the DST_OFFSET field
+   * to obtain a unique local time value.
+   * @stable ICU 2.8
+   */
+  UCAL_MILLISECONDS_IN_DAY,
+
+  /**
+   * Whether or not the current month is a leap month (0 or 1). See the Chinese calendar for
+   * an example of this.
+   */
+  UCAL_IS_LEAP_MONTH,
+  
+  /**
+   * Field count
+   * @stable ICU 2.6
+   */
+  UCAL_FIELD_COUNT,
+
+ /**
+   * Field number indicating the
+   * day of the month. This is a synonym for <code>UCAL_DATE</code>.
+   * The first day of the month has value 1.
+   * @see #UCAL_DATE
+   * Synonym for UCAL_DATE
+   * @stable ICU 2.8
+   **/
+  UCAL_DAY_OF_MONTH=UCAL_DATE
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarDateFields UCalendarDateFields;
+    /**
+     * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
+     * who create locale resources for the field of first-day-of-week should be aware of
+     * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY.
+     */
+/** Possible days of the week in a UCalendar 
+ * @stable ICU 2.0
+ */
+enum UCalendarDaysOfWeek {
+  /** Sunday */
+  UCAL_SUNDAY = 1,
+  /** Monday */
+  UCAL_MONDAY,
+  /** Tuesday */
+  UCAL_TUESDAY,
+  /** Wednesday */
+  UCAL_WEDNESDAY,
+  /** Thursday */
+  UCAL_THURSDAY,
+  /** Friday */
+  UCAL_FRIDAY,
+  /** Saturday */
+  UCAL_SATURDAY
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek;
+
+/** Possible months in a UCalendar. Note: Calendar month is 0-based.
+ * @stable ICU 2.0
+ */
+enum UCalendarMonths {
+  /** January */
+  UCAL_JANUARY,
+  /** February */
+  UCAL_FEBRUARY,
+  /** March */
+  UCAL_MARCH,
+  /** April */
+  UCAL_APRIL,
+  /** May */
+  UCAL_MAY,
+  /** June */
+  UCAL_JUNE,
+  /** July */
+  UCAL_JULY,
+  /** August */
+  UCAL_AUGUST,
+  /** September */
+  UCAL_SEPTEMBER,
+  /** October */
+  UCAL_OCTOBER,
+  /** November */
+  UCAL_NOVEMBER,
+  /** December */
+  UCAL_DECEMBER,
+  /** Value of the <code>UCAL_MONTH</code> field indicating the
+    * thirteenth month of the year. Although the Gregorian calendar
+    * does not use this value, lunar calendars do.
+    */
+  UCAL_UNDECIMBER
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarMonths UCalendarMonths;
+
+/** Possible AM/PM values in a UCalendar 
+ * @stable ICU 2.0
+ */
+enum UCalendarAMPMs {
+    /** AM */
+  UCAL_AM,
+  /** PM */
+  UCAL_PM
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarAMPMs UCalendarAMPMs;
+
+/**
+ * Create an enumeration over all time zones.
+ *
+ * @param ec input/output error code
+ *
+ * @return an enumeration object that the caller must dispose of using
+ * uenum_close(), or NULL upon failure. In case of failure *ec will
+ * indicate the error.
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UEnumeration* U_EXPORT2
+ucal_openTimeZones(UErrorCode* ec);
+
+/**
+ * Create an enumeration over all time zones associated with the given
+ * country. Some zones are affiliated with no country (e.g., "UTC");
+ * these may also be retrieved, as a group.
+ *
+ * @param country the ISO 3166 two-letter country code, or NULL to
+ * retrieve zones not affiliated with any country
+ *
+ * @param ec input/output error code
+ *
+ * @return an enumeration object that the caller must dispose of using
+ * uenum_close(), or NULL upon failure. In case of failure *ec will
+ * indicate the error.
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UEnumeration* U_EXPORT2
+ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
+
+/**
+ * Return the default time zone. The default is determined initially
+ * by querying the host operating system. It may be changed with
+ * ucal_setDefaultTimeZone() or with the C++ TimeZone API.
+ *
+ * @param result A buffer to receive the result, or NULL
+ *
+ * @param resultCapacity The capacity of the result buffer
+ *
+ * @param ec input/output error code
+ *
+ * @return The result string length, not including the terminating
+ * null
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
+
+/**
+ * Set the default time zone.
+ *
+ * @param zoneID null-terminated time zone ID
+ *
+ * @param ec input/output error code
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);
+
+/**
+ * Return the amount of time in milliseconds that the clock is
+ * advanced during daylight savings time for the given time zone, or
+ * zero if the time zone does not observe daylight savings time.
+ *
+ * @param zoneID null-terminated time zone ID
+ *
+ * @param ec input/output error code
+ *
+ * @return the number of milliseconds the time is advanced with
+ * respect to standard time when the daylight savings rules are in
+ * effect. This is always a non-negative number, most commonly either
+ * 3,600,000 (one hour) or zero.
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);
+
+/**
+ * Get the current date and time.
+ * The value returned is represented as milliseconds from the epoch.
+ * @return The current date and time.
+ * @stable ICU 2.0
+ */
+U_STABLE UDate U_EXPORT2 
+ucal_getNow(void);
+
+/**
+ * Open a UCalendar.
+ * A UCalendar may be used to convert a millisecond value to a year,
+ * month, and day.
+ * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.
+ * @param len The length of zoneID, or -1 if null-terminated.
+ * @param locale The desired locale
+ * @param type The type of UCalendar to open.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return A pointer to a UCalendar, or 0 if an error occurred.
+ * @stable ICU 2.0
+ */
+U_STABLE UCalendar* U_EXPORT2 
+ucal_open(const UChar*   zoneID,
+          int32_t        len,
+          const char*    locale,
+          UCalendarType  type,
+          UErrorCode*    status);
+
+/**
+ * Close a UCalendar.
+ * Once closed, a UCalendar may no longer be used.
+ * @param cal The UCalendar to close.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_close(UCalendar *cal);
+
+/**
+ * Open a copy of a UCalendar.
+ * This function performs a deep copy.
+ * @param cal The calendar to copy
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return A pointer to a UCalendar identical to cal.
+ * @draft ICU 4.0
+ */
+U_DRAFT UCalendar* U_EXPORT2 
+ucal_clone(const UCalendar* cal,
+           UErrorCode*      status);
+
+/**
+ * Set the TimeZone used by a UCalendar.
+ * A UCalendar uses a timezone for converting from Greenwich time to local time.
+ * @param cal The UCalendar to set.
+ * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.
+ * @param len The length of zoneID, or -1 if null-terminated.
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_setTimeZone(UCalendar*    cal,
+                 const UChar*  zoneID,
+                 int32_t       len,
+                 UErrorCode*   status);
+
+/**
+ * Possible formats for a UCalendar's display name 
+ * @stable ICU 2.0
+ */
+enum UCalendarDisplayNameType {
+  /** Standard display name */
+  UCAL_STANDARD,
+  /** Short standard display name */
+  UCAL_SHORT_STANDARD,
+  /** Daylight savings display name */
+  UCAL_DST,
+  /** Short daylight savings display name */
+  UCAL_SHORT_DST
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarDisplayNameType UCalendarDisplayNameType;
+
+/**
+ * Get the display name for a UCalendar's TimeZone.
+ * A display name is suitable for presentation to a user.
+ * @param cal          The UCalendar to query.
+ * @param type         The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD,
+ *                     UCAL_DST, UCAL_SHORT_DST
+ * @param locale       The desired locale for the display name.
+ * @param result       A pointer to a buffer to receive the formatted number.
+ * @param resultLength The maximum size of result.
+ * @param status       A pointer to an UErrorCode to receive any errors
+ * @return             The total buffer size needed; if greater than resultLength, the output was truncated.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucal_getTimeZoneDisplayName(const UCalendar*          cal,
+                            UCalendarDisplayNameType  type,
+                            const char*               locale,
+                            UChar*                    result,
+                            int32_t                   resultLength,
+                            UErrorCode*               status);
+
+/**
+ * Determine if a UCalendar is currently in daylight savings time.
+ * Daylight savings time is not used in all parts of the world.
+ * @param cal The UCalendar to query.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return TRUE if cal is currently in daylight savings time, FALSE otherwise
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2 
+ucal_inDaylightTime(const UCalendar*  cal,
+                    UErrorCode*       status );
+
+/**
+ * Sets the GregorianCalendar change date. This is the point when the switch from
+ * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
+ * 15, 1582. Previous to this time and date will be Julian dates.
+ *
+ * This function works only for Gregorian calendars. If the UCalendar is not
+ * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR
+ * error code is set.
+ *
+ * @param cal        The calendar object.
+ * @param date       The given Gregorian cutover date.
+ * @param pErrorCode Pointer to a standard ICU error code. Its input value must
+ *                   pass the U_SUCCESS() test, or else the function returns
+ *                   immediately. Check for U_FAILURE() on output or use with
+ *                   function chaining. (See User Guide for details.)
+ *
+ * @see GregorianCalendar::setGregorianChange
+ * @see ucal_getGregorianChange
+ * @stable ICU 3.6
+ */
+U_STABLE void U_EXPORT2
+ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode);
+
+/**
+ * Gets the Gregorian Calendar change date. This is the point when the switch from
+ * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
+ * 15, 1582. Previous to this time and date will be Julian dates.
+ *
+ * This function works only for Gregorian calendars. If the UCalendar is not
+ * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR
+ * error code is set.
+ *
+ * @param cal        The calendar object.
+ * @param pErrorCode Pointer to a standard ICU error code. Its input value must
+ *                   pass the U_SUCCESS() test, or else the function returns
+ *                   immediately. Check for U_FAILURE() on output or use with
+ *                   function chaining. (See User Guide for details.)
+ * @return   The Gregorian cutover time for this calendar.
+ *
+ * @see GregorianCalendar::getGregorianChange
+ * @see ucal_setGregorianChange
+ * @stable ICU 3.6
+ */
+U_STABLE UDate U_EXPORT2
+ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode);
+
+/**
+ * Types of UCalendar attributes 
+ * @stable ICU 2.0
+ */
+enum UCalendarAttribute {
+    /** Lenient parsing */
+  UCAL_LENIENT,
+  /** First day of week */
+  UCAL_FIRST_DAY_OF_WEEK,
+  /** Minimum number of days in first week */
+  UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarAttribute UCalendarAttribute;
+
+/**
+ * Get a numeric attribute associated with a UCalendar.
+ * Numeric attributes include the first day of the week, or the minimal numbers
+ * of days in the first week of the month.
+ * @param cal The UCalendar to query.
+ * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
+ * or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
+ * @return The value of attr.
+ * @see ucal_setAttribute
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucal_getAttribute(const UCalendar*    cal,
+                  UCalendarAttribute  attr);
+
+/**
+ * Set a numeric attribute associated with a UCalendar.
+ * Numeric attributes include the first day of the week, or the minimal numbers
+ * of days in the first week of the month.
+ * @param cal The UCalendar to set.
+ * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
+ * or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
+ * @param newValue The new value of attr.
+ * @see ucal_getAttribute
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_setAttribute(UCalendar*          cal,
+                  UCalendarAttribute  attr,
+                  int32_t             newValue);
+
+/**
+ * Get a locale for which calendars are available.
+ * A UCalendar in a locale returned by this function will contain the correct
+ * day and month names for the locale.
+ * @param index The index of the desired locale.
+ * @return A locale for which calendars are available, or 0 if none.
+ * @see ucal_countAvailable
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2 
+ucal_getAvailable(int32_t index);
+
+/**
+ * Determine how many locales have calendars available.
+ * This function is most useful as determining the loop ending condition for
+ * calls to \ref ucal_getAvailable.
+ * @return The number of locales for which calendars are available.
+ * @see ucal_getAvailable
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucal_countAvailable(void);
+
+/**
+ * Get a UCalendar's current time in millis.
+ * The time is represented as milliseconds from the epoch.
+ * @param cal The UCalendar to query.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return The calendar's current time in millis.
+ * @see ucal_setMillis
+ * @see ucal_setDate
+ * @see ucal_setDateTime
+ * @stable ICU 2.0
+ */
+U_STABLE UDate U_EXPORT2 
+ucal_getMillis(const UCalendar*  cal,
+               UErrorCode*       status);
+
+/**
+ * Set a UCalendar's current time in millis.
+ * The time is represented as milliseconds from the epoch.
+ * @param cal The UCalendar to set.
+ * @param dateTime The desired date and time.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @see ucal_getMillis
+ * @see ucal_setDate
+ * @see ucal_setDateTime
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_setMillis(UCalendar*   cal,
+               UDate        dateTime,
+               UErrorCode*  status );
+
+/**
+ * Set a UCalendar's current date.
+ * The date is represented as a series of 32-bit integers.
+ * @param cal The UCalendar to set.
+ * @param year The desired year.
+ * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
+ * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
+ * @param date The desired day of the month.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @see ucal_getMillis
+ * @see ucal_setMillis
+ * @see ucal_setDateTime
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_setDate(UCalendar*   cal,
+             int32_t      year,
+             int32_t      month,
+             int32_t      date,
+             UErrorCode*  status);
+
+/**
+ * Set a UCalendar's current date.
+ * The date is represented as a series of 32-bit integers.
+ * @param cal The UCalendar to set.
+ * @param year The desired year.
+ * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
+ * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
+ * @param date The desired day of the month.
+ * @param hour The desired hour of day.
+ * @param minute The desired minute.
+ * @param second The desirec second.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @see ucal_getMillis
+ * @see ucal_setMillis
+ * @see ucal_setDate
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_setDateTime(UCalendar*   cal,
+                 int32_t      year,
+                 int32_t      month,
+                 int32_t      date,
+                 int32_t      hour,
+                 int32_t      minute,
+                 int32_t      second,
+                 UErrorCode*  status);
+
+/**
+ * Returns TRUE if two UCalendars are equivalent.  Equivalent
+ * UCalendars will behave identically, but they may be set to
+ * different times.
+ * @param cal1 The first of the UCalendars to compare.
+ * @param cal2 The second of the UCalendars to compare.
+ * @return TRUE if cal1 and cal2 are equivalent, FALSE otherwise.
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2 
+ucal_equivalentTo(const UCalendar*  cal1,
+                  const UCalendar*  cal2);
+
+/**
+ * Add a specified signed amount to a particular field in a UCalendar.
+ * This can modify more significant fields in the calendar.
+ * @param cal The UCalendar to which to add.
+ * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
+ * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
+ * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
+ * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
+ * @param amount The signed amount to add to field. If the amount causes the value
+ * to exceed to maximum or minimum values for that field, other fields are modified
+ * to preserve the magnitude of the change.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @see ucal_roll
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_add(UCalendar*           cal,
+         UCalendarDateFields  field,
+         int32_t              amount,
+         UErrorCode*          status);
+
+/**
+ * Add a specified signed amount to a particular field in a UCalendar.
+ * This will not modify more significant fields in the calendar.
+ * @param cal The UCalendar to which to add.
+ * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
+ * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
+ * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
+ * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
+ * @param amount The signed amount to add to field. If the amount causes the value
+ * to exceed to maximum or minimum values for that field, the field is pinned to a permissible
+ * value.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @see ucal_add
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_roll(UCalendar*           cal,
+          UCalendarDateFields  field,
+          int32_t              amount,
+          UErrorCode*          status);
+
+/**
+ * Get the current value of a field from a UCalendar.
+ * All fields are represented as 32-bit integers.
+ * @param cal The UCalendar to query.
+ * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
+ * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
+ * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
+ * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return The value of the desired field.
+ * @see ucal_set
+ * @see ucal_isSet
+ * @see ucal_clearField
+ * @see ucal_clear
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucal_get(const UCalendar*     cal,
+         UCalendarDateFields  field,
+         UErrorCode*          status );
+
+/**
+ * Set the value of a field in a UCalendar.
+ * All fields are represented as 32-bit integers.
+ * @param cal The UCalendar to set.
+ * @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
+ * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
+ * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
+ * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
+ * @param value The desired value of field.
+ * @see ucal_get
+ * @see ucal_isSet
+ * @see ucal_clearField
+ * @see ucal_clear
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_set(UCalendar*           cal,
+         UCalendarDateFields  field,
+         int32_t              value);
+
+/**
+ * Determine if a field in a UCalendar is set.
+ * All fields are represented as 32-bit integers.
+ * @param cal The UCalendar to query.
+ * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
+ * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
+ * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
+ * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
+ * @return TRUE if field is set, FALSE otherwise.
+ * @see ucal_get
+ * @see ucal_set
+ * @see ucal_clearField
+ * @see ucal_clear
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2 
+ucal_isSet(const UCalendar*     cal,
+           UCalendarDateFields  field);
+
+/**
+ * Clear a field in a UCalendar.
+ * All fields are represented as 32-bit integers.
+ * @param cal The UCalendar containing the field to clear.
+ * @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
+ * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
+ * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
+ * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
+ * @see ucal_get
+ * @see ucal_set
+ * @see ucal_isSet
+ * @see ucal_clear
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_clearField(UCalendar*           cal,
+                UCalendarDateFields  field);
+
+/**
+ * Clear all fields in a UCalendar.
+ * All fields are represented as 32-bit integers.
+ * @param calendar The UCalendar to clear.
+ * @see ucal_get
+ * @see ucal_set
+ * @see ucal_isSet
+ * @see ucal_clearField
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucal_clear(UCalendar* calendar);
+
+/**
+ * Possible limit values for a UCalendar 
+ * @stable ICU 2.0
+ */
+enum UCalendarLimitType {
+  /** Minimum value */
+  UCAL_MINIMUM,
+  /** Maximum value */
+  UCAL_MAXIMUM,
+  /** Greatest minimum value */
+  UCAL_GREATEST_MINIMUM,
+  /** Leaest maximum value */
+  UCAL_LEAST_MAXIMUM,
+  /** Actual minimum value */
+  UCAL_ACTUAL_MINIMUM,
+  /** Actual maximum value */
+  UCAL_ACTUAL_MAXIMUM
+};
+
+/** @stable ICU 2.0 */
+typedef enum UCalendarLimitType UCalendarLimitType;
+
+/**
+ * Determine a limit for a field in a UCalendar.
+ * A limit is a maximum or minimum value for a field.
+ * @param cal The UCalendar to query.
+ * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
+ * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
+ * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
+ * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
+ * @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM,
+ * UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return The requested value.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucal_getLimit(const UCalendar*     cal,
+              UCalendarDateFields  field,
+              UCalendarLimitType   type,
+              UErrorCode*          status);
+
+/** Get the locale for this calendar object. You can choose between valid and actual locale.
+ *  @param cal The calendar object
+ *  @param type type of the locale we're looking for (valid or actual) 
+ *  @param status error code for the operation
+ *  @return the locale name
+ *  @stable ICU 2.8
+ */
+U_STABLE const char * U_EXPORT2
+ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status);
+
+/**
+ * Returns the timezone data version currently used by ICU.
+ * @param status error code for the operation
+ * @return the version string, such as "2007f"
+ * @stable ICU 4.0
+ */
+U_DRAFT const char * U_EXPORT2
+ucal_getTZDataVersion(UErrorCode* status);
+
+/**
+ * Returns the canonical system timezone ID or the normalized
+ * custom time zone ID for the given time zone ID.
+ * @param id        The input timezone ID to be canonicalized.
+ * @param len       The length of id, or -1 if null-terminated.
+ * @param result    The buffer receives the canonical system timezone ID
+ *                  or the custom timezone ID in normalized format.
+ * @param resultCapacity    The capacity of the result buffer.
+ * @param isSystemID        Receives if the given ID is a known system
+     *                      timezone ID.
+ * @param status    Recevies the status.  When the given timezone ID
+ *                  is neither a known system time zone ID nor a
+ *                  valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR
+ *                  is set.
+ * @return          The result string length, not including the terminating
+ *                  null.
+ * @draft ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
+                            UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status);
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ucasemap.h b/CoreFoundation/icu/unicode/ucasemap.h
new file mode 100644
index 0000000..75e818d
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucasemap.h
@@ -0,0 +1,395 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2005-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  ucasemap.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2005may06
+*   created by: Markus W. Scherer
+*
+*   Case mapping service object and functions using it.
+*/
+
+#ifndef __UCASEMAP_H__
+#define __UCASEMAP_H__
+
+#include "unicode/utypes.h"
+#include "unicode/ustring.h"
+
+/**
+ * \file
+ * \brief C API: Unicode case mapping functions using a UCaseMap service object.
+ *
+ * The service object takes care of memory allocations, data loading, and setup
+ * for the attributes, as usual.
+ *
+ * Currently, the functionality provided here does not overlap with uchar.h
+ * and ustring.h, except for ucasemap_toTitle().
+ *
+ * ucasemap_utf8XYZ() functions operate directly on UTF-8 strings.
+ */
+
+/**
+ * UCaseMap is an opaque service object for newer ICU case mapping functions.
+ * Older functions did not use a service object.
+ * @stable ICU 3.4
+ */
+struct UCaseMap;
+typedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @stable ICU 3.4 */
+
+/**
+ * Open a UCaseMap service object for a locale and a set of options.
+ * The locale ID and options are preprocessed so that functions using the
+ * service object need not process them in each call.
+ *
+ * @param locale ICU locale ID, used for language-dependent
+ *               upper-/lower-/title-casing according to the Unicode standard.
+ *               Usual semantics: ""=root, NULL=default locale, etc.
+ * @param options Options bit set, used for case folding and string comparisons.
+ *                Same flags as for u_foldCase(), u_strFoldCase(),
+ *                u_strCaseCompare(), etc.
+ *                Use 0 or U_FOLD_CASE_DEFAULT for default behavior.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                   which must not indicate a failure before the function call.
+ * @return Pointer to a UCaseMap service object, if successful.
+ *
+ * @see U_FOLD_CASE_DEFAULT
+ * @see U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ * @see U_TITLECASE_NO_LOWERCASE
+ * @see U_TITLECASE_NO_BREAK_ADJUSTMENT
+ * @stable ICU 3.4
+ */
+U_STABLE UCaseMap * U_EXPORT2
+ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);
+
+/**
+ * Close a UCaseMap service object.
+ * @param csm Object to be closed.
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+ucasemap_close(UCaseMap *csm);
+
+/**
+ * Get the locale ID that is used for language-dependent case mappings.
+ * @param csm UCaseMap service object.
+ * @return locale ID
+ * @stable ICU 3.4
+ */
+U_STABLE const char * U_EXPORT2
+ucasemap_getLocale(const UCaseMap *csm);
+
+/**
+ * Get the options bit set that is used for case folding and string comparisons.
+ * @param csm UCaseMap service object.
+ * @return options bit set
+ * @stable ICU 3.4
+ */
+U_STABLE uint32_t U_EXPORT2
+ucasemap_getOptions(const UCaseMap *csm);
+
+/**
+ * Set the locale ID that is used for language-dependent case mappings.
+ *
+ * @param csm UCaseMap service object.
+ * @param locale Locale ID, see ucasemap_open().
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                   which must not indicate a failure before the function call.
+ *
+ * @see ucasemap_open
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);
+
+/**
+ * Set the options bit set that is used for case folding and string comparisons.
+ *
+ * @param csm UCaseMap service object.
+ * @param options Options bit set, see ucasemap_open().
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                   which must not indicate a failure before the function call.
+ *
+ * @see ucasemap_open
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);
+
+#ifndef U_HIDE_DRAFT_API
+
+/**
+ * Do not lowercase non-initial parts of words when titlecasing.
+ * Option bit for titlecasing APIs that take an options bit set.
+ *
+ * By default, titlecasing will titlecase the first cased character
+ * of a word and lowercase all other characters.
+ * With this option, the other characters will not be modified.
+ *
+ * @see ucasemap_setOptions
+ * @see ucasemap_toTitle
+ * @see ucasemap_utf8ToTitle
+ * @see UnicodeString::toTitle
+ * @stable ICU 4.0
+ */
+#define U_TITLECASE_NO_LOWERCASE 0x100
+
+/**
+ * Do not adjust the titlecasing indexes from BreakIterator::next() indexes;
+ * titlecase exactly the characters at breaks from the iterator.
+ * Option bit for titlecasing APIs that take an options bit set.
+ *
+ * By default, titlecasing will take each break iterator index,
+ * adjust it by looking for the next cased character, and titlecase that one.
+ * Other characters are lowercased.
+ *
+ * This follows Unicode 4 & 5 section 3.13 Default Case Operations:
+ *
+ * R3  toTitlecase(X): Find the word boundaries based on Unicode Standard Annex
+ * #29, "Text Boundaries." Between each pair of word boundaries, find the first
+ * cased character F. If F exists, map F to default_title(F); then map each
+ * subsequent character C to default_lower(C).
+ *
+ * @see ucasemap_setOptions
+ * @see ucasemap_toTitle
+ * @see ucasemap_utf8ToTitle
+ * @see UnicodeString::toTitle
+ * @see U_TITLECASE_NO_LOWERCASE
+ * @stable ICU 4.0
+ */
+#define U_TITLECASE_NO_BREAK_ADJUSTMENT 0x200
+
+#endif
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+/**
+ * Get the break iterator that is used for titlecasing.
+ * Do not modify the returned break iterator.
+ * @param csm UCaseMap service object.
+ * @return titlecasing break iterator
+ * @stable ICU 4.0
+ */
+U_DRAFT const UBreakIterator * U_EXPORT2
+ucasemap_getBreakIterator(const UCaseMap *csm);
+
+/**
+ * Set the break iterator that is used for titlecasing.
+ * The UCaseMap service object releases a previously set break iterator
+ * and "adopts" this new one, taking ownership of it.
+ * It will be released in a subsequent call to ucasemap_setBreakIterator()
+ * or ucasemap_close().
+ *
+ * Break iterator operations are not thread-safe. Therefore, titlecasing
+ * functions use non-const UCaseMap objects. It is not possible to titlecase
+ * strings concurrently using the same UCaseMap.
+ *
+ * @param csm UCaseMap service object.
+ * @param iterToAdopt Break iterator to be adopted for titlecasing.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                   which must not indicate a failure before the function call.
+ *
+ * @see ucasemap_toTitle
+ * @see ucasemap_utf8ToTitle
+ * @stable ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode *pErrorCode);
+
+/**
+ * Titlecase a UTF-16 string. This function is almost a duplicate of u_strToTitle(),
+ * except that it takes ucasemap_setOptions() into account and has performance
+ * advantages from being able to use a UCaseMap object for multiple case mapping
+ * operations, saving setup time.
+ *
+ * Casing is locale-dependent and context-sensitive.
+ * Titlecasing uses a break iterator to find the first characters of words
+ * that are to be titlecased. It titlecases those characters and lowercases
+ * all others. (This can be modified with ucasemap_setOptions().)
+ *
+ * The titlecase break iterator can be provided to customize for arbitrary
+ * styles, using rules and dictionaries beyond the standard iterators.
+ * It may be more efficient to always provide an iterator to avoid
+ * opening and closing one for each string.
+ * The standard titlecase iterator for the root locale implements the
+ * algorithm of Unicode TR 21.
+ *
+ * This function uses only the setText(), first() and next() methods of the
+ * provided break iterator.
+ *
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer must not overlap.
+ *
+ * @param csm       UCaseMap service object.
+ * @param dest      A buffer for the result string. The result will be NUL-terminated if
+ *                  the buffer is large enough.
+ *                  The contents is undefined in case of failure.
+ * @param destCapacity The size of the buffer (number of bytes). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string.
+ * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ *
+ * @see u_strToTitle
+ * @stable ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+ucasemap_toTitle(UCaseMap *csm,
+                 UChar *dest, int32_t destCapacity,
+                 const UChar *src, int32_t srcLength,
+                 UErrorCode *pErrorCode);
+
+#endif
+
+/**
+ * Lowercase the characters in a UTF-8 string.
+ * Casing is locale-dependent and context-sensitive.
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer must not overlap.
+ *
+ * @param csm       UCaseMap service object.
+ * @param dest      A buffer for the result string. The result will be NUL-terminated if
+ *                  the buffer is large enough.
+ *                  The contents is undefined in case of failure.
+ * @param destCapacity The size of the buffer (number of bytes). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string.
+ * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ *
+ * @see u_strToLower
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+ucasemap_utf8ToLower(const UCaseMap *csm,
+                     char *dest, int32_t destCapacity,
+                     const char *src, int32_t srcLength,
+                     UErrorCode *pErrorCode);
+
+/**
+ * Uppercase the characters in a UTF-8 string.
+ * Casing is locale-dependent and context-sensitive.
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer must not overlap.
+ *
+ * @param csm       UCaseMap service object.
+ * @param dest      A buffer for the result string. The result will be NUL-terminated if
+ *                  the buffer is large enough.
+ *                  The contents is undefined in case of failure.
+ * @param destCapacity The size of the buffer (number of bytes). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string.
+ * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ *
+ * @see u_strToUpper
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+ucasemap_utf8ToUpper(const UCaseMap *csm,
+                     char *dest, int32_t destCapacity,
+                     const char *src, int32_t srcLength,
+                     UErrorCode *pErrorCode);
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+/**
+ * Titlecase a UTF-8 string.
+ * Casing is locale-dependent and context-sensitive.
+ * Titlecasing uses a break iterator to find the first characters of words
+ * that are to be titlecased. It titlecases those characters and lowercases
+ * all others. (This can be modified with ucasemap_setOptions().)
+ *
+ * The titlecase break iterator can be provided to customize for arbitrary
+ * styles, using rules and dictionaries beyond the standard iterators.
+ * It may be more efficient to always provide an iterator to avoid
+ * opening and closing one for each string.
+ * The standard titlecase iterator for the root locale implements the
+ * algorithm of Unicode TR 21.
+ *
+ * This function uses only the setText(), first() and next() methods of the
+ * provided break iterator.
+ *
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer must not overlap.
+ *
+ * @param csm       UCaseMap service object.
+ * @param dest      A buffer for the result string. The result will be NUL-terminated if
+ *                  the buffer is large enough.
+ *                  The contents is undefined in case of failure.
+ * @param destCapacity The size of the buffer (number of bytes). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string.
+ * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ *
+ * @see u_strToTitle
+ * @see U_TITLECASE_NO_LOWERCASE
+ * @see U_TITLECASE_NO_BREAK_ADJUSTMENT
+ * @stable ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+ucasemap_utf8ToTitle(UCaseMap *csm,
+                    char *dest, int32_t destCapacity,
+                    const char *src, int32_t srcLength,
+                    UErrorCode *pErrorCode);
+
+#endif
+
+/**
+ * Case-fold the characters in a UTF-8 string.
+ * Case-folding is locale-independent and not context-sensitive,
+ * but there is an option for whether to include or exclude mappings for dotted I
+ * and dotless i that are marked with 'I' in CaseFolding.txt.
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer must not overlap.
+ *
+ * @param csm       UCaseMap service object.
+ * @param dest      A buffer for the result string. The result will be NUL-terminated if
+ *                  the buffer is large enough.
+ *                  The contents is undefined in case of failure.
+ * @param destCapacity The size of the buffer (number of bytes). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string.
+ * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ *
+ * @see u_strFoldCase
+ * @see ucasemap_setOptions
+ * @see U_FOLD_CASE_DEFAULT
+ * @see U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ * @stable ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+ucasemap_utf8FoldCase(const UCaseMap *csm,
+                      char *dest, int32_t destCapacity,
+                      const char *src, int32_t srcLength,
+                      UErrorCode *pErrorCode);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ucat.h b/CoreFoundation/icu/unicode/ucat.h
new file mode 100644
index 0000000..ad9f037
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucat.h
@@ -0,0 +1,158 @@
+/*
+**********************************************************************
+* Copyright (c) 2003-2004, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+* Author: Alan Liu
+* Created: March 19 2003
+* Since: ICU 2.6
+**********************************************************************
+*/
+#ifndef UCAT_H
+#define UCAT_H
+
+#include "unicode/utypes.h"
+#include "unicode/ures.h"
+
+/**
+ * \file
+ * \brief C API: Message Catalog Wrappers
+ *
+ * This C API provides look-alike functions that deliberately resemble
+ * the POSIX catopen, catclose, and catgets functions.  The underlying
+ * implementation is in terms of ICU resource bundles, rather than
+ * POSIX message catalogs.
+ *
+ * The ICU resource bundles obey standard ICU inheritance policies.
+ * To facilitate this, sets and messages are flattened into one tier.
+ * This is done by creating resource bundle keys of the form
+ * &lt;set_num&gt;%&lt;msg_num&gt; where set_num is the set number and msg_num is
+ * the message number, formatted as decimal strings.
+ *
+ * Example:  Consider a message catalog containing two sets:
+ *
+ * Set 1: Message 4  = "Good morning."
+ *        Message 5  = "Good afternoon."
+ *        Message 7  = "Good evening."
+ *        Message 8  = "Good night."
+ * Set 4: Message 14 = "Please "
+ *        Message 19 = "Thank you."
+ *        Message 20 = "Sincerely,"
+ *
+ * The ICU resource bundle source file would, assuming it is named
+ * "greet.txt", would look like this:
+ *
+ * greet
+ * {
+ *     1%4  { "Good morning." }
+ *     1%5  { "Good afternoon." }
+ *     1%7  { "Good evening." }
+ *     1%8  { "Good night." }
+ * 
+ *     4%14 { "Please " }
+ *     4%19 { "Thank you." }
+ *     4%20 { "Sincerely," }
+ * }
+ *
+ * The catgets function is commonly used in combination with functions
+ * like printf and strftime.  ICU components like message format can
+ * be used instead, although they use a different format syntax.
+ * There is an ICU package, icuio, that provides some of
+ * the POSIX-style formatting API.
+ */
+
+U_CDECL_BEGIN
+
+/**
+ * An ICU message catalog descriptor, analogous to nl_catd.
+ * 
+ * @stable ICU 2.6
+ */
+typedef UResourceBundle* u_nl_catd;
+
+/**
+ * Open and return an ICU message catalog descriptor. The descriptor
+ * may be passed to u_catgets() to retrieve localized strings.
+ *
+ * @param name string containing the full path pointing to the
+ * directory where the resources reside followed by the package name
+ * e.g. "/usr/resource/my_app/resources/guimessages" on a Unix system.
+ * If NULL, ICU default data files will be used.
+ *
+ * Unlike POSIX, environment variables are not interpolated within the
+ * name.
+ *
+ * @param locale the locale for which we want to open the resource. If
+ * NULL, the default ICU locale will be used (see uloc_getDefault). If
+ * strlen(locale) == 0, the root locale will be used.
+ *
+ * @param ec input/output error code. Upon output,
+ * U_USING_FALLBACK_WARNING indicates that a fallback locale was
+ * used. For example, 'de_CH' was requested, but nothing was found
+ * there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that the
+ * default locale data or root locale data was used; neither the
+ * requested locale nor any of its fallback locales were found.
+ *
+ * @return a message catalog descriptor that may be passed to
+ * u_catgets(). If the ec parameter indicates success, then the caller
+ * is responsible for calling u_catclose() to close the message
+ * catalog. If the ec parameter indicates failure, then NULL will be
+ * returned.
+ * 
+ * @stable ICU 2.6
+ */
+U_STABLE u_nl_catd U_EXPORT2
+u_catopen(const char* name, const char* locale, UErrorCode* ec);
+
+/**
+ * Close an ICU message catalog, given its descriptor.
+ *
+ * @param catd a message catalog descriptor to be closed. May be NULL,
+ * in which case no action is taken.
+ * 
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+u_catclose(u_nl_catd catd);
+
+/**
+ * Retrieve a localized string from an ICU message catalog.
+ *
+ * @param catd a message catalog descriptor returned by u_catopen.
+ *
+ * @param set_num the message catalog set number. Sets need not be
+ * numbered consecutively.
+ *
+ * @param msg_num the message catalog message number within the
+ * set. Messages need not be numbered consecutively.
+ *
+ * @param s the default string. This is returned if the string
+ * specified by the set_num and msg_num is not found. It must be
+ * zero-terminated.
+ *
+ * @param len fill-in parameter to receive the length of the result.
+ * May be NULL, in which case it is ignored.
+ *
+ * @param ec input/output error code. May be U_USING_FALLBACK_WARNING
+ * or U_USING_DEFAULT_WARNING. U_MISSING_RESOURCE_ERROR indicates that
+ * the set_num/msg_num tuple does not specify a valid message string
+ * in this catalog.
+ *
+ * @return a pointer to a zero-terminated UChar array which lives in
+ * an internal buffer area, typically a memory mapped/DLL file. The
+ * caller must NOT delete this pointer. If the call is unsuccessful
+ * for any reason, then s is returned.  This includes the situation in
+ * which ec indicates a failing error code upon entry to this
+ * function.
+ * 
+ * @stable ICU 2.6
+ */
+U_STABLE const UChar* U_EXPORT2
+u_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,
+          const UChar* s,
+          int32_t* len, UErrorCode* ec);
+
+U_CDECL_END
+
+#endif /*UCAT_H*/
+/*eof*/
diff --git a/CoreFoundation/icu/unicode/uchar.h b/CoreFoundation/icu/unicode/uchar.h
new file mode 100644
index 0000000..0f629c0
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uchar.h
@@ -0,0 +1,3062 @@
+/*
+**********************************************************************
+*   Copyright (C) 1997-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File UCHAR.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/02/97    aliu        Creation.
+*   03/29/99    helena      Updated for C APIs.
+*   4/15/99     Madhu       Updated for C Implementation and Javadoc
+*   5/20/99     Madhu       Added the function u_getVersion()
+*   8/19/1999   srl         Upgraded scripts to Unicode 3.0
+*   8/27/1999   schererm    UCharDirection constants: U_...
+*   11/11/1999  weiv        added u_isalnum(), cleaned comments
+*   01/11/2000  helena      Renamed u_getVersion to u_getUnicodeVersion().
+******************************************************************************
+*/
+
+#ifndef UCHAR_H
+#define UCHAR_H
+
+#include "unicode/utypes.h"
+
+U_CDECL_BEGIN
+
+/*==========================================================================*/
+/* Unicode version number                                                   */
+/*==========================================================================*/
+/**
+ * Unicode version number, default for the current ICU version.
+ * The actual Unicode Character Database (UCD) data is stored in uprops.dat
+ * and may be generated from UCD files from a different Unicode version.
+ * Call u_getUnicodeVersion to get the actual Unicode version of the data.
+ *
+ * @see u_getUnicodeVersion
+ * @stable ICU 2.0
+ */
+#define U_UNICODE_VERSION "5.1"
+
+/**
+ * \file
+ * \brief C API: Unicode Properties
+ *
+ * This C API provides low-level access to the Unicode Character Database.
+ * In addition to raw property values, some convenience functions calculate
+ * derived properties, for example for Java-style programming.
+ *
+ * Unicode assigns each code point (not just assigned character) values for
+ * many properties.
+ * Most of them are simple boolean flags, or constants from a small enumerated list.
+ * For some properties, values are strings or other relatively more complex types.
+ *
+ * For more information see
+ * "About the Unicode Character Database" (http://www.unicode.org/ucd/)
+ * and the ICU User Guide chapter on Properties (http://icu-project.org/userguide/properties.html).
+ *
+ * Many functions are designed to match java.lang.Character functions.
+ * See the individual function documentation,
+ * and see the JDK 1.4 java.lang.Character documentation
+ * at http://java.sun.com/j2se/1.4/docs/api/java/lang/Character.html
+ *
+ * There are also functions that provide easy migration from C/POSIX functions
+ * like isblank(). Their use is generally discouraged because the C/POSIX
+ * standards do not define their semantics beyond the ASCII range, which means
+ * that different implementations exhibit very different behavior.
+ * Instead, Unicode properties should be used directly.
+ *
+ * There are also only a few, broad C/POSIX character classes, and they tend
+ * to be used for conflicting purposes. For example, the "isalpha()" class
+ * is sometimes used to determine word boundaries, while a more sophisticated
+ * approach would at least distinguish initial letters from continuation
+ * characters (the latter including combining marks).
+ * (In ICU, BreakIterator is the most sophisticated API for word boundaries.)
+ * Another example: There is no "istitle()" class for titlecase characters.
+ *
+ * ICU 3.4 and later provides API access for all twelve C/POSIX character classes.
+ * ICU implements them according to the Standard Recommendations in
+ * Annex C: Compatibility Properties of UTS #18 Unicode Regular Expressions
+ * (http://www.unicode.org/reports/tr18/#Compatibility_Properties).
+ *
+ * API access for C/POSIX character classes is as follows:
+ * - alpha:     u_isUAlphabetic(c) or u_hasBinaryProperty(c, UCHAR_ALPHABETIC)
+ * - lower:     u_isULowercase(c) or u_hasBinaryProperty(c, UCHAR_LOWERCASE)
+ * - upper:     u_isUUppercase(c) or u_hasBinaryProperty(c, UCHAR_UPPERCASE)
+ * - punct:     u_ispunct(c)
+ * - digit:     u_isdigit(c) or u_charType(c)==U_DECIMAL_DIGIT_NUMBER
+ * - xdigit:    u_isxdigit(c) or u_hasBinaryProperty(c, UCHAR_POSIX_XDIGIT)
+ * - alnum:     u_hasBinaryProperty(c, UCHAR_POSIX_ALNUM)
+ * - space:     u_isUWhiteSpace(c) or u_hasBinaryProperty(c, UCHAR_WHITE_SPACE)
+ * - blank:     u_isblank(c) or u_hasBinaryProperty(c, UCHAR_POSIX_BLANK)
+ * - cntrl:     u_charType(c)==U_CONTROL_CHAR
+ * - graph:     u_hasBinaryProperty(c, UCHAR_POSIX_GRAPH)
+ * - print:     u_hasBinaryProperty(c, UCHAR_POSIX_PRINT)
+ *
+ * Note: Some of the u_isxyz() functions in uchar.h predate, and do not match,
+ * the Standard Recommendations in UTS #18. Instead, they match Java
+ * functions according to their API documentation.
+ *
+ * \htmlonly
+ * The C/POSIX character classes are also available in UnicodeSet patterns,
+ * using patterns like [:graph:] or \p{graph}.
+ * \endhtmlonly
+ *
+ * Note: There are several ICU whitespace functions.
+ * Comparison:
+ * - u_isUWhiteSpace=UCHAR_WHITE_SPACE: Unicode White_Space property;
+ *       most of general categories "Z" (separators) + most whitespace ISO controls
+ *       (including no-break spaces, but excluding IS1..IS4 and ZWSP)
+ * - u_isWhitespace: Java isWhitespace; Z + whitespace ISO controls but excluding no-break spaces
+ * - u_isJavaSpaceChar: Java isSpaceChar; just Z (including no-break spaces)
+ * - u_isspace: Z + whitespace ISO controls (including no-break spaces)
+ * - u_isblank: "horizontal spaces" = TAB + Zs - ZWSP
+ */
+
+/**
+ * Constants.
+ */
+
+/** The lowest Unicode code point value. Code points are non-negative. @stable ICU 2.0 */
+#define UCHAR_MIN_VALUE 0
+
+/**
+ * The highest Unicode code point value (scalar value) according to
+ * The Unicode Standard. This is a 21-bit value (20.1 bits, rounded up).
+ * For a single character, UChar32 is a simple type that can hold any code point value.
+ *
+ * @see UChar32
+ * @stable ICU 2.0
+ */
+#define UCHAR_MAX_VALUE 0x10ffff
+
+/**
+ * Get a single-bit bit set (a flag) from a bit number 0..31.
+ * @stable ICU 2.1
+ */
+#define U_MASK(x) ((uint32_t)1<<(x))
+
+/*
+ * !! Note: Several comments in this file are machine-read by the
+ * genpname tool.  These comments describe the correspondence between
+ * icu enum constants and UCD entities.  Do not delete them.  Update
+ * these comments as needed.
+ *
+ * Any comment of the form "/ *[name]* /" (spaces added) is such
+ * a comment.
+ *
+ * The U_JG_* and U_GC_*_MASK constants are matched by their symbolic
+ * name, which must match PropertyValueAliases.txt.
+ */
+
+/**
+ * Selection constants for Unicode properties.
+ * These constants are used in functions like u_hasBinaryProperty to select
+ * one of the Unicode properties.
+ *
+ * The properties APIs are intended to reflect Unicode properties as defined
+ * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).
+ * For details about the properties see http://www.unicode.org/ucd/ .
+ * For names of Unicode properties see the UCD file PropertyAliases.txt.
+ *
+ * Important: If ICU is built with UCD files from Unicode versions below, e.g., 3.2,
+ * then properties marked with "new in Unicode 3.2" are not or not fully available.
+ * Check u_getUnicodeVersion to be sure.
+ *
+ * @see u_hasBinaryProperty
+ * @see u_getIntPropertyValue
+ * @see u_getUnicodeVersion
+ * @stable ICU 2.1
+ */
+typedef enum UProperty {
+    /*  See note !!.  Comments of the form "Binary property Dash",
+        "Enumerated property Script", "Double property Numeric_Value",
+        and "String property Age" are read by genpname. */
+
+    /*  Note: Place UCHAR_ALPHABETIC before UCHAR_BINARY_START so that
+    debuggers display UCHAR_ALPHABETIC as the symbolic name for 0,
+    rather than UCHAR_BINARY_START.  Likewise for other *_START
+    identifiers. */
+
+    /** Binary property Alphabetic. Same as u_isUAlphabetic, different from u_isalpha.
+        Lu+Ll+Lt+Lm+Lo+Nl+Other_Alphabetic @stable ICU 2.1 */
+    UCHAR_ALPHABETIC=0,
+    /** First constant for binary Unicode properties. @stable ICU 2.1 */
+    UCHAR_BINARY_START=UCHAR_ALPHABETIC,
+    /** Binary property ASCII_Hex_Digit. 0-9 A-F a-f @stable ICU 2.1 */
+    UCHAR_ASCII_HEX_DIGIT=1,
+    /** Binary property Bidi_Control.
+        Format controls which have specific functions
+        in the Bidi Algorithm. @stable ICU 2.1 */
+    UCHAR_BIDI_CONTROL=2,
+    /** Binary property Bidi_Mirrored.
+        Characters that may change display in RTL text.
+        Same as u_isMirrored.
+        See Bidi Algorithm, UTR 9. @stable ICU 2.1 */
+    UCHAR_BIDI_MIRRORED=3,
+    /** Binary property Dash. Variations of dashes. @stable ICU 2.1 */
+    UCHAR_DASH=4,
+    /** Binary property Default_Ignorable_Code_Point (new in Unicode 3.2).
+        Ignorable in most processing.
+        <2060..206F, FFF0..FFFB, E0000..E0FFF>+Other_Default_Ignorable_Code_Point+(Cf+Cc+Cs-White_Space) @stable ICU 2.1 */
+    UCHAR_DEFAULT_IGNORABLE_CODE_POINT=5,
+    /** Binary property Deprecated (new in Unicode 3.2).
+        The usage of deprecated characters is strongly discouraged. @stable ICU 2.1 */
+    UCHAR_DEPRECATED=6,
+    /** Binary property Diacritic. Characters that linguistically modify
+        the meaning of another character to which they apply. @stable ICU 2.1 */
+    UCHAR_DIACRITIC=7,
+    /** Binary property Extender.
+        Extend the value or shape of a preceding alphabetic character,
+        e.g., length and iteration marks. @stable ICU 2.1 */
+    UCHAR_EXTENDER=8,
+    /** Binary property Full_Composition_Exclusion.
+        CompositionExclusions.txt+Singleton Decompositions+
+        Non-Starter Decompositions. @stable ICU 2.1 */
+    UCHAR_FULL_COMPOSITION_EXCLUSION=9,
+    /** Binary property Grapheme_Base (new in Unicode 3.2).
+        For programmatic determination of grapheme cluster boundaries.
+        [0..10FFFF]-Cc-Cf-Cs-Co-Cn-Zl-Zp-Grapheme_Link-Grapheme_Extend-CGJ @stable ICU 2.1 */
+    UCHAR_GRAPHEME_BASE=10,
+    /** Binary property Grapheme_Extend (new in Unicode 3.2).
+        For programmatic determination of grapheme cluster boundaries.
+        Me+Mn+Mc+Other_Grapheme_Extend-Grapheme_Link-CGJ @stable ICU 2.1 */
+    UCHAR_GRAPHEME_EXTEND=11,
+    /** Binary property Grapheme_Link (new in Unicode 3.2).
+        For programmatic determination of grapheme cluster boundaries. @stable ICU 2.1 */
+    UCHAR_GRAPHEME_LINK=12,
+    /** Binary property Hex_Digit.
+        Characters commonly used for hexadecimal numbers. @stable ICU 2.1 */
+    UCHAR_HEX_DIGIT=13,
+    /** Binary property Hyphen. Dashes used to mark connections
+        between pieces of words, plus the Katakana middle dot. @stable ICU 2.1 */
+    UCHAR_HYPHEN=14,
+    /** Binary property ID_Continue.
+        Characters that can continue an identifier.
+        DerivedCoreProperties.txt also says "NOTE: Cf characters should be filtered out."
+        ID_Start+Mn+Mc+Nd+Pc @stable ICU 2.1 */
+    UCHAR_ID_CONTINUE=15,
+    /** Binary property ID_Start.
+        Characters that can start an identifier.
+        Lu+Ll+Lt+Lm+Lo+Nl @stable ICU 2.1 */
+    UCHAR_ID_START=16,
+    /** Binary property Ideographic.
+        CJKV ideographs. @stable ICU 2.1 */
+    UCHAR_IDEOGRAPHIC=17,
+    /** Binary property IDS_Binary_Operator (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_IDS_BINARY_OPERATOR=18,
+    /** Binary property IDS_Trinary_Operator (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_IDS_TRINARY_OPERATOR=19,
+    /** Binary property Join_Control.
+        Format controls for cursive joining and ligation. @stable ICU 2.1 */
+    UCHAR_JOIN_CONTROL=20,
+    /** Binary property Logical_Order_Exception (new in Unicode 3.2).
+        Characters that do not use logical order and
+        require special handling in most processing. @stable ICU 2.1 */
+    UCHAR_LOGICAL_ORDER_EXCEPTION=21,
+    /** Binary property Lowercase. Same as u_isULowercase, different from u_islower.
+        Ll+Other_Lowercase @stable ICU 2.1 */
+    UCHAR_LOWERCASE=22,
+    /** Binary property Math. Sm+Other_Math @stable ICU 2.1 */
+    UCHAR_MATH=23,
+    /** Binary property Noncharacter_Code_Point.
+        Code points that are explicitly defined as illegal
+        for the encoding of characters. @stable ICU 2.1 */
+    UCHAR_NONCHARACTER_CODE_POINT=24,
+    /** Binary property Quotation_Mark. @stable ICU 2.1 */
+    UCHAR_QUOTATION_MARK=25,
+    /** Binary property Radical (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_RADICAL=26,
+    /** Binary property Soft_Dotted (new in Unicode 3.2).
+        Characters with a "soft dot", like i or j.
+        An accent placed on these characters causes
+        the dot to disappear. @stable ICU 2.1 */
+    UCHAR_SOFT_DOTTED=27,
+    /** Binary property Terminal_Punctuation.
+        Punctuation characters that generally mark
+        the end of textual units. @stable ICU 2.1 */
+    UCHAR_TERMINAL_PUNCTUATION=28,
+    /** Binary property Unified_Ideograph (new in Unicode 3.2).
+        For programmatic determination of
+        Ideographic Description Sequences. @stable ICU 2.1 */
+    UCHAR_UNIFIED_IDEOGRAPH=29,
+    /** Binary property Uppercase. Same as u_isUUppercase, different from u_isupper.
+        Lu+Other_Uppercase @stable ICU 2.1 */
+    UCHAR_UPPERCASE=30,
+    /** Binary property White_Space.
+        Same as u_isUWhiteSpace, different from u_isspace and u_isWhitespace.
+        Space characters+TAB+CR+LF-ZWSP-ZWNBSP @stable ICU 2.1 */
+    UCHAR_WHITE_SPACE=31,
+    /** Binary property XID_Continue.
+        ID_Continue modified to allow closure under
+        normalization forms NFKC and NFKD. @stable ICU 2.1 */
+    UCHAR_XID_CONTINUE=32,
+    /** Binary property XID_Start. ID_Start modified to allow
+        closure under normalization forms NFKC and NFKD. @stable ICU 2.1 */
+    UCHAR_XID_START=33,
+    /** Binary property Case_Sensitive. Either the source of a case
+        mapping or _in_ the target of a case mapping. Not the same as
+        the general category Cased_Letter. @stable ICU 2.6 */
+   UCHAR_CASE_SENSITIVE=34,
+    /** Binary property STerm (new in Unicode 4.0.1).
+        Sentence Terminal. Used in UAX #29: Text Boundaries
+        (http://www.unicode.org/reports/tr29/)
+        @stable ICU 3.0 */
+    UCHAR_S_TERM=35,
+    /** Binary property Variation_Selector (new in Unicode 4.0.1).
+        Indicates all those characters that qualify as Variation Selectors.
+        For details on the behavior of these characters,
+        see StandardizedVariants.html and 15.6 Variation Selectors.
+        @stable ICU 3.0 */
+    UCHAR_VARIATION_SELECTOR=36,
+    /** Binary property NFD_Inert.
+        ICU-specific property for characters that are inert under NFD,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+
+        There is one such property per normalization form.
+        These properties are computed as follows - an inert character is:
+        a) unassigned, or ALL of the following:
+        b) of combining class 0.
+        c) not decomposed by this normalization form.
+        AND if NFC or NFKC,
+        d) can never compose with a previous character.
+        e) can never compose with a following character.
+        f) can never change if another character is added.
+           Example: a-breve might satisfy all but f, but if you
+           add an ogonek it changes to a-ogonek + breve
+
+        See also com.ibm.text.UCD.NFSkippable in the ICU4J repository,
+        and icu/source/common/unormimp.h .
+        @stable ICU 3.0 */
+    UCHAR_NFD_INERT=37,
+    /** Binary property NFKD_Inert.
+        ICU-specific property for characters that are inert under NFKD,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+        @see UCHAR_NFD_INERT
+        @stable ICU 3.0 */
+    UCHAR_NFKD_INERT=38,
+    /** Binary property NFC_Inert.
+        ICU-specific property for characters that are inert under NFC,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+        @see UCHAR_NFD_INERT
+        @stable ICU 3.0 */
+    UCHAR_NFC_INERT=39,
+    /** Binary property NFKC_Inert.
+        ICU-specific property for characters that are inert under NFKC,
+        i.e., they do not interact with adjacent characters.
+        Used for example in normalizing transforms in incremental mode
+        to find the boundary of safely normalizable text despite possible
+        text additions.
+        @see UCHAR_NFD_INERT
+        @stable ICU 3.0 */
+    UCHAR_NFKC_INERT=40,
+    /** Binary Property Segment_Starter.
+        ICU-specific property for characters that are starters in terms of
+        Unicode normalization and combining character sequences.
+        They have ccc=0 and do not occur in non-initial position of the
+        canonical decomposition of any character
+        (like " in NFD(a-umlaut) and a Jamo T in an NFD(Hangul LVT)).
+        ICU uses this property for segmenting a string for generating a set of
+        canonically equivalent strings, e.g. for canonical closure while
+        processing collation tailoring rules.
+        @stable ICU 3.0 */
+    UCHAR_SEGMENT_STARTER=41,
+    /** Binary property Pattern_Syntax (new in Unicode 4.1).
+        See UAX #31 Identifier and Pattern Syntax
+        (http://www.unicode.org/reports/tr31/)
+        @stable ICU 3.4 */
+    UCHAR_PATTERN_SYNTAX=42,
+    /** Binary property Pattern_White_Space (new in Unicode 4.1).
+        See UAX #31 Identifier and Pattern Syntax
+        (http://www.unicode.org/reports/tr31/)
+        @stable ICU 3.4 */
+    UCHAR_PATTERN_WHITE_SPACE=43,
+    /** Binary property alnum (a C/POSIX character class).
+        Implemented according to the UTS #18 Annex C Standard Recommendation.
+        See the uchar.h file documentation.
+        @stable ICU 3.4 */
+    UCHAR_POSIX_ALNUM=44,
+    /** Binary property blank (a C/POSIX character class).
+        Implemented according to the UTS #18 Annex C Standard Recommendation.
+        See the uchar.h file documentation.
+        @stable ICU 3.4 */
+    UCHAR_POSIX_BLANK=45,
+    /** Binary property graph (a C/POSIX character class).
+        Implemented according to the UTS #18 Annex C Standard Recommendation.
+        See the uchar.h file documentation.
+        @stable ICU 3.4 */
+    UCHAR_POSIX_GRAPH=46,
+    /** Binary property print (a C/POSIX character class).
+        Implemented according to the UTS #18 Annex C Standard Recommendation.
+        See the uchar.h file documentation.
+        @stable ICU 3.4 */
+    UCHAR_POSIX_PRINT=47,
+    /** Binary property xdigit (a C/POSIX character class).
+        Implemented according to the UTS #18 Annex C Standard Recommendation.
+        See the uchar.h file documentation.
+        @stable ICU 3.4 */
+    UCHAR_POSIX_XDIGIT=48,
+    /** One more than the last constant for binary Unicode properties. @stable ICU 2.1 */
+    UCHAR_BINARY_LIMIT=49,
+
+    /** Enumerated property Bidi_Class.
+        Same as u_charDirection, returns UCharDirection values. @stable ICU 2.2 */
+    UCHAR_BIDI_CLASS=0x1000,
+    /** First constant for enumerated/integer Unicode properties. @stable ICU 2.2 */
+    UCHAR_INT_START=UCHAR_BIDI_CLASS,
+    /** Enumerated property Block.
+        Same as ublock_getCode, returns UBlockCode values. @stable ICU 2.2 */
+    UCHAR_BLOCK=0x1001,
+    /** Enumerated property Canonical_Combining_Class.
+        Same as u_getCombiningClass, returns 8-bit numeric values. @stable ICU 2.2 */
+    UCHAR_CANONICAL_COMBINING_CLASS=0x1002,
+    /** Enumerated property Decomposition_Type.
+        Returns UDecompositionType values. @stable ICU 2.2 */
+    UCHAR_DECOMPOSITION_TYPE=0x1003,
+    /** Enumerated property East_Asian_Width.
+        See http://www.unicode.org/reports/tr11/
+        Returns UEastAsianWidth values. @stable ICU 2.2 */
+    UCHAR_EAST_ASIAN_WIDTH=0x1004,
+    /** Enumerated property General_Category.
+        Same as u_charType, returns UCharCategory values. @stable ICU 2.2 */
+    UCHAR_GENERAL_CATEGORY=0x1005,
+    /** Enumerated property Joining_Group.
+        Returns UJoiningGroup values. @stable ICU 2.2 */
+    UCHAR_JOINING_GROUP=0x1006,
+    /** Enumerated property Joining_Type.
+        Returns UJoiningType values. @stable ICU 2.2 */
+    UCHAR_JOINING_TYPE=0x1007,
+    /** Enumerated property Line_Break.
+        Returns ULineBreak values. @stable ICU 2.2 */
+    UCHAR_LINE_BREAK=0x1008,
+    /** Enumerated property Numeric_Type.
+        Returns UNumericType values. @stable ICU 2.2 */
+    UCHAR_NUMERIC_TYPE=0x1009,
+    /** Enumerated property Script.
+        Same as uscript_getScript, returns UScriptCode values. @stable ICU 2.2 */
+    UCHAR_SCRIPT=0x100A,
+    /** Enumerated property Hangul_Syllable_Type, new in Unicode 4.
+        Returns UHangulSyllableType values. @stable ICU 2.6 */
+    UCHAR_HANGUL_SYLLABLE_TYPE=0x100B,
+    /** Enumerated property NFD_Quick_Check.
+        Returns UNormalizationCheckResult values. @stable ICU 3.0 */
+    UCHAR_NFD_QUICK_CHECK=0x100C,
+    /** Enumerated property NFKD_Quick_Check.
+        Returns UNormalizationCheckResult values. @stable ICU 3.0 */
+    UCHAR_NFKD_QUICK_CHECK=0x100D,
+    /** Enumerated property NFC_Quick_Check.
+        Returns UNormalizationCheckResult values. @stable ICU 3.0 */
+    UCHAR_NFC_QUICK_CHECK=0x100E,
+    /** Enumerated property NFKC_Quick_Check.
+        Returns UNormalizationCheckResult values. @stable ICU 3.0 */
+    UCHAR_NFKC_QUICK_CHECK=0x100F,
+    /** Enumerated property Lead_Canonical_Combining_Class.
+        ICU-specific property for the ccc of the first code point
+        of the decomposition, or lccc(c)=ccc(NFD(c)[0]).
+        Useful for checking for canonically ordered text;
+        see UNORM_FCD and http://www.unicode.org/notes/tn5/#FCD .
+        Returns 8-bit numeric values like UCHAR_CANONICAL_COMBINING_CLASS. @stable ICU 3.0 */
+    UCHAR_LEAD_CANONICAL_COMBINING_CLASS=0x1010,
+    /** Enumerated property Trail_Canonical_Combining_Class.
+        ICU-specific property for the ccc of the last code point
+        of the decomposition, or tccc(c)=ccc(NFD(c)[last]).
+        Useful for checking for canonically ordered text;
+        see UNORM_FCD and http://www.unicode.org/notes/tn5/#FCD .
+        Returns 8-bit numeric values like UCHAR_CANONICAL_COMBINING_CLASS. @stable ICU 3.0 */
+    UCHAR_TRAIL_CANONICAL_COMBINING_CLASS=0x1011,
+    /** Enumerated property Grapheme_Cluster_Break (new in Unicode 4.1).
+        Used in UAX #29: Text Boundaries
+        (http://www.unicode.org/reports/tr29/)
+        Returns UGraphemeClusterBreak values. @stable ICU 3.4 */
+    UCHAR_GRAPHEME_CLUSTER_BREAK=0x1012,
+    /** Enumerated property Sentence_Break (new in Unicode 4.1).
+        Used in UAX #29: Text Boundaries
+        (http://www.unicode.org/reports/tr29/)
+        Returns USentenceBreak values. @stable ICU 3.4 */
+    UCHAR_SENTENCE_BREAK=0x1013,
+    /** Enumerated property Word_Break (new in Unicode 4.1).
+        Used in UAX #29: Text Boundaries
+        (http://www.unicode.org/reports/tr29/)
+        Returns UWordBreakValues values. @stable ICU 3.4 */
+    UCHAR_WORD_BREAK=0x1014,
+    /** One more than the last constant for enumerated/integer Unicode properties. @stable ICU 2.2 */
+    UCHAR_INT_LIMIT=0x1015,
+
+    /** Bitmask property General_Category_Mask.
+        This is the General_Category property returned as a bit mask.
+        When used in u_getIntPropertyValue(c), same as U_MASK(u_charType(c)),
+        returns bit masks for UCharCategory values where exactly one bit is set.
+        When used with u_getPropertyValueName() and u_getPropertyValueEnum(),
+        a multi-bit mask is used for sets of categories like "Letters".
+        Mask values should be cast to uint32_t.
+        @stable ICU 2.4 */
+    UCHAR_GENERAL_CATEGORY_MASK=0x2000,
+    /** First constant for bit-mask Unicode properties. @stable ICU 2.4 */
+    UCHAR_MASK_START=UCHAR_GENERAL_CATEGORY_MASK,
+    /** One more than the last constant for bit-mask Unicode properties. @stable ICU 2.4 */
+    UCHAR_MASK_LIMIT=0x2001,
+
+    /** Double property Numeric_Value.
+        Corresponds to u_getNumericValue. @stable ICU 2.4 */
+    UCHAR_NUMERIC_VALUE=0x3000,
+    /** First constant for double Unicode properties. @stable ICU 2.4 */
+    UCHAR_DOUBLE_START=UCHAR_NUMERIC_VALUE,
+    /** One more than the last constant for double Unicode properties. @stable ICU 2.4 */
+    UCHAR_DOUBLE_LIMIT=0x3001,
+
+    /** String property Age.
+        Corresponds to u_charAge. @stable ICU 2.4 */
+    UCHAR_AGE=0x4000,
+    /** First constant for string Unicode properties. @stable ICU 2.4 */
+    UCHAR_STRING_START=UCHAR_AGE,
+    /** String property Bidi_Mirroring_Glyph.
+        Corresponds to u_charMirror. @stable ICU 2.4 */
+    UCHAR_BIDI_MIRRORING_GLYPH=0x4001,
+    /** String property Case_Folding.
+        Corresponds to u_strFoldCase in ustring.h. @stable ICU 2.4 */
+    UCHAR_CASE_FOLDING=0x4002,
+    /** String property ISO_Comment.
+        Corresponds to u_getISOComment. @stable ICU 2.4 */
+    UCHAR_ISO_COMMENT=0x4003,
+    /** String property Lowercase_Mapping.
+        Corresponds to u_strToLower in ustring.h. @stable ICU 2.4 */
+    UCHAR_LOWERCASE_MAPPING=0x4004,
+    /** String property Name.
+        Corresponds to u_charName. @stable ICU 2.4 */
+    UCHAR_NAME=0x4005,
+    /** String property Simple_Case_Folding.
+        Corresponds to u_foldCase. @stable ICU 2.4 */
+    UCHAR_SIMPLE_CASE_FOLDING=0x4006,
+    /** String property Simple_Lowercase_Mapping.
+        Corresponds to u_tolower. @stable ICU 2.4 */
+    UCHAR_SIMPLE_LOWERCASE_MAPPING=0x4007,
+    /** String property Simple_Titlecase_Mapping.
+        Corresponds to u_totitle. @stable ICU 2.4 */
+    UCHAR_SIMPLE_TITLECASE_MAPPING=0x4008,
+    /** String property Simple_Uppercase_Mapping.
+        Corresponds to u_toupper. @stable ICU 2.4 */
+    UCHAR_SIMPLE_UPPERCASE_MAPPING=0x4009,
+    /** String property Titlecase_Mapping.
+        Corresponds to u_strToTitle in ustring.h. @stable ICU 2.4 */
+    UCHAR_TITLECASE_MAPPING=0x400A,
+    /** String property Unicode_1_Name.
+        Corresponds to u_charName. @stable ICU 2.4 */
+    UCHAR_UNICODE_1_NAME=0x400B,
+    /** String property Uppercase_Mapping.
+        Corresponds to u_strToUpper in ustring.h. @stable ICU 2.4 */
+    UCHAR_UPPERCASE_MAPPING=0x400C,
+    /** One more than the last constant for string Unicode properties. @stable ICU 2.4 */
+    UCHAR_STRING_LIMIT=0x400D,
+
+    /** Represents a nonexistent or invalid property or property value. @stable ICU 2.4 */
+    UCHAR_INVALID_CODE = -1
+} UProperty;
+
+/**
+ * Data for enumerated Unicode general category types.
+ * See http://www.unicode.org/Public/UNIDATA/UnicodeData.html .
+ * @stable ICU 2.0
+ */
+typedef enum UCharCategory
+{
+    /** See note !!.  Comments of the form "Cn" are read by genpname. */
+
+    /** Non-category for unassigned and non-character code points. @stable ICU 2.0 */
+    U_UNASSIGNED              = 0,
+    /** Cn "Other, Not Assigned (no characters in [UnicodeData.txt] have this property)" (same as U_UNASSIGNED!) @stable ICU 2.0 */
+    U_GENERAL_OTHER_TYPES     = 0,
+    /** Lu @stable ICU 2.0 */
+    U_UPPERCASE_LETTER        = 1,
+    /** Ll @stable ICU 2.0 */
+    U_LOWERCASE_LETTER        = 2,
+    /** Lt @stable ICU 2.0 */
+    U_TITLECASE_LETTER        = 3,
+    /** Lm @stable ICU 2.0 */
+    U_MODIFIER_LETTER         = 4,
+    /** Lo @stable ICU 2.0 */
+    U_OTHER_LETTER            = 5,
+    /** Mn @stable ICU 2.0 */
+    U_NON_SPACING_MARK        = 6,
+    /** Me @stable ICU 2.0 */
+    U_ENCLOSING_MARK          = 7,
+    /** Mc @stable ICU 2.0 */
+    U_COMBINING_SPACING_MARK  = 8,
+    /** Nd @stable ICU 2.0 */
+    U_DECIMAL_DIGIT_NUMBER    = 9,
+    /** Nl @stable ICU 2.0 */
+    U_LETTER_NUMBER           = 10,
+    /** No @stable ICU 2.0 */
+    U_OTHER_NUMBER            = 11,
+    /** Zs @stable ICU 2.0 */
+    U_SPACE_SEPARATOR         = 12,
+    /** Zl @stable ICU 2.0 */
+    U_LINE_SEPARATOR          = 13,
+    /** Zp @stable ICU 2.0 */
+    U_PARAGRAPH_SEPARATOR     = 14,
+    /** Cc @stable ICU 2.0 */
+    U_CONTROL_CHAR            = 15,
+    /** Cf @stable ICU 2.0 */
+    U_FORMAT_CHAR             = 16,
+    /** Co @stable ICU 2.0 */
+    U_PRIVATE_USE_CHAR        = 17,
+    /** Cs @stable ICU 2.0 */
+    U_SURROGATE               = 18,
+    /** Pd @stable ICU 2.0 */
+    U_DASH_PUNCTUATION        = 19,
+    /** Ps @stable ICU 2.0 */
+    U_START_PUNCTUATION       = 20,
+    /** Pe @stable ICU 2.0 */
+    U_END_PUNCTUATION         = 21,
+    /** Pc @stable ICU 2.0 */
+    U_CONNECTOR_PUNCTUATION   = 22,
+    /** Po @stable ICU 2.0 */
+    U_OTHER_PUNCTUATION       = 23,
+    /** Sm @stable ICU 2.0 */
+    U_MATH_SYMBOL             = 24,
+    /** Sc @stable ICU 2.0 */
+    U_CURRENCY_SYMBOL         = 25,
+    /** Sk @stable ICU 2.0 */
+    U_MODIFIER_SYMBOL         = 26,
+    /** So @stable ICU 2.0 */
+    U_OTHER_SYMBOL            = 27,
+    /** Pi @stable ICU 2.0 */
+    U_INITIAL_PUNCTUATION     = 28,
+    /** Pf @stable ICU 2.0 */
+    U_FINAL_PUNCTUATION       = 29,
+    /** One higher than the last enum UCharCategory constant. @stable ICU 2.0 */
+    U_CHAR_CATEGORY_COUNT
+} UCharCategory;
+
+/**
+ * U_GC_XX_MASK constants are bit flags corresponding to Unicode
+ * general category values.
+ * For each category, the nth bit is set if the numeric value of the
+ * corresponding UCharCategory constant is n.
+ *
+ * There are also some U_GC_Y_MASK constants for groups of general categories
+ * like L for all letter categories.
+ *
+ * @see u_charType
+ * @see U_GET_GC_MASK
+ * @see UCharCategory
+ * @stable ICU 2.1
+ */
+#define U_GC_CN_MASK    U_MASK(U_GENERAL_OTHER_TYPES)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LU_MASK    U_MASK(U_UPPERCASE_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LL_MASK    U_MASK(U_LOWERCASE_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LT_MASK    U_MASK(U_TITLECASE_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LM_MASK    U_MASK(U_MODIFIER_LETTER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_LO_MASK    U_MASK(U_OTHER_LETTER)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_MN_MASK    U_MASK(U_NON_SPACING_MARK)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ME_MASK    U_MASK(U_ENCLOSING_MARK)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_MC_MASK    U_MASK(U_COMBINING_SPACING_MARK)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ND_MASK    U_MASK(U_DECIMAL_DIGIT_NUMBER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_NL_MASK    U_MASK(U_LETTER_NUMBER)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_NO_MASK    U_MASK(U_OTHER_NUMBER)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ZS_MASK    U_MASK(U_SPACE_SEPARATOR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ZL_MASK    U_MASK(U_LINE_SEPARATOR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_ZP_MASK    U_MASK(U_PARAGRAPH_SEPARATOR)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CC_MASK    U_MASK(U_CONTROL_CHAR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CF_MASK    U_MASK(U_FORMAT_CHAR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CO_MASK    U_MASK(U_PRIVATE_USE_CHAR)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_CS_MASK    U_MASK(U_SURROGATE)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PD_MASK    U_MASK(U_DASH_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PS_MASK    U_MASK(U_START_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PE_MASK    U_MASK(U_END_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PC_MASK    U_MASK(U_CONNECTOR_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PO_MASK    U_MASK(U_OTHER_PUNCTUATION)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SM_MASK    U_MASK(U_MATH_SYMBOL)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SC_MASK    U_MASK(U_CURRENCY_SYMBOL)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SK_MASK    U_MASK(U_MODIFIER_SYMBOL)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_SO_MASK    U_MASK(U_OTHER_SYMBOL)
+
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PI_MASK    U_MASK(U_INITIAL_PUNCTUATION)
+/** Mask constant for a UCharCategory. @stable ICU 2.1 */
+#define U_GC_PF_MASK    U_MASK(U_FINAL_PUNCTUATION)
+
+
+/** Mask constant for multiple UCharCategory bits (L Letters). @stable ICU 2.1 */
+#define U_GC_L_MASK \
+            (U_GC_LU_MASK|U_GC_LL_MASK|U_GC_LT_MASK|U_GC_LM_MASK|U_GC_LO_MASK)
+
+/** Mask constant for multiple UCharCategory bits (LC Cased Letters). @stable ICU 2.1 */
+#define U_GC_LC_MASK \
+            (U_GC_LU_MASK|U_GC_LL_MASK|U_GC_LT_MASK)
+
+/** Mask constant for multiple UCharCategory bits (M Marks). @stable ICU 2.1 */
+#define U_GC_M_MASK (U_GC_MN_MASK|U_GC_ME_MASK|U_GC_MC_MASK)
+
+/** Mask constant for multiple UCharCategory bits (N Numbers). @stable ICU 2.1 */
+#define U_GC_N_MASK (U_GC_ND_MASK|U_GC_NL_MASK|U_GC_NO_MASK)
+
+/** Mask constant for multiple UCharCategory bits (Z Separators). @stable ICU 2.1 */
+#define U_GC_Z_MASK (U_GC_ZS_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK)
+
+/** Mask constant for multiple UCharCategory bits (C Others). @stable ICU 2.1 */
+#define U_GC_C_MASK \
+            (U_GC_CN_MASK|U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CO_MASK|U_GC_CS_MASK)
+
+/** Mask constant for multiple UCharCategory bits (P Punctuation). @stable ICU 2.1 */
+#define U_GC_P_MASK \
+            (U_GC_PD_MASK|U_GC_PS_MASK|U_GC_PE_MASK|U_GC_PC_MASK|U_GC_PO_MASK| \
+             U_GC_PI_MASK|U_GC_PF_MASK)
+
+/** Mask constant for multiple UCharCategory bits (S Symbols). @stable ICU 2.1 */
+#define U_GC_S_MASK (U_GC_SM_MASK|U_GC_SC_MASK|U_GC_SK_MASK|U_GC_SO_MASK)
+
+/**
+ * This specifies the language directional property of a character set.
+ * @stable ICU 2.0
+ */
+typedef enum UCharDirection {
+    /** See note !!.  Comments of the form "EN" are read by genpname. */
+
+    /** L @stable ICU 2.0 */
+    U_LEFT_TO_RIGHT               = 0,
+    /** R @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT               = 1,
+    /** EN @stable ICU 2.0 */
+    U_EUROPEAN_NUMBER             = 2,
+    /** ES @stable ICU 2.0 */
+    U_EUROPEAN_NUMBER_SEPARATOR   = 3,
+    /** ET @stable ICU 2.0 */
+    U_EUROPEAN_NUMBER_TERMINATOR  = 4,
+    /** AN @stable ICU 2.0 */
+    U_ARABIC_NUMBER               = 5,
+    /** CS @stable ICU 2.0 */
+    U_COMMON_NUMBER_SEPARATOR     = 6,
+    /** B @stable ICU 2.0 */
+    U_BLOCK_SEPARATOR             = 7,
+    /** S @stable ICU 2.0 */
+    U_SEGMENT_SEPARATOR           = 8,
+    /** WS @stable ICU 2.0 */
+    U_WHITE_SPACE_NEUTRAL         = 9,
+    /** ON @stable ICU 2.0 */
+    U_OTHER_NEUTRAL               = 10,
+    /** LRE @stable ICU 2.0 */
+    U_LEFT_TO_RIGHT_EMBEDDING     = 11,
+    /** LRO @stable ICU 2.0 */
+    U_LEFT_TO_RIGHT_OVERRIDE      = 12,
+    /** AL @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT_ARABIC        = 13,
+    /** RLE @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT_EMBEDDING     = 14,
+    /** RLO @stable ICU 2.0 */
+    U_RIGHT_TO_LEFT_OVERRIDE      = 15,
+    /** PDF @stable ICU 2.0 */
+    U_POP_DIRECTIONAL_FORMAT      = 16,
+    /** NSM @stable ICU 2.0 */
+    U_DIR_NON_SPACING_MARK        = 17,
+    /** BN @stable ICU 2.0 */
+    U_BOUNDARY_NEUTRAL            = 18,
+    /** @stable ICU 2.0 */
+    U_CHAR_DIRECTION_COUNT
+} UCharDirection;
+
+/**
+ * Constants for Unicode blocks, see the Unicode Data file Blocks.txt
+ * @stable ICU 2.0
+ */
+enum UBlockCode {
+
+    /** New No_Block value in Unicode 4. @stable ICU 2.6 */
+    UBLOCK_NO_BLOCK = 0, /*[none]*/ /* Special range indicating No_Block */
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BASIC_LATIN = 1, /*[0000]*/ /*See note !!*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_1_SUPPLEMENT=2, /*[0080]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_EXTENDED_A =3, /*[0100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_EXTENDED_B =4, /*[0180]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_IPA_EXTENSIONS =5, /*[0250]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SPACING_MODIFIER_LETTERS =6, /*[02B0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_COMBINING_DIACRITICAL_MARKS =7, /*[0300]*/
+
+    /**
+     * Unicode 3.2 renames this block to "Greek and Coptic".
+     * @stable ICU 2.0
+     */
+    UBLOCK_GREEK =8, /*[0370]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CYRILLIC =9, /*[0400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARMENIAN =10, /*[0530]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HEBREW =11, /*[0590]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARABIC =12, /*[0600]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SYRIAC =13, /*[0700]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_THAANA =14, /*[0780]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_DEVANAGARI =15, /*[0900]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BENGALI =16, /*[0980]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GURMUKHI =17, /*[0A00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GUJARATI =18, /*[0A80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ORIYA =19, /*[0B00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_TAMIL =20, /*[0B80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_TELUGU =21, /*[0C00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KANNADA =22, /*[0C80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MALAYALAM =23, /*[0D00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SINHALA =24, /*[0D80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_THAI =25, /*[0E00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LAO =26, /*[0E80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_TIBETAN =27, /*[0F00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MYANMAR =28, /*[1000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GEORGIAN =29, /*[10A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HANGUL_JAMO =30, /*[1100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ETHIOPIC =31, /*[1200]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CHEROKEE =32, /*[13A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS =33, /*[1400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_OGHAM =34, /*[1680]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_RUNIC =35, /*[16A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KHMER =36, /*[1780]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MONGOLIAN =37, /*[1800]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LATIN_EXTENDED_ADDITIONAL =38, /*[1E00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GREEK_EXTENDED =39, /*[1F00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GENERAL_PUNCTUATION =40, /*[2000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SUPERSCRIPTS_AND_SUBSCRIPTS =41, /*[2070]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CURRENCY_SYMBOLS =42, /*[20A0]*/
+
+    /**
+     * Unicode 3.2 renames this block to "Combining Diacritical Marks for Symbols".
+     * @stable ICU 2.0
+     */
+    UBLOCK_COMBINING_MARKS_FOR_SYMBOLS =43, /*[20D0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LETTERLIKE_SYMBOLS =44, /*[2100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_NUMBER_FORMS =45, /*[2150]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARROWS =46, /*[2190]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MATHEMATICAL_OPERATORS =47, /*[2200]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MISCELLANEOUS_TECHNICAL =48, /*[2300]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CONTROL_PICTURES =49, /*[2400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_OPTICAL_CHARACTER_RECOGNITION =50, /*[2440]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ENCLOSED_ALPHANUMERICS =51, /*[2460]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BOX_DRAWING =52, /*[2500]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BLOCK_ELEMENTS =53, /*[2580]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_GEOMETRIC_SHAPES =54, /*[25A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_MISCELLANEOUS_SYMBOLS =55, /*[2600]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_DINGBATS =56, /*[2700]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BRAILLE_PATTERNS =57, /*[2800]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_RADICALS_SUPPLEMENT =58, /*[2E80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KANGXI_RADICALS =59, /*[2F00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_IDEOGRAPHIC_DESCRIPTION_CHARACTERS =60, /*[2FF0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION =61, /*[3000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HIRAGANA =62, /*[3040]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KATAKANA =63, /*[30A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BOPOMOFO =64, /*[3100]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HANGUL_COMPATIBILITY_JAMO =65, /*[3130]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_KANBUN =66, /*[3190]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_BOPOMOFO_EXTENDED =67, /*[31A0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ENCLOSED_CJK_LETTERS_AND_MONTHS =68, /*[3200]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY =69, /*[3300]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A =70, /*[3400]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_UNIFIED_IDEOGRAPHS =71, /*[4E00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_YI_SYLLABLES =72, /*[A000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_YI_RADICALS =73, /*[A490]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HANGUL_SYLLABLES =74, /*[AC00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HIGH_SURROGATES =75, /*[D800]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HIGH_PRIVATE_USE_SURROGATES =76, /*[DB80]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_LOW_SURROGATES =77, /*[DC00]*/
+
+    /**
+     * Same as UBLOCK_PRIVATE_USE_AREA.
+     * Until Unicode 3.1.1, the corresponding block name was "Private Use",
+     * and multiple code point ranges had this block.
+     * Unicode 3.2 renames the block for the BMP PUA to "Private Use Area" and
+     * adds separate blocks for the supplementary PUAs.
+     *
+     * @stable ICU 2.0
+     */
+    UBLOCK_PRIVATE_USE = 78,
+    /**
+     * Same as UBLOCK_PRIVATE_USE.
+     * Until Unicode 3.1.1, the corresponding block name was "Private Use",
+     * and multiple code point ranges had this block.
+     * Unicode 3.2 renames the block for the BMP PUA to "Private Use Area" and
+     * adds separate blocks for the supplementary PUAs.
+     *
+     * @stable ICU 2.0
+     */
+    UBLOCK_PRIVATE_USE_AREA =UBLOCK_PRIVATE_USE, /*[E000]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS =79, /*[F900]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ALPHABETIC_PRESENTATION_FORMS =80, /*[FB00]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARABIC_PRESENTATION_FORMS_A =81, /*[FB50]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_COMBINING_HALF_MARKS =82, /*[FE20]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY_FORMS =83, /*[FE30]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SMALL_FORM_VARIANTS =84, /*[FE50]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_ARABIC_PRESENTATION_FORMS_B =85, /*[FE70]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_SPECIALS =86, /*[FFF0]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS =87, /*[FF00]*/
+
+    /* New blocks in Unicode 3.1 */
+
+    /** @stable ICU 2.0 */
+    UBLOCK_OLD_ITALIC = 88  , /*[10300]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_GOTHIC = 89 , /*[10330]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_DESERET = 90 , /*[10400]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_BYZANTINE_MUSICAL_SYMBOLS = 91 , /*[1D000]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_MUSICAL_SYMBOLS = 92 , /*[1D100]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS = 93  , /*[1D400]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B  = 94 , /*[20000]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT = 95 , /*[2F800]*/
+    /** @stable ICU 2.0 */
+    UBLOCK_TAGS = 96, /*[E0000]*/
+
+    /* New blocks in Unicode 3.2 */
+
+    /**
+     * Unicode 4.0.1 renames the "Cyrillic Supplementary" block to "Cyrillic Supplement".
+     * @stable ICU 2.2
+     */
+    UBLOCK_CYRILLIC_SUPPLEMENTARY = 97, 
+    /** @stable ICU 3.0  */
+    UBLOCK_CYRILLIC_SUPPLEMENT = UBLOCK_CYRILLIC_SUPPLEMENTARY, /*[0500]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_TAGALOG = 98, /*[1700]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_HANUNOO = 99, /*[1720]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_BUHID = 100, /*[1740]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_TAGBANWA = 101, /*[1760]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A = 102, /*[27C0]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTAL_ARROWS_A = 103, /*[27F0]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTAL_ARROWS_B = 104, /*[2900]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B = 105, /*[2980]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS = 106, /*[2A00]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_KATAKANA_PHONETIC_EXTENSIONS = 107, /*[31F0]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_VARIATION_SELECTORS = 108, /*[FE00]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_A = 109, /*[F0000]*/
+    /** @stable ICU 2.2 */
+    UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_B = 110, /*[100000]*/
+
+    /* New blocks in Unicode 4 */
+
+    /** @stable ICU 2.6 */
+    UBLOCK_LIMBU = 111, /*[1900]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_TAI_LE = 112, /*[1950]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_KHMER_SYMBOLS = 113, /*[19E0]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_PHONETIC_EXTENSIONS = 114, /*[1D00]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS = 115, /*[2B00]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_YIJING_HEXAGRAM_SYMBOLS = 116, /*[4DC0]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_LINEAR_B_SYLLABARY = 117, /*[10000]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_LINEAR_B_IDEOGRAMS = 118, /*[10080]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_AEGEAN_NUMBERS = 119, /*[10100]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_UGARITIC = 120, /*[10380]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_SHAVIAN = 121, /*[10450]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_OSMANYA = 122, /*[10480]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_CYPRIOT_SYLLABARY = 123, /*[10800]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_TAI_XUAN_JING_SYMBOLS = 124, /*[1D300]*/
+    /** @stable ICU 2.6 */
+    UBLOCK_VARIATION_SELECTORS_SUPPLEMENT = 125, /*[E0100]*/
+
+    /* New blocks in Unicode 4.1 */
+
+    /** @stable ICU 3.4 */
+    UBLOCK_ANCIENT_GREEK_MUSICAL_NOTATION = 126, /*[1D200]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_ANCIENT_GREEK_NUMBERS = 127, /*[10140]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_ARABIC_SUPPLEMENT = 128, /*[0750]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_BUGINESE = 129, /*[1A00]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_CJK_STROKES = 130, /*[31C0]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT = 131, /*[1DC0]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_COPTIC = 132, /*[2C80]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_ETHIOPIC_EXTENDED = 133, /*[2D80]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_ETHIOPIC_SUPPLEMENT = 134, /*[1380]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_GEORGIAN_SUPPLEMENT = 135, /*[2D00]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_GLAGOLITIC = 136, /*[2C00]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_KHAROSHTHI = 137, /*[10A00]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_MODIFIER_TONE_LETTERS = 138, /*[A700]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_NEW_TAI_LUE = 139, /*[1980]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_OLD_PERSIAN = 140, /*[103A0]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_PHONETIC_EXTENSIONS_SUPPLEMENT = 141, /*[1D80]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_SUPPLEMENTAL_PUNCTUATION = 142, /*[2E00]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_SYLOTI_NAGRI = 143, /*[A800]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_TIFINAGH = 144, /*[2D30]*/
+    /** @stable ICU 3.4 */
+    UBLOCK_VERTICAL_FORMS = 145, /*[FE10]*/
+
+    /* New blocks in Unicode 5.0 */
+
+    /** @stable ICU 3.6 */
+    UBLOCK_NKO = 146, /*[07C0]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_BALINESE = 147, /*[1B00]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_LATIN_EXTENDED_C = 148, /*[2C60]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_LATIN_EXTENDED_D = 149, /*[A720]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_PHAGS_PA = 150, /*[A840]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_PHOENICIAN = 151, /*[10900]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_CUNEIFORM = 152, /*[12000]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_CUNEIFORM_NUMBERS_AND_PUNCTUATION = 153, /*[12400]*/
+    /** @stable ICU 3.6 */
+    UBLOCK_COUNTING_ROD_NUMERALS = 154, /*[1D360]*/
+
+    /* New blocks in Unicode 5.1 */
+
+    /** @draft ICU 4.0 */
+    UBLOCK_SUNDANESE = 155, /*[1B80]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_LEPCHA = 156, /*[1C00]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_OL_CHIKI = 157, /*[1C50]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_CYRILLIC_EXTENDED_A = 158, /*[2DE0]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_VAI = 159, /*[A500]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_CYRILLIC_EXTENDED_B = 160, /*[A640]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_SAURASHTRA = 161, /*[A880]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_KAYAH_LI = 162, /*[A900]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_REJANG = 163, /*[A930]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_CHAM = 164, /*[AA00]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_ANCIENT_SYMBOLS = 165, /*[10190]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_PHAISTOS_DISC = 166, /*[101D0]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_LYCIAN = 167, /*[10280]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_CARIAN = 168, /*[102A0]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_LYDIAN = 169, /*[10920]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_MAHJONG_TILES = 170, /*[1F000]*/
+    /** @draft ICU 4.0 */
+    UBLOCK_DOMINO_TILES = 171, /*[1F030]*/
+
+    /** @stable ICU 2.0 */
+    UBLOCK_COUNT = 172,
+
+    /** @stable ICU 2.0 */
+    UBLOCK_INVALID_CODE=-1
+};
+
+/** @stable ICU 2.0 */
+typedef enum UBlockCode UBlockCode;
+
+/**
+ * East Asian Width constants.
+ *
+ * @see UCHAR_EAST_ASIAN_WIDTH
+ * @see u_getIntPropertyValue
+ * @stable ICU 2.2
+ */
+typedef enum UEastAsianWidth {
+    U_EA_NEUTRAL,   /*[N]*/ /*See note !!*/
+    U_EA_AMBIGUOUS, /*[A]*/
+    U_EA_HALFWIDTH, /*[H]*/
+    U_EA_FULLWIDTH, /*[F]*/
+    U_EA_NARROW,    /*[Na]*/
+    U_EA_WIDE,      /*[W]*/
+    U_EA_COUNT
+} UEastAsianWidth;
+/*
+ * Implementation note:
+ * Keep UEastAsianWidth constant values in sync with names list in genprops/props2.c.
+ */
+
+/**
+ * Selector constants for u_charName().
+ * u_charName() returns the "modern" name of a
+ * Unicode character; or the name that was defined in
+ * Unicode version 1.0, before the Unicode standard merged
+ * with ISO-10646; or an "extended" name that gives each
+ * Unicode code point a unique name.
+ *
+ * @see u_charName
+ * @stable ICU 2.0
+ */
+typedef enum UCharNameChoice {
+    U_UNICODE_CHAR_NAME,
+    U_UNICODE_10_CHAR_NAME,
+    U_EXTENDED_CHAR_NAME,
+    U_CHAR_NAME_CHOICE_COUNT
+} UCharNameChoice;
+
+/**
+ * Selector constants for u_getPropertyName() and
+ * u_getPropertyValueName().  These selectors are used to choose which
+ * name is returned for a given property or value.  All properties and
+ * values have a long name.  Most have a short name, but some do not.
+ * Unicode allows for additional names, beyond the long and short
+ * name, which would be indicated by U_LONG_PROPERTY_NAME + i, where
+ * i=1, 2,...
+ *
+ * @see u_getPropertyName()
+ * @see u_getPropertyValueName()
+ * @stable ICU 2.4
+ */
+typedef enum UPropertyNameChoice {
+    U_SHORT_PROPERTY_NAME,
+    U_LONG_PROPERTY_NAME,
+    U_PROPERTY_NAME_CHOICE_COUNT
+} UPropertyNameChoice;
+
+/**
+ * Decomposition Type constants.
+ *
+ * @see UCHAR_DECOMPOSITION_TYPE
+ * @stable ICU 2.2
+ */
+typedef enum UDecompositionType {
+    U_DT_NONE,              /*[none]*/ /*See note !!*/
+    U_DT_CANONICAL,         /*[can]*/
+    U_DT_COMPAT,            /*[com]*/
+    U_DT_CIRCLE,            /*[enc]*/
+    U_DT_FINAL,             /*[fin]*/
+    U_DT_FONT,              /*[font]*/
+    U_DT_FRACTION,          /*[fra]*/
+    U_DT_INITIAL,           /*[init]*/
+    U_DT_ISOLATED,          /*[iso]*/
+    U_DT_MEDIAL,            /*[med]*/
+    U_DT_NARROW,            /*[nar]*/
+    U_DT_NOBREAK,           /*[nb]*/
+    U_DT_SMALL,             /*[sml]*/
+    U_DT_SQUARE,            /*[sqr]*/
+    U_DT_SUB,               /*[sub]*/
+    U_DT_SUPER,             /*[sup]*/
+    U_DT_VERTICAL,          /*[vert]*/
+    U_DT_WIDE,              /*[wide]*/
+    U_DT_COUNT /* 18 */
+} UDecompositionType;
+
+/**
+ * Joining Type constants.
+ *
+ * @see UCHAR_JOINING_TYPE
+ * @stable ICU 2.2
+ */
+typedef enum UJoiningType {
+    U_JT_NON_JOINING,       /*[U]*/ /*See note !!*/
+    U_JT_JOIN_CAUSING,      /*[C]*/
+    U_JT_DUAL_JOINING,      /*[D]*/
+    U_JT_LEFT_JOINING,      /*[L]*/
+    U_JT_RIGHT_JOINING,     /*[R]*/
+    U_JT_TRANSPARENT,       /*[T]*/
+    U_JT_COUNT /* 6 */
+} UJoiningType;
+
+/**
+ * Joining Group constants.
+ *
+ * @see UCHAR_JOINING_GROUP
+ * @stable ICU 2.2
+ */
+typedef enum UJoiningGroup {
+    U_JG_NO_JOINING_GROUP,
+    U_JG_AIN,
+    U_JG_ALAPH,
+    U_JG_ALEF,
+    U_JG_BEH,
+    U_JG_BETH,
+    U_JG_DAL,
+    U_JG_DALATH_RISH,
+    U_JG_E,
+    U_JG_FEH,
+    U_JG_FINAL_SEMKATH,
+    U_JG_GAF,
+    U_JG_GAMAL,
+    U_JG_HAH,
+    U_JG_HAMZA_ON_HEH_GOAL,
+    U_JG_HE,
+    U_JG_HEH,
+    U_JG_HEH_GOAL,
+    U_JG_HETH,
+    U_JG_KAF,
+    U_JG_KAPH,
+    U_JG_KNOTTED_HEH,
+    U_JG_LAM,
+    U_JG_LAMADH,
+    U_JG_MEEM,
+    U_JG_MIM,
+    U_JG_NOON,
+    U_JG_NUN,
+    U_JG_PE,
+    U_JG_QAF,
+    U_JG_QAPH,
+    U_JG_REH,
+    U_JG_REVERSED_PE,
+    U_JG_SAD,
+    U_JG_SADHE,
+    U_JG_SEEN,
+    U_JG_SEMKATH,
+    U_JG_SHIN,
+    U_JG_SWASH_KAF,
+    U_JG_SYRIAC_WAW,
+    U_JG_TAH,
+    U_JG_TAW,
+    U_JG_TEH_MARBUTA,
+    U_JG_TETH,
+    U_JG_WAW,
+    U_JG_YEH,
+    U_JG_YEH_BARREE,
+    U_JG_YEH_WITH_TAIL,
+    U_JG_YUDH,
+    U_JG_YUDH_HE,
+    U_JG_ZAIN,
+    U_JG_FE,        /**< @stable ICU 2.6 */
+    U_JG_KHAPH,     /**< @stable ICU 2.6 */
+    U_JG_ZHAIN,     /**< @stable ICU 2.6 */
+    U_JG_BURUSHASKI_YEH_BARREE, /**< @draft ICU 4.0 */
+    U_JG_COUNT
+} UJoiningGroup;
+
+/**
+ * Grapheme Cluster Break constants.
+ *
+ * @see UCHAR_GRAPHEME_CLUSTER_BREAK
+ * @stable ICU 3.4
+ */
+typedef enum UGraphemeClusterBreak {
+    U_GCB_OTHER = 0,            /*[XX]*/ /*See note !!*/
+    U_GCB_CONTROL = 1,          /*[CN]*/
+    U_GCB_CR = 2,               /*[CR]*/
+    U_GCB_EXTEND = 3,           /*[EX]*/
+    U_GCB_L = 4,                /*[L]*/
+    U_GCB_LF = 5,               /*[LF]*/
+    U_GCB_LV = 6,               /*[LV]*/
+    U_GCB_LVT = 7,              /*[LVT]*/
+    U_GCB_T = 8,                /*[T]*/
+    U_GCB_V = 9,                /*[V]*/
+    U_GCB_SPACING_MARK = 10,    /*[SM]*/ /* from here on: new in Unicode 5.1/ICU 4.0 */
+    U_GCB_PREPEND = 11,         /*[PP]*/
+    U_GCB_COUNT = 12
+} UGraphemeClusterBreak;
+
+/**
+ * Word Break constants.
+ * (UWordBreak is a pre-existing enum type in ubrk.h for word break status tags.)
+ *
+ * @see UCHAR_WORD_BREAK
+ * @stable ICU 3.4
+ */
+typedef enum UWordBreakValues {
+    U_WB_OTHER = 0,             /*[XX]*/ /*See note !!*/
+    U_WB_ALETTER = 1,           /*[LE]*/
+    U_WB_FORMAT = 2,            /*[FO]*/
+    U_WB_KATAKANA = 3,          /*[KA]*/
+    U_WB_MIDLETTER = 4,         /*[ML]*/
+    U_WB_MIDNUM = 5,            /*[MN]*/
+    U_WB_NUMERIC = 6,           /*[NU]*/
+    U_WB_EXTENDNUMLET = 7,      /*[EX]*/
+    U_WB_CR = 8,                /*[CR]*/ /* from here on: new in Unicode 5.1/ICU 4.0 */
+    U_WB_EXTEND = 9,            /*[Extend]*/
+    U_WB_LF = 10,               /*[LF]*/
+    U_WB_MIDNUMLET =11,         /*[MB]*/
+    U_WB_NEWLINE =12,           /*[NL]*/
+    U_WB_COUNT = 13
+} UWordBreakValues;
+
+/**
+ * Sentence Break constants.
+ *
+ * @see UCHAR_SENTENCE_BREAK
+ * @stable ICU 3.4
+ */
+typedef enum USentenceBreak {
+    U_SB_OTHER = 0,             /*[XX]*/ /*See note !!*/
+    U_SB_ATERM = 1,             /*[AT]*/
+    U_SB_CLOSE = 2,             /*[CL]*/
+    U_SB_FORMAT = 3,            /*[FO]*/
+    U_SB_LOWER = 4,             /*[LO]*/
+    U_SB_NUMERIC = 5,           /*[NU]*/
+    U_SB_OLETTER = 6,           /*[LE]*/
+    U_SB_SEP = 7,               /*[SE]*/
+    U_SB_SP = 8,                /*[SP]*/
+    U_SB_STERM = 9,             /*[ST]*/
+    U_SB_UPPER = 10,            /*[UP]*/
+    U_SB_CR = 11,               /*[CR]*/ /* from here on: new in Unicode 5.1/ICU 4.0 */
+    U_SB_EXTEND = 12,           /*[EX]*/
+    U_SB_LF = 13,               /*[LF]*/
+    U_SB_SCONTINUE = 14,        /*[SC]*/
+    U_SB_COUNT = 15
+} USentenceBreak;
+
+/**
+ * Line Break constants.
+ *
+ * @see UCHAR_LINE_BREAK
+ * @stable ICU 2.2
+ */
+typedef enum ULineBreak {
+    U_LB_UNKNOWN = 0,           /*[XX]*/ /*See note !!*/
+    U_LB_AMBIGUOUS = 1,         /*[AI]*/
+    U_LB_ALPHABETIC = 2,        /*[AL]*/
+    U_LB_BREAK_BOTH = 3,        /*[B2]*/
+    U_LB_BREAK_AFTER = 4,       /*[BA]*/
+    U_LB_BREAK_BEFORE = 5,      /*[BB]*/
+    U_LB_MANDATORY_BREAK = 6,   /*[BK]*/
+    U_LB_CONTINGENT_BREAK = 7,  /*[CB]*/
+    U_LB_CLOSE_PUNCTUATION = 8, /*[CL]*/
+    U_LB_COMBINING_MARK = 9,    /*[CM]*/
+    U_LB_CARRIAGE_RETURN = 10,   /*[CR]*/
+    U_LB_EXCLAMATION = 11,       /*[EX]*/
+    U_LB_GLUE = 12,              /*[GL]*/
+    U_LB_HYPHEN = 13,            /*[HY]*/
+    U_LB_IDEOGRAPHIC = 14,       /*[ID]*/
+    U_LB_INSEPERABLE = 15,
+    /** Renamed from the misspelled "inseperable" in Unicode 4.0.1/ICU 3.0 @stable ICU 3.0 */
+    U_LB_INSEPARABLE=U_LB_INSEPERABLE,/*[IN]*/
+    U_LB_INFIX_NUMERIC = 16,     /*[IS]*/
+    U_LB_LINE_FEED = 17,         /*[LF]*/
+    U_LB_NONSTARTER = 18,        /*[NS]*/
+    U_LB_NUMERIC = 19,           /*[NU]*/
+    U_LB_OPEN_PUNCTUATION = 20,  /*[OP]*/
+    U_LB_POSTFIX_NUMERIC = 21,   /*[PO]*/
+    U_LB_PREFIX_NUMERIC = 22,    /*[PR]*/
+    U_LB_QUOTATION = 23,         /*[QU]*/
+    U_LB_COMPLEX_CONTEXT = 24,   /*[SA]*/
+    U_LB_SURROGATE = 25,         /*[SG]*/
+    U_LB_SPACE = 26,             /*[SP]*/
+    U_LB_BREAK_SYMBOLS = 27,     /*[SY]*/
+    U_LB_ZWSPACE = 28,           /*[ZW]*/
+    U_LB_NEXT_LINE = 29,         /*[NL]*/ /* from here on: new in Unicode 4/ICU 2.6 */
+    U_LB_WORD_JOINER = 30,       /*[WJ]*/
+    U_LB_H2 = 31,                /*[H2]*/ /* from here on: new in Unicode 4.1/ICU 3.4 */
+    U_LB_H3 = 32,                /*[H3]*/
+    U_LB_JL = 33,                /*[JL]*/
+    U_LB_JT = 34,                /*[JT]*/
+    U_LB_JV = 35,                /*[JV]*/
+    U_LB_COUNT = 36
+} ULineBreak;
+
+/**
+ * Numeric Type constants.
+ *
+ * @see UCHAR_NUMERIC_TYPE
+ * @stable ICU 2.2
+ */
+typedef enum UNumericType {
+    U_NT_NONE,              /*[None]*/ /*See note !!*/
+    U_NT_DECIMAL,           /*[de]*/
+    U_NT_DIGIT,             /*[di]*/
+    U_NT_NUMERIC,           /*[nu]*/
+    U_NT_COUNT
+} UNumericType;
+
+/**
+ * Hangul Syllable Type constants.
+ *
+ * @see UCHAR_HANGUL_SYLLABLE_TYPE
+ * @stable ICU 2.6
+ */
+typedef enum UHangulSyllableType {
+    U_HST_NOT_APPLICABLE,   /*[NA]*/ /*See note !!*/
+    U_HST_LEADING_JAMO,     /*[L]*/
+    U_HST_VOWEL_JAMO,       /*[V]*/
+    U_HST_TRAILING_JAMO,    /*[T]*/
+    U_HST_LV_SYLLABLE,      /*[LV]*/
+    U_HST_LVT_SYLLABLE,     /*[LVT]*/
+    U_HST_COUNT
+} UHangulSyllableType;
+
+/**
+ * Check a binary Unicode property for a code point.
+ *
+ * Unicode, especially in version 3.2, defines many more properties than the
+ * original set in UnicodeData.txt.
+ *
+ * The properties APIs are intended to reflect Unicode properties as defined
+ * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).
+ * For details about the properties see http://www.unicode.org/ucd/ .
+ * For names of Unicode properties see the UCD file PropertyAliases.txt.
+ *
+ * Important: If ICU is built with UCD files from Unicode versions below 3.2,
+ * then properties marked with "new in Unicode 3.2" are not or not fully available.
+ *
+ * @param c Code point to test.
+ * @param which UProperty selector constant, identifies which binary property to check.
+ *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT.
+ * @return TRUE or FALSE according to the binary Unicode property value for c.
+ *         Also FALSE if 'which' is out of bounds or if the Unicode version
+ *         does not have data for the property at all, or not for this code point.
+ *
+ * @see UProperty
+ * @see u_getIntPropertyValue
+ * @see u_getUnicodeVersion
+ * @stable ICU 2.1
+ */
+U_STABLE UBool U_EXPORT2
+u_hasBinaryProperty(UChar32 c, UProperty which);
+
+/**
+ * Check if a code point has the Alphabetic Unicode property.
+ * Same as u_hasBinaryProperty(c, UCHAR_ALPHABETIC).
+ * This is different from u_isalpha!
+ * @param c Code point to test
+ * @return true if the code point has the Alphabetic Unicode property, false otherwise
+ *
+ * @see UCHAR_ALPHABETIC
+ * @see u_isalpha
+ * @see u_hasBinaryProperty
+ * @stable ICU 2.1
+ */
+U_STABLE UBool U_EXPORT2
+u_isUAlphabetic(UChar32 c);
+
+/**
+ * Check if a code point has the Lowercase Unicode property.
+ * Same as u_hasBinaryProperty(c, UCHAR_LOWERCASE).
+ * This is different from u_islower!
+ * @param c Code point to test
+ * @return true if the code point has the Lowercase Unicode property, false otherwise
+ *
+ * @see UCHAR_LOWERCASE
+ * @see u_islower
+ * @see u_hasBinaryProperty
+ * @stable ICU 2.1
+ */
+U_STABLE UBool U_EXPORT2
+u_isULowercase(UChar32 c);
+
+/**
+ * Check if a code point has the Uppercase Unicode property.
+ * Same as u_hasBinaryProperty(c, UCHAR_UPPERCASE).
+ * This is different from u_isupper!
+ * @param c Code point to test
+ * @return true if the code point has the Uppercase Unicode property, false otherwise
+ *
+ * @see UCHAR_UPPERCASE
+ * @see u_isupper
+ * @see u_hasBinaryProperty
+ * @stable ICU 2.1
+ */
+U_STABLE UBool U_EXPORT2
+u_isUUppercase(UChar32 c);
+
+/**
+ * Check if a code point has the White_Space Unicode property.
+ * Same as u_hasBinaryProperty(c, UCHAR_WHITE_SPACE).
+ * This is different from both u_isspace and u_isWhitespace!
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * @param c Code point to test
+ * @return true if the code point has the White_Space Unicode property, false otherwise.
+ *
+ * @see UCHAR_WHITE_SPACE
+ * @see u_isWhitespace
+ * @see u_isspace
+ * @see u_isJavaSpaceChar
+ * @see u_hasBinaryProperty
+ * @stable ICU 2.1
+ */
+U_STABLE UBool U_EXPORT2
+u_isUWhiteSpace(UChar32 c);
+
+/**
+ * Get the property value for an enumerated or integer Unicode property for a code point.
+ * Also returns binary and mask property values.
+ *
+ * Unicode, especially in version 3.2, defines many more properties than the
+ * original set in UnicodeData.txt.
+ *
+ * The properties APIs are intended to reflect Unicode properties as defined
+ * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).
+ * For details about the properties see http://www.unicode.org/ .
+ * For names of Unicode properties see the UCD file PropertyAliases.txt.
+ *
+ * Sample usage:
+ * UEastAsianWidth ea=(UEastAsianWidth)u_getIntPropertyValue(c, UCHAR_EAST_ASIAN_WIDTH);
+ * UBool b=(UBool)u_getIntPropertyValue(c, UCHAR_IDEOGRAPHIC);
+ *
+ * @param c Code point to test.
+ * @param which UProperty selector constant, identifies which property to check.
+ *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT
+ *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT
+ *        or UCHAR_MASK_START<=which<UCHAR_MASK_LIMIT.
+ * @return Numeric value that is directly the property value or,
+ *         for enumerated properties, corresponds to the numeric value of the enumerated
+ *         constant of the respective property value enumeration type
+ *         (cast to enum type if necessary).
+ *         Returns 0 or 1 (for FALSE/TRUE) for binary Unicode properties.
+ *         Returns a bit-mask for mask properties.
+ *         Returns 0 if 'which' is out of bounds or if the Unicode version
+ *         does not have data for the property at all, or not for this code point.
+ *
+ * @see UProperty
+ * @see u_hasBinaryProperty
+ * @see u_getIntPropertyMinValue
+ * @see u_getIntPropertyMaxValue
+ * @see u_getUnicodeVersion
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_getIntPropertyValue(UChar32 c, UProperty which);
+
+/**
+ * Get the minimum value for an enumerated/integer/binary Unicode property.
+ * Can be used together with u_getIntPropertyMaxValue
+ * to allocate arrays of UnicodeSet or similar.
+ *
+ * @param which UProperty selector constant, identifies which binary property to check.
+ *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT
+ *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT.
+ * @return Minimum value returned by u_getIntPropertyValue for a Unicode property.
+ *         0 if the property selector is out of range.
+ *
+ * @see UProperty
+ * @see u_hasBinaryProperty
+ * @see u_getUnicodeVersion
+ * @see u_getIntPropertyMaxValue
+ * @see u_getIntPropertyValue
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_getIntPropertyMinValue(UProperty which);
+
+/**
+ * Get the maximum value for an enumerated/integer/binary Unicode property.
+ * Can be used together with u_getIntPropertyMinValue
+ * to allocate arrays of UnicodeSet or similar.
+ *
+ * Examples for min/max values (for Unicode 3.2):
+ *
+ * - UCHAR_BIDI_CLASS:    0/18 (U_LEFT_TO_RIGHT/U_BOUNDARY_NEUTRAL)
+ * - UCHAR_SCRIPT:        0/45 (USCRIPT_COMMON/USCRIPT_TAGBANWA)
+ * - UCHAR_IDEOGRAPHIC:   0/1  (FALSE/TRUE)
+ *
+ * For undefined UProperty constant values, min/max values will be 0/-1.
+ *
+ * @param which UProperty selector constant, identifies which binary property to check.
+ *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT
+ *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT.
+ * @return Maximum value returned by u_getIntPropertyValue for a Unicode property.
+ *         <=0 if the property selector is out of range.
+ *
+ * @see UProperty
+ * @see u_hasBinaryProperty
+ * @see u_getUnicodeVersion
+ * @see u_getIntPropertyMaxValue
+ * @see u_getIntPropertyValue
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_getIntPropertyMaxValue(UProperty which);
+
+/**
+ * Get the numeric value for a Unicode code point as defined in the
+ * Unicode Character Database.
+ *
+ * A "double" return type is necessary because
+ * some numeric values are fractions, negative, or too large for int32_t.
+ *
+ * For characters without any numeric values in the Unicode Character Database,
+ * this function will return U_NO_NUMERIC_VALUE.
+ *
+ * Similar to java.lang.Character.getNumericValue(), but u_getNumericValue()
+ * also supports negative values, large values, and fractions,
+ * while Java's getNumericValue() returns values 10..35 for ASCII letters.
+ *
+ * @param c Code point to get the numeric value for.
+ * @return Numeric value of c, or U_NO_NUMERIC_VALUE if none is defined.
+ *
+ * @see U_NO_NUMERIC_VALUE
+ * @stable ICU 2.2
+ */
+U_STABLE double U_EXPORT2
+u_getNumericValue(UChar32 c);
+
+/**
+ * Special value that is returned by u_getNumericValue when
+ * no numeric value is defined for a code point.
+ *
+ * @see u_getNumericValue
+ * @stable ICU 2.2
+ */
+#define U_NO_NUMERIC_VALUE ((double)-123456789.)
+
+/**
+ * Determines whether the specified code point has the general category "Ll"
+ * (lowercase letter).
+ *
+ * Same as java.lang.Character.isLowerCase().
+ *
+ * This misses some characters that are also lowercase but
+ * have a different general category value.
+ * In order to include those, use UCHAR_LOWERCASE.
+ *
+ * In addition to being equivalent to a Java function, this also serves
+ * as a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is an Ll lowercase letter
+ *
+ * @see UCHAR_LOWERCASE
+ * @see u_isupper
+ * @see u_istitle
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_islower(UChar32 c);
+
+/**
+ * Determines whether the specified code point has the general category "Lu"
+ * (uppercase letter).
+ *
+ * Same as java.lang.Character.isUpperCase().
+ *
+ * This misses some characters that are also uppercase but
+ * have a different general category value.
+ * In order to include those, use UCHAR_UPPERCASE.
+ *
+ * In addition to being equivalent to a Java function, this also serves
+ * as a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is an Lu uppercase letter
+ *
+ * @see UCHAR_UPPERCASE
+ * @see u_islower
+ * @see u_istitle
+ * @see u_tolower
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isupper(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a titlecase letter.
+ * True for general category "Lt" (titlecase letter).
+ *
+ * Same as java.lang.Character.isTitleCase().
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is an Lt titlecase letter
+ *
+ * @see u_isupper
+ * @see u_islower
+ * @see u_totitle
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_istitle(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a digit character according to Java.
+ * True for characters with general category "Nd" (decimal digit numbers).
+ * Beginning with Unicode 4, this is the same as
+ * testing for the Numeric_Type of Decimal.
+ *
+ * Same as java.lang.Character.isDigit().
+ *
+ * In addition to being equivalent to a Java function, this also serves
+ * as a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a digit character according to Character.isDigit()
+ *
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isdigit(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a letter character.
+ * True for general categories "L" (letters).
+ *
+ * Same as java.lang.Character.isLetter().
+ *
+ * In addition to being equivalent to a Java function, this also serves
+ * as a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a letter character
+ *
+ * @see u_isdigit
+ * @see u_isalnum
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isalpha(UChar32 c);
+
+/**
+ * Determines whether the specified code point is an alphanumeric character
+ * (letter or digit) according to Java.
+ * True for characters with general categories
+ * "L" (letters) and "Nd" (decimal digit numbers).
+ *
+ * Same as java.lang.Character.isLetterOrDigit().
+ *
+ * In addition to being equivalent to a Java function, this also serves
+ * as a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is an alphanumeric character according to Character.isLetterOrDigit()
+ *
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isalnum(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a hexadecimal digit.
+ * This is equivalent to u_digit(c, 16)>=0.
+ * True for characters with general category "Nd" (decimal digit numbers)
+ * as well as Latin letters a-f and A-F in both ASCII and Fullwidth ASCII.
+ * (That is, for letters with code points
+ * 0041..0046, 0061..0066, FF21..FF26, FF41..FF46.)
+ *
+ * In order to narrow the definition of hexadecimal digits to only ASCII
+ * characters, use (c<=0x7f && u_isxdigit(c)).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a hexadecimal digit
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isxdigit(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a punctuation character.
+ * True for characters with general categories "P" (punctuation).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a punctuation character
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_ispunct(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a "graphic" character
+ * (printable, excluding spaces).
+ * TRUE for all characters except those with general categories
+ * "Cc" (control codes), "Cf" (format controls), "Cs" (surrogates),
+ * "Cn" (unassigned), and "Z" (separators).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a "graphic" character
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isgraph(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a "blank" or "horizontal space",
+ * a character that visibly separates words on a line.
+ * The following are equivalent definitions:
+ *
+ * TRUE for Unicode White_Space characters except for "vertical space controls"
+ * where "vertical space controls" are the following characters:
+ * U+000A (LF) U+000B (VT) U+000C (FF) U+000D (CR) U+0085 (NEL) U+2028 (LS) U+2029 (PS)
+ *
+ * same as
+ *
+ * TRUE for U+0009 (TAB) and characters with general category "Zs" (space separators)
+ * except Zero Width Space (ZWSP, U+200B).
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a "blank"
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isblank(UChar32 c);
+
+/**
+ * Determines whether the specified code point is "defined",
+ * which usually means that it is assigned a character.
+ * True for general categories other than "Cn" (other, not assigned),
+ * i.e., true for all code points mentioned in UnicodeData.txt.
+ *
+ * Note that non-character code points (e.g., U+FDD0) are not "defined"
+ * (they are Cn), but surrogate code points are "defined" (Cs).
+ *
+ * Same as java.lang.Character.isDefined().
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is assigned a character
+ *
+ * @see u_isdigit
+ * @see u_isalpha
+ * @see u_isalnum
+ * @see u_isupper
+ * @see u_islower
+ * @see u_istitle
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isdefined(UChar32 c);
+
+/**
+ * Determines if the specified character is a space character or not.
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c    the character to be tested
+ * @return  true if the character is a space character; false otherwise.
+ *
+ * @see u_isJavaSpaceChar
+ * @see u_isWhitespace
+ * @see u_isUWhiteSpace
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isspace(UChar32 c);
+
+/**
+ * Determine if the specified code point is a space character according to Java.
+ * True for characters with general categories "Z" (separators),
+ * which does not include control codes (e.g., TAB or Line Feed).
+ *
+ * Same as java.lang.Character.isSpaceChar().
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a space character according to Character.isSpaceChar()
+ *
+ * @see u_isspace
+ * @see u_isWhitespace
+ * @see u_isUWhiteSpace
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isJavaSpaceChar(UChar32 c);
+
+/**
+ * Determines if the specified code point is a whitespace character according to Java/ICU.
+ * A character is considered to be a Java whitespace character if and only
+ * if it satisfies one of the following criteria:
+ *
+ * - It is a Unicode separator (categories "Z"), but is not
+ *      a no-break space (U+00A0 NBSP or U+2007 Figure Space or U+202F Narrow NBSP).
+ * - It is U+0009 HORIZONTAL TABULATION.
+ * - It is U+000A LINE FEED.
+ * - It is U+000B VERTICAL TABULATION.
+ * - It is U+000C FORM FEED.
+ * - It is U+000D CARRIAGE RETURN.
+ * - It is U+001C FILE SEPARATOR.
+ * - It is U+001D GROUP SEPARATOR.
+ * - It is U+001E RECORD SEPARATOR.
+ * - It is U+001F UNIT SEPARATOR.
+ * - It is U+0085 NEXT LINE.
+ *
+ * Same as java.lang.Character.isWhitespace() except that Java omits U+0085.
+ *
+ * Note: There are several ICU whitespace functions; please see the uchar.h
+ * file documentation for a detailed comparison.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a whitespace character according to Java/ICU
+ *
+ * @see u_isspace
+ * @see u_isJavaSpaceChar
+ * @see u_isUWhiteSpace
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isWhitespace(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a control character
+ * (as defined by this function).
+ * A control character is one of the following:
+ * - ISO 8-bit control character (U+0000..U+001f and U+007f..U+009f)
+ * - U_CONTROL_CHAR (Cc)
+ * - U_FORMAT_CHAR (Cf)
+ * - U_LINE_SEPARATOR (Zl)
+ * - U_PARAGRAPH_SEPARATOR (Zp)
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a control character
+ *
+ * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
+ * @see u_isprint
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_iscntrl(UChar32 c);
+
+/**
+ * Determines whether the specified code point is an ISO control code.
+ * True for U+0000..U+001f and U+007f..U+009f (general category "Cc").
+ *
+ * Same as java.lang.Character.isISOControl().
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is an ISO control code
+ *
+ * @see u_iscntrl
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+u_isISOControl(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a printable character.
+ * True for general categories <em>other</em> than "C" (controls).
+ *
+ * This is a C/POSIX migration function.
+ * See the comments about C/POSIX character classification functions in the
+ * documentation at the top of this header file.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a printable character
+ *
+ * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
+ * @see u_iscntrl
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isprint(UChar32 c);
+
+/**
+ * Determines whether the specified code point is a base character.
+ * True for general categories "L" (letters), "N" (numbers),
+ * "Mc" (spacing combining marks), and "Me" (enclosing marks).
+ *
+ * Note that this is different from the Unicode definition in
+ * chapter 3.5, conformance clause D13,
+ * which defines base characters to be all characters (not Cn)
+ * that do not graphically combine with preceding characters (M)
+ * and that are neither control (Cc) or format (Cf) characters.
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is a base character according to this function
+ *
+ * @see u_isalpha
+ * @see u_isdigit
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isbase(UChar32 c);
+
+/**
+ * Returns the bidirectional category value for the code point,
+ * which is used in the Unicode bidirectional algorithm
+ * (UAX #9 http://www.unicode.org/reports/tr9/).
+ * Note that some <em>unassigned</em> code points have bidi values
+ * of R or AL because they are in blocks that are reserved
+ * for Right-To-Left scripts.
+ *
+ * Same as java.lang.Character.getDirectionality()
+ *
+ * @param c the code point to be tested
+ * @return the bidirectional category (UCharDirection) value
+ *
+ * @see UCharDirection
+ * @stable ICU 2.0
+ */
+U_STABLE UCharDirection U_EXPORT2
+u_charDirection(UChar32 c);
+
+/**
+ * Determines whether the code point has the Bidi_Mirrored property.
+ * This property is set for characters that are commonly used in
+ * Right-To-Left contexts and need to be displayed with a "mirrored"
+ * glyph.
+ *
+ * Same as java.lang.Character.isMirrored().
+ * Same as UCHAR_BIDI_MIRRORED
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the character has the Bidi_Mirrored property
+ *
+ * @see UCHAR_BIDI_MIRRORED
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isMirrored(UChar32 c);
+
+/**
+ * Maps the specified character to a "mirror-image" character.
+ * For characters with the Bidi_Mirrored property, implementations
+ * sometimes need a "poor man's" mapping to another Unicode
+ * character (code point) such that the default glyph may serve
+ * as the mirror-image of the default glyph of the specified
+ * character. This is useful for text conversion to and from
+ * codepages with visual order, and for displays without glyph
+ * selecetion capabilities.
+ *
+ * @param c the code point to be mapped
+ * @return another Unicode code point that may serve as a mirror-image
+ *         substitute, or c itself if there is no such mapping or c
+ *         does not have the Bidi_Mirrored property
+ *
+ * @see UCHAR_BIDI_MIRRORED
+ * @see u_isMirrored
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_charMirror(UChar32 c);
+
+/**
+ * Returns the general category value for the code point.
+ *
+ * Same as java.lang.Character.getType().
+ *
+ * @param c the code point to be tested
+ * @return the general category (UCharCategory) value
+ *
+ * @see UCharCategory
+ * @stable ICU 2.0
+ */
+U_STABLE int8_t U_EXPORT2
+u_charType(UChar32 c);
+
+/**
+ * Get a single-bit bit set for the general category of a character.
+ * This bit set can be compared bitwise with U_GC_SM_MASK, U_GC_L_MASK, etc.
+ * Same as U_MASK(u_charType(c)).
+ *
+ * @param c the code point to be tested
+ * @return a single-bit mask corresponding to the general category (UCharCategory) value
+ *
+ * @see u_charType
+ * @see UCharCategory
+ * @see U_GC_CN_MASK
+ * @stable ICU 2.1
+ */
+#define U_GET_GC_MASK(c) U_MASK(u_charType(c))
+
+/**
+ * Callback from u_enumCharTypes(), is called for each contiguous range
+ * of code points c (where start<=c<limit)
+ * with the same Unicode general category ("character type").
+ *
+ * The callback function can stop the enumeration by returning FALSE.
+ *
+ * @param context an opaque pointer, as passed into utrie_enum()
+ * @param start the first code point in a contiguous range with value
+ * @param limit one past the last code point in a contiguous range with value
+ * @param type the general category for all code points in [start..limit[
+ * @return FALSE to stop the enumeration
+ *
+ * @stable ICU 2.1
+ * @see UCharCategory
+ * @see u_enumCharTypes
+ */
+typedef UBool U_CALLCONV
+UCharEnumTypeRange(const void *context, UChar32 start, UChar32 limit, UCharCategory type);
+
+/**
+ * Enumerate efficiently all code points with their Unicode general categories.
+ *
+ * This is useful for building data structures (e.g., UnicodeSet's),
+ * for enumerating all assigned code points (type!=U_UNASSIGNED), etc.
+ *
+ * For each contiguous range of code points with a given general category ("character type"),
+ * the UCharEnumTypeRange function is called.
+ * Adjacent ranges have different types.
+ * The Unicode Standard guarantees that the numeric value of the type is 0..31.
+ *
+ * @param enumRange a pointer to a function that is called for each contiguous range
+ *                  of code points with the same general category
+ * @param context an opaque pointer that is passed on to the callback function
+ *
+ * @stable ICU 2.1
+ * @see UCharCategory
+ * @see UCharEnumTypeRange
+ */
+U_STABLE void U_EXPORT2
+u_enumCharTypes(UCharEnumTypeRange *enumRange, const void *context);
+
+#if !UCONFIG_NO_NORMALIZATION
+
+/**
+ * Returns the combining class of the code point as specified in UnicodeData.txt.
+ *
+ * @param c the code point of the character
+ * @return the combining class of the character
+ * @stable ICU 2.0
+ */
+U_STABLE uint8_t U_EXPORT2
+u_getCombiningClass(UChar32 c);
+
+#endif
+
+/**
+ * Returns the decimal digit value of a decimal digit character.
+ * Such characters have the general category "Nd" (decimal digit numbers)
+ * and a Numeric_Type of Decimal.
+ *
+ * Unlike ICU releases before 2.6, no digit values are returned for any
+ * Han characters because Han number characters are often used with a special
+ * Chinese-style number format (with characters for powers of 10 in between)
+ * instead of in decimal-positional notation.
+ * Unicode 4 explicitly assigns Han number characters the Numeric_Type
+ * Numeric instead of Decimal.
+ * See Jitterbug 1483 for more details.
+ *
+ * Use u_getIntPropertyValue(c, UCHAR_NUMERIC_TYPE) and u_getNumericValue()
+ * for complete numeric Unicode properties.
+ *
+ * @param c the code point for which to get the decimal digit value
+ * @return the decimal digit value of c,
+ *         or -1 if c is not a decimal digit character
+ *
+ * @see u_getNumericValue
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_charDigitValue(UChar32 c);
+
+/**
+ * Returns the Unicode allocation block that contains the character.
+ *
+ * @param c the code point to be tested
+ * @return the block value (UBlockCode) for c
+ *
+ * @see UBlockCode
+ * @stable ICU 2.0
+ */
+U_STABLE UBlockCode U_EXPORT2
+ublock_getCode(UChar32 c);
+
+/**
+ * Retrieve the name of a Unicode character.
+ * Depending on <code>nameChoice</code>, the character name written
+ * into the buffer is the "modern" name or the name that was defined
+ * in Unicode version 1.0.
+ * The name contains only "invariant" characters
+ * like A-Z, 0-9, space, and '-'.
+ * Unicode 1.0 names are only retrieved if they are different from the modern
+ * names and if the data file contains the data for them. gennames may or may
+ * not be called with a command line option to include 1.0 names in unames.dat.
+ *
+ * @param code The character (code point) for which to get the name.
+ *             It must be <code>0<=code<=0x10ffff</code>.
+ * @param nameChoice Selector for which name to get.
+ * @param buffer Destination address for copying the name.
+ *               The name will always be zero-terminated.
+ *               If there is no name, then the buffer will be set to the empty string.
+ * @param bufferLength <code>==sizeof(buffer)</code>
+ * @param pErrorCode Pointer to a UErrorCode variable;
+ *        check for <code>U_SUCCESS()</code> after <code>u_charName()</code>
+ *        returns.
+ * @return The length of the name, or 0 if there is no name for this character.
+ *         If the bufferLength is less than or equal to the length, then the buffer
+ *         contains the truncated name and the returned length indicates the full
+ *         length of the name.
+ *         The length does not include the zero-termination.
+ *
+ * @see UCharNameChoice
+ * @see u_charFromName
+ * @see u_enumCharNames
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_charName(UChar32 code, UCharNameChoice nameChoice,
+           char *buffer, int32_t bufferLength,
+           UErrorCode *pErrorCode);
+
+/**
+ * Get the ISO 10646 comment for a character.
+ * The ISO 10646 comment is an informative field in the Unicode Character
+ * Database (UnicodeData.txt field 11) and is from the ISO 10646 names list.
+ *
+ * @param c The character (code point) for which to get the ISO comment.
+ *             It must be <code>0<=c<=0x10ffff</code>.
+ * @param dest Destination address for copying the comment.
+ *             The comment will be zero-terminated if possible.
+ *             If there is no comment, then the buffer will be set to the empty string.
+ * @param destCapacity <code>==sizeof(dest)</code>
+ * @param pErrorCode Pointer to a UErrorCode variable;
+ *        check for <code>U_SUCCESS()</code> after <code>u_getISOComment()</code>
+ *        returns.
+ * @return The length of the comment, or 0 if there is no comment for this character.
+ *         If the destCapacity is less than or equal to the length, then the buffer
+ *         contains the truncated name and the returned length indicates the full
+ *         length of the name.
+ *         The length does not include the zero-termination.
+ *
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_getISOComment(UChar32 c,
+                char *dest, int32_t destCapacity,
+                UErrorCode *pErrorCode);
+
+/**
+ * Find a Unicode character by its name and return its code point value.
+ * The name is matched exactly and completely.
+ * If the name does not correspond to a code point, <i>pErrorCode</i>
+ * is set to <code>U_INVALID_CHAR_FOUND</code>.
+ * A Unicode 1.0 name is matched only if it differs from the modern name.
+ * Unicode names are all uppercase. Extended names are lowercase followed
+ * by an uppercase hexadecimal number, and within angle brackets.
+ *
+ * @param nameChoice Selector for which name to match.
+ * @param name The name to match.
+ * @param pErrorCode Pointer to a UErrorCode variable
+ * @return The Unicode value of the code point with the given name,
+ *         or an undefined value if there is no such code point.
+ *
+ * @see UCharNameChoice
+ * @see u_charName
+ * @see u_enumCharNames
+ * @stable ICU 1.7
+ */
+U_STABLE UChar32 U_EXPORT2
+u_charFromName(UCharNameChoice nameChoice,
+               const char *name,
+               UErrorCode *pErrorCode);
+
+/**
+ * Type of a callback function for u_enumCharNames() that gets called
+ * for each Unicode character with the code point value and
+ * the character name.
+ * If such a function returns FALSE, then the enumeration is stopped.
+ *
+ * @param context The context pointer that was passed to u_enumCharNames().
+ * @param code The Unicode code point for the character with this name.
+ * @param nameChoice Selector for which kind of names is enumerated.
+ * @param name The character's name, zero-terminated.
+ * @param length The length of the name.
+ * @return TRUE if the enumeration should continue, FALSE to stop it.
+ *
+ * @see UCharNameChoice
+ * @see u_enumCharNames
+ * @stable ICU 1.7
+ */
+typedef UBool U_CALLCONV UEnumCharNamesFn(void *context,
+                               UChar32 code,
+                               UCharNameChoice nameChoice,
+                               const char *name,
+                               int32_t length);
+
+/**
+ * Enumerate all assigned Unicode characters between the start and limit
+ * code points (start inclusive, limit exclusive) and call a function
+ * for each, passing the code point value and the character name.
+ * For Unicode 1.0 names, only those are enumerated that differ from the
+ * modern names.
+ *
+ * @param start The first code point in the enumeration range.
+ * @param limit One more than the last code point in the enumeration range
+ *              (the first one after the range).
+ * @param fn The function that is to be called for each character name.
+ * @param context An arbitrary pointer that is passed to the function.
+ * @param nameChoice Selector for which kind of names to enumerate.
+ * @param pErrorCode Pointer to a UErrorCode variable
+ *
+ * @see UCharNameChoice
+ * @see UEnumCharNamesFn
+ * @see u_charName
+ * @see u_charFromName
+ * @stable ICU 1.7
+ */
+U_STABLE void U_EXPORT2
+u_enumCharNames(UChar32 start, UChar32 limit,
+                UEnumCharNamesFn *fn,
+                void *context,
+                UCharNameChoice nameChoice,
+                UErrorCode *pErrorCode);
+
+/**
+ * Return the Unicode name for a given property, as given in the
+ * Unicode database file PropertyAliases.txt.
+ *
+ * In addition, this function maps the property
+ * UCHAR_GENERAL_CATEGORY_MASK to the synthetic names "gcm" /
+ * "General_Category_Mask".  These names are not in
+ * PropertyAliases.txt.
+ *
+ * @param property UProperty selector other than UCHAR_INVALID_CODE.
+ *         If out of range, NULL is returned.
+ *
+ * @param nameChoice selector for which name to get.  If out of range,
+ *         NULL is returned.  All properties have a long name.  Most
+ *         have a short name, but some do not.  Unicode allows for
+ *         additional names; if present these will be returned by
+ *         U_LONG_PROPERTY_NAME + i, where i=1, 2,...
+ *
+ * @return a pointer to the name, or NULL if either the
+ *         property or the nameChoice is out of range.  If a given
+ *         nameChoice returns NULL, then all larger values of
+ *         nameChoice will return NULL, with one exception: if NULL is
+ *         returned for U_SHORT_PROPERTY_NAME, then
+ *         U_LONG_PROPERTY_NAME (and higher) may still return a
+ *         non-NULL value.  The returned pointer is valid until
+ *         u_cleanup() is called.
+ *
+ * @see UProperty
+ * @see UPropertyNameChoice
+ * @stable ICU 2.4
+ */
+U_STABLE const char* U_EXPORT2
+u_getPropertyName(UProperty property,
+                  UPropertyNameChoice nameChoice);
+
+/**
+ * Return the UProperty enum for a given property name, as specified
+ * in the Unicode database file PropertyAliases.txt.  Short, long, and
+ * any other variants are recognized.
+ *
+ * In addition, this function maps the synthetic names "gcm" /
+ * "General_Category_Mask" to the property
+ * UCHAR_GENERAL_CATEGORY_MASK.  These names are not in
+ * PropertyAliases.txt.
+ *
+ * @param alias the property name to be matched.  The name is compared
+ *         using "loose matching" as described in PropertyAliases.txt.
+ *
+ * @return a UProperty enum, or UCHAR_INVALID_CODE if the given name
+ *         does not match any property.
+ *
+ * @see UProperty
+ * @stable ICU 2.4
+ */
+U_STABLE UProperty U_EXPORT2
+u_getPropertyEnum(const char* alias);
+
+/**
+ * Return the Unicode name for a given property value, as given in the
+ * Unicode database file PropertyValueAliases.txt.
+ *
+ * Note: Some of the names in PropertyValueAliases.txt can only be
+ * retrieved using UCHAR_GENERAL_CATEGORY_MASK, not
+ * UCHAR_GENERAL_CATEGORY.  These include: "C" / "Other", "L" /
+ * "Letter", "LC" / "Cased_Letter", "M" / "Mark", "N" / "Number", "P"
+ * / "Punctuation", "S" / "Symbol", and "Z" / "Separator".
+ *
+ * @param property UProperty selector constant.
+ *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT
+ *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT
+ *        or UCHAR_MASK_START<=which<UCHAR_MASK_LIMIT.
+ *        If out of range, NULL is returned.
+ *
+ * @param value selector for a value for the given property.  If out
+ *         of range, NULL is returned.  In general, valid values range
+ *         from 0 up to some maximum.  There are a few exceptions:
+ *         (1.) UCHAR_BLOCK values begin at the non-zero value
+ *         UBLOCK_BASIC_LATIN.  (2.)  UCHAR_CANONICAL_COMBINING_CLASS
+ *         values are not contiguous and range from 0..240.  (3.)
+ *         UCHAR_GENERAL_CATEGORY_MASK values are not values of
+ *         UCharCategory, but rather mask values produced by
+ *         U_GET_GC_MASK().  This allows grouped categories such as
+ *         [:L:] to be represented.  Mask values range
+ *         non-contiguously from 1..U_GC_P_MASK.
+ *
+ * @param nameChoice selector for which name to get.  If out of range,
+ *         NULL is returned.  All values have a long name.  Most have
+ *         a short name, but some do not.  Unicode allows for
+ *         additional names; if present these will be returned by
+ *         U_LONG_PROPERTY_NAME + i, where i=1, 2,...
+
+ * @return a pointer to the name, or NULL if either the
+ *         property or the nameChoice is out of range.  If a given
+ *         nameChoice returns NULL, then all larger values of
+ *         nameChoice will return NULL, with one exception: if NULL is
+ *         returned for U_SHORT_PROPERTY_NAME, then
+ *         U_LONG_PROPERTY_NAME (and higher) may still return a
+ *         non-NULL value.  The returned pointer is valid until
+ *         u_cleanup() is called.
+ *
+ * @see UProperty
+ * @see UPropertyNameChoice
+ * @stable ICU 2.4
+ */
+U_STABLE const char* U_EXPORT2
+u_getPropertyValueName(UProperty property,
+                       int32_t value,
+                       UPropertyNameChoice nameChoice);
+
+/**
+ * Return the property value integer for a given value name, as
+ * specified in the Unicode database file PropertyValueAliases.txt.
+ * Short, long, and any other variants are recognized.
+ *
+ * Note: Some of the names in PropertyValueAliases.txt will only be
+ * recognized with UCHAR_GENERAL_CATEGORY_MASK, not
+ * UCHAR_GENERAL_CATEGORY.  These include: "C" / "Other", "L" /
+ * "Letter", "LC" / "Cased_Letter", "M" / "Mark", "N" / "Number", "P"
+ * / "Punctuation", "S" / "Symbol", and "Z" / "Separator".
+ *
+ * @param property UProperty selector constant.
+ *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT
+ *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT
+ *        or UCHAR_MASK_START<=which<UCHAR_MASK_LIMIT.
+ *        If out of range, UCHAR_INVALID_CODE is returned.
+ *
+ * @param alias the value name to be matched.  The name is compared
+ *         using "loose matching" as described in
+ *         PropertyValueAliases.txt.
+ *
+ * @return a value integer or UCHAR_INVALID_CODE if the given name
+ *         does not match any value of the given property, or if the
+ *         property is invalid.  Note: U CHAR_GENERAL_CATEGORY values
+ *         are not values of UCharCategory, but rather mask values
+ *         produced by U_GET_GC_MASK().  This allows grouped
+ *         categories such as [:L:] to be represented.
+ *
+ * @see UProperty
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t U_EXPORT2
+u_getPropertyValueEnum(UProperty property,
+                       const char* alias);
+
+/**
+ * Determines if the specified character is permissible as the
+ * first character in an identifier according to Unicode
+ * (The Unicode Standard, Version 3.0, chapter 5.16 Identifiers).
+ * True for characters with general categories "L" (letters) and "Nl" (letter numbers).
+ *
+ * Same as java.lang.Character.isUnicodeIdentifierStart().
+ * Same as UCHAR_ID_START
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point may start an identifier
+ *
+ * @see UCHAR_ID_START
+ * @see u_isalpha
+ * @see u_isIDPart
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isIDStart(UChar32 c);
+
+/**
+ * Determines if the specified character is permissible
+ * in an identifier according to Java.
+ * True for characters with general categories "L" (letters),
+ * "Nl" (letter numbers), "Nd" (decimal digits),
+ * "Mc" and "Mn" (combining marks), "Pc" (connecting punctuation), and
+ * u_isIDIgnorable(c).
+ *
+ * Same as java.lang.Character.isUnicodeIdentifierPart().
+ * Almost the same as Unicode's ID_Continue (UCHAR_ID_CONTINUE)
+ * except that Unicode recommends to ignore Cf which is less than
+ * u_isIDIgnorable(c).
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point may occur in an identifier according to Java
+ *
+ * @see UCHAR_ID_CONTINUE
+ * @see u_isIDStart
+ * @see u_isIDIgnorable
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isIDPart(UChar32 c);
+
+/**
+ * Determines if the specified character should be regarded
+ * as an ignorable character in an identifier,
+ * according to Java.
+ * True for characters with general category "Cf" (format controls) as well as
+ * non-whitespace ISO controls
+ * (U+0000..U+0008, U+000E..U+001B, U+007F..U+0084, U+0086..U+009F).
+ *
+ * Same as java.lang.Character.isIdentifierIgnorable()
+ * except that Java also returns TRUE for U+0085 Next Line
+ * (it omits U+0085 from whitespace ISO controls).
+ *
+ * Note that Unicode just recommends to ignore Cf (format controls).
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point is ignorable in identifiers according to Java
+ *
+ * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT
+ * @see u_isIDStart
+ * @see u_isIDPart
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isIDIgnorable(UChar32 c);
+
+/**
+ * Determines if the specified character is permissible as the
+ * first character in a Java identifier.
+ * In addition to u_isIDStart(c), true for characters with
+ * general categories "Sc" (currency symbols) and "Pc" (connecting punctuation).
+ *
+ * Same as java.lang.Character.isJavaIdentifierStart().
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point may start a Java identifier
+ *
+ * @see     u_isJavaIDPart
+ * @see     u_isalpha
+ * @see     u_isIDStart
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isJavaIDStart(UChar32 c);
+
+/**
+ * Determines if the specified character is permissible
+ * in a Java identifier.
+ * In addition to u_isIDPart(c), true for characters with
+ * general category "Sc" (currency symbols).
+ *
+ * Same as java.lang.Character.isJavaIdentifierPart().
+ *
+ * @param c the code point to be tested
+ * @return TRUE if the code point may occur in a Java identifier
+ *
+ * @see     u_isIDIgnorable
+ * @see     u_isJavaIDStart
+ * @see     u_isalpha
+ * @see     u_isdigit
+ * @see     u_isIDPart
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+u_isJavaIDPart(UChar32 c);
+
+/**
+ * The given character is mapped to its lowercase equivalent according to
+ * UnicodeData.txt; if the character has no lowercase equivalent, the character
+ * itself is returned.
+ *
+ * Same as java.lang.Character.toLowerCase().
+ *
+ * This function only returns the simple, single-code point case mapping.
+ * Full case mappings should be used whenever possible because they produce
+ * better results by working on whole strings.
+ * They take into account the string context and the language and can map
+ * to a result string with a different length as appropriate.
+ * Full case mappings are applied by the string case mapping functions,
+ * see ustring.h and the UnicodeString class.
+ * See also the User Guide chapter on C/POSIX migration:
+ * http://icu-project.org/userguide/posix.html#case_mappings
+ *
+ * @param c the code point to be mapped
+ * @return the Simple_Lowercase_Mapping of the code point, if any;
+ *         otherwise the code point itself.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_tolower(UChar32 c);
+
+/**
+ * The given character is mapped to its uppercase equivalent according to UnicodeData.txt;
+ * if the character has no uppercase equivalent, the character itself is
+ * returned.
+ *
+ * Same as java.lang.Character.toUpperCase().
+ *
+ * This function only returns the simple, single-code point case mapping.
+ * Full case mappings should be used whenever possible because they produce
+ * better results by working on whole strings.
+ * They take into account the string context and the language and can map
+ * to a result string with a different length as appropriate.
+ * Full case mappings are applied by the string case mapping functions,
+ * see ustring.h and the UnicodeString class.
+ * See also the User Guide chapter on C/POSIX migration:
+ * http://icu-project.org/userguide/posix.html#case_mappings
+ *
+ * @param c the code point to be mapped
+ * @return the Simple_Uppercase_Mapping of the code point, if any;
+ *         otherwise the code point itself.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_toupper(UChar32 c);
+
+/**
+ * The given character is mapped to its titlecase equivalent
+ * according to UnicodeData.txt;
+ * if none is defined, the character itself is returned.
+ *
+ * Same as java.lang.Character.toTitleCase().
+ *
+ * This function only returns the simple, single-code point case mapping.
+ * Full case mappings should be used whenever possible because they produce
+ * better results by working on whole strings.
+ * They take into account the string context and the language and can map
+ * to a result string with a different length as appropriate.
+ * Full case mappings are applied by the string case mapping functions,
+ * see ustring.h and the UnicodeString class.
+ * See also the User Guide chapter on C/POSIX migration:
+ * http://icu-project.org/userguide/posix.html#case_mappings
+ *
+ * @param c the code point to be mapped
+ * @return the Simple_Titlecase_Mapping of the code point, if any;
+ *         otherwise the code point itself.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_totitle(UChar32 c);
+
+/** Option value for case folding: use default mappings defined in CaseFolding.txt. @stable ICU 2.0 */
+#define U_FOLD_CASE_DEFAULT 0
+
+/**
+ * Option value for case folding:
+ *
+ * Use the modified set of mappings provided in CaseFolding.txt to handle dotted I
+ * and dotless i appropriately for Turkic languages (tr, az).
+ *
+ * Before Unicode 3.2, CaseFolding.txt contains mappings marked with 'I' that
+ * are to be included for default mappings and
+ * excluded for the Turkic-specific mappings.
+ *
+ * Unicode 3.2 CaseFolding.txt instead contains mappings marked with 'T' that
+ * are to be excluded for default mappings and
+ * included for the Turkic-specific mappings.
+ *
+ * @stable ICU 2.0
+ */
+#define U_FOLD_CASE_EXCLUDE_SPECIAL_I 1
+
+/**
+ * The given character is mapped to its case folding equivalent according to
+ * UnicodeData.txt and CaseFolding.txt;
+ * if the character has no case folding equivalent, the character
+ * itself is returned.
+ *
+ * This function only returns the simple, single-code point case mapping.
+ * Full case mappings should be used whenever possible because they produce
+ * better results by working on whole strings.
+ * They take into account the string context and the language and can map
+ * to a result string with a different length as appropriate.
+ * Full case mappings are applied by the string case mapping functions,
+ * see ustring.h and the UnicodeString class.
+ * See also the User Guide chapter on C/POSIX migration:
+ * http://icu-project.org/userguide/posix.html#case_mappings
+ *
+ * @param c the code point to be mapped
+ * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ * @return the Simple_Case_Folding of the code point, if any;
+ *         otherwise the code point itself.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_foldCase(UChar32 c, uint32_t options);
+
+/**
+ * Returns the decimal digit value of the code point in the
+ * specified radix.
+ *
+ * If the radix is not in the range <code>2<=radix<=36</code> or if the
+ * value of <code>c</code> is not a valid digit in the specified
+ * radix, <code>-1</code> is returned. A character is a valid digit
+ * if at least one of the following is true:
+ * <ul>
+ * <li>The character has a decimal digit value.
+ *     Such characters have the general category "Nd" (decimal digit numbers)
+ *     and a Numeric_Type of Decimal.
+ *     In this case the value is the character's decimal digit value.</li>
+ * <li>The character is one of the uppercase Latin letters
+ *     <code>'A'</code> through <code>'Z'</code>.
+ *     In this case the value is <code>c-'A'+10</code>.</li>
+ * <li>The character is one of the lowercase Latin letters
+ *     <code>'a'</code> through <code>'z'</code>.
+ *     In this case the value is <code>ch-'a'+10</code>.</li>
+ * <li>Latin letters from both the ASCII range (0061..007A, 0041..005A)
+ *     as well as from the Fullwidth ASCII range (FF41..FF5A, FF21..FF3A)
+ *     are recognized.</li>
+ * </ul>
+ *
+ * Same as java.lang.Character.digit().
+ *
+ * @param   ch      the code point to be tested.
+ * @param   radix   the radix.
+ * @return  the numeric value represented by the character in the
+ *          specified radix,
+ *          or -1 if there is no value or if the value exceeds the radix.
+ *
+ * @see     UCHAR_NUMERIC_TYPE
+ * @see     u_forDigit
+ * @see     u_charDigitValue
+ * @see     u_isdigit
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_digit(UChar32 ch, int8_t radix);
+
+/**
+ * Determines the character representation for a specific digit in
+ * the specified radix. If the value of <code>radix</code> is not a
+ * valid radix, or the value of <code>digit</code> is not a valid
+ * digit in the specified radix, the null character
+ * (<code>U+0000</code>) is returned.
+ * <p>
+ * The <code>radix</code> argument is valid if it is greater than or
+ * equal to 2 and less than or equal to 36.
+ * The <code>digit</code> argument is valid if
+ * <code>0 <= digit < radix</code>.
+ * <p>
+ * If the digit is less than 10, then
+ * <code>'0' + digit</code> is returned. Otherwise, the value
+ * <code>'a' + digit - 10</code> is returned.
+ *
+ * Same as java.lang.Character.forDigit().
+ *
+ * @param   digit   the number to convert to a character.
+ * @param   radix   the radix.
+ * @return  the <code>char</code> representation of the specified digit
+ *          in the specified radix.
+ *
+ * @see     u_digit
+ * @see     u_charDigitValue
+ * @see     u_isdigit
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_forDigit(int32_t digit, int8_t radix);
+
+/**
+ * Get the "age" of the code point.
+ * The "age" is the Unicode version when the code point was first
+ * designated (as a non-character or for Private Use)
+ * or assigned a character.
+ * This can be useful to avoid emitting code points to receiving
+ * processes that do not accept newer characters.
+ * The data is from the UCD file DerivedAge.txt.
+ *
+ * @param c The code point.
+ * @param versionArray The Unicode version number array, to be filled in.
+ *
+ * @stable ICU 2.1
+ */
+U_STABLE void U_EXPORT2
+u_charAge(UChar32 c, UVersionInfo versionArray);
+
+/**
+ * Gets the Unicode version information.
+ * The version array is filled in with the version information
+ * for the Unicode standard that is currently used by ICU.
+ * For example, Unicode version 3.1.1 is represented as an array with
+ * the values { 3, 1, 1, 0 }.
+ *
+ * @param versionArray an output array that will be filled in with
+ *                     the Unicode version number
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+u_getUnicodeVersion(UVersionInfo versionArray);
+
+/**
+ * Get the FC_NFKC_Closure property string for a character.
+ * See Unicode Standard Annex #15 for details, search for "FC_NFKC_Closure"
+ * or for "FNC": http://www.unicode.org/reports/tr15/
+ *
+ * @param c The character (code point) for which to get the FC_NFKC_Closure string.
+ *             It must be <code>0<=c<=0x10ffff</code>.
+ * @param dest Destination address for copying the string.
+ *             The string will be zero-terminated if possible.
+ *             If there is no FC_NFKC_Closure string,
+ *             then the buffer will be set to the empty string.
+ * @param destCapacity <code>==sizeof(dest)</code>
+ * @param pErrorCode Pointer to a UErrorCode variable.
+ * @return The length of the string, or 0 if there is no FC_NFKC_Closure string for this character.
+ *         If the destCapacity is less than or equal to the length, then the buffer
+ *         contains the truncated name and the returned length indicates the full
+ *         length of the name.
+ *         The length does not include the zero-termination.
+ *
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode);
+
+U_CDECL_END
+
+#endif /*_UCHAR*/
+/*eof*/
diff --git a/CoreFoundation/icu/unicode/uchriter.h b/CoreFoundation/icu/unicode/uchriter.h
new file mode 100644
index 0000000..6d5a990
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uchriter.h
@@ -0,0 +1,381 @@
+/*
+**********************************************************************
+*   Copyright (C) 1998-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*/
+
+#ifndef UCHRITER_H
+#define UCHRITER_H
+
+#include "unicode/utypes.h"
+#include "unicode/chariter.h"
+
+/**
+ * \file 
+ * \brief C++ API: UChar Character Iterator
+ */
+ 
+U_NAMESPACE_BEGIN
+
+/**
+ * A concrete subclass of CharacterIterator that iterates over the
+ * characters (code units or code points) in a UChar array.
+ * It's possible not only to create an
+ * iterator that iterates over an entire UChar array, but also to
+ * create one that iterates over only a subrange of a UChar array
+ * (iterators over different subranges of the same UChar array don't
+ * compare equal).
+ * @see CharacterIterator
+ * @see ForwardCharacterIterator
+ * @stable ICU 2.0
+ */
+class U_COMMON_API UCharCharacterIterator : public CharacterIterator {
+public:
+  /**
+   * Create an iterator over the UChar array referred to by "textPtr".
+   * The iteration range is 0 to <code>length-1</code>.
+   * text is only aliased, not adopted (the
+   * destructor will not delete it).
+   * @param textPtr The UChar array to be iterated over
+   * @param length The length of the UChar array
+   * @stable ICU 2.0
+   */
+  UCharCharacterIterator(const UChar* textPtr, int32_t length);
+
+  /**
+   * Create an iterator over the UChar array referred to by "textPtr".
+   * The iteration range is 0 to <code>length-1</code>.
+   * text is only aliased, not adopted (the
+   * destructor will not delete it).
+   * The starting
+   * position is specified by "position". If "position" is outside the valid
+   * iteration range, the behavior of this object is undefined.
+   * @param textPtr The UChar array to be iteratd over
+   * @param length The length of the UChar array
+   * @param position The starting position of the iteration
+   * @stable ICU 2.0
+   */
+  UCharCharacterIterator(const UChar* textPtr, int32_t length,
+                         int32_t position);
+
+  /**
+   * Create an iterator over the UChar array referred to by "textPtr".
+   * The iteration range is 0 to <code>end-1</code>.
+   * text is only aliased, not adopted (the
+   * destructor will not delete it).
+   * The starting
+   * position is specified by "position". If begin and end do not
+   * form a valid iteration range or "position" is outside the valid
+   * iteration range, the behavior of this object is undefined.
+   * @param textPtr The UChar array to be iterated over
+   * @param length The length of the UChar array
+   * @param textBegin  The begin position of the iteration range
+   * @param textEnd    The end position of the iteration range
+   * @param position    The starting position of the iteration
+   * @stable ICU 2.0
+   */
+  UCharCharacterIterator(const UChar* textPtr, int32_t length,
+                         int32_t textBegin,
+                         int32_t textEnd,
+                         int32_t position);
+
+  /**
+   * Copy constructor.  The new iterator iterates over the same range
+   * of the same string as "that", and its initial position is the
+   * same as "that"'s current position.
+   * @param that The UCharCharacterIterator to be copied
+   * @stable ICU 2.0
+   */
+  UCharCharacterIterator(const UCharCharacterIterator&  that);
+
+  /**
+   * Destructor.
+   * @stable ICU 2.0
+   */
+  virtual ~UCharCharacterIterator();
+
+  /**
+   * Assignment operator.  *this is altered to iterate over the sane
+   * range of the same string as "that", and refers to the same
+   * character within that string as "that" does.
+   * @param that The object to be copied
+   * @return the newly created object
+   * @stable ICU 2.0
+   */
+  UCharCharacterIterator&
+  operator=(const UCharCharacterIterator&    that);
+
+  /**
+   * Returns true if the iterators iterate over the same range of the
+   * same string and are pointing at the same character.
+   * @param that The ForwardCharacterIterator used to be compared for equality
+   * @return true if the iterators iterate over the same range of the
+   * same string and are pointing at the same character.
+   * @stable ICU 2.0
+   */
+  virtual UBool          operator==(const ForwardCharacterIterator& that) const;
+
+  /**
+   * Generates a hash code for this iterator.
+   * @return the hash code.
+   * @stable ICU 2.0
+   */
+  virtual int32_t         hashCode(void) const;
+
+  /**
+   * Returns a new UCharCharacterIterator referring to the same
+   * character in the same range of the same string as this one.  The
+   * caller must delete the new iterator.
+   * @return the CharacterIterator newly created
+   * @stable ICU 2.0
+   */
+  virtual CharacterIterator* clone(void) const;
+
+  /**
+   * Sets the iterator to refer to the first code unit in its
+   * iteration range, and returns that code unit.
+   * This can be used to begin an iteration with next().
+   * @return the first code unit in its iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar         first(void);
+
+  /**
+   * Sets the iterator to refer to the first code unit in its
+   * iteration range, returns that code unit, and moves the position
+   * to the second code unit. This is an alternative to setToStart()
+   * for forward iteration with nextPostInc().
+   * @return the first code unit in its iteration range
+   * @stable ICU 2.0
+   */
+  virtual UChar         firstPostInc(void);
+
+  /**
+   * Sets the iterator to refer to the first code point in its
+   * iteration range, and returns that code unit,
+   * This can be used to begin an iteration with next32().
+   * Note that an iteration with next32PostInc(), beginning with,
+   * e.g., setToStart() or firstPostInc(), is more efficient.
+   * @return the first code point in its iteration range
+   * @stable ICU 2.0
+   */
+  virtual UChar32       first32(void);
+
+  /**
+   * Sets the iterator to refer to the first code point in its
+   * iteration range, returns that code point, and moves the position
+   * to the second code point. This is an alternative to setToStart()
+   * for forward iteration with next32PostInc().
+   * @return the first code point in its iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar32       first32PostInc(void);
+
+  /**
+   * Sets the iterator to refer to the last code unit in its
+   * iteration range, and returns that code unit.
+   * This can be used to begin an iteration with previous().
+   * @return the last code unit in its iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar         last(void);
+
+  /**
+   * Sets the iterator to refer to the last code point in its
+   * iteration range, and returns that code unit.
+   * This can be used to begin an iteration with previous32().
+   * @return the last code point in its iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar32       last32(void);
+
+  /**
+   * Sets the iterator to refer to the "position"-th code unit
+   * in the text-storage object the iterator refers to, and
+   * returns that code unit.
+   * @param position the position within the text-storage object
+   * @return the code unit
+   * @stable ICU 2.0
+   */
+  virtual UChar         setIndex(int32_t position);
+
+  /**
+   * Sets the iterator to refer to the beginning of the code point
+   * that contains the "position"-th code unit
+   * in the text-storage object the iterator refers to, and
+   * returns that code point.
+   * The current position is adjusted to the beginning of the code point
+   * (its first code unit).
+   * @param position the position within the text-storage object
+   * @return the code unit
+   * @stable ICU 2.0
+   */
+  virtual UChar32       setIndex32(int32_t position);
+
+  /**
+   * Returns the code unit the iterator currently refers to.
+   * @return the code unit the iterator currently refers to.
+   * @stable ICU 2.0
+   */
+  virtual UChar         current(void) const;
+
+  /**
+   * Returns the code point the iterator currently refers to.
+   * @return the code point the iterator currently refers to.
+   * @stable ICU 2.0
+   */
+  virtual UChar32       current32(void) const;
+
+  /**
+   * Advances to the next code unit in the iteration range (toward
+   * endIndex()), and returns that code unit.  If there are no more
+   * code units to return, returns DONE.
+   * @return the next code unit in the iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar         next(void);
+
+  /**
+   * Gets the current code unit for returning and advances to the next code unit
+   * in the iteration range
+   * (toward endIndex()).  If there are
+   * no more code units to return, returns DONE.
+   * @return the current code unit.
+   * @stable ICU 2.0
+   */
+  virtual UChar         nextPostInc(void);
+
+  /**
+   * Advances to the next code point in the iteration range (toward
+   * endIndex()), and returns that code point.  If there are no more
+   * code points to return, returns DONE.
+   * Note that iteration with "pre-increment" semantics is less
+   * efficient than iteration with "post-increment" semantics
+   * that is provided by next32PostInc().
+   * @return the next code point in the iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar32       next32(void);
+
+  /**
+   * Gets the current code point for returning and advances to the next code point
+   * in the iteration range
+   * (toward endIndex()).  If there are
+   * no more code points to return, returns DONE.
+   * @return the current point.
+   * @stable ICU 2.0
+   */
+  virtual UChar32       next32PostInc(void);
+
+  /**
+   * Returns FALSE if there are no more code units or code points
+   * at or after the current position in the iteration range.
+   * This is used with nextPostInc() or next32PostInc() in forward
+   * iteration.
+   * @return FALSE if there are no more code units or code points
+   * at or after the current position in the iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UBool        hasNext();
+
+  /**
+   * Advances to the previous code unit in the iteration range (toward
+   * startIndex()), and returns that code unit.  If there are no more
+   * code units to return, returns DONE.
+   * @return the previous code unit in the iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar         previous(void);
+
+  /**
+   * Advances to the previous code point in the iteration range (toward
+   * startIndex()), and returns that code point.  If there are no more
+   * code points to return, returns DONE.
+   * @return the previous code point in the iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UChar32       previous32(void);
+
+  /**
+   * Returns FALSE if there are no more code units or code points
+   * before the current position in the iteration range.
+   * This is used with previous() or previous32() in backward
+   * iteration.
+   * @return FALSE if there are no more code units or code points
+   * before the current position in the iteration range.
+   * @stable ICU 2.0
+   */
+  virtual UBool        hasPrevious();
+
+  /**
+   * Moves the current position relative to the start or end of the
+   * iteration range, or relative to the current position itself.
+   * The movement is expressed in numbers of code units forward
+   * or backward by specifying a positive or negative delta.
+   * @param delta the position relative to origin. A positive delta means forward;
+   * a negative delta means backward.
+   * @param origin Origin enumeration {kStart, kCurrent, kEnd}
+   * @return the new position
+   * @stable ICU 2.0
+   */
+  virtual int32_t      move(int32_t delta, EOrigin origin);
+
+  /**
+   * Moves the current position relative to the start or end of the
+   * iteration range, or relative to the current position itself.
+   * The movement is expressed in numbers of code points forward
+   * or backward by specifying a positive or negative delta.
+   * @param delta the position relative to origin. A positive delta means forward;
+   * a negative delta means backward.
+   * @param origin Origin enumeration {kStart, kCurrent, kEnd}
+   * @return the new position
+   * @stable ICU 2.0
+   */
+  virtual int32_t      move32(int32_t delta, EOrigin origin);
+
+  /**
+   * Sets the iterator to iterate over a new range of text
+   * @stable ICU 2.0
+   */
+  void setText(const UChar* newText, int32_t newTextLength);
+
+  /**
+   * Copies the UChar array under iteration into the UnicodeString
+   * referred to by "result".  Even if this iterator iterates across
+   * only a part of this string, the whole string is copied.
+   * @param result Receives a copy of the text under iteration.
+   * @stable ICU 2.0
+   */
+  virtual void            getText(UnicodeString& result);
+
+  /**
+   * Return a class ID for this class (not really public)
+   * @return a class ID for this class
+   * @stable ICU 2.0
+   */
+  static UClassID         U_EXPORT2 getStaticClassID(void);
+
+  /**
+   * Return a class ID for this object (not really public)
+   * @return a class ID for this object.
+   * @stable ICU 2.0
+   */
+  virtual UClassID        getDynamicClassID(void) const;
+
+protected:
+  /**
+   * Protected constructor
+   * @stable ICU 2.0
+   */
+  UCharCharacterIterator();
+  /**
+   * Protected member text
+   * @stable ICU 2.0
+   */
+  const UChar*            text;
+
+};
+
+U_NAMESPACE_END
+#endif
diff --git a/CoreFoundation/icu/unicode/uclean.h b/CoreFoundation/icu/unicode/uclean.h
new file mode 100644
index 0000000..a13924a
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uclean.h
@@ -0,0 +1,267 @@
+/*
+******************************************************************************
+*                                                                            *
+* Copyright (C) 2001-2005, International Business Machines                   *
+*                Corporation and others. All Rights Reserved.                *
+*                                                                            *
+******************************************************************************
+*   file name:  uclean.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2001July05
+*   created by: George Rhoten
+*/
+
+#ifndef __UCLEAN_H__
+#define __UCLEAN_H__
+
+#include "unicode/utypes.h"
+/**
+ * \file
+ * \brief C API: Initialize and clean up ICU
+ */
+ 
+/**
+ *  Initialize ICU. The description further below applies to ICU 2.6 to ICU 3.4.
+ *  Starting with ICU 3.4, u_init() needs not be called any more for
+ *  ensuring thread safety, but it can give an indication for whether ICU
+ *  can load its data. In ICU 3.4, it will try to load the converter alias table
+ *  (cnvalias.icu) and give an error code if that fails.
+ *  This may change in the future.
+ *  <p>
+ *  For ensuring the availability of necessary data, an application should
+ *  open the service objects (converters, collators, etc.) that it will use
+ *  and check for error codes there.
+ *  <p>
+ *  Documentation for ICU 2.6 to ICU 3.4:
+ *  <p>
+ *  This function loads and initializes data items
+ *  that are required internally by various ICU functions.  Use of this explicit
+ *  initialization is required in multi-threaded applications; in 
+ *  single threaded apps, use is optional, but incurs little additional
+ *  cost, and is thus recommended.
+ *  <p>
+ *  In multi-threaded applications, u_init() should be called  in the
+ *  main thread before starting additional threads, or, alternatively
+ *  it can be called in each individual thread once, before other ICU
+ *  functions are called in that thread.  In this second scenario, the
+ *  application must guarantee that the first call to u_init() happen
+ *  without contention, in a single thread only.
+ *  <p>
+ *  If <code>u_setMemoryFunctions()</code> or 
+ *  <code>u_setMutexFunctions</code> are needed (uncommon), they must be
+ *  called _before_ <code>u_init()</code>.
+ *  <p>
+ *  Extra, repeated, or otherwise unneeded calls to u_init() do no harm,
+ *  other than taking a small amount of time.
+ *
+ * @param status An ICU UErrorCode parameter. It must not be <code>NULL</code>.
+ *    An Error will be returned if some required part of ICU data can not
+ *    be loaded or initialized.
+ *    The function returns immediately if the input error code indicates a
+ *    failure, as usual.
+ *
+ * @stable ICU 2.6
+ */  
+U_STABLE void U_EXPORT2 
+u_init(UErrorCode *status);
+
+/**
+ * Clean up the system resources, such as allocated memory or open files,
+ * used in all ICU libraries. This will free/delete all memory owned by the
+ * ICU libraries, and return them to their original load state. All open ICU
+ * items (collators, resource bundles, converters, etc.) must be closed before
+ * calling this function, otherwise ICU may not free its allocated memory
+ * (e.g. close your converters and resource bundles before calling this
+ * function). Generally, this function should be called once just before
+ * an application exits. For applications that dynamically load and unload
+ * the ICU libraries (relatively uncommon), u_cleanup() should be called
+ * just before the library unload.
+ * <p>
+ * u_cleanup() also clears any ICU heap functions, mutex functions or
+ * trace functions that may have been set for the process.  
+ * This has the effect of restoring ICU to its initial condition, before
+ * any of these override functions were installed.  Refer to
+ * u_setMemoryFunctions(), u_setMutexFunctions and 
+ * utrace_setFunctions().  If ICU is to be reinitialized after after
+ * calling u_cleanup(), these runtime override functions will need to
+ * be set up again if they are still required.
+ * <p>
+ * u_cleanup() is not thread safe.  All other threads should stop using ICU
+ * before calling this function.
+ * <p>
+ * Any open ICU items will be left in an undefined state by u_cleanup(),
+ * and any subsequent attempt to use such an item will give unpredictable
+ * results.
+ * <p>
+ * After calling u_cleanup(), an application may continue to use ICU by
+ * calling u_init().  An application must invoke u_init() first from one single
+ * thread before allowing other threads call u_init().  All threads existing
+ * at the time of the first thread's call to u_init() must also call
+ * u_init() themselves before continuing with other ICU operations.  
+ * <p>
+ * The use of u_cleanup() just before an application terminates is optional,
+ * but it should be called only once for performance reasons. The primary
+ * benefit is to eliminate reports of memory or resource leaks originating
+ * in ICU code from the results generated by heap analysis tools.
+ * <p>
+ * <strong>Use this function with great care!</strong>
+ * </p>
+ *
+ * @stable ICU 2.0
+ * @system
+ */
+U_STABLE void U_EXPORT2 
+u_cleanup(void);
+
+
+
+
+/**
+  * An opaque pointer type that represents an ICU mutex.
+  * For user-implemented mutexes, the value will typically point to a
+  *  struct or object that implements the mutex.
+  * @stable ICU 2.8
+  * @system
+  */
+typedef void *UMTX;
+
+/**
+  *  Function Pointer type for a user supplied mutex initialization function.
+  *  The user-supplied function will be called by ICU whenever ICU needs to create a
+  *  new mutex.  The function implementation should create a mutex, and store a pointer
+  *  to something that uniquely identifies the mutex into the UMTX that is supplied
+  *  as a paramter.
+  *  @param context user supplied value, obtained from from u_setMutexFunctions().
+  *  @param mutex   Receives a pointer that identifies the new mutex.
+  *                 The mutex init function must set the UMTX to a non-null value.   
+  *                 Subsequent calls by ICU to lock, unlock, or destroy a mutex will 
+  *                 identify the mutex by the UMTX value.
+  *  @param status  Error status.  Report errors back to ICU by setting this variable
+  *                 with an error code.
+  *  @stable ICU 2.8
+  *  @system
+  */
+typedef void U_CALLCONV UMtxInitFn (const void *context, UMTX  *mutex, UErrorCode* status);
+
+
+/**
+  *  Function Pointer type for a user supplied mutex functions.
+  *  One of the  user-supplied functions with this signature will be called by ICU
+  *  whenever ICU needs to lock, unlock, or destroy a mutex.
+  *  @param context user supplied value, obtained from from u_setMutexFunctions().
+  *  @param mutex   specify the mutex on which to operate.
+  *  @stable ICU 2.8
+  *  @system
+  */
+typedef void U_CALLCONV UMtxFn   (const void *context, UMTX  *mutex);
+
+
+/**
+  *  Set the functions that ICU will use for mutex operations
+  *  Use of this function is optional; by default (without this function), ICU will
+  *  directly access system functions for mutex operations
+  *  This function can only be used when ICU is in an initial, unused state, before
+  *  u_init() has been called.
+  *  This function may be used even when ICU has been built without multi-threaded
+  *  support  (see ICU_USE_THREADS pre-processor variable, umutex.h)
+  *  @param context This pointer value will be saved, and then (later) passed as
+  *                 a parameter to the user-supplied mutex functions each time they
+  *                 are called. 
+  *  @param init    Pointer to a mutex initialization function.  Must be non-null.
+  *  @param destroy Pointer to the mutex destroy function.  Must be non-null.
+  *  @param lock    pointer to the mutex lock function.  Must be non-null.
+  *  @param unlock  Pointer to the mutex unlock function.  Must be non-null.
+  *  @param status  Receives error values.
+  *  @stable ICU 2.8
+  *  @system
+  */  
+U_STABLE void U_EXPORT2 
+u_setMutexFunctions(const void *context, UMtxInitFn *init, UMtxFn *destroy, UMtxFn *lock, UMtxFn *unlock,
+                    UErrorCode *status);
+
+
+/**
+  *  Pointer type for a user supplied atomic increment or decrement function.
+  *  @param context user supplied value, obtained from from u_setAtomicIncDecFunctions().
+  *  @param p   Pointer to a 32 bit int to be incremented or decremented
+  *  @return    The value of the variable after the inc or dec operation.
+  *  @stable ICU 2.8
+  *  @system
+  */
+typedef int32_t U_CALLCONV UMtxAtomicFn(const void *context, int32_t *p);
+
+/**
+ *  Set the functions that ICU will use for atomic increment and decrement of int32_t values.
+ *  Use of this function is optional; by default (without this function), ICU will
+ *  use its own internal implementation of atomic increment/decrement.
+ *  This function can only be used when ICU is in an initial, unused state, before
+ *  u_init() has been called.
+ *  @param context This pointer value will be saved, and then (later) passed as
+ *                 a parameter to the increment and decrement functions each time they
+ *                 are called.  This function can only be called 
+ *  @param inc     Pointer to a function to do an atomic increment operation.  Must be non-null.
+ *  @param dec     Pointer to a function to do an atomic decrement operation.  Must be non-null.
+ *  @param status  Receives error values.
+ *  @stable ICU 2.8
+ *  @system
+ */  
+U_STABLE void U_EXPORT2 
+u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *inc, UMtxAtomicFn *dec,
+                    UErrorCode *status);
+
+
+
+/**
+  *  Pointer type for a user supplied memory allocation function.
+  *  @param context user supplied value, obtained from from u_setMemoryFunctions().
+  *  @param size    The number of bytes to be allocated
+  *  @return        Pointer to the newly allocated memory, or NULL if the allocation failed.
+  *  @stable ICU 2.8
+  *  @system
+  */
+typedef void *U_CALLCONV UMemAllocFn(const void *context, size_t size);
+/**
+  *  Pointer type for a user supplied memory re-allocation function.
+  *  @param context user supplied value, obtained from from u_setMemoryFunctions().
+  *  @param size    The number of bytes to be allocated
+  *  @return        Pointer to the newly allocated memory, or NULL if the allocation failed.
+  *  @stable ICU 2.8
+  *  @system
+  */
+typedef void *U_CALLCONV UMemReallocFn(const void *context, void *mem, size_t size);
+/**
+  *  Pointer type for a user supplied memory free  function.  Behavior should be
+  *  similar the standard C library free().
+  *  @param context user supplied value, obtained from from u_setMemoryFunctions().
+  *  @param mem     Pointer to the memory block to be resized
+  *  @param size    The new size for the block
+  *  @return        Pointer to the resized memory block, or NULL if the resizing failed.
+  *  @stable ICU 2.8
+  *  @system
+  */
+typedef void  U_CALLCONV UMemFreeFn (const void *context, void *mem);
+
+/**
+ *  Set the functions that ICU will use for memory allocation.
+ *  Use of this function is optional; by default (without this function), ICU will
+ *  use the standard C library malloc() and free() functions.
+ *  This function can only be used when ICU is in an initial, unused state, before
+ *  u_init() has been called.
+ *  @param context This pointer value will be saved, and then (later) passed as
+ *                 a parameter to the memory functions each time they
+ *                 are called.
+ *  @param a       Pointer to a user-supplied malloc function.
+ *  @param r       Pointer to a user-supplied realloc function.
+ *  @param f       Pointer to a user-supplied free function.
+ *  @param status  Receives error values.
+ *  @stable ICU 2.8
+ *  @system
+ */  
+U_STABLE void U_EXPORT2 
+u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMemFreeFn *f, 
+                    UErrorCode *status);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ucnv.h b/CoreFoundation/icu/unicode/ucnv.h
new file mode 100644
index 0000000..bfd7198
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucnv.h
@@ -0,0 +1,1967 @@
+/*
+**********************************************************************
+*   Copyright (C) 1999-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+ *  ucnv.h:
+ *  External APIs for the ICU's codeset conversion library
+ *  Bertrand A. Damiba
+ *
+ * Modification History:
+ *
+ *   Date        Name        Description
+ *   04/04/99    helena      Fixed internal header inclusion.
+ *   05/11/00    helena      Added setFallback and usesFallback APIs.
+ *   06/29/2000  helena      Major rewrite of the callback APIs.
+ *   12/07/2000  srl         Update of documentation
+ */
+
+/**
+ * \file
+ * \brief C API: Character conversion 
+ *
+ * <h2>Character Conversion C API</h2>
+ *
+ * <p>This API is used to convert codepage or character encoded data to and
+ * from UTF-16. You can open a converter with {@link ucnv_open() }. With that
+ * converter, you can get its properties, set options, convert your data and
+ * close the converter.</p>
+ *
+ * <p>Since many software programs recogize different converter names for
+ * different types of converters, there are other functions in this API to
+ * iterate over the converter aliases. The functions {@link ucnv_getAvailableName() },
+ * {@link ucnv_getAlias() } and {@link ucnv_getStandardName() } are some of the
+ * more frequently used alias functions to get this information.</p>
+ *
+ * <p>When a converter encounters an illegal, irregular, invalid or unmappable character
+ * its default behavior is to use a substitution character to replace the
+ * bad byte sequence. This behavior can be changed by using {@link ucnv_setFromUCallBack() }
+ * or {@link ucnv_setToUCallBack() } on the converter. The header ucnv_err.h defines
+ * many other callback actions that can be used instead of a character substitution.</p>
+ *
+ * <p>More information about this API can be found in our 
+ * <a href="http://icu-project.org/userguide/conversion.html">User's
+ * Guide</a>.</p>
+ */
+
+#ifndef UCNV_H
+#define UCNV_H
+
+#include "unicode/ucnv_err.h"
+#include "unicode/uenum.h"
+
+#ifndef __USET_H__
+
+/**
+ * USet is the C API type for Unicode sets.
+ * It is forward-declared here to avoid including the header file if related
+ * conversion APIs are not used.
+ * See unicode/uset.h
+ *
+ * @see ucnv_getUnicodeSet
+ * @stable ICU 2.6
+ */
+struct USet;
+/** @stable ICU 2.6 */
+typedef struct USet USet;
+
+#endif
+
+#if !UCONFIG_NO_CONVERSION
+
+U_CDECL_BEGIN
+
+/** Maximum length of a converter name including the terminating NULL @stable ICU 2.0 */
+#define UCNV_MAX_CONVERTER_NAME_LENGTH 60
+/** Maximum length of a converter name including path and terminating NULL @stable ICU 2.0 */
+#define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
+
+/** Shift in for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */
+#define  UCNV_SI 0x0F
+/** Shift out for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */
+#define  UCNV_SO 0x0E
+
+/**
+ * Enum for specifying basic types of converters
+ * @see ucnv_getType
+ * @stable ICU 2.0
+ */
+typedef enum {
+    UCNV_UNSUPPORTED_CONVERTER = -1,
+    UCNV_SBCS = 0,
+    UCNV_DBCS = 1,
+    UCNV_MBCS = 2,
+    UCNV_LATIN_1 = 3,
+    UCNV_UTF8 = 4,
+    UCNV_UTF16_BigEndian = 5,
+    UCNV_UTF16_LittleEndian = 6,
+    UCNV_UTF32_BigEndian = 7,
+    UCNV_UTF32_LittleEndian = 8,
+    UCNV_EBCDIC_STATEFUL = 9,
+    UCNV_ISO_2022 = 10,
+
+    UCNV_LMBCS_1 = 11,
+    UCNV_LMBCS_2, 
+    UCNV_LMBCS_3,
+    UCNV_LMBCS_4,
+    UCNV_LMBCS_5,
+    UCNV_LMBCS_6,
+    UCNV_LMBCS_8,
+    UCNV_LMBCS_11,
+    UCNV_LMBCS_16,
+    UCNV_LMBCS_17,
+    UCNV_LMBCS_18,
+    UCNV_LMBCS_19,
+    UCNV_LMBCS_LAST = UCNV_LMBCS_19,
+    UCNV_HZ,
+    UCNV_SCSU,
+    UCNV_ISCII,
+    UCNV_US_ASCII,
+    UCNV_UTF7,
+    UCNV_BOCU1,
+    UCNV_UTF16,
+    UCNV_UTF32,
+    UCNV_CESU8,
+    UCNV_IMAP_MAILBOX,
+
+    /* Number of converter types for which we have conversion routines. */
+    UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
+
+} UConverterType;
+
+/**
+ * Enum for specifying which platform a converter ID refers to.
+ * The use of platform/CCSID is not recommended. See ucnv_openCCSID().
+ *
+ * @see ucnv_getPlatform
+ * @see ucnv_openCCSID
+ * @see ucnv_getCCSID
+ * @stable ICU 2.0
+ */
+typedef enum {
+    UCNV_UNKNOWN = -1,
+    UCNV_IBM = 0
+} UConverterPlatform;
+
+/**
+ * Function pointer for error callback in the codepage to unicode direction.
+ * Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason).
+ * @param context Pointer to the callback's private data
+ * @param args Information about the conversion in progress
+ * @param codeUnits Points to 'length' bytes of the concerned codepage sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param reason Defines the reason the callback was invoked
+ * @param pErrorCode    ICU error code in/out parameter.
+ *                      For converter callback functions, set to a conversion error
+ *                      before the call, and the callback may reset it to U_ZERO_ERROR.
+ * @see ucnv_setToUCallBack
+ * @see UConverterToUnicodeArgs
+ * @stable ICU 2.0
+ */
+typedef void (U_EXPORT2 *UConverterToUCallback) (
+                  const void* context,
+                  UConverterToUnicodeArgs *args,
+                  const char *codeUnits,
+                  int32_t length,
+                  UConverterCallbackReason reason,
+                  UErrorCode *pErrorCode);
+
+/**
+ * Function pointer for error callback in the unicode to codepage direction.
+ * Called when an error has occured in conversion from unicode, or on open/close of the callback (see reason).
+ * @param context Pointer to the callback's private data
+ * @param args Information about the conversion in progress
+ * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
+ * @param reason Defines the reason the callback was invoked
+ * @param pErrorCode    ICU error code in/out parameter.
+ *                      For converter callback functions, set to a conversion error
+ *                      before the call, and the callback may reset it to U_ZERO_ERROR.
+ * @see ucnv_setFromUCallBack
+ * @stable ICU 2.0
+ */
+typedef void (U_EXPORT2 *UConverterFromUCallback) (
+                    const void* context,
+                    UConverterFromUnicodeArgs *args,
+                    const UChar* codeUnits,
+                    int32_t length,
+                    UChar32 codePoint,
+                    UConverterCallbackReason reason,
+                    UErrorCode *pErrorCode);
+
+U_CDECL_END
+
+/**
+ * Character that separates converter names from options and options from each other.
+ * @see ucnv_open
+ * @stable ICU 2.0
+ */
+#define UCNV_OPTION_SEP_CHAR ','
+
+/**
+ * String version of UCNV_OPTION_SEP_CHAR. 
+ * @see ucnv_open
+ * @stable ICU 2.0
+ */
+#define UCNV_OPTION_SEP_STRING ","
+
+/**
+ * Character that separates a converter option from its value.
+ * @see ucnv_open
+ * @stable ICU 2.0
+ */
+#define UCNV_VALUE_SEP_CHAR '='
+
+/**
+ * String version of UCNV_VALUE_SEP_CHAR. 
+ * @see ucnv_open
+ * @stable ICU 2.0
+ */
+#define UCNV_VALUE_SEP_STRING "="
+
+/**
+ * Converter option for specifying a locale.
+ * For example, ucnv_open("SCSU,locale=ja", &errorCode);
+ * See convrtrs.txt.
+ *
+ * @see ucnv_open
+ * @stable ICU 2.0
+ */
+#define UCNV_LOCALE_OPTION_STRING ",locale="
+
+/**
+ * Converter option for specifying a version selector (0..9) for some converters.
+ * For example, ucnv_open("UTF-7,version=1", &errorCode);
+ * See convrtrs.txt.
+ *
+ * @see ucnv_open
+ * @stable ICU 2.4
+ */
+#define UCNV_VERSION_OPTION_STRING ",version="
+
+/**
+ * Converter option for EBCDIC SBCS or mixed-SBCS/DBCS (stateful) codepages.
+ * Swaps Unicode mappings for EBCDIC LF and NL codes, as used on
+ * S/390 (z/OS) Unix System Services (Open Edition).
+ * For example, ucnv_open("ibm-1047,swaplfnl", &errorCode);
+ * See convrtrs.txt.
+ *
+ * @see ucnv_open
+ * @stable ICU 2.4
+ */
+#define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
+
+/**
+ * Do a fuzzy compare of two converter/alias names.
+ * The comparison is case-insensitive, ignores leading zeroes if they are not
+ * followed by further digits, and ignores all but letters and digits.
+ * Thus the strings "UTF-8", "utf_8", "u*T@f08" and "Utf 8" are exactly equivalent.
+ * See section 1.4, Charset Alias Matching in Unicode Technical Standard #22
+ * at http://www.unicode.org/reports/tr22/
+ *
+ * @param name1 a converter name or alias, zero-terminated
+ * @param name2 a converter name or alias, zero-terminated
+ * @return 0 if the names match, or a negative value if the name1
+ * lexically precedes name2, or a positive value if the name1
+ * lexically follows name2.
+ * @stable ICU 2.0
+ */
+U_STABLE int U_EXPORT2
+ucnv_compareNames(const char *name1, const char *name2);
+
+
+/**
+ * Creates a UConverter object with the name of a coded character set specified as a C string.
+ * The actual name will be resolved with the alias file
+ * using a case-insensitive string comparison that ignores
+ * leading zeroes and all non-alphanumeric characters.
+ * E.g., the names "UTF8", "utf-8", "u*T@f08" and "Utf 8" are all equivalent.
+ * (See also ucnv_compareNames().)
+ * If <code>NULL</code> is passed for the converter name, it will create one with the
+ * getDefaultName return value.
+ *
+ * <p>A converter name for ICU 1.5 and above may contain options
+ * like a locale specification to control the specific behavior of
+ * the newly instantiated converter.
+ * The meaning of the options depends on the particular converter.
+ * If an option is not defined for or recognized by a given converter, then it is ignored.</p>
+ *
+ * <p>Options are appended to the converter name string, with a
+ * <code>UCNV_OPTION_SEP_CHAR</code> between the name and the first option and
+ * also between adjacent options.</p>
+ *
+ * <p>If the alias is ambiguous, then the preferred converter is used
+ * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.</p>
+ *
+ * <p>The conversion behavior and names can vary between platforms. ICU may
+ * convert some characters differently from other platforms. Details on this topic
+ * are in the <a href="http://icu-project.org/userguide/conversion.html">User's
+ * Guide</a>. Aliases starting with a "cp" prefix have no specific meaning
+ * other than its an alias starting with the letters "cp". Please do not
+ * associate any meaning to these aliases.</p>
+ *
+ * @param converterName Name of the coded character set table.
+ *          This may have options appended to the string.
+ *          IANA alias character set names, IBM CCSIDs starting with "ibm-",
+ *          Windows codepage numbers starting with "windows-" are frequently
+ *          used for this parameter. See ucnv_getAvailableName and
+ *          ucnv_getAlias for a complete list that is available.
+ *          If this parameter is NULL, the default converter will be used.
+ * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
+ * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
+ * @see ucnv_openU
+ * @see ucnv_openCCSID
+ * @see ucnv_getAvailableName
+ * @see ucnv_getAlias
+ * @see ucnv_getDefaultName
+ * @see ucnv_close
+ * @see ucnv_compareNames
+ * @stable ICU 2.0
+ */
+U_STABLE UConverter* U_EXPORT2 
+ucnv_open(const char *converterName, UErrorCode *err);
+
+
+/**
+ * Creates a Unicode converter with the names specified as unicode string. 
+ * The name should be limited to the ASCII-7 alphanumerics range.
+ * The actual name will be resolved with the alias file
+ * using a case-insensitive string comparison that ignores
+ * leading zeroes and all non-alphanumeric characters.
+ * E.g., the names "UTF8", "utf-8", "u*T@f08" and "Utf 8" are all equivalent.
+ * (See also ucnv_compareNames().)
+ * If <TT>NULL</TT> is passed for the converter name, it will create 
+ * one with the ucnv_getDefaultName() return value.
+ * If the alias is ambiguous, then the preferred converter is used
+ * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
+ *
+ * <p>See ucnv_open for the complete details</p>
+ * @param name Name of the UConverter table in a zero terminated 
+ *        Unicode string
+ * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, 
+ *        U_FILE_ACCESS_ERROR</TT>
+ * @return the created Unicode converter object, or <TT>NULL</TT> if an 
+ *        error occured
+ * @see ucnv_open
+ * @see ucnv_openCCSID
+ * @see ucnv_close
+ * @see ucnv_compareNames
+ * @stable ICU 2.0
+ */
+U_STABLE UConverter* U_EXPORT2 
+ucnv_openU(const UChar *name,
+           UErrorCode *err);
+
+/**
+ * Creates a UConverter object from a CCSID number and platform pair.
+ * Note that the usefulness of this function is limited to platforms with numeric
+ * encoding IDs. Only IBM and Microsoft platforms use numeric (16-bit) identifiers for
+ * encodings.
+ *
+ * In addition, IBM CCSIDs and Unicode conversion tables are not 1:1 related.
+ * For many IBM CCSIDs there are multiple (up to six) Unicode conversion tables, and
+ * for some Unicode conversion tables there are multiple CCSIDs.
+ * Some "alternate" Unicode conversion tables are provided by the
+ * IBM CDRA conversion table registry.
+ * The most prominent example of a systematic modification of conversion tables that is
+ * not provided in the form of conversion table files in the repository is
+ * that S/390 Unix System Services swaps the codes for Line Feed and New Line in all
+ * EBCDIC codepages, which requires such a swap in the Unicode conversion tables as well.
+ *
+ * Only IBM default conversion tables are accessible with ucnv_openCCSID().
+ * ucnv_getCCSID() will return the same CCSID for all conversion tables that are associated
+ * with that CCSID.
+ *
+ * Currently, the only "platform" supported in the ICU converter API is UCNV_IBM.
+ *
+ * In summary, the use of CCSIDs and the associated API functions is not recommended.
+ *
+ * In order to open a converter with the default IBM CDRA Unicode conversion table,
+ * you can use this function or use the prefix "ibm-":
+ * \code
+ *     char name[20];
+ *     sprintf(name, "ibm-%hu", ccsid);
+ *     cnv=ucnv_open(name, &errorCode);
+ * \endcode
+ *
+ * In order to open a converter with the IBM S/390 Unix System Services variant
+ * of a Unicode/EBCDIC conversion table,
+ * you can use the prefix "ibm-" together with the option string UCNV_SWAP_LFNL_OPTION_STRING:
+ * \code
+ *     char name[20];
+ *     sprintf(name, "ibm-%hu" UCNV_SWAP_LFNL_OPTION_STRING, ccsid);
+ *     cnv=ucnv_open(name, &errorCode);
+ * \endcode
+ *
+ * In order to open a converter from a Microsoft codepage number, use the prefix "cp":
+ * \code
+ *     char name[20];
+ *     sprintf(name, "cp%hu", codepageID);
+ *     cnv=ucnv_open(name, &errorCode);
+ * \endcode
+ *
+ * If the alias is ambiguous, then the preferred converter is used
+ * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
+ *
+ * @param codepage codepage number to create
+ * @param platform the platform in which the codepage number exists
+ * @param err error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
+ * @return the created Unicode converter object, or <TT>NULL</TT> if an error
+ *   occured.
+ * @see ucnv_open
+ * @see ucnv_openU
+ * @see ucnv_close
+ * @see ucnv_getCCSID
+ * @see ucnv_getPlatform
+ * @see UConverterPlatform
+ * @stable ICU 2.0
+ */
+U_STABLE UConverter* U_EXPORT2
+ucnv_openCCSID(int32_t codepage,
+               UConverterPlatform platform,
+               UErrorCode * err);
+
+/**
+ * <p>Creates a UConverter object specified from a packageName and a converterName.</p>
+ * 
+ * <p>The packageName and converterName must point to an ICU udata object, as defined by
+ *   <code> udata_open( packageName, "cnv", converterName, err) </code> or equivalent.
+ * Typically, packageName will refer to a (.dat) file, or to a package registered with
+ * udata_setAppData(). Using a full file or directory pathname for packageName is deprecated.</p>
+ * 
+ * <p>The name will NOT be looked up in the alias mechanism, nor will the converter be
+ * stored in the converter cache or the alias table. The only way to open further converters
+ * is call this function multiple times, or use the ucnv_safeClone() function to clone a 
+ * 'master' converter.</p>
+ *
+ * <p>A future version of ICU may add alias table lookups and/or caching
+ * to this function.</p>
+ * 
+ * <p>Example Use:
+ *      <code>cnv = ucnv_openPackage("myapp", "myconverter", &err);</code>
+ * </p>
+ *
+ * @param packageName name of the package (equivalent to 'path' in udata_open() call)
+ * @param converterName name of the data item to be used, without suffix.
+ * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
+ * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
+ * @see udata_open
+ * @see ucnv_open
+ * @see ucnv_safeClone
+ * @see ucnv_close
+ * @stable ICU 2.2
+ */
+U_STABLE UConverter* U_EXPORT2 
+ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
+
+/**
+ * Thread safe converter cloning operation.
+ * For most efficient operation, pass in a stackBuffer (and a *pBufferSize)
+ * with at least U_CNV_SAFECLONE_BUFFERSIZE bytes of space.
+ * If the buffer size is sufficient, then the clone will use the stack buffer;
+ * otherwise, it will be allocated, and *pBufferSize will indicate
+ * the actual size. (This should not occur with U_CNV_SAFECLONE_BUFFERSIZE.)
+ *
+ * You must ucnv_close() the clone in any case.
+ *
+ * If *pBufferSize==0, (regardless of whether stackBuffer==NULL or not)
+ * then *pBufferSize will be changed to a sufficient size
+ * for cloning this converter,
+ * without actually cloning the converter ("pure pre-flighting").
+ *
+ * If *pBufferSize is greater than zero but not large enough for a stack-based
+ * clone, then the converter is cloned using newly allocated memory
+ * and *pBufferSize is changed to the necessary size.
+ *
+ * If the converter clone fits into the stack buffer but the stack buffer is not
+ * sufficiently aligned for the clone, then the clone will use an
+ * adjusted pointer and use an accordingly smaller buffer size.
+ *
+ * @param cnv converter to be cloned
+ * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. 
+ *  If buffer is not large enough, new memory will be allocated.
+ *  Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.
+ * @param pBufferSize pointer to size of allocated space. pBufferSize must not be NULL.
+ * @param status to indicate whether the operation went on smoothly or there were errors
+ *  An informational status value, U_SAFECLONE_ALLOCATED_WARNING,
+ *  is used if any allocations were necessary.
+ *  However, it is better to check if *pBufferSize grew for checking for
+ *  allocations because warning codes can be overridden by subsequent
+ *  function calls.
+ * @return pointer to the new clone
+ * @stable ICU 2.0
+ */
+U_STABLE UConverter * U_EXPORT2 
+ucnv_safeClone(const UConverter *cnv, 
+               void             *stackBuffer,
+               int32_t          *pBufferSize, 
+               UErrorCode       *status);
+
+/**
+ * \def U_CNV_SAFECLONE_BUFFERSIZE
+ * Definition of a buffer size that is designed to be large enough for
+ * converters to be cloned with ucnv_safeClone().
+ * @stable ICU 2.0
+ */
+#define U_CNV_SAFECLONE_BUFFERSIZE  1024
+
+/**
+ * Deletes the unicode converter and releases resources associated
+ * with just this instance.
+ * Does not free up shared converter tables.
+ *
+ * @param converter the converter object to be deleted
+ * @see ucnv_open
+ * @see ucnv_openU
+ * @see ucnv_openCCSID
+ * @stable ICU 2.0
+ */
+U_STABLE void  U_EXPORT2
+ucnv_close(UConverter * converter);
+
+/**
+ * Fills in the output parameter, subChars, with the substitution characters
+ * as multiple bytes.
+ * If ucnv_setSubstString() set a Unicode string because the converter is
+ * stateful, then subChars will be an empty string.
+ *
+ * @param converter the Unicode converter
+ * @param subChars the subsitution characters
+ * @param len on input the capacity of subChars, on output the number 
+ * of bytes copied to it
+ * @param  err the outgoing error status code.
+ * If the substitution character array is too small, an
+ * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
+ * @see ucnv_setSubstString
+ * @see ucnv_setSubstChars
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_getSubstChars(const UConverter *converter,
+                   char *subChars,
+                   int8_t *len,
+                   UErrorCode *err);
+
+/**
+ * Sets the substitution chars when converting from unicode to a codepage. The
+ * substitution is specified as a string of 1-4 bytes, and may contain
+ * <TT>NULL</TT> bytes.
+ * The subChars must represent a single character. The caller needs to know the
+ * byte sequence of a valid character in the converter's charset.
+ * For some converters, for example some ISO 2022 variants, only single-byte
+ * substitution characters may be supported.
+ * The newer ucnv_setSubstString() function relaxes these limitations.
+ *
+ * @param converter the Unicode converter
+ * @param subChars the substitution character byte sequence we want set
+ * @param len the number of bytes in subChars
+ * @param err the error status code.  <TT>U_INDEX_OUTOFBOUNDS_ERROR </TT> if
+ * len is bigger than the maximum number of bytes allowed in subchars
+ * @see ucnv_setSubstString
+ * @see ucnv_getSubstChars
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_setSubstChars(UConverter *converter,
+                   const char *subChars,
+                   int8_t len,
+                   UErrorCode *err);
+
+/**
+ * Set a substitution string for converting from Unicode to a charset.
+ * The caller need not know the charset byte sequence for each charset.
+ *
+ * Unlike ucnv_setSubstChars() which is designed to set a charset byte sequence
+ * for a single character, this function takes a Unicode string with
+ * zero, one or more characters, and immediately verifies that the string can be
+ * converted to the charset.
+ * If not, or if the result is too long (more than 32 bytes as of ICU 3.6),
+ * then the function returns with an error accordingly.
+ *
+ * Also unlike ucnv_setSubstChars(), this function works for stateful charsets
+ * by converting on the fly at the point of substitution rather than setting
+ * a fixed byte sequence.
+ *
+ * @param cnv The UConverter object.
+ * @param s The Unicode string.
+ * @param length The number of UChars in s, or -1 for a NUL-terminated string.
+ * @param err Pointer to a standard ICU error code. Its input value must
+ *            pass the U_SUCCESS() test, or else the function returns
+ *            immediately. Check for U_FAILURE() on output or use with
+ *            function chaining. (See User Guide for details.)
+ *
+ * @see ucnv_setSubstChars
+ * @see ucnv_getSubstChars
+ * @stable ICU 3.6
+ */
+U_STABLE void U_EXPORT2
+ucnv_setSubstString(UConverter *cnv,
+                    const UChar *s,
+                    int32_t length,
+                    UErrorCode *err);
+
+/**
+ * Fills in the output parameter, errBytes, with the error characters from the
+ * last failing conversion.
+ *
+ * @param converter the Unicode converter
+ * @param errBytes the codepage bytes which were in error
+ * @param len on input the capacity of errBytes, on output the number of
+ *  bytes which were copied to it
+ * @param err the error status code.
+ * If the substitution character array is too small, an
+ * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_getInvalidChars(const UConverter *converter,
+                     char *errBytes,
+                     int8_t *len,
+                     UErrorCode *err);
+
+/**
+ * Fills in the output parameter, errChars, with the error characters from the
+ * last failing conversion.
+ *
+ * @param converter the Unicode converter
+ * @param errUChars the UChars which were in error
+ * @param len on input the capacity of errUChars, on output the number of 
+ *  UChars which were copied to it
+ * @param err the error status code.
+ * If the substitution character array is too small, an
+ * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_getInvalidUChars(const UConverter *converter,
+                      UChar *errUChars,
+                      int8_t *len,
+                      UErrorCode *err);
+
+/**
+ * Resets the state of a converter to the default state. This is used
+ * in the case of an error, to restart a conversion from a known default state.
+ * It will also empty the internal output buffers.
+ * @param converter the Unicode converter
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_reset(UConverter *converter);
+
+/**
+ * Resets the to-Unicode part of a converter state to the default state.
+ * This is used in the case of an error to restart a conversion to
+ * Unicode to a known default state. It will also empty the internal
+ * output buffers used for the conversion to Unicode codepoints.
+ * @param converter the Unicode converter
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucnv_resetToUnicode(UConverter *converter);
+
+/**
+ * Resets the from-Unicode part of a converter state to the default state.
+ * This is used in the case of an error to restart a conversion from
+ * Unicode to a known default state. It will also empty the internal output
+ * buffers used for the conversion from Unicode codepoints.
+ * @param converter the Unicode converter
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucnv_resetFromUnicode(UConverter *converter);
+
+/**
+ * Returns the maximum number of bytes that are output per UChar in conversion
+ * from Unicode using this converter.
+ * The returned number can be used with UCNV_GET_MAX_BYTES_FOR_STRING
+ * to calculate the size of a target buffer for conversion from Unicode.
+ *
+ * Note: Before ICU 2.8, this function did not return reliable numbers for
+ * some stateful converters (EBCDIC_STATEFUL, ISO-2022) and LMBCS.
+ *
+ * This number may not be the same as the maximum number of bytes per
+ * "conversion unit". In other words, it may not be the intuitively expected
+ * number of bytes per character that would be published for a charset,
+ * and may not fulfill any other purpose than the allocation of an output
+ * buffer of guaranteed sufficient size for a given input length and converter.
+ *
+ * Examples for special cases that are taken into account:
+ * - Supplementary code points may convert to more bytes than BMP code points.
+ *   This function returns bytes per UChar (UTF-16 code unit), not per
+ *   Unicode code point, for efficient buffer allocation.
+ * - State-shifting output (SI/SO, escapes, etc.) from stateful converters.
+ * - When m input UChars are converted to n output bytes, then the maximum m/n
+ *   is taken into account.
+ *
+ * The number returned here does not take into account
+ * (see UCNV_GET_MAX_BYTES_FOR_STRING):
+ * - callbacks which output more than one charset character sequence per call,
+ *   like escape callbacks
+ * - initial and final non-character bytes that are output by some converters
+ *   (automatic BOMs, initial escape sequence, final SI, etc.)
+ *
+ * Examples for returned values:
+ * - SBCS charsets: 1
+ * - Shift-JIS: 2
+ * - UTF-16: 2 (2 per BMP, 4 per surrogate _pair_, BOM not counted)
+ * - UTF-8: 3 (3 per BMP, 4 per surrogate _pair_)
+ * - EBCDIC_STATEFUL (EBCDIC mixed SBCS/DBCS): 3 (SO + DBCS)
+ * - ISO-2022: 3 (always outputs UTF-8)
+ * - ISO-2022-JP: 6 (4-byte escape sequences + DBCS)
+ * - ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 + DBCS)
+ *
+ * @param converter The Unicode converter.
+ * @return The maximum number of bytes per UChar that are output by ucnv_fromUnicode(),
+ *         to be used together with UCNV_GET_MAX_BYTES_FOR_STRING for buffer allocation.
+ *
+ * @see UCNV_GET_MAX_BYTES_FOR_STRING
+ * @see ucnv_getMinCharSize
+ * @stable ICU 2.0
+ */
+U_STABLE int8_t U_EXPORT2
+ucnv_getMaxCharSize(const UConverter *converter);
+
+/**
+ * Calculates the size of a buffer for conversion from Unicode to a charset.
+ * The calculated size is guaranteed to be sufficient for this conversion.
+ *
+ * It takes into account initial and final non-character bytes that are output
+ * by some converters.
+ * It does not take into account callbacks which output more than one charset
+ * character sequence per call, like escape callbacks.
+ * The default (substitution) callback only outputs one charset character sequence.
+ *
+ * @param length Number of UChars to be converted.
+ * @param maxCharSize Return value from ucnv_getMaxCharSize() for the converter
+ *                    that will be used.
+ * @return Size of a buffer that will be large enough to hold the output bytes of
+ *         converting length UChars with the converter that returned the maxCharSize.
+ *
+ * @see ucnv_getMaxCharSize
+ * @stable ICU 2.8
+ */
+#define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
+     (((int32_t)(length)+10)*(int32_t)(maxCharSize))
+
+/**
+ * Returns the minimum byte length for characters in this codepage. 
+ * This is usually either 1 or 2.
+ * @param converter the Unicode converter
+ * @return the minimum number of bytes allowed by this particular converter
+ * @see ucnv_getMaxCharSize
+ * @stable ICU 2.0
+ */
+U_STABLE int8_t U_EXPORT2
+ucnv_getMinCharSize(const UConverter *converter);
+
+/**
+ * Returns the display name of the converter passed in based on the Locale 
+ * passed in. If the locale contains no display name, the internal ASCII
+ * name will be filled in.
+ *
+ * @param converter the Unicode converter.
+ * @param displayLocale is the specific Locale we want to localised for
+ * @param displayName user provided buffer to be filled in
+ * @param displayNameCapacity size of displayName Buffer
+ * @param err error status code
+ * @return displayNameLength number of UChar needed in displayName
+ * @see ucnv_getName
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_getDisplayName(const UConverter *converter,
+                    const char *displayLocale,
+                    UChar *displayName,
+                    int32_t displayNameCapacity,
+                    UErrorCode *err);
+
+/**
+ * Gets the internal, canonical name of the converter (zero-terminated).
+ * The lifetime of the returned string will be that of the converter 
+ * passed to this function.
+ * @param converter the Unicode converter
+ * @param err UErrorCode status
+ * @return the internal name of the converter
+ * @see ucnv_getDisplayName
+ * @stable ICU 2.0
+ */
+U_STABLE const char * U_EXPORT2 
+ucnv_getName(const UConverter *converter, UErrorCode *err);
+
+/**
+ * Gets a codepage number associated with the converter. This is not guaranteed
+ * to be the one used to create the converter. Some converters do not represent
+ * platform registered codepages and return zero for the codepage number.
+ * The error code fill-in parameter indicates if the codepage number
+ * is available.
+ * Does not check if the converter is <TT>NULL</TT> or if converter's data
+ * table is <TT>NULL</TT>.
+ *
+ * Important: The use of CCSIDs is not recommended because it is limited
+ * to only two platforms in principle and only one (UCNV_IBM) in the current
+ * ICU converter API.
+ * Also, CCSIDs are insufficient to identify IBM Unicode conversion tables precisely.
+ * For more details see ucnv_openCCSID().
+ *
+ * @param converter the Unicode converter
+ * @param err the error status code.
+ * @return If any error occurrs, -1 will be returned otherwise, the codepage number
+ * will be returned
+ * @see ucnv_openCCSID
+ * @see ucnv_getPlatform
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_getCCSID(const UConverter *converter,
+              UErrorCode *err);
+
+/**
+ * Gets a codepage platform associated with the converter. Currently, 
+ * only <TT>UCNV_IBM</TT> will be returned.
+ * Does not test if the converter is <TT>NULL</TT> or if converter's data 
+ * table is <TT>NULL</TT>. 
+ * @param converter the Unicode converter
+ * @param err the error status code.
+ * @return The codepage platform
+ * @stable ICU 2.0
+ */
+U_STABLE UConverterPlatform U_EXPORT2
+ucnv_getPlatform(const UConverter *converter,
+                 UErrorCode *err);
+
+/**
+ * Gets the type of the converter
+ * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, 
+ * EBCDIC_STATEFUL, LATIN_1
+ * @param converter a valid, opened converter
+ * @return the type of the converter
+ * @stable ICU 2.0
+ */
+U_STABLE UConverterType U_EXPORT2
+ucnv_getType(const UConverter * converter);
+
+/**
+ * Gets the "starter" (lead) bytes for converters of type MBCS.
+ * Will fill in an <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if converter passed in
+ * is not MBCS. Fills in an array of type UBool, with the value of the byte 
+ * as offset to the array. For example, if (starters[0x20] == TRUE) at return,
+ * it means that the byte 0x20 is a starter byte in this converter.
+ * Context pointers are always owned by the caller.
+ * 
+ * @param converter a valid, opened converter of type MBCS
+ * @param starters an array of size 256 to be filled in
+ * @param err error status, <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if the 
+ * converter is not a type which can return starters.
+ * @see ucnv_getType
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_getStarters(const UConverter* converter, 
+                 UBool starters[256],
+                 UErrorCode* err);
+
+
+/**
+ * Selectors for Unicode sets that can be returned by ucnv_getUnicodeSet().
+ * @see ucnv_getUnicodeSet
+ * @stable ICU 2.6
+ */
+typedef enum UConverterUnicodeSet {
+    /** Select the set of roundtrippable Unicode code points. @stable ICU 2.6 */
+    UCNV_ROUNDTRIP_SET,
+    /** Select the set of Unicode code points with roundtrip or fallback mappings. @draft ICU 4.0 */
+    UCNV_ROUNDTRIP_AND_FALLBACK_SET,
+    /** Number of UConverterUnicodeSet selectors. @stable ICU 2.6 */
+    UCNV_SET_COUNT
+} UConverterUnicodeSet;
+
+
+/**
+ * Returns the set of Unicode code points that can be converted by an ICU converter.
+ *
+ * Returns one of several kinds of set:
+ *
+ * 1. UCNV_ROUNDTRIP_SET
+ *
+ * The set of all Unicode code points that can be roundtrip-converted
+ * (converted without any data loss) with the converter (ucnv_fromUnicode()).
+ * This set will not include code points that have fallback mappings
+ * or are only the result of reverse fallback mappings.
+ * This set will also not include PUA code points with fallbacks, although
+ * ucnv_fromUnicode() will always uses those mappings despite ucnv_setFallback().
+ * See UTR #22 "Character Mapping Markup Language"
+ * at http://www.unicode.org/reports/tr22/
+ *
+ * This is useful for example for
+ * - checking that a string or document can be roundtrip-converted with a converter,
+ *   without/before actually performing the conversion
+ * - testing if a converter can be used for text for typical text for a certain locale,
+ *   by comparing its roundtrip set with the set of ExemplarCharacters from
+ *   ICU's locale data or other sources
+ *
+ * 2. UCNV_ROUNDTRIP_AND_FALLBACK_SET
+ *
+ * The set of all Unicode code points that can be converted with the converter (ucnv_fromUnicode())
+ * when fallbacks are turned on (see ucnv_setFallback()).
+ * This set includes all code points with roundtrips and fallbacks (but not reverse fallbacks).
+ *
+ * In the future, there may be more UConverterUnicodeSet choices to select
+ * sets with different properties.
+ *
+ * @param cnv The converter for which a set is requested.
+ * @param setFillIn A valid USet *. It will be cleared by this function before
+ *            the converter's specific set is filled into the USet.
+ * @param whichSet A UConverterUnicodeSet selector;
+ *              currently UCNV_ROUNDTRIP_SET is the only supported value.
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ *
+ * @see UConverterUnicodeSet
+ * @see uset_open
+ * @see uset_close
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+ucnv_getUnicodeSet(const UConverter *cnv,
+                   USet *setFillIn,
+                   UConverterUnicodeSet whichSet,
+                   UErrorCode *pErrorCode);
+
+/**
+ * Gets the current calback function used by the converter when an illegal
+ *  or invalid codepage sequence is found. 
+ * Context pointers are always owned by the caller.
+ *
+ * @param converter the unicode converter
+ * @param action fillin: returns the callback function pointer
+ * @param context fillin: returns the callback's private void* context
+ * @see ucnv_setToUCallBack
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_getToUCallBack (const UConverter * converter,
+                     UConverterToUCallback *action,
+                     const void **context);
+
+/**
+ * Gets the current callback function used by the converter when illegal 
+ * or invalid Unicode sequence is found.
+ * Context pointers are always owned by the caller.
+ *
+ * @param converter the unicode converter
+ * @param action fillin: returns the callback function pointer
+ * @param context fillin: returns the callback's private void* context
+ * @see ucnv_setFromUCallBack
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_getFromUCallBack (const UConverter * converter,
+                       UConverterFromUCallback *action,
+                       const void **context);
+
+/**
+ * Changes the callback function used by the converter when
+ * an illegal or invalid sequence is found.
+ * Context pointers are always owned by the caller.
+ * Predefined actions and contexts can be found in the ucnv_err.h header.
+ *
+ * @param converter the unicode converter
+ * @param newAction the new callback function
+ * @param newContext the new toUnicode callback context pointer. This can be NULL.
+ * @param oldAction fillin: returns the old callback function pointer. This can be NULL.
+ * @param oldContext fillin: returns the old callback's private void* context. This can be NULL.
+ * @param err The error code status
+ * @see ucnv_getToUCallBack
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_setToUCallBack (UConverter * converter,
+                     UConverterToUCallback newAction,
+                     const void* newContext,
+                     UConverterToUCallback *oldAction,
+                     const void** oldContext,
+                     UErrorCode * err);
+
+/**
+ * Changes the current callback function used by the converter when
+ * an illegal or invalid sequence is found.
+ * Context pointers are always owned by the caller.
+ * Predefined actions and contexts can be found in the ucnv_err.h header.
+ *
+ * @param converter the unicode converter
+ * @param newAction the new callback function
+ * @param newContext the new fromUnicode callback context pointer. This can be NULL.
+ * @param oldAction fillin: returns the old callback function pointer. This can be NULL.
+ * @param oldContext fillin: returns the old callback's private void* context. This can be NULL.
+ * @param err The error code status
+ * @see ucnv_getFromUCallBack
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_setFromUCallBack (UConverter * converter,
+                       UConverterFromUCallback newAction,
+                       const void *newContext,
+                       UConverterFromUCallback *oldAction,
+                       const void **oldContext,
+                       UErrorCode * err);
+
+/**
+ * Converts an array of unicode characters to an array of codepage
+ * characters. This function is optimized for converting a continuous
+ * stream of data in buffer-sized chunks, where the entire source and
+ * target does not fit in available buffers.
+ * 
+ * The source pointer is an in/out parameter. It starts out pointing where the 
+ * conversion is to begin, and ends up pointing after the last UChar consumed. 
+ * 
+ * Target similarly starts out pointer at the first available byte in the output
+ * buffer, and ends up pointing after the last byte written to the output.
+ * 
+ * The converter always attempts to consume the entire source buffer, unless 
+ * (1.) the target buffer is full, or (2.) a failing error is returned from the
+ * current callback function.  When a successful error status has been
+ * returned, it means that all of the source buffer has been
+ *  consumed. At that point, the caller should reset the source and
+ *  sourceLimit pointers to point to the next chunk.
+ * 
+ * At the end of the stream (flush==TRUE), the input is completely consumed
+ * when *source==sourceLimit and no error code is set.
+ * The converter object is then automatically reset by this function.
+ * (This means that a converter need not be reset explicitly between data
+ * streams if it finishes the previous stream without errors.)
+ * 
+ * This is a <I>stateful</I> conversion. Additionally, even when all source data has
+ * been consumed, some data may be in the converters' internal state.
+ * Call this function repeatedly, updating the target pointers with
+ * the next empty chunk of target in case of a
+ * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers
+ *  with the next chunk of source when a successful error status is
+ * returned, until there are no more chunks of source data.
+ * @param converter the Unicode converter
+ * @param target I/O parameter. Input : Points to the beginning of the buffer to copy
+ *  codepage characters to. Output : points to after the last codepage character copied
+ *  to <TT>target</TT>.
+ * @param targetLimit the pointer just after last of the <TT>target</TT> buffer
+ * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. 
+ * @param sourceLimit the pointer just after the last of the source buffer
+ * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
+ * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
+ * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
+ * For output data carried across calls, and other data without a specific source character
+ * (such as from escape sequences or callbacks)  -1 will be placed for offsets. 
+ * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
+ * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
+ * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
+ * the source buffer is consumed.
+ * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
+ * converter is <TT>NULL</TT>.
+ * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is 
+ * still data to be written to the target.
+ * @see ucnv_fromUChars
+ * @see ucnv_convert
+ * @see ucnv_getMinCharSize
+ * @see ucnv_setToUCallBack
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucnv_fromUnicode (UConverter * converter,
+                  char **target,
+                  const char *targetLimit,
+                  const UChar ** source,
+                  const UChar * sourceLimit,
+                  int32_t* offsets,
+                  UBool flush,
+                  UErrorCode * err);
+
+/**
+ * Converts a buffer of codepage bytes into an array of unicode UChars
+ * characters. This function is optimized for converting a continuous
+ * stream of data in buffer-sized chunks, where the entire source and
+ * target does not fit in available buffers.
+ * 
+ * The source pointer is an in/out parameter. It starts out pointing where the 
+ * conversion is to begin, and ends up pointing after the last byte of source consumed. 
+ * 
+ * Target similarly starts out pointer at the first available UChar in the output
+ * buffer, and ends up pointing after the last UChar written to the output. 
+ * It does NOT necessarily keep UChar sequences together.
+ * 
+ * The converter always attempts to consume the entire source buffer, unless 
+ * (1.) the target buffer is full, or (2.) a failing error is returned from the
+ * current callback function.  When a successful error status has been
+ * returned, it means that all of the source buffer has been
+ *  consumed. At that point, the caller should reset the source and
+ *  sourceLimit pointers to point to the next chunk.
+ *
+ * At the end of the stream (flush==TRUE), the input is completely consumed
+ * when *source==sourceLimit and no error code is set
+ * The converter object is then automatically reset by this function.
+ * (This means that a converter need not be reset explicitly between data
+ * streams if it finishes the previous stream without errors.)
+ * 
+ * This is a <I>stateful</I> conversion. Additionally, even when all source data has
+ * been consumed, some data may be in the converters' internal state.
+ * Call this function repeatedly, updating the target pointers with
+ * the next empty chunk of target in case of a
+ * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers
+ *  with the next chunk of source when a successful error status is
+ * returned, until there are no more chunks of source data.
+ * @param converter the Unicode converter
+ * @param target I/O parameter. Input : Points to the beginning of the buffer to copy
+ *  UChars into. Output : points to after the last UChar copied.
+ * @param targetLimit the pointer just after the end of the <TT>target</TT> buffer
+ * @param source I/O parameter, pointer to pointer to the source codepage buffer. 
+ * @param sourceLimit the pointer to the byte after the end of the source buffer
+ * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
+ * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
+ * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
+ * For output data carried across calls, and other data without a specific source character
+ * (such as from escape sequences or callbacks)  -1 will be placed for offsets. 
+ * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
+ * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
+ * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
+ * the source buffer is consumed.
+ * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
+ * converter is <TT>NULL</TT>.
+ * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is 
+ * still data to be written to the target. 
+ * @see ucnv_fromUChars
+ * @see ucnv_convert
+ * @see ucnv_getMinCharSize
+ * @see ucnv_setFromUCallBack
+ * @see ucnv_getNextUChar
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucnv_toUnicode(UConverter *converter,
+               UChar **target,
+               const UChar *targetLimit,
+               const char **source,
+               const char *sourceLimit,
+               int32_t *offsets,
+               UBool flush,
+               UErrorCode *err);
+
+/**
+ * Convert the Unicode string into a codepage string using an existing UConverter.
+ * The output string is NUL-terminated if possible.
+ *
+ * This function is a more convenient but less powerful version of ucnv_fromUnicode().
+ * It is only useful for whole strings, not for streaming conversion.
+ *
+ * The maximum output buffer capacity required (barring output from callbacks) will be
+ * UCNV_GET_MAX_BYTES_FOR_STRING(srcLength, ucnv_getMaxCharSize(cnv)).
+ *
+ * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called)
+ * @param src the input Unicode string
+ * @param srcLength the input string length, or -1 if NUL-terminated
+ * @param dest destination string buffer, can be NULL if destCapacity==0
+ * @param destCapacity the number of chars available at dest
+ * @param pErrorCode normal ICU error code;
+ *                  common error codes that may be set by this function include
+ *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
+ *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
+ * @return the length of the output string, not counting the terminating NUL;
+ *         if the length is greater than destCapacity, then the string will not fit
+ *         and a buffer of the indicated length would need to be passed in
+ * @see ucnv_fromUnicode
+ * @see ucnv_convert
+ * @see UCNV_GET_MAX_BYTES_FOR_STRING
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_fromUChars(UConverter *cnv,
+                char *dest, int32_t destCapacity,
+                const UChar *src, int32_t srcLength,
+                UErrorCode *pErrorCode);
+
+/**
+ * Convert the codepage string into a Unicode string using an existing UConverter.
+ * The output string is NUL-terminated if possible.
+ *
+ * This function is a more convenient but less powerful version of ucnv_toUnicode().
+ * It is only useful for whole strings, not for streaming conversion.
+ *
+ * The maximum output buffer capacity required (barring output from callbacks) will be
+ * 2*srcLength (each char may be converted into a surrogate pair).
+ *
+ * @param cnv the converter object to be used (ucnv_resetToUnicode() will be called)
+ * @param src the input codepage string
+ * @param srcLength the input string length, or -1 if NUL-terminated
+ * @param dest destination string buffer, can be NULL if destCapacity==0
+ * @param destCapacity the number of UChars available at dest
+ * @param pErrorCode normal ICU error code;
+ *                  common error codes that may be set by this function include
+ *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
+ *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
+ * @return the length of the output string, not counting the terminating NUL;
+ *         if the length is greater than destCapacity, then the string will not fit
+ *         and a buffer of the indicated length would need to be passed in
+ * @see ucnv_toUnicode
+ * @see ucnv_convert
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_toUChars(UConverter *cnv,
+              UChar *dest, int32_t destCapacity,
+              const char *src, int32_t srcLength,
+              UErrorCode *pErrorCode);
+
+/**
+ * Convert a codepage buffer into Unicode one character at a time.
+ * The input is completely consumed when the U_INDEX_OUTOFBOUNDS_ERROR is set.
+ *
+ * Advantage compared to ucnv_toUnicode() or ucnv_toUChars():
+ * - Faster for small amounts of data, for most converters, e.g.,
+ *   US-ASCII, ISO-8859-1, UTF-8/16/32, and most "normal" charsets.
+ *   (For complex converters, e.g., SCSU, UTF-7 and ISO 2022 variants,
+ *    it uses ucnv_toUnicode() internally.)
+ * - Convenient.
+ *
+ * Limitations compared to ucnv_toUnicode():
+ * - Always assumes flush=TRUE.
+ *   This makes ucnv_getNextUChar() unsuitable for "streaming" conversion,
+ *   that is, for where the input is supplied in multiple buffers,
+ *   because ucnv_getNextUChar() will assume the end of the input at the end
+ *   of the first buffer.
+ * - Does not provide offset output.
+ *
+ * It is possible to "mix" ucnv_getNextUChar() and ucnv_toUnicode() because
+ * ucnv_getNextUChar() uses the current state of the converter
+ * (unlike ucnv_toUChars() which always resets first).
+ * However, if ucnv_getNextUChar() is called after ucnv_toUnicode()
+ * stopped in the middle of a character sequence (with flush=FALSE),
+ * then ucnv_getNextUChar() will always use the slower ucnv_toUnicode()
+ * internally until the next character boundary.
+ * (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to
+ * start at a character boundary.)
+ *
+ * Instead of using ucnv_getNextUChar(), it is recommended
+ * to convert using ucnv_toUnicode() or ucnv_toUChars()
+ * and then iterate over the text using U16_NEXT() or a UCharIterator (uiter.h)
+ * or a C++ CharacterIterator or similar.
+ * This allows streaming conversion and offset output, for example.
+ *
+ * <p>Handling of surrogate pairs and supplementary-plane code points:<br>
+ * There are two different kinds of codepages that provide mappings for surrogate characters:
+ * <ul>
+ *   <li>Codepages like UTF-8, UTF-32, and GB 18030 provide direct representations for Unicode
+ *       code points U+10000-U+10ffff as well as for single surrogates U+d800-U+dfff.
+ *       Each valid sequence will result in exactly one returned code point.
+ *       If a sequence results in a single surrogate, then that will be returned
+ *       by itself, even if a neighboring sequence encodes the matching surrogate.</li>
+ *   <li>Codepages like SCSU and LMBCS (and UTF-16) provide direct representations only for BMP code points
+ *       including surrogates. Code points in supplementary planes are represented with
+ *       two sequences, each encoding a surrogate.
+ *       For these codepages, matching pairs of surrogates will be combined into single
+ *       code points for returning from this function.
+ *       (Note that SCSU is actually a mix of these codepage types.)</li>
+ * </ul></p>
+ *
+ * @param converter an open UConverter
+ * @param source the address of a pointer to the codepage buffer, will be
+ *  updated to point after the bytes consumed in the conversion call.
+ * @param sourceLimit points to the end of the input buffer
+ * @param err fills in error status (see ucnv_toUnicode)
+ * <code>U_INDEX_OUTOFBOUNDS_ERROR</code> will be set if the input 
+ * is empty or does not convert to any output (e.g.: pure state-change 
+ * codes SI/SO, escape sequences for ISO 2022,
+ * or if the callback did not output anything, ...).
+ * This function will not set a <code>U_BUFFER_OVERFLOW_ERROR</code> because
+ *  the "buffer" is the return code. However, there might be subsequent output
+ *  stored in the converter object
+ * that will be returned in following calls to this function.
+ * @return a UChar32 resulting from the partial conversion of source
+ * @see ucnv_toUnicode
+ * @see ucnv_toUChars
+ * @see ucnv_convert
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+ucnv_getNextUChar(UConverter * converter,
+                  const char **source,
+                  const char * sourceLimit,
+                  UErrorCode * err);
+
+/**
+ * Convert from one external charset to another using two existing UConverters.
+ * Internally, two conversions - ucnv_toUnicode() and ucnv_fromUnicode() -
+ * are used, "pivoting" through 16-bit Unicode.
+ *
+ * Important: For streaming conversion (multiple function calls for successive
+ * parts of a text stream), the caller must provide a pivot buffer explicitly,
+ * and must preserve the pivot buffer and associated pointers from one
+ * call to another. (The buffer may be moved if its contents and the relative
+ * pointer positions are preserved.)
+ *
+ * There is a similar function, ucnv_convert(),
+ * which has the following limitations:
+ * - it takes charset names, not converter objects, so that
+ *   - two converters are opened for each call
+ *   - only single-string conversion is possible, not streaming operation
+ * - it does not provide enough information to find out,
+ *   in case of failure, whether the toUnicode or
+ *   the fromUnicode conversion failed
+ *
+ * By contrast, ucnv_convertEx()
+ * - takes UConverter parameters instead of charset names
+ * - fully exposes the pivot buffer for streaming conversion and complete error handling
+ *
+ * ucnv_convertEx() also provides further convenience:
+ * - an option to reset the converters at the beginning
+ *   (if reset==TRUE, see parameters;
+ *    also sets *pivotTarget=*pivotSource=pivotStart)
+ * - allow NUL-terminated input
+ *   (only a single NUL byte, will not work for charsets with multi-byte NULs)
+ *   (if sourceLimit==NULL, see parameters)
+ * - terminate with a NUL on output
+ *   (only a single NUL byte, not useful for charsets with multi-byte NULs),
+ *   or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills
+ *   the target buffer
+ * - the pivot buffer can be provided internally;
+ *   possible only for whole-string conversion, not streaming conversion;
+ *   in this case, the caller will not be able to get details about where an
+ *   error occurred
+ *   (if pivotStart==NULL, see below)
+ *
+ * The function returns when one of the following is true:
+ * - the entire source text has been converted successfully to the target buffer
+ * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)
+ * - a conversion error occurred
+ *   (other U_FAILURE(), see description of pErrorCode)
+ *
+ * Limitation compared to the direct use of
+ * ucnv_fromUnicode() and ucnv_toUnicode():
+ * ucnv_convertEx() does not provide offset information.
+ *
+ * Limitation compared to ucnv_fromUChars() and ucnv_toUChars():
+ * ucnv_convertEx() does not support preflighting directly.
+ *
+ * Sample code for converting a single string from
+ * one external charset to UTF-8, ignoring the location of errors:
+ *
+ * \code
+ * int32_t
+ * myToUTF8(UConverter *cnv,
+ *          const char *s, int32_t length,
+ *          char *u8, int32_t capacity,
+ *          UErrorCode *pErrorCode) {
+ *     UConverter *utf8Cnv;
+ *     char *target;
+ *
+ *     if(U_FAILURE(*pErrorCode)) {
+ *         return 0;
+ *     }
+ *
+ *     utf8Cnv=myGetCachedUTF8Converter(pErrorCode);
+ *     if(U_FAILURE(*pErrorCode)) {
+ *         return 0;
+ *     }
+ *
+ *     if(length<0) {
+ *         length=strlen(s);
+ *     }
+ *     target=u8;
+ *     ucnv_convertEx(cnv, utf8Cnv,
+ *                    &target, u8+capacity,
+ *                    &s, s+length,
+ *                    NULL, NULL, NULL, NULL,
+ *                    TRUE, TRUE,
+ *                    pErrorCode);
+ * 
+ *     myReleaseCachedUTF8Converter(utf8Cnv);
+ *
+ *     // return the output string length, but without preflighting
+ *     return (int32_t)(target-u8);
+ * }
+ * \endcode
+ *
+ * @param targetCnv     Output converter, used to convert from the UTF-16 pivot
+ *                      to the target using ucnv_fromUnicode().
+ * @param sourceCnv     Input converter, used to convert from the source to
+ *                      the UTF-16 pivot using ucnv_toUnicode().
+ * @param target        I/O parameter, same as for ucnv_fromUChars().
+ *                      Input: *target points to the beginning of the target buffer.
+ *                      Output: *target points to the first unit after the last char written.
+ * @param targetLimit   Pointer to the first unit after the target buffer.
+ * @param source        I/O parameter, same as for ucnv_toUChars().
+ *                      Input: *source points to the beginning of the source buffer.
+ *                      Output: *source points to the first unit after the last char read.
+ * @param sourceLimit   Pointer to the first unit after the source buffer.
+ * @param pivotStart    Pointer to the UTF-16 pivot buffer. If pivotStart==NULL,
+ *                      then an internal buffer is used and the other pivot
+ *                      arguments are ignored and can be NULL as well.
+ * @param pivotSource   I/O parameter, same as source in ucnv_fromUChars() for
+ *                      conversion from the pivot buffer to the target buffer.
+ * @param pivotTarget   I/O parameter, same as target in ucnv_toUChars() for
+ *                      conversion from the source buffer to the pivot buffer.
+ *                      It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit
+ *                      and pivotStart<pivotLimit (unless pivotStart==NULL).
+ * @param pivotLimit    Pointer to the first unit after the pivot buffer.
+ * @param reset         If TRUE, then ucnv_resetToUnicode(sourceCnv) and
+ *                      ucnv_resetFromUnicode(targetCnv) are called, and the
+ *                      pivot pointers are reset (*pivotTarget=*pivotSource=pivotStart).
+ * @param flush         If true, indicates the end of the input.
+ *                      Passed directly to ucnv_toUnicode(), and carried over to
+ *                      ucnv_fromUnicode() when the source is empty as well.
+ * @param pErrorCode    ICU error code in/out parameter.
+ *                      Must fulfill U_SUCCESS before the function call.
+ *                      U_BUFFER_OVERFLOW_ERROR always refers to the target buffer
+ *                      because overflows into the pivot buffer are handled internally.
+ *                      Other conversion errors are from the source-to-pivot
+ *                      conversion if *pivotSource==pivotStart, otherwise from
+ *                      the pivot-to-target conversion.
+ *
+ * @see ucnv_convert
+ * @see ucnv_fromAlgorithmic
+ * @see ucnv_toAlgorithmic
+ * @see ucnv_fromUnicode
+ * @see ucnv_toUnicode
+ * @see ucnv_fromUChars
+ * @see ucnv_toUChars
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
+               char **target, const char *targetLimit,
+               const char **source, const char *sourceLimit,
+               UChar *pivotStart, UChar **pivotSource,
+               UChar **pivotTarget, const UChar *pivotLimit,
+               UBool reset, UBool flush,
+               UErrorCode *pErrorCode);
+
+/**
+ * Convert from one external charset to another.
+ * Internally, two converters are opened according to the name arguments,
+ * then the text is converted to and from the 16-bit Unicode "pivot"
+ * using ucnv_convertEx(), then the converters are closed again.
+ *
+ * This is a convenience function, not an efficient way to convert a lot of text:
+ * ucnv_convert()
+ * - takes charset names, not converter objects, so that
+ *   - two converters are opened for each call
+ *   - only single-string conversion is possible, not streaming operation
+ * - does not provide enough information to find out,
+ *   in case of failure, whether the toUnicode or
+ *   the fromUnicode conversion failed
+ * - allows NUL-terminated input
+ *   (only a single NUL byte, will not work for charsets with multi-byte NULs)
+ *   (if sourceLength==-1, see parameters)
+ * - terminate with a NUL on output
+ *   (only a single NUL byte, not useful for charsets with multi-byte NULs),
+ *   or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills
+ *   the target buffer
+ * - a pivot buffer is provided internally
+ *
+ * The function returns when one of the following is true:
+ * - the entire source text has been converted successfully to the target buffer
+ *   and either the target buffer is terminated with a single NUL byte
+ *   or the error code is set to U_STRING_NOT_TERMINATED_WARNING
+ * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)
+ *   and the full output string length is returned ("preflighting")
+ * - a conversion error occurred
+ *   (other U_FAILURE(), see description of pErrorCode)
+ *
+ * @param toConverterName   The name of the converter that is used to convert
+ *                          from the UTF-16 pivot buffer to the target.
+ * @param fromConverterName The name of the converter that is used to convert
+ *                          from the source to the UTF-16 pivot buffer.
+ * @param target            Pointer to the output buffer.
+ * @param targetCapacity    Capacity of the target, in bytes.
+ * @param source            Pointer to the input buffer.
+ * @param sourceLength      Length of the input text, in bytes, or -1 for NUL-terminated input.
+ * @param pErrorCode        ICU error code in/out parameter.
+ *                          Must fulfill U_SUCCESS before the function call.
+ * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
+ *         and a U_BUFFER_OVERFLOW_ERROR is set.
+ *
+ * @see ucnv_convertEx
+ * @see ucnv_fromAlgorithmic
+ * @see ucnv_toAlgorithmic
+ * @see ucnv_fromUnicode
+ * @see ucnv_toUnicode
+ * @see ucnv_fromUChars
+ * @see ucnv_toUChars
+ * @see ucnv_getNextUChar
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_convert(const char *toConverterName,
+             const char *fromConverterName,
+             char *target,
+             int32_t targetCapacity,
+             const char *source,
+             int32_t sourceLength,
+             UErrorCode *pErrorCode);
+
+/**
+ * Convert from one external charset to another.
+ * Internally, the text is converted to and from the 16-bit Unicode "pivot"
+ * using ucnv_convertEx(). ucnv_toAlgorithmic() works exactly like ucnv_convert()
+ * except that the two converters need not be looked up and opened completely.
+ *
+ * The source-to-pivot conversion uses the cnv converter parameter.
+ * The pivot-to-target conversion uses a purely algorithmic converter
+ * according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.
+ *
+ * Internally, the algorithmic converter is opened and closed for each
+ * function call, which is more efficient than using the public ucnv_open()
+ * but somewhat less efficient than only resetting an existing converter
+ * and using ucnv_convertEx().
+ *
+ * This function is more convenient than ucnv_convertEx() for single-string
+ * conversions, especially when "preflighting" is desired (returning the length
+ * of the complete output even if it does not fit into the target buffer;
+ * see the User Guide Strings chapter). See ucnv_convert() for details.
+ *
+ * @param algorithmicType   UConverterType constant identifying the desired target
+ *                          charset as a purely algorithmic converter.
+ *                          Those are converters for Unicode charsets like
+ *                          UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,
+ *                          as well as US-ASCII and ISO-8859-1.
+ * @param cnv               The converter that is used to convert
+ *                          from the source to the UTF-16 pivot buffer.
+ * @param target            Pointer to the output buffer.
+ * @param targetCapacity    Capacity of the target, in bytes.
+ * @param source            Pointer to the input buffer.
+ * @param sourceLength      Length of the input text, in bytes
+ * @param pErrorCode        ICU error code in/out parameter.
+ *                          Must fulfill U_SUCCESS before the function call.
+ * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
+ *         and a U_BUFFER_OVERFLOW_ERROR is set.
+ *
+ * @see ucnv_fromAlgorithmic
+ * @see ucnv_convert
+ * @see ucnv_convertEx
+ * @see ucnv_fromUnicode
+ * @see ucnv_toUnicode
+ * @see ucnv_fromUChars
+ * @see ucnv_toUChars
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_toAlgorithmic(UConverterType algorithmicType,
+                   UConverter *cnv,
+                   char *target, int32_t targetCapacity,
+                   const char *source, int32_t sourceLength,
+                   UErrorCode *pErrorCode);
+
+/**
+ * Convert from one external charset to another.
+ * Internally, the text is converted to and from the 16-bit Unicode "pivot"
+ * using ucnv_convertEx(). ucnv_fromAlgorithmic() works exactly like ucnv_convert()
+ * except that the two converters need not be looked up and opened completely.
+ *
+ * The source-to-pivot conversion uses a purely algorithmic converter
+ * according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.
+ * The pivot-to-target conversion uses the cnv converter parameter.
+ *
+ * Internally, the algorithmic converter is opened and closed for each
+ * function call, which is more efficient than using the public ucnv_open()
+ * but somewhat less efficient than only resetting an existing converter
+ * and using ucnv_convertEx().
+ *
+ * This function is more convenient than ucnv_convertEx() for single-string
+ * conversions, especially when "preflighting" is desired (returning the length
+ * of the complete output even if it does not fit into the target buffer;
+ * see the User Guide Strings chapter). See ucnv_convert() for details.
+ *
+ * @param cnv               The converter that is used to convert
+ *                          from the UTF-16 pivot buffer to the target.
+ * @param algorithmicType   UConverterType constant identifying the desired source
+ *                          charset as a purely algorithmic converter.
+ *                          Those are converters for Unicode charsets like
+ *                          UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,
+ *                          as well as US-ASCII and ISO-8859-1.
+ * @param target            Pointer to the output buffer.
+ * @param targetCapacity    Capacity of the target, in bytes.
+ * @param source            Pointer to the input buffer.
+ * @param sourceLength      Length of the input text, in bytes
+ * @param pErrorCode        ICU error code in/out parameter.
+ *                          Must fulfill U_SUCCESS before the function call.
+ * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
+ *         and a U_BUFFER_OVERFLOW_ERROR is set.
+ *
+ * @see ucnv_fromAlgorithmic
+ * @see ucnv_convert
+ * @see ucnv_convertEx
+ * @see ucnv_fromUnicode
+ * @see ucnv_toUnicode
+ * @see ucnv_fromUChars
+ * @see ucnv_toUChars
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_fromAlgorithmic(UConverter *cnv,
+                     UConverterType algorithmicType,
+                     char *target, int32_t targetCapacity,
+                     const char *source, int32_t sourceLength,
+                     UErrorCode *pErrorCode);
+
+/**
+ * Frees up memory occupied by unused, cached converter shared data.
+ *
+ * @return the number of cached converters successfully deleted
+ * @see ucnv_close
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_flushCache(void);
+
+/**
+ * Returns the number of available converters, as per the alias file.
+ *
+ * @return the number of available converters
+ * @see ucnv_getAvailableName
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_countAvailable(void);
+
+/**
+ * Gets the canonical converter name of the specified converter from a list of
+ * all available converters contaied in the alias file. All converters
+ * in this list can be opened.
+ *
+ * @param n the index to a converter available on the system (in the range <TT>[0..ucnv_countAvaiable()]</TT>)
+ * @return a pointer a string (library owned), or <TT>NULL</TT> if the index is out of bounds.
+ * @see ucnv_countAvailable
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2
+ucnv_getAvailableName(int32_t n);
+
+/**
+ * Returns a UEnumeration to enumerate all of the canonical converter
+ * names, as per the alias file, regardless of the ability to open each
+ * converter.
+ *
+ * @return A UEnumeration object for getting all the recognized canonical
+ *   converter names.
+ * @see ucnv_getAvailableName
+ * @see uenum_close
+ * @see uenum_next
+ * @stable ICU 2.4
+ */
+U_STABLE UEnumeration * U_EXPORT2
+ucnv_openAllNames(UErrorCode *pErrorCode);
+
+/**
+ * Gives the number of aliases for a given converter or alias name.
+ * If the alias is ambiguous, then the preferred converter is used
+ * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
+ * This method only enumerates the listed entries in the alias file.
+ * @param alias alias name
+ * @param pErrorCode error status
+ * @return number of names on alias list for given alias
+ * @stable ICU 2.0
+ */
+U_STABLE uint16_t U_EXPORT2 
+ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
+
+/**
+ * Gives the name of the alias at given index of alias list.
+ * This method only enumerates the listed entries in the alias file.
+ * If the alias is ambiguous, then the preferred converter is used
+ * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
+ * @param alias alias name
+ * @param n index in alias list
+ * @param pErrorCode result of operation
+ * @return returns the name of the alias at given index
+ * @see ucnv_countAliases
+ * @stable ICU 2.0
+ */
+U_STABLE const char * U_EXPORT2 
+ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
+
+/**
+ * Fill-up the list of alias names for the given alias.
+ * This method only enumerates the listed entries in the alias file.
+ * If the alias is ambiguous, then the preferred converter is used
+ * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
+ * @param alias alias name
+ * @param aliases fill-in list, aliases is a pointer to an array of
+ *        <code>ucnv_countAliases()</code> string-pointers
+ *        (<code>const char *</code>) that will be filled in.
+ *        The strings themselves are owned by the library.
+ * @param pErrorCode result of operation
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
+
+/**
+ * Return a new UEnumeration object for enumerating all the
+ * alias names for a given converter that are recognized by a standard.
+ * This method only enumerates the listed entries in the alias file.
+ * The convrtrs.txt file can be modified to change the results of
+ * this function.
+ * The first result in this list is the same result given by
+ * <code>ucnv_getStandardName</code>, which is the default alias for
+ * the specified standard name. The returned object must be closed with
+ * <code>uenum_close</code> when you are done with the object.
+ *
+ * @param convName original converter name
+ * @param standard name of the standard governing the names; MIME and IANA
+ *      are such standards
+ * @param pErrorCode The error code
+ * @return A UEnumeration object for getting all aliases that are recognized
+ *      by a standard. If any of the parameters are invalid, NULL
+ *      is returned.
+ * @see ucnv_getStandardName
+ * @see uenum_close
+ * @see uenum_next
+ * @stable ICU 2.2
+ */
+U_STABLE UEnumeration * U_EXPORT2
+ucnv_openStandardNames(const char *convName,
+                       const char *standard,
+                       UErrorCode *pErrorCode);
+
+/**
+ * Gives the number of standards associated to converter names.
+ * @return number of standards
+ * @stable ICU 2.0
+ */
+U_STABLE uint16_t U_EXPORT2
+ucnv_countStandards(void);
+
+/**
+ * Gives the name of the standard at given index of standard list.
+ * @param n index in standard list
+ * @param pErrorCode result of operation
+ * @return returns the name of the standard at given index. Owned by the library.
+ * @stable ICU 2.0
+ */
+U_STABLE const char * U_EXPORT2
+ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
+
+/**
+ * Returns a standard name for a given converter name.
+ * <p>
+ * Example alias table:<br>
+ * conv alias1 { STANDARD1 } alias2 { STANDARD1* }
+ * <p>
+ * Result of ucnv_getStandardName("conv", "STANDARD1") from example
+ * alias table:<br>
+ * <b>"alias2"</b>
+ *
+ * @param name original converter name
+ * @param standard name of the standard governing the names; MIME and IANA
+ *        are such standards
+ * @param pErrorCode result of operation
+ * @return returns the standard converter name;
+ *         if a standard converter name cannot be determined,
+ *         then <code>NULL</code> is returned. Owned by the library.
+ * @stable ICU 2.0
+ */
+U_STABLE const char * U_EXPORT2
+ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
+
+/**
+ * This function will return the internal canonical converter name of the
+ * tagged alias. This is the opposite of ucnv_openStandardNames, which
+ * returns the tagged alias given the canonical name.
+ * <p>
+ * Example alias table:<br>
+ * conv alias1 { STANDARD1 } alias2 { STANDARD1* }
+ * <p>
+ * Result of ucnv_getStandardName("alias1", "STANDARD1") from example
+ * alias table:<br>
+ * <b>"conv"</b>
+ *
+ * @return returns the canonical converter name;
+ *         if a standard or alias name cannot be determined,
+ *         then <code>NULL</code> is returned. The returned string is
+ *         owned by the library.
+ * @see ucnv_getStandardName
+ * @stable ICU 2.4
+ */
+U_STABLE const char * U_EXPORT2
+ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
+
+/**
+ * Returns the current default converter name. If you want to open
+ * a default converter, you do not need to use this function.
+ * It is faster if you pass a NULL argument to ucnv_open the
+ * default converter.
+ *
+ * @return returns the current default converter name.
+ *         Storage owned by the library
+ * @see ucnv_setDefaultName
+ * @stable ICU 2.0
+ */
+U_STABLE const char * U_EXPORT2
+ucnv_getDefaultName(void);
+
+/**
+ * This function is not thread safe. DO NOT call this function when ANY ICU
+ * function is being used from more than one thread! This function sets the
+ * current default converter name. If this function needs to be called, it
+ * should be called during application initialization. Most of the time, the
+ * results from ucnv_getDefaultName() or ucnv_open with a NULL string argument
+ * is sufficient for your application.
+ * @param name the converter name to be the default (must be known by ICU).
+ * @see ucnv_getDefaultName
+ * @system
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_setDefaultName(const char *name);
+
+/**
+ * Fixes the backslash character mismapping.  For example, in SJIS, the backslash 
+ * character in the ASCII portion is also used to represent the yen currency sign.  
+ * When mapping from Unicode character 0x005C, it's unclear whether to map the 
+ * character back to yen or backslash in SJIS.  This function will take the input
+ * buffer and replace all the yen sign characters with backslash.  This is necessary
+ * when the user tries to open a file with the input buffer on Windows.
+ * This function will test the converter to see whether such mapping is
+ * required.  You can sometimes avoid using this function by using the correct version
+ * of Shift-JIS.
+ *
+ * @param cnv The converter representing the target codepage.
+ * @param source the input buffer to be fixed
+ * @param sourceLen the length of the input buffer
+ * @see ucnv_isAmbiguous
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
+
+/**
+ * Determines if the converter contains ambiguous mappings of the same
+ * character or not.
+ * @param cnv the converter to be tested
+ * @return TRUE if the converter contains ambiguous mapping of the same 
+ * character, FALSE otherwise.
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2
+ucnv_isAmbiguous(const UConverter *cnv);
+
+/**
+ * Sets the converter to use fallback mappings or not.
+ * Regardless of this flag, the converter will always use
+ * fallbacks from Unicode Private Use code points, as well as
+ * reverse fallbacks (to Unicode).
+ * For details see ".ucm File Format"
+ * in the Conversion Data chapter of the ICU User Guide:
+ * http://www.icu-project.org/userguide/conversion-data.html#ucmformat
+ *
+ * @param cnv The converter to set the fallback mapping usage on.
+ * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback 
+ * mapping, FALSE otherwise.
+ * @stable ICU 2.0
+ * @see ucnv_usesFallback
+ */
+U_STABLE void U_EXPORT2 
+ucnv_setFallback(UConverter *cnv, UBool usesFallback);
+
+/**
+ * Determines if the converter uses fallback mappings or not.
+ * This flag has restrictions, see ucnv_setFallback().
+ *
+ * @param cnv The converter to be tested
+ * @return TRUE if the converter uses fallback, FALSE otherwise.
+ * @stable ICU 2.0
+ * @see ucnv_setFallback
+ */
+U_STABLE UBool U_EXPORT2 
+ucnv_usesFallback(const UConverter *cnv);
+
+/**
+ * Detects Unicode signature byte sequences at the start of the byte stream
+ * and returns the charset name of the indicated Unicode charset.
+ * NULL is returned when no Unicode signature is recognized.
+ * The number of bytes in the signature is output as well.
+ *
+ * The caller can ucnv_open() a converter using the charset name.
+ * The first code unit (UChar) from the start of the stream will be U+FEFF
+ * (the Unicode BOM/signature character) and can usually be ignored.
+ *
+ * For most Unicode charsets it is also possible to ignore the indicated
+ * number of initial stream bytes and start converting after them.
+ * However, there are stateful Unicode charsets (UTF-7 and BOCU-1) for which
+ * this will not work. Therefore, it is best to ignore the first output UChar
+ * instead of the input signature bytes.
+ * <p>
+ * Usage:
+ * @code     
+ *      UErrorCode err = U_ZERO_ERROR;
+ *      char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' };
+ *      int32_t signatureLength = 0;
+ *      char *encoding = ucnv_detectUnicodeSignature(input,sizeof(input),&signatureLength,&err);
+ *      UConverter *conv = NULL;
+ *      UChar output[100];
+ *      UChar *target = output, *out;
+ *      char *source = input;
+ *      if(encoding!=NULL && U_SUCCESS(err)){
+ *          // should signature be discarded ?
+ *          conv = ucnv_open(encoding, &err);
+ *          // do the conversion
+ *          ucnv_toUnicode(conv,
+ *                         target, output + sizeof(output)/U_SIZEOF_UCHAR,
+ *                         source, input + sizeof(input),
+ *                         NULL, TRUE, &err);
+ *          out = output;
+ *          if (discardSignature){
+ *              ++out; // ignore initial U+FEFF
+ *          }
+ *          while(out != target) {
+ *              printf("%04x ", *out++);
+ *          }
+ *          puts("");
+ *      }
+ *     
+ * @endcode
+ *
+ * @param source            The source string in which the signature should be detected.
+ * @param sourceLength      Length of the input string, or -1 if terminated with a NUL byte.
+ * @param signatureLength   A pointer to int32_t to receive the number of bytes that make up the signature 
+ *                          of the detected UTF. 0 if not detected.
+ *                          Can be a NULL pointer.
+ * @param pErrorCode        ICU error code in/out parameter.
+ *                          Must fulfill U_SUCCESS before the function call.
+ * @return The name of the encoding detected. NULL if encoding is not detected. 
+ * @stable ICU 2.4
+ */
+U_STABLE const char* U_EXPORT2
+ucnv_detectUnicodeSignature(const char* source,
+                            int32_t sourceLength,
+                            int32_t *signatureLength,
+                            UErrorCode *pErrorCode);
+
+/**
+ * Returns the number of UChars held in the converter's internal state 
+ * because more input is needed for completing the conversion. This function is 
+ * useful for mapping semantics of ICU's converter interface to those of iconv,
+ * and this information is not needed for normal conversion.
+ * @param cnv       The converter in which the input is held
+ * @param status    ICU error code in/out parameter.
+ *                  Must fulfill U_SUCCESS before the function call.
+ * @return The number of UChars in the state. -1 if an error is encountered.
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
+
+/**
+ * Returns the number of chars held in the converter's internal state
+ * because more input is needed for completing the conversion. This function is 
+ * useful for mapping semantics of ICU's converter interface to those of iconv,
+ * and this information is not needed for normal conversion.
+ * @param cnv       The converter in which the input is held as internal state
+ * @param status    ICU error code in/out parameter.
+ *                  Must fulfill U_SUCCESS before the function call.
+ * @return The number of chars in the state. -1 if an error is encountered.
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
+
+#endif
+
+#endif
+/*_UCNV*/
diff --git a/CoreFoundation/icu/unicode/ucnv_cb.h b/CoreFoundation/icu/unicode/ucnv_cb.h
new file mode 100644
index 0000000..f0e67ba
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucnv_cb.h
@@ -0,0 +1,162 @@
+/*
+**********************************************************************
+*   Copyright (C) 2000-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+ *  ucnv_cb.h:
+ *  External APIs for the ICU's codeset conversion library
+ *  Helena Shih
+ * 
+ * Modification History:
+ *
+ *   Date        Name        Description
+ */
+
+/**
+ * \file 
+ * \brief C UConverter functions to aid the writers of callbacks
+ *
+ * <h2> Callback API for UConverter </h2>
+ * 
+ * These functions are provided here for the convenience of the callback
+ * writer. If you are just looking for callback functions to use, please
+ * see ucnv_err.h.  DO NOT call these functions directly when you are 
+ * working with converters, unless your code has been called as a callback
+ * via ucnv_setFromUCallback or ucnv_setToUCallback !!
+ * 
+ * A note about error codes and overflow.  Unlike other ICU functions,
+ * these functions do not expect the error status to be U_ZERO_ERROR.
+ * Callbacks must be much more careful about their error codes.
+ * The error codes used here are in/out parameters, which should be passed
+ * back in the callback's error parameter.
+ * 
+ * For example, if you call ucnv_cbfromUWriteBytes to write data out 
+ * to the output codepage, it may return U_BUFFER_OVERFLOW_ERROR if 
+ * the data did not fit in the target. But this isn't a failing error, 
+ * in fact, ucnv_cbfromUWriteBytes may be called AGAIN with the error
+ * status still U_BUFFER_OVERFLOW_ERROR to attempt to write further bytes,
+ * which will also go into the internal overflow buffers.
+ * 
+ * Concerning offsets, the 'offset' parameters here are relative to the start
+ * of SOURCE.  For example, Suppose the string "ABCD" was being converted 
+ * from Unicode into a codepage which doesn't have a mapping for 'B'.
+ * 'A' will be written out correctly, but
+ * The FromU Callback will be called on an unassigned character for 'B'.
+ * At this point, this is the state of the world:
+ *    Target:    A [..]     [points after A]
+ *    Source:  A B [C] D    [points to C - B has been consumed]
+ *             0 1  2  3 
+ *    codePoint = "B"       [the unassigned codepoint] 
+ * 
+ * Now, suppose a callback wants to write the substitution character '?' to
+ * the target. It calls ucnv_cbFromUWriteBytes() to write the ?. 
+ * It should pass ZERO as the offset, because the offset as far as the 
+ * callback is concerned is relative to the SOURCE pointer [which points 
+ * before 'C'.]  If the callback goes into the args and consumes 'C' also,
+ * it would call FromUWriteBytes with an offset of 1 (and advance the source
+ * pointer).
+ *
+ */
+
+#ifndef UCNV_CB_H
+#define UCNV_CB_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_CONVERSION
+
+#include "unicode/ucnv.h"
+#include "unicode/ucnv_err.h"
+
+/**
+ * ONLY used by FromU callback functions.
+ * Writes out the specified byte output bytes to the target byte buffer or to converter internal buffers.
+ *
+ * @param args callback fromUnicode arguments
+ * @param source source bytes to write
+ * @param length length of bytes to write
+ * @param offsetIndex the relative offset index from callback.
+ * @param err error status. If <TT>U_BUFFER_OVERFLOW</TT> is returned, then U_BUFFER_OVERFLOW <STRONG>must</STRONG> 
+ * be returned to the user, because it means that not all data could be written into the target buffer, and some is 
+ * in the converter error buffer.
+ * @see ucnv_cbFromUWriteSub
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args,
+                        const char* source,
+                        int32_t length,
+                        int32_t offsetIndex,
+                        UErrorCode * err);
+
+/**
+ * ONLY used by FromU callback functions.  
+ * This function will write out the correct substitution character sequence 
+ * to the target.
+ *
+ * @param args callback fromUnicode arguments
+ * @param offsetIndex the relative offset index from the current source pointer to be used
+ * @param err error status. If <TT>U_BUFFER_OVERFLOW</TT> is returned, then U_BUFFER_OVERFLOW <STRONG>must</STRONG> 
+ * be returned to the user, because it means that not all data could be written into the target buffer, and some is 
+ * in the converter error buffer.
+ * @see ucnv_cbFromUWriteBytes
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args,
+                      int32_t offsetIndex,
+                      UErrorCode * err);
+
+/**
+ * ONLY used by fromU callback functions.  
+ * This function will write out the error character(s) to the target UChar buffer.
+ *
+ * @param args callback fromUnicode arguments
+ * @param source pointer to pointer to first UChar to write [on exit: 1 after last UChar processed]
+ * @param sourceLimit pointer after last UChar to write
+ * @param offsetIndex the relative offset index from callback which will be set
+ * @param err error status <TT>U_BUFFER_OVERFLOW</TT>
+ * @see ucnv_cbToUWriteSub
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,
+                             const UChar** source,
+                             const UChar*  sourceLimit,
+                             int32_t offsetIndex,
+                             UErrorCode * err);
+
+/**
+ * ONLY used by ToU callback functions.
+ *  This function will write out the specified characters to the target 
+ * UChar buffer.
+ *
+ * @param args callback toUnicode arguments
+ * @param source source string to write
+ * @param length the length of source string
+ * @param offsetIndex the relative offset index which will be written.
+ * @param err error status <TT>U_BUFFER_OVERFLOW</TT>
+ * @see ucnv_cbToUWriteSub
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,
+                                             const UChar* source,
+                                             int32_t length,
+                                             int32_t offsetIndex,
+                                             UErrorCode * err);
+
+/**
+ * ONLY used by ToU  callback functions.  
+ * This function will write out the Unicode substitution character (U+FFFD).
+ *
+ * @param args callback fromUnicode arguments
+ * @param offsetIndex the relative offset index from callback.
+ * @param err error status <TT>U_BUFFER_OVERFLOW</TT>
+ * @see ucnv_cbToUWriteUChars
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 ucnv_cbToUWriteSub (UConverterToUnicodeArgs *args,
+                       int32_t offsetIndex,
+                       UErrorCode * err);
+#endif
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ucnv_err.h b/CoreFoundation/icu/unicode/ucnv_err.h
new file mode 100644
index 0000000..6fde696
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucnv_err.h
@@ -0,0 +1,463 @@
+/*
+**********************************************************************
+*   Copyright (C) 1999-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+ *
+ *
+ *   ucnv_err.h:
+ */
+
+/**
+ * \file
+ * \brief C UConverter predefined error callbacks
+ *
+ *  <h2>Error Behaviour Functions</h2>
+ *  Defines some error behaviour functions called by ucnv_{from,to}Unicode
+ *  These are provided as part of ICU and many are stable, but they
+ *  can also be considered only as an example of what can be done with
+ *  callbacks.  You may of course write your own.
+ *
+ *  If you want to write your own, you may also find the functions from
+ *  ucnv_cb.h useful when writing your own callbacks.
+ *
+ *  These functions, although public, should NEVER be called directly.
+ *  They should be used as parameters to the ucnv_setFromUCallback
+ *  and ucnv_setToUCallback functions, to set the behaviour of a converter
+ *  when it encounters ILLEGAL/UNMAPPED/INVALID sequences.
+ *
+ *  usage example:  'STOP' doesn't need any context, but newContext
+ *    could be set to something other than 'NULL' if needed. The available
+ *    contexts in this header can modify the default behavior of the callback.
+ *
+ *  \code
+ *  UErrorCode err = U_ZERO_ERROR;
+ *  UConverter *myConverter = ucnv_open("ibm-949", &err);
+ *  const void *oldContext;
+ *  UConverterFromUCallback oldAction;
+ *
+ *
+ *  if (U_SUCCESS(err))
+ *  {
+ *      ucnv_setFromUCallBack(myConverter,
+ *                       UCNV_FROM_U_CALLBACK_STOP,
+ *                       NULL,
+ *                       &oldAction,
+ *                       &oldContext,
+ *                       &status);
+ *  }
+ *  \endcode
+ *
+ *  The code above tells "myConverter" to stop when it encounters an
+ *  ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from
+ *  Unicode -> Codepage. The behavior from Codepage to Unicode is not changed,
+ *  and ucnv_setToUCallBack would need to be called in order to change
+ *  that behavior too.
+ *
+ *  Here is an example with a context:
+ *
+ *  \code
+ *  UErrorCode err = U_ZERO_ERROR;
+ *  UConverter *myConverter = ucnv_open("ibm-949", &err);
+ *  const void *oldContext;
+ *  UConverterFromUCallback oldAction;
+ *
+ *
+ *  if (U_SUCCESS(err))
+ *  {
+ *      ucnv_setToUCallBack(myConverter,
+ *                       UCNV_TO_U_CALLBACK_SUBSTITUTE,
+ *                       UCNV_SUB_STOP_ON_ILLEGAL,
+ *                       &oldAction,
+ *                       &oldContext,
+ *                       &status);
+ *  }
+ *  \endcode
+ *
+ *  The code above tells "myConverter" to stop when it encounters an
+ *  ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from
+ *  Codepage -> Unicode. Any unmapped and legal characters will be
+ *  substituted to be the default substitution character.
+ */
+
+#ifndef UCNV_ERR_H
+#define UCNV_ERR_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_CONVERSION
+
+/** Forward declaring the UConverter structure. @stable ICU 2.0 */
+struct UConverter;
+
+/** @stable ICU 2.0 */
+typedef struct UConverter UConverter;
+
+/**
+ * FROM_U, TO_U context options for sub callback
+ * @stable ICU 2.0
+ */
+#define UCNV_SUB_STOP_ON_ILLEGAL "i"
+
+/**
+ * FROM_U, TO_U context options for skip callback
+ * @stable ICU 2.0
+ */
+#define UCNV_SKIP_STOP_ON_ILLEGAL "i"
+
+/**
+ * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX) 
+ * @stable ICU 2.0
+ */
+#define UCNV_ESCAPE_ICU       NULL
+/**
+ * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to JAVA (\\uXXXX)
+ * @stable ICU 2.0
+ */
+#define UCNV_ESCAPE_JAVA      "J"
+/**
+ * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to C (\\uXXXX \\UXXXXXXXX)
+ * TO_U_CALLBACK_ESCAPE option to escape the character value accoding to C (\\xXXXX)
+ * @stable ICU 2.0
+ */
+#define UCNV_ESCAPE_C         "C"
+/**
+ * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Decimal escape \htmlonly(&amp;#DDDD;)\endhtmlonly
+ * TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Decimal escape \htmlonly(&amp;#DDDD;)\endhtmlonly
+ * @stable ICU 2.0
+ */
+#define UCNV_ESCAPE_XML_DEC   "D"
+/**
+ * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Hex escape \htmlonly(&amp;#xXXXX;)\endhtmlonly
+ * TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Hex escape \htmlonly(&amp;#xXXXX;)\endhtmlonly
+ * @stable ICU 2.0
+ */
+#define UCNV_ESCAPE_XML_HEX   "X"
+/**
+ * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to Unicode (U+XXXXX)
+ * @stable ICU 2.0
+ */
+#define UCNV_ESCAPE_UNICODE   "U"
+
+/**
+ * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to CSS2 conventions (\\HH..H<space>, that is,
+ * a backslash, 1..6 hex digits, and a space)
+ * @draft ICU 4.0
+ */
+#define UCNV_ESCAPE_CSS2   "S"
+
+/** 
+ * The process condition code to be used with the callbacks.  
+ * Codes which are greater than UCNV_IRREGULAR should be 
+ * passed on to any chained callbacks.
+ * @stable ICU 2.0
+ */
+typedef enum {
+    UCNV_UNASSIGNED = 0,  /**< The code point is unassigned.
+                             The error code U_INVALID_CHAR_FOUND will be set. */
+    UCNV_ILLEGAL = 1,     /**< The code point is illegal. For example, 
+                             \\x81\\x2E is illegal in SJIS because \\x2E
+                             is not a valid trail byte for the \\x81 
+                             lead byte.
+                             Also, starting with Unicode 3.0.1, non-shortest byte sequences
+                             in UTF-8 (like \\xC1\\xA1 instead of \\x61 for U+0061)
+                             are also illegal, not just irregular.
+                             The error code U_ILLEGAL_CHAR_FOUND will be set. */
+    UCNV_IRREGULAR = 2,   /**< The codepoint is not a regular sequence in 
+                             the encoding. For example, \\xED\\xA0\\x80..\\xED\\xBF\\xBF
+                             are irregular UTF-8 byte sequences for single surrogate
+                             code points.
+                             The error code U_INVALID_CHAR_FOUND will be set. */
+    UCNV_RESET = 3,       /**< The callback is called with this reason when a
+                             'reset' has occured. Callback should reset all
+                             state. */
+    UCNV_CLOSE = 4,        /**< Called when the converter is closed. The
+                             callback should release any allocated memory.*/
+    UCNV_CLONE = 5         /**< Called when ucnv_safeClone() is called on the
+                              converter. the pointer available as the
+                              'context' is an alias to the original converters'
+                              context pointer. If the context must be owned
+                              by the new converter, the callback must clone 
+                              the data and call ucnv_setFromUCallback 
+                              (or setToUCallback) with the correct pointer.
+                              @stable ICU 2.2
+                           */
+} UConverterCallbackReason;
+
+
+/**
+ * The structure for the fromUnicode callback function parameter.
+ * @stable ICU 2.0
+ */
+typedef struct {
+    uint16_t size;              /**< The size of this struct. @stable ICU 2.0 */
+    UBool flush;                /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0    */
+    UConverter *converter;      /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0  */
+    const UChar *source;        /**< Pointer to the source source buffer. @stable ICU 2.0    */
+    const UChar *sourceLimit;   /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0    */
+    char *target;               /**< Pointer to the target buffer. @stable ICU 2.0    */
+    const char *targetLimit;    /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0     */
+    int32_t *offsets;           /**< Pointer to the buffer that recieves the offsets. *offset = blah ; offset++;. @stable ICU 2.0  */
+} UConverterFromUnicodeArgs;
+
+
+/**
+ * The structure for the toUnicode callback function parameter.
+ * @stable ICU 2.0
+ */
+typedef struct {
+    uint16_t size;              /**< The size of this struct   @stable ICU 2.0 */
+    UBool flush;                /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0   */
+    UConverter *converter;      /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */
+    const char *source;         /**< Pointer to the source source buffer. @stable ICU 2.0    */
+    const char *sourceLimit;    /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0    */
+    UChar *target;              /**< Pointer to the target buffer. @stable ICU 2.0    */
+    const UChar *targetLimit;   /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0     */
+    int32_t *offsets;           /**< Pointer to the buffer that recieves the offsets. *offset = blah ; offset++;. @stable ICU 2.0  */
+} UConverterToUnicodeArgs;
+
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This From Unicode callback STOPS at the ILLEGAL_SEQUENCE,
+ * returning the error code back to the caller immediately.
+ *
+ * @param context Pointer to the callback's private data
+ * @param fromUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
+ * @param reason Defines the reason the callback was invoked
+ * @param err This should always be set to a failure status prior to calling.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (
+                  const void *context,
+                  UConverterFromUnicodeArgs *fromUArgs,
+                  const UChar* codeUnits,
+                  int32_t length,
+                  UChar32 codePoint,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This To Unicode callback STOPS at the ILLEGAL_SEQUENCE,
+ * returning the error code back to the caller immediately.
+ *
+ * @param context Pointer to the callback's private data
+ * @param toUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' bytes of the concerned codepage sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param reason Defines the reason the callback was invoked
+ * @param err This should always be set to a failure status prior to calling.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (
+                  const void *context,
+                  UConverterToUnicodeArgs *toUArgs,
+                  const char* codeUnits,
+                  int32_t length,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This From Unicode callback skips any ILLEGAL_SEQUENCE, or
+ * skips only UNASSINGED_SEQUENCE depending on the context parameter
+ * simply ignoring those characters. 
+ *
+ * @param context  The function currently recognizes the callback options:
+ *                 UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,
+ *                      returning the error code back to the caller immediately.
+ *                 NULL: Skips any ILLEGAL_SEQUENCE
+ * @param fromUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
+ * @param reason Defines the reason the callback was invoked
+ * @param err Return value will be set to success if the callback was handled,
+ *      otherwise this value will be set to a failure status.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (
+                  const void *context,
+                  UConverterFromUnicodeArgs *fromUArgs,
+                  const UChar* codeUnits,
+                  int32_t length,
+                  UChar32 codePoint,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or 
+ * UNASSIGNED_SEQUENCE depending on context parameter, with the
+ * current substitution string for the converter. This is the default
+ * callback.
+ *
+ * @param context The function currently recognizes the callback options:
+ *                 UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,
+ *                      returning the error code back to the caller immediately.
+ *                 NULL: Substitutes any ILLEGAL_SEQUENCE
+ * @param fromUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
+ * @param reason Defines the reason the callback was invoked
+ * @param err Return value will be set to success if the callback was handled,
+ *      otherwise this value will be set to a failure status.
+ * @see ucnv_setSubstChars
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
+                  const void *context,
+                  UConverterFromUnicodeArgs *fromUArgs,
+                  const UChar* codeUnits,
+                  int32_t length,
+                  UChar32 codePoint,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This From Unicode callback will Substitute the ILLEGAL SEQUENCE with the
+ * hexadecimal representation of the illegal codepoints
+ *
+ * @param context The function currently recognizes the callback options:
+ *        <ul>
+ *        <li>UCNV_ESCAPE_ICU: Substitues the  ILLEGAL SEQUENCE with the hexadecimal 
+ *          representation in the format  %UXXXX, e.g. "%uFFFE%u00AC%uC8FE"). 
+ *          In the Event the converter doesn't support the characters {%,U}[A-F][0-9], 
+ *          it will  substitute  the illegal sequence with the substitution characters.
+ *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as
+ *          %UD84D%UDC56</li>
+ *        <li>UCNV_ESCAPE_JAVA: Substitues the  ILLEGAL SEQUENCE with the hexadecimal 
+ *          representation in the format  \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). 
+ *          In the Event the converter doesn't support the characters {\,u}[A-F][0-9], 
+ *          it will  substitute  the illegal sequence with the substitution characters.
+ *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as
+ *          \\uD84D\\uDC56</li>
+ *        <li>UCNV_ESCAPE_C: Substitues the  ILLEGAL SEQUENCE with the hexadecimal 
+ *          representation in the format  \\uXXXX, e.g. "\\uFFFE\\u00AC\\uC8FE"). 
+ *          In the Event the converter doesn't support the characters {\,u,U}[A-F][0-9], 
+ *          it will  substitute  the illegal sequence with the substitution characters.
+ *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as
+ *          \\U00023456</li>
+ *        <li>UCNV_ESCAPE_XML_DEC: Substitues the  ILLEGAL SEQUENCE with the decimal 
+ *          representation in the format \htmlonly&amp;#DDDDDDDD;, e.g. "&amp;#65534;&amp;#172;&amp;#51454;")\endhtmlonly. 
+ *          In the Event the converter doesn't support the characters {&amp;,#}[0-9], 
+ *          it will  substitute  the illegal sequence with the substitution characters.
+ *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as
+ *          &amp;#144470; and Zero padding is ignored.</li>
+ *        <li>UCNV_ESCAPE_XML_HEX:Substitues the  ILLEGAL SEQUENCE with the decimal 
+ *          representation in the format \htmlonly&amp;#xXXXX; e.g. "&amp;#xFFFE;&amp;#x00AC;&amp;#xC8FE;")\endhtmlonly. 
+ *          In the Event the converter doesn't support the characters {&,#,x}[0-9], 
+ *          it will  substitute  the illegal sequence with the substitution characters.
+ *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as
+ *          \htmlonly&amp;#x23456;\endhtmlonly</li>
+ *        </ul>
+ * @param fromUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
+ * @param reason Defines the reason the callback was invoked
+ * @param err Return value will be set to success if the callback was handled,
+ *      otherwise this value will be set to a failure status.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
+                  const void *context,
+                  UConverterFromUnicodeArgs *fromUArgs,
+                  const UChar* codeUnits,
+                  int32_t length,
+                  UChar32 codePoint,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This To Unicode callback skips any ILLEGAL_SEQUENCE, or
+ * skips only UNASSINGED_SEQUENCE depending on the context parameter
+ * simply ignoring those characters. 
+ *
+ * @param context  The function currently recognizes the callback options:
+ *                 UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,
+ *                      returning the error code back to the caller immediately.
+ *                 NULL: Skips any ILLEGAL_SEQUENCE
+ * @param toUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' bytes of the concerned codepage sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param reason Defines the reason the callback was invoked
+ * @param err Return value will be set to success if the callback was handled,
+ *      otherwise this value will be set to a failure status.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (
+                  const void *context,
+                  UConverterToUnicodeArgs *toUArgs,
+                  const char* codeUnits,
+                  int32_t length,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or 
+ * UNASSIGNED_SEQUENCE depending on context parameter,  with the
+ * Unicode substitution character, U+FFFD.
+ *
+ * @param context  The function currently recognizes the callback options:
+ *                 UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,
+ *                      returning the error code back to the caller immediately.
+ *                 NULL: Substitutes any ILLEGAL_SEQUENCE
+ * @param toUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' bytes of the concerned codepage sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param reason Defines the reason the callback was invoked
+ * @param err Return value will be set to success if the callback was handled,
+ *      otherwise this value will be set to a failure status.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (
+                  const void *context,
+                  UConverterToUnicodeArgs *toUArgs,
+                  const char* codeUnits,
+                  int32_t length,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+/**
+ * DO NOT CALL THIS FUNCTION DIRECTLY!
+ * This To Unicode callback will Substitute the ILLEGAL SEQUENCE with the
+ * hexadecimal representation of the illegal bytes
+ *  (in the format  %XNN, e.g. "%XFF%X0A%XC8%X03").
+ *
+ * @param context This function currently recognizes the callback options:
+ *      UCNV_ESCAPE_ICU, UCNV_ESCAPE_JAVA, UCNV_ESCAPE_C, UCNV_ESCAPE_XML_DEC,
+ *      UCNV_ESCAPE_XML_HEX and UCNV_ESCAPE_UNICODE.
+ * @param toUArgs Information about the conversion in progress
+ * @param codeUnits Points to 'length' bytes of the concerned codepage sequence
+ * @param length Size (in bytes) of the concerned codepage sequence
+ * @param reason Defines the reason the callback was invoked
+ * @param err Return value will be set to success if the callback was handled,
+ *      otherwise this value will be set to a failure status.
+ * @stable ICU 2.0
+ */
+
+U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (
+                  const void *context,
+                  UConverterToUnicodeArgs *toUArgs,
+                  const char* codeUnits,
+                  int32_t length,
+                  UConverterCallbackReason reason,
+                  UErrorCode * err);
+
+#endif
+
+#endif
+
+/*UCNV_ERR_H*/ 
diff --git a/CoreFoundation/icu/unicode/ucol.h b/CoreFoundation/icu/unicode/ucol.h
new file mode 100644
index 0000000..9fd952e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucol.h
@@ -0,0 +1,1132 @@
+/*
+*******************************************************************************
+* Copyright (c) 1996-2008, International Business Machines Corporation and others.
+* All Rights Reserved.
+*******************************************************************************
+*/
+
+#ifndef UCOL_H
+#define UCOL_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/unorm.h"
+#include "unicode/parseerr.h"
+#include "unicode/uloc.h"
+#include "unicode/uset.h"
+
+/**
+ * \file
+ * \brief C API: Collator 
+ *
+ * <h2> Collator C API </h2>
+ *
+ * The C API for Collator performs locale-sensitive
+ * string comparison. You use this service to build
+ * searching and sorting routines for natural language text.
+ * <em>Important: </em>The ICU collation service has been reimplemented 
+ * in order to achieve better performance and UCA compliance. 
+ * For details, see the 
+ * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm">
+ * collation design document</a>.
+ * <p>
+ * For more information about the collation service see 
+ * <a href="http://icu-project.org/userguide/Collate_Intro.html">the users guide</a>.
+ * <p>
+ * Collation service provides correct sorting orders for most locales supported in ICU. 
+ * If specific data for a locale is not available, the orders eventually falls back
+ * to the <a href="http://www.unicode.org/unicode/reports/tr10/">UCA sort order</a>. 
+ * <p>
+ * Sort ordering may be customized by providing your own set of rules. For more on
+ * this subject see the 
+ * <a href="http://icu-project.org/userguide/Collate_Customization.html">
+ * Collation customization</a> section of the users guide.
+ * <p>
+ * @see         UCollationResult
+ * @see         UNormalizationMode
+ * @see         UCollationStrength
+ * @see         UCollationElements
+ */
+
+/** A collator.
+*  For usage in C programs.
+*/
+struct UCollator;
+/** structure representing a collator object instance 
+ * @stable ICU 2.0
+ */
+typedef struct UCollator UCollator;
+
+
+/**
+ * UCOL_LESS is returned if source string is compared to be less than target
+ * string in the u_strcoll() method.
+ * UCOL_EQUAL is returned if source string is compared to be equal to target
+ * string in the u_strcoll() method.
+ * UCOL_GREATER is returned if source string is compared to be greater than
+ * target string in the u_strcoll() method.
+ * @see u_strcoll()
+ * <p>
+ * Possible values for a comparison result 
+ * @stable ICU 2.0
+ */
+typedef enum {
+  /** string a == string b */
+  UCOL_EQUAL    = 0,
+  /** string a > string b */
+  UCOL_GREATER    = 1,
+  /** string a < string b */
+  UCOL_LESS    = -1
+} UCollationResult ;
+
+
+/** Enum containing attribute values for controling collation behavior.
+ * Here are all the allowable values. Not every attribute can take every value. The only
+ * universal value is UCOL_DEFAULT, which resets the attribute value to the predefined  
+ * value for that locale 
+ * @stable ICU 2.0
+ */
+typedef enum {
+  /** accepted by most attributes */
+  UCOL_DEFAULT = -1,
+
+  /** Primary collation strength */
+  UCOL_PRIMARY = 0,
+  /** Secondary collation strength */
+  UCOL_SECONDARY = 1,
+  /** Tertiary collation strength */
+  UCOL_TERTIARY = 2,
+  /** Default collation strength */
+  UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY,
+  UCOL_CE_STRENGTH_LIMIT,
+  /** Quaternary collation strength */
+  UCOL_QUATERNARY=3,
+  /** Identical collation strength */
+  UCOL_IDENTICAL=15,
+  UCOL_STRENGTH_LIMIT,
+
+  /** Turn the feature off - works for UCOL_FRENCH_COLLATION, 
+      UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE
+      & UCOL_DECOMPOSITION_MODE*/
+  UCOL_OFF = 16,
+  /** Turn the feature on - works for UCOL_FRENCH_COLLATION, 
+      UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE
+      & UCOL_DECOMPOSITION_MODE*/
+  UCOL_ON = 17,
+  
+  /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be shifted */
+  UCOL_SHIFTED = 20,
+  /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be non ignorable */
+  UCOL_NON_IGNORABLE = 21,
+
+  /** Valid for UCOL_CASE_FIRST - 
+      lower case sorts before upper case */
+  UCOL_LOWER_FIRST = 24,
+  /** upper case sorts before lower case */
+  UCOL_UPPER_FIRST = 25,
+
+  UCOL_ATTRIBUTE_VALUE_COUNT
+
+} UColAttributeValue;
+
+/**
+ * Base letter represents a primary difference.  Set comparison
+ * level to UCOL_PRIMARY to ignore secondary and tertiary differences.
+ * Use this to set the strength of a Collator object.
+ * Example of primary difference, "abc" &lt; "abd"
+ * 
+ * Diacritical differences on the same base letter represent a secondary
+ * difference.  Set comparison level to UCOL_SECONDARY to ignore tertiary
+ * differences. Use this to set the strength of a Collator object.
+ * Example of secondary difference, "&auml;" >> "a".
+ *
+ * Uppercase and lowercase versions of the same character represents a
+ * tertiary difference.  Set comparison level to UCOL_TERTIARY to include
+ * all comparison differences. Use this to set the strength of a Collator
+ * object.
+ * Example of tertiary difference, "abc" &lt;&lt;&lt; "ABC".
+ *
+ * Two characters are considered "identical" when they have the same
+ * unicode spellings.  UCOL_IDENTICAL.
+ * For example, "&auml;" == "&auml;".
+ *
+ * UCollationStrength is also used to determine the strength of sort keys 
+ * generated from UCollator objects
+ * These values can be now found in the UColAttributeValue enum.
+ * @stable ICU 2.0
+ **/
+typedef UColAttributeValue UCollationStrength;
+
+/** Attributes that collation service understands. All the attributes can take UCOL_DEFAULT
+ * value, as well as the values specific to each one. 
+ * @stable ICU 2.0
+ */
+typedef enum {
+     /** Attribute for direction of secondary weights - used in French.
+      * Acceptable values are UCOL_ON, which results in secondary weights
+      * being considered backwards and UCOL_OFF which treats secondary
+      * weights in the order they appear.*/
+     UCOL_FRENCH_COLLATION, 
+     /** Attribute for handling variable elements.
+      * Acceptable values are UCOL_NON_IGNORABLE (default)
+      * which treats all the codepoints with non-ignorable 
+      * primary weights in the same way,
+      * and UCOL_SHIFTED which causes codepoints with primary 
+      * weights that are equal or below the variable top value
+      * to be ignored on primary level and moved to the quaternary 
+      * level.*/
+     UCOL_ALTERNATE_HANDLING, 
+     /** Controls the ordering of upper and lower case letters.
+      * Acceptable values are UCOL_OFF (default), which orders
+      * upper and lower case letters in accordance to their tertiary
+      * weights, UCOL_UPPER_FIRST which forces upper case letters to 
+      * sort before lower case letters, and UCOL_LOWER_FIRST which does 
+      * the opposite. */
+     UCOL_CASE_FIRST, 
+     /** Controls whether an extra case level (positioned before the third
+      * level) is generated or not. Acceptable values are UCOL_OFF (default), 
+      * when case level is not generated, and UCOL_ON which causes the case
+      * level to be generated. Contents of the case level are affected by
+      * the value of UCOL_CASE_FIRST attribute. A simple way to ignore 
+      * accent differences in a string is to set the strength to UCOL_PRIMARY
+      * and enable case level. */
+     UCOL_CASE_LEVEL,
+     /** Controls whether the normalization check and necessary normalizations
+      * are performed. When set to UCOL_OFF (default) no normalization check
+      * is performed. The correctness of the result is guaranteed only if the 
+      * input data is in so-called FCD form (see users manual for more info).
+      * When set to UCOL_ON, an incremental check is performed to see whether
+      * the input data is in the FCD form. If the data is not in the FCD form,
+      * incremental NFD normalization is performed. */
+     UCOL_NORMALIZATION_MODE, 
+     /** An alias for UCOL_NORMALIZATION_MODE attribute */
+     UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE,
+     /** The strength attribute. Can be either UCOL_PRIMARY, UCOL_SECONDARY,
+      * UCOL_TERTIARY, UCOL_QUATERNARY or UCOL_IDENTICAL. The usual strength
+      * for most locales (except Japanese) is tertiary. Quaternary strength 
+      * is useful when combined with shifted setting for alternate handling
+      * attribute and for JIS x 4061 collation, when it is used to distinguish
+      * between Katakana  and Hiragana (this is achieved by setting the 
+      * UCOL_HIRAGANA_QUATERNARY mode to on. Otherwise, quaternary level
+      * is affected only by the number of non ignorable code points in
+      * the string. Identical strength is rarely useful, as it amounts 
+      * to codepoints of the NFD form of the string. */
+     UCOL_STRENGTH,  
+     /** When turned on, this attribute positions Hiragana before all  
+      * non-ignorables on quaternary level This is a sneaky way to produce JIS
+      * sort order */
+     UCOL_HIRAGANA_QUATERNARY_MODE,
+     /** When turned on, this attribute generates a collation key
+      * for the numeric value of substrings of digits.
+      * This is a way to get '100' to sort AFTER '2'. */
+     UCOL_NUMERIC_COLLATION, 
+     UCOL_ATTRIBUTE_COUNT
+} UColAttribute;
+
+/** Options for retrieving the rule string 
+ *  @stable ICU 2.0
+ */
+typedef enum {
+  /** Retrieve tailoring only */
+  UCOL_TAILORING_ONLY, 
+  /** Retrieve UCA rules and tailoring */
+  UCOL_FULL_RULES 
+} UColRuleOption ;
+
+/**
+ * Open a UCollator for comparing strings.
+ * The UCollator pointer is used in all the calls to the Collation 
+ * service. After finished, collator must be disposed of by calling
+ * {@link #ucol_close }.
+ * @param loc The locale containing the required collation rules. 
+ *            Special values for locales can be passed in - 
+ *            if NULL is passed for the locale, the default locale
+ *            collation rules will be used. If empty string ("") or
+ *            "root" are passed, UCA rules will be used.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return A pointer to a UCollator, or 0 if an error occurred.
+ * @see ucol_openRules
+ * @see ucol_safeClone
+ * @see ucol_close
+ * @stable ICU 2.0
+ */
+U_STABLE UCollator* U_EXPORT2 
+ucol_open(const char *loc, UErrorCode *status);
+
+/**
+ * Produce an UCollator instance according to the rules supplied.
+ * The rules are used to change the default ordering, defined in the
+ * UCA in a process called tailoring. The resulting UCollator pointer
+ * can be used in the same way as the one obtained by {@link #ucol_strcoll }.
+ * @param rules A string describing the collation rules. For the syntax
+ *              of the rules please see users guide.
+ * @param rulesLength The length of rules, or -1 if null-terminated.
+ * @param normalizationMode The normalization mode: One of
+ *             UCOL_OFF     (expect the text to not need normalization),
+ *             UCOL_ON      (normalize), or
+ *             UCOL_DEFAULT (set the mode according to the rules)
+ * @param strength The default collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY,
+ * UCOL_TERTIARY, UCOL_IDENTICAL,UCOL_DEFAULT_STRENGTH - can be also set in the rules.
+ * @param parseError  A pointer to UParseError to recieve information about errors
+ *                    occurred during parsing. This argument can currently be set
+ *                    to NULL, but at users own risk. Please provide a real structure.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return A pointer to a UCollator. It is not guaranteed that NULL be returned in case
+ *         of error - please use status argument to check for errors.
+ * @see ucol_open
+ * @see ucol_safeClone
+ * @see ucol_close
+ * @stable ICU 2.0
+ */
+U_STABLE UCollator* U_EXPORT2 
+ucol_openRules( const UChar        *rules,
+                int32_t            rulesLength,
+                UColAttributeValue normalizationMode,
+                UCollationStrength strength,
+                UParseError        *parseError,
+                UErrorCode         *status);
+
+/** 
+ * Open a collator defined by a short form string.
+ * The structure and the syntax of the string is defined in the "Naming collators"
+ * section of the users guide: 
+ * http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators
+ * Attributes are overriden by the subsequent attributes. So, for "S2_S3", final
+ * strength will be 3. 3066bis locale overrides individual locale parts.
+ * The call to this function is equivalent to a call to ucol_open, followed by a 
+ * series of calls to ucol_setAttribute and ucol_setVariableTop.
+ * @param definition A short string containing a locale and a set of attributes. 
+ *                   Attributes not explicitly mentioned are left at the default
+ *                   state for a locale.
+ * @param parseError if not NULL, structure that will get filled with error's pre
+ *                   and post context in case of error.
+ * @param forceDefaults if FALSE, the settings that are the same as the collator 
+ *                   default settings will not be applied (for example, setting
+ *                   French secondary on a French collator would not be executed). 
+ *                   If TRUE, all the settings will be applied regardless of the 
+ *                   collator default value. If the definition
+ *                   strings are to be cached, should be set to FALSE.
+ * @param status     Error code. Apart from regular error conditions connected to 
+ *                   instantiating collators (like out of memory or similar), this
+ *                   API will return an error if an invalid attribute or attribute/value
+ *                   combination is specified.
+ * @return           A pointer to a UCollator or 0 if an error occured (including an 
+ *                   invalid attribute).
+ * @see ucol_open
+ * @see ucol_setAttribute
+ * @see ucol_setVariableTop
+ * @see ucol_getShortDefinitionString
+ * @see ucol_normalizeShortDefinitionString
+ * @stable ICU 3.0
+ *
+ */
+U_STABLE UCollator* U_EXPORT2
+ucol_openFromShortString( const char *definition,
+                          UBool forceDefaults,
+                          UParseError *parseError,
+                          UErrorCode *status);
+
+/**
+ * Get a set containing the contractions defined by the collator. The set includes
+ * both the UCA contractions and the contractions defined by the collator. This set
+ * will contain only strings. If a tailoring explicitly suppresses contractions from 
+ * the UCA (like Russian), removed contractions will not be in the resulting set.
+ * @param coll collator 
+ * @param conts the set to hold the result. It gets emptied before
+ *              contractions are added. 
+ * @param status to hold the error code
+ * @return the size of the contraction set
+ *
+ * @deprecated ICU 3.4, use ucol_getContractionsAndExpansions instead
+ */
+U_DEPRECATED int32_t U_EXPORT2
+ucol_getContractions( const UCollator *coll,
+                  USet *conts,
+                  UErrorCode *status);
+
+/**
+ * Get a set containing the expansions defined by the collator. The set includes
+ * both the UCA expansions and the expansions defined by the tailoring
+ * @param coll collator
+ * @param contractions if not NULL, the set to hold the contractions
+ * @param expansions if not NULL, the set to hold the expansions
+ * @param addPrefixes add the prefix contextual elements to contractions
+ * @param status to hold the error code
+ *
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+ucol_getContractionsAndExpansions( const UCollator *coll,
+                  USet *contractions, USet *expansions,
+                  UBool addPrefixes, UErrorCode *status);
+
+/** 
+ * Close a UCollator.
+ * Once closed, a UCollator should not be used. Every open collator should
+ * be closed. Otherwise, a memory leak will result.
+ * @param coll The UCollator to close.
+ * @see ucol_open
+ * @see ucol_openRules
+ * @see ucol_safeClone
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_close(UCollator *coll);
+
+/**
+ * Compare two strings.
+ * The strings will be compared using the options already specified.
+ * @param coll The UCollator containing the comparison rules.
+ * @param source The source string.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param target The target string.
+ * @param targetLength The length of target, or -1 if null-terminated.
+ * @return The result of comparing the strings; one of UCOL_EQUAL,
+ * UCOL_GREATER, UCOL_LESS
+ * @see ucol_greater
+ * @see ucol_greaterOrEqual
+ * @see ucol_equal
+ * @stable ICU 2.0
+ */
+U_STABLE UCollationResult U_EXPORT2 
+ucol_strcoll(    const    UCollator    *coll,
+        const    UChar        *source,
+        int32_t            sourceLength,
+        const    UChar        *target,
+        int32_t            targetLength);
+
+/**
+ * Determine if one string is greater than another.
+ * This function is equivalent to {@link #ucol_strcoll } == UCOL_GREATER
+ * @param coll The UCollator containing the comparison rules.
+ * @param source The source string.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param target The target string.
+ * @param targetLength The length of target, or -1 if null-terminated.
+ * @return TRUE if source is greater than target, FALSE otherwise.
+ * @see ucol_strcoll
+ * @see ucol_greaterOrEqual
+ * @see ucol_equal
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2 
+ucol_greater(const UCollator *coll,
+             const UChar     *source, int32_t sourceLength,
+             const UChar     *target, int32_t targetLength);
+
+/**
+ * Determine if one string is greater than or equal to another.
+ * This function is equivalent to {@link #ucol_strcoll } != UCOL_LESS
+ * @param coll The UCollator containing the comparison rules.
+ * @param source The source string.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param target The target string.
+ * @param targetLength The length of target, or -1 if null-terminated.
+ * @return TRUE if source is greater than or equal to target, FALSE otherwise.
+ * @see ucol_strcoll
+ * @see ucol_greater
+ * @see ucol_equal
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2 
+ucol_greaterOrEqual(const UCollator *coll,
+                    const UChar     *source, int32_t sourceLength,
+                    const UChar     *target, int32_t targetLength);
+
+/**
+ * Compare two strings for equality.
+ * This function is equivalent to {@link #ucol_strcoll } == UCOL_EQUAL
+ * @param coll The UCollator containing the comparison rules.
+ * @param source The source string.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param target The target string.
+ * @param targetLength The length of target, or -1 if null-terminated.
+ * @return TRUE if source is equal to target, FALSE otherwise
+ * @see ucol_strcoll
+ * @see ucol_greater
+ * @see ucol_greaterOrEqual
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2 
+ucol_equal(const UCollator *coll,
+           const UChar     *source, int32_t sourceLength,
+           const UChar     *target, int32_t targetLength);
+
+/**
+ * Compare two UTF-8 encoded trings.
+ * The strings will be compared using the options already specified.
+ * @param coll The UCollator containing the comparison rules.
+ * @param sIter The source string iterator.
+ * @param tIter The target string iterator.
+ * @return The result of comparing the strings; one of UCOL_EQUAL,
+ * UCOL_GREATER, UCOL_LESS
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @see ucol_strcoll
+ * @stable ICU 2.6
+ */
+U_STABLE UCollationResult U_EXPORT2 
+ucol_strcollIter(  const    UCollator    *coll,
+                  UCharIterator *sIter,
+                  UCharIterator *tIter,
+                  UErrorCode *status);
+
+/**
+ * Get the collation strength used in a UCollator.
+ * The strength influences how strings are compared.
+ * @param coll The UCollator to query.
+ * @return The collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY,
+ * UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL
+ * @see ucol_setStrength
+ * @stable ICU 2.0
+ */
+U_STABLE UCollationStrength U_EXPORT2 
+ucol_getStrength(const UCollator *coll);
+
+/**
+ * Set the collation strength used in a UCollator.
+ * The strength influences how strings are compared.
+ * @param coll The UCollator to set.
+ * @param strength The desired collation strength; one of UCOL_PRIMARY, 
+ * UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT
+ * @see ucol_getStrength
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_setStrength(UCollator *coll,
+                 UCollationStrength strength);
+
+/**
+ * Get the display name for a UCollator.
+ * The display name is suitable for presentation to a user.
+ * @param objLoc The locale of the collator in question.
+ * @param dispLoc The locale for display.
+ * @param result A pointer to a buffer to receive the attribute.
+ * @param resultLength The maximum size of result.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return The total buffer size needed; if greater than resultLength,
+ * the output was truncated.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_getDisplayName(    const    char        *objLoc,
+            const    char        *dispLoc,
+            UChar             *result,
+            int32_t         resultLength,
+            UErrorCode        *status);
+
+/**
+ * Get a locale for which collation rules are available.
+ * A UCollator in a locale returned by this function will perform the correct
+ * collation for the locale.
+ * @param index The index of the desired locale.
+ * @return A locale for which collation rules are available, or 0 if none.
+ * @see ucol_countAvailable
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2 
+ucol_getAvailable(int32_t index);
+
+/**
+ * Determine how many locales have collation rules available.
+ * This function is most useful as determining the loop ending condition for
+ * calls to {@link #ucol_getAvailable }.
+ * @return The number of locales for which collation rules are available.
+ * @see ucol_getAvailable
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_countAvailable(void);
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * Create a string enumerator of all locales for which a valid
+ * collator may be opened.
+ * @param status input-output error code
+ * @return a string enumeration over locale strings. The caller is
+ * responsible for closing the result.
+ * @stable ICU 3.0
+ */
+U_STABLE UEnumeration* U_EXPORT2
+ucol_openAvailableLocales(UErrorCode *status);
+#endif
+
+/**
+ * Create a string enumerator of all possible keywords that are relevant to
+ * collation. At this point, the only recognized keyword for this
+ * service is "collation".
+ * @param status input-output error code
+ * @return a string enumeration over locale strings. The caller is
+ * responsible for closing the result.
+ * @stable ICU 3.0
+ */
+U_STABLE UEnumeration* U_EXPORT2
+ucol_getKeywords(UErrorCode *status);
+
+/**
+ * Given a keyword, create a string enumeration of all values
+ * for that keyword that are currently in use.
+ * @param keyword a particular keyword as enumerated by
+ * ucol_getKeywords. If any other keyword is passed in, *status is set
+ * to U_ILLEGAL_ARGUMENT_ERROR.
+ * @param status input-output error code
+ * @return a string enumeration over collation keyword values, or NULL
+ * upon error. The caller is responsible for closing the result.
+ * @stable ICU 3.0
+ */
+U_STABLE UEnumeration* U_EXPORT2
+ucol_getKeywordValues(const char *keyword, UErrorCode *status);
+
+/**
+ * Return the functionally equivalent locale for the given
+ * requested locale, with respect to given keyword, for the
+ * collation service.  If two locales return the same result, then
+ * collators instantiated for these locales will behave
+ * equivalently.  The converse is not always true; two collators
+ * may in fact be equivalent, but return different results, due to
+ * internal details.  The return result has no other meaning than
+ * that stated above, and implies nothing as to the relationship
+ * between the two locales.  This is intended for use by
+ * applications who wish to cache collators, or otherwise reuse
+ * collators when possible.  The functional equivalent may change
+ * over time.  For more information, please see the <a
+ * href="http://icu-project.org/userguide/locale.html#services">
+ * Locales and Services</a> section of the ICU User Guide.
+ * @param result fillin for the functionally equivalent locale
+ * @param resultCapacity capacity of the fillin buffer
+ * @param keyword a particular keyword as enumerated by
+ * ucol_getKeywords.
+ * @param locale the requested locale
+ * @param isAvailable if non-NULL, pointer to a fillin parameter that
+ * indicates whether the requested locale was 'available' to the
+ * collation service. A locale is defined as 'available' if it
+ * physically exists within the collation locale data.
+ * @param status pointer to input-output error code
+ * @return the actual buffer size needed for the locale.  If greater
+ * than resultCapacity, the returned full name will be truncated and
+ * an error code will be returned.
+ * @stable ICU 3.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
+                             const char* keyword, const char* locale,
+                             UBool* isAvailable, UErrorCode* status);
+
+/**
+ * Get the collation rules from a UCollator.
+ * The rules will follow the rule syntax.
+ * @param coll The UCollator to query.
+ * @param length 
+ * @return The collation rules.
+ * @stable ICU 2.0
+ */
+U_STABLE const UChar* U_EXPORT2 
+ucol_getRules(    const    UCollator    *coll, 
+        int32_t            *length);
+
+/** Get the short definition string for a collator. This API harvests the collator's
+ *  locale and the attribute set and produces a string that can be used for opening 
+ *  a collator with the same properties using the ucol_openFromShortString API.
+ *  This string will be normalized.
+ *  The structure and the syntax of the string is defined in the "Naming collators"
+ *  section of the users guide: 
+ *  http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators
+ *  This API supports preflighting.
+ *  @param coll a collator
+ *  @param locale a locale that will appear as a collators locale in the resulting
+ *                short string definition. If NULL, the locale will be harvested 
+ *                from the collator.
+ *  @param buffer space to hold the resulting string
+ *  @param capacity capacity of the buffer
+ *  @param status for returning errors. All the preflighting errors are featured
+ *  @return length of the resulting string
+ *  @see ucol_openFromShortString
+ *  @see ucol_normalizeShortDefinitionString
+ *  @stable ICU 3.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucol_getShortDefinitionString(const UCollator *coll,
+                              const char *locale,
+                              char *buffer,
+                              int32_t capacity,
+                              UErrorCode *status);
+
+/** Verifies and normalizes short definition string.
+ *  Normalized short definition string has all the option sorted by the argument name,
+ *  so that equivalent definition strings are the same. 
+ *  This API supports preflighting.
+ *  @param source definition string
+ *  @param destination space to hold the resulting string
+ *  @param capacity capacity of the buffer
+ *  @param parseError if not NULL, structure that will get filled with error's pre
+ *                   and post context in case of error.
+ *  @param status     Error code. This API will return an error if an invalid attribute 
+ *                    or attribute/value combination is specified. All the preflighting 
+ *                    errors are also featured
+ *  @return length of the resulting normalized string.
+ *
+ *  @see ucol_openFromShortString
+ *  @see ucol_getShortDefinitionString
+ * 
+ *  @stable ICU 3.0
+ */
+
+U_STABLE int32_t U_EXPORT2
+ucol_normalizeShortDefinitionString(const char *source,
+                                    char *destination,
+                                    int32_t capacity,
+                                    UParseError *parseError,
+                                    UErrorCode *status);
+
+
+/**
+ * Get a sort key for a string from a UCollator.
+ * Sort keys may be compared using <TT>strcmp</TT>.
+ * @param coll The UCollator containing the collation rules.
+ * @param source The string to transform.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param result A pointer to a buffer to receive the attribute.
+ * @param resultLength The maximum size of result.
+ * @return The size needed to fully store the sort key.
+ *      If there was an internal error generating the sort key,
+ *      a zero value is returned.
+ * @see ucol_keyHashCode
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_getSortKey(const    UCollator    *coll,
+        const    UChar        *source,
+        int32_t        sourceLength,
+        uint8_t        *result,
+        int32_t        resultLength);
+
+
+/** Gets the next count bytes of a sort key. Caller needs
+ *  to preserve state array between calls and to provide
+ *  the same type of UCharIterator set with the same string.
+ *  The destination buffer provided must be big enough to store
+ *  the number of requested bytes. Generated sortkey is not 
+ *  compatible with sortkeys generated using ucol_getSortKey
+ *  API, since we don't do any compression. If uncompressed
+ *  sortkeys are required, this API can be used.
+ *  @param coll The UCollator containing the collation rules.
+ *  @param iter UCharIterator containing the string we need 
+ *              the sort key to be calculated for.
+ *  @param state Opaque state of sortkey iteration.
+ *  @param dest Buffer to hold the resulting sortkey part
+ *  @param count number of sort key bytes required.
+ *  @param status error code indicator.
+ *  @return the actual number of bytes of a sortkey. It can be
+ *          smaller than count if we have reached the end of 
+ *          the sort key.
+ *  @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_nextSortKeyPart(const UCollator *coll,
+                     UCharIterator *iter,
+                     uint32_t state[2],
+                     uint8_t *dest, int32_t count,
+                     UErrorCode *status);
+
+/** enum that is taken by ucol_getBound API 
+ * See below for explanation                
+ * do not change the values assigned to the 
+ * members of this enum. Underlying code    
+ * depends on them having these numbers     
+ * @stable ICU 2.0
+ */
+typedef enum {
+  /** lower bound */
+  UCOL_BOUND_LOWER = 0,
+  /** upper bound that will match strings of exact size */
+  UCOL_BOUND_UPPER = 1,
+  /** upper bound that will match all the strings that have the same initial substring as the given string */
+  UCOL_BOUND_UPPER_LONG = 2,
+  UCOL_BOUND_VALUE_COUNT
+} UColBoundMode;
+
+/**
+ * Produce a bound for a given sortkey and a number of levels.
+ * Return value is always the number of bytes needed, regardless of 
+ * whether the result buffer was big enough or even valid.<br>
+ * Resulting bounds can be used to produce a range of strings that are
+ * between upper and lower bounds. For example, if bounds are produced
+ * for a sortkey of string "smith", strings between upper and lower 
+ * bounds with one level would include "Smith", "SMITH", "sMiTh".<br>
+ * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER
+ * is produced, strings matched would be as above. However, if bound
+ * produced using UCOL_BOUND_UPPER_LONG is used, the above example will
+ * also match "Smithsonian" and similar.<br>
+ * For more on usage, see example in cintltst/capitst.c in procedure
+ * TestBounds.
+ * Sort keys may be compared using <TT>strcmp</TT>.
+ * @param source The source sortkey.
+ * @param sourceLength The length of source, or -1 if null-terminated. 
+ *                     (If an unmodified sortkey is passed, it is always null 
+ *                      terminated).
+ * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which 
+ *                  produces a lower inclusive bound, UCOL_BOUND_UPPER, that 
+ *                  produces upper bound that matches strings of the same length 
+ *                  or UCOL_BOUND_UPPER_LONG that matches strings that have the 
+ *                  same starting substring as the source string.
+ * @param noOfLevels  Number of levels required in the resulting bound (for most 
+ *                    uses, the recommended value is 1). See users guide for 
+ *                    explanation on number of levels a sortkey can have.
+ * @param result A pointer to a buffer to receive the resulting sortkey.
+ * @param resultLength The maximum size of result.
+ * @param status Used for returning error code if something went wrong. If the 
+ *               number of levels requested is higher than the number of levels
+ *               in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is 
+ *               issued.
+ * @return The size needed to fully store the bound. 
+ * @see ucol_keyHashCode
+ * @stable ICU 2.1
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_getBound(const uint8_t       *source,
+        int32_t             sourceLength,
+        UColBoundMode       boundType,
+        uint32_t            noOfLevels,
+        uint8_t             *result,
+        int32_t             resultLength,
+        UErrorCode          *status);
+        
+/**
+ * Gets the version information for a Collator. Version is currently
+ * an opaque 32-bit number which depends, among other things, on major
+ * versions of the collator tailoring and UCA.
+ * @param coll The UCollator to query.
+ * @param info the version # information, the result will be filled in
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+ucol_getVersion(const UCollator* coll, UVersionInfo info);
+
+/**
+ * Gets the UCA version information for a Collator. Version is the
+ * UCA version number (3.1.1, 4.0).
+ * @param coll The UCollator to query.
+ * @param info the version # information, the result will be filled in
+ * @stable ICU 2.8
+ */
+U_STABLE void U_EXPORT2
+ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
+
+/** 
+ * Merge two sort keys. The levels are merged with their corresponding counterparts
+ * (primaries with primaries, secondaries with secondaries etc.). Between the values
+ * from the same level a separator is inserted.
+ * example (uncompressed): 
+ * 191B1D 01 050505 01 910505 00 and 1F2123 01 050505 01 910505 00
+ * will be merged as 
+ * 191B1D 02 1F212301 050505 02 050505 01 910505 02 910505 00
+ * This allows for concatenating of first and last names for sorting, among other things.
+ * If the destination buffer is not big enough, the results are undefined.
+ * If any of source lengths are zero or any of source pointers are NULL/undefined, 
+ * result is of size zero.
+ * @param src1 pointer to the first sortkey
+ * @param src1Length length of the first sortkey
+ * @param src2 pointer to the second sortkey
+ * @param src2Length length of the second sortkey
+ * @param dest buffer to hold the result
+ * @param destCapacity size of the buffer for the result
+ * @return size of the result. If the buffer is big enough size is always
+ *         src1Length+src2Length-1
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
+                   const uint8_t *src2, int32_t src2Length,
+                   uint8_t *dest, int32_t destCapacity);
+
+/**
+ * Universal attribute setter
+ * @param coll collator which attributes are to be changed
+ * @param attr attribute type 
+ * @param value attribute value
+ * @param status to indicate whether the operation went on smoothly or there were errors
+ * @see UColAttribute
+ * @see UColAttributeValue
+ * @see ucol_getAttribute
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status);
+
+/**
+ * Universal attribute getter
+ * @param coll collator which attributes are to be changed
+ * @param attr attribute type
+ * @return attribute value
+ * @param status to indicate whether the operation went on smoothly or there were errors
+ * @see UColAttribute
+ * @see UColAttributeValue
+ * @see ucol_setAttribute
+ * @stable ICU 2.0
+ */
+U_STABLE UColAttributeValue  U_EXPORT2 
+ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status);
+
+/** Variable top
+ * is a two byte primary value which causes all the codepoints with primary values that
+ * are less or equal than the variable top to be shifted when alternate handling is set
+ * to UCOL_SHIFTED.
+ * Sets the variable top to a collation element value of a string supplied. 
+ * @param coll collator which variable top needs to be changed
+ * @param varTop one or more (if contraction) UChars to which the variable top should be set
+ * @param len length of variable top string. If -1 it is considered to be zero terminated.
+ * @param status error code. If error code is set, the return value is undefined. 
+ *               Errors set by this function are: <br>
+ *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such 
+ *    a contraction<br>
+ *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
+ * @return a 32 bit value containing the value of the variable top in upper 16 bits. 
+ *         Lower 16 bits are undefined
+ * @see ucol_getVariableTop
+ * @see ucol_restoreVariableTop
+ * @stable ICU 2.0
+ */
+U_STABLE uint32_t U_EXPORT2 
+ucol_setVariableTop(UCollator *coll, 
+                    const UChar *varTop, int32_t len, 
+                    UErrorCode *status);
+
+/** 
+ * Gets the variable top value of a Collator. 
+ * Lower 16 bits are undefined and should be ignored.
+ * @param coll collator which variable top needs to be retrieved
+ * @param status error code (not changed by function). If error code is set, 
+ *               the return value is undefined.
+ * @return the variable top value of a Collator.
+ * @see ucol_setVariableTop
+ * @see ucol_restoreVariableTop
+ * @stable ICU 2.0
+ */
+U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);
+
+/** 
+ * Sets the variable top to a collation element value supplied. Variable top is 
+ * set to the upper 16 bits. 
+ * Lower 16 bits are ignored.
+ * @param coll collator which variable top needs to be changed
+ * @param varTop CE value, as returned by ucol_setVariableTop or ucol)getVariableTop
+ * @param status error code (not changed by function)
+ * @see ucol_getVariableTop
+ * @see ucol_setVariableTop
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status);
+
+/**
+ * Thread safe cloning operation. The result is a clone of a given collator.
+ * @param coll collator to be cloned
+ * @param stackBuffer user allocated space for the new clone. 
+ * If NULL new memory will be allocated. 
+ *  If buffer is not large enough, new memory will be allocated.
+ *  Clients can use the U_COL_SAFECLONE_BUFFERSIZE. 
+ *  This will probably be enough to avoid memory allocations.
+ * @param pBufferSize pointer to size of allocated space. 
+ *  If *pBufferSize == 0, a sufficient size for use in cloning will 
+ *  be returned ('pre-flighting')
+ *  If *pBufferSize is not enough for a stack-based safe clone, 
+ *  new memory will be allocated.
+ * @param status to indicate whether the operation went on smoothly or there were errors
+ *    An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any
+ * allocations were necessary.
+ * @return pointer to the new clone
+ * @see ucol_open
+ * @see ucol_openRules
+ * @see ucol_close
+ * @stable ICU 2.0
+ */
+U_STABLE UCollator* U_EXPORT2 
+ucol_safeClone(const UCollator *coll,
+               void            *stackBuffer,
+               int32_t         *pBufferSize,
+               UErrorCode      *status);
+
+/** default memory size for the new clone. It needs to be this large for os/400 large pointers 
+ * @stable ICU 2.0
+ */
+#define U_COL_SAFECLONE_BUFFERSIZE 512
+
+/**
+ * Returns current rules. Delta defines whether full rules are returned or just the tailoring. 
+ * Returns number of UChars needed to store rules. If buffer is NULL or bufferLen is not enough 
+ * to store rules, will store up to available space.
+ * @param coll collator to get the rules from
+ * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES. 
+ * @param buffer buffer to store the result in. If NULL, you'll get no rules.
+ * @param bufferLen lenght of buffer to store rules in. If less then needed you'll get only the part that fits in.
+ * @return current rules
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen);
+
+/**
+ * gets the locale name of the collator. If the collator
+ * is instantiated from the rules, then this function returns
+ * NULL.
+ * @param coll The UCollator for which the locale is needed
+ * @param type You can choose between requested, valid and actual
+ *             locale. For description see the definition of
+ *             ULocDataLocaleType in uloc.h
+ * @param status error code of the operation
+ * @return real locale name from which the collation data comes. 
+ *         If the collator was instantiated from rules, returns
+ *         NULL.
+ * @deprecated ICU 2.8 Use ucol_getLocaleByType instead
+ */
+U_DEPRECATED const char * U_EXPORT2
+ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
+
+
+/**
+ * gets the locale name of the collator. If the collator
+ * is instantiated from the rules, then this function returns
+ * NULL.
+ * @param coll The UCollator for which the locale is needed
+ * @param type You can choose between requested, valid and actual
+ *             locale. For description see the definition of
+ *             ULocDataLocaleType in uloc.h
+ * @param status error code of the operation
+ * @return real locale name from which the collation data comes. 
+ *         If the collator was instantiated from rules, returns
+ *         NULL.
+ * @stable ICU 2.8
+ */
+U_STABLE const char * U_EXPORT2
+ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
+
+/**
+ * Get an Unicode set that contains all the characters and sequences tailored in 
+ * this collator. The result must be disposed of by using uset_close.
+ * @param coll        The UCollator for which we want to get tailored chars
+ * @param status      error code of the operation
+ * @return a pointer to newly created USet. Must be be disposed by using uset_close
+ * @see ucol_openRules
+ * @see uset_close
+ * @stable ICU 2.4
+ */
+U_STABLE USet * U_EXPORT2
+ucol_getTailoredSet(const UCollator *coll, UErrorCode *status);
+
+/**
+ * Universal attribute getter that returns UCOL_DEFAULT if the value is default
+ * @param coll collator which attributes are to be changed
+ * @param attr attribute type
+ * @return attribute value or UCOL_DEFAULT if the value is default
+ * @param status to indicate whether the operation went on smoothly or there were errors
+ * @see UColAttribute
+ * @see UColAttributeValue
+ * @see ucol_setAttribute
+ * @internal ICU 3.0
+ */
+U_INTERNAL UColAttributeValue  U_EXPORT2
+ucol_getAttributeOrDefault(const UCollator *coll, UColAttribute attr, UErrorCode *status);
+
+/** Check whether two collators are equal. Collators are considered equal if they
+ *  will sort strings the same. This means that both the current attributes and the
+ *  rules must be equivalent. Currently used for RuleBasedCollator::operator==.
+ *  @param source first collator
+ *  @param target second collator
+ *  @return TRUE or FALSE
+ *  @internal ICU 3.0
+ */
+U_INTERNAL UBool U_EXPORT2
+ucol_equals(const UCollator *source, const UCollator *target);
+
+/** Calculates the set of unsafe code points, given a collator.
+ *   A character is unsafe if you could append any character and cause the ordering to alter significantly.
+ *   Collation sorts in normalized order, so anything that rearranges in normalization can cause this.
+ *   Thus if you have a character like a_umlaut, and you add a lower_dot to it,
+ *   then it normalizes to a_lower_dot + umlaut, and sorts differently.
+ *  @param coll Collator
+ *  @param unsafe a fill-in set to receive the unsafe points
+ *  @param status for catching errors
+ *  @return number of elements in the set
+ *  @internal ICU 3.0
+ */
+U_INTERNAL int32_t U_EXPORT2
+ucol_getUnsafeSet( const UCollator *coll,
+                  USet *unsafe,
+                  UErrorCode *status);
+
+/** Reset UCA's static pointers. You don't want to use this, unless your static memory can go away.
+ * @internal ICU 3.2.1
+ */
+U_INTERNAL void U_EXPORT2
+ucol_forgetUCA(void);
+
+/** Touches all resources needed for instantiating a collator from a short string definition,
+ *  thus filling up the cache.
+ * @param definition A short string containing a locale and a set of attributes. 
+ *                   Attributes not explicitly mentioned are left at the default
+ *                   state for a locale.
+ * @param parseError if not NULL, structure that will get filled with error's pre
+ *                   and post context in case of error.
+ * @param forceDefaults if FALSE, the settings that are the same as the collator 
+ *                   default settings will not be applied (for example, setting
+ *                   French secondary on a French collator would not be executed). 
+ *                   If TRUE, all the settings will be applied regardless of the 
+ *                   collator default value. If the definition
+ *                   strings are to be cached, should be set to FALSE.
+ * @param status     Error code. Apart from regular error conditions connected to 
+ *                   instantiating collators (like out of memory or similar), this
+ *                   API will return an error if an invalid attribute or attribute/value
+ *                   combination is specified.
+ * @see ucol_openFromShortString
+ * @internal ICU 3.2.1
+ */
+U_INTERNAL void U_EXPORT2
+ucol_prepareShortStringOpen( const char *definition,
+                          UBool forceDefaults,
+                          UParseError *parseError,
+                          UErrorCode *status);
+
+/** Creates a binary image of a collator. This binary image can be stored and 
+ *  later used to instantiate a collator using ucol_openBinary.
+ *  This API supports preflighting.
+ *  @param coll Collator
+ *  @param buffer a fill-in buffer to receive the binary image
+ *  @param capacity capacity of the destination buffer
+ *  @param status for catching errors
+ *  @return size of the image
+ *  @see ucol_openBinary
+ *  @stable ICU 3.2
+ */
+U_STABLE int32_t U_EXPORT2
+ucol_cloneBinary(const UCollator *coll,
+                 uint8_t *buffer, int32_t capacity,
+                 UErrorCode *status);
+
+/** Opens a collator from a collator binary image created using
+ *  ucol_cloneBinary. Binary image used in instantiation of the 
+ *  collator remains owned by the user and should stay around for 
+ *  the lifetime of the collator. The API also takes a base collator
+ *  which usualy should be UCA.
+ *  @param bin binary image owned by the user and required through the
+ *             lifetime of the collator
+ *  @param length size of the image. If negative, the API will try to
+ *                figure out the length of the image
+ *  @param base fallback collator, usually UCA. Base is required to be
+ *              present through the lifetime of the collator. Currently 
+ *              it cannot be NULL.
+ *  @param status for catching errors
+ *  @return newly created collator
+ *  @see ucol_cloneBinary
+ *  @stable ICU 3.2
+ */
+U_STABLE UCollator* U_EXPORT2
+ucol_openBinary(const uint8_t *bin, int32_t length, 
+                const UCollator *base, 
+                UErrorCode *status);
+
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
+
diff --git a/CoreFoundation/icu/unicode/ucoleitr.h b/CoreFoundation/icu/unicode/ucoleitr.h
new file mode 100644
index 0000000..9c951a9
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucoleitr.h
@@ -0,0 +1,315 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2001-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+* File ucoleitr.cpp
+*
+* Modification History:
+*
+* Date        Name        Description
+* 02/15/2001  synwee      Modified all methods to process its own function 
+*                         instead of calling the equivalent c++ api (coleitr.h)
+*******************************************************************************/
+
+#ifndef UCOLEITR_H
+#define UCOLEITR_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_COLLATION
+
+/**  
+ * This indicates an error has occured during processing or if no more CEs is 
+ * to be returned.
+ * @stable ICU 2.0
+ */
+#define UCOL_NULLORDER        ((int32_t)0xFFFFFFFF)
+
+/**  
+ * This indicates an error has occured during processing or there are no more CEs 
+ * to be returned.
+ *
+ * @internal
+ */
+#define UCOL_PROCESSED_NULLORDER        ((int64_t)U_INT64_MAX)
+
+#include "unicode/ucol.h"
+
+/** 
+ * The UCollationElements struct.
+ * For usage in C programs.
+ * @stable ICU 2.0
+ */
+typedef struct UCollationElements UCollationElements;
+
+/**
+ * \file
+ * \brief C API: UCollationElements
+ *
+ * The UCollationElements API is used as an iterator to walk through each 
+ * character of an international string. Use the iterator to return the
+ * ordering priority of the positioned character. The ordering priority of a 
+ * character, which we refer to as a key, defines how a character is collated 
+ * in the given collation object.
+ * For example, consider the following in Spanish:
+ * <pre>
+ * .       "ca" -> the first key is key('c') and second key is key('a').
+ * .       "cha" -> the first key is key('ch') and second key is key('a').
+ * </pre>
+ * And in German,
+ * <pre>
+ * .       "<ae ligature>b"-> the first key is key('a'), the second key is key('e'), and
+ * .       the third key is key('b').
+ * </pre>
+ * <p>Example of the iterator usage: (without error checking)
+ * <pre>
+ * .  void CollationElementIterator_Example()
+ * .  {
+ * .      UChar *s;
+ * .      t_int32 order, primaryOrder;
+ * .      UCollationElements *c;
+ * .      UCollatorOld *coll;
+ * .      UErrorCode success = U_ZERO_ERROR;
+ * .      s=(UChar*)malloc(sizeof(UChar) * (strlen("This is a test")+1) );
+ * .      u_uastrcpy(s, "This is a test");
+ * .      coll = ucol_open(NULL, &success);
+ * .      c = ucol_openElements(coll, str, u_strlen(str), &status);
+ * .      order = ucol_next(c, &success);
+ * .      ucol_reset(c);
+ * .      order = ucol_prev(c, &success);
+ * .      free(s);
+ * .      ucol_close(coll);
+ * .      ucol_closeElements(c);
+ * .  }
+ * </pre>
+ * <p>
+ * ucol_next() returns the collation order of the next.
+ * ucol_prev() returns the collation order of the previous character.
+ * The Collation Element Iterator moves only in one direction between calls to
+ * ucol_reset. That is, ucol_next() and ucol_prev can not be inter-used. 
+ * Whenever ucol_prev is to be called after ucol_next() or vice versa, 
+ * ucol_reset has to be called first to reset the status, shifting pointers to 
+ * either the end or the start of the string. Hence at the next call of 
+ * ucol_prev or ucol_next, the first or last collation order will be returned. 
+ * If a change of direction is done without a ucol_reset, the result is 
+ * undefined.
+ * The result of a forward iterate (ucol_next) and reversed result of the  
+ * backward iterate (ucol_prev) on the same string are equivalent, if 
+ * collation orders with the value UCOL_IGNORABLE are ignored.
+ * Character based on the comparison level of the collator.  A collation order 
+ * consists of primary order, secondary order and tertiary order.  The data 
+ * type of the collation order is <strong>t_int32</strong>. 
+ *
+ * @see UCollator
+ */
+
+/**
+ * Open the collation elements for a string.
+ *
+ * @param coll The collator containing the desired collation rules.
+ * @param text The text to iterate over.
+ * @param textLength The number of characters in text, or -1 if null-terminated
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return a struct containing collation element information
+ * @stable ICU 2.0
+ */
+U_STABLE UCollationElements* U_EXPORT2 
+ucol_openElements(const UCollator  *coll,
+                  const UChar      *text,
+                        int32_t    textLength,
+                        UErrorCode *status);
+
+/**
+ * get a hash code for a key... Not very useful!
+ * @param key    the given key.
+ * @param length the size of the key array.
+ * @return       the hash code.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_keyHashCode(const uint8_t* key, int32_t length);
+
+/**
+ * Close a UCollationElements.
+ * Once closed, a UCollationElements may no longer be used.
+ * @param elems The UCollationElements to close.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_closeElements(UCollationElements *elems);
+
+/**
+ * Reset the collation elements to their initial state.
+ * This will move the 'cursor' to the beginning of the text.
+ * Property settings for collation will be reset to the current status.
+ * @param elems The UCollationElements to reset.
+ * @see ucol_next
+ * @see ucol_previous
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_reset(UCollationElements *elems);
+
+/**
+ * Get the ordering priority of the next collation element in the text.
+ * A single character may contain more than one collation element.
+ * @param elems The UCollationElements containing the text.
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return The next collation elements ordering, otherwise returns NULLORDER 
+ *         if an error has occured or if the end of string has been reached
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_next(UCollationElements *elems, UErrorCode *status);
+
+/**
+ * Get the ordering priority of the previous collation element in the text.
+ * A single character may contain more than one collation element.
+ * Note that internally a stack is used to store buffered collation elements. 
+ * It is very rare that the stack will overflow, however if such a case is 
+ * encountered, the problem can be solved by increasing the size 
+ * UCOL_EXPAND_CE_BUFFER_SIZE in ucol_imp.h.
+ * @param elems The UCollationElements containing the text.
+ * @param status A pointer to an UErrorCode to receive any errors. Noteably 
+ *               a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack
+ *               buffer has been exhausted.
+ * @return The previous collation elements ordering, otherwise returns 
+ *         NULLORDER if an error has occured or if the start of string has 
+ *         been reached.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_previous(UCollationElements *elems, UErrorCode *status);
+
+/**
+ * Get the processed ordering priority of the next collation element in the text.
+ * A single character may contain more than one collation element.
+ *
+ * @param elems The UCollationElements containing the text.
+ * @param ixLow a pointer to an int32_t to receive the iterator index before fetching the CE.
+ * @param ixHigh a pointer to an int32_t to receive the iterator index after fetching the CE.
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return The next collation elements ordering, otherwise returns UCOL_PROCESSED_NULLORDER 
+ *         if an error has occured or if the end of string has been reached
+ *
+ * @internal
+ */
+U_INTERNAL int64_t U_EXPORT2
+ucol_nextProcessed(UCollationElements *elems, int32_t *ixLow, int32_t *ixHigh, UErrorCode *status);
+
+/**
+ * Get the processed ordering priority of the previous collation element in the text.
+ * A single character may contain more than one collation element.
+ * Note that internally a stack is used to store buffered collation elements. 
+ * It is very rare that the stack will overflow, however if such a case is 
+ * encountered, the problem can be solved by increasing the size 
+ * UCOL_EXPAND_CE_BUFFER_SIZE in ucol_imp.h.
+ *
+ * @param elems The UCollationElements containing the text.
+ * @param ixLow A pointer to an int32_t to receive the iterator index after fetching the CE
+ * @param ixHigh A pointer to an int32_t to receiver the iterator index before fetching the CE
+ * @param status A pointer to an UErrorCode to receive any errors. Noteably 
+ *               a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack
+ *               buffer has been exhausted.
+ * @return The previous collation elements ordering, otherwise returns 
+ *         UCOL_PROCESSED_NULLORDER if an error has occured or if the start of
+ *         string has been reached.
+ *
+ * @internal
+ */
+U_INTERNAL int64_t U_EXPORT2
+ucol_previousProcessed(UCollationElements *elems, int32_t *ixLow, int32_t *ixHigh, UErrorCode *status);
+
+/**
+ * Get the maximum length of any expansion sequences that end with the 
+ * specified comparison order.
+ * This is useful for .... ?
+ * @param elems The UCollationElements containing the text.
+ * @param order A collation order returned by previous or next.
+ * @return maximum size of the expansion sequences ending with the collation 
+ *         element or 1 if collation element does not occur at the end of any 
+ *         expansion sequence
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_getMaxExpansion(const UCollationElements *elems, int32_t order);
+
+/**
+ * Set the text containing the collation elements.
+ * Property settings for collation will remain the same.
+ * In order to reset the iterator to the current collation property settings,
+ * the API reset() has to be called.
+ * @param elems The UCollationElements to set.
+ * @param text The source text containing the collation elements.
+ * @param textLength The length of text, or -1 if null-terminated.
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @see ucol_getText
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_setText(      UCollationElements *elems, 
+             const UChar              *text,
+                   int32_t            textLength,
+                   UErrorCode         *status);
+
+/**
+ * Get the offset of the current source character.
+ * This is an offset into the text of the character containing the current
+ * collation elements.
+ * @param elems The UCollationElements to query.
+ * @return The offset of the current source character.
+ * @see ucol_setOffset
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ucol_getOffset(const UCollationElements *elems);
+
+/**
+ * Set the offset of the current source character.
+ * This is an offset into the text of the character to be processed.
+ * Property settings for collation will remain the same.
+ * In order to reset the iterator to the current collation property settings,
+ * the API reset() has to be called.
+ * @param elems The UCollationElements to set.
+ * @param offset The desired character offset.
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @see ucol_getOffset
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ucol_setOffset(UCollationElements *elems,
+               int32_t        offset,
+               UErrorCode         *status);
+
+/**
+* Get the primary order of a collation order.
+* @param order the collation order
+* @return the primary order of a collation order.
+* @stable ICU 2.6
+*/
+U_STABLE int32_t U_EXPORT2
+ucol_primaryOrder (int32_t order); 
+
+/**
+* Get the secondary order of a collation order.
+* @param order the collation order
+* @return the secondary order of a collation order.
+* @stable ICU 2.6
+*/
+U_STABLE int32_t U_EXPORT2
+ucol_secondaryOrder (int32_t order); 
+
+/**
+* Get the tertiary order of a collation order.
+* @param order the collation order
+* @return the tertiary order of a collation order.
+* @stable ICU 2.6
+*/
+U_STABLE int32_t U_EXPORT2
+ucol_tertiaryOrder (int32_t order); 
+
+#endif /* #if !UCONFIG_NO_COLLATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uconfig.h b/CoreFoundation/icu/unicode/uconfig.h
new file mode 100755
index 0000000..3eacd22
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uconfig.h
@@ -0,0 +1,232 @@
+/*  
+**********************************************************************
+*   Copyright (C) 2002-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*   file name:  uconfig.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2002sep19
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __UCONFIG_H__
+#define __UCONFIG_H__
+
+
+/*!
+ * \file
+ * \brief Switches for excluding parts of ICU library code modules.
+ *
+ * Allows to build partial, smaller libraries for special purposes.
+ * By default, all modules are built.
+ * The switches are fairly coarse, controlling large modules.
+ * Basic services cannot be turned off.
+ *
+ * Building with any of these options does not guarantee that the
+ * ICU build process will completely work. It is recommended that
+ * the ICU libraries and data be built using the normal build.
+ * At that time you should remove the data used by those services.
+ * After building the ICU data library, you should rebuild the ICU
+ * libraries with these switches customized to your needs.
+ *
+ * @stable ICU 2.4
+ */
+
+/**
+ * \def UCONFIG_USE_LOCAL
+ * If this switch is defined, ICU will attempt to load a header file named "uconfig_local.h"
+ * prior to determining default settings for uconfig variables.
+ * 
+ * @internal ICU 4.0
+ * 
+ */
+#if defined(UCONFIG_USE_LOCAL)
+#include "uconfig_local.h"
+#endif
+
+/**
+ * \def UCONFIG_ONLY_COLLATION
+ * This switch turns off modules that are not needed for collation.
+ *
+ * It does not turn off legacy conversion because that is necessary
+ * for ICU to work on EBCDIC platforms (for the default converter).
+ * If you want "only collation" and do not build for EBCDIC,
+ * then you can define UCONFIG_NO_LEGACY_CONVERSION 1 as well.
+ *
+ * @stable ICU 2.4
+ */
+#ifndef UCONFIG_ONLY_COLLATION
+#   define UCONFIG_ONLY_COLLATION 0
+#endif
+
+#if UCONFIG_ONLY_COLLATION
+    /* common library */
+#   define UCONFIG_NO_BREAK_ITERATION 1
+#   define UCONFIG_NO_IDNA 1
+
+    /* i18n library */
+#   if UCONFIG_NO_COLLATION
+#       error Contradictory collation switches in uconfig.h.
+#   endif
+#   define UCONFIG_NO_FORMATTING 1
+#   define UCONFIG_NO_TRANSLITERATION 1
+#   define UCONFIG_NO_REGULAR_EXPRESSIONS 1
+#endif
+
+/* common library switches -------------------------------------------------- */
+
+/**
+ * \def UCONFIG_NO_FILE_IO
+ * This switch turns off all file access in the common library
+ * where file access is only used for data loading.
+ * ICU data must then be provided in the form of a data DLL (or with an
+ * equivalent way to link to the data residing in an executable,
+ * as in building a combined library with both the common library's code and
+ * the data), or via udata_setCommonData().
+ * Application data must be provided via udata_setAppData() or by using
+ * "open" functions that take pointers to data, for example ucol_openBinary().
+ *
+ * File access is not used at all in the i18n library.
+ *
+ * File access cannot be turned off for the icuio library or for the ICU
+ * test suites and ICU tools.
+ *
+ * @stable ICU 3.6
+ */
+#ifndef UCONFIG_NO_FILE_IO
+#   define UCONFIG_NO_FILE_IO 0
+#endif
+
+/**
+ * \def UCONFIG_NO_CONVERSION
+ * ICU will not completely build with this switch turned on.
+ * This switch turns off all converters.
+ *
+ * @stable ICU 3.2
+ */
+#ifndef UCONFIG_NO_CONVERSION
+#   define UCONFIG_NO_CONVERSION 0
+#endif
+
+#if UCONFIG_NO_CONVERSION
+#   define UCONFIG_NO_LEGACY_CONVERSION 1
+#endif
+
+/**
+ * \def UCONFIG_NO_LEGACY_CONVERSION
+ * This switch turns off all converters except for
+ * - Unicode charsets (UTF-7/8/16/32, CESU-8, SCSU, BOCU-1)
+ * - US-ASCII
+ * - ISO-8859-1
+ *
+ * Turning off legacy conversion is not possible on EBCDIC platforms
+ * because they need ibm-37 or ibm-1047 default converters.
+ *
+ * @stable ICU 2.4
+ */
+#ifndef UCONFIG_NO_LEGACY_CONVERSION
+#   define UCONFIG_NO_LEGACY_CONVERSION 0
+#endif
+
+/**
+ * \def UCONFIG_NO_NORMALIZATION
+ * This switch turns off normalization.
+ * It implies turning off several other services as well, for example
+ * collation and IDNA.
+ *
+ * @stable ICU 2.6
+ */
+#ifndef UCONFIG_NO_NORMALIZATION
+#   define UCONFIG_NO_NORMALIZATION 0
+#elif UCONFIG_NO_NORMALIZATION
+    /* common library */
+#   define UCONFIG_NO_IDNA 1
+
+    /* i18n library */
+#   if UCONFIG_ONLY_COLLATION
+#       error Contradictory collation switches in uconfig.h.
+#   endif
+#   define UCONFIG_NO_COLLATION 1
+#   define UCONFIG_NO_TRANSLITERATION 1
+#endif
+
+/**
+ * \def UCONFIG_NO_BREAK_ITERATION
+ * This switch turns off break iteration.
+ *
+ * @stable ICU 2.4
+ */
+#ifndef UCONFIG_NO_BREAK_ITERATION
+#   define UCONFIG_NO_BREAK_ITERATION 0
+#endif
+
+/**
+ * \def UCONFIG_NO_IDNA
+ * This switch turns off IDNA.
+ *
+ * @stable ICU 2.6
+ */
+#ifndef UCONFIG_NO_IDNA
+#   define UCONFIG_NO_IDNA 0
+#endif
+
+/* i18n library switches ---------------------------------------------------- */
+
+/**
+ * \def UCONFIG_NO_COLLATION
+ * This switch turns off collation and collation-based string search.
+ *
+ * @stable ICU 2.4
+ */
+#ifndef UCONFIG_NO_COLLATION
+#   define UCONFIG_NO_COLLATION 0
+#endif
+
+/**
+ * \def UCONFIG_NO_FORMATTING
+ * This switch turns off formatting and calendar/timezone services.
+ *
+ * @stable ICU 2.4
+ */
+#ifndef UCONFIG_NO_FORMATTING
+#   define UCONFIG_NO_FORMATTING 0
+#endif
+
+/**
+ * \def UCONFIG_NO_TRANSLITERATION
+ * This switch turns off transliteration.
+ *
+ * @stable ICU 2.4
+ */
+#ifndef UCONFIG_NO_TRANSLITERATION
+#   define UCONFIG_NO_TRANSLITERATION 0
+#endif
+
+/**
+ * \def UCONFIG_NO_REGULAR_EXPRESSIONS
+ * This switch turns off regular expressions.
+ *
+ * @stable ICU 2.4
+ */
+#ifndef UCONFIG_NO_REGULAR_EXPRESSIONS
+#   define UCONFIG_NO_REGULAR_EXPRESSIONS 0
+#endif
+
+/**
+ * \def UCONFIG_NO_SERVICE
+ * This switch turns off service registration.
+ *
+ * @stable ICU 3.2
+ */
+#ifndef UCONFIG_NO_SERVICE
+#if DEPLOYMENT_TARGET_MACOSX 
+#   define UCONFIG_NO_SERVICE 0
+#else
+#   define UCONFIG_NO_SERVICE 1
+#endif
+#endif
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ucsdet.h b/CoreFoundation/icu/unicode/ucsdet.h
new file mode 100644
index 0000000..31f622c
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucsdet.h
@@ -0,0 +1,349 @@
+/*
+ **********************************************************************
+ *   Copyright (C) 2005-2007, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ **********************************************************************
+ *   file name:  ucsdet.h
+ *   encoding:   US-ASCII
+ *   indentation:4
+ *
+ *   created on: 2005Aug04
+ *   created by: Andy Heninger
+ *
+ *   ICU Character Set Detection, API for C
+ *
+ *   Draft version 18 Oct 2005
+ *
+ */
+
+#ifndef __UCSDET_H
+#define __UCSDET_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_CONVERSION
+#include "unicode/uenum.h"
+
+/**
+ * \file 
+ * \brief C API: Charset Detection API
+ *
+ * This API provides a facility for detecting the
+ * charset or encoding of character data in an unknown text format.
+ * The input data can be from an array of bytes.
+ * <p>
+ * Character set detection is at best an imprecise operation.  The detection
+ * process will attempt to identify the charset that best matches the characteristics
+ * of the byte data, but the process is partly statistical in nature, and
+ * the results can not be guaranteed to always be correct.
+ * <p>
+ * For best accuracy in charset detection, the input data should be primarily
+ * in a single language, and a minimum of a few hundred bytes worth of plain text
+ * in the language are needed.  The detection process will attempt to
+ * ignore html or xml style markup that could otherwise obscure the content.
+ */
+ 
+
+struct UCharsetDetector;
+/**
+  * Structure representing a charset detector
+  * @stable ICU 3.6
+  */
+typedef struct UCharsetDetector UCharsetDetector;
+
+struct UCharsetMatch;
+/**
+  *  Opaque structure representing a match that was identified
+  *  from a charset detection operation.
+  *  @stable ICU 3.6
+  */
+typedef struct UCharsetMatch UCharsetMatch;
+
+/**
+  *  Open a charset detector.
+  *
+  *  @param status Any error conditions occurring during the open
+  *                operation are reported back in this variable.
+  *  @return the newly opened charset detector.
+  *  @stable ICU 3.6
+  */
+U_STABLE UCharsetDetector * U_EXPORT2
+ucsdet_open(UErrorCode   *status);
+
+/**
+  * Close a charset detector.  All storage and any other resources
+  *   owned by this charset detector will be released.  Failure to
+  *   close a charset detector when finished with it can result in
+  *   memory leaks in the application.
+  *
+  *  @param ucsd  The charset detector to be closed.
+  *  @stable ICU 3.6
+  */
+U_STABLE void U_EXPORT2
+ucsdet_close(UCharsetDetector *ucsd);
+
+/**
+  * Set the input byte data whose charset is to detected.
+  *
+  * Ownership of the input  text byte array remains with the caller.
+  * The input string must not be altered or deleted until the charset
+  * detector is either closed or reset to refer to different input text.
+  *
+  * @param ucsd   the charset detector to be used.
+  * @param textIn the input text of unknown encoding.   .
+  * @param len    the length of the input text, or -1 if the text
+  *               is NUL terminated.
+  * @param status any error conditions are reported back in this variable.
+  *
+  * @stable ICU 3.6
+  */
+U_STABLE void U_EXPORT2
+ucsdet_setText(UCharsetDetector *ucsd, const char *textIn, int32_t len, UErrorCode *status);
+
+
+/** Set the declared encoding for charset detection.
+ *  The declared encoding of an input text is an encoding obtained
+ *  by the user from an http header or xml declaration or similar source that
+ *  can be provided as an additional hint to the charset detector.
+ *
+ *  How and whether the declared encoding will be used during the
+ *  detection process is TBD.
+ *
+ * @param ucsd      the charset detector to be used.
+ * @param encoding  an encoding for the current data obtained from
+ *                  a header or declaration or other source outside
+ *                  of the byte data itself.
+ * @param length    the length of the encoding name, or -1 if the name string
+ *                  is NUL terminated.
+ * @param status    any error conditions are reported back in this variable.
+ *
+ * @stable ICU 3.6
+ */
+U_STABLE void U_EXPORT2
+ucsdet_setDeclaredEncoding(UCharsetDetector *ucsd, const char *encoding, int32_t length, UErrorCode *status);
+
+
+/**
+ * Return the charset that best matches the supplied input data.
+ * 
+ * Note though, that because the detection 
+ * only looks at the start of the input data,
+ * there is a possibility that the returned charset will fail to handle
+ * the full set of input data.
+ * <p>
+ * The returned UCharsetMatch object is owned by the UCharsetDetector.
+ * It will remain valid until the detector input is reset, or until
+ * the detector is closed.
+ * <p>
+ * The function will fail if
+ *  <ul>
+ *    <li>no charset appears to match the data.</li>
+ *    <li>no input text has been provided</li>
+ *  </ul>
+ *
+ * @param ucsd      the charset detector to be used.
+ * @param status    any error conditions are reported back in this variable.
+ * @return          a UCharsetMatch  representing the best matching charset,
+ *                  or NULL if no charset matches the byte data.
+ *
+ * @stable ICU 3.6
+ */
+U_STABLE const UCharsetMatch * U_EXPORT2
+ucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status);
+    
+
+/**
+ *  Find all charset matches that appear to be consistent with the input,
+ *  returning an array of results.  The results are ordered with the
+ *  best quality match first.
+ *
+ *  Because the detection only looks at a limited amount of the
+ *  input byte data, some of the returned charsets may fail to handle
+ *  the all of input data.
+ *  <p>
+ *  The returned UCharsetMatch objects are owned by the UCharsetDetector.
+ *  They will remain valid until the detector is closed or modified
+ *  
+ * <p>
+ * Return an error if 
+ *  <ul>
+ *    <li>no charsets appear to match the input data.</li>
+ *    <li>no input text has been provided</li>
+ *  </ul>
+ * 
+ * @param ucsd          the charset detector to be used.
+ * @param matchesFound  pointer to a variable that will be set to the
+ *                      number of charsets identified that are consistent with
+ *                      the input data.  Output only.
+ * @param status        any error conditions are reported back in this variable.
+ * @return              A pointer to an array of pointers to UCharSetMatch objects.
+ *                      This array, and the UCharSetMatch instances to which it refers,
+ *                      are owned by the UCharsetDetector, and will remain valid until
+ *                      the detector is closed or modified.
+ * @stable ICU 3.6
+ */
+U_STABLE const UCharsetMatch ** U_EXPORT2
+ucsdet_detectAll(UCharsetDetector *ucsd, int32_t *matchesFound, UErrorCode *status);
+
+
+
+/**
+ *  Get the name of the charset represented by a UCharsetMatch.
+ *
+ *  The storage for the returned name string is owned by the
+ *  UCharsetMatch, and will remain valid while the UCharsetMatch
+ *  is valid.
+ *
+ *  The name returned is suitable for use with the ICU conversion APIs.
+ *
+ *  @param ucsm    The charset match object.
+ *  @param status  Any error conditions are reported back in this variable.
+ *  @return        The name of the matching charset.
+ *
+ *  @stable ICU 3.6
+ */
+U_STABLE const char * U_EXPORT2
+ucsdet_getName(const UCharsetMatch *ucsm, UErrorCode *status);
+
+/**
+ *  Get a confidence number for the quality of the match of the byte
+ *  data with the charset.  Confidence numbers range from zero to 100,
+ *  with 100 representing complete confidence and zero representing
+ *  no confidence.
+ *
+ *  The confidence values are somewhat arbitrary.  They define an
+ *  an ordering within the results for any single detection operation
+ *  but are not generally comparable between the results for different input.
+ *
+ *  A confidence value of ten does have a general meaning - it is used
+ *  for charsets that can represent the input data, but for which there
+ *  is no other indication that suggests that the charset is the correct one.
+ *  Pure 7 bit ASCII data, for example, is compatible with a
+ *  great many charsets, most of which will appear as possible matches
+ *  with a confidence of 10.
+ *
+ *  @param ucsm    The charset match object.
+ *  @param status  Any error conditions are reported back in this variable.
+ *  @return        A confidence number for the charset match.
+ *
+ *  @stable ICU 3.6
+ */
+U_STABLE int32_t U_EXPORT2
+ucsdet_getConfidence(const UCharsetMatch *ucsm, UErrorCode *status);
+
+/**
+ *  Get the RFC 3066 code for the language of the input data.
+ *
+ *  The Charset Detection service is intended primarily for detecting
+ *  charsets, not language.  For some, but not all, charsets, a language is
+ *  identified as a byproduct of the detection process, and that is what
+ *  is returned by this function.
+ *
+ *  CAUTION:
+ *    1.  Language information is not available for input data encoded in
+ *        all charsets. In particular, no language is identified
+ *        for UTF-8 input data.
+ *
+ *    2.  Closely related languages may sometimes be confused.
+ *
+ *  If more accurate language detection is required, a linguistic
+ *  analysis package should be used.
+ *
+ *  The storage for the returned name string is owned by the
+ *  UCharsetMatch, and will remain valid while the UCharsetMatch
+ *  is valid.
+ *
+ *  @param ucsm    The charset match object.
+ *  @param status  Any error conditions are reported back in this variable.
+ *  @return        The RFC 3066 code for the language of the input data, or
+ *                 an empty string if the language could not be determined.
+ *
+ *  @stable ICU 3.6
+ */
+U_STABLE const char * U_EXPORT2
+ucsdet_getLanguage(const UCharsetMatch *ucsm, UErrorCode *status);
+
+
+/**
+  *  Get the entire input text as a UChar string, placing it into
+  *  a caller-supplied buffer.  A terminating
+  *  NUL character will be appended to the buffer if space is available.
+  *
+  *  The number of UChars in the output string, not including the terminating
+  *  NUL, is returned. 
+  *
+  *  If the supplied buffer is smaller than required to hold the output,
+  *  the contents of the buffer are undefined.  The full output string length
+  *  (in UChars) is returned as always, and can be used to allocate a buffer
+  *  of the correct size.
+  *
+  *
+  * @param ucsm    The charset match object.
+  * @param buf     A UChar buffer to be filled with the converted text data.
+  * @param cap     The capacity of the buffer in UChars.
+  * @param status  Any error conditions are reported back in this variable.
+  * @return        The number of UChars in the output string.
+  *
+  * @stable ICU 3.6
+  */
+U_STABLE  int32_t U_EXPORT2
+ucsdet_getUChars(const UCharsetMatch *ucsm,
+                 UChar *buf, int32_t cap, UErrorCode *status);
+
+
+
+/**
+  *  Get an iterator over the set of all detectable charsets - 
+  *  over the charsets that are known to the charset detection
+  *  service.
+  *
+  *  The returned UEnumeration provides access to the names of
+  *  the charsets.
+  *
+  *  The state of the Charset detector that is passed in does not
+  *  affect the result of this function, but requiring a valid, open
+  *  charset detector as a parameter insures that the charset detection
+  *  service has been safely initialized and that the required detection
+  *  data is available.
+  *
+  *  @param ucsd a Charset detector.
+  *  @param status  Any error conditions are reported back in this variable.
+  *  @return an iterator providing access to the detectable charset names.
+  *  @stable ICU 3.6
+  */
+U_STABLE  UEnumeration * U_EXPORT2
+ucsdet_getAllDetectableCharsets(const UCharsetDetector *ucsd,  UErrorCode *status);
+
+
+/**
+  *  Test whether input filtering is enabled for this charset detector.
+  *  Input filtering removes text that appears to be HTML or xml
+  *  markup from the input before applying the code page detection
+  *  heuristics.
+  *
+  *  @param ucsd  The charset detector to check.
+  *  @return TRUE if filtering is enabled.
+  *  @stable ICU 3.6
+  */
+U_STABLE  UBool U_EXPORT2
+ucsdet_isInputFilterEnabled(const UCharsetDetector *ucsd);
+
+
+/**
+ * Enable filtering of input text. If filtering is enabled,
+ * text within angle brackets ("<" and ">") will be removed
+ * before detection, which will remove most HTML or xml markup.
+ *
+ * @param ucsd   the charset detector to be modified.
+ * @param filter <code>true</code> to enable input text filtering.
+ * @return The previous setting.
+ *
+ * @stable ICU 3.6
+ */
+U_STABLE  UBool U_EXPORT2
+ucsdet_enableInputFilter(UCharsetDetector *ucsd, UBool filter);
+
+#endif
+#endif   /* __UCSDET_H */
+
+
diff --git a/CoreFoundation/icu/unicode/ucurr.h b/CoreFoundation/icu/unicode/ucurr.h
new file mode 100644
index 0000000..9e336c2
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ucurr.h
@@ -0,0 +1,270 @@
+/*
+**********************************************************************
+* Copyright (c) 2002-2008, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+*/
+#ifndef _UCURR_H_
+#define _UCURR_H_
+
+#include "unicode/utypes.h"
+#include "unicode/uenum.h"
+
+/**
+ * \file 
+ * \brief C API: Encapsulates information about a currency.
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+/**
+ * The ucurr API encapsulates information about a currency, as defined by
+ * ISO 4217.  A currency is represented by a 3-character string
+ * containing its ISO 4217 code.  This API can return various data
+ * necessary the proper display of a currency:
+ *
+ * <ul><li>A display symbol, for a specific locale
+ * <li>The number of fraction digits to display
+ * <li>A rounding increment
+ * </ul>
+ *
+ * The <tt>DecimalFormat</tt> class uses these data to display
+ * currencies.
+ * @author Alan Liu
+ * @since ICU 2.2
+ */
+
+/**
+ * Finds a currency code for the given locale.
+ * @param locale the locale for which to retrieve a currency code. 
+ *               Currency can be specified by the "currency" keyword
+ *               in which case it overrides the default currency code
+ * @param buff   fill in buffer. Can be NULL for preflighting.
+ * @param buffCapacity capacity of the fill in buffer. Can be 0 for
+ *               preflighting. If it is non-zero, the buff parameter
+ *               must not be NULL.
+ * @param ec error code
+ * @return length of the currency string. It should always be 3. If 0,
+ *                currency couldn't be found or the input values are 
+ *                invalid. 
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+ucurr_forLocale(const char* locale,
+                UChar* buff,
+                int32_t buffCapacity,
+                UErrorCode* ec);
+
+/**
+ * Selector constants for ucurr_getName().
+ *
+ * @see ucurr_getName
+ * @stable ICU 2.6
+ */
+typedef enum UCurrNameStyle {
+    /**
+     * Selector for ucurr_getName indicating a symbolic name for a
+     * currency, such as "$" for USD.
+     * @stable ICU 2.6
+     */
+    UCURR_SYMBOL_NAME,
+
+    /**
+     * Selector for ucurr_getName indicating the long name for a
+     * currency, such as "US Dollar" for USD.
+     * @stable ICU 2.6
+     */
+    UCURR_LONG_NAME
+} UCurrNameStyle;
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * @stable ICU 2.6
+ */
+typedef const void* UCurrRegistryKey;
+
+/**
+ * Register an (existing) ISO 4217 currency code for the given locale.
+ * Only the country code and the two variants EURO and PRE_EURO are
+ * recognized.
+ * @param isoCode the three-letter ISO 4217 currency code
+ * @param locale  the locale for which to register this currency code
+ * @param status the in/out status code
+ * @return a registry key that can be used to unregister this currency code, or NULL
+ * if there was an error.
+ * @stable ICU 2.6
+ */
+U_STABLE UCurrRegistryKey U_EXPORT2
+ucurr_register(const UChar* isoCode, 
+                   const char* locale,  
+                   UErrorCode* status);
+/**
+ * Unregister the previously-registered currency definitions using the
+ * URegistryKey returned from ucurr_register.  Key becomes invalid after
+ * a successful call and should not be used again.  Any currency 
+ * that might have been hidden by the original ucurr_register call is 
+ * restored.
+ * @param key the registry key returned by a previous call to ucurr_register
+ * @param status the in/out status code, no special meanings are assigned
+ * @return TRUE if the currency for this key was successfully unregistered
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+ucurr_unregister(UCurrRegistryKey key, UErrorCode* status);
+#endif /* UCONFIG_NO_SERVICE */
+
+/**
+ * Returns the display name for the given currency in the
+ * given locale.  For example, the display name for the USD
+ * currency object in the en_US locale is "$".
+ * @param currency null-terminated 3-letter ISO 4217 code
+ * @param locale locale in which to display currency
+ * @param nameStyle selector for which kind of name to return
+ * @param isChoiceFormat fill-in set to TRUE if the returned value
+ * is a ChoiceFormat pattern; otherwise it is a static string
+ * @param len fill-in parameter to receive length of result
+ * @param ec error code
+ * @return pointer to display string of 'len' UChars.  If the resource
+ * data contains no entry for 'currency', then 'currency' itself is
+ * returned.  If *isChoiceFormat is TRUE, then the result is a
+ * ChoiceFormat pattern.  Otherwise it is a static string.
+ * @stable ICU 2.6
+ */
+U_STABLE const UChar* U_EXPORT2
+ucurr_getName(const UChar* currency,
+              const char* locale,
+              UCurrNameStyle nameStyle,
+              UBool* isChoiceFormat,
+              int32_t* len,
+              UErrorCode* ec);
+
+/**
+ * Returns the number of the number of fraction digits that should
+ * be displayed for the given currency.
+ * @param currency null-terminated 3-letter ISO 4217 code
+ * @param ec input-output error code
+ * @return a non-negative number of fraction digits to be
+ * displayed, or 0 if there is an error
+ * @stable ICU 3.0
+ */
+U_STABLE int32_t U_EXPORT2
+ucurr_getDefaultFractionDigits(const UChar* currency,
+                               UErrorCode* ec);
+
+/**
+ * Returns the rounding increment for the given currency, or 0.0 if no
+ * rounding is done by the currency.
+ * @param currency null-terminated 3-letter ISO 4217 code
+ * @param ec input-output error code
+ * @return the non-negative rounding increment, or 0.0 if none,
+ * or 0.0 if there is an error
+ * @stable ICU 3.0
+ */
+U_STABLE double U_EXPORT2
+ucurr_getRoundingIncrement(const UChar* currency,
+                           UErrorCode* ec);
+
+/**
+ * Selector constants for ucurr_openCurrencies().
+ *
+ * @see ucurr_openCurrencies
+ * @stable ICU 3.2
+ */
+typedef enum UCurrCurrencyType {
+    /**
+     * Select all ISO-4217 currency codes.
+     * @stable ICU 3.2
+     */
+    UCURR_ALL = INT32_MAX,
+    /**
+     * Select only ISO-4217 commonly used currency codes.
+     * These currencies can be found in common use, and they usually have
+     * bank notes or coins associated with the currency code.
+     * This does not include fund codes, precious metals and other
+     * various ISO-4217 codes limited to special financial products.
+     * @stable ICU 3.2
+     */
+    UCURR_COMMON = 1,
+    /**
+     * Select ISO-4217 uncommon currency codes.
+     * These codes respresent fund codes, precious metals and other
+     * various ISO-4217 codes limited to special financial products.
+     * A fund code is a monetary resource associated with a currency.
+     * @stable ICU 3.2
+     */
+    UCURR_UNCOMMON = 2,
+    /**
+     * Select only deprecated ISO-4217 codes.
+     * These codes are no longer in general public use.
+     * @stable ICU 3.2
+     */
+    UCURR_DEPRECATED = 4,
+    /**
+     * Select only non-deprecated ISO-4217 codes.
+     * These codes are in general public use.
+     * @stable ICU 3.2
+     */
+    UCURR_NON_DEPRECATED = 8
+} UCurrCurrencyType;
+
+/**
+ * Provides a UEnumeration object for listing ISO-4217 codes.
+ * @param currType You can use one of several UCurrCurrencyType values for this
+ *      variable. You can also | (or) them together to get a specific list of
+ *      currencies. Most people will want to use the (UCURR_CURRENCY|UCURR_NON_DEPRECATED) value to
+ *      get a list of current currencies.
+ * @param pErrorCode Error code
+ * @stable ICU 3.2
+ */
+U_STABLE UEnumeration * U_EXPORT2
+ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode);
+
+/** 
+ * Finds the number of valid currency codes for the
+ * given locale and date.
+ * @param locale the locale for which to retrieve the
+ *               currency count.
+ * @param date   the date for which to retrieve the
+ *               currency count for the given locale.
+ * @param ec     error code
+ * @return       the number of currency codes for the
+ *               given locale and date.  If 0, currency
+ *               codes couldn't be found for the input
+ *               values are invalid.
+ * @draft ICU 4.0
+ */ 
+U_DRAFT int32_t U_EXPORT2
+ucurr_countCurrencies(const char* locale, 
+                 UDate date, 
+                 UErrorCode* ec); 
+
+/** 
+ * Finds a currency code for the given locale and date 
+ * @param locale the locale for which to retrieve a currency code.  
+ *               Currency can be specified by the "currency" keyword 
+ *               in which case it overrides the default currency code 
+ * @param date   the date for which to retrieve a currency code for 
+ *               the given locale. 
+ * @param index  the index within the available list of currency codes
+ *               for the given locale on the given date.
+ * @param buff   fill in buffer. Can be NULL for preflighting. 
+ * @param buffCapacity capacity of the fill in buffer. Can be 0 for 
+ *               preflighting. If it is non-zero, the buff parameter 
+ *               must not be NULL. 
+ * @param ec     error code 
+ * @return       length of the currency string. It should always be 3. 
+ *               If 0, currency couldn't be found or the input values are  
+ *               invalid.  
+ * @draft ICU 4.0 
+ */ 
+U_DRAFT int32_t U_EXPORT2 
+ucurr_forLocaleAndDate(const char* locale, 
+                UDate date, 
+                int32_t index,
+                UChar* buff, 
+                int32_t buffCapacity, 
+                UErrorCode* ec); 
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/udat.h b/CoreFoundation/icu/unicode/udat.h
new file mode 100644
index 0000000..1d0ea98
--- /dev/null
+++ b/CoreFoundation/icu/unicode/udat.h
@@ -0,0 +1,899 @@
+/*
+ *******************************************************************************
+ * Copyright (C) 1996-2008, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *******************************************************************************
+*/
+
+#ifndef UDAT_H
+#define UDAT_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ucal.h"
+#include "unicode/unum.h"
+/**
+ * \file
+ * \brief C API: DateFormat
+ *
+ * <h2> Date Format C API</h2>
+ *
+ * Date Format C API  consists of functions that convert dates and
+ * times from their internal representations to textual form and back again in a
+ * language-independent manner. Converting from the internal representation (milliseconds
+ * since midnight, January 1, 1970) to text is known as "formatting," and converting
+ * from text to millis is known as "parsing."  We currently define only one concrete
+ * structure UDateFormat, which can handle pretty much all normal
+ * date formatting and parsing actions.
+ * <P>
+ * Date Format helps you to format and parse dates for any locale. Your code can
+ * be completely independent of the locale conventions for months, days of the
+ * week, or even the calendar format: lunar vs. solar.
+ * <P>
+ * To format a date for the current Locale with default time and date style,
+ * use one of the static factory methods:
+ * <pre>
+ * \code
+ *  UErrorCode status = U_ZERO_ERROR;
+ *  UChar *myString;
+ *  int32_t myStrlen = 0;
+ *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, -1, &status);
+ *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status);
+ *  if (status==U_BUFFER_OVERFLOW_ERROR){
+ *      status=U_ZERO_ERROR;
+ *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
+ *      udat_format(dfmt, myDate, myString, myStrlen+1, NULL, &status);
+ *  }
+ * \endcode
+ * </pre>
+ * If you are formatting multiple numbers, it is more efficient to get the
+ * format and use it multiple times so that the system doesn't have to fetch the
+ * information about the local language and country conventions multiple times.
+ * <pre>
+ * \code
+ *  UErrorCode status = U_ZERO_ERROR;
+ *  int32_t i, myStrlen = 0;
+ *  UChar* myString;
+ *  char buffer[1024];
+ *  UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
+ *  UDateFormat* df = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, 0, &status);
+ *  for (i = 0; i < 3; i++) {
+ *      myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status);
+ *      if(status == U_BUFFER_OVERFLOW_ERROR){
+ *          status = U_ZERO_ERROR;
+ *          myString = (UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
+ *          udat_format(df, myDateArr[i], myString, myStrlen+1, NULL, &status);
+ *          printf("%s\n", u_austrcpy(buffer, myString) );
+ *          free(myString);
+ *      }
+ *  }
+ * \endcode
+ * </pre>
+ * To get specific fields of a date, you can use UFieldPosition to
+ * get specific fields.
+ * <pre>
+ * \code
+ *  UErrorCode status = U_ZERO_ERROR;
+ *  UFieldPosition pos;
+ *  UChar *myString;
+ *  int32_t myStrlen = 0;
+ *  char buffer[1024];
+ *
+ *  pos.field = 1;  // Same as the DateFormat::EField enum
+ *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, -1, NULL, 0, &status);
+ *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
+ *  if (status==U_BUFFER_OVERFLOW_ERROR){
+ *      status=U_ZERO_ERROR;
+ *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
+ *      udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);
+ *  }
+ *  printf("date format: %s\n", u_austrcpy(buffer, myString));
+ *  buffer[pos.endIndex] = 0;   // NULL terminate the string.
+ *  printf("UFieldPosition position equals %s\n", &buffer[pos.beginIndex]);
+ * \endcode
+ * </pre>
+ * To format a date for a different Locale, specify it in the call to
+ * udat_open()
+ * <pre>
+ * \code
+ *        UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", NULL, -1, NULL, 0, &status);
+ * \endcode
+ * </pre>
+ * You can use a DateFormat API udat_parse() to parse.
+ * <pre>
+ * \code
+ *  UErrorCode status = U_ZERO_ERROR;
+ *  int32_t parsepos=0;
+ *  UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);
+ * \endcode
+ * </pre>
+ *  You can pass in different options for the arguments for date and time style
+ *  to control the length of the result; from SHORT to MEDIUM to LONG to FULL.
+ *  The exact result depends on the locale, but generally:
+ *  see UDateFormatStyle for more details
+ * <ul type=round>
+ *   <li>   UDAT_SHORT is completely numeric, such as 12/13/52 or 3:30pm
+ *   <li>   UDAT_MEDIUM is longer, such as Jan 12, 1952
+ *   <li>   UDAT_LONG is longer, such as January 12, 1952 or 3:30:32pm
+ *   <li>   UDAT_FULL is pretty completely specified, such as
+ *          Tuesday, April 12, 1952 AD or 3:30:42pm PST.
+ * </ul>
+ * You can also set the time zone on the format if you wish.
+ * <P>
+ * You can also use forms of the parse and format methods with Parse Position and
+ * UFieldPosition to allow you to
+ * <ul type=round>
+ *   <li>   Progressively parse through pieces of a string.
+ *   <li>   Align any particular field, or find out where it is for selection
+ *          on the screen.
+ * </ul>
+ */
+
+/** A date formatter.
+ *  For usage in C programs.
+ *  @stable ICU 2.6
+ */
+typedef void* UDateFormat;
+
+/** The possible date/time format styles 
+ *  @stable ICU 2.6
+ */
+typedef enum UDateFormatStyle {
+    /** Full style */
+    UDAT_FULL,
+    /** Long style */
+    UDAT_LONG,
+    /** Medium style */
+    UDAT_MEDIUM,
+    /** Short style */
+    UDAT_SHORT,
+    /** Default style */
+    UDAT_DEFAULT = UDAT_MEDIUM,
+
+    /** Bitfield for relative date */
+    UDAT_RELATIVE = (1 << 7),
+    
+    UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
+        
+    UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
+    
+    UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
+    
+    UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
+    
+    
+    /** No style */
+    UDAT_NONE = -1,
+    /** for internal API use only */
+    UDAT_IGNORE = -2
+
+} UDateFormatStyle;
+
+
+/**
+ * Below are a set of pre-defined skeletons.
+ *
+ * <P>
+ * A skeleton 
+ * <ol>
+ * <li>
+ *    only keeps the field pattern letter and ignores all other parts 
+ *    in a pattern, such as space, punctuations, and string literals.
+ * </li>
+ * <li>
+ *    hides the order of fields. 
+ * </li>
+ * <li>
+ *    might hide a field's pattern letter length.
+ *
+ *    For those non-digit calendar fields, the pattern letter length is 
+ *    important, such as MMM, MMMM, and MMMMM; EEE and EEEE, 
+ *    and the field's pattern letter length is honored.
+ *    
+ *    For the digit calendar fields,  such as M or MM, d or dd, yy or yyyy, 
+ *    the field pattern length is ignored and the best match, which is defined 
+ *    in date time patterns, will be returned without honor the field pattern
+ *    letter length in skeleton.
+ * </li>
+ * </ol>
+ *
+ * @draft ICU 4.0
+ */
+
+#define UDAT_MINUTE_SECOND              "ms"
+#define UDAT_HOUR24_MINUTE              "Hm"
+#define UDAT_HOUR24_MINUTE_SECOND       "Hms"      
+#define UDAT_HOUR_MINUTE_SECOND         "hms"
+#define UDAT_STANDALONE_MONTH           "LLLL"
+#define UDAT_ABBR_STANDALONE_MONTH      "LLL"
+#define UDAT_YEAR_QUARTER               "yQQQ"
+#define UDAT_YEAR_ABBR_QUARTER          "yQ"
+/**
+ * Below are a set of pre-defined skeletons that 
+ * have pre-defined interval patterns in resource files.
+ * Users are encouraged to use them in date interval format factory methods.
+ *
+ */
+#define UDAT_HOUR_MINUTE                "hm"
+#define UDAT_YEAR                       "y"
+#define UDAT_DAY                        "d"
+#define UDAT_NUM_MONTH_WEEKDAY_DAY      "MEd"
+#define UDAT_YEAR_NUM_MONTH             "yM"              
+#define UDAT_NUM_MONTH_DAY              "Md"
+#define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
+#define UDAT_ABBR_MONTH_WEEKDAY_DAY     "MMMEd"
+#define UDAT_YEAR_MONTH                 "yMMMM"
+#define UDAT_YEAR_ABBR_MONTH            "yMMM"
+#define UDAT_MONTH_DAY                  "MMMMd"
+#define UDAT_ABBR_MONTH_DAY             "MMMd" 
+#define UDAT_MONTH_WEEKDAY_DAY          "MMMMEEEEd"
+#define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd" 
+#define UDAT_YEAR_MONTH_WEEKDAY_DAY     "yMMMMEEEEd"
+#define UDAT_YEAR_MONTH_DAY             "yMMMMd"
+#define UDAT_YEAR_ABBR_MONTH_DAY        "yMMMd"
+#define UDAT_YEAR_NUM_MONTH_DAY         "yMd"
+#define UDAT_NUM_MONTH                  "M"
+#define UDAT_ABBR_MONTH                 "MMM"
+#define UDAT_MONTH                      "MMMM"
+#define UDAT_HOUR_MINUTE_GENERIC_TZ     "hmv"
+#define UDAT_HOUR_MINUTE_TZ             "hmz"
+#define UDAT_HOUR                       "h"
+#define UDAT_HOUR_GENERIC_TZ            "hv"
+#define UDAT_HOUR_TZ                    "hz"
+
+
+/**
+ * FieldPosition and UFieldPosition selectors for format fields
+ * defined by DateFormat and UDateFormat.
+ * @stable ICU 3.0
+ */
+typedef enum UDateFormatField {
+    /**
+     * FieldPosition and UFieldPosition selector for 'G' field alignment,
+     * corresponding to the UCAL_ERA field.
+     * @stable ICU 3.0
+     */
+    UDAT_ERA_FIELD = 0,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'y' field alignment,
+     * corresponding to the UCAL_YEAR field.
+     * @stable ICU 3.0
+     */
+    UDAT_YEAR_FIELD = 1,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'M' field alignment,
+     * corresponding to the UCAL_MONTH field.
+     * @stable ICU 3.0
+     */
+    UDAT_MONTH_FIELD = 2,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'd' field alignment,
+     * corresponding to the UCAL_DATE field.
+     * @stable ICU 3.0
+     */
+    UDAT_DATE_FIELD = 3,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'k' field alignment,
+     * corresponding to the UCAL_HOUR_OF_DAY field.
+     * UDAT_HOUR_OF_DAY1_FIELD is used for the one-based 24-hour clock.
+     * For example, 23:59 + 01:00 results in 24:59.
+     * @stable ICU 3.0
+     */
+    UDAT_HOUR_OF_DAY1_FIELD = 4,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'H' field alignment,
+     * corresponding to the UCAL_HOUR_OF_DAY field.
+     * UDAT_HOUR_OF_DAY0_FIELD is used for the zero-based 24-hour clock.
+     * For example, 23:59 + 01:00 results in 00:59.
+     * @stable ICU 3.0
+     */
+    UDAT_HOUR_OF_DAY0_FIELD = 5,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'm' field alignment,
+     * corresponding to the UCAL_MINUTE field.
+     * @stable ICU 3.0
+     */
+    UDAT_MINUTE_FIELD = 6,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 's' field alignment,
+     * corresponding to the UCAL_SECOND field.
+     * @stable ICU 3.0
+     */
+    UDAT_SECOND_FIELD = 7,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'S' field alignment,
+     * corresponding to the UCAL_MILLISECOND field.
+     * @stable ICU 3.0
+     */
+    UDAT_FRACTIONAL_SECOND_FIELD = 8,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'E' field alignment,
+     * corresponding to the UCAL_DAY_OF_WEEK field.
+     * @stable ICU 3.0
+     */
+    UDAT_DAY_OF_WEEK_FIELD = 9,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'D' field alignment,
+     * corresponding to the UCAL_DAY_OF_YEAR field.
+     * @stable ICU 3.0
+     */
+    UDAT_DAY_OF_YEAR_FIELD = 10,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'F' field alignment,
+     * corresponding to the UCAL_DAY_OF_WEEK_IN_MONTH field.
+     * @stable ICU 3.0
+     */
+    UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'w' field alignment,
+     * corresponding to the UCAL_WEEK_OF_YEAR field.
+     * @stable ICU 3.0
+     */
+    UDAT_WEEK_OF_YEAR_FIELD = 12,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'W' field alignment,
+     * corresponding to the UCAL_WEEK_OF_MONTH field.
+     * @stable ICU 3.0
+     */
+    UDAT_WEEK_OF_MONTH_FIELD = 13,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'a' field alignment,
+     * corresponding to the UCAL_AM_PM field.
+     * @stable ICU 3.0
+     */
+    UDAT_AM_PM_FIELD = 14,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'h' field alignment,
+     * corresponding to the UCAL_HOUR field.
+     * UDAT_HOUR1_FIELD is used for the one-based 12-hour clock.
+     * For example, 11:30 PM + 1 hour results in 12:30 AM.
+     * @stable ICU 3.0
+     */
+    UDAT_HOUR1_FIELD = 15,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'K' field alignment,
+     * corresponding to the UCAL_HOUR field.
+     * UDAT_HOUR0_FIELD is used for the zero-based 12-hour clock.
+     * For example, 11:30 PM + 1 hour results in 00:30 AM.
+     * @stable ICU 3.0
+     */
+    UDAT_HOUR0_FIELD = 16,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'z' field alignment,
+     * corresponding to the UCAL_ZONE_OFFSET and
+     * UCAL_DST_OFFSET fields.
+     * @stable ICU 3.0
+     */
+    UDAT_TIMEZONE_FIELD = 17,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'Y' field alignment,
+     * corresponding to the UCAL_YEAR_WOY field.
+     * @stable ICU 3.0
+     */
+    UDAT_YEAR_WOY_FIELD = 18,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'e' field alignment,
+     * corresponding to the UCAL_DOW_LOCAL field.
+     * @stable ICU 3.0
+     */
+    UDAT_DOW_LOCAL_FIELD = 19,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'u' field alignment,
+     * corresponding to the UCAL_EXTENDED_YEAR field.
+     * @stable ICU 3.0
+     */
+    UDAT_EXTENDED_YEAR_FIELD = 20,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'g' field alignment,
+     * corresponding to the UCAL_JULIAN_DAY field.
+     * @stable ICU 3.0
+     */
+    UDAT_JULIAN_DAY_FIELD = 21,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'A' field alignment,
+     * corresponding to the UCAL_MILLISECONDS_IN_DAY field.
+     * @stable ICU 3.0
+     */
+    UDAT_MILLISECONDS_IN_DAY_FIELD = 22,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'Z' field alignment,
+     * corresponding to the UCAL_ZONE_OFFSET and
+     * UCAL_DST_OFFSET fields.
+     * @stable ICU 3.0
+     */
+    UDAT_TIMEZONE_RFC_FIELD = 23,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'v' field alignment,
+     * corresponding to the UCAL_ZONE_OFFSET field.
+     * @stable ICU 3.4
+     */
+    UDAT_TIMEZONE_GENERIC_FIELD = 24,
+    /**
+     * FieldPosition selector for 'c' field alignment,
+     * corresponding to the {@link #UCAL_DATE} field. 
+     * This displays the stand alone day name, if available.
+     * @stable ICU 3.4
+     */
+    UDAT_STANDALONE_DAY_FIELD = 25,
+    
+    /**
+     * FieldPosition selector for 'L' field alignment,
+     * corresponding to the {@link #UCAL_MONTH} field.  
+     * This displays the stand alone month name, if available.
+     * @stable ICU 3.4
+     */
+    UDAT_STANDALONE_MONTH_FIELD = 26,
+
+    /**
+     * FieldPosition selector for "Q" field alignment,
+     * corresponding to quarters. This is implemented
+     * using the {@link #UCAL_MONTH} field. This
+     * displays the quarter.
+     * @stable ICU 3.6
+     */
+    UDAT_QUARTER_FIELD = 27,
+
+    /**
+     * FieldPosition selector for the "q" field alignment,
+     * corresponding to stand-alone quarters. This is
+     * implemented using the {@link #UCAL_MONTH} field.
+     * This displays the stand-alone quarter.
+     * @stable ICU 3.6
+     */
+    UDAT_STANDALONE_QUARTER_FIELD = 28,
+
+    /**
+     * FieldPosition and UFieldPosition selector for 'V' field alignment,
+     * corresponding to the UCAL_ZONE_OFFSET field.
+     * @stable ICU 3.8
+     */
+    UDAT_TIMEZONE_SPECIAL_FIELD = 29,
+
+   /**
+     * Number of FieldPosition and UFieldPosition selectors for 
+     * DateFormat and UDateFormat.
+     * Valid selectors range from 0 to UDAT_FIELD_COUNT-1.
+     * This value is subject to change if new fields are defined
+     * in the future.
+     * @stable ICU 3.0
+     */
+    UDAT_FIELD_COUNT = 30
+
+} UDateFormatField;
+
+/**
+ * Open a new UDateFormat for formatting and parsing dates and times.
+ * A UDateFormat may be used to format dates in calls to {@link #udat_format },
+ * and to parse dates in calls to {@link #udat_parse }.
+ * @param timeStyle The style used to format times; one of UDAT_FULL, UDAT_LONG,
+ * UDAT_MEDIUM, UDAT_SHORT, or UDAT_DEFAULT
+ * @param dateStyle The style used to format dates; one of UDAT_FULL, UDAT_LONG,
+ * UDAT_MEDIUM, UDAT_SHORT, or UDAT_DEFAULT
+ * @param locale The locale specifying the formatting conventions
+ * @param tzID A timezone ID specifying the timezone to use.  If 0, use
+ * the default timezone.
+ * @param tzIDLength The length of tzID, or -1 if null-terminated.
+ * @param pattern A pattern specifying the format to use.
+ * @param patternLength The number of characters in the pattern, or -1 if null-terminated.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @return A pointer to a UDateFormat to use for formatting dates and times, or 0 if
+ * an error occurred.
+ * @stable ICU 2.0
+ */
+U_STABLE UDateFormat* U_EXPORT2 
+udat_open(UDateFormatStyle  timeStyle,
+          UDateFormatStyle  dateStyle,
+          const char        *locale,
+          const UChar       *tzID,
+          int32_t           tzIDLength,
+          const UChar       *pattern,
+          int32_t           patternLength,
+          UErrorCode        *status);
+
+
+/**
+* Close a UDateFormat.
+* Once closed, a UDateFormat may no longer be used.
+* @param format The formatter to close.
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_close(UDateFormat* format);
+
+/**
+ * Open a copy of a UDateFormat.
+ * This function performs a deep copy.
+ * @param fmt The format to copy
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return A pointer to a UDateFormat identical to fmt.
+ * @stable ICU 2.0
+ */
+U_STABLE UDateFormat* U_EXPORT2 
+udat_clone(const UDateFormat *fmt,
+       UErrorCode *status);
+
+/**
+* Format a date using an UDateFormat.
+* The date will be formatted using the conventions specified in {@link #udat_open }
+* @param format The formatter to use
+* @param dateToFormat The date to format
+* @param result A pointer to a buffer to receive the formatted number.
+* @param resultLength The maximum size of result.
+* @param position A pointer to a UFieldPosition.  On input, position->field
+* is read.  On output, position->beginIndex and position->endIndex indicate
+* the beginning and ending indices of field number position->field, if such
+* a field exists.  This parameter may be NULL, in which case no field
+* position data is returned.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The total buffer size needed; if greater than resultLength, the output was truncated.
+* @see udat_parse
+* @see UFieldPosition
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+udat_format(    const    UDateFormat*    format,
+                        UDate           dateToFormat,
+                        UChar*          result,
+                        int32_t         resultLength,
+                        UFieldPosition* position,
+                        UErrorCode*     status);
+
+/**
+* Parse a string into an date/time using a UDateFormat.
+* The date will be parsed using the conventions specified in {@link #udat_open }
+* @param format The formatter to use.
+* @param text The text to parse.
+* @param textLength The length of text, or -1 if null-terminated.
+* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The value of the parsed date/time
+* @see udat_format
+* @stable ICU 2.0
+*/
+U_STABLE UDate U_EXPORT2 
+udat_parse(    const    UDateFormat*    format,
+            const    UChar*          text,
+                    int32_t         textLength,
+                    int32_t         *parsePos,
+                    UErrorCode      *status);
+
+/**
+* Parse a string into an date/time using a UDateFormat.
+* The date will be parsed using the conventions specified in {@link #udat_open }
+* @param format The formatter to use.
+* @param calendar The calendar in which to store the parsed data.
+* @param text The text to parse.
+* @param textLength The length of text, or -1 if null-terminated.
+* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param status A pointer to an UErrorCode to receive any errors
+* @see udat_format
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_parseCalendar(const    UDateFormat*    format,
+                            UCalendar*      calendar,
+                   const    UChar*          text,
+                            int32_t         textLength,
+                            int32_t         *parsePos,
+                            UErrorCode      *status);
+
+/**
+* Determine if an UDateFormat will perform lenient parsing.
+* With lenient parsing, the parser may use heuristics to interpret inputs that do not
+* precisely match the pattern. With strict parsing, inputs must match the pattern.
+* @param fmt The formatter to query
+* @return TRUE if fmt is set to perform lenient parsing, FALSE otherwise.
+* @see udat_setLenient
+* @stable ICU 2.0
+*/
+U_STABLE UBool U_EXPORT2 
+udat_isLenient(const UDateFormat* fmt);
+
+/**
+* Specify whether an UDateFormat will perform lenient parsing.
+* With lenient parsing, the parser may use heuristics to interpret inputs that do not
+* precisely match the pattern. With strict parsing, inputs must match the pattern.
+* @param fmt The formatter to set
+* @param isLenient TRUE if fmt should perform lenient parsing, FALSE otherwise.
+* @see dat_isLenient
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_setLenient(    UDateFormat*    fmt,
+                    UBool          isLenient);
+
+/**
+* Get the UCalendar associated with an UDateFormat.
+* A UDateFormat uses a UCalendar to convert a raw value to, for example,
+* the day of the week.
+* @param fmt The formatter to query.
+* @return A pointer to the UCalendar used by fmt.
+* @see udat_setCalendar
+* @stable ICU 2.0
+*/
+U_STABLE const UCalendar* U_EXPORT2 
+udat_getCalendar(const UDateFormat* fmt);
+
+/**
+* Set the UCalendar associated with an UDateFormat.
+* A UDateFormat uses a UCalendar to convert a raw value to, for example,
+* the day of the week.
+* @param fmt The formatter to set.
+* @param calendarToSet A pointer to an UCalendar to be used by fmt.
+* @see udat_setCalendar
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_setCalendar(            UDateFormat*    fmt,
+                    const   UCalendar*      calendarToSet);
+
+/**
+* Get the UNumberFormat associated with an UDateFormat.
+* A UDateFormat uses a UNumberFormat to format numbers within a date,
+* for example the day number.
+* @param fmt The formatter to query.
+* @return A pointer to the UNumberFormat used by fmt to format numbers.
+* @see udat_setNumberFormat
+* @stable ICU 2.0
+*/
+U_STABLE const UNumberFormat* U_EXPORT2 
+udat_getNumberFormat(const UDateFormat* fmt);
+
+/**
+* Set the UNumberFormat associated with an UDateFormat.
+* A UDateFormat uses a UNumberFormat to format numbers within a date,
+* for example the day number.
+* @param fmt The formatter to set.
+* @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.
+* @see udat_getNumberFormat
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_setNumberFormat(            UDateFormat*    fmt,
+                        const   UNumberFormat*  numberFormatToSet);
+
+/**
+* Get a locale for which date/time formatting patterns are available.
+* A UDateFormat in a locale returned by this function will perform the correct
+* formatting and parsing for the locale.
+* @param index The index of the desired locale.
+* @return A locale for which date/time formatting patterns are available, or 0 if none.
+* @see udat_countAvailable
+* @stable ICU 2.0
+*/
+U_STABLE const char* U_EXPORT2 
+udat_getAvailable(int32_t index);
+
+/**
+* Determine how many locales have date/time  formatting patterns available.
+* This function is most useful as determining the loop ending condition for
+* calls to {@link #udat_getAvailable }.
+* @return The number of locales for which date/time formatting patterns are available.
+* @see udat_getAvailable
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+udat_countAvailable(void);
+
+/**
+* Get the year relative to which all 2-digit years are interpreted.
+* For example, if the 2-digit start year is 2100, the year 99 will be
+* interpreted as 2199.
+* @param fmt The formatter to query.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The year relative to which all 2-digit years are interpreted.
+* @see udat_Set2DigitYearStart
+* @stable ICU 2.0
+*/
+U_STABLE UDate U_EXPORT2 
+udat_get2DigitYearStart(    const   UDateFormat     *fmt,
+                                    UErrorCode      *status);
+
+/**
+* Set the year relative to which all 2-digit years will be interpreted.
+* For example, if the 2-digit start year is 2100, the year 99 will be
+* interpreted as 2199.
+* @param fmt The formatter to set.
+* @param d The year relative to which all 2-digit years will be interpreted.
+* @param status A pointer to an UErrorCode to receive any errors
+* @see udat_Set2DigitYearStart
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_set2DigitYearStart(    UDateFormat     *fmt,
+                            UDate           d,
+                            UErrorCode      *status);
+
+/**
+* Extract the pattern from a UDateFormat.
+* The pattern will follow the pattern syntax rules.
+* @param fmt The formatter to query.
+* @param localized TRUE if the pattern should be localized, FALSE otherwise.
+* @param result A pointer to a buffer to receive the pattern.
+* @param resultLength The maximum size of result.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The total buffer size needed; if greater than resultLength, the output was truncated.
+* @see udat_applyPattern
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+udat_toPattern(    const   UDateFormat     *fmt,
+                        UBool          localized,
+                        UChar           *result,
+                        int32_t         resultLength,
+                        UErrorCode      *status);
+
+/**
+* Set the pattern used by an UDateFormat.
+* The pattern should follow the pattern syntax rules.
+* @param format The formatter to set.
+* @param localized TRUE if the pattern is localized, FALSE otherwise.
+* @param pattern The new pattern
+* @param patternLength The length of pattern, or -1 if null-terminated.
+* @see udat_toPattern
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_applyPattern(            UDateFormat     *format,
+                            UBool          localized,
+                    const   UChar           *pattern,
+                            int32_t         patternLength);
+
+/** 
+ * The possible types of date format symbols 
+ * @stable ICU 2.6
+ */
+typedef enum UDateFormatSymbolType {
+    /** The era names, for example AD */
+    UDAT_ERAS,
+    /** The month names, for example February */
+    UDAT_MONTHS,
+    /** The short month names, for example Feb. */
+    UDAT_SHORT_MONTHS,
+    /** The weekday names, for example Monday */
+    UDAT_WEEKDAYS,
+    /** The short weekday names, for example Mon. */
+    UDAT_SHORT_WEEKDAYS,
+    /** The AM/PM names, for example AM */
+    UDAT_AM_PMS,
+    /** The localized characters */
+    UDAT_LOCALIZED_CHARS,
+    /** The long era names, for example Anno Domini */
+    UDAT_ERA_NAMES,
+    /** The narrow month names, for example F */
+    UDAT_NARROW_MONTHS,
+    /** The narrow weekday names, for example N */
+    UDAT_NARROW_WEEKDAYS,
+    /** Standalone context versions of months */
+    UDAT_STANDALONE_MONTHS,
+    UDAT_STANDALONE_SHORT_MONTHS,
+    UDAT_STANDALONE_NARROW_MONTHS,
+    /** Standalone context versions of weekdays */
+    UDAT_STANDALONE_WEEKDAYS,
+    UDAT_STANDALONE_SHORT_WEEKDAYS,
+    UDAT_STANDALONE_NARROW_WEEKDAYS,
+    /** The quarters, for example 1st Quarter */
+    UDAT_QUARTERS,
+    /** The short quarter names, for example Q1 */
+    UDAT_SHORT_QUARTERS,
+    /** Standalone context versions of quarters */
+    UDAT_STANDALONE_QUARTERS,
+    UDAT_STANDALONE_SHORT_QUARTERS
+
+} UDateFormatSymbolType;
+
+struct UDateFormatSymbols;
+/** Date format symbols.
+ *  For usage in C programs.
+ *  @stable ICU 2.6
+ */
+typedef struct UDateFormatSymbols UDateFormatSymbols;
+
+/**
+* Get the symbols associated with an UDateFormat.
+* The symbols are what a UDateFormat uses to represent locale-specific data,
+* for example month or day names.
+* @param fmt The formatter to query.
+* @param type The type of symbols to get.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
+* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
+* @param index The desired symbol of type type.
+* @param result A pointer to a buffer to receive the pattern.
+* @param resultLength The maximum size of result.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The total buffer size needed; if greater than resultLength, the output was truncated.
+* @see udat_countSymbols
+* @see udat_setSymbols
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+udat_getSymbols(const   UDateFormat             *fmt,
+                        UDateFormatSymbolType   type,
+                        int32_t                 index,
+                        UChar                   *result,
+                        int32_t                 resultLength,
+                        UErrorCode              *status);
+
+/**
+* Count the number of particular symbols for an UDateFormat.
+* This function is most useful as for detemining the loop termination condition
+* for calls to {@link #udat_getSymbols }.
+* @param fmt The formatter to query.
+* @param type The type of symbols to count.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
+* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
+* @return The number of symbols of type type.
+* @see udat_getSymbols
+* @see udat_setSymbols
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+udat_countSymbols(    const    UDateFormat                *fmt,
+                            UDateFormatSymbolType    type);
+
+/**
+* Set the symbols associated with an UDateFormat.
+* The symbols are what a UDateFormat uses to represent locale-specific data,
+* for example month or day names.
+* @param format The formatter to set
+* @param type The type of symbols to set.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
+* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
+* @param index The index of the symbol to set of type type.
+* @param value The new value
+* @param valueLength The length of value, or -1 if null-terminated
+* @param status A pointer to an UErrorCode to receive any errors
+* @see udat_getSymbols
+* @see udat_countSymbols
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+udat_setSymbols(    UDateFormat             *format,
+                    UDateFormatSymbolType   type,
+                    int32_t                 index,
+                    UChar                   *value,
+                    int32_t                 valueLength,
+                    UErrorCode              *status);
+
+/**
+ * Get the locale for this date format object.
+ * You can choose between valid and actual locale.
+ * @param fmt The formatter to get the locale from
+ * @param type type of the locale we're looking for (valid or actual) 
+ * @param status error code for the operation
+ * @return the locale name
+ * @stable ICU 2.8
+ */
+U_STABLE const char* U_EXPORT2
+udat_getLocaleByType(const UDateFormat *fmt,
+                     ULocDataLocaleType type,
+                     UErrorCode* status); 
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/udata.h b/CoreFoundation/icu/unicode/udata.h
new file mode 100644
index 0000000..84046d5
--- /dev/null
+++ b/CoreFoundation/icu/unicode/udata.h
@@ -0,0 +1,389 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1999-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*   file name:  udata.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999oct25
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __UDATA_H__
+#define __UDATA_H__
+
+#include "unicode/utypes.h"
+
+U_CDECL_BEGIN
+
+/**
+ * \file
+ * \brief C API: Data loading interface
+ *
+ * <h2>Information about data loading interface</h2>
+ *
+ * This API is used to find and efficiently load data for ICU and applications
+ * using ICU. It provides an abstract interface that specifies a data type and
+ * name to find and load the data. Normally this API is used by other ICU APIs
+ * to load required data out of the ICU data library, but it can be used to
+ * load data out of other places.
+ *
+ * See the User Guide Data Management chapter.
+ */
+ 
+#ifndef U_HIDE_INTERNAL_API
+/**
+ * Character used to separate package names from tree names 
+ * @internal ICU 3.0
+ */
+#define U_TREE_SEPARATOR '-'
+
+/**
+ * String used to separate package names from tree names 
+ * @internal ICU 3.0
+ */
+#define U_TREE_SEPARATOR_STRING "-"
+
+/**
+ * Character used to separate parts of entry names
+ * @internal ICU 3.0
+ */
+#define U_TREE_ENTRY_SEP_CHAR '/'
+
+/**
+ * String used to separate parts of entry names
+ * @internal ICU 3.0
+ */
+#define U_TREE_ENTRY_SEP_STRING "/"
+
+/**
+ * Alias for standard ICU data 
+ * @internal ICU 3.0
+ */
+#define U_ICUDATA_ALIAS "ICUDATA"
+
+#endif /* U_HIDE_INTERNAL_API */
+
+/**
+ * UDataInfo contains the properties about the requested data.
+ * This is meta data.
+ *
+ * <p>This structure may grow in the future, indicated by the
+ * <code>size</code> field.</p>
+ *
+ * <p>The platform data property fields help determine if a data
+ * file can be efficiently used on a given machine.
+ * The particular fields are of importance only if the data
+ * is affected by the properties - if there is integer data
+ * with word sizes > 1 byte, char* text, or UChar* text.</p>
+ *
+ * <p>The implementation for the <code>udata_open[Choice]()</code>
+ * functions may reject data based on the value in <code>isBigEndian</code>.
+ * No other field is used by the <code>udata</code> API implementation.</p>
+ *
+ * <p>The <code>dataFormat</code> may be used to identify
+ * the kind of data, e.g. a converter table.</p>
+ *
+ * <p>The <code>formatVersion</code> field should be used to
+ * make sure that the format can be interpreted.
+ * I may be a good idea to check only for the one or two highest
+ * of the version elements to allow the data memory to
+ * get more or somewhat rearranged contents, for as long
+ * as the using code can still interpret the older contents.</p>
+ *
+ * <p>The <code>dataVersion</code> field is intended to be a
+ * common place to store the source version of the data;
+ * for data from the Unicode character database, this could
+ * reflect the Unicode version.</p>
+ * @stable ICU 2.0
+ */
+typedef struct {
+    /** sizeof(UDataInfo)
+     *  @stable ICU 2.0 */
+    uint16_t size;
+
+    /** unused, set to 0 
+     *  @stable ICU 2.0*/
+    uint16_t reservedWord;
+
+    /* platform data properties */
+    /** 0 for little-endian machine, 1 for big-endian
+     *  @stable ICU 2.0 */
+    uint8_t isBigEndian;
+
+    /** see U_CHARSET_FAMILY values in utypes.h 
+     *  @stable ICU 2.0*/
+    uint8_t charsetFamily;
+
+    /** sizeof(UChar), one of { 1, 2, 4 } 
+     *  @stable ICU 2.0*/
+    uint8_t sizeofUChar;
+
+    /** unused, set to 0 
+     *  @stable ICU 2.0*/
+    uint8_t reservedByte;
+
+    /** data format identifier 
+     *  @stable ICU 2.0*/
+    uint8_t dataFormat[4];
+
+    /** versions: [0] major [1] minor [2] milli [3] micro 
+     *  @stable ICU 2.0*/
+    uint8_t formatVersion[4];
+
+    /** versions: [0] major [1] minor [2] milli [3] micro 
+     *  @stable ICU 2.0*/
+    uint8_t dataVersion[4];
+} UDataInfo;
+
+/* API for reading data -----------------------------------------------------*/
+
+/**
+ * Forward declaration of the data memory type.
+ * @stable ICU 2.0
+ */
+typedef struct UDataMemory UDataMemory;
+
+/**
+ * Callback function for udata_openChoice().
+ * @param context parameter passed into <code>udata_openChoice()</code>.
+ * @param type The type of the data as passed into <code>udata_openChoice()</code>.
+ *             It may be <code>NULL</code>.
+ * @param name The name of the data as passed into <code>udata_openChoice()</code>.
+ * @param pInfo A pointer to the <code>UDataInfo</code> structure
+ *              of data that has been loaded and will be returned
+ *              by <code>udata_openChoice()</code> if this function
+ *              returns <code>TRUE</code>.
+ * @return TRUE if the current data memory is acceptable
+ * @stable ICU 2.0
+ */
+typedef UBool U_CALLCONV
+UDataMemoryIsAcceptable(void *context,
+                        const char *type, const char *name,
+                        const UDataInfo *pInfo);
+
+
+/**
+ * Convenience function.
+ * This function works the same as <code>udata_openChoice</code>
+ * except that any data that matches the type and name
+ * is assumed to be acceptable.
+ * @param path Specifies an absolute path and/or a basename for the
+ *             finding of the data in the file system.
+ *             <code>NULL</code> for ICU data.
+ * @param type A string that specifies the type of data to be loaded.
+ *             For example, resource bundles are loaded with type "res",
+ *             conversion tables with type "cnv".
+ *             This may be <code>NULL</code> or empty.
+ * @param name A string that specifies the name of the data.
+ * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>.
+ * @return A pointer (handle) to a data memory object, or <code>NULL</code>
+ *         if an error occurs. Call <code>udata_getMemory()</code>
+ *         to get a pointer to the actual data.
+ *
+ * @see udata_openChoice
+ * @stable ICU 2.0
+ */
+U_STABLE UDataMemory * U_EXPORT2
+udata_open(const char *path, const char *type, const char *name,
+           UErrorCode *pErrorCode);
+
+/**
+ * Data loading function.
+ * This function is used to find and load efficiently data for
+ * ICU and applications using ICU.
+ * It provides an abstract interface that allows to specify a data
+ * type and name to find and load the data.
+ *
+ * <p>The implementation depends on platform properties and user preferences
+ * and may involve loading shared libraries (DLLs), mapping
+ * files into memory, or fopen()/fread() files.
+ * It may also involve using static memory or database queries etc.
+ * Several or all data items may be combined into one entity
+ * (DLL, memory-mappable file).</p>
+ *
+ * <p>The data is always preceded by a header that includes
+ * a <code>UDataInfo</code> structure.
+ * The caller's <code>isAcceptable()</code> function is called to make
+ * sure that the data is useful. It may be called several times if it
+ * rejects the data and there is more than one location with data
+ * matching the type and name.</p>
+ *
+ * <p>If <code>path==NULL</code>, then ICU data is loaded.
+ * Otherwise, it is separated into a basename and a basename-less directory string.
+ * The basename is used as the data package name, and the directory is
+ * logically prepended to the ICU data directory string.</p>
+ *
+ * <p>For details about ICU data loading see the User Guide
+ * Data Management chapter. (http://icu-project.org/userguide/icudata.html)</p>
+ *
+ * @param path Specifies an absolute path and/or a basename for the
+ *             finding of the data in the file system.
+ *             <code>NULL</code> for ICU data.
+ * @param type A string that specifies the type of data to be loaded.
+ *             For example, resource bundles are loaded with type "res",
+ *             conversion tables with type "cnv".
+ *             This may be <code>NULL</code> or empty.
+ * @param name A string that specifies the name of the data.
+ * @param isAcceptable This function is called to verify that loaded data
+ *                     is useful for the client code. If it returns FALSE
+ *                     for all data items, then <code>udata_openChoice()</code>
+ *                     will return with an error.
+ * @param context Arbitrary parameter to be passed into isAcceptable.
+ * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>.
+ * @return A pointer (handle) to a data memory object, or <code>NULL</code>
+ *         if an error occurs. Call <code>udata_getMemory()</code>
+ *         to get a pointer to the actual data.
+ * @stable ICU 2.0
+ */
+U_STABLE UDataMemory * U_EXPORT2
+udata_openChoice(const char *path, const char *type, const char *name,
+                 UDataMemoryIsAcceptable *isAcceptable, void *context,
+                 UErrorCode *pErrorCode);
+
+/**
+ * Close the data memory.
+ * This function must be called to allow the system to
+ * release resources associated with this data memory.
+ * @param pData The pointer to data memory object
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+udata_close(UDataMemory *pData);
+
+/**
+ * Get the pointer to the actual data inside the data memory.
+ * The data is read-only.
+ * @param pData The pointer to data memory object
+ * @stable ICU 2.0
+ */
+U_STABLE const void * U_EXPORT2
+udata_getMemory(UDataMemory *pData);
+
+/**
+ * Get the information from the data memory header.
+ * This allows to get access to the header containing
+ * platform data properties etc. which is not part of
+ * the data itself and can therefore not be accessed
+ * via the pointer that <code>udata_getMemory()</code> returns.
+ *
+ * @param pData pointer to the data memory object
+ * @param pInfo pointer to a UDataInfo object;
+ *              its <code>size</code> field must be set correctly,
+ *              typically to <code>sizeof(UDataInfo)</code>.
+ *
+ * <code>*pInfo</code> will be filled with the UDataInfo structure
+ * in the data memory object. If this structure is smaller than
+ * <code>pInfo->size</code>, then the <code>size</code> will be
+ * adjusted and only part of the structure will be filled.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+udata_getInfo(UDataMemory *pData, UDataInfo *pInfo);
+
+/**
+ * This function bypasses the normal ICU data loading process and
+ * allows you to force ICU's system data to come out of a user-specified
+ * area in memory.
+ *
+ * The format of this data is that of the icu common data file, as is
+ * generated by the pkgdata tool with mode=common or mode=dll.
+ * You can read in a whole common mode file and pass the address to the start of the
+ * data, or (with the appropriate link options) pass in the pointer to
+ * the data that has been loaded from a dll by the operating system,
+ * as shown in this code:
+ *
+ *       extern const  char U_IMPORT U_ICUDATA_ENTRY_POINT []; 
+ *        // U_ICUDATA_ENTRY_POINT is same as entry point specified to pkgdata tool
+ *       UErrorCode  status = U_ZERO_ERROR;
+ *
+ *       udata_setCommonData(&U_ICUDATA_ENTRY_POINT, &status);
+ *
+ * Warning: ICU must NOT have even attempted to access its data yet
+ * when this call is made, or U_USING_DEFAULT_WARNING code will
+ * be returned. Be careful of UnicodeStrings in static initialization which
+ * may attempt to load a converter (use the UNICODE_STRING(x) macro instead).
+ *
+ * Also note that it is important that the declaration be as above. The entry point
+ * must not be declared as an extern void*.
+ *
+ * This function has no effect on application (non ICU) data.  See udata_setAppData()
+ * for similar functionality for application data.
+ *
+ * @param data pointer to ICU common data
+ * @param err outgoing error status <code>U_USING_DEFAULT_WARNING, U_UNSUPPORTED_ERROR</code>
+ * @stable ICU 2.0
+ */
+
+U_STABLE void U_EXPORT2
+udata_setCommonData(const void *data, UErrorCode *err);
+
+
+/**
+ * This function bypasses the normal ICU data loading process for application-specific
+ * data and allows you to force the it to come out of a user-specified
+ * pointer.
+ *
+ * The format of this data is that of the icu common data file, like 'icudt26l.dat'
+ * or the corresponding shared library (DLL) file.
+ * The application must read in or otherwise construct an image of the data and then
+ * pass the address of it to this function.
+ *
+ *
+ * Warning:  setAppData will set a U_USING_DEFAULT_WARNING code if
+ *           data with the specifed path that has already been opened, or
+ *           if setAppData with the same path has already been called.
+ *           Any such calls to setAppData will have no effect.
+ *
+ *
+ * @param packageName the package name by which the application will refer
+ *             to (open) this data
+ * @param data pointer to the data
+ * @param err outgoing error status <code>U_USING_DEFAULT_WARNING, U_UNSUPPORTED_ERROR</code>
+ * @see udata_setCommonData
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+udata_setAppData(const char *packageName, const void *data, UErrorCode *err);
+
+/**
+ * Possible settings for udata_setFileAccess()
+ * @see udata_setFileAccess
+ * @stable ICU 3.4
+ */
+typedef enum UDataFileAccess {
+    /** ICU looks for data in single files first, then in packages. (default) */
+    UDATA_FILES_FIRST,
+    /** ICU only loads data from packages, not from single files. */
+    UDATA_ONLY_PACKAGES,
+    /** ICU loads data from packages first, and only from single files
+        if the data cannot be found in a package. */
+    UDATA_PACKAGES_FIRST,
+    /** ICU does not access the file system for data loading. */
+    UDATA_NO_FILES,
+    /** An alias for the default access mode. */
+    UDATA_DEFAULT_ACCESS = UDATA_FILES_FIRST,
+    UDATA_FILE_ACCESS_COUNT
+} UDataFileAccess;
+
+/**
+ * This function may be called to control how ICU loads data. It must be called
+ * before any ICU data is loaded, including application data loaded with ures/ResourceBundle or
+ * udata APIs. It should be called before u_init.  This function is not multithread safe.  
+ * The results of calling it while other threads are loading data are undefined.
+ * @param access The type of file access to be used
+ * @param status Error code.
+ * @see UDataFileAccess
+ * @stable ICU 3.4 
+ */
+U_STABLE void U_EXPORT2
+udata_setFileAccess(UDataFileAccess access, UErrorCode *status);
+
+U_CDECL_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/udatpg.h b/CoreFoundation/icu/unicode/udatpg.h
new file mode 100644
index 0000000..b348146
--- /dev/null
+++ b/CoreFoundation/icu/unicode/udatpg.h
@@ -0,0 +1,475 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2007-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  udatpg.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2007jul30
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __UDATPG_H__
+#define __UDATPG_H__
+
+#include "unicode/utypes.h"
+#include "unicode/uenum.h"
+
+/**
+ * \file
+ * \brief C API: Wrapper for DateTimePatternGenerator (unicode/dtptngen.h).
+ *
+ * UDateTimePatternGenerator provides flexible generation of date format patterns, 
+ * like "yy-MM-dd". The user can build up the generator by adding successive 
+ * patterns. Once that is done, a query can be made using a "skeleton", which is 
+ * a pattern which just includes the desired fields and lengths. The generator 
+ * will return the "best fit" pattern corresponding to that skeleton.
+ * <p>The main method people will use is udatpg_getBestPattern, since normally
+ * UDateTimePatternGenerator is pre-built with data from a particular locale. 
+ * However, generators can be built directly from other data as well.
+ * <p><i>Issue: may be useful to also have a function that returns the list of 
+ * fields in a pattern, in order, since we have that internally.
+ * That would be useful for getting the UI order of field elements.</i>
+ */
+
+/**
+ * Opaque type for a date/time pattern generator object.
+ * @stable ICU 4.0
+ */
+typedef void *UDateTimePatternGenerator;
+
+#ifndef U_HIDE_DRAFT_API
+
+/**
+ * Field number constants for udatpg_getAppendItemFormats() and similar functions.
+ * These constants are separate from UDateFormatField despite semantic overlap
+ * because some fields are merged for the date/time pattern generator.
+ * @stable ICU 4.0
+ */
+typedef enum UDateTimePatternField {
+    /** @stable ICU 4.0 */
+    UDATPG_ERA_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_YEAR_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_QUARTER_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_MONTH_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_WEEK_OF_YEAR_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_WEEK_OF_MONTH_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_WEEKDAY_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_DAY_OF_YEAR_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_DAY_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_DAYPERIOD_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_HOUR_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_MINUTE_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_SECOND_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_FRACTIONAL_SECOND_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_ZONE_FIELD,
+    /** @stable ICU 4.0 */
+    UDATPG_FIELD_COUNT
+} UDateTimePatternField;
+
+/**
+ * Status return values from udatpg_addPattern().
+ * @stable ICU 4.0
+ */
+typedef enum UDateTimePatternConflict {
+    /** @stable ICU 4.0 */
+    UDATPG_NO_CONFLICT,
+    /** @stable ICU 4.0 */
+    UDATPG_BASE_CONFLICT,
+    /** @stable ICU 4.0 */
+    UDATPG_CONFLICT,
+    /** @stable ICU 4.0 */
+    UDATPG_CONFLICT_COUNT
+} UDateTimePatternConflict;
+
+#endif
+
+/**
+  * Open a generator according to a given locale.
+  * @param locale
+  * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+  *                   failure before the function call.
+  * @return a pointer to UDateTimePatternGenerator.
+  * @stable ICU 4.0
+  */
+U_DRAFT UDateTimePatternGenerator * U_EXPORT2
+udatpg_open(const char *locale, UErrorCode *pErrorCode);
+
+/**
+  * Open an empty generator, to be constructed with udatpg_addPattern(...) etc.
+  * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+  *                   failure before the function call.
+  * @return a pointer to UDateTimePatternGenerator.
+  * @stable ICU 4.0
+  */
+U_DRAFT UDateTimePatternGenerator * U_EXPORT2
+udatpg_openEmpty(UErrorCode *pErrorCode);
+
+/**
+  * Close a generator.
+  * @param dtpg a pointer to UDateTimePatternGenerator.
+  * @stable ICU 4.0
+  */
+U_DRAFT void U_EXPORT2
+udatpg_close(UDateTimePatternGenerator *dtpg);
+
+/**
+  * Create a copy pf a generator.
+  * @param dtpg a pointer to UDateTimePatternGenerator to be copied.
+  * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+  *                   failure before the function call.
+  * @return a pointer to a new UDateTimePatternGenerator.
+  * @stable ICU 4.0
+ */
+U_DRAFT UDateTimePatternGenerator * U_EXPORT2
+udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
+
+/**
+ * Get the best pattern matching the input skeleton. It is guaranteed to
+ * have all of the fields in the skeleton.
+ * 
+ * Note that this function uses a non-const UDateTimePatternGenerator:
+ * It uses a stateful pattern parser which is set up for each generator object,
+ * rather than creating one for each function call.
+ * Consecutive calls to this function do not affect each other,
+ * but this function cannot be used concurrently on a single generator object.
+ * 
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param skeleton
+ *            The skeleton is a pattern containing only the variable fields.
+ *            For example, "MMMdd" and "mmhh" are skeletons.
+ * @param length the length of skeleton
+ * @param bestPattern
+ *            The best pattern found from the given skeleton.
+ * @param capacity the capacity of bestPattern.
+ * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+ *                   failure before the function call.
+ * @return the length of bestPattern.
+ * @stable ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
+                      const UChar *skeleton, int32_t length,
+                      UChar *bestPattern, int32_t capacity,
+                      UErrorCode *pErrorCode);
+
+/**
+  * Get a unique skeleton from a given pattern. For example,
+  * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd".
+  * 
+  * Note that this function uses a non-const UDateTimePatternGenerator:
+  * It uses a stateful pattern parser which is set up for each generator object,
+  * rather than creating one for each function call.
+  * Consecutive calls to this function do not affect each other,
+  * but this function cannot be used concurrently on a single generator object.
+  *
+  * @param dtpg     a pointer to UDateTimePatternGenerator.
+  * @param pattern  input pattern, such as "dd/MMM".
+  * @param length   the length of pattern.
+  * @param skeleton such as "MMMdd"
+  * @param capacity the capacity of skeleton.
+  * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+  *                  failure before the function call.
+  * @return the length of skeleton.
+  * @stable ICU 4.0
+  */
+U_DRAFT int32_t U_EXPORT2
+udatpg_getSkeleton(UDateTimePatternGenerator *dtpg,
+                   const UChar *pattern, int32_t length,
+                   UChar *skeleton, int32_t capacity,
+                   UErrorCode *pErrorCode);
+
+/**
+ * Get a unique base skeleton from a given pattern. This is the same
+ * as the skeleton, except that differences in length are minimized so
+ * as to only preserve the difference between string and numeric form. So
+ * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd"
+ * (notice the single d).
+ *
+ * Note that this function uses a non-const UDateTimePatternGenerator:
+ * It uses a stateful pattern parser which is set up for each generator object,
+ * rather than creating one for each function call.
+ * Consecutive calls to this function do not affect each other,
+ * but this function cannot be used concurrently on a single generator object.
+ *
+ * @param dtpg     a pointer to UDateTimePatternGenerator.
+ * @param pattern  input pattern, such as "dd/MMM".
+ * @param length   the length of pattern.
+ * @param baseSkeleton such as "Md"
+ * @param capacity the capacity of base skeleton.
+ * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+ *                  failure before the function call.
+ * @return the length of baseSkeleton.
+ * @stable ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+udatpg_getBaseSkeleton(UDateTimePatternGenerator *dtpg,
+                       const UChar *pattern, int32_t length,
+                       UChar *baseSkeleton, int32_t capacity,
+                       UErrorCode *pErrorCode);
+
+/**
+ * Adds a pattern to the generator. If the pattern has the same skeleton as
+ * an existing pattern, and the override parameter is set, then the previous
+ * value is overriden. Otherwise, the previous value is retained. In either
+ * case, the conflicting status is set and previous vale is stored in 
+ * conflicting pattern.
+ * <p>
+ * Note that single-field patterns (like "MMM") are automatically added, and
+ * don't need to be added explicitly!
+ *
+ * @param dtpg     a pointer to UDateTimePatternGenerator.
+ * @param pattern  input pattern, such as "dd/MMM"
+ * @param patternLength the length of pattern.
+ * @param override  When existing values are to be overridden use true, 
+ *                  otherwise use false.
+ * @param conflictingPattern  Previous pattern with the same skeleton.
+ * @param capacity the capacity of conflictingPattern.
+ * @param pLength a pointer to the length of conflictingPattern.
+ * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+ *                  failure before the function call.
+ * @return conflicting status. The value could be UDATPG_NO_CONFLICT, 
+ *                  UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
+ * @stable ICU 4.0
+ */
+U_DRAFT UDateTimePatternConflict U_EXPORT2
+udatpg_addPattern(UDateTimePatternGenerator *dtpg,
+                  const UChar *pattern, int32_t patternLength,
+                  UBool override,
+                  UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
+                  UErrorCode *pErrorCode);
+
+/**
+  * An AppendItem format is a pattern used to append a field if there is no
+  * good match. For example, suppose that the input skeleton is "GyyyyMMMd",
+  * and there is no matching pattern internally, but there is a pattern
+  * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the
+  * G. The way these two are conjoined is by using the AppendItemFormat for G
+  * (era). So if that value is, say "{0}, {1}" then the final resulting
+  * pattern is "d-MM-yyyy, G".
+  * <p>
+  * There are actually three available variables: {0} is the pattern so far,
+  * {1} is the element we are adding, and {2} is the name of the element.
+  * <p>
+  * This reflects the way that the CLDR data is organized.
+  *
+  * @param dtpg   a pointer to UDateTimePatternGenerator.
+  * @param field  UDateTimePatternField, such as UDATPG_ERA_FIELD
+  * @param value  pattern, such as "{0}, {1}"
+  * @param length the length of value.
+  * @stable ICU 4.0
+  */
+U_DRAFT void U_EXPORT2
+udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
+                           UDateTimePatternField field,
+                           const UChar *value, int32_t length);
+
+/**
+ * Getter corresponding to setAppendItemFormat. Values below 0 or at or
+ * above UDATPG_FIELD_COUNT are illegal arguments.
+ *
+ * @param dtpg   A pointer to UDateTimePatternGenerator.
+ * @param field  UDateTimePatternField, such as UDATPG_ERA_FIELD
+ * @param pLength A pointer that will receive the length of appendItemFormat.
+ * @return appendItemFormat for field.
+ * @stable ICU 4.0
+ */
+U_DRAFT const UChar * U_EXPORT2
+udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
+                           UDateTimePatternField field,
+                           int32_t *pLength);
+
+/**
+   * Set the name of field, eg "era" in English for ERA. These are only
+   * used if the corresponding AppendItemFormat is used, and if it contains a
+   * {2} variable.
+   * <p>
+   * This reflects the way that the CLDR data is organized.
+   *
+   * @param dtpg   a pointer to UDateTimePatternGenerator.
+   * @param field  UDateTimePatternField
+   * @param value  name for the field.
+   * @param length the length of value.
+   * @stable ICU 4.0
+   */
+U_DRAFT void U_EXPORT2
+udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
+                         UDateTimePatternField field,
+                         const UChar *value, int32_t length);
+
+/**
+ * Getter corresponding to setAppendItemNames. Values below 0 or at or above
+ * UDATPG_FIELD_COUNT are illegal arguments.
+ *
+ * @param dtpg   a pointer to UDateTimePatternGenerator.
+ * @param field  UDateTimePatternField, such as UDATPG_ERA_FIELD
+ * @param pLength A pointer that will receive the length of the name for field.
+ * @return name for field
+ * @stable ICU 4.0
+ */
+U_DRAFT const UChar * U_EXPORT2
+udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
+                         UDateTimePatternField field,
+                         int32_t *pLength);
+
+/**
+ * The date time format is a message format pattern used to compose date and
+ * time patterns. The default value is "{0} {1}", where {0} will be replaced
+ * by the date pattern and {1} will be replaced by the time pattern.
+ * <p>
+ * This is used when the input skeleton contains both date and time fields,
+ * but there is not a close match among the added patterns. For example,
+ * suppose that this object was created by adding "dd-MMM" and "hh:mm", and
+ * its datetimeFormat is the default "{0} {1}". Then if the input skeleton
+ * is "MMMdhmm", there is not an exact match, so the input skeleton is
+ * broken up into two components "MMMd" and "hmm". There are close matches
+ * for those two skeletons, so the result is put together with this pattern,
+ * resulting in "d-MMM h:mm".
+ *
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param dtFormat
+ *            message format pattern, here {0} will be replaced by the date
+ *            pattern and {1} will be replaced by the time pattern.
+ * @param length the length of dtFormat.
+ * @stable ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
+                         const UChar *dtFormat, int32_t length);
+
+/**
+ * Getter corresponding to setDateTimeFormat.
+ * @param dtpg   a pointer to UDateTimePatternGenerator.
+ * @param pLength A pointer that will receive the length of the format
+ * @return dateTimeFormat.
+ * @stable ICU 4.0
+ */
+U_DRAFT const UChar * U_EXPORT2
+udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
+                         int32_t *pLength);
+
+/**
+ * The decimal value is used in formatting fractions of seconds. If the
+ * skeleton contains fractional seconds, then this is used with the
+ * fractional seconds. For example, suppose that the input pattern is
+ * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and
+ * the decimal string is ",". Then the resulting pattern is modified to be
+ * "H:mm:ss,SSSS"
+ *
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param decimal
+ * @param length the length of decimal.
+ * @stable ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
+                  const UChar *decimal, int32_t length);
+
+/**
+ * Getter corresponding to setDecimal.
+ * 
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param pLength A pointer that will receive the length of the decimal string.
+ * @return corresponding to the decimal point.
+ * @stable ICU 4.0
+ */
+U_DRAFT const UChar * U_EXPORT2
+udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
+                  int32_t *pLength);
+
+/**
+ * Adjusts the field types (width and subtype) of a pattern to match what is
+ * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
+ * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
+ * "dd-MMMM hh:mm". This is used internally to get the best match for the
+ * input skeleton, but can also be used externally.
+ *
+ * Note that this function uses a non-const UDateTimePatternGenerator:
+ * It uses a stateful pattern parser which is set up for each generator object,
+ * rather than creating one for each function call.
+ * Consecutive calls to this function do not affect each other,
+ * but this function cannot be used concurrently on a single generator object.
+ *
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param pattern Input pattern
+ * @param patternLength the length of input pattern.
+ * @param skeleton
+ * @param skeletonLength the length of input skeleton.
+ * @param dest  pattern adjusted to match the skeleton fields widths and subtypes.
+ * @param destCapacity the capacity of dest.
+ * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+ *                  failure before the function call.
+ * @return the length of dest.
+ * @stable ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
+                         const UChar *pattern, int32_t patternLength,
+                         const UChar *skeleton, int32_t skeletonLength,
+                         UChar *dest, int32_t destCapacity,
+                         UErrorCode *pErrorCode);
+
+/**
+ * Return a UEnumeration list of all the skeletons in canonical form.
+ * Call udatpg_getPatternForSkeleton() to get the corresponding pattern.
+ * 
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+ *                  failure before the function call
+ * @return a UEnumeration list of all the skeletons
+ *         The caller must close the object.
+ * @stable ICU 4.0
+ */
+U_DRAFT UEnumeration * U_EXPORT2
+udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
+
+/**
+ * Return a UEnumeration list of all the base skeletons in canonical form.
+ *
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param pErrorCode a pointer to the UErrorCode which must not indicate a
+ *             failure before the function call.
+ * @return a UEnumeration list of all the base skeletons
+ *             The caller must close the object.
+ * @stable ICU 4.0
+ */
+U_DRAFT UEnumeration * U_EXPORT2
+udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
+
+/**
+ * Get the pattern corresponding to a given skeleton.
+ * 
+ * @param dtpg a pointer to UDateTimePatternGenerator.
+ * @param skeleton 
+ * @param skeletonLength pointer to the length of skeleton.
+ * @param pLength pointer to the length of return pattern.
+ * @return pattern corresponding to a given skeleton.
+ * @stable ICU 4.0
+ */
+U_DRAFT const UChar * U_EXPORT2
+udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
+                             const UChar *skeleton, int32_t skeletonLength,
+                             int32_t *pLength);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/udeprctd.h b/CoreFoundation/icu/unicode/udeprctd.h
new file mode 100644
index 0000000..9bf45f3
--- /dev/null
+++ b/CoreFoundation/icu/unicode/udeprctd.h
@@ -0,0 +1,50 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2004-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Created by: genheaders.pl, a perl script written by Ram Viswanadha
+*
+*  Contains data for commenting out APIs.
+*  Gets included by umachine.h
+*
+*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
+*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
+*/
+
+#ifndef UDEPRCTD_H
+#define UDEPRCTD_H
+
+#ifdef U_HIDE_DEPRECATED_API
+
+#    if U_DISABLE_RENAMING
+#        define ucol_getContractions ucol_getContractions_DEPRECATED_API_DO_NOT_USE
+#        define ucol_getLocale ucol_getLocale_DEPRECATED_API_DO_NOT_USE
+#        define ures_countArrayItems ures_countArrayItems_DEPRECATED_API_DO_NOT_USE
+#        define ures_getLocale ures_getLocale_DEPRECATED_API_DO_NOT_USE
+#        define ures_getVersionNumber ures_getVersionNumber_DEPRECATED_API_DO_NOT_USE
+#        define utrans_getAvailableID utrans_getAvailableID_DEPRECATED_API_DO_NOT_USE
+#        define utrans_getID utrans_getID_DEPRECATED_API_DO_NOT_USE
+#        define utrans_open utrans_open_DEPRECATED_API_DO_NOT_USE
+#        define utrans_unregister utrans_unregister_DEPRECATED_API_DO_NOT_USE
+#    else
+#        define ucol_getContractions_4_0 ucol_getContractions_DEPRECATED_API_DO_NOT_USE
+#        define ucol_getLocale_4_0 ucol_getLocale_DEPRECATED_API_DO_NOT_USE
+#        define ures_countArrayItems_4_0 ures_countArrayItems_DEPRECATED_API_DO_NOT_USE
+#        define ures_getLocale_4_0 ures_getLocale_DEPRECATED_API_DO_NOT_USE
+#        define ures_getVersionNumber_4_0 ures_getVersionNumber_DEPRECATED_API_DO_NOT_USE
+#        define utrans_getAvailableID_4_0 utrans_getAvailableID_DEPRECATED_API_DO_NOT_USE
+#        define utrans_getID_4_0 utrans_getID_DEPRECATED_API_DO_NOT_USE
+#        define utrans_open_4_0 utrans_open_DEPRECATED_API_DO_NOT_USE
+#        define utrans_unregister_4_0 utrans_unregister_DEPRECATED_API_DO_NOT_USE
+#    endif /* U_DISABLE_RENAMING */
+
+#endif /* U_HIDE_DEPRECATED_API */
+#endif /* UDEPRCTD_H */
+
diff --git a/CoreFoundation/icu/unicode/udraft.h b/CoreFoundation/icu/unicode/udraft.h
new file mode 100644
index 0000000..5426adf
--- /dev/null
+++ b/CoreFoundation/icu/unicode/udraft.h
@@ -0,0 +1,166 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2004-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Created by: genheaders.pl, a perl script written by Ram Viswanadha
+*
+*  Contains data for commenting out APIs.
+*  Gets included by umachine.h
+*
+*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
+*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
+*/
+
+#ifndef UDRAFT_H
+#define UDRAFT_H
+
+#ifdef U_HIDE_DRAFT_API
+
+#    if U_DISABLE_RENAMING
+#        define afkLanguageCode afkLanguageCode_DRAFT_API_DO_NOT_USE
+#        define armiScriptCode armiScriptCode_DRAFT_API_DO_NOT_USE
+#        define u_fclose u_fclose_DRAFT_API_DO_NOT_USE
+#        define u_feof u_feof_DRAFT_API_DO_NOT_USE
+#        define u_fflush u_fflush_DRAFT_API_DO_NOT_USE
+#        define u_fgetConverter u_fgetConverter_DRAFT_API_DO_NOT_USE
+#        define u_fgetc u_fgetc_DRAFT_API_DO_NOT_USE
+#        define u_fgetcodepage u_fgetcodepage_DRAFT_API_DO_NOT_USE
+#        define u_fgetcx u_fgetcx_DRAFT_API_DO_NOT_USE
+#        define u_fgetfile u_fgetfile_DRAFT_API_DO_NOT_USE
+#        define u_fgetlocale u_fgetlocale_DRAFT_API_DO_NOT_USE
+#        define u_fgets u_fgets_DRAFT_API_DO_NOT_USE
+#        define u_file_read u_file_read_DRAFT_API_DO_NOT_USE
+#        define u_file_write u_file_write_DRAFT_API_DO_NOT_USE
+#        define u_finit u_finit_DRAFT_API_DO_NOT_USE
+#        define u_fopen u_fopen_DRAFT_API_DO_NOT_USE
+#        define u_fprintf u_fprintf_DRAFT_API_DO_NOT_USE
+#        define u_fprintf_u u_fprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_fputc u_fputc_DRAFT_API_DO_NOT_USE
+#        define u_fputs u_fputs_DRAFT_API_DO_NOT_USE
+#        define u_frewind u_frewind_DRAFT_API_DO_NOT_USE
+#        define u_fscanf u_fscanf_DRAFT_API_DO_NOT_USE
+#        define u_fscanf_u u_fscanf_u_DRAFT_API_DO_NOT_USE
+#        define u_fsetcodepage u_fsetcodepage_DRAFT_API_DO_NOT_USE
+#        define u_fsetlocale u_fsetlocale_DRAFT_API_DO_NOT_USE
+#        define u_fsettransliterator u_fsettransliterator_DRAFT_API_DO_NOT_USE
+#        define u_fstropen u_fstropen_DRAFT_API_DO_NOT_USE
+#        define u_fungetc u_fungetc_DRAFT_API_DO_NOT_USE
+#        define u_snprintf u_snprintf_DRAFT_API_DO_NOT_USE
+#        define u_snprintf_u u_snprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_sprintf u_sprintf_DRAFT_API_DO_NOT_USE
+#        define u_sprintf_u u_sprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_sscanf u_sscanf_DRAFT_API_DO_NOT_USE
+#        define u_sscanf_u u_sscanf_u_DRAFT_API_DO_NOT_USE
+#        define u_vfprintf u_vfprintf_DRAFT_API_DO_NOT_USE
+#        define u_vfprintf_u u_vfprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_vfscanf u_vfscanf_DRAFT_API_DO_NOT_USE
+#        define u_vfscanf_u u_vfscanf_u_DRAFT_API_DO_NOT_USE
+#        define u_vsnprintf u_vsnprintf_DRAFT_API_DO_NOT_USE
+#        define u_vsnprintf_u u_vsnprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_vsprintf u_vsprintf_DRAFT_API_DO_NOT_USE
+#        define u_vsprintf_u u_vsprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_vsscanf u_vsscanf_DRAFT_API_DO_NOT_USE
+#        define u_vsscanf_u u_vsscanf_u_DRAFT_API_DO_NOT_USE
+#        define ucal_clone ucal_clone_DRAFT_API_DO_NOT_USE
+#        define ucal_getCanonicalTimeZoneID ucal_getCanonicalTimeZoneID_DRAFT_API_DO_NOT_USE
+#        define ucurr_countCurrencies ucurr_countCurrencies_DRAFT_API_DO_NOT_USE
+#        define ucurr_forLocaleAndDate ucurr_forLocaleAndDate_DRAFT_API_DO_NOT_USE
+#        define uloc_addLikelySubtags uloc_addLikelySubtags_DRAFT_API_DO_NOT_USE
+#        define uloc_getCharacterOrientation uloc_getCharacterOrientation_DRAFT_API_DO_NOT_USE
+#        define uloc_getLineOrientation uloc_getLineOrientation_DRAFT_API_DO_NOT_USE
+#        define uloc_minimizeSubtags uloc_minimizeSubtags_DRAFT_API_DO_NOT_USE
+#        define uregex_getMatchCallback uregex_getMatchCallback_DRAFT_API_DO_NOT_USE
+#        define uregex_getStackLimit uregex_getStackLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_getTimeLimit uregex_getTimeLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_hasAnchoringBounds uregex_hasAnchoringBounds_DRAFT_API_DO_NOT_USE
+#        define uregex_hasTransparentBounds uregex_hasTransparentBounds_DRAFT_API_DO_NOT_USE
+#        define uregex_hitEnd uregex_hitEnd_DRAFT_API_DO_NOT_USE
+#        define uregex_regionEnd uregex_regionEnd_DRAFT_API_DO_NOT_USE
+#        define uregex_regionStart uregex_regionStart_DRAFT_API_DO_NOT_USE
+#        define uregex_requireEnd uregex_requireEnd_DRAFT_API_DO_NOT_USE
+#        define uregex_setMatchCallback uregex_setMatchCallback_DRAFT_API_DO_NOT_USE
+#        define uregex_setRegion uregex_setRegion_DRAFT_API_DO_NOT_USE
+#        define uregex_setStackLimit uregex_setStackLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_setTimeLimit uregex_setTimeLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_useAnchoringBounds uregex_useAnchoringBounds_DRAFT_API_DO_NOT_USE
+#        define uregex_useTransparentBounds uregex_useTransparentBounds_DRAFT_API_DO_NOT_USE
+#    else
+#        define afkLanguageCode_4_0 afkLanguageCode_DRAFT_API_DO_NOT_USE
+#        define armiScriptCode_4_0 armiScriptCode_DRAFT_API_DO_NOT_USE
+#        define u_fclose_4_0 u_fclose_DRAFT_API_DO_NOT_USE
+#        define u_feof_4_0 u_feof_DRAFT_API_DO_NOT_USE
+#        define u_fflush_4_0 u_fflush_DRAFT_API_DO_NOT_USE
+#        define u_fgetConverter_4_0 u_fgetConverter_DRAFT_API_DO_NOT_USE
+#        define u_fgetc_4_0 u_fgetc_DRAFT_API_DO_NOT_USE
+#        define u_fgetcodepage_4_0 u_fgetcodepage_DRAFT_API_DO_NOT_USE
+#        define u_fgetcx_4_0 u_fgetcx_DRAFT_API_DO_NOT_USE
+#        define u_fgetfile_4_0 u_fgetfile_DRAFT_API_DO_NOT_USE
+#        define u_fgetlocale_4_0 u_fgetlocale_DRAFT_API_DO_NOT_USE
+#        define u_fgets_4_0 u_fgets_DRAFT_API_DO_NOT_USE
+#        define u_file_read_4_0 u_file_read_DRAFT_API_DO_NOT_USE
+#        define u_file_write_4_0 u_file_write_DRAFT_API_DO_NOT_USE
+#        define u_finit_4_0 u_finit_DRAFT_API_DO_NOT_USE
+#        define u_fopen_4_0 u_fopen_DRAFT_API_DO_NOT_USE
+#        define u_fprintf_4_0 u_fprintf_DRAFT_API_DO_NOT_USE
+#        define u_fprintf_u_4_0 u_fprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_fputc_4_0 u_fputc_DRAFT_API_DO_NOT_USE
+#        define u_fputs_4_0 u_fputs_DRAFT_API_DO_NOT_USE
+#        define u_frewind_4_0 u_frewind_DRAFT_API_DO_NOT_USE
+#        define u_fscanf_4_0 u_fscanf_DRAFT_API_DO_NOT_USE
+#        define u_fscanf_u_4_0 u_fscanf_u_DRAFT_API_DO_NOT_USE
+#        define u_fsetcodepage_4_0 u_fsetcodepage_DRAFT_API_DO_NOT_USE
+#        define u_fsetlocale_4_0 u_fsetlocale_DRAFT_API_DO_NOT_USE
+#        define u_fsettransliterator_4_0 u_fsettransliterator_DRAFT_API_DO_NOT_USE
+#        define u_fstropen_4_0 u_fstropen_DRAFT_API_DO_NOT_USE
+#        define u_fungetc_4_0 u_fungetc_DRAFT_API_DO_NOT_USE
+#        define u_snprintf_4_0 u_snprintf_DRAFT_API_DO_NOT_USE
+#        define u_snprintf_u_4_0 u_snprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_sprintf_4_0 u_sprintf_DRAFT_API_DO_NOT_USE
+#        define u_sprintf_u_4_0 u_sprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_sscanf_4_0 u_sscanf_DRAFT_API_DO_NOT_USE
+#        define u_sscanf_u_4_0 u_sscanf_u_DRAFT_API_DO_NOT_USE
+#        define u_vfprintf_4_0 u_vfprintf_DRAFT_API_DO_NOT_USE
+#        define u_vfprintf_u_4_0 u_vfprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_vfscanf_4_0 u_vfscanf_DRAFT_API_DO_NOT_USE
+#        define u_vfscanf_u_4_0 u_vfscanf_u_DRAFT_API_DO_NOT_USE
+#        define u_vsnprintf_4_0 u_vsnprintf_DRAFT_API_DO_NOT_USE
+#        define u_vsnprintf_u_4_0 u_vsnprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_vsprintf_4_0 u_vsprintf_DRAFT_API_DO_NOT_USE
+#        define u_vsprintf_u_4_0 u_vsprintf_u_DRAFT_API_DO_NOT_USE
+#        define u_vsscanf_4_0 u_vsscanf_DRAFT_API_DO_NOT_USE
+#        define u_vsscanf_u_4_0 u_vsscanf_u_DRAFT_API_DO_NOT_USE
+#        define ucal_clone_4_0 ucal_clone_DRAFT_API_DO_NOT_USE
+#        define ucal_getCanonicalTimeZoneID_4_0 ucal_getCanonicalTimeZoneID_DRAFT_API_DO_NOT_USE
+#        define ucurr_countCurrencies_4_0 ucurr_countCurrencies_DRAFT_API_DO_NOT_USE
+#        define ucurr_forLocaleAndDate_4_0 ucurr_forLocaleAndDate_DRAFT_API_DO_NOT_USE
+#        define uloc_addLikelySubtags_4_0 uloc_addLikelySubtags_DRAFT_API_DO_NOT_USE
+#        define uloc_getCharacterOrientation_4_0 uloc_getCharacterOrientation_DRAFT_API_DO_NOT_USE
+#        define uloc_getLineOrientation_4_0 uloc_getLineOrientation_DRAFT_API_DO_NOT_USE
+#        define uloc_minimizeSubtags_4_0 uloc_minimizeSubtags_DRAFT_API_DO_NOT_USE
+#        define uregex_getMatchCallback_4_0 uregex_getMatchCallback_DRAFT_API_DO_NOT_USE
+#        define uregex_getStackLimit_4_0 uregex_getStackLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_getTimeLimit_4_0 uregex_getTimeLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_hasAnchoringBounds_4_0 uregex_hasAnchoringBounds_DRAFT_API_DO_NOT_USE
+#        define uregex_hasTransparentBounds_4_0 uregex_hasTransparentBounds_DRAFT_API_DO_NOT_USE
+#        define uregex_hitEnd_4_0 uregex_hitEnd_DRAFT_API_DO_NOT_USE
+#        define uregex_regionEnd_4_0 uregex_regionEnd_DRAFT_API_DO_NOT_USE
+#        define uregex_regionStart_4_0 uregex_regionStart_DRAFT_API_DO_NOT_USE
+#        define uregex_requireEnd_4_0 uregex_requireEnd_DRAFT_API_DO_NOT_USE
+#        define uregex_setMatchCallback_4_0 uregex_setMatchCallback_DRAFT_API_DO_NOT_USE
+#        define uregex_setRegion_4_0 uregex_setRegion_DRAFT_API_DO_NOT_USE
+#        define uregex_setStackLimit_4_0 uregex_setStackLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_setTimeLimit_4_0 uregex_setTimeLimit_DRAFT_API_DO_NOT_USE
+#        define uregex_useAnchoringBounds_4_0 uregex_useAnchoringBounds_DRAFT_API_DO_NOT_USE
+#        define uregex_useTransparentBounds_4_0 uregex_useTransparentBounds_DRAFT_API_DO_NOT_USE
+#    endif /* U_DISABLE_RENAMING */
+
+#endif /* U_HIDE_DRAFT_API */
+#endif /* UDRAFT_H */
+
diff --git a/CoreFoundation/icu/unicode/uenum.h b/CoreFoundation/icu/unicode/uenum.h
new file mode 100644
index 0000000..ff9b299
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uenum.h
@@ -0,0 +1,134 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2002-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  uenum.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:2
+*
+*   created on: 2002jul08
+*   created by: Vladimir Weinstein
+*/
+
+#ifndef __UENUM_H
+#define __UENUM_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C API: String Enumeration 
+ */
+ 
+/**
+ * An enumeration object.
+ * For usage in C programs.
+ * @stable ICU 2.2
+ */
+struct UEnumeration;
+/** structure representing an enumeration object instance @stable ICU 2.2 */
+typedef struct UEnumeration UEnumeration;
+
+/**
+ * Disposes of resources in use by the iterator.  If en is NULL,
+ * does nothing.  After this call, any char* or UChar* pointer
+ * returned by uenum_unext() or uenum_next() is invalid.
+ * @param en UEnumeration structure pointer
+ * @stable ICU 2.2
+ */
+U_STABLE void U_EXPORT2
+uenum_close(UEnumeration* en);
+
+/**
+ * Returns the number of elements that the iterator traverses.  If
+ * the iterator is out-of-sync with its service, status is set to
+ * U_ENUM_OUT_OF_SYNC_ERROR.
+ * This is a convenience function. It can end up being very
+ * expensive as all the items might have to be pre-fetched (depending
+ * on the type of data being traversed). Use with caution and only 
+ * when necessary.
+ * @param en UEnumeration structure pointer
+ * @param status error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the
+ *               iterator is out of sync.
+ * @return number of elements in the iterator
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+uenum_count(UEnumeration* en, UErrorCode* status);
+
+/**
+ * Returns the next element in the iterator's list.  If there are
+ * no more elements, returns NULL.  If the iterator is out-of-sync
+ * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and
+ * NULL is returned.  If the native service string is a char* string,
+ * it is converted to UChar* with the invariant converter.
+ * The result is terminated by (UChar)0.
+ * @param en the iterator object
+ * @param resultLength pointer to receive the length of the result
+ *                     (not including the terminating \\0).
+ *                     If the pointer is NULL it is ignored.
+ * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
+ *               the iterator is out of sync with its service.
+ * @return a pointer to the string.  The string will be
+ *         zero-terminated.  The return pointer is owned by this iterator
+ *         and must not be deleted by the caller.  The pointer is valid
+ *         until the next call to any uenum_... method, including
+ *         uenum_next() or uenum_unext().  When all strings have been
+ *         traversed, returns NULL.
+ * @stable ICU 2.2
+ */
+U_STABLE const UChar* U_EXPORT2
+uenum_unext(UEnumeration* en,
+            int32_t* resultLength,
+            UErrorCode* status);
+
+/**
+ * Returns the next element in the iterator's list.  If there are
+ * no more elements, returns NULL.  If the iterator is out-of-sync
+ * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and
+ * NULL is returned.  If the native service string is a UChar*
+ * string, it is converted to char* with the invariant converter.
+ * The result is terminated by (char)0.  If the conversion fails
+ * (because a character cannot be converted) then status is set to
+ * U_INVARIANT_CONVERSION_ERROR and the return value is undefined
+ * (but non-NULL).
+ * @param en the iterator object
+ * @param resultLength pointer to receive the length of the result
+ *                     (not including the terminating \\0).
+ *                     If the pointer is NULL it is ignored.
+ * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
+ *               the iterator is out of sync with its service.  Set to
+ *               U_INVARIANT_CONVERSION_ERROR if the underlying native string is
+ *               UChar* and conversion to char* with the invariant converter
+ *               fails. This error pertains only to current string, so iteration
+ *               might be able to continue successfully.
+ * @return a pointer to the string.  The string will be
+ *         zero-terminated.  The return pointer is owned by this iterator
+ *         and must not be deleted by the caller.  The pointer is valid
+ *         until the next call to any uenum_... method, including
+ *         uenum_next() or uenum_unext().  When all strings have been
+ *         traversed, returns NULL.
+ * @stable ICU 2.2
+ */
+U_STABLE const char* U_EXPORT2
+uenum_next(UEnumeration* en,
+           int32_t* resultLength,
+           UErrorCode* status);
+
+/**
+ * Resets the iterator to the current list of service IDs.  This
+ * re-establishes sync with the service and rewinds the iterator
+ * to start at the first element.
+ * @param en the iterator object
+ * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
+ *               the iterator is out of sync with its service.  
+ * @stable ICU 2.2
+ */
+U_STABLE void U_EXPORT2
+uenum_reset(UEnumeration* en, UErrorCode* status);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uidna.h b/CoreFoundation/icu/unicode/uidna.h
new file mode 100644
index 0000000..52aa6e9
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uidna.h
@@ -0,0 +1,312 @@
+/*
+ *******************************************************************************
+ *
+ *   Copyright (C) 2003-2007, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ *
+ *******************************************************************************
+ *   file name:  uidna.h
+ *   encoding:   US-ASCII
+ *   tab size:   8 (not used)
+ *   indentation:4
+ *
+ *   created on: 2003feb1
+ *   created by: Ram Viswanadha
+ */
+
+#ifndef __UIDNA_H__
+#define __UIDNA_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_IDNA
+
+#include "unicode/parseerr.h"
+  
+/**
+ * \file
+ * \brief C API: Internationalized Domain Names in Applications Tranformation
+ *
+ * UIDNA API implements the IDNA protocol as defined in the IDNA RFC 
+ * (http://www.ietf.org/rfc/rfc3490.txt).
+ * The RFC defines 2 operations: ToASCII and ToUnicode. Domain labels 
+ * containing non-ASCII code points are required to be processed by
+ * ToASCII operation before passing it to resolver libraries. Domain names
+ * that are obtained from resolver libraries are required to be processed by
+ * ToUnicode operation before displaying the domain name to the user.
+ * IDNA requires that implementations process input strings with Nameprep
+ * (http://www.ietf.org/rfc/rfc3491.txt), 
+ * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt), 
+ * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt). 
+ * Implementations of IDNA MUST fully implement Nameprep and Punycode; 
+ * neither Nameprep nor Punycode are optional.
+ * The input and output of ToASCII and ToUnicode operations are Unicode 
+ * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations
+ * multiple times to an input string will yield the same result as applying the operation
+ * once.
+ * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) 
+ * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string).
+ *
+ */
+
+/** 
+ * Option to prohibit processing of unassigned codepoints in the input and
+ * do not check if the input conforms to STD-3 ASCII rules.
+ * 
+ * @see  uidna_toASCII uidna_toUnicode
+ * @stable ICU 2.6
+ */
+#define UIDNA_DEFAULT          0x0000
+/** 
+ * Option to allow processing of unassigned codepoints in the input
+ * 
+ * @see  uidna_toASCII uidna_toUnicode
+ * @stable ICU 2.6
+ */
+#define UIDNA_ALLOW_UNASSIGNED 0x0001
+/** 
+ * Option to check if input conforms to STD-3 ASCII rules
+ * 
+ * @see  uidna_toASCII uidna_toUnicode
+ * @stable ICU 2.6
+ */
+#define UIDNA_USE_STD3_RULES   0x0002
+
+/**
+ * This function implements the ToASCII operation as defined in the IDNA RFC.
+ * This operation is done on <b>single labels</b> before sending it to something that expects
+ * ASCII names. A label is an individual part of a domain name. Labels are usually
+ * separated by dots; e.g." "www.example.com" is composed of 3 labels 
+ * "www","example", and "com".
+ *
+ *
+ * @param src               Input UChar array containing label in Unicode.
+ * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
+ * @param dest              Output UChar array with ASCII (ACE encoded) label.
+ * @param destCapacity      Size of dest.
+ * @param options           A bit set of options:
+ *
+ *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
+ *                              and do not use STD3 ASCII rules
+ *                              If unassigned code points are found the operation fails with 
+ *                              U_UNASSIGNED_ERROR error code.
+ *
+ *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
+ *                              If this option is set, the unassigned code points are in the input 
+ *                              are treated as normal Unicode code points.
+ *                          
+ *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
+ *                              If this option is set and the input does not satisfy STD3 rules,  
+ *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
+ *
+ * @param parseError        Pointer to UParseError struct to receive information on position 
+ *                          of error if an error is encountered. Can be NULL.
+ * @param status            ICU in/out error code parameter.
+ *                          U_INVALID_CHAR_FOUND if src contains
+ *                          unmatched single surrogates.
+ *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
+ *                          too many code points.
+ *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+uidna_toASCII(const UChar* src, int32_t srcLength, 
+              UChar* dest, int32_t destCapacity,
+              int32_t options,
+              UParseError* parseError,
+              UErrorCode* status);
+
+
+/**
+ * This function implements the ToUnicode operation as defined in the IDNA RFC.
+ * This operation is done on <b>single labels</b> before sending it to something that expects
+ * Unicode names. A label is an individual part of a domain name. Labels are usually
+ * separated by dots; for e.g." "www.example.com" is composed of 3 labels 
+ * "www","example", and "com".
+ *
+ * @param src               Input UChar array containing ASCII (ACE encoded) label.
+ * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
+ * @param dest Output       Converted UChar array containing Unicode equivalent of label.
+ * @param destCapacity      Size of dest.
+ * @param options           A bit set of options:
+ *  
+ *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
+ *                              and do not use STD3 ASCII rules
+ *                              If unassigned code points are found the operation fails with 
+ *                              U_UNASSIGNED_ERROR error code.
+ *
+ *  - UIDNA_ALLOW_UNASSIGNED      Unassigned values can be converted to ASCII for query operations
+ *                              If this option is set, the unassigned code points are in the input 
+ *                              are treated as normal Unicode code points. <b> Note: </b> This option is 
+ *                              required on toUnicode operation because the RFC mandates 
+ *                              verification of decoded ACE input by applying toASCII and comparing
+ *                              its output with source
+ *
+ *                          
+ *                          
+ *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
+ *                              If this option is set and the input does not satisfy STD3 rules,  
+ *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
+ *
+ * @param parseError        Pointer to UParseError struct to receive information on position 
+ *                          of error if an error is encountered. Can be NULL.
+ * @param status            ICU in/out error code parameter.
+ *                          U_INVALID_CHAR_FOUND if src contains
+ *                          unmatched single surrogates.
+ *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
+ *                          too many code points.
+ *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+uidna_toUnicode(const UChar* src, int32_t srcLength,
+                UChar* dest, int32_t destCapacity,
+                int32_t options,
+                UParseError* parseError,
+                UErrorCode* status);
+
+
+/**
+ * Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC.
+ * This operation is done on complete domain names, e.g: "www.example.com". 
+ * It is important to note that this operation can fail. If it fails, then the input 
+ * domain name cannot be used as an Internationalized Domain Name and the application
+ * should have methods defined to deal with the failure.
+ * 
+ * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name
+ * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 
+ * and then convert. This function does not offer that level of granularity. The options once  
+ * set will apply to all labels in the domain name
+ *
+ * @param src               Input UChar array containing IDN in Unicode.
+ * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
+ * @param dest              Output UChar array with ASCII (ACE encoded) IDN.
+ * @param destCapacity      Size of dest.
+ * @param options           A bit set of options:
+ *  
+ *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
+ *                              and do not use STD3 ASCII rules
+ *                              If unassigned code points are found the operation fails with 
+ *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
+ *
+ *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
+ *                              If this option is set, the unassigned code points are in the input 
+ *                              are treated as normal Unicode code points.
+ *                          
+ *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
+ *                              If this option is set and the input does not satisfy STD3 rules,  
+ *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
+ * 
+ * @param parseError        Pointer to UParseError struct to receive information on position 
+ *                          of error if an error is encountered. Can be NULL.
+ * @param status            ICU in/out error code parameter.
+ *                          U_INVALID_CHAR_FOUND if src contains
+ *                          unmatched single surrogates.
+ *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
+ *                          too many code points.
+ *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+uidna_IDNToASCII(  const UChar* src, int32_t srcLength,
+                   UChar* dest, int32_t destCapacity,
+                   int32_t options,
+                   UParseError* parseError,
+                   UErrorCode* status);
+
+/**
+ * Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC.
+ * This operation is done on complete domain names, e.g: "www.example.com". 
+ *
+ * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name
+ * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 
+ * and then convert. This function does not offer that level of granularity. The options once  
+ * set will apply to all labels in the domain name
+ *
+ * @param src               Input UChar array containing IDN in ASCII (ACE encoded) form.
+ * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
+ * @param dest Output       UChar array containing Unicode equivalent of source IDN.
+ * @param destCapacity      Size of dest.
+ * @param options           A bit set of options:
+ *  
+ *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
+ *                              and do not use STD3 ASCII rules
+ *                              If unassigned code points are found the operation fails with 
+ *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
+ *
+ *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
+ *                              If this option is set, the unassigned code points are in the input 
+ *                              are treated as normal Unicode code points.
+ *                          
+ *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
+ *                              If this option is set and the input does not satisfy STD3 rules,  
+ *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
+ *
+ * @param parseError        Pointer to UParseError struct to receive information on position 
+ *                          of error if an error is encountered. Can be NULL.
+ * @param status            ICU in/out error code parameter.
+ *                          U_INVALID_CHAR_FOUND if src contains
+ *                          unmatched single surrogates.
+ *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
+ *                          too many code points.
+ *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
+ * @return The length of the result string, if successful - or in case of a buffer overflow,
+ *         in which case it will be greater than destCapacity.
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+uidna_IDNToUnicode(  const UChar* src, int32_t srcLength,
+                     UChar* dest, int32_t destCapacity,
+                     int32_t options,
+                     UParseError* parseError,
+                     UErrorCode* status);
+
+/**
+ * Compare two IDN strings for equivalence.
+ * This function splits the domain names into labels and compares them.
+ * According to IDN RFC, whenever two labels are compared, they are 
+ * considered equal if and only if their ASCII forms (obtained by 
+ * applying toASCII) match using an case-insensitive ASCII comparison.
+ * Two domain names are considered a match if and only if all labels 
+ * match regardless of whether label separators match.
+ *
+ * @param s1                First source string.
+ * @param length1           Length of first source string, or -1 if NUL-terminated.
+ *
+ * @param s2                Second source string.
+ * @param length2           Length of second source string, or -1 if NUL-terminated.
+ * @param options           A bit set of options:
+ *  
+ *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
+ *                              and do not use STD3 ASCII rules
+ *                              If unassigned code points are found the operation fails with 
+ *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
+ *
+ *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
+ *                              If this option is set, the unassigned code points are in the input 
+ *                              are treated as normal Unicode code points.
+ *                          
+ *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
+ *                              If this option is set and the input does not satisfy STD3 rules,  
+ *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
+ *
+ * @param status            ICU error code in/out parameter.
+ *                          Must fulfill U_SUCCESS before the function call.
+ * @return <0 or 0 or >0 as usual for string comparisons
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+uidna_compare(  const UChar *s1, int32_t length1,
+                const UChar *s2, int32_t length2,
+                int32_t options,
+                UErrorCode* status);
+
+#endif /* #if !UCONFIG_NO_IDNA */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uintrnal.h b/CoreFoundation/icu/unicode/uintrnal.h
new file mode 100644
index 0000000..6a01f6b
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uintrnal.h
@@ -0,0 +1,180 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2004-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Created by: genheaders.pl, a perl script written by Ram Viswanadha
+*
+*  Contains data for commenting out APIs.
+*  Gets included by umachine.h
+*
+*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
+*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
+*/
+
+#ifndef UINTRNAL_H
+#define UINTRNAL_H
+
+#ifdef U_HIDE_INTERNAL_API
+
+#    if U_DISABLE_RENAMING
+#        define RegexPatternDump RegexPatternDump_INTERNAL_API_DO_NOT_USE
+#        define pl_addFontRun pl_addFontRun_INTERNAL_API_DO_NOT_USE
+#        define pl_addLocaleRun pl_addLocaleRun_INTERNAL_API_DO_NOT_USE
+#        define pl_addValueRun pl_addValueRun_INTERNAL_API_DO_NOT_USE
+#        define pl_close pl_close_INTERNAL_API_DO_NOT_USE
+#        define pl_closeFontRuns pl_closeFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_closeLine pl_closeLine_INTERNAL_API_DO_NOT_USE
+#        define pl_closeLocaleRuns pl_closeLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_closeValueRuns pl_closeValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_countLineRuns pl_countLineRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_create pl_create_INTERNAL_API_DO_NOT_USE
+#        define pl_getAscent pl_getAscent_INTERNAL_API_DO_NOT_USE
+#        define pl_getDescent pl_getDescent_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunCount pl_getFontRunCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunFont pl_getFontRunFont_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunLastLimit pl_getFontRunLastLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunLimit pl_getFontRunLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getLeading pl_getLeading_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineAscent pl_getLineAscent_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineDescent pl_getLineDescent_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineLeading pl_getLineLeading_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineVisualRun pl_getLineVisualRun_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineWidth pl_getLineWidth_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunCount pl_getLocaleRunCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunLastLimit pl_getLocaleRunLastLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunLimit pl_getLocaleRunLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunLocale pl_getLocaleRunLocale_INTERNAL_API_DO_NOT_USE
+#        define pl_getParagraphLevel pl_getParagraphLevel_INTERNAL_API_DO_NOT_USE
+#        define pl_getTextDirection pl_getTextDirection_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunCount pl_getValueRunCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunLastLimit pl_getValueRunLastLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunLimit pl_getValueRunLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunValue pl_getValueRunValue_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunAscent pl_getVisualRunAscent_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunDescent pl_getVisualRunDescent_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunDirection pl_getVisualRunDirection_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunFont pl_getVisualRunFont_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunGlyphCount pl_getVisualRunGlyphCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunGlyphToCharMap pl_getVisualRunGlyphToCharMap_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunGlyphs pl_getVisualRunGlyphs_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunLeading pl_getVisualRunLeading_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunPositions pl_getVisualRunPositions_INTERNAL_API_DO_NOT_USE
+#        define pl_isComplex pl_isComplex_INTERNAL_API_DO_NOT_USE
+#        define pl_line pl_line_INTERNAL_API_DO_NOT_USE
+#        define pl_nextLine pl_nextLine_INTERNAL_API_DO_NOT_USE
+#        define pl_openEmptyFontRuns pl_openEmptyFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openEmptyLocaleRuns pl_openEmptyLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openEmptyValueRuns pl_openEmptyValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openFontRuns pl_openFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openLocaleRuns pl_openLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openValueRuns pl_openValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_paragraph pl_paragraph_INTERNAL_API_DO_NOT_USE
+#        define pl_reflow pl_reflow_INTERNAL_API_DO_NOT_USE
+#        define pl_resetFontRuns pl_resetFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_resetLocaleRuns pl_resetLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_resetValueRuns pl_resetValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_visualRun pl_visualRun_INTERNAL_API_DO_NOT_USE
+#        define ucol_equals ucol_equals_INTERNAL_API_DO_NOT_USE
+#        define ucol_forgetUCA ucol_forgetUCA_INTERNAL_API_DO_NOT_USE
+#        define ucol_getAttributeOrDefault ucol_getAttributeOrDefault_INTERNAL_API_DO_NOT_USE
+#        define ucol_getUnsafeSet ucol_getUnsafeSet_INTERNAL_API_DO_NOT_USE
+#        define ucol_nextProcessed ucol_nextProcessed_INTERNAL_API_DO_NOT_USE
+#        define ucol_prepareShortStringOpen ucol_prepareShortStringOpen_INTERNAL_API_DO_NOT_USE
+#        define ucol_previousProcessed ucol_previousProcessed_INTERNAL_API_DO_NOT_USE
+#        define uprv_getDefaultCodepage uprv_getDefaultCodepage_INTERNAL_API_DO_NOT_USE
+#        define uprv_getDefaultLocaleID uprv_getDefaultLocaleID_INTERNAL_API_DO_NOT_USE
+#        define ures_openFillIn ures_openFillIn_INTERNAL_API_DO_NOT_USE
+#        define usearch_search usearch_search_INTERNAL_API_DO_NOT_USE
+#        define usearch_searchBackwards usearch_searchBackwards_INTERNAL_API_DO_NOT_USE
+#        define utf8_appendCharSafeBody utf8_appendCharSafeBody_INTERNAL_API_DO_NOT_USE
+#        define utf8_back1SafeBody utf8_back1SafeBody_INTERNAL_API_DO_NOT_USE
+#        define utf8_countTrailBytes utf8_countTrailBytes_INTERNAL_API_DO_NOT_USE
+#        define utf8_nextCharSafeBody utf8_nextCharSafeBody_INTERNAL_API_DO_NOT_USE
+#        define utf8_prevCharSafeBody utf8_prevCharSafeBody_INTERNAL_API_DO_NOT_USE
+#    else
+#        define RegexPatternDump_4_0 RegexPatternDump_INTERNAL_API_DO_NOT_USE
+#        define pl_addFontRun_4_0 pl_addFontRun_INTERNAL_API_DO_NOT_USE
+#        define pl_addLocaleRun_4_0 pl_addLocaleRun_INTERNAL_API_DO_NOT_USE
+#        define pl_addValueRun_4_0 pl_addValueRun_INTERNAL_API_DO_NOT_USE
+#        define pl_closeFontRuns_4_0 pl_closeFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_closeLine_4_0 pl_closeLine_INTERNAL_API_DO_NOT_USE
+#        define pl_closeLocaleRuns_4_0 pl_closeLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_closeValueRuns_4_0 pl_closeValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_close_4_0 pl_close_INTERNAL_API_DO_NOT_USE
+#        define pl_countLineRuns_4_0 pl_countLineRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_create_4_0 pl_create_INTERNAL_API_DO_NOT_USE
+#        define pl_getAscent_4_0 pl_getAscent_INTERNAL_API_DO_NOT_USE
+#        define pl_getDescent_4_0 pl_getDescent_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunCount_4_0 pl_getFontRunCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunFont_4_0 pl_getFontRunFont_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunLastLimit_4_0 pl_getFontRunLastLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getFontRunLimit_4_0 pl_getFontRunLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getLeading_4_0 pl_getLeading_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineAscent_4_0 pl_getLineAscent_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineDescent_4_0 pl_getLineDescent_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineLeading_4_0 pl_getLineLeading_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineVisualRun_4_0 pl_getLineVisualRun_INTERNAL_API_DO_NOT_USE
+#        define pl_getLineWidth_4_0 pl_getLineWidth_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunCount_4_0 pl_getLocaleRunCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunLastLimit_4_0 pl_getLocaleRunLastLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunLimit_4_0 pl_getLocaleRunLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getLocaleRunLocale_4_0 pl_getLocaleRunLocale_INTERNAL_API_DO_NOT_USE
+#        define pl_getParagraphLevel_4_0 pl_getParagraphLevel_INTERNAL_API_DO_NOT_USE
+#        define pl_getTextDirection_4_0 pl_getTextDirection_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunCount_4_0 pl_getValueRunCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunLastLimit_4_0 pl_getValueRunLastLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunLimit_4_0 pl_getValueRunLimit_INTERNAL_API_DO_NOT_USE
+#        define pl_getValueRunValue_4_0 pl_getValueRunValue_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunAscent_4_0 pl_getVisualRunAscent_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunDescent_4_0 pl_getVisualRunDescent_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunDirection_4_0 pl_getVisualRunDirection_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunFont_4_0 pl_getVisualRunFont_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunGlyphCount_4_0 pl_getVisualRunGlyphCount_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunGlyphToCharMap_4_0 pl_getVisualRunGlyphToCharMap_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunGlyphs_4_0 pl_getVisualRunGlyphs_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunLeading_4_0 pl_getVisualRunLeading_INTERNAL_API_DO_NOT_USE
+#        define pl_getVisualRunPositions_4_0 pl_getVisualRunPositions_INTERNAL_API_DO_NOT_USE
+#        define pl_isComplex_4_0 pl_isComplex_INTERNAL_API_DO_NOT_USE
+#        define pl_line_4_0 pl_line_INTERNAL_API_DO_NOT_USE
+#        define pl_nextLine_4_0 pl_nextLine_INTERNAL_API_DO_NOT_USE
+#        define pl_openEmptyFontRuns_4_0 pl_openEmptyFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openEmptyLocaleRuns_4_0 pl_openEmptyLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openEmptyValueRuns_4_0 pl_openEmptyValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openFontRuns_4_0 pl_openFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openLocaleRuns_4_0 pl_openLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_openValueRuns_4_0 pl_openValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_paragraph_4_0 pl_paragraph_INTERNAL_API_DO_NOT_USE
+#        define pl_reflow_4_0 pl_reflow_INTERNAL_API_DO_NOT_USE
+#        define pl_resetFontRuns_4_0 pl_resetFontRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_resetLocaleRuns_4_0 pl_resetLocaleRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_resetValueRuns_4_0 pl_resetValueRuns_INTERNAL_API_DO_NOT_USE
+#        define pl_visualRun_4_0 pl_visualRun_INTERNAL_API_DO_NOT_USE
+#        define ucol_equals_4_0 ucol_equals_INTERNAL_API_DO_NOT_USE
+#        define ucol_forgetUCA_4_0 ucol_forgetUCA_INTERNAL_API_DO_NOT_USE
+#        define ucol_getAttributeOrDefault_4_0 ucol_getAttributeOrDefault_INTERNAL_API_DO_NOT_USE
+#        define ucol_getUnsafeSet_4_0 ucol_getUnsafeSet_INTERNAL_API_DO_NOT_USE
+#        define ucol_nextProcessed_4_0 ucol_nextProcessed_INTERNAL_API_DO_NOT_USE
+#        define ucol_prepareShortStringOpen_4_0 ucol_prepareShortStringOpen_INTERNAL_API_DO_NOT_USE
+#        define ucol_previousProcessed_4_0 ucol_previousProcessed_INTERNAL_API_DO_NOT_USE
+#        define uprv_getDefaultCodepage_4_0 uprv_getDefaultCodepage_INTERNAL_API_DO_NOT_USE
+#        define uprv_getDefaultLocaleID_4_0 uprv_getDefaultLocaleID_INTERNAL_API_DO_NOT_USE
+#        define ures_openFillIn_4_0 ures_openFillIn_INTERNAL_API_DO_NOT_USE
+#        define usearch_searchBackwards_4_0 usearch_searchBackwards_INTERNAL_API_DO_NOT_USE
+#        define usearch_search_4_0 usearch_search_INTERNAL_API_DO_NOT_USE
+#        define utf8_appendCharSafeBody_4_0 utf8_appendCharSafeBody_INTERNAL_API_DO_NOT_USE
+#        define utf8_back1SafeBody_4_0 utf8_back1SafeBody_INTERNAL_API_DO_NOT_USE
+#        define utf8_countTrailBytes_4_0 utf8_countTrailBytes_INTERNAL_API_DO_NOT_USE
+#        define utf8_nextCharSafeBody_4_0 utf8_nextCharSafeBody_INTERNAL_API_DO_NOT_USE
+#        define utf8_prevCharSafeBody_4_0 utf8_prevCharSafeBody_INTERNAL_API_DO_NOT_USE
+#    endif /* U_DISABLE_RENAMING */
+
+#endif /* U_HIDE_INTERNAL_API */
+#endif /* UINTRNAL_H */
+
diff --git a/CoreFoundation/icu/unicode/uiter.h b/CoreFoundation/icu/unicode/uiter.h
new file mode 100644
index 0000000..9409f01
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uiter.h
@@ -0,0 +1,707 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2002-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  uiter.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2002jan18
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __UITER_H__
+#define __UITER_H__
+
+/**
+ * \file
+ * \brief C API: Unicode Character Iteration
+ *
+ * @see UCharIterator
+ */
+
+#include "unicode/utypes.h"
+
+#ifdef XP_CPLUSPLUS
+    U_NAMESPACE_BEGIN
+
+    class CharacterIterator;
+    class Replaceable;
+
+    U_NAMESPACE_END
+#endif
+
+U_CDECL_BEGIN
+
+struct UCharIterator;
+typedef struct UCharIterator UCharIterator; /**< C typedef for struct UCharIterator. @stable ICU 2.1 */
+
+/**
+ * Origin constants for UCharIterator.getIndex() and UCharIterator.move().
+ * @see UCharIteratorMove
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef enum UCharIteratorOrigin {
+    UITER_START, UITER_CURRENT, UITER_LIMIT, UITER_ZERO, UITER_LENGTH
+} UCharIteratorOrigin;
+
+/** Constants for UCharIterator. @stable ICU 2.6 */
+enum {
+    /**
+     * Constant value that may be returned by UCharIteratorMove
+     * indicating that the final UTF-16 index is not known, but that the move succeeded.
+     * This can occur when moving relative to limit or length, or
+     * when moving relative to the current index after a setState()
+     * when the current UTF-16 index is not known.
+     *
+     * It would be very inefficient to have to count from the beginning of the text
+     * just to get the current/limit/length index after moving relative to it.
+     * The actual index can be determined with getIndex(UITER_CURRENT)
+     * which will count the UChars if necessary.
+     *
+     * @stable ICU 2.6
+     */
+    UITER_UNKNOWN_INDEX=-2
+};
+
+
+/**
+ * Constant for UCharIterator getState() indicating an error or
+ * an unknown state.
+ * Returned by uiter_getState()/UCharIteratorGetState
+ * when an error occurs.
+ * Also, some UCharIterator implementations may not be able to return
+ * a valid state for each position. This will be clearly documented
+ * for each such iterator (none of the public ones here).
+ *
+ * @stable ICU 2.6
+ */
+#define UITER_NO_STATE ((uint32_t)0xffffffff)
+
+/**
+ * Function type declaration for UCharIterator.getIndex().
+ *
+ * Gets the current position, or the start or limit of the
+ * iteration range.
+ *
+ * This function may perform slowly for UITER_CURRENT after setState() was called,
+ * or for UITER_LENGTH, because an iterator implementation may have to count
+ * UChars if the underlying storage is not UTF-16.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @param origin get the 0, start, limit, length, or current index
+ * @return the requested index, or U_SENTINEL in an error condition
+ *
+ * @see UCharIteratorOrigin
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef int32_t U_CALLCONV
+UCharIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin);
+
+/**
+ * Function type declaration for UCharIterator.move().
+ *
+ * Use iter->move(iter, index, UITER_ZERO) like CharacterIterator::setIndex(index).
+ *
+ * Moves the current position relative to the start or limit of the
+ * iteration range, or relative to the current position itself.
+ * The movement is expressed in numbers of code units forward
+ * or backward by specifying a positive or negative delta.
+ * Out of bounds movement will be pinned to the start or limit.
+ *
+ * This function may perform slowly for moving relative to UITER_LENGTH
+ * because an iterator implementation may have to count the rest of the
+ * UChars if the native storage is not UTF-16.
+ *
+ * When moving relative to the limit or length, or
+ * relative to the current position after setState() was called,
+ * move() may return UITER_UNKNOWN_INDEX (-2) to avoid an inefficient
+ * determination of the actual UTF-16 index.
+ * The actual index can be determined with getIndex(UITER_CURRENT)
+ * which will count the UChars if necessary.
+ * See UITER_UNKNOWN_INDEX for details.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @param delta can be positive, zero, or negative
+ * @param origin move relative to the 0, start, limit, length, or current index
+ * @return the new index, or U_SENTINEL on an error condition,
+ *         or UITER_UNKNOWN_INDEX when the index is not known.
+ *
+ * @see UCharIteratorOrigin
+ * @see UCharIterator
+ * @see UITER_UNKNOWN_INDEX
+ * @stable ICU 2.1
+ */
+typedef int32_t U_CALLCONV
+UCharIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin);
+
+/**
+ * Function type declaration for UCharIterator.hasNext().
+ *
+ * Check if current() and next() can still
+ * return another code unit.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return boolean value for whether current() and next() can still return another code unit
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef UBool U_CALLCONV
+UCharIteratorHasNext(UCharIterator *iter);
+
+/**
+ * Function type declaration for UCharIterator.hasPrevious().
+ *
+ * Check if previous() can still return another code unit.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return boolean value for whether previous() can still return another code unit
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef UBool U_CALLCONV
+UCharIteratorHasPrevious(UCharIterator *iter);
+ 
+/**
+ * Function type declaration for UCharIterator.current().
+ *
+ * Return the code unit at the current position,
+ * or U_SENTINEL if there is none (index is at the limit).
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the current code unit
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef UChar32 U_CALLCONV
+UCharIteratorCurrent(UCharIterator *iter);
+
+/**
+ * Function type declaration for UCharIterator.next().
+ *
+ * Return the code unit at the current index and increment
+ * the index (post-increment, like s[i++]),
+ * or return U_SENTINEL if there is none (index is at the limit).
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the current code unit (and post-increment the current index)
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef UChar32 U_CALLCONV
+UCharIteratorNext(UCharIterator *iter);
+
+/**
+ * Function type declaration for UCharIterator.previous().
+ *
+ * Decrement the index and return the code unit from there
+ * (pre-decrement, like s[--i]),
+ * or return U_SENTINEL if there is none (index is at the start).
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the previous code unit (after pre-decrementing the current index)
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef UChar32 U_CALLCONV
+UCharIteratorPrevious(UCharIterator *iter);
+
+/**
+ * Function type declaration for UCharIterator.reservedFn().
+ * Reserved for future use.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @param something some integer argument
+ * @return some integer
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+typedef int32_t U_CALLCONV
+UCharIteratorReserved(UCharIterator *iter, int32_t something);
+
+/**
+ * Function type declaration for UCharIterator.getState().
+ *
+ * Get the "state" of the iterator in the form of a single 32-bit word.
+ * It is recommended that the state value be calculated to be as small as
+ * is feasible. For strings with limited lengths, fewer than 32 bits may
+ * be sufficient.
+ *
+ * This is used together with setState()/UCharIteratorSetState
+ * to save and restore the iterator position more efficiently than with
+ * getIndex()/move().
+ *
+ * The iterator state is defined as a uint32_t value because it is designed
+ * for use in ucol_nextSortKeyPart() which provides 32 bits to store the state
+ * of the character iterator.
+ *
+ * With some UCharIterator implementations (e.g., UTF-8),
+ * getting and setting the UTF-16 index with existing functions
+ * (getIndex(UITER_CURRENT) followed by move(pos, UITER_ZERO)) is possible but
+ * relatively slow because the iterator has to "walk" from a known index
+ * to the requested one.
+ * This takes more time the farther it needs to go.
+ *
+ * An opaque state value allows an iterator implementation to provide
+ * an internal index (UTF-8: the source byte array index) for
+ * fast, constant-time restoration.
+ *
+ * After calling setState(), a getIndex(UITER_CURRENT) may be slow because
+ * the UTF-16 index may not be restored as well, but the iterator can deliver
+ * the correct text contents and move relative to the current position
+ * without performance degradation.
+ *
+ * Some UCharIterator implementations may not be able to return
+ * a valid state for each position, in which case they return UITER_NO_STATE instead.
+ * This will be clearly documented for each such iterator (none of the public ones here).
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the state word
+ *
+ * @see UCharIterator
+ * @see UCharIteratorSetState
+ * @see UITER_NO_STATE
+ * @stable ICU 2.6
+ */
+typedef uint32_t U_CALLCONV
+UCharIteratorGetState(const UCharIterator *iter);
+
+/**
+ * Function type declaration for UCharIterator.setState().
+ *
+ * Restore the "state" of the iterator using a state word from a getState() call.
+ * The iterator object need not be the same one as for which getState() was called,
+ * but it must be of the same type (set up using the same uiter_setXYZ function)
+ * and it must iterate over the same string
+ * (binary identical regardless of memory address).
+ * For more about the state word see UCharIteratorGetState.
+ *
+ * After calling setState(), a getIndex(UITER_CURRENT) may be slow because
+ * the UTF-16 index may not be restored as well, but the iterator can deliver
+ * the correct text contents and move relative to the current position
+ * without performance degradation.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @param state the state word from a getState() call
+ *              on a same-type, same-string iterator
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                   which must not indicate a failure before the function call.
+ *
+ * @see UCharIterator
+ * @see UCharIteratorGetState
+ * @stable ICU 2.6
+ */
+typedef void U_CALLCONV
+UCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
+
+
+/**
+ * C API for code unit iteration.
+ * This can be used as a C wrapper around
+ * CharacterIterator, Replaceable, or implemented using simple strings, etc.
+ *
+ * There are two roles for using UCharIterator:
+ *
+ * A "provider" sets the necessary function pointers and controls the "protected"
+ * fields of the UCharIterator structure. A "provider" passes a UCharIterator
+ * into C APIs that need a UCharIterator as an abstract, flexible string interface.
+ *
+ * Implementations of such C APIs are "callers" of UCharIterator functions;
+ * they only use the "public" function pointers and never access the "protected"
+ * fields directly.
+ *
+ * The current() and next() functions only check the current index against the
+ * limit, and previous() only checks the current index against the start,
+ * to see if the iterator already reached the end of the iteration range.
+ *
+ * The assumption - in all iterators - is that the index is moved via the API,
+ * which means it won't go out of bounds, or the index is modified by
+ * user code that knows enough about the iterator implementation to set valid
+ * index values.
+ *
+ * UCharIterator functions return code unit values 0..0xffff,
+ * or U_SENTINEL if the iteration bounds are reached.
+ *
+ * @stable ICU 2.1
+ */
+struct UCharIterator {
+    /**
+     * (protected) Pointer to string or wrapped object or similar.
+     * Not used by caller.
+     * @stable ICU 2.1
+     */
+    const void *context;
+
+    /**
+     * (protected) Length of string or similar.
+     * Not used by caller.
+     * @stable ICU 2.1
+     */
+    int32_t length;
+
+    /**
+     * (protected) Start index or similar.
+     * Not used by caller.
+     * @stable ICU 2.1
+     */
+    int32_t start;
+
+    /**
+     * (protected) Current index or similar.
+     * Not used by caller.
+     * @stable ICU 2.1
+     */
+    int32_t index;
+
+    /**
+     * (protected) Limit index or similar.
+     * Not used by caller.
+     * @stable ICU 2.1
+     */
+    int32_t limit;
+
+    /**
+     * (protected) Used by UTF-8 iterators and possibly others.
+     * @stable ICU 2.1
+     */
+    int32_t reservedField;
+
+    /**
+     * (public) Returns the current position or the
+     * start or limit index of the iteration range.
+     *
+     * @see UCharIteratorGetIndex
+     * @stable ICU 2.1
+     */
+    UCharIteratorGetIndex *getIndex;
+
+    /**
+     * (public) Moves the current position relative to the start or limit of the
+     * iteration range, or relative to the current position itself.
+     * The movement is expressed in numbers of code units forward
+     * or backward by specifying a positive or negative delta.
+     *
+     * @see UCharIteratorMove
+     * @stable ICU 2.1
+     */
+    UCharIteratorMove *move;
+
+    /**
+     * (public) Check if current() and next() can still
+     * return another code unit.
+     *
+     * @see UCharIteratorHasNext
+     * @stable ICU 2.1
+     */
+    UCharIteratorHasNext *hasNext;
+
+    /**
+     * (public) Check if previous() can still return another code unit.
+     *
+     * @see UCharIteratorHasPrevious
+     * @stable ICU 2.1
+     */
+    UCharIteratorHasPrevious *hasPrevious;
+
+    /**
+     * (public) Return the code unit at the current position,
+     * or U_SENTINEL if there is none (index is at the limit).
+     *
+     * @see UCharIteratorCurrent
+     * @stable ICU 2.1
+     */
+    UCharIteratorCurrent *current;
+
+    /**
+     * (public) Return the code unit at the current index and increment
+     * the index (post-increment, like s[i++]),
+     * or return U_SENTINEL if there is none (index is at the limit).
+     *
+     * @see UCharIteratorNext
+     * @stable ICU 2.1
+     */
+    UCharIteratorNext *next;
+
+    /**
+     * (public) Decrement the index and return the code unit from there
+     * (pre-decrement, like s[--i]),
+     * or return U_SENTINEL if there is none (index is at the start).
+     *
+     * @see UCharIteratorPrevious
+     * @stable ICU 2.1
+     */
+    UCharIteratorPrevious *previous;
+
+    /**
+     * (public) Reserved for future use. Currently NULL.
+     *
+     * @see UCharIteratorReserved
+     * @stable ICU 2.1
+     */
+    UCharIteratorReserved *reservedFn;
+
+    /**
+     * (public) Return the state of the iterator, to be restored later with setState().
+     * This function pointer is NULL if the iterator does not implement it.
+     *
+     * @see UCharIteratorGet
+     * @stable ICU 2.6
+     */
+    UCharIteratorGetState *getState;
+
+    /**
+     * (public) Restore the iterator state from the state word from a call
+     * to getState().
+     * This function pointer is NULL if the iterator does not implement it.
+     *
+     * @see UCharIteratorSet
+     * @stable ICU 2.6
+     */
+    UCharIteratorSetState *setState;
+};
+
+/**
+ * Helper function for UCharIterator to get the code point
+ * at the current index.
+ *
+ * Return the code point that includes the code unit at the current position,
+ * or U_SENTINEL if there is none (index is at the limit).
+ * If the current code unit is a lead or trail surrogate,
+ * then the following or preceding surrogate is used to form
+ * the code point value.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the current code point
+ *
+ * @see UCharIterator
+ * @see U16_GET
+ * @see UnicodeString::char32At()
+ * @stable ICU 2.1
+ */
+U_STABLE UChar32 U_EXPORT2
+uiter_current32(UCharIterator *iter);
+
+/**
+ * Helper function for UCharIterator to get the next code point.
+ *
+ * Return the code point at the current index and increment
+ * the index (post-increment, like s[i++]),
+ * or return U_SENTINEL if there is none (index is at the limit).
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the current code point (and post-increment the current index)
+ *
+ * @see UCharIterator
+ * @see U16_NEXT
+ * @stable ICU 2.1
+ */
+U_STABLE UChar32 U_EXPORT2
+uiter_next32(UCharIterator *iter);
+
+/**
+ * Helper function for UCharIterator to get the previous code point.
+ *
+ * Decrement the index and return the code point from there
+ * (pre-decrement, like s[--i]),
+ * or return U_SENTINEL if there is none (index is at the start).
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the previous code point (after pre-decrementing the current index)
+ *
+ * @see UCharIterator
+ * @see U16_PREV
+ * @stable ICU 2.1
+ */
+U_STABLE UChar32 U_EXPORT2
+uiter_previous32(UCharIterator *iter);
+
+/**
+ * Get the "state" of the iterator in the form of a single 32-bit word.
+ * This is a convenience function that calls iter->getState(iter)
+ * if iter->getState is not NULL;
+ * if it is NULL or any other error occurs, then UITER_NO_STATE is returned.
+ *
+ * Some UCharIterator implementations may not be able to return
+ * a valid state for each position, in which case they return UITER_NO_STATE instead.
+ * This will be clearly documented for each such iterator (none of the public ones here).
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @return the state word
+ *
+ * @see UCharIterator
+ * @see UCharIteratorGetState
+ * @see UITER_NO_STATE
+ * @stable ICU 2.6
+ */
+U_STABLE uint32_t U_EXPORT2
+uiter_getState(const UCharIterator *iter);
+
+/**
+ * Restore the "state" of the iterator using a state word from a getState() call.
+ * This is a convenience function that calls iter->setState(iter, state, pErrorCode)
+ * if iter->setState is not NULL; if it is NULL, then U_UNSUPPORTED_ERROR is set.
+ *
+ * @param iter the UCharIterator structure ("this pointer")
+ * @param state the state word from a getState() call
+ *              on a same-type, same-string iterator
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                   which must not indicate a failure before the function call.
+ *
+ * @see UCharIterator
+ * @see UCharIteratorSetState
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
+
+/**
+ * Set up a UCharIterator to iterate over a string.
+ *
+ * Sets the UCharIterator function pointers for iteration over the string s
+ * with iteration boundaries start=index=0 and length=limit=string length.
+ * The "provider" may set the start, index, and limit values at any time
+ * within the range 0..length.
+ * The length field will be ignored.
+ *
+ * The string pointer s is set into UCharIterator.context without copying
+ * or reallocating the string contents.
+ *
+ * getState() simply returns the current index.
+ * move() will always return the final index.
+ *
+ * @param iter UCharIterator structure to be set for iteration
+ * @param s String to iterate over
+ * @param length Length of s, or -1 if NUL-terminated
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+U_STABLE void U_EXPORT2
+uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
+
+/**
+ * Set up a UCharIterator to iterate over a UTF-16BE string
+ * (byte vector with a big-endian pair of bytes per UChar).
+ *
+ * Everything works just like with a normal UChar iterator (uiter_setString),
+ * except that UChars are assembled from byte pairs,
+ * and that the length argument here indicates an even number of bytes.
+ *
+ * getState() simply returns the current index.
+ * move() will always return the final index.
+ *
+ * @param iter UCharIterator structure to be set for iteration
+ * @param s UTF-16BE string to iterate over
+ * @param length Length of s as an even number of bytes, or -1 if NUL-terminated
+ *               (NUL means pair of 0 bytes at even index from s)
+ *
+ * @see UCharIterator
+ * @see uiter_setString
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
+
+/**
+ * Set up a UCharIterator to iterate over a UTF-8 string.
+ *
+ * Sets the UCharIterator function pointers for iteration over the UTF-8 string s
+ * with UTF-8 iteration boundaries 0 and length.
+ * The implementation counts the UTF-16 index on the fly and
+ * lazily evaluates the UTF-16 length of the text.
+ *
+ * The start field is used as the UTF-8 offset, the limit field as the UTF-8 length.
+ * When the reservedField is not 0, then it contains a supplementary code point
+ * and the UTF-16 index is between the two corresponding surrogates.
+ * At that point, the UTF-8 index is behind that code point.
+ *
+ * The UTF-8 string pointer s is set into UCharIterator.context without copying
+ * or reallocating the string contents.
+ *
+ * getState() returns a state value consisting of
+ * - the current UTF-8 source byte index (bits 31..1)
+ * - a flag (bit 0) that indicates whether the UChar position is in the middle
+ *   of a surrogate pair
+ *   (from a 4-byte UTF-8 sequence for the corresponding supplementary code point)
+ *
+ * getState() cannot also encode the UTF-16 index in the state value.
+ * move(relative to limit or length), or
+ * move(relative to current) after setState(), may return UITER_UNKNOWN_INDEX.
+ *
+ * @param iter UCharIterator structure to be set for iteration
+ * @param s UTF-8 string to iterate over
+ * @param length Length of s in bytes, or -1 if NUL-terminated
+ *
+ * @see UCharIterator
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
+
+#ifdef XP_CPLUSPLUS
+
+/**
+ * Set up a UCharIterator to wrap around a C++ CharacterIterator.
+ *
+ * Sets the UCharIterator function pointers for iteration using the
+ * CharacterIterator charIter.
+ *
+ * The CharacterIterator pointer charIter is set into UCharIterator.context
+ * without copying or cloning the CharacterIterator object.
+ * The other "protected" UCharIterator fields are set to 0 and will be ignored.
+ * The iteration index and boundaries are controlled by the CharacterIterator.
+ *
+ * getState() simply returns the current index.
+ * move() will always return the final index.
+ *
+ * @param iter UCharIterator structure to be set for iteration
+ * @param charIter CharacterIterator to wrap
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+U_STABLE void U_EXPORT2
+uiter_setCharacterIterator(UCharIterator *iter, U_NAMESPACE_QUALIFIER CharacterIterator *charIter);
+
+/**
+ * Set up a UCharIterator to iterate over a C++ Replaceable.
+ *
+ * Sets the UCharIterator function pointers for iteration over the
+ * Replaceable rep with iteration boundaries start=index=0 and
+ * length=limit=rep->length().
+ * The "provider" may set the start, index, and limit values at any time
+ * within the range 0..length=rep->length().
+ * The length field will be ignored.
+ *
+ * The Replaceable pointer rep is set into UCharIterator.context without copying
+ * or cloning/reallocating the Replaceable object.
+ *
+ * getState() simply returns the current index.
+ * move() will always return the final index.
+ *
+ * @param iter UCharIterator structure to be set for iteration
+ * @param rep Replaceable to iterate over
+ *
+ * @see UCharIterator
+ * @stable ICU 2.1
+ */
+U_STABLE void U_EXPORT2
+uiter_setReplaceable(UCharIterator *iter, const U_NAMESPACE_QUALIFIER Replaceable *rep);
+
+#endif
+
+U_CDECL_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uloc.h b/CoreFoundation/icu/unicode/uloc.h
new file mode 100644
index 0000000..29c479a
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uloc.h
@@ -0,0 +1,1046 @@
+/*
+**********************************************************************
+*   Copyright (C) 1997-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File ULOC.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/01/97    aliu        Creation.
+*   08/22/98    stephen     JDK 1.2 sync.
+*   12/08/98    rtg         New C API for Locale
+*   03/30/99    damiba      overhaul
+*   03/31/99    helena      Javadoc for uloc functions.
+*   04/15/99    Madhu       Updated Javadoc
+********************************************************************************
+*/
+
+#ifndef ULOC_H
+#define ULOC_H
+
+#include "unicode/utypes.h"
+#include "unicode/uenum.h"
+
+/**    
+ * \file
+ * \brief  C API: Locale 
+ *
+ * <h2> ULoc C API for Locale </h2>
+ * A <code>Locale</code> represents a specific geographical, political,
+ * or cultural region. An operation that requires a <code>Locale</code> to perform
+ * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>
+ * to tailor information for the user. For example, displaying a number
+ * is a locale-sensitive operation--the number should be formatted
+ * according to the customs/conventions of the user's native country,
+ * region, or culture.  In the C APIs, a locales is simply a const char string.
+ *
+ * <P>
+ * You create a <code>Locale</code> with one of the three options listed below.
+ * Each of the component is separated by '_' in the locale string.
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code
+ *       newLanguage
+ * 
+ *       newLanguage + newCountry
+ * 
+ *       newLanguage + newCountry + newVariant
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * The first option is a valid <STRONG>ISO
+ * Language Code.</STRONG> These codes are the lower-case two-letter
+ * codes as defined by ISO-639.
+ * You can find a full list of these codes at a number of sites, such as:
+ * <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">
+ * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</a>
+ *
+ * <P>
+ * The second option includes an additonal <STRONG>ISO Country
+ * Code.</STRONG> These codes are the upper-case two-letter codes
+ * as defined by ISO-3166.
+ * You can find a full list of these codes at a number of sites, such as:
+ * <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html">
+ * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</a>
+ *
+ * <P>
+ * The third option requires another additonal information--the 
+ * <STRONG>Variant.</STRONG>
+ * The Variant codes are vendor and browser-specific.
+ * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX.
+ * Where there are two variants, separate them with an underscore, and
+ * put the most important one first. For
+ * example, a Traditional Spanish collation might be referenced, with
+ * "ES", "ES", "Traditional_WIN".
+ *
+ * <P>
+ * Because a <code>Locale</code> is just an identifier for a region,
+ * no validity check is performed when you specify a <code>Locale</code>.
+ * If you want to see whether particular resources are available for the
+ * <code>Locale</code> you asked for, you must query those resources. For
+ * example, ask the <code>UNumberFormat</code> for the locales it supports
+ * using its <code>getAvailable</code> method.
+ * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular
+ * locale, you get back the best available match, not necessarily
+ * precisely what you asked for. For more information, look at
+ * <code>UResourceBundle</code>.
+ *
+ * <P>
+ * The <code>Locale</code> provides a number of convenient constants
+ * that you can use to specify the commonly used
+ * locales. For example, the following refers to a locale
+ * for the United States:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code
+ *       ULOC_US
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * <P>
+ * Once you've specified a locale you can query it for information about
+ * itself. Use <code>uloc_getCountry</code> to get the ISO Country Code and
+ * <code>uloc_getLanguage</code> to get the ISO Language Code. You can
+ * use <code>uloc_getDisplayCountry</code> to get the
+ * name of the country suitable for displaying to the user. Similarly,
+ * you can use <code>uloc_getDisplayLanguage</code> to get the name of
+ * the language suitable for displaying to the user. Interestingly,
+ * the <code>uloc_getDisplayXXX</code> methods are themselves locale-sensitive
+ * and have two versions: one that uses the default locale and one
+ * that takes a locale as an argument and displays the name or country in
+ * a language appropriate to that locale.
+ *
+ * <P>
+ * The ICU provides a number of services that perform locale-sensitive
+ * operations. For example, the <code>unum_xxx</code> functions format
+ * numbers, currency, or percentages in a locale-sensitive manner. 
+ * </P>
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code
+ *     UErrorCode success = U_ZERO_ERROR;
+ *     UNumberFormat *nf;
+ *     const char* myLocale = "fr_FR";
+ * 
+ *     nf = unum_open( UNUM_DEFAULT, NULL, success );          
+ *     unum_close(nf);
+ *     nf = unum_open( UNUM_CURRENCY, NULL, success );
+ *     unum_close(nf);
+ *     nf = unum_open( UNUM_PERCENT, NULL, success );   
+ *     unum_close(nf);
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * Each of these methods has two variants; one with an explicit locale
+ * and one without; the latter using the default locale.
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code 
+ * 
+ *     nf = unum_open( UNUM_DEFAULT, myLocale, success );          
+ *     unum_close(nf);
+ *     nf = unum_open( UNUM_CURRENCY, myLocale, success );
+ *     unum_close(nf);
+ *     nf = unum_open( UNUM_PERCENT, myLocale, success );   
+ *     unum_close(nf);
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * A <code>Locale</code> is the mechanism for identifying the kind of services
+ * (<code>UNumberFormat</code>) that you would like to get. The locale is
+ * <STRONG>just</STRONG> a mechanism for identifying these services.
+ *
+ * <P>
+ * Each international serivce that performs locale-sensitive operations 
+ * allows you
+ * to get all the available objects of that type. You can sift
+ * through these objects by language, country, or variant,
+ * and use the display names to present a menu to the user.
+ * For example, you can create a menu of all the collation objects
+ * suitable for a given language. Such classes implement these
+ * three class methods:
+ * \htmlonly<blockquote>\endhtmlonly
+ * <pre>
+ * \code
+ *       const char* uloc_getAvailable(int32_t index);
+ *       int32_t uloc_countAvailable();
+ *       int32_t
+ *       uloc_getDisplayName(const char* localeID,
+ *                 const char* inLocaleID, 
+ *                 UChar* result,
+ *                 int32_t maxResultSize,
+ *                  UErrorCode* err);
+ * 
+ * \endcode
+ * </pre>
+ * \htmlonly</blockquote>\endhtmlonly
+ * <P>
+ * Concerning POSIX/RFC1766 Locale IDs, 
+ *  the getLanguage/getCountry/getVariant/getName functions do understand
+ * the POSIX type form of  language_COUNTRY.ENCODING\@VARIANT
+ * and if there is not an ICU-stype variant, uloc_getVariant() for example
+ * will return the one listed after the \@at sign. As well, the hyphen
+ * "-" is recognized as a country/variant separator similarly to RFC1766.
+ * So for example, "en-us" will be interpreted as en_US.  
+ * As a result, uloc_getName() is far from a no-op, and will have the
+ * effect of converting POSIX/RFC1766 IDs into ICU form, although it does
+ * NOT map any of the actual codes (i.e. russian->ru) in any way.
+ * Applications should call uloc_getName() at the point where a locale ID
+ * is coming from an external source (user entry, OS, web browser)
+ * and pass the resulting string to other ICU functions.  For example,
+ * don't use de-de\@EURO as an argument to resourcebundle.
+ *
+ * @see UResourceBundle
+ */
+
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_CHINESE            "zh"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_ENGLISH            "en"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_FRENCH             "fr"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_GERMAN             "de"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_ITALIAN            "it"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_JAPANESE           "ja"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_KOREAN             "ko"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_SIMPLIFIED_CHINESE "zh_CN"
+/** Useful constant for this language. @stable ICU 2.0 */
+#define ULOC_TRADITIONAL_CHINESE "zh_TW"
+
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_CANADA         "en_CA"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_CANADA_FRENCH  "fr_CA"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_CHINA          "zh_CN"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_PRC            "zh_CN"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_FRANCE         "fr_FR"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_GERMANY        "de_DE"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_ITALY          "it_IT"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_JAPAN          "ja_JP"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_KOREA          "ko_KR"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_TAIWAN         "zh_TW"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_UK             "en_GB"
+/** Useful constant for this country/region. @stable ICU 2.0 */
+#define ULOC_US             "en_US"
+
+/**
+ * Useful constant for the maximum size of the language part of a locale ID.
+ * (including the terminating NULL).
+ * @stable ICU 2.0
+ */
+#define ULOC_LANG_CAPACITY 12
+
+/**
+ * Useful constant for the maximum size of the country part of a locale ID
+ * (including the terminating NULL).
+ * @stable ICU 2.0
+ */
+#define ULOC_COUNTRY_CAPACITY 4
+/**
+ * Useful constant for the maximum size of the whole locale ID
+ * (including the terminating NULL).
+ * @stable ICU 2.0
+ */
+#define ULOC_FULLNAME_CAPACITY 56
+
+/**
+ * Useful constant for the maximum size of the script part of a locale ID
+ * (including the terminating NULL).
+ * @stable ICU 2.8
+ */
+#define ULOC_SCRIPT_CAPACITY 6
+
+/**
+ * Useful constant for the maximum size of keywords in a locale
+ * @stable ICU 2.8
+ */
+#define ULOC_KEYWORDS_CAPACITY 50
+
+/**
+ * Useful constant for the maximum SIZE of keywords in a locale
+ * @stable ICU 2.8
+ */
+#define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
+
+/**
+ * Character separating keywords from the locale string
+ * different for EBCDIC - TODO
+ * @stable ICU 2.8
+ */
+#define ULOC_KEYWORD_SEPARATOR '@'
+/**
+ * Character for assigning value to a keyword
+ * @stable ICU 2.8
+ */
+#define ULOC_KEYWORD_ASSIGN '='
+/**
+ * Character separating keywords
+ * @stable ICU 2.8
+ */
+#define ULOC_KEYWORD_ITEM_SEPARATOR ';'
+
+/**
+ * Constants for *_getLocale()
+ * Allow user to select whether she wants information on 
+ * requested, valid or actual locale.
+ * For example, a collator for "en_US_CALIFORNIA" was
+ * requested. In the current state of ICU (2.0), 
+ * the requested locale is "en_US_CALIFORNIA",
+ * the valid locale is "en_US" (most specific locale supported by ICU)
+ * and the actual locale is "root" (the collation data comes unmodified 
+ * from the UCA)
+ * The locale is considered supported by ICU if there is a core ICU bundle 
+ * for that locale (although it may be empty).
+ * @stable ICU 2.1
+ */
+typedef enum {
+  /** This is locale the data actually comes from 
+   * @stable ICU 2.1
+   */
+  ULOC_ACTUAL_LOCALE    = 0,
+  /** This is the most specific locale supported by ICU 
+   * @stable ICU 2.1
+   */
+  ULOC_VALID_LOCALE    = 1,
+
+#ifndef U_HIDE_DEPRECATED_API
+  /** This is the requested locale
+   *  @deprecated ICU 2.8 
+   */
+  ULOC_REQUESTED_LOCALE = 2,
+#endif /* U_HIDE_DEPRECATED_API */
+
+  ULOC_DATA_LOCALE_TYPE_LIMIT = 3
+} ULocDataLocaleType ;
+
+
+/**
+ * Gets ICU's default locale.  
+ * The returned string is a snapshot in time, and will remain valid
+ *   and unchanged even when uloc_setDefault() is called.
+ *   The returned storage is owned by ICU, and must not be altered or deleted
+ *   by the caller.
+ *  
+ * @return the ICU default locale
+ * @system
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2
+uloc_getDefault(void);
+
+/**
+ * Sets ICU's default locale.  
+ *    By default (without calling this function), ICU's default locale will be based
+ *    on information obtained from the underlying system environment.
+ *    <p>
+ *    Changes to ICU's default locale do not propagate back to the
+ *    system environment.
+ *    <p>
+ *    Changes to ICU's default locale to not affect any ICU services that
+ *    may already be open based on the previous default locale value.
+ *
+ * @param localeID the new ICU default locale. A value of NULL will try to get
+ *                 the system's default locale.
+ * @param status the error information if the setting of default locale fails
+ * @system
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+uloc_setDefault(const char* localeID,
+        UErrorCode*       status);
+
+/**
+ * Gets the language code for the specified locale.
+ *
+ * @param localeID the locale to get the ISO language code with
+ * @param language the language code for localeID
+ * @param languageCapacity the size of the language buffer to store the  
+ * language code with
+ * @param err error information if retrieving the language code failed
+ * @return the actual buffer size needed for the language code.  If it's greater 
+ * than languageCapacity, the returned language code will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getLanguage(const char*    localeID,
+         char* language,
+         int32_t languageCapacity,
+         UErrorCode* err);
+
+/**
+ * Gets the script code for the specified locale.
+ *
+ * @param localeID the locale to get the ISO language code with
+ * @param script the language code for localeID
+ * @param scriptCapacity the size of the language buffer to store the  
+ * language code with
+ * @param err error information if retrieving the language code failed
+ * @return the actual buffer size needed for the language code.  If it's greater 
+ * than scriptCapacity, the returned language code will be truncated.  
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getScript(const char*    localeID,
+         char* script,
+         int32_t scriptCapacity,
+         UErrorCode* err);
+
+/**
+ * Gets the  country code for the specified locale.
+ *
+ * @param localeID the locale to get the country code with
+ * @param country the country code for localeID
+ * @param countryCapacity the size of the country buffer to store the  
+ * country code with
+ * @param err error information if retrieving the country code failed
+ * @return the actual buffer size needed for the country code.  If it's greater 
+ * than countryCapacity, the returned country code will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getCountry(const char*    localeID,
+        char* country,
+        int32_t countryCapacity,
+        UErrorCode* err);
+
+/**
+ * Gets the variant code for the specified locale.
+ *
+ * @param localeID the locale to get the variant code with
+ * @param variant the variant code for localeID
+ * @param variantCapacity the size of the variant buffer to store the 
+ * variant code with
+ * @param err error information if retrieving the variant code failed
+ * @return the actual buffer size needed for the variant code.  If it's greater 
+ * than variantCapacity, the returned variant code will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getVariant(const char*    localeID,
+        char* variant,
+        int32_t variantCapacity,
+        UErrorCode* err);
+
+
+/**
+ * Gets the full name for the specified locale.
+ * Note: This has the effect of 'canonicalizing' the ICU locale ID to
+ * a certain extent. Upper and lower case are set as needed.
+ * It does NOT map aliased names in any way.
+ * See the top of this header file.
+ * This API supports preflighting.
+ *
+ * @param localeID the locale to get the full name with
+ * @param name fill in buffer for the name without keywords.
+ * @param nameCapacity capacity of the fill in buffer.
+ * @param err error information if retrieving the full name failed
+ * @return the actual buffer size needed for the full name.  If it's greater 
+ * than nameCapacity, the returned full name will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getName(const char*    localeID,
+         char* name,
+         int32_t nameCapacity,
+         UErrorCode* err);
+
+/**
+ * Gets the full name for the specified locale.
+ * Note: This has the effect of 'canonicalizing' the string to
+ * a certain extent. Upper and lower case are set as needed,
+ * and if the components were in 'POSIX' format they are changed to
+ * ICU format.  It does NOT map aliased names in any way.
+ * See the top of this header file.
+ *
+ * @param localeID the locale to get the full name with
+ * @param name the full name for localeID
+ * @param nameCapacity the size of the name buffer to store the 
+ * full name with
+ * @param err error information if retrieving the full name failed
+ * @return the actual buffer size needed for the full name.  If it's greater 
+ * than nameCapacity, the returned full name will be truncated.  
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_canonicalize(const char*    localeID,
+         char* name,
+         int32_t nameCapacity,
+         UErrorCode* err);
+
+/**
+ * Gets the ISO language code for the specified locale.
+ *
+ * @param localeID the locale to get the ISO language code with
+ * @return language the ISO language code for localeID
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2
+uloc_getISO3Language(const char* localeID);
+
+
+/**
+ * Gets the ISO country code for the specified locale.
+ *
+ * @param localeID the locale to get the ISO country code with
+ * @return country the ISO country code for localeID
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2
+uloc_getISO3Country(const char* localeID);
+
+/**
+ * Gets the Win32 LCID value for the specified locale.
+ * If the ICU locale is not recognized by Windows, 0 will be returned.
+ *
+ * @param localeID the locale to get the Win32 LCID value with
+ * @return country the Win32 LCID for localeID
+ * @stable ICU 2.0
+ */
+U_STABLE uint32_t U_EXPORT2
+uloc_getLCID(const char* localeID);
+
+/**
+ * Gets the language name suitable for display for the specified locale.
+ *
+ * @param locale the locale to get the ISO language code with
+ * @param displayLocale Specifies the locale to be used to display the name.  In other words,
+ *                 if the locale's language code is "en", passing Locale::getFrench() for
+ *                 inLocale would result in "Anglais", while passing Locale::getGerman()
+ *                 for inLocale would result in "Englisch".
+ * @param language the displayable language code for localeID
+ * @param languageCapacity the size of the language buffer to store the  
+ * displayable language code with
+ * @param status error information if retrieving the displayable language code failed
+ * @return the actual buffer size needed for the displayable language code.  If it's greater 
+ * than languageCapacity, the returned language code will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getDisplayLanguage(const char* locale,
+            const char* displayLocale,
+            UChar* language,
+            int32_t languageCapacity,
+            UErrorCode* status);
+
+/**
+ * Gets the script name suitable for display for the specified locale.
+ *
+ * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name.  In other words,
+ *                 if the locale's language code is "en", passing Locale::getFrench() for
+ *                 inLocale would result in "", while passing Locale::getGerman()
+ *                 for inLocale would result in "". NULL may be used to specify the default.
+ * @param script the displayable country code for localeID
+ * @param scriptCapacity the size of the script buffer to store the  
+ * displayable script code with
+ * @param status error information if retrieving the displayable script code failed
+ * @return the actual buffer size needed for the displayable script code.  If it's greater 
+ * than scriptCapacity, the returned displayable script code will be truncated.  
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getDisplayScript(const char* locale,
+            const char* displayLocale,
+            UChar* script,
+            int32_t scriptCapacity,
+            UErrorCode* status);
+
+/**
+ * Gets the country name suitable for display for the specified locale.
+ *
+ * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name.  In other words,
+ *                 if the locale's language code is "en", passing Locale::getFrench() for
+ *                 inLocale would result in "Anglais", while passing Locale::getGerman()
+ *                 for inLocale would result in "Englisch". NULL may be used to specify the default.
+ * @param country the displayable country code for localeID
+ * @param countryCapacity the size of the country buffer to store the  
+ * displayable country code with
+ * @param status error information if retrieving the displayable country code failed
+ * @return the actual buffer size needed for the displayable country code.  If it's greater 
+ * than countryCapacity, the returned displayable country code will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getDisplayCountry(const char* locale,
+                       const char* displayLocale,
+                       UChar* country,
+                       int32_t countryCapacity,
+                       UErrorCode* status);
+
+
+/**
+ * Gets the variant name suitable for display for the specified locale.
+ *
+ * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.
+ * @param displayLocale Specifies the locale to be used to display the name.  In other words,
+ *                 if the locale's language code is "en", passing Locale::getFrench() for
+ *                 inLocale would result in "Anglais", while passing Locale::getGerman()
+ *                 for inLocale would result in "Englisch". NULL may be used to specify the default.
+ * @param variant the displayable variant code for localeID
+ * @param variantCapacity the size of the variant buffer to store the 
+ * displayable variant code with
+ * @param status error information if retrieving the displayable variant code failed
+ * @return the actual buffer size needed for the displayable variant code.  If it's greater 
+ * than variantCapacity, the returned displayable variant code will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getDisplayVariant(const char* locale,
+                       const char* displayLocale,
+                       UChar* variant,
+                       int32_t variantCapacity,
+                       UErrorCode* status);
+
+/**
+ * Gets the keyword name suitable for display for the specified locale.
+ * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display 
+ * string for the keyword collation. 
+ * Usage:
+ * <code>
+ *    UErrorCode status = U_ZERO_ERROR;
+ *    const char* keyword =NULL;
+ *    int32_t keywordLen = 0;
+ *    int32_t keywordCount = 0;
+ *    UChar displayKeyword[256];
+ *    int32_t displayKeywordLen = 0;
+ *    UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status);
+ *    for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){
+ *          if(U_FAILURE(status)){
+ *              ...something went wrong so handle the error...
+ *              break;
+ *          }
+ *          // the uenum_next returns NUL terminated string
+ *          keyword = uenum_next(keywordEnum, &keywordLen, &status);
+ *          displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256);
+ *          ... do something interesting .....
+ *    }
+ *    uenum_close(keywordEnum);
+ * </code>
+ * @param keyword           The keyword whose display string needs to be returned.
+ * @param displayLocale     Specifies the locale to be used to display the name.  In other words,
+ *                          if the locale's language code is "en", passing Locale::getFrench() for
+ *                          inLocale would result in "Anglais", while passing Locale::getGerman()
+ *                          for inLocale would result in "Englisch". NULL may be used to specify the default.
+ * @param dest              the buffer to which the displayable keyword should be written.
+ * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then
+ *                          dest may be NULL and the function will only return the length of the 
+ *                          result without writing any of the result string (pre-flighting).
+ * @param status            error information if retrieving the displayable string failed. 
+ *                          Should not be NULL and should not indicate failure on entry.
+ * @return the actual buffer size needed for the displayable variant code.  
+ * @see #uloc_openKeywords
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getDisplayKeyword(const char* keyword,
+                       const char* displayLocale,
+                       UChar* dest,
+                       int32_t destCapacity,
+                       UErrorCode* status);
+/**
+ * Gets the value of the keyword suitable for display for the specified locale.
+ * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display 
+ * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword.
+ *
+ * @param locale            The locale to get the displayable variant code with. NULL may be used to specify the default.
+ * @param keyword           The keyword for whose value should be used.
+ * @param displayLocale     Specifies the locale to be used to display the name.  In other words,
+ *                          if the locale's language code is "en", passing Locale::getFrench() for
+ *                          inLocale would result in "Anglais", while passing Locale::getGerman()
+ *                          for inLocale would result in "Englisch". NULL may be used to specify the default.
+ * @param dest              the buffer to which the displayable keyword should be written.
+ * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then
+ *                          dest may be NULL and the function will only return the length of the 
+ *                          result without writing any of the result string (pre-flighting).
+ * @param status            error information if retrieving the displayable string failed. 
+ *                          Should not be NULL and must not indicate failure on entry.
+ * @return the actual buffer size needed for the displayable variant code.  
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getDisplayKeywordValue(   const char* locale,
+                               const char* keyword,
+                               const char* displayLocale,
+                               UChar* dest,
+                               int32_t destCapacity,
+                               UErrorCode* status);
+/**
+ * Gets the full name suitable for display for the specified locale.
+ *
+ * @param localeID the locale to get the displayable name with. NULL may be used to specify the default.
+ * @param inLocaleID Specifies the locale to be used to display the name.  In other words,
+ *                   if the locale's language code is "en", passing Locale::getFrench() for
+ *                   inLocale would result in "Anglais", while passing Locale::getGerman()
+ *                   for inLocale would result in "Englisch". NULL may be used to specify the default.
+ * @param result the displayable name for localeID
+ * @param maxResultSize the size of the name buffer to store the 
+ * displayable full name with
+ * @param err error information if retrieving the displayable name failed
+ * @return the actual buffer size needed for the displayable name.  If it's greater 
+ * than maxResultSize, the returned displayable name will be truncated.  
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getDisplayName(const char* localeID,
+            const char* inLocaleID,
+            UChar* result,
+            int32_t maxResultSize,
+            UErrorCode* err);
+
+
+/**
+ * Gets the specified locale from a list of all available locales.  
+ * The return value is a pointer to an item of 
+ * a locale name array.  Both this array and the pointers
+ * it contains are owned by ICU and should not be deleted or written through
+ * by the caller.  The locale name is terminated by a null pointer.
+ * @param n the specific locale name index of the available locale list
+ * @return a specified locale name of all available locales
+ * @stable ICU 2.0
+ */
+U_STABLE const char* U_EXPORT2
+uloc_getAvailable(int32_t n);
+
+/**
+ * Gets the size of the all available locale list.
+ *
+ * @return the size of the locale list
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
+
+/**
+ *
+ * Gets a list of all available language codes defined in ISO 639.  This is a pointer
+ * to an array of pointers to arrays of char.  All of these pointers are owned
+ * by ICU-- do not delete them, and do not write through them.  The array is
+ * terminated with a null pointer.
+ * @return a list of all available language codes
+ * @stable ICU 2.0
+ */
+U_STABLE const char* const* U_EXPORT2
+uloc_getISOLanguages(void);
+
+/**
+ *
+ * Gets a list of all available 2-letter country codes defined in ISO 639.  This is a
+ * pointer to an array of pointers to arrays of char.  All of these pointers are
+ * owned by ICU-- do not delete them, and do not write through them.  The array is
+ * terminated with a null pointer.
+ * @return a list of all available country codes
+ * @stable ICU 2.0
+ */
+U_STABLE const char* const* U_EXPORT2
+uloc_getISOCountries(void);
+
+/**
+ * Truncate the locale ID string to get the parent locale ID.
+ * Copies the part of the string before the last underscore.
+ * The parent locale ID will be an empty string if there is no
+ * underscore, or if there is only one underscore at localeID[0].
+ *
+ * @param localeID Input locale ID string.
+ * @param parent   Output string buffer for the parent locale ID.
+ * @param parentCapacity Size of the output buffer.
+ * @param err A UErrorCode value.
+ * @return The length of the parent locale ID.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getParent(const char*    localeID,
+                 char* parent,
+                 int32_t parentCapacity,
+                 UErrorCode* err);
+
+
+
+
+/**
+ * Gets the full name for the specified locale.
+ * Note: This has the effect of 'canonicalizing' the string to
+ * a certain extent. Upper and lower case are set as needed,
+ * and if the components were in 'POSIX' format they are changed to
+ * ICU format.  It does NOT map aliased names in any way.
+ * See the top of this header file.
+ * This API strips off the keyword part, so "de_DE\@collation=phonebook" 
+ * will become "de_DE". 
+ * This API supports preflighting.
+ *
+ * @param localeID the locale to get the full name with
+ * @param name fill in buffer for the name without keywords.
+ * @param nameCapacity capacity of the fill in buffer.
+ * @param err error information if retrieving the full name failed
+ * @return the actual buffer size needed for the full name.  If it's greater 
+ * than nameCapacity, the returned full name will be truncated.  
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getBaseName(const char*    localeID,
+         char* name,
+         int32_t nameCapacity,
+         UErrorCode* err);
+
+/**
+ * Gets an enumeration of keywords for the specified locale. Enumeration
+ * must get disposed of by the client using uenum_close function.
+ *
+ * @param localeID the locale to get the variant code with
+ * @param status error information if retrieving the keywords failed
+ * @return enumeration of keywords or NULL if there are no keywords.
+ * @stable ICU 2.8
+ */
+U_STABLE UEnumeration* U_EXPORT2
+uloc_openKeywords(const char* localeID,
+                        UErrorCode* status);
+
+/**
+ * Get the value for a keyword. Locale name does not need to be normalized.
+ * 
+ * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK")
+ * @param keywordName name of the keyword for which we want the value. Case insensitive.
+ * @param buffer receiving buffer
+ * @param bufferCapacity capacity of receiving buffer
+ * @param status containing error code - buffer not big enough.
+ * @return the length of keyword value
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_getKeywordValue(const char* localeID,
+                     const char* keywordName,
+                     char* buffer, int32_t bufferCapacity,
+                     UErrorCode* status);
+
+
+/**
+ * Set the value of the specified keyword.
+ * NOTE: Unlike almost every other ICU function which takes a
+ * buffer, this function will NOT truncate the output text. If a
+ * BUFFER_OVERFLOW_ERROR is received, it means that the original
+ * buffer is untouched. This is done to prevent incorrect or possibly
+ * even malformed locales from being generated and used.
+ * 
+ * @param keywordName name of the keyword to be set. Case insensitive.
+ * @param keywordValue value of the keyword to be set. If 0-length or
+ *  NULL, will result in the keyword being removed. No error is given if 
+ *  that keyword does not exist.
+ * @param buffer input buffer containing locale to be modified.
+ * @param bufferCapacity capacity of receiving buffer
+ * @param status containing error code - buffer not big enough.
+ * @return the length needed for the buffer
+ * @see uloc_getKeywordValue
+ * @stable ICU 3.2
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_setKeywordValue(const char* keywordName,
+                     const char* keywordValue,
+                     char* buffer, int32_t bufferCapacity,
+                     UErrorCode* status);
+
+/**
+ * enums for the  return value for the character and line orientation
+ * functions.
+ * @draft ICU 4.0
+ */
+typedef enum {
+  ULOC_LAYOUT_LTR   = 0,  /* left-to-right. */
+  ULOC_LAYOUT_RTL    = 1,  /* right-to-left. */
+  ULOC_LAYOUT_TTB    = 2,  /* top-to-bottom. */
+  ULOC_LAYOUT_BTT    = 3,   /* bottom-to-top. */
+  ULOC_LAYOUT_UNKNOWN
+} ULayoutType;
+
+/**
+ * Get the layout character orientation for the specified locale.
+ * 
+ * @param localeId locale name
+ * @param status Error status
+ * @return an enum indicating the layout orientation for characters.
+ * @draft ICU 4.0
+ */
+U_DRAFT ULayoutType U_EXPORT2
+uloc_getCharacterOrientation(const char* localeId,
+                             UErrorCode *status);
+
+/**
+ * Get the layout line orientation for the specified locale.
+ * 
+ * @param localeId locale name
+ * @param status Error status
+ * @return an enum indicating the layout orientation for lines.
+ * @draft ICU 4.0
+ */
+U_DRAFT ULayoutType U_EXPORT2
+uloc_getLineOrientation(const char* localeId,
+                        UErrorCode *status);
+
+/**
+ * enums for the 'outResult' parameter return value
+ * @see uloc_acceptLanguageFromHTTP
+ * @see uloc_acceptLanguage
+ * @stable ICU 3.2
+ */
+typedef enum {
+  ULOC_ACCEPT_FAILED   = 0,  /* No exact match was found. */
+  ULOC_ACCEPT_VALID    = 1,  /* An exact match was found. */
+  ULOC_ACCEPT_FALLBACK = 2   /* A fallback was found, for example, 
+                                Accept list contained 'ja_JP'
+                                which matched available locale 'ja'. */
+} UAcceptResult;
+
+
+/**
+ * Based on a HTTP header from a web browser and a list of available locales,
+ * determine an acceptable locale for the user.
+ * @param result - buffer to accept the result locale
+ * @param resultAvailable the size of the result buffer.
+ * @param outResult - An out parameter that contains the fallback status
+ * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP.
+ * @param availableLocales - list of available locales to match
+ * @param status Error status, may be BUFFER_OVERFLOW_ERROR
+ * @return length needed for the locale.
+ * @stable ICU 3.2
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
+                            UAcceptResult *outResult,
+                            const char *httpAcceptLanguage,
+                            UEnumeration* availableLocales,
+                            UErrorCode *status);
+
+/**
+ * Based on a list of available locales,
+ * determine an acceptable locale for the user.
+ * @param result - buffer to accept the result locale
+ * @param resultAvailable the size of the result buffer.
+ * @param outResult - An out parameter that contains the fallback status
+ * @param acceptList - list of acceptable languages
+ * @param acceptListCount - count of acceptList items
+ * @param availableLocales - list of available locales to match
+ * @param status Error status, may be BUFFER_OVERFLOW_ERROR
+ * @return length needed for the locale.
+ * @stable ICU 3.2
+ */
+U_STABLE int32_t U_EXPORT2
+uloc_acceptLanguage(char *result, int32_t resultAvailable, 
+                    UAcceptResult *outResult, const char **acceptList,
+                    int32_t acceptListCount,
+                    UEnumeration* availableLocales,
+                    UErrorCode *status);
+
+
+/**
+ * Gets the ICU locale ID for the specified Win32 LCID value.
+ *
+ * @param hostID the Win32 LCID to translate
+ * @param locale the output buffer for the ICU locale ID, which will be NUL-terminated
+ *  if there is room.
+ * @param localeCapacity the size of the output buffer
+ * @param status an error is returned if the LCID is unrecognized or the output buffer
+ *  is too small
+ * @return actual the actual size of the locale ID, not including NUL-termination 
+ * @stable ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
+                    UErrorCode *status);
+
+
+/**
+ * Add the likely subtags for a provided locale ID, per the algorithm described
+ * in the following CLDR technical report:
+ *
+ *   http://www.unicode.org/reports/tr35/#Likely_Subtags
+ *
+ * If localeID is already in the maximal form, or there is no data available
+ * for maximization, it will be copied to the output buffer.  For example,
+ * "und-Zzzz" cannot be maximized, since there is no reasonable maximization.
+ *
+ * Examples:
+ *
+ * "en" maximizes to "en_Latn_US"
+ *
+ * "de" maximizes to "de_Latn_US"
+ *
+ * "sr" maximizes to "sr_Cyrl_RS"
+ *
+ * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.)
+ *
+ * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)
+ *
+ * @param localeID The locale to maximize
+ * @param maximizedLocaleID The maximized locale
+ * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer
+ * @param err Error information if maximizing the locale failed.  If the length
+ * of the localeID and the null-terminator is greater than the maximum allowed size,
+ * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
+ * @return The actual buffer size needed for the maximized locale.  If it's
+ * greater than maximizedLocaleIDCapacity, the returned ID will be truncated.
+ * On error, the return value is -1.
+ * @draft ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+uloc_addLikelySubtags(const char*    localeID,
+         char* maximizedLocaleID,
+         int32_t maximizedLocaleIDCapacity,
+         UErrorCode* err);
+
+
+/**
+ * Minimize the subtags for a provided locale ID, per the algorithm described
+ * in the following CLDR technical report:
+ *
+ *   http://www.unicode.org/reports/tr35/#Likely_Subtags
+ *
+ * If localeID is already in the minimal form, or there is no data available
+ * for minimization, it will be copied to the output buffer.  Since the
+ * minimization algorithm relies on proper maximization, see the comments
+ * for uloc_addLikelySubtags for reasons why there might not be any data.
+ *
+ * Examples:
+ *
+ * "en_Latn_US" minimizes to "en"
+ *
+ * "de_Latn_US" minimizes to "de"
+ *
+ * "sr_Cyrl_RS" minimizes to "sr"
+ *
+ * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the
+ * script, and minimizing to "zh" would imply "zh_Hans_CN".)
+ *
+ * @param localeID The locale to minimize
+ * @param minimizedLocaleID The minimized locale
+ * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer
+ * @param err Error information if minimizing the locale failed.  If the length
+ * of the localeID and the null-terminator is greater than the maximum allowed size,
+ * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
+ * @return The actual buffer size needed for the minimized locale.  If it's
+ * greater than minimizedLocaleIDCapacity, the returned ID will be truncated.
+ * On error, the return value is -1.
+ * @draft ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+uloc_minimizeSubtags(const char*    localeID,
+         char* minimizedLocaleID,
+         int32_t minimizedLocaleIDCapacity,
+         UErrorCode* err);
+
+#endif /*_ULOC*/
diff --git a/CoreFoundation/icu/unicode/ulocdata.h b/CoreFoundation/icu/unicode/ulocdata.h
new file mode 100644
index 0000000..6bcc472
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ulocdata.h
@@ -0,0 +1,194 @@
+/*
+******************************************************************************
+*                                                                            *
+* Copyright (C) 2003-2007, International Business Machines                   *
+*                Corporation and others. All Rights Reserved.                *
+*                                                                            *
+******************************************************************************
+*   file name:  ulocdata.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2003Oct21
+*   created by: Ram Viswanadha
+*/
+
+#ifndef __ULOCDATA_H__
+#define __ULOCDATA_H__
+
+#include "unicode/ures.h"
+#include "unicode/uloc.h"
+#include "unicode/uset.h"
+
+/**
+ * \file
+ * \brief C API: Provides access to locale data. 
+ */
+
+/** Forward declaration of the ULocaleData structure. @stable ICU 3.6 */
+struct ULocaleData;
+
+/** A locale data object. @stable ICU 3.6 */
+typedef struct ULocaleData ULocaleData;
+
+
+
+/** The possible types of exemplar character sets.
+  * @stable ICU 3.4
+  */
+typedef enum ULocaleDataExemplarSetType  {
+     ULOCDATA_ES_STANDARD=0,      /* Basic set */
+     ULOCDATA_ES_AUXILIARY=1,     /* Auxiliary set */
+     ULOCDATA_ES_COUNT=2
+} ULocaleDataExemplarSetType;
+
+/** The possible types of delimiters.
+  * @stable ICU 3.4
+  */
+typedef enum ULocaleDataDelimiterType {
+#ifndef U_HIDE_DRAFT_API 
+    ULOCDATA_QUOTATION_START = 0,     /* Quotation start */
+     ULOCDATA_QUOTATION_END = 1,       /* Quotation end */
+     ULOCDATA_ALT_QUOTATION_START = 2, /* Alternate quotation start */
+     ULOCDATA_ALT_QUOTATION_END = 3,   /* Alternate quotation end */
+#endif
+     ULOCDATA_DELIMITER_COUNT = 4
+} ULocaleDataDelimiterType;
+
+/**
+ * Opens a locale data object for the given locale
+ *
+ * @param localeID  Specifies the locale associated with this locale
+ *                  data object.
+ * @param status    Pointer to error status code.
+ * @stable ICU 3.4
+ */
+U_STABLE ULocaleData* U_EXPORT2 
+ulocdata_open(const char *localeID, UErrorCode *status);
+
+/**
+ * Closes a locale data object.
+ *
+ * @param uld       The locale data object to close
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2 
+ulocdata_close(ULocaleData *uld);
+
+/**
+ * Sets the "no Substitute" attribute of the locale data
+ * object.  If true, then any methods associated with the
+ * locale data object will return null when there is no
+ * data available for that method, given the locale ID
+ * supplied to ulocdata_open().
+ *
+ * @param uld       The locale data object to set.
+ * @param setting   Value of the "no substitute" attribute.
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2 
+ulocdata_setNoSubstitute(ULocaleData *uld, UBool setting);
+
+/**
+ * Retrieves the current "no Substitute" value of the locale data
+ * object.  If true, then any methods associated with the
+ * locale data object will return null when there is no
+ * data available for that method, given the locale ID
+ * supplied to ulocdata_open().
+ *
+ * @param uld       Pointer to the The locale data object to set.
+ * @return UBool    Value of the "no substitute" attribute.
+ * @stable ICU 3.4
+ */
+U_STABLE UBool U_EXPORT2 
+ulocdata_getNoSubstitute(ULocaleData *uld);
+
+/**
+ * Returns the set of exemplar characters for a locale.
+ *
+ * @param uld       Pointer to the locale data object from which the 
+ *                  exemplar character set is to be retrieved.
+ * @param fillIn    Pointer to a USet object to receive the 
+ *                  exemplar character set for the given locale.  Previous
+ *                  contents of fillIn are lost.  <em>If fillIn is NULL,
+ *                  then a new USet is created and returned.  The caller
+ *                  owns the result and must dispose of it by calling
+ *                  uset_close.</em>
+ * @param options   Bitmask for options to apply to the exemplar pattern.
+ *                  Specify zero to retrieve the exemplar set as it is
+ *                  defined in the locale data.  Specify
+ *                  USET_CASE_INSENSITIVE to retrieve a case-folded
+ *                  exemplar set.  See uset_applyPattern for a complete
+ *                  list of valid options.  The USET_IGNORE_SPACE bit is
+ *                  always set, regardless of the value of 'options'.
+ * @param extype    Specifies the type of exemplar set to be retrieved.
+ * @param status    Pointer to an input-output error code value;
+ *                  must not be NULL.
+ * @return USet*    Either fillIn, or if fillIn is NULL, a pointer to
+ *                  a newly-allocated USet that the user must close.
+ * @stable ICU 3.4
+ */
+U_STABLE USet* U_EXPORT2 
+ulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn, 
+                        uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status);
+
+/**
+ * Returns one of the delimiter strings associated with a locale.
+ *
+ * @param uld           Pointer to the locale data object from which the 
+ *                      delimiter string is to be retrieved.
+ * @param type          the type of delimiter to be retrieved.
+ * @param result        A pointer to a buffer to receive the result.
+ * @param resultLength  The maximum size of result.
+ * @param status        Pointer to an error code value
+ * @return int32_t      The total buffer size needed; if greater than resultLength,
+ *                      the output was truncated.
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2 
+ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type, UChar *result, int32_t resultLength, UErrorCode *status);
+
+/**
+ * Enumeration for representing the measurement systems.
+ * @stable ICU 2.8
+ */
+typedef enum UMeasurementSystem {
+    UMS_SI,     /** Measurement system specified by SI otherwise known as Metric system. */
+    UMS_US,     /** Measurement system followed in the United States of America. */ 
+    UMS_LIMIT
+} UMeasurementSystem;
+
+/**
+ * Returns the measurement system used in the locale specified by the localeID.
+ * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
+ *
+ * @param localeID      The id of the locale for which the measurement system to be retrieved.
+ * @param status        Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @return UMeasurementSystem the measurement system used in the locale.
+ * @stable ICU 2.8
+ */
+U_STABLE UMeasurementSystem U_EXPORT2
+ulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status);
+
+/**
+ * Returns the element gives the normal business letter size, and customary units. 
+ * The units for the numbers are always in <em>milli-meters</em>.
+ * For US since 8.5 and 11 do not yeild an integral value when converted to milli-meters,
+ * the values are rounded off.
+ * So for A4 size paper the height and width are 297 mm and 210 mm repectively, 
+ * and for US letter size the height and width are 279 mm and 216 mm respectively.
+ * Please note that this API will change in ICU 3.6 and will use an ulocdata object.
+ *
+ * @param localeID      The id of the locale for which the paper size information to be retrieved.
+ * @param height        A pointer to int to recieve the height information.
+ * @param width         A pointer to int to recieve the width information.
+ * @param status        Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @stable ICU 2.8
+ */
+U_STABLE void U_EXPORT2
+ulocdata_getPaperSize(const char *localeID, int32_t *height, int32_t *width, UErrorCode *status);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/umachine.h b/CoreFoundation/icu/unicode/umachine.h
new file mode 100644
index 0000000..083f9cf
--- /dev/null
+++ b/CoreFoundation/icu/unicode/umachine.h
@@ -0,0 +1,338 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1999-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*   file name:  umachine.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999sep13
+*   created by: Markus W. Scherer
+*
+*   This file defines basic types and constants for utf.h to be
+*   platform-independent. umachine.h and utf.h are included into
+*   utypes.h to provide all the general definitions for ICU.
+*   All of these definitions used to be in utypes.h before
+*   the UTF-handling macros made this unmaintainable.
+*/
+
+#ifndef __UMACHINE_H__
+#define __UMACHINE_H__
+
+
+/**
+ * \file
+ * \brief Basic types and constants for UTF 
+ * 
+ * <h2> Basic types and constants for UTF </h2>
+ *   This file defines basic types and constants for utf.h to be
+ *   platform-independent. umachine.h and utf.h are included into
+ *   utypes.h to provide all the general definitions for ICU.
+ *   All of these definitions used to be in utypes.h before
+ *   the UTF-handling macros made this unmaintainable.
+ * 
+ */
+/*==========================================================================*/
+/* Include platform-dependent definitions                                   */
+/* which are contained in the platform-specific file platform.h             */
+/*==========================================================================*/
+
+#if defined(U_PALMOS)
+#   include "unicode/ppalmos.h"
+#elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+#   include "unicode/pwin32.h"
+#else
+#   include "unicode/platform.h"
+#endif
+
+/*
+ * ANSI C headers:
+ * stddef.h defines wchar_t
+ */
+#include <stddef.h>
+
+/*==========================================================================*/
+/* XP_CPLUSPLUS is a cross-platform symbol which should be defined when     */
+/* using C++.  It should not be defined when compiling under C.             */
+/*==========================================================================*/
+
+#ifdef __cplusplus
+#   ifndef XP_CPLUSPLUS
+#       define XP_CPLUSPLUS
+#   endif
+#else
+#   undef XP_CPLUSPLUS
+#endif
+
+/*==========================================================================*/
+/* For C wrappers, we use the symbol U_STABLE.                                */
+/* This works properly if the includer is C or C++.                         */
+/* Functions are declared   U_STABLE return-type U_EXPORT2 function-name()... */
+/*==========================================================================*/
+
+/**
+ * \def U_CFUNC
+ * This is used in a declaration of a library private ICU C function.
+ * @stable ICU 2.4
+ */
+
+/**
+ * \def U_CDECL_BEGIN
+ * This is used to begin a declaration of a library private ICU C API.
+ * @stable ICU 2.4
+ */
+
+/**
+ * \def U_CDECL_END
+ * This is used to end a declaration of a library private ICU C API 
+ * @stable ICU 2.4
+ */
+
+#ifdef XP_CPLUSPLUS
+#   define U_CFUNC extern "C"
+#   define U_CDECL_BEGIN extern "C" {
+#   define U_CDECL_END   }
+#else
+#   define U_CFUNC extern
+#   define U_CDECL_BEGIN
+#   define U_CDECL_END
+#endif
+
+/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
+#define U_CAPI U_CFUNC U_EXPORT
+#define U_STABLE U_CAPI
+#define U_DRAFT  U_CAPI
+#define U_DEPRECATED U_CAPI
+#define U_OBSOLETE U_CAPI
+#define U_INTERNAL U_CAPI
+
+/*==========================================================================*/
+/* limits for int32_t etc., like in POSIX inttypes.h                        */
+/*==========================================================================*/
+
+#ifndef INT8_MIN
+/** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
+#   define INT8_MIN        ((int8_t)(-128))
+#endif
+#ifndef INT16_MIN
+/** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
+#   define INT16_MIN       ((int16_t)(-32767-1))
+#endif
+#ifndef INT32_MIN
+/** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
+#   define INT32_MIN       ((int32_t)(-2147483647-1))
+#endif
+
+#ifndef INT8_MAX
+/** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
+#   define INT8_MAX        ((int8_t)(127))
+#endif
+#ifndef INT16_MAX
+/** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
+#   define INT16_MAX       ((int16_t)(32767))
+#endif
+#ifndef INT32_MAX
+/** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
+#   define INT32_MAX       ((int32_t)(2147483647))
+#endif
+
+#ifndef UINT8_MAX
+/** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
+#   define UINT8_MAX       ((uint8_t)(255U))
+#endif
+#ifndef UINT16_MAX
+/** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
+#   define UINT16_MAX      ((uint16_t)(65535U))
+#endif
+#ifndef UINT32_MAX
+/** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
+#   define UINT32_MAX      ((uint32_t)(4294967295U))
+#endif
+
+#if defined(U_INT64_T_UNAVAILABLE)
+# error int64_t is required for decimal format and rule-based number format.
+#else
+# ifndef INT64_C
+/**
+ * Provides a platform independent way to specify a signed 64-bit integer constant.
+ * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
+ * @stable ICU 2.8
+ */
+#   define INT64_C(c) c ## LL
+# endif
+# ifndef UINT64_C
+/**
+ * Provides a platform independent way to specify an unsigned 64-bit integer constant.
+ * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
+ * @stable ICU 2.8
+ */
+#   define UINT64_C(c) c ## ULL
+# endif
+# ifndef U_INT64_MIN
+/** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
+#     define U_INT64_MIN       ((int64_t)(INT64_C(-9223372036854775807)-1))
+# endif
+# ifndef U_INT64_MAX
+/** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
+#     define U_INT64_MAX       ((int64_t)(INT64_C(9223372036854775807)))
+# endif
+# ifndef U_UINT64_MAX
+/** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
+#     define U_UINT64_MAX      ((uint64_t)(UINT64_C(18446744073709551615)))
+# endif
+#endif
+
+/*==========================================================================*/
+/* Boolean data type                                                        */
+/*==========================================================================*/
+
+/** The ICU boolean type @stable ICU 2.0 */
+typedef int8_t UBool;
+
+#ifndef TRUE
+/** The TRUE value of a UBool @stable ICU 2.0 */
+#   define TRUE  1
+#endif
+#ifndef FALSE
+/** The FALSE value of a UBool @stable ICU 2.0 */
+#   define FALSE 0
+#endif
+
+
+/*==========================================================================*/
+/* Unicode data types                                                       */
+/*==========================================================================*/
+
+/* wchar_t-related definitions -------------------------------------------- */
+
+/**
+ * \def U_HAVE_WCHAR_H
+ * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
+ *
+ * @stable ICU 2.0
+ */
+#ifndef U_HAVE_WCHAR_H
+#   define U_HAVE_WCHAR_H 1
+#endif
+
+/**
+ * \def U_SIZEOF_WCHAR_T
+ * U_SIZEOF_WCHAR_T==sizeof(wchar_t) (0 means it is not defined or autoconf could not set it)
+ *
+ * @stable ICU 2.0
+ */
+#if U_SIZEOF_WCHAR_T==0
+#   undef U_SIZEOF_WCHAR_T
+#   define U_SIZEOF_WCHAR_T 4
+#endif
+
+/*
+ * \def U_WCHAR_IS_UTF16
+ * Defined if wchar_t uses UTF-16.
+ *
+ * @stable ICU 2.0
+ */
+/*
+ * \def U_WCHAR_IS_UTF32
+ * Defined if wchar_t uses UTF-32.
+ *
+ * @stable ICU 2.0
+ */
+#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
+#   ifdef __STDC_ISO_10646__ 
+#       if (U_SIZEOF_WCHAR_T==2)
+#           define U_WCHAR_IS_UTF16
+#       elif (U_SIZEOF_WCHAR_T==4)
+#           define  U_WCHAR_IS_UTF32
+#       endif
+#   elif defined __UCS2__
+#       if (__OS390__ || __OS400__) && (U_SIZEOF_WCHAR_T==2)
+#           define U_WCHAR_IS_UTF16
+#       endif
+#   elif defined __UCS4__
+#       if (U_SIZEOF_WCHAR_T==4)
+#           define U_WCHAR_IS_UTF32
+#       endif
+#   elif defined(U_WINDOWS)
+#       define U_WCHAR_IS_UTF16    
+#   endif
+#endif
+
+/* UChar and UChar32 definitions -------------------------------------------- */
+
+/** Number of bytes in a UChar. @stable ICU 2.0 */
+#define U_SIZEOF_UCHAR 2
+
+/**
+ * \var UChar
+ * Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
+ * If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
+ * This makes the definition of UChar platform-dependent
+ * but allows direct string type compatibility with platforms with
+ * 16-bit wchar_t types.
+ *
+ * @stable ICU 2.0
+ */
+
+/* Define UChar to be compatible with wchar_t if possible. */
+#if U_SIZEOF_WCHAR_T==2
+    typedef wchar_t UChar;
+#else
+    typedef uint16_t UChar;
+#endif
+
+/**
+ * Define UChar32 as a type for single Unicode code points.
+ * UChar32 is a signed 32-bit integer (same as int32_t).
+ *
+ * The Unicode code point range is 0..0x10ffff.
+ * All other values (negative or >=0x110000) are illegal as Unicode code points.
+ * They may be used as sentinel values to indicate "done", "error"
+ * or similar non-code point conditions.
+ *
+ * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
+ * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
+ * or else to be uint32_t.
+ * That is, the definition of UChar32 was platform-dependent.
+ *
+ * @see U_SENTINEL
+ * @stable ICU 2.4
+ */
+typedef int32_t UChar32;
+
+/*==========================================================================*/
+/* U_INLINE and U_ALIGN_CODE   Set default values if these are not already  */
+/*                             defined.  Definitions normally are in        */
+/*                             platform.h or the corresponding file for     */
+/*                             the OS in use.                               */
+/*==========================================================================*/
+
+#ifndef U_HIDE_INTERNAL_API
+
+/**
+ * \def U_ALIGN_CODE
+ * This is used to align code fragments to a specific byte boundary.
+ * This is useful for getting consistent performance test results.
+ * @internal
+ */
+#ifndef U_ALIGN_CODE
+#   define U_ALIGN_CODE(n)
+#endif
+
+#endif /* U_HIDE_INTERNAL_API */
+
+#ifndef U_INLINE
+#   ifdef XP_CPLUSPLUS
+#       define U_INLINE inline
+#   else
+#       define U_INLINE
+#   endif
+#endif
+
+#include "unicode/urename.h"
+
+#endif
diff --git a/CoreFoundation/icu/unicode/umisc.h b/CoreFoundation/icu/unicode/umisc.h
new file mode 100644
index 0000000..d85451f
--- /dev/null
+++ b/CoreFoundation/icu/unicode/umisc.h
@@ -0,0 +1,60 @@
+/*
+**********************************************************************
+*   Copyright (C) 1999-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*   file name:  umisc.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999oct15
+*   created by: Markus W. Scherer
+*/
+
+#ifndef UMISC_H
+#define UMISC_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief  C API:misc definitions 
+ *
+ *  This file contains miscellaneous definitions for the C APIs. 
+ */
+
+U_CDECL_BEGIN
+
+/** A struct representing a range of text containing a specific field 
+ *  @stable ICU 2.0
+ */
+typedef struct UFieldPosition {
+  /**
+   * The field 
+   * @stable ICU 2.0
+   */
+  int32_t field;
+  /**
+   * The start of the text range containing field 
+   * @stable ICU 2.0
+   */
+  int32_t beginIndex;
+  /** 
+   * The limit of the text range containing field 
+   * @stable ICU 2.0
+   */
+  int32_t endIndex;
+} UFieldPosition;
+
+#if !UCONFIG_NO_SERVICE
+/**
+ * Opaque type returned by registerInstance, registerFactory and unregister for service registration.
+ * @stable ICU 2.6
+ */
+typedef const void* URegistryKey;
+#endif
+
+U_CDECL_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/umsg.h b/CoreFoundation/icu/unicode/umsg.h
new file mode 100644
index 0000000..32ed063
--- /dev/null
+++ b/CoreFoundation/icu/unicode/umsg.h
@@ -0,0 +1,647 @@
+/*
+*******************************************************************************
+* Copyright (C) 1996-2006, International Business Machines Corporation
+* and others. All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  umsg.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Change history:
+*
+*   08/5/2001  Ram         Added C wrappers for C++ API.
+*                          
+*
+*/
+
+#ifndef UMSG_H
+#define UMSG_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uloc.h"
+#include "unicode/parseerr.h"
+#include <stdarg.h>
+/**
+ * \file
+ * \brief C API: MessageFormat
+ *
+ * <h2>Message Format C API </h2>
+ *
+ * Provides means to produce concatenated messages in language-neutral way.
+ * Use this for all concatenations that show up to end users.
+ * <P>
+ * Takes a set of objects, formats them, then inserts the formatted
+ * strings into the pattern at the appropriate places.
+ * <P>
+ * Here are some examples of usage:
+ * Example 1:
+ * <pre>
+ * \code
+ *     UChar *result, *tzID, *str;
+ *     UChar pattern[100];
+ *     int32_t resultLengthOut, resultlength;
+ *     UCalendar *cal;
+ *     UDate d1;
+ *     UDateFormat *def1;
+ *     UErrorCode status = U_ZERO_ERROR;
+ *
+ *     str=(UChar*)malloc(sizeof(UChar) * (strlen("disturbance in force") +1));
+ *     u_uastrcpy(str, "disturbance in force");
+ *     tzID=(UChar*)malloc(sizeof(UChar) * 4);
+ *     u_uastrcpy(tzID, "PST");
+ *     cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
+ *     ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status);
+ *     d1=ucal_getMillis(cal, &status);
+ *     u_uastrcpy(pattern, "On {0, date, long}, there was a {1} on planet {2,number,integer}");
+ *     resultlength=0;
+ *     resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, d1, str, 7);
+ *     if(status==U_BUFFER_OVERFLOW_ERROR){
+ *         status=U_ZERO_ERROR;
+ *         resultlength=resultLengthOut+1;
+ *         result=(UChar*)realloc(result, sizeof(UChar) * resultlength);
+ *         u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, d1, str, 7);
+ *     }
+ *     printf("%s\n", austrdup(result) );//austrdup( a function used to convert UChar* to char*)
+ *     //output>: "On March 18, 1999, there was a disturbance in force on planet 7
+ * \endcode
+ * </pre>
+ * Typically, the message format will come from resources, and the
+ * arguments will be dynamically set at runtime.
+ * <P>
+ * Example 2:
+ * <pre>
+ * \code
+ *     UChar* str;
+ *     UErrorCode status = U_ZERO_ERROR;
+ *     UChar *result;
+ *     UChar pattern[100];
+ *     int32_t resultlength, resultLengthOut, i;
+ *     double testArgs= { 100.0, 1.0, 0.0};
+ *
+ *     str=(UChar*)malloc(sizeof(UChar) * 10);
+ *     u_uastrcpy(str, "MyDisk");
+ *     u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}");
+ *     for(i=0; i<3; i++){
+ *       resultlength=0;
+ *       resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str);
+ *       if(status==U_BUFFER_OVERFLOW_ERROR){
+ *         status=U_ZERO_ERROR;
+ *         resultlength=resultLengthOut+1;
+ *         result=(UChar*)malloc(sizeof(UChar) * resultlength);
+ *         u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);
+ *       }
+ *       printf("%s\n", austrdup(result) );  //austrdup( a function used to convert UChar* to char*)
+ *       free(result);
+ *     }
+ *     // output, with different testArgs:
+ *     // output: The disk "MyDisk" contains 100 files.
+ *     // output: The disk "MyDisk" contains one file.
+ *     // output: The disk "MyDisk" contains no files.
+ * \endcode
+ *  </pre>
+ *
+ *  The pattern is of the following form.  Legend:
+ *  <pre>
+ * \code
+ *       {optional item}
+ *       (group that may be repeated)*
+ * \endcode
+ *  </pre>
+ *  Do not confuse optional items with items inside quotes braces, such
+ *  as this: "{".  Quoted braces are literals.
+ *  <pre>
+ * \code
+ *       messageFormatPattern := string ( "{" messageFormatElement "}" string )*
+ *
+ *       messageFormatElement := argument { "," elementFormat }
+ *
+ *       elementFormat := "time" { "," datetimeStyle }
+ *                      | "date" { "," datetimeStyle }
+ *                      | "number" { "," numberStyle }
+ *                      | "choice" "," choiceStyle
+ *
+ *       datetimeStyle := "short"
+ *                      | "medium"
+ *                      | "long"
+ *                      | "full"
+ *                      | dateFormatPattern
+ *
+ *       numberStyle :=   "currency"
+ *                      | "percent"
+ *                      | "integer"
+ *                      | numberFormatPattern
+ *
+ *       choiceStyle :=   choiceFormatPattern
+ * \endcode
+ * </pre>
+ * If there is no elementFormat, then the argument must be a string,
+ * which is substituted. If there is no dateTimeStyle or numberStyle,
+ * then the default format is used (e.g.  NumberFormat.getInstance(),
+ * DateFormat.getDefaultTime() or DateFormat.getDefaultDate(). For
+ * a ChoiceFormat, the pattern must always be specified, since there
+ * is no default.
+ * <P>
+ * In strings, single quotes can be used to quote the "{" sign if
+ * necessary. A real single quote is represented by ''.  Inside a
+ * messageFormatElement, quotes are [not] removed. For example,
+ * {1,number,$'#',##} will produce a number format with the pound-sign
+ * quoted, with a result such as: "$#31,45".
+ * <P>
+ * If a pattern is used, then unquoted braces in the pattern, if any,
+ * must match: that is, "ab {0} de" and "ab '}' de" are ok, but "ab
+ * {0'}' de" and "ab } de" are not.
+ * <p>
+ * <dl><dt><b>Warning:</b><dd>The rules for using quotes within message
+ * format patterns unfortunately have shown to be somewhat confusing.
+ * In particular, it isn't always obvious to localizers whether single
+ * quotes need to be doubled or not. Make sure to inform localizers about
+ * the rules, and tell them (for example, by using comments in resource
+ * bundle source files) which strings will be processed by MessageFormat.
+ * Note that localizers may need to use single quotes in translated
+ * strings where the original version doesn't have them.
+ * <br>Note also that the simplest way to avoid the problem is to
+ * use the real apostrophe (single quote) character U+2019 (') for
+ * human-readable text, and to use the ASCII apostrophe (U+0027 ' )
+ * only in program syntax, like quoting in MessageFormat.
+ * See the annotations for U+0027 Apostrophe in The Unicode Standard.</p>
+ * </dl>
+ * <P>
+ * The argument is a number from 0 to 9, which corresponds to the
+ * arguments presented in an array to be formatted.
+ * <P>
+ * It is ok to have unused arguments in the array.  With missing
+ * arguments or arguments that are not of the right class for the
+ * specified format, a failing UErrorCode result is set.
+ * <P>
+
+ * <P>
+ * [Note:] As we see above, the string produced by a choice Format in
+ * MessageFormat is treated specially; occurances of '{' are used to
+ * indicated subformats.
+ * <P>
+ * [Note:] Formats are numbered by order of variable in the string.
+ * This is [not] the same as the argument numbering!
+ * <pre>
+ * \code
+ *    For example: with "abc{2}def{3}ghi{0}...",
+ *
+ *    format0 affects the first variable {2}
+ *    format1 affects the second variable {3}
+ *    format2 affects the second variable {0}
+ * \endcode
+ * </pre>
+ * and so on.
+ */
+
+/**
+ * Format a message for a locale.
+ * This function may perform re-ordering of the arguments depending on the
+ * locale. For all numeric arguments, double is assumed unless the type is
+ * explicitly integer.  All choice format arguments must be of type double.
+ * @param locale The locale for which the message will be formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param result A pointer to a buffer to receive the formatted message.
+ * @param resultLength The maximum size of result.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @param ... A variable-length argument list containing the arguments specified
+ * in pattern.
+ * @return The total buffer size needed; if greater than resultLength, the
+ * output was truncated.
+ * @see u_parseMessage
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+u_formatMessage(const char  *locale,
+                 const UChar *pattern,
+                int32_t     patternLength,
+                UChar       *result,
+                int32_t     resultLength,
+                UErrorCode  *status,
+                ...);
+
+/**
+ * Format a message for a locale.
+ * This function may perform re-ordering of the arguments depending on the
+ * locale. For all numeric arguments, double is assumed unless the type is
+ * explicitly integer.  All choice format arguments must be of type double.
+ * @param locale The locale for which the message will be formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param result A pointer to a buffer to receive the formatted message.
+ * @param resultLength The maximum size of result.
+ * @param ap A variable-length argument list containing the arguments specified
+ * @param status A pointer to an UErrorCode to receive any errors
+ * in pattern.
+ * @return The total buffer size needed; if greater than resultLength, the
+ * output was truncated.
+ * @see u_parseMessage
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+u_vformatMessage(   const char  *locale,
+                    const UChar *pattern,
+                    int32_t     patternLength,
+                    UChar       *result,
+                    int32_t     resultLength,
+                    va_list     ap,
+                    UErrorCode  *status);
+
+/**
+ * Parse a message.
+ * For numeric arguments, this function will always use doubles.  Integer types
+ * should not be passed.
+ * This function is not able to parse all output from {@link #u_formatMessage }.
+ * @param locale The locale for which the message is formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param source The text to parse.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @param ... A variable-length argument list containing the arguments
+ * specified in pattern.
+ * @see u_formatMessage
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+u_parseMessage( const char   *locale,
+                const UChar  *pattern,
+                int32_t      patternLength,
+                const UChar  *source,
+                int32_t      sourceLength,
+                UErrorCode   *status,
+                ...);
+
+/**
+ * Parse a message.
+ * For numeric arguments, this function will always use doubles.  Integer types
+ * should not be passed.
+ * This function is not able to parse all output from {@link #u_formatMessage }.
+ * @param locale The locale for which the message is formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param source The text to parse.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param ap A variable-length argument list containing the arguments
+ * @param status A pointer to an UErrorCode to receive any errors
+ * specified in pattern.
+ * @see u_formatMessage
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+u_vparseMessage(const char  *locale,
+                const UChar *pattern,
+                int32_t     patternLength,
+                const UChar *source,
+                int32_t     sourceLength,
+                va_list     ap,
+                UErrorCode  *status);
+
+/**
+ * Format a message for a locale.
+ * This function may perform re-ordering of the arguments depending on the
+ * locale. For all numeric arguments, double is assumed unless the type is
+ * explicitly integer.  All choice format arguments must be of type double.
+ * @param locale The locale for which the message will be formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param result A pointer to a buffer to receive the formatted message.
+ * @param resultLength The maximum size of result.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @param ... A variable-length argument list containing the arguments specified
+ * in pattern.
+ * @param parseError  A pointer to UParseError to receive information about errors
+ *                     occurred during parsing.
+ * @return The total buffer size needed; if greater than resultLength, the
+ * output was truncated.
+ * @see u_parseMessage
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+u_formatMessageWithError(   const char    *locale,
+                            const UChar   *pattern,
+                            int32_t       patternLength,
+                            UChar         *result,
+                            int32_t       resultLength,
+                            UParseError   *parseError,
+                            UErrorCode    *status,
+                            ...);
+
+/**
+ * Format a message for a locale.
+ * This function may perform re-ordering of the arguments depending on the
+ * locale. For all numeric arguments, double is assumed unless the type is
+ * explicitly integer.  All choice format arguments must be of type double.
+ * @param locale The locale for which the message will be formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param result A pointer to a buffer to receive the formatted message.
+ * @param resultLength The maximum size of result.
+ * @param parseError  A pointer to UParseError to receive information about errors
+ *                    occurred during parsing.
+ * @param ap A variable-length argument list containing the arguments specified
+ * @param status A pointer to an UErrorCode to receive any errors
+ * in pattern.
+ * @return The total buffer size needed; if greater than resultLength, the
+ * output was truncated.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+u_vformatMessageWithError(  const char   *locale,
+                            const UChar  *pattern,
+                            int32_t      patternLength,
+                            UChar        *result,
+                            int32_t      resultLength,
+                            UParseError* parseError,
+                            va_list      ap,
+                            UErrorCode   *status);
+
+/**
+ * Parse a message.
+ * For numeric arguments, this function will always use doubles.  Integer types
+ * should not be passed.
+ * This function is not able to parse all output from {@link #u_formatMessage }.
+ * @param locale The locale for which the message is formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param source The text to parse.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param parseError  A pointer to UParseError to receive information about errors
+ *                     occurred during parsing.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * @param ... A variable-length argument list containing the arguments
+ * specified in pattern.
+ * @see u_formatMessage
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+u_parseMessageWithError(const char  *locale,
+                        const UChar *pattern,
+                        int32_t     patternLength,
+                        const UChar *source,
+                        int32_t     sourceLength,
+                        UParseError *parseError,
+                        UErrorCode  *status,
+                        ...);
+
+/**
+ * Parse a message.
+ * For numeric arguments, this function will always use doubles.  Integer types
+ * should not be passed.
+ * This function is not able to parse all output from {@link #u_formatMessage }.
+ * @param locale The locale for which the message is formatted
+ * @param pattern The pattern specifying the message's format
+ * @param patternLength The length of pattern
+ * @param source The text to parse.
+ * @param sourceLength The length of source, or -1 if null-terminated.
+ * @param ap A variable-length argument list containing the arguments
+ * @param parseError  A pointer to UParseError to receive information about errors
+ *                     occurred during parsing.
+ * @param status A pointer to an UErrorCode to receive any errors
+ * specified in pattern.
+ * @see u_formatMessage
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+u_vparseMessageWithError(const char  *locale,
+                         const UChar *pattern,
+                         int32_t     patternLength,
+                         const UChar *source,
+                         int32_t     sourceLength,
+                         va_list     ap,
+                         UParseError *parseError,
+                         UErrorCode* status);
+
+/*----------------------- New experimental API --------------------------- */
+/** 
+ * The message format object
+ * @stable ICU 2.0
+ */
+typedef void* UMessageFormat;
+
+
+/**
+ * Open a message formatter with given pattern and for the given locale.
+ * @param pattern       A pattern specifying the format to use.
+ * @param patternLength Length of the pattern to use
+ * @param locale        The locale for which the messages are formatted.
+ * @param parseError    A pointer to UParseError struct to receive any errors 
+ *                      occured during parsing. Can be NULL.
+ * @param status        A pointer to an UErrorCode to receive any errors.
+ * @return              A pointer to a UMessageFormat to use for formatting 
+ *                      messages, or 0 if an error occurred. 
+ * @stable ICU 2.0
+ */
+U_STABLE UMessageFormat* U_EXPORT2 
+umsg_open(  const UChar     *pattern,
+            int32_t         patternLength,
+            const  char     *locale,
+            UParseError     *parseError,
+            UErrorCode      *status);
+
+/**
+ * Close a UMessageFormat.
+ * Once closed, a UMessageFormat may no longer be used.
+ * @param format The formatter to close.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+umsg_close(UMessageFormat* format);
+
+/**
+ * Open a copy of a UMessageFormat.
+ * This function performs a deep copy.
+ * @param fmt The formatter to copy
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return A pointer to a UDateFormat identical to fmt.
+ * @stable ICU 2.0
+ */
+U_STABLE UMessageFormat U_EXPORT2 
+umsg_clone(const UMessageFormat *fmt,
+           UErrorCode *status);
+
+/**
+ * Sets the locale. This locale is used for fetching default number or date
+ * format information.
+ * @param fmt The formatter to set
+ * @param locale The locale the formatter should use.
+ * @stable ICU 2.0
+ */
+U_STABLE void  U_EXPORT2 
+umsg_setLocale(UMessageFormat *fmt,
+               const char* locale);
+
+/**
+ * Gets the locale. This locale is used for fetching default number or date
+ * format information.
+ * @param fmt The formatter to querry
+ * @return the locale.
+ * @stable ICU 2.0
+ */
+U_STABLE const char*  U_EXPORT2 
+umsg_getLocale(const UMessageFormat *fmt);
+
+/**
+ * Sets the pattern.
+ * @param fmt           The formatter to use
+ * @param pattern       The pattern to be applied.
+ * @param patternLength Length of the pattern to use
+ * @param parseError    Struct to receive information on position 
+ *                      of error if an error is encountered.Can be NULL.
+ * @param status        Output param set to success/failure code on
+ *                      exit. If the pattern is invalid, this will be
+ *                      set to a failure result.
+ * @stable ICU 2.0
+ */
+U_STABLE void  U_EXPORT2 
+umsg_applyPattern( UMessageFormat *fmt,
+                   const UChar* pattern,
+                   int32_t patternLength,
+                   UParseError* parseError,
+                   UErrorCode* status);
+
+/**
+ * Gets the pattern.
+ * @param fmt          The formatter to use
+ * @param result       A pointer to a buffer to receive the pattern.
+ * @param resultLength The maximum size of result.
+ * @param status       Output param set to success/failure code on
+ *                     exit. If the pattern is invalid, this will be
+ *                     set to a failure result.  
+ * @return the pattern of the format
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t  U_EXPORT2 
+umsg_toPattern(const UMessageFormat *fmt,
+               UChar* result, 
+               int32_t resultLength,
+               UErrorCode* status);
+
+/**
+ * Format a message for a locale.
+ * This function may perform re-ordering of the arguments depending on the
+ * locale. For all numeric arguments, double is assumed unless the type is
+ * explicitly integer.  All choice format arguments must be of type double.
+ * @param fmt           The formatter to use
+ * @param result        A pointer to a buffer to receive the formatted message.
+ * @param resultLength  The maximum size of result.
+ * @param status        A pointer to an UErrorCode to receive any errors
+ * @param ...           A variable-length argument list containing the arguments 
+ *                      specified in pattern.
+ * @return              The total buffer size needed; if greater than resultLength, 
+ *                      the output was truncated.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+umsg_format(    const UMessageFormat *fmt,
+                UChar          *result,
+                int32_t        resultLength,
+                UErrorCode     *status,
+                ...);
+
+/**
+ * Format a message for a locale.
+ * This function may perform re-ordering of the arguments depending on the
+ * locale. For all numeric arguments, double is assumed unless the type is
+ * explicitly integer.  All choice format arguments must be of type double.
+ * @param fmt          The formatter to use 
+ * @param result       A pointer to a buffer to receive the formatted message.
+ * @param resultLength The maximum size of result.
+ * @param ap           A variable-length argument list containing the arguments 
+ * @param status       A pointer to an UErrorCode to receive any errors
+ *                     specified in pattern.
+ * @return             The total buffer size needed; if greater than resultLength, 
+ *                     the output was truncated.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+umsg_vformat(   const UMessageFormat *fmt,
+                UChar          *result,
+                int32_t        resultLength,
+                va_list        ap,
+                UErrorCode     *status);
+
+/**
+ * Parse a message.
+ * For numeric arguments, this function will always use doubles.  Integer types
+ * should not be passed.
+ * This function is not able to parse all output from {@link #umsg_format }.
+ * @param fmt           The formatter to use 
+ * @param source        The text to parse.
+ * @param sourceLength  The length of source, or -1 if null-terminated.
+ * @param count         Output param to receive number of elements returned.
+ * @param status        A pointer to an UErrorCode to receive any errors
+ * @param ...           A variable-length argument list containing the arguments
+ *                      specified in pattern.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+umsg_parse( const UMessageFormat *fmt,
+            const UChar    *source,
+            int32_t        sourceLength,
+            int32_t        *count,
+            UErrorCode     *status,
+            ...);
+
+/**
+ * Parse a message.
+ * For numeric arguments, this function will always use doubles.  Integer types
+ * should not be passed.
+ * This function is not able to parse all output from {@link #umsg_format }.
+ * @param fmt           The formatter to use 
+ * @param source        The text to parse.
+ * @param sourceLength  The length of source, or -1 if null-terminated.
+ * @param count         Output param to receive number of elements returned.
+ * @param ap            A variable-length argument list containing the arguments
+ * @param status        A pointer to an UErrorCode to receive any errors
+ *                      specified in pattern.
+ * @see u_formatMessage
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+umsg_vparse(const UMessageFormat *fmt,
+            const UChar    *source,
+            int32_t        sourceLength,
+            int32_t        *count,
+            va_list        ap,
+            UErrorCode     *status);
+
+
+/**
+ * Convert an 'apostrophe-friendly' pattern into a standard
+ * pattern.  Standard patterns treat all apostrophes as
+ * quotes, which is problematic in some languages, e.g. 
+ * French, where apostrophe is commonly used.  This utility
+ * assumes that only an unpaired apostrophe immediately before
+ * a brace is a true quote.  Other unpaired apostrophes are paired,
+ * and the resulting standard pattern string is returned.
+ *
+ * <p><b>Note</b> it is not guaranteed that the returned pattern
+ * is indeed a valid pattern.  The only effect is to convert
+ * between patterns having different quoting semantics.
+ *
+ * @param pattern the 'apostrophe-friendly' patttern to convert
+ * @param patternLength the length of pattern, or -1 if unknown and pattern is null-terminated
+ * @param dest the buffer for the result, or NULL if preflight only
+ * @param destCapacity the length of the buffer, or 0 if preflighting
+ * @param ec the error code
+ * @return the length of the resulting text, not including trailing null
+ *        if buffer has room for the trailing null, it is provided, otherwise
+ *        not
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2 
+umsg_autoQuoteApostrophe(const UChar* pattern, 
+                         int32_t patternLength,
+                         UChar* dest,
+                         int32_t destCapacity,
+                         UErrorCode* ec);
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/unifilt.h b/CoreFoundation/icu/unicode/unifilt.h
new file mode 100644
index 0000000..5bf1ba4
--- /dev/null
+++ b/CoreFoundation/icu/unicode/unifilt.h
@@ -0,0 +1,127 @@
+/*
+**********************************************************************
+* Copyright (C) 1999-2006, International Business Machines Corporation and others.
+* All Rights Reserved.
+**********************************************************************
+*   Date        Name        Description
+*   11/17/99    aliu        Creation.
+**********************************************************************
+*/
+#ifndef UNIFILT_H
+#define UNIFILT_H
+
+#include "unicode/unifunct.h"
+#include "unicode/unimatch.h"
+
+/**
+ * \file 
+ * \brief C++ API: Unicode Filter
+ */
+
+U_NAMESPACE_BEGIN
+
+/**
+ * U_ETHER is used to represent character values for positions outside
+ * a range.  For example, transliterator uses this to represent
+ * characters outside the range contextStart..contextLimit-1.  This
+ * allows explicit matching by rules and UnicodeSets of text outside a
+ * defined range.
+ * @stable ICU 3.0
+ */
+#define U_ETHER ((UChar)0xFFFF)
+
+/**
+ *
+ * <code>UnicodeFilter</code> defines a protocol for selecting a
+ * subset of the full range (U+0000 to U+10FFFF) of Unicode characters.
+ * Currently, filters are used in conjunction with classes like {@link
+ * Transliterator} to only process selected characters through a
+ * transformation.
+ *
+ * <p>Note: UnicodeFilter currently stubs out two pure virtual methods
+ * of its base class, UnicodeMatcher.  These methods are toPattern()
+ * and matchesIndexValue().  This is done so that filter classes that
+ * are not actually used as matchers -- specifically, those in the
+ * UnicodeFilterLogic component, and those in tests -- can continue to
+ * work without defining these methods.  As long as a filter is not
+ * used in an RBT during real transliteration, these methods will not
+ * be called.  However, this breaks the UnicodeMatcher base class
+ * protocol, and it is not a correct solution.
+ *
+ * <p>In the future we may revisit the UnicodeMatcher / UnicodeFilter
+ * hierarchy and either redesign it, or simply remove the stubs in
+ * UnicodeFilter and force subclasses to implement the full
+ * UnicodeMatcher protocol.
+ *
+ * @see UnicodeFilterLogic
+ * @stable ICU 2.0
+ */
+class U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher {
+
+public:
+    /**
+     * Destructor
+     * @stable ICU 2.0
+     */
+    virtual ~UnicodeFilter();
+
+    /**
+     * Returns <tt>true</tt> for characters that are in the selected
+     * subset.  In other words, if a character is <b>to be
+     * filtered</b>, then <tt>contains()</tt> returns
+     * <b><tt>false</tt></b>.
+     * @stable ICU 2.0
+     */
+    virtual UBool contains(UChar32 c) const = 0;
+
+    /**
+     * UnicodeFunctor API.  Cast 'this' to a UnicodeMatcher* pointer
+     * and return the pointer.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeMatcher* toMatcher() const;
+
+    /**
+     * Implement UnicodeMatcher API.
+     * @stable ICU 2.4
+     */
+    virtual UMatchDegree matches(const Replaceable& text,
+                                 int32_t& offset,
+                                 int32_t limit,
+                                 UBool incremental);
+
+    /**
+     * UnicodeFunctor API.  Nothing to do.
+     * @stable ICU 2.4
+     */
+    virtual void setData(const TransliterationRuleData*);
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const = 0;
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+protected:
+
+    /*
+     * Since this class has pure virtual functions,
+     * a constructor can't be used.
+     * @stable ICU 2.0
+     */
+/*    UnicodeFilter();*/
+};
+
+/*inline UnicodeFilter::UnicodeFilter() {}*/
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/unifunct.h b/CoreFoundation/icu/unicode/unifunct.h
new file mode 100644
index 0000000..3aa7b03
--- /dev/null
+++ b/CoreFoundation/icu/unicode/unifunct.h
@@ -0,0 +1,125 @@
+/*
+**********************************************************************
+*   Copyright (c) 2002-2005, International Business Machines Corporation
+*   and others.  All Rights Reserved.
+**********************************************************************
+*   Date        Name        Description
+*   01/14/2002  aliu        Creation.
+**********************************************************************
+*/
+#ifndef UNIFUNCT_H
+#define UNIFUNCT_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+
+/**
+ * \file 
+ * \brief C++ API: Unicode Functor
+ */
+ 
+U_NAMESPACE_BEGIN
+
+class UnicodeMatcher;
+class UnicodeReplacer;
+class TransliterationRuleData;
+
+/**
+ * <code>UnicodeFunctor</code> is an abstract base class for objects
+ * that perform match and/or replace operations on Unicode strings.
+ * @author Alan Liu
+ * @stable ICU 2.4
+ */
+class U_COMMON_API UnicodeFunctor : public UObject {
+
+public:
+
+    /**
+     * Destructor
+     * @stable ICU 2.4
+     */
+    virtual ~UnicodeFunctor();
+
+    /**
+     * Return a copy of this object.  All UnicodeFunctor objects
+     * have to support cloning in order to allow classes using
+     * UnicodeFunctor to implement cloning.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeFunctor* clone() const = 0;
+
+    /**
+     * Cast 'this' to a UnicodeMatcher* pointer and return the
+     * pointer, or null if this is not a UnicodeMatcher*.  Subclasses
+     * that mix in UnicodeMatcher as a base class must override this.
+     * This protocol is required because a pointer to a UnicodeFunctor
+     * cannot be cast to a pointer to a UnicodeMatcher, since
+     * UnicodeMatcher is a mixin that does not derive from
+     * UnicodeFunctor.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeMatcher* toMatcher() const;
+
+    /**
+     * Cast 'this' to a UnicodeReplacer* pointer and return the
+     * pointer, or null if this is not a UnicodeReplacer*.  Subclasses
+     * that mix in UnicodeReplacer as a base class must override this.
+     * This protocol is required because a pointer to a UnicodeFunctor
+     * cannot be cast to a pointer to a UnicodeReplacer, since
+     * UnicodeReplacer is a mixin that does not derive from
+     * UnicodeFunctor.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeReplacer* toReplacer() const;
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID <b>polymorphically</b>.  This method
+     * is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI.  Polymorphic operator==() and
+     * clone() methods call this method.
+     *
+     * <p>Concrete subclasses of UnicodeFunctor should use the macro
+     *    UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
+     *    provide definitios getStaticClassID and getDynamicClassID.
+     *
+     * @return The class ID for this object. All objects of a given
+     * class have the same class ID.  Objects of other classes have
+     * different class IDs.
+     * @stable ICU 2.4
+     */
+    virtual UClassID getDynamicClassID(void) const = 0;
+
+    /**
+     * Set the data object associated with this functor.  The data
+     * object provides context for functor-to-standin mapping.  This
+     * method is required when assigning a functor to a different data
+     * object.  This function MAY GO AWAY later if the architecture is
+     * changed to pass data object pointers through the API.
+     * @internal ICU 2.1
+     */
+    virtual void setData(const TransliterationRuleData*) = 0;
+
+protected:
+
+    /**
+     * Since this class has pure virtual functions,
+     * a constructor can't be used.
+     * @stable ICU 2.0
+     */
+    /*UnicodeFunctor();*/
+
+};
+
+/*inline UnicodeFunctor::UnicodeFunctor() {}*/
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/unimatch.h b/CoreFoundation/icu/unicode/unimatch.h
new file mode 100644
index 0000000..0dbb14e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/unimatch.h
@@ -0,0 +1,163 @@
+/*
+* Copyright (C) 2001-2005, International Business Machines Corporation and others. All Rights Reserved.
+**********************************************************************
+*   Date        Name        Description
+*   07/18/01    aliu        Creation.
+**********************************************************************
+*/
+#ifndef UNIMATCH_H
+#define UNIMATCH_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: Unicode Matcher
+ */
+
+
+U_NAMESPACE_BEGIN
+
+class Replaceable;
+class UnicodeString;
+class UnicodeSet;
+
+/**
+ * Constants returned by <code>UnicodeMatcher::matches()</code>
+ * indicating the degree of match.
+ * @stable ICU 2.4
+ */
+enum UMatchDegree {
+    /**
+     * Constant returned by <code>matches()</code> indicating a
+     * mismatch between the text and this matcher.  The text contains
+     * a character which does not match, or the text does not contain
+     * all desired characters for a non-incremental match.
+     * @stable ICU 2.4
+     */
+    U_MISMATCH,
+    
+    /**
+     * Constant returned by <code>matches()</code> indicating a
+     * partial match between the text and this matcher.  This value is
+     * only returned for incremental match operations.  All characters
+     * of the text match, but more characters are required for a
+     * complete match.  Alternatively, for variable-length matchers,
+     * all characters of the text match, and if more characters were
+     * supplied at limit, they might also match.
+     * @stable ICU 2.4
+     */
+    U_PARTIAL_MATCH,
+    
+    /**
+     * Constant returned by <code>matches()</code> indicating a
+     * complete match between the text and this matcher.  For an
+     * incremental variable-length match, this value is returned if
+     * the given text matches, and it is known that additional
+     * characters would not alter the extent of the match.
+     * @stable ICU 2.4
+     */
+    U_MATCH
+};
+
+/**
+ * <code>UnicodeMatcher</code> defines a protocol for objects that can
+ * match a range of characters in a Replaceable string.
+ * @stable ICU 2.4
+ */
+class U_COMMON_API UnicodeMatcher /* not : public UObject because this is an interface/mixin class */ {
+
+public:
+    /**
+     * Destructor.
+     * @stable ICU 2.4
+     */
+    virtual ~UnicodeMatcher();
+
+    /**
+     * Return a UMatchDegree value indicating the degree of match for
+     * the given text at the given offset.  Zero, one, or more
+     * characters may be matched.
+     *
+     * Matching in the forward direction is indicated by limit >
+     * offset.  Characters from offset forwards to limit-1 will be
+     * considered for matching.
+     * 
+     * Matching in the reverse direction is indicated by limit <
+     * offset.  Characters from offset backwards to limit+1 will be
+     * considered for matching.
+     *
+     * If limit == offset then the only match possible is a zero
+     * character match (which subclasses may implement if desired).
+     *
+     * As a side effect, advance the offset parameter to the limit of
+     * the matched substring.  In the forward direction, this will be
+     * the index of the last matched character plus one.  In the
+     * reverse direction, this will be the index of the last matched
+     * character minus one.
+     *
+     * <p>Note:  This method is not const because some classes may
+     * modify their state as the result of a match.
+     *
+     * @param text the text to be matched
+     * @param offset on input, the index into text at which to begin
+     * matching.  On output, the limit of the matched text.  The
+     * number of matched characters is the output value of offset
+     * minus the input value.  Offset should always point to the
+     * HIGH SURROGATE (leading code unit) of a pair of surrogates,
+     * both on entry and upon return.
+     * @param limit the limit index of text to be matched.  Greater
+     * than offset for a forward direction match, less than offset for
+     * a backward direction match.  The last character to be
+     * considered for matching will be text.charAt(limit-1) in the
+     * forward direction or text.charAt(limit+1) in the backward
+     * direction.
+     * @param incremental if TRUE, then assume further characters may
+     * be inserted at limit and check for partial matching.  Otherwise
+     * assume the text as given is complete.
+     * @return a match degree value indicating a full match, a partial
+     * match, or a mismatch.  If incremental is FALSE then
+     * U_PARTIAL_MATCH should never be returned.
+     * @stable ICU 2.4
+     */
+    virtual UMatchDegree matches(const Replaceable& text,
+                                 int32_t& offset,
+                                 int32_t limit,
+                                 UBool incremental) = 0;
+
+    /**
+     * Returns a string representation of this matcher.  If the result of
+     * calling this function is passed to the appropriate parser, it
+     * will produce another matcher that is equal to this one.
+     * @param result the string to receive the pattern.  Previous
+     * contents will be deleted.
+     * @param escapeUnprintable if TRUE then convert unprintable
+     * character to their hex escape representations, \\uxxxx or
+     * \\Uxxxxxxxx.  Unprintable characters are those other than
+     * U+000A, U+0020..U+007E.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeString& toPattern(UnicodeString& result,
+                                     UBool escapeUnprintable = FALSE) const = 0;
+
+    /**
+     * Returns TRUE if this matcher will match a character c, where c
+     * & 0xFF == v, at offset, in the forward direction (with limit >
+     * offset).  This is used by <tt>RuleBasedTransliterator</tt> for
+     * indexing.
+     * @stable ICU 2.4
+     */
+    virtual UBool matchesIndexValue(uint8_t v) const = 0;
+
+    /**
+     * Union the set of all characters that may be matched by this object
+     * into the given set.
+     * @param toUnionTo the set into which to union the source characters
+     * @stable ICU 2.4
+     */
+    virtual void addMatchSetTo(UnicodeSet& toUnionTo) const = 0;
+};
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/unirepl.h b/CoreFoundation/icu/unicode/unirepl.h
new file mode 100644
index 0000000..6b7746b
--- /dev/null
+++ b/CoreFoundation/icu/unicode/unirepl.h
@@ -0,0 +1,97 @@
+/*
+**********************************************************************
+*   Copyright (c) 2002-2005, International Business Machines Corporation
+*   and others.  All Rights Reserved.
+**********************************************************************
+*   Date        Name        Description
+*   01/14/2002  aliu        Creation.
+**********************************************************************
+*/
+#ifndef UNIREPL_H
+#define UNIREPL_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: UnicodeReplacer
+ */
+
+U_NAMESPACE_BEGIN
+
+class Replaceable;
+class UnicodeString;
+class UnicodeSet;
+
+/**
+ * <code>UnicodeReplacer</code> defines a protocol for objects that
+ * replace a range of characters in a Replaceable string with output
+ * text.  The replacement is done via the Replaceable API so as to
+ * preserve out-of-band data.
+ *
+ * <p>This is a mixin class.
+ * @author Alan Liu
+ * @stable ICU 2.4
+ */
+class U_I18N_API UnicodeReplacer /* not : public UObject because this is an interface/mixin class */ {
+
+ public:
+
+    /**
+     * Destructor.
+     * @stable ICU 2.4
+     */
+    virtual ~UnicodeReplacer();
+
+    /**
+     * Replace characters in 'text' from 'start' to 'limit' with the
+     * output text of this object.  Update the 'cursor' parameter to
+     * give the cursor position and return the length of the
+     * replacement text.
+     *
+     * @param text the text to be matched
+     * @param start inclusive start index of text to be replaced
+     * @param limit exclusive end index of text to be replaced;
+     * must be greater than or equal to start
+     * @param cursor output parameter for the cursor position.
+     * Not all replacer objects will update this, but in a complete
+     * tree of replacer objects, representing the entire output side
+     * of a transliteration rule, at least one must update it.
+     * @return the number of 16-bit code units in the text replacing
+     * the characters at offsets start..(limit-1) in text
+     * @stable ICU 2.4
+     */
+    virtual int32_t replace(Replaceable& text,
+                            int32_t start,
+                            int32_t limit,
+                            int32_t& cursor) = 0;
+
+    /**
+     * Returns a string representation of this replacer.  If the
+     * result of calling this function is passed to the appropriate
+     * parser, typically TransliteratorParser, it will produce another
+     * replacer that is equal to this one.
+     * @param result the string to receive the pattern.  Previous
+     * contents will be deleted.
+     * @param escapeUnprintable if TRUE then convert unprintable
+     * character to their hex escape representations, \\uxxxx or
+     * \\Uxxxxxxxx.  Unprintable characters are defined by
+     * Utility.isUnprintable().
+     * @return a reference to 'result'.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeString& toReplacerPattern(UnicodeString& result,
+                                             UBool escapeUnprintable) const = 0;
+
+    /**
+     * Union the set of all characters that may output by this object
+     * into the given set.
+     * @param toUnionTo the set into which to union the output characters
+     * @stable ICU 2.4
+     */
+    virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const = 0;
+};
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uniset.h b/CoreFoundation/icu/unicode/uniset.h
new file mode 100644
index 0000000..7839661
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uniset.h
@@ -0,0 +1,1566 @@
+/*
+***************************************************************************
+* Copyright (C) 1999-2008, International Business Machines Corporation
+* and others. All Rights Reserved.
+***************************************************************************
+*   Date        Name        Description
+*   10/20/99    alan        Creation.
+***************************************************************************
+*/
+
+#ifndef UNICODESET_H
+#define UNICODESET_H
+
+#include "unicode/unifilt.h"
+#include "unicode/unistr.h"
+#include "unicode/uset.h"
+
+/**
+ * \file
+ * \brief C++ API: Unicode Set
+ */
+
+U_NAMESPACE_BEGIN
+
+class BMPSet;
+class ParsePosition;
+class SymbolTable;
+class UnicodeSetStringSpan;
+class UVector;
+class RuleCharacterIterator;
+
+/**
+ * A mutable set of Unicode characters and multicharacter strings.  Objects of this class
+ * represent <em>character classes</em> used in regular expressions.
+ * A character specifies a subset of Unicode code points.  Legal
+ * code points are U+0000 to U+10FFFF, inclusive.
+ *
+ * <p>The UnicodeSet class is not designed to be subclassed.
+ *
+ * <p><code>UnicodeSet</code> supports two APIs. The first is the
+ * <em>operand</em> API that allows the caller to modify the value of
+ * a <code>UnicodeSet</code> object. It conforms to Java 2's
+ * <code>java.util.Set</code> interface, although
+ * <code>UnicodeSet</code> does not actually implement that
+ * interface. All methods of <code>Set</code> are supported, with the
+ * modification that they take a character range or single character
+ * instead of an <code>Object</code>, and they take a
+ * <code>UnicodeSet</code> instead of a <code>Collection</code>.  The
+ * operand API may be thought of in terms of boolean logic: a boolean
+ * OR is implemented by <code>add</code>, a boolean AND is implemented
+ * by <code>retain</code>, a boolean XOR is implemented by
+ * <code>complement</code> taking an argument, and a boolean NOT is
+ * implemented by <code>complement</code> with no argument.  In terms
+ * of traditional set theory function names, <code>add</code> is a
+ * union, <code>retain</code> is an intersection, <code>remove</code>
+ * is an asymmetric difference, and <code>complement</code> with no
+ * argument is a set complement with respect to the superset range
+ * <code>MIN_VALUE-MAX_VALUE</code>
+ *
+ * <p>The second API is the
+ * <code>applyPattern()</code>/<code>toPattern()</code> API from the
+ * <code>java.text.Format</code>-derived classes.  Unlike the
+ * methods that add characters, add categories, and control the logic
+ * of the set, the method <code>applyPattern()</code> sets all
+ * attributes of a <code>UnicodeSet</code> at once, based on a
+ * string pattern.
+ *
+ * <p><b>Pattern syntax</b></p>
+ *
+ * Patterns are accepted by the constructors and the
+ * <code>applyPattern()</code> methods and returned by the
+ * <code>toPattern()</code> method.  These patterns follow a syntax
+ * similar to that employed by version 8 regular expression character
+ * classes.  Here are some simple examples:
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ *   <table>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="left"><code>[]</code></td>
+ *       <td valign="top">No characters</td>
+ *     </tr><tr align="top">
+ *       <td nowrap valign="top" align="left"><code>[a]</code></td>
+ *       <td valign="top">The character 'a'</td>
+ *     </tr><tr align="top">
+ *       <td nowrap valign="top" align="left"><code>[ae]</code></td>
+ *       <td valign="top">The characters 'a' and 'e'</td>
+ *     </tr>
+ *     <tr>
+ *       <td nowrap valign="top" align="left"><code>[a-e]</code></td>
+ *       <td valign="top">The characters 'a' through 'e' inclusive, in Unicode code
+ *       point order</td>
+ *     </tr>
+ *     <tr>
+ *       <td nowrap valign="top" align="left"><code>[\\u4E01]</code></td>
+ *       <td valign="top">The character U+4E01</td>
+ *     </tr>
+ *     <tr>
+ *       <td nowrap valign="top" align="left"><code>[a{ab}{ac}]</code></td>
+ *       <td valign="top">The character 'a' and the multicharacter strings &quot;ab&quot; and
+ *       &quot;ac&quot;</td>
+ *     </tr>
+ *     <tr>
+ *       <td nowrap valign="top" align="left"><code>[\\p{Lu}]</code></td>
+ *       <td valign="top">All characters in the general category Uppercase Letter</td>
+ *     </tr>
+ *   </table>
+ * \htmlonly</blockquote>\endhtmlonly
+ *
+ * Any character may be preceded by a backslash in order to remove any special
+ * meaning.  White space characters, as defined by UCharacter.isWhitespace(), are
+ * ignored, unless they are escaped.
+ *
+ * <p>Property patterns specify a set of characters having a certain
+ * property as defined by the Unicode standard.  Both the POSIX-like
+ * "[:Lu:]" and the Perl-like syntax "\\p{Lu}" are recognized.  For a
+ * complete list of supported property patterns, see the User's Guide
+ * for UnicodeSet at
+ * <a href="http://icu-project.org/userguide/unicodeSet.html">
+ * http://icu-project.org/userguide/unicodeSet.html</a>.
+ * Actual determination of property data is defined by the underlying
+ * Unicode database as implemented by UCharacter.
+ *
+ * <p>Patterns specify individual characters, ranges of characters, and
+ * Unicode property sets.  When elements are concatenated, they
+ * specify their union.  To complement a set, place a '^' immediately
+ * after the opening '['.  Property patterns are inverted by modifying
+ * their delimiters; "[:^foo]" and "\\P{foo}".  In any other location,
+ * '^' has no special meaning.
+ *
+ * <p>Ranges are indicated by placing two a '-' between two
+ * characters, as in "a-z".  This specifies the range of all
+ * characters from the left to the right, in Unicode order.  If the
+ * left character is greater than or equal to the
+ * right character it is a syntax error.  If a '-' occurs as the first
+ * character after the opening '[' or '[^', or if it occurs as the
+ * last character before the closing ']', then it is taken as a
+ * literal.  Thus "[a\-b]", "[-ab]", and "[ab-]" all indicate the same
+ * set of three characters, 'a', 'b', and '-'.
+ *
+ * <p>Sets may be intersected using the '&' operator or the asymmetric
+ * set difference may be taken using the '-' operator, for example,
+ * "[[:L:]&[\\u0000-\\u0FFF]]" indicates the set of all Unicode letters
+ * with values less than 4096.  Operators ('&' and '|') have equal
+ * precedence and bind left-to-right.  Thus
+ * "[[:L:]-[a-z]-[\\u0100-\\u01FF]]" is equivalent to
+ * "[[[:L:]-[a-z]]-[\\u0100-\\u01FF]]".  This only really matters for
+ * difference; intersection is commutative.
+ *
+ * <table>
+ * <tr valign=top><td nowrap><code>[a]</code><td>The set containing 'a'
+ * <tr valign=top><td nowrap><code>[a-z]</code><td>The set containing 'a'
+ * through 'z' and all letters in between, in Unicode order
+ * <tr valign=top><td nowrap><code>[^a-z]</code><td>The set containing
+ * all characters but 'a' through 'z',
+ * that is, U+0000 through 'a'-1 and 'z'+1 through U+10FFFF
+ * <tr valign=top><td nowrap><code>[[<em>pat1</em>][<em>pat2</em>]]</code>
+ * <td>The union of sets specified by <em>pat1</em> and <em>pat2</em>
+ * <tr valign=top><td nowrap><code>[[<em>pat1</em>]&[<em>pat2</em>]]</code>
+ * <td>The intersection of sets specified by <em>pat1</em> and <em>pat2</em>
+ * <tr valign=top><td nowrap><code>[[<em>pat1</em>]-[<em>pat2</em>]]</code>
+ * <td>The asymmetric difference of sets specified by <em>pat1</em> and
+ * <em>pat2</em>
+ * <tr valign=top><td nowrap><code>[:Lu:] or \\p{Lu}</code>
+ * <td>The set of characters having the specified
+ * Unicode property; in
+ * this case, Unicode uppercase letters
+ * <tr valign=top><td nowrap><code>[:^Lu:] or \\P{Lu}</code>
+ * <td>The set of characters <em>not</em> having the given
+ * Unicode property
+ * </table>
+ *
+ * <p><b>Warning</b>: you cannot add an empty string ("") to a UnicodeSet.</p>
+ *
+ * <p><b>Formal syntax</b></p>
+ *
+ * \htmlonly<blockquote>\endhtmlonly
+ *   <table>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="right"><code>pattern :=&nbsp; </code></td>
+ *       <td valign="top"><code>('[' '^'? item* ']') |
+ *       property</code></td>
+ *     </tr>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="right"><code>item :=&nbsp; </code></td>
+ *       <td valign="top"><code>char | (char '-' char) | pattern-expr<br>
+ *       </code></td>
+ *     </tr>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="right"><code>pattern-expr :=&nbsp; </code></td>
+ *       <td valign="top"><code>pattern | pattern-expr pattern |
+ *       pattern-expr op pattern<br>
+ *       </code></td>
+ *     </tr>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="right"><code>op :=&nbsp; </code></td>
+ *       <td valign="top"><code>'&amp;' | '-'<br>
+ *       </code></td>
+ *     </tr>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="right"><code>special :=&nbsp; </code></td>
+ *       <td valign="top"><code>'[' | ']' | '-'<br>
+ *       </code></td>
+ *     </tr>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="right"><code>char :=&nbsp; </code></td>
+ *       <td valign="top"><em>any character that is not</em><code> special<br>
+ *       | ('\' </code><em>any character</em><code>)<br>
+ *       | ('\\u' hex hex hex hex)<br>
+ *       </code></td>
+ *     </tr>
+ *     <tr align="top">
+ *       <td nowrap valign="top" align="right"><code>hex :=&nbsp; </code></td>
+ *       <td valign="top"><em>any character for which
+ *       </em><code>Character.digit(c, 16)</code><em>
+ *       returns a non-negative result</em></td>
+ *     </tr>
+ *     <tr>
+ *       <td nowrap valign="top" align="right"><code>property :=&nbsp; </code></td>
+ *       <td valign="top"><em>a Unicode property set pattern</em></td>
+ *     </tr>
+ *   </table>
+ *   <br>
+ *   <table border="1">
+ *     <tr>
+ *       <td>Legend: <table>
+ *         <tr>
+ *           <td nowrap valign="top"><code>a := b</code></td>
+ *           <td width="20" valign="top">&nbsp; </td>
+ *           <td valign="top"><code>a</code> may be replaced by <code>b</code> </td>
+ *         </tr>
+ *         <tr>
+ *           <td nowrap valign="top"><code>a?</code></td>
+ *           <td valign="top"></td>
+ *           <td valign="top">zero or one instance of <code>a</code><br>
+ *           </td>
+ *         </tr>
+ *         <tr>
+ *           <td nowrap valign="top"><code>a*</code></td>
+ *           <td valign="top"></td>
+ *           <td valign="top">one or more instances of <code>a</code><br>
+ *           </td>
+ *         </tr>
+ *         <tr>
+ *           <td nowrap valign="top"><code>a | b</code></td>
+ *           <td valign="top"></td>
+ *           <td valign="top">either <code>a</code> or <code>b</code><br>
+ *           </td>
+ *         </tr>
+ *         <tr>
+ *           <td nowrap valign="top"><code>'a'</code></td>
+ *           <td valign="top"></td>
+ *           <td valign="top">the literal string between the quotes </td>
+ *         </tr>
+ *       </table>
+ *       </td>
+ *     </tr>
+ *   </table>
+ * \htmlonly</blockquote>\endhtmlonly
+ * 
+ * <p>Note:
+ *  - Most UnicodeSet methods do not take a UErrorCode parameter because
+ *   there are usually very few opportunities for failure other than a shortage
+ *   of memory, error codes in low-level C++ string methods would be inconvenient,
+ *   and the error code as the last parameter (ICU convention) would prevent
+ *   the use of default parameter values.
+ *   Instead, such methods set the UnicodeSet into a "bogus" state
+ *   (see isBogus()) if an error occurs.
+ *
+ * @author Alan Liu
+ * @stable ICU 2.0
+ */
+class U_COMMON_API UnicodeSet : public UnicodeFilter {
+
+    int32_t len; // length of list used; 0 <= len <= capacity
+    int32_t capacity; // capacity of list
+    UChar32* list; // MUST be terminated with HIGH
+    BMPSet *bmpSet; // The set is frozen iff either bmpSet or stringSpan is not NULL.
+    UChar32* buffer; // internal buffer, may be NULL
+    int32_t bufferCapacity; // capacity of buffer
+    int32_t patLen;
+
+    /**
+     * The pattern representation of this set.  This may not be the
+     * most economical pattern.  It is the pattern supplied to
+     * applyPattern(), with variables substituted and whitespace
+     * removed.  For sets constructed without applyPattern(), or
+     * modified using the non-pattern API, this string will be empty,
+     * indicating that toPattern() must generate a pattern
+     * representation from the inversion list.
+     */
+    UChar *pat;
+    UVector* strings; // maintained in sorted order
+    UnicodeSetStringSpan *stringSpan;
+
+private:
+    enum { // constants
+        kIsBogus = 1       // This set is bogus (i.e. not valid)
+    };
+    uint8_t fFlags;         // Bit flag (see constants above)
+public:
+    /**
+     * Determine if this object contains a valid set.
+     * A bogus set has no value. It is different from an empty set.
+     * It can be used to indicate that no set value is available.
+     *
+     * @return TRUE if the set is valid, FALSE otherwise
+     * @see setToBogus()
+     * @draft ICU 4.0
+     */
+    inline UBool isBogus(void) const;
+    
+    /**
+     * Make this UnicodeSet object invalid.
+     * The string will test TRUE with isBogus().
+     *
+     * A bogus set has no value. It is different from an empty set.
+     * It can be used to indicate that no set value is available.
+     *
+     * This utility function is used throughout the UnicodeSet
+     * implementation to indicate that a UnicodeSet operation failed,
+     * and may be used in other functions,
+     * especially but not exclusively when such functions do not
+     * take a UErrorCode for simplicity.
+     *
+     * @see isBogus()
+     * @draft ICU 4.0
+     */
+    void setToBogus();
+
+public:
+
+    enum {
+        /**
+         * Minimum value that can be stored in a UnicodeSet.
+         * @stable ICU 2.4
+         */
+        MIN_VALUE = 0,
+
+        /**
+         * Maximum value that can be stored in a UnicodeSet.
+         * @stable ICU 2.4
+         */
+        MAX_VALUE = 0x10ffff
+    };
+
+    //----------------------------------------------------------------
+    // Constructors &c
+    //----------------------------------------------------------------
+
+public:
+
+    /**
+     * Constructs an empty set.
+     * @stable ICU 2.0
+     */
+    UnicodeSet();
+
+    /**
+     * Constructs a set containing the given range. If <code>end >
+     * start</code> then an empty set is created.
+     *
+     * @param start first character, inclusive, of range
+     * @param end last character, inclusive, of range
+     * @stable ICU 2.4
+     */
+    UnicodeSet(UChar32 start, UChar32 end);
+
+    /**
+     * Constructs a set from the given pattern.  See the class
+     * description for the syntax of the pattern language.
+     * @param pattern a string specifying what characters are in the set
+     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
+     * contains a syntax error.
+     * @stable ICU 2.0
+     */
+    UnicodeSet(const UnicodeString& pattern,
+               UErrorCode& status);
+
+    /**
+     * Constructs a set from the given pattern.  See the class
+     * description for the syntax of the pattern language.
+     * @param pattern a string specifying what characters are in the set
+     * @param options bitmask for options to apply to the pattern.
+     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
+     * @param symbols a symbol table mapping variable names to values
+     * and stand-in characters to UnicodeSets; may be NULL
+     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
+     * contains a syntax error.
+     * @internal
+     */
+    UnicodeSet(const UnicodeString& pattern,
+               uint32_t options,
+               const SymbolTable* symbols,
+               UErrorCode& status);
+
+    /**
+     * Constructs a set from the given pattern.  See the class description
+     * for the syntax of the pattern language.
+     * @param pattern a string specifying what characters are in the set
+     * @param pos on input, the position in pattern at which to start parsing.
+     * On output, the position after the last character parsed.
+     * @param options bitmask for options to apply to the pattern.
+     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
+     * @param symbols a symbol table mapping variable names to values
+     * and stand-in characters to UnicodeSets; may be NULL
+     * @param status input-output error code
+     * @stable ICU 2.8
+     */
+    UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
+               uint32_t options,
+               const SymbolTable* symbols,
+               UErrorCode& status);
+
+    /**
+     * Constructs a set that is identical to the given UnicodeSet.
+     * @stable ICU 2.0
+     */
+    UnicodeSet(const UnicodeSet& o);
+
+    /**
+     * Destructs the set.
+     * @stable ICU 2.0
+     */
+    virtual ~UnicodeSet();
+
+    /**
+     * Assigns this object to be a copy of another.
+     * A frozen set will not be modified.
+     * @stable ICU 2.0
+     */
+    UnicodeSet& operator=(const UnicodeSet& o);
+
+    /**
+     * Compares the specified object with this set for equality.  Returns
+     * <tt>true</tt> if the two sets
+     * have the same size, and every member of the specified set is
+     * contained in this set (or equivalently, every member of this set is
+     * contained in the specified set).
+     *
+     * @param o set to be compared for equality with this set.
+     * @return <tt>true</tt> if the specified set is equal to this set.
+     * @stable ICU 2.0
+     */
+    virtual UBool operator==(const UnicodeSet& o) const;
+
+    /**
+     * Compares the specified object with this set for equality.  Returns
+     * <tt>true</tt> if the specified set is not equal to this set.
+     * @stable ICU 2.0
+     */
+    UBool operator!=(const UnicodeSet& o) const;
+
+    /**
+     * Returns a copy of this object.  All UnicodeFunctor objects have
+     * to support cloning in order to allow classes using
+     * UnicodeFunctors, such as Transliterator, to implement cloning.
+     * If this set is frozen, then the clone will be frozen as well.
+     * Use cloneAsThawed() for a mutable clone of a frozen set.
+     * @see cloneAsThawed
+     * @stable ICU 2.0
+     */
+    virtual UnicodeFunctor* clone() const;
+
+    /**
+     * Returns the hash code value for this set.
+     *
+     * @return the hash code value for this set.
+     * @see Object#hashCode()
+     * @stable ICU 2.0
+     */
+    virtual int32_t hashCode(void) const;
+
+    //----------------------------------------------------------------
+    // Freezable API
+    //----------------------------------------------------------------
+
+    /**
+     * Determines whether the set has been frozen (made immutable) or not.
+     * See the ICU4J Freezable interface for details.
+     * @return TRUE/FALSE for whether the set has been frozen
+     * @see freeze
+     * @see cloneAsThawed
+     * @stable ICU 4.0
+     */
+    inline UBool isFrozen() const;
+
+    /**
+     * Freeze the set (make it immutable).
+     * Once frozen, it cannot be unfrozen and is therefore thread-safe
+     * until it is deleted.
+     * See the ICU4J Freezable interface for details.
+     * Freezing the set may also make some operations faster, for example
+     * contains() and span().
+     * A frozen set will not be modified. (It remains frozen.)
+     * @return this set.
+     * @see isFrozen
+     * @see cloneAsThawed
+     * @stable ICU 4.0
+     */
+    UnicodeFunctor *freeze();
+
+    /**
+     * Clone the set and make the clone mutable.
+     * See the ICU4J Freezable interface for details.
+     * @return the mutable clone
+     * @see freeze
+     * @see isFrozen
+     * @stable ICU 4.0
+     */
+    UnicodeFunctor *cloneAsThawed() const;
+
+    //----------------------------------------------------------------
+    // Public API
+    //----------------------------------------------------------------
+
+    /**
+     * Make this object represent the range <code>start - end</code>.
+     * If <code>end > start</code> then this object is set to an
+     * an empty range.
+     * A frozen set will not be modified.
+     *
+     * @param start first character in the set, inclusive
+     * @param end last character in the set, inclusive
+     * @stable ICU 2.4
+     */
+    UnicodeSet& set(UChar32 start, UChar32 end);
+
+    /**
+     * Return true if the given position, in the given pattern, appears
+     * to be the start of a UnicodeSet pattern.
+     * @stable ICU 2.4
+     */
+    static UBool resemblesPattern(const UnicodeString& pattern,
+                                  int32_t pos);
+
+    /**
+     * Modifies this set to represent the set specified by the given
+     * pattern, optionally ignoring white space.  See the class
+     * description for the syntax of the pattern language.
+     * A frozen set will not be modified.
+     * @param pattern a string specifying what characters are in the set
+     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
+     * contains a syntax error.
+     * <em> Empties the set passed before applying the pattern.</em>
+     * @return a reference to this
+     * @stable ICU 2.0
+     */
+    UnicodeSet& applyPattern(const UnicodeString& pattern,
+                             UErrorCode& status);
+
+    /**
+     * Modifies this set to represent the set specified by the given
+     * pattern, optionally ignoring white space.  See the class
+     * description for the syntax of the pattern language.
+     * A frozen set will not be modified.
+     * @param pattern a string specifying what characters are in the set
+     * @param options bitmask for options to apply to the pattern.
+     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
+     * @param symbols a symbol table mapping variable names to
+     * values and stand-ins to UnicodeSets; may be NULL
+     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
+     * contains a syntax error.
+     *<em> Empties the set passed before applying the pattern.</em>
+     * @return a reference to this
+     * @internal
+     */
+    UnicodeSet& applyPattern(const UnicodeString& pattern,
+                             uint32_t options,
+                             const SymbolTable* symbols,
+                             UErrorCode& status);
+
+    /**
+     * Parses the given pattern, starting at the given position.  The
+     * character at pattern.charAt(pos.getIndex()) must be '[', or the
+     * parse fails.  Parsing continues until the corresponding closing
+     * ']'.  If a syntax error is encountered between the opening and
+     * closing brace, the parse fails.  Upon return from a successful
+     * parse, the ParsePosition is updated to point to the character
+     * following the closing ']', and a StringBuffer containing a
+     * pairs list for the parsed pattern is returned.  This method calls
+     * itself recursively to parse embedded subpatterns.
+     *<em> Empties the set passed before applying the pattern.</em>
+     * A frozen set will not be modified.
+     *
+     * @param pattern the string containing the pattern to be parsed.
+     * The portion of the string from pos.getIndex(), which must be a
+     * '[', to the corresponding closing ']', is parsed.
+     * @param pos upon entry, the position at which to being parsing.
+     * The character at pattern.charAt(pos.getIndex()) must be a '['.
+     * Upon return from a successful parse, pos.getIndex() is either
+     * the character after the closing ']' of the parsed pattern, or
+     * pattern.length() if the closing ']' is the last character of
+     * the pattern string.
+     * @param options bitmask for options to apply to the pattern.
+     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
+     * @param symbols a symbol table mapping variable names to
+     * values and stand-ins to UnicodeSets; may be NULL
+     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern
+     * contains a syntax error.
+     * @return a reference to this
+     * @stable ICU 2.8
+     */
+    UnicodeSet& applyPattern(const UnicodeString& pattern,
+                             ParsePosition& pos,
+                             uint32_t options,
+                             const SymbolTable* symbols,
+                             UErrorCode& status);
+
+    /**
+     * Returns a string representation of this set.  If the result of
+     * calling this function is passed to a UnicodeSet constructor, it
+     * will produce another set that is equal to this one.
+     * A frozen set will not be modified.
+     * @param result the string to receive the rules.  Previous
+     * contents will be deleted.
+     * @param escapeUnprintable if TRUE then convert unprintable
+     * character to their hex escape representations, \\uxxxx or
+     * \\Uxxxxxxxx.  Unprintable characters are those other than
+     * U+000A, U+0020..U+007E.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeString& toPattern(UnicodeString& result,
+                             UBool escapeUnprintable = FALSE) const;
+
+    /**
+     * Modifies this set to contain those code points which have the given value
+     * for the given binary or enumerated property, as returned by
+     * u_getIntPropertyValue.  Prior contents of this set are lost.
+     * A frozen set will not be modified.
+     *
+     * @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1
+     * or UCHAR_INT_START..UCHAR_INT_LIMIT-1
+     * or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.
+     *
+     * @param value a value in the range u_getIntPropertyMinValue(prop)..
+     * u_getIntPropertyMaxValue(prop), with one exception.  If prop is
+     * UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but
+     * rather a mask value produced by U_GET_GC_MASK().  This allows grouped
+     * categories such as [:L:] to be represented.
+     *
+     * @param ec error code input/output parameter
+     *
+     * @return a reference to this set
+     *
+     * @stable ICU 2.4
+     */
+    UnicodeSet& applyIntPropertyValue(UProperty prop,
+                                      int32_t value,
+                                      UErrorCode& ec);
+
+    /**
+     * Modifies this set to contain those code points which have the
+     * given value for the given property.  Prior contents of this
+     * set are lost.
+     * A frozen set will not be modified.
+     *
+     * @param prop a property alias, either short or long.  The name is matched
+     * loosely.  See PropertyAliases.txt for names and a description of loose
+     * matching.  If the value string is empty, then this string is interpreted
+     * as either a General_Category value alias, a Script value alias, a binary
+     * property alias, or a special ID.  Special IDs are matched loosely and
+     * correspond to the following sets:
+     *
+     * "ANY" = [\\u0000-\\U0010FFFF],
+     * "ASCII" = [\\u0000-\\u007F],
+     * "Assigned" = [:^Cn:].
+     *
+     * @param value a value alias, either short or long.  The name is matched
+     * loosely.  See PropertyValueAliases.txt for names and a description of
+     * loose matching.  In addition to aliases listed, numeric values and
+     * canonical combining classes may be expressed numerically, e.g., ("nv",
+     * "0.5") or ("ccc", "220").  The value string may also be empty.
+     *
+     * @param ec error code input/output parameter
+     *
+     * @return a reference to this set
+     *
+     * @stable ICU 2.4
+     */
+    UnicodeSet& applyPropertyAlias(const UnicodeString& prop,
+                                   const UnicodeString& value,
+                                   UErrorCode& ec);
+
+    /**
+     * Returns the number of elements in this set (its cardinality).
+     * Note than the elements of a set may include both individual
+     * codepoints and strings.
+     *
+     * @return the number of elements in this set (its cardinality).
+     * @stable ICU 2.0
+     */
+    virtual int32_t size(void) const;
+
+    /**
+     * Returns <tt>true</tt> if this set contains no elements.
+     *
+     * @return <tt>true</tt> if this set contains no elements.
+     * @stable ICU 2.0
+     */
+    virtual UBool isEmpty(void) const;
+
+    /**
+     * Returns true if this set contains the given character.
+     * This function works faster with a frozen set.
+     * @param c character to be checked for containment
+     * @return true if the test condition is met
+     * @stable ICU 2.0
+     */
+    virtual UBool contains(UChar32 c) const;
+
+    /**
+     * Returns true if this set contains every character
+     * of the given range.
+     * @param start first character, inclusive, of the range
+     * @param end last character, inclusive, of the range
+     * @return true if the test condition is met
+     * @stable ICU 2.0
+     */
+    virtual UBool contains(UChar32 start, UChar32 end) const;
+
+    /**
+     * Returns <tt>true</tt> if this set contains the given
+     * multicharacter string.
+     * @param s string to be checked for containment
+     * @return <tt>true</tt> if this set contains the specified string
+     * @stable ICU 2.4
+     */
+    UBool contains(const UnicodeString& s) const;
+
+    /**
+     * Returns true if this set contains all the characters and strings
+     * of the given set.
+     * @param c set to be checked for containment
+     * @return true if the test condition is met
+     * @stable ICU 2.4
+     */
+    virtual UBool containsAll(const UnicodeSet& c) const;
+
+    /**
+     * Returns true if this set contains all the characters
+     * of the given string.
+     * @param s string containing characters to be checked for containment
+     * @return true if the test condition is met
+     * @stable ICU 2.4
+     */
+    UBool containsAll(const UnicodeString& s) const;
+
+    /**
+     * Returns true if this set contains none of the characters
+     * of the given range.
+     * @param start first character, inclusive, of the range
+     * @param end last character, inclusive, of the range
+     * @return true if the test condition is met
+     * @stable ICU 2.4
+     */
+    UBool containsNone(UChar32 start, UChar32 end) const;
+
+    /**
+     * Returns true if this set contains none of the characters and strings
+     * of the given set.
+     * @param c set to be checked for containment
+     * @return true if the test condition is met
+     * @stable ICU 2.4
+     */
+    UBool containsNone(const UnicodeSet& c) const;
+
+    /**
+     * Returns true if this set contains none of the characters
+     * of the given string.
+     * @param s string containing characters to be checked for containment
+     * @return true if the test condition is met
+     * @stable ICU 2.4
+     */
+    UBool containsNone(const UnicodeString& s) const;
+
+    /**
+     * Returns true if this set contains one or more of the characters
+     * in the given range.
+     * @param start first character, inclusive, of the range
+     * @param end last character, inclusive, of the range
+     * @return true if the condition is met
+     * @stable ICU 2.4
+     */
+    inline UBool containsSome(UChar32 start, UChar32 end) const;
+
+    /**
+     * Returns true if this set contains one or more of the characters
+     * and strings of the given set.
+     * @param s The set to be checked for containment
+     * @return true if the condition is met
+     * @stable ICU 2.4
+     */
+    inline UBool containsSome(const UnicodeSet& s) const;
+
+    /**
+     * Returns true if this set contains one or more of the characters
+     * of the given string.
+     * @param s string containing characters to be checked for containment
+     * @return true if the condition is met
+     * @stable ICU 2.4
+     */
+    inline UBool containsSome(const UnicodeString& s) const;
+
+    /**
+     * Returns the length of the initial substring of the input string which
+     * consists only of characters and strings that are contained in this set
+     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+     * or only of characters and strings that are not contained
+     * in this set (USET_SPAN_NOT_CONTAINED).
+     * See USetSpanCondition for details.
+     * Similar to the strspn() C library function.
+     * Unpaired surrogates are treated according to contains() of their surrogate code points.
+     * This function works faster with a frozen set and with a non-negative string length argument.
+     * @param s start of the string
+     * @param length of the string; can be -1 for NUL-terminated
+     * @param spanCondition specifies the containment condition
+     * @return the length of the initial substring according to the spanCondition;
+     *         0 if the start of the string does not fit the spanCondition
+     * @stable ICU 4.0
+     * @see USetSpanCondition
+     */
+    int32_t span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
+
+    /**
+     * Returns the start of the trailing substring of the input string which
+     * consists only of characters and strings that are contained in this set
+     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+     * or only of characters and strings that are not contained
+     * in this set (USET_SPAN_NOT_CONTAINED).
+     * See USetSpanCondition for details.
+     * Unpaired surrogates are treated according to contains() of their surrogate code points.
+     * This function works faster with a frozen set and with a non-negative string length argument.
+     * @param s start of the string
+     * @param length of the string; can be -1 for NUL-terminated
+     * @param spanCondition specifies the containment condition
+     * @return the start of the trailing substring according to the spanCondition;
+     *         the string length if the end of the string does not fit the spanCondition
+     * @stable ICU 4.0
+     * @see USetSpanCondition
+     */
+    int32_t spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;
+
+    /**
+     * Returns the length of the initial substring of the input string which
+     * consists only of characters and strings that are contained in this set
+     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+     * or only of characters and strings that are not contained
+     * in this set (USET_SPAN_NOT_CONTAINED).
+     * See USetSpanCondition for details.
+     * Similar to the strspn() C library function.
+     * Malformed byte sequences are treated according to contains(0xfffd).
+     * This function works faster with a frozen set and with a non-negative string length argument.
+     * @param s start of the string (UTF-8)
+     * @param length of the string; can be -1 for NUL-terminated
+     * @param spanCondition specifies the containment condition
+     * @return the length of the initial substring according to the spanCondition;
+     *         0 if the start of the string does not fit the spanCondition
+     * @stable ICU 4.0
+     * @see USetSpanCondition
+     */
+    int32_t spanUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
+
+    /**
+     * Returns the start of the trailing substring of the input string which
+     * consists only of characters and strings that are contained in this set
+     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+     * or only of characters and strings that are not contained
+     * in this set (USET_SPAN_NOT_CONTAINED).
+     * See USetSpanCondition for details.
+     * Malformed byte sequences are treated according to contains(0xfffd).
+     * This function works faster with a frozen set and with a non-negative string length argument.
+     * @param s start of the string (UTF-8)
+     * @param length of the string; can be -1 for NUL-terminated
+     * @param spanCondition specifies the containment condition
+     * @return the start of the trailing substring according to the spanCondition;
+     *         the string length if the end of the string does not fit the spanCondition
+     * @stable ICU 4.0
+     * @see USetSpanCondition
+     */
+    int32_t spanBackUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;
+
+    /**
+     * Implement UnicodeMatcher::matches()
+     * @stable ICU 2.4
+     */
+    virtual UMatchDegree matches(const Replaceable& text,
+                         int32_t& offset,
+                         int32_t limit,
+                         UBool incremental);
+
+private:
+    /**
+     * Returns the longest match for s in text at the given position.
+     * If limit > start then match forward from start+1 to limit
+     * matching all characters except s.charAt(0).  If limit < start,
+     * go backward starting from start-1 matching all characters
+     * except s.charAt(s.length()-1).  This method assumes that the
+     * first character, text.charAt(start), matches s, so it does not
+     * check it.
+     * @param text the text to match
+     * @param start the first character to match.  In the forward
+     * direction, text.charAt(start) is matched against s.charAt(0).
+     * In the reverse direction, it is matched against
+     * s.charAt(s.length()-1).
+     * @param limit the limit offset for matching, either last+1 in
+     * the forward direction, or last-1 in the reverse direction,
+     * where last is the index of the last character to match.
+     * @return If part of s matches up to the limit, return |limit -
+     * start|.  If all of s matches before reaching the limit, return
+     * s.length().  If there is a mismatch between s and text, return
+     * 0
+     */
+    static int32_t matchRest(const Replaceable& text,
+                             int32_t start, int32_t limit,
+                             const UnicodeString& s);
+
+    /**
+     * Returns the smallest value i such that c < list[i].  Caller
+     * must ensure that c is a legal value or this method will enter
+     * an infinite loop.  This method performs a binary search.
+     * @param c a character in the range MIN_VALUE..MAX_VALUE
+     * inclusive
+     * @return the smallest integer i in the range 0..len-1,
+     * inclusive, such that c < list[i]
+     */
+    int32_t findCodePoint(UChar32 c) const;
+
+public:
+
+    /**
+     * Implementation of UnicodeMatcher API.  Union the set of all
+     * characters that may be matched by this object into the given
+     * set.
+     * @param toUnionTo the set into which to union the source characters
+     * @stable ICU 2.4
+     */
+    virtual void addMatchSetTo(UnicodeSet& toUnionTo) const;
+
+    /**
+     * Returns the index of the given character within this set, where
+     * the set is ordered by ascending code point.  If the character
+     * is not in this set, return -1.  The inverse of this method is
+     * <code>charAt()</code>.
+     * @return an index from 0..size()-1, or -1
+     * @stable ICU 2.4
+     */
+    int32_t indexOf(UChar32 c) const;
+
+    /**
+     * Returns the character at the given index within this set, where
+     * the set is ordered by ascending code point.  If the index is
+     * out of range, return (UChar32)-1.  The inverse of this method is
+     * <code>indexOf()</code>.
+     * @param index an index from 0..size()-1
+     * @return the character at the given index, or (UChar32)-1.
+     * @stable ICU 2.4
+     */
+    UChar32 charAt(int32_t index) const;
+
+    /**
+     * Adds the specified range to this set if it is not already
+     * present.  If this set already contains the specified range,
+     * the call leaves this set unchanged.  If <code>end > start</code>
+     * then an empty range is added, leaving the set unchanged.
+     * This is equivalent to a boolean logic OR, or a set UNION.
+     * A frozen set will not be modified.
+     *
+     * @param start first character, inclusive, of range to be added
+     * to this set.
+     * @param end last character, inclusive, of range to be added
+     * to this set.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& add(UChar32 start, UChar32 end);
+
+    /**
+     * Adds the specified character to this set if it is not already
+     * present.  If this set already contains the specified character,
+     * the call leaves this set unchanged.
+     * A frozen set will not be modified.
+     * @stable ICU 2.0
+     */
+    UnicodeSet& add(UChar32 c);
+
+    /**
+     * Adds the specified multicharacter to this set if it is not already
+     * present.  If this set already contains the multicharacter,
+     * the call leaves this set unchanged.
+     * Thus "ch" => {"ch"}
+     * <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
+     * A frozen set will not be modified.
+     * @param s the source string
+     * @return this object, for chaining
+     * @stable ICU 2.4
+     */
+    UnicodeSet& add(const UnicodeString& s);
+
+ private:
+    /**
+     * @return a code point IF the string consists of a single one.
+     * otherwise returns -1.
+     * @param string to test
+     */
+    static int32_t getSingleCP(const UnicodeString& s);
+
+    void _add(const UnicodeString& s);
+
+ public:
+    /**
+     * Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}
+     * If this set already any particular character, it has no effect on that character.
+     * A frozen set will not be modified.
+     * @param s the source string
+     * @return this object, for chaining
+     * @stable ICU 2.4
+     */
+    UnicodeSet& addAll(const UnicodeString& s);
+
+    /**
+     * Retains EACH of the characters in this string. Note: "ch" == {"c", "h"}
+     * If this set already any particular character, it has no effect on that character.
+     * A frozen set will not be modified.
+     * @param s the source string
+     * @return this object, for chaining
+     * @stable ICU 2.4
+     */
+    UnicodeSet& retainAll(const UnicodeString& s);
+
+    /**
+     * Complement EACH of the characters in this string. Note: "ch" == {"c", "h"}
+     * If this set already any particular character, it has no effect on that character.
+     * A frozen set will not be modified.
+     * @param s the source string
+     * @return this object, for chaining
+     * @stable ICU 2.4
+     */
+    UnicodeSet& complementAll(const UnicodeString& s);
+
+    /**
+     * Remove EACH of the characters in this string. Note: "ch" == {"c", "h"}
+     * If this set already any particular character, it has no effect on that character.
+     * A frozen set will not be modified.
+     * @param s the source string
+     * @return this object, for chaining
+     * @stable ICU 2.4
+     */
+    UnicodeSet& removeAll(const UnicodeString& s);
+
+    /**
+     * Makes a set from a multicharacter string. Thus "ch" => {"ch"}
+     * <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
+     * @param s the source string
+     * @return a newly created set containing the given string.
+     * The caller owns the return object and is responsible for deleting it.
+     * @stable ICU 2.4
+     */
+    static UnicodeSet* U_EXPORT2 createFrom(const UnicodeString& s);
+
+
+    /**
+     * Makes a set from each of the characters in the string. Thus "ch" => {"c", "h"}
+     * @param s the source string
+     * @return a newly created set containing the given characters
+     * The caller owns the return object and is responsible for deleting it.
+     * @stable ICU 2.4
+     */
+    static UnicodeSet* U_EXPORT2 createFromAll(const UnicodeString& s);
+
+    /**
+     * Retain only the elements in this set that are contained in the
+     * specified range.  If <code>end > start</code> then an empty range is
+     * retained, leaving the set empty.  This is equivalent to
+     * a boolean logic AND, or a set INTERSECTION.
+     * A frozen set will not be modified.
+     *
+     * @param start first character, inclusive, of range to be retained
+     * to this set.
+     * @param end last character, inclusive, of range to be retained
+     * to this set.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& retain(UChar32 start, UChar32 end);
+
+
+    /**
+     * Retain the specified character from this set if it is present.
+     * A frozen set will not be modified.
+     * @stable ICU 2.0
+     */
+    UnicodeSet& retain(UChar32 c);
+
+    /**
+     * Removes the specified range from this set if it is present.
+     * The set will not contain the specified range once the call
+     * returns.  If <code>end > start</code> then an empty range is
+     * removed, leaving the set unchanged.
+     * A frozen set will not be modified.
+     *
+     * @param start first character, inclusive, of range to be removed
+     * from this set.
+     * @param end last character, inclusive, of range to be removed
+     * from this set.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& remove(UChar32 start, UChar32 end);
+
+    /**
+     * Removes the specified character from this set if it is present.
+     * The set will not contain the specified range once the call
+     * returns.
+     * A frozen set will not be modified.
+     * @stable ICU 2.0
+     */
+    UnicodeSet& remove(UChar32 c);
+
+    /**
+     * Removes the specified string from this set if it is present.
+     * The set will not contain the specified character once the call
+     * returns.
+     * A frozen set will not be modified.
+     * @param s the source string
+     * @return this object, for chaining
+     * @stable ICU 2.4
+     */
+    UnicodeSet& remove(const UnicodeString& s);
+
+    /**
+     * Inverts this set.  This operation modifies this set so that
+     * its value is its complement.  This is equivalent to
+     * <code>complement(MIN_VALUE, MAX_VALUE)</code>.
+     * A frozen set will not be modified.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& complement(void);
+
+    /**
+     * Complements the specified range in this set.  Any character in
+     * the range will be removed if it is in this set, or will be
+     * added if it is not in this set.  If <code>end > start</code>
+     * then an empty range is complemented, leaving the set unchanged.
+     * This is equivalent to a boolean logic XOR.
+     * A frozen set will not be modified.
+     *
+     * @param start first character, inclusive, of range to be removed
+     * from this set.
+     * @param end last character, inclusive, of range to be removed
+     * from this set.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& complement(UChar32 start, UChar32 end);
+
+    /**
+     * Complements the specified character in this set.  The character
+     * will be removed if it is in this set, or will be added if it is
+     * not in this set.
+     * A frozen set will not be modified.
+     * @stable ICU 2.0
+     */
+    UnicodeSet& complement(UChar32 c);
+
+    /**
+     * Complement the specified string in this set.
+     * The set will not contain the specified string once the call
+     * returns.
+     * <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
+     * A frozen set will not be modified.
+     * @param s the string to complement
+     * @return this object, for chaining
+     * @stable ICU 2.4
+     */
+    UnicodeSet& complement(const UnicodeString& s);
+
+    /**
+     * Adds all of the elements in the specified set to this set if
+     * they're not already present.  This operation effectively
+     * modifies this set so that its value is the <i>union</i> of the two
+     * sets.  The behavior of this operation is unspecified if the specified
+     * collection is modified while the operation is in progress.
+     * A frozen set will not be modified.
+     *
+     * @param c set whose elements are to be added to this set.
+     * @see #add(UChar32, UChar32)
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& addAll(const UnicodeSet& c);
+
+    /**
+     * Retains only the elements in this set that are contained in the
+     * specified set.  In other words, removes from this set all of
+     * its elements that are not contained in the specified set.  This
+     * operation effectively modifies this set so that its value is
+     * the <i>intersection</i> of the two sets.
+     * A frozen set will not be modified.
+     *
+     * @param c set that defines which elements this set will retain.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& retainAll(const UnicodeSet& c);
+
+    /**
+     * Removes from this set all of its elements that are contained in the
+     * specified set.  This operation effectively modifies this
+     * set so that its value is the <i>asymmetric set difference</i> of
+     * the two sets.
+     * A frozen set will not be modified.
+     *
+     * @param c set that defines which elements will be removed from
+     *          this set.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& removeAll(const UnicodeSet& c);
+
+    /**
+     * Complements in this set all elements contained in the specified
+     * set.  Any character in the other set will be removed if it is
+     * in this set, or will be added if it is not in this set.
+     * A frozen set will not be modified.
+     *
+     * @param c set that defines which elements will be xor'ed from
+     *          this set.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeSet& complementAll(const UnicodeSet& c);
+
+    /**
+     * Removes all of the elements from this set.  This set will be
+     * empty after this call returns.
+     * A frozen set will not be modified.
+     * @stable ICU 2.0
+     */
+    virtual UnicodeSet& clear(void);
+
+    /**
+     * Close this set over the given attribute.  For the attribute
+     * USET_CASE, the result is to modify this set so that:
+     *
+     * 1. For each character or string 'a' in this set, all strings or
+     * characters 'b' such that foldCase(a) == foldCase(b) are added
+     * to this set.
+     *
+     * 2. For each string 'e' in the resulting set, if e !=
+     * foldCase(e), 'e' will be removed.
+     *
+     * Example: [aq\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\u00DF\\uFB01{ss}{bc}{fi}]
+     *
+     * (Here foldCase(x) refers to the operation u_strFoldCase, and a
+     * == b denotes that the contents are the same, not pointer
+     * comparison.)
+     *
+     * A frozen set will not be modified.
+     *
+     * @param attribute bitmask for attributes to close over.
+     * Currently only the USET_CASE bit is supported.  Any undefined bits
+     * are ignored.
+     * @return a reference to this set.
+     * @internal
+     */
+    UnicodeSet& closeOver(int32_t attribute);
+
+    /**
+     * Remove all strings from this set.
+     *
+     * @return a reference to this set.
+     * @internal
+     */
+    virtual UnicodeSet &removeAllStrings();
+
+    /**
+     * Iteration method that returns the number of ranges contained in
+     * this set.
+     * @see #getRangeStart
+     * @see #getRangeEnd
+     * @stable ICU 2.4
+     */
+    virtual int32_t getRangeCount(void) const;
+
+    /**
+     * Iteration method that returns the first character in the
+     * specified range of this set.
+     * @see #getRangeCount
+     * @see #getRangeEnd
+     * @stable ICU 2.4
+     */
+    virtual UChar32 getRangeStart(int32_t index) const;
+
+    /**
+     * Iteration method that returns the last character in the
+     * specified range of this set.
+     * @see #getRangeStart
+     * @see #getRangeEnd
+     * @stable ICU 2.4
+     */
+    virtual UChar32 getRangeEnd(int32_t index) const;
+
+    /**
+     * Serializes this set into an array of 16-bit integers.  Serialization
+     * (currently) only records the characters in the set; multicharacter
+     * strings are ignored.
+     *
+     * The array has following format (each line is one 16-bit
+     * integer):
+     *
+     *  length     = (n+2*m) | (m!=0?0x8000:0)
+     *  bmpLength  = n; present if m!=0
+     *  bmp[0]
+     *  bmp[1]
+     *  ...
+     *  bmp[n-1]
+     *  supp-high[0]
+     *  supp-low[0]
+     *  supp-high[1]
+     *  supp-low[1]
+     *  ...
+     *  supp-high[m-1]
+     *  supp-low[m-1]
+     *
+     * The array starts with a header.  After the header are n bmp
+     * code points, then m supplementary code points.  Either n or m
+     * or both may be zero.  n+2*m is always <= 0x7FFF.
+     *
+     * If there are no supplementary characters (if m==0) then the
+     * header is one 16-bit integer, 'length', with value n.
+     *
+     * If there are supplementary characters (if m!=0) then the header
+     * is two 16-bit integers.  The first, 'length', has value
+     * (n+2*m)|0x8000.  The second, 'bmpLength', has value n.
+     *
+     * After the header the code points are stored in ascending order.
+     * Supplementary code points are stored as most significant 16
+     * bits followed by least significant 16 bits.
+     *
+     * @param dest pointer to buffer of destCapacity 16-bit integers.
+     * May be NULL only if destCapacity is zero.
+     * @param destCapacity size of dest, or zero.  Must not be negative.
+     * @param ec error code.  Will be set to U_INDEX_OUTOFBOUNDS_ERROR
+     * if n+2*m > 0x7FFF.  Will be set to U_BUFFER_OVERFLOW_ERROR if
+     * n+2*m+(m!=0?2:1) > destCapacity.
+     * @return the total length of the serialized format, including
+     * the header, that is, n+2*m+(m!=0?2:1), or 0 on error other
+     * than U_BUFFER_OVERFLOW_ERROR.
+     * @stable ICU 2.4
+     */
+    int32_t serialize(uint16_t *dest, int32_t destCapacity, UErrorCode& ec) const;
+
+    /**
+     * Reallocate this objects internal structures to take up the least
+     * possible space, without changing this object's value.
+     * A frozen set will not be modified.
+     * @stable ICU 2.4
+     */
+    virtual UnicodeSet& compact();
+
+    /**
+     * Return the class ID for this class.  This is useful only for
+     * comparing to a return value from getDynamicClassID().  For example:
+     * <pre>
+     * .      Base* polymorphic_pointer = createPolymorphicObject();
+     * .      if (polymorphic_pointer->getDynamicClassID() ==
+     * .          Derived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 2.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Implement UnicodeFunctor API.
+     *
+     * @return The class ID for this object. All objects of a given
+     * class have the same class ID.  Objects of other classes have
+     * different class IDs.
+     * @stable ICU 2.4
+     */
+    virtual UClassID getDynamicClassID(void) const;
+
+private:
+
+    // Private API for the USet API
+
+    friend class USetAccess;
+
+    int32_t getStringCount() const;
+
+    const UnicodeString* getString(int32_t index) const;
+
+    //----------------------------------------------------------------
+    // RuleBasedTransliterator support
+    //----------------------------------------------------------------
+
+private:
+
+    /**
+     * Returns <tt>true</tt> if this set contains any character whose low byte
+     * is the given value.  This is used by <tt>RuleBasedTransliterator</tt> for
+     * indexing.
+     */
+    virtual UBool matchesIndexValue(uint8_t v) const;
+
+private:
+
+    //----------------------------------------------------------------
+    // Implementation: Clone as thawed (see ICU4J Freezable)
+    //----------------------------------------------------------------
+
+    UnicodeSet(const UnicodeSet& o, UBool /* asThawed */);
+
+    //----------------------------------------------------------------
+    // Implementation: Pattern parsing
+    //----------------------------------------------------------------
+
+    void applyPattern(RuleCharacterIterator& chars,
+                      const SymbolTable* symbols,
+                      UnicodeString& rebuiltPat,
+                      uint32_t options,
+                      UErrorCode& ec);
+
+    //----------------------------------------------------------------
+    // Implementation: Utility methods
+    //----------------------------------------------------------------
+
+    void ensureCapacity(int32_t newLen, UErrorCode& ec);
+
+    void ensureBufferCapacity(int32_t newLen, UErrorCode& ec);
+
+    void swapBuffers(void);
+
+    UBool allocateStrings(UErrorCode &status);
+
+    UnicodeString& _toPattern(UnicodeString& result,
+                              UBool escapeUnprintable) const;
+
+    UnicodeString& _generatePattern(UnicodeString& result,
+                                    UBool escapeUnprintable) const;
+
+    static void _appendToPat(UnicodeString& buf, const UnicodeString& s, UBool escapeUnprintable);
+
+    static void _appendToPat(UnicodeString& buf, UChar32 c, UBool escapeUnprintable);
+
+    //----------------------------------------------------------------
+    // Implementation: Fundamental operators
+    //----------------------------------------------------------------
+
+    void exclusiveOr(const UChar32* other, int32_t otherLen, int8_t polarity);
+
+    void add(const UChar32* other, int32_t otherLen, int8_t polarity);
+
+    void retain(const UChar32* other, int32_t otherLen, int8_t polarity);
+
+    /**
+     * Return true if the given position, in the given pattern, appears
+     * to be the start of a property set pattern [:foo:], \\p{foo}, or
+     * \\P{foo}, or \\N{name}.
+     */
+    static UBool resemblesPropertyPattern(const UnicodeString& pattern,
+                                          int32_t pos);
+
+    static UBool resemblesPropertyPattern(RuleCharacterIterator& chars,
+                                          int32_t iterOpts);
+
+    /**
+     * Parse the given property pattern at the given parse position
+     * and set this UnicodeSet to the result.
+     *
+     * The original design document is out of date, but still useful.
+     * Ignore the property and value names:
+     * http://source.icu-project.org/repos/icu/icuhtml/trunk/design/unicodeset_properties.html
+     *
+     * Recognized syntax:
+     *
+     * [:foo:] [:^foo:] - white space not allowed within "[:" or ":]"
+     * \\p{foo} \\P{foo}  - white space not allowed within "\\p" or "\\P"
+     * \\N{name}         - white space not allowed within "\\N"
+     *
+     * Other than the above restrictions, white space is ignored.  Case
+     * is ignored except in "\\p" and "\\P" and "\\N".  In 'name' leading
+     * and trailing space is deleted, and internal runs of whitespace
+     * are collapsed to a single space.
+     *
+     * We support binary properties, enumerated properties, and the
+     * following non-enumerated properties:
+     *
+     *  Numeric_Value
+     *  Name
+     *  Unicode_1_Name
+     *
+     * @param pattern the pattern string
+     * @param ppos on entry, the position at which to begin parsing.
+     * This should be one of the locations marked '^':
+     *
+     *   [:blah:]     \\p{blah}     \\P{blah}     \\N{name}
+     *   ^       %    ^       %    ^       %    ^       %
+     *
+     * On return, the position after the last character parsed, that is,
+     * the locations marked '%'.  If the parse fails, ppos is returned
+     * unchanged.
+     * @return a reference to this.
+     */
+    UnicodeSet& applyPropertyPattern(const UnicodeString& pattern,
+                                     ParsePosition& ppos,
+                                     UErrorCode &ec);
+
+    void applyPropertyPattern(RuleCharacterIterator& chars,
+                              UnicodeString& rebuiltPat,
+                              UErrorCode& ec);
+
+    static const UnicodeSet* getInclusions(int32_t src, UErrorCode &status);
+
+    /**
+     * A filter that returns TRUE if the given code point should be
+     * included in the UnicodeSet being constructed.
+     */
+    typedef UBool (*Filter)(UChar32 codePoint, void* context);
+
+    /**
+     * Given a filter, set this UnicodeSet to the code points
+     * contained by that filter.  The filter MUST be
+     * property-conformant.  That is, if it returns value v for one
+     * code point, then it must return v for all affiliated code
+     * points, as defined by the inclusions list.  See
+     * getInclusions().
+     * src is a UPropertySource value.
+     */
+    void applyFilter(Filter filter,
+                     void* context,
+                     int32_t src,
+                     UErrorCode &status);
+
+    /**
+     * Set the new pattern to cache.
+     */
+    void setPattern(const UnicodeString& newPat);
+    /**
+     * Release existing cached pattern.
+     */
+    void releasePattern();
+
+    friend class UnicodeSetIterator;
+};
+
+inline UBool UnicodeSet::operator!=(const UnicodeSet& o) const {
+    return !operator==(o);
+}
+
+inline UBool UnicodeSet::isFrozen() const {
+    return (UBool)(bmpSet!=NULL || stringSpan!=NULL);
+}
+
+inline UBool UnicodeSet::containsSome(UChar32 start, UChar32 end) const {
+    return !containsNone(start, end);
+}
+
+inline UBool UnicodeSet::containsSome(const UnicodeSet& s) const {
+    return !containsNone(s);
+}
+
+inline UBool UnicodeSet::containsSome(const UnicodeString& s) const {
+    return !containsNone(s);
+}
+
+inline UBool UnicodeSet::isBogus() const {
+    return (UBool)(fFlags & kIsBogus);
+}
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/unistr.h b/CoreFoundation/icu/unicode/unistr.h
new file mode 100644
index 0000000..880f98e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/unistr.h
@@ -0,0 +1,4230 @@
+/*
+**********************************************************************
+*   Copyright (C) 1998-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File unistr.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   09/25/98    stephen     Creation.
+*   11/11/98    stephen     Changed per 11/9 code review.
+*   04/20/99    stephen     Overhauled per 4/16 code review.
+*   11/18/99    aliu        Made to inherit from Replaceable.  Added method
+*                           handleReplaceBetween(); other methods unchanged.
+*   06/25/01    grhoten     Remove dependency on iostream.
+******************************************************************************
+*/
+
+#ifndef UNISTR_H
+#define UNISTR_H
+
+/**
+ * \file 
+ * \brief C++ API: Unicode String 
+ */
+
+#include "unicode/rep.h"
+
+struct UConverter;          // unicode/ucnv.h
+class  StringThreadTest;
+
+#ifndef U_COMPARE_CODE_POINT_ORDER
+/* see also ustring.h and unorm.h */
+/**
+ * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:
+ * Compare strings in code point order instead of code unit order.
+ * @stable ICU 2.2
+ */
+#define U_COMPARE_CODE_POINT_ORDER  0x8000
+#endif
+
+#ifndef USTRING_H
+/**
+ * \ingroup ustring_ustrlen
+ */
+U_STABLE int32_t U_EXPORT2
+u_strlen(const UChar *s);
+#endif
+
+U_NAMESPACE_BEGIN
+
+class Locale;               // unicode/locid.h
+class StringCharacterIterator;
+class BreakIterator;        // unicode/brkiter.h
+
+/* The <iostream> include has been moved to unicode/ustream.h */
+
+/**
+ * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
+ * which constructs a Unicode string from an invariant-character char * string.
+ * About invariant characters see utypes.h.
+ * This constructor has no runtime dependency on conversion code and is
+ * therefore recommended over ones taking a charset name string
+ * (where the empty string "" indicates invariant-character conversion).
+ *
+ * @stable ICU 3.2
+ */
+#define US_INV U_NAMESPACE_QUALIFIER UnicodeString::kInvariant
+
+/**
+ * Unicode String literals in C++.
+ * Dependent on the platform properties, different UnicodeString
+ * constructors should be used to create a UnicodeString object from
+ * a string literal.
+ * The macros are defined for maximum performance.
+ * They work only for strings that contain "invariant characters", i.e.,
+ * only latin letters, digits, and some punctuation.
+ * See utypes.h for details.
+ *
+ * The string parameter must be a C string literal.
+ * The length of the string, not including the terminating
+ * <code>NUL</code>, must be specified as a constant.
+ * The U_STRING_DECL macro should be invoked exactly once for one
+ * such string variable before it is used.
+ * @stable ICU 2.0
+ */
+#if defined(U_DECLARE_UTF16)
+#   define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length)
+#elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
+#   define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)L ## cs, _length)
+#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
+#   define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(TRUE, (const UChar *)cs, _length)
+#else
+#   define UNICODE_STRING(cs, _length) U_NAMESPACE_QUALIFIER UnicodeString(cs, _length, US_INV)
+#endif
+
+/**
+ * Unicode String literals in C++.
+ * Dependent on the platform properties, different UnicodeString
+ * constructors should be used to create a UnicodeString object from
+ * a string literal.
+ * The macros are defined for improved performance.
+ * They work only for strings that contain "invariant characters", i.e.,
+ * only latin letters, digits, and some punctuation.
+ * See utypes.h for details.
+ *
+ * The string parameter must be a C string literal.
+ * @stable ICU 2.0
+ */
+#define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
+
+/**
+ * UnicodeString is a string class that stores Unicode characters directly and provides
+ * similar functionality as the Java String and StringBuffer classes.
+ * It is a concrete implementation of the abstract class Replaceable (for transliteration).
+ *
+ * The UnicodeString class is not suitable for subclassing.
+ *
+ * <p>For an overview of Unicode strings in C and C++ see the
+ * <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p>
+ *
+ * <p>In ICU, a Unicode string consists of 16-bit Unicode <em>code units</em>.
+ * A Unicode character may be stored with either one code unit
+ * (the most common case) or with a matched pair of special code units
+ * ("surrogates"). The data type for code units is UChar. 
+ * For single-character handling, a Unicode character code <em>point</em> is a value
+ * in the range 0..0x10ffff. ICU uses the UChar32 type for code points.</p>
+ *
+ * <p>Indexes and offsets into and lengths of strings always count code units, not code points.
+ * This is the same as with multi-byte char* strings in traditional string handling.
+ * Operations on partial strings typically do not test for code point boundaries.
+ * If necessary, the user needs to take care of such boundaries by testing for the code unit
+ * values or by using functions like
+ * UnicodeString::getChar32Start() and UnicodeString::getChar32Limit()
+ * (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h).</p>
+ *
+ * UnicodeString methods are more lenient with regard to input parameter values
+ * than other ICU APIs. In particular:
+ * - If indexes are out of bounds for a UnicodeString object
+ *   (<0 or >length()) then they are "pinned" to the nearest boundary.
+ * - If primitive string pointer values (e.g., const UChar * or char *)
+ *   for input strings are NULL, then those input string parameters are treated
+ *   as if they pointed to an empty string.
+ *   However, this is <em>not</em> the case for char * parameters for charset names
+ *   or other IDs.
+ * - Most UnicodeString methods do not take a UErrorCode parameter because
+ *   there are usually very few opportunities for failure other than a shortage
+ *   of memory, error codes in low-level C++ string methods would be inconvenient,
+ *   and the error code as the last parameter (ICU convention) would prevent
+ *   the use of default parameter values.
+ *   Instead, such methods set the UnicodeString into a "bogus" state
+ *   (see isBogus()) if an error occurs.
+ *
+ * In string comparisons, two UnicodeString objects that are both "bogus"
+ * compare equal (to be transitive and prevent endless loops in sorting),
+ * and a "bogus" string compares less than any non-"bogus" one.
+ *
+ * Const UnicodeString methods are thread-safe. Multiple threads can use
+ * const methods on the same UnicodeString object simultaneously,
+ * but non-const methods must not be called concurrently (in multiple threads)
+ * with any other (const or non-const) methods.
+ *
+ * Similarly, const UnicodeString & parameters are thread-safe.
+ * One object may be passed in as such a parameter concurrently in multiple threads.
+ * This includes the const UnicodeString & parameters for
+ * copy construction, assignment, and cloning.
+ *
+ * <p>UnicodeString uses several storage methods.
+ * String contents can be stored inside the UnicodeString object itself,
+ * in an allocated and shared buffer, or in an outside buffer that is "aliased".
+ * Most of this is done transparently, but careful aliasing in particular provides
+ * significant performance improvements.
+ * Also, the internal buffer is accessible via special functions.
+ * For details see the
+ * <a href="http://icu-project.org/userguide/strings.html">User Guide Strings chapter</a>.</p>
+ *
+ * @see utf.h
+ * @see CharacterIterator
+ * @stable ICU 2.0
+ */
+class U_COMMON_API UnicodeString : public Replaceable
+{
+public:
+
+  /**
+   * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor
+   * which constructs a Unicode string from an invariant-character char * string.
+   * Use the macro US_INV instead of the full qualification for this value.
+   *
+   * @see US_INV
+   * @stable ICU 3.2
+   */
+  enum EInvariant {
+    /**
+     * @see EInvariant
+     * @stable ICU 3.2
+     */
+    kInvariant
+  };
+
+  //========================================
+  // Read-only operations
+  //========================================
+
+  /* Comparison - bitwise only - for international comparison use collation */
+
+  /**
+   * Equality operator. Performs only bitwise comparison.
+   * @param text The UnicodeString to compare to this one.
+   * @return TRUE if <TT>text</TT> contains the same characters as this one,
+   * FALSE otherwise.
+   * @stable ICU 2.0
+   */
+  inline UBool operator== (const UnicodeString& text) const;
+
+  /**
+   * Inequality operator. Performs only bitwise comparison.
+   * @param text The UnicodeString to compare to this one.
+   * @return FALSE if <TT>text</TT> contains the same characters as this one,
+   * TRUE otherwise.
+   * @stable ICU 2.0
+   */
+  inline UBool operator!= (const UnicodeString& text) const;
+
+  /**
+   * Greater than operator. Performs only bitwise comparison.
+   * @param text The UnicodeString to compare to this one.
+   * @return TRUE if the characters in this are bitwise
+   * greater than the characters in <code>text</code>, FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool operator> (const UnicodeString& text) const;
+
+  /**
+   * Less than operator. Performs only bitwise comparison.
+   * @param text The UnicodeString to compare to this one.
+   * @return TRUE if the characters in this are bitwise
+   * less than the characters in <code>text</code>, FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool operator< (const UnicodeString& text) const;
+
+  /**
+   * Greater than or equal operator. Performs only bitwise comparison.
+   * @param text The UnicodeString to compare to this one.
+   * @return TRUE if the characters in this are bitwise
+   * greater than or equal to the characters in <code>text</code>, FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool operator>= (const UnicodeString& text) const;
+
+  /**
+   * Less than or equal operator. Performs only bitwise comparison.
+   * @param text The UnicodeString to compare to this one.
+   * @return TRUE if the characters in this are bitwise
+   * less than or equal to the characters in <code>text</code>, FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool operator<= (const UnicodeString& text) const;
+
+  /**
+   * Compare the characters bitwise in this UnicodeString to
+   * the characters in <code>text</code>.
+   * @param text The UnicodeString to compare to this one.
+   * @return The result of bitwise character comparison: 0 if this
+   * contains the same characters as <code>text</code>, -1 if the characters in
+   * this are bitwise less than the characters in <code>text</code>, +1 if the
+   * characters in this are bitwise greater than the characters
+   * in <code>text</code>.
+   * @stable ICU 2.0
+   */
+  inline int8_t compare(const UnicodeString& text) const;
+
+  /**
+   * Compare the characters bitwise in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the characters
+   * in <TT>text</TT>
+   * @param start the offset at which the compare operation begins
+   * @param length the number of characters of text to compare.
+   * @param text the other text to be compared against this string.
+   * @return The result of bitwise character comparison: 0 if this
+   * contains the same characters as <code>text</code>, -1 if the characters in
+   * this are bitwise less than the characters in <code>text</code>, +1 if the
+   * characters in this are bitwise greater than the characters
+   * in <code>text</code>.
+   * @stable ICU 2.0
+   */
+  inline int8_t compare(int32_t start,
+         int32_t length,
+         const UnicodeString& text) const;
+
+  /**
+   * Compare the characters bitwise in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the characters
+   * in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * @param start the offset at which the compare operation begins
+   * @param length the number of characters in this to compare.
+   * @param srcText the text to be compared
+   * @param srcStart the offset into <TT>srcText</TT> to start comparison
+   * @param srcLength the number of characters in <TT>src</TT> to compare
+   * @return The result of bitwise character comparison: 0 if this
+   * contains the same characters as <code>srcText</code>, -1 if the characters in
+   * this are bitwise less than the characters in <code>srcText</code>, +1 if the
+   * characters in this are bitwise greater than the characters
+   * in <code>srcText</code>.
+   * @stable ICU 2.0
+   */
+   inline int8_t compare(int32_t start,
+         int32_t length,
+         const UnicodeString& srcText,
+         int32_t srcStart,
+         int32_t srcLength) const;
+
+  /**
+   * Compare the characters bitwise in this UnicodeString with the first
+   * <TT>srcLength</TT> characters in <TT>srcChars</TT>.
+   * @param srcChars The characters to compare to this UnicodeString.
+   * @param srcLength the number of characters in <TT>srcChars</TT> to compare
+   * @return The result of bitwise character comparison: 0 if this
+   * contains the same characters as <code>srcChars</code>, -1 if the characters in
+   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
+   * characters in this are bitwise greater than the characters
+   * in <code>srcChars</code>.
+   * @stable ICU 2.0
+   */
+  inline int8_t compare(const UChar *srcChars,
+         int32_t srcLength) const;
+
+  /**
+   * Compare the characters bitwise in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the first
+   * <TT>length</TT> characters in <TT>srcChars</TT>
+   * @param start the offset at which the compare operation begins
+   * @param length the number of characters to compare.
+   * @param srcChars the characters to be compared
+   * @return The result of bitwise character comparison: 0 if this
+   * contains the same characters as <code>srcChars</code>, -1 if the characters in
+   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
+   * characters in this are bitwise greater than the characters
+   * in <code>srcChars</code>.
+   * @stable ICU 2.0
+   */
+  inline int8_t compare(int32_t start,
+         int32_t length,
+         const UChar *srcChars) const;
+
+  /**
+   * Compare the characters bitwise in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the characters
+   * in <TT>srcChars</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * @param start the offset at which the compare operation begins
+   * @param length the number of characters in this to compare
+   * @param srcChars the characters to be compared
+   * @param srcStart the offset into <TT>srcChars</TT> to start comparison
+   * @param srcLength the number of characters in <TT>srcChars</TT> to compare
+   * @return The result of bitwise character comparison: 0 if this
+   * contains the same characters as <code>srcChars</code>, -1 if the characters in
+   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the
+   * characters in this are bitwise greater than the characters
+   * in <code>srcChars</code>.
+   * @stable ICU 2.0
+   */
+  inline int8_t compare(int32_t start,
+         int32_t length,
+         const UChar *srcChars,
+         int32_t srcStart,
+         int32_t srcLength) const;
+
+  /**
+   * Compare the characters bitwise in the range
+   * [<TT>start</TT>, <TT>limit</TT>) with the characters
+   * in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcLimit</TT>).
+   * @param start the offset at which the compare operation begins
+   * @param limit the offset immediately following the compare operation
+   * @param srcText the text to be compared
+   * @param srcStart the offset into <TT>srcText</TT> to start comparison
+   * @param srcLimit the offset into <TT>srcText</TT> to limit comparison
+   * @return The result of bitwise character comparison: 0 if this
+   * contains the same characters as <code>srcText</code>, -1 if the characters in
+   * this are bitwise less than the characters in <code>srcText</code>, +1 if the
+   * characters in this are bitwise greater than the characters
+   * in <code>srcText</code>.
+   * @stable ICU 2.0
+   */
+  inline int8_t compareBetween(int32_t start,
+            int32_t limit,
+            const UnicodeString& srcText,
+            int32_t srcStart,
+            int32_t srcLimit) const;
+
+  /**
+   * Compare two Unicode strings in code point order.
+   * The result may be different from the results of compare(), operator<, etc.
+   * if supplementary characters are present:
+   *
+   * In UTF-16, supplementary characters (with code points U+10000 and above) are
+   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
+   * which means that they compare as less than some other BMP characters like U+feff.
+   * This function compares Unicode strings in code point order.
+   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
+   *
+   * @param text Another string to compare this one to.
+   * @return a negative/zero/positive integer corresponding to whether
+   * this string is less than/equal to/greater than the second one
+   * in code point order
+   * @stable ICU 2.0
+   */
+  inline int8_t compareCodePointOrder(const UnicodeString& text) const;
+
+  /**
+   * Compare two Unicode strings in code point order.
+   * The result may be different from the results of compare(), operator<, etc.
+   * if supplementary characters are present:
+   *
+   * In UTF-16, supplementary characters (with code points U+10000 and above) are
+   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
+   * which means that they compare as less than some other BMP characters like U+feff.
+   * This function compares Unicode strings in code point order.
+   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcText Another string to compare this one to.
+   * @return a negative/zero/positive integer corresponding to whether
+   * this string is less than/equal to/greater than the second one
+   * in code point order
+   * @stable ICU 2.0
+   */
+  inline int8_t compareCodePointOrder(int32_t start,
+                                      int32_t length,
+                                      const UnicodeString& srcText) const;
+
+  /**
+   * Compare two Unicode strings in code point order.
+   * The result may be different from the results of compare(), operator<, etc.
+   * if supplementary characters are present:
+   *
+   * In UTF-16, supplementary characters (with code points U+10000 and above) are
+   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
+   * which means that they compare as less than some other BMP characters like U+feff.
+   * This function compares Unicode strings in code point order.
+   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcText Another string to compare this one to.
+   * @param srcStart The start offset in that string at which the compare operation begins.
+   * @param srcLength The number of code units from that string to compare.
+   * @return a negative/zero/positive integer corresponding to whether
+   * this string is less than/equal to/greater than the second one
+   * in code point order
+   * @stable ICU 2.0
+   */
+   inline int8_t compareCodePointOrder(int32_t start,
+                                       int32_t length,
+                                       const UnicodeString& srcText,
+                                       int32_t srcStart,
+                                       int32_t srcLength) const;
+
+  /**
+   * Compare two Unicode strings in code point order.
+   * The result may be different from the results of compare(), operator<, etc.
+   * if supplementary characters are present:
+   *
+   * In UTF-16, supplementary characters (with code points U+10000 and above) are
+   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
+   * which means that they compare as less than some other BMP characters like U+feff.
+   * This function compares Unicode strings in code point order.
+   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
+   *
+   * @param srcChars A pointer to another string to compare this one to.
+   * @param srcLength The number of code units from that string to compare.
+   * @return a negative/zero/positive integer corresponding to whether
+   * this string is less than/equal to/greater than the second one
+   * in code point order
+   * @stable ICU 2.0
+   */
+  inline int8_t compareCodePointOrder(const UChar *srcChars,
+                                      int32_t srcLength) const;
+
+  /**
+   * Compare two Unicode strings in code point order.
+   * The result may be different from the results of compare(), operator<, etc.
+   * if supplementary characters are present:
+   *
+   * In UTF-16, supplementary characters (with code points U+10000 and above) are
+   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
+   * which means that they compare as less than some other BMP characters like U+feff.
+   * This function compares Unicode strings in code point order.
+   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcChars A pointer to another string to compare this one to.
+   * @return a negative/zero/positive integer corresponding to whether
+   * this string is less than/equal to/greater than the second one
+   * in code point order
+   * @stable ICU 2.0
+   */
+  inline int8_t compareCodePointOrder(int32_t start,
+                                      int32_t length,
+                                      const UChar *srcChars) const;
+
+  /**
+   * Compare two Unicode strings in code point order.
+   * The result may be different from the results of compare(), operator<, etc.
+   * if supplementary characters are present:
+   *
+   * In UTF-16, supplementary characters (with code points U+10000 and above) are
+   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
+   * which means that they compare as less than some other BMP characters like U+feff.
+   * This function compares Unicode strings in code point order.
+   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcChars A pointer to another string to compare this one to.
+   * @param srcStart The start offset in that string at which the compare operation begins.
+   * @param srcLength The number of code units from that string to compare.
+   * @return a negative/zero/positive integer corresponding to whether
+   * this string is less than/equal to/greater than the second one
+   * in code point order
+   * @stable ICU 2.0
+   */
+  inline int8_t compareCodePointOrder(int32_t start,
+                                      int32_t length,
+                                      const UChar *srcChars,
+                                      int32_t srcStart,
+                                      int32_t srcLength) const;
+
+  /**
+   * Compare two Unicode strings in code point order.
+   * The result may be different from the results of compare(), operator<, etc.
+   * if supplementary characters are present:
+   *
+   * In UTF-16, supplementary characters (with code points U+10000 and above) are
+   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,
+   * which means that they compare as less than some other BMP characters like U+feff.
+   * This function compares Unicode strings in code point order.
+   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param limit The offset after the last code unit from this string to compare.
+   * @param srcText Another string to compare this one to.
+   * @param srcStart The start offset in that string at which the compare operation begins.
+   * @param srcLimit The offset after the last code unit from that string to compare.
+   * @return a negative/zero/positive integer corresponding to whether
+   * this string is less than/equal to/greater than the second one
+   * in code point order
+   * @stable ICU 2.0
+   */
+  inline int8_t compareCodePointOrderBetween(int32_t start,
+                                             int32_t limit,
+                                             const UnicodeString& srcText,
+                                             int32_t srcStart,
+                                             int32_t srcLimit) const;
+
+  /**
+   * Compare two strings case-insensitively using full case folding.
+   * This is equivalent to this->foldCase(options).compare(text.foldCase(options)).
+   *
+   * @param text Another string to compare this one to.
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Comparison in code unit order with default case folding.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *
+   * @return A negative, zero, or positive integer indicating the comparison result.
+   * @stable ICU 2.0
+   */
+  inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const;
+
+  /**
+   * Compare two strings case-insensitively using full case folding.
+   * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcText Another string to compare this one to.
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Comparison in code unit order with default case folding.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *
+   * @return A negative, zero, or positive integer indicating the comparison result.
+   * @stable ICU 2.0
+   */
+  inline int8_t caseCompare(int32_t start,
+         int32_t length,
+         const UnicodeString& srcText,
+         uint32_t options) const;
+
+  /**
+   * Compare two strings case-insensitively using full case folding.
+   * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcText Another string to compare this one to.
+   * @param srcStart The start offset in that string at which the compare operation begins.
+   * @param srcLength The number of code units from that string to compare.
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Comparison in code unit order with default case folding.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *
+   * @return A negative, zero, or positive integer indicating the comparison result.
+   * @stable ICU 2.0
+   */
+  inline int8_t caseCompare(int32_t start,
+         int32_t length,
+         const UnicodeString& srcText,
+         int32_t srcStart,
+         int32_t srcLength,
+         uint32_t options) const;
+
+  /**
+   * Compare two strings case-insensitively using full case folding.
+   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
+   *
+   * @param srcChars A pointer to another string to compare this one to.
+   * @param srcLength The number of code units from that string to compare.
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Comparison in code unit order with default case folding.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *
+   * @return A negative, zero, or positive integer indicating the comparison result.
+   * @stable ICU 2.0
+   */
+  inline int8_t caseCompare(const UChar *srcChars,
+         int32_t srcLength,
+         uint32_t options) const;
+
+  /**
+   * Compare two strings case-insensitively using full case folding.
+   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcChars A pointer to another string to compare this one to.
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Comparison in code unit order with default case folding.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *
+   * @return A negative, zero, or positive integer indicating the comparison result.
+   * @stable ICU 2.0
+   */
+  inline int8_t caseCompare(int32_t start,
+         int32_t length,
+         const UChar *srcChars,
+         uint32_t options) const;
+
+  /**
+   * Compare two strings case-insensitively using full case folding.
+   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param length The number of code units from this string to compare.
+   * @param srcChars A pointer to another string to compare this one to.
+   * @param srcStart The start offset in that string at which the compare operation begins.
+   * @param srcLength The number of code units from that string to compare.
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Comparison in code unit order with default case folding.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *
+   * @return A negative, zero, or positive integer indicating the comparison result.
+   * @stable ICU 2.0
+   */
+  inline int8_t caseCompare(int32_t start,
+         int32_t length,
+         const UChar *srcChars,
+         int32_t srcStart,
+         int32_t srcLength,
+         uint32_t options) const;
+
+  /**
+   * Compare two strings case-insensitively using full case folding.
+   * This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)).
+   *
+   * @param start The start offset in this string at which the compare operation begins.
+   * @param limit The offset after the last code unit from this string to compare.
+   * @param srcText Another string to compare this one to.
+   * @param srcStart The start offset in that string at which the compare operation begins.
+   * @param srcLimit The offset after the last code unit from that string to compare.
+   * @param options A bit set of options:
+   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+   *     Comparison in code unit order with default case folding.
+   *
+   *   - U_COMPARE_CODE_POINT_ORDER
+   *     Set to choose code point order instead of code unit order
+   *     (see u_strCompare for details).
+   *
+   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   *
+   * @return A negative, zero, or positive integer indicating the comparison result.
+   * @stable ICU 2.0
+   */
+  inline int8_t caseCompareBetween(int32_t start,
+            int32_t limit,
+            const UnicodeString& srcText,
+            int32_t srcStart,
+            int32_t srcLimit,
+            uint32_t options) const;
+
+  /**
+   * Determine if this starts with the characters in <TT>text</TT>
+   * @param text The text to match.
+   * @return TRUE if this starts with the characters in <TT>text</TT>,
+   * FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool startsWith(const UnicodeString& text) const;
+
+  /**
+   * Determine if this starts with the characters in <TT>srcText</TT>
+   * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * @param srcText The text to match.
+   * @param srcStart the offset into <TT>srcText</TT> to start matching
+   * @param srcLength the number of characters in <TT>srcText</TT> to match
+   * @return TRUE if this starts with the characters in <TT>text</TT>,
+   * FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool startsWith(const UnicodeString& srcText,
+            int32_t srcStart,
+            int32_t srcLength) const;
+
+  /**
+   * Determine if this starts with the characters in <TT>srcChars</TT>
+   * @param srcChars The characters to match.
+   * @param srcLength the number of characters in <TT>srcChars</TT>
+   * @return TRUE if this starts with the characters in <TT>srcChars</TT>,
+   * FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool startsWith(const UChar *srcChars,
+            int32_t srcLength) const;
+
+  /**
+   * Determine if this ends with the characters in <TT>srcChars</TT>
+   * in the range  [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * @param srcChars The characters to match.
+   * @param srcStart the offset into <TT>srcText</TT> to start matching
+   * @param srcLength the number of characters in <TT>srcChars</TT> to match
+   * @return TRUE if this ends with the characters in <TT>srcChars</TT>, FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool startsWith(const UChar *srcChars,
+            int32_t srcStart,
+            int32_t srcLength) const;
+
+  /**
+   * Determine if this ends with the characters in <TT>text</TT>
+   * @param text The text to match.
+   * @return TRUE if this ends with the characters in <TT>text</TT>,
+   * FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool endsWith(const UnicodeString& text) const;
+
+  /**
+   * Determine if this ends with the characters in <TT>srcText</TT>
+   * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * @param srcText The text to match.
+   * @param srcStart the offset into <TT>srcText</TT> to start matching
+   * @param srcLength the number of characters in <TT>srcText</TT> to match
+   * @return TRUE if this ends with the characters in <TT>text</TT>,
+   * FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool endsWith(const UnicodeString& srcText,
+          int32_t srcStart,
+          int32_t srcLength) const;
+
+  /**
+   * Determine if this ends with the characters in <TT>srcChars</TT>
+   * @param srcChars The characters to match.
+   * @param srcLength the number of characters in <TT>srcChars</TT>
+   * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
+   * FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool endsWith(const UChar *srcChars,
+          int32_t srcLength) const;
+
+  /**
+   * Determine if this ends with the characters in <TT>srcChars</TT>
+   * in the range  [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * @param srcChars The characters to match.
+   * @param srcStart the offset into <TT>srcText</TT> to start matching
+   * @param srcLength the number of characters in <TT>srcChars</TT> to match
+   * @return TRUE if this ends with the characters in <TT>srcChars</TT>,
+   * FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool endsWith(const UChar *srcChars,
+          int32_t srcStart,
+          int32_t srcLength) const;
+
+
+  /* Searching - bitwise only */
+
+  /**
+   * Locate in this the first occurrence of the characters in <TT>text</TT>,
+   * using bitwise comparison.
+   * @param text The text to search for.
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(const UnicodeString& text) const;
+
+  /**
+   * Locate in this the first occurrence of the characters in <TT>text</TT>
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   * @param text The text to search for.
+   * @param start The offset at which searching will start.
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(const UnicodeString& text,
+              int32_t start) const;
+
+  /**
+   * Locate in this the first occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   * in <TT>text</TT>, using bitwise comparison.
+   * @param text The text to search for.
+   * @param start The offset at which searching will start.
+   * @param length The number of characters to search
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(const UnicodeString& text,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the first occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   *  in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
+   * using bitwise comparison.
+   * @param srcText The text to search for.
+   * @param srcStart the offset into <TT>srcText</TT> at which
+   * to start matching
+   * @param srcLength the number of characters in <TT>srcText</TT> to match
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(const UnicodeString& srcText,
+              int32_t srcStart,
+              int32_t srcLength,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the first occurrence of the characters in
+   * <TT>srcChars</TT>
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   * @param srcChars The text to search for.
+   * @param srcLength the number of characters in <TT>srcChars</TT> to match
+   * @param start the offset into this at which to start matching
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(const UChar *srcChars,
+              int32_t srcLength,
+              int32_t start) const;
+
+  /**
+   * Locate in this the first occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   * in <TT>srcChars</TT>, using bitwise comparison.
+   * @param srcChars The text to search for.
+   * @param srcLength the number of characters in <TT>srcChars</TT>
+   * @param start The offset at which searching will start.
+   * @param length The number of characters to search
+   * @return The offset into this of the start of <TT>srcChars</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(const UChar *srcChars,
+              int32_t srcLength,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the first occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   * in <TT>srcChars</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
+   * using bitwise comparison.
+   * @param srcChars The text to search for.
+   * @param srcStart the offset into <TT>srcChars</TT> at which
+   * to start matching
+   * @param srcLength the number of characters in <TT>srcChars</TT> to match
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  int32_t indexOf(const UChar *srcChars,
+              int32_t srcStart,
+              int32_t srcLength,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the first occurrence of the BMP code point <code>c</code>,
+   * using bitwise comparison.
+   * @param c The code unit to search for.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(UChar c) const;
+
+  /**
+   * Locate in this the first occurrence of the code point <TT>c</TT>,
+   * using bitwise comparison.
+   *
+   * @param c The code point to search for.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(UChar32 c) const;
+
+  /**
+   * Locate in this the first occurrence of the BMP code point <code>c</code>,
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   * @param c The code unit to search for.
+   * @param start The offset at which searching will start.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(UChar c,
+              int32_t start) const;
+
+  /**
+   * Locate in this the first occurrence of the code point <TT>c</TT>
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   *
+   * @param c The code point to search for.
+   * @param start The offset at which searching will start.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(UChar32 c,
+              int32_t start) const;
+
+  /**
+   * Locate in this the first occurrence of the BMP code point <code>c</code>
+   * in the range [<TT>start</TT>, <TT>start + length</TT>),
+   * using bitwise comparison.
+   * @param c The code unit to search for.
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(UChar c,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the first occurrence of the code point <TT>c</TT>
+   * in the range [<TT>start</TT>, <TT>start + length</TT>),
+   * using bitwise comparison.
+   *
+   * @param c The code point to search for.
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t indexOf(UChar32 c,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the last occurrence of the characters in <TT>text</TT>,
+   * using bitwise comparison.
+   * @param text The text to search for.
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(const UnicodeString& text) const;
+
+  /**
+   * Locate in this the last occurrence of the characters in <TT>text</TT>
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   * @param text The text to search for.
+   * @param start The offset at which searching will start.
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(const UnicodeString& text,
+              int32_t start) const;
+
+  /**
+   * Locate in this the last occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   * in <TT>text</TT>, using bitwise comparison.
+   * @param text The text to search for.
+   * @param start The offset at which searching will start.
+   * @param length The number of characters to search
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(const UnicodeString& text,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the last occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   * in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
+   * using bitwise comparison.
+   * @param srcText The text to search for.
+   * @param srcStart the offset into <TT>srcText</TT> at which
+   * to start matching
+   * @param srcLength the number of characters in <TT>srcText</TT> to match
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(const UnicodeString& srcText,
+              int32_t srcStart,
+              int32_t srcLength,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the last occurrence of the characters in <TT>srcChars</TT>
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   * @param srcChars The text to search for.
+   * @param srcLength the number of characters in <TT>srcChars</TT> to match
+   * @param start the offset into this at which to start matching
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(const UChar *srcChars,
+              int32_t srcLength,
+              int32_t start) const;
+
+  /**
+   * Locate in this the last occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   * in <TT>srcChars</TT>, using bitwise comparison.
+   * @param srcChars The text to search for.
+   * @param srcLength the number of characters in <TT>srcChars</TT>
+   * @param start The offset at which searching will start.
+   * @param length The number of characters to search
+   * @return The offset into this of the start of <TT>srcChars</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(const UChar *srcChars,
+              int32_t srcLength,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the last occurrence in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) of the characters
+   * in <TT>srcChars</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),
+   * using bitwise comparison.
+   * @param srcChars The text to search for.
+   * @param srcStart the offset into <TT>srcChars</TT> at which
+   * to start matching
+   * @param srcLength the number of characters in <TT>srcChars</TT> to match
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of the start of <TT>text</TT>,
+   * or -1 if not found.
+   * @stable ICU 2.0
+   */
+  int32_t lastIndexOf(const UChar *srcChars,
+              int32_t srcStart,
+              int32_t srcLength,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the last occurrence of the BMP code point <code>c</code>,
+   * using bitwise comparison.
+   * @param c The code unit to search for.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(UChar c) const;
+
+  /**
+   * Locate in this the last occurrence of the code point <TT>c</TT>,
+   * using bitwise comparison.
+   *
+   * @param c The code point to search for.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(UChar32 c) const;
+
+  /**
+   * Locate in this the last occurrence of the BMP code point <code>c</code>
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   * @param c The code unit to search for.
+   * @param start The offset at which searching will start.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(UChar c,
+              int32_t start) const;
+
+  /**
+   * Locate in this the last occurrence of the code point <TT>c</TT>
+   * starting at offset <TT>start</TT>, using bitwise comparison.
+   *
+   * @param c The code point to search for.
+   * @param start The offset at which searching will start.
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(UChar32 c,
+              int32_t start) const;
+
+  /**
+   * Locate in this the last occurrence of the BMP code point <code>c</code>
+   * in the range [<TT>start</TT>, <TT>start + length</TT>),
+   * using bitwise comparison.
+   * @param c The code unit to search for.
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(UChar c,
+              int32_t start,
+              int32_t length) const;
+
+  /**
+   * Locate in this the last occurrence of the code point <TT>c</TT>
+   * in the range [<TT>start</TT>, <TT>start + length</TT>),
+   * using bitwise comparison.
+   *
+   * @param c The code point to search for.
+   * @param start the offset into this at which to start matching
+   * @param length the number of characters in this to search
+   * @return The offset into this of <TT>c</TT>, or -1 if not found.
+   * @stable ICU 2.0
+   */
+  inline int32_t lastIndexOf(UChar32 c,
+              int32_t start,
+              int32_t length) const;
+
+
+  /* Character access */
+
+  /**
+   * Return the code unit at offset <tt>offset</tt>.
+   * If the offset is not valid (0..length()-1) then U+ffff is returned.
+   * @param offset a valid offset into the text
+   * @return the code unit at offset <tt>offset</tt>
+   *         or 0xffff if the offset is not valid for this string
+   * @stable ICU 2.0
+   */
+  inline UChar charAt(int32_t offset) const;
+
+  /**
+   * Return the code unit at offset <tt>offset</tt>.
+   * If the offset is not valid (0..length()-1) then U+ffff is returned.
+   * @param offset a valid offset into the text
+   * @return the code unit at offset <tt>offset</tt>
+   * @stable ICU 2.0
+   */
+  inline UChar operator[] (int32_t offset) const;
+
+  /**
+   * Return the code point that contains the code unit
+   * at offset <tt>offset</tt>.
+   * If the offset is not valid (0..length()-1) then U+ffff is returned.
+   * @param offset a valid offset into the text
+   * that indicates the text offset of any of the code units
+   * that will be assembled into a code point (21-bit value) and returned
+   * @return the code point of text at <tt>offset</tt>
+   *         or 0xffff if the offset is not valid for this string
+   * @stable ICU 2.0
+   */
+  inline UChar32 char32At(int32_t offset) const;
+
+  /**
+   * Adjust a random-access offset so that
+   * it points to the beginning of a Unicode character.
+   * The offset that is passed in points to
+   * any code unit of a code point,
+   * while the returned offset will point to the first code unit
+   * of the same code point.
+   * In UTF-16, if the input offset points to a second surrogate
+   * of a surrogate pair, then the returned offset will point
+   * to the first surrogate.
+   * @param offset a valid offset into one code point of the text
+   * @return offset of the first code unit of the same code point
+   * @see U16_SET_CP_START
+   * @stable ICU 2.0
+   */
+  inline int32_t getChar32Start(int32_t offset) const;
+
+  /**
+   * Adjust a random-access offset so that
+   * it points behind a Unicode character.
+   * The offset that is passed in points behind
+   * any code unit of a code point,
+   * while the returned offset will point behind the last code unit
+   * of the same code point.
+   * In UTF-16, if the input offset points behind the first surrogate
+   * (i.e., to the second surrogate)
+   * of a surrogate pair, then the returned offset will point
+   * behind the second surrogate (i.e., to the first surrogate).
+   * @param offset a valid offset after any code unit of a code point of the text
+   * @return offset of the first code unit after the same code point
+   * @see U16_SET_CP_LIMIT
+   * @stable ICU 2.0
+   */
+  inline int32_t getChar32Limit(int32_t offset) const;
+
+  /**
+   * Move the code unit index along the string by delta code points.
+   * Interpret the input index as a code unit-based offset into the string,
+   * move the index forward or backward by delta code points, and
+   * return the resulting index.
+   * The input index should point to the first code unit of a code point,
+   * if there is more than one.
+   *
+   * Both input and output indexes are code unit-based as for all
+   * string indexes/offsets in ICU (and other libraries, like MBCS char*).
+   * If delta<0 then the index is moved backward (toward the start of the string).
+   * If delta>0 then the index is moved forward (toward the end of the string).
+   *
+   * This behaves like CharacterIterator::move32(delta, kCurrent).
+   *
+   * Behavior for out-of-bounds indexes:
+   * <code>moveIndex32</code> pins the input index to 0..length(), i.e.,
+   * if the input index<0 then it is pinned to 0;
+   * if it is index>length() then it is pinned to length().
+   * Afterwards, the index is moved by <code>delta</code> code points
+   * forward or backward,
+   * but no further backward than to 0 and no further forward than to length().
+   * The resulting index return value will be in between 0 and length(), inclusively.
+   *
+   * Examples:
+   * <pre>
+   * // s has code points 'a' U+10000 'b' U+10ffff U+2029
+   * UnicodeString s=UNICODE_STRING("a\\U00010000b\\U0010ffff\\u2029", 31).unescape();
+   *
+   * // initial index: position of U+10000
+   * int32_t index=1;
+   *
+   * // the following examples will all result in index==4, position of U+10ffff
+   *
+   * // skip 2 code points from some position in the string
+   * index=s.moveIndex32(index, 2); // skips U+10000 and 'b'
+   *
+   * // go to the 3rd code point from the start of s (0-based)
+   * index=s.moveIndex32(0, 3); // skips 'a', U+10000, and 'b'
+   *
+   * // go to the next-to-last code point of s
+   * index=s.moveIndex32(s.length(), -2); // backward-skips U+2029 and U+10ffff
+   * </pre>
+   *
+   * @param index input code unit index
+   * @param delta (signed) code point count to move the index forward or backward
+   *        in the string
+   * @return the resulting code unit index
+   * @stable ICU 2.0
+   */
+  int32_t moveIndex32(int32_t index, int32_t delta) const;
+
+  /* Substring extraction */
+
+  /**
+   * Copy the characters in the range
+   * [<tt>start</tt>, <tt>start + length</tt>) into the array <tt>dst</tt>,
+   * beginning at <tt>dstStart</tt>.
+   * If the string aliases to <code>dst</code> itself as an external buffer,
+   * then extract() will not copy the contents.
+   *
+   * @param start offset of first character which will be copied into the array
+   * @param length the number of characters to extract
+   * @param dst array in which to copy characters.  The length of <tt>dst</tt>
+   * must be at least (<tt>dstStart + length</tt>).
+   * @param dstStart the offset in <TT>dst</TT> where the first character
+   * will be extracted
+   * @stable ICU 2.0
+   */
+  inline void extract(int32_t start,
+           int32_t length,
+           UChar *dst,
+           int32_t dstStart = 0) const;
+
+  /**
+   * Copy the contents of the string into dest.
+   * This is a convenience function that
+   * checks if there is enough space in dest,
+   * extracts the entire string if possible,
+   * and NUL-terminates dest if possible.
+   *
+   * If the string fits into dest but cannot be NUL-terminated
+   * (length()==destCapacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING.
+   * If the string itself does not fit into dest
+   * (length()>destCapacity) then the error code is set to U_BUFFER_OVERFLOW_ERROR.
+   *
+   * If the string aliases to <code>dest</code> itself as an external buffer,
+   * then extract() will not copy the contents.
+   *
+   * @param dest Destination string buffer.
+   * @param destCapacity Number of UChars available at dest.
+   * @param errorCode ICU error code.
+   * @return length()
+   * @stable ICU 2.0
+   */
+  int32_t
+  extract(UChar *dest, int32_t destCapacity,
+          UErrorCode &errorCode) const;
+
+  /**
+   * Copy the characters in the range
+   * [<tt>start</tt>, <tt>start + length</tt>) into the  UnicodeString
+   * <tt>target</tt>.
+   * @param start offset of first character which will be copied
+   * @param length the number of characters to extract
+   * @param target UnicodeString into which to copy characters.
+   * @return A reference to <TT>target</TT>
+   * @stable ICU 2.0
+   */
+  inline void extract(int32_t start,
+           int32_t length,
+           UnicodeString& target) const;
+
+  /**
+   * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
+   * into the array <tt>dst</tt>, beginning at <tt>dstStart</tt>.
+   * @param start offset of first character which will be copied into the array
+   * @param limit offset immediately following the last character to be copied
+   * @param dst array in which to copy characters.  The length of <tt>dst</tt>
+   * must be at least (<tt>dstStart + (limit - start)</tt>).
+   * @param dstStart the offset in <TT>dst</TT> where the first character
+   * will be extracted
+   * @stable ICU 2.0
+   */
+  inline void extractBetween(int32_t start,
+              int32_t limit,
+              UChar *dst,
+              int32_t dstStart = 0) const;
+
+  /**
+   * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)
+   * into the UnicodeString <tt>target</tt>.  Replaceable API.
+   * @param start offset of first character which will be copied
+   * @param limit offset immediately following the last character to be copied
+   * @param target UnicodeString into which to copy characters.
+   * @return A reference to <TT>target</TT>
+   * @stable ICU 2.0
+   */
+  virtual void extractBetween(int32_t start,
+              int32_t limit,
+              UnicodeString& target) const;
+
+  /**
+   * Copy the characters in the range 
+   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters.
+   * All characters must be invariant (see utypes.h).
+   * Use US_INV as the last, signature-distinguishing parameter.
+   *
+   * This function does not write any more than <code>targetLength</code>
+   * characters but returns the length of the entire output string
+   * so that one can allocate a larger buffer and call the function again
+   * if necessary.
+   * The output string is NUL-terminated if possible.
+   *
+   * @param start offset of first character which will be copied
+   * @param startLength the number of characters to extract
+   * @param target the target buffer for extraction, can be NULL
+   *               if targetLength is 0
+   * @param targetCapacity the length of the target buffer
+   * @param inv Signature-distinguishing paramater, use US_INV.
+   * @return the output string length, not including the terminating NUL
+   * @stable ICU 3.2
+   */
+  int32_t extract(int32_t start,
+           int32_t startLength,
+           char *target,
+           int32_t targetCapacity,
+           enum EInvariant inv) const;
+
+#if !UCONFIG_NO_CONVERSION
+
+  /**
+   * Copy the characters in the range
+   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
+   * in a specified codepage.
+   * The output string is NUL-terminated.
+   *
+   * Recommendation: For invariant-character strings use
+   * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const
+   * because it avoids object code dependencies of UnicodeString on
+   * the conversion code.
+   *
+   * @param start offset of first character which will be copied
+   * @param startLength the number of characters to extract
+   * @param target the target buffer for extraction
+   * @param codepage the desired codepage for the characters.  0 has
+   * the special meaning of the default codepage
+   * If <code>codepage</code> is an empty string (<code>""</code>),
+   * then a simple conversion is performed on the codepage-invariant
+   * subset ("invariant characters") of the platform encoding. See utypes.h.
+   * If <TT>target</TT> is NULL, then the number of bytes required for
+   * <TT>target</TT> is returned. It is assumed that the target is big enough
+   * to fit all of the characters.
+   * @return the output string length, not including the terminating NUL
+   * @stable ICU 2.0
+   */
+  inline int32_t extract(int32_t start,
+                 int32_t startLength,
+                 char *target,
+                 const char *codepage = 0) const;
+
+  /**
+   * Copy the characters in the range
+   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters
+   * in a specified codepage.
+   * This function does not write any more than <code>targetLength</code>
+   * characters but returns the length of the entire output string
+   * so that one can allocate a larger buffer and call the function again
+   * if necessary.
+   * The output string is NUL-terminated if possible.
+   *
+   * Recommendation: For invariant-character strings use
+   * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const
+   * because it avoids object code dependencies of UnicodeString on
+   * the conversion code.
+   *
+   * @param start offset of first character which will be copied
+   * @param startLength the number of characters to extract
+   * @param target the target buffer for extraction
+   * @param targetLength the length of the target buffer
+   * @param codepage the desired codepage for the characters.  0 has
+   * the special meaning of the default codepage
+   * If <code>codepage</code> is an empty string (<code>""</code>),
+   * then a simple conversion is performed on the codepage-invariant
+   * subset ("invariant characters") of the platform encoding. See utypes.h.
+   * If <TT>target</TT> is NULL, then the number of bytes required for
+   * <TT>target</TT> is returned.
+   * @return the output string length, not including the terminating NUL
+   * @stable ICU 2.0
+   */
+  int32_t extract(int32_t start,
+           int32_t startLength,
+           char *target,
+           uint32_t targetLength,
+           const char *codepage = 0) const;
+
+  /**
+   * Convert the UnicodeString into a codepage string using an existing UConverter.
+   * The output string is NUL-terminated if possible.
+   *
+   * This function avoids the overhead of opening and closing a converter if
+   * multiple strings are extracted.
+   *
+   * @param dest destination string buffer, can be NULL if destCapacity==0
+   * @param destCapacity the number of chars available at dest
+   * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called),
+   *        or NULL for the default converter
+   * @param errorCode normal ICU error code
+   * @return the length of the output string, not counting the terminating NUL;
+   *         if the length is greater than destCapacity, then the string will not fit
+   *         and a buffer of the indicated length would need to be passed in
+   * @stable ICU 2.0
+   */
+  int32_t extract(char *dest, int32_t destCapacity,
+                  UConverter *cnv,
+                  UErrorCode &errorCode) const;
+
+#endif
+
+  /* Length operations */
+
+  /**
+   * Return the length of the UnicodeString object.
+   * The length is the number of UChar code units are in the UnicodeString.
+   * If you want the number of code points, please use countChar32().
+   * @return the length of the UnicodeString object
+   * @see countChar32
+   * @stable ICU 2.0
+   */
+  inline int32_t length(void) const;
+
+  /**
+   * Count Unicode code points in the length UChar code units of the string.
+   * A code point may occupy either one or two UChar code units.
+   * Counting code points involves reading all code units.
+   *
+   * This functions is basically the inverse of moveIndex32().
+   *
+   * @param start the index of the first code unit to check
+   * @param length the number of UChar code units to check
+   * @return the number of code points in the specified code units
+   * @see length
+   * @stable ICU 2.0
+   */
+  int32_t
+  countChar32(int32_t start=0, int32_t length=INT32_MAX) const;
+
+  /**
+   * Check if the length UChar code units of the string
+   * contain more Unicode code points than a certain number.
+   * This is more efficient than counting all code points in this part of the string
+   * and comparing that number with a threshold.
+   * This function may not need to scan the string at all if the length
+   * falls within a certain range, and
+   * never needs to count more than 'number+1' code points.
+   * Logically equivalent to (countChar32(start, length)>number).
+   * A Unicode code point may occupy either one or two UChar code units.
+   *
+   * @param start the index of the first code unit to check (0 for the entire string)
+   * @param length the number of UChar code units to check
+   *               (use INT32_MAX for the entire string; remember that start/length
+   *                values are pinned)
+   * @param number The number of code points in the (sub)string is compared against
+   *               the 'number' parameter.
+   * @return Boolean value for whether the string contains more Unicode code points
+   *         than 'number'. Same as (u_countChar32(s, length)>number).
+   * @see countChar32
+   * @see u_strHasMoreChar32Than
+   * @stable ICU 2.4
+   */
+  UBool
+  hasMoreChar32Than(int32_t start, int32_t length, int32_t number) const;
+
+  /**
+   * Determine if this string is empty.
+   * @return TRUE if this string contains 0 characters, FALSE otherwise.
+   * @stable ICU 2.0
+   */
+  inline UBool isEmpty(void) const;
+
+  /**
+   * Return the capacity of the internal buffer of the UnicodeString object.
+   * This is useful together with the getBuffer functions.
+   * See there for details.
+   *
+   * @return the number of UChars available in the internal buffer
+   * @see getBuffer
+   * @stable ICU 2.0
+   */
+  inline int32_t getCapacity(void) const;
+
+  /* Other operations */
+
+  /**
+   * Generate a hash code for this object.
+   * @return The hash code of this UnicodeString.
+   * @stable ICU 2.0
+   */
+  inline int32_t hashCode(void) const;
+
+  /**
+   * Determine if this object contains a valid string.
+   * A bogus string has no value. It is different from an empty string.
+   * It can be used to indicate that no string value is available.
+   * getBuffer() and getTerminatedBuffer() return NULL, and
+   * length() returns 0.
+   *
+   * @return TRUE if the string is valid, FALSE otherwise
+   * @see setToBogus()
+   * @stable ICU 2.0
+   */
+  inline UBool isBogus(void) const;
+
+
+  //========================================
+  // Write operations
+  //========================================
+
+  /* Assignment operations */
+
+  /**
+   * Assignment operator.  Replace the characters in this UnicodeString
+   * with the characters from <TT>srcText</TT>.
+   * @param srcText The text containing the characters to replace
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString &operator=(const UnicodeString &srcText);
+
+  /**
+   * Almost the same as the assignment operator.
+   * Replace the characters in this UnicodeString
+   * with the characters from <code>srcText</code>.
+   *
+   * This function works the same for all strings except for ones that
+   * are readonly aliases.
+   * Starting with ICU 2.4, the assignment operator and the copy constructor
+   * allocate a new buffer and copy the buffer contents even for readonly aliases.
+   * This function implements the old, more efficient but less safe behavior
+   * of making this string also a readonly alias to the same buffer.
+   * The fastCopyFrom function must be used only if it is known that the lifetime of
+   * this UnicodeString is at least as long as the lifetime of the aliased buffer
+   * including its contents, for example for strings from resource bundles
+   * or aliases to string contents.
+   *
+   * @param src The text containing the characters to replace.
+   * @return a reference to this
+   * @stable ICU 2.4
+   */
+  UnicodeString &fastCopyFrom(const UnicodeString &src);
+
+  /**
+   * Assignment operator.  Replace the characters in this UnicodeString
+   * with the code unit <TT>ch</TT>.
+   * @param ch the code unit to replace
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& operator= (UChar ch);
+
+  /**
+   * Assignment operator.  Replace the characters in this UnicodeString
+   * with the code point <TT>ch</TT>.
+   * @param ch the code point to replace
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& operator= (UChar32 ch);
+
+  /**
+   * Set the text in the UnicodeString object to the characters
+   * in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcText.length()</TT>).
+   * <TT>srcText</TT> is not modified.
+   * @param srcText the source for the new characters
+   * @param srcStart the offset into <TT>srcText</TT> where new characters
+   * will be obtained
+   * @return a reference to this
+   * @stable ICU 2.2
+   */
+  inline UnicodeString& setTo(const UnicodeString& srcText,
+               int32_t srcStart);
+
+  /**
+   * Set the text in the UnicodeString object to the characters
+   * in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * <TT>srcText</TT> is not modified.
+   * @param srcText the source for the new characters
+   * @param srcStart the offset into <TT>srcText</TT> where new characters
+   * will be obtained
+   * @param srcLength the number of characters in <TT>srcText</TT> in the
+   * replace string.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& setTo(const UnicodeString& srcText,
+               int32_t srcStart,
+               int32_t srcLength);
+
+  /**
+   * Set the text in the UnicodeString object to the characters in
+   * <TT>srcText</TT>.
+   * <TT>srcText</TT> is not modified.
+   * @param srcText the source for the new characters
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& setTo(const UnicodeString& srcText);
+
+  /**
+   * Set the characters in the UnicodeString object to the characters
+   * in <TT>srcChars</TT>. <TT>srcChars</TT> is not modified.
+   * @param srcChars the source for the new characters
+   * @param srcLength the number of Unicode characters in srcChars.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& setTo(const UChar *srcChars,
+               int32_t srcLength);
+
+  /**
+   * Set the characters in the UnicodeString object to the code unit
+   * <TT>srcChar</TT>.
+   * @param srcChar the code unit which becomes the UnicodeString's character
+   * content
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& setTo(UChar srcChar);
+
+  /**
+   * Set the characters in the UnicodeString object to the code point
+   * <TT>srcChar</TT>.
+   * @param srcChar the code point which becomes the UnicodeString's character
+   * content
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& setTo(UChar32 srcChar);
+
+  /**
+   * Aliasing setTo() function, analogous to the readonly-aliasing UChar* constructor.
+   * The text will be used for the UnicodeString object, but
+   * it will not be released when the UnicodeString is destroyed.
+   * This has copy-on-write semantics:
+   * When the string is modified, then the buffer is first copied into
+   * newly allocated memory.
+   * The aliased buffer is never modified.
+   * In an assignment to another UnicodeString, the text will be aliased again,
+   * so that both strings then alias the same readonly-text.
+   *
+   * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.
+   *                     This must be true if <code>textLength==-1</code>.
+   * @param text The characters to alias for the UnicodeString.
+   * @param textLength The number of Unicode characters in <code>text</code> to alias.
+   *                   If -1, then this constructor will determine the length
+   *                   by calling <code>u_strlen()</code>.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString &setTo(UBool isTerminated,
+                       const UChar *text,
+                       int32_t textLength);
+
+  /**
+   * Aliasing setTo() function, analogous to the writable-aliasing UChar* constructor.
+   * The text will be used for the UnicodeString object, but
+   * it will not be released when the UnicodeString is destroyed.
+   * This has write-through semantics:
+   * For as long as the capacity of the buffer is sufficient, write operations
+   * will directly affect the buffer. When more capacity is necessary, then
+   * a new buffer will be allocated and the contents copied as with regularly
+   * constructed strings.
+   * In an assignment to another UnicodeString, the buffer will be copied.
+   * The extract(UChar *dst) function detects whether the dst pointer is the same
+   * as the string buffer itself and will in this case not copy the contents.
+   *
+   * @param buffer The characters to alias for the UnicodeString.
+   * @param buffLength The number of Unicode characters in <code>buffer</code> to alias.
+   * @param buffCapacity The size of <code>buffer</code> in UChars.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString &setTo(UChar *buffer,
+                       int32_t buffLength,
+                       int32_t buffCapacity);
+
+  /**
+   * Make this UnicodeString object invalid.
+   * The string will test TRUE with isBogus().
+   *
+   * A bogus string has no value. It is different from an empty string.
+   * It can be used to indicate that no string value is available.
+   * getBuffer() and getTerminatedBuffer() return NULL, and
+   * length() returns 0.
+   *
+   * This utility function is used throughout the UnicodeString
+   * implementation to indicate that a UnicodeString operation failed,
+   * and may be used in other functions,
+   * especially but not exclusively when such functions do not
+   * take a UErrorCode for simplicity.
+   *
+   * The following methods, and no others, will clear a string object's bogus flag:
+   * - remove()
+   * - remove(0, INT32_MAX)
+   * - truncate(0)
+   * - operator=() (assignment operator)
+   * - setTo(...)
+   *
+   * The simplest ways to turn a bogus string into an empty one
+   * is to use the remove() function.
+   * Examples for other functions that are equivalent to "set to empty string":
+   * \code
+   * if(s.isBogus()) {
+   *   s.remove();           // set to an empty string (remove all), or
+   *   s.remove(0, INT32_MAX); // set to an empty string (remove all), or
+   *   s.truncate(0);        // set to an empty string (complete truncation), or
+   *   s=UnicodeString();    // assign an empty string, or
+   *   s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or
+   *   static const UChar nul=0;
+   *   s.setTo(&nul, 0);     // set to an empty C Unicode string
+   * }
+   * \endcode
+   *
+   * @see isBogus()
+   * @stable ICU 2.0
+   */
+  void setToBogus();
+
+  /**
+   * Set the character at the specified offset to the specified character.
+   * @param offset A valid offset into the text of the character to set
+   * @param ch The new character
+   * @return A reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& setCharAt(int32_t offset,
+               UChar ch);
+
+
+  /* Append operations */
+
+  /**
+   * Append operator. Append the code unit <TT>ch</TT> to the UnicodeString
+   * object.
+   * @param ch the code unit to be appended
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+ inline  UnicodeString& operator+= (UChar ch);
+
+  /**
+   * Append operator. Append the code point <TT>ch</TT> to the UnicodeString
+   * object.
+   * @param ch the code point to be appended
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+ inline  UnicodeString& operator+= (UChar32 ch);
+
+  /**
+   * Append operator. Append the characters in <TT>srcText</TT> to the
+   * UnicodeString object at offset <TT>start</TT>. <TT>srcText</TT> is
+   * not modified.
+   * @param srcText the source for the new characters
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& operator+= (const UnicodeString& srcText);
+
+  /**
+   * Append the characters
+   * in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the
+   * UnicodeString object at offset <TT>start</TT>. <TT>srcText</TT>
+   * is not modified.
+   * @param srcText the source for the new characters
+   * @param srcStart the offset into <TT>srcText</TT> where new characters
+   * will be obtained
+   * @param srcLength the number of characters in <TT>srcText</TT> in
+   * the append string
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& append(const UnicodeString& srcText,
+            int32_t srcStart,
+            int32_t srcLength);
+
+  /**
+   * Append the characters in <TT>srcText</TT> to the UnicodeString object at
+   * offset <TT>start</TT>. <TT>srcText</TT> is not modified.
+   * @param srcText the source for the new characters
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& append(const UnicodeString& srcText);
+
+  /**
+   * Append the characters in <TT>srcChars</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the UnicodeString
+   * object at offset
+   * <TT>start</TT>. <TT>srcChars</TT> is not modified.
+   * @param srcChars the source for the new characters
+   * @param srcStart the offset into <TT>srcChars</TT> where new characters
+   * will be obtained
+   * @param srcLength the number of characters in <TT>srcChars</TT> in
+   * the append string
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& append(const UChar *srcChars,
+            int32_t srcStart,
+            int32_t srcLength);
+
+  /**
+   * Append the characters in <TT>srcChars</TT> to the UnicodeString object
+   * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
+   * @param srcChars the source for the new characters
+   * @param srcLength the number of Unicode characters in <TT>srcChars</TT>
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& append(const UChar *srcChars,
+            int32_t srcLength);
+
+  /**
+   * Append the code unit <TT>srcChar</TT> to the UnicodeString object.
+   * @param srcChar the code unit to append
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& append(UChar srcChar);
+
+  /**
+   * Append the code point <TT>srcChar</TT> to the UnicodeString object.
+   * @param srcChar the code point to append
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& append(UChar32 srcChar);
+
+
+  /* Insert operations */
+
+  /**
+   * Insert the characters in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
+   * object at offset <TT>start</TT>. <TT>srcText</TT> is not modified.
+   * @param start the offset where the insertion begins
+   * @param srcText the source for the new characters
+   * @param srcStart the offset into <TT>srcText</TT> where new characters
+   * will be obtained
+   * @param srcLength the number of characters in <TT>srcText</TT> in
+   * the insert string
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& insert(int32_t start,
+            const UnicodeString& srcText,
+            int32_t srcStart,
+            int32_t srcLength);
+
+  /**
+   * Insert the characters in <TT>srcText</TT> into the UnicodeString object
+   * at offset <TT>start</TT>. <TT>srcText</TT> is not modified.
+   * @param start the offset where the insertion begins
+   * @param srcText the source for the new characters
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& insert(int32_t start,
+            const UnicodeString& srcText);
+
+  /**
+   * Insert the characters in <TT>srcChars</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString
+   *  object at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
+   * @param start the offset at which the insertion begins
+   * @param srcChars the source for the new characters
+   * @param srcStart the offset into <TT>srcChars</TT> where new characters
+   * will be obtained
+   * @param srcLength the number of characters in <TT>srcChars</TT>
+   * in the insert string
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& insert(int32_t start,
+            const UChar *srcChars,
+            int32_t srcStart,
+            int32_t srcLength);
+
+  /**
+   * Insert the characters in <TT>srcChars</TT> into the UnicodeString object
+   * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.
+   * @param start the offset where the insertion begins
+   * @param srcChars the source for the new characters
+   * @param srcLength the number of Unicode characters in srcChars.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& insert(int32_t start,
+            const UChar *srcChars,
+            int32_t srcLength);
+
+  /**
+   * Insert the code unit <TT>srcChar</TT> into the UnicodeString object at
+   * offset <TT>start</TT>.
+   * @param start the offset at which the insertion occurs
+   * @param srcChar the code unit to insert
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& insert(int32_t start,
+            UChar srcChar);
+
+  /**
+   * Insert the code point <TT>srcChar</TT> into the UnicodeString object at
+   * offset <TT>start</TT>.
+   * @param start the offset at which the insertion occurs
+   * @param srcChar the code point to insert
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& insert(int32_t start,
+            UChar32 srcChar);
+
+
+  /* Replace operations */
+
+  /**
+   * Replace the characters in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in
+   * <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).
+   * <TT>srcText</TT> is not modified.
+   * @param start the offset at which the replace operation begins
+   * @param length the number of characters to replace. The character at
+   * <TT>start + length</TT> is not modified.
+   * @param srcText the source for the new characters
+   * @param srcStart the offset into <TT>srcText</TT> where new characters
+   * will be obtained
+   * @param srcLength the number of characters in <TT>srcText</TT> in
+   * the replace string
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& replace(int32_t start,
+             int32_t length,
+             const UnicodeString& srcText,
+             int32_t srcStart,
+             int32_t srcLength);
+
+  /**
+   * Replace the characters in the range
+   * [<TT>start</TT>, <TT>start + length</TT>)
+   * with the characters in <TT>srcText</TT>.  <TT>srcText</TT> is
+   *  not modified.
+   * @param start the offset at which the replace operation begins
+   * @param length the number of characters to replace. The character at
+   * <TT>start + length</TT> is not modified.
+   * @param srcText the source for the new characters
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& replace(int32_t start,
+             int32_t length,
+             const UnicodeString& srcText);
+
+  /**
+   * Replace the characters in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in
+   * <TT>srcChars</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). <TT>srcChars</TT>
+   * is not modified.
+   * @param start the offset at which the replace operation begins
+   * @param length the number of characters to replace.  The character at
+   * <TT>start + length</TT> is not modified.
+   * @param srcChars the source for the new characters
+   * @param srcStart the offset into <TT>srcChars</TT> where new characters
+   * will be obtained
+   * @param srcLength the number of characters in <TT>srcChars</TT>
+   * in the replace string
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& replace(int32_t start,
+             int32_t length,
+             const UChar *srcChars,
+             int32_t srcStart,
+             int32_t srcLength);
+
+  /**
+   * Replace the characters in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in
+   * <TT>srcChars</TT>.  <TT>srcChars</TT> is not modified.
+   * @param start the offset at which the replace operation begins
+   * @param length number of characters to replace.  The character at
+   * <TT>start + length</TT> is not modified.
+   * @param srcChars the source for the new characters
+   * @param srcLength the number of Unicode characters in srcChars
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& replace(int32_t start,
+             int32_t length,
+             const UChar *srcChars,
+             int32_t srcLength);
+
+  /**
+   * Replace the characters in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the code unit
+   * <TT>srcChar</TT>.
+   * @param start the offset at which the replace operation begins
+   * @param length the number of characters to replace.  The character at
+   * <TT>start + length</TT> is not modified.
+   * @param srcChar the new code unit
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& replace(int32_t start,
+             int32_t length,
+             UChar srcChar);
+
+  /**
+   * Replace the characters in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) with the code point
+   * <TT>srcChar</TT>.
+   * @param start the offset at which the replace operation begins
+   * @param length the number of characters to replace.  The character at
+   * <TT>start + length</TT> is not modified.
+   * @param srcChar the new code point
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& replace(int32_t start,
+             int32_t length,
+             UChar32 srcChar);
+
+  /**
+   * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
+   * with the characters in <TT>srcText</TT>. <TT>srcText</TT> is not modified.
+   * @param start the offset at which the replace operation begins
+   * @param limit the offset immediately following the replace range
+   * @param srcText the source for the new characters
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& replaceBetween(int32_t start,
+                int32_t limit,
+                const UnicodeString& srcText);
+
+  /**
+   * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)
+   * with the characters in <TT>srcText</TT> in the range
+   * [<TT>srcStart</TT>, <TT>srcLimit</TT>). <TT>srcText</TT> is not modified.
+   * @param start the offset at which the replace operation begins
+   * @param limit the offset immediately following the replace range
+   * @param srcText the source for the new characters
+   * @param srcStart the offset into <TT>srcChars</TT> where new characters
+   * will be obtained
+   * @param srcLimit the offset immediately following the range to copy
+   * in <TT>srcText</TT>
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& replaceBetween(int32_t start,
+                int32_t limit,
+                const UnicodeString& srcText,
+                int32_t srcStart,
+                int32_t srcLimit);
+
+  /**
+   * Replace a substring of this object with the given text.
+   * @param start the beginning index, inclusive; <code>0 <= start
+   * <= limit</code>.
+   * @param limit the ending index, exclusive; <code>start <= limit
+   * <= length()</code>.
+   * @param text the text to replace characters <code>start</code>
+   * to <code>limit - 1</code>
+   * @stable ICU 2.0
+   */
+  virtual void handleReplaceBetween(int32_t start,
+                                    int32_t limit,
+                                    const UnicodeString& text);
+
+  /**
+   * Replaceable API
+   * @return TRUE if it has MetaData
+   * @stable ICU 2.4
+   */
+  virtual UBool hasMetaData() const;
+
+  /**
+   * Copy a substring of this object, retaining attribute (out-of-band)
+   * information.  This method is used to duplicate or reorder substrings.
+   * The destination index must not overlap the source range.
+   *
+   * @param start the beginning index, inclusive; <code>0 <= start <=
+   * limit</code>.
+   * @param limit the ending index, exclusive; <code>start <= limit <=
+   * length()</code>.
+   * @param dest the destination index.  The characters from
+   * <code>start..limit-1</code> will be copied to <code>dest</code>.
+   * Implementations of this method may assume that <code>dest <= start ||
+   * dest >= limit</code>.
+   * @stable ICU 2.0
+   */
+  virtual void copy(int32_t start, int32_t limit, int32_t dest);
+
+  /* Search and replace operations */
+
+  /**
+   * Replace all occurrences of characters in oldText with the characters
+   * in newText
+   * @param oldText the text containing the search text
+   * @param newText the text containing the replacement text
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& findAndReplace(const UnicodeString& oldText,
+                const UnicodeString& newText);
+
+  /**
+   * Replace all occurrences of characters in oldText with characters
+   * in newText
+   * in the range [<TT>start</TT>, <TT>start + length</TT>).
+   * @param start the start of the range in which replace will performed
+   * @param length the length of the range in which replace will be performed
+   * @param oldText the text containing the search text
+   * @param newText the text containing the replacement text
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& findAndReplace(int32_t start,
+                int32_t length,
+                const UnicodeString& oldText,
+                const UnicodeString& newText);
+
+  /**
+   * Replace all occurrences of characters in oldText in the range
+   * [<TT>oldStart</TT>, <TT>oldStart + oldLength</TT>) with the characters
+   * in newText in the range
+   * [<TT>newStart</TT>, <TT>newStart + newLength</TT>)
+   * in the range [<TT>start</TT>, <TT>start + length</TT>).
+   * @param start the start of the range in which replace will performed
+   * @param length the length of the range in which replace will be performed
+   * @param oldText the text containing the search text
+   * @param oldStart the start of the search range in <TT>oldText</TT>
+   * @param oldLength the length of the search range in <TT>oldText</TT>
+   * @param newText the text containing the replacement text
+   * @param newStart the start of the replacement range in <TT>newText</TT>
+   * @param newLength the length of the replacement range in <TT>newText</TT>
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& findAndReplace(int32_t start,
+                int32_t length,
+                const UnicodeString& oldText,
+                int32_t oldStart,
+                int32_t oldLength,
+                const UnicodeString& newText,
+                int32_t newStart,
+                int32_t newLength);
+
+
+  /* Remove operations */
+
+  /**
+   * Remove all characters from the UnicodeString object.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& remove(void);
+
+  /**
+   * Remove the characters in the range
+   * [<TT>start</TT>, <TT>start + length</TT>) from the UnicodeString object.
+   * @param start the offset of the first character to remove
+   * @param length the number of characters to remove
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& remove(int32_t start,
+                               int32_t length = (int32_t)INT32_MAX);
+
+  /**
+   * Remove the characters in the range
+   * [<TT>start</TT>, <TT>limit</TT>) from the UnicodeString object.
+   * @param start the offset of the first character to remove
+   * @param limit the offset immediately following the range to remove
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& removeBetween(int32_t start,
+                                      int32_t limit = (int32_t)INT32_MAX);
+
+
+  /* Length operations */
+
+  /**
+   * Pad the start of this UnicodeString with the character <TT>padChar</TT>.
+   * If the length of this UnicodeString is less than targetLength,
+   * length() - targetLength copies of padChar will be added to the
+   * beginning of this UnicodeString.
+   * @param targetLength the desired length of the string
+   * @param padChar the character to use for padding. Defaults to
+   * space (U+0020)
+   * @return TRUE if the text was padded, FALSE otherwise.
+   * @stable ICU 2.0
+   */
+  UBool padLeading(int32_t targetLength,
+                    UChar padChar = 0x0020);
+
+  /**
+   * Pad the end of this UnicodeString with the character <TT>padChar</TT>.
+   * If the length of this UnicodeString is less than targetLength,
+   * length() - targetLength copies of padChar will be added to the
+   * end of this UnicodeString.
+   * @param targetLength the desired length of the string
+   * @param padChar the character to use for padding. Defaults to
+   * space (U+0020)
+   * @return TRUE if the text was padded, FALSE otherwise.
+   * @stable ICU 2.0
+   */
+  UBool padTrailing(int32_t targetLength,
+                     UChar padChar = 0x0020);
+
+  /**
+   * Truncate this UnicodeString to the <TT>targetLength</TT>.
+   * @param targetLength the desired length of this UnicodeString.
+   * @return TRUE if the text was truncated, FALSE otherwise
+   * @stable ICU 2.0
+   */
+  inline UBool truncate(int32_t targetLength);
+
+  /**
+   * Trims leading and trailing whitespace from this UnicodeString.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  UnicodeString& trim(void);
+
+
+  /* Miscellaneous operations */
+
+  /**
+   * Reverse this UnicodeString in place.
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& reverse(void);
+
+  /**
+   * Reverse the range [<TT>start</TT>, <TT>start + length</TT>) in
+   * this UnicodeString.
+   * @param start the start of the range to reverse
+   * @param length the number of characters to to reverse
+   * @return a reference to this
+   * @stable ICU 2.0
+   */
+  inline UnicodeString& reverse(int32_t start,
+             int32_t length);
+
+  /**
+   * Convert the characters in this to UPPER CASE following the conventions of
+   * the default locale.
+   * @return A reference to this.
+   * @stable ICU 2.0
+   */
+  UnicodeString& toUpper(void);
+
+  /**
+   * Convert the characters in this to UPPER CASE following the conventions of
+   * a specific locale.
+   * @param locale The locale containing the conventions to use.
+   * @return A reference to this.
+   * @stable ICU 2.0
+   */
+  UnicodeString& toUpper(const Locale& locale);
+
+  /**
+   * Convert the characters in this to lower case following the conventions of
+   * the default locale.
+   * @return A reference to this.
+   * @stable ICU 2.0
+   */
+  UnicodeString& toLower(void);
+
+  /**
+   * Convert the characters in this to lower case following the conventions of
+   * a specific locale.
+   * @param locale The locale containing the conventions to use.
+   * @return A reference to this.
+   * @stable ICU 2.0
+   */
+  UnicodeString& toLower(const Locale& locale);
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+  /**
+   * Titlecase this string, convenience function using the default locale.
+   *
+   * Casing is locale-dependent and context-sensitive.
+   * Titlecasing uses a break iterator to find the first characters of words
+   * that are to be titlecased. It titlecases those characters and lowercases
+   * all others.
+   *
+   * The titlecase break iterator can be provided to customize for arbitrary
+   * styles, using rules and dictionaries beyond the standard iterators.
+   * It may be more efficient to always provide an iterator to avoid
+   * opening and closing one for each string.
+   * The standard titlecase iterator for the root locale implements the
+   * algorithm of Unicode TR 21.
+   *
+   * This function uses only the setText(), first() and next() methods of the
+   * provided break iterator.
+   *
+   * @param titleIter A break iterator to find the first characters of words
+   *                  that are to be titlecased.
+   *                  If none is provided (0), then a standard titlecase
+   *                  break iterator is opened.
+   *                  Otherwise the provided iterator is set to the string's text.
+   * @return A reference to this.
+   * @stable ICU 2.1
+   */
+  UnicodeString &toTitle(BreakIterator *titleIter);
+
+  /**
+   * Titlecase this string.
+   *
+   * Casing is locale-dependent and context-sensitive.
+   * Titlecasing uses a break iterator to find the first characters of words
+   * that are to be titlecased. It titlecases those characters and lowercases
+   * all others.
+   *
+   * The titlecase break iterator can be provided to customize for arbitrary
+   * styles, using rules and dictionaries beyond the standard iterators.
+   * It may be more efficient to always provide an iterator to avoid
+   * opening and closing one for each string.
+   * The standard titlecase iterator for the root locale implements the
+   * algorithm of Unicode TR 21.
+   *
+   * This function uses only the setText(), first() and next() methods of the
+   * provided break iterator.
+   *
+   * @param titleIter A break iterator to find the first characters of words
+   *                  that are to be titlecased.
+   *                  If none is provided (0), then a standard titlecase
+   *                  break iterator is opened.
+   *                  Otherwise the provided iterator is set to the string's text.
+   * @param locale    The locale to consider.
+   * @return A reference to this.
+   * @stable ICU 2.1
+   */
+  UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale);
+
+  /**
+   * Titlecase this string, with options.
+   *
+   * Casing is locale-dependent and context-sensitive.
+   * Titlecasing uses a break iterator to find the first characters of words
+   * that are to be titlecased. It titlecases those characters and lowercases
+   * all others. (This can be modified with options.)
+   *
+   * The titlecase break iterator can be provided to customize for arbitrary
+   * styles, using rules and dictionaries beyond the standard iterators.
+   * It may be more efficient to always provide an iterator to avoid
+   * opening and closing one for each string.
+   * The standard titlecase iterator for the root locale implements the
+   * algorithm of Unicode TR 21.
+   *
+   * This function uses only the setText(), first() and next() methods of the
+   * provided break iterator.
+   *
+   * @param titleIter A break iterator to find the first characters of words
+   *                  that are to be titlecased.
+   *                  If none is provided (0), then a standard titlecase
+   *                  break iterator is opened.
+   *                  Otherwise the provided iterator is set to the string's text.
+   * @param locale    The locale to consider.
+   * @param options Options bit set, see ucasemap_open().
+   * @return A reference to this.
+   * @see U_TITLECASE_NO_LOWERCASE
+   * @see U_TITLECASE_NO_BREAK_ADJUSTMENT
+   * @see ucasemap_open
+   * @stable ICU 4.0
+   */
+  UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale, uint32_t options);
+
+#endif
+
+  /**
+   * Case-fold the characters in this string.
+   * Case-folding is locale-independent and not context-sensitive,
+   * but there is an option for whether to include or exclude mappings for dotted I
+   * and dotless i that are marked with 'I' in CaseFolding.txt.
+   * The result may be longer or shorter than the original.
+   *
+   * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I
+   * @return A reference to this.
+   * @stable ICU 2.0
+   */
+  UnicodeString &foldCase(uint32_t options=0 /*U_FOLD_CASE_DEFAULT*/);
+
+  //========================================
+  // Access to the internal buffer
+  //========================================
+
+  /**
+   * Get a read/write pointer to the internal buffer.
+   * The buffer is guaranteed to be large enough for at least minCapacity UChars,
+   * writable, and is still owned by the UnicodeString object.
+   * Calls to getBuffer(minCapacity) must not be nested, and
+   * must be matched with calls to releaseBuffer(newLength).
+   * If the string buffer was read-only or shared,
+   * then it will be reallocated and copied.
+   *
+   * An attempted nested call will return 0, and will not further modify the
+   * state of the UnicodeString object.
+   * It also returns 0 if the string is bogus.
+   *
+   * The actual capacity of the string buffer may be larger than minCapacity.
+   * getCapacity() returns the actual capacity.
+   * For many operations, the full capacity should be used to avoid reallocations.
+   *
+   * While the buffer is "open" between getBuffer(minCapacity)
+   * and releaseBuffer(newLength), the following applies:
+   * - The string length is set to 0.
+   * - Any read API call on the UnicodeString object will behave like on a 0-length string.
+   * - Any write API call on the UnicodeString object is disallowed and will have no effect.
+   * - You can read from and write to the returned buffer.
+   * - The previous string contents will still be in the buffer;
+   *   if you want to use it, then you need to call length() before getBuffer(minCapacity).
+   *   If the length() was greater than minCapacity, then any contents after minCapacity
+   *   may be lost.
+   *   The buffer contents is not NUL-terminated by getBuffer().
+   *   If length()<getCapacity() then you can terminate it by writing a NUL
+   *   at index length().
+   * - You must call releaseBuffer(newLength) before and in order to
+   *   return to normal UnicodeString operation.
+   *
+   * @param minCapacity the minimum number of UChars that are to be available
+   *        in the buffer, starting at the returned pointer;
+   *        default to the current string capacity if minCapacity==-1
+   * @return a writable pointer to the internal string buffer,
+   *         or 0 if an error occurs (nested calls, out of memory)
+   *
+   * @see releaseBuffer
+   * @see getTerminatedBuffer()
+   * @stable ICU 2.0
+   */
+  UChar *getBuffer(int32_t minCapacity);
+
+  /**
+   * Release a read/write buffer on a UnicodeString object with an
+   * "open" getBuffer(minCapacity).
+   * This function must be called in a matched pair with getBuffer(minCapacity).
+   * releaseBuffer(newLength) must be called if and only if a getBuffer(minCapacity) is "open".
+   *
+   * It will set the string length to newLength, at most to the current capacity.
+   * If newLength==-1 then it will set the length according to the
+   * first NUL in the buffer, or to the capacity if there is no NUL.
+   *
+   * After calling releaseBuffer(newLength) the UnicodeString is back to normal operation.
+   *
+   * @param newLength the new length of the UnicodeString object;
+   *        defaults to the current capacity if newLength is greater than that;
+   *        if newLength==-1, it defaults to u_strlen(buffer) but not more than
+   *        the current capacity of the string
+   *
+   * @see getBuffer(int32_t minCapacity)
+   * @stable ICU 2.0
+   */
+  void releaseBuffer(int32_t newLength=-1);
+
+  /**
+   * Get a read-only pointer to the internal buffer.
+   * This can be called at any time on a valid UnicodeString.
+   *
+   * It returns 0 if the string is bogus, or
+   * during an "open" getBuffer(minCapacity).
+   *
+   * It can be called as many times as desired.
+   * The pointer that it returns will remain valid until the UnicodeString object is modified,
+   * at which time the pointer is semantically invalidated and must not be used any more.
+   *
+   * The capacity of the buffer can be determined with getCapacity().
+   * The part after length() may or may not be initialized and valid,
+   * depending on the history of the UnicodeString object.
+   *
+   * The buffer contents is (probably) not NUL-terminated.
+   * You can check if it is with
+   * <code>(s.length()<s.getCapacity() && buffer[s.length()]==0)</code>.
+   * (See getTerminatedBuffer().)
+   *
+   * The buffer may reside in read-only memory. Its contents must not
+   * be modified.
+   *
+   * @return a read-only pointer to the internal string buffer,
+   *         or 0 if the string is empty or bogus
+   *
+   * @see getBuffer(int32_t minCapacity)
+   * @see getTerminatedBuffer()
+   * @stable ICU 2.0
+   */
+  inline const UChar *getBuffer() const;
+
+  /**
+   * Get a read-only pointer to the internal buffer,
+   * making sure that it is NUL-terminated.
+   * This can be called at any time on a valid UnicodeString.
+   *
+   * It returns 0 if the string is bogus, or
+   * during an "open" getBuffer(minCapacity), or if the buffer cannot
+   * be NUL-terminated (because memory allocation failed).
+   *
+   * It can be called as many times as desired.
+   * The pointer that it returns will remain valid until the UnicodeString object is modified,
+   * at which time the pointer is semantically invalidated and must not be used any more.
+   *
+   * The capacity of the buffer can be determined with getCapacity().
+   * The part after length()+1 may or may not be initialized and valid,
+   * depending on the history of the UnicodeString object.
+   *
+   * The buffer contents is guaranteed to be NUL-terminated.
+   * getTerminatedBuffer() may reallocate the buffer if a terminating NUL
+   * is written.
+   * For this reason, this function is not const, unlike getBuffer().
+   * Note that a UnicodeString may also contain NUL characters as part of its contents.
+   *
+   * The buffer may reside in read-only memory. Its contents must not
+   * be modified.
+   *
+   * @return a read-only pointer to the internal string buffer,
+   *         or 0 if the string is empty or bogus
+   *
+   * @see getBuffer(int32_t minCapacity)
+   * @see getBuffer()
+   * @stable ICU 2.2
+   */
+  inline const UChar *getTerminatedBuffer();
+
+  //========================================
+  // Constructors
+  //========================================
+
+  /** Construct an empty UnicodeString.
+   * @stable ICU 2.0
+   */
+  UnicodeString();
+
+  /**
+   * Construct a UnicodeString with capacity to hold <TT>capacity</TT> UChars
+   * @param capacity the number of UChars this UnicodeString should hold
+   * before a resize is necessary; if count is greater than 0 and count
+   * code points c take up more space than capacity, then capacity is adjusted
+   * accordingly.
+   * @param c is used to initially fill the string
+   * @param count specifies how many code points c are to be written in the
+   *              string
+   * @stable ICU 2.0
+   */
+  UnicodeString(int32_t capacity, UChar32 c, int32_t count);
+
+  /**
+   * Single UChar (code unit) constructor.
+   * @param ch the character to place in the UnicodeString
+   * @stable ICU 2.0
+   */
+  UnicodeString(UChar ch);
+
+  /**
+   * Single UChar32 (code point) constructor.
+   * @param ch the character to place in the UnicodeString
+   * @stable ICU 2.0
+   */
+  UnicodeString(UChar32 ch);
+
+  /**
+   * UChar* constructor.
+   * @param text The characters to place in the UnicodeString.  <TT>text</TT>
+   * must be NULL (U+0000) terminated.
+   * @stable ICU 2.0
+   */
+  UnicodeString(const UChar *text);
+
+  /**
+   * UChar* constructor.
+   * @param text The characters to place in the UnicodeString.
+   * @param textLength The number of Unicode characters in <TT>text</TT>
+   * to copy.
+   * @stable ICU 2.0
+   */
+  UnicodeString(const UChar *text,
+        int32_t textLength);
+
+  /**
+   * Readonly-aliasing UChar* constructor.
+   * The text will be used for the UnicodeString object, but
+   * it will not be released when the UnicodeString is destroyed.
+   * This has copy-on-write semantics:
+   * When the string is modified, then the buffer is first copied into
+   * newly allocated memory.
+   * The aliased buffer is never modified.
+   * In an assignment to another UnicodeString, the text will be aliased again,
+   * so that both strings then alias the same readonly-text.
+   *
+   * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.
+   *                     This must be true if <code>textLength==-1</code>.
+   * @param text The characters to alias for the UnicodeString.
+   * @param textLength The number of Unicode characters in <code>text</code> to alias.
+   *                   If -1, then this constructor will determine the length
+   *                   by calling <code>u_strlen()</code>.
+   * @stable ICU 2.0
+   */
+  UnicodeString(UBool isTerminated,
+                const UChar *text,
+                int32_t textLength);
+
+  /**
+   * Writable-aliasing UChar* constructor.
+   * The text will be used for the UnicodeString object, but
+   * it will not be released when the UnicodeString is destroyed.
+   * This has write-through semantics:
+   * For as long as the capacity of the buffer is sufficient, write operations
+   * will directly affect the buffer. When more capacity is necessary, then
+   * a new buffer will be allocated and the contents copied as with regularly
+   * constructed strings.
+   * In an assignment to another UnicodeString, the buffer will be copied.
+   * The extract(UChar *dst) function detects whether the dst pointer is the same
+   * as the string buffer itself and will in this case not copy the contents.
+   *
+   * @param buffer The characters to alias for the UnicodeString.
+   * @param buffLength The number of Unicode characters in <code>buffer</code> to alias.
+   * @param buffCapacity The size of <code>buffer</code> in UChars.
+   * @stable ICU 2.0
+   */
+  UnicodeString(UChar *buffer, int32_t buffLength, int32_t buffCapacity);
+
+#if !UCONFIG_NO_CONVERSION
+
+  /**
+   * char* constructor.
+   * @param codepageData an array of bytes, null-terminated
+   * @param codepage the encoding of <TT>codepageData</TT>.  The special
+   * value 0 for <TT>codepage</TT> indicates that the text is in the
+   * platform's default codepage.
+   *
+   * If <code>codepage</code> is an empty string (<code>""</code>),
+   * then a simple conversion is performed on the codepage-invariant
+   * subset ("invariant characters") of the platform encoding. See utypes.h.
+   * Recommendation: For invariant-character strings use the constructor
+   * UnicodeString(const char *src, int32_t length, enum EInvariant inv)
+   * because it avoids object code dependencies of UnicodeString on
+   * the conversion code.
+   *
+   * @stable ICU 2.0
+   */
+  UnicodeString(const char *codepageData,
+        const char *codepage = 0);
+
+  /**
+   * char* constructor.
+   * @param codepageData an array of bytes.
+   * @param dataLength The number of bytes in <TT>codepageData</TT>.
+   * @param codepage the encoding of <TT>codepageData</TT>.  The special
+   * value 0 for <TT>codepage</TT> indicates that the text is in the
+   * platform's default codepage.
+   * If <code>codepage</code> is an empty string (<code>""</code>),
+   * then a simple conversion is performed on the codepage-invariant
+   * subset ("invariant characters") of the platform encoding. See utypes.h.
+   * Recommendation: For invariant-character strings use the constructor
+   * UnicodeString(const char *src, int32_t length, enum EInvariant inv)
+   * because it avoids object code dependencies of UnicodeString on
+   * the conversion code.
+   *
+   * @stable ICU 2.0
+   */
+  UnicodeString(const char *codepageData,
+        int32_t dataLength,
+        const char *codepage = 0);
+
+  /**
+   * char * / UConverter constructor.
+   * This constructor uses an existing UConverter object to
+   * convert the codepage string to Unicode and construct a UnicodeString
+   * from that.
+   *
+   * The converter is reset at first.
+   * If the error code indicates a failure before this constructor is called,
+   * or if an error occurs during conversion or construction,
+   * then the string will be bogus.
+   *
+   * This function avoids the overhead of opening and closing a converter if
+   * multiple strings are constructed.
+   *
+   * @param src input codepage string
+   * @param srcLength length of the input string, can be -1 for NUL-terminated strings
+   * @param cnv converter object (ucnv_resetToUnicode() will be called),
+   *        can be NULL for the default converter
+   * @param errorCode normal ICU error code
+   * @stable ICU 2.0
+   */
+  UnicodeString(
+        const char *src, int32_t srcLength,
+        UConverter *cnv,
+        UErrorCode &errorCode);
+
+#endif
+
+  /**
+   * Constructs a Unicode string from an invariant-character char * string.
+   * About invariant characters see utypes.h.
+   * This constructor has no runtime dependency on conversion code and is
+   * therefore recommended over ones taking a charset name string
+   * (where the empty string "" indicates invariant-character conversion).
+   *
+   * Use the macro US_INV as the third, signature-distinguishing parameter.
+   *
+   * For example:
+   * \code
+   * void fn(const char *s) {
+   *   UnicodeString ustr(s, -1, US_INV);
+   *   // use ustr ...
+   * }
+   * \endcode
+   *
+   * @param src String using only invariant characters.
+   * @param length Length of src, or -1 if NUL-terminated.
+   * @param inv Signature-distinguishing paramater, use US_INV.
+   *
+   * @see US_INV
+   * @stable ICU 3.2
+   */
+  UnicodeString(const char *src, int32_t length, enum EInvariant inv);
+
+
+  /**
+   * Copy constructor.
+   * @param that The UnicodeString object to copy.
+   * @stable ICU 2.0
+   */
+  UnicodeString(const UnicodeString& that);
+
+  /**
+   * 'Substring' constructor from tail of source string.
+   * @param src The UnicodeString object to copy.
+   * @param srcStart The offset into <tt>src</tt> at which to start copying.
+   * @stable ICU 2.2
+   */
+  UnicodeString(const UnicodeString& src, int32_t srcStart);
+
+  /**
+   * 'Substring' constructor from subrange of source string.
+   * @param src The UnicodeString object to copy.
+   * @param srcStart The offset into <tt>src</tt> at which to start copying.
+   * @param srcLength The number of characters from <tt>src</tt> to copy.
+   * @stable ICU 2.2
+   */
+  UnicodeString(const UnicodeString& src, int32_t srcStart, int32_t srcLength);
+
+  /**
+   * Clone this object, an instance of a subclass of Replaceable.
+   * Clones can be used concurrently in multiple threads.
+   * If a subclass does not implement clone(), or if an error occurs,
+   * then NULL is returned.
+   * The clone functions in all subclasses return a pointer to a Replaceable
+   * because some compilers do not support covariant (same-as-this)
+   * return types; cast to the appropriate subclass if necessary.
+   * The caller must delete the clone.
+   *
+   * @return a clone of this object
+   *
+   * @see Replaceable::clone
+   * @see getDynamicClassID
+   * @stable ICU 2.6
+   */
+  virtual Replaceable *clone() const;
+
+  /** Destructor.
+   * @stable ICU 2.0
+   */
+  virtual ~UnicodeString();
+
+
+  /* Miscellaneous operations */
+
+  /**
+   * Unescape a string of characters and return a string containing
+   * the result.  The following escape sequences are recognized:
+   *
+   * \\uhhhh       4 hex digits; h in [0-9A-Fa-f]
+   * \\Uhhhhhhhh   8 hex digits
+   * \\xhh         1-2 hex digits
+   * \\ooo         1-3 octal digits; o in [0-7]
+   * \\cX          control-X; X is masked with 0x1F
+   *
+   * as well as the standard ANSI C escapes:
+   *
+   * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A,
+   * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B,
+   * \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C
+   *
+   * Anything else following a backslash is generically escaped.  For
+   * example, "[a\\-z]" returns "[a-z]".
+   *
+   * If an escape sequence is ill-formed, this method returns an empty
+   * string.  An example of an ill-formed sequence is "\\u" followed by
+   * fewer than 4 hex digits.
+   *
+   * This function is similar to u_unescape() but not identical to it.
+   * The latter takes a source char*, so it does escape recognition
+   * and also invariant conversion.
+   *
+   * @return a string with backslash escapes interpreted, or an
+   * empty string on error.
+   * @see UnicodeString#unescapeAt()
+   * @see u_unescape()
+   * @see u_unescapeAt()
+   * @stable ICU 2.0
+   */
+  UnicodeString unescape() const;
+
+  /**
+   * Unescape a single escape sequence and return the represented
+   * character.  See unescape() for a listing of the recognized escape
+   * sequences.  The character at offset-1 is assumed (without
+   * checking) to be a backslash.  If the escape sequence is
+   * ill-formed, or the offset is out of range, (UChar32)0xFFFFFFFF is
+   * returned.
+   *
+   * @param offset an input output parameter.  On input, it is the
+   * offset into this string where the escape sequence is located,
+   * after the initial backslash.  On output, it is advanced after the
+   * last character parsed.  On error, it is not advanced at all.
+   * @return the character represented by the escape sequence at
+   * offset, or (UChar32)0xFFFFFFFF on error.
+   * @see UnicodeString#unescape()
+   * @see u_unescape()
+   * @see u_unescapeAt()
+   * @stable ICU 2.0
+   */
+  UChar32 unescapeAt(int32_t &offset) const;
+
+  /**
+   * ICU "poor man's RTTI", returns a UClassID for this class.
+   *
+   * @stable ICU 2.2
+   */
+  static UClassID U_EXPORT2 getStaticClassID();
+
+  /**
+   * ICU "poor man's RTTI", returns a UClassID for the actual class.
+   *
+   * @stable ICU 2.2
+   */
+  virtual UClassID getDynamicClassID() const;
+
+  //========================================
+  // Implementation methods
+  //========================================
+
+protected:
+  /**
+   * Implement Replaceable::getLength() (see jitterbug 1027).
+   * @stable ICU 2.4
+   */
+  virtual int32_t getLength() const;
+
+  /**
+   * The change in Replaceable to use virtual getCharAt() allows
+   * UnicodeString::charAt() to be inline again (see jitterbug 709).
+   * @stable ICU 2.4
+   */
+  virtual UChar getCharAt(int32_t offset) const;
+
+  /**
+   * The change in Replaceable to use virtual getChar32At() allows
+   * UnicodeString::char32At() to be inline again (see jitterbug 709).
+   * @stable ICU 2.4
+   */
+  virtual UChar32 getChar32At(int32_t offset) const;
+
+private:
+
+  inline int8_t
+  doCompare(int32_t start,
+           int32_t length,
+           const UnicodeString& srcText,
+           int32_t srcStart,
+           int32_t srcLength) const;
+
+  int8_t doCompare(int32_t start,
+           int32_t length,
+           const UChar *srcChars,
+           int32_t srcStart,
+           int32_t srcLength) const;
+
+  inline int8_t
+  doCompareCodePointOrder(int32_t start,
+                          int32_t length,
+                          const UnicodeString& srcText,
+                          int32_t srcStart,
+                          int32_t srcLength) const;
+
+  int8_t doCompareCodePointOrder(int32_t start,
+                                 int32_t length,
+                                 const UChar *srcChars,
+                                 int32_t srcStart,
+                                 int32_t srcLength) const;
+
+  inline int8_t
+  doCaseCompare(int32_t start,
+                int32_t length,
+                const UnicodeString &srcText,
+                int32_t srcStart,
+                int32_t srcLength,
+                uint32_t options) const;
+
+  int8_t
+  doCaseCompare(int32_t start,
+                int32_t length,
+                const UChar *srcChars,
+                int32_t srcStart,
+                int32_t srcLength,
+                uint32_t options) const;
+
+  int32_t doIndexOf(UChar c,
+            int32_t start,
+            int32_t length) const;
+
+  int32_t doIndexOf(UChar32 c,
+                        int32_t start,
+                        int32_t length) const;
+
+  int32_t doLastIndexOf(UChar c,
+                int32_t start,
+                int32_t length) const;
+
+  int32_t doLastIndexOf(UChar32 c,
+                            int32_t start,
+                            int32_t length) const;
+
+  void doExtract(int32_t start,
+         int32_t length,
+         UChar *dst,
+         int32_t dstStart) const;
+
+  inline void doExtract(int32_t start,
+         int32_t length,
+         UnicodeString& target) const;
+
+  inline UChar doCharAt(int32_t offset)  const;
+
+  UnicodeString& doReplace(int32_t start,
+               int32_t length,
+               const UnicodeString& srcText,
+               int32_t srcStart,
+               int32_t srcLength);
+
+  UnicodeString& doReplace(int32_t start,
+               int32_t length,
+               const UChar *srcChars,
+               int32_t srcStart,
+               int32_t srcLength);
+
+  UnicodeString& doReverse(int32_t start,
+               int32_t length);
+
+  // calculate hash code
+  int32_t doHashCode(void) const;
+
+  // get pointer to start of array
+  // these do not check for kOpenGetBuffer, unlike the public getBuffer() function
+  inline UChar* getArrayStart(void);
+  inline const UChar* getArrayStart(void) const;
+
+  // A UnicodeString object (not necessarily its current buffer)
+  // is writable unless it isBogus() or it has an "open" getBuffer(minCapacity).
+  inline UBool isWritable() const;
+
+  // Is the current buffer writable?
+  inline UBool isBufferWritable() const;
+
+  // None of the following does releaseArray().
+  inline void setLength(int32_t len);        // sets only fShortLength and fLength
+  inline void setToEmpty();                  // sets fFlags=kShortString
+  inline void setToStackBuffer(int32_t len); // sets fFlags=kShortString
+  inline void setArray(UChar *array, int32_t len, int32_t capacity); // does not set fFlags
+
+  // allocate the array; result may be fStackBuffer
+  // sets refCount to 1 if appropriate
+  // sets fArray, fCapacity, and fFlags
+  // returns boolean for success or failure
+  UBool allocate(int32_t capacity);
+
+  // release the array if owned
+  void releaseArray(void);
+
+  // turn a bogus string into an empty one
+  void unBogus();
+
+  // implements assigment operator, copy constructor, and fastCopyFrom()
+  UnicodeString &copyFrom(const UnicodeString &src, UBool fastCopy=FALSE);
+
+  // Pin start and limit to acceptable values.
+  inline void pinIndex(int32_t& start) const;
+  inline void pinIndices(int32_t& start,
+                         int32_t& length) const;
+
+#if !UCONFIG_NO_CONVERSION
+
+  /* Internal extract() using UConverter. */
+  int32_t doExtract(int32_t start, int32_t length,
+                    char *dest, int32_t destCapacity,
+                    UConverter *cnv,
+                    UErrorCode &errorCode) const;
+
+  /*
+   * Real constructor for converting from codepage data.
+   * It assumes that it is called with !fRefCounted.
+   *
+   * If <code>codepage==0</code>, then the default converter
+   * is used for the platform encoding.
+   * If <code>codepage</code> is an empty string (<code>""</code>),
+   * then a simple conversion is performed on the codepage-invariant
+   * subset ("invariant characters") of the platform encoding. See utypes.h.
+   */
+  void doCodepageCreate(const char *codepageData,
+                        int32_t dataLength,
+                        const char *codepage);
+
+  /*
+   * Worker function for creating a UnicodeString from
+   * a codepage string using a UConverter.
+   */
+  void
+  doCodepageCreate(const char *codepageData,
+                   int32_t dataLength,
+                   UConverter *converter,
+                   UErrorCode &status);
+
+#endif
+
+  /*
+   * This function is called when write access to the array
+   * is necessary.
+   *
+   * We need to make a copy of the array if
+   * the buffer is read-only, or
+   * the buffer is refCounted (shared), and refCount>1, or
+   * the buffer is too small.
+   *
+   * Return FALSE if memory could not be allocated.
+   */
+  UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
+                            int32_t growCapacity = -1,
+                            UBool doCopyArray = TRUE,
+                            int32_t **pBufferToDelete = 0,
+                            UBool forceClone = FALSE);
+
+  // common function for case mappings
+  UnicodeString &
+  caseMap(BreakIterator *titleIter,
+          const char *locale,
+          uint32_t options,
+          int32_t toWhichCase);
+
+  // ref counting
+  void addRef(void);
+  int32_t removeRef(void);
+  int32_t refCount(void) const;
+
+  // constants
+  enum {
+    // Set the stack buffer size so that sizeof(UnicodeString) is a multiple of sizeof(pointer):
+    // 32-bit pointers: 4+1+1+13*2 = 32 bytes
+    // 64-bit pointers: 8+1+1+15*2 = 40 bytes
+    US_STACKBUF_SIZE= sizeof(void *)==4 ? 13 : 15, // Size of stack buffer for small strings
+    kInvalidUChar=0xffff, // invalid UChar index
+    kGrowSize=128, // grow size for this buffer
+    kInvalidHashCode=0, // invalid hash code
+    kEmptyHashCode=1, // hash code for empty string
+
+    // bit flag values for fFlags
+    kIsBogus=1,         // this string is bogus, i.e., not valid or NULL
+    kUsingStackBuffer=2,// fArray==fStackBuffer
+    kRefCounted=4,      // there is a refCount field before the characters in fArray
+    kBufferIsReadonly=8,// do not write to this buffer
+    kOpenGetBuffer=16,  // getBuffer(minCapacity) was called (is "open"),
+                        // and releaseBuffer(newLength) must be called
+
+    // combined values for convenience
+    kShortString=kUsingStackBuffer,
+    kLongString=kRefCounted,
+    kReadonlyAlias=kBufferIsReadonly,
+    kWritableAlias=0
+  };
+
+  friend class StringThreadTest;
+
+  union StackBufferOrFields;        // forward declaration necessary before friend declaration
+  friend union StackBufferOrFields; // make US_STACKBUF_SIZE visible inside fUnion
+
+  /*
+   * The following are all the class fields that are stored
+   * in each UnicodeString object.
+   * Note that UnicodeString has virtual functions,
+   * therefore there is an implicit vtable pointer
+   * as the first real field.
+   * The fields should be aligned such that no padding is
+   * necessary, mostly by having larger types first.
+   * On 32-bit machines, the size should be 32 bytes,
+   * on 64-bit machines (8-byte pointers), it should be 40 bytes.
+   */
+  // (implicit) *vtable;
+  int8_t    fShortLength;   // 0..127: length  <0: real length is in fUnion.fFields.fLength
+  uint8_t   fFlags;         // bit flags: see constants above
+  union StackBufferOrFields {
+    // fStackBuffer is used iff (fFlags&kUsingStackBuffer)
+    // else fFields is used
+  UChar     fStackBuffer [ US_STACKBUF_SIZE ]; // buffer for small strings
+    struct {
+      uint16_t  fPadding;   // align the following field at 8B (32b pointers) or 12B (64b)
+      int32_t   fLength;    // number of characters in fArray if >127; else undefined
+      UChar     *fArray;    // the Unicode data (aligned at 12B (32b pointers) or 16B (64b))
+      int32_t   fCapacity;  // sizeof fArray
+    } fFields;
+  } fUnion;
+};
+
+/**
+ * Create a new UnicodeString with the concatenation of two others.
+ *
+ * @param s1 The first string to be copied to the new one.
+ * @param s2 The second string to be copied to the new one, after s1.
+ * @return UnicodeString(s1).append(s2)
+ * @stable ICU 2.8
+ */
+U_COMMON_API UnicodeString U_EXPORT2
+operator+ (const UnicodeString &s1, const UnicodeString &s2);
+
+//========================================
+// Inline members
+//========================================
+
+//========================================
+// Privates
+//========================================
+
+inline void
+UnicodeString::pinIndex(int32_t& start) const
+{
+  // pin index
+  if(start < 0) {
+    start = 0;
+  } else if(start > length()) {
+    start = length();
+  }
+}
+
+inline void
+UnicodeString::pinIndices(int32_t& start,
+                          int32_t& _length) const
+{
+  // pin indices
+  int32_t len = length();
+  if(start < 0) {
+    start = 0;
+  } else if(start > len) {
+    start = len;
+  }
+  if(_length < 0) {
+    _length = 0;
+  } else if(_length > (len - start)) {
+    _length = (len - start);
+  }
+}
+
+inline UChar*
+UnicodeString::getArrayStart()
+{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }
+
+inline const UChar*
+UnicodeString::getArrayStart() const
+{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }
+
+//========================================
+// Read-only implementation methods
+//========================================
+inline int32_t
+UnicodeString::length() const
+{ return fShortLength>=0 ? fShortLength : fUnion.fFields.fLength; }
+
+inline int32_t
+UnicodeString::getCapacity() const
+{ return (fFlags&kUsingStackBuffer) ? US_STACKBUF_SIZE : fUnion.fFields.fCapacity; }
+
+inline int32_t
+UnicodeString::hashCode() const
+{ return doHashCode(); }
+
+inline UBool
+UnicodeString::isBogus() const
+{ return (UBool)(fFlags & kIsBogus); }
+
+inline UBool
+UnicodeString::isWritable() const
+{ return (UBool)!(fFlags&(kOpenGetBuffer|kIsBogus)); }
+
+inline UBool
+UnicodeString::isBufferWritable() const
+{
+  return (UBool)(
+      !(fFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
+      (!(fFlags&kRefCounted) || refCount()==1));
+}
+
+inline const UChar *
+UnicodeString::getBuffer() const {
+  if(fFlags&(kIsBogus|kOpenGetBuffer)) {
+    return 0;
+  } else if(fFlags&kUsingStackBuffer) {
+    return fUnion.fStackBuffer;
+  } else {
+    return fUnion.fFields.fArray;
+  }
+}
+
+//========================================
+// Read-only alias methods
+//========================================
+inline int8_t
+UnicodeString::doCompare(int32_t start,
+              int32_t thisLength,
+              const UnicodeString& srcText,
+              int32_t srcStart,
+              int32_t srcLength) const
+{
+  if(srcText.isBogus()) {
+    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
+  } else {
+    srcText.pinIndices(srcStart, srcLength);
+    return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
+  }
+}
+
+inline UBool
+UnicodeString::operator== (const UnicodeString& text) const
+{
+  if(isBogus()) {
+    return text.isBogus();
+  } else {
+    int32_t len = length(), textLength = text.length();
+    return
+      !text.isBogus() &&
+      len == textLength &&
+      doCompare(0, len, text, 0, textLength) == 0;
+  }
+}
+
+inline UBool
+UnicodeString::operator!= (const UnicodeString& text) const
+{ return (! operator==(text)); }
+
+inline UBool
+UnicodeString::operator> (const UnicodeString& text) const
+{ return doCompare(0, length(), text, 0, text.length()) == 1; }
+
+inline UBool
+UnicodeString::operator< (const UnicodeString& text) const
+{ return doCompare(0, length(), text, 0, text.length()) == -1; }
+
+inline UBool
+UnicodeString::operator>= (const UnicodeString& text) const
+{ return doCompare(0, length(), text, 0, text.length()) != -1; }
+
+inline UBool
+UnicodeString::operator<= (const UnicodeString& text) const
+{ return doCompare(0, length(), text, 0, text.length()) != 1; }
+
+inline int8_t
+UnicodeString::compare(const UnicodeString& text) const
+{ return doCompare(0, length(), text, 0, text.length()); }
+
+inline int8_t
+UnicodeString::compare(int32_t start,
+               int32_t _length,
+               const UnicodeString& srcText) const
+{ return doCompare(start, _length, srcText, 0, srcText.length()); }
+
+inline int8_t
+UnicodeString::compare(const UChar *srcChars,
+               int32_t srcLength) const
+{ return doCompare(0, length(), srcChars, 0, srcLength); }
+
+inline int8_t
+UnicodeString::compare(int32_t start,
+               int32_t _length,
+               const UnicodeString& srcText,
+               int32_t srcStart,
+               int32_t srcLength) const
+{ return doCompare(start, _length, srcText, srcStart, srcLength); }
+
+inline int8_t
+UnicodeString::compare(int32_t start,
+               int32_t _length,
+               const UChar *srcChars) const
+{ return doCompare(start, _length, srcChars, 0, _length); }
+
+inline int8_t
+UnicodeString::compare(int32_t start,
+               int32_t _length,
+               const UChar *srcChars,
+               int32_t srcStart,
+               int32_t srcLength) const
+{ return doCompare(start, _length, srcChars, srcStart, srcLength); }
+
+inline int8_t
+UnicodeString::compareBetween(int32_t start,
+                  int32_t limit,
+                  const UnicodeString& srcText,
+                  int32_t srcStart,
+                  int32_t srcLimit) const
+{ return doCompare(start, limit - start,
+           srcText, srcStart, srcLimit - srcStart); }
+
+inline int8_t
+UnicodeString::doCompareCodePointOrder(int32_t start,
+                                       int32_t thisLength,
+                                       const UnicodeString& srcText,
+                                       int32_t srcStart,
+                                       int32_t srcLength) const
+{
+  if(srcText.isBogus()) {
+    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
+  } else {
+    srcText.pinIndices(srcStart, srcLength);
+    return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
+  }
+}
+
+inline int8_t
+UnicodeString::compareCodePointOrder(const UnicodeString& text) const
+{ return doCompareCodePointOrder(0, length(), text, 0, text.length()); }
+
+inline int8_t
+UnicodeString::compareCodePointOrder(int32_t start,
+                                     int32_t _length,
+                                     const UnicodeString& srcText) const
+{ return doCompareCodePointOrder(start, _length, srcText, 0, srcText.length()); }
+
+inline int8_t
+UnicodeString::compareCodePointOrder(const UChar *srcChars,
+                                     int32_t srcLength) const
+{ return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }
+
+inline int8_t
+UnicodeString::compareCodePointOrder(int32_t start,
+                                     int32_t _length,
+                                     const UnicodeString& srcText,
+                                     int32_t srcStart,
+                                     int32_t srcLength) const
+{ return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
+
+inline int8_t
+UnicodeString::compareCodePointOrder(int32_t start,
+                                     int32_t _length,
+                                     const UChar *srcChars) const
+{ return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
+
+inline int8_t
+UnicodeString::compareCodePointOrder(int32_t start,
+                                     int32_t _length,
+                                     const UChar *srcChars,
+                                     int32_t srcStart,
+                                     int32_t srcLength) const
+{ return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
+
+inline int8_t
+UnicodeString::compareCodePointOrderBetween(int32_t start,
+                                            int32_t limit,
+                                            const UnicodeString& srcText,
+                                            int32_t srcStart,
+                                            int32_t srcLimit) const
+{ return doCompareCodePointOrder(start, limit - start,
+           srcText, srcStart, srcLimit - srcStart); }
+
+inline int8_t
+UnicodeString::doCaseCompare(int32_t start,
+                             int32_t thisLength,
+                             const UnicodeString &srcText,
+                             int32_t srcStart,
+                             int32_t srcLength,
+                             uint32_t options) const
+{
+  if(srcText.isBogus()) {
+    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise
+  } else {
+    srcText.pinIndices(srcStart, srcLength);
+    return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
+  }
+}
+
+inline int8_t
+UnicodeString::caseCompare(const UnicodeString &text, uint32_t options) const {
+  return doCaseCompare(0, length(), text, 0, text.length(), options);
+}
+
+inline int8_t
+UnicodeString::caseCompare(int32_t start,
+                           int32_t _length,
+                           const UnicodeString &srcText,
+                           uint32_t options) const {
+  return doCaseCompare(start, _length, srcText, 0, srcText.length(), options);
+}
+
+inline int8_t
+UnicodeString::caseCompare(const UChar *srcChars,
+                           int32_t srcLength,
+                           uint32_t options) const {
+  return doCaseCompare(0, length(), srcChars, 0, srcLength, options);
+}
+
+inline int8_t
+UnicodeString::caseCompare(int32_t start,
+                           int32_t _length,
+                           const UnicodeString &srcText,
+                           int32_t srcStart,
+                           int32_t srcLength,
+                           uint32_t options) const {
+  return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
+}
+
+inline int8_t
+UnicodeString::caseCompare(int32_t start,
+                           int32_t _length,
+                           const UChar *srcChars,
+                           uint32_t options) const {
+  return doCaseCompare(start, _length, srcChars, 0, _length, options);
+}
+
+inline int8_t
+UnicodeString::caseCompare(int32_t start,
+                           int32_t _length,
+                           const UChar *srcChars,
+                           int32_t srcStart,
+                           int32_t srcLength,
+                           uint32_t options) const {
+  return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
+}
+
+inline int8_t
+UnicodeString::caseCompareBetween(int32_t start,
+                                  int32_t limit,
+                                  const UnicodeString &srcText,
+                                  int32_t srcStart,
+                                  int32_t srcLimit,
+                                  uint32_t options) const {
+  return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
+}
+
+inline int32_t
+UnicodeString::indexOf(const UnicodeString& srcText,
+               int32_t srcStart,
+               int32_t srcLength,
+               int32_t start,
+               int32_t _length) const
+{
+  if(!srcText.isBogus()) {
+    srcText.pinIndices(srcStart, srcLength);
+    if(srcLength > 0) {
+      return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
+    }
+  }
+  return -1;
+}
+
+inline int32_t
+UnicodeString::indexOf(const UnicodeString& text) const
+{ return indexOf(text, 0, text.length(), 0, length()); }
+
+inline int32_t
+UnicodeString::indexOf(const UnicodeString& text,
+               int32_t start) const {
+  pinIndex(start);
+  return indexOf(text, 0, text.length(), start, length() - start);
+}
+
+inline int32_t
+UnicodeString::indexOf(const UnicodeString& text,
+               int32_t start,
+               int32_t _length) const
+{ return indexOf(text, 0, text.length(), start, _length); }
+
+inline int32_t
+UnicodeString::indexOf(const UChar *srcChars,
+               int32_t srcLength,
+               int32_t start) const {
+  pinIndex(start);
+  return indexOf(srcChars, 0, srcLength, start, length() - start);
+}
+
+inline int32_t
+UnicodeString::indexOf(const UChar *srcChars,
+               int32_t srcLength,
+               int32_t start,
+               int32_t _length) const
+{ return indexOf(srcChars, 0, srcLength, start, _length); }
+
+inline int32_t
+UnicodeString::indexOf(UChar c,
+               int32_t start,
+               int32_t _length) const
+{ return doIndexOf(c, start, _length); }
+
+inline int32_t
+UnicodeString::indexOf(UChar32 c,
+               int32_t start,
+               int32_t _length) const
+{ return doIndexOf(c, start, _length); }
+
+inline int32_t
+UnicodeString::indexOf(UChar c) const
+{ return doIndexOf(c, 0, length()); }
+
+inline int32_t
+UnicodeString::indexOf(UChar32 c) const
+{ return indexOf(c, 0, length()); }
+
+inline int32_t
+UnicodeString::indexOf(UChar c,
+               int32_t start) const {
+  pinIndex(start);
+  return doIndexOf(c, start, length() - start);
+}
+
+inline int32_t
+UnicodeString::indexOf(UChar32 c,
+               int32_t start) const {
+  pinIndex(start);
+  return indexOf(c, start, length() - start);
+}
+
+inline int32_t
+UnicodeString::lastIndexOf(const UChar *srcChars,
+               int32_t srcLength,
+               int32_t start,
+               int32_t _length) const
+{ return lastIndexOf(srcChars, 0, srcLength, start, _length); }
+
+inline int32_t
+UnicodeString::lastIndexOf(const UChar *srcChars,
+               int32_t srcLength,
+               int32_t start) const {
+  pinIndex(start);
+  return lastIndexOf(srcChars, 0, srcLength, start, length() - start);
+}
+
+inline int32_t
+UnicodeString::lastIndexOf(const UnicodeString& srcText,
+               int32_t srcStart,
+               int32_t srcLength,
+               int32_t start,
+               int32_t _length) const
+{
+  if(!srcText.isBogus()) {
+    srcText.pinIndices(srcStart, srcLength);
+    if(srcLength > 0) {
+      return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
+    }
+  }
+  return -1;
+}
+
+inline int32_t
+UnicodeString::lastIndexOf(const UnicodeString& text,
+               int32_t start,
+               int32_t _length) const
+{ return lastIndexOf(text, 0, text.length(), start, _length); }
+
+inline int32_t
+UnicodeString::lastIndexOf(const UnicodeString& text,
+               int32_t start) const {
+  pinIndex(start);
+  return lastIndexOf(text, 0, text.length(), start, length() - start);
+}
+
+inline int32_t
+UnicodeString::lastIndexOf(const UnicodeString& text) const
+{ return lastIndexOf(text, 0, text.length(), 0, length()); }
+
+inline int32_t
+UnicodeString::lastIndexOf(UChar c,
+               int32_t start,
+               int32_t _length) const
+{ return doLastIndexOf(c, start, _length); }
+
+inline int32_t
+UnicodeString::lastIndexOf(UChar32 c,
+               int32_t start,
+               int32_t _length) const {
+  return doLastIndexOf(c, start, _length);
+}
+
+inline int32_t
+UnicodeString::lastIndexOf(UChar c) const
+{ return doLastIndexOf(c, 0, length()); }
+
+inline int32_t
+UnicodeString::lastIndexOf(UChar32 c) const {
+  return lastIndexOf(c, 0, length());
+}
+
+inline int32_t
+UnicodeString::lastIndexOf(UChar c,
+               int32_t start) const {
+  pinIndex(start);
+  return doLastIndexOf(c, start, length() - start);
+}
+
+inline int32_t
+UnicodeString::lastIndexOf(UChar32 c,
+               int32_t start) const {
+  pinIndex(start);
+  return lastIndexOf(c, start, length() - start);
+}
+
+inline UBool
+UnicodeString::startsWith(const UnicodeString& text) const
+{ return compare(0, text.length(), text, 0, text.length()) == 0; }
+
+inline UBool
+UnicodeString::startsWith(const UnicodeString& srcText,
+              int32_t srcStart,
+              int32_t srcLength) const
+{ return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
+
+inline UBool
+UnicodeString::startsWith(const UChar *srcChars,
+              int32_t srcLength) const
+{ return doCompare(0, srcLength, srcChars, 0, srcLength) == 0; }
+
+inline UBool
+UnicodeString::startsWith(const UChar *srcChars,
+              int32_t srcStart,
+              int32_t srcLength) const
+{ return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;}
+
+inline UBool
+UnicodeString::endsWith(const UnicodeString& text) const
+{ return doCompare(length() - text.length(), text.length(),
+           text, 0, text.length()) == 0; }
+
+inline UBool
+UnicodeString::endsWith(const UnicodeString& srcText,
+            int32_t srcStart,
+            int32_t srcLength) const {
+  srcText.pinIndices(srcStart, srcLength);
+  return doCompare(length() - srcLength, srcLength,
+                   srcText, srcStart, srcLength) == 0;
+}
+
+inline UBool
+UnicodeString::endsWith(const UChar *srcChars,
+            int32_t srcLength) const {
+  if(srcLength < 0) {
+    srcLength = u_strlen(srcChars);
+  }
+  return doCompare(length() - srcLength, srcLength,
+                   srcChars, 0, srcLength) == 0;
+}
+
+inline UBool
+UnicodeString::endsWith(const UChar *srcChars,
+            int32_t srcStart,
+            int32_t srcLength) const {
+  if(srcLength < 0) {
+    srcLength = u_strlen(srcChars + srcStart);
+  }
+  return doCompare(length() - srcLength, srcLength,
+                   srcChars, srcStart, srcLength) == 0;
+}
+
+//========================================
+// replace
+//========================================
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+               int32_t _length,
+               const UnicodeString& srcText)
+{ return doReplace(start, _length, srcText, 0, srcText.length()); }
+
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+               int32_t _length,
+               const UnicodeString& srcText,
+               int32_t srcStart,
+               int32_t srcLength)
+{ return doReplace(start, _length, srcText, srcStart, srcLength); }
+
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+               int32_t _length,
+               const UChar *srcChars,
+               int32_t srcLength)
+{ return doReplace(start, _length, srcChars, 0, srcLength); }
+
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+               int32_t _length,
+               const UChar *srcChars,
+               int32_t srcStart,
+               int32_t srcLength)
+{ return doReplace(start, _length, srcChars, srcStart, srcLength); }
+
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+               int32_t _length,
+               UChar srcChar)
+{ return doReplace(start, _length, &srcChar, 0, 1); }
+
+inline UnicodeString&
+UnicodeString::replace(int32_t start,
+               int32_t _length,
+               UChar32 srcChar) {
+  UChar buffer[U16_MAX_LENGTH];
+  int32_t count = 0;
+  UBool isError = FALSE;
+  U16_APPEND(buffer, count, U16_MAX_LENGTH, srcChar, isError);
+  return doReplace(start, _length, buffer, 0, count);
+}
+
+inline UnicodeString&
+UnicodeString::replaceBetween(int32_t start,
+                  int32_t limit,
+                  const UnicodeString& srcText)
+{ return doReplace(start, limit - start, srcText, 0, srcText.length()); }
+
+inline UnicodeString&
+UnicodeString::replaceBetween(int32_t start,
+                  int32_t limit,
+                  const UnicodeString& srcText,
+                  int32_t srcStart,
+                  int32_t srcLimit)
+{ return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
+
+inline UnicodeString&
+UnicodeString::findAndReplace(const UnicodeString& oldText,
+                  const UnicodeString& newText)
+{ return findAndReplace(0, length(), oldText, 0, oldText.length(),
+            newText, 0, newText.length()); }
+
+inline UnicodeString&
+UnicodeString::findAndReplace(int32_t start,
+                  int32_t _length,
+                  const UnicodeString& oldText,
+                  const UnicodeString& newText)
+{ return findAndReplace(start, _length, oldText, 0, oldText.length(),
+            newText, 0, newText.length()); }
+
+// ============================
+// extract
+// ============================
+inline void
+UnicodeString::doExtract(int32_t start,
+             int32_t _length,
+             UnicodeString& target) const
+{ target.replace(0, target.length(), *this, start, _length); }
+
+inline void
+UnicodeString::extract(int32_t start,
+               int32_t _length,
+               UChar *target,
+               int32_t targetStart) const
+{ doExtract(start, _length, target, targetStart); }
+
+inline void
+UnicodeString::extract(int32_t start,
+               int32_t _length,
+               UnicodeString& target) const
+{ doExtract(start, _length, target); }
+
+#if !UCONFIG_NO_CONVERSION
+
+inline int32_t
+UnicodeString::extract(int32_t start,
+               int32_t _length,
+               char *dst,
+               const char *codepage) const
+
+{
+  // This dstSize value will be checked explicitly
+  return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
+}
+
+#endif
+
+inline void
+UnicodeString::extractBetween(int32_t start,
+                  int32_t limit,
+                  UChar *dst,
+                  int32_t dstStart) const {
+  pinIndex(start);
+  pinIndex(limit);
+  doExtract(start, limit - start, dst, dstStart);
+}
+
+inline UChar
+UnicodeString::doCharAt(int32_t offset) const
+{
+  if((uint32_t)offset < (uint32_t)length()) {
+    return getArrayStart()[offset];
+  } else {
+    return kInvalidUChar;
+  }
+}
+
+inline UChar
+UnicodeString::charAt(int32_t offset) const
+{ return doCharAt(offset); }
+
+inline UChar
+UnicodeString::operator[] (int32_t offset) const
+{ return doCharAt(offset); }
+
+inline UChar32
+UnicodeString::char32At(int32_t offset) const
+{
+  int32_t len = length();
+  if((uint32_t)offset < (uint32_t)len) {
+    const UChar *array = getArrayStart();
+    UChar32 c;
+    U16_GET(array, 0, offset, len, c);
+    return c;
+  } else {
+    return kInvalidUChar;
+  }
+}
+
+inline int32_t
+UnicodeString::getChar32Start(int32_t offset) const {
+  if((uint32_t)offset < (uint32_t)length()) {
+    const UChar *array = getArrayStart();
+    U16_SET_CP_START(array, 0, offset);
+    return offset;
+  } else {
+    return 0;
+  }
+}
+
+inline int32_t
+UnicodeString::getChar32Limit(int32_t offset) const {
+  int32_t len = length();
+  if((uint32_t)offset < (uint32_t)len) {
+    const UChar *array = getArrayStart();
+    U16_SET_CP_LIMIT(array, 0, offset, len);
+    return offset;
+  } else {
+    return len;
+  }
+}
+
+inline UBool
+UnicodeString::isEmpty() const {
+  return fShortLength == 0;
+}
+
+//========================================
+// Write implementation methods
+//========================================
+inline void
+UnicodeString::setLength(int32_t len) {
+  if(len <= 127) {
+    fShortLength = (int8_t)len;
+  } else {
+    fShortLength = (int8_t)-1;
+    fUnion.fFields.fLength = len;
+  }
+}
+
+inline void
+UnicodeString::setToEmpty() {
+  fShortLength = 0;
+  fFlags = kShortString;
+}
+
+inline void
+UnicodeString::setToStackBuffer(int32_t len) {
+  fShortLength = (int8_t)len;
+  fFlags = kShortString;
+}
+
+inline void
+UnicodeString::setArray(UChar *array, int32_t len, int32_t capacity) {
+  setLength(len);
+  fUnion.fFields.fArray = array;
+  fUnion.fFields.fCapacity = capacity;
+}
+
+inline const UChar *
+UnicodeString::getTerminatedBuffer() {
+  if(!isWritable()) {
+    return 0;
+  } else {
+    UChar *array = getArrayStart();
+    int32_t len = length();
+    if(len < getCapacity() && array[len] == 0) {
+      return array;
+    } else if(cloneArrayIfNeeded(len+1)) {
+      array = getArrayStart();
+      array[len] = 0;
+      return array;
+    } else {
+      return 0;
+    }
+  }
+}
+
+inline UnicodeString&
+UnicodeString::operator= (UChar ch)
+{ return doReplace(0, length(), &ch, 0, 1); }
+
+inline UnicodeString&
+UnicodeString::operator= (UChar32 ch)
+{ return replace(0, length(), ch); }
+
+inline UnicodeString&
+UnicodeString::setTo(const UnicodeString& srcText,
+             int32_t srcStart,
+             int32_t srcLength)
+{
+  unBogus();
+  return doReplace(0, length(), srcText, srcStart, srcLength);
+}
+
+inline UnicodeString&
+UnicodeString::setTo(const UnicodeString& srcText,
+             int32_t srcStart)
+{
+  unBogus();
+  srcText.pinIndex(srcStart);
+  return doReplace(0, length(), srcText, srcStart, srcText.length() - srcStart);
+}
+
+inline UnicodeString&
+UnicodeString::setTo(const UnicodeString& srcText)
+{
+  unBogus();
+  return doReplace(0, length(), srcText, 0, srcText.length());
+}
+
+inline UnicodeString&
+UnicodeString::setTo(const UChar *srcChars,
+             int32_t srcLength)
+{
+  unBogus();
+  return doReplace(0, length(), srcChars, 0, srcLength);
+}
+
+inline UnicodeString&
+UnicodeString::setTo(UChar srcChar)
+{
+  unBogus();
+  return doReplace(0, length(), &srcChar, 0, 1);
+}
+
+inline UnicodeString&
+UnicodeString::setTo(UChar32 srcChar)
+{
+  unBogus();
+  return replace(0, length(), srcChar);
+}
+
+inline UnicodeString&
+UnicodeString::append(const UnicodeString& srcText,
+              int32_t srcStart,
+              int32_t srcLength)
+{ return doReplace(length(), 0, srcText, srcStart, srcLength); }
+
+inline UnicodeString&
+UnicodeString::append(const UnicodeString& srcText)
+{ return doReplace(length(), 0, srcText, 0, srcText.length()); }
+
+inline UnicodeString&
+UnicodeString::append(const UChar *srcChars,
+              int32_t srcStart,
+              int32_t srcLength)
+{ return doReplace(length(), 0, srcChars, srcStart, srcLength); }
+
+inline UnicodeString&
+UnicodeString::append(const UChar *srcChars,
+              int32_t srcLength)
+{ return doReplace(length(), 0, srcChars, 0, srcLength); }
+
+inline UnicodeString&
+UnicodeString::append(UChar srcChar)
+{ return doReplace(length(), 0, &srcChar, 0, 1); }
+
+inline UnicodeString&
+UnicodeString::append(UChar32 srcChar) {
+  UChar buffer[U16_MAX_LENGTH];
+  int32_t _length = 0;
+  UBool isError = FALSE;
+  U16_APPEND(buffer, _length, U16_MAX_LENGTH, srcChar, isError);
+  return doReplace(length(), 0, buffer, 0, _length);
+}
+
+inline UnicodeString&
+UnicodeString::operator+= (UChar ch)
+{ return doReplace(length(), 0, &ch, 0, 1); }
+
+inline UnicodeString&
+UnicodeString::operator+= (UChar32 ch) {
+  return append(ch);
+}
+
+inline UnicodeString&
+UnicodeString::operator+= (const UnicodeString& srcText)
+{ return doReplace(length(), 0, srcText, 0, srcText.length()); }
+
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+              const UnicodeString& srcText,
+              int32_t srcStart,
+              int32_t srcLength)
+{ return doReplace(start, 0, srcText, srcStart, srcLength); }
+
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+              const UnicodeString& srcText)
+{ return doReplace(start, 0, srcText, 0, srcText.length()); }
+
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+              const UChar *srcChars,
+              int32_t srcStart,
+              int32_t srcLength)
+{ return doReplace(start, 0, srcChars, srcStart, srcLength); }
+
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+              const UChar *srcChars,
+              int32_t srcLength)
+{ return doReplace(start, 0, srcChars, 0, srcLength); }
+
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+              UChar srcChar)
+{ return doReplace(start, 0, &srcChar, 0, 1); }
+
+inline UnicodeString&
+UnicodeString::insert(int32_t start,
+              UChar32 srcChar)
+{ return replace(start, 0, srcChar); }
+
+
+inline UnicodeString&
+UnicodeString::remove()
+{
+  // remove() of a bogus string makes the string empty and non-bogus
+  if(isBogus()) {
+    unBogus();
+  } else {
+    setLength(0);
+  }
+  return *this;
+}
+
+inline UnicodeString&
+UnicodeString::remove(int32_t start,
+             int32_t _length)
+{
+    if(start <= 0 && _length == INT32_MAX) {
+        // remove(guaranteed everything) of a bogus string makes the string empty and non-bogus
+        return remove();
+    }
+    return doReplace(start, _length, NULL, 0, 0);
+}
+
+inline UnicodeString&
+UnicodeString::removeBetween(int32_t start,
+                int32_t limit)
+{ return doReplace(start, limit - start, NULL, 0, 0); }
+
+inline UBool
+UnicodeString::truncate(int32_t targetLength)
+{
+  if(isBogus() && targetLength == 0) {
+    // truncate(0) of a bogus string makes the string empty and non-bogus
+    unBogus();
+    return FALSE;
+  } else if((uint32_t)targetLength < (uint32_t)length()) {
+    setLength(targetLength);
+    return TRUE;
+  } else {
+    return FALSE;
+  }
+}
+
+inline UnicodeString&
+UnicodeString::reverse()
+{ return doReverse(0, length()); }
+
+inline UnicodeString&
+UnicodeString::reverse(int32_t start,
+               int32_t _length)
+{ return doReverse(start, _length); }
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/unorm.h b/CoreFoundation/icu/unicode/unorm.h
new file mode 100644
index 0000000..c22b808
--- /dev/null
+++ b/CoreFoundation/icu/unicode/unorm.h
@@ -0,0 +1,576 @@
+/*
+*******************************************************************************
+* Copyright (c) 1996-2007, International Business Machines Corporation
+*               and others. All Rights Reserved.
+*******************************************************************************
+* File unorm.h
+*
+* Created by: Vladimir Weinstein 12052000
+*
+* Modification history :
+*
+* Date        Name        Description
+* 02/01/01    synwee      Added normalization quickcheck enum and method.
+*/
+#ifndef UNORM_H
+#define UNORM_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_NORMALIZATION
+
+#include "unicode/uiter.h"
+
+/**
+ * \file
+ * \brief C API: Unicode Normalization 
+ *
+ * <h2>Unicode normalization API</h2>
+ *
+ * <code>unorm_normalize</code> transforms Unicode text into an equivalent composed or
+ * decomposed form, allowing for easier sorting and searching of text.
+ * <code>unorm_normalize</code> supports the standard normalization forms described in
+ * <a href="http://www.unicode.org/unicode/reports/tr15/" target="unicode">
+ * Unicode Standard Annex #15: Unicode Normalization Forms</a>.
+ *
+ * Characters with accents or other adornments can be encoded in
+ * several different ways in Unicode.  For example, take the character A-acute.
+ * In Unicode, this can be encoded as a single character (the
+ * "composed" form):
+ *
+ * \code
+ *      00C1    LATIN CAPITAL LETTER A WITH ACUTE
+ * \endcode
+ *
+ * or as two separate characters (the "decomposed" form):
+ *
+ * \code
+ *      0041    LATIN CAPITAL LETTER A
+ *      0301    COMBINING ACUTE ACCENT
+ * \endcode
+ *
+ * To a user of your program, however, both of these sequences should be
+ * treated as the same "user-level" character "A with acute accent".  When you are searching or
+ * comparing text, you must ensure that these two sequences are treated 
+ * equivalently.  In addition, you must handle characters with more than one
+ * accent.  Sometimes the order of a character's combining accents is
+ * significant, while in other cases accent sequences in different orders are
+ * really equivalent.
+ *
+ * Similarly, the string "ffi" can be encoded as three separate letters:
+ *
+ * \code
+ *      0066    LATIN SMALL LETTER F
+ *      0066    LATIN SMALL LETTER F
+ *      0069    LATIN SMALL LETTER I
+ * \endcode
+ *
+ * or as the single character
+ *
+ * \code
+ *      FB03    LATIN SMALL LIGATURE FFI
+ * \endcode
+ *
+ * The ffi ligature is not a distinct semantic character, and strictly speaking
+ * it shouldn't be in Unicode at all, but it was included for compatibility
+ * with existing character sets that already provided it.  The Unicode standard
+ * identifies such characters by giving them "compatibility" decompositions
+ * into the corresponding semantic characters.  When sorting and searching, you
+ * will often want to use these mappings.
+ *
+ * <code>unorm_normalize</code> helps solve these problems by transforming text into the
+ * canonical composed and decomposed forms as shown in the first example above.  
+ * In addition, you can have it perform compatibility decompositions so that 
+ * you can treat compatibility characters the same as their equivalents.
+ * Finally, <code>unorm_normalize</code> rearranges accents into the proper canonical
+ * order, so that you do not have to worry about accent rearrangement on your
+ * own.
+ *
+ * Form FCD, "Fast C or D", is also designed for collation.
+ * It allows to work on strings that are not necessarily normalized
+ * with an algorithm (like in collation) that works under "canonical closure", i.e., it treats precomposed
+ * characters and their decomposed equivalents the same.
+ *
+ * It is not a normalization form because it does not provide for uniqueness of representation. Multiple strings
+ * may be canonically equivalent (their NFDs are identical) and may all conform to FCD without being identical
+ * themselves.
+ *
+ * The form is defined such that the "raw decomposition", the recursive canonical decomposition of each character,
+ * results in a string that is canonically ordered. This means that precomposed characters are allowed for as long
+ * as their decompositions do not need canonical reordering.
+ *
+ * Its advantage for a process like collation is that all NFD and most NFC texts - and many unnormalized texts -
+ * already conform to FCD and do not need to be normalized (NFD) for such a process. The FCD quick check will
+ * return UNORM_YES for most strings in practice.
+ *
+ * unorm_normalize(UNORM_FCD) may be implemented with UNORM_NFD.
+ *
+ * For more details on FCD see the collation design document:
+ * http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm
+ *
+ * ICU collation performs either NFD or FCD normalization automatically if normalization
+ * is turned on for the collator object.
+ * Beyond collation and string search, normalized strings may be useful for string equivalence comparisons,
+ * transliteration/transcription, unique representations, etc.
+ *
+ * The W3C generally recommends to exchange texts in NFC.
+ * Note also that most legacy character encodings use only precomposed forms and often do not
+ * encode any combining marks by themselves. For conversion to such character encodings the
+ * Unicode text needs to be normalized to NFC.
+ * For more usage examples, see the Unicode Standard Annex.
+ */
+
+/**
+ * Constants for normalization modes.
+ * @stable ICU 2.0
+ */
+typedef enum {
+  /** No decomposition/composition. @stable ICU 2.0 */
+  UNORM_NONE = 1, 
+  /** Canonical decomposition. @stable ICU 2.0 */
+  UNORM_NFD = 2,
+  /** Compatibility decomposition. @stable ICU 2.0 */
+  UNORM_NFKD = 3,
+  /** Canonical decomposition followed by canonical composition. @stable ICU 2.0 */
+  UNORM_NFC = 4,
+  /** Default normalization. @stable ICU 2.0 */
+  UNORM_DEFAULT = UNORM_NFC, 
+  /** Compatibility decomposition followed by canonical composition. @stable ICU 2.0 */
+  UNORM_NFKC =5,
+  /** "Fast C or D" form. @stable ICU 2.0 */
+  UNORM_FCD = 6,
+
+  /** One more than the highest normalization mode constant. @stable ICU 2.0 */
+  UNORM_MODE_COUNT
+} UNormalizationMode;
+
+/**
+ * Constants for options flags for normalization.
+ * Use 0 for default options,
+ * including normalization according to the Unicode version
+ * that is currently supported by ICU (see u_getUnicodeVersion).
+ * @stable ICU 2.6
+ */
+enum {
+    /**
+     * Options bit set value to select Unicode 3.2 normalization
+     * (except NormalizationCorrections).
+     * At most one Unicode version can be selected at a time.
+     * @stable ICU 2.6
+     */
+    UNORM_UNICODE_3_2=0x20
+};
+
+/**
+ * Lowest-order bit number of unorm_compare() options bits corresponding to
+ * normalization options bits.
+ *
+ * The options parameter for unorm_compare() uses most bits for
+ * itself and for various comparison and folding flags.
+ * The most significant bits, however, are shifted down and passed on
+ * to the normalization implementation.
+ * (That is, from unorm_compare(..., options, ...),
+ * options>>UNORM_COMPARE_NORM_OPTIONS_SHIFT will be passed on to the
+ * internal normalization functions.)
+ *
+ * @see unorm_compare
+ * @stable ICU 2.6
+ */
+#define UNORM_COMPARE_NORM_OPTIONS_SHIFT 20
+
+/**
+ * Normalize a string.
+ * The string will be normalized according the specified normalization mode
+ * and options.
+ * The source and result buffers must not be the same, nor overlap.
+ *
+ * @param source The string to normalize.
+ * @param sourceLength The length of source, or -1 if NUL-terminated.
+ * @param mode The normalization mode; one of UNORM_NONE, 
+ *             UNORM_NFD, UNORM_NFC, UNORM_NFKC, UNORM_NFKD, UNORM_DEFAULT.
+ * @param options The normalization options, ORed together (0 for no options).
+ * @param result A pointer to a buffer to receive the result string.
+ *               The result string is NUL-terminated if possible.
+ * @param resultLength The maximum size of result.
+ * @param status A pointer to a UErrorCode to receive any errors.
+ * @return The total buffer size needed; if greater than resultLength,
+ *         the output was truncated, and the error code is set to U_BUFFER_OVERFLOW_ERROR.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+unorm_normalize(const UChar *source, int32_t sourceLength,
+                UNormalizationMode mode, int32_t options,
+                UChar *result, int32_t resultLength,
+                UErrorCode *status);
+#endif
+/**
+ * Result values for unorm_quickCheck().
+ * For details see Unicode Technical Report 15.
+ * @stable ICU 2.0
+ */
+typedef enum UNormalizationCheckResult {
+  /** 
+   * Indicates that string is not in the normalized format
+   */
+  UNORM_NO,
+  /** 
+   * Indicates that string is in the normalized format
+   */
+  UNORM_YES,
+  /** 
+   * Indicates that string cannot be determined if it is in the normalized 
+   * format without further thorough checks.
+   */
+  UNORM_MAYBE
+} UNormalizationCheckResult;
+#if !UCONFIG_NO_NORMALIZATION
+/**
+ * Performing quick check on a string, to quickly determine if the string is 
+ * in a particular normalization format.
+ * Three types of result can be returned UNORM_YES, UNORM_NO or
+ * UNORM_MAYBE. Result UNORM_YES indicates that the argument
+ * string is in the desired normalized format, UNORM_NO determines that
+ * argument string is not in the desired normalized format. A 
+ * UNORM_MAYBE result indicates that a more thorough check is required, 
+ * the user may have to put the string in its normalized form and compare the 
+ * results.
+ *
+ * @param source       string for determining if it is in a normalized format
+ * @param sourcelength length of source to test, or -1 if NUL-terminated
+ * @param mode         which normalization form to test for
+ * @param status       a pointer to a UErrorCode to receive any errors
+ * @return UNORM_YES, UNORM_NO or UNORM_MAYBE
+ *
+ * @see unorm_isNormalized
+ * @stable ICU 2.0
+ */
+U_STABLE UNormalizationCheckResult U_EXPORT2
+unorm_quickCheck(const UChar *source, int32_t sourcelength,
+                 UNormalizationMode mode,
+                 UErrorCode *status);
+
+/**
+ * Performing quick check on a string; same as unorm_quickCheck but
+ * takes an extra options parameter like most normalization functions.
+ *
+ * @param src        String that is to be tested if it is in a normalization format.
+ * @param srcLength  Length of source to test, or -1 if NUL-terminated.
+ * @param mode       Which normalization form to test for.
+ * @param options    The normalization options, ORed together (0 for no options).
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ * @return UNORM_YES, UNORM_NO or UNORM_MAYBE
+ *
+ * @see unorm_quickCheck
+ * @see unorm_isNormalized
+ * @stable ICU 2.6
+ */
+U_STABLE UNormalizationCheckResult U_EXPORT2
+unorm_quickCheckWithOptions(const UChar *src, int32_t srcLength, 
+                            UNormalizationMode mode, int32_t options,
+                            UErrorCode *pErrorCode);
+
+/**
+ * Test if a string is in a given normalization form.
+ * This is semantically equivalent to source.equals(normalize(source, mode)) .
+ *
+ * Unlike unorm_quickCheck(), this function returns a definitive result,
+ * never a "maybe".
+ * For NFD, NFKD, and FCD, both functions work exactly the same.
+ * For NFC and NFKC where quickCheck may return "maybe", this function will
+ * perform further tests to arrive at a TRUE/FALSE result.
+ *
+ * @param src        String that is to be tested if it is in a normalization format.
+ * @param srcLength  Length of source to test, or -1 if NUL-terminated.
+ * @param mode       Which normalization form to test for.
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ * @return Boolean value indicating whether the source string is in the
+ *         "mode" normalization form.
+ *
+ * @see unorm_quickCheck
+ * @stable ICU 2.2
+ */
+U_STABLE UBool U_EXPORT2
+unorm_isNormalized(const UChar *src, int32_t srcLength,
+                   UNormalizationMode mode,
+                   UErrorCode *pErrorCode);
+
+/**
+ * Test if a string is in a given normalization form; same as unorm_isNormalized but
+ * takes an extra options parameter like most normalization functions.
+ *
+ * @param src        String that is to be tested if it is in a normalization format.
+ * @param srcLength  Length of source to test, or -1 if NUL-terminated.
+ * @param mode       Which normalization form to test for.
+ * @param options    The normalization options, ORed together (0 for no options).
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ * @return Boolean value indicating whether the source string is in the
+ *         "mode/options" normalization form.
+ *
+ * @see unorm_quickCheck
+ * @see unorm_isNormalized
+ * @stable ICU 2.6
+ */
+U_STABLE UBool U_EXPORT2
+unorm_isNormalizedWithOptions(const UChar *src, int32_t srcLength,
+                              UNormalizationMode mode, int32_t options,
+                              UErrorCode *pErrorCode);
+
+/**
+ * Iterative normalization forward.
+ * This function (together with unorm_previous) is somewhat
+ * similar to the C++ Normalizer class (see its non-static functions).
+ *
+ * Iterative normalization is useful when only a small portion of a longer
+ * string/text needs to be processed.
+ *
+ * For example, the likelihood may be high that processing the first 10% of some
+ * text will be sufficient to find certain data.
+ * Another example: When one wants to concatenate two normalized strings and get a
+ * normalized result, it is much more efficient to normalize just a small part of
+ * the result around the concatenation place instead of re-normalizing everything.
+ *
+ * The input text is an instance of the C character iteration API UCharIterator.
+ * It may wrap around a simple string, a CharacterIterator, a Replaceable, or any
+ * other kind of text object.
+ *
+ * If a buffer overflow occurs, then the caller needs to reset the iterator to the
+ * old index and call the function again with a larger buffer - if the caller cares
+ * for the actual output.
+ * Regardless of the output buffer, the iterator will always be moved to the next
+ * normalization boundary.
+ *
+ * This function (like unorm_previous) serves two purposes:
+ *
+ * 1) To find the next boundary so that the normalization of the part of the text
+ * from the current position to that boundary does not affect and is not affected
+ * by the part of the text beyond that boundary.
+ *
+ * 2) To normalize the text up to the boundary.
+ *
+ * The second step is optional, per the doNormalize parameter.
+ * It is omitted for operations like string concatenation, where the two adjacent
+ * string ends need to be normalized together.
+ * In such a case, the output buffer will just contain a copy of the text up to the
+ * boundary.
+ *
+ * pNeededToNormalize is an output-only parameter. Its output value is only defined
+ * if normalization was requested (doNormalize) and successful (especially, no
+ * buffer overflow).
+ * It is useful for operations like a normalizing transliterator, where one would
+ * not want to replace a piece of text if it is not modified.
+ *
+ * If doNormalize==TRUE and pNeededToNormalize!=NULL then *pNeeded... is set TRUE
+ * if the normalization was necessary.
+ *
+ * If doNormalize==FALSE then *pNeededToNormalize will be set to FALSE.
+ *
+ * If the buffer overflows, then *pNeededToNormalize will be undefined;
+ * essentially, whenever U_FAILURE is true (like in buffer overflows), this result
+ * will be undefined.
+ *
+ * @param src The input text in the form of a C character iterator.
+ * @param dest The output buffer; can be NULL if destCapacity==0 for pure preflighting.
+ * @param destCapacity The number of UChars that fit into dest.
+ * @param mode The normalization mode.
+ * @param options The normalization options, ORed together (0 for no options).
+ * @param doNormalize Indicates if the source text up to the next boundary
+ *                    is to be normalized (TRUE) or just copied (FALSE).
+ * @param pNeededToNormalize Output flag indicating if the normalization resulted in
+ *                           different text from the input.
+ *                           Not defined if an error occurs including buffer overflow.
+ *                           Always FALSE if !doNormalize.
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ * @return Length of output (number of UChars) when successful or buffer overflow.
+ *
+ * @see unorm_previous
+ * @see unorm_normalize
+ *
+ * @stable ICU 2.1
+ */
+U_STABLE int32_t U_EXPORT2
+unorm_next(UCharIterator *src,
+           UChar *dest, int32_t destCapacity,
+           UNormalizationMode mode, int32_t options,
+           UBool doNormalize, UBool *pNeededToNormalize,
+           UErrorCode *pErrorCode);
+
+/**
+ * Iterative normalization backward.
+ * This function (together with unorm_next) is somewhat
+ * similar to the C++ Normalizer class (see its non-static functions).
+ * For all details see unorm_next.
+ *
+ * @param src The input text in the form of a C character iterator.
+ * @param dest The output buffer; can be NULL if destCapacity==0 for pure preflighting.
+ * @param destCapacity The number of UChars that fit into dest.
+ * @param mode The normalization mode.
+ * @param options The normalization options, ORed together (0 for no options).
+ * @param doNormalize Indicates if the source text up to the next boundary
+ *                    is to be normalized (TRUE) or just copied (FALSE).
+ * @param pNeededToNormalize Output flag indicating if the normalization resulted in
+ *                           different text from the input.
+ *                           Not defined if an error occurs including buffer overflow.
+ *                           Always FALSE if !doNormalize.
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ * @return Length of output (number of UChars) when successful or buffer overflow.
+ *
+ * @see unorm_next
+ * @see unorm_normalize
+ *
+ * @stable ICU 2.1
+ */
+U_STABLE int32_t U_EXPORT2
+unorm_previous(UCharIterator *src,
+               UChar *dest, int32_t destCapacity,
+               UNormalizationMode mode, int32_t options,
+               UBool doNormalize, UBool *pNeededToNormalize,
+               UErrorCode *pErrorCode);
+
+/**
+ * Concatenate normalized strings, making sure that the result is normalized as well.
+ *
+ * If both the left and the right strings are in
+ * the normalization form according to "mode/options",
+ * then the result will be
+ *
+ * \code
+ *     dest=normalize(left+right, mode, options)
+ * \endcode
+ *
+ * With the input strings already being normalized,
+ * this function will use unorm_next() and unorm_previous()
+ * to find the adjacent end pieces of the input strings.
+ * Only the concatenation of these end pieces will be normalized and
+ * then concatenated with the remaining parts of the input strings.
+ *
+ * It is allowed to have dest==left to avoid copying the entire left string.
+ *
+ * @param left Left source string, may be same as dest.
+ * @param leftLength Length of left source string, or -1 if NUL-terminated.
+ * @param right Right source string. Must not be the same as dest, nor overlap.
+ * @param rightLength Length of right source string, or -1 if NUL-terminated.
+ * @param dest The output buffer; can be NULL if destCapacity==0 for pure preflighting.
+ * @param destCapacity The number of UChars that fit into dest.
+ * @param mode The normalization mode.
+ * @param options The normalization options, ORed together (0 for no options).
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ * @return Length of output (number of UChars) when successful or buffer overflow.
+ *
+ * @see unorm_normalize
+ * @see unorm_next
+ * @see unorm_previous
+ *
+ * @stable ICU 2.1
+ */
+U_STABLE int32_t U_EXPORT2
+unorm_concatenate(const UChar *left, int32_t leftLength,
+                  const UChar *right, int32_t rightLength,
+                  UChar *dest, int32_t destCapacity,
+                  UNormalizationMode mode, int32_t options,
+                  UErrorCode *pErrorCode);
+
+/**
+ * Option bit for unorm_compare:
+ * Both input strings are assumed to fulfill FCD conditions.
+ * @stable ICU 2.2
+ */
+#define UNORM_INPUT_IS_FCD          0x20000
+
+/**
+ * Option bit for unorm_compare:
+ * Perform case-insensitive comparison.
+ * @stable ICU 2.2
+ */
+#define U_COMPARE_IGNORE_CASE       0x10000
+
+#ifndef U_COMPARE_CODE_POINT_ORDER
+/* see also unistr.h and ustring.h */
+/**
+ * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:
+ * Compare strings in code point order instead of code unit order.
+ * @stable ICU 2.2
+ */
+#define U_COMPARE_CODE_POINT_ORDER  0x8000
+#endif
+
+/**
+ * Compare two strings for canonical equivalence.
+ * Further options include case-insensitive comparison and
+ * code point order (as opposed to code unit order).
+ *
+ * Canonical equivalence between two strings is defined as their normalized
+ * forms (NFD or NFC) being identical.
+ * This function compares strings incrementally instead of normalizing
+ * (and optionally case-folding) both strings entirely,
+ * improving performance significantly.
+ *
+ * Bulk normalization is only necessary if the strings do not fulfill the FCD
+ * conditions. Only in this case, and only if the strings are relatively long,
+ * is memory allocated temporarily.
+ * For FCD strings and short non-FCD strings there is no memory allocation.
+ *
+ * Semantically, this is equivalent to
+ *   strcmp[CodePointOrder](NFD(foldCase(NFD(s1))), NFD(foldCase(NFD(s2))))
+ * where code point order and foldCase are all optional.
+ *
+ * UAX 21 2.5 Caseless Matching specifies that for a canonical caseless match
+ * the case folding must be performed first, then the normalization.
+ *
+ * @param s1 First source string.
+ * @param length1 Length of first source string, or -1 if NUL-terminated.
+ *
+ * @param s2 Second source string.
+ * @param length2 Length of second source string, or -1 if NUL-terminated.
+ *
+ * @param options A bit set of options:
+ *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+ *     Case-sensitive comparison in code unit order, and the input strings
+ *     are quick-checked for FCD.
+ *
+ *   - UNORM_INPUT_IS_FCD
+ *     Set if the caller knows that both s1 and s2 fulfill the FCD conditions.
+ *     If not set, the function will quickCheck for FCD
+ *     and normalize if necessary.
+ *
+ *   - U_COMPARE_CODE_POINT_ORDER
+ *     Set to choose code point order instead of code unit order
+ *     (see u_strCompare for details).
+ *
+ *   - U_COMPARE_IGNORE_CASE
+ *     Set to compare strings case-insensitively using case folding,
+ *     instead of case-sensitively.
+ *     If set, then the following case folding options are used.
+ *
+ *   - Options as used with case-insensitive comparisons, currently:
+ *
+ *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ *    (see u_strCaseCompare for details)
+ *
+ *   - regular normalization options shifted left by UNORM_COMPARE_NORM_OPTIONS_SHIFT
+ *
+ * @param pErrorCode ICU error code in/out parameter.
+ *                   Must fulfill U_SUCCESS before the function call.
+ * @return <0 or 0 or >0 as usual for string comparisons
+ *
+ * @see unorm_normalize
+ * @see UNORM_FCD
+ * @see u_strCompare
+ * @see u_strCaseCompare
+ *
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+unorm_compare(const UChar *s1, int32_t length1,
+              const UChar *s2, int32_t length2,
+              uint32_t options,
+              UErrorCode *pErrorCode);
+
+#endif /* #if !UCONFIG_NO_NORMALIZATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/unum.h b/CoreFoundation/icu/unicode/unum.h
new file mode 100644
index 0000000..c5df2bb
--- /dev/null
+++ b/CoreFoundation/icu/unicode/unum.h
@@ -0,0 +1,869 @@
+/*
+*******************************************************************************
+* Copyright (C) 1997-2008, International Business Machines Corporation and others.
+* All Rights Reserved.
+* Modification History:
+*
+*   Date        Name        Description
+*   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes
+*******************************************************************************
+*/
+
+#ifndef _UNUM
+#define _UNUM
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uloc.h"
+#include "unicode/umisc.h"
+#include "unicode/parseerr.h"
+/**
+ * \file
+ * \brief C API: NumberFormat
+ *
+ * <h2> Number Format C API </h2>
+ *
+ * Number Format C API  Provides functions for
+ * formatting and parsing a number.  Also provides methods for
+ * determining which locales have number formats, and what their names
+ * are.
+ * <P>
+ * UNumberFormat helps you to format and parse numbers for any locale.
+ * Your code can be completely independent of the locale conventions
+ * for decimal points, thousands-separators, or even the particular
+ * decimal digits used, or whether the number format is even decimal.
+ * There are different number format styles like decimal, currency,
+ * percent and spellout.
+ * <P>
+ * To format a number for the current Locale, use one of the static
+ * factory methods:
+ * <pre>
+ * \code
+ *    UChar myString[20];
+ *    double myNumber = 7.0;
+ *    UErrorCode status = U_ZERO_ERROR;
+ *    UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status);
+ *    unum_formatDouble(nf, myNumber, myString, 20, NULL, &status);
+ *    printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
+ * \endcode
+ * </pre>
+ * If you are formatting multiple numbers, it is more efficient to get
+ * the format and use it multiple times so that the system doesn't
+ * have to fetch the information about the local language and country
+ * conventions multiple times.
+ * <pre>
+ * \code
+ * uint32_t i, resultlength, reslenneeded;
+ * UErrorCode status = U_ZERO_ERROR;
+ * UFieldPosition pos;
+ * uint32_t a[] = { 123, 3333, -1234567 };
+ * const uint32_t a_len = sizeof(a) / sizeof(a[0]);
+ * UNumberFormat* nf;
+ * UChar* result = NULL;
+ *
+ * nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status);
+ * for (i = 0; i < a_len; i++) {
+ *    resultlength=0;
+ *    reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status);
+ *    result = NULL;
+ *    if(status==U_BUFFER_OVERFLOW_ERROR){
+ *       status=U_ZERO_ERROR;
+ *       resultlength=reslenneeded+1;
+ *       result=(UChar*)malloc(sizeof(UChar) * resultlength);
+ *       unum_format(nf, a[i], result, resultlength, &pos, &status);
+ *    }
+ *    printf( " Example 2: %s\n", austrdup(result));
+ *    free(result);
+ * }
+ * \endcode
+ * </pre>
+ * To format a number for a different Locale, specify it in the
+ * call to unum_open().
+ * <pre>
+ * \code
+ *     UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, "fr_FR", NULL, &success)
+ * \endcode
+ * </pre>
+ * You can use a NumberFormat API unum_parse() to parse.
+ * <pre>
+ * \code
+ *    UErrorCode status = U_ZERO_ERROR;
+ *    int32_t pos=0;
+ *    int32_t num;
+ *    num = unum_parse(nf, str, u_strlen(str), &pos, &status);
+ * \endcode
+ * </pre>
+ * Use UNUM_DECIMAL to get the normal number format for that country.
+ * There are other static options available.  Use UNUM_CURRENCY
+ * to get the currency number format for that country.  Use UNUM_PERCENT
+ * to get a format for displaying percentages. With this format, a
+ * fraction from 0.53 is displayed as 53%.
+ * <P>
+ * Use a pattern to create either a DecimalFormat or a RuleBasedNumberFormat
+ * formatter.  The pattern must conform to the syntax defined for those
+ * formatters.
+ * <P>
+ * You can also control the display of numbers with such function as
+ * unum_getAttribues() and unum_setAtributes(), which let you set the
+ * miminum fraction digits, grouping, etc.
+ * @see UNumberFormatAttributes for more details
+ * <P>
+ * You can also use forms of the parse and format methods with
+ * ParsePosition and UFieldPosition to allow you to:
+ * <ul type=round>
+ *   <li>(a) progressively parse through pieces of a string.
+ *   <li>(b) align the decimal point and other areas.
+ * </ul>
+ * <p>
+ * It is also possible to change or set the symbols used for a particular
+ * locale like the currency symbol, the grouping seperator , monetary seperator
+ * etc by making use of functions unum_setSymbols() and unum_getSymbols().
+ */
+
+/** A number formatter.
+ *  For usage in C programs.
+ *  @stable ICU 2.0
+ */
+typedef void* UNumberFormat;
+
+/** The possible number format styles. 
+ *  @stable ICU 2.0
+ */
+typedef enum UNumberFormatStyle {
+    /**
+     * Decimal format defined by pattern 
+     * @stable ICU 3.0
+     */
+    UNUM_PATTERN_DECIMAL=0,
+    /** Decimal format */
+    UNUM_DECIMAL=1,
+    /** Currency format */
+    UNUM_CURRENCY,
+    /** Percent format */
+    UNUM_PERCENT,
+    /** Scientific format */
+    UNUM_SCIENTIFIC,
+    /** Spellout rule-based format */
+    UNUM_SPELLOUT,
+    /** 
+     * Ordinal rule-based format 
+     * @stable ICU 3.0
+     */
+    UNUM_ORDINAL,
+    /** 
+     * Duration rule-based format 
+     * @stable ICU 3.0
+     */
+    UNUM_DURATION,
+    /** 
+     * Rule-based format defined by pattern 
+     * @stable ICU 3.0
+     */
+    UNUM_PATTERN_RULEBASED,
+    /** Default format */
+    UNUM_DEFAULT = UNUM_DECIMAL,
+    /** (Alias for UNUM_PATTERN_DECIMAL) */
+    UNUM_IGNORE = UNUM_PATTERN_DECIMAL
+} UNumberFormatStyle;
+
+/** The possible number format rounding modes. 
+ *  @stable ICU 2.0
+ */
+typedef enum UNumberFormatRoundingMode {
+    UNUM_ROUND_CEILING,
+    UNUM_ROUND_FLOOR,
+    UNUM_ROUND_DOWN,
+    UNUM_ROUND_UP,
+    /**
+     * Half-even rounding, misspelled name
+     * @deprecated, ICU 3.8
+     */
+    UNUM_FOUND_HALFEVEN,
+    UNUM_ROUND_HALFDOWN,
+    UNUM_ROUND_HALFUP,
+    /**
+     * Half-even rounding
+     * @stable, ICU 3.8
+     */
+    UNUM_ROUND_HALFEVEN = UNUM_FOUND_HALFEVEN
+} UNumberFormatRoundingMode;
+
+/** The possible number format pad positions. 
+ *  @stable ICU 2.0
+ */
+typedef enum UNumberFormatPadPosition {
+    UNUM_PAD_BEFORE_PREFIX,
+    UNUM_PAD_AFTER_PREFIX,
+    UNUM_PAD_BEFORE_SUFFIX,
+    UNUM_PAD_AFTER_SUFFIX
+} UNumberFormatPadPosition;
+
+/**
+ * Create and return a new UNumberFormat for formatting and parsing
+ * numbers.  A UNumberFormat may be used to format numbers by calling
+ * {@link #unum_format }, and to parse numbers by calling {@link #unum_parse }.
+ * The caller must call {@link #unum_close } when done to release resources
+ * used by this object.
+ * @param style The type of number format to open: one of
+ * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, UNUM_SPELLOUT,
+ * UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT.
+ * If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the
+ * number format is opened using the given pattern, which must conform
+ * to the syntax described in DecimalFormat or RuleBasedNumberFormat,
+ * respectively.
+ * @param pattern A pattern specifying the format to use. 
+ * This parameter is ignored unless the style is
+ * UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED.
+ * @param patternLength The number of characters in the pattern, or -1
+ * if null-terminated. This parameter is ignored unless the style is
+ * UNUM_PATTERN.
+ * @param locale A locale identifier to use to determine formatting
+ * and parsing conventions, or NULL to use the default locale.
+ * @param parseErr A pointer to a UParseError struct to receive the
+ * details of any parsing errors, or NULL if no parsing error details
+ * are desired.
+ * @param status A pointer to an input-output UErrorCode.
+ * @return A pointer to a newly created UNumberFormat, or NULL if an
+ * error occurred.
+ * @see unum_close
+ * @see DecimalFormat
+ * @stable ICU 2.0
+ */
+U_STABLE UNumberFormat* U_EXPORT2 
+unum_open(  UNumberFormatStyle    style,
+            const    UChar*    pattern,
+            int32_t            patternLength,
+            const    char*     locale,
+            UParseError*       parseErr,
+            UErrorCode*        status);
+
+
+/**
+* Close a UNumberFormat.
+* Once closed, a UNumberFormat may no longer be used.
+* @param fmt The formatter to close.
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+unum_close(UNumberFormat* fmt);
+
+/**
+ * Open a copy of a UNumberFormat.
+ * This function performs a deep copy.
+ * @param fmt The format to copy
+ * @param status A pointer to an UErrorCode to receive any errors.
+ * @return A pointer to a UNumberFormat identical to fmt.
+ * @stable ICU 2.0
+ */
+U_STABLE UNumberFormat* U_EXPORT2 
+unum_clone(const UNumberFormat *fmt,
+       UErrorCode *status);
+
+/**
+* Format an integer using a UNumberFormat.
+* The integer will be formatted according to the UNumberFormat's locale.
+* @param fmt The formatter to use.
+* @param number The number to format.
+* @param result A pointer to a buffer to receive the formatted number.
+* @param resultLength The maximum size of result.
+* @param pos    A pointer to a UFieldPosition.  On input, position->field
+* is read.  On output, position->beginIndex and position->endIndex indicate
+* the beginning and ending indices of field number position->field, if such
+* a field exists.  This parameter may be NULL, in which case no field
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The total buffer size needed; if greater than resultLength, the output was truncated.
+* @see unum_formatInt64
+* @see unum_formatDouble
+* @see unum_parse
+* @see unum_parseInt64
+* @see unum_parseDouble
+* @see UFieldPosition
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+unum_format(    const    UNumberFormat*    fmt,
+        int32_t            number,
+        UChar*            result,
+        int32_t            resultLength,
+        UFieldPosition    *pos,
+        UErrorCode*        status);
+
+/**
+* Format an int64 using a UNumberFormat.
+* The int64 will be formatted according to the UNumberFormat's locale.
+* @param fmt The formatter to use.
+* @param number The number to format.
+* @param result A pointer to a buffer to receive the formatted number.
+* @param resultLength The maximum size of result.
+* @param pos    A pointer to a UFieldPosition.  On input, position->field
+* is read.  On output, position->beginIndex and position->endIndex indicate
+* the beginning and ending indices of field number position->field, if such
+* a field exists.  This parameter may be NULL, in which case no field
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The total buffer size needed; if greater than resultLength, the output was truncated.
+* @see unum_format
+* @see unum_formatDouble
+* @see unum_parse
+* @see unum_parseInt64
+* @see unum_parseDouble
+* @see UFieldPosition
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+unum_formatInt64(const UNumberFormat *fmt,
+        int64_t         number,
+        UChar*          result,
+        int32_t         resultLength,
+        UFieldPosition *pos,
+        UErrorCode*     status);
+
+/**
+* Format a double using a UNumberFormat.
+* The double will be formatted according to the UNumberFormat's locale.
+* @param fmt The formatter to use.
+* @param number The number to format.
+* @param result A pointer to a buffer to receive the formatted number.
+* @param resultLength The maximum size of result.
+* @param pos    A pointer to a UFieldPosition.  On input, position->field
+* is read.  On output, position->beginIndex and position->endIndex indicate
+* the beginning and ending indices of field number position->field, if such
+* a field exists.  This parameter may be NULL, in which case no field
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The total buffer size needed; if greater than resultLength, the output was truncated.
+* @see unum_format
+* @see unum_formatInt64
+* @see unum_parse
+* @see unum_parseInt64
+* @see unum_parseDouble
+* @see UFieldPosition
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+unum_formatDouble(    const    UNumberFormat*  fmt,
+            double          number,
+            UChar*          result,
+            int32_t         resultLength,
+            UFieldPosition  *pos, /* 0 if ignore */
+            UErrorCode*     status);
+
+/**
+ * Format a double currency amount using a UNumberFormat.
+ * The double will be formatted according to the UNumberFormat's locale.
+ * @param fmt the formatter to use
+ * @param number the number to format
+ * @param currency the 3-letter null-terminated ISO 4217 currency code
+ * @param result a pointer to the buffer to receive the formatted number
+ * @param resultLength the maximum number of UChars to write to result
+ * @param pos a pointer to a UFieldPosition.  On input,
+ * position->field is read.  On output, position->beginIndex and
+ * position->endIndex indicate the beginning and ending indices of
+ * field number position->field, if such a field exists.  This
+ * parameter may be NULL, in which case it is ignored.
+ * @param status a pointer to an input-output UErrorCode
+ * @return the total buffer size needed; if greater than resultLength,
+ * the output was truncated.
+ * @see unum_formatDouble
+ * @see unum_parseDoubleCurrency
+ * @see UFieldPosition
+ * @stable ICU 3.0
+ */
+U_STABLE int32_t U_EXPORT2 
+unum_formatDoubleCurrency(const UNumberFormat* fmt,
+                          double number,
+                          UChar* currency,
+                          UChar* result,
+                          int32_t resultLength,
+                          UFieldPosition* pos, /* ignored if 0 */
+                          UErrorCode* status);
+
+/**
+* Parse a string into an integer using a UNumberFormat.
+* The string will be parsed according to the UNumberFormat's locale.
+* @param fmt The formatter to use.
+* @param text The text to parse.
+* @param textLength The length of text, or -1 if null-terminated.
+* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The value of the parsed integer
+* @see unum_parseInt64
+* @see unum_parseDouble
+* @see unum_format
+* @see unum_formatInt64
+* @see unum_formatDouble
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+unum_parse(    const   UNumberFormat*  fmt,
+        const   UChar*          text,
+        int32_t         textLength,
+        int32_t         *parsePos /* 0 = start */,
+        UErrorCode      *status);
+
+/**
+* Parse a string into an int64 using a UNumberFormat.
+* The string will be parsed according to the UNumberFormat's locale.
+* @param fmt The formatter to use.
+* @param text The text to parse.
+* @param textLength The length of text, or -1 if null-terminated.
+* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The value of the parsed integer
+* @see unum_parse
+* @see unum_parseDouble
+* @see unum_format
+* @see unum_formatInt64
+* @see unum_formatDouble
+* @stable ICU 2.8
+*/
+U_STABLE int64_t U_EXPORT2 
+unum_parseInt64(const UNumberFormat*  fmt,
+        const UChar*  text,
+        int32_t       textLength,
+        int32_t       *parsePos /* 0 = start */,
+        UErrorCode    *status);
+
+/**
+* Parse a string into a double using a UNumberFormat.
+* The string will be parsed according to the UNumberFormat's locale.
+* @param fmt The formatter to use.
+* @param text The text to parse.
+* @param textLength The length of text, or -1 if null-terminated.
+* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
+* to begin parsing.  If not 0, on output the offset at which parsing ended.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The value of the parsed double
+* @see unum_parse
+* @see unum_parseInt64
+* @see unum_format
+* @see unum_formatInt64
+* @see unum_formatDouble
+* @stable ICU 2.0
+*/
+U_STABLE double U_EXPORT2 
+unum_parseDouble(    const   UNumberFormat*  fmt,
+            const   UChar*          text,
+            int32_t         textLength,
+            int32_t         *parsePos /* 0 = start */,
+            UErrorCode      *status);
+
+/**
+ * Parse a string into a double and a currency using a UNumberFormat.
+ * The string will be parsed according to the UNumberFormat's locale.
+ * @param fmt the formatter to use
+ * @param text the text to parse
+ * @param textLength the length of text, or -1 if null-terminated
+ * @param parsePos a pointer to an offset index into text at which to
+ * begin parsing. On output, *parsePos will point after the last
+ * parsed character.  This parameter may be 0, in which case parsing
+ * begins at offset 0.
+ * @param currency a pointer to the buffer to receive the parsed null-
+ * terminated currency.  This buffer must have a capacity of at least
+ * 4 UChars.
+ * @param status a pointer to an input-output UErrorCode
+ * @return the parsed double
+ * @see unum_parseDouble
+ * @see unum_formatDoubleCurrency
+ * @stable ICU 3.0
+ */
+U_STABLE double U_EXPORT2
+unum_parseDoubleCurrency(const UNumberFormat* fmt,
+                         const UChar* text,
+                         int32_t textLength,
+                         int32_t* parsePos, /* 0 = start */
+                         UChar* currency,
+                         UErrorCode* status);
+
+/**
+ * Set the pattern used by a UNumberFormat.  This can only be used
+ * on a DecimalFormat, other formats return U_ILLEGAL_ARGUMENT_ERROR
+ * in the status.
+ * @param format The formatter to set.
+ * @param localized TRUE if the pattern is localized, FALSE otherwise.
+ * @param pattern The new pattern
+ * @param patternLength The length of pattern, or -1 if null-terminated.
+ * @param parseError A pointer to UParseError to recieve information
+ * about errors occurred during parsing, or NULL if no parse error
+ * information is desired.
+ * @param status A pointer to an input-output UErrorCode.
+ * @see unum_toPattern
+ * @see DecimalFormat
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+unum_applyPattern(          UNumberFormat  *format,
+                            UBool          localized,
+                    const   UChar          *pattern,
+                            int32_t         patternLength,
+                            UParseError    *parseError,
+                            UErrorCode     *status
+                                    );
+
+/**
+* Get a locale for which decimal formatting patterns are available.
+* A UNumberFormat in a locale returned by this function will perform the correct
+* formatting and parsing for the locale.  The results of this call are not
+* valid for rule-based number formats.
+* @param index The index of the desired locale.
+* @return A locale for which number formatting patterns are available, or 0 if none.
+* @see unum_countAvailable
+* @stable ICU 2.0
+*/
+U_STABLE const char* U_EXPORT2 
+unum_getAvailable(int32_t index);
+
+/**
+* Determine how many locales have decimal formatting patterns available.  The
+* results of this call are not valid for rule-based number formats.
+* This function is useful for determining the loop ending condition for
+* calls to {@link #unum_getAvailable }.
+* @return The number of locales for which decimal formatting patterns are available.
+* @see unum_getAvailable
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+unum_countAvailable(void);
+
+/** The possible UNumberFormat numeric attributes @stable ICU 2.0 */
+typedef enum UNumberFormatAttribute {
+  /** Parse integers only */
+  UNUM_PARSE_INT_ONLY,
+  /** Use grouping separator */
+  UNUM_GROUPING_USED,
+  /** Always show decimal point */
+  UNUM_DECIMAL_ALWAYS_SHOWN,
+  /** Maximum integer digits */
+  UNUM_MAX_INTEGER_DIGITS,
+  /** Minimum integer digits */
+  UNUM_MIN_INTEGER_DIGITS,
+  /** Integer digits */
+  UNUM_INTEGER_DIGITS,
+  /** Maximum fraction digits */
+  UNUM_MAX_FRACTION_DIGITS,
+  /** Minimum fraction digits */
+  UNUM_MIN_FRACTION_DIGITS,
+  /** Fraction digits */
+  UNUM_FRACTION_DIGITS,
+  /** Multiplier */
+  UNUM_MULTIPLIER,
+  /** Grouping size */
+  UNUM_GROUPING_SIZE,
+  /** Rounding Mode */
+  UNUM_ROUNDING_MODE,
+  /** Rounding increment */
+  UNUM_ROUNDING_INCREMENT,
+  /** The width to which the output of <code>format()</code> is padded. */
+  UNUM_FORMAT_WIDTH,
+  /** The position at which padding will take place. */
+  UNUM_PADDING_POSITION,
+  /** Secondary grouping size */
+  UNUM_SECONDARY_GROUPING_SIZE,
+  /** Use significant digits
+   * @stable ICU 3.0 */
+  UNUM_SIGNIFICANT_DIGITS_USED,
+  /** Minimum significant digits
+   * @stable ICU 3.0 */
+  UNUM_MIN_SIGNIFICANT_DIGITS,
+  /** Maximum significant digits
+   * @stable ICU 3.0 */
+  UNUM_MAX_SIGNIFICANT_DIGITS,
+  /** Lenient parse mode used by rule-based formats.
+   * @stable ICU 3.0
+   */
+  UNUM_LENIENT_PARSE
+} UNumberFormatAttribute;
+
+/**
+* Get a numeric attribute associated with a UNumberFormat.
+* An example of a numeric attribute is the number of integer digits a formatter will produce.
+* @param fmt The formatter to query.
+* @param attr The attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED,
+* UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS,
+* UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER,
+* UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE.
+* @return The value of attr.
+* @see unum_setAttribute
+* @see unum_getDoubleAttribute
+* @see unum_setDoubleAttribute
+* @see unum_getTextAttribute
+* @see unum_setTextAttribute
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+unum_getAttribute(const UNumberFormat*          fmt,
+          UNumberFormatAttribute  attr);
+
+/**
+* Set a numeric attribute associated with a UNumberFormat.
+* An example of a numeric attribute is the number of integer digits a formatter will produce.  If the
+* formatter does not understand the attribute, the call is ignored.  Rule-based formatters only understand
+* the lenient-parse attribute.
+* @param fmt The formatter to set.
+* @param attr The attribute to set; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED,
+* UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS,
+* UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER,
+* UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE,
+* or UNUM_LENIENT_PARSE.
+* @param newValue The new value of attr.
+* @see unum_getAttribute
+* @see unum_getDoubleAttribute
+* @see unum_setDoubleAttribute
+* @see unum_getTextAttribute
+* @see unum_setTextAttribute
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+unum_setAttribute(    UNumberFormat*          fmt,
+            UNumberFormatAttribute  attr,
+            int32_t                 newValue);
+
+
+/**
+* Get a numeric attribute associated with a UNumberFormat.
+* An example of a numeric attribute is the number of integer digits a formatter will produce.
+* If the formatter does not understand the attribute, -1 is returned.
+* @param fmt The formatter to query.
+* @param attr The attribute to query; e.g. UNUM_ROUNDING_INCREMENT.
+* @return The value of attr.
+* @see unum_getAttribute
+* @see unum_setAttribute
+* @see unum_setDoubleAttribute
+* @see unum_getTextAttribute
+* @see unum_setTextAttribute
+* @stable ICU 2.0
+*/
+U_STABLE double U_EXPORT2 
+unum_getDoubleAttribute(const UNumberFormat*          fmt,
+          UNumberFormatAttribute  attr);
+
+/**
+* Set a numeric attribute associated with a UNumberFormat.
+* An example of a numeric attribute is the number of integer digits a formatter will produce.
+* If the formatter does not understand the attribute, this call is ignored.
+* @param fmt The formatter to set.
+* @param attr The attribute to set; e.g. UNUM_ROUNDING_INCREMENT.
+* @param newValue The new value of attr.
+* @see unum_getAttribute
+* @see unum_setAttribute
+* @see unum_getDoubleAttribute
+* @see unum_getTextAttribute
+* @see unum_setTextAttribute
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+unum_setDoubleAttribute(    UNumberFormat*          fmt,
+            UNumberFormatAttribute  attr,
+            double                 newValue);
+
+/** The possible UNumberFormat text attributes @stable ICU 2.0*/
+typedef enum UNumberFormatTextAttribute {
+  /** Positive prefix */
+  UNUM_POSITIVE_PREFIX,
+  /** Positive suffix */
+  UNUM_POSITIVE_SUFFIX,
+  /** Negative prefix */
+  UNUM_NEGATIVE_PREFIX,
+  /** Negative suffix */
+  UNUM_NEGATIVE_SUFFIX,
+  /** The character used to pad to the format width. */
+  UNUM_PADDING_CHARACTER,
+  /** The ISO currency code */
+  UNUM_CURRENCY_CODE,
+  /**
+   * The default rule set.  This is only available with rule-based formatters.
+   * @stable ICU 3.0
+   */
+  UNUM_DEFAULT_RULESET,
+  /**
+   * The public rule sets.  This is only available with rule-based formatters.
+   * This is a read-only attribute.  The public rulesets are returned as a
+   * single string, with each ruleset name delimited by ';' (semicolon).
+   * @stable ICU 3.0
+   */
+  UNUM_PUBLIC_RULESETS
+} UNumberFormatTextAttribute;
+
+/**
+* Get a text attribute associated with a UNumberFormat.
+* An example of a text attribute is the suffix for positive numbers.  If the formatter
+* does not understand the attributre, U_UNSUPPORTED_ERROR is returned as the status.
+* Rule-based formatters only understand UNUM_DEFAULT_RULESET and UNUM_PUBLIC_RULESETS.
+* @param fmt The formatter to query.
+* @param tag The attribute to query; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX,
+* UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE,
+* UNUM_DEFAULT_RULESET, or UNUM_PUBLIC_RULESETS.
+* @param result A pointer to a buffer to receive the attribute.
+* @param resultLength The maximum size of result.
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The total buffer size needed; if greater than resultLength, the output was truncated.
+* @see unum_setTextAttribute
+* @see unum_getAttribute
+* @see unum_setAttribute
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2 
+unum_getTextAttribute(    const    UNumberFormat*                    fmt,
+            UNumberFormatTextAttribute      tag,
+            UChar*                            result,
+            int32_t                            resultLength,
+            UErrorCode*                        status);
+
+/**
+* Set a text attribute associated with a UNumberFormat.
+* An example of a text attribute is the suffix for positive numbers.  Rule-based formatters
+* only understand UNUM_DEFAULT_RULESET.
+* @param fmt The formatter to set.
+* @param tag The attribute to set; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX,
+* UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE,
+* or UNUM_DEFAULT_RULESET.
+* @param newValue The new value of attr.
+* @param newValueLength The length of newValue, or -1 if null-terminated.
+* @param status A pointer to an UErrorCode to receive any errors
+* @see unum_getTextAttribute
+* @see unum_getAttribute
+* @see unum_setAttribute
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2 
+unum_setTextAttribute(    UNumberFormat*                    fmt,
+            UNumberFormatTextAttribute      tag,
+            const    UChar*                            newValue,
+            int32_t                            newValueLength,
+            UErrorCode                        *status);
+
+/**
+ * Extract the pattern from a UNumberFormat.  The pattern will follow
+ * the DecimalFormat pattern syntax.
+ * @param fmt The formatter to query.
+ * @param isPatternLocalized TRUE if the pattern should be localized,
+ * FALSE otherwise.  This is ignored if the formatter is a rule-based
+ * formatter.
+ * @param result A pointer to a buffer to receive the pattern.
+ * @param resultLength The maximum size of result.
+ * @param status A pointer to an input-output UErrorCode.
+ * @return The total buffer size needed; if greater than resultLength,
+ * the output was truncated.
+ * @see unum_applyPattern
+ * @see DecimalFormat
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+unum_toPattern(    const    UNumberFormat*          fmt,
+        UBool                  isPatternLocalized,
+        UChar*                  result,
+        int32_t                 resultLength,
+        UErrorCode*             status);
+
+
+/**
+ * Constants for specifying a number format symbol.
+ * @stable ICU 2.0
+ */
+typedef enum UNumberFormatSymbol {
+  /** The decimal separator */
+  UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
+  /** The grouping separator */
+  UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
+  /** The pattern separator */
+  UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
+  /** The percent sign */
+  UNUM_PERCENT_SYMBOL = 3,
+  /** Zero*/
+  UNUM_ZERO_DIGIT_SYMBOL = 4,
+  /** Character representing a digit in the pattern */
+  UNUM_DIGIT_SYMBOL = 5,
+  /** The minus sign */
+  UNUM_MINUS_SIGN_SYMBOL = 6,
+  /** The plus sign */
+  UNUM_PLUS_SIGN_SYMBOL = 7,
+  /** The currency symbol */
+  UNUM_CURRENCY_SYMBOL = 8,
+  /** The international currency symbol */
+  UNUM_INTL_CURRENCY_SYMBOL = 9,
+  /** The monetary separator */
+  UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
+  /** The exponential symbol */
+  UNUM_EXPONENTIAL_SYMBOL = 11,
+  /** Per mill symbol */
+  UNUM_PERMILL_SYMBOL = 12,
+  /** Escape padding character */
+  UNUM_PAD_ESCAPE_SYMBOL = 13,
+  /** Infinity symbol */
+  UNUM_INFINITY_SYMBOL = 14,
+  /** Nan symbol */
+  UNUM_NAN_SYMBOL = 15,
+  /** Significant digit symbol
+   * @stable ICU 3.0 */
+  UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
+  /** The monetary grouping separator 
+   * @stable ICU 3.6
+   */
+  UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,  
+  /** count symbol constants */
+  UNUM_FORMAT_SYMBOL_COUNT = 18
+} UNumberFormatSymbol;
+
+/**
+* Get a symbol associated with a UNumberFormat.
+* A UNumberFormat uses symbols to represent the special locale-dependent
+* characters in a number, for example the percent sign. This API is not
+* supported for rule-based formatters.
+* @param fmt The formatter to query.
+* @param symbol The UNumberFormatSymbol constant for the symbol to get
+* @param buffer The string buffer that will receive the symbol string;
+*               if it is NULL, then only the length of the symbol is returned
+* @param size The size of the string buffer
+* @param status A pointer to an UErrorCode to receive any errors
+* @return The length of the symbol; the buffer is not modified if
+*         <code>length&gt;=size</code>
+* @see unum_setSymbol
+* @stable ICU 2.0
+*/
+U_STABLE int32_t U_EXPORT2
+unum_getSymbol(const UNumberFormat *fmt,
+               UNumberFormatSymbol symbol,
+               UChar *buffer,
+               int32_t size,
+               UErrorCode *status);
+
+/**
+* Set a symbol associated with a UNumberFormat.
+* A UNumberFormat uses symbols to represent the special locale-dependent
+* characters in a number, for example the percent sign.  This API is not
+* supported for rule-based formatters.
+* @param fmt The formatter to set.
+* @param symbol The UNumberFormatSymbol constant for the symbol to set
+* @param value The string to set the symbol to
+* @param length The length of the string, or -1 for a zero-terminated string
+* @param status A pointer to an UErrorCode to receive any errors.
+* @see unum_getSymbol
+* @stable ICU 2.0
+*/
+U_STABLE void U_EXPORT2
+unum_setSymbol(UNumberFormat *fmt,
+               UNumberFormatSymbol symbol,
+               const UChar *value,
+               int32_t length,
+               UErrorCode *status);
+
+
+/**
+ * Get the locale for this number format object.
+ * You can choose between valid and actual locale.
+ * @param fmt The formatter to get the locale from
+ * @param type type of the locale we're looking for (valid or actual) 
+ * @param status error code for the operation
+ * @return the locale name
+ * @stable ICU 2.8
+ */
+U_STABLE const char* U_EXPORT2
+unum_getLocaleByType(const UNumberFormat *fmt,
+                     ULocDataLocaleType type,
+                     UErrorCode* status); 
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uobject.h b/CoreFoundation/icu/unicode/uobject.h
new file mode 100644
index 0000000..3d8b96e
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uobject.h
@@ -0,0 +1,308 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 2002-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*   file name:  uobject.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2002jun26
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __UOBJECT_H__
+#define __UOBJECT_H__
+
+#include "unicode/utypes.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * \file
+ * \brief C++ API: Common ICU base class UObject.
+ */
+
+/**  U_OVERRIDE_CXX_ALLOCATION - Define this to override operator new and
+ *                               delete in UMemory. Enabled by default for ICU.
+ *
+ *         Enabling forces all allocation of ICU object types to use ICU's
+ *         memory allocation. On Windows, this allows the ICU DLL to be used by
+ *         applications that statically link the C Runtime library, meaning that
+ *         the app and ICU will be using different heaps.
+ *
+ * @stable ICU 2.2
+ */                              
+#ifndef U_OVERRIDE_CXX_ALLOCATION
+#define U_OVERRIDE_CXX_ALLOCATION 1
+#endif
+
+/**  U_HAVE_PLACEMENT_NEW - Define this to define the placement new and
+ *                          delete in UMemory for STL.
+ *
+ * @stable ICU 2.6
+ */                              
+#ifndef U_HAVE_PLACEMENT_NEW
+#define U_HAVE_PLACEMENT_NEW 1
+#endif
+
+
+/**  U_HAVE_DEBUG_LOCATION_NEW - Define this to define the MFC debug
+ * version of the operator new.
+ *
+ * @stable ICU 3.4
+ */                              
+#ifndef U_HAVE_DEBUG_LOCATION_NEW
+#define U_HAVE_DEBUG_LOCATION_NEW 0
+#endif
+
+/**
+ * UMemory is the common ICU base class.
+ * All other ICU C++ classes are derived from UMemory (starting with ICU 2.4).
+ *
+ * This is primarily to make it possible and simple to override the
+ * C++ memory management by adding new/delete operators to this base class.
+ *
+ * To override ALL ICU memory management, including that from plain C code,
+ * replace the allocation functions declared in cmemory.h
+ *
+ * UMemory does not contain any virtual functions.
+ * Common "boilerplate" functions are defined in UObject.
+ *
+ * @stable ICU 2.4
+ */
+class U_COMMON_API UMemory {
+public:
+
+#if U_OVERRIDE_CXX_ALLOCATION
+    /**
+     * Override for ICU4C C++ memory management.
+     * simple, non-class types are allocated using the macros in common/cmemory.h
+     * (uprv_malloc(), uprv_free(), uprv_realloc());
+     * they or something else could be used here to implement C++ new/delete
+     * for ICU4C C++ classes
+     * @stable ICU 2.4
+     */
+    static void * U_EXPORT2 operator new(size_t size);
+
+    /**
+     * Override for ICU4C C++ memory management.
+     * See new().
+     * @stable ICU 2.4
+     */
+    static void * U_EXPORT2 operator new[](size_t size);
+
+    /**
+     * Override for ICU4C C++ memory management.
+     * simple, non-class types are allocated using the macros in common/cmemory.h
+     * (uprv_malloc(), uprv_free(), uprv_realloc());
+     * they or something else could be used here to implement C++ new/delete
+     * for ICU4C C++ classes
+     * @stable ICU 2.4
+     */
+    static void U_EXPORT2 operator delete(void *p);
+
+    /**
+     * Override for ICU4C C++ memory management.
+     * See delete().
+     * @stable ICU 2.4
+     */
+    static void U_EXPORT2 operator delete[](void *p);
+
+#if U_HAVE_PLACEMENT_NEW
+    /**
+     * Override for ICU4C C++ memory management for STL.
+     * See new().
+     * @stable ICU 2.6
+     */
+    static inline void * U_EXPORT2 operator new(size_t, void *ptr) { return ptr; }
+
+    /**
+     * Override for ICU4C C++ memory management for STL.
+     * See delete().
+     * @stable ICU 2.6
+     */
+    static inline void U_EXPORT2 operator delete(void *, void *) {}
+#endif /* U_HAVE_PLACEMENT_NEW */
+#if U_HAVE_DEBUG_LOCATION_NEW
+    /**
+      * This method overrides the MFC debug version of the operator new
+      * 
+      * @param size   The requested memory size
+      * @param file   The file where the allocation was requested
+      * @param line   The line where the allocation was requested 
+      */ 
+    static void * U_EXPORT2 operator new(size_t size, const char* file, int line);
+    /**
+      * This method provides a matching delete for the MFC debug new
+      * 
+      * @param p      The pointer to the allocated memory
+      * @param file   The file where the allocation was requested
+      * @param line   The line where the allocation was requested 
+      */ 
+    static void U_EXPORT2 operator delete(void* p, const char* file, int line);
+#endif /* U_HAVE_DEBUG_LOCATION_NEW */
+#endif /* U_OVERRIDE_CXX_ALLOCATION */
+
+    /*
+     * Assignment operator not declared. The compiler will provide one
+     * which does nothing since this class does not contain any data members.
+     * API/code coverage may show the assignment operator as present and
+     * untested - ignore.
+     * Subclasses need this assignment operator if they use compiler-provided
+     * assignment operators of their own. An alternative to not declaring one
+     * here would be to declare and empty-implement a protected or public one.
+    UMemory &UMemory::operator=(const UMemory &);
+     */
+};
+
+/**
+ * UObject is the common ICU "boilerplate" class.
+ * UObject inherits UMemory (starting with ICU 2.4),
+ * and all other public ICU C++ classes
+ * are derived from UObject (starting with ICU 2.2).
+ *
+ * UObject contains common virtual functions like for ICU's "poor man's RTTI".
+ * It does not contain default implementations of virtual methods
+ * like getDynamicClassID to allow derived classes such as Format
+ * to declare these as pure virtual.
+ *
+ * The clone() function is not available in UObject because it is not
+ * implemented by all ICU classes.
+ * Many ICU services provide a clone() function for their class trees,
+ * defined on the service's C++ base class, and all subclasses within that
+ * service class tree return a pointer to the service base class
+ * (which itself is a subclass of UObject).
+ * This is because some compilers do not support covariant (same-as-this)
+ * return types; cast to the appropriate subclass if necessary.
+ *
+ * @stable ICU 2.2
+ */
+class U_COMMON_API UObject : public UMemory {
+public:
+    /**
+     * Destructor.
+     *
+     * @stable ICU 2.2
+     */
+    virtual ~UObject();
+
+    /**
+     * ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual UClassID getDynamicClassID() const = 0;
+
+protected:
+    // the following functions are protected to prevent instantiation and
+    // direct use of UObject itself
+
+    // default constructor
+    // commented out because UObject is abstract (see getDynamicClassID)
+    // inline UObject() {}
+
+    // copy constructor
+    // commented out because UObject is abstract (see getDynamicClassID)
+    // inline UObject(const UObject &other) {}
+
+#if 0
+    // TODO Sometime in the future. Implement operator==().
+    // (This comment inserted in 2.2)
+    // some or all of the following "boilerplate" functions may be made public
+    // in a future ICU4C release when all subclasses implement them
+
+    // assignment operator
+    // (not virtual, see "Taligent's Guide to Designing Programs" pp.73..74)
+    // commented out because the implementation is the same as a compiler's default
+    // UObject &operator=(const UObject &other) { return *this; }
+
+    // comparison operators
+    virtual inline UBool operator==(const UObject &other) const { return this==&other; }
+    inline UBool operator!=(const UObject &other) const { return !operator==(other); }
+
+    // clone() commented out from the base class:
+    // some compilers do not support co-variant return types
+    // (i.e., subclasses would have to return UObject * as well, instead of SubClass *)
+    // see also UObject class documentation.
+    // virtual UObject *clone() const;
+#endif
+
+    /*
+     * Assignment operator not declared. The compiler will provide one
+     * which does nothing since this class does not contain any data members.
+     * API/code coverage may show the assignment operator as present and
+     * untested - ignore.
+     * Subclasses need this assignment operator if they use compiler-provided
+     * assignment operators of their own. An alternative to not declaring one
+     * here would be to declare and empty-implement a protected or public one.
+    UObject &UObject::operator=(const UObject &);
+     */
+
+// Future implementation for RTTI that support subtyping. [alan]
+// 
+//  public:
+//     /**
+//      * @internal
+//      */
+//     static UClassID getStaticClassID();
+// 
+//     /**
+//      * @internal
+//      */
+//     UBool instanceOf(UClassID type) const;
+};
+
+/**
+ * This is a simple macro to add ICU RTTI to an ICU object implementation.
+ * This does not go into the header. This should only be used in *.cpp files.
+ *
+ * @param myClass The name of the class that needs RTTI defined.
+ * @internal
+ */
+#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass) \
+    UClassID U_EXPORT2 myClass::getStaticClassID() { \
+        static char classID = 0; \
+        return (UClassID)&classID; \
+    } \
+    UClassID myClass::getDynamicClassID() const \
+    { return myClass::getStaticClassID(); }
+
+
+/**
+ * This macro adds ICU RTTI to an ICU abstract class implementation.
+ * This macro should be invoked in *.cpp files.  The corresponding
+ * header should declare getStaticClassID.
+ *
+ * @param myClass The name of the class that needs RTTI defined.
+ * @internal
+ */
+#define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass) \
+    UClassID U_EXPORT2 myClass::getStaticClassID() { \
+        static char classID = 0; \
+        return (UClassID)&classID; \
+    }
+
+// /**
+//  * This macro adds ICU RTTI to an ICU concrete class implementation.
+//  * This macro should be invoked in *.cpp files.  The corresponding
+//  * header should declare getDynamicClassID and getStaticClassID.
+//  *
+//  * @param myClass The name of the class that needs RTTI defined.
+//  * @param myParent The name of the myClass's parent.
+//  * @internal
+//  */
+/*#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass, myParent) \
+    UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass, myParent) \
+    UClassID myClass::getDynamicClassID() const { \
+        return myClass::getStaticClassID(); \
+    }
+*/
+
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uobslete.h b/CoreFoundation/icu/unicode/uobslete.h
new file mode 100644
index 0000000..91be243
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uobslete.h
@@ -0,0 +1,32 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2004-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Created by: genheaders.pl, a perl script written by Ram Viswanadha
+*
+*  Contains data for commenting out APIs.
+*  Gets included by umachine.h
+*
+*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
+*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
+*/
+
+#ifndef UOBSLETE_H
+#define UOBSLETE_H
+
+#ifdef U_HIDE_OBSOLETE_API
+
+#    if U_DISABLE_RENAMING
+#    else
+#    endif /* U_DISABLE_RENAMING */
+
+#endif /* U_HIDE_OBSOLETE_API */
+#endif /* UOBSLETE_H */
+
diff --git a/CoreFoundation/icu/unicode/urbtok.h b/CoreFoundation/icu/unicode/urbtok.h
new file mode 100755
index 0000000..936ddde
--- /dev/null
+++ b/CoreFoundation/icu/unicode/urbtok.h
@@ -0,0 +1,126 @@
+/*
+******************************************************************************
+* Copyright (C) 2006-2008 Apple Inc. All Rights Reserved.
+******************************************************************************
+*/
+
+#ifndef URBTOK_H
+#define URBTOK_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+#include "unicode/utext.h"
+#include "unicode/ubrk.h"
+#include "unicode/parseerr.h"
+
+
+typedef struct RuleBasedTokenRange {
+    signed long location;
+    signed long length;
+} RuleBasedTokenRange;
+
+/**
+ * Open a new UBreakIterator for tokenizing text using specified breaking rules.
+ * The rule syntax is ... (TBD)
+ * @param rules A set of rules specifying the text breaking conventions.
+ * @param rulesLength The number of characters in rules, or -1 if null-terminated.
+ * @param parseErr   Receives position and context information for any syntax errors
+ *                   detected while parsing the rules.
+ * @param status A UErrorCode to receive any errors.
+ * @return A UBreakIterator for the specified rules.
+ * @see ubrk_open
+ * @internal
+ */
+U_INTERNAL UBreakIterator* U_EXPORT2
+urbtok_openRules(const UChar     *rules,
+               int32_t         rulesLength,
+               UParseError     *parseErr,
+               UErrorCode      *status);
+
+/**
+ * Open a new UBreakIterator for tokenizing text using specified breaking rules.
+ * @param rules A set of rules specifying the text breaking conventions. The binary rules
+ *              must be at least 32-bit aligned. Note: This version makes a copy of the
+ *				rules, so after calling this function the caller can close or release
+ *				the rules that were passed to this function. The copy created by this
+ *				call will be freed when ubrk_close() is called on the UBreakIterator*.
+ * @param status A UErrorCode to receive any errors.
+ * @return A UBreakIterator for the specified rules.
+ * @see ubrk_open
+ * @internal
+ */
+U_INTERNAL UBreakIterator* U_EXPORT2
+urbtok_openBinaryRules(const uint8_t *rules,
+               UErrorCode      *status);
+
+/**
+ * Open a new UBreakIterator for tokenizing text using specified breaking rules.
+ * @param rules A set of rules specifying the text breaking conventions. The binary rules
+ *              must be at least 32-bit aligned. Note: This version does NOT make a copy
+ *				of the rules, so after calling this function the caller must not close or
+ *				release the rules passed to this function until after they are finished
+ *				with this UBreakIterator* (and any others created using the same rules)
+  *				and have called ubrk_close() to close the UBreakIterator* (and any others
+ *				using the same rules).
+ * @param status A UErrorCode to receive any errors.
+ * @return A UBreakIterator for the specified rules.
+ * @see ubrk_open
+ * @internal
+ */
+U_INTERNAL UBreakIterator* U_EXPORT2
+urbtok_openBinaryRulesNoCopy(const uint8_t *rules,
+               UErrorCode      *status);
+
+/**
+ * Get the (native-endian) binary break rules for this tokenizer.
+ * @param bi The tokenizer to use.
+ * @param buffer The output buffer for the rules. You can pass 0 to get the required size.
+ * @param buffSize The size of the output buffer.
+ * @param status A UErrorCode to receive any errors.
+ * @return The actual size of the binary rules, whether they fit the buffer or not.
+ * @internal
+ */
+U_INTERNAL uint32_t U_EXPORT2
+urbtok_getBinaryRules(UBreakIterator      *bi,
+                uint8_t             *buffer,
+                uint32_t            buffSize,
+                UErrorCode          *status);
+
+/**
+ * Tokenize text using a rule-based tokenizer.
+ * @param bi The tokenizer to use.
+ * @param maxTokens The maximum number of tokens to return.
+ * @param outTokens An array of RuleBasedTokenRange to fill in with the tokens.
+ * @param outTokenFlags An (optional) array of uint32_t to fill in with token flags.
+ * @return The number of tokens returned, 0 if done.
+ * @internal
+ */
+U_INTERNAL int32_t U_EXPORT2
+urbtok_tokenize(UBreakIterator      *bi,
+               int32_t              maxTokens,
+               RuleBasedTokenRange  *outTokens,
+               unsigned long        *outTokenFlags);
+
+/**
+ * Swap the endianness of a set of binary break rules.
+ * @param rules A set of rules which need swapping.
+ * @param buffer The output buffer for the swapped rules, which must be the same
+ *               size as the input rules buffer.
+ * @param inIsBigEndian UBool indicating whether the input is big-endian
+ * @param outIsBigEndian UBool indicating whether the output should be big-endian
+ * @param status A UErrorCode to receive any errors.
+ * @internal
+ */
+U_INTERNAL void U_EXPORT2
+urbtok_swapBinaryRules(const uint8_t *rules,
+               uint8_t          *buffer,
+               UBool            inIsBigEndian,
+               UBool            outIsBigEndian,
+               UErrorCode       *status);
+
+
+#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uregex.h b/CoreFoundation/icu/unicode/uregex.h
new file mode 100644
index 0000000..d646047
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uregex.h
@@ -0,0 +1,989 @@
+/*
+**********************************************************************
+*   Copyright (C) 2004-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*   file name:  regex.h
+*   encoding:   US-ASCII
+*   indentation:4
+*
+*   created on: 2004mar09
+*   created by: Andy Heninger
+*
+*   ICU Regular Expressions, API for C
+*/
+
+/**
+ * \file
+ * \brief C API: Regular Expressions
+ *
+ * <p>This is a C wrapper around the C++ RegexPattern and RegexMatcher classes.</p>
+ */
+
+#ifndef UREGEX_H
+#define UREGEX_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_REGULAR_EXPRESSIONS
+
+#include "unicode/parseerr.h"
+
+struct URegularExpression;
+/**
+  * Structure represeting a compiled regular rexpression, plus the results
+  *    of a match operation.
+  * @stable ICU 3.0
+  */
+typedef struct URegularExpression URegularExpression;
+
+
+/**
+ * Constants for Regular Expression Match Modes.
+ * @stable ICU 2.4
+ */
+typedef enum URegexpFlag{
+
+#ifndef U_HIDE_DRAFT_API 
+    /** Forces normalization of pattern and strings. 
+    Not implemented yet, just a placeholder, hence draft. 
+    @draft ICU 2.4 */
+    UREGEX_CANON_EQ         = 128,
+#endif
+    /**  Enable case insensitive matching.  @stable ICU 2.4 */
+    UREGEX_CASE_INSENSITIVE = 2,
+
+    /**  Allow white space and comments within patterns  @stable ICU 2.4 */
+    UREGEX_COMMENTS         = 4,
+
+    /**  If set, '.' matches line terminators,  otherwise '.' matching stops at line end.
+      *  @stable ICU 2.4 */
+    UREGEX_DOTALL           = 32,
+    
+    /**  If set, treat the entire pattern as a literal string.  
+      *  Metacharacters or escape sequences in the input sequence will be given 
+      *  no special meaning.
+      *
+      *  The flags CASE_INSENSITIVE and UNICODE_CASE retain their impact
+      *  on matching when used in conjunction with this flag.
+      *  The other flags become superfluous.
+      *  TODO:  say which escapes are still handled; anything Java does
+      *         early (\u) we should still do.
+      * @draft ICU 4.0
+      */
+    UREGEX_LITERAL = 16,
+
+    /**   Control behavior of "$" and "^"
+      *    If set, recognize line terminators within string,
+      *    otherwise, match only at start and end of input string.
+      *   @stable ICU 2.4 */
+    UREGEX_MULTILINE        = 8,
+    
+    /**   Unix-only line endings.
+      *   When this mode is enabled, only \u000a is recognized as a line ending
+      *    in the behavior of ., ^, and $.
+      *   @draft ICU 4.0
+      */
+    UREGEX_UNIX_LINES = 1,
+
+    /**  Unicode word boundaries.
+      *     If set, \b uses the Unicode TR 29 definition of word boundaries.
+      *     Warning: Unicode word boundaries are quite different from
+      *     traditional regular expression word boundaries.  See
+      *     http://unicode.org/reports/tr29/#Word_Boundaries
+      *     @stable ICU 2.8
+      */
+    UREGEX_UWORD            = 256,
+
+     /**  Error on Unrecognized backslash escapes.
+       *     If set, fail with an error on patterns that contain
+       *     backslash-escaped ASCII letters without a known specail
+       *     meaning.  If this flag is not set, these
+       *     escaped letters represent themselves.
+       *     @draft ICU 4.0
+       */
+     UREGEX_ERROR_ON_UNKNOWN_ESCAPES = 512
+
+}  URegexpFlag;
+
+/**
+  *  Open (compile) an ICU regular expression.  Compiles the regular expression in
+  *  string form into an internal representation using the specified match mode flags.
+  *  The resulting regular expression handle can then be used to perform various
+  *   matching operations.
+  *
+  * @param pattern        The Regular Expression pattern to be compiled. 
+  * @param patternLength  The length of the pattern, or -1 if the pattern is
+  *                       NUL termintated.
+  * @param flags          Flags that alter the default matching behavior for
+  *                       the regular expression, UREGEX_CASE_INSENSITIVE, for
+  *                       example.  For default behavior, set this parameter to zero.
+  *                       See <code>enum URegexpFlag</code>.  All desired flags
+  *                       are bitwise-ORed together.
+  * @param pe             Receives the position (line and column nubers) of any syntax
+  *                       error within the source regular expression string.  If this
+  *                       information is not wanted, pass NULL for this parameter.
+  * @param status         Receives error detected by this function.
+  * @stable ICU 3.0
+  *
+  */
+U_STABLE URegularExpression * U_EXPORT2
+uregex_open( const  UChar          *pattern,
+                    int32_t         patternLength,
+                    uint32_t        flags,
+                    UParseError    *pe,
+                    UErrorCode     *status);
+
+/**
+  *  Open (compile) an ICU regular expression.  The resulting regular expression
+  *   handle can then be used to perform various matching operations.
+  *  <p>
+  *   This function is the same as uregex_open, except that the pattern
+  *   is supplied as an 8 bit char * string in the default code page.
+  *
+  * @param pattern        The Regular Expression pattern to be compiled, 
+  *                       NUL termintated.  
+  * @param flags          Flags that alter the default matching behavior for
+  *                       the regular expression, UREGEX_CASE_INSENSITIVE, for
+  *                       example.  For default behavior, set this parameter to zero.
+  *                       See <code>enum URegexpFlag</code>.  All desired flags
+  *                       are bitwise-ORed together.
+  * @param pe             Receives the position (line and column nubers) of any syntax
+  *                       error within the source regular expression string.  If this
+  *                       information is not wanted, pass NULL for this parameter.
+  * @param status         Receives errors detected by this function.
+  * @return               The URegularExpression object representing the compiled
+  *                       pattern.
+  *
+  * @stable ICU 3.0
+  */
+#if !UCONFIG_NO_CONVERSION
+U_STABLE URegularExpression * U_EXPORT2
+uregex_openC( const char           *pattern,
+                    uint32_t        flags,
+                    UParseError    *pe,
+                    UErrorCode     *status);
+#endif
+
+
+
+/**
+  *  Close the regular expression, recovering all resources (memory) it
+  *   was holding.
+  *
+  * @param regexp   The regular expression to be closed.
+  * @stable ICU 3.0
+  */
+U_STABLE void U_EXPORT2 
+uregex_close(URegularExpression *regexp);
+
+/**
+ * Make a copy of a compiled regular expression.  Cloning a regular
+ * expression is faster than opening a second instance from the source
+ * form of the expression, and requires less memory.
+ * <p>
+ * Note that the current input string and the position of any matched text
+ *  within it are not cloned; only the pattern itself and and the
+ *  match mode flags are copied.
+ * <p>
+ * Cloning can be particularly useful to threaded applications that perform
+ * multiple match operations in parallel.  Each concurrent RE
+ * operation requires its own instance of a URegularExpression.
+ *
+ * @param regexp   The compiled regular expression to be cloned.
+ * @param status   Receives indication of any errors encountered
+ * @return the cloned copy of the compiled regular expression.
+ * @stable ICU 3.0
+ */
+U_STABLE URegularExpression * U_EXPORT2 
+uregex_clone(const URegularExpression *regexp, UErrorCode *status);
+
+/**
+ *  Return a pointer to the source form of the pattern for this regular expression.
+ *
+ * @param regexp     The compiled regular expression.
+ * @param patLength  This output parameter will be set to the length of the
+ *                   pattern string.  A NULL pointer may be used here if the
+ *                   pattern length is not needed, as would be the case if
+ *                   the pattern is known in advance to be a NUL terminated
+ *                   string.
+ * @param status     Receives errors detected by this function.
+ * @return a pointer to the pattern string.  The storage for the string is
+ *                   owned by the regular expression object, and must not be
+ *                   altered or deleted by the application.  The returned string
+ *                   will remain valid until the regular expression is closed.
+ * @stable ICU 3.0
+ */
+U_STABLE const UChar * U_EXPORT2 
+uregex_pattern(const  URegularExpression   *regexp,
+                         int32_t           *patLength,
+                         UErrorCode        *status);
+
+
+/**
+  * Get the match mode flags that were specified when compiling this regular expression.
+  * @param status   Receives errors detected by this function.
+  * @param regexp   The compiled regular expression.
+  * @return         The match mode flags
+  * @see URegexpFlag
+  * @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_flags(const  URegularExpression   *regexp,
+                    UErrorCode           *status);
+
+
+/**
+  *  Set the subject text string upon which the regular expression will look for matches.
+  *  This function may be called any number of times, allowing the regular
+  *  expression pattern to be applied to different strings.
+  *  <p>
+  *  Regular expression matching operations work directly on the application's
+  *  string data.  No copy is made.  The subject string data must not be
+  *  altered after calling this function until after all regular expression
+  *  operations involving this string data are completed.  
+  *  <p>
+  *  Zero length strings are permitted.  In this case, no subsequent match
+  *  operation will dereference the text string pointer.
+  *
+  * @param regexp     The compiled regular expression.
+  * @param text       The subject text string.
+  * @param textLength The length of the subject text, or -1 if the string
+  *                   is NUL terminated.
+  * @param status     Receives errors detected by this function.
+  * @stable ICU 3.0
+  */
+U_STABLE void U_EXPORT2 
+uregex_setText(URegularExpression *regexp,
+               const UChar        *text,
+               int32_t             textLength,
+               UErrorCode         *status);
+
+/**
+  *  Get the subject text that is currently associated with this 
+  *   regular expression object.  This simply returns whatever string
+  *   pointer was previously supplied via uregex_setText().
+  *
+  * @param regexp      The compiled regular expression.
+  * @param textLength  The length of the string is returned in this output parameter. 
+  *                    A NULL pointer may be used here if the
+  *                    text length is not needed, as would be the case if
+  *                    the text is known in advance to be a NUL terminated
+  *                    string.
+  * @param status      Receives errors detected by this function.
+  * @return            Poiner to the subject text string currently associated with
+  *                    this regular expression.
+  * @stable ICU 3.0
+  */
+U_STABLE const UChar * U_EXPORT2 
+uregex_getText(URegularExpression *regexp,
+               int32_t            *textLength,
+               UErrorCode         *status);
+
+/**
+  *   Attempts to match the input string against the pattern.
+  *   To succeed, the match must extend to the end of the string,
+  *   or cover the complete match region.
+  *
+  *   If startIndex >= zero the match operation starts at the specified
+  *   index and must extend to the end of the input string.  Any region
+  *   that has been specified is reset.
+  *
+  *   If startIndex == -1 the match must cover the input region, or the entire
+  *   input string if no region has been set.  This directly corresponds to
+  *   Matcher.matches() in Java
+  *
+  *    @param  regexp      The compiled regular expression.
+  *    @param  startIndex  The input string index at which to begin matching, or -1
+  *                        to match the input Region.
+  *    @param  status      Receives errors detected by this function.
+  *    @return             TRUE if there is a match
+  *    @stable ICU 3.0
+  */
+U_STABLE UBool U_EXPORT2 
+uregex_matches(URegularExpression *regexp,
+                int32_t            startIndex,
+                UErrorCode        *status);
+
+/**
+  *   Attempts to match the input string, starting from the specified index, against the pattern.
+  *   The match may be of any length, and is not required to extend to the end
+  *   of the input string.  Contrast with uregex_matches().
+  *
+  *   <p>If startIndex is >= 0 any input region that was set for this
+  *   URegularExpression is reset before the operation begins.
+  *
+  *   <p>If the specified starting index == -1 the match begins at the start of the input 
+  *   region, or at the start of the full string if no region has been specified.
+  *   This corresponds directly with Matcher.lookingAt() in Java.
+  *
+  *   <p>If the match succeeds then more information can be obtained via the
+  *    <code>uregexp_start()</code>, <code>uregexp_end()</code>,
+  *    and <code>uregexp_group()</code> functions.</p>
+  *
+  *    @param   regexp      The compiled regular expression.
+  *    @param   startIndex  The input string index at which to begin matching, or
+  *                         -1 to match the Input Region
+  *    @param   status      A reference to a UErrorCode to receive any errors.
+  *    @return  TRUE if there is a match.
+  *    @stable ICU 3.0
+  */
+U_STABLE UBool U_EXPORT2 
+uregex_lookingAt(URegularExpression *regexp,
+                 int32_t             startIndex,
+                 UErrorCode         *status);
+
+/**
+  *   Find the first matching substring of the input string that matches the pattern.
+  *   If startIndex is >= zero the search for a match begins at the specified index,
+  *          and any match region is reset.  This corresponds directly with
+  *          Matcher.find(startIndex) in Java.
+  *
+  *   If startIndex == -1 the search begins at the start of the input region,
+  *           or at the start of the full string if no region has been specified.
+  *
+  *   If a match is found, <code>uregex_start(), uregex_end()</code>, and
+  *   <code>uregex_group()</code> will provide more information regarding the match.
+  *
+  *   @param   regexp      The compiled regular expression.
+  *   @param   startIndex  The position in the input string to begin the search, or
+  *                        -1 to search within the Input Region.
+  *   @param   status      A reference to a UErrorCode to receive any errors.
+  *   @return              TRUE if a match is found.
+  *   @stable ICU 3.0
+  */
+U_STABLE UBool U_EXPORT2 
+uregex_find(URegularExpression *regexp,
+            int32_t             startIndex, 
+            UErrorCode         *status);
+
+/**
+  *  Find the next pattern match in the input string.  Begin searching 
+  *  the input at the location following the end of he previous match, 
+  *  or at the start of the string (or region) if there is no 
+  *  previous match.  If a match is found, <code>uregex_start(), uregex_end()</code>, and
+  *  <code>uregex_group()</code> will provide more information regarding the match.
+  *
+  *  @param   regexp      The compiled regular expression.
+  *  @param   status      A reference to a UErrorCode to receive any errors.
+  *  @return              TRUE if a match is found.
+  *  @see uregex_reset
+  *  @stable ICU 3.0
+  */
+U_STABLE UBool U_EXPORT2 
+uregex_findNext(URegularExpression *regexp,
+                UErrorCode         *status);
+
+/**
+  *   Get the number of capturing groups in this regular expression's pattern.
+  *   @param   regexp      The compiled regular expression.
+  *   @param   status      A reference to a UErrorCode to receive any errors.
+  *   @return the number of capture groups
+  *   @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_groupCount(URegularExpression *regexp,
+                  UErrorCode         *status);
+
+/** Extract the string for the specified matching expression or subexpression.
+  * Group #0 is the complete string of matched text.
+  * Group #1 is the text matched by the first set of capturing parentheses.
+  *
+  *   @param   regexp       The compiled regular expression.
+  *   @param   groupNum     The capture group to extract.  Group 0 is the complete
+  *                         match.  The value of this parameter must be
+  *                         less than or equal to the number of capture groups in
+  *                         the pattern.
+  *   @param   dest         Buffer to receive the matching string data
+  *   @param   destCapacity Capacity of the dest buffer.
+  *   @param   status       A reference to a UErrorCode to receive any errors.
+  *   @return               Length of matching data,
+  *                         or -1 if no applicable match.
+  *   @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_group(URegularExpression *regexp,
+             int32_t             groupNum,
+             UChar              *dest,
+             int32_t             destCapacity,
+             UErrorCode          *status);
+
+
+/**
+  *   Returns the index in the input string of the start of the text matched by the
+  *   specified capture group during the previous match operation.  Return -1 if
+  *   the capture group was not part of the last match.
+  *   Group #0 refers to the complete range of matched text.
+  *   Group #1 refers to the text matched by the first set of capturing parentheses.
+  *
+  *    @param   regexp      The compiled regular expression.
+  *    @param   groupNum    The capture group number
+  *    @param   status      A reference to a UErrorCode to receive any errors.
+  *    @return              the starting position in the input of the text matched 
+  *                         by the specified group.
+  *    @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_start(URegularExpression *regexp,
+             int32_t             groupNum,
+             UErrorCode          *status);
+
+/**
+  *   Returns the index in the input string of the position following the end
+  *   of the text matched by the specified capture group.
+  *   Return -1 if the capture group was not part of the last match.
+  *   Group #0 refers to the complete range of matched text.
+  *   Group #1 refers to the text matched by the first set of capturing parentheses.
+  *
+  *    @param   regexp      The compiled regular expression.
+  *    @param   groupNum    The capture group number
+  *    @param   status      A reference to a UErrorCode to receive any errors.
+  *    @return              the index of the position following the last matched character.
+  *    @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_end(URegularExpression   *regexp,
+           int32_t               groupNum,
+           UErrorCode           *status);
+
+/**
+  *  Reset any saved state from the previous match.  Has the effect of
+  *  causing uregex_findNext to begin at the specified index, and causing
+  *  uregex_start(), uregex_end() and uregex_group() to return an error 
+  *  indicating that there is no match information available.  Clears any
+  *  match region that may have been set.
+  *
+  *    @param   regexp      The compiled regular expression.
+  *    @param   index       The position in the text at which a
+  *                         uregex_findNext() should begin searching.
+  *    @param   status      A reference to a UErrorCode to receive any errors.
+  *    @stable ICU 3.0
+  */
+U_STABLE void U_EXPORT2 
+uregex_reset(URegularExpression    *regexp,
+             int32_t               index,
+             UErrorCode            *status);
+             
+             
+/** Sets the limits of the matching region for this URegularExpression.
+  * The region is the part of the input string that will be considered when matching.
+  * Invoking this method resets any saved state from the previous match, 
+  * then sets the region to start at the index specified by the start parameter
+  * and end at the index specified by the end parameter.
+  *
+  * Depending on the transparency and anchoring being used (see useTransparentBounds
+  * and useAnchoringBounds), certain constructs such as anchors may behave differently
+  * at or around the boundaries of the region
+  *
+  * The function will fail if start is greater than limit, or if either index
+  *  is less than zero or greater than the length of the string being matched.
+  *
+  * @param regexp The compiled regular expression.
+  * @param regionStart  The index to begin searches at.
+  * @param regionLimit  The index to end searches at (exclusive).
+  * @param status A pointer to a UErrorCode to receive any errors.
+  * @draft ICU 4.0
+  */
+U_DRAFT void U_EXPORT2
+uregex_setRegion(URegularExpression   *regexp,
+                 int32_t               regionStart,
+                 int32_t               regionLimit,
+                 UErrorCode           *status);
+
+/**
+  * Reports the start index of the matching region. Any matches found are limited to
+  * to the region bounded by regionStart (inclusive) and regionEnd (exclusive).
+  *
+  * @param regexp The compiled regular expression.
+  * @param status A pointer to a UErrorCode to receive any errors.
+  * @return The starting index of this matcher's region.
+  * @draft ICU 4.0
+  */
+U_DRAFT int32_t U_EXPORT2
+uregex_regionStart(const  URegularExpression   *regexp,
+                          UErrorCode           *status);
+
+
+
+/**
+  * Reports the end index (exclusive) of the matching region for this URegularExpression.
+  * Any matches found are limited to to the region bounded by regionStart (inclusive)
+  * and regionEnd (exclusive).
+  *
+  * @param regexp The compiled regular expression.
+  * @param status A pointer to a UErrorCode to receive any errors.
+  * @return The ending point of this matcher's region.
+  * @draft ICU 4.0
+  */
+U_DRAFT int32_t U_EXPORT2
+uregex_regionEnd(const  URegularExpression   *regexp,
+                        UErrorCode           *status);
+
+/**
+  * Queries the transparency of region bounds for this URegularExpression.
+  * See useTransparentBounds for a description of transparent and opaque bounds.
+  * By default, matching boundaries are opaque.
+  *
+  * @param regexp The compiled regular expression.
+  * @param status A pointer to a UErrorCode to receive any errors.
+  * @return TRUE if this matcher is using opaque bounds, false if it is not.
+  * @draft ICU 4.0
+  */
+U_DRAFT UBool U_EXPORT2
+uregex_hasTransparentBounds(const  URegularExpression   *regexp,
+                                   UErrorCode           *status);
+
+
+/**
+  * Sets the transparency of region bounds for this URegularExpression.
+  * Invoking this function with an argument of TRUE will set matches to use transparent bounds.
+  * If the boolean argument is FALSE, then opaque bounds will be used.
+  *
+  * Using transparent bounds, the boundaries of the matching region are transparent
+  * to lookahead, lookbehind, and boundary matching constructs. Those constructs can
+  * see text beyond the boundaries of the region while checking for a match.
+  *
+  * With opaque bounds, no text outside of the matching region is visible to lookahead,
+  * lookbehind, and boundary matching constructs.
+  *
+  * By default, opaque bounds are used.
+  *
+  * @param   regexp The compiled regular expression.
+  * @param   b      TRUE for transparent bounds; FALSE for opaque bounds
+  * @param   status A pointer to a UErrorCode to receive any errors.
+  * @draft   ICU 4.0
+  **/
+U_DRAFT void U_EXPORT2  
+uregex_useTransparentBounds(URegularExpression   *regexp, 
+                            UBool                b,
+                            UErrorCode           *status);
+
+
+/**
+  * Return true if this URegularExpression is using anchoring bounds.
+  * By default, anchoring region bounds are used.
+  *
+  * @param  regexp The compiled regular expression.
+  * @param  status A pointer to a UErrorCode to receive any errors.
+  * @return TRUE if this matcher is using anchoring bounds.
+  * @draft  ICU 4.0
+  */
+U_DRAFT UBool U_EXPORT2
+uregex_hasAnchoringBounds(const  URegularExpression   *regexp,
+                                 UErrorCode           *status);
+
+
+/**
+  * Set whether this URegularExpression is using Anchoring Bounds for its region.
+  * With anchoring bounds, pattern anchors such as ^ and $ will match at the start
+  * and end of the region.  Without Anchoring Bounds, anchors will only match at
+  * the positions they would in the complete text.
+  *
+  * Anchoring Bounds are the default for regions.
+  *
+  * @param regexp The compiled regular expression.
+  * @param b      TRUE if to enable anchoring bounds; FALSE to disable them.
+  * @param status A pointer to a UErrorCode to receive any errors.
+  * @draft   ICU 4.0
+  */
+U_DRAFT void U_EXPORT2
+uregex_useAnchoringBounds(URegularExpression   *regexp,
+                          UBool                 b,
+                          UErrorCode           *status);
+
+/**
+  * Return TRUE if the most recent matching operation touched the
+  *  end of the text being processed.  In this case, additional input text could
+  *  change the results of that match.
+  *
+  *  @param regexp The compiled regular expression.
+  *  @param status A pointer to a UErrorCode to receive any errors.
+  *  @return  TRUE if the most recent match hit the end of input
+  *  @draft   ICU 4.0
+  */
+U_DRAFT UBool U_EXPORT2
+uregex_hitEnd(const  URegularExpression   *regexp,
+                     UErrorCode           *status);
+
+/**
+  * Return TRUE the most recent match succeeded and additional input could cause
+  * it to fail. If this function returns false and a match was found, then more input
+  * might change the match but the match won't be lost. If a match was not found,
+  * then requireEnd has no meaning.
+  *
+  * @param regexp The compiled regular expression.
+  * @param status A pointer to a UErrorCode to receive any errors.
+  * @return TRUE  if more input could cause the most recent match to no longer match.
+  * @draft  ICU 4.0
+  */
+U_DRAFT UBool U_EXPORT2   
+uregex_requireEnd(const  URegularExpression   *regexp,
+                         UErrorCode           *status);
+
+
+
+
+
+/**
+  *    Replaces every substring of the input that matches the pattern
+  *    with the given replacement string.  This is a convenience function that
+  *    provides a complete find-and-replace-all operation.
+  *
+  *    This method scans the input string looking for matches of the pattern. 
+  *    Input that is not part of any match is copied unchanged to the
+  *    destination buffer.  Matched regions are replaced in the output
+  *    buffer by the replacement string.   The replacement string may contain
+  *    references to capture groups; these take the form of $1, $2, etc.
+  *
+  *    @param   regexp             The compiled regular expression.
+  *    @param   replacementText    A string containing the replacement text.
+  *    @param   replacementLength  The length of the replacement string, or
+  *                                -1 if it is NUL terminated.
+  *    @param   destBuf            A (UChar *) buffer that will receive the result.
+  *    @param   destCapacity       The capacity of the desitnation buffer.
+  *    @param   status             A reference to a UErrorCode to receive any errors.
+  *    @return                     The length of the string resulting from the find
+  *                                and replace operation.  In the event that the
+  *                                destination capacity is inadequate, the return value
+  *                                is still the full length of the untruncated string.
+  *    @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_replaceAll(URegularExpression    *regexp,
+                  const UChar           *replacementText,
+                  int32_t                replacementLength,
+                  UChar                 *destBuf,
+                  int32_t                destCapacity,
+                  UErrorCode            *status);
+
+
+/**
+  *    Replaces the first substring of the input that matches the pattern
+  *    with the given replacement string.  This is a convenience function that
+  *    provides a complete find-and-replace operation.
+  *
+  *    This method scans the input string looking for a match of the pattern. 
+  *    All input that is not part of the match is copied unchanged to the
+  *    destination buffer.  The matched region is replaced in the output
+  *    buffer by the replacement string.   The replacement string may contain
+  *    references to capture groups; these take the form of $1, $2, etc.
+  *
+  *    @param   regexp             The compiled regular expression.
+  *    @param   replacementText    A string containing the replacement text.
+  *    @param   replacementLength  The length of the replacement string, or
+  *                                -1 if it is NUL terminated.
+  *    @param   destBuf            A (UChar *) buffer that will receive the result.
+  *    @param   destCapacity       The capacity of the desitnation buffer.
+  *    @param   status             a reference to a UErrorCode to receive any errors.
+  *    @return                     The length of the string resulting from the find
+  *                                and replace operation.  In the event that the
+  *                                destination capacity is inadequate, the return value
+  *                                is still the full length of the untruncated string.
+  *    @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_replaceFirst(URegularExpression  *regexp,
+                    const UChar         *replacementText,
+                    int32_t              replacementLength,
+                    UChar               *destBuf,
+                    int32_t              destCapacity,
+                    UErrorCode          *status);
+
+
+/**
+  *   Implements a replace operation intended to be used as part of an
+  *   incremental find-and-replace.
+  *
+  *   <p>The input string, starting from the end of the previous match and ending at
+  *   the start of the current match, is appended to the destination string.  Then the
+  *   replacement string is appended to the output string,
+  *   including handling any substitutions of captured text.</p>
+  *
+  *   <p>A note on preflight computation of buffersize and error handling:
+  *   Calls to uregex_appendReplacement() and uregex_appendTail() are
+  *   designed to be chained, one after another, with the destination
+  *   buffer pointer and buffer capacity updated after each in preparation
+  *   to for the next.  If the destination buffer is exhausted partway through such a
+  *   sequence, a U_BUFFER_OVERFLOW_ERROR status will be returned.  Normal
+  *   ICU conventions are for a function to perform no action if it is
+  *   called with an error status, but for this one case, uregex_appendRepacement()
+  *   will operate normally so that buffer size computations will complete
+  *   correctly.
+  *
+  *   <p>For simple, prepackaged, non-incremental find-and-replace
+  *      operations, see replaceFirst() or replaceAll().</p>
+  *
+  *   @param   regexp      The regular expression object.  
+  *   @param   replacementText The string that will replace the matched portion of the
+  *                        input string as it is copied to the destination buffer.
+  *                        The replacement text may contain references ($1, for
+  *                        example) to capture groups from the match.
+  *   @param   replacementLength  The length of the replacement text string,
+  *                        or -1 if the string is NUL terminated.
+  *   @param   destBuf     The buffer into which the results of the
+  *                        find-and-replace are placed.  On return, this pointer
+  *                        will be updated to refer to the beginning of the
+  *                        unused portion of buffer, leaving it in position for
+  *                        a subsequent call to this function.
+  *   @param   destCapacity The size of the output buffer,  On return, this
+  *                        parameter will be updated to reflect the space remaining
+  *                        unused in the output buffer.
+  *   @param   status      A reference to a UErrorCode to receive any errors. 
+  *   @return              The length of the result string.  In the event that
+  *                        destCapacity is inadequate, the full length of the
+  *                        untruncated output string is returned.
+  *
+  *   @stable ICU 3.0
+  *
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_appendReplacement(URegularExpression    *regexp,
+                  const UChar           *replacementText,
+                  int32_t                replacementLength,
+                  UChar                **destBuf,
+                  int32_t               *destCapacity,
+                  UErrorCode            *status);
+
+
+/**
+  * As the final step in a find-and-replace operation, append the remainder
+  * of the input string, starting at the position following the last match,
+  * to the destination string. <code>uregex_appendTail()</code> is intended 
+  *  to be invoked after one or more invocations of the
+  *  <code>uregex_appendReplacement()</code> function.
+  *
+  *   @param   regexp      The regular expression object.  This is needed to 
+  *                        obtain the input string and with the position
+  *                        of the last match within it.
+  *   @param   destBuf     The buffer in which the results of the
+  *                        find-and-replace are placed.  On return, the pointer
+  *                        will be updated to refer to the beginning of the
+  *                        unused portion of buffer.
+  *   @param   destCapacity The size of the output buffer,  On return, this
+  *                        value will be updated to reflect the space remaining
+  *                        unused in the output buffer.
+  *   @param   status      A reference to a UErrorCode to receive any errors. 
+  *   @return              The length of the result string.  In the event that
+  *                        destCapacity is inadequate, the full length of the
+  *                        untruncated output string is returned.
+  *
+  *   @stable ICU 3.0
+  */
+U_STABLE int32_t U_EXPORT2 
+uregex_appendTail(URegularExpression    *regexp,
+                  UChar                **destBuf,
+                  int32_t               *destCapacity,
+                  UErrorCode            *status);
+
+
+
+
+ /**
+   * Split a string into fields.  Somewhat like split() from Perl.
+   *  The pattern matches identify delimiters that separate the input
+   *  into fields.  The input data between the matches becomes the
+   *  fields themselves.
+   * <p>
+   *  Each of the fields is copied from the input string to the destination
+   *  buffer, and the NUL terminated.  The position of each field within
+   *  the destination buffer is returned in the destFields array.
+   *
+   *  Note:  another choice for the design of this function would be to not
+   *         copy the resulting fields at all, but to return indexes and
+   *         lengths within the source text.  
+   *           Advantages would be
+   *             o  Faster.  No Copying.
+   *             o  Nothing extra needed when field data may contain embedded NUL chars.
+   *             o  Less memory needed if working on large data.
+   *           Disadvantages
+   *             o  Less consistent with C++ split, which copies into an
+   *                array of UnicodeStrings.
+   *             o  No NUL termination, extracted fields would be less convenient
+   *                to use in most cases.
+   *             o  Possible problems in the future, when support Unicode Normalization
+   *                could cause the fields to not correspond exactly to
+   *                a range of the source text.
+   * 
+   *    @param   regexp      The compiled regular expression.
+   *    @param   destBuf     A (UChar *) buffer to receive the fields that
+   *                         are extracted from the input string. These
+   *                         field pointers will refer to positions within the
+   *                         destination buffer supplied by the caller.  Any
+   *                         extra positions within the destFields array will be
+   *                         set to NULL.
+   *    @param   destCapacity The capacity of the destBuf.
+   *    @param   requiredCapacity  The actual capacity required of the destBuf.
+   *                         If destCapacity is too small, requiredCapacity will return 
+   *                         the total capacity required to hold all of the output, and
+   *                         a U_BUFFER_OVERFLOW_ERROR will be returned.
+   *    @param   destFields  An array to be filled with the position of each
+   *                         of the extracted fields within destBuf.
+   *    @param   destFieldsCapacity  The number of elements in the destFields array.
+   *                If the number of fields found is less than destFieldsCapacity,
+   *                the extra destFields elements are set to zero.
+   *                If destFieldsCapacity is too small, the trailing part of the
+   *                input, including any field delimiters, is treated as if it
+   *                were the last field - it is copied to the destBuf, and
+   *                its position is in the destBuf is stored in the last element
+   *                of destFields.  This behavior mimics that of Perl.  It is not
+   *                an error condition, and no error status is returned when all destField
+   *                positions are used.
+   * @param status  A reference to a UErrorCode to receive any errors.
+   * @return        The number of fields into which the input string was split.
+   * @stable ICU 3.0
+   */
+U_STABLE int32_t U_EXPORT2 
+uregex_split(   URegularExpression      *regexp,
+                  UChar                 *destBuf,
+                  int32_t                destCapacity,
+                  int32_t               *requiredCapacity,
+                  UChar                 *destFields[],
+                  int32_t                destFieldsCapacity,
+                  UErrorCode            *status);
+
+
+
+
+/**
+ * Set a processing time limit for match operations with this URegularExpression.
+ *
+ * Some patterns, when matching certain strings, can run in exponential time.
+ * For practical purposes, the match operation may appear to be in an
+ * infinite loop.
+ * When a limit is set a match operation will fail with an error if the
+ * limit is exceeded.
+ * <p>
+ * The units of the limit are steps of the match engine.
+ * Correspondence with actual processor time will depend on the speed
+ * of the processor and the details of the specific pattern, but will
+ * typically be on the order of milliseconds.
+ * <p>
+ * By default, the matching time is not limited.
+ * <p>
+ *
+ * @param   regexp      The compiled regular expression.
+ * @param   limit       The limit value, or 0 for no limit.
+ * @param   status      A reference to a UErrorCode to receive any errors.
+ * @draft ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+uregex_setTimeLimit(URegularExpression      *regexp,
+                    int32_t                  limit,
+                    UErrorCode              *status);
+
+/**
+ * Get the time limit for for matches with this URegularExpression.
+ * A return value of zero indicates that there is no limit.
+ *
+ * @param   regexp      The compiled regular expression.
+ * @param   status      A reference to a UErrorCode to receive any errors.
+ * @return the maximum allowed time for a match, in units of processing steps.
+ * @draft ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+uregex_getTimeLimit(const URegularExpression      *regexp,
+                          UErrorCode              *status);
+
+/**
+ * Set the amount of heap storage avaliable for use by the match backtracking stack.
+ * <p>
+ * ICU uses a backtracking regular expression engine, with the backtrack stack
+ * maintained on the heap.  This function sets the limit to the amount of memory
+ * that can be used  for this purpose.  A backtracking stack overflow will
+ * result in an error from the match operation that caused it.
+ * <p>
+ * A limit is desirable because a malicious or poorly designed pattern can use
+ * excessive memory, potentially crashing the process.  A limit is enabled
+ * by default.
+ * <p>
+ * @param   regexp      The compiled regular expression.
+ * @param   limit       The maximum size, in bytes, of the matching backtrack stack.
+ *                      A value of -1 means no limit.
+ *                      The limit must be greater than zero, or -1.
+ * @param   status      A reference to a UErrorCode to receive any errors.
+ *
+ * @draft ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+uregex_setStackLimit(URegularExpression      *regexp,
+                     int32_t                  limit,
+                     UErrorCode              *status);
+
+/**
+ * Get the size of the heap storage available for use by the back tracking stack.
+ *
+ * @return  the maximum backtracking stack size, in bytes, or zero if the
+ *          stack size is unlimited.
+ * @draft ICU 4.0
+ */
+U_DRAFT int32_t U_EXPORT2
+uregex_getStackLimit(const URegularExpression      *regexp,
+                           UErrorCode              *status);
+
+
+/**
+ * Function pointer for a regular expression matching callback function.
+ * When set, a callback function will be called periodically during matching
+ * operations.  If the call back function returns FALSE, the matching
+ * operation will be terminated early.
+ *
+ * Note:  the callback function must not call other functions on this
+ *        URegularExpression.
+ *
+ * @param context  context pointer.  The callback function will be invoked
+ *                 with the context specified at the time that
+ *                 uregex_setMatchCallback() is called.
+ * @param steps    the accumulated processing time, in match steps, 
+ *                 for this matching operation.
+ * @return         TRUE to continue the matching operation.
+ *                 FALSE to terminate the matching operation.
+ * @draft ICU 4.0
+ */
+U_CDECL_BEGIN
+typedef UBool U_CALLCONV URegexMatchCallback (
+                   const void *context,
+                   int32_t     steps);
+U_CDECL_END
+
+/**
+ * Set a callback function for this URegularExpression.
+ * During matching operations the function will be called periodically,
+ * giving the application the opportunity to terminate a long-running
+ * match.
+ *
+ * @param   regexp      The compiled regular expression.
+ * @param   callback    A pointer to the user-supplied callback function.
+ * @param   context     User context pointer.  The value supplied at the
+ *                      time the callback function is set will be saved
+ *                      and passed to the callback each time that it is called.
+ * @param   status      A reference to a UErrorCode to receive any errors.
+ * @draft ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+uregex_setMatchCallback(URegularExpression      *regexp,
+                        URegexMatchCallback     *callback,
+                        const void              *context,
+                        UErrorCode              *status);
+
+
+/**
+ *  Get the callback function for this URegularExpression.
+ *
+ * @param   regexp      The compiled regular expression.
+ * @param   callback    Out paramater, receives a pointer to the user-supplied 
+ *                      callback function.
+ * @param   context     Out parameter, receives the user context pointer that
+ *                      was set when uregex_setMatchCallback() was called.
+ * @param   status      A reference to a UErrorCode to receive any errors.
+ * @draft ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+uregex_getMatchCallback(const URegularExpression    *regexp,
+                        URegexMatchCallback        **callback,
+                        const void                 **context,
+                        UErrorCode                  *status);
+
+
+
+#endif   /*  !UCONFIG_NO_REGULAR_EXPRESSIONS  */
+#endif   /*  UREGEX_H  */
diff --git a/CoreFoundation/icu/unicode/urename.h b/CoreFoundation/icu/unicode/urename.h
new file mode 100644
index 0000000..5282958
--- /dev/null
+++ b/CoreFoundation/icu/unicode/urename.h
@@ -0,0 +1,1775 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2002-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  urename.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Created by: Perl script written by Vladimir Weinstein
+*
+*  Contains data for renaming ICU exports.
+*  Gets included by umachine.h
+*
+*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
+*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
+*/
+
+#ifndef URENAME_H
+#define URENAME_H
+
+/* Uncomment the following line to disable renaming on platforms
+   that do not use Autoconf. */
+/* #define U_DISABLE_RENAMING 1 */
+
+#if !U_DISABLE_RENAMING
+
+/* C exports renaming data */
+
+#define T_CString_int64ToString T_CString_int64ToString_4_0
+#define T_CString_integerToString T_CString_integerToString_4_0
+#define T_CString_stricmp T_CString_stricmp_4_0
+#define T_CString_stringToInteger T_CString_stringToInteger_4_0
+#define T_CString_strnicmp T_CString_strnicmp_4_0
+#define T_CString_toLowerCase T_CString_toLowerCase_4_0
+#define T_CString_toUpperCase T_CString_toUpperCase_4_0
+#define UCNV_FROM_U_CALLBACK_ESCAPE UCNV_FROM_U_CALLBACK_ESCAPE_4_0
+#define UCNV_FROM_U_CALLBACK_SKIP UCNV_FROM_U_CALLBACK_SKIP_4_0
+#define UCNV_FROM_U_CALLBACK_STOP UCNV_FROM_U_CALLBACK_STOP_4_0
+#define UCNV_FROM_U_CALLBACK_SUBSTITUTE UCNV_FROM_U_CALLBACK_SUBSTITUTE_4_0
+#define UCNV_TO_U_CALLBACK_ESCAPE UCNV_TO_U_CALLBACK_ESCAPE_4_0
+#define UCNV_TO_U_CALLBACK_SKIP UCNV_TO_U_CALLBACK_SKIP_4_0
+#define UCNV_TO_U_CALLBACK_STOP UCNV_TO_U_CALLBACK_STOP_4_0
+#define UCNV_TO_U_CALLBACK_SUBSTITUTE UCNV_TO_U_CALLBACK_SUBSTITUTE_4_0
+#define UDataMemory_createNewInstance UDataMemory_createNewInstance_4_0
+#define UDataMemory_init UDataMemory_init_4_0
+#define UDataMemory_isLoaded UDataMemory_isLoaded_4_0
+#define UDataMemory_normalizeDataPointer UDataMemory_normalizeDataPointer_4_0
+#define UDataMemory_setData UDataMemory_setData_4_0
+#define UDatamemory_assign UDatamemory_assign_4_0
+#define _ASCIIData _ASCIIData_4_0
+#define _Bocu1Data _Bocu1Data_4_0
+#define _CESU8Data _CESU8Data_4_0
+#define _HZData _HZData_4_0
+#define _IMAPData _IMAPData_4_0
+#define _ISCIIData _ISCIIData_4_0
+#define _ISO2022Data _ISO2022Data_4_0
+#define _LMBCSData1 _LMBCSData1_4_0
+#define _LMBCSData11 _LMBCSData11_4_0
+#define _LMBCSData16 _LMBCSData16_4_0
+#define _LMBCSData17 _LMBCSData17_4_0
+#define _LMBCSData18 _LMBCSData18_4_0
+#define _LMBCSData19 _LMBCSData19_4_0
+#define _LMBCSData2 _LMBCSData2_4_0
+#define _LMBCSData3 _LMBCSData3_4_0
+#define _LMBCSData4 _LMBCSData4_4_0
+#define _LMBCSData5 _LMBCSData5_4_0
+#define _LMBCSData6 _LMBCSData6_4_0
+#define _LMBCSData8 _LMBCSData8_4_0
+#define _Latin1Data _Latin1Data_4_0
+#define _MBCSData _MBCSData_4_0
+#define _SCSUData _SCSUData_4_0
+#define _UTF16BEData _UTF16BEData_4_0
+#define _UTF16Data _UTF16Data_4_0
+#define _UTF16LEData _UTF16LEData_4_0
+#define _UTF32BEData _UTF32BEData_4_0
+#define _UTF32Data _UTF32Data_4_0
+#define _UTF32LEData _UTF32LEData_4_0
+#define _UTF7Data _UTF7Data_4_0
+#define _UTF8Data _UTF8Data_4_0
+#define cmemory_cleanup cmemory_cleanup_4_0
+#define cmemory_inUse cmemory_inUse_4_0
+#define le_close le_close_4_0
+#define le_create le_create_4_0
+#define le_getCharIndices le_getCharIndices_4_0
+#define le_getCharIndicesWithBase le_getCharIndicesWithBase_4_0
+#define le_getGlyphCount le_getGlyphCount_4_0
+#define le_getGlyphPosition le_getGlyphPosition_4_0
+#define le_getGlyphPositions le_getGlyphPositions_4_0
+#define le_getGlyphs le_getGlyphs_4_0
+#define le_layoutChars le_layoutChars_4_0
+#define le_reset le_reset_4_0
+#define locale_getKeywords locale_getKeywords_4_0
+#define locale_get_default locale_get_default_4_0
+#define locale_set_default locale_set_default_4_0
+#define pl_addFontRun pl_addFontRun_4_0
+#define pl_addLocaleRun pl_addLocaleRun_4_0
+#define pl_addValueRun pl_addValueRun_4_0
+#define pl_close pl_close_4_0
+#define pl_closeFontRuns pl_closeFontRuns_4_0
+#define pl_closeLine pl_closeLine_4_0
+#define pl_closeLocaleRuns pl_closeLocaleRuns_4_0
+#define pl_closeValueRuns pl_closeValueRuns_4_0
+#define pl_countLineRuns pl_countLineRuns_4_0
+#define pl_create pl_create_4_0
+#define pl_getAscent pl_getAscent_4_0
+#define pl_getDescent pl_getDescent_4_0
+#define pl_getFontRunCount pl_getFontRunCount_4_0
+#define pl_getFontRunFont pl_getFontRunFont_4_0
+#define pl_getFontRunLastLimit pl_getFontRunLastLimit_4_0
+#define pl_getFontRunLimit pl_getFontRunLimit_4_0
+#define pl_getLeading pl_getLeading_4_0
+#define pl_getLineAscent pl_getLineAscent_4_0
+#define pl_getLineDescent pl_getLineDescent_4_0
+#define pl_getLineLeading pl_getLineLeading_4_0
+#define pl_getLineVisualRun pl_getLineVisualRun_4_0
+#define pl_getLineWidth pl_getLineWidth_4_0
+#define pl_getLocaleRunCount pl_getLocaleRunCount_4_0
+#define pl_getLocaleRunLastLimit pl_getLocaleRunLastLimit_4_0
+#define pl_getLocaleRunLimit pl_getLocaleRunLimit_4_0
+#define pl_getLocaleRunLocale pl_getLocaleRunLocale_4_0
+#define pl_getParagraphLevel pl_getParagraphLevel_4_0
+#define pl_getTextDirection pl_getTextDirection_4_0
+#define pl_getValueRunCount pl_getValueRunCount_4_0
+#define pl_getValueRunLastLimit pl_getValueRunLastLimit_4_0
+#define pl_getValueRunLimit pl_getValueRunLimit_4_0
+#define pl_getValueRunValue pl_getValueRunValue_4_0
+#define pl_getVisualRunAscent pl_getVisualRunAscent_4_0
+#define pl_getVisualRunDescent pl_getVisualRunDescent_4_0
+#define pl_getVisualRunDirection pl_getVisualRunDirection_4_0
+#define pl_getVisualRunFont pl_getVisualRunFont_4_0
+#define pl_getVisualRunGlyphCount pl_getVisualRunGlyphCount_4_0
+#define pl_getVisualRunGlyphToCharMap pl_getVisualRunGlyphToCharMap_4_0
+#define pl_getVisualRunGlyphs pl_getVisualRunGlyphs_4_0
+#define pl_getVisualRunLeading pl_getVisualRunLeading_4_0
+#define pl_getVisualRunPositions pl_getVisualRunPositions_4_0
+#define pl_isComplex pl_isComplex_4_0
+#define pl_nextLine pl_nextLine_4_0
+#define pl_openEmptyFontRuns pl_openEmptyFontRuns_4_0
+#define pl_openEmptyLocaleRuns pl_openEmptyLocaleRuns_4_0
+#define pl_openEmptyValueRuns pl_openEmptyValueRuns_4_0
+#define pl_openFontRuns pl_openFontRuns_4_0
+#define pl_openLocaleRuns pl_openLocaleRuns_4_0
+#define pl_openValueRuns pl_openValueRuns_4_0
+#define pl_reflow pl_reflow_4_0
+#define pl_resetFontRuns pl_resetFontRuns_4_0
+#define pl_resetLocaleRuns pl_resetLocaleRuns_4_0
+#define pl_resetValueRuns pl_resetValueRuns_4_0
+#define res_countArrayItems res_countArrayItems_4_0
+#define res_findResource res_findResource_4_0
+#define res_getAlias res_getAlias_4_0
+#define res_getArrayItem res_getArrayItem_4_0
+#define res_getBinary res_getBinary_4_0
+#define res_getIntVector res_getIntVector_4_0
+#define res_getResource res_getResource_4_0
+#define res_getString res_getString_4_0
+#define res_getTableItemByIndex res_getTableItemByIndex_4_0
+#define res_getTableItemByKey res_getTableItemByKey_4_0
+#define res_load res_load_4_0
+#define res_unload res_unload_4_0
+#define transliterator_cleanup transliterator_cleanup_4_0
+#define triedict_swap triedict_swap_4_0
+#define u_UCharsToChars u_UCharsToChars_4_0
+#define u_austrcpy u_austrcpy_4_0
+#define u_austrncpy u_austrncpy_4_0
+#define u_catclose u_catclose_4_0
+#define u_catgets u_catgets_4_0
+#define u_catopen u_catopen_4_0
+#define u_charAge u_charAge_4_0
+#define u_charDigitValue u_charDigitValue_4_0
+#define u_charDirection u_charDirection_4_0
+#define u_charFromName u_charFromName_4_0
+#define u_charMirror u_charMirror_4_0
+#define u_charName u_charName_4_0
+#define u_charType u_charType_4_0
+#define u_charsToUChars u_charsToUChars_4_0
+#define u_cleanup u_cleanup_4_0
+#define u_countChar32 u_countChar32_4_0
+#define u_digit u_digit_4_0
+#define u_enumCharNames u_enumCharNames_4_0
+#define u_enumCharTypes u_enumCharTypes_4_0
+#define u_errorName u_errorName_4_0
+#define u_fclose u_fclose_4_0
+#define u_feof u_feof_4_0
+#define u_fflush u_fflush_4_0
+#define u_fgetConverter u_fgetConverter_4_0
+#define u_fgetc u_fgetc_4_0
+#define u_fgetcodepage u_fgetcodepage_4_0
+#define u_fgetcx u_fgetcx_4_0
+#define u_fgetfile u_fgetfile_4_0
+#define u_fgetlocale u_fgetlocale_4_0
+#define u_fgets u_fgets_4_0
+#define u_file_read u_file_read_4_0
+#define u_file_write u_file_write_4_0
+#define u_file_write_flush u_file_write_flush_4_0
+#define u_finit u_finit_4_0
+#define u_foldCase u_foldCase_4_0
+#define u_fopen u_fopen_4_0
+#define u_forDigit u_forDigit_4_0
+#define u_formatMessage u_formatMessage_4_0
+#define u_formatMessageWithError u_formatMessageWithError_4_0
+#define u_fprintf u_fprintf_4_0
+#define u_fprintf_u u_fprintf_u_4_0
+#define u_fputc u_fputc_4_0
+#define u_fputs u_fputs_4_0
+#define u_frewind u_frewind_4_0
+#define u_fscanf u_fscanf_4_0
+#define u_fscanf_u u_fscanf_u_4_0
+#define u_fsetcodepage u_fsetcodepage_4_0
+#define u_fsetlocale u_fsetlocale_4_0
+#define u_fsettransliterator u_fsettransliterator_4_0
+#define u_fstropen u_fstropen_4_0
+#define u_fungetc u_fungetc_4_0
+#define u_getCombiningClass u_getCombiningClass_4_0
+#define u_getDataDirectory u_getDataDirectory_4_0
+#define u_getDefaultConverter u_getDefaultConverter_4_0
+#define u_getFC_NFKC_Closure u_getFC_NFKC_Closure_4_0
+#define u_getISOComment u_getISOComment_4_0
+#define u_getIntPropertyMaxValue u_getIntPropertyMaxValue_4_0
+#define u_getIntPropertyMinValue u_getIntPropertyMinValue_4_0
+#define u_getIntPropertyValue u_getIntPropertyValue_4_0
+#define u_getNumericValue u_getNumericValue_4_0
+#define u_getPropertyEnum u_getPropertyEnum_4_0
+#define u_getPropertyName u_getPropertyName_4_0
+#define u_getPropertyValueEnum u_getPropertyValueEnum_4_0
+#define u_getPropertyValueName u_getPropertyValueName_4_0
+#define u_getUnicodeProperties u_getUnicodeProperties_4_0
+#define u_getUnicodeVersion u_getUnicodeVersion_4_0
+#define u_getVersion u_getVersion_4_0
+#define u_growBufferFromStatic u_growBufferFromStatic_4_0
+#define u_hasBinaryProperty u_hasBinaryProperty_4_0
+#define u_init u_init_4_0
+#define u_isIDIgnorable u_isIDIgnorable_4_0
+#define u_isIDPart u_isIDPart_4_0
+#define u_isIDStart u_isIDStart_4_0
+#define u_isISOControl u_isISOControl_4_0
+#define u_isJavaIDPart u_isJavaIDPart_4_0
+#define u_isJavaIDStart u_isJavaIDStart_4_0
+#define u_isJavaSpaceChar u_isJavaSpaceChar_4_0
+#define u_isMirrored u_isMirrored_4_0
+#define u_isUAlphabetic u_isUAlphabetic_4_0
+#define u_isULowercase u_isULowercase_4_0
+#define u_isUUppercase u_isUUppercase_4_0
+#define u_isUWhiteSpace u_isUWhiteSpace_4_0
+#define u_isWhitespace u_isWhitespace_4_0
+#define u_isalnum u_isalnum_4_0
+#define u_isalnumPOSIX u_isalnumPOSIX_4_0
+#define u_isalpha u_isalpha_4_0
+#define u_isbase u_isbase_4_0
+#define u_isblank u_isblank_4_0
+#define u_iscntrl u_iscntrl_4_0
+#define u_isdefined u_isdefined_4_0
+#define u_isdigit u_isdigit_4_0
+#define u_isgraph u_isgraph_4_0
+#define u_isgraphPOSIX u_isgraphPOSIX_4_0
+#define u_islower u_islower_4_0
+#define u_isprint u_isprint_4_0
+#define u_isprintPOSIX u_isprintPOSIX_4_0
+#define u_ispunct u_ispunct_4_0
+#define u_isspace u_isspace_4_0
+#define u_istitle u_istitle_4_0
+#define u_isupper u_isupper_4_0
+#define u_isxdigit u_isxdigit_4_0
+#define u_lengthOfIdenticalLevelRun u_lengthOfIdenticalLevelRun_4_0
+#define u_locbund_close u_locbund_close_4_0
+#define u_locbund_getNumberFormat u_locbund_getNumberFormat_4_0
+#define u_locbund_init u_locbund_init_4_0
+#define u_memcasecmp u_memcasecmp_4_0
+#define u_memchr u_memchr_4_0
+#define u_memchr32 u_memchr32_4_0
+#define u_memcmp u_memcmp_4_0
+#define u_memcmpCodePointOrder u_memcmpCodePointOrder_4_0
+#define u_memcpy u_memcpy_4_0
+#define u_memmove u_memmove_4_0
+#define u_memrchr u_memrchr_4_0
+#define u_memrchr32 u_memrchr32_4_0
+#define u_memset u_memset_4_0
+#define u_parseMessage u_parseMessage_4_0
+#define u_parseMessageWithError u_parseMessageWithError_4_0
+#define u_printf_parse u_printf_parse_4_0
+#define u_releaseDefaultConverter u_releaseDefaultConverter_4_0
+#define u_scanf_parse u_scanf_parse_4_0
+#define u_setAtomicIncDecFunctions u_setAtomicIncDecFunctions_4_0
+#define u_setDataDirectory u_setDataDirectory_4_0
+#define u_setMemoryFunctions u_setMemoryFunctions_4_0
+#define u_setMutexFunctions u_setMutexFunctions_4_0
+#define u_shapeArabic u_shapeArabic_4_0
+#define u_snprintf u_snprintf_4_0
+#define u_snprintf_u u_snprintf_u_4_0
+#define u_sprintf u_sprintf_4_0
+#define u_sprintf_u u_sprintf_u_4_0
+#define u_sscanf u_sscanf_4_0
+#define u_sscanf_u u_sscanf_u_4_0
+#define u_strCaseCompare u_strCaseCompare_4_0
+#define u_strCompare u_strCompare_4_0
+#define u_strCompareIter u_strCompareIter_4_0
+#define u_strFindFirst u_strFindFirst_4_0
+#define u_strFindLast u_strFindLast_4_0
+#define u_strFoldCase u_strFoldCase_4_0
+#define u_strFromPunycode u_strFromPunycode_4_0
+#define u_strFromUTF32 u_strFromUTF32_4_0
+#define u_strFromUTF8 u_strFromUTF8_4_0
+#define u_strFromUTF8Lenient u_strFromUTF8Lenient_4_0
+#define u_strFromUTF8WithSub u_strFromUTF8WithSub_4_0
+#define u_strFromWCS u_strFromWCS_4_0
+#define u_strHasMoreChar32Than u_strHasMoreChar32Than_4_0
+#define u_strToLower u_strToLower_4_0
+#define u_strToPunycode u_strToPunycode_4_0
+#define u_strToTitle u_strToTitle_4_0
+#define u_strToUTF32 u_strToUTF32_4_0
+#define u_strToUTF8 u_strToUTF8_4_0
+#define u_strToUTF8WithSub u_strToUTF8WithSub_4_0
+#define u_strToUpper u_strToUpper_4_0
+#define u_strToWCS u_strToWCS_4_0
+#define u_strcasecmp u_strcasecmp_4_0
+#define u_strcat u_strcat_4_0
+#define u_strchr u_strchr_4_0
+#define u_strchr32 u_strchr32_4_0
+#define u_strcmp u_strcmp_4_0
+#define u_strcmpCodePointOrder u_strcmpCodePointOrder_4_0
+#define u_strcmpFold u_strcmpFold_4_0
+#define u_strcpy u_strcpy_4_0
+#define u_strcspn u_strcspn_4_0
+#define u_strlen u_strlen_4_0
+#define u_strncasecmp u_strncasecmp_4_0
+#define u_strncat u_strncat_4_0
+#define u_strncmp u_strncmp_4_0
+#define u_strncmpCodePointOrder u_strncmpCodePointOrder_4_0
+#define u_strncpy u_strncpy_4_0
+#define u_strpbrk u_strpbrk_4_0
+#define u_strrchr u_strrchr_4_0
+#define u_strrchr32 u_strrchr32_4_0
+#define u_strrstr u_strrstr_4_0
+#define u_strspn u_strspn_4_0
+#define u_strstr u_strstr_4_0
+#define u_strtok_r u_strtok_r_4_0
+#define u_terminateChars u_terminateChars_4_0
+#define u_terminateUChar32s u_terminateUChar32s_4_0
+#define u_terminateUChars u_terminateUChars_4_0
+#define u_terminateWChars u_terminateWChars_4_0
+#define u_tolower u_tolower_4_0
+#define u_totitle u_totitle_4_0
+#define u_toupper u_toupper_4_0
+#define u_uastrcpy u_uastrcpy_4_0
+#define u_uastrncpy u_uastrncpy_4_0
+#define u_unescape u_unescape_4_0
+#define u_unescapeAt u_unescapeAt_4_0
+#define u_versionFromString u_versionFromString_4_0
+#define u_versionToString u_versionToString_4_0
+#define u_vformatMessage u_vformatMessage_4_0
+#define u_vformatMessageWithError u_vformatMessageWithError_4_0
+#define u_vfprintf u_vfprintf_4_0
+#define u_vfprintf_u u_vfprintf_u_4_0
+#define u_vfscanf u_vfscanf_4_0
+#define u_vfscanf_u u_vfscanf_u_4_0
+#define u_vparseMessage u_vparseMessage_4_0
+#define u_vparseMessageWithError u_vparseMessageWithError_4_0
+#define u_vsnprintf u_vsnprintf_4_0
+#define u_vsnprintf_u u_vsnprintf_u_4_0
+#define u_vsprintf u_vsprintf_4_0
+#define u_vsprintf_u u_vsprintf_u_4_0
+#define u_vsscanf u_vsscanf_4_0
+#define u_vsscanf_u u_vsscanf_u_4_0
+#define u_writeDiff u_writeDiff_4_0
+#define u_writeIdenticalLevelRun u_writeIdenticalLevelRun_4_0
+#define u_writeIdenticalLevelRunTwoChars u_writeIdenticalLevelRunTwoChars_4_0
+#define ubidi_addPropertyStarts ubidi_addPropertyStarts_4_0
+#define ubidi_close ubidi_close_4_0
+#define ubidi_closeProps ubidi_closeProps_4_0
+#define ubidi_countParagraphs ubidi_countParagraphs_4_0
+#define ubidi_countRuns ubidi_countRuns_4_0
+#define ubidi_getClass ubidi_getClass_4_0
+#define ubidi_getClassCallback ubidi_getClassCallback_4_0
+#define ubidi_getCustomizedClass ubidi_getCustomizedClass_4_0
+#define ubidi_getDirection ubidi_getDirection_4_0
+#define ubidi_getJoiningGroup ubidi_getJoiningGroup_4_0
+#define ubidi_getJoiningType ubidi_getJoiningType_4_0
+#define ubidi_getLength ubidi_getLength_4_0
+#define ubidi_getLevelAt ubidi_getLevelAt_4_0
+#define ubidi_getLevels ubidi_getLevels_4_0
+#define ubidi_getLogicalIndex ubidi_getLogicalIndex_4_0
+#define ubidi_getLogicalMap ubidi_getLogicalMap_4_0
+#define ubidi_getLogicalRun ubidi_getLogicalRun_4_0
+#define ubidi_getMaxValue ubidi_getMaxValue_4_0
+#define ubidi_getMemory ubidi_getMemory_4_0
+#define ubidi_getMirror ubidi_getMirror_4_0
+#define ubidi_getParaLevel ubidi_getParaLevel_4_0
+#define ubidi_getParagraph ubidi_getParagraph_4_0
+#define ubidi_getParagraphByIndex ubidi_getParagraphByIndex_4_0
+#define ubidi_getProcessedLength ubidi_getProcessedLength_4_0
+#define ubidi_getReorderingMode ubidi_getReorderingMode_4_0
+#define ubidi_getReorderingOptions ubidi_getReorderingOptions_4_0
+#define ubidi_getResultLength ubidi_getResultLength_4_0
+#define ubidi_getRuns ubidi_getRuns_4_0
+#define ubidi_getSingleton ubidi_getSingleton_4_0
+#define ubidi_getText ubidi_getText_4_0
+#define ubidi_getVisualIndex ubidi_getVisualIndex_4_0
+#define ubidi_getVisualMap ubidi_getVisualMap_4_0
+#define ubidi_getVisualRun ubidi_getVisualRun_4_0
+#define ubidi_invertMap ubidi_invertMap_4_0
+#define ubidi_isBidiControl ubidi_isBidiControl_4_0
+#define ubidi_isInverse ubidi_isInverse_4_0
+#define ubidi_isJoinControl ubidi_isJoinControl_4_0
+#define ubidi_isMirrored ubidi_isMirrored_4_0
+#define ubidi_isOrderParagraphsLTR ubidi_isOrderParagraphsLTR_4_0
+#define ubidi_open ubidi_open_4_0
+#define ubidi_openSized ubidi_openSized_4_0
+#define ubidi_orderParagraphsLTR ubidi_orderParagraphsLTR_4_0
+#define ubidi_reorderLogical ubidi_reorderLogical_4_0
+#define ubidi_reorderVisual ubidi_reorderVisual_4_0
+#define ubidi_setClassCallback ubidi_setClassCallback_4_0
+#define ubidi_setInverse ubidi_setInverse_4_0
+#define ubidi_setLine ubidi_setLine_4_0
+#define ubidi_setPara ubidi_setPara_4_0
+#define ubidi_setReorderingMode ubidi_setReorderingMode_4_0
+#define ubidi_setReorderingOptions ubidi_setReorderingOptions_4_0
+#define ubidi_writeReordered ubidi_writeReordered_4_0
+#define ubidi_writeReverse ubidi_writeReverse_4_0
+#define ublock_getCode ublock_getCode_4_0
+#define ubrk_close ubrk_close_4_0
+#define ubrk_countAvailable ubrk_countAvailable_4_0
+#define ubrk_current ubrk_current_4_0
+#define ubrk_first ubrk_first_4_0
+#define ubrk_following ubrk_following_4_0
+#define ubrk_getAvailable ubrk_getAvailable_4_0
+#define ubrk_getLocaleByType ubrk_getLocaleByType_4_0
+#define ubrk_getRuleStatus ubrk_getRuleStatus_4_0
+#define ubrk_getRuleStatusVec ubrk_getRuleStatusVec_4_0
+#define ubrk_isBoundary ubrk_isBoundary_4_0
+#define ubrk_last ubrk_last_4_0
+#define ubrk_next ubrk_next_4_0
+#define ubrk_open ubrk_open_4_0
+#define ubrk_openRules ubrk_openRules_4_0
+#define ubrk_preceding ubrk_preceding_4_0
+#define ubrk_previous ubrk_previous_4_0
+#define ubrk_safeClone ubrk_safeClone_4_0
+#define ubrk_setText ubrk_setText_4_0
+#define ubrk_setUText ubrk_setUText_4_0
+#define ubrk_swap ubrk_swap_4_0
+#define ucal_add ucal_add_4_0
+#define ucal_clear ucal_clear_4_0
+#define ucal_clearField ucal_clearField_4_0
+#define ucal_clone ucal_clone_4_0
+#define ucal_close ucal_close_4_0
+#define ucal_countAvailable ucal_countAvailable_4_0
+#define ucal_equivalentTo ucal_equivalentTo_4_0
+#define ucal_get ucal_get_4_0
+#define ucal_getAttribute ucal_getAttribute_4_0
+#define ucal_getAvailable ucal_getAvailable_4_0
+#define ucal_getCanonicalTimeZoneID ucal_getCanonicalTimeZoneID_4_0
+#define ucal_getDSTSavings ucal_getDSTSavings_4_0
+#define ucal_getDefaultTimeZone ucal_getDefaultTimeZone_4_0
+#define ucal_getGregorianChange ucal_getGregorianChange_4_0
+#define ucal_getLimit ucal_getLimit_4_0
+#define ucal_getLocaleByType ucal_getLocaleByType_4_0
+#define ucal_getMillis ucal_getMillis_4_0
+#define ucal_getNow ucal_getNow_4_0
+#define ucal_getTZDataVersion ucal_getTZDataVersion_4_0
+#define ucal_getTimeZoneDisplayName ucal_getTimeZoneDisplayName_4_0
+#define ucal_inDaylightTime ucal_inDaylightTime_4_0
+#define ucal_isSet ucal_isSet_4_0
+#define ucal_open ucal_open_4_0
+#define ucal_openCountryTimeZones ucal_openCountryTimeZones_4_0
+#define ucal_openTimeZones ucal_openTimeZones_4_0
+#define ucal_roll ucal_roll_4_0
+#define ucal_set ucal_set_4_0
+#define ucal_setAttribute ucal_setAttribute_4_0
+#define ucal_setDate ucal_setDate_4_0
+#define ucal_setDateTime ucal_setDateTime_4_0
+#define ucal_setDefaultTimeZone ucal_setDefaultTimeZone_4_0
+#define ucal_setGregorianChange ucal_setGregorianChange_4_0
+#define ucal_setMillis ucal_setMillis_4_0
+#define ucal_setTimeZone ucal_setTimeZone_4_0
+#define ucase_addCaseClosure ucase_addCaseClosure_4_0
+#define ucase_addPropertyStarts ucase_addPropertyStarts_4_0
+#define ucase_addStringCaseClosure ucase_addStringCaseClosure_4_0
+#define ucase_close ucase_close_4_0
+#define ucase_fold ucase_fold_4_0
+#define ucase_getCaseLocale ucase_getCaseLocale_4_0
+#define ucase_getSingleton ucase_getSingleton_4_0
+#define ucase_getType ucase_getType_4_0
+#define ucase_getTypeOrIgnorable ucase_getTypeOrIgnorable_4_0
+#define ucase_hasBinaryProperty ucase_hasBinaryProperty_4_0
+#define ucase_isCaseSensitive ucase_isCaseSensitive_4_0
+#define ucase_isSoftDotted ucase_isSoftDotted_4_0
+#define ucase_toFullFolding ucase_toFullFolding_4_0
+#define ucase_toFullLower ucase_toFullLower_4_0
+#define ucase_toFullTitle ucase_toFullTitle_4_0
+#define ucase_toFullUpper ucase_toFullUpper_4_0
+#define ucase_tolower ucase_tolower_4_0
+#define ucase_totitle ucase_totitle_4_0
+#define ucase_toupper ucase_toupper_4_0
+#define ucasemap_close ucasemap_close_4_0
+#define ucasemap_getBreakIterator ucasemap_getBreakIterator_4_0
+#define ucasemap_getLocale ucasemap_getLocale_4_0
+#define ucasemap_getOptions ucasemap_getOptions_4_0
+#define ucasemap_open ucasemap_open_4_0
+#define ucasemap_setBreakIterator ucasemap_setBreakIterator_4_0
+#define ucasemap_setLocale ucasemap_setLocale_4_0
+#define ucasemap_setOptions ucasemap_setOptions_4_0
+#define ucasemap_toTitle ucasemap_toTitle_4_0
+#define ucasemap_utf8FoldCase ucasemap_utf8FoldCase_4_0
+#define ucasemap_utf8ToLower ucasemap_utf8ToLower_4_0
+#define ucasemap_utf8ToTitle ucasemap_utf8ToTitle_4_0
+#define ucasemap_utf8ToUpper ucasemap_utf8ToUpper_4_0
+#define uchar_addPropertyStarts uchar_addPropertyStarts_4_0
+#define uchar_getHST uchar_getHST_4_0
+#define uchar_swapNames uchar_swapNames_4_0
+#define ucln_common_registerCleanup ucln_common_registerCleanup_4_0
+#define ucln_i18n_registerCleanup ucln_i18n_registerCleanup_4_0
+#define ucln_io_registerCleanup ucln_io_registerCleanup_4_0
+#define ucln_lib_cleanup ucln_lib_cleanup_4_0
+#define ucln_registerCleanup ucln_registerCleanup_4_0
+#define ucnv_MBCSFromUChar32 ucnv_MBCSFromUChar32_4_0
+#define ucnv_MBCSFromUnicodeWithOffsets ucnv_MBCSFromUnicodeWithOffsets_4_0
+#define ucnv_MBCSGetFilteredUnicodeSetForUnicode ucnv_MBCSGetFilteredUnicodeSetForUnicode_4_0
+#define ucnv_MBCSGetType ucnv_MBCSGetType_4_0
+#define ucnv_MBCSGetUnicodeSetForUnicode ucnv_MBCSGetUnicodeSetForUnicode_4_0
+#define ucnv_MBCSIsLeadByte ucnv_MBCSIsLeadByte_4_0
+#define ucnv_MBCSSimpleGetNextUChar ucnv_MBCSSimpleGetNextUChar_4_0
+#define ucnv_MBCSToUnicodeWithOffsets ucnv_MBCSToUnicodeWithOffsets_4_0
+#define ucnv_bld_countAvailableConverters ucnv_bld_countAvailableConverters_4_0
+#define ucnv_bld_getAvailableConverter ucnv_bld_getAvailableConverter_4_0
+#define ucnv_cbFromUWriteBytes ucnv_cbFromUWriteBytes_4_0
+#define ucnv_cbFromUWriteSub ucnv_cbFromUWriteSub_4_0
+#define ucnv_cbFromUWriteUChars ucnv_cbFromUWriteUChars_4_0
+#define ucnv_cbToUWriteSub ucnv_cbToUWriteSub_4_0
+#define ucnv_cbToUWriteUChars ucnv_cbToUWriteUChars_4_0
+#define ucnv_close ucnv_close_4_0
+#define ucnv_compareNames ucnv_compareNames_4_0
+#define ucnv_convert ucnv_convert_4_0
+#define ucnv_convertEx ucnv_convertEx_4_0
+#define ucnv_countAliases ucnv_countAliases_4_0
+#define ucnv_countAvailable ucnv_countAvailable_4_0
+#define ucnv_countStandards ucnv_countStandards_4_0
+#define ucnv_createAlgorithmicConverter ucnv_createAlgorithmicConverter_4_0
+#define ucnv_createConverter ucnv_createConverter_4_0
+#define ucnv_createConverterFromPackage ucnv_createConverterFromPackage_4_0
+#define ucnv_createConverterFromSharedData ucnv_createConverterFromSharedData_4_0
+#define ucnv_detectUnicodeSignature ucnv_detectUnicodeSignature_4_0
+#define ucnv_extContinueMatchFromU ucnv_extContinueMatchFromU_4_0
+#define ucnv_extContinueMatchToU ucnv_extContinueMatchToU_4_0
+#define ucnv_extGetUnicodeSet ucnv_extGetUnicodeSet_4_0
+#define ucnv_extInitialMatchFromU ucnv_extInitialMatchFromU_4_0
+#define ucnv_extInitialMatchToU ucnv_extInitialMatchToU_4_0
+#define ucnv_extSimpleMatchFromU ucnv_extSimpleMatchFromU_4_0
+#define ucnv_extSimpleMatchToU ucnv_extSimpleMatchToU_4_0
+#define ucnv_fixFileSeparator ucnv_fixFileSeparator_4_0
+#define ucnv_flushCache ucnv_flushCache_4_0
+#define ucnv_fromAlgorithmic ucnv_fromAlgorithmic_4_0
+#define ucnv_fromUChars ucnv_fromUChars_4_0
+#define ucnv_fromUCountPending ucnv_fromUCountPending_4_0
+#define ucnv_fromUWriteBytes ucnv_fromUWriteBytes_4_0
+#define ucnv_fromUnicode ucnv_fromUnicode_4_0
+#define ucnv_fromUnicode_UTF8 ucnv_fromUnicode_UTF8_4_0
+#define ucnv_fromUnicode_UTF8_OFFSETS_LOGIC ucnv_fromUnicode_UTF8_OFFSETS_LOGIC_4_0
+#define ucnv_getAlias ucnv_getAlias_4_0
+#define ucnv_getAliases ucnv_getAliases_4_0
+#define ucnv_getAvailableName ucnv_getAvailableName_4_0
+#define ucnv_getCCSID ucnv_getCCSID_4_0
+#define ucnv_getCanonicalName ucnv_getCanonicalName_4_0
+#define ucnv_getCompleteUnicodeSet ucnv_getCompleteUnicodeSet_4_0
+#define ucnv_getDefaultName ucnv_getDefaultName_4_0
+#define ucnv_getDisplayName ucnv_getDisplayName_4_0
+#define ucnv_getFromUCallBack ucnv_getFromUCallBack_4_0
+#define ucnv_getInvalidChars ucnv_getInvalidChars_4_0
+#define ucnv_getInvalidUChars ucnv_getInvalidUChars_4_0
+#define ucnv_getMaxCharSize ucnv_getMaxCharSize_4_0
+#define ucnv_getMinCharSize ucnv_getMinCharSize_4_0
+#define ucnv_getName ucnv_getName_4_0
+#define ucnv_getNextUChar ucnv_getNextUChar_4_0
+#define ucnv_getNonSurrogateUnicodeSet ucnv_getNonSurrogateUnicodeSet_4_0
+#define ucnv_getPlatform ucnv_getPlatform_4_0
+#define ucnv_getStandard ucnv_getStandard_4_0
+#define ucnv_getStandardName ucnv_getStandardName_4_0
+#define ucnv_getStarters ucnv_getStarters_4_0
+#define ucnv_getSubstChars ucnv_getSubstChars_4_0
+#define ucnv_getToUCallBack ucnv_getToUCallBack_4_0
+#define ucnv_getType ucnv_getType_4_0
+#define ucnv_getUnicodeSet ucnv_getUnicodeSet_4_0
+#define ucnv_incrementRefCount ucnv_incrementRefCount_4_0
+#define ucnv_io_countKnownConverters ucnv_io_countKnownConverters_4_0
+#define ucnv_io_getConverterName ucnv_io_getConverterName_4_0
+#define ucnv_io_stripASCIIForCompare ucnv_io_stripASCIIForCompare_4_0
+#define ucnv_io_stripEBCDICForCompare ucnv_io_stripEBCDICForCompare_4_0
+#define ucnv_isAmbiguous ucnv_isAmbiguous_4_0
+#define ucnv_load ucnv_load_4_0
+#define ucnv_loadSharedData ucnv_loadSharedData_4_0
+#define ucnv_open ucnv_open_4_0
+#define ucnv_openAllNames ucnv_openAllNames_4_0
+#define ucnv_openCCSID ucnv_openCCSID_4_0
+#define ucnv_openPackage ucnv_openPackage_4_0
+#define ucnv_openStandardNames ucnv_openStandardNames_4_0
+#define ucnv_openU ucnv_openU_4_0
+#define ucnv_reset ucnv_reset_4_0
+#define ucnv_resetFromUnicode ucnv_resetFromUnicode_4_0
+#define ucnv_resetToUnicode ucnv_resetToUnicode_4_0
+#define ucnv_safeClone ucnv_safeClone_4_0
+#define ucnv_setDefaultName ucnv_setDefaultName_4_0
+#define ucnv_setFallback ucnv_setFallback_4_0
+#define ucnv_setFromUCallBack ucnv_setFromUCallBack_4_0
+#define ucnv_setSubstChars ucnv_setSubstChars_4_0
+#define ucnv_setSubstString ucnv_setSubstString_4_0
+#define ucnv_setToUCallBack ucnv_setToUCallBack_4_0
+#define ucnv_swap ucnv_swap_4_0
+#define ucnv_swapAliases ucnv_swapAliases_4_0
+#define ucnv_toAlgorithmic ucnv_toAlgorithmic_4_0
+#define ucnv_toUChars ucnv_toUChars_4_0
+#define ucnv_toUCountPending ucnv_toUCountPending_4_0
+#define ucnv_toUWriteCodePoint ucnv_toUWriteCodePoint_4_0
+#define ucnv_toUWriteUChars ucnv_toUWriteUChars_4_0
+#define ucnv_toUnicode ucnv_toUnicode_4_0
+#define ucnv_unload ucnv_unload_4_0
+#define ucnv_unloadSharedDataIfReady ucnv_unloadSharedDataIfReady_4_0
+#define ucnv_usesFallback ucnv_usesFallback_4_0
+#define ucol_allocWeights ucol_allocWeights_4_0
+#define ucol_assembleTailoringTable ucol_assembleTailoringTable_4_0
+#define ucol_calcSortKey ucol_calcSortKey_4_0
+#define ucol_calcSortKeySimpleTertiary ucol_calcSortKeySimpleTertiary_4_0
+#define ucol_cloneBinary ucol_cloneBinary_4_0
+#define ucol_cloneRuleData ucol_cloneRuleData_4_0
+#define ucol_close ucol_close_4_0
+#define ucol_closeElements ucol_closeElements_4_0
+#define ucol_countAvailable ucol_countAvailable_4_0
+#define ucol_createElements ucol_createElements_4_0
+#define ucol_doCE ucol_doCE_4_0
+#define ucol_equal ucol_equal_4_0
+#define ucol_equals ucol_equals_4_0
+#define ucol_forgetUCA ucol_forgetUCA_4_0
+#define ucol_getAttribute ucol_getAttribute_4_0
+#define ucol_getAttributeOrDefault ucol_getAttributeOrDefault_4_0
+#define ucol_getAvailable ucol_getAvailable_4_0
+#define ucol_getBound ucol_getBound_4_0
+#define ucol_getCEStrengthDifference ucol_getCEStrengthDifference_4_0
+#define ucol_getContractions ucol_getContractions_4_0
+#define ucol_getContractionsAndExpansions ucol_getContractionsAndExpansions_4_0
+#define ucol_getDisplayName ucol_getDisplayName_4_0
+#define ucol_getFirstCE ucol_getFirstCE_4_0
+#define ucol_getFunctionalEquivalent ucol_getFunctionalEquivalent_4_0
+#define ucol_getKeywordValues ucol_getKeywordValues_4_0
+#define ucol_getKeywords ucol_getKeywords_4_0
+#define ucol_getLocale ucol_getLocale_4_0
+#define ucol_getLocaleByType ucol_getLocaleByType_4_0
+#define ucol_getMaxExpansion ucol_getMaxExpansion_4_0
+#define ucol_getNextCE ucol_getNextCE_4_0
+#define ucol_getOffset ucol_getOffset_4_0
+#define ucol_getPrevCE ucol_getPrevCE_4_0
+#define ucol_getRules ucol_getRules_4_0
+#define ucol_getRulesEx ucol_getRulesEx_4_0
+#define ucol_getShortDefinitionString ucol_getShortDefinitionString_4_0
+#define ucol_getSortKey ucol_getSortKey_4_0
+#define ucol_getSortKeySize ucol_getSortKeySize_4_0
+#define ucol_getSortKeyWithAllocation ucol_getSortKeyWithAllocation_4_0
+#define ucol_getStrength ucol_getStrength_4_0
+#define ucol_getTailoredSet ucol_getTailoredSet_4_0
+#define ucol_getUCAVersion ucol_getUCAVersion_4_0
+#define ucol_getUnsafeSet ucol_getUnsafeSet_4_0
+#define ucol_getVariableTop ucol_getVariableTop_4_0
+#define ucol_getVersion ucol_getVersion_4_0
+#define ucol_greater ucol_greater_4_0
+#define ucol_greaterOrEqual ucol_greaterOrEqual_4_0
+#define ucol_initBuffers ucol_initBuffers_4_0
+#define ucol_initCollator ucol_initCollator_4_0
+#define ucol_initInverseUCA ucol_initInverseUCA_4_0
+#define ucol_initUCA ucol_initUCA_4_0
+#define ucol_inv_getNextCE ucol_inv_getNextCE_4_0
+#define ucol_inv_getPrevCE ucol_inv_getPrevCE_4_0
+#define ucol_isTailored ucol_isTailored_4_0
+#define ucol_keyHashCode ucol_keyHashCode_4_0
+#define ucol_mergeSortkeys ucol_mergeSortkeys_4_0
+#define ucol_next ucol_next_4_0
+#define ucol_nextProcessed ucol_nextProcessed_4_0
+#define ucol_nextSortKeyPart ucol_nextSortKeyPart_4_0
+#define ucol_nextWeight ucol_nextWeight_4_0
+#define ucol_normalizeShortDefinitionString ucol_normalizeShortDefinitionString_4_0
+#define ucol_open ucol_open_4_0
+#define ucol_openAvailableLocales ucol_openAvailableLocales_4_0
+#define ucol_openBinary ucol_openBinary_4_0
+#define ucol_openElements ucol_openElements_4_0
+#define ucol_openFromShortString ucol_openFromShortString_4_0
+#define ucol_openRules ucol_openRules_4_0
+#define ucol_open_internal ucol_open_internal_4_0
+#define ucol_prepareShortStringOpen ucol_prepareShortStringOpen_4_0
+#define ucol_previous ucol_previous_4_0
+#define ucol_previousProcessed ucol_previousProcessed_4_0
+#define ucol_primaryOrder ucol_primaryOrder_4_0
+#define ucol_prv_getSpecialCE ucol_prv_getSpecialCE_4_0
+#define ucol_prv_getSpecialPrevCE ucol_prv_getSpecialPrevCE_4_0
+#define ucol_reset ucol_reset_4_0
+#define ucol_restoreVariableTop ucol_restoreVariableTop_4_0
+#define ucol_safeClone ucol_safeClone_4_0
+#define ucol_secondaryOrder ucol_secondaryOrder_4_0
+#define ucol_setAttribute ucol_setAttribute_4_0
+#define ucol_setOffset ucol_setOffset_4_0
+#define ucol_setOptionsFromHeader ucol_setOptionsFromHeader_4_0
+#define ucol_setReqValidLocales ucol_setReqValidLocales_4_0
+#define ucol_setStrength ucol_setStrength_4_0
+#define ucol_setText ucol_setText_4_0
+#define ucol_setVariableTop ucol_setVariableTop_4_0
+#define ucol_strcoll ucol_strcoll_4_0
+#define ucol_strcollIter ucol_strcollIter_4_0
+#define ucol_swap ucol_swap_4_0
+#define ucol_swapBinary ucol_swapBinary_4_0
+#define ucol_swapInverseUCA ucol_swapInverseUCA_4_0
+#define ucol_tertiaryOrder ucol_tertiaryOrder_4_0
+#define ucol_tok_assembleTokenList ucol_tok_assembleTokenList_4_0
+#define ucol_tok_closeTokenList ucol_tok_closeTokenList_4_0
+#define ucol_tok_getNextArgument ucol_tok_getNextArgument_4_0
+#define ucol_tok_initTokenList ucol_tok_initTokenList_4_0
+#define ucol_tok_parseNextToken ucol_tok_parseNextToken_4_0
+#define ucol_updateInternalState ucol_updateInternalState_4_0
+#define ucsdet_close ucsdet_close_4_0
+#define ucsdet_detect ucsdet_detect_4_0
+#define ucsdet_detectAll ucsdet_detectAll_4_0
+#define ucsdet_enableInputFilter ucsdet_enableInputFilter_4_0
+#define ucsdet_getAllDetectableCharsets ucsdet_getAllDetectableCharsets_4_0
+#define ucsdet_getConfidence ucsdet_getConfidence_4_0
+#define ucsdet_getLanguage ucsdet_getLanguage_4_0
+#define ucsdet_getName ucsdet_getName_4_0
+#define ucsdet_getUChars ucsdet_getUChars_4_0
+#define ucsdet_isInputFilterEnabled ucsdet_isInputFilterEnabled_4_0
+#define ucsdet_open ucsdet_open_4_0
+#define ucsdet_setDeclaredEncoding ucsdet_setDeclaredEncoding_4_0
+#define ucsdet_setText ucsdet_setText_4_0
+#define ucurr_countCurrencies ucurr_countCurrencies_4_0
+#define ucurr_forLocale ucurr_forLocale_4_0
+#define ucurr_forLocaleAndDate ucurr_forLocaleAndDate_4_0
+#define ucurr_getDefaultFractionDigits ucurr_getDefaultFractionDigits_4_0
+#define ucurr_getName ucurr_getName_4_0
+#define ucurr_getRoundingIncrement ucurr_getRoundingIncrement_4_0
+#define ucurr_openISOCurrencies ucurr_openISOCurrencies_4_0
+#define ucurr_register ucurr_register_4_0
+#define ucurr_unregister ucurr_unregister_4_0
+#define udat_applyPattern udat_applyPattern_4_0
+#define udat_clone udat_clone_4_0
+#define udat_close udat_close_4_0
+#define udat_countAvailable udat_countAvailable_4_0
+#define udat_countSymbols udat_countSymbols_4_0
+#define udat_format udat_format_4_0
+#define udat_get2DigitYearStart udat_get2DigitYearStart_4_0
+#define udat_getAvailable udat_getAvailable_4_0
+#define udat_getCalendar udat_getCalendar_4_0
+#define udat_getLocaleByType udat_getLocaleByType_4_0
+#define udat_getNumberFormat udat_getNumberFormat_4_0
+#define udat_getSymbols udat_getSymbols_4_0
+#define udat_isLenient udat_isLenient_4_0
+#define udat_open udat_open_4_0
+#define udat_parse udat_parse_4_0
+#define udat_parseCalendar udat_parseCalendar_4_0
+#define udat_set2DigitYearStart udat_set2DigitYearStart_4_0
+#define udat_setCalendar udat_setCalendar_4_0
+#define udat_setLenient udat_setLenient_4_0
+#define udat_setNumberFormat udat_setNumberFormat_4_0
+#define udat_setSymbols udat_setSymbols_4_0
+#define udat_toPattern udat_toPattern_4_0
+#define udata_checkCommonData udata_checkCommonData_4_0
+#define udata_close udata_close_4_0
+#define udata_closeSwapper udata_closeSwapper_4_0
+#define udata_getHeaderSize udata_getHeaderSize_4_0
+#define udata_getInfo udata_getInfo_4_0
+#define udata_getInfoSize udata_getInfoSize_4_0
+#define udata_getLength udata_getLength_4_0
+#define udata_getMemory udata_getMemory_4_0
+#define udata_getRawMemory udata_getRawMemory_4_0
+#define udata_open udata_open_4_0
+#define udata_openChoice udata_openChoice_4_0
+#define udata_openSwapper udata_openSwapper_4_0
+#define udata_openSwapperForInputData udata_openSwapperForInputData_4_0
+#define udata_printError udata_printError_4_0
+#define udata_readInt16 udata_readInt16_4_0
+#define udata_readInt32 udata_readInt32_4_0
+#define udata_setAppData udata_setAppData_4_0
+#define udata_setCommonData udata_setCommonData_4_0
+#define udata_setFileAccess udata_setFileAccess_4_0
+#define udata_swapDataHeader udata_swapDataHeader_4_0
+#define udata_swapInvStringBlock udata_swapInvStringBlock_4_0
+#define udatpg_addPattern udatpg_addPattern_4_0
+#define udatpg_clone udatpg_clone_4_0
+#define udatpg_close udatpg_close_4_0
+#define udatpg_getAppendItemFormat udatpg_getAppendItemFormat_4_0
+#define udatpg_getAppendItemName udatpg_getAppendItemName_4_0
+#define udatpg_getBaseSkeleton udatpg_getBaseSkeleton_4_0
+#define udatpg_getBestPattern udatpg_getBestPattern_4_0
+#define udatpg_getDateTimeFormat udatpg_getDateTimeFormat_4_0
+#define udatpg_getDecimal udatpg_getDecimal_4_0
+#define udatpg_getPatternForSkeleton udatpg_getPatternForSkeleton_4_0
+#define udatpg_getSkeleton udatpg_getSkeleton_4_0
+#define udatpg_open udatpg_open_4_0
+#define udatpg_openBaseSkeletons udatpg_openBaseSkeletons_4_0
+#define udatpg_openEmpty udatpg_openEmpty_4_0
+#define udatpg_openSkeletons udatpg_openSkeletons_4_0
+#define udatpg_replaceFieldTypes udatpg_replaceFieldTypes_4_0
+#define udatpg_setAppendItemFormat udatpg_setAppendItemFormat_4_0
+#define udatpg_setAppendItemName udatpg_setAppendItemName_4_0
+#define udatpg_setDateTimeFormat udatpg_setDateTimeFormat_4_0
+#define udatpg_setDecimal udatpg_setDecimal_4_0
+#define uenum_close uenum_close_4_0
+#define uenum_count uenum_count_4_0
+#define uenum_next uenum_next_4_0
+#define uenum_nextDefault uenum_nextDefault_4_0
+#define uenum_openCharStringsEnumeration uenum_openCharStringsEnumeration_4_0
+#define uenum_openStringEnumeration uenum_openStringEnumeration_4_0
+#define uenum_reset uenum_reset_4_0
+#define uenum_unext uenum_unext_4_0
+#define uenum_unextDefault uenum_unextDefault_4_0
+#define ufile_close_translit ufile_close_translit_4_0
+#define ufile_fill_uchar_buffer ufile_fill_uchar_buffer_4_0
+#define ufile_flush_translit ufile_flush_translit_4_0
+#define ufile_getch ufile_getch_4_0
+#define ufile_getch32 ufile_getch32_4_0
+#define ufmt_64tou ufmt_64tou_4_0
+#define ufmt_defaultCPToUnicode ufmt_defaultCPToUnicode_4_0
+#define ufmt_digitvalue ufmt_digitvalue_4_0
+#define ufmt_isdigit ufmt_isdigit_4_0
+#define ufmt_ptou ufmt_ptou_4_0
+#define ufmt_uto64 ufmt_uto64_4_0
+#define ufmt_utop ufmt_utop_4_0
+#define uhash_close uhash_close_4_0
+#define uhash_compareCaselessUnicodeString uhash_compareCaselessUnicodeString_4_0
+#define uhash_compareChars uhash_compareChars_4_0
+#define uhash_compareIChars uhash_compareIChars_4_0
+#define uhash_compareLong uhash_compareLong_4_0
+#define uhash_compareUChars uhash_compareUChars_4_0
+#define uhash_compareUnicodeString uhash_compareUnicodeString_4_0
+#define uhash_count uhash_count_4_0
+#define uhash_deleteHashtable uhash_deleteHashtable_4_0
+#define uhash_deleteUVector uhash_deleteUVector_4_0
+#define uhash_deleteUnicodeString uhash_deleteUnicodeString_4_0
+#define uhash_equals uhash_equals_4_0
+#define uhash_find uhash_find_4_0
+#define uhash_freeBlock uhash_freeBlock_4_0
+#define uhash_get uhash_get_4_0
+#define uhash_geti uhash_geti_4_0
+#define uhash_hashCaselessUnicodeString uhash_hashCaselessUnicodeString_4_0
+#define uhash_hashChars uhash_hashChars_4_0
+#define uhash_hashIChars uhash_hashIChars_4_0
+#define uhash_hashLong uhash_hashLong_4_0
+#define uhash_hashUChars uhash_hashUChars_4_0
+#define uhash_hashUCharsN uhash_hashUCharsN_4_0
+#define uhash_hashUnicodeString uhash_hashUnicodeString_4_0
+#define uhash_iget uhash_iget_4_0
+#define uhash_igeti uhash_igeti_4_0
+#define uhash_init uhash_init_4_0
+#define uhash_iput uhash_iput_4_0
+#define uhash_iputi uhash_iputi_4_0
+#define uhash_iremove uhash_iremove_4_0
+#define uhash_iremovei uhash_iremovei_4_0
+#define uhash_nextElement uhash_nextElement_4_0
+#define uhash_open uhash_open_4_0
+#define uhash_openSize uhash_openSize_4_0
+#define uhash_put uhash_put_4_0
+#define uhash_puti uhash_puti_4_0
+#define uhash_remove uhash_remove_4_0
+#define uhash_removeAll uhash_removeAll_4_0
+#define uhash_removeElement uhash_removeElement_4_0
+#define uhash_removei uhash_removei_4_0
+#define uhash_setKeyComparator uhash_setKeyComparator_4_0
+#define uhash_setKeyDeleter uhash_setKeyDeleter_4_0
+#define uhash_setKeyHasher uhash_setKeyHasher_4_0
+#define uhash_setResizePolicy uhash_setResizePolicy_4_0
+#define uhash_setValueComparator uhash_setValueComparator_4_0
+#define uhash_setValueDeleter uhash_setValueDeleter_4_0
+#define uhst_addPropertyStarts uhst_addPropertyStarts_4_0
+#define uidna_IDNToASCII uidna_IDNToASCII_4_0
+#define uidna_IDNToUnicode uidna_IDNToUnicode_4_0
+#define uidna_compare uidna_compare_4_0
+#define uidna_toASCII uidna_toASCII_4_0
+#define uidna_toUnicode uidna_toUnicode_4_0
+#define uiter_current32 uiter_current32_4_0
+#define uiter_getState uiter_getState_4_0
+#define uiter_next32 uiter_next32_4_0
+#define uiter_previous32 uiter_previous32_4_0
+#define uiter_setCharacterIterator uiter_setCharacterIterator_4_0
+#define uiter_setReplaceable uiter_setReplaceable_4_0
+#define uiter_setState uiter_setState_4_0
+#define uiter_setString uiter_setString_4_0
+#define uiter_setUTF16BE uiter_setUTF16BE_4_0
+#define uiter_setUTF8 uiter_setUTF8_4_0
+#define uloc_acceptLanguage uloc_acceptLanguage_4_0
+#define uloc_acceptLanguageFromHTTP uloc_acceptLanguageFromHTTP_4_0
+#define uloc_addLikelySubtags uloc_addLikelySubtags_4_0
+#define uloc_canonicalize uloc_canonicalize_4_0
+#define uloc_countAvailable uloc_countAvailable_4_0
+#define uloc_getAvailable uloc_getAvailable_4_0
+#define uloc_getBaseName uloc_getBaseName_4_0
+#define uloc_getCharacterOrientation uloc_getCharacterOrientation_4_0
+#define uloc_getCountry uloc_getCountry_4_0
+#define uloc_getDefault uloc_getDefault_4_0
+#define uloc_getDisplayCountry uloc_getDisplayCountry_4_0
+#define uloc_getDisplayKeyword uloc_getDisplayKeyword_4_0
+#define uloc_getDisplayKeywordValue uloc_getDisplayKeywordValue_4_0
+#define uloc_getDisplayLanguage uloc_getDisplayLanguage_4_0
+#define uloc_getDisplayName uloc_getDisplayName_4_0
+#define uloc_getDisplayScript uloc_getDisplayScript_4_0
+#define uloc_getDisplayVariant uloc_getDisplayVariant_4_0
+#define uloc_getISO3Country uloc_getISO3Country_4_0
+#define uloc_getISO3Language uloc_getISO3Language_4_0
+#define uloc_getISOCountries uloc_getISOCountries_4_0
+#define uloc_getISOLanguages uloc_getISOLanguages_4_0
+#define uloc_getKeywordValue uloc_getKeywordValue_4_0
+#define uloc_getLCID uloc_getLCID_4_0
+#define uloc_getLanguage uloc_getLanguage_4_0
+#define uloc_getLineOrientation uloc_getLineOrientation_4_0
+#define uloc_getLocaleForLCID uloc_getLocaleForLCID_4_0
+#define uloc_getName uloc_getName_4_0
+#define uloc_getParent uloc_getParent_4_0
+#define uloc_getScript uloc_getScript_4_0
+#define uloc_getVariant uloc_getVariant_4_0
+#define uloc_minimizeSubtags uloc_minimizeSubtags_4_0
+#define uloc_openKeywordList uloc_openKeywordList_4_0
+#define uloc_openKeywords uloc_openKeywords_4_0
+#define uloc_setDefault uloc_setDefault_4_0
+#define uloc_setKeywordValue uloc_setKeywordValue_4_0
+#define ulocdata_close ulocdata_close_4_0
+#define ulocdata_getDelimiter ulocdata_getDelimiter_4_0
+#define ulocdata_getExemplarSet ulocdata_getExemplarSet_4_0
+#define ulocdata_getMeasurementSystem ulocdata_getMeasurementSystem_4_0
+#define ulocdata_getNoSubstitute ulocdata_getNoSubstitute_4_0
+#define ulocdata_getPaperSize ulocdata_getPaperSize_4_0
+#define ulocdata_open ulocdata_open_4_0
+#define ulocdata_setNoSubstitute ulocdata_setNoSubstitute_4_0
+#define umsg_applyPattern umsg_applyPattern_4_0
+#define umsg_autoQuoteApostrophe umsg_autoQuoteApostrophe_4_0
+#define umsg_clone umsg_clone_4_0
+#define umsg_close umsg_close_4_0
+#define umsg_format umsg_format_4_0
+#define umsg_getLocale umsg_getLocale_4_0
+#define umsg_open umsg_open_4_0
+#define umsg_parse umsg_parse_4_0
+#define umsg_setLocale umsg_setLocale_4_0
+#define umsg_toPattern umsg_toPattern_4_0
+#define umsg_vformat umsg_vformat_4_0
+#define umsg_vparse umsg_vparse_4_0
+#define umtx_atomic_dec umtx_atomic_dec_4_0
+#define umtx_atomic_inc umtx_atomic_inc_4_0
+#define umtx_cleanup umtx_cleanup_4_0
+#define umtx_destroy umtx_destroy_4_0
+#define umtx_init umtx_init_4_0
+#define umtx_lock umtx_lock_4_0
+#define umtx_unlock umtx_unlock_4_0
+#define unorm_addPropertyStarts unorm_addPropertyStarts_4_0
+#define unorm_closeIter unorm_closeIter_4_0
+#define unorm_compare unorm_compare_4_0
+#define unorm_compose unorm_compose_4_0
+#define unorm_concatenate unorm_concatenate_4_0
+#define unorm_decompose unorm_decompose_4_0
+#define unorm_getCanonStartSet unorm_getCanonStartSet_4_0
+#define unorm_getCanonicalDecomposition unorm_getCanonicalDecomposition_4_0
+#define unorm_getDecomposition unorm_getDecomposition_4_0
+#define unorm_getFCD16FromCodePoint unorm_getFCD16FromCodePoint_4_0
+#define unorm_getFCDTrie unorm_getFCDTrie_4_0
+#define unorm_getNX unorm_getNX_4_0
+#define unorm_getQuickCheck unorm_getQuickCheck_4_0
+#define unorm_getUnicodeVersion unorm_getUnicodeVersion_4_0
+#define unorm_haveData unorm_haveData_4_0
+#define unorm_internalIsFullCompositionExclusion unorm_internalIsFullCompositionExclusion_4_0
+#define unorm_internalNormalize unorm_internalNormalize_4_0
+#define unorm_internalNormalizeWithNX unorm_internalNormalizeWithNX_4_0
+#define unorm_internalQuickCheck unorm_internalQuickCheck_4_0
+#define unorm_isCanonSafeStart unorm_isCanonSafeStart_4_0
+#define unorm_isNFSkippable unorm_isNFSkippable_4_0
+#define unorm_isNormalized unorm_isNormalized_4_0
+#define unorm_isNormalizedWithOptions unorm_isNormalizedWithOptions_4_0
+#define unorm_next unorm_next_4_0
+#define unorm_normalize unorm_normalize_4_0
+#define unorm_openIter unorm_openIter_4_0
+#define unorm_previous unorm_previous_4_0
+#define unorm_quickCheck unorm_quickCheck_4_0
+#define unorm_quickCheckWithOptions unorm_quickCheckWithOptions_4_0
+#define unorm_setIter unorm_setIter_4_0
+#define unum_applyPattern unum_applyPattern_4_0
+#define unum_clone unum_clone_4_0
+#define unum_close unum_close_4_0
+#define unum_countAvailable unum_countAvailable_4_0
+#define unum_format unum_format_4_0
+#define unum_formatDouble unum_formatDouble_4_0
+#define unum_formatDoubleCurrency unum_formatDoubleCurrency_4_0
+#define unum_formatInt64 unum_formatInt64_4_0
+#define unum_getAttribute unum_getAttribute_4_0
+#define unum_getAvailable unum_getAvailable_4_0
+#define unum_getDoubleAttribute unum_getDoubleAttribute_4_0
+#define unum_getLocaleByType unum_getLocaleByType_4_0
+#define unum_getSymbol unum_getSymbol_4_0
+#define unum_getTextAttribute unum_getTextAttribute_4_0
+#define unum_open unum_open_4_0
+#define unum_parse unum_parse_4_0
+#define unum_parseDouble unum_parseDouble_4_0
+#define unum_parseDoubleCurrency unum_parseDoubleCurrency_4_0
+#define unum_parseInt64 unum_parseInt64_4_0
+#define unum_setAttribute unum_setAttribute_4_0
+#define unum_setDoubleAttribute unum_setDoubleAttribute_4_0
+#define unum_setSymbol unum_setSymbol_4_0
+#define unum_setTextAttribute unum_setTextAttribute_4_0
+#define unum_toPattern unum_toPattern_4_0
+#define upname_swap upname_swap_4_0
+#define uprops_getSource uprops_getSource_4_0
+#define upropsvec_addPropertyStarts upropsvec_addPropertyStarts_4_0
+#define uprv_asciiFromEbcdic uprv_asciiFromEbcdic_4_0
+#define uprv_asciitolower uprv_asciitolower_4_0
+#define uprv_ceil uprv_ceil_4_0
+#define uprv_cnttab_addContraction uprv_cnttab_addContraction_4_0
+#define uprv_cnttab_changeContraction uprv_cnttab_changeContraction_4_0
+#define uprv_cnttab_changeLastCE uprv_cnttab_changeLastCE_4_0
+#define uprv_cnttab_clone uprv_cnttab_clone_4_0
+#define uprv_cnttab_close uprv_cnttab_close_4_0
+#define uprv_cnttab_constructTable uprv_cnttab_constructTable_4_0
+#define uprv_cnttab_findCE uprv_cnttab_findCE_4_0
+#define uprv_cnttab_findCP uprv_cnttab_findCP_4_0
+#define uprv_cnttab_getCE uprv_cnttab_getCE_4_0
+#define uprv_cnttab_insertContraction uprv_cnttab_insertContraction_4_0
+#define uprv_cnttab_isTailored uprv_cnttab_isTailored_4_0
+#define uprv_cnttab_open uprv_cnttab_open_4_0
+#define uprv_cnttab_setContraction uprv_cnttab_setContraction_4_0
+#define uprv_compareASCIIPropertyNames uprv_compareASCIIPropertyNames_4_0
+#define uprv_compareEBCDICPropertyNames uprv_compareEBCDICPropertyNames_4_0
+#define uprv_compareInvAscii uprv_compareInvAscii_4_0
+#define uprv_compareInvEbcdic uprv_compareInvEbcdic_4_0
+#define uprv_convertToLCID uprv_convertToLCID_4_0
+#define uprv_convertToPosix uprv_convertToPosix_4_0
+#define uprv_copyAscii uprv_copyAscii_4_0
+#define uprv_copyEbcdic uprv_copyEbcdic_4_0
+#define uprv_ebcdicFromAscii uprv_ebcdicFromAscii_4_0
+#define uprv_ebcdictolower uprv_ebcdictolower_4_0
+#define uprv_fabs uprv_fabs_4_0
+#define uprv_floor uprv_floor_4_0
+#define uprv_fmax uprv_fmax_4_0
+#define uprv_fmin uprv_fmin_4_0
+#define uprv_fmod uprv_fmod_4_0
+#define uprv_free uprv_free_4_0
+#define uprv_getCharNameCharacters uprv_getCharNameCharacters_4_0
+#define uprv_getDefaultCodepage uprv_getDefaultCodepage_4_0
+#define uprv_getDefaultLocaleID uprv_getDefaultLocaleID_4_0
+#define uprv_getInfinity uprv_getInfinity_4_0
+#define uprv_getMaxCharNameLength uprv_getMaxCharNameLength_4_0
+#define uprv_getMaxValues uprv_getMaxValues_4_0
+#define uprv_getNaN uprv_getNaN_4_0
+#define uprv_getStaticCurrencyName uprv_getStaticCurrencyName_4_0
+#define uprv_getUTCtime uprv_getUTCtime_4_0
+#define uprv_haveProperties uprv_haveProperties_4_0
+#define uprv_init_collIterate uprv_init_collIterate_4_0
+#define uprv_init_pce uprv_init_pce_4_0
+#define uprv_int32Comparator uprv_int32Comparator_4_0
+#define uprv_isInfinite uprv_isInfinite_4_0
+#define uprv_isInvariantString uprv_isInvariantString_4_0
+#define uprv_isInvariantUString uprv_isInvariantUString_4_0
+#define uprv_isNaN uprv_isNaN_4_0
+#define uprv_isNegativeInfinity uprv_isNegativeInfinity_4_0
+#define uprv_isPositiveInfinity uprv_isPositiveInfinity_4_0
+#define uprv_isRuleWhiteSpace uprv_isRuleWhiteSpace_4_0
+#define uprv_itou uprv_itou_4_0
+#define uprv_log uprv_log_4_0
+#define uprv_malloc uprv_malloc_4_0
+#define uprv_mapFile uprv_mapFile_4_0
+#define uprv_max uprv_max_4_0
+#define uprv_maxMantissa uprv_maxMantissa_4_0
+#define uprv_maximumPtr uprv_maximumPtr_4_0
+#define uprv_min uprv_min_4_0
+#define uprv_modf uprv_modf_4_0
+#define uprv_openRuleWhiteSpaceSet uprv_openRuleWhiteSpaceSet_4_0
+#define uprv_parseCurrency uprv_parseCurrency_4_0
+#define uprv_pathIsAbsolute uprv_pathIsAbsolute_4_0
+#define uprv_pow uprv_pow_4_0
+#define uprv_pow10 uprv_pow10_4_0
+#define uprv_realloc uprv_realloc_4_0
+#define uprv_round uprv_round_4_0
+#define uprv_sortArray uprv_sortArray_4_0
+#define uprv_strCompare uprv_strCompare_4_0
+#define uprv_strdup uprv_strdup_4_0
+#define uprv_strndup uprv_strndup_4_0
+#define uprv_syntaxError uprv_syntaxError_4_0
+#define uprv_timezone uprv_timezone_4_0
+#define uprv_toupper uprv_toupper_4_0
+#define uprv_trunc uprv_trunc_4_0
+#define uprv_tzname uprv_tzname_4_0
+#define uprv_tzset uprv_tzset_4_0
+#define uprv_uca_addAnElement uprv_uca_addAnElement_4_0
+#define uprv_uca_assembleTable uprv_uca_assembleTable_4_0
+#define uprv_uca_canonicalClosure uprv_uca_canonicalClosure_4_0
+#define uprv_uca_closeTempTable uprv_uca_closeTempTable_4_0
+#define uprv_uca_getCodePointFromRaw uprv_uca_getCodePointFromRaw_4_0
+#define uprv_uca_getImplicitFromRaw uprv_uca_getImplicitFromRaw_4_0
+#define uprv_uca_getRawFromCodePoint uprv_uca_getRawFromCodePoint_4_0
+#define uprv_uca_getRawFromImplicit uprv_uca_getRawFromImplicit_4_0
+#define uprv_uca_initImplicitConstants uprv_uca_initImplicitConstants_4_0
+#define uprv_uca_initTempTable uprv_uca_initTempTable_4_0
+#define uprv_uint16Comparator uprv_uint16Comparator_4_0
+#define uprv_uint32Comparator uprv_uint32Comparator_4_0
+#define uprv_unmapFile uprv_unmapFile_4_0
+#define uregex_appendReplacement uregex_appendReplacement_4_0
+#define uregex_appendTail uregex_appendTail_4_0
+#define uregex_clone uregex_clone_4_0
+#define uregex_close uregex_close_4_0
+#define uregex_end uregex_end_4_0
+#define uregex_find uregex_find_4_0
+#define uregex_findNext uregex_findNext_4_0
+#define uregex_flags uregex_flags_4_0
+#define uregex_getMatchCallback uregex_getMatchCallback_4_0
+#define uregex_getStackLimit uregex_getStackLimit_4_0
+#define uregex_getText uregex_getText_4_0
+#define uregex_getTimeLimit uregex_getTimeLimit_4_0
+#define uregex_group uregex_group_4_0
+#define uregex_groupCount uregex_groupCount_4_0
+#define uregex_hasAnchoringBounds uregex_hasAnchoringBounds_4_0
+#define uregex_hasTransparentBounds uregex_hasTransparentBounds_4_0
+#define uregex_hitEnd uregex_hitEnd_4_0
+#define uregex_lookingAt uregex_lookingAt_4_0
+#define uregex_matches uregex_matches_4_0
+#define uregex_open uregex_open_4_0
+#define uregex_openC uregex_openC_4_0
+#define uregex_pattern uregex_pattern_4_0
+#define uregex_regionEnd uregex_regionEnd_4_0
+#define uregex_regionStart uregex_regionStart_4_0
+#define uregex_replaceAll uregex_replaceAll_4_0
+#define uregex_replaceFirst uregex_replaceFirst_4_0
+#define uregex_requireEnd uregex_requireEnd_4_0
+#define uregex_reset uregex_reset_4_0
+#define uregex_setMatchCallback uregex_setMatchCallback_4_0
+#define uregex_setRegion uregex_setRegion_4_0
+#define uregex_setStackLimit uregex_setStackLimit_4_0
+#define uregex_setText uregex_setText_4_0
+#define uregex_setTimeLimit uregex_setTimeLimit_4_0
+#define uregex_split uregex_split_4_0
+#define uregex_start uregex_start_4_0
+#define uregex_useAnchoringBounds uregex_useAnchoringBounds_4_0
+#define uregex_useTransparentBounds uregex_useTransparentBounds_4_0
+#define ures_close ures_close_4_0
+#define ures_copyResb ures_copyResb_4_0
+#define ures_countArrayItems ures_countArrayItems_4_0
+#define ures_findResource ures_findResource_4_0
+#define ures_findSubResource ures_findSubResource_4_0
+#define ures_getBinary ures_getBinary_4_0
+#define ures_getByIndex ures_getByIndex_4_0
+#define ures_getByKey ures_getByKey_4_0
+#define ures_getByKeyWithFallback ures_getByKeyWithFallback_4_0
+#define ures_getFunctionalEquivalent ures_getFunctionalEquivalent_4_0
+#define ures_getInt ures_getInt_4_0
+#define ures_getIntVector ures_getIntVector_4_0
+#define ures_getKey ures_getKey_4_0
+#define ures_getKeywordValues ures_getKeywordValues_4_0
+#define ures_getLocale ures_getLocale_4_0
+#define ures_getLocaleByType ures_getLocaleByType_4_0
+#define ures_getName ures_getName_4_0
+#define ures_getNextResource ures_getNextResource_4_0
+#define ures_getNextString ures_getNextString_4_0
+#define ures_getSize ures_getSize_4_0
+#define ures_getString ures_getString_4_0
+#define ures_getStringByIndex ures_getStringByIndex_4_0
+#define ures_getStringByKey ures_getStringByKey_4_0
+#define ures_getStringByKeyWithFallback ures_getStringByKeyWithFallback_4_0
+#define ures_getType ures_getType_4_0
+#define ures_getUInt ures_getUInt_4_0
+#define ures_getUTF8String ures_getUTF8String_4_0
+#define ures_getUTF8StringByIndex ures_getUTF8StringByIndex_4_0
+#define ures_getUTF8StringByKey ures_getUTF8StringByKey_4_0
+#define ures_getVersion ures_getVersion_4_0
+#define ures_getVersionNumber ures_getVersionNumber_4_0
+#define ures_hasNext ures_hasNext_4_0
+#define ures_initStackObject ures_initStackObject_4_0
+#define ures_open ures_open_4_0
+#define ures_openAvailableLocales ures_openAvailableLocales_4_0
+#define ures_openDirect ures_openDirect_4_0
+#define ures_openFillIn ures_openFillIn_4_0
+#define ures_openU ures_openU_4_0
+#define ures_resetIterator ures_resetIterator_4_0
+#define ures_swap ures_swap_4_0
+#define uscript_closeRun uscript_closeRun_4_0
+#define uscript_getCode uscript_getCode_4_0
+#define uscript_getName uscript_getName_4_0
+#define uscript_getScript uscript_getScript_4_0
+#define uscript_getShortName uscript_getShortName_4_0
+#define uscript_nextRun uscript_nextRun_4_0
+#define uscript_openRun uscript_openRun_4_0
+#define uscript_resetRun uscript_resetRun_4_0
+#define uscript_setRunText uscript_setRunText_4_0
+#define usearch_close usearch_close_4_0
+#define usearch_first usearch_first_4_0
+#define usearch_following usearch_following_4_0
+#define usearch_getAttribute usearch_getAttribute_4_0
+#define usearch_getBreakIterator usearch_getBreakIterator_4_0
+#define usearch_getCollator usearch_getCollator_4_0
+#define usearch_getMatchedLength usearch_getMatchedLength_4_0
+#define usearch_getMatchedStart usearch_getMatchedStart_4_0
+#define usearch_getMatchedText usearch_getMatchedText_4_0
+#define usearch_getOffset usearch_getOffset_4_0
+#define usearch_getPattern usearch_getPattern_4_0
+#define usearch_getText usearch_getText_4_0
+#define usearch_handleNextCanonical usearch_handleNextCanonical_4_0
+#define usearch_handleNextExact usearch_handleNextExact_4_0
+#define usearch_handlePreviousCanonical usearch_handlePreviousCanonical_4_0
+#define usearch_handlePreviousExact usearch_handlePreviousExact_4_0
+#define usearch_last usearch_last_4_0
+#define usearch_next usearch_next_4_0
+#define usearch_open usearch_open_4_0
+#define usearch_openFromCollator usearch_openFromCollator_4_0
+#define usearch_preceding usearch_preceding_4_0
+#define usearch_previous usearch_previous_4_0
+#define usearch_reset usearch_reset_4_0
+#define usearch_search usearch_search_4_0
+#define usearch_searchBackwards usearch_searchBackwards_4_0
+#define usearch_setAttribute usearch_setAttribute_4_0
+#define usearch_setBreakIterator usearch_setBreakIterator_4_0
+#define usearch_setCollator usearch_setCollator_4_0
+#define usearch_setOffset usearch_setOffset_4_0
+#define usearch_setPattern usearch_setPattern_4_0
+#define usearch_setText usearch_setText_4_0
+#define uset_add uset_add_4_0
+#define uset_addAll uset_addAll_4_0
+#define uset_addAllCodePoints uset_addAllCodePoints_4_0
+#define uset_addRange uset_addRange_4_0
+#define uset_addString uset_addString_4_0
+#define uset_applyIntPropertyValue uset_applyIntPropertyValue_4_0
+#define uset_applyPattern uset_applyPattern_4_0
+#define uset_applyPropertyAlias uset_applyPropertyAlias_4_0
+#define uset_charAt uset_charAt_4_0
+#define uset_clear uset_clear_4_0
+#define uset_clone uset_clone_4_0
+#define uset_cloneAsThawed uset_cloneAsThawed_4_0
+#define uset_close uset_close_4_0
+#define uset_compact uset_compact_4_0
+#define uset_complement uset_complement_4_0
+#define uset_complementAll uset_complementAll_4_0
+#define uset_contains uset_contains_4_0
+#define uset_containsAll uset_containsAll_4_0
+#define uset_containsAllCodePoints uset_containsAllCodePoints_4_0
+#define uset_containsNone uset_containsNone_4_0
+#define uset_containsRange uset_containsRange_4_0
+#define uset_containsSome uset_containsSome_4_0
+#define uset_containsString uset_containsString_4_0
+#define uset_equals uset_equals_4_0
+#define uset_freeze uset_freeze_4_0
+#define uset_getItem uset_getItem_4_0
+#define uset_getItemCount uset_getItemCount_4_0
+#define uset_getSerializedRange uset_getSerializedRange_4_0
+#define uset_getSerializedRangeCount uset_getSerializedRangeCount_4_0
+#define uset_getSerializedSet uset_getSerializedSet_4_0
+#define uset_indexOf uset_indexOf_4_0
+#define uset_isEmpty uset_isEmpty_4_0
+#define uset_isFrozen uset_isFrozen_4_0
+#define uset_open uset_open_4_0
+#define uset_openPattern uset_openPattern_4_0
+#define uset_openPatternOptions uset_openPatternOptions_4_0
+#define uset_remove uset_remove_4_0
+#define uset_removeAll uset_removeAll_4_0
+#define uset_removeRange uset_removeRange_4_0
+#define uset_removeString uset_removeString_4_0
+#define uset_resemblesPattern uset_resemblesPattern_4_0
+#define uset_retain uset_retain_4_0
+#define uset_retainAll uset_retainAll_4_0
+#define uset_serialize uset_serialize_4_0
+#define uset_serializedContains uset_serializedContains_4_0
+#define uset_set uset_set_4_0
+#define uset_setSerializedToOne uset_setSerializedToOne_4_0
+#define uset_size uset_size_4_0
+#define uset_span uset_span_4_0
+#define uset_spanBack uset_spanBack_4_0
+#define uset_spanBackUTF8 uset_spanBackUTF8_4_0
+#define uset_spanUTF8 uset_spanUTF8_4_0
+#define uset_toPattern uset_toPattern_4_0
+#define usprep_close usprep_close_4_0
+#define usprep_open usprep_open_4_0
+#define usprep_prepare usprep_prepare_4_0
+#define usprep_swap usprep_swap_4_0
+#define ustr_foldCase ustr_foldCase_4_0
+#define ustr_toLower ustr_toLower_4_0
+#define ustr_toTitle ustr_toTitle_4_0
+#define ustr_toUpper ustr_toUpper_4_0
+#define utext_char32At utext_char32At_4_0
+#define utext_clone utext_clone_4_0
+#define utext_close utext_close_4_0
+#define utext_copy utext_copy_4_0
+#define utext_current32 utext_current32_4_0
+#define utext_equals utext_equals_4_0
+#define utext_extract utext_extract_4_0
+#define utext_freeze utext_freeze_4_0
+#define utext_getNativeIndex utext_getNativeIndex_4_0
+#define utext_getPreviousNativeIndex utext_getPreviousNativeIndex_4_0
+#define utext_hasMetaData utext_hasMetaData_4_0
+#define utext_isLengthExpensive utext_isLengthExpensive_4_0
+#define utext_isWritable utext_isWritable_4_0
+#define utext_moveIndex32 utext_moveIndex32_4_0
+#define utext_nativeLength utext_nativeLength_4_0
+#define utext_next32 utext_next32_4_0
+#define utext_next32From utext_next32From_4_0
+#define utext_openCharacterIterator utext_openCharacterIterator_4_0
+#define utext_openConstUnicodeString utext_openConstUnicodeString_4_0
+#define utext_openReplaceable utext_openReplaceable_4_0
+#define utext_openUChars utext_openUChars_4_0
+#define utext_openUTF8 utext_openUTF8_4_0
+#define utext_openUnicodeString utext_openUnicodeString_4_0
+#define utext_previous32 utext_previous32_4_0
+#define utext_previous32From utext_previous32From_4_0
+#define utext_replace utext_replace_4_0
+#define utext_setNativeIndex utext_setNativeIndex_4_0
+#define utext_setup utext_setup_4_0
+#define utf8_appendCharSafeBody utf8_appendCharSafeBody_4_0
+#define utf8_back1SafeBody utf8_back1SafeBody_4_0
+#define utf8_countTrailBytes utf8_countTrailBytes_4_0
+#define utf8_nextCharSafeBody utf8_nextCharSafeBody_4_0
+#define utf8_prevCharSafeBody utf8_prevCharSafeBody_4_0
+#define utmscale_fromInt64 utmscale_fromInt64_4_0
+#define utmscale_getTimeScaleValue utmscale_getTimeScaleValue_4_0
+#define utmscale_toInt64 utmscale_toInt64_4_0
+#define utrace_cleanup utrace_cleanup_4_0
+#define utrace_data utrace_data_4_0
+#define utrace_entry utrace_entry_4_0
+#define utrace_exit utrace_exit_4_0
+#define utrace_format utrace_format_4_0
+#define utrace_functionName utrace_functionName_4_0
+#define utrace_getFunctions utrace_getFunctions_4_0
+#define utrace_getLevel utrace_getLevel_4_0
+#define utrace_level utrace_level_4_0
+#define utrace_setFunctions utrace_setFunctions_4_0
+#define utrace_setLevel utrace_setLevel_4_0
+#define utrace_vformat utrace_vformat_4_0
+#define utrans_clone utrans_clone_4_0
+#define utrans_close utrans_close_4_0
+#define utrans_countAvailableIDs utrans_countAvailableIDs_4_0
+#define utrans_getAvailableID utrans_getAvailableID_4_0
+#define utrans_getID utrans_getID_4_0
+#define utrans_getUnicodeID utrans_getUnicodeID_4_0
+#define utrans_open utrans_open_4_0
+#define utrans_openIDs utrans_openIDs_4_0
+#define utrans_openInverse utrans_openInverse_4_0
+#define utrans_openU utrans_openU_4_0
+#define utrans_register utrans_register_4_0
+#define utrans_rep_caseContextIterator utrans_rep_caseContextIterator_4_0
+#define utrans_setFilter utrans_setFilter_4_0
+#define utrans_stripRules utrans_stripRules_4_0
+#define utrans_trans utrans_trans_4_0
+#define utrans_transIncremental utrans_transIncremental_4_0
+#define utrans_transIncrementalUChars utrans_transIncrementalUChars_4_0
+#define utrans_transUChars utrans_transUChars_4_0
+#define utrans_unregister utrans_unregister_4_0
+#define utrans_unregisterID utrans_unregisterID_4_0
+#define utrie_clone utrie_clone_4_0
+#define utrie_close utrie_close_4_0
+#define utrie_defaultGetFoldingOffset utrie_defaultGetFoldingOffset_4_0
+#define utrie_enum utrie_enum_4_0
+#define utrie_get32 utrie_get32_4_0
+#define utrie_getData utrie_getData_4_0
+#define utrie_open utrie_open_4_0
+#define utrie_serialize utrie_serialize_4_0
+#define utrie_set32 utrie_set32_4_0
+#define utrie_setRange32 utrie_setRange32_4_0
+#define utrie_swap utrie_swap_4_0
+#define utrie_unserialize utrie_unserialize_4_0
+#define utrie_unserializeDummy utrie_unserializeDummy_4_0
+/* C++ class names renaming defines */
+
+#ifdef XP_CPLUSPLUS
+#if !U_HAVE_NAMESPACE
+
+#define AbsoluteValueSubstitution AbsoluteValueSubstitution_4_0
+#define AlternateSubstitutionSubtable AlternateSubstitutionSubtable_4_0
+#define AnchorTable AnchorTable_4_0
+#define AndConstraint AndConstraint_4_0
+#define AnnualTimeZoneRule AnnualTimeZoneRule_4_0
+#define AnyTransliterator AnyTransliterator_4_0
+#define ArabicOpenTypeLayoutEngine ArabicOpenTypeLayoutEngine_4_0
+#define ArabicShaping ArabicShaping_4_0
+#define BMPSet BMPSet_4_0
+#define BasicCalendarFactory BasicCalendarFactory_4_0
+#define BasicTimeZone BasicTimeZone_4_0
+#define BinarySearchLookupTable BinarySearchLookupTable_4_0
+#define BreakIterator BreakIterator_4_0
+#define BreakTransliterator BreakTransliterator_4_0
+#define BuddhistCalendar BuddhistCalendar_4_0
+#define BuildCompactTrieHorizontalNode BuildCompactTrieHorizontalNode_4_0
+#define BuildCompactTrieNode BuildCompactTrieNode_4_0
+#define BuildCompactTrieVerticalNode BuildCompactTrieVerticalNode_4_0
+#define CEBuffer CEBuffer_4_0
+#define CECalendar CECalendar_4_0
+#define CFactory CFactory_4_0
+#define Calendar Calendar_4_0
+#define CalendarAstronomer CalendarAstronomer_4_0
+#define CalendarCache CalendarCache_4_0
+#define CalendarData CalendarData_4_0
+#define CalendarService CalendarService_4_0
+#define CanonMarkFilter CanonMarkFilter_4_0
+#define CanonShaping CanonShaping_4_0
+#define CanonicalIterator CanonicalIterator_4_0
+#define CaseMapTransliterator CaseMapTransliterator_4_0
+#define ChainingContextualSubstitutionFormat1Subtable ChainingContextualSubstitutionFormat1Subtable_4_0
+#define ChainingContextualSubstitutionFormat2Subtable ChainingContextualSubstitutionFormat2Subtable_4_0
+#define ChainingContextualSubstitutionFormat3Subtable ChainingContextualSubstitutionFormat3Subtable_4_0
+#define ChainingContextualSubstitutionSubtable ChainingContextualSubstitutionSubtable_4_0
+#define CharSubstitutionFilter CharSubstitutionFilter_4_0
+#define CharacterIterator CharacterIterator_4_0
+#define CharacterNode CharacterNode_4_0
+#define CharsetDetector CharsetDetector_4_0
+#define CharsetMatch CharsetMatch_4_0
+#define CharsetRecog_2022 CharsetRecog_2022_4_0
+#define CharsetRecog_2022CN CharsetRecog_2022CN_4_0
+#define CharsetRecog_2022JP CharsetRecog_2022JP_4_0
+#define CharsetRecog_2022KR CharsetRecog_2022KR_4_0
+#define CharsetRecog_8859_1 CharsetRecog_8859_1_4_0
+#define CharsetRecog_8859_1_da CharsetRecog_8859_1_da_4_0
+#define CharsetRecog_8859_1_de CharsetRecog_8859_1_de_4_0
+#define CharsetRecog_8859_1_en CharsetRecog_8859_1_en_4_0
+#define CharsetRecog_8859_1_es CharsetRecog_8859_1_es_4_0
+#define CharsetRecog_8859_1_fr CharsetRecog_8859_1_fr_4_0
+#define CharsetRecog_8859_1_it CharsetRecog_8859_1_it_4_0
+#define CharsetRecog_8859_1_nl CharsetRecog_8859_1_nl_4_0
+#define CharsetRecog_8859_1_no CharsetRecog_8859_1_no_4_0
+#define CharsetRecog_8859_1_pt CharsetRecog_8859_1_pt_4_0
+#define CharsetRecog_8859_1_sv CharsetRecog_8859_1_sv_4_0
+#define CharsetRecog_8859_2 CharsetRecog_8859_2_4_0
+#define CharsetRecog_8859_2_cs CharsetRecog_8859_2_cs_4_0
+#define CharsetRecog_8859_2_hu CharsetRecog_8859_2_hu_4_0
+#define CharsetRecog_8859_2_pl CharsetRecog_8859_2_pl_4_0
+#define CharsetRecog_8859_2_ro CharsetRecog_8859_2_ro_4_0
+#define CharsetRecog_8859_5 CharsetRecog_8859_5_4_0
+#define CharsetRecog_8859_5_ru CharsetRecog_8859_5_ru_4_0
+#define CharsetRecog_8859_6 CharsetRecog_8859_6_4_0
+#define CharsetRecog_8859_6_ar CharsetRecog_8859_6_ar_4_0
+#define CharsetRecog_8859_7 CharsetRecog_8859_7_4_0
+#define CharsetRecog_8859_7_el CharsetRecog_8859_7_el_4_0
+#define CharsetRecog_8859_8 CharsetRecog_8859_8_4_0
+#define CharsetRecog_8859_8_I_he CharsetRecog_8859_8_I_he_4_0
+#define CharsetRecog_8859_8_he CharsetRecog_8859_8_he_4_0
+#define CharsetRecog_8859_9 CharsetRecog_8859_9_4_0
+#define CharsetRecog_8859_9_tr CharsetRecog_8859_9_tr_4_0
+#define CharsetRecog_KOI8_R CharsetRecog_KOI8_R_4_0
+#define CharsetRecog_UTF8 CharsetRecog_UTF8_4_0
+#define CharsetRecog_UTF_16_BE CharsetRecog_UTF_16_BE_4_0
+#define CharsetRecog_UTF_16_LE CharsetRecog_UTF_16_LE_4_0
+#define CharsetRecog_UTF_32 CharsetRecog_UTF_32_4_0
+#define CharsetRecog_UTF_32_BE CharsetRecog_UTF_32_BE_4_0
+#define CharsetRecog_UTF_32_LE CharsetRecog_UTF_32_LE_4_0
+#define CharsetRecog_Unicode CharsetRecog_Unicode_4_0
+#define CharsetRecog_big5 CharsetRecog_big5_4_0
+#define CharsetRecog_euc CharsetRecog_euc_4_0
+#define CharsetRecog_euc_jp CharsetRecog_euc_jp_4_0
+#define CharsetRecog_euc_kr CharsetRecog_euc_kr_4_0
+#define CharsetRecog_gb_18030 CharsetRecog_gb_18030_4_0
+#define CharsetRecog_mbcs CharsetRecog_mbcs_4_0
+#define CharsetRecog_sbcs CharsetRecog_sbcs_4_0
+#define CharsetRecog_sjis CharsetRecog_sjis_4_0
+#define CharsetRecog_windows_1251 CharsetRecog_windows_1251_4_0
+#define CharsetRecog_windows_1256 CharsetRecog_windows_1256_4_0
+#define CharsetRecognizer CharsetRecognizer_4_0
+#define ChineseCalendar ChineseCalendar_4_0
+#define ChoiceFormat ChoiceFormat_4_0
+#define ClassDefFormat1Table ClassDefFormat1Table_4_0
+#define ClassDefFormat2Table ClassDefFormat2Table_4_0
+#define ClassDefinitionTable ClassDefinitionTable_4_0
+#define CollationElementIterator CollationElementIterator_4_0
+#define CollationKey CollationKey_4_0
+#define CollationLocaleListEnumeration CollationLocaleListEnumeration_4_0
+#define Collator Collator_4_0
+#define CollatorFactory CollatorFactory_4_0
+#define CompactTrieDictionary CompactTrieDictionary_4_0
+#define CompactTrieEnumeration CompactTrieEnumeration_4_0
+#define CompoundTransliterator CompoundTransliterator_4_0
+#define ContextualGlyphSubstitutionProcessor ContextualGlyphSubstitutionProcessor_4_0
+#define ContextualSubstitutionBase ContextualSubstitutionBase_4_0
+#define ContextualSubstitutionFormat1Subtable ContextualSubstitutionFormat1Subtable_4_0
+#define ContextualSubstitutionFormat2Subtable ContextualSubstitutionFormat2Subtable_4_0
+#define ContextualSubstitutionFormat3Subtable ContextualSubstitutionFormat3Subtable_4_0
+#define ContextualSubstitutionSubtable ContextualSubstitutionSubtable_4_0
+#define CopticCalendar CopticCalendar_4_0
+#define CoverageFormat1Table CoverageFormat1Table_4_0
+#define CoverageFormat2Table CoverageFormat2Table_4_0
+#define CoverageTable CoverageTable_4_0
+#define CurrencyAmount CurrencyAmount_4_0
+#define CurrencyFormat CurrencyFormat_4_0
+#define CurrencyUnit CurrencyUnit_4_0
+#define CursiveAttachmentSubtable CursiveAttachmentSubtable_4_0
+#define DTRedundantEnumeration DTRedundantEnumeration_4_0
+#define DTSkeletonEnumeration DTSkeletonEnumeration_4_0
+#define DateFormat DateFormat_4_0
+#define DateFormatSymbols DateFormatSymbols_4_0
+#define DateInterval DateInterval_4_0
+#define DateIntervalFormat DateIntervalFormat_4_0
+#define DateIntervalInfo DateIntervalInfo_4_0
+#define DateTimeMatcher DateTimeMatcher_4_0
+#define DateTimePatternGenerator DateTimePatternGenerator_4_0
+#define DateTimeRule DateTimeRule_4_0
+#define DecimalFormat DecimalFormat_4_0
+#define DecimalFormatSymbols DecimalFormatSymbols_4_0
+#define DefaultCalendarFactory DefaultCalendarFactory_4_0
+#define DefaultCharMapper DefaultCharMapper_4_0
+#define DeviceTable DeviceTable_4_0
+#define DictionaryBreakEngine DictionaryBreakEngine_4_0
+#define DigitList DigitList_4_0
+#define DistanceInfo DistanceInfo_4_0
+#define Entry Entry_4_0
+#define EnumToOffset EnumToOffset_4_0
+#define EscapeTransliterator EscapeTransliterator_4_0
+#define EthiopicCalendar EthiopicCalendar_4_0
+#define EventListener EventListener_4_0
+#define ExtensionSubtable ExtensionSubtable_4_0
+#define FeatureListTable FeatureListTable_4_0
+#define FieldPosition FieldPosition_4_0
+#define FontRuns FontRuns_4_0
+#define Format Format_4_0
+#define Format1AnchorTable Format1AnchorTable_4_0
+#define Format2AnchorTable Format2AnchorTable_4_0
+#define Format3AnchorTable Format3AnchorTable_4_0
+#define FormatNameEnumeration FormatNameEnumeration_4_0
+#define FormatParser FormatParser_4_0
+#define Formattable Formattable_4_0
+#define ForwardCharacterIterator ForwardCharacterIterator_4_0
+#define FractionalPartSubstitution FractionalPartSubstitution_4_0
+#define FunctionReplacer FunctionReplacer_4_0
+#define GDEFMarkFilter GDEFMarkFilter_4_0
+#define GXLayoutEngine GXLayoutEngine_4_0
+#define GlyphDefinitionTableHeader GlyphDefinitionTableHeader_4_0
+#define GlyphIterator GlyphIterator_4_0
+#define GlyphLookupTableHeader GlyphLookupTableHeader_4_0
+#define GlyphPositionAdjustments GlyphPositionAdjustments_4_0
+#define GlyphPositioningLookupProcessor GlyphPositioningLookupProcessor_4_0
+#define GlyphPositioningTableHeader GlyphPositioningTableHeader_4_0
+#define GlyphSubstitutionLookupProcessor GlyphSubstitutionLookupProcessor_4_0
+#define GlyphSubstitutionTableHeader GlyphSubstitutionTableHeader_4_0
+#define Grego Grego_4_0
+#define GregorianCalendar GregorianCalendar_4_0
+#define HanOpenTypeLayoutEngine HanOpenTypeLayoutEngine_4_0
+#define HangulOpenTypeLayoutEngine HangulOpenTypeLayoutEngine_4_0
+#define HebrewCalendar HebrewCalendar_4_0
+#define ICUBreakIteratorFactory ICUBreakIteratorFactory_4_0
+#define ICUBreakIteratorService ICUBreakIteratorService_4_0
+#define ICUCollatorFactory ICUCollatorFactory_4_0
+#define ICUCollatorService ICUCollatorService_4_0
+#define ICULanguageBreakFactory ICULanguageBreakFactory_4_0
+#define ICULocaleService ICULocaleService_4_0
+#define ICUNotifier ICUNotifier_4_0
+#define ICUNumberFormatFactory ICUNumberFormatFactory_4_0
+#define ICUNumberFormatService ICUNumberFormatService_4_0
+#define ICUResourceBundleFactory ICUResourceBundleFactory_4_0
+#define ICUService ICUService_4_0
+#define ICUServiceFactory ICUServiceFactory_4_0
+#define ICUServiceKey ICUServiceKey_4_0
+#define ICU_Utility ICU_Utility_4_0
+#define IndianCalendar IndianCalendar_4_0
+#define IndicClassTable IndicClassTable_4_0
+#define IndicOpenTypeLayoutEngine IndicOpenTypeLayoutEngine_4_0
+#define IndicRearrangementProcessor IndicRearrangementProcessor_4_0
+#define IndicReordering IndicReordering_4_0
+#define InitialTimeZoneRule InitialTimeZoneRule_4_0
+#define InputText InputText_4_0
+#define IntegralPartSubstitution IntegralPartSubstitution_4_0
+#define IslamicCalendar IslamicCalendar_4_0
+#define IteratedChar IteratedChar_4_0
+#define JapaneseCalendar JapaneseCalendar_4_0
+#define KernTable KernTable_4_0
+#define KeywordEnumeration KeywordEnumeration_4_0
+#define KhmerClassTable KhmerClassTable_4_0
+#define KhmerOpenTypeLayoutEngine KhmerOpenTypeLayoutEngine_4_0
+#define KhmerReordering KhmerReordering_4_0
+#define LECharMapper LECharMapper_4_0
+#define LEFontInstance LEFontInstance_4_0
+#define LEGlyphFilter LEGlyphFilter_4_0
+#define LEGlyphStorage LEGlyphStorage_4_0
+#define LEInsertionCallback LEInsertionCallback_4_0
+#define LEInsertionList LEInsertionList_4_0
+#define LXUtilities LXUtilities_4_0
+#define LanguageBreakEngine LanguageBreakEngine_4_0
+#define LanguageBreakFactory LanguageBreakFactory_4_0
+#define LayoutEngine LayoutEngine_4_0
+#define LigatureSubstitutionProcessor LigatureSubstitutionProcessor_4_0
+#define LigatureSubstitutionSubtable LigatureSubstitutionSubtable_4_0
+#define LocDataParser LocDataParser_4_0
+#define Locale Locale_4_0
+#define LocaleBased LocaleBased_4_0
+#define LocaleKey LocaleKey_4_0
+#define LocaleKeyFactory LocaleKeyFactory_4_0
+#define LocaleRuns LocaleRuns_4_0
+#define LocaleUtility LocaleUtility_4_0
+#define LocalizationInfo LocalizationInfo_4_0
+#define LookupListTable LookupListTable_4_0
+#define LookupProcessor LookupProcessor_4_0
+#define LookupSubtable LookupSubtable_4_0
+#define LookupTable LookupTable_4_0
+#define LowercaseTransliterator LowercaseTransliterator_4_0
+#define MPreFixups MPreFixups_4_0
+#define MarkArray MarkArray_4_0
+#define MarkToBasePositioningSubtable MarkToBasePositioningSubtable_4_0
+#define MarkToLigaturePositioningSubtable MarkToLigaturePositioningSubtable_4_0
+#define MarkToMarkPositioningSubtable MarkToMarkPositioningSubtable_4_0
+#define Math Math_4_0
+#define Measure Measure_4_0
+#define MeasureFormat MeasureFormat_4_0
+#define MeasureUnit MeasureUnit_4_0
+#define MessageFormat MessageFormat_4_0
+#define MessageFormatAdapter MessageFormatAdapter_4_0
+#define ModulusSubstitution ModulusSubstitution_4_0
+#define MoonRiseSetCoordFunc MoonRiseSetCoordFunc_4_0
+#define MoonTimeAngleFunc MoonTimeAngleFunc_4_0
+#define MorphSubtableHeader MorphSubtableHeader_4_0
+#define MorphTableHeader MorphTableHeader_4_0
+#define MultipleSubstitutionSubtable MultipleSubstitutionSubtable_4_0
+#define MultiplierSubstitution MultiplierSubstitution_4_0
+#define MutableTrieDictionary MutableTrieDictionary_4_0
+#define MutableTrieEnumeration MutableTrieEnumeration_4_0
+#define NFFactory NFFactory_4_0
+#define NFRule NFRule_4_0
+#define NFRuleSet NFRuleSet_4_0
+#define NFSubstitution NFSubstitution_4_0
+#define NGramParser NGramParser_4_0
+#define NameToEnum NameToEnum_4_0
+#define NameUnicodeTransliterator NameUnicodeTransliterator_4_0
+#define NonContextualGlyphSubstitutionProcessor NonContextualGlyphSubstitutionProcessor_4_0
+#define NonContiguousEnumToOffset NonContiguousEnumToOffset_4_0
+#define NormalizationTransliterator NormalizationTransliterator_4_0
+#define Normalizer Normalizer_4_0
+#define NullSubstitution NullSubstitution_4_0
+#define NullTransliterator NullTransliterator_4_0
+#define NumberFormat NumberFormat_4_0
+#define NumberFormatFactory NumberFormatFactory_4_0
+#define NumeratorSubstitution NumeratorSubstitution_4_0
+#define OlsonTimeZone OlsonTimeZone_4_0
+#define OpenTypeLayoutEngine OpenTypeLayoutEngine_4_0
+#define OpenTypeUtilities OpenTypeUtilities_4_0
+#define OrConstraint OrConstraint_4_0
+#define PCEBuffer PCEBuffer_4_0
+#define PairPositioningFormat1Subtable PairPositioningFormat1Subtable_4_0
+#define PairPositioningFormat2Subtable PairPositioningFormat2Subtable_4_0
+#define PairPositioningSubtable PairPositioningSubtable_4_0
+#define ParagraphLayout ParagraphLayout_4_0
+#define ParseData ParseData_4_0
+#define ParsePosition ParsePosition_4_0
+#define PatternMap PatternMap_4_0
+#define PatternMapIterator PatternMapIterator_4_0
+#define PersianCalendar PersianCalendar_4_0
+#define PluralFormat PluralFormat_4_0
+#define PluralKeywordEnumeration PluralKeywordEnumeration_4_0
+#define PluralRules PluralRules_4_0
+#define PropertyAliases PropertyAliases_4_0
+#define PtnElem PtnElem_4_0
+#define PtnSkeleton PtnSkeleton_4_0
+#define Quantifier Quantifier_4_0
+#define RBBIDataWrapper RBBIDataWrapper_4_0
+#define RBBINode RBBINode_4_0
+#define RBBIRuleBuilder RBBIRuleBuilder_4_0
+#define RBBIRuleScanner RBBIRuleScanner_4_0
+#define RBBISetBuilder RBBISetBuilder_4_0
+#define RBBIStateDescriptor RBBIStateDescriptor_4_0
+#define RBBISymbolTable RBBISymbolTable_4_0
+#define RBBISymbolTableEntry RBBISymbolTableEntry_4_0
+#define RBBITableBuilder RBBITableBuilder_4_0
+#define RCEBuffer RCEBuffer_4_0
+#define RangeDescriptor RangeDescriptor_4_0
+#define RegexCImpl RegexCImpl_4_0
+#define RegexCompile RegexCompile_4_0
+#define RegexMatcher RegexMatcher_4_0
+#define RegexPattern RegexPattern_4_0
+#define RegexStaticSets RegexStaticSets_4_0
+#define RelativeDateFormat RelativeDateFormat_4_0
+#define RemoveTransliterator RemoveTransliterator_4_0
+#define Replaceable Replaceable_4_0
+#define ReplaceableGlue ReplaceableGlue_4_0
+#define ResourceBundle ResourceBundle_4_0
+#define RiseSetCoordFunc RiseSetCoordFunc_4_0
+#define RuleBasedBreakIterator RuleBasedBreakIterator_4_0
+#define RuleBasedCollator RuleBasedCollator_4_0
+#define RuleBasedNumberFormat RuleBasedNumberFormat_4_0
+#define RuleBasedTimeZone RuleBasedTimeZone_4_0
+#define RuleBasedTransliterator RuleBasedTransliterator_4_0
+#define RuleChain RuleChain_4_0
+#define RuleCharacterIterator RuleCharacterIterator_4_0
+#define RuleHalf RuleHalf_4_0
+#define RuleParser RuleParser_4_0
+#define RunArray RunArray_4_0
+#define SafeZoneStringFormatPtr SafeZoneStringFormatPtr_4_0
+#define SameValueSubstitution SameValueSubstitution_4_0
+#define ScriptListTable ScriptListTable_4_0
+#define ScriptRunIterator ScriptRunIterator_4_0
+#define ScriptTable ScriptTable_4_0
+#define SearchIterator SearchIterator_4_0
+#define SegmentArrayProcessor SegmentArrayProcessor_4_0
+#define SegmentSingleProcessor SegmentSingleProcessor_4_0
+#define ServiceEnumeration ServiceEnumeration_4_0
+#define ServiceListener ServiceListener_4_0
+#define SimpleArrayProcessor SimpleArrayProcessor_4_0
+#define SimpleDateFormat SimpleDateFormat_4_0
+#define SimpleFactory SimpleFactory_4_0
+#define SimpleLocaleKeyFactory SimpleLocaleKeyFactory_4_0
+#define SimpleNumberFormatFactory SimpleNumberFormatFactory_4_0
+#define SimpleTimeZone SimpleTimeZone_4_0
+#define SinglePositioningFormat1Subtable SinglePositioningFormat1Subtable_4_0
+#define SinglePositioningFormat2Subtable SinglePositioningFormat2Subtable_4_0
+#define SinglePositioningSubtable SinglePositioningSubtable_4_0
+#define SingleSubstitutionFormat1Subtable SingleSubstitutionFormat1Subtable_4_0
+#define SingleSubstitutionFormat2Subtable SingleSubstitutionFormat2Subtable_4_0
+#define SingleSubstitutionSubtable SingleSubstitutionSubtable_4_0
+#define SingleTableProcessor SingleTableProcessor_4_0
+#define Spec Spec_4_0
+#define StateTableProcessor StateTableProcessor_4_0
+#define StringCharacterIterator StringCharacterIterator_4_0
+#define StringEnumeration StringEnumeration_4_0
+#define StringLocalizationInfo StringLocalizationInfo_4_0
+#define StringMatcher StringMatcher_4_0
+#define StringPair StringPair_4_0
+#define StringReplacer StringReplacer_4_0
+#define StringSearch StringSearch_4_0
+#define StyleRuns StyleRuns_4_0
+#define SubstitutionLookup SubstitutionLookup_4_0
+#define SubtableProcessor SubtableProcessor_4_0
+#define SunTimeAngleFunc SunTimeAngleFunc_4_0
+#define SymbolTable SymbolTable_4_0
+#define TZEnumeration TZEnumeration_4_0
+#define TaiwanCalendar TaiwanCalendar_4_0
+#define TernaryNode TernaryNode_4_0
+#define TextTrieMap TextTrieMap_4_0
+#define TextTrieMapSearchResultHandler TextTrieMapSearchResultHandler_4_0
+#define ThaiBreakEngine ThaiBreakEngine_4_0
+#define ThaiLayoutEngine ThaiLayoutEngine_4_0
+#define ThaiShaping ThaiShaping_4_0
+#define TibetanClassTable TibetanClassTable_4_0
+#define TibetanOpenTypeLayoutEngine TibetanOpenTypeLayoutEngine_4_0
+#define TibetanReordering TibetanReordering_4_0
+#define TimeArrayTimeZoneRule TimeArrayTimeZoneRule_4_0
+#define TimeZone TimeZone_4_0
+#define TimeZoneRule TimeZoneRule_4_0
+#define TimeZoneTransition TimeZoneTransition_4_0
+#define TitlecaseTransliterator TitlecaseTransliterator_4_0
+#define TransliterationRule TransliterationRule_4_0
+#define TransliterationRuleData TransliterationRuleData_4_0
+#define TransliterationRuleSet TransliterationRuleSet_4_0
+#define Transliterator Transliterator_4_0
+#define TransliteratorAlias TransliteratorAlias_4_0
+#define TransliteratorIDParser TransliteratorIDParser_4_0
+#define TransliteratorParser TransliteratorParser_4_0
+#define TransliteratorRegistry TransliteratorRegistry_4_0
+#define TrieWordDictionary TrieWordDictionary_4_0
+#define TrimmedArrayProcessor TrimmedArrayProcessor_4_0
+#define UCharCharacterIterator UCharCharacterIterator_4_0
+#define UCollationPCE UCollationPCE_4_0
+#define ULocRuns ULocRuns_4_0
+#define UMemory UMemory_4_0
+#define UObject UObject_4_0
+#define URegularExpression URegularExpression_4_0
+#define UStack UStack_4_0
+#define UStringEnumeration UStringEnumeration_4_0
+#define UVector UVector_4_0
+#define UVector32 UVector32_4_0
+#define UnescapeTransliterator UnescapeTransliterator_4_0
+#define UnhandledEngine UnhandledEngine_4_0
+#define UnicodeArabicOpenTypeLayoutEngine UnicodeArabicOpenTypeLayoutEngine_4_0
+#define UnicodeFilter UnicodeFilter_4_0
+#define UnicodeFunctor UnicodeFunctor_4_0
+#define UnicodeMatcher UnicodeMatcher_4_0
+#define UnicodeNameTransliterator UnicodeNameTransliterator_4_0
+#define UnicodeReplacer UnicodeReplacer_4_0
+#define UnicodeSet UnicodeSet_4_0
+#define UnicodeSetIterator UnicodeSetIterator_4_0
+#define UnicodeSetStringSpan UnicodeSetStringSpan_4_0
+#define UnicodeString UnicodeString_4_0
+#define UppercaseTransliterator UppercaseTransliterator_4_0
+#define VTZReader VTZReader_4_0
+#define VTZWriter VTZWriter_4_0
+#define VTimeZone VTimeZone_4_0
+#define ValueRecord ValueRecord_4_0
+#define ValueRuns ValueRuns_4_0
+#define ZSFCache ZSFCache_4_0
+#define ZSFCacheEntry ZSFCacheEntry_4_0
+#define ZoneMeta ZoneMeta_4_0
+#define ZoneStringFormat ZoneStringFormat_4_0
+#define ZoneStringInfo ZoneStringInfo_4_0
+#define ZoneStringSearchResultHandler ZoneStringSearchResultHandler_4_0
+#define ZoneStrings ZoneStrings_4_0
+#define locale_set_default_internal locale_set_default_internal_4_0
+#define util64_fromDouble util64_fromDouble_4_0
+#define util64_pow util64_pow_4_0
+#define util64_tou util64_tou_4_0
+
+#endif
+#endif
+
+#endif
+
+#endif
diff --git a/CoreFoundation/icu/unicode/urep.h b/CoreFoundation/icu/unicode/urep.h
new file mode 100644
index 0000000..57b547c
--- /dev/null
+++ b/CoreFoundation/icu/unicode/urep.h
@@ -0,0 +1,155 @@
+/*
+******************************************************************************
+*   Copyright (C) 1997-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+******************************************************************************
+*   Date        Name        Description
+*   06/23/00    aliu        Creation.
+******************************************************************************
+*/
+
+#ifndef __UREP_H
+#define __UREP_H
+
+#include "unicode/utypes.h"
+
+U_CDECL_BEGIN
+
+/********************************************************************
+ * General Notes
+ ********************************************************************
+ * TODO
+ * Add usage scenario
+ * Add test code
+ * Talk about pinning
+ * Talk about "can truncate result if out of memory"
+ */
+
+/********************************************************************
+ * Data Structures
+ ********************************************************************/
+/**
+ * \file
+ * \brief C API: Callbacks for UReplacebale
+ */
+/**
+ * An opaque replaceable text object.  This will be manipulated only
+ * through the caller-supplied UReplaceableFunctor struct.  Related
+ * to the C++ class Replaceable.
+ * This is currently only used in the Transliterator C API, see utrans.h .
+ * @stable ICU 2.0
+ */
+typedef void* UReplaceable;
+
+/**
+ * A set of function pointers that transliterators use to manipulate a
+ * UReplaceable.  The caller should supply the required functions to
+ * manipulate their text appropriately.  Related to the C++ class
+ * Replaceable.
+ * @stable ICU 2.0
+ */
+typedef struct UReplaceableCallbacks {
+
+    /**
+     * Function pointer that returns the number of UChar code units in
+     * this text.
+     *
+     * @param rep A pointer to "this" UReplaceable object.
+     * @return The length of the text.
+     * @stable ICU 2.0
+     */
+    int32_t (*length)(const UReplaceable* rep);
+
+    /**
+     * Function pointer that returns a UChar code units at the given
+     * offset into this text; 0 <= offset < n, where n is the value
+     * returned by (*length)(rep).  See unistr.h for a description of
+     * charAt() vs. char32At().
+     *
+     * @param rep A pointer to "this" UReplaceable object.
+     * @param offset The index at which to fetch the UChar (code unit).
+     * @return The UChar (code unit) at offset, or U+FFFF if the offset is out of bounds.
+     * @stable ICU 2.0
+     */
+    UChar   (*charAt)(const UReplaceable* rep,
+                      int32_t offset);
+
+    /**
+     * Function pointer that returns a UChar32 code point at the given
+     * offset into this text.  See unistr.h for a description of
+     * charAt() vs. char32At().
+     *
+     * @param rep A pointer to "this" UReplaceable object.
+     * @param offset The index at which to fetch the UChar32 (code point).
+     * @return The UChar32 (code point) at offset, or U+FFFF if the offset is out of bounds.
+     * @stable ICU 2.0
+     */
+    UChar32 (*char32At)(const UReplaceable* rep,
+                        int32_t offset);
+    
+    /**
+     * Function pointer that replaces text between start and limit in
+     * this text with the given text.  Attributes (out of band info)
+     * should be retained.
+     *
+     * @param rep A pointer to "this" UReplaceable object.
+     * @param start the starting index of the text to be replaced,
+     * inclusive.
+     * @param limit the ending index of the text to be replaced,
+     * exclusive.
+     * @param text the new text to replace the UChars from
+     * start..limit-1.
+     * @param textLength the number of UChars at text, or -1 if text
+     * is null-terminated.
+     * @stable ICU 2.0
+     */
+    void    (*replace)(UReplaceable* rep,
+                       int32_t start,
+                       int32_t limit,
+                       const UChar* text,
+                       int32_t textLength);
+    
+    /**
+     * Function pointer that copies the characters in the range
+     * [<tt>start</tt>, <tt>limit</tt>) into the array <tt>dst</tt>.
+     *
+     * @param rep A pointer to "this" UReplaceable object.
+     * @param start offset of first character which will be copied
+     * into the array
+     * @param limit offset immediately following the last character to
+     * be copied
+     * @param dst array in which to copy characters.  The length of
+     * <tt>dst</tt> must be at least <tt>(limit - start)</tt>.
+     * @stable ICU 2.1
+     */
+    void    (*extract)(UReplaceable* rep,
+                       int32_t start,
+                       int32_t limit,
+                       UChar* dst);
+
+    /**
+     * Function pointer that copies text between start and limit in
+     * this text to another index in the text.  Attributes (out of
+     * band info) should be retained.  After this call, there will be
+     * (at least) two copies of the characters originally located at
+     * start..limit-1.
+     *
+     * @param rep A pointer to "this" UReplaceable object.
+     * @param start the starting index of the text to be copied,
+     * inclusive.
+     * @param limit the ending index of the text to be copied,
+     * exclusive.
+     * @param dest the index at which the copy of the UChars should be
+     * inserted.
+     * @stable ICU 2.0
+     */
+    void    (*copy)(UReplaceable* rep,
+                    int32_t start,
+                    int32_t limit,
+                    int32_t dest);    
+
+} UReplaceableCallbacks;
+
+U_CDECL_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ures.h b/CoreFoundation/icu/unicode/ures.h
new file mode 100644
index 0000000..9cc2e89
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ures.h
@@ -0,0 +1,871 @@
+/*
+**********************************************************************
+*   Copyright (C) 1997-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File URES.H (formerly CRESBUND.H)
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   04/01/97    aliu        Creation.
+*   02/22/99    damiba      overhaul.
+*   04/04/99    helena      Fixed internal header inclusion.
+*   04/15/99    Madhu       Updated Javadoc  
+*   06/14/99    stephen     Removed functions taking a filename suffix.
+*   07/20/99    stephen     Language-independent ypedef to void*
+*   11/09/99    weiv        Added ures_getLocale()
+*   06/24/02    weiv        Added support for resource sharing
+******************************************************************************
+*/
+
+#ifndef URES_H
+#define URES_H
+
+#include "unicode/utypes.h"
+#include "unicode/uloc.h"
+
+/**
+ * \file
+ * \brief C API: Resource Bundle 
+ *
+ * <h2>C API: Resource Bundle</h2>
+ *
+ * C API representing a collection of resource information pertaining to a given
+ * locale. A resource bundle provides a way of accessing locale- specific information in
+ * a data file. You create a resource bundle that manages the resources for a given
+ * locale and then ask it for individual resources.
+ * <P>
+ * Resource bundles in ICU4C are currently defined using text files which conform to the following
+ * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt">BNF definition</a>.
+ * More on resource bundle concepts and syntax can be found in the 
+ * <a href="http://icu-project.org/userguide/ResourceManagement.html">Users Guide</a>.
+ * <P>
+ */
+
+/**
+ * UResourceBundle is an opaque type for handles for resource bundles in C APIs.
+ * @stable ICU 2.0
+ */
+struct UResourceBundle;
+
+/**
+ * @stable ICU 2.0
+ */
+typedef struct UResourceBundle UResourceBundle;
+
+/**
+ * Numeric constants for types of resource items.
+ * @see ures_getType
+ * @stable ICU 2.0
+ */
+typedef enum {
+    /** Resource type constant for "no resource". @stable ICU 2.6 */
+    URES_NONE=-1,
+
+    /** Resource type constant for 16-bit Unicode strings. @stable ICU 2.6 */
+    URES_STRING=0,
+
+    /** Resource type constant for binary data. @stable ICU 2.6 */
+    URES_BINARY=1,
+
+    /** Resource type constant for tables of key-value pairs. @stable ICU 2.6 */
+    URES_TABLE=2,
+
+    /**
+     * Resource type constant for aliases;
+     * internally stores a string which identifies the actual resource
+     * storing the data (can be in a different resource bundle).
+     * Resolved internally before delivering the actual resource through the API.
+     * @stable ICU 2.6
+     */
+    URES_ALIAS=3,
+
+#ifndef U_HIDE_INTERNAL_API
+
+    /**
+     * Internal use only.
+     * Alternative resource type constant for tables of key-value pairs.
+     * Never returned by ures_getType().
+     * @internal
+     */
+    URES_TABLE32=4,
+
+#endif /* U_HIDE_INTERNAL_API */
+
+    /**
+     * Resource type constant for a single 28-bit integer, interpreted as
+     * signed or unsigned by the ures_getInt() or ures_getUInt() function.
+     * @see ures_getInt
+     * @see ures_getUInt
+     * @stable ICU 2.6
+     */
+    URES_INT=7,
+
+    /** Resource type constant for arrays of resources. @stable ICU 2.6 */
+    URES_ARRAY=8,
+
+    /**
+     * Resource type constant for vectors of 32-bit integers.
+     * @see ures_getIntVector
+     * @stable ICU 2.6
+     */
+    URES_INT_VECTOR = 14,
+#ifndef U_HIDE_DEPRECATED_API
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_NONE=URES_NONE,
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_STRING=URES_STRING,
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_BINARY=URES_BINARY,
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_TABLE=URES_TABLE,
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_ALIAS=URES_ALIAS,
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_INT=URES_INT,
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_ARRAY=URES_ARRAY,
+    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
+    RES_INT_VECTOR=URES_INT_VECTOR,
+    /** @deprecated ICU 2.6 Not used. */
+    RES_RESERVED=15, 
+#endif /* U_HIDE_DEPRECATED_API */
+
+    URES_LIMIT = 16
+} UResType;
+
+/*
+ * Functions to create and destroy resource bundles.
+ */
+
+/**
+ * Opens a UResourceBundle, from which users can extract strings by using
+ * their corresponding keys.
+ * Note that the caller is responsible of calling <TT>ures_close</TT> on each succesfully
+ * opened resource bundle.
+ * @param packageName   The packageName and locale together point to an ICU udata object, 
+ *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
+ *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
+ *                      a package registered with udata_setAppData(). Using a full file or directory
+ *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
+ * @param locale  specifies the locale for which we want to open the resource
+ *                if NULL, the default locale will be used. If strlen(locale) == 0
+ *                root locale will be used.
+ *                
+ * @param status  fills in the outgoing error code.
+ * The UErrorCode err parameter is used to return status information to the user. To
+ * check whether the construction succeeded or not, you should check the value of
+ * U_SUCCESS(err). If you wish more detailed information, you can check for
+ * informational status results which still indicate success. U_USING_FALLBACK_WARNING
+ * indicates that a fall back locale was used. For example, 'de_CH' was requested,
+ * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that
+ * the default locale data or root locale data was used; neither the requested locale 
+ * nor any of its fall back locales could be found. Please see the users guide for more 
+ * information on this topic.
+ * @return      a newly allocated resource bundle.
+ * @see ures_close
+ * @stable ICU 2.0
+ */
+U_STABLE UResourceBundle*  U_EXPORT2 
+ures_open(const char*    packageName,
+          const char*  locale, 
+          UErrorCode*     status);
+
+
+/** This function does not care what kind of localeID is passed in. It simply opens a bundle with 
+ *  that name. Fallback mechanism is disabled for the new bundle. If the requested bundle contains
+ *  an %%ALIAS directive, the results are undefined.
+ * @param packageName   The packageName and locale together point to an ICU udata object, 
+ *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
+ *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
+ *                      a package registered with udata_setAppData(). Using a full file or directory
+ *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
+ * @param locale  specifies the locale for which we want to open the resource
+ *                if NULL, the default locale will be used. If strlen(locale) == 0
+ *                root locale will be used.
+ *                
+ * @param status fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR
+ * @return      a newly allocated resource bundle or NULL if it doesn't exist.
+ * @see ures_close
+ * @stable ICU 2.0
+ */
+U_STABLE UResourceBundle* U_EXPORT2 
+ures_openDirect(const char* packageName, 
+                const char* locale, 
+                UErrorCode* status);
+
+/**
+ * Same as ures_open() but takes a const UChar *path.
+ * This path will be converted to char * using the default converter,
+ * then ures_open() is called.
+ *
+ * @param packageName   The packageName and locale together point to an ICU udata object, 
+ *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
+ *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
+ *                      a package registered with udata_setAppData(). Using a full file or directory
+ *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
+ * @param locale  specifies the locale for which we want to open the resource
+ *                if NULL, the default locale will be used. If strlen(locale) == 0
+ *                root locale will be used.
+ * @param status  fills in the outgoing error code.
+ * @return      a newly allocated resource bundle.
+ * @see ures_open
+ * @stable ICU 2.0
+ */
+U_STABLE UResourceBundle* U_EXPORT2 
+ures_openU(const UChar* packageName, 
+           const char* locale, 
+           UErrorCode* status);
+
+/**
+ * Returns the number of strings/arrays in resource bundles.
+ * Better to use ures_getSize, as this function will be deprecated. 
+ *
+ *@param resourceBundle resource bundle containing the desired strings
+ *@param resourceKey key tagging the resource
+ *@param err fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_FALLBACK_WARNING </TT>
+ *@return: for    <STRONG>Arrays</STRONG>: returns the number of resources in the array
+ *                <STRONG>Tables</STRONG>: returns the number of resources in the table
+ *                <STRONG>single string</STRONG>: returns 1
+ *@see ures_getSize
+ * @deprecated ICU 2.8 User ures_getSize instead
+ */
+U_DEPRECATED int32_t U_EXPORT2 
+ures_countArrayItems(const UResourceBundle* resourceBundle,
+                     const char* resourceKey,
+                     UErrorCode* err);
+/**
+ * Close a resource bundle, all pointers returned from the various ures_getXXX calls
+ * on this particular bundle should be considered invalid henceforth.
+ *
+ * @param resourceBundle a pointer to a resourceBundle struct. Can be NULL.
+ * @see ures_open
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ures_close(UResourceBundle* resourceBundle);
+
+/**
+ * Return the version number associated with this ResourceBundle as a string. Please
+ * use ures_getVersion as this function is going to be deprecated.
+ *
+ * @param resourceBundle The resource bundle for which the version is checked.
+ * @return  A version number string as specified in the resource bundle or its parent.
+ *          The caller does not own this string.
+ * @see ures_getVersion
+ * @deprecated ICU 2.8 Use ures_getVersion instead.
+ */
+U_DEPRECATED const char* U_EXPORT2 
+ures_getVersionNumber(const UResourceBundle*   resourceBundle);
+
+/**
+ * Return the version number associated with this ResourceBundle as an 
+ * UVersionInfo array.
+ *
+ * @param resB The resource bundle for which the version is checked.
+ * @param versionInfo A UVersionInfo array that is filled with the version number
+ *                    as specified in the resource bundle or its parent.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ures_getVersion(const UResourceBundle* resB, 
+                UVersionInfo versionInfo);
+
+/**
+ * Return the name of the Locale associated with this ResourceBundle. This API allows
+ * you to query for the real locale of the resource. For example, if you requested 
+ * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned. 
+ * For subresources, the locale where this resource comes from will be returned.
+ * If fallback has occured, getLocale will reflect this.
+ *
+ * @param resourceBundle resource bundle in question
+ * @param status just for catching illegal arguments
+ * @return  A Locale name
+ * @deprecated ICU 2.8 Use ures_getLocaleByType instead.
+ */
+U_DEPRECATED const char* U_EXPORT2 
+ures_getLocale(const UResourceBundle* resourceBundle, 
+               UErrorCode* status);
+
+
+/**
+ * Return the name of the Locale associated with this ResourceBundle. 
+ * You can choose between requested, valid and real locale.
+ *
+ * @param resourceBundle resource bundle in question
+ * @param type You can choose between requested, valid and actual
+ *             locale. For description see the definition of
+ *             ULocDataLocaleType in uloc.h
+ * @param status just for catching illegal arguments
+ * @return  A Locale name
+ * @stable ICU 2.8
+ */
+U_STABLE const char* U_EXPORT2 
+ures_getLocaleByType(const UResourceBundle* resourceBundle, 
+                     ULocDataLocaleType type, 
+                     UErrorCode* status);
+
+
+/**
+ * Same as ures_open() but uses the fill-in parameter instead of allocating
+ * a bundle, if r!=NULL.
+ * TODO need to revisit usefulness of this function
+ *      and usage model for fillIn parameters without knowing sizeof(UResourceBundle)
+ * @param r The resourcebundle to open
+ * @param packageName   The packageName and locale together point to an ICU udata object, 
+ *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
+ *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
+ *                      a package registered with udata_setAppData(). Using a full file or directory
+ *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
+ * @param localeID specifies the locale for which we want to open the resource
+ * @param status The error code
+ * @return a newly allocated resource bundle or NULL if it doesn't exist.
+ * @internal
+ */
+U_INTERNAL void U_EXPORT2 
+ures_openFillIn(UResourceBundle *r, 
+                const char* packageName,
+                const char* localeID, 
+                UErrorCode* status);
+
+/**
+ * Returns a string from a string resource type
+ *
+ * @param resourceBundle a string resource
+ * @param len    fills in the length of resulting string
+ * @param status fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                Always check the value of status. Don't count on returning NULL.
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
+ * @see ures_getBinary
+ * @see ures_getIntVector
+ * @see ures_getInt
+ * @see ures_getUInt
+ * @stable ICU 2.0
+ */
+U_STABLE const UChar* U_EXPORT2 
+ures_getString(const UResourceBundle* resourceBundle, 
+               int32_t* len, 
+               UErrorCode* status);
+
+/**
+ * Returns a UTF-8 string from a string resource.
+ * The UTF-8 string may be returnable directly as a pointer, or
+ * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
+ * or equivalent.
+ *
+ * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * and dest is returned.
+ *
+ * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * without needing a dest buffer (it can be NULL). If the string needs to be
+ * copied or transformed, then it may be placed into dest at an arbitrary offset.
+ *
+ * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
+ * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
+ *
+ * If the string is transformed from UTF-16, then a conversion error may occur
+ * if an unpaired surrogate is encountered. If the function is successful, then
+ * the output UTF-8 string is always well-formed.
+ *
+ * @param resB Resource bundle.
+ * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
+ * @param length Input: Capacity of destination buffer.
+ *               Output: Actual length of the UTF-8 string, not counting the
+ *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
+ *               Can be NULL, meaning capacity=0 and the string length is not
+ *               returned to the caller.
+ * @param forceCopy If TRUE, then the output string will always be written to
+ *                  dest, with U_BUFFER_OVERFLOW_ERROR and
+ *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.
+ *                  If FALSE, then the dest buffer may or may not contain a
+ *                  copy of the string. dest may or may not be modified.
+ *                  If a copy needs to be written, then the UErrorCode parameter
+ *                  indicates overflow etc. as usual.
+ * @param status Pointer to a standard ICU error code. Its input value must
+ *               pass the U_SUCCESS() test, or else the function returns
+ *               immediately. Check for U_FAILURE() on output or use with
+ *               function chaining. (See User Guide for details.)
+ * @return The pointer to the UTF-8 string. It may be dest, or at some offset
+ *         from dest (only if !forceCopy), or in unrelated memory.
+ *         Always NUL-terminated unless the string was written to dest and
+ *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
+ *
+ * @see ures_getString
+ * @see u_strToUTF8
+ * @stable ICU 3.6
+ */
+U_STABLE const char * U_EXPORT2
+ures_getUTF8String(const UResourceBundle *resB,
+                   char *dest, int32_t *length,
+                   UBool forceCopy,
+                   UErrorCode *status);
+
+/**
+ * Returns a binary data from a binary resource. 
+ *
+ * @param resourceBundle a string resource
+ * @param len    fills in the length of resulting byte chunk
+ * @param status fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                Always check the value of status. Don't count on returning NULL.
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return a pointer to a chuck of unsigned bytes which live in a memory mapped/DLL file.
+ * @see ures_getString
+ * @see ures_getIntVector
+ * @see ures_getInt
+ * @see ures_getUInt
+ * @stable ICU 2.0
+ */
+U_STABLE const uint8_t* U_EXPORT2 
+ures_getBinary(const UResourceBundle* resourceBundle, 
+               int32_t* len, 
+               UErrorCode* status);
+
+/**
+ * Returns a 32 bit integer array from a resource. 
+ *
+ * @param resourceBundle an int vector resource
+ * @param len    fills in the length of resulting byte chunk
+ * @param status fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                Always check the value of status. Don't count on returning NULL.
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
+ * @see ures_getBinary
+ * @see ures_getString
+ * @see ures_getInt
+ * @see ures_getUInt
+ * @stable ICU 2.0
+ */
+U_STABLE const int32_t* U_EXPORT2 
+ures_getIntVector(const UResourceBundle* resourceBundle, 
+                  int32_t* len, 
+                  UErrorCode* status);
+
+/**
+ * Returns an unsigned integer from a resource. 
+ * This integer is originally 28 bits.
+ *
+ * @param resourceBundle a string resource
+ * @param status fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return an integer value
+ * @see ures_getInt
+ * @see ures_getIntVector
+ * @see ures_getBinary
+ * @see ures_getString
+ * @stable ICU 2.0
+ */
+U_STABLE uint32_t U_EXPORT2 
+ures_getUInt(const UResourceBundle* resourceBundle, 
+             UErrorCode *status);
+
+/**
+ * Returns a signed integer from a resource. 
+ * This integer is originally 28 bit and the sign gets propagated.
+ *
+ * @param resourceBundle a string resource
+ * @param status  fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return an integer value
+ * @see ures_getUInt
+ * @see ures_getIntVector
+ * @see ures_getBinary
+ * @see ures_getString
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ures_getInt(const UResourceBundle* resourceBundle, 
+            UErrorCode *status);
+
+/**
+ * Returns the size of a resource. Size for scalar types is always 1, 
+ * and for vector/table types is the number of child resources.
+ * @warning Integer array is treated as a scalar type. There are no 
+ *          APIs to access individual members of an integer array. It
+ *          is always returned as a whole.
+ * @param resourceBundle a resource
+ * @return number of resources in a given resource.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+ures_getSize(const UResourceBundle *resourceBundle);
+
+/**
+ * Returns the type of a resource. Available types are defined in enum UResType
+ *
+ * @param resourceBundle a resource
+ * @return type of the given resource.
+ * @see UResType
+ * @stable ICU 2.0
+ */
+U_STABLE UResType U_EXPORT2 
+ures_getType(const UResourceBundle *resourceBundle);
+
+/**
+ * Returns the key associated with a given resource. Not all the resources have a key - only 
+ * those that are members of a table.
+ *
+ * @param resourceBundle a resource
+ * @return a key associated to this resource, or NULL if it doesn't have a key
+ * @stable ICU 2.0
+ */
+U_STABLE const char * U_EXPORT2 
+ures_getKey(const UResourceBundle *resourceBundle);
+
+/* ITERATION API 
+    This API provides means for iterating through a resource
+*/
+
+/**
+ * Resets the internal context of a resource so that iteration starts from the first element.
+ *
+ * @param resourceBundle a resource
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+ures_resetIterator(UResourceBundle *resourceBundle);
+
+/**
+ * Checks whether the given resource has another element to iterate over.
+ *
+ * @param resourceBundle a resource
+ * @return TRUE if there are more elements, FALSE if there is no more elements
+ * @stable ICU 2.0
+ */
+U_STABLE UBool U_EXPORT2 
+ures_hasNext(const UResourceBundle *resourceBundle);
+
+/**
+ * Returns the next resource in a given resource or NULL if there are no more resources 
+ * to iterate over. Features a fill-in parameter. 
+ *
+ * @param resourceBundle    a resource
+ * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
+ *                          Alternatively, you can supply a struct to be filled by this function.
+ * @param status            fills in the outgoing error code. You may still get a non NULL result even if an
+ *                          error occured. Check status instead.
+ * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
+ * @stable ICU 2.0
+ */
+U_STABLE UResourceBundle* U_EXPORT2 
+ures_getNextResource(UResourceBundle *resourceBundle, 
+                     UResourceBundle *fillIn, 
+                     UErrorCode *status);
+
+/**
+ * Returns the next string in a given resource or NULL if there are no more resources 
+ * to iterate over. 
+ *
+ * @param resourceBundle    a resource
+ * @param len               fill in length of the string
+ * @param key               fill in for key associated with this string. NULL if no key
+ * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't
+ *                          count on it. Check status instead!
+ * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
+ * @stable ICU 2.0
+ */
+U_STABLE const UChar* U_EXPORT2 
+ures_getNextString(UResourceBundle *resourceBundle, 
+                   int32_t* len, 
+                   const char ** key, 
+                   UErrorCode *status);
+
+/**
+ * Returns the resource in a given resource at the specified index. Features a fill-in parameter. 
+ *
+ * @param resourceBundle    the resource bundle from which to get a sub-resource
+ * @param indexR            an index to the wanted resource.
+ * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
+ *                          Alternatively, you can supply a struct to be filled by this function.
+ * @param status            fills in the outgoing error code. Don't count on NULL being returned if an error has
+ *                          occured. Check status instead.
+ * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
+ * @stable ICU 2.0
+ */
+U_STABLE UResourceBundle* U_EXPORT2 
+ures_getByIndex(const UResourceBundle *resourceBundle, 
+                int32_t indexR, 
+                UResourceBundle *fillIn, 
+                UErrorCode *status);
+
+/**
+ * Returns the string in a given resource at the specified index.
+ *
+ * @param resourceBundle    a resource
+ * @param indexS            an index to the wanted string.
+ * @param len               fill in length of the string
+ * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't
+ *                          count on it. Check status instead!
+ * @return                  a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
+ * @stable ICU 2.0
+ */
+U_STABLE const UChar* U_EXPORT2 
+ures_getStringByIndex(const UResourceBundle *resourceBundle, 
+                      int32_t indexS, 
+                      int32_t* len, 
+                      UErrorCode *status);
+
+/**
+ * Returns a UTF-8 string from a resource at the specified index.
+ * The UTF-8 string may be returnable directly as a pointer, or
+ * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
+ * or equivalent.
+ *
+ * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * and dest is returned.
+ *
+ * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * without needing a dest buffer (it can be NULL). If the string needs to be
+ * copied or transformed, then it may be placed into dest at an arbitrary offset.
+ *
+ * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
+ * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
+ *
+ * If the string is transformed from UTF-16, then a conversion error may occur
+ * if an unpaired surrogate is encountered. If the function is successful, then
+ * the output UTF-8 string is always well-formed.
+ *
+ * @param resB Resource bundle.
+ * @param index An index to the wanted string.
+ * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
+ * @param pLength Input: Capacity of destination buffer.
+ *               Output: Actual length of the UTF-8 string, not counting the
+ *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
+ *               Can be NULL, meaning capacity=0 and the string length is not
+ *               returned to the caller.
+ * @param forceCopy If TRUE, then the output string will always be written to
+ *                  dest, with U_BUFFER_OVERFLOW_ERROR and
+ *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.
+ *                  If FALSE, then the dest buffer may or may not contain a
+ *                  copy of the string. dest may or may not be modified.
+ *                  If a copy needs to be written, then the UErrorCode parameter
+ *                  indicates overflow etc. as usual.
+ * @param status Pointer to a standard ICU error code. Its input value must
+ *               pass the U_SUCCESS() test, or else the function returns
+ *               immediately. Check for U_FAILURE() on output or use with
+ *               function chaining. (See User Guide for details.)
+ * @return The pointer to the UTF-8 string. It may be dest, or at some offset
+ *         from dest (only if !forceCopy), or in unrelated memory.
+ *         Always NUL-terminated unless the string was written to dest and
+ *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
+ *
+ * @see ures_getStringByIndex
+ * @see u_strToUTF8
+ * @stable ICU 3.6
+ */
+U_STABLE const char * U_EXPORT2
+ures_getUTF8StringByIndex(const UResourceBundle *resB,
+                          int32_t index,
+                          char *dest, int32_t *pLength,
+                          UBool forceCopy,
+                          UErrorCode *status);
+
+/**
+ * Returns a resource in a given resource that has a given key. This procedure works only with table
+ * resources. Features a fill-in parameter. 
+ *
+ * @param resourceBundle    a resource
+ * @param key               a key associated with the wanted resource
+ * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
+ *                          Alternatively, you can supply a struct to be filled by this function.
+ * @param status            fills in the outgoing error code.
+ * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
+ * @stable ICU 2.0
+ */
+U_STABLE UResourceBundle* U_EXPORT2 
+ures_getByKey(const UResourceBundle *resourceBundle, 
+              const char* key, 
+              UResourceBundle *fillIn, 
+              UErrorCode *status);
+
+/**
+ * Returns a string in a given resource that has a given key. This procedure works only with table
+ * resources. 
+ *
+ * @param resB              a resource
+ * @param key               a key associated with the wanted string
+ * @param len               fill in length of the string
+ * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't
+ *                          count on it. Check status instead!
+ * @return                  a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
+ * @stable ICU 2.0
+ */
+U_STABLE const UChar* U_EXPORT2 
+ures_getStringByKey(const UResourceBundle *resB, 
+                    const char* key, 
+                    int32_t* len, 
+                    UErrorCode *status);
+
+/**
+ * Returns a UTF-8 string from a resource and a key.
+ * This function works only with table resources.
+ *
+ * The UTF-8 string may be returnable directly as a pointer, or
+ * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
+ * or equivalent.
+ *
+ * If forceCopy==TRUE, then the string is always written to the dest buffer
+ * and dest is returned.
+ *
+ * If forceCopy==FALSE, then the string is returned as a pointer if possible,
+ * without needing a dest buffer (it can be NULL). If the string needs to be
+ * copied or transformed, then it may be placed into dest at an arbitrary offset.
+ *
+ * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
+ * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
+ *
+ * If the string is transformed from UTF-16, then a conversion error may occur
+ * if an unpaired surrogate is encountered. If the function is successful, then
+ * the output UTF-8 string is always well-formed.
+ *
+ * @param resB Resource bundle.
+ * @param key  A key associated with the wanted resource
+ * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
+ * @param pLength Input: Capacity of destination buffer.
+ *               Output: Actual length of the UTF-8 string, not counting the
+ *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
+ *               Can be NULL, meaning capacity=0 and the string length is not
+ *               returned to the caller.
+ * @param forceCopy If TRUE, then the output string will always be written to
+ *                  dest, with U_BUFFER_OVERFLOW_ERROR and
+ *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.
+ *                  If FALSE, then the dest buffer may or may not contain a
+ *                  copy of the string. dest may or may not be modified.
+ *                  If a copy needs to be written, then the UErrorCode parameter
+ *                  indicates overflow etc. as usual.
+ * @param status Pointer to a standard ICU error code. Its input value must
+ *               pass the U_SUCCESS() test, or else the function returns
+ *               immediately. Check for U_FAILURE() on output or use with
+ *               function chaining. (See User Guide for details.)
+ * @return The pointer to the UTF-8 string. It may be dest, or at some offset
+ *         from dest (only if !forceCopy), or in unrelated memory.
+ *         Always NUL-terminated unless the string was written to dest and
+ *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
+ *
+ * @see ures_getStringByKey
+ * @see u_strToUTF8
+ * @stable ICU 3.6
+ */
+U_STABLE const char * U_EXPORT2
+ures_getUTF8StringByKey(const UResourceBundle *resB,
+                        const char *key,
+                        char *dest, int32_t *pLength,
+                        UBool forceCopy,
+                        UErrorCode *status);
+
+#ifdef XP_CPLUSPLUS
+#include "unicode/unistr.h"
+
+U_NAMESPACE_BEGIN
+/**
+ * returns a string from a string resource type
+ *
+ * @param resB    a resource
+ * @param status: fills in the outgoing error code
+ *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
+ *                could be a non-failing error 
+ *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
+ * @return        a UnicodeString object. If there is an error, string is bogus
+ * @stable ICU 2.0
+ */
+inline UnicodeString 
+ures_getUnicodeString(const UResourceBundle *resB, 
+                      UErrorCode* status) 
+{
+    int32_t len = 0;
+    const UChar *r = ures_getString(resB, &len, status);
+    return UnicodeString(TRUE, r, len);
+}
+
+/**
+ * Returns the next string in a resource or NULL if there are no more resources 
+ * to iterate over. 
+ *
+ * @param resB              a resource
+ * @param key               fill in for key associated with this string
+ * @param status            fills in the outgoing error code
+ * @return an UnicodeString object.
+ * @stable ICU 2.0
+ */
+inline UnicodeString 
+ures_getNextUnicodeString(UResourceBundle *resB, 
+                          const char ** key, 
+                          UErrorCode* status) 
+{
+    int32_t len = 0;
+    const UChar* r = ures_getNextString(resB, &len, key, status);
+    return UnicodeString(TRUE, r, len);
+}
+
+/**
+ * Returns the string in a given resource at the specified index.
+ *
+ * @param resB              a resource
+ * @param index             an index to the wanted string.
+ * @param status            fills in the outgoing error code
+ * @return                  an UnicodeString object. If there is an error, string is bogus
+ * @stable ICU 2.0
+ */
+inline UnicodeString 
+ures_getUnicodeStringByIndex(const UResourceBundle *resB, 
+                             int32_t indexS, 
+                             UErrorCode* status) 
+{
+    int32_t len = 0;
+    const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
+    return UnicodeString(TRUE, r, len);
+}
+
+/**
+ * Returns a string in a resource that has a given key. This procedure works only with table
+ * resources. 
+ *
+ * @param resB              a resource
+ * @param key               a key associated with the wanted string
+ * @param status            fills in the outgoing error code
+ * @return                  an UnicodeString object. If there is an error, string is bogus
+ * @stable ICU 2.0
+ */
+inline UnicodeString 
+ures_getUnicodeStringByKey(const UResourceBundle *resB, 
+                           const char* key, 
+                           UErrorCode* status) 
+{
+    int32_t len = 0;
+    const UChar* r = ures_getStringByKey(resB, key, &len, status);
+    return UnicodeString(TRUE, r, len);
+}
+
+U_NAMESPACE_END
+
+#endif
+
+/**
+ * Create a string enumerator, owned by the caller, of all locales located within 
+ * the specified resource tree.
+ * @param packageName name of the tree, such as (NULL) or U_ICUDATA_ALIAS or  or "ICUDATA-coll"
+ * This call is similar to uloc_getAvailable().
+ * @param status error code
+ * @stable ICU 3.2
+ */
+U_STABLE UEnumeration* U_EXPORT2
+ures_openAvailableLocales(const char *packageName, UErrorCode *status);
+
+
+#endif /*_URES*/
+/*eof*/
diff --git a/CoreFoundation/icu/unicode/uscript.h b/CoreFoundation/icu/unicode/uscript.h
new file mode 100644
index 0000000..c915d8d
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uscript.h
@@ -0,0 +1,254 @@
+/*
+ **********************************************************************
+ *   Copyright (C) 1997-2008, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ **********************************************************************
+ *
+ * File USCRIPT.H
+ *
+ * Modification History:
+ *
+ *   Date        Name        Description
+ *   07/06/2001    Ram         Creation.
+ ******************************************************************************
+ */
+
+#ifndef USCRIPT_H
+#define USCRIPT_H
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C API: Unicode Script Information
+ */
+ 
+/**
+ * Constants for ISO 15924 script codes.
+ *
+ * Many of these script codes - those from Unicode's ScriptNames.txt -
+ * are character property values for Unicode's Script property.
+ * See UAX #24 Script Names (http://www.unicode.org/reports/tr24/).
+ *
+ * Starting with ICU 3.6, constants for most ISO 15924 script codes
+ * are included (currently excluding private-use codes Qaaa..Qabx).
+ * For scripts for which there are codes in ISO 15924 but which are not
+ * used in the Unicode Character Database (UCD), there are no Unicode characters
+ * associated with those scripts.
+ *
+ * For example, there are no characters that have a UCD script code of
+ * Hans or Hant. All Han ideographs have the Hani script code.
+ * The Hans and Hant script codes are used with CLDR data.
+ *
+ * ISO 15924 script codes are included for use with CLDR and similar.
+ *
+ * @stable ICU 2.2
+ */
+typedef enum UScriptCode {
+      USCRIPT_INVALID_CODE = -1,
+      USCRIPT_COMMON       =  0 , /* Zyyy */
+      USCRIPT_INHERITED    =  1,  /* Qaai */
+      USCRIPT_ARABIC       =  2,  /* Arab */
+      USCRIPT_ARMENIAN     =  3,  /* Armn */
+      USCRIPT_BENGALI      =  4,  /* Beng */
+      USCRIPT_BOPOMOFO     =  5,  /* Bopo */
+      USCRIPT_CHEROKEE     =  6,  /* Cher */
+      USCRIPT_COPTIC       =  7,  /* Copt */
+      USCRIPT_CYRILLIC     =  8,  /* Cyrl */
+      USCRIPT_DESERET      =  9,  /* Dsrt */
+      USCRIPT_DEVANAGARI   = 10,  /* Deva */
+      USCRIPT_ETHIOPIC     = 11,  /* Ethi */
+      USCRIPT_GEORGIAN     = 12,  /* Geor */
+      USCRIPT_GOTHIC       = 13,  /* Goth */
+      USCRIPT_GREEK        = 14,  /* Grek */
+      USCRIPT_GUJARATI     = 15,  /* Gujr */
+      USCRIPT_GURMUKHI     = 16,  /* Guru */
+      USCRIPT_HAN          = 17,  /* Hani */
+      USCRIPT_HANGUL       = 18,  /* Hang */
+      USCRIPT_HEBREW       = 19,  /* Hebr */
+      USCRIPT_HIRAGANA     = 20,  /* Hira */
+      USCRIPT_KANNADA      = 21,  /* Knda */
+      USCRIPT_KATAKANA     = 22,  /* Kana */
+      USCRIPT_KHMER        = 23,  /* Khmr */
+      USCRIPT_LAO          = 24,  /* Laoo */
+      USCRIPT_LATIN        = 25,  /* Latn */
+      USCRIPT_MALAYALAM    = 26,  /* Mlym */
+      USCRIPT_MONGOLIAN    = 27,  /* Mong */
+      USCRIPT_MYANMAR      = 28,  /* Mymr */
+      USCRIPT_OGHAM        = 29,  /* Ogam */
+      USCRIPT_OLD_ITALIC   = 30,  /* Ital */
+      USCRIPT_ORIYA        = 31,  /* Orya */
+      USCRIPT_RUNIC        = 32,  /* Runr */
+      USCRIPT_SINHALA      = 33,  /* Sinh */
+      USCRIPT_SYRIAC       = 34,  /* Syrc */
+      USCRIPT_TAMIL        = 35,  /* Taml */
+      USCRIPT_TELUGU       = 36,  /* Telu */
+      USCRIPT_THAANA       = 37,  /* Thaa */
+      USCRIPT_THAI         = 38,  /* Thai */
+      USCRIPT_TIBETAN      = 39,  /* Tibt */
+      /** Canadian_Aboriginal script. @stable ICU 2.6 */
+      USCRIPT_CANADIAN_ABORIGINAL = 40,  /* Cans */
+      /** Canadian_Aboriginal script (alias). @stable ICU 2.2 */
+      USCRIPT_UCAS         = USCRIPT_CANADIAN_ABORIGINAL,
+      USCRIPT_YI           = 41,  /* Yiii */
+      USCRIPT_TAGALOG      = 42,  /* Tglg */
+      USCRIPT_HANUNOO      = 43,  /* Hano */
+      USCRIPT_BUHID        = 44,  /* Buhd */
+      USCRIPT_TAGBANWA     = 45,  /* Tagb */
+
+      /* New scripts in Unicode 4 @stable ICU 2.6 */
+      USCRIPT_BRAILLE      = 46,  /* Brai */
+      USCRIPT_CYPRIOT      = 47,  /* Cprt */
+      USCRIPT_LIMBU        = 48,  /* Limb */
+      USCRIPT_LINEAR_B     = 49,  /* Linb */
+      USCRIPT_OSMANYA      = 50,  /* Osma */
+      USCRIPT_SHAVIAN      = 51,  /* Shaw */
+      USCRIPT_TAI_LE       = 52,  /* Tale */
+      USCRIPT_UGARITIC     = 53,  /* Ugar */
+
+      /** New script code in Unicode 4.0.1 @stable ICU 3.0 */
+      USCRIPT_KATAKANA_OR_HIRAGANA = 54,/*Hrkt */
+      
+      /* New scripts in Unicode 4.1 @stable ICU 3.4 */
+      USCRIPT_BUGINESE      = 55, /* Bugi */
+      USCRIPT_GLAGOLITIC    = 56, /* Glag */
+      USCRIPT_KHAROSHTHI    = 57, /* Khar */
+      USCRIPT_SYLOTI_NAGRI  = 58, /* Sylo */
+      USCRIPT_NEW_TAI_LUE   = 59, /* Talu */
+      USCRIPT_TIFINAGH      = 60, /* Tfng */
+      USCRIPT_OLD_PERSIAN   = 61, /* Xpeo */
+
+      /* New script codes from ISO 15924 @stable ICU 3.6 */
+      USCRIPT_BALINESE                      = 62, /* Bali */
+      USCRIPT_BATAK                         = 63, /* Batk */
+      USCRIPT_BLISSYMBOLS                   = 64, /* Blis */
+      USCRIPT_BRAHMI                        = 65, /* Brah */
+      USCRIPT_CHAM                          = 66, /* Cham */
+      USCRIPT_CIRTH                         = 67, /* Cirt */
+      USCRIPT_OLD_CHURCH_SLAVONIC_CYRILLIC  = 68, /* Cyrs */
+      USCRIPT_DEMOTIC_EGYPTIAN              = 69, /* Egyd */
+      USCRIPT_HIERATIC_EGYPTIAN             = 70, /* Egyh */
+      USCRIPT_EGYPTIAN_HIEROGLYPHS          = 71, /* Egyp */
+      USCRIPT_KHUTSURI                      = 72, /* Geok */
+      USCRIPT_SIMPLIFIED_HAN                = 73, /* Hans */
+      USCRIPT_TRADITIONAL_HAN               = 74, /* Hant */
+      USCRIPT_PAHAWH_HMONG                  = 75, /* Hmng */
+      USCRIPT_OLD_HUNGARIAN                 = 76, /* Hung */
+      USCRIPT_HARAPPAN_INDUS                = 77, /* Inds */
+      USCRIPT_JAVANESE                      = 78, /* Java */
+      USCRIPT_KAYAH_LI                      = 79, /* Kali */
+      USCRIPT_LATIN_FRAKTUR                 = 80, /* Latf */
+      USCRIPT_LATIN_GAELIC                  = 81, /* Latg */
+      USCRIPT_LEPCHA                        = 82, /* Lepc */
+      USCRIPT_LINEAR_A                      = 83, /* Lina */
+      USCRIPT_MANDAEAN                      = 84, /* Mand */
+      USCRIPT_MAYAN_HIEROGLYPHS             = 85, /* Maya */
+      USCRIPT_MEROITIC                      = 86, /* Mero */
+      USCRIPT_NKO                           = 87, /* Nkoo */
+      USCRIPT_ORKHON                        = 88, /* Orkh */
+      USCRIPT_OLD_PERMIC                    = 89, /* Perm */
+      USCRIPT_PHAGS_PA                      = 90, /* Phag */
+      USCRIPT_PHOENICIAN                    = 91, /* Phnx */
+      USCRIPT_PHONETIC_POLLARD              = 92, /* Plrd */
+      USCRIPT_RONGORONGO                    = 93, /* Roro */
+      USCRIPT_SARATI                        = 94, /* Sara */
+      USCRIPT_ESTRANGELO_SYRIAC             = 95, /* Syre */
+      USCRIPT_WESTERN_SYRIAC                = 96, /* Syrj */
+      USCRIPT_EASTERN_SYRIAC                = 97, /* Syrn */
+      USCRIPT_TENGWAR                       = 98, /* Teng */
+      USCRIPT_VAI                           = 99, /* Vaii */
+      USCRIPT_VISIBLE_SPEECH                = 100, /* Visp */
+      USCRIPT_CUNEIFORM                     = 101,/* Xsux */
+      USCRIPT_UNWRITTEN_LANGUAGES           = 102,/* Zxxx */
+      USCRIPT_UNKNOWN                       = 103,/* Zzzz */ /* Unknown="Code for uncoded script", for unassigned code points */
+
+      /* New script codes from ISO 15924 @stable ICU 4.0 */
+      USCRIPT_CARIAN                        = 104,/* Cari */
+      USCRIPT_JAPANESE                      = 105,/* Jpan */
+      USCRIPT_LANNA                         = 106,/* Lana */
+      USCRIPT_LYCIAN                        = 107,/* Lyci */
+      USCRIPT_LYDIAN                        = 108,/* Lydi */
+      USCRIPT_OL_CHIKI                      = 109,/* Olck */
+      USCRIPT_REJANG                        = 110,/* Rjng */
+      USCRIPT_SAURASHTRA                    = 111,/* Saur */
+      USCRIPT_SIGN_WRITING                  = 112,/* Sgnw */
+      USCRIPT_SUNDANESE                     = 113,/* Sund */
+      USCRIPT_MOON                          = 114,/* Moon */
+      USCRIPT_MEITEI_MAYEK                  = 115,/* Mtei */
+
+      /* New script codes from ISO 15924 @draft ICU 4.0 */
+      USCRIPT_IMPERIAL_ARAMAIC              = 116,/* Armi */
+      USCRIPT_AVESTAN                       = 117,/* Avst */
+      USCRIPT_CHAKMA                        = 118,/* Cakm */
+      USCRIPT_KOREAN                        = 119,/* Kore */
+      USCRIPT_KAITHI                        = 120,/* Kthi */
+      USCRIPT_MANICHAEAN                    = 121,/* Mani */
+      USCRIPT_INSCRIPTIONAL_PAHLAVI         = 122,/* Phli */
+      USCRIPT_PSALTER_PAHLAVI               = 123,/* Phlp */
+      USCRIPT_BOOK_PAHLAVI                  = 124,/* Phlv */
+      USCRIPT_INSCRIPTIONAL_PARTHIAN        = 125,/* Prti */
+      USCRIPT_SAMARITAN                     = 126,/* Samr */
+      USCRIPT_TAI_VIET                      = 127,/* Tavt */
+      USCRIPT_MATHEMATICAL_NOTATION         = 128,/* Zmth */
+      USCRIPT_SYMBOLS                       = 129,/* Zsym */
+
+      /* Private use codes from Qaaa - Qabx are not supported*/
+      USCRIPT_CODE_LIMIT    = 130
+} UScriptCode;
+
+/**
+ * Gets script codes associated with the given locale or ISO 15924 abbreviation or name. 
+ * Fills in USCRIPT_MALAYALAM given "Malayam" OR "Mlym".
+ * Fills in USCRIPT_LATIN given "en" OR "en_US" 
+ * If required capacity is greater than capacity of the destination buffer then the error code
+ * is set to U_BUFFER_OVERFLOW_ERROR and the required capacity is returned
+ *
+ * <p>Note: To search by short or long script alias only, use
+ * u_getPropertyValueEnum(UCHAR_SCRIPT, alias) instead.  This does
+ * a fast lookup with no access of the locale data.
+ * @param nameOrAbbrOrLocale name of the script, as given in
+ * PropertyValueAliases.txt, or ISO 15924 code or locale
+ * @param fillIn the UScriptCode buffer to fill in the script code
+ * @param capacity the capacity (size) fo UScriptCode buffer passed in.
+ * @param err the error status code.
+ * @return The number of script codes filled in the buffer passed in 
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t  U_EXPORT2 
+uscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capacity,UErrorCode *err);
+
+/**
+ * Gets a script name associated with the given script code. 
+ * Returns  "Malayam" given USCRIPT_MALAYALAM
+ * @param scriptCode UScriptCode enum
+ * @return script long name as given in
+ * PropertyValueAliases.txt, or NULL if scriptCode is invalid
+ * @stable ICU 2.4
+ */
+U_STABLE const char*  U_EXPORT2 
+uscript_getName(UScriptCode scriptCode);
+
+/**
+ * Gets a script name associated with the given script code. 
+ * Returns  "Mlym" given USCRIPT_MALAYALAM
+ * @param scriptCode UScriptCode enum
+ * @return script abbreviated name as given in
+ * PropertyValueAliases.txt, or NULL if scriptCode is invalid
+ * @stable ICU 2.4
+ */
+U_STABLE const char*  U_EXPORT2 
+uscript_getShortName(UScriptCode scriptCode);
+
+/** 
+ * Gets the script code associated with the given codepoint.
+ * Returns USCRIPT_MALAYALAM given 0x0D02 
+ * @param codepoint UChar32 codepoint
+ * @param err the error status code.
+ * @return The UScriptCode, or 0 if codepoint is invalid 
+ * @stable ICU 2.4
+ */
+U_STABLE UScriptCode  U_EXPORT2 
+uscript_getScript(UChar32 codepoint, UErrorCode *err);
+
+#endif
+
+
diff --git a/CoreFoundation/icu/unicode/usearch.h b/CoreFoundation/icu/unicode/usearch.h
new file mode 100644
index 0000000..deaa78f
--- /dev/null
+++ b/CoreFoundation/icu/unicode/usearch.h
@@ -0,0 +1,766 @@
+/*
+**********************************************************************
+*   Copyright (C) 2001-2008 IBM and others. All rights reserved.
+**********************************************************************
+*   Date        Name        Description
+*  06/28/2001   synwee      Creation.
+**********************************************************************
+*/
+#ifndef USEARCH_H
+#define USEARCH_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
+
+#include "unicode/ucol.h"
+#include "unicode/ucoleitr.h"
+#include "unicode/ubrk.h"
+
+/**
+ * \file
+ * \brief C API: StringSearch
+ *
+ * C Apis for an engine that provides language-sensitive text searching based 
+ * on the comparison rules defined in a <tt>UCollator</tt> data struct,
+ * see <tt>ucol.h</tt>. This ensures that language eccentricity can be 
+ * handled, e.g. for the German collator, characters &szlig; and SS will be matched 
+ * if case is chosen to be ignored. 
+ * See the <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm">
+ * "ICU Collation Design Document"</a> for more information.
+ * <p> 
+ * The algorithm implemented is a modified form of the Boyer Moore's search.
+ * For more information  see 
+ * <a href="http://icu-project.org/docs/papers/efficient_text_searching_in_java.html">
+ * "Efficient Text Searching in Java"</a>, published in <i>Java Report</i> 
+ * in February, 1999, for further information on the algorithm.
+ * <p>
+ * There are 2 match options for selection:<br>
+ * Let S' be the sub-string of a text string S between the offsets start and 
+ * end <start, end>.
+ * <br>
+ * A pattern string P matches a text string S at the offsets <start, end> 
+ * if
+ * <pre> 
+ * option 1. Some canonical equivalent of P matches some canonical equivalent 
+ *           of S'
+ * option 2. P matches S' and if P starts or ends with a combining mark, 
+ *           there exists no non-ignorable combining mark before or after S' 
+ *           in S respectively. 
+ * </pre>
+ * Option 2. will be the default.
+ * <p>
+ * This search has APIs similar to that of other text iteration mechanisms 
+ * such as the break iterators in <tt>ubrk.h</tt>. Using these 
+ * APIs, it is easy to scan through text looking for all occurances of 
+ * a given pattern. This search iterator allows changing of direction by 
+ * calling a <tt>reset</tt> followed by a <tt>next</tt> or <tt>previous</tt>. 
+ * Though a direction change can occur without calling <tt>reset</tt> first,  
+ * this operation comes with some speed penalty.
+ * Generally, match results in the forward direction will match the result 
+ * matches in the backwards direction in the reverse order
+ * <p>
+ * <tt>usearch.h</tt> provides APIs to specify the starting position 
+ * within the text string to be searched, e.g. <tt>usearch_setOffset</tt>,
+ * <tt>usearch_preceding</tt> and <tt>usearch_following</tt>. Since the 
+ * starting position will be set as it is specified, please take note that 
+ * there are some dangerous positions which the search may render incorrect 
+ * results:
+ * <ul>
+ * <li> The midst of a substring that requires normalization.
+ * <li> If the following match is to be found, the position should not be the
+ *      second character which requires to be swapped with the preceding 
+ *      character. Vice versa, if the preceding match is to be found, 
+ *      position to search from should not be the first character which 
+ *      requires to be swapped with the next character. E.g certain Thai and
+ *      Lao characters require swapping.
+ * <li> If a following pattern match is to be found, any position within a 
+ *      contracting sequence except the first will fail. Vice versa if a 
+ *      preceding pattern match is to be found, a invalid starting point 
+ *      would be any character within a contracting sequence except the last.
+ * </ul>
+ * <p>
+ * A breakiterator can be used if only matches at logical breaks are desired.
+ * Using a breakiterator will only give you results that exactly matches the
+ * boundaries given by the breakiterator. For instance the pattern "e" will
+ * not be found in the string "\u00e9" if a character break iterator is used.
+ * <p>
+ * Options are provided to handle overlapping matches. 
+ * E.g. In English, overlapping matches produces the result 0 and 2 
+ * for the pattern "abab" in the text "ababab", where else mutually 
+ * exclusive matches only produce the result of 0.
+ * <p>
+ * Though collator attributes will be taken into consideration while 
+ * performing matches, there are no APIs here for setting and getting the 
+ * attributes. These attributes can be set by getting the collator
+ * from <tt>usearch_getCollator</tt> and using the APIs in <tt>ucol.h</tt>.
+ * Lastly to update String Search to the new collator attributes, 
+ * usearch_reset() has to be called.
+ * <p> 
+ * Restriction: <br>
+ * Currently there are no composite characters that consists of a
+ * character with combining class > 0 before a character with combining 
+ * class == 0. However, if such a character exists in the future, the 
+ * search mechanism does not guarantee the results for option 1.
+ * 
+ * <p>
+ * Example of use:<br>
+ * <pre><code>
+ * char *tgtstr = "The quick brown fox jumped over the lazy fox";
+ * char *patstr = "fox";
+ * UChar target[64];
+ * UChar pattern[16];
+ * UErrorCode status = U_ZERO_ERROR;
+ * u_uastrcpy(target, tgtstr);
+ * u_uastrcpy(pattern, patstr);
+ *
+ * UStringSearch *search = usearch_open(pattern, -1, target, -1, "en_US", 
+ *                                  NULL, &status);
+ * if (U_SUCCESS(status)) {
+ *     for (int pos = usearch_first(search, &status); 
+ *          pos != USEARCH_DONE; 
+ *          pos = usearch_next(search, &status))
+ *     {
+ *         printf("Found match at %d pos, length is %d\n", pos, 
+ *                                        usearch_getMatchLength(search));
+ *     }
+ * }
+ *
+ * usearch_close(search);
+ * </code></pre>
+ * @stable ICU 2.4
+ */
+
+/**
+* DONE is returned by previous() and next() after all valid matches have 
+* been returned, and by first() and last() if there are no matches at all.
+* @stable ICU 2.4
+*/
+#define USEARCH_DONE -1
+
+/**
+* Data structure for searching
+* @stable ICU 2.4
+*/
+struct UStringSearch;
+/**
+* Data structure for searching
+* @stable ICU 2.4
+*/
+typedef struct UStringSearch UStringSearch;
+
+/**
+* @stable ICU 2.4
+*/
+typedef enum {
+    /** Option for overlapping matches */
+    USEARCH_OVERLAP,
+    /** 
+    Option for canonical matches. option 1 in header documentation.
+    The default value will be USEARCH_OFF
+    */
+    USEARCH_CANONICAL_MATCH,
+    USEARCH_ATTRIBUTE_COUNT
+} USearchAttribute;
+
+/**
+* @stable ICU 2.4
+*/
+typedef enum {
+    /** default value for any USearchAttribute */
+    USEARCH_DEFAULT = -1,
+    /** value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH */
+    USEARCH_OFF, 
+    /** value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH */
+    USEARCH_ON,
+    USEARCH_ATTRIBUTE_VALUE_COUNT
+} USearchAttributeValue;
+
+/* open and close ------------------------------------------------------ */
+
+/**
+* Creating a search iterator data struct using the argument locale language
+* rule set. A collator will be created in the process, which will be owned by
+* this search and will be deleted in <tt>usearch_close</tt>.
+* @param pattern for matching
+* @param patternlength length of the pattern, -1 for null-termination
+* @param text text string
+* @param textlength length of the text string, -1 for null-termination
+* @param locale name of locale for the rules to be used
+* @param breakiter A BreakIterator that will be used to restrict the points
+*                  at which matches are detected. If a match is found, but 
+*                  the match's start or end index is not a boundary as 
+*                  determined by the <tt>BreakIterator</tt>, the match will 
+*                  be rejected and another will be searched for. 
+*                  If this parameter is <tt>NULL</tt>, no break detection is 
+*                  attempted.
+* @param status for errors if it occurs. If pattern or text is NULL, or if
+*               patternlength or textlength is 0 then an 
+*               U_ILLEGAL_ARGUMENT_ERROR is returned.
+* @return search iterator data structure, or NULL if there is an error.
+* @stable ICU 2.4
+*/
+U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar          *pattern, 
+                                              int32_t         patternlength, 
+                                        const UChar          *text, 
+                                              int32_t         textlength,
+                                        const char           *locale,
+                                              UBreakIterator *breakiter,
+                                              UErrorCode     *status);
+
+/**
+* Creating a search iterator data struct using the argument collator language
+* rule set. Note, user retains the ownership of this collator, thus the 
+* responsibility of deletion lies with the user.
+* NOTE: string search cannot be instantiated from a collator that has 
+* collate digits as numbers (CODAN) turned on.
+* @param pattern for matching
+* @param patternlength length of the pattern, -1 for null-termination
+* @param text text string
+* @param textlength length of the text string, -1 for null-termination
+* @param collator used for the language rules
+* @param breakiter A BreakIterator that will be used to restrict the points
+*                  at which matches are detected. If a match is found, but 
+*                  the match's start or end index is not a boundary as 
+*                  determined by the <tt>BreakIterator</tt>, the match will 
+*                  be rejected and another will be searched for. 
+*                  If this parameter is <tt>NULL</tt>, no break detection is 
+*                  attempted.
+* @param status for errors if it occurs. If collator, pattern or text is NULL, 
+*               or if patternlength or textlength is 0 then an 
+*               U_ILLEGAL_ARGUMENT_ERROR is returned.
+* @return search iterator data structure, or NULL if there is an error.
+* @stable ICU 2.4
+*/
+U_STABLE UStringSearch * U_EXPORT2 usearch_openFromCollator(
+                                         const UChar *pattern, 
+                                               int32_t         patternlength,
+                                         const UChar          *text, 
+                                               int32_t         textlength,
+                                         const UCollator      *collator,
+                                               UBreakIterator *breakiter,
+                                               UErrorCode     *status);
+
+/**
+* Destroying and cleaning up the search iterator data struct.
+* If a collator is created in <tt>usearch_open</tt>, it will be destroyed here.
+* @param searchiter data struct to clean up
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);
+
+/* get and set methods -------------------------------------------------- */
+
+/**
+* Sets the current position in the text string which the next search will 
+* start from. Clears previous states. 
+* This method takes the argument index and sets the position in the text 
+* string accordingly without checking if the index is pointing to a 
+* valid starting point to begin searching. 
+* Search positions that may render incorrect results are highlighted in the
+* header comments
+* @param strsrch search iterator data struct
+* @param position position to start next search from. If position is less
+*          than or greater than the text range for searching, 
+*          an U_INDEX_OUTOFBOUNDS_ERROR will be returned
+* @param status error status if any.
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch, 
+                                        int32_t    position,
+                                        UErrorCode    *status);
+
+/**
+* Return the current index in the string text being searched.
+* If the iteration has gone past the end of the text (or past the beginning 
+* for a backwards search), <tt>USEARCH_DONE</tt> is returned.
+* @param strsrch search iterator data struct
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
+    
+/**
+* Sets the text searching attributes located in the enum USearchAttribute
+* with values from the enum USearchAttributeValue.
+* <tt>USEARCH_DEFAULT</tt> can be used for all attributes for resetting.
+* @param strsrch search iterator data struct
+* @param attribute text attribute to be set
+* @param value text attribute value
+* @param status for errors if it occurs
+* @see #usearch_getAttribute
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch         *strsrch, 
+                                           USearchAttribute       attribute,
+                                           USearchAttributeValue  value,
+                                           UErrorCode            *status);
+
+/**    
+* Gets the text searching attributes.
+* @param strsrch search iterator data struct
+* @param attribute text attribute to be retrieve
+* @return text attribute value
+* @see #usearch_setAttribute
+* @stable ICU 2.4
+*/
+U_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute(
+                                         const UStringSearch    *strsrch,
+                                               USearchAttribute  attribute);
+
+/**
+* Returns the index to the match in the text string that was searched.
+* This call returns a valid result only after a successful call to 
+* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, 
+* or <tt>usearch_last</tt>.
+* Just after construction, or after a searching method returns 
+* <tt>USEARCH_DONE</tt>, this method will return <tt>USEARCH_DONE</tt>.
+* <p>
+* Use <tt>usearch_getMatchedLength</tt> to get the matched string length.
+* @param strsrch search iterator data struct
+* @return index to a substring within the text string that is being 
+*         searched.
+* @see #usearch_first
+* @see #usearch_next
+* @see #usearch_previous
+* @see #usearch_last
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(
+                                               const UStringSearch *strsrch);
+    
+/**
+* Returns the length of text in the string which matches the search pattern. 
+* This call returns a valid result only after a successful call to 
+* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, 
+* or <tt>usearch_last</tt>.
+* Just after construction, or after a searching method returns 
+* <tt>USEARCH_DONE</tt>, this method will return 0.
+* @param strsrch search iterator data struct
+* @return The length of the match in the string text, or 0 if there is no 
+*         match currently.
+* @see #usearch_first
+* @see #usearch_next
+* @see #usearch_previous
+* @see #usearch_last
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(
+                                               const UStringSearch *strsrch);
+
+/**
+* Returns the text that was matched by the most recent call to 
+* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, 
+* or <tt>usearch_last</tt>.
+* If the iterator is not pointing at a valid match (e.g. just after 
+* construction or after <tt>USEARCH_DONE</tt> has been returned, returns
+* an empty string. If result is not large enough to store the matched text,
+* result will be filled with the partial text and an U_BUFFER_OVERFLOW_ERROR 
+* will be returned in status. result will be null-terminated whenever 
+* possible. If the buffer fits the matched text exactly, a null-termination 
+* is not possible, then a U_STRING_NOT_TERMINATED_ERROR set in status.
+* Pre-flighting can be either done with length = 0 or the API 
+* <tt>usearch_getMatchLength</tt>.
+* @param strsrch search iterator data struct
+* @param result UChar buffer to store the matched string
+* @param resultCapacity length of the result buffer
+* @param status error returned if result is not large enough
+* @return exact length of the matched text, not counting the null-termination
+* @see #usearch_first
+* @see #usearch_next
+* @see #usearch_previous
+* @see #usearch_last
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, 
+                                            UChar         *result, 
+                                            int32_t        resultCapacity, 
+                                            UErrorCode    *status);
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+/**
+* Set the BreakIterator that will be used to restrict the points at which 
+* matches are detected.
+* @param strsrch search iterator data struct
+* @param breakiter A BreakIterator that will be used to restrict the points
+*                  at which matches are detected. If a match is found, but 
+*                  the match's start or end index is not a boundary as 
+*                  determined by the <tt>BreakIterator</tt>, the match will 
+*                  be rejected and another will be searched for. 
+*                  If this parameter is <tt>NULL</tt>, no break detection is 
+*                  attempted.
+* @param status for errors if it occurs
+* @see #usearch_getBreakIterator
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch  *strsrch, 
+                                               UBreakIterator *breakiter,
+                                               UErrorCode     *status);
+
+/**
+* Returns the BreakIterator that is used to restrict the points at which 
+* matches are detected. This will be the same object that was passed to the 
+* constructor or to <tt>usearch_setBreakIterator</tt>. Note that 
+* <tt>NULL</tt> 
+* is a legal value; it means that break detection should not be attempted.
+* @param strsrch search iterator data struct
+* @return break iterator used
+* @see #usearch_setBreakIterator
+* @stable ICU 2.4
+*/
+U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(
+                                              const UStringSearch *strsrch);
+    
+#endif
+    
+/**
+* Set the string text to be searched. Text iteration will hence begin at the 
+* start of the text string. This method is useful if you want to re-use an 
+* iterator to search for the same pattern within a different body of text.
+* @param strsrch search iterator data struct
+* @param text new string to look for match
+* @param textlength length of the new string, -1 for null-termination
+* @param status for errors if it occurs. If text is NULL, or textlength is 0 
+*               then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change
+*               done to strsrch.
+* @see #usearch_getText
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_setText(      UStringSearch *strsrch, 
+                                      const UChar         *text,
+                                            int32_t        textlength,
+                                            UErrorCode    *status);
+
+/**
+* Return the string text to be searched.
+* @param strsrch search iterator data struct
+* @param length returned string text length
+* @return string text 
+* @see #usearch_setText
+* @stable ICU 2.4
+*/
+U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, 
+                                               int32_t       *length);
+
+/**
+* Gets the collator used for the language rules. 
+* <p>
+* Deleting the returned <tt>UCollator</tt> before calling 
+* <tt>usearch_close</tt> would cause the string search to fail.
+* <tt>usearch_close</tt> will delete the collator if this search owns it.
+* @param strsrch search iterator data struct
+* @return collator
+* @stable ICU 2.4
+*/
+U_STABLE UCollator * U_EXPORT2 usearch_getCollator(
+                                               const UStringSearch *strsrch);
+
+/**
+* Sets the collator used for the language rules. User retains the ownership 
+* of this collator, thus the responsibility of deletion lies with the user.
+* This method causes internal data such as Boyer-Moore shift tables to  
+* be recalculated, but the iterator's position is unchanged.
+* @param strsrch search iterator data struct
+* @param collator to be used
+* @param status for errors if it occurs
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_setCollator(      UStringSearch *strsrch, 
+                                          const UCollator     *collator,
+                                                UErrorCode    *status);
+
+/**
+* Sets the pattern used for matching.
+* Internal data like the Boyer Moore table will be recalculated, but the 
+* iterator's position is unchanged.
+* @param strsrch search iterator data struct
+* @param pattern string
+* @param patternlength pattern length, -1 for null-terminated string
+* @param status for errors if it occurs. If text is NULL, or textlength is 0 
+*               then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change
+*               done to strsrch.
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_setPattern(      UStringSearch *strsrch, 
+                                         const UChar         *pattern,
+                                               int32_t        patternlength,
+                                               UErrorCode    *status);
+
+/**
+* Gets the search pattern
+* @param strsrch search iterator data struct
+* @param length return length of the pattern, -1 indicates that the pattern 
+*               is null-terminated
+* @return pattern string
+* @stable ICU 2.4
+*/
+U_STABLE const UChar * U_EXPORT2 usearch_getPattern(
+                                               const UStringSearch *strsrch, 
+                                                     int32_t       *length);
+
+/* methods ------------------------------------------------------------- */
+
+/**
+* Returns the first index at which the string text matches the search 
+* pattern.  
+* The iterator is adjusted so that its current index (as returned by 
+* <tt>usearch_getOffset</tt>) is the match position if one was found.
+* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.
+* @param strsrch search iterator data struct
+* @param status for errors if it occurs
+* @return The character index of the first match, or 
+* <tt>USEARCH_DONE</tt> if there are no matches.
+* @see #usearch_getOffset
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, 
+                                           UErrorCode    *status);
+
+/**
+* Returns the first index greater than <tt>position</tt> at which the string 
+* text 
+* matches the search pattern. The iterator is adjusted so that its current 
+* index (as returned by <tt>usearch_getOffset</tt>) is the match position if 
+* one was found.
+* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* <p>
+* Search positions that may render incorrect results are highlighted in the
+* header comments. If position is less than or greater than the text range 
+* for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned
+* @param strsrch search iterator data struct
+* @param position to start the search at
+* @param status for errors if it occurs
+* @return The character index of the first match following <tt>pos</tt>,
+*         or <tt>USEARCH_DONE</tt> if there are no matches.
+* @see #usearch_getOffset
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, 
+                                               int32_t    position, 
+                                               UErrorCode    *status);
+    
+/**
+* Returns the last index in the target text at which it matches the search 
+* pattern. The iterator is adjusted so that its current 
+* index (as returned by <tt>usearch_getOffset</tt>) is the match position if 
+* one was found.
+* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.
+* @param strsrch search iterator data struct
+* @param status for errors if it occurs
+* @return The index of the first match, or <tt>USEARCH_DONE</tt> if there 
+*         are no matches.
+* @see #usearch_getOffset
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, 
+                                          UErrorCode    *status);
+
+/**
+* Returns the first index less than <tt>position</tt> at which the string text 
+* matches the search pattern. The iterator is adjusted so that its current 
+* index (as returned by <tt>usearch_getOffset</tt>) is the match position if 
+* one was found.
+* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* <p>
+* Search positions that may render incorrect results are highlighted in the
+* header comments. If position is less than or greater than the text range 
+* for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned
+* @param strsrch search iterator data struct
+* @param position index position the search is to begin at
+* @param status for errors if it occurs
+* @return The character index of the first match preceding <tt>pos</tt>,
+*         or <tt>USEARCH_DONE</tt> if there are no matches.
+* @see #usearch_getOffset
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, 
+                                               int32_t    position, 
+                                               UErrorCode    *status);
+    
+/**
+* Returns the index of the next point at which the string text matches the
+* search pattern, starting from the current position.
+* The iterator is adjusted so that its current 
+* index (as returned by <tt>usearch_getOffset</tt>) is the match position if 
+* one was found.
+* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* @param strsrch search iterator data struct
+* @param status for errors if it occurs
+* @return The index of the next match after the current position, or 
+*         <tt>USEARCH_DONE</tt> if there are no more matches.
+* @see #usearch_first
+* @see #usearch_getOffset
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, 
+                                          UErrorCode    *status);
+
+/**
+* Returns the index of the previous point at which the string text matches
+* the search pattern, starting at the current position.
+* The iterator is adjusted so that its current 
+* index (as returned by <tt>usearch_getOffset</tt>) is the match position if 
+* one was found.
+* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and
+* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>
+* @param strsrch search iterator data struct
+* @param status for errors if it occurs
+* @return The index of the previous match before the current position,
+*         or <tt>USEARCH_DONE</tt> if there are no more matches.
+* @see #usearch_last
+* @see #usearch_getOffset
+* @see #USEARCH_DONE
+* @stable ICU 2.4
+*/
+U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, 
+                                              UErrorCode    *status);
+    
+/** 
+* Reset the iteration.
+* Search will begin at the start of the text string if a forward iteration 
+* is initiated before a backwards iteration. Otherwise if a backwards 
+* iteration is initiated before a forwards iteration, the search will begin
+* at the end of the text string.
+* @param strsrch search iterator data struct
+* @see #usearch_first
+* @stable ICU 2.4
+*/
+U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
+
+/**
+  *  Simple forward search for the pattern, starting at a specified index,
+  *     and using using a default set search options.
+  *
+  *  This is an experimental function, and is not an official part of the
+  *      ICU API.
+  *
+  *  The collator options, such as UCOL_STRENGTH and UCOL_NORMALIZTION, are honored.
+  *
+  *  The UStringSearch options USEARCH_CANONICAL_MATCH, USEARCH_OVERLAP and
+  *  any Break Iterator are ignored.
+  *
+  *  Matches obey the following constraints:
+  *
+  *      Characters at the start or end positions of a match that are ignorable
+  *      for collation are not included as part of the match, unless they
+  *      are part of a combining sequence, as described below.
+  *
+  *      A match will not include a partial combining sequence.  Combining
+  *      character sequences  are considered to be  inseperable units,
+  *      and either match the pattern completely, or are considered to not match
+  *      at all.  Thus, for example, an A followed a combining accent mark will 
+  *      not be found when searching for a plain (unaccented) A.   (unless
+  *      the collation strength has been set to ignore all accents).
+  *
+  *      When beginning a search, the initial starting position, startIdx,
+  *      is assumed to be an acceptable match boundary with respect to
+  *      combining characters.  A combining sequence that spans across the
+  *      starting point will not supress a match beginning at startIdx.
+  *
+  *      Characters that expand to multiple collation elements
+  *      (German sharp-S becoming 'ss', or the composed forms of accented
+  *      characters, for example) also must match completely.
+  *      Searching for a single 's' in a string containing only a sharp-s will 
+  *      find no match.
+  *
+  *
+  *  @param strsrch    the UStringSearch struct, which references both
+  *                    the text to be searched  and the pattern being sought.
+  *  @param startIdx   The index into the text to begin the search.
+  *  @param matchStart An out parameter, the starting index of the matched text.
+  *                    This parameter may be NULL.
+  *                    A value of -1 will be returned if no match was found.
+  *  @param matchLimit Out parameter, the index of the first position following the matched text.
+  *                    The matchLimit will be at a suitable position for beginning a subsequent search
+  *                    in the input text.
+  *                    This parameter may be NULL.
+  *                    A value of -1 will be returned if no match was found.
+  *          
+  *  @param status     Report any errors.  Note that no match found is not an error.
+  *  @return           TRUE if a match was found, FALSE otherwise.
+  *
+  *  @internal
+  */
+U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
+                                          int32_t        startIdx,
+                                          int32_t        *matchStart,
+                                          int32_t        *matchLimit,
+                                          UErrorCode     *status);
+
+/**
+  *  Simple backwards search for the pattern, starting at a specified index,
+  *     and using using a default set search options.
+  *
+  *  This is an experimental function, and is not an official part of the
+  *      ICU API.
+  *
+  *  The collator options, such as UCOL_STRENGTH and UCOL_NORMALIZTION, are honored.
+  *
+  *  The UStringSearch options USEARCH_CANONICAL_MATCH, USEARCH_OVERLAP and
+  *  any Break Iterator are ignored.
+  *
+  *  Matches obey the following constraints:
+  *
+  *      Characters at the start or end positions of a match that are ignorable
+  *      for collation are not included as part of the match, unless they
+  *      are part of a combining sequence, as described below.
+  *
+  *      A match will not include a partial combining sequence.  Combining
+  *      character sequences  are considered to be  inseperable units,
+  *      and either match the pattern completely, or are considered to not match
+  *      at all.  Thus, for example, an A followed a combining accent mark will 
+  *      not be found when searching for a plain (unaccented) A.   (unless
+  *      the collation strength has been set to ignore all accents).
+  *
+  *      When beginning a search, the initial starting position, startIdx,
+  *      is assumed to be an acceptable match boundary with respect to
+  *      combining characters.  A combining sequence that spans across the
+  *      starting point will not supress a match beginning at startIdx.
+  *
+  *      Characters that expand to multiple collation elements
+  *      (German sharp-S becoming 'ss', or the composed forms of accented
+  *      characters, for example) also must match completely.
+  *      Searching for a single 's' in a string containing only a sharp-s will 
+  *      find no match.
+  *
+  *
+  *  @param strsrch    the UStringSearch struct, which references both
+  *                    the text to be searched  and the pattern being sought.
+  *  @param startIdx   The index into the text to begin the search.
+  *  @param matchStart An out parameter, the starting index of the matched text.
+  *                    This parameter may be NULL.
+  *                    A value of -1 will be returned if no match was found.
+  *  @param matchLimit Out parameter, the index of the first position following the matched text.
+  *                    The matchLimit will be at a suitable position for beginning a subsequent search
+  *                    in the input text.
+  *                    This parameter may be NULL.
+  *                    A value of -1 will be returned if no match was found.
+  *          
+  *  @param status     Report any errors.  Note that no match found is not an error.
+  *  @return           TRUE if a match was found, FALSE otherwise.
+  *
+  *  @internal
+  */
+U_INTERNAL UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
+                                                   int32_t        startIdx,
+                                                   int32_t        *matchStart,
+                                                   int32_t        *matchLimit,
+                                                   UErrorCode     *status);
+
+#endif /* #if !UCONFIG_NO_COLLATION  && !UCONFIG_NO_BREAK_ITERATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/uset.h b/CoreFoundation/icu/unicode/uset.h
new file mode 100644
index 0000000..8fb09fa
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uset.h
@@ -0,0 +1,1056 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2002-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  uset.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2002mar07
+*   created by: Markus W. Scherer
+*
+*   C version of UnicodeSet.
+*/
+
+
+/**
+ * \file
+ * \brief C API: Unicode Set
+ *
+ * <p>This is a C wrapper around the C++ UnicodeSet class.</p>
+ */
+
+#ifndef __USET_H__
+#define __USET_H__
+
+#include "unicode/utypes.h"
+#include "unicode/uchar.h"
+
+#ifndef UCNV_H
+struct USet;
+/**
+ * A UnicodeSet.  Use the uset_* API to manipulate.  Create with
+ * uset_open*, and destroy with uset_close.
+ * @stable ICU 2.4
+ */
+typedef struct USet USet;
+#endif
+
+/**
+ * Bitmask values to be passed to uset_openPatternOptions() or
+ * uset_applyPattern() taking an option parameter.
+ * @stable ICU 2.4
+ */
+enum {
+    /**
+     * Ignore white space within patterns unless quoted or escaped.
+     * @stable ICU 2.4
+     */
+    USET_IGNORE_SPACE = 1,  
+
+    /**
+     * Enable case insensitive matching.  E.g., "[ab]" with this flag
+     * will match 'a', 'A', 'b', and 'B'.  "[^ab]" with this flag will
+     * match all except 'a', 'A', 'b', and 'B'. This performs a full
+     * closure over case mappings, e.g. U+017F for s.
+     *
+     * The resulting set is a superset of the input for the code points but
+     * not for the strings.
+     * It performs a case mapping closure of the code points and adds
+     * full case folding strings for the code points, and reduces strings of
+     * the original set to their full case folding equivalents.
+     *
+     * This is designed for case-insensitive matches, for example
+     * in regular expressions. The full code point case closure allows checking of
+     * an input character directly against the closure set.
+     * Strings are matched by comparing the case-folded form from the closure
+     * set with an incremental case folding of the string in question.
+     *
+     * The closure set will also contain single code points if the original
+     * set contained case-equivalent strings (like U+00DF for "ss" or "Ss" etc.).
+     * This is not necessary (that is, redundant) for the above matching method
+     * but results in the same closure sets regardless of whether the original
+     * set contained the code point or a string.
+     *
+     * @stable ICU 2.4
+     */
+    USET_CASE_INSENSITIVE = 2,  
+
+    /**
+     * Enable case insensitive matching.  E.g., "[ab]" with this flag
+     * will match 'a', 'A', 'b', and 'B'.  "[^ab]" with this flag will
+     * match all except 'a', 'A', 'b', and 'B'. This adds the lower-,
+     * title-, and uppercase mappings as well as the case folding
+     * of each existing element in the set.
+     * @stable ICU 3.2
+     */
+    USET_ADD_CASE_MAPPINGS = 4,
+    
+    /**
+     * Enough for any single-code point set
+     * @internal
+     */
+    USET_SERIALIZED_STATIC_ARRAY_CAPACITY=8
+};
+
+#ifndef U_HIDE_DRAFT_API
+
+/**
+ * Argument values for whether span() and similar functions continue while
+ * the current character is contained vs. not contained in the set.
+ *
+ * The functionality is straightforward for sets with only single code points,
+ * without strings (which is the common case):
+ * - USET_SPAN_CONTAINED and USET_SPAN_SIMPLE
+ *   work the same.
+ * - span() and spanBack() partition any string the same way when
+ *   alternating between span(USET_SPAN_NOT_CONTAINED) and
+ *   span(either "contained" condition).
+ * - Using a complemented (inverted) set and the opposite span conditions
+ *   yields the same results.
+ *
+ * When a set contains multi-code point strings, then these statements may not
+ * be true, depending on the strings in the set (for example, whether they
+ * overlap with each other) and the string that is processed.
+ * For a set with strings:
+ * - The complement of the set contains the opposite set of code points,
+ *   but the same set of strings.
+ *   Therefore, complementing both the set and the span conditions
+ *   may yield different results.
+ * - When starting spans at different positions in a string
+ *   (span(s, ...) vs. span(s+1, ...)) the ends of the spans may be different
+ *   because a set string may start before the later position.
+ * - span(USET_SPAN_SIMPLE) may be shorter than
+ *   span(USET_SPAN_CONTAINED) because it will not recursively try
+ *   all possible paths.
+ *   For example, with a set which contains the three strings "xy", "xya" and "ax",
+ *   span("xyax", USET_SPAN_CONTAINED) will return 4 but
+ *   span("xyax", USET_SPAN_SIMPLE) will return 3.
+ *   span(USET_SPAN_SIMPLE) will never be longer than
+ *   span(USET_SPAN_CONTAINED).
+ * - With either "contained" condition, span() and spanBack() may partition
+ *   a string in different ways.
+ *   For example, with a set which contains the two strings "ab" and "ba",
+ *   and when processing the string "aba",
+ *   span() will yield contained/not-contained boundaries of { 0, 2, 3 }
+ *   while spanBack() will yield boundaries of { 0, 1, 3 }.
+ *
+ * Note: If it is important to get the same boundaries whether iterating forward
+ * or backward through a string, then either only span() should be used and
+ * the boundaries cached for backward operation, or an ICU BreakIterator
+ * could be used.
+ *
+ * Note: Unpaired surrogates are treated like surrogate code points.
+ * Similarly, set strings match only on code point boundaries,
+ * never in the middle of a surrogate pair.
+ * Illegal UTF-8 sequences are treated like U+FFFD.
+ * When processing UTF-8 strings, malformed set strings
+ * (strings with unpaired surrogates which cannot be converted to UTF-8)
+ * are ignored.
+ *
+ * @stable ICU 4.0
+ */
+typedef enum USetSpanCondition {
+    /**
+     * Continue a span() while there is no set element at the current position.
+     * Stops before the first set element (character or string).
+     * (For code points only, this is like while contains(current)==FALSE).
+     *
+     * When span() returns, the substring between where it started and the position
+     * it returned consists only of characters that are not in the set,
+     * and none of its strings overlap with the span.
+     *
+     * @stable ICU 4.0
+     */
+    USET_SPAN_NOT_CONTAINED = 0,
+    /**
+     * Continue a span() while there is a set element at the current position.
+     * (For characters only, this is like while contains(current)==TRUE).
+     *
+     * When span() returns, the substring between where it started and the position
+     * it returned consists only of set elements (characters or strings) that are in the set.
+     *
+     * If a set contains strings, then the span will be the longest substring
+     * matching any of the possible concatenations of set elements (characters or strings).
+     * (There must be a single, non-overlapping concatenation of characters or strings.)
+     * This is equivalent to a POSIX regular expression for (OR of each set element)*.
+     *
+     * @stable ICU 4.0
+     */
+    USET_SPAN_CONTAINED = 1,
+    /**
+     * Continue a span() while there is a set element at the current position.
+     * (For characters only, this is like while contains(current)==TRUE).
+     *
+     * When span() returns, the substring between where it started and the position
+     * it returned consists only of set elements (characters or strings) that are in the set.
+     *
+     * If a set only contains single characters, then this is the same
+     * as USET_SPAN_CONTAINED.
+     *
+     * If a set contains strings, then the span will be the longest substring
+     * with a match at each position with the longest single set element (character or string).
+     *
+     * Use this span condition together with other longest-match algorithms,
+     * such as ICU converters (ucnv_getUnicodeSet()).
+     *
+     * @stable ICU 4.0
+     */
+    USET_SPAN_SIMPLE = 2,
+    /**
+     * One more than the last span condition.
+     * @stable ICU 4.0
+     */
+    USET_SPAN_CONDITION_COUNT
+} USetSpanCondition;
+
+#endif /* U_HIDE_DRAFT_API */
+
+/**
+ * A serialized form of a Unicode set.  Limited manipulations are
+ * possible directly on a serialized set.  See below.
+ * @stable ICU 2.4
+ */
+typedef struct USerializedSet {
+    /**
+     * The serialized Unicode Set.
+     * @stable ICU 2.4
+     */
+    const uint16_t *array;
+    /**
+     * The length of the array that contains BMP characters.
+     * @stable ICU 2.4
+     */
+    int32_t bmpLength;
+    /**
+     * The total length of the array.
+     * @stable ICU 2.4
+     */
+    int32_t length;
+    /**
+     * A small buffer for the array to reduce memory allocations.
+     * @stable ICU 2.4
+     */
+    uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY];
+} USerializedSet;
+
+/*********************************************************************
+ * USet API
+ *********************************************************************/
+
+/**
+ * Creates a USet object that contains the range of characters
+ * start..end, inclusive.  If <code>start > end</code> 
+ * then an empty set is created.
+ * @param start first character of the range, inclusive
+ * @param end last character of the range, inclusive
+ * @return a newly created USet.  The caller must call uset_close() on
+ * it when done.
+ * @stable ICU 2.4
+ */
+U_STABLE USet* U_EXPORT2
+uset_open(UChar32 start, UChar32 end);
+
+/**
+ * Creates a set from the given pattern.  See the UnicodeSet class
+ * description for the syntax of the pattern language.
+ * @param pattern a string specifying what characters are in the set
+ * @param patternLength the length of the pattern, or -1 if null
+ * terminated
+ * @param ec the error code
+ * @stable ICU 2.4
+ */
+U_STABLE USet* U_EXPORT2
+uset_openPattern(const UChar* pattern, int32_t patternLength,
+                 UErrorCode* ec);
+
+/**
+ * Creates a set from the given pattern.  See the UnicodeSet class
+ * description for the syntax of the pattern language.
+ * @param pattern a string specifying what characters are in the set
+ * @param patternLength the length of the pattern, or -1 if null
+ * terminated
+ * @param options bitmask for options to apply to the pattern.
+ * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
+ * @param ec the error code
+ * @stable ICU 2.4
+ */
+U_STABLE USet* U_EXPORT2
+uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
+                 uint32_t options,
+                 UErrorCode* ec);
+
+/**
+ * Disposes of the storage used by a USet object.  This function should
+ * be called exactly once for objects returned by uset_open().
+ * @param set the object to dispose of
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_close(USet* set);
+
+/**
+ * Returns a copy of this object.
+ * If this set is frozen, then the clone will be frozen as well.
+ * Use uset_cloneAsThawed() for a mutable clone of a frozen set.
+ * @param set the original set
+ * @return the newly allocated copy of the set
+ * @see uset_cloneAsThawed
+ * @stable ICU 4.0
+ */
+U_DRAFT USet * U_EXPORT2
+uset_clone(const USet *set);
+
+/**
+ * Determines whether the set has been frozen (made immutable) or not.
+ * See the ICU4J Freezable interface for details.
+ * @param set the set
+ * @return TRUE/FALSE for whether the set has been frozen
+ * @see uset_freeze
+ * @see uset_cloneAsThawed
+ * @stable ICU 4.0
+ */
+U_DRAFT UBool U_EXPORT2
+uset_isFrozen(const USet *set);
+
+/**
+ * Freeze the set (make it immutable).
+ * Once frozen, it cannot be unfrozen and is therefore thread-safe
+ * until it is deleted.
+ * See the ICU4J Freezable interface for details.
+ * Freezing the set may also make some operations faster, for example
+ * uset_contains() and uset_span().
+ * A frozen set will not be modified. (It remains frozen.)
+ * @param set the set
+ * @return the same set, now frozen
+ * @see uset_isFrozen
+ * @see uset_cloneAsThawed
+ * @stable ICU 4.0
+ */
+U_DRAFT void U_EXPORT2
+uset_freeze(USet *set);
+
+/**
+ * Clone the set and make the clone mutable.
+ * See the ICU4J Freezable interface for details.
+ * @param set the set
+ * @return the mutable clone
+ * @see uset_freeze
+ * @see uset_isFrozen
+ * @see uset_clone
+ * @stable ICU 4.0
+ */
+U_DRAFT USet * U_EXPORT2
+uset_cloneAsThawed(const USet *set);
+
+/**
+ * Causes the USet object to represent the range <code>start - end</code>.
+ * If <code>start > end</code> then this USet is set to an empty range.
+ * A frozen set will not be modified.
+ * @param set the object to set to the given range
+ * @param start first character in the set, inclusive
+ * @param end last character in the set, inclusive
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_set(USet* set,
+         UChar32 start, UChar32 end);
+
+/**
+ * Modifies the set to represent the set specified by the given
+ * pattern. See the UnicodeSet class description for the syntax of 
+ * the pattern language. See also the User Guide chapter about UnicodeSet.
+ * <em>Empties the set passed before applying the pattern.</em>
+ * A frozen set will not be modified.
+ * @param set               The set to which the pattern is to be applied. 
+ * @param pattern           A pointer to UChar string specifying what characters are in the set.
+ *                          The character at pattern[0] must be a '['.
+ * @param patternLength     The length of the UChar string. -1 if NUL terminated.
+ * @param options           A bitmask for options to apply to the pattern.
+ *                          Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.
+ * @param status            Returns an error if the pattern cannot be parsed.
+ * @return                  Upon successful parse, the value is either
+ *                          the index of the character after the closing ']' 
+ *                          of the parsed pattern.
+ *                          If the status code indicates failure, then the return value 
+ *                          is the index of the error in the source.
+ *
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2 
+uset_applyPattern(USet *set,
+                  const UChar *pattern, int32_t patternLength,
+                  uint32_t options,
+                  UErrorCode *status);
+
+/**
+ * Modifies the set to contain those code points which have the given value
+ * for the given binary or enumerated property, as returned by
+ * u_getIntPropertyValue.  Prior contents of this set are lost.
+ * A frozen set will not be modified.
+ *
+ * @param set the object to contain the code points defined by the property
+ *
+ * @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1
+ * or UCHAR_INT_START..UCHAR_INT_LIMIT-1
+ * or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.
+ *
+ * @param value a value in the range u_getIntPropertyMinValue(prop)..
+ * u_getIntPropertyMaxValue(prop), with one exception.  If prop is
+ * UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but
+ * rather a mask value produced by U_GET_GC_MASK().  This allows grouped
+ * categories such as [:L:] to be represented.
+ *
+ * @param ec error code input/output parameter
+ *
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_applyIntPropertyValue(USet* set,
+                           UProperty prop, int32_t value, UErrorCode* ec);
+
+/**
+ * Modifies the set to contain those code points which have the
+ * given value for the given property.  Prior contents of this
+ * set are lost.
+ * A frozen set will not be modified.
+ *
+ * @param set the object to contain the code points defined by the given
+ * property and value alias
+ *
+ * @param prop a string specifying a property alias, either short or long.
+ * The name is matched loosely.  See PropertyAliases.txt for names and a
+ * description of loose matching.  If the value string is empty, then this
+ * string is interpreted as either a General_Category value alias, a Script
+ * value alias, a binary property alias, or a special ID.  Special IDs are
+ * matched loosely and correspond to the following sets:
+ *
+ * "ANY" = [\\u0000-\\U0010FFFF],
+ * "ASCII" = [\\u0000-\\u007F],
+ * "Assigned" = [:^Cn:].
+ *
+ * @param propLength the length of the prop, or -1 if NULL
+ *
+ * @param value a string specifying a value alias, either short or long.
+ * The name is matched loosely.  See PropertyValueAliases.txt for names
+ * and a description of loose matching.  In addition to aliases listed,
+ * numeric values and canonical combining classes may be expressed
+ * numerically, e.g., ("nv", "0.5") or ("ccc", "220").  The value string
+ * may also be empty.
+ *
+ * @param valueLength the length of the value, or -1 if NULL
+ *
+ * @param ec error code input/output parameter
+ *
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_applyPropertyAlias(USet* set,
+                        const UChar *prop, int32_t propLength,
+                        const UChar *value, int32_t valueLength,
+                        UErrorCode* ec);
+
+/**
+ * Return true if the given position, in the given pattern, appears
+ * to be the start of a UnicodeSet pattern.
+ *
+ * @param pattern a string specifying the pattern
+ * @param patternLength the length of the pattern, or -1 if NULL
+ * @param pos the given position
+ * @stable ICU 3.2
+ */
+U_STABLE UBool U_EXPORT2
+uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
+                      int32_t pos);
+
+/**
+ * Returns a string representation of this set.  If the result of
+ * calling this function is passed to a uset_openPattern(), it
+ * will produce another set that is equal to this one.
+ * @param set the set
+ * @param result the string to receive the rules, may be NULL
+ * @param resultCapacity the capacity of result, may be 0 if result is NULL
+ * @param escapeUnprintable if TRUE then convert unprintable
+ * character to their hex escape representations, \\uxxxx or
+ * \\Uxxxxxxxx.  Unprintable characters are those other than
+ * U+000A, U+0020..U+007E.
+ * @param ec error code.
+ * @return length of string, possibly larger than resultCapacity
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t U_EXPORT2
+uset_toPattern(const USet* set,
+               UChar* result, int32_t resultCapacity,
+               UBool escapeUnprintable,
+               UErrorCode* ec);
+
+/**
+ * Adds the given character to the given USet.  After this call,
+ * uset_contains(set, c) will return TRUE.
+ * A frozen set will not be modified.
+ * @param set the object to which to add the character
+ * @param c the character to add
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_add(USet* set, UChar32 c);
+
+/**
+ * Adds all of the elements in the specified set to this set if
+ * they're not already present.  This operation effectively
+ * modifies this set so that its value is the <i>union</i> of the two
+ * sets.  The behavior of this operation is unspecified if the specified
+ * collection is modified while the operation is in progress.
+ * A frozen set will not be modified.
+ *
+ * @param set the object to which to add the set
+ * @param additionalSet the source set whose elements are to be added to this set.
+ * @stable ICU 2.6
+ */
+U_STABLE void U_EXPORT2
+uset_addAll(USet* set, const USet *additionalSet);
+
+/**
+ * Adds the given range of characters to the given USet.  After this call,
+ * uset_contains(set, start, end) will return TRUE.
+ * A frozen set will not be modified.
+ * @param set the object to which to add the character
+ * @param start the first character of the range to add, inclusive
+ * @param end the last character of the range to add, inclusive
+ * @stable ICU 2.2
+ */
+U_STABLE void U_EXPORT2
+uset_addRange(USet* set, UChar32 start, UChar32 end);
+
+/**
+ * Adds the given string to the given USet.  After this call,
+ * uset_containsString(set, str, strLen) will return TRUE.
+ * A frozen set will not be modified.
+ * @param set the object to which to add the character
+ * @param str the string to add
+ * @param strLen the length of the string or -1 if null terminated.
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_addString(USet* set, const UChar* str, int32_t strLen);
+
+/**
+ * Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}
+ * If this set already any particular character, it has no effect on that character.
+ * A frozen set will not be modified.
+ * @param set the object to which to add the character
+ * @param str the source string
+ * @param strLen the length of the string or -1 if null terminated.
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
+
+/**
+ * Removes the given character from the given USet.  After this call,
+ * uset_contains(set, c) will return FALSE.
+ * A frozen set will not be modified.
+ * @param set the object from which to remove the character
+ * @param c the character to remove
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_remove(USet* set, UChar32 c);
+
+/**
+ * Removes the given range of characters from the given USet.  After this call,
+ * uset_contains(set, start, end) will return FALSE.
+ * A frozen set will not be modified.
+ * @param set the object to which to add the character
+ * @param start the first character of the range to remove, inclusive
+ * @param end the last character of the range to remove, inclusive
+ * @stable ICU 2.2
+ */
+U_STABLE void U_EXPORT2
+uset_removeRange(USet* set, UChar32 start, UChar32 end);
+
+/**
+ * Removes the given string to the given USet.  After this call,
+ * uset_containsString(set, str, strLen) will return FALSE.
+ * A frozen set will not be modified.
+ * @param set the object to which to add the character
+ * @param str the string to remove
+ * @param strLen the length of the string or -1 if null terminated.
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_removeString(USet* set, const UChar* str, int32_t strLen);
+
+/**
+ * Removes from this set all of its elements that are contained in the
+ * specified set.  This operation effectively modifies this
+ * set so that its value is the <i>asymmetric set difference</i> of
+ * the two sets.
+ * A frozen set will not be modified.
+ * @param set the object from which the elements are to be removed
+ * @param removeSet the object that defines which elements will be
+ * removed from this set
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_removeAll(USet* set, const USet* removeSet);
+
+/**
+ * Retain only the elements in this set that are contained in the
+ * specified range.  If <code>start > end</code> then an empty range is
+ * retained, leaving the set empty.  This is equivalent to
+ * a boolean logic AND, or a set INTERSECTION.
+ * A frozen set will not be modified.
+ *
+ * @param set the object for which to retain only the specified range
+ * @param start first character, inclusive, of range to be retained
+ * to this set.
+ * @param end last character, inclusive, of range to be retained
+ * to this set.
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_retain(USet* set, UChar32 start, UChar32 end);
+
+/**
+ * Retains only the elements in this set that are contained in the
+ * specified set.  In other words, removes from this set all of
+ * its elements that are not contained in the specified set.  This
+ * operation effectively modifies this set so that its value is
+ * the <i>intersection</i> of the two sets.
+ * A frozen set will not be modified.
+ *
+ * @param set the object on which to perform the retain
+ * @param retain set that defines which elements this set will retain
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_retainAll(USet* set, const USet* retain);
+
+/**
+ * Reallocate this objects internal structures to take up the least
+ * possible space, without changing this object's value.
+ * A frozen set will not be modified.
+ *
+ * @param set the object on which to perfrom the compact
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_compact(USet* set);
+
+/**
+ * Inverts this set.  This operation modifies this set so that
+ * its value is its complement.  This operation does not affect
+ * the multicharacter strings, if any.
+ * A frozen set will not be modified.
+ * @param set the set
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_complement(USet* set);
+
+/**
+ * Complements in this set all elements contained in the specified
+ * set.  Any character in the other set will be removed if it is
+ * in this set, or will be added if it is not in this set.
+ * A frozen set will not be modified.
+ *
+ * @param set the set with which to complement
+ * @param complement set that defines which elements will be xor'ed
+ * from this set.
+ * @stable ICU 3.2
+ */
+U_STABLE void U_EXPORT2
+uset_complementAll(USet* set, const USet* complement);
+
+/**
+ * Removes all of the elements from this set.  This set will be
+ * empty after this call returns.
+ * A frozen set will not be modified.
+ * @param set the set
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_clear(USet* set);
+
+/**
+ * Returns TRUE if the given USet contains no characters and no
+ * strings.
+ * @param set the set
+ * @return true if set is empty
+ * @stable ICU 2.4
+ */
+U_STABLE UBool U_EXPORT2
+uset_isEmpty(const USet* set);
+
+/**
+ * Returns TRUE if the given USet contains the given character.
+ * This function works faster with a frozen set.
+ * @param set the set
+ * @param c The codepoint to check for within the set
+ * @return true if set contains c
+ * @stable ICU 2.4
+ */
+U_STABLE UBool U_EXPORT2
+uset_contains(const USet* set, UChar32 c);
+
+/**
+ * Returns TRUE if the given USet contains all characters c
+ * where start <= c && c <= end.
+ * @param set the set
+ * @param start the first character of the range to test, inclusive
+ * @param end the last character of the range to test, inclusive
+ * @return TRUE if set contains the range
+ * @stable ICU 2.2
+ */
+U_STABLE UBool U_EXPORT2
+uset_containsRange(const USet* set, UChar32 start, UChar32 end);
+
+/**
+ * Returns TRUE if the given USet contains the given string.
+ * @param set the set
+ * @param str the string
+ * @param strLen the length of the string or -1 if null terminated.
+ * @return true if set contains str
+ * @stable ICU 2.4
+ */
+U_STABLE UBool U_EXPORT2
+uset_containsString(const USet* set, const UChar* str, int32_t strLen);
+
+/**
+ * Returns the index of the given character within this set, where
+ * the set is ordered by ascending code point.  If the character
+ * is not in this set, return -1.  The inverse of this method is
+ * <code>charAt()</code>.
+ * @param set the set
+ * @param c the character to obtain the index for
+ * @return an index from 0..size()-1, or -1
+ * @stable ICU 3.2
+ */
+U_STABLE int32_t U_EXPORT2
+uset_indexOf(const USet* set, UChar32 c);
+
+/**
+ * Returns the character at the given index within this set, where
+ * the set is ordered by ascending code point.  If the index is
+ * out of range, return (UChar32)-1.  The inverse of this method is
+ * <code>indexOf()</code>.
+ * @param set the set
+ * @param index an index from 0..size()-1 to obtain the char for
+ * @return the character at the given index, or (UChar32)-1.
+ * @stable ICU 3.2
+ */
+U_STABLE UChar32 U_EXPORT2
+uset_charAt(const USet* set, int32_t index);
+
+/**
+ * Returns the number of characters and strings contained in the given
+ * USet.
+ * @param set the set
+ * @return a non-negative integer counting the characters and strings
+ * contained in set
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t U_EXPORT2
+uset_size(const USet* set);
+
+/**
+ * Returns the number of items in this set.  An item is either a range
+ * of characters or a single multicharacter string.
+ * @param set the set
+ * @return a non-negative integer counting the character ranges
+ * and/or strings contained in set
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t U_EXPORT2
+uset_getItemCount(const USet* set);
+
+/**
+ * Returns an item of this set.  An item is either a range of
+ * characters or a single multicharacter string.
+ * @param set the set
+ * @param itemIndex a non-negative integer in the range 0..
+ * uset_getItemCount(set)-1
+ * @param start pointer to variable to receive first character
+ * in range, inclusive
+ * @param end pointer to variable to receive last character in range,
+ * inclusive
+ * @param str buffer to receive the string, may be NULL
+ * @param strCapacity capacity of str, or 0 if str is NULL
+ * @param ec error code
+ * @return the length of the string (>= 2), or 0 if the item is a
+ * range, in which case it is the range *start..*end, or -1 if
+ * itemIndex is out of range
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t U_EXPORT2
+uset_getItem(const USet* set, int32_t itemIndex,
+             UChar32* start, UChar32* end,
+             UChar* str, int32_t strCapacity,
+             UErrorCode* ec);
+
+/**
+ * Returns true if set1 contains all the characters and strings
+ * of set2. It answers the question, 'Is set1 a superset of set2?'
+ * @param set1 set to be checked for containment
+ * @param set2 set to be checked for containment
+ * @return true if the test condition is met
+ * @stable ICU 3.2
+ */
+U_STABLE UBool U_EXPORT2
+uset_containsAll(const USet* set1, const USet* set2);
+
+/**
+ * Returns true if this set contains all the characters
+ * of the given string. This is does not check containment of grapheme
+ * clusters, like uset_containsString.
+ * @param set set of characters to be checked for containment
+ * @param str string containing codepoints to be checked for containment
+ * @param strLen the length of the string or -1 if null terminated.
+ * @return true if the test condition is met
+ * @stable ICU 3.4
+ */
+U_STABLE UBool U_EXPORT2
+uset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);
+
+/**
+ * Returns true if set1 contains none of the characters and strings
+ * of set2. It answers the question, 'Is set1 a disjoint set of set2?'
+ * @param set1 set to be checked for containment
+ * @param set2 set to be checked for containment
+ * @return true if the test condition is met
+ * @stable ICU 3.2
+ */
+U_STABLE UBool U_EXPORT2
+uset_containsNone(const USet* set1, const USet* set2);
+
+/**
+ * Returns true if set1 contains some of the characters and strings
+ * of set2. It answers the question, 'Does set1 and set2 have an intersection?'
+ * @param set1 set to be checked for containment
+ * @param set2 set to be checked for containment
+ * @return true if the test condition is met
+ * @stable ICU 3.2
+ */
+U_STABLE UBool U_EXPORT2
+uset_containsSome(const USet* set1, const USet* set2);
+
+/**
+ * Returns the length of the initial substring of the input string which
+ * consists only of characters and strings that are contained in this set
+ * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+ * or only of characters and strings that are not contained
+ * in this set (USET_SPAN_NOT_CONTAINED).
+ * See USetSpanCondition for details.
+ * Similar to the strspn() C library function.
+ * Unpaired surrogates are treated according to contains() of their surrogate code points.
+ * This function works faster with a frozen set and with a non-negative string length argument.
+ * @param set the set
+ * @param s start of the string
+ * @param length of the string; can be -1 for NUL-terminated
+ * @param spanCondition specifies the containment condition
+ * @return the length of the initial substring according to the spanCondition;
+ *         0 if the start of the string does not fit the spanCondition
+ * @stable ICU 4.0
+ * @see USetSpanCondition
+ */
+U_DRAFT int32_t U_EXPORT2
+uset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
+
+/**
+ * Returns the start of the trailing substring of the input string which
+ * consists only of characters and strings that are contained in this set
+ * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+ * or only of characters and strings that are not contained
+ * in this set (USET_SPAN_NOT_CONTAINED).
+ * See USetSpanCondition for details.
+ * Unpaired surrogates are treated according to contains() of their surrogate code points.
+ * This function works faster with a frozen set and with a non-negative string length argument.
+ * @param set the set
+ * @param s start of the string
+ * @param length of the string; can be -1 for NUL-terminated
+ * @param spanCondition specifies the containment condition
+ * @return the start of the trailing substring according to the spanCondition;
+ *         the string length if the end of the string does not fit the spanCondition
+ * @stable ICU 4.0
+ * @see USetSpanCondition
+ */
+U_DRAFT int32_t U_EXPORT2
+uset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);
+
+/**
+ * Returns the length of the initial substring of the input string which
+ * consists only of characters and strings that are contained in this set
+ * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+ * or only of characters and strings that are not contained
+ * in this set (USET_SPAN_NOT_CONTAINED).
+ * See USetSpanCondition for details.
+ * Similar to the strspn() C library function.
+ * Malformed byte sequences are treated according to contains(0xfffd).
+ * This function works faster with a frozen set and with a non-negative string length argument.
+ * @param set the set
+ * @param s start of the string (UTF-8)
+ * @param length of the string; can be -1 for NUL-terminated
+ * @param spanCondition specifies the containment condition
+ * @return the length of the initial substring according to the spanCondition;
+ *         0 if the start of the string does not fit the spanCondition
+ * @stable ICU 4.0
+ * @see USetSpanCondition
+ */
+U_DRAFT int32_t U_EXPORT2
+uset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
+
+/**
+ * Returns the start of the trailing substring of the input string which
+ * consists only of characters and strings that are contained in this set
+ * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),
+ * or only of characters and strings that are not contained
+ * in this set (USET_SPAN_NOT_CONTAINED).
+ * See USetSpanCondition for details.
+ * Malformed byte sequences are treated according to contains(0xfffd).
+ * This function works faster with a frozen set and with a non-negative string length argument.
+ * @param set the set
+ * @param s start of the string (UTF-8)
+ * @param length of the string; can be -1 for NUL-terminated
+ * @param spanCondition specifies the containment condition
+ * @return the start of the trailing substring according to the spanCondition;
+ *         the string length if the end of the string does not fit the spanCondition
+ * @stable ICU 4.0
+ * @see USetSpanCondition
+ */
+U_DRAFT int32_t U_EXPORT2
+uset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);
+
+/**
+ * Returns true if set1 contains all of the characters and strings
+ * of set2, and vis versa. It answers the question, 'Is set1 equal to set2?'
+ * @param set1 set to be checked for containment
+ * @param set2 set to be checked for containment
+ * @return true if the test condition is met
+ * @stable ICU 3.2
+ */
+U_STABLE UBool U_EXPORT2
+uset_equals(const USet* set1, const USet* set2);
+
+/*********************************************************************
+ * Serialized set API
+ *********************************************************************/
+
+/**
+ * Serializes this set into an array of 16-bit integers.  Serialization
+ * (currently) only records the characters in the set; multicharacter
+ * strings are ignored.
+ *
+ * The array
+ * has following format (each line is one 16-bit integer):
+ *
+ *  length     = (n+2*m) | (m!=0?0x8000:0)
+ *  bmpLength  = n; present if m!=0
+ *  bmp[0]
+ *  bmp[1]
+ *  ...
+ *  bmp[n-1]
+ *  supp-high[0]
+ *  supp-low[0]
+ *  supp-high[1]
+ *  supp-low[1]
+ *  ...
+ *  supp-high[m-1]
+ *  supp-low[m-1]
+ *
+ * The array starts with a header.  After the header are n bmp
+ * code points, then m supplementary code points.  Either n or m
+ * or both may be zero.  n+2*m is always <= 0x7FFF.
+ *
+ * If there are no supplementary characters (if m==0) then the
+ * header is one 16-bit integer, 'length', with value n.
+ *
+ * If there are supplementary characters (if m!=0) then the header
+ * is two 16-bit integers.  The first, 'length', has value
+ * (n+2*m)|0x8000.  The second, 'bmpLength', has value n.
+ *
+ * After the header the code points are stored in ascending order.
+ * Supplementary code points are stored as most significant 16
+ * bits followed by least significant 16 bits.
+ *
+ * @param set the set
+ * @param dest pointer to buffer of destCapacity 16-bit integers.
+ * May be NULL only if destCapacity is zero.
+ * @param destCapacity size of dest, or zero.  Must not be negative.
+ * @param pErrorCode pointer to the error code.  Will be set to
+ * U_INDEX_OUTOFBOUNDS_ERROR if n+2*m > 0x7FFF.  Will be set to
+ * U_BUFFER_OVERFLOW_ERROR if n+2*m+(m!=0?2:1) > destCapacity.
+ * @return the total length of the serialized format, including
+ * the header, that is, n+2*m+(m!=0?2:1), or 0 on error other
+ * than U_BUFFER_OVERFLOW_ERROR.
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t U_EXPORT2
+uset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);
+
+/**
+ * Given a serialized array, fill in the given serialized set object.
+ * @param fillSet pointer to result
+ * @param src pointer to start of array
+ * @param srcLength length of array
+ * @return true if the given array is valid, otherwise false
+ * @stable ICU 2.4
+ */
+U_STABLE UBool U_EXPORT2
+uset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);
+
+/**
+ * Set the USerializedSet to contain the given character (and nothing
+ * else).
+ * @param fillSet pointer to result
+ * @param c The codepoint to set
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+uset_setSerializedToOne(USerializedSet* fillSet, UChar32 c);
+
+/**
+ * Returns TRUE if the given USerializedSet contains the given
+ * character.
+ * @param set the serialized set
+ * @param c The codepoint to check for within the set
+ * @return true if set contains c
+ * @stable ICU 2.4
+ */
+U_STABLE UBool U_EXPORT2
+uset_serializedContains(const USerializedSet* set, UChar32 c);
+
+/**
+ * Returns the number of disjoint ranges of characters contained in
+ * the given serialized set.  Ignores any strings contained in the
+ * set.
+ * @param set the serialized set
+ * @return a non-negative integer counting the character ranges
+ * contained in set
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t U_EXPORT2
+uset_getSerializedRangeCount(const USerializedSet* set);
+
+/**
+ * Returns a range of characters contained in the given serialized
+ * set.
+ * @param set the serialized set
+ * @param rangeIndex a non-negative integer in the range 0..
+ * uset_getSerializedRangeCount(set)-1
+ * @param pStart pointer to variable to receive first character
+ * in range, inclusive
+ * @param pEnd pointer to variable to receive last character in range,
+ * inclusive
+ * @return true if rangeIndex is valid, otherwise false
+ * @stable ICU 2.4
+ */
+U_STABLE UBool U_EXPORT2
+uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,
+                        UChar32* pStart, UChar32* pEnd);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/usetiter.h b/CoreFoundation/icu/unicode/usetiter.h
new file mode 100644
index 0000000..defa75c
--- /dev/null
+++ b/CoreFoundation/icu/unicode/usetiter.h
@@ -0,0 +1,318 @@
+/*
+**********************************************************************
+* Copyright (c) 2002-2006, International Business Machines
+* Corporation and others.  All Rights Reserved.
+**********************************************************************
+*/
+#ifndef USETITER_H
+#define USETITER_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+
+/**
+ * \file 
+ * \brief C++ API: UnicodeSetIterator iterates over the contents of a UnicodeSet.
+ */
+
+U_NAMESPACE_BEGIN
+
+class UnicodeSet;
+class UnicodeString;
+
+/**
+ *
+ * UnicodeSetIterator iterates over the contents of a UnicodeSet.  It
+ * iterates over either code points or code point ranges.  After all
+ * code points or ranges have been returned, it returns the
+ * multicharacter strings of the UnicodSet, if any.
+ *
+ * This class is not intended to be subclassed.  Consider any fields
+ *  or methods declared as "protected" to be private.  The use of
+ *  protected in this class is an artifact of history.
+ *
+ * <p>To iterate over code points and strings, use a loop like this:
+ * <pre>
+ * UnicodeSetIterator it(set);
+ * while (set.next()) {
+ *     processItem(set.getString());
+ * }
+ * </pre>
+ * <p>Each item in the set is accessed as a string.  Set elements
+ *    consisting of single code points are returned as strings containing
+ *    just the one code point.
+ *
+ * <p>To iterate over code point ranges, instead of individual code points,
+ *    use a loop like this:
+ * <pre>
+ * UnicodeSetIterator it(set);
+ * while (it.nextRange()) {
+ *   if (it.isString()) {
+ *     processString(it.getString());
+ *   } else {
+ *     processCodepointRange(it.getCodepoint(), it.getCodepointEnd());
+ *   }
+ * }
+ * </pre>
+ * @author M. Davis
+ * @stable ICU 2.4
+ */
+class U_COMMON_API UnicodeSetIterator : public UObject {
+
+ protected:
+
+    /**
+     * Value of <tt>codepoint</tt> if the iterator points to a string.
+     * If <tt>codepoint == IS_STRING</tt>, then examine
+     * <tt>string</tt> for the current iteration result.
+     * @stable ICU 2.4
+     */
+    enum { IS_STRING = -1 };
+
+    /**
+     * Current code point, or the special value <tt>IS_STRING</tt>, if
+     * the iterator points to a string.
+     * @stable ICU 2.4
+     */
+    UChar32 codepoint;
+
+    /**
+     * When iterating over ranges using <tt>nextRange()</tt>,
+     * <tt>codepointEnd</tt> contains the inclusive end of the
+     * iteration range, if <tt>codepoint != IS_STRING</tt>.  If
+     * iterating over code points using <tt>next()</tt>, or if
+     * <tt>codepoint == IS_STRING</tt>, then the value of
+     * <tt>codepointEnd</tt> is undefined.
+     * @stable ICU 2.4
+     */
+    UChar32 codepointEnd;
+
+    /**
+     * If <tt>codepoint == IS_STRING</tt>, then <tt>string</tt> points
+     * to the current string.  If <tt>codepoint != IS_STRING</tt>, the
+     * value of <tt>string</tt> is undefined.
+     * @stable ICU 2.4
+     */
+    const UnicodeString* string;
+
+ public:
+
+    /**
+     * Create an iterator over the given set.  The iterator is valid
+     * only so long as <tt>set</tt> is valid.
+     * @param set set to iterate over
+     * @stable ICU 2.4
+     */
+    UnicodeSetIterator(const UnicodeSet& set);
+
+    /**
+     * Create an iterator over nothing.  <tt>next()</tt> and
+     * <tt>nextRange()</tt> return false. This is a convenience
+     * constructor allowing the target to be set later.
+     * @stable ICU 2.4
+     */
+    UnicodeSetIterator();
+
+    /**
+     * Destructor.
+     * @stable ICU 2.4
+     */
+    virtual ~UnicodeSetIterator();
+
+    /**
+     * Returns true if the current element is a string.  If so, the
+     * caller can retrieve it with <tt>getString()</tt>.  If this
+     * method returns false, the current element is a code point or
+     * code point range, depending on whether <tt>next()</tt> or
+     * <tt>nextRange()</tt> was called.
+     * Elements of types string and codepoint can both be retrieved
+     * with the function <tt>getString()</tt>.
+     * Elements of type codepoint can also be retrieved with
+     * <tt>getCodepoint()</tt>.
+     * For ranges, <tt>getCodepoint()</tt> returns the starting codepoint
+     * of the range, and <tt>getCodepointEnd()</tt> returns the end
+     * of the range.
+     * @stable ICU 2.4
+     */
+    inline UBool isString() const;
+
+    /**
+     * Returns the current code point, if <tt>isString()</tt> returned
+     * false.  Otherwise returns an undefined result.
+     * @stable ICU 2.4
+     */
+    inline UChar32 getCodepoint() const;
+
+    /**
+     * Returns the end of the current code point range, if
+     * <tt>isString()</tt> returned false and <tt>nextRange()</tt> was
+     * called.  Otherwise returns an undefined result.
+     * @stable ICU 2.4
+     */
+    inline UChar32 getCodepointEnd() const;
+
+    /**
+     * Returns the current string, if <tt>isString()</tt> returned
+     * true.  If the current iteration item is a code point, a UnicodeString
+     * containing that single code point is returned.
+     *
+     * Ownership of the returned string remains with the iterator.
+     * The string is guaranteed to remain valid only until the iterator is
+     *   advanced to the next item, or until the iterator is deleted.
+     * 
+     * @stable ICU 2.4
+     */
+    const UnicodeString& getString();
+
+    /**
+     * Advances the iteration position to the next element in the set, 
+     * which can be either a single code point or a string.  
+     * If there are no more elements in the set, return false.
+     *
+     * <p>
+     * If <tt>isString() == TRUE</tt>, the value is a
+     * string, otherwise the value is a
+     * single code point.  Elements of either type can be retrieved
+     * with the function <tt>getString()</tt>, while elements of
+     * consisting of a single code point can be retrieved with
+     * <tt>getCodepoint()</tt>
+     *
+     * <p>The order of iteration is all code points in sorted order,
+     * followed by all strings sorted order.    Do not mix
+     * calls to <tt>next()</tt> and <tt>nextRange()</tt> without
+     * calling <tt>reset()</tt> between them.  The results of doing so
+     * are undefined.
+     *
+     * @return true if there was another element in the set.
+     * @stable ICU 2.4
+     */
+    UBool next();
+
+    /**
+     * Returns the next element in the set, either a code point range
+     * or a string.  If there are no more elements in the set, return
+     * false.  If <tt>isString() == TRUE</tt>, the value is a
+     * string and can be accessed with <tt>getString()</tt>.  Otherwise the value is a
+     * range of one or more code points from <tt>getCodepoint()</tt> to
+     * <tt>getCodepointeEnd()</tt> inclusive.
+     *
+     * <p>The order of iteration is all code points ranges in sorted
+     * order, followed by all strings sorted order.  Ranges are
+     * disjoint and non-contiguous.  The value returned from <tt>getString()</tt>
+     * is undefined unless <tt>isString() == TRUE</tt>.  Do not mix calls to
+     * <tt>next()</tt> and <tt>nextRange()</tt> without calling
+     * <tt>reset()</tt> between them.  The results of doing so are
+     * undefined.
+     *
+     * @return true if there was another element in the set.
+     * @stable ICU 2.4
+     */
+    UBool nextRange();
+
+    /**
+     * Sets this iterator to visit the elements of the given set and
+     * resets it to the start of that set.  The iterator is valid only
+     * so long as <tt>set</tt> is valid.
+     * @param set the set to iterate over.
+     * @stable ICU 2.4
+     */
+    void reset(const UnicodeSet& set);
+
+    /**
+     * Resets this iterator to the start of the set.
+     * @stable ICU 2.4
+     */
+    void reset();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.4
+     */
+    static UClassID U_EXPORT2 getStaticClassID();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.4
+     */
+    virtual UClassID getDynamicClassID() const;
+
+    // ======================= PRIVATES ===========================
+
+ protected:
+
+    // endElement and nextElements are really UChar32's, but we keep
+    // them as signed int32_t's so we can do comparisons with
+    // endElement set to -1.  Leave them as int32_t's.
+    /** The set
+     * @stable ICU 2.4
+     */
+    const UnicodeSet* set;
+    /** End range
+     * @stable ICU 2.4
+     */
+    int32_t endRange;
+    /** Range
+     * @stable ICU 2.4
+     */
+    int32_t range;
+    /** End element
+     * @stable ICU 2.4
+     */
+    int32_t endElement;
+    /** Next element
+     * @stable ICU 2.4
+     */
+    int32_t nextElement;
+    //UBool abbreviated;
+    /** Next string
+     * @stable ICU 2.4
+     */
+    int32_t nextString;
+    /** String count
+     * @stable ICU 2.4
+     */
+    int32_t stringCount;
+
+    /**
+     *  Points to the string to use when the caller asks for a
+     *  string and the current iteration item is a code point, not a string.
+     *  @internal
+     */
+    UnicodeString *cpString;
+
+    /** Copy constructor. Disallowed.
+     * @stable ICU 2.4
+     */
+    UnicodeSetIterator(const UnicodeSetIterator&); // disallow
+
+    /** Assignment operator. Disallowed.
+     * @stable ICU 2.4
+     */
+    UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow
+
+    /** Load range
+     * @stable ICU 2.4
+     */
+    virtual void loadRange(int32_t range);
+
+};
+
+inline UBool UnicodeSetIterator::isString() const {
+    return codepoint == (UChar32)IS_STRING;
+}
+
+inline UChar32 UnicodeSetIterator::getCodepoint() const {
+    return codepoint;
+}
+
+inline UChar32 UnicodeSetIterator::getCodepointEnd() const {
+    return codepointEnd;
+}
+
+
+U_NAMESPACE_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ushape.h b/CoreFoundation/icu/unicode/ushape.h
new file mode 100644
index 0000000..f165e14
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ushape.h
@@ -0,0 +1,263 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 2000-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*   file name:  ushape.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2000jun29
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __USHAPE_H__
+#define __USHAPE_H__
+
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C API:  Arabic shaping
+ * 
+ */
+
+/**
+ * Shape Arabic text on a character basis.
+ *
+ * <p>This function performs basic operations for "shaping" Arabic text. It is most
+ * useful for use with legacy data formats and legacy display technology
+ * (simple terminals). All operations are performed on Unicode characters.</p>
+ *
+ * <p>Text-based shaping means that some character code points in the text are
+ * replaced by others depending on the context. It transforms one kind of text
+ * into another. In comparison, modern displays for Arabic text select
+ * appropriate, context-dependent font glyphs for each text element, which means
+ * that they transform text into a glyph vector.</p>
+ *
+ * <p>Text transformations are necessary when modern display technology is not
+ * available or when text needs to be transformed to or from legacy formats that
+ * use "shaped" characters. Since the Arabic script is cursive, connecting
+ * adjacent letters to each other, computers select images for each letter based
+ * on the surrounding letters. This usually results in four images per Arabic
+ * letter: initial, middle, final, and isolated forms. In Unicode, on the other
+ * hand, letters are normally stored abstract, and a display system is expected
+ * to select the necessary glyphs. (This makes searching and other text
+ * processing easier because the same letter has only one code.) It is possible
+ * to mimic this with text transformations because there are characters in
+ * Unicode that are rendered as letters with a specific shape
+ * (or cursive connectivity). They were included for interoperability with
+ * legacy systems and codepages, and for unsophisticated display systems.</p>
+ *
+ * <p>A second kind of text transformations is supported for Arabic digits:
+ * For compatibility with legacy codepages that only include European digits,
+ * it is possible to replace one set of digits by another, changing the
+ * character code points. These operations can be performed for either
+ * Arabic-Indic Digits (U+0660...U+0669) or Eastern (Extended) Arabic-Indic
+ * digits (U+06f0...U+06f9).</p>
+ *
+ * <p>Some replacements may result in more or fewer characters (code points).
+ * By default, this means that the destination buffer may receive text with a
+ * length different from the source length. Some legacy systems rely on the
+ * length of the text to be constant. They expect extra spaces to be added
+ * or consumed either next to the affected character or at the end of the
+ * text.</p>
+ *
+ * <p>For details about the available operations, see the description of the
+ * <code>U_SHAPE_...</code> options.</p>
+ *
+ * @param source The input text.
+ *
+ * @param sourceLength The number of UChars in <code>source</code>.
+ *
+ * @param dest The destination buffer that will receive the results of the
+ *             requested operations. It may be <code>NULL</code> only if
+ *             <code>destSize</code> is 0. The source and destination must not
+ *             overlap.
+ *
+ * @param destSize The size (capacity) of the destination buffer in UChars.
+ *                 If <code>destSize</code> is 0, then no output is produced,
+ *                 but the necessary buffer size is returned ("preflighting").
+ *
+ * @param options This is a 32-bit set of flags that specify the operations
+ *                that are performed on the input text. If no error occurs,
+ *                then the result will always be written to the destination
+ *                buffer.
+ *
+ * @param pErrorCode must be a valid pointer to an error code value,
+ *        which must not indicate a failure before the function call.
+ *
+ * @return The number of UChars written to the destination buffer.
+ *         If an error occured, then no output was written, or it may be
+ *         incomplete. If <code>U_BUFFER_OVERFLOW_ERROR</code> is set, then
+ *         the return value indicates the necessary destination buffer size.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_shapeArabic(const UChar *source, int32_t sourceLength,
+              UChar *dest, int32_t destSize,
+              uint32_t options,
+              UErrorCode *pErrorCode);
+
+/**
+ * Memory option: allow the result to have a different length than the source.
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_LENGTH_GROW_SHRINK              0
+
+/**
+ * Memory option: the result must have the same length as the source.
+ * If more room is necessary, then try to consume spaces next to modified characters.
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_LENGTH_FIXED_SPACES_NEAR        1
+
+/**
+ * Memory option: the result must have the same length as the source.
+ * If more room is necessary, then try to consume spaces at the end of the text.
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_LENGTH_FIXED_SPACES_AT_END      2
+
+/**
+ * Memory option: the result must have the same length as the source.
+ * If more room is necessary, then try to consume spaces at the beginning of the text.
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING 3
+
+/** Bit mask for memory options. @stable ICU 2.0 */
+#define U_SHAPE_LENGTH_MASK                     3
+
+
+/** Direction indicator: the source is in logical (keyboard) order. @stable ICU 2.0 */
+#define U_SHAPE_TEXT_DIRECTION_LOGICAL          0
+
+/**
+ * Direction indicator:
+ * the source is in visual LTR order,
+ * the leftmost displayed character stored first.
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_TEXT_DIRECTION_VISUAL_LTR       4
+
+/** Bit mask for direction indicators. @stable ICU 2.0 */
+#define U_SHAPE_TEXT_DIRECTION_MASK             4
+
+
+/** Letter shaping option: do not perform letter shaping. @stable ICU 2.0 */
+#define U_SHAPE_LETTERS_NOOP                    0
+
+/** Letter shaping option: replace abstract letter characters by "shaped" ones. @stable ICU 2.0 */
+#define U_SHAPE_LETTERS_SHAPE                   8
+
+/** Letter shaping option: replace "shaped" letter characters by abstract ones. @stable ICU 2.0 */
+#define U_SHAPE_LETTERS_UNSHAPE                 0x10
+
+/**
+ * Letter shaping option: replace abstract letter characters by "shaped" ones.
+ * The only difference with U_SHAPE_LETTERS_SHAPE is that Tashkeel letters
+ * are always "shaped" into the isolated form instead of the medial form
+ * (selecting code points from the Arabic Presentation Forms-B block).
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED 0x18
+
+/** Bit mask for letter shaping options. @stable ICU 2.0 */
+#define U_SHAPE_LETTERS_MASK                    0x18
+
+
+/** Digit shaping option: do not perform digit shaping. @stable ICU 2.0 */
+#define U_SHAPE_DIGITS_NOOP                     0
+
+/**
+ * Digit shaping option:
+ * Replace European digits (U+0030...) by Arabic-Indic digits.
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_DIGITS_EN2AN                    0x20
+
+/**
+ * Digit shaping option:
+ * Replace Arabic-Indic digits by European digits (U+0030...).
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_DIGITS_AN2EN                    0x40
+
+/**
+ * Digit shaping option:
+ * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent
+ * strongly directional character is an Arabic letter
+ * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>
+ * The direction of "preceding" depends on the direction indicator option.
+ * For the first characters, the preceding strongly directional character
+ * (initial state) is assumed to be not an Arabic letter
+ * (it is <code>U_LEFT_TO_RIGHT</code> [L] or <code>U_RIGHT_TO_LEFT</code> [R]).
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_DIGITS_ALEN2AN_INIT_LR          0x60
+
+/**
+ * Digit shaping option:
+ * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent
+ * strongly directional character is an Arabic letter
+ * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>
+ * The direction of "preceding" depends on the direction indicator option.
+ * For the first characters, the preceding strongly directional character
+ * (initial state) is assumed to be an Arabic letter.
+ * @stable ICU 2.0
+ */
+#define U_SHAPE_DIGITS_ALEN2AN_INIT_AL          0x80
+
+/** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */
+#define U_SHAPE_DIGITS_RESERVED                 0xa0
+
+/** Bit mask for digit shaping options. @stable ICU 2.0 */
+#define U_SHAPE_DIGITS_MASK                     0xe0
+
+
+/** Digit type option: Use Arabic-Indic digits (U+0660...U+0669). @stable ICU 2.0 */
+#define U_SHAPE_DIGIT_TYPE_AN                   0
+
+/** Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9). @stable ICU 2.0 */
+#define U_SHAPE_DIGIT_TYPE_AN_EXTENDED          0x100
+
+/** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */
+#define U_SHAPE_DIGIT_TYPE_RESERVED             0x200
+
+/** Bit mask for digit type options. @stable ICU 2.0 */
+#define U_SHAPE_DIGIT_TYPE_MASK                 0x3f00
+
+/** 
+ * Tashkeel aggregation option:
+ * Replaces any combination of U+0651 with one of
+ * U+064C, U+064D, U+064E, U+064F, U+0650 with
+ * U+FC5E, U+FC5F, U+FC60, U+FC61, U+FC62 consecutively.
+ * @stable ICU 3.6
+ */
+#define U_SHAPE_AGGREGATE_TASHKEEL              0x4000
+/** Tashkeel aggregation option: do not aggregate tashkeels. @stable ICU 3.6 */
+#define U_SHAPE_AGGREGATE_TASHKEEL_NOOP         0
+/** Bit mask for tashkeel aggregation. @stable ICU 3.6 */
+#define U_SHAPE_AGGREGATE_TASHKEEL_MASK         0x4000
+
+/** 
+ * Presentation form option:
+ * Don't replace Arabic Presentation Forms-A and Arabic Presentation Forms-B
+ * characters with 0+06xx characters, before shaping.
+ * @stable ICU 3.6
+ */
+#define U_SHAPE_PRESERVE_PRESENTATION           0x8000
+/** Presentation form option: 
+ * Replace Arabic Presentation Forms-A and Arabic Presentationo Forms-B with 
+ * their unshaped correspondants in range 0+06xx, before shaping.
+ * @stable ICU 3.6 
+ */
+#define U_SHAPE_PRESERVE_PRESENTATION_NOOP      0
+/** Bit mask for preserve presentation form. @stable ICU 3.6 */
+#define U_SHAPE_PRESERVE_PRESENTATION_MASK      0x8000
+
+#endif
diff --git a/CoreFoundation/icu/unicode/usprep.h b/CoreFoundation/icu/unicode/usprep.h
new file mode 100644
index 0000000..c7e75a5
--- /dev/null
+++ b/CoreFoundation/icu/unicode/usprep.h
@@ -0,0 +1,156 @@
+/*
+ *******************************************************************************
+ *
+ *   Copyright (C) 2003-2006, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ *
+ *******************************************************************************
+ *   file name:  usprep.h
+ *   encoding:   US-ASCII
+ *   tab size:   8 (not used)
+ *   indentation:4
+ *
+ *   created on: 2003jul2
+ *   created by: Ram Viswanadha
+ */
+
+#ifndef __USPREP_H__
+#define __USPREP_H__
+
+/**
+ * \file 
+ * \brief C API: Implements the StringPrep algorithm.
+ */
+
+#include "unicode/utypes.h"
+/**
+ *
+ * StringPrep API implements the StingPrep framework as described by RFC 3454.
+ * StringPrep prepares Unicode strings for use in network protocols.
+ * Profiles of StingPrep are set of rules and data according to with the
+ * Unicode Strings are prepared. Each profiles contains tables which describe
+ * how a code point should be treated. The tables are broadly classied into
+ * <ul>
+ *     <li> Unassinged Table: Contains code points that are unassigned 
+ *          in the Unicode Version supported by StringPrep. Currently 
+ *          RFC 3454 supports Unicode 3.2. </li>
+ *     <li> Prohibited Table: Contains code points that are prohibted from
+ *          the output of the StringPrep processing function. </li>
+ *     <li> Mapping Table: Contains code ponts that are deleted from the output or case mapped. </li>
+ * </ul>
+ * 
+ * The procedure for preparing Unicode strings:
+ * <ol>
+ *      <li> Map: For each character in the input, check if it has a mapping
+ *           and, if so, replace it with its mapping. </li>
+ *      <li> Normalize: Possibly normalize the result of step 1 using Unicode
+ *           normalization. </li>
+ *      <li> Prohibit: Check for any characters that are not allowed in the
+ *        output.  If any are found, return an error.</li>
+ *      <li> Check bidi: Possibly check for right-to-left characters, and if
+ *           any are found, make sure that the whole string satisfies the
+ *           requirements for bidirectional strings.  If the string does not
+ *           satisfy the requirements for bidirectional strings, return an
+ *           error.  </li>
+ * </ol>
+ * @author Ram Viswanadha
+ */
+#if !UCONFIG_NO_IDNA
+
+#include "unicode/parseerr.h"
+
+/**
+ * The StringPrep profile
+ * @stable ICU 2.8
+ */
+typedef struct UStringPrepProfile UStringPrepProfile;
+
+
+/** 
+ * Option to prohibit processing of unassigned code points in the input
+ * 
+ * @see  usprep_prepare
+ * @stable ICU 2.8
+ */
+#define USPREP_DEFAULT 0x0000
+
+/** 
+ * Option to allow processing of unassigned code points in the input
+ * 
+ * @see  usprep_prepare
+ * @stable ICU 2.8
+ */
+#define USPREP_ALLOW_UNASSIGNED 0x0001
+
+
+/**
+ * Creates a StringPrep profile from the data file.
+ *
+ * @param path      string containing the full path pointing to the directory
+ *                  where the profile reside followed by the package name
+ *                  e.g. "/usr/resource/my_app/profiles/mydata" on a Unix system.
+ *                  if NULL, ICU default data files will be used.
+ * @param fileName  name of the profile file to be opened
+ * @param status    ICU error code in/out parameter. Must not be NULL.
+ *                  Must fulfill U_SUCCESS before the function call.
+ * @return Pointer to UStringPrepProfile that is opened. Should be closed by
+ * calling usprep_close()
+ * @see usprep_close()
+ * @stable ICU 2.8
+ */
+U_STABLE UStringPrepProfile* U_EXPORT2
+usprep_open(const char* path, 
+            const char* fileName,
+            UErrorCode* status);
+
+
+/**
+ * Closes the profile
+ * @param profile The profile to close
+ * @stable ICU 2.8
+ */
+U_STABLE void U_EXPORT2
+usprep_close(UStringPrepProfile* profile);
+
+
+/**
+ * Prepare the input buffer for use in applications with the given profile. This operation maps, normalizes(NFKC),
+ * checks for prohited and BiDi characters in the order defined by RFC 3454
+ * depending on the options specified in the profile.
+ *
+ * @param prep          The profile to use 
+ * @param src           Pointer to UChar buffer containing the string to prepare
+ * @param srcLength     Number of characters in the source string
+ * @param dest          Pointer to the destination buffer to receive the output
+ * @param destCapacity  The capacity of destination array
+ * @param options       A bit set of options:
+ *
+ *  - USPREP_NONE               Prohibit processing of unassigned code points in the input
+ *
+ *  - USPREP_ALLOW_UNASSIGNED   Treat the unassigned code points are in the input 
+ *                              as normal Unicode code points.
+ *
+ * @param parseError        Pointer to UParseError struct to receive information on position 
+ *                          of error if an error is encountered. Can be NULL.
+ * @param status            ICU in/out error code parameter.
+ *                          U_INVALID_CHAR_FOUND if src contains
+ *                          unmatched single surrogates.
+ *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
+ *                          too many code points.
+ *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
+ * @return The number of UChars in the destination buffer
+ * @stable ICU 2.8
+ */
+
+U_STABLE int32_t U_EXPORT2
+usprep_prepare(   const UStringPrepProfile* prep,
+                  const UChar* src, int32_t srcLength, 
+                  UChar* dest, int32_t destCapacity,
+                  int32_t options,
+                  UParseError* parseError,
+                  UErrorCode* status );
+
+
+#endif /* #if !UCONFIG_NO_IDNA */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ustdio.h b/CoreFoundation/icu/unicode/ustdio.h
new file mode 100644
index 0000000..235db32
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ustdio.h
@@ -0,0 +1,907 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File ustdio.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   10/16/98    stephen     Creation.
+*   11/06/98    stephen     Modified per code review.
+*   03/12/99    stephen     Modified for new C API.
+*   07/19/99    stephen     Minor doc update.
+*   02/01/01    george      Added sprintf & sscanf with all of its variants
+******************************************************************************
+*/
+
+#ifndef USTDIO_H
+#define USTDIO_H
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "unicode/utypes.h"
+#include "unicode/ucnv.h"
+#include "unicode/utrans.h"
+
+/*
+    TODO
+ The following is a small list as to what is currently wrong/suggestions for
+ ustdio.
+
+ * Make sure that * in the scanf format specification works for all formats.
+ * Each UFILE takes up at least 2KB.
+    Look into adding setvbuf() for configurable buffers.
+ * This library does buffering. The OS should do this for us already. Check on
+    this, and remove it from this library, if this is the case. Double buffering
+    wastes a lot of time and space.
+ * Test stdin and stdout with the u_f* functions
+ * Testing should be done for reading and writing multi-byte encodings,
+    and make sure that a character that is contained across buffer boundries
+    works even for incomplete characters.
+ * Make sure that the last character is flushed when the file/string is closed.
+ * snprintf should follow the C99 standard for the return value, which is
+    return the number of characters (excluding the trailing '\0')
+    which would have been written to the destination string regardless
+    of available space. This is like pre-flighting.
+ * Everything that uses %s should do what operator>> does for UnicodeString.
+    It should convert one byte at a time, and once a character is
+    converted then check to see if it's whitespace or in the scanset.
+    If it's whitespace or in the scanset, put all the bytes back (do nothing
+    for sprintf/sscanf).
+ * If bad string data is encountered, make sure that the function fails
+    without memory leaks and the unconvertable characters are valid
+    substitution or are escaped characters.
+ * u_fungetc() can't unget a character when it's at the beginning of the
+    internal conversion buffer. For example, read the buffer size # of
+    characters, and then ungetc to get the previous character that was
+    at the end of the last buffer.
+ * u_fflush() and u_fclose should return an int32_t like C99 functions.
+    0 is returned if the operation was successful and EOF otherwise.
+ * u_fsettransliterator does not support U_READ side of transliteration.
+ * The format specifier should limit the size of a format or honor it in
+    order to prevent buffer overruns.  (e.g. %256.256d).
+ * u_fread and u_fwrite don't exist. They're needed for reading and writing
+    data structures without any conversion.
+ * u_file_read and u_file_write are used for writing strings. u_fgets and
+    u_fputs or u_fread and u_fwrite should be used to do this.
+ * The width parameter for all scanf formats, including scanset, needs
+    better testing. This prevents buffer overflows.
+ * Figure out what is suppose to happen when a codepage is changed midstream.
+    Maybe a flush or a rewind are good enough.
+ * Make sure that a UFile opened with "rw" can be used after using
+    u_fflush with a u_frewind.
+ * scanf(%i) should detect what type of number to use.
+ * Add more testing of the alternate format, %#
+ * Look at newline handling of fputs/puts
+ * Think more about codeunit/codepoint error handling/support in %S,%s,%C,%c,%[]
+ * Complete the file documentation with proper doxygen formatting.
+    See http://oss.software.ibm.com/pipermail/icu/2003-July/005647.html
+*/
+
+/**
+ * \file
+ * \brief C API: Unicode stdio-like API
+ *
+ * <h2>Unicode stdio-like C API</h2>
+ *
+ * <p>This API provides an stdio-like API wrapper around ICU's other
+ * formatting and parsing APIs. It is meant to ease the transition of adding
+ * Unicode support to a preexisting applications using stdio. The following
+ * is a small list of noticable differences between stdio and ICU I/O's
+ * ustdio implementation.</p>
+ *
+ * <ul>
+ * <li>Locale specific formatting and parsing is only done with file IO.</li>
+ * <li>u_fstropen can be used to simulate file IO with strings.
+ * This is similar to the iostream API, and it allows locale specific
+ * formatting and parsing to be used.</li>
+ * <li>This API provides uniform formatting and parsing behavior between
+ * platforms (unlike the standard stdio implementations found on various
+ * platforms).</li>
+ * <li>This API is better suited for text data handling than binary data
+ * handling when compared to the typical stdio implementation.</li>
+ * <li>You can specify a Transliterator while using the file IO.</li>
+ * <li>You can specify a file's codepage separately from the default
+ * system codepage.</li>
+ * </ul>
+ *
+ * <h2>Formatting and Parsing Specification</h2>
+ *
+ * General printf format:<br>
+ * %[format modifier][width][.precision][type modifier][format]
+ * 
+ * General scanf format:<br>
+ * %[*][format modifier][width][type modifier][format]
+ * 
+<table cellspacing="3">
+<tr><td>format</td><td>default<br>printf<br>type</td><td>default<br>scanf<br>type</td><td>description</td></tr>
+<tr><td>%E</td><td>double</td><td>float</td><td>Scientific with an uppercase exponent</td></tr>
+<tr><td>%e</td><td>double</td><td>float</td><td>Scientific with a lowercase exponent</td></tr>
+<tr><td>%G</td><td>double</td><td>float</td><td>Use %E or %f for best format</td></tr>
+<tr><td>%g</td><td>double</td><td>float</td><td>Use %e or %f for best format</td></tr>
+<tr><td>%f</td><td>double</td><td>float</td><td>Simple floating point without the exponent</td></tr>
+<tr><td>%X</td><td>int32_t</td><td>int32_t</td><td>ustdio special uppercase hex radix formatting</td></tr>
+<tr><td>%x</td><td>int32_t</td><td>int32_t</td><td>ustdio special lowercase hex radix formatting</td></tr>
+<tr><td>%d</td><td>int32_t</td><td>int32_t</td><td>Decimal format</td></tr>
+<tr><td>%i</td><td>int32_t</td><td>int32_t</td><td>Same as %d</td></tr>
+<tr><td>%n</td><td>int32_t</td><td>int32_t</td><td>count (write the number of UTF-16 codeunits read/written)</td></tr>
+<tr><td>%o</td><td>int32_t</td><td>int32_t</td><td>ustdio special octal radix formatting</td></tr>
+<tr><td>%u</td><td>uint32_t</td><td>uint32_t</td><td>Decimal format</td></tr>
+<tr><td>%p</td><td>void *</td><td>void *</td><td>Prints the pointer value</td></tr>
+<tr><td>%s</td><td>char *</td><td>char *</td><td>Use default converter or specified converter from fopen</td></tr>
+<tr><td>%c</td><td>char</td><td>char</td><td>Use default converter or specified converter from fopen<br>
+When width is specified for scanf, this acts like a non-NULL-terminated char * string.<br>
+By default, only one char is written.</td></tr>
+<tr><td>%S</td><td>UChar *</td><td>UChar *</td><td>Null terminated UTF-16 string</td></tr>
+<tr><td>%C</td><td>UChar</td><td>UChar</td><td>16-bit Unicode code unit<br>
+When width is specified for scanf, this acts like a non-NULL-terminated UChar * string<br>
+By default, only one codepoint is written.</td></tr>
+<tr><td>%[]</td><td>&nbsp;</td><td>UChar *</td><td>Null terminated UTF-16 string which contains the filtered set of characters specified by the UnicodeSet</td></tr>
+<tr><td>%%</td><td>&nbsp;</td><td>&nbsp;</td><td>Show a percent sign</td></tr>
+</table>
+
+Format modifiers
+<table>
+<tr><td>modifier</td><td>formats</td><td>type</td><td>comments</td></tr>
+<tr><td>%h</td><td>%d, %i, %o, %x</td><td>int16_t</td><td>short format</td></tr>
+<tr><td>%h</td><td>%u</td><td>uint16_t</td><td>short format</td></tr>
+<tr><td>%h</td><td>c</td><td>char</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
+<tr><td>%h</td><td>s</td><td>char *</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
+<tr><td>%h</td><td>C</td><td>char</td><td><b>(Unimplemented)</b> 8-bit Unicode code unit</td></tr>
+<tr><td>%h</td><td>S</td><td>char *</td><td><b>(Unimplemented)</b> Null terminated UTF-8 string</td></tr>
+<tr><td>%l</td><td>%d, %i, %o, %x</td><td>int32_t</td><td>long format (no effect)</td></tr>
+<tr><td>%l</td><td>%u</td><td>uint32_t</td><td>long format (no effect)</td></tr>
+<tr><td>%l</td><td>c</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
+<tr><td>%l</td><td>s</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
+<tr><td>%l</td><td>C</td><td>UChar32</td><td><b>(Unimplemented)</b> 32-bit Unicode code unit</td></tr>
+<tr><td>%l</td><td>S</td><td>UChar32 *</td><td><b>(Unimplemented)</b> Null terminated UTF-32 string</td></tr>
+<tr><td>%ll</td><td>%d, %i, %o, %x</td><td>int64_t</td><td>long long format</td></tr>
+<tr><td>%ll</td><td>%u</td><td>uint64_t</td><td><b>(Unimplemented)</b> long long format</td></tr>
+<tr><td>%-</td><td><i>all</i></td><td>N/A</td><td>Left justify</td></tr>
+<tr><td>%+</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Always show the plus or minus sign. Needs data for plus sign.</td></tr>
+<tr><td>% </td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Instead of a "+" output a blank character for positive numbers.</td></tr>
+<tr><td>%#</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Precede octal value with 0, hex with 0x and show the 
+                decimal point for floats.</td></tr>
+<tr><td>%<i>n</i></td><td><i>all</i></td><td>N/A</td><td>Width of input/output. num is an actual number from 0 to 
+                some large number.</td></tr>
+<tr><td>%.<i>n</i></td><td>%e, %f, %g, %E, %F, %G</td><td>N/A</td><td>Significant digits precision. num is an actual number from
+                0 to some large number.<br>If * is used in printf, then the precision is passed in as an argument before the number to be formatted.</td></tr>
+</table>
+
+printf modifier
+%*  int32_t     Next argument after this one specifies the width
+
+scanf modifier
+%*  N/A         This field is scanned, but not stored
+
+<p>If you are using this C API instead of the ustream.h API for C++,
+you can use one of the following u_fprintf examples to display a UnicodeString.</p>
+
+<pre><code>
+    UFILE *out = u_finit(stdout, NULL, NULL);
+    UnicodeString string1("string 1");
+    UnicodeString string2("string 2");
+    u_fprintf(out, "%S\n", string1.getTerminatedBuffer());
+    u_fprintf(out, "%.*S\n", string2.length(), string2.getBuffer());
+    u_fclose(out);
+</code></pre>
+
+ */
+
+
+/**
+ * When an end of file is encountered, this value can be returned.
+ * @see u_fgetc
+ * @stable 3.0
+ */
+#define U_EOF 0xFFFF
+
+/** Forward declaration of a Unicode-aware file @stable 3.0 */
+typedef struct UFILE UFILE;
+
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Enum for which direction of stream a transliterator applies to.
+ * @see u_fsettransliterator
+ * @draft 3.0
+ */
+typedef enum { 
+   U_READ = 1,
+   U_WRITE = 2, 
+   U_READWRITE =3  /* == (U_READ | U_WRITE) */ 
+} UFileDirection;
+
+#endif /* U_HIDE_DRAFT_API */
+
+/**
+ * Open a UFILE.
+ * A UFILE is a wrapper around a FILE* that is locale and codepage aware.
+ * That is, data written to a UFILE will be formatted using the conventions
+ * specified by that UFILE's Locale; this data will be in the character set
+ * specified by that UFILE's codepage.
+ * @param filename The name of the file to open.
+ * @param perm The read/write permission for the UFILE; one of "r", "w", "rw"
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output. If this parameter is NULL, the default locale will 
+ * be used.
+ * @param codepage The codepage in which data will be written to and
+ * read from the file. If this paramter is NULL the system default codepage
+ * will be used.
+ * @return A new UFILE, or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT UFILE* U_EXPORT2
+u_fopen(const char    *filename,
+    const char    *perm,
+    const char    *locale,
+    const char    *codepage);
+
+/**
+ * Open a UFILE on top of an existing FILE* stream.
+ * @param f The FILE* to which this UFILE will attach.
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output. If this parameter is NULL, the default locale will 
+ * be used.
+ * @param codepage The codepage in which data will be written to and
+ * read from the file. If this paramter is NULL, data will be written and
+ * read using the default codepage for <TT>locale</TT>, unless <TT>locale</TT>
+ * is NULL, in which case the system default codepage will be used.
+ * @return A new UFILE, or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT UFILE* U_EXPORT2
+u_finit(FILE        *f,
+    const char    *locale,
+    const char    *codepage);
+
+/**
+ * Create a UFILE that can be used for localized formatting or parsing.
+ * The u_sprintf and u_sscanf functions do not read or write numbers for a
+ * specific locale. The ustdio.h file functions can be used on this UFILE.
+ * The string is usable once u_fclose or u_fflush has been called on the
+ * returned UFILE.
+ * @param stringBuf The string used for reading or writing.
+ * @param capacity The number of code units available for use in stringBuf
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output. If this parameter is NULL, the default locale will 
+ * be used.
+ * @return A new UFILE, or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT UFILE* U_EXPORT2
+u_fstropen(UChar      *stringBuf,
+           int32_t     capacity,
+           const char *locale);
+
+/**
+ * Close a UFILE.
+ * @param file The UFILE to close.
+ * @draft 3.0
+ */
+U_DRAFT void U_EXPORT2
+u_fclose(UFILE *file);
+
+/**
+ * Tests if the UFILE is at the end of the file stream.
+ * @param f The UFILE from which to read.
+ * @return Returns TRUE after the first read operation that attempts to
+ * read past the end of the file. It returns FALSE if the current position is
+ * not end of file.
+ * @draft 3.0
+*/
+U_DRAFT UBool U_EXPORT2
+u_feof(UFILE  *f);
+
+/**
+ * Flush output of a UFILE. Implies a flush of
+ * converter/transliterator state. (That is, a logical break is
+ * made in the output stream - for example if a different type of
+ * output is desired.)  The underlying OS level file is also flushed.
+ * @param file The UFILE to flush.
+ * @draft 3.0
+ */
+U_DRAFT void U_EXPORT2
+u_fflush(UFILE *file);
+
+/**
+ * Rewind the file pointer to the beginning of the file.
+ * @param file The UFILE to rewind.
+ * @draft 3.0
+ */
+U_DRAFT void
+u_frewind(UFILE *file);
+
+/**
+ * Get the FILE* associated with a UFILE.
+ * @param f The UFILE
+ * @return A FILE*, owned by the UFILE.  The FILE <EM>must not</EM> be closed.
+ * @draft 3.0
+ */
+U_DRAFT FILE* U_EXPORT2
+u_fgetfile(UFILE *f);
+
+#if !UCONFIG_NO_FORMATTING
+
+/**
+ * Get the locale whose conventions are used to format and parse output.
+ * This is the same locale passed in the preceding call to<TT>u_fsetlocale</TT>
+ * or <TT>u_fopen</TT>.
+ * @param file The UFILE to set.
+ * @return The locale whose conventions are used to format and parse output.
+ * @draft 3.0
+ */
+U_DRAFT const char* U_EXPORT2
+u_fgetlocale(UFILE *file);
+
+/**
+ * Set the locale whose conventions will be used to format and parse output.
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output.
+ * @param file The UFILE to query.
+ * @return NULL if successful, otherwise a negative number.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fsetlocale(UFILE      *file,
+             const char *locale);
+
+#endif
+
+/**
+ * Get the codepage in which data is written to and read from the UFILE.
+ * This is the same codepage passed in the preceding call to 
+ * <TT>u_fsetcodepage</TT> or <TT>u_fopen</TT>.
+ * @param file The UFILE to query.
+ * @return The codepage in which data is written to and read from the UFILE,
+ * or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT const char* U_EXPORT2
+u_fgetcodepage(UFILE *file);
+
+/**
+ * Set the codepage in which data will be written to and read from the UFILE.
+ * All Unicode data written to the UFILE will be converted to this codepage
+ * before it is written to the underlying FILE*. It it generally a bad idea to
+ * mix codepages within a file. This should only be called right
+ * after opening the <TT>UFile</TT>, or after calling <TT>u_frewind</TT>.
+ * @param codepage The codepage in which data will be written to 
+ * and read from the file. For example <TT>"latin-1"</TT> or <TT>"ibm-943</TT>.
+ * A value of NULL means the default codepage for the UFILE's current 
+ * locale will be used.
+ * @param file The UFILE to set.
+ * @return 0 if successful, otherwise a negative number.
+ * @see u_frewind
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fsetcodepage(const char   *codepage,
+               UFILE        *file);
+
+
+/**
+ * Returns an alias to the converter being used for this file.
+ * @param f The UFILE to get the value from
+ * @return alias to the converter
+ * @draft 3.0
+ */
+U_DRAFT UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
+
+#if !UCONFIG_NO_FORMATTING
+
+/* Output functions */
+
+/**
+ * Write formatted data to a UFILE.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fprintf(UFILE         *f,
+          const char    *patternSpecification,
+          ... );
+
+/**
+ * Write formatted data to a UFILE.
+ * This is identical to <TT>u_fprintf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @see u_fprintf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfprintf(UFILE        *f,
+           const char   *patternSpecification,
+           va_list      ap);
+
+/**
+ * Write formatted data to a UFILE.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fprintf_u(UFILE       *f,
+            const UChar *patternSpecification,
+            ... );
+
+/**
+ * Write formatted data to a UFILE.
+ * This is identical to <TT>u_fprintf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @see u_fprintf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfprintf_u(UFILE      *f,
+            const UChar *patternSpecification,
+            va_list     ap);
+#endif
+/**
+ * Write a Unicode to a UFILE.  The null (U+0000) terminated UChar*
+ * <TT>s</TT> will be written to <TT>f</TT>, excluding the NULL terminator.
+ * A newline will be added to <TT>f</TT>.
+ * @param s The UChar* to write.
+ * @param f The UFILE to which to write.
+ * @return A non-negative number if successful, EOF otherwise.
+ * @see u_file_write
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fputs(const UChar *s,
+        UFILE       *f);
+
+/**
+ * Write a UChar to a UFILE.
+ * @param uc The UChar to write.
+ * @param f The UFILE to which to write.
+ * @return The character written if successful, EOF otherwise.
+ * @draft 3.0
+ */
+U_DRAFT UChar32 U_EXPORT2
+u_fputc(UChar32  uc,
+        UFILE  *f);
+
+/**
+ * Write Unicode to a UFILE.
+ * The ustring passed in will be converted to the UFILE's underlying
+ * codepage before it is written.
+ * @param ustring A pointer to the Unicode data to write.
+ * @param count The number of Unicode characters to write
+ * @param f The UFILE to which to write.
+ * @return The number of Unicode characters written.
+ * @see u_fputs
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_file_write(const UChar    *ustring, 
+             int32_t        count, 
+             UFILE          *f);
+
+
+/* Input functions */
+#if !UCONFIG_NO_FORMATTING
+
+/**
+ * Read formatted data from a UFILE.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fscanf(UFILE      *f,
+         const char *patternSpecification,
+         ... );
+
+/**
+ * Read formatted data from a UFILE.
+ * This is identical to <TT>u_fscanf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_fscanf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfscanf(UFILE         *f,
+          const char    *patternSpecification,
+          va_list        ap);
+
+/**
+ * Read formatted data from a UFILE.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fscanf_u(UFILE        *f,
+           const UChar  *patternSpecification,
+           ... );
+
+/**
+ * Read formatted data from a UFILE.
+ * This is identical to <TT>u_fscanf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_fscanf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfscanf_u(UFILE       *f,
+            const UChar *patternSpecification,
+            va_list      ap);
+#endif
+
+/**
+ * Read one line of text into a UChar* string from a UFILE. The newline
+ * at the end of the line is read into the string. The string is always
+ * null terminated
+ * @param f The UFILE from which to read.
+ * @param n The maximum number of characters - 1 to read.
+ * @param s The UChar* to receive the read data.  Characters will be
+ * stored successively in <TT>s</TT> until a newline or EOF is
+ * reached. A null character (U+0000) will be appended to <TT>s</TT>.
+ * @return A pointer to <TT>s</TT>, or NULL if no characters were available.
+ * @draft 3.0
+ */
+U_DRAFT UChar* U_EXPORT2
+u_fgets(UChar  *s,
+        int32_t n,
+        UFILE  *f);
+
+/**
+ * Read a UChar from a UFILE. It is recommended that <TT>u_fgetcx</TT>
+ * used instead for proper parsing functions, but sometimes reading
+ * code units is needed instead of codepoints.
+ *
+ * @param f The UFILE from which to read.
+ * @return The UChar value read, or U+FFFF if no character was available.
+ * @draft 3.0
+ */
+U_DRAFT UChar U_EXPORT2
+u_fgetc(UFILE   *f);
+
+/**
+ * Read a UChar32 from a UFILE.
+ *
+ * @param f The UFILE from which to read.
+ * @return The UChar32 value read, or U_EOF if no character was
+ * available, or U+FFFFFFFF if an ill-formed character was
+ * encountered.
+ * @see u_unescape()
+ * @draft 3.0
+ */
+U_DRAFT UChar32 U_EXPORT2
+u_fgetcx(UFILE  *f);
+
+/**
+ * Unget a UChar from a UFILE.
+ * If this function is not the first to operate on <TT>f</TT> after a call
+ * to <TT>u_fgetc</TT>, the results are undefined.
+ * If this function is passed a character that was not recieved from the
+ * previous <TT>u_fgetc</TT> or <TT>u_fgetcx</TT> call, the results are undefined.
+ * @param c The UChar to put back on the stream.
+ * @param f The UFILE to receive <TT>c</TT>.
+ * @return The UChar32 value put back if successful, U_EOF otherwise.
+ * @draft 3.0
+ */
+U_DRAFT UChar32 U_EXPORT2
+u_fungetc(UChar32   c,
+      UFILE        *f);
+
+/**
+ * Read Unicode from a UFILE.
+ * Bytes will be converted from the UFILE's underlying codepage, with
+ * subsequent conversion to Unicode. The data will not be NULL terminated.
+ * @param chars A pointer to receive the Unicode data.
+ * @param count The number of Unicode characters to read.
+ * @param f The UFILE from which to read.
+ * @return The number of Unicode characters read.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_file_read(UChar        *chars, 
+        int32_t        count, 
+        UFILE         *f);
+
+#if !UCONFIG_NO_TRANSLITERATION
+
+/**
+ * Set a transliterator on the UFILE. The transliterator will be owned by the
+ * UFILE. 
+ * @param file The UFILE to set transliteration on
+ * @param adopt The UTransliterator to set. Can be NULL, which will
+ * mean that no transliteration is used.
+ * @param direction either U_READ, U_WRITE, or U_READWRITE - sets
+ *  which direction the transliterator is to be applied to. If
+ * U_READWRITE, the "Read" transliteration will be in the inverse
+ * direction.
+ * @param status ICU error code.
+ * @return The previously set transliterator, owned by the
+ * caller. If U_READWRITE is specified, only the WRITE transliterator
+ * is returned. In most cases, the caller should call utrans_close()
+ * on the result of this function.
+ * @draft 3.0
+ */
+U_DRAFT UTransliterator* U_EXPORT2
+u_fsettransliterator(UFILE *file, UFileDirection direction,
+                     UTransliterator *adopt, UErrorCode *status);
+
+#endif
+
+
+/* Output string functions */
+#if !UCONFIG_NO_FORMATTING
+
+
+/**
+ * Write formatted data to a Unicode string.
+ *
+ * @param buffer The Unicode String to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode code units written to <TT>buffer</TT>. This
+ * does not include the terminating null character.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sprintf(UChar       *buffer,
+        const char    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string. When the number of code units
+ * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
+ * units of data are stored in <TT>buffer</TT> and a negative value is
+ * returned. When the number of code units required to store the data equals
+ * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
+ * returned.
+ *
+ * @param buffer The Unicode String to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters that would have been written to
+ * <TT>buffer</TT> had count been sufficiently large. This does not include
+ * the terminating null character.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_snprintf(UChar      *buffer,
+        int32_t       count,
+        const char    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_sprintf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>buffer</TT>.
+ * @see u_sprintf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsprintf(UChar      *buffer,
+        const char    *patternSpecification,
+        va_list        ap);
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_snprintf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.<br><br>
+ * When the number of code units required to store the data exceeds
+ * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
+ * <TT>buffer</TT> and a negative value is returned. When the number of code
+ * units required to store the data equals <TT>count</TT>, the string is not
+ * null terminated and <TT>count</TT> is returned.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters that would have been written to
+ * <TT>buffer</TT> had count been sufficiently large.
+ * @see u_sprintf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsnprintf(UChar     *buffer,
+        int32_t       count,
+        const char    *patternSpecification,
+        va_list        ap);
+
+/**
+ * Write formatted data to a Unicode string.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>buffer</TT>.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sprintf_u(UChar      *buffer,
+        const UChar    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string. When the number of code units
+ * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
+ * units of data are stored in <TT>buffer</TT> and a negative value is
+ * returned. When the number of code units required to store the data equals
+ * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
+ * returned.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters that would have been written to
+ * <TT>buffer</TT> had count been sufficiently large.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_snprintf_u(UChar     *buffer,
+        int32_t        count,
+        const UChar    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_sprintf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @see u_sprintf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsprintf_u(UChar     *buffer,
+        const UChar    *patternSpecification,
+        va_list        ap);
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_snprintf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * When the number of code units required to store the data exceeds
+ * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
+ * <TT>buffer</TT> and a negative value is returned. When the number of code
+ * units required to store the data equals <TT>count</TT>, the string is not
+ * null terminated and <TT>count</TT> is returned.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters that would have been written to
+ * <TT>f</TT> had count been sufficiently large.
+ * @see u_sprintf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsnprintf_u(UChar *buffer,
+        int32_t         count,
+        const UChar     *patternSpecification,
+        va_list         ap);
+
+/* Input string functions */
+
+/**
+ * Read formatted data from a Unicode string.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sscanf(const UChar   *buffer,
+        const char     *patternSpecification,
+        ... );
+
+/**
+ * Read formatted data from a Unicode string.
+ * This is identical to <TT>u_sscanf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_sscanf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsscanf(const UChar  *buffer,
+        const char     *patternSpecification,
+        va_list        ap);
+
+/**
+ * Read formatted data from a Unicode string.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sscanf_u(const UChar  *buffer,
+        const UChar     *patternSpecification,
+        ... );
+
+/**
+ * Read formatted data from a Unicode string.
+ * This is identical to <TT>u_sscanf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_sscanf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsscanf_u(const UChar *buffer,
+        const UChar     *patternSpecification,
+        va_list         ap);
+
+#endif
+#endif
+
+
diff --git a/CoreFoundation/icu/unicode/ustream.h b/CoreFoundation/icu/unicode/ustream.h
new file mode 100644
index 0000000..36ffec0
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ustream.h
@@ -0,0 +1,67 @@
+/*
+**********************************************************************
+*   Copyright (C) 2001-2007 International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*  FILE NAME : ustream.h
+*
+*   Modification History:
+*
+*   Date        Name        Description
+*   06/25/2001  grhoten     Move iostream from unistr.h
+******************************************************************************
+*/
+   
+#ifndef USTREAM_H
+#define USTREAM_H
+
+#include "unicode/unistr.h"
+
+/**
+ * \file
+ * \brief C++ API: Unicode iostream like API
+ *
+ * At this time, this API is very limited. It contains
+ * operator<< and operator>> for UnicodeString manipulation with the
+ * C++ I/O stream API.
+ */
+
+#if U_IOSTREAM_SOURCE >= 199711
+#include <istream>
+#include <ostream>
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Write the contents of a UnicodeString to a C++ ostream. This functions writes
+ * the characters in a UnicodeString to an ostream. The UChars in the
+ * UnicodeString are converted to the char based ostream with the default
+ * converter.
+ * @stable 3.0
+ */
+U_IO_API std::ostream & U_EXPORT2 operator<<(std::ostream& stream, const UnicodeString& s);
+
+/**
+ * Write the contents from a C++ istream to a UnicodeString. The UChars in the
+ * UnicodeString are converted from the char based istream with the default
+ * converter.
+ * @stable 3.0
+ */
+U_IO_API std::istream & U_EXPORT2 operator>>(std::istream& stream, UnicodeString& s);
+U_NAMESPACE_END
+
+#elif U_IOSTREAM_SOURCE >= 198506
+/* <istream.h> and <ostream.h> don't exist. */
+#include <iostream.h>
+
+U_NAMESPACE_BEGIN
+U_IO_API ostream & U_EXPORT2 operator<<(ostream& stream, const UnicodeString& s);
+
+U_IO_API istream & U_EXPORT2 operator>>(istream& stream, UnicodeString& s);
+U_NAMESPACE_END
+
+#endif
+
+/* No operator for UChar because it can conflict with wchar_t  */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/ustring.h b/CoreFoundation/icu/unicode/ustring.h
new file mode 100644
index 0000000..12411ef
--- /dev/null
+++ b/CoreFoundation/icu/unicode/ustring.h
@@ -0,0 +1,1479 @@
+/*
+**********************************************************************
+*   Copyright (C) 1998-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File ustring.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   12/07/98    bertrand    Creation.
+******************************************************************************
+*/
+
+#ifndef USTRING_H
+#define USTRING_H
+
+#include "unicode/utypes.h"
+#include "unicode/putil.h"
+#include "unicode/uiter.h"
+
+/** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. @stable ICU 2.1*/
+#ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
+#   define UBRK_TYPEDEF_UBREAK_ITERATOR
+    typedef void UBreakIterator;
+#endif
+
+/**
+ * \file
+ * \brief C API: Unicode string handling functions
+ *
+ * These C API functions provide general Unicode string handling.
+ *
+ * Some functions are equivalent in name, signature, and behavior to the ANSI C <string.h>
+ * functions. (For example, they do not check for bad arguments like NULL string pointers.)
+ * In some cases, only the thread-safe variant of such a function is implemented here
+ * (see u_strtok_r()).
+ *
+ * Other functions provide more Unicode-specific functionality like locale-specific
+ * upper/lower-casing and string comparison in code point order.
+ *
+ * ICU uses 16-bit Unicode (UTF-16) in the form of arrays of UChar code units.
+ * UTF-16 encodes each Unicode code point with either one or two UChar code units.
+ * (This is the default form of Unicode, and a forward-compatible extension of the original,
+ * fixed-width form that was known as UCS-2. UTF-16 superseded UCS-2 with Unicode 2.0
+ * in 1996.)
+ *
+ * Some APIs accept a 32-bit UChar32 value for a single code point.
+ *
+ * ICU also handles 16-bit Unicode text with unpaired surrogates.
+ * Such text is not well-formed UTF-16.
+ * Code-point-related functions treat unpaired surrogates as surrogate code points,
+ * i.e., as separate units.
+ *
+ * Although UTF-16 is a variable-width encoding form (like some legacy multi-byte encodings),
+ * it is much more efficient even for random access because the code unit values
+ * for single-unit characters vs. lead units vs. trail units are completely disjoint.
+ * This means that it is easy to determine character (code point) boundaries from
+ * random offsets in the string.
+ *
+ * Unicode (UTF-16) string processing is optimized for the single-unit case.
+ * Although it is important to support supplementary characters
+ * (which use pairs of lead/trail code units called "surrogates"),
+ * their occurrence is rare. Almost all characters in modern use require only
+ * a single UChar code unit (i.e., their code point values are <=0xffff).
+ *
+ * For more details see the User Guide Strings chapter (http://icu-project.org/userguide/strings.html).
+ * For a discussion of the handling of unpaired surrogates see also
+ * Jitterbug 2145 and its icu mailing list proposal on 2002-sep-18.
+ */
+
+/**
+ * \defgroup ustring_ustrlen String Length
+ * \ingroup ustring_strlen
+ */
+/*@{*/
+/**
+ * Determine the length of an array of UChar.
+ *
+ * @param s The array of UChars, NULL (U+0000) terminated.
+ * @return The number of UChars in <code>chars</code>, minus the terminator.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strlen(const UChar *s);
+/*@}*/
+
+/**
+ * Count Unicode code points in the length UChar code units of the string.
+ * A code point may occupy either one or two UChar code units.
+ * Counting code points involves reading all code units.
+ *
+ * This functions is basically the inverse of the U16_FWD_N() macro (see utf.h).
+ *
+ * @param s The input string.
+ * @param length The number of UChar code units to be checked, or -1 to count all
+ *               code points before the first NUL (U+0000).
+ * @return The number of code points in the specified code units.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_countChar32(const UChar *s, int32_t length);
+
+/**
+ * Check if the string contains more Unicode code points than a certain number.
+ * This is more efficient than counting all code points in the entire string
+ * and comparing that number with a threshold.
+ * This function may not need to scan the string at all if the length is known
+ * (not -1 for NUL-termination) and falls within a certain range, and
+ * never needs to count more than 'number+1' code points.
+ * Logically equivalent to (u_countChar32(s, length)>number).
+ * A Unicode code point may occupy either one or two UChar code units.
+ *
+ * @param s The input string.
+ * @param length The length of the string, or -1 if it is NUL-terminated.
+ * @param number The number of code points in the string is compared against
+ *               the 'number' parameter.
+ * @return Boolean value for whether the string contains more Unicode code points
+ *         than 'number'. Same as (u_countChar32(s, length)>number).
+ * @stable ICU 2.4
+ */
+U_STABLE UBool U_EXPORT2
+u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number);
+
+/**
+ * Concatenate two ustrings.  Appends a copy of <code>src</code>,
+ * including the null terminator, to <code>dst</code>. The initial copied
+ * character from <code>src</code> overwrites the null terminator in <code>dst</code>.
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_strcat(UChar     *dst, 
+    const UChar     *src);
+
+/**
+ * Concatenate two ustrings.  
+ * Appends at most <code>n</code> characters from <code>src</code> to <code>dst</code>.
+ * Adds a terminating NUL.
+ * If src is too long, then only <code>n-1</code> characters will be copied
+ * before the terminating NUL.
+ * If <code>n&lt;=0</code> then dst is not modified.
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @param n The maximum number of characters to compare.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_strncat(UChar     *dst, 
+     const UChar     *src, 
+     int32_t     n);
+
+/**
+ * Find the first occurrence of a substring in a string.
+ * The substring is found at code point boundaries.
+ * That means that if the substring begins with
+ * a trail surrogate or ends with a lead surrogate,
+ * then it is found only if these surrogates stand alone in the text.
+ * Otherwise, the substring edge units would be matched against
+ * halves of surrogate pairs.
+ *
+ * @param s The string to search (NUL-terminated).
+ * @param substring The substring to find (NUL-terminated).
+ * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>,
+ *         or <code>s</code> itself if the <code>substring</code> is empty,
+ *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
+ * @stable ICU 2.0
+ *
+ * @see u_strrstr
+ * @see u_strFindFirst
+ * @see u_strFindLast
+ */
+U_STABLE UChar * U_EXPORT2
+u_strstr(const UChar *s, const UChar *substring);
+
+/**
+ * Find the first occurrence of a substring in a string.
+ * The substring is found at code point boundaries.
+ * That means that if the substring begins with
+ * a trail surrogate or ends with a lead surrogate,
+ * then it is found only if these surrogates stand alone in the text.
+ * Otherwise, the substring edge units would be matched against
+ * halves of surrogate pairs.
+ *
+ * @param s The string to search.
+ * @param length The length of s (number of UChars), or -1 if it is NUL-terminated.
+ * @param substring The substring to find (NUL-terminated).
+ * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated.
+ * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>,
+ *         or <code>s</code> itself if the <code>substring</code> is empty,
+ *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
+ * @stable ICU 2.4
+ *
+ * @see u_strstr
+ * @see u_strFindLast
+ */
+U_STABLE UChar * U_EXPORT2
+u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
+
+/**
+ * Find the first occurrence of a BMP code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (NUL-terminated).
+ * @param c The BMP code point to find.
+ * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.0
+ *
+ * @see u_strchr32
+ * @see u_memchr
+ * @see u_strstr
+ * @see u_strFindFirst
+ */
+U_STABLE UChar * U_EXPORT2
+u_strchr(const UChar *s, UChar c);
+
+/**
+ * Find the first occurrence of a code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (NUL-terminated).
+ * @param c The code point to find.
+ * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.0
+ *
+ * @see u_strchr
+ * @see u_memchr32
+ * @see u_strstr
+ * @see u_strFindFirst
+ */
+U_STABLE UChar * U_EXPORT2
+u_strchr32(const UChar *s, UChar32 c);
+
+/**
+ * Find the last occurrence of a substring in a string.
+ * The substring is found at code point boundaries.
+ * That means that if the substring begins with
+ * a trail surrogate or ends with a lead surrogate,
+ * then it is found only if these surrogates stand alone in the text.
+ * Otherwise, the substring edge units would be matched against
+ * halves of surrogate pairs.
+ *
+ * @param s The string to search (NUL-terminated).
+ * @param substring The substring to find (NUL-terminated).
+ * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>,
+ *         or <code>s</code> itself if the <code>substring</code> is empty,
+ *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
+ * @stable ICU 2.4
+ *
+ * @see u_strstr
+ * @see u_strFindFirst
+ * @see u_strFindLast
+ */
+U_STABLE UChar * U_EXPORT2
+u_strrstr(const UChar *s, const UChar *substring);
+
+/**
+ * Find the last occurrence of a substring in a string.
+ * The substring is found at code point boundaries.
+ * That means that if the substring begins with
+ * a trail surrogate or ends with a lead surrogate,
+ * then it is found only if these surrogates stand alone in the text.
+ * Otherwise, the substring edge units would be matched against
+ * halves of surrogate pairs.
+ *
+ * @param s The string to search.
+ * @param length The length of s (number of UChars), or -1 if it is NUL-terminated.
+ * @param substring The substring to find (NUL-terminated).
+ * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated.
+ * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>,
+ *         or <code>s</code> itself if the <code>substring</code> is empty,
+ *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
+ * @stable ICU 2.4
+ *
+ * @see u_strstr
+ * @see u_strFindLast
+ */
+U_STABLE UChar * U_EXPORT2
+u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
+
+/**
+ * Find the last occurrence of a BMP code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (NUL-terminated).
+ * @param c The BMP code point to find.
+ * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.4
+ *
+ * @see u_strrchr32
+ * @see u_memrchr
+ * @see u_strrstr
+ * @see u_strFindLast
+ */
+U_STABLE UChar * U_EXPORT2
+u_strrchr(const UChar *s, UChar c);
+
+/**
+ * Find the last occurrence of a code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (NUL-terminated).
+ * @param c The code point to find.
+ * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.4
+ *
+ * @see u_strrchr
+ * @see u_memchr32
+ * @see u_strrstr
+ * @see u_strFindLast
+ */
+U_STABLE UChar * U_EXPORT2
+u_strrchr32(const UChar *s, UChar32 c);
+
+/**
+ * Locates the first occurrence in the string <code>string</code> of any of the characters
+ * in the string <code>matchSet</code>.
+ * Works just like C's strpbrk but with Unicode.
+ *
+ * @param string The string in which to search, NUL-terminated.
+ * @param matchSet A NUL-terminated string defining a set of code points
+ *                 for which to search in the text string.
+ * @return A pointer to the  character in <code>string</code> that matches one of the
+ *         characters in <code>matchSet</code>, or NULL if no such character is found.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar * U_EXPORT2
+u_strpbrk(const UChar *string, const UChar *matchSet);
+
+/**
+ * Returns the number of consecutive characters in <code>string</code>,
+ * beginning with the first, that do not occur somewhere in <code>matchSet</code>.
+ * Works just like C's strcspn but with Unicode.
+ *
+ * @param string The string in which to search, NUL-terminated.
+ * @param matchSet A NUL-terminated string defining a set of code points
+ *                 for which to search in the text string.
+ * @return The number of initial characters in <code>string</code> that do not
+ *         occur in <code>matchSet</code>.
+ * @see u_strspn
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strcspn(const UChar *string, const UChar *matchSet);
+
+/**
+ * Returns the number of consecutive characters in <code>string</code>,
+ * beginning with the first, that occur somewhere in <code>matchSet</code>.
+ * Works just like C's strspn but with Unicode.
+ *
+ * @param string The string in which to search, NUL-terminated.
+ * @param matchSet A NUL-terminated string defining a set of code points
+ *                 for which to search in the text string.
+ * @return The number of initial characters in <code>string</code> that do
+ *         occur in <code>matchSet</code>.
+ * @see u_strcspn
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strspn(const UChar *string, const UChar *matchSet);
+
+/**
+ * The string tokenizer API allows an application to break a string into
+ * tokens. Unlike strtok(), the saveState (the current pointer within the
+ * original string) is maintained in saveState. In the first call, the
+ * argument src is a pointer to the string. In subsequent calls to
+ * return successive tokens of that string, src must be specified as
+ * NULL. The value saveState is set by this function to maintain the
+ * function's position within the string, and on each subsequent call
+ * you must give this argument the same variable. This function does
+ * handle surrogate pairs. This function is similar to the strtok_r()
+ * the POSIX Threads Extension (1003.1c-1995) version.
+ *
+ * @param src String containing token(s). This string will be modified.
+ *            After the first call to u_strtok_r(), this argument must
+ *            be NULL to get to the next token.
+ * @param delim Set of delimiter characters (Unicode code points).
+ * @param saveState The current pointer within the original string,
+ *              which is set by this function. The saveState
+ *              parameter should the address of a local variable of type
+ *              UChar *. (i.e. defined "Uhar *myLocalSaveState" and use
+ *              &myLocalSaveState for this parameter).
+ * @return A pointer to the next token found in src, or NULL
+ *         when there are no more tokens.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar * U_EXPORT2
+u_strtok_r(UChar    *src, 
+     const UChar    *delim,
+           UChar   **saveState);
+
+/**
+ * Compare two Unicode strings for bitwise equality (code unit order).
+ *
+ * @param s1 A string to compare.
+ * @param s2 A string to compare.
+ * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative
+ * value if <code>s1</code> is bitwise less than <code>s2,</code>; a positive
+ * value if <code>s1</code> is bitwise greater than <code>s2</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t  U_EXPORT2
+u_strcmp(const UChar     *s1, 
+         const UChar     *s2);
+
+/**
+ * Compare two Unicode strings in code point order.
+ * See u_strCompare for details.
+ *
+ * @param s1 A string to compare.
+ * @param s2 A string to compare.
+ * @return a negative/zero/positive integer corresponding to whether
+ * the first string is less than/equal to/greater than the second one
+ * in code point order
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strcmpCodePointOrder(const UChar *s1, const UChar *s2);
+
+/**
+ * Compare two Unicode strings (binary order).
+ *
+ * The comparison can be done in code unit order or in code point order.
+ * They differ only in UTF-16 when
+ * comparing supplementary code points (U+10000..U+10ffff)
+ * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff).
+ * In code unit order, high BMP code points sort after supplementary code points
+ * because they are stored as pairs of surrogates which are at U+d800..U+dfff.
+ *
+ * This functions works with strings of different explicitly specified lengths
+ * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
+ * NUL-terminated strings are possible with length arguments of -1.
+ *
+ * @param s1 First source string.
+ * @param length1 Length of first source string, or -1 if NUL-terminated.
+ *
+ * @param s2 Second source string.
+ * @param length2 Length of second source string, or -1 if NUL-terminated.
+ *
+ * @param codePointOrder Choose between code unit order (FALSE)
+ *                       and code point order (TRUE).
+ *
+ * @return <0 or 0 or >0 as usual for string comparisons
+ *
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_strCompare(const UChar *s1, int32_t length1,
+             const UChar *s2, int32_t length2,
+             UBool codePointOrder);
+
+/**
+ * Compare two Unicode strings (binary order)
+ * as presented by UCharIterator objects.
+ * Works otherwise just like u_strCompare().
+ *
+ * Both iterators are reset to their start positions.
+ * When the function returns, it is undefined where the iterators
+ * have stopped.
+ *
+ * @param iter1 First source string iterator.
+ * @param iter2 Second source string iterator.
+ * @param codePointOrder Choose between code unit order (FALSE)
+ *                       and code point order (TRUE).
+ *
+ * @return <0 or 0 or >0 as usual for string comparisons
+ *
+ * @see u_strCompare
+ *
+ * @stable ICU 2.6
+ */
+U_STABLE int32_t U_EXPORT2
+u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder);
+
+#ifndef U_COMPARE_CODE_POINT_ORDER
+/* see also unistr.h and unorm.h */
+/**
+ * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:
+ * Compare strings in code point order instead of code unit order.
+ * @stable ICU 2.2
+ */
+#define U_COMPARE_CODE_POINT_ORDER  0x8000
+#endif
+
+/**
+ * Compare two strings case-insensitively using full case folding.
+ * This is equivalent to
+ *   u_strCompare(u_strFoldCase(s1, options),
+ *                u_strFoldCase(s2, options),
+ *                (options&U_COMPARE_CODE_POINT_ORDER)!=0).
+ *
+ * The comparison can be done in UTF-16 code unit order or in code point order.
+ * They differ only when comparing supplementary code points (U+10000..U+10ffff)
+ * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff).
+ * In code unit order, high BMP code points sort after supplementary code points
+ * because they are stored as pairs of surrogates which are at U+d800..U+dfff.
+ *
+ * This functions works with strings of different explicitly specified lengths
+ * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
+ * NUL-terminated strings are possible with length arguments of -1.
+ *
+ * @param s1 First source string.
+ * @param length1 Length of first source string, or -1 if NUL-terminated.
+ *
+ * @param s2 Second source string.
+ * @param length2 Length of second source string, or -1 if NUL-terminated.
+ *
+ * @param options A bit set of options:
+ *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+ *     Comparison in code unit order with default case folding.
+ *
+ *   - U_COMPARE_CODE_POINT_ORDER
+ *     Set to choose code point order instead of code unit order
+ *     (see u_strCompare for details).
+ *
+ *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ *
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ *
+ * @return <0 or 0 or >0 as usual for string comparisons
+ *
+ * @stable ICU 2.2
+ */
+U_STABLE int32_t U_EXPORT2
+u_strCaseCompare(const UChar *s1, int32_t length1,
+                 const UChar *s2, int32_t length2,
+                 uint32_t options,
+                 UErrorCode *pErrorCode);
+
+/**
+ * Compare two ustrings for bitwise equality. 
+ * Compares at most <code>n</code> characters.
+ *
+ * @param ucs1 A string to compare.
+ * @param ucs2 A string to compare.
+ * @param n The maximum number of characters to compare.
+ * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative
+ * value if <code>s1</code> is bitwise less than <code>s2</code>; a positive
+ * value if <code>s1</code> is bitwise greater than <code>s2</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strncmp(const UChar     *ucs1, 
+     const UChar     *ucs2, 
+     int32_t     n);
+
+/**
+ * Compare two Unicode strings in code point order.
+ * This is different in UTF-16 from u_strncmp() if supplementary characters are present.
+ * For details, see u_strCompare().
+ *
+ * @param s1 A string to compare.
+ * @param s2 A string to compare.
+ * @param n The maximum number of characters to compare.
+ * @return a negative/zero/positive integer corresponding to whether
+ * the first string is less than/equal to/greater than the second one
+ * in code point order
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);
+
+/**
+ * Compare two strings case-insensitively using full case folding.
+ * This is equivalent to u_strcmp(u_strFoldCase(s1, options), u_strFoldCase(s2, options)).
+ *
+ * @param s1 A string to compare.
+ * @param s2 A string to compare.
+ * @param options A bit set of options:
+ *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+ *     Comparison in code unit order with default case folding.
+ *
+ *   - U_COMPARE_CODE_POINT_ORDER
+ *     Set to choose code point order instead of code unit order
+ *     (see u_strCompare for details).
+ *
+ *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ *
+ * @return A negative, zero, or positive integer indicating the comparison result.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);
+
+/**
+ * Compare two strings case-insensitively using full case folding.
+ * This is equivalent to u_strcmp(u_strFoldCase(s1, at most n, options),
+ * u_strFoldCase(s2, at most n, options)).
+ *
+ * @param s1 A string to compare.
+ * @param s2 A string to compare.
+ * @param n The maximum number of characters each string to case-fold and then compare.
+ * @param options A bit set of options:
+ *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+ *     Comparison in code unit order with default case folding.
+ *
+ *   - U_COMPARE_CODE_POINT_ORDER
+ *     Set to choose code point order instead of code unit order
+ *     (see u_strCompare for details).
+ *
+ *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ *
+ * @return A negative, zero, or positive integer indicating the comparison result.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);
+
+/**
+ * Compare two strings case-insensitively using full case folding.
+ * This is equivalent to u_strcmp(u_strFoldCase(s1, n, options),
+ * u_strFoldCase(s2, n, options)).
+ *
+ * @param s1 A string to compare.
+ * @param s2 A string to compare.
+ * @param length The number of characters in each string to case-fold and then compare.
+ * @param options A bit set of options:
+ *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
+ *     Comparison in code unit order with default case folding.
+ *
+ *   - U_COMPARE_CODE_POINT_ORDER
+ *     Set to choose code point order instead of code unit order
+ *     (see u_strCompare for details).
+ *
+ *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ *
+ * @return A negative, zero, or positive integer indicating the comparison result.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options);
+
+/**
+ * Copy a ustring. Adds a null terminator.
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_strcpy(UChar     *dst, 
+    const UChar     *src);
+
+/**
+ * Copy a ustring.
+ * Copies at most <code>n</code> characters.  The result will be null terminated
+ * if the length of <code>src</code> is less than <code>n</code>.
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @param n The maximum number of characters to copy.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_strncpy(UChar     *dst, 
+     const UChar     *src, 
+     int32_t     n);
+
+#if !UCONFIG_NO_CONVERSION
+
+/**
+ * Copy a byte string encoded in the default codepage to a ustring.
+ * Adds a null terminator.
+ * Performs a host byte to UChar conversion
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
+               const char *src );
+
+/**
+ * Copy a byte string encoded in the default codepage to a ustring.
+ * Copies at most <code>n</code> characters.  The result will be null terminated
+ * if the length of <code>src</code> is less than <code>n</code>.
+ * Performs a host byte to UChar conversion
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @param n The maximum number of characters to copy.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
+            const char *src,
+            int32_t n);
+
+/**
+ * Copy ustring to a byte string encoded in the default codepage.
+ * Adds a null terminator.
+ * Performs a UChar to host byte conversion
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE char* U_EXPORT2 u_austrcpy(char *dst,
+            const UChar *src );
+
+/**
+ * Copy ustring to a byte string encoded in the default codepage.
+ * Copies at most <code>n</code> characters.  The result will be null terminated
+ * if the length of <code>src</code> is less than <code>n</code>.
+ * Performs a UChar to host byte conversion
+ *
+ * @param dst The destination string.
+ * @param src The source string.
+ * @param n The maximum number of characters to copy.
+ * @return A pointer to <code>dst</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE char* U_EXPORT2 u_austrncpy(char *dst,
+            const UChar *src,
+            int32_t n );
+
+#endif
+
+/**
+ * Synonym for memcpy(), but with UChars only.
+ * @param dest The destination string
+ * @param src The source string
+ * @param count The number of characters to copy
+ * @return A pointer to <code>dest</code>
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_memcpy(UChar *dest, const UChar *src, int32_t count);
+
+/**
+ * Synonym for memmove(), but with UChars only.
+ * @param dest The destination string
+ * @param src The source string
+ * @param count The number of characters to move
+ * @return A pointer to <code>dest</code>
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_memmove(UChar *dest, const UChar *src, int32_t count);
+
+/**
+ * Initialize <code>count</code> characters of <code>dest</code> to <code>c</code>.
+ *
+ * @param dest The destination string.
+ * @param c The character to initialize the string.
+ * @param count The maximum number of characters to set.
+ * @return A pointer to <code>dest</code>.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_memset(UChar *dest, UChar c, int32_t count);
+
+/**
+ * Compare the first <code>count</code> UChars of each buffer.
+ *
+ * @param buf1 The first string to compare.
+ * @param buf2 The second string to compare.
+ * @param count The maximum number of UChars to compare.
+ * @return When buf1 < buf2, a negative number is returned.
+ *      When buf1 == buf2, 0 is returned.
+ *      When buf1 > buf2, a positive number is returned.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count);
+
+/**
+ * Compare two Unicode strings in code point order.
+ * This is different in UTF-16 from u_memcmp() if supplementary characters are present.
+ * For details, see u_strCompare().
+ *
+ * @param s1 A string to compare.
+ * @param s2 A string to compare.
+ * @param count The maximum number of characters to compare.
+ * @return a negative/zero/positive integer corresponding to whether
+ * the first string is less than/equal to/greater than the second one
+ * in code point order
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count);
+
+/**
+ * Find the first occurrence of a BMP code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (contains <code>count</code> UChars).
+ * @param c The BMP code point to find.
+ * @param count The length of the string.
+ * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.0
+ *
+ * @see u_strchr
+ * @see u_memchr32
+ * @see u_strFindFirst
+ */
+U_STABLE UChar* U_EXPORT2
+u_memchr(const UChar *s, UChar c, int32_t count);
+
+/**
+ * Find the first occurrence of a code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (contains <code>count</code> UChars).
+ * @param c The code point to find.
+ * @param count The length of the string.
+ * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.0
+ *
+ * @see u_strchr32
+ * @see u_memchr
+ * @see u_strFindFirst
+ */
+U_STABLE UChar* U_EXPORT2
+u_memchr32(const UChar *s, UChar32 c, int32_t count);
+
+/**
+ * Find the last occurrence of a BMP code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (contains <code>count</code> UChars).
+ * @param c The BMP code point to find.
+ * @param count The length of the string.
+ * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.4
+ *
+ * @see u_strrchr
+ * @see u_memrchr32
+ * @see u_strFindLast
+ */
+U_STABLE UChar* U_EXPORT2
+u_memrchr(const UChar *s, UChar c, int32_t count);
+
+/**
+ * Find the last occurrence of a code point in a string.
+ * A surrogate code point is found only if its match in the text is not
+ * part of a surrogate pair.
+ * A NUL character is found at the string terminator.
+ *
+ * @param s The string to search (contains <code>count</code> UChars).
+ * @param c The code point to find.
+ * @param count The length of the string.
+ * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
+ *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
+ * @stable ICU 2.4
+ *
+ * @see u_strrchr32
+ * @see u_memrchr
+ * @see u_strFindLast
+ */
+U_STABLE UChar* U_EXPORT2
+u_memrchr32(const UChar *s, UChar32 c, int32_t count);
+
+/**
+ * Unicode String literals in C.
+ * We need one macro to declare a variable for the string
+ * and to statically preinitialize it if possible,
+ * and a second macro to dynamically intialize such a string variable if necessary.
+ *
+ * The macros are defined for maximum performance.
+ * They work only for strings that contain "invariant characters", i.e.,
+ * only latin letters, digits, and some punctuation.
+ * See utypes.h for details.
+ *
+ * A pair of macros for a single string must be used with the same
+ * parameters.
+ * The string parameter must be a C string literal.
+ * The length of the string, not including the terminating
+ * <code>NUL</code>, must be specified as a constant.
+ * The U_STRING_DECL macro should be invoked exactly once for one
+ * such string variable before it is used.
+ *
+ * Usage:
+ * <pre>
+ *    U_STRING_DECL(ustringVar1, "Quick-Fox 2", 11);
+ *    U_STRING_DECL(ustringVar2, "jumps 5%", 8);
+ *    static UBool didInit=FALSE;
+ * 
+ *    int32_t function() {
+ *        if(!didInit) {
+ *            U_STRING_INIT(ustringVar1, "Quick-Fox 2", 11);
+ *            U_STRING_INIT(ustringVar2, "jumps 5%", 8);
+ *            didInit=TRUE;
+ *        }
+ *        return u_strcmp(ustringVar1, ustringVar2);
+ *    }
+ * </pre>
+ * @stable ICU 2.0
+ */
+#if defined(U_DECLARE_UTF16)
+#   define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=U_DECLARE_UTF16(cs)
+    /**@stable ICU 2.0 */
+#   define U_STRING_INIT(var, cs, length)
+#elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
+#   define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=L ## cs
+    /**@stable ICU 2.0 */
+#   define U_STRING_INIT(var, cs, length)
+#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
+#   define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=cs
+    /**@stable ICU 2.0 */
+#   define U_STRING_INIT(var, cs, length)
+#else
+#   define U_STRING_DECL(var, cs, length) static UChar var[(length)+1]
+    /**@stable ICU 2.0 */
+#   define U_STRING_INIT(var, cs, length) u_charsToUChars(cs, var, length+1)
+#endif
+
+/**
+ * Unescape a string of characters and write the resulting
+ * Unicode characters to the destination buffer.  The following escape
+ * sequences are recognized:
+ *
+ * \\uhhhh       4 hex digits; h in [0-9A-Fa-f]
+ * \\Uhhhhhhhh   8 hex digits
+ * \\xhh         1-2 hex digits
+ * \\x{h...}     1-8 hex digits
+ * \\ooo         1-3 octal digits; o in [0-7]
+ * \\cX          control-X; X is masked with 0x1F
+ *
+ * as well as the standard ANSI C escapes:
+ *
+ * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A,
+ * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B,
+ * \\" => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C
+ *
+ * Anything else following a backslash is generically escaped.  For
+ * example, "[a\\-z]" returns "[a-z]".
+ *
+ * If an escape sequence is ill-formed, this method returns an empty
+ * string.  An example of an ill-formed sequence is "\\u" followed by
+ * fewer than 4 hex digits.
+ *
+ * The above characters are recognized in the compiler's codepage,
+ * that is, they are coded as 'u', '\\', etc.  Characters that are
+ * not parts of escape sequences are converted using u_charsToUChars().
+ *
+ * This function is similar to UnicodeString::unescape() but not
+ * identical to it.  The latter takes a source UnicodeString, so it
+ * does escape recognition but no conversion.
+ *
+ * @param src a zero-terminated string of invariant characters
+ * @param dest pointer to buffer to receive converted and unescaped
+ * text and, if there is room, a zero terminator.  May be NULL for
+ * preflighting, in which case no UChars will be written, but the
+ * return value will still be valid.  On error, an empty string is
+ * stored here (if possible).
+ * @param destCapacity the number of UChars that may be written at
+ * dest.  Ignored if dest == NULL.
+ * @return the length of unescaped string.
+ * @see u_unescapeAt
+ * @see UnicodeString#unescape()
+ * @see UnicodeString#unescapeAt()
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_unescape(const char *src,
+           UChar *dest, int32_t destCapacity);
+
+U_CDECL_BEGIN
+/**
+ * Callback function for u_unescapeAt() that returns a character of
+ * the source text given an offset and a context pointer.  The context
+ * pointer will be whatever is passed into u_unescapeAt().
+ *
+ * @param offset pointer to the offset that will be passed to u_unescapeAt().
+ * @param context an opaque pointer passed directly into u_unescapeAt()
+ * @return the character represented by the escape sequence at
+ * offset
+ * @see u_unescapeAt
+ * @stable ICU 2.0
+ */
+typedef UChar (U_CALLCONV *UNESCAPE_CHAR_AT)(int32_t offset, void *context);
+U_CDECL_END
+
+/**
+ * Unescape a single sequence. The character at offset-1 is assumed
+ * (without checking) to be a backslash.  This method takes a callback
+ * pointer to a function that returns the UChar at a given offset.  By
+ * varying this callback, ICU functions are able to unescape char*
+ * strings, UnicodeString objects, and UFILE pointers.
+ *
+ * If offset is out of range, or if the escape sequence is ill-formed,
+ * (UChar32)0xFFFFFFFF is returned.  See documentation of u_unescape()
+ * for a list of recognized sequences.
+ *
+ * @param charAt callback function that returns a UChar of the source
+ * text given an offset and a context pointer.
+ * @param offset pointer to the offset that will be passed to charAt.
+ * The offset value will be updated upon return to point after the
+ * last parsed character of the escape sequence.  On error the offset
+ * is unchanged.
+ * @param length the number of characters in the source text.  The
+ * last character of the source text is considered to be at offset
+ * length-1.
+ * @param context an opaque pointer passed directly into charAt.
+ * @return the character represented by the escape sequence at
+ * offset, or (UChar32)0xFFFFFFFF on error.
+ * @see u_unescape()
+ * @see UnicodeString#unescape()
+ * @see UnicodeString#unescapeAt()
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32 U_EXPORT2
+u_unescapeAt(UNESCAPE_CHAR_AT charAt,
+             int32_t *offset,
+             int32_t length,
+             void *context);
+
+/**
+ * Uppercase the characters in a string.
+ * Casing is locale-dependent and context-sensitive.
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer are allowed to overlap.
+ *
+ * @param dest      A buffer for the result string. The result will be zero-terminated if
+ *                  the buffer is large enough.
+ * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string
+ * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
+ * @param locale    The locale to consider, or "" for the root locale or NULL for the default locale.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string. It may be greater than destCapacity. In that case,
+ *         only some of the result was written to the destination buffer.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strToUpper(UChar *dest, int32_t destCapacity,
+             const UChar *src, int32_t srcLength,
+             const char *locale,
+             UErrorCode *pErrorCode);
+
+/**
+ * Lowercase the characters in a string.
+ * Casing is locale-dependent and context-sensitive.
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer are allowed to overlap.
+ *
+ * @param dest      A buffer for the result string. The result will be zero-terminated if
+ *                  the buffer is large enough.
+ * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string
+ * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
+ * @param locale    The locale to consider, or "" for the root locale or NULL for the default locale.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string. It may be greater than destCapacity. In that case,
+ *         only some of the result was written to the destination buffer.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strToLower(UChar *dest, int32_t destCapacity,
+             const UChar *src, int32_t srcLength,
+             const char *locale,
+             UErrorCode *pErrorCode);
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+/**
+ * Titlecase a string.
+ * Casing is locale-dependent and context-sensitive.
+ * Titlecasing uses a break iterator to find the first characters of words
+ * that are to be titlecased. It titlecases those characters and lowercases
+ * all others.
+ *
+ * The titlecase break iterator can be provided to customize for arbitrary
+ * styles, using rules and dictionaries beyond the standard iterators.
+ * It may be more efficient to always provide an iterator to avoid
+ * opening and closing one for each string.
+ * The standard titlecase iterator for the root locale implements the
+ * algorithm of Unicode TR 21.
+ *
+ * This function uses only the setText(), first() and next() methods of the
+ * provided break iterator.
+ *
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer are allowed to overlap.
+ *
+ * @param dest      A buffer for the result string. The result will be zero-terminated if
+ *                  the buffer is large enough.
+ * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string
+ * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
+ * @param titleIter A break iterator to find the first characters of words
+ *                  that are to be titlecased.
+ *                  If none is provided (NULL), then a standard titlecase
+ *                  break iterator is opened.
+ * @param locale    The locale to consider, or "" for the root locale or NULL for the default locale.
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string. It may be greater than destCapacity. In that case,
+ *         only some of the result was written to the destination buffer.
+ * @stable ICU 2.1
+ */
+U_STABLE int32_t U_EXPORT2
+u_strToTitle(UChar *dest, int32_t destCapacity,
+             const UChar *src, int32_t srcLength,
+             UBreakIterator *titleIter,
+             const char *locale,
+             UErrorCode *pErrorCode);
+
+#endif
+
+/**
+ * Case-fold the characters in a string.
+ * Case-folding is locale-independent and not context-sensitive,
+ * but there is an option for whether to include or exclude mappings for dotted I
+ * and dotless i that are marked with 'I' in CaseFolding.txt.
+ * The result may be longer or shorter than the original.
+ * The source string and the destination buffer are allowed to overlap.
+ *
+ * @param dest      A buffer for the result string. The result will be zero-terminated if
+ *                  the buffer is large enough.
+ * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
+ *                  dest may be NULL and the function will only return the length of the result
+ *                  without writing any of the result string.
+ * @param src       The original string
+ * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
+ * @param options   Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I
+ * @param pErrorCode Must be a valid pointer to an error code value,
+ *                  which must not indicate a failure before the function call.
+ * @return The length of the result string. It may be greater than destCapacity. In that case,
+ *         only some of the result was written to the destination buffer.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2
+u_strFoldCase(UChar *dest, int32_t destCapacity,
+              const UChar *src, int32_t srcLength,
+              uint32_t options,
+              UErrorCode *pErrorCode);
+
+#if defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION
+/**
+ * Converts a sequence of UChars to wchar_t units.
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of wchar_t's). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param pErrorCode    Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @return The pointer to destination buffer.
+ * @stable ICU 2.0
+ */
+U_STABLE wchar_t* U_EXPORT2
+u_strToWCS(wchar_t *dest, 
+           int32_t destCapacity,
+           int32_t *pDestLength,
+           const UChar *src, 
+           int32_t srcLength,
+           UErrorCode *pErrorCode);
+/**
+ * Converts a sequence of wchar_t units to UChars
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param pErrorCode    Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @return The pointer to destination buffer.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2
+u_strFromWCS(UChar   *dest,
+             int32_t destCapacity, 
+             int32_t *pDestLength,
+             const wchar_t *src,
+             int32_t srcLength,
+             UErrorCode *pErrorCode);
+#endif /* defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION */
+
+/**
+ * Converts a sequence of UChars (UTF-16) to UTF-8 bytes
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of chars). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param pErrorCode    Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @return The pointer to destination buffer.
+ * @stable ICU 2.0
+ * @see u_strToUTF8WithSub
+ * @see u_strFromUTF8
+ */
+U_STABLE char* U_EXPORT2 
+u_strToUTF8(char *dest,           
+            int32_t destCapacity,
+            int32_t *pDestLength,
+            const UChar *src, 
+            int32_t srcLength,
+            UErrorCode *pErrorCode);
+
+/**
+ * Converts a sequence of UTF-8 bytes to UChars (UTF-16).
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param pErrorCode    Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @return The pointer to destination buffer.
+ * @stable ICU 2.0
+ * @see u_strFromUTF8WithSub
+ * @see u_strFromUTF8Lenient
+ */
+U_STABLE UChar* U_EXPORT2
+u_strFromUTF8(UChar *dest,             
+              int32_t destCapacity,
+              int32_t *pDestLength,
+              const char *src, 
+              int32_t srcLength,
+              UErrorCode *pErrorCode);
+
+/**
+ * Converts a sequence of UChars (UTF-16) to UTF-8 bytes.
+ * Same as u_strToUTF8() except for the additional subchar which is output for
+ * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.
+ * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF8().
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of chars). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param subchar       The substitution character to use in place of an illegal input sequence,
+ *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.
+ *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)
+ *                      except for surrogate code points (U+D800..U+DFFF).
+ *                      The recommended value is U+FFFD "REPLACEMENT CHARACTER".
+ * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.
+ *                      Set to 0 if no substitutions occur or subchar<0.
+ *                      pNumSubstitutions can be NULL.
+ * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
+ *                      pass the U_SUCCESS() test, or else the function returns
+ *                      immediately. Check for U_FAILURE() on output or use with
+ *                      function chaining. (See User Guide for details.)
+ * @return The pointer to destination buffer.
+ * @see u_strToUTF8
+ * @see u_strFromUTF8WithSub
+ * @stable ICU 3.6
+ */
+U_STABLE char* U_EXPORT2
+u_strToUTF8WithSub(char *dest,
+            int32_t destCapacity,
+            int32_t *pDestLength,
+            const UChar *src,
+            int32_t srcLength,
+            UChar32 subchar, int32_t *pNumSubstitutions,
+            UErrorCode *pErrorCode);
+
+/**
+ * Converts a sequence of UTF-8 bytes to UChars (UTF-16).
+ * Same as u_strFromUTF8() except for the additional subchar which is output for
+ * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.
+ * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF8().
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param subchar       The substitution character to use in place of an illegal input sequence,
+ *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.
+ *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)
+ *                      except for surrogate code points (U+D800..U+DFFF).
+ *                      The recommended value is U+FFFD "REPLACEMENT CHARACTER".
+ * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.
+ *                      Set to 0 if no substitutions occur or subchar<0.
+ *                      pNumSubstitutions can be NULL.
+ * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
+ *                      pass the U_SUCCESS() test, or else the function returns
+ *                      immediately. Check for U_FAILURE() on output or use with
+ *                      function chaining. (See User Guide for details.)
+ * @return The pointer to destination buffer.
+ * @see u_strFromUTF8
+ * @see u_strFromUTF8Lenient
+ * @see u_strToUTF8WithSub
+ * @stable ICU 3.6
+ */
+U_STABLE UChar* U_EXPORT2
+u_strFromUTF8WithSub(UChar *dest,
+              int32_t destCapacity,
+              int32_t *pDestLength,
+              const char *src,
+              int32_t srcLength,
+              UChar32 subchar, int32_t *pNumSubstitutions,
+              UErrorCode *pErrorCode);
+
+/**
+ * Converts a sequence of UTF-8 bytes to UChars (UTF-16).
+ * Same as u_strFromUTF8() except that this function is designed to be very fast,
+ * which it achieves by being lenient about malformed UTF-8 sequences.
+ * This function is intended for use in environments where UTF-8 text is
+ * expected to be well-formed.
+ *
+ * Its semantics are:
+ * - Well-formed UTF-8 text is correctly converted to well-formed UTF-16 text.
+ * - The function will not read beyond the input string, nor write beyond
+ *   the destCapacity.
+ * - Malformed UTF-8 results in "garbage" 16-bit Unicode strings which may not
+ *   be well-formed UTF-16.
+ *   The function will resynchronize to valid code point boundaries
+ *   within a small number of code points after an illegal sequence.
+ * - Non-shortest forms are not detected and will result in "spoofing" output.
+ *
+ * For further performance improvement, if srcLength is given (>=0),
+ * then it must be destCapacity>=srcLength.
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ *                      Unlike for other ICU functions, if srcLength>=0 then it
+ *                      must be destCapacity>=srcLength.
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ *                      Unlike for other ICU functions, if srcLength>=0 but
+ *                      destCapacity<srcLength, then *pDestLength will be set to srcLength
+ *                      (and U_BUFFER_OVERFLOW_ERROR will be set)
+ *                      regardless of the actual result length.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
+ *                      pass the U_SUCCESS() test, or else the function returns
+ *                      immediately. Check for U_FAILURE() on output or use with
+ *                      function chaining. (See User Guide for details.)
+ * @return The pointer to destination buffer.
+ * @see u_strFromUTF8
+ * @see u_strFromUTF8WithSub
+ * @see u_strToUTF8WithSub
+ * @stable ICU 3.6
+ */
+U_STABLE UChar * U_EXPORT2
+u_strFromUTF8Lenient(UChar *dest,
+                     int32_t destCapacity,
+                     int32_t *pDestLength,
+                     const char *src,
+                     int32_t srcLength,
+                     UErrorCode *pErrorCode);
+
+/**
+ * Converts a sequence of UChars (UTF-16) to UTF32 units.
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of UChar32s). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param pErrorCode    Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @return The pointer to destination buffer.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar32* U_EXPORT2 
+u_strToUTF32(UChar32 *dest, 
+             int32_t  destCapacity,
+             int32_t  *pDestLength,
+             const UChar *src, 
+             int32_t  srcLength,
+             UErrorCode *pErrorCode);
+
+/**
+ * Converts a sequence of UTF32 units to UChars (UTF-16)
+ *
+ * @param dest          A buffer for the result string. The result will be zero-terminated if
+ *                      the buffer is large enough.
+ * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
+ *                      dest may be NULL and the function will only return the length of the 
+ *                      result without writing any of the result string (pre-flighting).
+ * @param pDestLength   A pointer to receive the number of units written to the destination. If 
+ *                      pDestLength!=NULL then *pDestLength is always set to the 
+ *                      number of output units corresponding to the transformation of 
+ *                      all the input units, even in case of a buffer overflow.
+ * @param src           The original source string
+ * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
+ * @param pErrorCode    Must be a valid pointer to an error code value,
+ *                      which must not indicate a failure before the function call.
+ * @return The pointer to destination buffer.
+ * @stable ICU 2.0
+ */
+U_STABLE UChar* U_EXPORT2 
+u_strFromUTF32(UChar   *dest,
+               int32_t destCapacity, 
+               int32_t *pDestLength,
+               const UChar32 *src,
+               int32_t srcLength,
+               UErrorCode *pErrorCode);
+
+#endif
diff --git a/CoreFoundation/icu/unicode/usystem.h b/CoreFoundation/icu/unicode/usystem.h
new file mode 100644
index 0000000..752e2f1
--- /dev/null
+++ b/CoreFoundation/icu/unicode/usystem.h
@@ -0,0 +1,46 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2004-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Created by: genheaders.pl, a perl script written by Ram Viswanadha
+*
+*  Contains data for commenting out APIs.
+*  Gets included by umachine.h
+*
+*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
+*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
+*/
+
+#ifndef USYSTEM_H
+#define USYSTEM_H
+
+#ifdef U_HIDE_SYSTEM_API
+
+#    if U_DISABLE_RENAMING
+#        define u_cleanup u_cleanup_SYSTEM_API_DO_NOT_USE
+#        define u_setAtomicIncDecFunctions u_setAtomicIncDecFunctions_SYSTEM_API_DO_NOT_USE
+#        define u_setMemoryFunctions u_setMemoryFunctions_SYSTEM_API_DO_NOT_USE
+#        define u_setMutexFunctions u_setMutexFunctions_SYSTEM_API_DO_NOT_USE
+#        define ucnv_setDefaultName ucnv_setDefaultName_SYSTEM_API_DO_NOT_USE
+#        define uloc_getDefault uloc_getDefault_SYSTEM_API_DO_NOT_USE
+#        define uloc_setDefault uloc_setDefault_SYSTEM_API_DO_NOT_USE
+#    else
+#        define u_cleanup_4_0 u_cleanup_SYSTEM_API_DO_NOT_USE
+#        define u_setAtomicIncDecFunctions_4_0 u_setAtomicIncDecFunctions_SYSTEM_API_DO_NOT_USE
+#        define u_setMemoryFunctions_4_0 u_setMemoryFunctions_SYSTEM_API_DO_NOT_USE
+#        define u_setMutexFunctions_4_0 u_setMutexFunctions_SYSTEM_API_DO_NOT_USE
+#        define ucnv_setDefaultName_4_0 ucnv_setDefaultName_SYSTEM_API_DO_NOT_USE
+#        define uloc_getDefault_4_0 uloc_getDefault_SYSTEM_API_DO_NOT_USE
+#        define uloc_setDefault_4_0 uloc_setDefault_SYSTEM_API_DO_NOT_USE
+#    endif /* U_DISABLE_RENAMING */
+
+#endif /* U_HIDE_SYSTEM_API */
+#endif /* USYSTEM_H */
+
diff --git a/CoreFoundation/icu/unicode/utext.h b/CoreFoundation/icu/unicode/utext.h
new file mode 100644
index 0000000..866b850
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utext.h
@@ -0,0 +1,1562 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2004-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  utext.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2004oct06
+*   created by: Markus W. Scherer
+*/
+
+#ifndef __UTEXT_H__
+#define __UTEXT_H__
+
+/**
+ * \file
+ * \brief C API: Abstract Unicode Text API
+ *
+ * The Text Access API provides a means to allow text that is stored in alternative
+ * formats to work with ICU services.  ICU normally operates on text that is
+ * stored in UTF-16 format, in (UChar *) arrays for the C APIs or as type
+ * UnicodeString for C++ APIs.
+ *
+ * ICU Text Access allows other formats, such as UTF-8 or non-contiguous
+ * UTF-16 strings, to be placed in a UText wrapper and then passed to ICU services.
+ *
+ * There are three general classes of usage for UText:
+ *
+ *     Application Level Use.  This is the simplest usage - applications would
+ *     use one of the utext_open() functions on their input text, and pass
+ *     the resulting UText to the desired ICU service.
+ *
+ *     Second is usage in ICU Services, such as break iteration, that will need to
+ *     operate on input presented to them as a UText.  These implementations
+ *     will need to use the iteration and related UText functions to gain
+ *     access to the actual text.
+ *
+ *     The third class of UText users are "text providers."  These are the
+ *     UText implementations for the various text storage formats.  An application
+ *     or system with a unique text storage format can implement a set of
+ *     UText provider functions for that format, which will then allow
+ *     ICU services to operate on that format.
+ *
+ *
+ * <em>Iterating over text</em>
+ *
+ * Here is sample code for a forward iteration over the contents of a UText
+ *
+ * \code
+ *    UChar32  c;
+ *    UText    *ut = whatever();
+ *
+ *    for (c=utext_next32From(ut, 0); c>=0; c=utext_next32(ut)) {
+ *       // do whatever with the codepoint c here.
+ *    }
+ * \endcode
+ *
+ * And here is similar code to iterate in the reverse direction, from the end
+ * of the text towards the beginning.
+ *
+ * \code
+ *    UChar32  c;
+ *    UText    *ut = whatever();
+ *    int      textLength = utext_nativeLength(ut);
+ *    for (c=utext_previous32From(ut, textLength); c>=0; c=utext_previous32(ut)) {
+ *       // do whatever with the codepoint c here.
+ *    }
+ * \endcode
+ *
+ * <em>Characters and Indexing</em>
+ *
+ * Indexing into text by UText functions is nearly always in terms of the native
+ * indexing of the underlying text storage.  The storage format could be UTF-8
+ * or UTF-32, for example.  When coding to the UText access API, no assumptions
+ * can be made regarding the size of characters, or how far an index
+ * may move when iterating between characters.
+ *
+ * All indices supplied to UText functions are pinned to the length of the
+ * text.  An out-of-bounds index is not considered to be an error, but is
+ * adjusted to be in the range  0 <= index <= length of input text.
+ *
+ *
+ * When an index position is returned from a UText function, it will be
+ * a native index to the underlying text.  In the case of multi-unit characters,
+ * it will  always refer to the first position of the character,
+ * never to the interior.  This is essentially the same thing as saying that
+ * a returned index will always point to a boundary between characters.
+ *
+ * When a native index is supplied to a UText function, all indices that
+ * refer to any part of a multi-unit character representation are considered
+ * to be equivalent.  In the case of multi-unit characters, an incoming index
+ * will be logically normalized to refer to the start of the character.
+ * 
+ * It is possible to test whether a native index is on a code point boundary
+ * by doing a utext_setNativeIndex() followed by a utext_getNativeIndex().
+ * If the index is returned unchanged, it was on a code point boundary.  If
+ * an adjusted index is returned, the original index referred to the
+ * interior of a character.
+ *
+ * <em>Conventions for calling UText functions</em>
+ *
+ * Most UText access functions have as their first parameter a (UText *) pointer,
+ * which specifies the UText to be used.  Unless otherwise noted, the
+ * pointer must refer to a valid, open UText.  Attempting to
+ * use a closed UText or passing a NULL pointer is a programming error and
+ * will produce undefined results or NULL pointer exceptions.
+ * 
+ * The UText_Open family of functions can either open an existing (closed)
+ * UText, or heap allocate a new UText.  Here is sample code for creating
+ * a stack-allocated UText.
+ *
+ * \code
+ *    char     *s = whatever();  // A utf-8 string 
+ *    U_ErrorCode status = U_ZERO_ERROR;
+ *    UText    ut = UTEXT_INITIALIZER;
+ *    utext_openUTF8(ut, s, -1, &status);
+ *    if (U_FAILURE(status)) {
+ *        // error handling
+ *    } else {
+ *        // work with the UText
+ *    }
+ * \endcode
+ *
+ * Any existing UText passed to an open function _must_ have been initialized, 
+ * either by the UTEXT_INITIALIZER, or by having been originally heap-allocated
+ * by an open function.  Passing NULL will cause the open function to
+ * heap-allocate and fully initialize a new UText.
+ *
+ */
+
+
+
+#include "unicode/utypes.h"
+#ifdef XP_CPLUSPLUS
+#include "unicode/rep.h"
+#include "unicode/unistr.h"
+#include "unicode/chariter.h"
+#endif
+
+
+U_CDECL_BEGIN
+
+struct UText;
+typedef struct UText UText; /**< C typedef for struct UText. @stable ICU 3.6 */
+
+
+/***************************************************************************************
+ *
+ *   C Functions for creating UText wrappers around various kinds of text strings.
+ *
+ ****************************************************************************************/
+
+
+/**
+  * Close function for UText instances.
+  * Cleans up, releases any resources being held by an open UText.
+  * <p>
+  *   If the UText was originally allocated by one of the utext_open functions,
+  *   the storage associated with the utext will also be freed.
+  *   If the UText storage originated with the application, as it would with
+  *   a local or static instance, the storage will not be deleted.
+  *
+  *   An open UText can be reset to refer to new string by using one of the utext_open()
+  *   functions without first closing the UText.  
+  *
+  * @param ut  The UText to be closed.
+  * @return    NULL if the UText struct was deleted by the close.  If the UText struct
+  *            was originally provided by the caller to the open function, it is
+  *            returned by this function, and may be safely used again in
+  *            a subsequent utext_open.
+  *
+  * @stable ICU 3.4
+  */
+U_STABLE UText * U_EXPORT2
+utext_close(UText *ut);
+
+
+/**
+ * Open a read-only UText implementation for UTF-8 strings.
+ * 
+ * \htmlonly
+ * Any invalid UTF-8 in the input will be handled in this way:
+ * a sequence of bytes that has the form of a truncated, but otherwise valid,
+ * UTF-8 sequence will be replaced by a single unicode replacement character, \uFFFD. 
+ * Any other illegal bytes will each be replaced by a \uFFFD.
+ * \endhtmlonly
+ * 
+ * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.
+ *               If non-NULL, must refer to an initialized UText struct, which will then
+ *               be reset to reference the specified UTF-8 string.
+ * @param s      A UTF-8 string.  Must not be NULL.
+ * @param length The length of the UTF-8 string in bytes, or -1 if the string is
+ *               zero terminated.
+ * @param status Errors are returned here.
+ * @return       A pointer to the UText.  If a pre-allocated UText was provided, it
+ *               will always be used and returned.
+ * @stable ICU 3.4
+ */
+U_STABLE UText * U_EXPORT2
+utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
+
+
+/**
+ * Open a read-only UText for UChar * string.
+ * 
+ * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.
+ *               If non-NULL, must refer to an initialized UText struct, which will then
+ *               be reset to reference the specified UChar string.
+ * @param s      A UChar (UTF-16) string
+ * @param length The number of UChars in the input string, or -1 if the string is
+ *               zero terminated.
+ * @param status Errors are returned here.
+ * @return       A pointer to the UText.  If a pre-allocated UText was provided, it
+ *               will always be used and returned.
+ * @stable ICU 3.4
+ */
+U_STABLE UText * U_EXPORT2
+utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
+
+
+#ifdef XP_CPLUSPLUS
+/**
+ * Open a writable UText for a non-const UnicodeString. 
+ * 
+ * @param ut      Pointer to a UText struct.  If NULL, a new UText will be created.
+ *                 If non-NULL, must refer to an initialized UText struct, which will then
+ *                 be reset to reference the specified input string.
+ * @param s       A UnicodeString.
+ * @param status Errors are returned here.
+ * @return        Pointer to the UText.  If a UText was supplied as input, this
+ *                 will always be used and returned.
+ * @stable ICU 3.4
+ */
+U_STABLE UText * U_EXPORT2
+utext_openUnicodeString(UText *ut, U_NAMESPACE_QUALIFIER UnicodeString *s, UErrorCode *status);
+
+
+/**
+ * Open a UText for a const UnicodeString.   The resulting UText will not be writable.
+ * 
+ * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
+ *               If non-NULL, must refer to an initialized UText struct, which will then
+ *               be reset to reference the specified input string.
+ * @param s      A const UnicodeString to be wrapped.
+ * @param status Errors are returned here.
+ * @return       Pointer to the UText.  If a UText was supplied as input, this
+ *               will always be used and returned.
+ * @stable ICU 3.4
+ */
+U_STABLE UText * U_EXPORT2
+utext_openConstUnicodeString(UText *ut, const U_NAMESPACE_QUALIFIER UnicodeString *s, UErrorCode *status);
+
+
+/**
+ * Open a writable UText implementation for an ICU Replaceable object.
+ * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
+ *               If non-NULL, must refer to an already existing UText, which will then
+ *               be reset to reference the specified replaceable text.
+ * @param rep    A Replaceable text object.
+ * @param status Errors are returned here.
+ * @return       Pointer to the UText.  If a UText was supplied as input, this
+ *               will always be used and returned.
+ * @see Replaceable
+ * @stable ICU 3.4
+ */
+U_STABLE UText * U_EXPORT2
+utext_openReplaceable(UText *ut, U_NAMESPACE_QUALIFIER Replaceable *rep, UErrorCode *status);
+
+/**
+ * Open a  UText implementation over an ICU CharacterIterator.
+ * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
+ *               If non-NULL, must refer to an already existing UText, which will then
+ *               be reset to reference the specified replaceable text.
+ * @param ci     A Character Iterator.
+ * @param status Errors are returned here.
+ * @return       Pointer to the UText.  If a UText was supplied as input, this
+ *               will always be used and returned.
+ * @see Replaceable
+ * @stable ICU 3.4
+ */
+U_STABLE UText * U_EXPORT2
+utext_openCharacterIterator(UText *ut, U_NAMESPACE_QUALIFIER CharacterIterator *ic, UErrorCode *status);
+
+#endif
+
+
+/**
+  *  Clone a UText.  This is much like opening a UText where the source text is itself
+  *  another UText.
+  *
+  *  A deep clone will copy both the UText data structures and the underlying text.
+  *  The original and cloned UText will operate completely independently; modifications
+  *  made to the text in one will not affect the other.  Text providers are not
+  *  required to support deep clones.  The user of clone() must check the status return
+  *  and be prepared to handle failures.
+  *
+  *  The standard UText implementations for UTF8, UChar *, UnicodeString and
+  *  Replaceable all support deep cloning.
+  *
+  *  The UText returned from a deep clone will be writable, assuming that the text
+  *  provider is able to support writing, even if the source UText had been made
+  *  non-writable by means of UText_freeze().
+  *
+  *  A shallow clone replicates only the UText data structures; it does not make
+  *  a copy of the underlying text.  Shallow clones can be used as an efficient way to 
+  *  have multiple iterators active in a single text string that is not being
+  *  modified.
+  *
+  *  A shallow clone operation will not fail, barring truly exceptional conditions such
+  *  as memory allocation failures.
+  *
+  *  Shallow UText clones should be avoided if the UText functions that modify the
+  *  text are expected to be used, either on the original or the cloned UText.
+  *  Any such modifications  can cause unpredictable behavior.  Read Only
+  *  shallow clones provide some protection against errors of this type by
+  *  disabling text modification via the cloned UText.
+  *
+  *  A shallow clone made with the readOnly parameter == FALSE will preserve the 
+  *  utext_isWritable() state of the source object.  Note, however, that
+  *  write operations must be avoided while more than one UText exists that refer
+  *  to the same underlying text.
+  *
+  *  A UText and its clone may be safely concurrently accessed by separate threads.
+  *  This is true for read access only with shallow clones, and for both read and
+  *  write access with deep clones.
+  *  It is the responsibility of the Text Provider to ensure that this thread safety
+  *  constraint is met.
+  *
+  *  @param dest   A UText struct to be filled in with the result of the clone operation,
+  *                or NULL if the clone function should heap-allocate a new UText struct.
+  *                If non-NULL, must refer to an already existing UText, which will then
+  *                be reset to become the clone.
+  *  @param src    The UText to be cloned.
+  *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.
+  *  @param readOnly TRUE to request that the cloned UText have read only access to the 
+  *                underlying text.  
+
+  *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR
+  *                will be returned if the text provider is unable to clone the
+  *                original text.
+  *  @return       The newly created clone, or NULL if the clone operation failed.
+  *  @stable ICU 3.4
+  */
+U_STABLE UText * U_EXPORT2
+utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);
+
+
+/**
+  *  Compare two UText objects for equality.
+  *  UTexts are equal if they are iterating over the same text, and
+  *    have the same iteration position within the text.
+  *    If either or both of the parameters are NULL, the comparison is FALSE.
+  *
+  *  @param a   The first of the two UTexts to compare.
+  *  @param b   The other UText to be compared.
+  *  @return    TRUE if the two UTexts are equal.
+  *  @stable ICU 3.6
+  */
+U_STABLE UBool U_EXPORT2
+utext_equals(const UText *a, const UText *b);
+
+
+/*****************************************************************************
+ *
+ *   Functions to work with the text represeted by a UText wrapper
+ *
+ *****************************************************************************/
+
+/**
+  * Get the length of the text.  Depending on the characteristics
+  * of the underlying text representation, this may be expensive.  
+  * @see  utext_isLengthExpensive()
+  *
+  *
+  * @param ut  the text to be accessed.
+  * @return the length of the text, expressed in native units.
+  *
+  * @stable ICU 3.4
+  */
+U_STABLE int64_t U_EXPORT2
+utext_nativeLength(UText *ut);
+
+/**
+ *  Return TRUE if calculating the length of the text could be expensive.
+ *  Finding the length of NUL terminated strings is considered to be expensive.
+ *
+ *  Note that the value of this function may change
+ *  as the result of other operations on a UText.
+ *  Once the length of a string has been discovered, it will no longer
+ *  be expensive to report it.
+ *
+ * @param ut the text to be accessed.
+ * @return TRUE if determining the length of the text could be time consuming.
+ * @stable ICU 3.4
+ */
+U_STABLE UBool U_EXPORT2
+utext_isLengthExpensive(const UText *ut);
+
+/**
+ * Returns the code point at the requested index,
+ * or U_SENTINEL (-1) if it is out of bounds.
+ *
+ * If the specified index points to the interior of a multi-unit
+ * character - one of the trail bytes of a UTF-8 sequence, for example -
+ * the complete code point will be returned.
+ *
+ * The iteration position will be set to the start of the returned code point.
+ *
+ * This function is roughly equivalent to the the sequence
+ *    utext_setNativeIndex(index);
+ *    utext_current32();
+ * (There is a subtle difference if the index is out of bounds by being less than zero - 
+ * utext_setNativeIndex(negative value) sets the index to zero, after which utext_current()
+ * will return the char at zero.  utext_char32At(negative index), on the other hand, will
+ * return the U_SENTINEL value of -1.)
+ * 
+ * @param ut the text to be accessed
+ * @param nativeIndex the native index of the character to be accessed.  If the index points
+ *        to other than the first unit of a multi-unit character, it will be adjusted
+ *        to the start of the character.
+ * @return the code point at the specified index.
+ * @stable ICU 3.4
+ */
+U_STABLE UChar32 U_EXPORT2
+utext_char32At(UText *ut, int64_t nativeIndex);
+
+
+/**
+ *
+ * Get the code point at the current iteration position,
+ * or U_SENTINEL (-1) if the iteration has reached the end of
+ * the input text.
+ *
+ * @param ut the text to be accessed.
+ * @return the Unicode code point at the current iterator position.
+ * @stable ICU 3.4
+ */
+U_STABLE UChar32 U_EXPORT2
+utext_current32(UText *ut);
+
+
+/**
+ * Get the code point at the current iteration position of the UText, and
+ * advance the position to the first index following the character.
+ *
+ * If the position is at the end of the text (the index following
+ * the last character, which is also the length of the text), 
+ * return U_SENTINEL (-1) and do not advance the index. 
+ *
+ * This is a post-increment operation.
+ *
+ * An inline macro version of this function, UTEXT_NEXT32(), 
+ * is available for performance critical use.
+ *
+ * @param ut the text to be accessed.
+ * @return the Unicode code point at the iteration position.
+ * @see UTEXT_NEXT32
+ * @stable ICU 3.4
+ */
+U_STABLE UChar32 U_EXPORT2
+utext_next32(UText *ut);
+
+
+/**
+ *  Move the iterator position to the character (code point) whose
+ *  index precedes the current position, and return that character.
+ *  This is a pre-decrement operation.
+ *
+ *  If the initial position is at the start of the text (index of 0) 
+ *  return U_SENTINEL (-1), and leave the position unchanged.
+ *
+ *  An inline macro version of this function, UTEXT_PREVIOUS32(), 
+ *  is available for performance critical use.
+ *
+ *  @param ut the text to be accessed.
+ *  @return the previous UChar32 code point, or U_SENTINEL (-1) 
+ *          if the iteration has reached the start of the text.
+ *  @see UTEXT_PREVIOUS32
+ *  @stable ICU 3.4
+ */
+U_STABLE UChar32 U_EXPORT2
+utext_previous32(UText *ut);
+
+
+/**
+  * Set the iteration index and return the code point at that index. 
+  * Leave the iteration index at the start of the following code point.
+  *
+  * This function is the most efficient and convenient way to
+  * begin a forward iteration.  The results are identical to the those
+  * from the sequence
+  * \code
+  *    utext_setIndex();
+  *    utext_next32();
+  * \endcode
+  *
+  *  @param ut the text to be accessed.
+  *  @param nativeIndex Iteration index, in the native units of the text provider.
+  *  @return Code point which starts at or before index,
+  *         or U_SENTINEL (-1) if it is out of bounds.
+  * @stable ICU 3.4
+  */
+U_STABLE UChar32 U_EXPORT2
+utext_next32From(UText *ut, int64_t nativeIndex);
+
+
+
+/**
+  * Set the iteration index, and return the code point preceding the
+  * one specified by the initial index.  Leave the iteration position
+  * at the start of the returned code point.
+  *
+  * This function is the most efficient and convenient way to
+  * begin a backwards iteration.
+  *
+  * @param ut the text to be accessed.
+  * @param nativeIndex Iteration index in the native units of the text provider.
+  * @return Code point preceding the one at the initial index,
+  *         or U_SENTINEL (-1) if it is out of bounds.
+  *
+  * @stable ICU 3.4
+  */
+U_STABLE UChar32 U_EXPORT2
+utext_previous32From(UText *ut, int64_t nativeIndex);
+
+/**
+  * Get the current iterator position, which can range from 0 to 
+  * the length of the text.
+  * The position is a native index into the input text, in whatever format it
+  * may have (possibly UTF-8 for example), and may not always be the same as
+  * the corresponding UChar (UTF-16) index.
+  * The returned position will always be aligned to a code point boundary. 
+  *
+  * @param ut the text to be accessed.
+  * @return the current index position, in the native units of the text provider.
+  * @stable ICU 3.4
+  */
+U_STABLE int64_t U_EXPORT2
+utext_getNativeIndex(const UText *ut);
+
+/**
+ * Set the current iteration position to the nearest code point
+ * boundary at or preceding the specified index.
+ * The index is in the native units of the original input text.
+ * If the index is out of range, it will be pinned to be within
+ * the range of the input text.
+ * <p>
+ * It will usually be more efficient to begin an iteration
+ * using the functions utext_next32From() or utext_previous32From()
+ * rather than setIndex().
+ * <p>
+ * Moving the index position to an adjacent character is best done
+ * with utext_next32(), utext_previous32() or utext_moveIndex32().
+ * Attempting to do direct arithmetic on the index position is
+ * complicated by the fact that the size (in native units) of a
+ * character depends on the underlying representation of the character
+ * (UTF-8, UTF-16, UTF-32, arbitrary codepage), and is not
+ * easily knowable.
+ *
+ * @param ut the text to be accessed.
+ * @param nativeIndex the native unit index of the new iteration position.
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+utext_setNativeIndex(UText *ut, int64_t nativeIndex);
+
+/**
+ * Move the iterator postion by delta code points.  The number of code points
+ * is a signed number; a negative delta will move the iterator backwards,
+ * towards the start of the text.
+ * <p>
+ * The index is moved by <code>delta</code> code points
+ * forward or backward, but no further backward than to 0 and
+ * no further forward than to utext_nativeLength().
+ * The resulting index value will be in between 0 and length, inclusive.
+ *
+ * @param ut the text to be accessed.
+ * @param delta the signed number of code points to move the iteration position.
+ * @return TRUE if the position could be moved the requested number of positions while
+ *              staying within the range [0 - text length].
+ * @stable ICU 3.4
+ */
+U_STABLE UBool U_EXPORT2
+utext_moveIndex32(UText *ut, int32_t delta);
+
+/**
+ * Get the native index of the character preceeding the current position.
+ * If the iteration position is already at the start of the text, zero
+ * is returned.
+ * The value returned is the same as that obtained from the following sequence,
+ * but without the side effect of changing the iteration position.
+ *   
+ * \code
+ *    UText  *ut = whatever;
+ *      ...
+ *    utext_previous(ut)
+ *    utext_getNativeIndex(ut);
+ * \endcode
+ *
+ * This function is most useful during forwards iteration, where it will get the
+ *   native index of the character most recently returned from utext_next().
+ *
+ * @param ut the text to be accessed
+ * @return the native index of the character preceeding the current index position,
+ *         or zero if the current position is at the start of the text.
+ * @stable ICU 3.6
+ */
+U_STABLE int64_t U_EXPORT2
+utext_getPreviousNativeIndex(UText *ut); 
+
+
+/**
+ *
+ * Extract text from a UText into a UChar buffer.  The range of text to be extracted
+ * is specified in the native indices of the UText provider.  These may not necessarily
+ * be UTF-16 indices.
+ * <p>
+ * The size (number of 16 bit UChars) of the data to be extracted is returned.  The
+ * full number of UChars is returned, even when the extracted text is truncated
+ * because the specified buffer size is too small.
+ * <p>
+ * The extracted string will (if you are a user) / must (if you are a text provider)
+ * be NUL-terminated if there is sufficient space in the destination buffer.  This
+ * terminating NUL is not included in the returned length.
+ * <p>
+ * The iteration index is left at the position following the last extracted character.
+ *
+ * @param  ut    the UText from which to extract data.
+ * @param  nativeStart the native index of the first character to extract.\
+ *               If the specified index is out of range,
+ *               it will be pinned to to be within 0 <= index <= textLength
+ * @param  nativeLimit the native string index of the position following the last
+ *               character to extract.  If the specified index is out of range,
+ *               it will be pinned to to be within 0 <= index <= textLength.
+ *               nativeLimit must be >= nativeStart.
+ * @param  dest  the UChar (UTF-16) buffer into which the extracted text is placed
+ * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero
+ *               for precomputing the required size.
+ * @param  status receives any error status.
+ *         U_BUFFER_OVERFLOW_ERROR: the extracted text was truncated because the 
+ *         buffer was too small.  Returns number of UChars for preflighting.
+ * @return Number of UChars in the data to be extracted.  Does not include a trailing NUL.
+ *
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+utext_extract(UText *ut,
+             int64_t nativeStart, int64_t nativeLimit,
+             UChar *dest, int32_t destCapacity,
+             UErrorCode *status);
+
+
+/************************************************************************************
+ *
+ *  #define inline versions of selected performance-critical text access functions
+ *          Caution:  do not use auto increment++ or decrement-- expressions
+ *                    as parameters to these macros.
+ *
+ *          For most use, where there is no extreme performance constraint, the
+ *          normal, non-inline functions are a better choice.  The resulting code
+ *          will be smaller, and, if the need ever arises, easier to debug.
+ *
+ *          These are implemented as #defines rather than real functions
+ *          because there is no fully portable way to do inline functions in plain C.
+ *
+ ************************************************************************************/
+
+/**
+ * inline version of utext_next32(), for performance-critical situations.
+ *
+ * Get the code point at the current iteration position of the UText, and
+ * advance the position to the first index following the character.
+ * This is a post-increment operation.
+ * Returns U_SENTINEL (-1) if the position is at the end of the
+ * text.
+ *
+ * @stable ICU 3.4
+ */
+#define UTEXT_NEXT32(ut)  \
+    ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
+    ((ut)->chunkContents)[((ut)->chunkOffset)++] : utext_next32(ut))
+
+/**
+ * inline version of utext_previous32(), for performance-critical situations.
+ *
+ *  Move the iterator position to the character (code point) whose
+ *  index precedes the current position, and return that character.
+ *  This is a pre-decrement operation.
+ *  Returns U_SENTINEL (-1) if the position is at the start of the  text.
+ *
+ * @stable ICU 3.4
+ */
+#define UTEXT_PREVIOUS32(ut)  \
+    ((ut)->chunkOffset > 0 && \
+     (ut)->chunkContents[(ut)->chunkOffset-1] < 0xd800 ? \
+          (ut)->chunkContents[--((ut)->chunkOffset)]  :  utext_previous32(ut))
+
+/**
+  *  inline version of utext_getNativeIndex(), for performance-critical situations.
+  *
+  * Get the current iterator position, which can range from 0 to 
+  * the length of the text.
+  * The position is a native index into the input text, in whatever format it
+  * may have (possibly UTF-8 for example), and may not always be the same as
+  * the corresponding UChar (UTF-16) index.
+  * The returned position will always be aligned to a code point boundary. 
+  *
+  * @stable ICU 3.6
+  */
+#define UTEXT_GETNATIVEINDEX(ut)                       \
+    ((ut)->chunkOffset <= (ut)->nativeIndexingLimit?   \
+        (ut)->chunkNativeStart+(ut)->chunkOffset :     \
+        (ut)->pFuncs->mapOffsetToNative(ut))    
+
+/**
+  *  inline version of utext_setNativeIndex(), for performance-critical situations.
+  *
+  * Set the current iteration position to the nearest code point
+  * boundary at or preceding the specified index.
+  * The index is in the native units of the original input text.
+  * If the index is out of range, it will be pinned to be within
+  * the range of the input text.
+  *
+  * @stable ICU 4.0
+  */
+#define UTEXT_SETNATIVEINDEX(ut, ix)                       \
+    { int64_t __offset = (ix) - (ut)->chunkNativeStart; \
+      if (__offset>=0 && __offset<=(int64_t)(ut)->nativeIndexingLimit) { \
+          (ut)->chunkOffset=(int32_t)__offset; \
+      } else { \
+          utext_setNativeIndex((ut), (ix)); } }
+
+
+
+/************************************************************************************
+ *
+ *   Functions related to writing or modifying the text.
+ *   These will work only with modifiable UTexts.  Attempting to
+ *   modify a read-only UText will return an error status.
+ *
+ ************************************************************************************/
+
+
+/**
+ *  Return TRUE if the text can be written (modified) with utext_replace() or
+ *  utext_copy().  For the text to be writable, the text provider must
+ *  be of a type that supports writing and the UText must not be frozen.
+ *
+ *  Attempting to modify text when utext_isWriteable() is FALSE will fail -
+ *  the text will not be modified, and an error will be returned from the function
+ *  that attempted the modification.
+ *
+ * @param  ut   the UText to be tested.
+ * @return TRUE if the text is modifiable.
+ *
+ * @see    utext_freeze()
+ * @see    utext_replace()
+ * @see    utext_copy()
+ * @stable ICU 3.4
+ *
+ */
+U_STABLE UBool U_EXPORT2
+utext_isWritable(const UText *ut);
+
+
+/**
+  * Test whether there is meta data associated with the text.
+  * @see Replaceable::hasMetaData()
+  *
+  * @param ut The UText to be tested
+  * @return TRUE if the underlying text includes meta data.
+  * @stable ICU 3.4
+  */
+U_STABLE UBool U_EXPORT2
+utext_hasMetaData(const UText *ut);
+
+
+/**
+ * Replace a range of the original text with a replacement text.
+ *
+ * Leaves the current iteration position at the position following the
+ *  newly inserted replacement text.
+ *
+ * This function is only available on UText types that support writing,
+ * that is, ones where utext_isWritable() returns TRUE.
+ *
+ * When using this function, there should be only a single UText opened onto the
+ * underlying native text string.  Behavior after a replace operation
+ * on a UText is undefined for any other additional UTexts that refer to the
+ * modified string.
+ *
+ * @param ut               the UText representing the text to be operated on.
+ * @param nativeStart      the native index of the start of the region to be replaced
+ * @param nativeLimit      the native index of the character following the region to be replaced.
+ * @param replacementText  pointer to the replacement text
+ * @param replacementLength length of the replacement text, or -1 if the text is NUL terminated.
+ * @param status           receives any error status.  Possible errors include
+ *                         U_NO_WRITE_PERMISSION
+ *
+ * @return The signed number of (native) storage units by which
+ *         the length of the text expanded or contracted.
+ *
+ * @stable ICU 3.4
+ */
+U_STABLE int32_t U_EXPORT2
+utext_replace(UText *ut,
+             int64_t nativeStart, int64_t nativeLimit,
+             const UChar *replacementText, int32_t replacementLength,
+             UErrorCode *status);
+
+
+
+/**
+ *
+ * Copy or move a substring from one position to another within the text,
+ * while retaining any metadata associated with the text.
+ * This function is used to duplicate or reorder substrings.
+ * The destination index must not overlap the source range.
+ *
+ * The text to be copied or moved is inserted at destIndex;
+ * it does not replace or overwrite any existing text.
+ *
+ * The iteration position is left following the newly inserted text
+ * at the destination position.
+ *
+ * This function is only available on UText types that support writing,
+ * that is, ones where utext_isWritable() returns TRUE.
+ *
+ * When using this function, there should be only a single UText opened onto the
+ * underlying native text string.  Behavior after a copy operation
+ * on a UText is undefined in any other additional UTexts that refer to the
+ * modified string.
+ *
+ * @param ut           The UText representing the text to be operated on.
+ * @param nativeStart  The native index of the start of the region to be copied or moved
+ * @param nativeLimit  The native index of the character position following the region
+ *                     to be copied.
+ * @param destIndex    The native destination index to which the source substring is
+ *                     copied or moved.
+ * @param move         If TRUE, then the substring is moved, not copied/duplicated.
+ * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION
+ *                       
+ * @stable ICU 3.4
+ */
+U_STABLE void U_EXPORT2
+utext_copy(UText *ut,
+          int64_t nativeStart, int64_t nativeLimit,
+          int64_t destIndex,
+          UBool move,
+          UErrorCode *status);
+
+
+/**
+  *  <p>
+  *  Freeze a UText.  This prevents any modification to the underlying text itself
+  *  by means of functions operating on this UText.
+  *  </p>
+  *  <p>
+  *  Once frozen, a UText can not be unfrozen.  The intent is to ensure
+  *  that a the text underlying a frozen UText wrapper cannot be modified via that UText.
+  *  </p>
+  *  <p>
+  *  Caution:  freezing a UText will disable changes made via the specific
+  *   frozen UText wrapper only; it will not have any effect on the ability to
+  *   directly modify the text by bypassing the UText.  Any such backdoor modifications
+  *   are always an error while UText access is occuring because the underlying
+  *   text can get out of sync with UText's buffering.
+  *  </p>
+  *
+  *  @param ut  The UText to be frozen.
+  *  @see   utext_isWritable()
+  *  @stable ICU 3.6
+  */
+U_STABLE void U_EXPORT2
+utext_freeze(UText *ut);
+
+
+/**
+ * UText provider properties (bit field indexes).
+ *
+ * @see UText
+ * @stable ICU 3.4
+ */
+enum {
+    /**
+     * It is potentially time consuming for the provider to determine the length of the text.
+     * @stable ICU 3.4
+     */
+    UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,
+    /**
+     * Text chunks remain valid and usable until the text object is modified or
+     * deleted, not just until the next time the access() function is called
+     * (which is the default).
+     * @stable ICU 3.4
+     */
+    UTEXT_PROVIDER_STABLE_CHUNKS = 2,
+    /**
+     * The provider supports modifying the text via the replace() and copy()
+     * functions.
+     * @see Replaceable
+     * @stable ICU 3.4
+     */
+    UTEXT_PROVIDER_WRITABLE = 3,
+    /**
+     * There is meta data associated with the text.
+     * @see Replaceable::hasMetaData()
+     * @stable ICU 3.4
+     */ 
+    UTEXT_PROVIDER_HAS_META_DATA = 4,
+    /**
+     * Text provider owns the text storage.
+     *  Generally occurs as the result of a deep clone of the UText.
+     *  When closing the UText, the associated text must
+     *  also be closed/deleted/freed/ whatever is appropriate.
+     * @stable ICU 3.6
+     */
+     UTEXT_PROVIDER_OWNS_TEXT = 5
+};
+
+/**
+  * Function type declaration for UText.clone().
+  *
+  *  clone a UText.  Much like opening a UText where the source text is itself
+  *  another UText.
+  *
+  *  A deep clone will copy both the UText data structures and the underlying text.
+  *  The original and cloned UText will operate completely independently; modifications
+  *  made to the text in one will not effect the other.  Text providers are not
+  *  required to support deep clones.  The user of clone() must check the status return
+  *  and be prepared to handle failures.
+  *
+  *  A shallow clone replicates only the UText data structures; it does not make
+  *  a copy of the underlying text.  Shallow clones can be used as an efficient way to 
+  *  have multiple iterators active in a single text string that is not being
+  *  modified.
+  *
+  *  A shallow clone operation must not fail except for truly exceptional conditions such
+  *  as memory allocation failures.
+  *
+  *  A UText and its clone may be safely concurrently accessed by separate threads.
+  *  This is true for both shallow and deep clones.
+  *  It is the responsibility of the Text Provider to ensure that this thread safety
+  *  constraint is met.
+
+  *
+  *  @param dest   A UText struct to be filled in with the result of the clone operation,
+  *                or NULL if the clone function should heap-allocate a new UText struct.
+  *  @param src    The UText to be cloned.
+  *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.
+  *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR
+  *                should be returned if the text provider is unable to clone the
+  *                original text.
+  *  @return       The newly created clone, or NULL if the clone operation failed.
+  *
+  * @stable ICU 3.4
+  */
+typedef UText * U_CALLCONV
+UTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
+
+
+/**
+ * Function type declaration for UText.nativeLength().
+ *
+ * @param ut the UText to get the length of.
+ * @return the length, in the native units of the original text string.
+ * @see UText
+ * @stable ICU 3.4
+ */
+typedef int64_t U_CALLCONV
+UTextNativeLength(UText *ut);
+
+/**
+ * Function type declaration for UText.access().  Get the description of the text chunk
+ *  containing the text at a requested native index.  The UText's iteration
+ *  position will be left at the requested index.  If the index is out
+ *  of bounds, the iteration position will be left at the start or end
+ *  of the string, as appropriate.
+ *
+ *  Chunks must begin and end on code point boundaries.  A single code point
+ *  comprised of multiple storage units must never span a chunk boundary.
+ *
+ *
+ * @param ut          the UText being accessed.
+ * @param nativeIndex Requested index of the text to be accessed.
+ * @param forward     If TRUE, then the returned chunk must contain text
+ *                    starting from the index, so that start<=index<limit.
+ *                    If FALSE, then the returned chunk must contain text
+ *                    before the index, so that start<index<=limit.
+ * @return            True if the requested index could be accessed.  The chunk
+ *                    will contain the requested text.
+ *                    False value if a chunk cannot be accessed
+ *                    (the requested index is out of bounds).
+ *
+ * @see UText
+ * @stable ICU 3.4
+ */
+typedef UBool U_CALLCONV
+UTextAccess(UText *ut, int64_t nativeIndex, UBool forward);
+
+/**
+ * Function type declaration for UText.extract().
+ *
+ * Extract text from a UText into a UChar buffer.  The range of text to be extracted
+ * is specified in the native indices of the UText provider.  These may not necessarily
+ * be UTF-16 indices.
+ * <p>
+ * The size (number of 16 bit UChars) in the data to be extracted is returned.  The
+ * full amount is returned, even when the specified buffer size is smaller.
+ * <p>
+ * The extracted string will (if you are a user) / must (if you are a text provider)
+ * be NUL-terminated if there is sufficient space in the destination buffer.
+ *
+ * @param  ut            the UText from which to extract data.
+ * @param  nativeStart   the native index of the first characer to extract.
+ * @param  nativeLimit   the native string index of the position following the last
+ *                       character to extract.
+ * @param  dest          the UChar (UTF-16) buffer into which the extracted text is placed
+ * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero
+ *                       for precomputing the required size.
+ * @param  status        receives any error status.
+ *                       If U_BUFFER_OVERFLOW_ERROR: Returns number of UChars for
+ *                       preflighting.
+ * @return Number of UChars in the data.  Does not include a trailing NUL.
+ *
+ * @stable ICU 3.4
+ */
+typedef int32_t U_CALLCONV
+UTextExtract(UText *ut,
+             int64_t nativeStart, int64_t nativeLimit,
+             UChar *dest, int32_t destCapacity,
+             UErrorCode *status);
+
+/**
+ * Function type declaration for UText.replace().
+ *
+ * Replace a range of the original text with a replacement text.
+ *
+ * Leaves the current iteration position at the position following the
+ *  newly inserted replacement text.
+ *
+ * This function need only be implemented on UText types that support writing.
+ *
+ * When using this function, there should be only a single UText opened onto the
+ * underlying native text string.  The function is responsible for updating the
+ * text chunk within the UText to reflect the updated iteration position,
+ * taking into account any changes to the underlying string's structure caused
+ * by the replace operation.
+ *
+ * @param ut               the UText representing the text to be operated on.
+ * @param nativeStart      the index of the start of the region to be replaced
+ * @param nativeLimit      the index of the character following the region to be replaced.
+ * @param replacementText  pointer to the replacement text
+ * @param replacmentLength length of the replacement text in UChars, or -1 if the text is NUL terminated.
+ * @param status           receives any error status.  Possible errors include
+ *                         U_NO_WRITE_PERMISSION
+ *
+ * @return The signed number of (native) storage units by which
+ *         the length of the text expanded or contracted.
+ *
+ * @stable ICU 3.4
+ */
+typedef int32_t U_CALLCONV
+UTextReplace(UText *ut,
+             int64_t nativeStart, int64_t nativeLimit,
+             const UChar *replacementText, int32_t replacmentLength,
+             UErrorCode *status);
+
+/**
+ * Function type declaration for UText.copy().
+ *
+ * Copy or move a substring from one position to another within the text,
+ * while retaining any metadata associated with the text.
+ * This function is used to duplicate or reorder substrings.
+ * The destination index must not overlap the source range.
+ *
+ * The text to be copied or moved is inserted at destIndex;
+ * it does not replace or overwrite any existing text.
+ *
+ * This function need only be implemented for UText types that support writing.
+ *
+ * When using this function, there should be only a single UText opened onto the
+ * underlying native text string.  The function is responsible for updating the
+ * text chunk within the UText to reflect the updated iteration position,
+ * taking into account any changes to the underlying string's structure caused
+ * by the replace operation.
+ *
+ * @param ut           The UText representing the text to be operated on.
+ * @param nativeStart  The index of the start of the region to be copied or moved
+ * @param nativeLimit  The index of the character following the region to be replaced.
+ * @param nativeDest   The destination index to which the source substring is copied or moved.
+ * @param move         If TRUE, then the substring is moved, not copied/duplicated.
+ * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION
+ *
+ * @stable ICU 3.4
+ */
+typedef void U_CALLCONV
+UTextCopy(UText *ut,
+          int64_t nativeStart, int64_t nativeLimit,
+          int64_t nativeDest,
+          UBool move,
+          UErrorCode *status);
+
+/**
+ * Function type declaration for UText.mapOffsetToNative().
+ * Map from the current UChar offset within the current text chunk to
+ *  the corresponding native index in the original source text.
+ *
+ * This is required only for text providers that do not use native UTF-16 indexes.
+ *
+ * @param ut     the UText.
+ * @return Absolute (native) index corresponding to chunkOffset in the current chunk.
+ *         The returned native index should always be to a code point boundary.
+ *
+ * @stable ICU 3.4
+ */
+typedef int64_t U_CALLCONV
+UTextMapOffsetToNative(const UText *ut);
+
+/**
+ * Function type declaration for UText.mapIndexToUTF16().
+ * Map from a native index to a UChar offset within a text chunk.
+ * Behavior is undefined if the native index does not fall within the
+ *   current chunk.
+ *
+ * This function is required only for text providers that do not use native UTF-16 indexes.
+ *
+ * @param ut          The UText containing the text chunk.
+ * @param nativeIndex Absolute (native) text index, chunk->start<=index<=chunk->limit.
+ * @return            Chunk-relative UTF-16 offset corresponding to the specified native
+ *                    index.
+ *
+ * @stable ICU 3.4
+ */
+typedef int32_t U_CALLCONV
+UTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex);
+
+
+/**
+ * Function type declaration for UText.utextClose().
+ *
+ * A Text Provider close function is only required for provider types that make
+ *  allocations in their open function (or other functions) that must be 
+ *  cleaned when the UText is closed.
+ *
+ * The allocation of the UText struct itself and any "extra" storage
+ * associated with the UText is handled by the common UText implementation
+ * and does not require provider specific cleanup in a close function.
+ *
+ * Most UText provider implementations do not need to implement this function.
+ *
+ * @param ut A UText object to be closed.
+ *
+ * @stable ICU 3.4
+ */
+typedef void U_CALLCONV
+UTextClose(UText *ut);
+
+
+/**
+  *   (public)  Function dispatch table for UText.
+  *             Conceptually very much like a C++ Virtual Function Table.
+  *             This struct defines the organization of the table.
+  *             Each text provider implementation must provide an
+  *              actual table that is initialized with the appropriate functions
+  *              for the type of text being handled.
+  *   @stable ICU 3.6
+  */
+struct UTextFuncs {
+    /**
+     *   (public)  Function table size, sizeof(UTextFuncs)
+     *             Intended for use should the table grow to accomodate added
+     *             functions in the future, to allow tests for older format
+     *             function tables that do not contain the extensions.
+     *
+     *             Fields are placed for optimal alignment on
+     *             32/64/128-bit-pointer machines, by normally grouping together
+     *             4 32-bit fields,
+     *             4 pointers,
+     *             2 64-bit fields
+     *             in sequence.
+     *   @stable ICU 3.6
+     */
+    int32_t       tableSize;
+
+    /**
+      *   (private)  Alignment padding.
+      *              Do not use, reserved for use by the UText framework only.
+      *   @internal
+      */
+    int32_t       reserved1, /** @internal */ reserved2, /** @internal */ reserved3;
+
+
+    /**
+     * (public) Function pointer for UTextClone
+     *
+     * @see UTextClone
+     * @stable ICU 3.6
+     */
+    UTextClone *clone;
+
+    /**
+     * (public) function pointer for UTextLength
+     * May be expensive to compute!
+     *
+     * @see UTextLength
+     * @stable ICU 3.6
+     */
+    UTextNativeLength *nativeLength;
+
+    /**
+     * (public) Function pointer for UTextAccess.
+     *
+     * @see UTextAccess
+     * @stable ICU 3.6
+     */
+    UTextAccess *access;
+
+    /**
+     * (public) Function pointer for UTextExtract.
+     *
+     * @see UTextExtract
+     * @stable ICU 3.6
+     */
+    UTextExtract *extract;
+
+    /**
+     * (public) Function pointer for UTextReplace.
+     *
+     * @see UTextReplace
+     * @stable ICU 3.6
+     */
+    UTextReplace *replace;
+
+    /**
+     * (public) Function pointer for UTextCopy.
+     *
+     * @see UTextCopy
+     * @stable ICU 3.6
+     */
+    UTextCopy *copy;
+
+    /**
+     * (public) Function pointer for UTextMapOffsetToNative.
+     *
+     * @see UTextMapOffsetToNative
+     * @stable ICU 3.6
+     */
+    UTextMapOffsetToNative *mapOffsetToNative;
+
+    /**
+     * (public) Function pointer for UTextMapNativeIndexToUTF16.
+     *
+     * @see UTextMapNativeIndexToUTF16
+     * @stable ICU 3.6
+     */
+    UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;
+
+    /**
+     * (public) Function pointer for UTextClose.
+      *
+      * @see UTextClose
+      * @stable ICU 3.6
+      */
+    UTextClose  *close;
+
+    /**
+      * (private)  Spare function pointer
+      * @internal
+      */
+
+    UTextClose  *spare1;
+    /**
+      * (private)  Spare function pointer
+      * @internal
+      */
+    UTextClose  *spare2;
+
+    /**
+      * (private)  Spare function pointer
+      * @internal
+      */
+    UTextClose  *spare3;
+
+};
+/**
+ * Function dispatch table for UText
+ * @see UTextFuncs
+ */
+typedef struct UTextFuncs UTextFuncs;
+
+ /**
+  *   UText struct.  Provides the interface between the generic UText access code
+  *                  and the UText provider code that works on specific kinds of
+  *                  text  (UTF-8, noncontiguous UTF-16, whatever.)
+  *
+  *                  Applications that are using predefined types of text providers
+  *                  to pass text data to ICU services will have no need to view the
+  *                  internals of the UText structs that they open.
+  *
+  * @stable ICU 3.6
+  */
+struct UText {
+    /**
+     *     (private)  Magic.  Used to help detect when UText functions are handed
+     *                        invalid or unitialized UText structs.
+     *                        utext_openXYZ() functions take an initialized,
+     *                        but not necessarily open, UText struct as an
+     *                        optional fill-in parameter.  This magic field
+     *                        is used to check for that initialization.
+     *                        Text provider close functions must NOT clear
+     *                        the magic field because that would prevent
+     *                        reuse of the UText struct.
+     * @internal
+     */
+    uint32_t       magic;
+
+
+    /**
+     *     (private)  Flags for managing the allocation and freeing of
+     *                memory associated with this UText.
+     * @internal
+     */
+    int32_t        flags;
+
+
+    /**
+      *  Text provider properties.  This set of flags is maintainted by the
+      *                             text provider implementation.
+      *  @stable ICU 3.4
+      */
+    int32_t         providerProperties;
+
+    /**
+     * (public) sizeOfStruct=sizeof(UText)
+     * Allows possible backward compatible extension.
+     *
+     * @stable ICU 3.4
+     */
+    int32_t         sizeOfStruct;
+    
+    /* ------ 16 byte alignment boundary -----------  */
+    
+
+    /**
+      *  (protected) Native index of the first character position following
+      *              the current chunk.
+      *  @stable ICU 3.6
+      */
+    int64_t         chunkNativeLimit;
+
+    /**
+     *   (protected)  Size in bytes of the extra space (pExtra).
+     *  @stable ICU 3.4
+     */
+    int32_t        extraSize;
+
+    /**
+      *    (protected) The highest chunk offset where native indexing and
+      *    chunk (UTF-16) indexing correspond.  For UTF-16 sources, value
+      *    will be equal to chunkLength.
+      *
+      *    @stable ICU 3.6
+      */
+    int32_t         nativeIndexingLimit;
+
+    /* ---- 16 byte alignment boundary------ */
+    
+    /**
+     *  (protected) Native index of the first character in the text chunk.
+     *  @stable ICU 3.6
+     */
+    int64_t         chunkNativeStart;
+
+    /**
+     *  (protected) Current iteration position within the text chunk (UTF-16 buffer).
+     *  This is the index to the character that will be returned by utext_next32().
+     *  @stable ICU 3.6
+     */
+    int32_t         chunkOffset;
+
+    /**
+     *  (protected) Length the text chunk (UTF-16 buffer), in UChars.
+     *  @stable ICU 3.6
+     */
+    int32_t         chunkLength;
+
+    /* ---- 16  byte alignment boundary-- */
+    
+
+    /**
+     *  (protected)  pointer to a chunk of text in UTF-16 format.
+     *  May refer either to original storage of the source of the text, or
+     *  if conversion was required, to a buffer owned by the UText.
+     *  @stable ICU 3.6
+     */
+    const UChar    *chunkContents;
+
+     /**
+      * (public)     Pointer to Dispatch table for accessing functions for this UText.
+      * @stable ICU 3.6
+      */
+    const UTextFuncs     *pFuncs;
+
+    /**
+     *  (protected)  Pointer to additional space requested by the
+     *               text provider during the utext_open operation.
+     * @stable ICU 3.4
+     */
+    void          *pExtra;
+
+    /**
+     * (protected) Pointer to string or text-containin object or similar.
+     * This is the source of the text that this UText is wrapping, in a format
+     *  that is known to the text provider functions.
+     * @stable ICU 3.4
+     */
+    const void   *context;
+
+    /* --- 16 byte alignment boundary--- */
+
+    /**
+     * (protected) Pointer fields available for use by the text provider.
+     * Not used by UText common code.
+     * @stable ICU 3.6
+     */
+    const void     *p; 
+    /**
+     * (protected) Pointer fields available for use by the text provider.
+     * Not used by UText common code.
+     * @stable ICU 3.6
+     */
+    const void     *q;
+     /**
+     * (protected) Pointer fields available for use by the text provider.
+     * Not used by UText common code.
+     * @stable ICU 3.6
+      */
+    const void     *r;
+
+    /**
+      *  Private field reserved for future use by the UText framework
+      *     itself.  This is not to be touched by the text providers.
+      * @internal ICU 3.4
+      */
+    void           *privP;
+
+
+    /* --- 16 byte alignment boundary--- */
+    
+
+    /**
+      * (protected) Integer field reserved for use by the text provider.
+      * Not used by the UText framework, or by the client (user) of the UText.
+      * @stable ICU 3.4
+      */
+    int64_t         a;
+
+    /**
+      * (protected) Integer field reserved for use by the text provider.
+      * Not used by the UText framework, or by the client (user) of the UText.
+      * @stable ICU 3.4
+      */
+    int32_t         b;
+
+    /**
+      * (protected) Integer field reserved for use by the text provider.
+      * Not used by the UText framework, or by the client (user) of the UText.
+      * @stable ICU 3.4
+      */
+    int32_t         c;
+
+    /*  ---- 16 byte alignment boundary---- */
+
+
+    /**
+      *  Private field reserved for future use by the UText framework
+      *     itself.  This is not to be touched by the text providers.
+      * @internal ICU 3.4
+      */
+    int64_t         privA;
+    /**
+      *  Private field reserved for future use by the UText framework
+      *     itself.  This is not to be touched by the text providers.
+      * @internal ICU 3.4
+      */
+    int32_t         privB;
+    /**
+      *  Private field reserved for future use by the UText framework
+      *     itself.  This is not to be touched by the text providers.
+      * @internal ICU 3.4
+      */
+    int32_t         privC;
+};
+
+
+/**
+ *  Common function for use by Text Provider implementations to allocate and/or initialize
+ *  a new UText struct.  To be called in the implementation of utext_open() functions.
+ *  If the supplied UText parameter is null, a new UText struct will be allocated on the heap.
+ *  If the supplied UText is already open, the provider's close function will be called
+ *  so that the struct can be reused by the open that is in progress.
+ *
+ * @param ut   pointer to a UText struct to be re-used, or null if a new UText
+ *             should be allocated.
+ * @param extraSpace The amount of additional space to be allocated as part
+ *             of this UText, for use by types of providers that require
+ *             additional storage.
+ * @param status Errors are returned here.
+ * @return pointer to the UText, allocated if necessary, with extra space set up if requested.
+ * @stable ICU 3.4
+ */
+U_STABLE UText * U_EXPORT2
+utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
+
+/**
+  * @internal
+  *  Value used to help identify correctly initialized UText structs.
+  *  Note:  must be publicly visible so that UTEXT_INITIALIZER can access it.
+  */
+enum {
+    UTEXT_MAGIC = 0x345ad82c
+};
+
+/**
+ * initializer to be used with local (stack) instances of a UText
+ *  struct.  UText structs must be initialized before passing
+ *  them to one of the utext_open functions.
+ *
+ * @stable ICU 3.6
+ */
+#define UTEXT_INITIALIZER {                                        \
+                  UTEXT_MAGIC,          /* magic                */ \
+                  0,                    /* flags                */ \
+                  0,                    /* providerProps        */ \
+                  sizeof(UText),        /* sizeOfStruct         */ \
+                  0,                    /* chunkNativeLimit     */ \
+                  0,                    /* extraSize            */ \
+                  0,                    /* nativeIndexingLimit  */ \
+                  0,                    /* chunkNativeStart     */ \
+                  0,                    /* chunkOffset          */ \
+                  0,                    /* chunkLength          */ \
+                  NULL,                 /* chunkContents        */ \
+                  NULL,                 /* pFuncs               */ \
+                  NULL,                 /* pExtra               */ \
+                  NULL,                 /* context              */ \
+                  NULL, NULL, NULL,     /* p, q, r              */ \
+                  NULL,                 /* privP                */ \
+                  0, 0, 0,              /* a, b, c              */ \
+                  0, 0, 0               /* privA,B,C,           */ \
+                  }
+
+
+U_CDECL_END
+
+
+
+#endif
diff --git a/CoreFoundation/icu/unicode/utf.h b/CoreFoundation/icu/unicode/utf.h
new file mode 100644
index 0000000..1682283
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utf.h
@@ -0,0 +1,227 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1999-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  utf.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999sep09
+*   created by: Markus W. Scherer
+*/
+
+/**
+ * \file
+ * \brief C API: Code point macros
+ *
+ * This file defines macros for checking whether a code point is
+ * a surrogate or a non-character etc.
+ *
+ * The UChar and UChar32 data types for Unicode code units and code points
+ * are defined in umachines.h because they can be machine-dependent.
+ *
+ * utf.h is included by utypes.h and itself includes utf8.h and utf16.h after some
+ * common definitions. Those files define macros for efficiently getting code points
+ * in and out of UTF-8/16 strings.
+ * utf16.h macros have "U16_" prefixes.
+ * utf8.h defines similar macros with "U8_" prefixes for UTF-8 string handling.
+ *
+ * ICU processes 16-bit Unicode strings.
+ * Most of the time, such strings are well-formed UTF-16.
+ * Single, unpaired surrogates must be handled as well, and are treated in ICU
+ * like regular code points where possible.
+ * (Pairs of surrogate code points are indistinguishable from supplementary
+ * code points encoded as pairs of supplementary code units.)
+ *
+ * In fact, almost all Unicode code points in normal text (>99%)
+ * are on the BMP (<=U+ffff) and even <=U+d7ff.
+ * ICU functions handle supplementary code points (U+10000..U+10ffff)
+ * but are optimized for the much more frequently occurring BMP code points.
+ *
+ * utf.h defines UChar to be an unsigned 16-bit integer. If this matches wchar_t, then
+ * UChar is defined to be exactly wchar_t, otherwise uint16_t.
+ *
+ * UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit
+ * Unicode code point (Unicode scalar value, 0..0x10ffff).
+ * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as
+ * the definition of UChar. For details see the documentation for UChar32 itself.
+ *
+ * utf.h also defines a small number of C macros for single Unicode code points.
+ * These are simple checks for surrogates and non-characters.
+ * For actual Unicode character properties see uchar.h.
+ *
+ * By default, string operations must be done with error checking in case
+ * a string is not well-formed UTF-16.
+ * The macros will detect if a surrogate code unit is unpaired
+ * (lead unit without trail unit or vice versa) and just return the unit itself
+ * as the code point.
+ * (It is an accidental property of Unicode and UTF-16 that all
+ * malformed sequences can be expressed unambiguously with a distinct subrange
+ * of Unicode code points.)
+ *
+ * The regular "safe" macros require that the initial, passed-in string index
+ * is within bounds. They only check the index when they read more than one
+ * code unit. This is usually done with code similar to the following loop:
+ * <pre>while(i<length) {
+ *   U16_NEXT(s, i, length, c);
+ *   // use c
+ * }</pre>
+ *
+ * When it is safe to assume that text is well-formed UTF-16
+ * (does not contain single, unpaired surrogates), then one can use
+ * U16_..._UNSAFE macros.
+ * These do not check for proper code unit sequences or truncated text and may
+ * yield wrong results or even cause a crash if they are used with "malformed"
+ * text.
+ * In practice, U16_..._UNSAFE macros will produce slightly less code but
+ * should not be faster because the processing is only different when a
+ * surrogate code unit is detected, which will be rare.
+ *
+ * Similarly for UTF-8, there are "safe" macros without a suffix,
+ * and U8_..._UNSAFE versions.
+ * The performance differences are much larger here because UTF-8 provides so
+ * many opportunities for malformed sequences.
+ * The unsafe UTF-8 macros are entirely implemented inside the macro definitions
+ * and are fast, while the safe UTF-8 macros call functions for all but the
+ * trivial (ASCII) cases.
+ * (ICU 3.6 optimizes U8_NEXT() and U8_APPEND() to handle most other common
+ * characters inline as well.)
+ *
+ * Unlike with UTF-16, malformed sequences cannot be expressed with distinct
+ * code point values (0..U+10ffff). They are indicated with negative values instead.
+ *
+ * For more information see the ICU User Guide Strings chapter
+ * (http://icu-project.org/userguide/strings.html).
+ *
+ * <em>Usage:</em>
+ * ICU coding guidelines for if() statements should be followed when using these macros.
+ * Compound statements (curly braces {}) must be used  for if-else-while... 
+ * bodies and all macro statements should be terminated with semicolon.
+ *
+ * @stable ICU 2.4
+ */
+
+#ifndef __UTF_H__
+#define __UTF_H__
+
+#include "unicode/utypes.h"
+/* include the utfXX.h after the following definitions */
+
+/* single-code point definitions -------------------------------------------- */
+
+/**
+ * This value is intended for sentinel values for APIs that
+ * (take or) return single code points (UChar32).
+ * It is outside of the Unicode code point range 0..0x10ffff.
+ * 
+ * For example, a "done" or "error" value in a new API
+ * could be indicated with U_SENTINEL.
+ *
+ * ICU APIs designed before ICU 2.4 usually define service-specific "done"
+ * values, mostly 0xffff.
+ * Those may need to be distinguished from
+ * actual U+ffff text contents by calling functions like
+ * CharacterIterator::hasNext() or UnicodeString::length().
+ *
+ * @return -1
+ * @see UChar32
+ * @stable ICU 2.4
+ */
+#define U_SENTINEL (-1)
+
+/**
+ * Is this code point a Unicode noncharacter?
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U_IS_UNICODE_NONCHAR(c) \
+    ((c)>=0xfdd0 && \
+     ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \
+     (uint32_t)(c)<=0x10ffff)
+
+/**
+ * Is c a Unicode code point value (0..U+10ffff)
+ * that can be assigned a character?
+ *
+ * Code points that are not characters include:
+ * - single surrogate code points (U+d800..U+dfff, 2048 code points)
+ * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)
+ * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)
+ * - the highest Unicode code point value is U+10ffff
+ *
+ * This means that all code points below U+d800 are character code points,
+ * and that boundary is tested first for performance.
+ *
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U_IS_UNICODE_CHAR(c) \
+    ((uint32_t)(c)<0xd800 || \
+        ((uint32_t)(c)>0xdfff && \
+         (uint32_t)(c)<=0x10ffff && \
+         !U_IS_UNICODE_NONCHAR(c)))
+
+/**
+ * Is this code point a BMP code point (U+0000..U+ffff)?
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.8
+ */
+#define U_IS_BMP(c) ((uint32_t)(c)<=0xffff)
+
+/**
+ * Is this code point a supplementary code point (U+10000..U+10ffff)?
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.8
+ */
+#define U_IS_SUPPLEMENTARY(c) ((uint32_t)((c)-0x10000)<=0xfffff)
+ 
+/**
+ * Is this code point a lead surrogate (U+d800..U+dbff)?
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
+
+/**
+ * Is this code point a trail surrogate (U+dc00..U+dfff)?
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
+
+/**
+ * Is this code point a surrogate (U+d800..U+dfff)?
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800)
+
+/**
+ * Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
+ * is it a lead surrogate?
+ * @param c 32-bit code point
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
+
+/* include the utfXX.h ------------------------------------------------------ */
+
+#include "unicode/utf8.h"
+#include "unicode/utf16.h"
+
+/* utf_old.h contains deprecated, pre-ICU 2.4 definitions */
+#include "unicode/utf_old.h"
+
+#endif
diff --git a/CoreFoundation/icu/unicode/utf16.h b/CoreFoundation/icu/unicode/utf16.h
new file mode 100644
index 0000000..719bc04
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utf16.h
@@ -0,0 +1,605 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1999-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  utf16.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999sep09
+*   created by: Markus W. Scherer
+*/
+
+/**
+ * \file
+ * \brief C API: 16-bit Unicode handling macros
+ * 
+ * This file defines macros to deal with 16-bit Unicode (UTF-16) code units and strings.
+ * utf16.h is included by utf.h after unicode/umachine.h
+ * and some common definitions.
+ *
+ * For more information see utf.h and the ICU User Guide Strings chapter
+ * (http://icu-project.org/userguide/strings.html).
+ *
+ * <em>Usage:</em>
+ * ICU coding guidelines for if() statements should be followed when using these macros.
+ * Compound statements (curly braces {}) must be used  for if-else-while... 
+ * bodies and all macro statements should be terminated with semicolon.
+ */
+
+#ifndef __UTF16_H__
+#define __UTF16_H__
+
+/* utf.h must be included first. */
+#ifndef __UTF_H__
+#   include "unicode/utf.h"
+#endif
+
+/* single-code point definitions -------------------------------------------- */
+
+/**
+ * Does this code unit alone encode a code point (BMP, not a surrogate)?
+ * @param c 16-bit code unit
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c)
+
+/**
+ * Is this code unit a lead surrogate (U+d800..U+dbff)?
+ * @param c 16-bit code unit
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)
+
+/**
+ * Is this code unit a trail surrogate (U+dc00..U+dfff)?
+ * @param c 16-bit code unit
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)
+
+/**
+ * Is this code unit a surrogate (U+d800..U+dfff)?
+ * @param c 16-bit code unit
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c)
+
+/**
+ * Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),
+ * is it a lead surrogate?
+ * @param c 16-bit code unit
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)
+
+/**
+ * Helper constant for U16_GET_SUPPLEMENTARY.
+ * @internal
+ */
+#define U16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
+
+/**
+ * Get a supplementary code point value (U+10000..U+10ffff)
+ * from its lead and trail surrogates.
+ * The result is undefined if the input values are not
+ * lead and trail surrogates.
+ *
+ * @param lead lead surrogate (U+d800..U+dbff)
+ * @param trail trail surrogate (U+dc00..U+dfff)
+ * @return supplementary code point (U+10000..U+10ffff)
+ * @stable ICU 2.4
+ */
+#define U16_GET_SUPPLEMENTARY(lead, trail) \
+    (((UChar32)(lead)<<10UL)+(UChar32)(trail)-U16_SURROGATE_OFFSET)
+
+
+/**
+ * Get the lead surrogate (0xd800..0xdbff) for a
+ * supplementary code point (0x10000..0x10ffff).
+ * @param supplementary 32-bit code point (U+10000..U+10ffff)
+ * @return lead surrogate (U+d800..U+dbff) for supplementary
+ * @stable ICU 2.4
+ */
+#define U16_LEAD(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)
+
+/**
+ * Get the trail surrogate (0xdc00..0xdfff) for a
+ * supplementary code point (0x10000..0x10ffff).
+ * @param supplementary 32-bit code point (U+10000..U+10ffff)
+ * @return trail surrogate (U+dc00..U+dfff) for supplementary
+ * @stable ICU 2.4
+ */
+#define U16_TRAIL(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)
+
+/**
+ * How many 16-bit code units are used to encode this Unicode code point? (1 or 2)
+ * The result is not defined if c is not a Unicode code point (U+0000..U+10ffff).
+ * @param c 32-bit code point
+ * @return 1 or 2
+ * @stable ICU 2.4
+ */
+#define U16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
+
+/**
+ * The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff).
+ * @return 2
+ * @stable ICU 2.4
+ */
+#define U16_MAX_LENGTH 2
+
+/**
+ * Get a code point from a string at a random-access offset,
+ * without changing the offset.
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * The offset may point to either the lead or trail surrogate unit
+ * for a supplementary code point, in which case the macro will read
+ * the adjacent matching surrogate as well.
+ * The result is undefined if the offset points to a single, unpaired surrogate.
+ * Iteration through a string is more efficient with U16_NEXT_UNSAFE or U16_NEXT.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @param c output UChar32 variable
+ * @see U16_GET
+ * @stable ICU 2.4
+ */
+#define U16_GET_UNSAFE(s, i, c) { \
+    (c)=(s)[i]; \
+    if(U16_IS_SURROGATE(c)) { \
+        if(U16_IS_SURROGATE_LEAD(c)) { \
+            (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)+1]); \
+        } else { \
+            (c)=U16_GET_SUPPLEMENTARY((s)[(i)-1], (c)); \
+        } \
+    } \
+}
+
+/**
+ * Get a code point from a string at a random-access offset,
+ * without changing the offset.
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * The offset may point to either the lead or trail surrogate unit
+ * for a supplementary code point, in which case the macro will read
+ * the adjacent matching surrogate as well.
+ * If the offset points to a single, unpaired surrogate, then that itself
+ * will be returned as the code point.
+ * Iteration through a string is more efficient with U16_NEXT_UNSAFE or U16_NEXT.
+ *
+ * @param s const UChar * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<=i<length
+ * @param length string length
+ * @param c output UChar32 variable
+ * @see U16_GET_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_GET(s, start, i, length, c) { \
+    (c)=(s)[i]; \
+    if(U16_IS_SURROGATE(c)) { \
+        uint16_t __c2; \
+        if(U16_IS_SURROGATE_LEAD(c)) { \
+            if((i)+1<(length) && U16_IS_TRAIL(__c2=(s)[(i)+1])) { \
+                (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
+            } \
+        } else { \
+            if((i)-1>=(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
+                (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
+            } \
+        } \
+    } \
+}
+
+/* definitions with forward iteration --------------------------------------- */
+
+/**
+ * Get a code point from a string at a code point boundary offset,
+ * and advance the offset to the next code point boundary.
+ * (Post-incrementing forward iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * The offset may point to the lead surrogate unit
+ * for a supplementary code point, in which case the macro will read
+ * the following trail surrogate as well.
+ * If the offset points to a trail surrogate, then that itself
+ * will be returned as the code point.
+ * The result is undefined if the offset points to a single, unpaired lead surrogate.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @param c output UChar32 variable
+ * @see U16_NEXT
+ * @stable ICU 2.4
+ */
+#define U16_NEXT_UNSAFE(s, i, c) { \
+    (c)=(s)[(i)++]; \
+    if(U16_IS_LEAD(c)) { \
+        (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \
+    } \
+}
+
+/**
+ * Get a code point from a string at a code point boundary offset,
+ * and advance the offset to the next code point boundary.
+ * (Post-incrementing forward iteration.)
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * The offset may point to the lead surrogate unit
+ * for a supplementary code point, in which case the macro will read
+ * the following trail surrogate as well.
+ * If the offset points to a trail surrogate or
+ * to a single, unpaired lead surrogate, then that itself
+ * will be returned as the code point.
+ *
+ * @param s const UChar * string
+ * @param i string offset, must be i<length
+ * @param length string length
+ * @param c output UChar32 variable
+ * @see U16_NEXT_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_NEXT(s, i, length, c) { \
+    (c)=(s)[(i)++]; \
+    if(U16_IS_LEAD(c)) { \
+        uint16_t __c2; \
+        if((i)<(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \
+            ++(i); \
+            (c)=U16_GET_SUPPLEMENTARY((c), __c2); \
+        } \
+    } \
+}
+
+/**
+ * Append a code point to a string, overwriting 1 or 2 code units.
+ * The offset points to the current end of the string contents
+ * and is advanced (post-increment).
+ * "Unsafe" macro, assumes a valid code point and sufficient space in the string.
+ * Otherwise, the result is undefined.
+ *
+ * @param s const UChar * string buffer
+ * @param i string offset
+ * @param c code point to append
+ * @see U16_APPEND
+ * @stable ICU 2.4
+ */
+#define U16_APPEND_UNSAFE(s, i, c) { \
+    if((uint32_t)(c)<=0xffff) { \
+        (s)[(i)++]=(uint16_t)(c); \
+    } else { \
+        (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
+        (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
+    } \
+}
+
+/**
+ * Append a code point to a string, overwriting 1 or 2 code units.
+ * The offset points to the current end of the string contents
+ * and is advanced (post-increment).
+ * "Safe" macro, checks for a valid code point.
+ * If a surrogate pair is written, checks for sufficient space in the string.
+ * If the code point is not valid or a trail surrogate does not fit,
+ * then isError is set to TRUE.
+ *
+ * @param s const UChar * string buffer
+ * @param i string offset, must be i<capacity
+ * @param capacity size of the string buffer
+ * @param c code point to append
+ * @param isError output UBool set to TRUE if an error occurs, otherwise not modified
+ * @see U16_APPEND_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_APPEND(s, i, capacity, c, isError) { \
+    if((uint32_t)(c)<=0xffff) { \
+        (s)[(i)++]=(uint16_t)(c); \
+    } else if((uint32_t)(c)<=0x10ffff && (i)+1<(capacity)) { \
+        (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
+        (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
+    } else /* c>0x10ffff or not enough space */ { \
+        (isError)=TRUE; \
+    } \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the next.
+ * (Post-incrementing iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @see U16_FWD_1
+ * @stable ICU 2.4
+ */
+#define U16_FWD_1_UNSAFE(s, i) { \
+    if(U16_IS_LEAD((s)[(i)++])) { \
+        ++(i); \
+    } \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the next.
+ * (Post-incrementing iteration.)
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * @param s const UChar * string
+ * @param i string offset, must be i<length
+ * @param length string length
+ * @see U16_FWD_1_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_FWD_1(s, i, length) { \
+    if(U16_IS_LEAD((s)[(i)++]) && (i)<(length) && U16_IS_TRAIL((s)[i])) { \
+        ++(i); \
+    } \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the n-th next one,
+ * i.e., move forward by n code points.
+ * (Post-incrementing iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @param n number of code points to skip
+ * @see U16_FWD_N
+ * @stable ICU 2.4
+ */
+#define U16_FWD_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        U16_FWD_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the n-th next one,
+ * i.e., move forward by n code points.
+ * (Post-incrementing iteration.)
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * @param s const UChar * string
+ * @param i string offset, must be i<length
+ * @param length string length
+ * @param n number of code points to skip
+ * @see U16_FWD_N_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_FWD_N(s, i, length, n) { \
+    int32_t __N=(n); \
+    while(__N>0 && (i)<(length)) { \
+        U16_FWD_1(s, i, length); \
+        --__N; \
+    } \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary
+ * at the start of a code point.
+ * If the offset points to the trail surrogate of a surrogate pair,
+ * then the offset is decremented.
+ * Otherwise, it is not modified.
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @see U16_SET_CP_START
+ * @stable ICU 2.4
+ */
+#define U16_SET_CP_START_UNSAFE(s, i) { \
+    if(U16_IS_TRAIL((s)[i])) { \
+        --(i); \
+    } \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary
+ * at the start of a code point.
+ * If the offset points to the trail surrogate of a surrogate pair,
+ * then the offset is decremented.
+ * Otherwise, it is not modified.
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * @param s const UChar * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<=i
+ * @see U16_SET_CP_START_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_SET_CP_START(s, start, i) { \
+    if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \
+        --(i); \
+    } \
+}
+
+/* definitions with backward iteration -------------------------------------- */
+
+/**
+ * Move the string offset from one code point boundary to the previous one
+ * and get the code point between them.
+ * (Pre-decrementing backward iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * The input offset may be the same as the string length.
+ * If the offset is behind a trail surrogate unit
+ * for a supplementary code point, then the macro will read
+ * the preceding lead surrogate as well.
+ * If the offset is behind a lead surrogate, then that itself
+ * will be returned as the code point.
+ * The result is undefined if the offset is behind a single, unpaired trail surrogate.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @param c output UChar32 variable
+ * @see U16_PREV
+ * @stable ICU 2.4
+ */
+#define U16_PREV_UNSAFE(s, i, c) { \
+    (c)=(s)[--(i)]; \
+    if(U16_IS_TRAIL(c)) { \
+        (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the previous one
+ * and get the code point between them.
+ * (Pre-decrementing backward iteration.)
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * The input offset may be the same as the string length.
+ * If the offset is behind a trail surrogate unit
+ * for a supplementary code point, then the macro will read
+ * the preceding lead surrogate as well.
+ * If the offset is behind a lead surrogate or behind a single, unpaired
+ * trail surrogate, then that itself
+ * will be returned as the code point.
+ *
+ * @param s const UChar * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<i
+ * @param c output UChar32 variable
+ * @see U16_PREV_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_PREV(s, start, i, c) { \
+    (c)=(s)[--(i)]; \
+    if(U16_IS_TRAIL(c)) { \
+        uint16_t __c2; \
+        if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \
+            --(i); \
+            (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \
+        } \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the previous one.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @see U16_BACK_1
+ * @stable ICU 2.4
+ */
+#define U16_BACK_1_UNSAFE(s, i) { \
+    if(U16_IS_TRAIL((s)[--(i)])) { \
+        --(i); \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the previous one.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * @param s const UChar * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<i
+ * @see U16_BACK_1_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_BACK_1(s, start, i) { \
+    if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \
+        --(i); \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the n-th one before it,
+ * i.e., move backward by n code points.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @param n number of code points to skip
+ * @see U16_BACK_N
+ * @stable ICU 2.4
+ */
+#define U16_BACK_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        U16_BACK_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the n-th one before it,
+ * i.e., move backward by n code points.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * @param s const UChar * string
+ * @param start start of string
+ * @param i string offset, must be start<i
+ * @param n number of code points to skip
+ * @see U16_BACK_N_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_BACK_N(s, start, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0 && (i)>(start)) { \
+        U16_BACK_1(s, start, i); \
+        --__N; \
+    } \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary after a code point.
+ * If the offset is behind the lead surrogate of a surrogate pair,
+ * then the offset is incremented.
+ * Otherwise, it is not modified.
+ * The input offset may be the same as the string length.
+ * "Unsafe" macro, assumes well-formed UTF-16.
+ *
+ * @param s const UChar * string
+ * @param i string offset
+ * @see U16_SET_CP_LIMIT
+ * @stable ICU 2.4
+ */
+#define U16_SET_CP_LIMIT_UNSAFE(s, i) { \
+    if(U16_IS_LEAD((s)[(i)-1])) { \
+        ++(i); \
+    } \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary after a code point.
+ * If the offset is behind the lead surrogate of a surrogate pair,
+ * then the offset is incremented.
+ * Otherwise, it is not modified.
+ * The input offset may be the same as the string length.
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * @param s const UChar * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, start<=i<=length
+ * @param length string length
+ * @see U16_SET_CP_LIMIT_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U16_SET_CP_LIMIT(s, start, i, length) { \
+    if((start)<(i) && (i)<(length) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \
+        ++(i); \
+    } \
+}
+
+#endif
diff --git a/CoreFoundation/icu/unicode/utf32.h b/CoreFoundation/icu/unicode/utf32.h
new file mode 100644
index 0000000..bf63e69
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utf32.h
@@ -0,0 +1,23 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1999-2001, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  utf32.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999sep20
+*   created by: Markus W. Scherer
+*/
+/**
+ * \file
+ * \brief C API: UTF-32 macros
+ *
+ * This file is obsolete and its contents moved to utf_old.h.
+ * See utf_old.h and Jitterbug 2150 and its discussion on the ICU mailing list
+ * in September 2002.
+ */
diff --git a/CoreFoundation/icu/unicode/utf8.h b/CoreFoundation/icu/unicode/utf8.h
new file mode 100644
index 0000000..1142c44
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utf8.h
@@ -0,0 +1,652 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1999-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  utf8.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 1999sep13
+*   created by: Markus W. Scherer
+*/
+
+/**
+ * \file
+ * \brief C API: 8-bit Unicode handling macros
+ * 
+ * This file defines macros to deal with 8-bit Unicode (UTF-8) code units (bytes) and strings.
+ * utf8.h is included by utf.h after unicode/umachine.h
+ * and some common definitions.
+ *
+ * For more information see utf.h and the ICU User Guide Strings chapter
+ * (http://icu-project.org/userguide/strings.html).
+ *
+ * <em>Usage:</em>
+ * ICU coding guidelines for if() statements should be followed when using these macros.
+ * Compound statements (curly braces {}) must be used  for if-else-while... 
+ * bodies and all macro statements should be terminated with semicolon.
+ */
+
+#ifndef __UTF8_H__
+#define __UTF8_H__
+
+/* utf.h must be included first. */
+#ifndef __UTF_H__
+#   include "unicode/utf.h"
+#endif
+
+/* internal definitions ----------------------------------------------------- */
+
+/**
+ * \var utf8_countTrailBytes
+ * Internal array with numbers of trail bytes for any given byte used in
+ * lead byte position.
+ * @internal
+ */
+#ifdef U_UTF8_IMPL
+U_EXPORT const uint8_t 
+#elif defined(U_STATIC_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION)
+U_CFUNC const uint8_t
+#else
+U_CFUNC U_IMPORT const uint8_t /* U_IMPORT2? */ /*U_IMPORT*/ 
+#endif
+utf8_countTrailBytes[256];
+
+/**
+ * Count the trail bytes for a UTF-8 lead byte.
+ * @internal
+ */
+#define U8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte])
+
+/**
+ * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value.
+ * @internal
+ */
+#define U8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1)
+
+/**
+ * Function for handling "next code point" with error-checking.
+ * @internal
+ */
+U_INTERNAL UChar32 U_EXPORT2
+utf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict);
+
+/**
+ * Function for handling "append code point" with error-checking.
+ * @internal
+ */
+U_INTERNAL int32_t U_EXPORT2
+utf8_appendCharSafeBody(uint8_t *s, int32_t i, int32_t length, UChar32 c, UBool *pIsError);
+
+/**
+ * Function for handling "previous code point" with error-checking.
+ * @internal
+ */
+U_INTERNAL UChar32 U_EXPORT2
+utf8_prevCharSafeBody(const uint8_t *s, int32_t start, int32_t *pi, UChar32 c, UBool strict);
+
+/**
+ * Function for handling "skip backward one code point" with error-checking.
+ * @internal
+ */
+U_INTERNAL int32_t U_EXPORT2
+utf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);
+
+/* single-code point definitions -------------------------------------------- */
+
+/**
+ * Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)?
+ * @param c 8-bit code unit (byte)
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U8_IS_SINGLE(c) (((c)&0x80)==0)
+
+/**
+ * Is this code unit (byte) a UTF-8 lead byte?
+ * @param c 8-bit code unit (byte)
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U8_IS_LEAD(c) ((uint8_t)((c)-0xc0)<0x3e)
+
+/**
+ * Is this code unit (byte) a UTF-8 trail byte?
+ * @param c 8-bit code unit (byte)
+ * @return TRUE or FALSE
+ * @stable ICU 2.4
+ */
+#define U8_IS_TRAIL(c) (((c)&0xc0)==0x80)
+
+/**
+ * How many code units (bytes) are used for the UTF-8 encoding
+ * of this Unicode code point?
+ * @param c 32-bit code point
+ * @return 1..4, or 0 if c is a surrogate or not a Unicode code point
+ * @stable ICU 2.4
+ */
+#define U8_LENGTH(c) \
+    ((uint32_t)(c)<=0x7f ? 1 : \
+        ((uint32_t)(c)<=0x7ff ? 2 : \
+            ((uint32_t)(c)<=0xd7ff ? 3 : \
+                ((uint32_t)(c)<=0xdfff || (uint32_t)(c)>0x10ffff ? 0 : \
+                    ((uint32_t)(c)<=0xffff ? 3 : 4)\
+                ) \
+            ) \
+        ) \
+    )
+
+/**
+ * The maximum number of UTF-8 code units (bytes) per Unicode code point (U+0000..U+10ffff).
+ * @return 4
+ * @stable ICU 2.4
+ */
+#define U8_MAX_LENGTH 4
+
+/**
+ * Get a code point from a string at a random-access offset,
+ * without changing the offset.
+ * The offset may point to either the lead byte or one of the trail bytes
+ * for a code point, in which case the macro will read all of the bytes
+ * for the code point.
+ * The result is undefined if the offset points to an illegal UTF-8
+ * byte sequence.
+ * Iteration through a string is more efficient with U8_NEXT_UNSAFE or U8_NEXT.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @param c output UChar32 variable
+ * @see U8_GET
+ * @stable ICU 2.4
+ */
+#define U8_GET_UNSAFE(s, i, c) { \
+    int32_t _u8_get_unsafe_index=(int32_t)(i); \
+    U8_SET_CP_START_UNSAFE(s, _u8_get_unsafe_index); \
+    U8_NEXT_UNSAFE(s, _u8_get_unsafe_index, c); \
+}
+
+/**
+ * Get a code point from a string at a random-access offset,
+ * without changing the offset.
+ * The offset may point to either the lead byte or one of the trail bytes
+ * for a code point, in which case the macro will read all of the bytes
+ * for the code point.
+ * If the offset points to an illegal UTF-8 byte sequence, then
+ * c is set to a negative value.
+ * Iteration through a string is more efficient with U8_NEXT_UNSAFE or U8_NEXT.
+ *
+ * @param s const uint8_t * string
+ * @param start starting string offset
+ * @param i string offset, must be start<=i<length
+ * @param length string length
+ * @param c output UChar32 variable, set to <0 in case of an error
+ * @see U8_GET_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_GET(s, start, i, length, c) { \
+    int32_t _u8_get_index=(int32_t)(i); \
+    U8_SET_CP_START(s, start, _u8_get_index); \
+    U8_NEXT(s, _u8_get_index, length, c); \
+}
+
+/* definitions with forward iteration --------------------------------------- */
+
+/**
+ * Get a code point from a string at a code point boundary offset,
+ * and advance the offset to the next code point boundary.
+ * (Post-incrementing forward iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * The offset may point to the lead byte of a multi-byte sequence,
+ * in which case the macro will read the whole sequence.
+ * The result is undefined if the offset points to a trail byte
+ * or an illegal UTF-8 sequence.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @param c output UChar32 variable
+ * @see U8_NEXT
+ * @stable ICU 2.4
+ */
+#define U8_NEXT_UNSAFE(s, i, c) { \
+    (c)=(uint8_t)(s)[(i)++]; \
+    if((uint8_t)((c)-0xc0)<0x35) { \
+        uint8_t __count=U8_COUNT_TRAIL_BYTES(c); \
+        U8_MASK_LEAD_BYTE(c, __count); \
+        switch(__count) { \
+        /* each following branch falls through to the next one */ \
+        case 3: \
+            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
+        case 2: \
+            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
+        case 1: \
+            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
+        /* no other branches to optimize switch() */ \
+            break; \
+        } \
+    } \
+}
+
+/**
+ * Get a code point from a string at a code point boundary offset,
+ * and advance the offset to the next code point boundary.
+ * (Post-incrementing forward iteration.)
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * The offset may point to the lead byte of a multi-byte sequence,
+ * in which case the macro will read the whole sequence.
+ * If the offset points to a trail byte or an illegal UTF-8 sequence, then
+ * c is set to a negative value.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset, must be i<length
+ * @param length string length
+ * @param c output UChar32 variable, set to <0 in case of an error
+ * @see U8_NEXT_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_NEXT(s, i, length, c) { \
+    (c)=(uint8_t)(s)[(i)++]; \
+    if((c)>=0x80) { \
+        uint8_t __t1, __t2; \
+        if( /* handle U+1000..U+CFFF inline */ \
+            (0xe0<(c) && (c)<=0xec) && \
+            (((i)+1)<(length)) && \
+            (__t1=(uint8_t)((s)[i]-0x80))<=0x3f && \
+            (__t2=(uint8_t)((s)[(i)+1]-0x80))<= 0x3f \
+        ) { \
+            /* no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */ \
+            (c)=(UChar)(((c)<<12)|(__t1<<6)|__t2); \
+            (i)+=2; \
+        } else if( /* handle U+0080..U+07FF inline */ \
+            ((c)<0xe0 && (c)>=0xc2) && \
+            ((i)<(length)) && \
+            (__t1=(uint8_t)((s)[i]-0x80))<=0x3f \
+        ) { \
+            (c)=(UChar)((((c)&0x1f)<<6)|__t1); \
+            ++(i); \
+        } else if(U8_IS_LEAD(c)) { \
+            /* function call for "complicated" and error cases */ \
+            (c)=utf8_nextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -1); \
+        } else { \
+            (c)=U_SENTINEL; \
+        } \
+    } \
+}
+
+/**
+ * Append a code point to a string, overwriting 1 to 4 bytes.
+ * The offset points to the current end of the string contents
+ * and is advanced (post-increment).
+ * "Unsafe" macro, assumes a valid code point and sufficient space in the string.
+ * Otherwise, the result is undefined.
+ *
+ * @param s const uint8_t * string buffer
+ * @param i string offset
+ * @param c code point to append
+ * @see U8_APPEND
+ * @stable ICU 2.4
+ */
+#define U8_APPEND_UNSAFE(s, i, c) { \
+    if((uint32_t)(c)<=0x7f) { \
+        (s)[(i)++]=(uint8_t)(c); \
+    } else { \
+        if((uint32_t)(c)<=0x7ff) { \
+            (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \
+        } else { \
+            if((uint32_t)(c)<=0xffff) { \
+                (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \
+            } else { \
+                (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \
+                (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \
+            } \
+            (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \
+        } \
+        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \
+    } \
+}
+
+/**
+ * Append a code point to a string, overwriting 1 to 4 bytes.
+ * The offset points to the current end of the string contents
+ * and is advanced (post-increment).
+ * "Safe" macro, checks for a valid code point.
+ * If a non-ASCII code point is written, checks for sufficient space in the string.
+ * If the code point is not valid or trail bytes do not fit,
+ * then isError is set to TRUE.
+ *
+ * @param s const uint8_t * string buffer
+ * @param i string offset, must be i<capacity
+ * @param capacity size of the string buffer
+ * @param c code point to append
+ * @param isError output UBool set to TRUE if an error occurs, otherwise not modified
+ * @see U8_APPEND_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_APPEND(s, i, capacity, c, isError) { \
+    if((uint32_t)(c)<=0x7f) { \
+        (s)[(i)++]=(uint8_t)(c); \
+    } else if((uint32_t)(c)<=0x7ff && (i)+1<(capacity)) { \
+        (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \
+        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \
+    } else if((uint32_t)(c)<=0xd7ff && (i)+2<(capacity)) { \
+        (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \
+        (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \
+        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \
+    } else { \
+        (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(capacity), c, &(isError)); \
+    } \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the next.
+ * (Post-incrementing iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @see U8_FWD_1
+ * @stable ICU 2.4
+ */
+#define U8_FWD_1_UNSAFE(s, i) { \
+    (i)+=1+U8_COUNT_TRAIL_BYTES((s)[i]); \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the next.
+ * (Post-incrementing iteration.)
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset, must be i<length
+ * @param length string length
+ * @see U8_FWD_1_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_FWD_1(s, i, length) { \
+    uint8_t __b=(uint8_t)(s)[(i)++]; \
+    if(U8_IS_LEAD(__b)) { \
+        uint8_t __count=U8_COUNT_TRAIL_BYTES(__b); \
+        if((i)+__count>(length)) { \
+            __count=(uint8_t)((length)-(i)); \
+        } \
+        while(__count>0 && U8_IS_TRAIL((s)[i])) { \
+            ++(i); \
+            --__count; \
+        } \
+    } \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the n-th next one,
+ * i.e., move forward by n code points.
+ * (Post-incrementing iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @param n number of code points to skip
+ * @see U8_FWD_N
+ * @stable ICU 2.4
+ */
+#define U8_FWD_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        U8_FWD_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/**
+ * Advance the string offset from one code point boundary to the n-th next one,
+ * i.e., move forward by n code points.
+ * (Post-incrementing iteration.)
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset, must be i<length
+ * @param length string length
+ * @param n number of code points to skip
+ * @see U8_FWD_N_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_FWD_N(s, i, length, n) { \
+    int32_t __N=(n); \
+    while(__N>0 && (i)<(length)) { \
+        U8_FWD_1(s, i, length); \
+        --__N; \
+    } \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary
+ * at the start of a code point.
+ * If the offset points to a UTF-8 trail byte,
+ * then the offset is moved backward to the corresponding lead byte.
+ * Otherwise, it is not modified.
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @see U8_SET_CP_START
+ * @stable ICU 2.4
+ */
+#define U8_SET_CP_START_UNSAFE(s, i) { \
+    while(U8_IS_TRAIL((s)[i])) { --(i); } \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary
+ * at the start of a code point.
+ * If the offset points to a UTF-8 trail byte,
+ * then the offset is moved backward to the corresponding lead byte.
+ * Otherwise, it is not modified.
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * @param s const uint8_t * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<=i
+ * @see U8_SET_CP_START_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_SET_CP_START(s, start, i) { \
+    if(U8_IS_TRAIL((s)[(i)])) { \
+        (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \
+    } \
+}
+
+/* definitions with backward iteration -------------------------------------- */
+
+/**
+ * Move the string offset from one code point boundary to the previous one
+ * and get the code point between them.
+ * (Pre-decrementing backward iteration.)
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * The input offset may be the same as the string length.
+ * If the offset is behind a multi-byte sequence, then the macro will read
+ * the whole sequence.
+ * If the offset is behind a lead byte, then that itself
+ * will be returned as the code point.
+ * The result is undefined if the offset is behind an illegal UTF-8 sequence.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @param c output UChar32 variable
+ * @see U8_PREV
+ * @stable ICU 2.4
+ */
+#define U8_PREV_UNSAFE(s, i, c) { \
+    (c)=(uint8_t)(s)[--(i)]; \
+    if(U8_IS_TRAIL(c)) { \
+        uint8_t __b, __count=1, __shift=6; \
+\
+        /* c is a trail byte */ \
+        (c)&=0x3f; \
+        for(;;) { \
+            __b=(uint8_t)(s)[--(i)]; \
+            if(__b>=0xc0) { \
+                U8_MASK_LEAD_BYTE(__b, __count); \
+                (c)|=(UChar32)__b<<__shift; \
+                break; \
+            } else { \
+                (c)|=(UChar32)(__b&0x3f)<<__shift; \
+                ++__count; \
+                __shift+=6; \
+            } \
+        } \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the previous one
+ * and get the code point between them.
+ * (Pre-decrementing backward iteration.)
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * The input offset may be the same as the string length.
+ * If the offset is behind a multi-byte sequence, then the macro will read
+ * the whole sequence.
+ * If the offset is behind a lead byte, then that itself
+ * will be returned as the code point.
+ * If the offset is behind an illegal UTF-8 sequence, then c is set to a negative value.
+ *
+ * @param s const uint8_t * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<i
+ * @param c output UChar32 variable, set to <0 in case of an error
+ * @see U8_PREV_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_PREV(s, start, i, c) { \
+    (c)=(uint8_t)(s)[--(i)]; \
+    if((c)>=0x80) { \
+        if((c)<=0xbf) { \
+            (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -1); \
+        } else { \
+            (c)=U_SENTINEL; \
+        } \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the previous one.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @see U8_BACK_1
+ * @stable ICU 2.4
+ */
+#define U8_BACK_1_UNSAFE(s, i) { \
+    while(U8_IS_TRAIL((s)[--(i)])) {} \
+}
+
+/**
+ * Move the string offset from one code point boundary to the previous one.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * @param s const uint8_t * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<i
+ * @see U8_BACK_1_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_BACK_1(s, start, i) { \
+    if(U8_IS_TRAIL((s)[--(i)])) { \
+        (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the n-th one before it,
+ * i.e., move backward by n code points.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @param n number of code points to skip
+ * @see U8_BACK_N
+ * @stable ICU 2.4
+ */
+#define U8_BACK_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        U8_BACK_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/**
+ * Move the string offset from one code point boundary to the n-th one before it,
+ * i.e., move backward by n code points.
+ * (Pre-decrementing backward iteration.)
+ * The input offset may be the same as the string length.
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * @param s const uint8_t * string
+ * @param start index of the start of the string
+ * @param i string offset, must be start<i
+ * @param n number of code points to skip
+ * @see U8_BACK_N_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_BACK_N(s, start, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0 && (i)>(start)) { \
+        U8_BACK_1(s, start, i); \
+        --__N; \
+    } \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary after a code point.
+ * If the offset is behind a partial multi-byte sequence,
+ * then the offset is incremented to behind the whole sequence.
+ * Otherwise, it is not modified.
+ * The input offset may be the same as the string length.
+ * "Unsafe" macro, assumes well-formed UTF-8.
+ *
+ * @param s const uint8_t * string
+ * @param i string offset
+ * @see U8_SET_CP_LIMIT
+ * @stable ICU 2.4
+ */
+#define U8_SET_CP_LIMIT_UNSAFE(s, i) { \
+    U8_BACK_1_UNSAFE(s, i); \
+    U8_FWD_1_UNSAFE(s, i); \
+}
+
+/**
+ * Adjust a random-access offset to a code point boundary after a code point.
+ * If the offset is behind a partial multi-byte sequence,
+ * then the offset is incremented to behind the whole sequence.
+ * Otherwise, it is not modified.
+ * The input offset may be the same as the string length.
+ * "Safe" macro, checks for illegal sequences and for string boundaries.
+ *
+ * @param s const uint8_t * string
+ * @param start starting string offset (usually 0)
+ * @param i string offset, must be start<=i<=length
+ * @param length string length
+ * @see U8_SET_CP_LIMIT_UNSAFE
+ * @stable ICU 2.4
+ */
+#define U8_SET_CP_LIMIT(s, start, i, length) { \
+    if((start)<(i) && (i)<(length)) { \
+        U8_BACK_1(s, start, i); \
+        U8_FWD_1(s, i, length); \
+    } \
+}
+
+#endif
diff --git a/CoreFoundation/icu/unicode/utf_old.h b/CoreFoundation/icu/unicode/utf_old.h
new file mode 100644
index 0000000..2397889
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utf_old.h
@@ -0,0 +1,1171 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2002-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  utf.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2002sep21
+*   created by: Markus W. Scherer
+*/
+
+/**
+ * \file 
+ * \brief C API: Deprecated macros for Unicode string handling
+ */
+
+/**
+ * 
+ * The macros in utf_old.h are all deprecated and their use discouraged.
+ * Some of the design principles behind the set of UTF macros
+ * have changed or proved impractical.
+ * Almost all of the old "UTF macros" are at least renamed.
+ * If you are looking for a new equivalent to an old macro, please see the
+ * comment at the old one.
+ *
+ * utf_old.h is included by utf.h after unicode/umachine.h
+ * and some common definitions, to not break old code.
+ *
+ * Brief summary of reasons for deprecation:
+ * - Switch on UTF_SIZE (selection of UTF-8/16/32 default string processing)
+ *   was impractical.
+ * - Switch on UTF_SAFE etc. (selection of unsafe/safe/strict default string processing)
+ *   was of little use and impractical.
+ * - Whole classes of macros became obsolete outside of the UTF_SIZE/UTF_SAFE
+ *   selection framework: UTF32_ macros (all trivial)
+ *   and UTF_ default and intermediate macros (all aliases).
+ * - The selection framework also caused many macro aliases.
+ * - Change in Unicode standard: "irregular" sequences (3.0) became illegal (3.2).
+ * - Change of language in Unicode standard:
+ *   Growing distinction between internal x-bit Unicode strings and external UTF-x
+ *   forms, with the former more lenient.
+ *   Suggests renaming of UTF16_ macros to U16_.
+ * - The prefix "UTF_" without a width number confused some users.
+ * - "Safe" append macros needed the addition of an error indicator output.
+ * - "Safe" UTF-8 macros used legitimate (if rarely used) code point values
+ *   to indicate error conditions.
+ * - The use of the "_CHAR" infix for code point operations confused some users.
+ *
+ * More details:
+ *
+ * Until ICU 2.2, utf.h theoretically allowed to choose among UTF-8/16/32
+ * for string processing, and among unsafe/safe/strict default macros for that.
+ *
+ * It proved nearly impossible to write non-trivial, high-performance code
+ * that is UTF-generic.
+ * Unsafe default macros would be dangerous for default string processing,
+ * and the main reason for the "strict" versions disappeared:
+ * Between Unicode 3.0 and 3.2 all "irregular" UTF-8 sequences became illegal.
+ * The only other conditions that "strict" checked for were non-characters,
+ * which are valid during processing. Only during text input/output should they
+ * be checked, and at that time other well-formedness checks may be
+ * necessary or useful as well.
+ * This can still be done by using U16_NEXT and U_IS_UNICODE_NONCHAR
+ * or U_IS_UNICODE_CHAR.
+ *
+ * The old UTF8_..._SAFE macros also used some normal Unicode code points
+ * to indicate malformed sequences.
+ * The new UTF8_ macros without suffix use negative values instead.
+ *
+ * The entire contents of utf32.h was moved here without replacement
+ * because all those macros were trivial and
+ * were meaningful only in the framework of choosing the UTF size.
+ *
+ * See Jitterbug 2150 and its discussion on the ICU mailing list
+ * in September 2002.
+ *
+ * <hr>
+ *
+ * <em>Obsolete part</em> of pre-ICU 2.4 utf.h file documentation:
+ *
+ * <p>The original concept for these files was for ICU to allow
+ * in principle to set which UTF (UTF-8/16/32) is used internally
+ * by defining UTF_SIZE to either 8, 16, or 32. utf.h would then define the UChar type
+ * accordingly. UTF-16 was the default.</p>
+ *
+ * <p>This concept has been abandoned.
+ * A lot of the ICU source code assumes UChar strings are in UTF-16.
+ * This is especially true for low-level code like
+ * conversion, normalization, and collation.
+ * The utf.h header enforces the default of UTF-16.
+ * The UTF-8 and UTF-32 macros remain for now for completeness and backward compatibility.</p>
+ *
+ * <p>Accordingly, utf.h defines UChar to be an unsigned 16-bit integer. If this matches wchar_t, then
+ * UChar is defined to be exactly wchar_t, otherwise uint16_t.</p>
+ *
+ * <p>UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit
+ * Unicode code point (Unicode scalar value, 0..0x10ffff).
+ * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as
+ * the definition of UChar. For details see the documentation for UChar32 itself.</p>
+ *
+ * <p>utf.h also defines a number of C macros for handling single Unicode code points and
+ * for using UTF Unicode strings. It includes utf8.h, utf16.h, and utf32.h for the actual
+ * implementations of those macros and then aliases one set of them (for UTF-16) for general use.
+ * The UTF-specific macros have the UTF size in the macro name prefixes (UTF16_...), while
+ * the general alias macros always begin with UTF_...</p>
+ *
+ * <p>Many string operations can be done with or without error checking.
+ * Where such a distinction is useful, there are two versions of the macros, "unsafe" and "safe"
+ * ones with ..._UNSAFE and ..._SAFE suffixes. The unsafe macros are fast but may cause
+ * program failures if the strings are not well-formed. The safe macros have an additional, boolean
+ * parameter "strict". If strict is FALSE, then only illegal sequences are detected.
+ * Otherwise, irregular sequences and non-characters are detected as well (like single surrogates).
+ * Safe macros return special error code points for illegal/irregular sequences:
+ * Typically, U+ffff, or values that would result in a code unit sequence of the same length
+ * as the erroneous input sequence.<br>
+ * Note that _UNSAFE macros have fewer parameters: They do not have the strictness parameter, and
+ * they do not have start/length parameters for boundary checking.</p>
+ *
+ * <p>Here, the macros are aliased in two steps:
+ * In the first step, the UTF-specific macros with UTF16_ prefix and _UNSAFE and _SAFE suffixes are
+ * aliased according to the UTF_SIZE to macros with UTF_ prefix and the same suffixes and signatures.
+ * Then, in a second step, the default, general alias macros are set to use either the unsafe or
+ * the safe/not strict (default) or the safe/strict macro;
+ * these general macros do not have a strictness parameter.</p>
+ *
+ * <p>It is possible to change the default choice for the general alias macros to be unsafe, safe/not strict or safe/strict.
+ * The default is safe/not strict. It is not recommended to select the unsafe macros as the basis for
+ * Unicode string handling in ICU! To select this, define UTF_SAFE, UTF_STRICT, or UTF_UNSAFE.</p>
+ *
+ * <p>For general use, one should use the default, general macros with UTF_ prefix and no _SAFE/_UNSAFE suffix.
+ * Only in some cases it may be necessary to control the choice of macro directly and use a less generic alias.
+ * For example, if it can be assumed that a string is well-formed and the index will stay within the bounds,
+ * then the _UNSAFE version may be used.
+ * If a UTF-8 string is to be processed, then the macros with UTF8_ prefixes need to be used.</p>
+ *
+ * <hr>
+ *
+ * @deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead.
+ */
+
+#ifndef __UTF_OLD_H__
+#define __UTF_OLD_H__
+
+#ifndef U_HIDE_DEPRECATED_API
+
+/* utf.h must be included first. */
+#ifndef __UTF_H__
+#   include "unicode/utf.h"
+#endif
+
+/* Formerly utf.h, part 1 --------------------------------------------------- */
+
+#ifdef U_USE_UTF_DEPRECATES
+/**
+ * Unicode string and array offset and index type.
+ * ICU always counts Unicode code units (UChars) for
+ * string offsets, indexes, and lengths, not Unicode code points.
+ *
+ * @obsolete ICU 2.6. Use int32_t directly instead since this API will be removed in that release.
+ */
+typedef int32_t UTextOffset;
+#endif
+
+/** Number of bits in a Unicode string code unit - ICU uses 16-bit Unicode. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF_SIZE 16
+
+/**
+ * The default choice for general Unicode string macros is to use the ..._SAFE macro implementations
+ * with strict=FALSE.
+ *
+ * @deprecated ICU 2.4. Obsolete, see utf_old.h.
+ */
+#define UTF_SAFE
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#undef UTF_UNSAFE
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#undef UTF_STRICT
+
+/**
+ * <p>UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8,
+ * which need 1 or 2 bytes in UTF-8:<br>
+ * U+0015 = NAK = Negative Acknowledge, C0 control character<br>
+ * U+009f = highest C1 control character</p>
+ *
+ * <p>These are used by UTF8_..._SAFE macros so that they can return an error value
+ * that needs the same number of code units (bytes) as were seen by
+ * a macro. They should be tested with UTF_IS_ERROR() or UTF_IS_VALID().</p>
+ *
+ * @deprecated ICU 2.4. Obsolete, see utf_old.h.
+ */
+#define UTF8_ERROR_VALUE_1 0x15
+
+/**
+ * See documentation on UTF8_ERROR_VALUE_1 for details.
+ *
+ * @deprecated ICU 2.4. Obsolete, see utf_old.h.
+ */
+#define UTF8_ERROR_VALUE_2 0x9f
+
+/**
+ * Error value for all UTFs. This code point value will be set by macros with error
+ * checking if an error is detected.
+ *
+ * @deprecated ICU 2.4. Obsolete, see utf_old.h.
+ */
+#define UTF_ERROR_VALUE 0xffff
+
+/**
+ * Is a given 32-bit code an error value
+ * as returned by one of the macros for any UTF?
+ *
+ * @deprecated ICU 2.4. Obsolete, see utf_old.h.
+ */
+#define UTF_IS_ERROR(c) \
+    (((c)&0xfffe)==0xfffe || (c)==UTF8_ERROR_VALUE_1 || (c)==UTF8_ERROR_VALUE_2)
+
+/**
+ * This is a combined macro: Is c a valid Unicode value _and_ not an error code?
+ *
+ * @deprecated ICU 2.4. Obsolete, see utf_old.h.
+ */
+#define UTF_IS_VALID(c) \
+    (UTF_IS_UNICODE_CHAR(c) && \
+     (c)!=UTF8_ERROR_VALUE_1 && (c)!=UTF8_ERROR_VALUE_2)
+
+/**
+ * Is this code unit or code point a surrogate (U+d800..U+dfff)?
+ * @deprecated ICU 2.4. Renamed to U_IS_SURROGATE and U16_IS_SURROGATE, see utf_old.h.
+ */
+#define UTF_IS_SURROGATE(uchar) (((uchar)&0xfffff800)==0xd800)
+
+/**
+ * Is a given 32-bit code point a Unicode noncharacter?
+ *
+ * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_NONCHAR, see utf_old.h.
+ */
+#define UTF_IS_UNICODE_NONCHAR(c) \
+    ((c)>=0xfdd0 && \
+     ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \
+     (uint32_t)(c)<=0x10ffff)
+
+/**
+ * Is a given 32-bit value a Unicode code point value (0..U+10ffff)
+ * that can be assigned a character?
+ *
+ * Code points that are not characters include:
+ * - single surrogate code points (U+d800..U+dfff, 2048 code points)
+ * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)
+ * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)
+ * - the highest Unicode code point value is U+10ffff
+ *
+ * This means that all code points below U+d800 are character code points,
+ * and that boundary is tested first for performance.
+ *
+ * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_CHAR, see utf_old.h.
+ */
+#define UTF_IS_UNICODE_CHAR(c) \
+    ((uint32_t)(c)<0xd800 || \
+        ((uint32_t)(c)>0xdfff && \
+         (uint32_t)(c)<=0x10ffff && \
+         !UTF_IS_UNICODE_NONCHAR(c)))
+
+/* Formerly utf8.h ---------------------------------------------------------- */
+
+/**
+ * Count the trail bytes for a UTF-8 lead byte.
+ * @deprecated ICU 2.4. Renamed to U8_COUNT_TRAIL_BYTES, see utf_old.h.
+ */
+#define UTF8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte])
+
+/**
+ * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value.
+ * @deprecated ICU 2.4. Renamed to U8_MASK_LEAD_BYTE, see utf_old.h.
+ */
+#define UTF8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1)
+
+/** Is this this code point a single code unit (byte)? @deprecated ICU 2.4. Renamed to U8_IS_SINGLE, see utf_old.h. */
+#define UTF8_IS_SINGLE(uchar) (((uchar)&0x80)==0)
+/** Is this this code unit the lead code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_LEAD, see utf_old.h. */
+#define UTF8_IS_LEAD(uchar) ((uint8_t)((uchar)-0xc0)<0x3e)
+/** Is this this code unit a trailing code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_TRAIL, see utf_old.h. */
+#define UTF8_IS_TRAIL(uchar) (((uchar)&0xc0)==0x80)
+
+/** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U8_LENGTH or test ((uint32_t)(c)>0x7f) instead, see utf_old.h. */
+#define UTF8_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0x7f)
+
+/**
+ * Given the lead character, how many bytes are taken by this code point.
+ * ICU does not deal with code points >0x10ffff
+ * unless necessary for advancing in the byte stream.
+ *
+ * These length macros take into account that for values >0x10ffff
+ * the UTF8_APPEND_CHAR_SAFE macros would write the error code point 0xffff
+ * with 3 bytes.
+ * Code point comparisons need to be in uint32_t because UChar32
+ * may be a signed type, and negative values must be recognized.
+ *
+ * @deprecated ICU 2.4. Use U8_LENGTH instead, see utf_old.h.
+ */
+#if 1
+#   define UTF8_CHAR_LENGTH(c) \
+        ((uint32_t)(c)<=0x7f ? 1 : \
+            ((uint32_t)(c)<=0x7ff ? 2 : \
+                ((uint32_t)((c)-0x10000)>0xfffff ? 3 : 4) \
+            ) \
+        )
+#else
+#   define UTF8_CHAR_LENGTH(c) \
+        ((uint32_t)(c)<=0x7f ? 1 : \
+            ((uint32_t)(c)<=0x7ff ? 2 : \
+                ((uint32_t)(c)<=0xffff ? 3 : \
+                    ((uint32_t)(c)<=0x10ffff ? 4 : \
+                        ((uint32_t)(c)<=0x3ffffff ? 5 : \
+                            ((uint32_t)(c)<=0x7fffffff ? 6 : 3) \
+                        ) \
+                    ) \
+                ) \
+            ) \
+        )
+#endif
+
+/** The maximum number of bytes per code point. @deprecated ICU 2.4. Renamed to U8_MAX_LENGTH, see utf_old.h. */
+#define UTF8_MAX_CHAR_LENGTH 4
+
+/** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF8_ARRAY_SIZE(size) ((5*(size))/2)
+
+/** @deprecated ICU 2.4. Renamed to U8_GET_UNSAFE, see utf_old.h. */
+#define UTF8_GET_CHAR_UNSAFE(s, i, c) { \
+    int32_t _utf8_get_char_unsafe_index=(int32_t)(i); \
+    UTF8_SET_CHAR_START_UNSAFE(s, _utf8_get_char_unsafe_index); \
+    UTF8_NEXT_CHAR_UNSAFE(s, _utf8_get_char_unsafe_index, c); \
+}
+
+/** @deprecated ICU 2.4. Use U8_GET instead, see utf_old.h. */
+#define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
+    int32_t _utf8_get_char_safe_index=(int32_t)(i); \
+    UTF8_SET_CHAR_START_SAFE(s, start, _utf8_get_char_safe_index); \
+    UTF8_NEXT_CHAR_SAFE(s, _utf8_get_char_safe_index, length, c, strict); \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_NEXT_UNSAFE, see utf_old.h. */
+#define UTF8_NEXT_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[(i)++]; \
+    if((uint8_t)((c)-0xc0)<0x35) { \
+        uint8_t __count=UTF8_COUNT_TRAIL_BYTES(c); \
+        UTF8_MASK_LEAD_BYTE(c, __count); \
+        switch(__count) { \
+        /* each following branch falls through to the next one */ \
+        case 3: \
+            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
+        case 2: \
+            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
+        case 1: \
+            (c)=((c)<<6)|((s)[(i)++]&0x3f); \
+        /* no other branches to optimize switch() */ \
+            break; \
+        } \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_APPEND_UNSAFE, see utf_old.h. */
+#define UTF8_APPEND_CHAR_UNSAFE(s, i, c) { \
+    if((uint32_t)(c)<=0x7f) { \
+        (s)[(i)++]=(uint8_t)(c); \
+    } else { \
+        if((uint32_t)(c)<=0x7ff) { \
+            (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \
+        } else { \
+            if((uint32_t)(c)<=0xffff) { \
+                (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \
+            } else { \
+                (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \
+                (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \
+            } \
+            (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \
+        } \
+        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_FWD_1_UNSAFE, see utf_old.h. */
+#define UTF8_FWD_1_UNSAFE(s, i) { \
+    (i)+=1+UTF8_COUNT_TRAIL_BYTES((s)[i]); \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_FWD_N_UNSAFE, see utf_old.h. */
+#define UTF8_FWD_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        UTF8_FWD_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_SET_CP_START_UNSAFE, see utf_old.h. */
+#define UTF8_SET_CHAR_START_UNSAFE(s, i) { \
+    while(UTF8_IS_TRAIL((s)[i])) { --(i); } \
+}
+
+/** @deprecated ICU 2.4. Use U8_NEXT instead, see utf_old.h. */
+#define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
+    (c)=(s)[(i)++]; \
+    if((c)>=0x80) { \
+        if(UTF8_IS_LEAD(c)) { \
+            (c)=utf8_nextCharSafeBody(s, &(i), (int32_t)(length), c, strict); \
+        } else { \
+            (c)=UTF8_ERROR_VALUE_1; \
+        } \
+    } \
+}
+
+/** @deprecated ICU 2.4. Use U8_APPEND instead, see utf_old.h. */
+#define UTF8_APPEND_CHAR_SAFE(s, i, length, c)  { \
+    if((uint32_t)(c)<=0x7f) { \
+        (s)[(i)++]=(uint8_t)(c); \
+    } else { \
+        (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(length), c, NULL); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_FWD_1, see utf_old.h. */
+#define UTF8_FWD_1_SAFE(s, i, length) U8_FWD_1(s, i, length)
+
+/** @deprecated ICU 2.4. Renamed to U8_FWD_N, see utf_old.h. */
+#define UTF8_FWD_N_SAFE(s, i, length, n) U8_FWD_N(s, i, length, n)
+
+/** @deprecated ICU 2.4. Renamed to U8_SET_CP_START, see utf_old.h. */
+#define UTF8_SET_CHAR_START_SAFE(s, start, i) U8_SET_CP_START(s, start, i)
+
+/** @deprecated ICU 2.4. Renamed to U8_PREV_UNSAFE, see utf_old.h. */
+#define UTF8_PREV_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[--(i)]; \
+    if(UTF8_IS_TRAIL(c)) { \
+        uint8_t __b, __count=1, __shift=6; \
+\
+        /* c is a trail byte */ \
+        (c)&=0x3f; \
+        for(;;) { \
+            __b=(s)[--(i)]; \
+            if(__b>=0xc0) { \
+                UTF8_MASK_LEAD_BYTE(__b, __count); \
+                (c)|=(UChar32)__b<<__shift; \
+                break; \
+            } else { \
+                (c)|=(UChar32)(__b&0x3f)<<__shift; \
+                ++__count; \
+                __shift+=6; \
+            } \
+        } \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_BACK_1_UNSAFE, see utf_old.h. */
+#define UTF8_BACK_1_UNSAFE(s, i) { \
+    while(UTF8_IS_TRAIL((s)[--(i)])) {} \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_BACK_N_UNSAFE, see utf_old.h. */
+#define UTF8_BACK_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        UTF8_BACK_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
+#define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) { \
+    UTF8_BACK_1_UNSAFE(s, i); \
+    UTF8_FWD_1_UNSAFE(s, i); \
+}
+
+/** @deprecated ICU 2.4. Use U8_PREV instead, see utf_old.h. */
+#define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) { \
+    (c)=(s)[--(i)]; \
+    if((c)>=0x80) { \
+        if((c)<=0xbf) { \
+            (c)=utf8_prevCharSafeBody(s, start, &(i), c, strict); \
+        } else { \
+            (c)=UTF8_ERROR_VALUE_1; \
+        } \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U8_BACK_1, see utf_old.h. */
+#define UTF8_BACK_1_SAFE(s, start, i) U8_BACK_1(s, start, i)
+
+/** @deprecated ICU 2.4. Renamed to U8_BACK_N, see utf_old.h. */
+#define UTF8_BACK_N_SAFE(s, start, i, n) U8_BACK_N(s, start, i, n)
+
+/** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT, see utf_old.h. */
+#define UTF8_SET_CHAR_LIMIT_SAFE(s, start, i, length) U8_SET_CP_LIMIT(s, start, i, length)
+
+/* Formerly utf16.h --------------------------------------------------------- */
+
+/** Is uchar a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h. */
+#define UTF_IS_FIRST_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xd800)
+
+/** Is uchar a second/trail surrogate? @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h. */
+#define UTF_IS_SECOND_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xdc00)
+
+/** Assuming c is a surrogate, is it a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_SURROGATE_LEAD and U16_IS_SURROGATE_LEAD, see utf_old.h. */
+#define UTF_IS_SURROGATE_FIRST(c) (((c)&0x400)==0)
+
+/** Helper constant for UTF16_GET_PAIR_VALUE. @deprecated ICU 2.4. Renamed to U16_SURROGATE_OFFSET, see utf_old.h. */
+#define UTF_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
+
+/** Get the UTF-32 value from the surrogate code units. @deprecated ICU 2.4. Renamed to U16_GET_SUPPLEMENTARY, see utf_old.h. */
+#define UTF16_GET_PAIR_VALUE(first, second) \
+    (((first)<<10UL)+(second)-UTF_SURROGATE_OFFSET)
+
+/** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */
+#define UTF_FIRST_SURROGATE(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)
+
+/** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */
+#define UTF_SECOND_SURROGATE(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)
+
+/** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */
+#define UTF16_LEAD(supplementary) UTF_FIRST_SURROGATE(supplementary)
+
+/** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */
+#define UTF16_TRAIL(supplementary) UTF_SECOND_SURROGATE(supplementary)
+
+/** @deprecated ICU 2.4. Renamed to U16_IS_SINGLE, see utf_old.h. */
+#define UTF16_IS_SINGLE(uchar) !UTF_IS_SURROGATE(uchar)
+
+/** @deprecated ICU 2.4. Renamed to U16_IS_LEAD, see utf_old.h. */
+#define UTF16_IS_LEAD(uchar) UTF_IS_FIRST_SURROGATE(uchar)
+
+/** @deprecated ICU 2.4. Renamed to U16_IS_TRAIL, see utf_old.h. */
+#define UTF16_IS_TRAIL(uchar) UTF_IS_SECOND_SURROGATE(uchar)
+
+/** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead, see utf_old.h. */
+#define UTF16_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0xffff)
+
+/** @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h. */
+#define UTF16_CHAR_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
+
+/** @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h. */
+#define UTF16_MAX_CHAR_LENGTH 2
+
+/** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF16_ARRAY_SIZE(size) (size)
+
+/**
+ * Get a single code point from an offset that points to any
+ * of the code units that belong to that code point.
+ * Assume 0<=i<length.
+ *
+ * This could be used for iteration together with
+ * UTF16_CHAR_LENGTH() and UTF_IS_ERROR(),
+ * but the use of UTF16_NEXT_CHAR[_UNSAFE]() and
+ * UTF16_PREV_CHAR[_UNSAFE]() is more efficient for that.
+ * @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h.
+ */
+#define UTF16_GET_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[i]; \
+    if(UTF_IS_SURROGATE(c)) { \
+        if(UTF_IS_SURROGATE_FIRST(c)) { \
+            (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)+1]); \
+        } else { \
+            (c)=UTF16_GET_PAIR_VALUE((s)[(i)-1], (c)); \
+        } \
+    } \
+}
+
+/** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */
+#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
+    (c)=(s)[i]; \
+    if(UTF_IS_SURROGATE(c)) { \
+        uint16_t __c2; \
+        if(UTF_IS_SURROGATE_FIRST(c)) { \
+            if((i)+1<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)+1])) { \
+                (c)=UTF16_GET_PAIR_VALUE((c), __c2); \
+                /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
+            } else if(strict) {\
+                /* unmatched first surrogate */ \
+                (c)=UTF_ERROR_VALUE; \
+            } \
+        } else { \
+            if((i)-1>=(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \
+                (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
+                /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
+            } else if(strict) {\
+                /* unmatched second surrogate */ \
+                (c)=UTF_ERROR_VALUE; \
+            } \
+        } \
+    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
+        (c)=UTF_ERROR_VALUE; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */
+#define UTF16_NEXT_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[(i)++]; \
+    if(UTF_IS_FIRST_SURROGATE(c)) { \
+        (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)++]); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */
+#define UTF16_APPEND_CHAR_UNSAFE(s, i, c) { \
+    if((uint32_t)(c)<=0xffff) { \
+        (s)[(i)++]=(uint16_t)(c); \
+    } else { \
+        (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
+        (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */
+#define UTF16_FWD_1_UNSAFE(s, i) { \
+    if(UTF_IS_FIRST_SURROGATE((s)[(i)++])) { \
+        ++(i); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */
+#define UTF16_FWD_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        UTF16_FWD_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */
+#define UTF16_SET_CHAR_START_UNSAFE(s, i) { \
+    if(UTF_IS_SECOND_SURROGATE((s)[i])) { \
+        --(i); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */
+#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
+    (c)=(s)[(i)++]; \
+    if(UTF_IS_FIRST_SURROGATE(c)) { \
+        uint16_t __c2; \
+        if((i)<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)])) { \
+            ++(i); \
+            (c)=UTF16_GET_PAIR_VALUE((c), __c2); \
+            /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
+        } else if(strict) {\
+            /* unmatched first surrogate */ \
+            (c)=UTF_ERROR_VALUE; \
+        } \
+    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
+        /* unmatched second surrogate or other non-character */ \
+        (c)=UTF_ERROR_VALUE; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */
+#define UTF16_APPEND_CHAR_SAFE(s, i, length, c) { \
+    if((uint32_t)(c)<=0xffff) { \
+        (s)[(i)++]=(uint16_t)(c); \
+    } else if((uint32_t)(c)<=0x10ffff) { \
+        if((i)+1<(length)) { \
+            (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \
+            (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \
+        } else /* not enough space */ { \
+            (s)[(i)++]=UTF_ERROR_VALUE; \
+        } \
+    } else /* c>0x10ffff, write error value */ { \
+        (s)[(i)++]=UTF_ERROR_VALUE; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */
+#define UTF16_FWD_1_SAFE(s, i, length) U16_FWD_1(s, i, length)
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */
+#define UTF16_FWD_N_SAFE(s, i, length, n) U16_FWD_N(s, i, length, n)
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */
+#define UTF16_SET_CHAR_START_SAFE(s, start, i) U16_SET_CP_START(s, start, i)
+
+/** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */
+#define UTF16_PREV_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[--(i)]; \
+    if(UTF_IS_SECOND_SURROGATE(c)) { \
+        (c)=UTF16_GET_PAIR_VALUE((s)[--(i)], (c)); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */
+#define UTF16_BACK_1_UNSAFE(s, i) { \
+    if(UTF_IS_SECOND_SURROGATE((s)[--(i)])) { \
+        --(i); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */
+#define UTF16_BACK_N_UNSAFE(s, i, n) { \
+    int32_t __N=(n); \
+    while(__N>0) { \
+        UTF16_BACK_1_UNSAFE(s, i); \
+        --__N; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
+#define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) { \
+    if(UTF_IS_FIRST_SURROGATE((s)[(i)-1])) { \
+        ++(i); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */
+#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) { \
+    (c)=(s)[--(i)]; \
+    if(UTF_IS_SECOND_SURROGATE(c)) { \
+        uint16_t __c2; \
+        if((i)>(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \
+            --(i); \
+            (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \
+            /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \
+        } else if(strict) {\
+            /* unmatched second surrogate */ \
+            (c)=UTF_ERROR_VALUE; \
+        } \
+    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \
+        /* unmatched first surrogate or other non-character */ \
+        (c)=UTF_ERROR_VALUE; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */
+#define UTF16_BACK_1_SAFE(s, start, i) U16_BACK_1(s, start, i)
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */
+#define UTF16_BACK_N_SAFE(s, start, i, n) U16_BACK_N(s, start, i, n)
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */
+#define UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)
+
+/* Formerly utf32.h --------------------------------------------------------- */
+
+/*
+* Old documentation:
+*
+*   This file defines macros to deal with UTF-32 code units and code points.
+*   Signatures and semantics are the same as for the similarly named macros
+*   in utf16.h.
+*   utf32.h is included by utf.h after unicode/umachine.h</p>
+*   and some common definitions.
+*   <p><b>Usage:</b>  ICU coding guidelines for if() statements should be followed when using these macros.
+*                  Compound statements (curly braces {}) must be used  for if-else-while...
+*                  bodies and all macro statements should be terminated with semicolon.</p>
+*/
+
+/* internal definitions ----------------------------------------------------- */
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_IS_SAFE(c, strict) \
+    (!(strict) ? \
+        (uint32_t)(c)<=0x10ffff : \
+        UTF_IS_UNICODE_CHAR(c))
+
+/*
+ * For the semantics of all of these macros, see utf16.h.
+ * The UTF-32 versions are trivial because any code point is
+ * encoded using exactly one code unit.
+ */
+
+/* single-code point definitions -------------------------------------------- */
+
+/* classes of code unit values */
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_IS_SINGLE(uchar) 1
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_IS_LEAD(uchar) 0
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_IS_TRAIL(uchar) 0
+
+/* number of code units per code point */
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_NEED_MULTIPLE_UCHAR(c) 0
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_CHAR_LENGTH(c) 1
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_MAX_CHAR_LENGTH 1
+
+/* average number of code units compared to UTF-16 */
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_ARRAY_SIZE(size) (size)
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_GET_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[i]; \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
+    (c)=(s)[i]; \
+    if(!UTF32_IS_SAFE(c, strict)) { \
+        (c)=UTF_ERROR_VALUE; \
+    } \
+}
+
+/* definitions with forward iteration --------------------------------------- */
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[(i)++]; \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \
+    (s)[(i)++]=(c); \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_FWD_1_UNSAFE(s, i) { \
+    ++(i); \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_FWD_N_UNSAFE(s, i, n) { \
+    (i)+=(n); \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_SET_CHAR_START_UNSAFE(s, i) { \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
+    (c)=(s)[(i)++]; \
+    if(!UTF32_IS_SAFE(c, strict)) { \
+        (c)=UTF_ERROR_VALUE; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \
+    if((uint32_t)(c)<=0x10ffff) { \
+        (s)[(i)++]=(c); \
+    } else /* c>0x10ffff, write 0xfffd */ { \
+        (s)[(i)++]=0xfffd; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_FWD_1_SAFE(s, i, length) { \
+    ++(i); \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_FWD_N_SAFE(s, i, length, n) { \
+    if(((i)+=(n))>(length)) { \
+        (i)=(length); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_SET_CHAR_START_SAFE(s, start, i) { \
+}
+
+/* definitions with backward iteration -------------------------------------- */
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \
+    (c)=(s)[--(i)]; \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_BACK_1_UNSAFE(s, i) { \
+    --(i); \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_BACK_N_UNSAFE(s, i, n) { \
+    (i)-=(n); \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \
+    (c)=(s)[--(i)]; \
+    if(!UTF32_IS_SAFE(c, strict)) { \
+        (c)=UTF_ERROR_VALUE; \
+    } \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_BACK_1_SAFE(s, start, i) { \
+    --(i); \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_BACK_N_SAFE(s, start, i, n) { \
+    (i)-=(n); \
+    if((i)<(start)) { \
+        (i)=(start); \
+    } \
+}
+
+/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */
+#define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \
+}
+
+/* Formerly utf.h, part 2 --------------------------------------------------- */
+
+/**
+ * Estimate the number of code units for a string based on the number of UTF-16 code units.
+ *
+ * @deprecated ICU 2.4. Obsolete, see utf_old.h.
+ */
+#define UTF_ARRAY_SIZE(size) UTF16_ARRAY_SIZE(size)
+
+/** @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */
+#define UTF_GET_CHAR_UNSAFE(s, i, c)                 UTF16_GET_CHAR_UNSAFE(s, i, c)
+
+/** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */
+#define UTF_GET_CHAR_SAFE(s, start, i, length, c, strict) UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */
+#define UTF_NEXT_CHAR_UNSAFE(s, i, c)                UTF16_NEXT_CHAR_UNSAFE(s, i, c)
+
+/** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */
+#define UTF_NEXT_CHAR_SAFE(s, i, length, c, strict)  UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */
+#define UTF_APPEND_CHAR_UNSAFE(s, i, c)              UTF16_APPEND_CHAR_UNSAFE(s, i, c)
+
+/** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */
+#define UTF_APPEND_CHAR_SAFE(s, i, length, c)        UTF16_APPEND_CHAR_SAFE(s, i, length, c)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */
+#define UTF_FWD_1_UNSAFE(s, i)                       UTF16_FWD_1_UNSAFE(s, i)
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */
+#define UTF_FWD_1_SAFE(s, i, length)                 UTF16_FWD_1_SAFE(s, i, length)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */
+#define UTF_FWD_N_UNSAFE(s, i, n)                    UTF16_FWD_N_UNSAFE(s, i, n)
+
+/** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */
+#define UTF_FWD_N_SAFE(s, i, length, n)              UTF16_FWD_N_SAFE(s, i, length, n)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */
+#define UTF_SET_CHAR_START_UNSAFE(s, i)              UTF16_SET_CHAR_START_UNSAFE(s, i)
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */
+#define UTF_SET_CHAR_START_SAFE(s, start, i)         UTF16_SET_CHAR_START_SAFE(s, start, i)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */
+#define UTF_PREV_CHAR_UNSAFE(s, i, c)                UTF16_PREV_CHAR_UNSAFE(s, i, c)
+
+/** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */
+#define UTF_PREV_CHAR_SAFE(s, start, i, c, strict)   UTF16_PREV_CHAR_SAFE(s, start, i, c, strict)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */
+#define UTF_BACK_1_UNSAFE(s, i)                      UTF16_BACK_1_UNSAFE(s, i)
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */
+#define UTF_BACK_1_SAFE(s, start, i)                 UTF16_BACK_1_SAFE(s, start, i)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */
+#define UTF_BACK_N_UNSAFE(s, i, n)                   UTF16_BACK_N_UNSAFE(s, i, n)
+
+/** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */
+#define UTF_BACK_N_SAFE(s, start, i, n)              UTF16_BACK_N_SAFE(s, start, i, n)
+
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */
+#define UTF_SET_CHAR_LIMIT_UNSAFE(s, i)              UTF16_SET_CHAR_LIMIT_UNSAFE(s, i)
+
+/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */
+#define UTF_SET_CHAR_LIMIT_SAFE(s, start, i, length) UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length)
+
+/* Define default macros (UTF-16 "safe") ------------------------------------ */
+
+/**
+ * Does this code unit alone encode a code point (BMP, not a surrogate)?
+ * Same as UTF16_IS_SINGLE.
+ * @deprecated ICU 2.4. Renamed to U_IS_SINGLE and U16_IS_SINGLE, see utf_old.h.
+ */
+#define UTF_IS_SINGLE(uchar) U16_IS_SINGLE(uchar)
+
+/**
+ * Is this code unit the first one of several (a lead surrogate)?
+ * Same as UTF16_IS_LEAD.
+ * @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h.
+ */
+#define UTF_IS_LEAD(uchar) U16_IS_LEAD(uchar)
+
+/**
+ * Is this code unit one of several but not the first one (a trail surrogate)?
+ * Same as UTF16_IS_TRAIL.
+ * @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h.
+ */
+#define UTF_IS_TRAIL(uchar) U16_IS_TRAIL(uchar)
+
+/**
+ * Does this code point require multiple code units (is it a supplementary code point)?
+ * Same as UTF16_NEED_MULTIPLE_UCHAR.
+ * @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead.
+ */
+#define UTF_NEED_MULTIPLE_UCHAR(c) UTF16_NEED_MULTIPLE_UCHAR(c)
+
+/**
+ * How many code units are used to encode this code point (1 or 2)?
+ * Same as UTF16_CHAR_LENGTH.
+ * @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h.
+ */
+#define UTF_CHAR_LENGTH(c) U16_LENGTH(c)
+
+/**
+ * How many code units are used at most for any Unicode code point (2)?
+ * Same as UTF16_MAX_CHAR_LENGTH.
+ * @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h.
+ */
+#define UTF_MAX_CHAR_LENGTH U16_MAX_LENGTH
+
+/**
+ * Set c to the code point that contains the code unit i.
+ * i could point to the lead or the trail surrogate for the code point.
+ * i is not modified.
+ * Same as UTF16_GET_CHAR.
+ * \pre 0<=i<length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_GET, see utf_old.h.
+ */
+#define UTF_GET_CHAR(s, start, i, length, c) U16_GET(s, start, i, length, c)
+
+/**
+ * Set c to the code point that starts at code unit i
+ * and advance i to beyond the code units of this code point (post-increment).
+ * i must point to the first code unit of a code point.
+ * Otherwise c is set to the trail unit (surrogate) itself.
+ * Same as UTF16_NEXT_CHAR.
+ * \pre 0<=i<length
+ * \post 0<i<=length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_NEXT, see utf_old.h.
+ */
+#define UTF_NEXT_CHAR(s, i, length, c) U16_NEXT(s, i, length, c)
+
+/**
+ * Append the code units of code point c to the string at index i
+ * and advance i to beyond the new code units (post-increment).
+ * The code units beginning at index i will be overwritten.
+ * Same as UTF16_APPEND_CHAR.
+ * \pre 0<=c<=0x10ffff
+ * \pre 0<=i<length
+ * \post 0<i<=length
+ *
+ * @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h.
+ */
+#define UTF_APPEND_CHAR(s, i, length, c) UTF16_APPEND_CHAR_SAFE(s, i, length, c)
+
+/**
+ * Advance i to beyond the code units of the code point that begins at i.
+ * I.e., advance i by one code point.
+ * Same as UTF16_FWD_1.
+ * \pre 0<=i<length
+ * \post 0<i<=length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h.
+ */
+#define UTF_FWD_1(s, i, length) U16_FWD_1(s, i, length)
+
+/**
+ * Advance i to beyond the code units of the n code points where the first one begins at i.
+ * I.e., advance i by n code points.
+ * Same as UT16_FWD_N.
+ * \pre 0<=i<length
+ * \post 0<i<=length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h.
+ */
+#define UTF_FWD_N(s, i, length, n) U16_FWD_N(s, i, length, n)
+
+/**
+ * Take the random-access index i and adjust it so that it points to the beginning
+ * of a code point.
+ * The input index points to any code unit of a code point and is moved to point to
+ * the first code unit of the same code point. i is never incremented.
+ * In other words, if i points to a trail surrogate that is preceded by a matching
+ * lead surrogate, then i is decremented. Otherwise it is not modified.
+ * This can be used to start an iteration with UTF_NEXT_CHAR() from a random index.
+ * Same as UTF16_SET_CHAR_START.
+ * \pre start<=i<length
+ * \post start<=i<length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h.
+ */
+#define UTF_SET_CHAR_START(s, start, i) U16_SET_CP_START(s, start, i)
+
+/**
+ * Set c to the code point that has code units before i
+ * and move i backward (towards the beginning of the string)
+ * to the first code unit of this code point (pre-increment).
+ * i must point to the first code unit after the last unit of a code point (i==length is allowed).
+ * Same as UTF16_PREV_CHAR.
+ * \pre start<i<=length
+ * \post start<=i<length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_PREV, see utf_old.h.
+ */
+#define UTF_PREV_CHAR(s, start, i, c) U16_PREV(s, start, i, c)
+
+/**
+ * Move i backward (towards the beginning of the string)
+ * to the first code unit of the code point that has code units before i.
+ * I.e., move i backward by one code point.
+ * i must point to the first code unit after the last unit of a code point (i==length is allowed).
+ * Same as UTF16_BACK_1.
+ * \pre start<i<=length
+ * \post start<=i<length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h.
+ */
+#define UTF_BACK_1(s, start, i) U16_BACK_1(s, start, i)
+
+/**
+ * Move i backward (towards the beginning of the string)
+ * to the first code unit of the n code points that have code units before i.
+ * I.e., move i backward by n code points.
+ * i must point to the first code unit after the last unit of a code point (i==length is allowed).
+ * Same as UTF16_BACK_N.
+ * \pre start<i<=length
+ * \post start<=i<length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h.
+ */
+#define UTF_BACK_N(s, start, i, n) U16_BACK_N(s, start, i, n)
+
+/**
+ * Take the random-access index i and adjust it so that it points beyond
+ * a code point. The input index points beyond any code unit
+ * of a code point and is moved to point beyond the last code unit of the same
+ * code point. i is never decremented.
+ * In other words, if i points to a trail surrogate that is preceded by a matching
+ * lead surrogate, then i is incremented. Otherwise it is not modified.
+ * This can be used to start an iteration with UTF_PREV_CHAR() from a random index.
+ * Same as UTF16_SET_CHAR_LIMIT.
+ * \pre start<i<=length
+ * \post start<i<=length
+ *
+ * @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h.
+ */
+#define UTF_SET_CHAR_LIMIT(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)
+
+#endif /* U_HIDE_DEPRECATED_API */
+
+#endif
+
diff --git a/CoreFoundation/icu/unicode/utmscale.h b/CoreFoundation/icu/unicode/utmscale.h
new file mode 100644
index 0000000..368e426
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utmscale.h
@@ -0,0 +1,481 @@
+/*
+*******************************************************************************
+* Copyright (C) 2004 - 2008, International Business Machines Corporation and
+* others. All Rights Reserved.
+*******************************************************************************
+*/
+
+#ifndef UTMSCALE_H
+#define UTMSCALE_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+/** 
+ * \file
+ * \brief C API: Universal Time Scale
+ *
+ * There are quite a few different conventions for binary datetime, depending on different
+ * platforms and protocols. Some of these have severe drawbacks. For example, people using
+ * Unix time (seconds since Jan 1, 1970) think that they are safe until near the year 2038.
+ * But cases can and do arise where arithmetic manipulations causes serious problems. Consider
+ * the computation of the average of two datetimes, for example: if one calculates them with
+ * <code>averageTime = (time1 + time2)/2</code>, there will be overflow even with dates
+ * around the present. Moreover, even if these problems don't occur, there is the issue of
+ * conversion back and forth between different systems.
+ *
+ * <p>
+ * Binary datetimes differ in a number of ways: the datatype, the unit,
+ * and the epoch (origin). We'll refer to these as time scales. For example:
+ *
+ * <table border="1" cellspacing="0" cellpadding="4">
+ *  <caption>Table 1: Binary Time Scales</caption>
+ *  <tr>
+ *    <th align="left">Source</th>
+ *    <th align="left">Datatype</th>
+ *    <th align="left">Unit</th>
+ *    <th align="left">Epoch</th>
+ *  </tr>
+ *
+ *  <tr>
+ *    <td>UDTS_JAVA_TIME</td>
+ *    <td>int64_t</td>
+ *    <td>milliseconds</td>
+ *    <td>Jan 1, 1970</td>
+ *  </tr>
+ *  <tr>
+ *
+ *    <td>UDTS_UNIX_TIME</td>
+ *    <td>int32_t or int64_t</td>
+ *    <td>seconds</td>
+ *    <td>Jan 1, 1970</td>
+ *  </tr>
+ *  <tr>
+ *    <td>UDTS_ICU4C_TIME</td>
+ *
+ *    <td>double</td>
+ *    <td>milliseconds</td>
+ *    <td>Jan 1, 1970</td>
+ *  </tr>
+ *  <tr>
+ *    <td>UDTS_WINDOWS_FILE_TIME</td>
+ *    <td>int64_t</td>
+ *
+ *    <td>ticks (100 nanoseconds)</td>
+ *    <td>Jan 1, 1601</td>
+ *  </tr>
+ *  <tr>
+ *    <td>UDTS_DOTNET_DATE_TIME</td>
+ *    <td>int64_t</td>
+ *    <td>ticks (100 nanoseconds)</td>
+ *
+ *    <td>Jan 1, 0001</td>
+ *  </tr>
+ *  <tr>
+ *    <td>UDTS_MAC_OLD_TIME</td>
+ *    <td>int32_t or int64_t</td>
+ *    <td>seconds</td>
+ *    <td>Jan 1, 1904</td>
+ *
+ *  </tr>
+ *  <tr>
+ *    <td>UDTS_MAC_TIME</td>
+ *    <td>double</td>
+ *    <td>seconds</td>
+ *    <td>Jan 1, 2001</td>
+ *  </tr>
+ *
+ *  <tr>
+ *    <td>UDTS_EXCEL_TIME</td>
+ *    <td>?</td>
+ *    <td>days</td>
+ *    <td>Dec 31, 1899</td>
+ *  </tr>
+ *  <tr>
+ *
+ *    <td>UDTS_DB2_TIME</td>
+ *    <td>?</td>
+ *    <td>days</td>
+ *    <td>Dec 31, 1899</td>
+ *  </tr>
+ *
+ *  <tr>
+ *    <td>UDTS_UNIX_MICROSECONDS_TIME</td>
+ *    <td>int64_t</td>
+ *    <td>microseconds</td>
+ *    <td>Jan 1, 1970</td>
+ *  </tr>
+ * </table>
+ *
+ * <p>
+ * All of the epochs start at 00:00 am (the earliest possible time on the day in question),
+ * and are assumed to be UTC.
+ *
+ * <p>
+ * The ranges for different datatypes are given in the following table (all values in years).
+ * The range of years includes the entire range expressible with positive and negative
+ * values of the datatype. The range of years for double is the range that would be allowed
+ * without losing precision to the corresponding unit.
+ *
+ * <table border="1" cellspacing="0" cellpadding="4">
+ *  <tr>
+ *    <th align="left">Units</th>
+ *    <th align="left">int64_t</th>
+ *    <th align="left">double</th>
+ *    <th align="left">int32_t</th>
+ *  </tr>
+ *
+ *  <tr>
+ *    <td>1 sec</td>
+ *    <td align="right">5.84542x10<sup>11</sup></td>
+ *    <td align="right">285,420,920.94</td>
+ *    <td align="right">136.10</td>
+ *  </tr>
+ *  <tr>
+ *
+ *    <td>1 millisecond</td>
+ *    <td align="right">584,542,046.09</td>
+ *    <td align="right">285,420.92</td>
+ *    <td align="right">0.14</td>
+ *  </tr>
+ *  <tr>
+ *    <td>1 microsecond</td>
+ *
+ *    <td align="right">584,542.05</td>
+ *    <td align="right">285.42</td>
+ *    <td align="right">0.00</td>
+ *  </tr>
+ *  <tr>
+ *    <td>100 nanoseconds (tick)</td>
+ *    <td align="right">58,454.20</td>
+ *    <td align="right">28.54</td>
+ *    <td align="right">0.00</td>
+ *  </tr>
+ *  <tr>
+ *    <td>1 nanosecond</td>
+ *    <td align="right">584.5420461</td>
+ *    <td align="right">0.2854</td>
+ *    <td align="right">0.00</td>
+ *  </tr>
+ * </table>
+ *
+ * <p>
+ * These functions implement a universal time scale which can be used as a 'pivot',
+ * and provide conversion functions to and from all other major time scales.
+ * This datetimes to be converted to the pivot time, safely manipulated,
+ * and converted back to any other datetime time scale.
+ *
+ *<p>
+ * So what to use for this pivot? Java time has plenty of range, but cannot represent
+ * .NET <code>System.DateTime</code> values without severe loss of precision. ICU4C time addresses this by using a
+ * <code>double</code> that is otherwise equivalent to the Java time. However, there are disadvantages
+ * with <code>doubles</code>. They provide for much more graceful degradation in arithmetic operations.
+ * But they only have 53 bits of accuracy, which means that they will lose precision when
+ * converting back and forth to ticks. What would really be nice would be a
+ * <code>long double</code> (80 bits -- 64 bit mantissa), but that is not supported on most systems.
+ *
+ *<p>
+ * The Unix extended time uses a structure with two components: time in seconds and a
+ * fractional field (microseconds). However, this is clumsy, slow, and
+ * prone to error (you always have to keep track of overflow and underflow in the
+ * fractional field). <code>BigDecimal</code> would allow for arbitrary precision and arbitrary range,
+ * but we do not want to use this as the normal type, because it is slow and does not
+ * have a fixed size.
+ *
+ *<p>
+ * Because of these issues, we ended up concluding that the .NET framework's
+ * <code>System.DateTime</code> would be the best pivot. However, we use the full range
+ * allowed by the datatype, allowing for datetimes back to 29,000 BC and up to 29,000 AD.
+ * This time scale is very fine grained, does not lose precision, and covers a range that
+ * will meet almost all requirements. It will not handle the range that Java times do,
+ * but frankly, being able to handle dates before 29,000 BC or after 29,000 AD is of very limited interest.
+ *
+ */
+
+/**
+ * <code>UDateTimeScale</code> values are used to specify the time scale used for
+ * conversion into or out if the universal time scale.
+ *
+ * @stable ICU 3.2
+ */
+typedef enum UDateTimeScale {
+    /**
+     * Used in the JDK. Data is a Java <code>long</code> (<code>int64_t</code>). Value
+     * is milliseconds since January 1, 1970.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_JAVA_TIME = 0,
+
+    /**
+     * Used on Unix systems. Data is <code>int32_t</code> or <code>int64_t</code>. Value
+     * is seconds since January 1, 1970.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_UNIX_TIME,
+    
+    /**
+     * Used in IUC4C. Data is a <code>double</code>. Value
+     * is milliseconds since January 1, 1970.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_ICU4C_TIME,
+    
+    /**
+     * Used in Windows for file times. Data is an <code>int64_t</code>. Value
+     * is ticks (1 tick == 100 nanoseconds) since January 1, 1601.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_WINDOWS_FILE_TIME,
+    
+    /**
+     * Used in the .NET framework's <code>System.DateTime</code> structure. Data is an <code>int64_t</code>. Value
+     * is ticks (1 tick == 100 nanoseconds) since January 1, 0001.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_DOTNET_DATE_TIME,
+    
+    /**
+     * Used in older Macintosh systems. Data is <code>int32_t</code> or <code>int64_t</code>. Value
+     * is seconds since January 1, 1904.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_MAC_OLD_TIME,
+    
+    /**
+     * Used in newer Macintosh systems. Data is a <code>double</code>. Value
+     * is seconds since January 1, 2001.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_MAC_TIME,
+    
+    /**
+     * Used in Excel. Data is an <code>?unknown?</code>. Value
+     * is days since December 31, 1899.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_EXCEL_TIME,
+    
+    /**
+     * Used in DB2. Data is an <code>?unknown?</code>. Value
+     * is days since December 31, 1899.
+     *
+     * @stable ICU 3.2
+     */
+    UDTS_DB2_TIME,
+
+    /**
+     * Data is a <code>long</code>. Value is microseconds since January 1, 1970.
+     * Similar to Unix time (linear value from 1970) and struct timeval
+     * (microseconds resolution).
+     *
+     * @stable ICU 4.0
+     */
+    UDTS_UNIX_MICROSECONDS_TIME,
+
+    /**
+     * The first unused time scale value. The limit of this enum
+     */
+    UDTS_MAX_SCALE
+} UDateTimeScale;
+
+/**
+ * <code>UTimeScaleValue</code> values are used to specify the time scale values
+ * to <code>utmscale_getTimeScaleValue</code>.
+ *
+ * @see utmscale_getTimeScaleValue
+ *
+ * @stable ICU 3.2
+ */
+typedef enum UTimeScaleValue {
+    /**
+     * The constant used to select the units vale
+     * for a time scale.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @stable ICU 3.2
+     */
+    UTSV_UNITS_VALUE = 0,
+
+    /**
+     * The constant used to select the epoch offset value
+     * for a time scale.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @stable ICU 3.2
+     */
+    UTSV_EPOCH_OFFSET_VALUE=1,
+
+    /**
+     * The constant used to select the minimum from value
+     * for a time scale.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @stable ICU 3.2
+     */
+    UTSV_FROM_MIN_VALUE=2,
+
+    /**
+     * The constant used to select the maximum from value
+     * for a time scale.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @stable ICU 3.2
+     */
+    UTSV_FROM_MAX_VALUE=3,
+
+    /**
+     * The constant used to select the minimum to value
+     * for a time scale.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @stable ICU 3.2
+     */
+    UTSV_TO_MIN_VALUE=4,
+
+    /**
+     * The constant used to select the maximum to value
+     * for a time scale.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @stable ICU 3.2
+     */
+    UTSV_TO_MAX_VALUE=5,
+
+#ifndef U_HIDE_INTERNAL_API
+    /**
+     * The constant used to select the epoch plus one value
+     * for a time scale.
+     * 
+     * NOTE: This is an internal value. DO NOT USE IT. May not
+     * actually be equal to the epoch offset value plus one.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @internal ICU 3.2
+     */
+    UTSV_EPOCH_OFFSET_PLUS_1_VALUE=6,
+
+    /**
+     * The constant used to select the epoch plus one value
+     * for a time scale.
+     * 
+     * NOTE: This is an internal value. DO NOT USE IT. May not
+     * actually be equal to the epoch offset value plus one.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @internal ICU 3.2
+     */
+    UTSV_EPOCH_OFFSET_MINUS_1_VALUE=7,
+
+    /**
+     * The constant used to select the units round value
+     * for a time scale.
+     * 
+     * NOTE: This is an internal value. DO NOT USE IT.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @internal ICU 3.2
+     */
+    UTSV_UNITS_ROUND_VALUE=8,
+
+    /**
+     * The constant used to select the minimum safe rounding value
+     * for a time scale.
+     * 
+     * NOTE: This is an internal value. DO NOT USE IT.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @internal ICU 3.2
+     */
+    UTSV_MIN_ROUND_VALUE=9,
+
+    /**
+     * The constant used to select the maximum safe rounding value
+     * for a time scale.
+     * 
+     * NOTE: This is an internal value. DO NOT USE IT.
+     * 
+     * @see utmscale_getTimeScaleValue
+     *
+     * @internal ICU 3.2
+     */
+    UTSV_MAX_ROUND_VALUE=10,
+
+#endif /* U_HIDE_INTERNAL_API */
+
+    /**
+     * The number of time scale values, in other words limit of this enum.
+     * 
+     * @see utmscale_getTimeScaleValue
+     */
+    UTSV_MAX_SCALE_VALUE=11
+
+} UTimeScaleValue;
+
+/**
+ * Get a value associated with a particular time scale.
+ * 
+ * @param timeScale The time scale
+ * @param value A constant representing the value to get
+ * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if arguments are invalid.
+ * @return - the value.
+ * 
+ * @stable ICU 3.2
+ */
+U_STABLE int64_t U_EXPORT2
+    utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErrorCode *status);
+
+/* Conversion to 'universal time scale' */
+
+/**
+ * Convert a <code>int64_t</code> datetime from the given time scale to the universal time scale.
+ *
+ * @param otherTime The <code>int64_t</code> datetime
+ * @param timeScale The time scale to convert from
+ * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.
+ * 
+ * @return The datetime converted to the universal time scale
+ *
+ * @stable ICU 3.2
+ */
+U_STABLE int64_t U_EXPORT2
+    utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status);
+
+/* Conversion from 'universal time scale' */
+
+/**
+ * Convert a datetime from the universal time scale to a <code>int64_t</code> in the given time scale.
+ *
+ * @param universalTime The datetime in the universal time scale
+ * @param timeScale The time scale to convert to
+ * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.
+ * 
+ * @return The datetime converted to the given time scale
+ *
+ * @stable ICU 3.2
+ */
+U_STABLE int64_t U_EXPORT2
+    utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status);
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
+
diff --git a/CoreFoundation/icu/unicode/utrace.h b/CoreFoundation/icu/unicode/utrace.h
new file mode 100644
index 0000000..3c8be9f
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utrace.h
@@ -0,0 +1,358 @@
+/*
+*******************************************************************************
+*
+*   Copyright (C) 2003-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*   file name:  utrace.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2003aug06
+*   created by: Markus W. Scherer
+*
+*   Definitions for ICU tracing/logging.
+*
+*/
+
+#ifndef __UTRACE_H__
+#define __UTRACE_H__
+
+#include <stdarg.h>
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C API:  Definitions for ICU tracing/logging. 
+ *
+ * This provides API for debugging the internals of ICU without the use of
+ * a traditional debugger.
+ *
+ * By default, tracing is disabled in ICU. If you need to debug ICU with 
+ * tracing, please compile ICU with the --enable-tracing configure option.
+ */
+ 
+U_CDECL_BEGIN
+
+/**
+ * Trace severity levels.  Higher levels increase the verbosity of the trace output.
+ * @see utrace_setLevel
+ * @stable ICU 2.8
+ */
+typedef enum UTraceLevel {
+    /** Disable all tracing  @stable ICU 2.8*/
+    UTRACE_OFF=-1,
+    /** Trace error conditions only  @stable ICU 2.8*/
+    UTRACE_ERROR=0,
+    /** Trace errors and warnings  @stable ICU 2.8*/
+    UTRACE_WARNING=3,
+    /** Trace opens and closes of ICU services  @stable ICU 2.8*/
+    UTRACE_OPEN_CLOSE=5,
+    /** Trace an intermediate number of ICU operations  @stable ICU 2.8*/
+    UTRACE_INFO=7,
+    /** Trace the maximum number of ICU operations  @stable ICU 2.8*/
+    UTRACE_VERBOSE=9
+} UTraceLevel;
+
+/**
+ *  These are the ICU functions that will be traced when tracing is enabled.
+ *  @stable ICU 2.8
+ */
+typedef enum UTraceFunctionNumber {
+    UTRACE_FUNCTION_START=0,
+    UTRACE_U_INIT=UTRACE_FUNCTION_START,
+    UTRACE_U_CLEANUP,
+    UTRACE_FUNCTION_LIMIT,
+
+    UTRACE_CONVERSION_START=0x1000,
+    UTRACE_UCNV_OPEN=UTRACE_CONVERSION_START,
+    UTRACE_UCNV_OPEN_PACKAGE,
+    UTRACE_UCNV_OPEN_ALGORITHMIC,
+    UTRACE_UCNV_CLONE,
+    UTRACE_UCNV_CLOSE,
+    UTRACE_UCNV_FLUSH_CACHE,
+    UTRACE_UCNV_LOAD,
+    UTRACE_UCNV_UNLOAD,
+    UTRACE_CONVERSION_LIMIT,
+
+    UTRACE_COLLATION_START=0x2000,
+    UTRACE_UCOL_OPEN=UTRACE_COLLATION_START,
+    UTRACE_UCOL_CLOSE,
+    UTRACE_UCOL_STRCOLL,
+    UTRACE_UCOL_GET_SORTKEY,
+    UTRACE_UCOL_GETLOCALE,
+    UTRACE_UCOL_NEXTSORTKEYPART,
+    UTRACE_UCOL_STRCOLLITER,
+    UTRACE_UCOL_OPEN_FROM_SHORT_STRING,
+    UTRACE_COLLATION_LIMIT
+} UTraceFunctionNumber;
+
+/**
+ * Setter for the trace level.
+ * @param traceLevel A UTraceLevel value.
+ * @stable ICU 2.8
+ */
+U_STABLE void U_EXPORT2
+utrace_setLevel(int32_t traceLevel);
+
+/**
+ * Getter for the trace level.
+ * @return The UTraceLevel value being used by ICU.
+ * @stable ICU 2.8
+ */
+U_STABLE int32_t U_EXPORT2
+utrace_getLevel(void);
+
+/* Trace function pointers types  ----------------------------- */
+
+/**
+  *  Type signature for the trace function to be called when entering a function.
+  *  @param context value supplied at the time the trace functions are set.
+  *  @param fnNumber Enum value indicating the ICU function being entered.
+  *  @stable ICU 2.8
+  */
+typedef void U_CALLCONV
+UTraceEntry(const void *context, int32_t fnNumber);
+
+/**
+  *  Type signature for the trace function to be called when exiting from a function.
+  *  @param context value supplied at the time the trace functions are set.
+  *  @param fnNumber Enum value indicating the ICU function being exited.
+  *  @param fmt     A formatting string that describes the number and types
+  *                 of arguments included with the variable args.  The fmt
+  *                 string has the same form as the utrace_vformat format
+  *                 string.
+  *  @param args    A variable arguments list.  Contents are described by
+  *                 the fmt parameter.
+  *  @see   utrace_vformat
+  *  @stable ICU 2.8
+  */
+typedef void U_CALLCONV
+UTraceExit(const void *context, int32_t fnNumber, 
+           const char *fmt, va_list args);
+
+/**
+  *  Type signature for the trace function to be called from within an ICU function
+  *  to display data or messages.
+  *  @param context  value supplied at the time the trace functions are set.
+  *  @param fnNumber Enum value indicating the ICU function being exited.
+  *  @param level    The current tracing level
+  *  @param fmt      A format string describing the tracing data that is supplied
+  *                  as variable args
+  *  @param args     The data being traced, passed as variable args.
+  *  @stable ICU 2.8
+  */
+typedef void U_CALLCONV
+UTraceData(const void *context, int32_t fnNumber, int32_t level,
+           const char *fmt, va_list args);
+
+/**
+  *  Set ICU Tracing functions.  Installs application-provided tracing
+  *  functions into ICU.  After doing this, subsequent ICU operations
+  *  will call back to the installed functions, providing a trace
+  *  of the use of ICU.  Passing a NULL pointer for a tracing function
+  *  is allowed, and inhibits tracing action at points where that function
+  *  would be called.
+  *  <p>
+  *  Tracing and Threads:  Tracing functions are global to a process, and
+  *  will be called in response to ICU operations performed by any
+  *  thread.  If tracing of an individual thread is desired, the
+  *  tracing functions must themselves filter by checking that the
+  *  current thread is the desired thread.
+  *
+  *  @param context an uninterpretted pointer.  Whatever is passed in
+  *                 here will in turn be passed to each of the tracing
+  *                 functions UTraceEntry, UTraceExit and UTraceData.
+  *                 ICU does not use or alter this pointer.
+  *  @param e       Callback function to be called on entry to a 
+  *                 a traced ICU function.
+  *  @param x       Callback function to be called on exit from a
+  *                 traced ICU function.
+  *  @param d       Callback function to be called from within a 
+  *                 traced ICU function, for the purpose of providing
+  *                 data to the trace.
+  *
+  *  @stable ICU 2.8
+  */
+U_STABLE void U_EXPORT2
+utrace_setFunctions(const void *context,
+                    UTraceEntry *e, UTraceExit *x, UTraceData *d);
+
+/**
+  * Get the currently installed ICU tracing functions.   Note that a null function
+  *   pointer will be returned if no trace function has been set.
+  *
+  * @param context  The currently installed tracing context.
+  * @param e        The currently installed UTraceEntry function.
+  * @param x        The currently installed UTraceExit function.
+  * @param d        The currently installed UTraceData function.
+  * @stable ICU 2.8
+  */
+U_STABLE void U_EXPORT2
+utrace_getFunctions(const void **context,
+                    UTraceEntry **e, UTraceExit **x, UTraceData **d);
+
+
+
+/*
+ *
+ * ICU trace format string syntax
+ *
+ * Format Strings are passed to UTraceData functions, and define the
+ * number and types of the trace data being passed on each call.
+ *
+ * The UTraceData function, which is supplied by the application,
+ * not by ICU, can either forward the trace data (passed via
+ * varargs) and the format string back to ICU for formatting into
+ * a displayable string, or it can interpret the format itself,
+ * and do as it wishes with the trace data.
+ *
+ *
+ * Goals for the format string
+ * - basic data output
+ * - easy to use for trace programmer
+ * - sufficient provision for data types for trace output readability
+ * - well-defined types and binary portable APIs
+ *
+ * Non-goals
+ * - printf compatibility
+ * - fancy formatting
+ * - argument reordering and other internationalization features
+ *
+ * ICU trace format strings contain plain text with argument inserts,
+ * much like standard printf format strings.
+ * Each insert begins with a '%', then optionally contains a 'v',
+ * then exactly one type character.
+ * Two '%' in a row represent a '%' instead of an insert.
+ * The trace format strings need not have \n at the end.
+ *
+ *
+ * Types
+ * -----
+ *
+ * Type characters:
+ * - c A char character in the default codepage.
+ * - s A NUL-terminated char * string in the default codepage.
+ * - S A UChar * string.  Requires two params, (ptr, length).  Length=-1 for nul term.
+ * - b A byte (8-bit integer).
+ * - h A 16-bit integer.  Also a 16 bit Unicode code unit.
+ * - d A 32-bit integer.  Also a 20 bit Unicode code point value. 
+ * - l A 64-bit integer.
+ * - p A data pointer.
+ *
+ * Vectors
+ * -------
+ *
+ * If the 'v' is not specified, then one item of the specified type
+ * is passed in.
+ * If the 'v' (for "vector") is specified, then a vector of items of the
+ * specified type is passed in, via a pointer to the first item
+ * and an int32_t value for the length of the vector.
+ * Length==-1 means zero or NUL termination.  Works for vectors of all types.
+ *
+ * Note:  %vS is a vector of (UChar *) strings.  The strings must
+ *        be nul terminated as there is no way to provide a
+ *        separate length parameter for each string.  The length
+ *        parameter (required for all vectors) is the number of
+ *        strings, not the length of the strings.
+ *
+ * Examples
+ * --------
+ *
+ * These examples show the parameters that will be passed to an application's
+ *   UTraceData() function for various formats.
+ *
+ * - the precise formatting is up to the application!
+ * - the examples use type casts for arguments only to _show_ the types of
+ *   arguments without needing variable declarations in the examples;
+ *   the type casts will not be necessary in actual code
+ *
+ * UTraceDataFunc(context, fnNumber, level,
+ *              "There is a character %c in the string %s.",   // Format String 
+ *              (char)c, (const char *)s);                     // varargs parameters
+ * ->   There is a character 0x42 'B' in the string "Bravo".
+ *
+ * UTraceDataFunc(context, fnNumber, level,
+ *              "Vector of bytes %vb vector of chars %vc",
+ *              (const uint8_t *)bytes, (int32_t)bytesLength,
+ *              (const char *)chars, (int32_t)charsLength);
+ * ->  Vector of bytes
+ *      42 63 64 3f [4]
+ *     vector of chars
+ *      "Bcd?"[4]
+ *
+ * UTraceDataFunc(context, fnNumber, level,
+ *              "An int32_t %d and a whole bunch of them %vd",
+ *              (int32_t)-5, (const int32_t *)ints, (int32_t)intsLength);
+ * ->   An int32_t 0xfffffffb and a whole bunch of them
+ *      fffffffb 00000005 0000010a [3]
+ *
+ */
+
+
+
+/**
+  *  Trace output Formatter.  An application's UTraceData tracing functions may call
+  *                 back to this function to format the trace output in a
+  *                 human readable form.  Note that a UTraceData function may choose
+  *                 to not format the data;  it could, for example, save it in
+  *                 in the raw form it was received (more compact), leaving
+  *                 formatting for a later trace analyis tool.
+  *  @param outBuf  pointer to a buffer to receive the formatted output.  Output
+  *                 will be nul terminated if there is space in the buffer -
+  *                 if the length of the requested output < the output buffer size.
+  *  @param capacity  Length of the output buffer.
+  *  @param indent  Number of spaces to indent the output.  Intended to allow
+  *                 data displayed from nested functions to be indented for readability.
+  *  @param fmt     Format specification for the data to output
+  *  @param args    Data to be formatted.
+  *  @return        Length of formatted output, including the terminating NUL.
+  *                 If buffer capacity is insufficient, the required capacity is returned. 
+  *  @stable ICU 2.8
+  */
+U_STABLE int32_t U_EXPORT2
+utrace_vformat(char *outBuf, int32_t capacity,
+              int32_t indent, const char *fmt,  va_list args);
+
+/**
+  *  Trace output Formatter.  An application's UTraceData tracing functions may call
+  *                 this function to format any additional trace data, beyond that
+  *                 provided by default, in human readable form with the same
+  *                 formatting conventions used by utrace_vformat().
+  *  @param outBuf  pointer to a buffer to receive the formatted output.  Output
+  *                 will be nul terminated if there is space in the buffer -
+  *                 if the length of the requested output < the output buffer size.
+  *  @param capacity  Length of the output buffer.
+  *  @param indent  Number of spaces to indent the output.  Intended to allow
+  *                 data displayed from nested functions to be indented for readability.
+  *  @param fmt     Format specification for the data to output
+  *  @param ...     Data to be formatted.
+  *  @return        Length of formatted output, including the terminating NUL.
+  *                 If buffer capacity is insufficient, the required capacity is returned. 
+  *  @stable ICU 2.8
+  */
+U_STABLE int32_t U_EXPORT2
+utrace_format(char *outBuf, int32_t capacity,
+              int32_t indent, const char *fmt,  ...);
+
+
+
+/* Trace function numbers --------------------------------------------------- */
+
+/**
+ * Get the name of a function from its trace function number.
+ *
+ * @param fnNumber The trace number for an ICU function.
+ * @return The name string for the function.
+ *
+ * @see UTraceFunctionNumber
+ * @stable ICU 2.8
+ */
+U_STABLE const char * U_EXPORT2
+utrace_functionName(int32_t fnNumber);
+
+U_CDECL_END
+
+#endif
diff --git a/CoreFoundation/icu/unicode/utrans.h b/CoreFoundation/icu/unicode/utrans.h
new file mode 100644
index 0000000..a460a34
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utrans.h
@@ -0,0 +1,583 @@
+/*
+*******************************************************************************
+*   Copyright (C) 1997-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*   Date        Name        Description
+*   06/21/00    aliu        Creation.
+*******************************************************************************
+*/
+
+#ifndef UTRANS_H
+#define UTRANS_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_TRANSLITERATION
+
+#include "unicode/urep.h"
+#include "unicode/parseerr.h"
+#include "unicode/uenum.h"
+
+/********************************************************************
+ * General Notes
+ ********************************************************************
+ */
+/**
+ * \file
+ * \brief C API: Transliterator
+ *
+ * <h2> Transliteration </h2>
+ * The data structures and functions described in this header provide
+ * transliteration services.  Transliteration services are implemented
+ * as C++ classes.  The comments and documentation in this header
+ * assume the reader is familiar with the C++ headers translit.h and
+ * associated documentation.
+ *
+ * A significant but incomplete subset of the C++ transliteration
+ * services are available to C code through this header.  In order to
+ * access more complex transliteration services, refer to the C++
+ * headers and documentation.
+ *
+ * There are two sets of functions for working with transliterator IDs:
+ *
+ * An old, deprecated set uses char * IDs, which works for true and pure
+ * identifiers that these APIs were designed for,
+ * for example "Cyrillic-Latin".
+ * It does not work when the ID contains filters ("[:Script=Cyrl:]")
+ * or even a complete set of rules because then the ID string contains more
+ * than just "invariant" characters (see utypes.h).
+ *
+ * A new set of functions replaces the old ones and uses UChar * IDs,
+ * paralleling the UnicodeString IDs in the C++ API. (New in ICU 2.8.)
+ */
+
+/********************************************************************
+ * Data Structures
+ ********************************************************************/
+
+/**
+ * An opaque transliterator for use in C.  Open with utrans_openxxx()
+ * and close with utrans_close() when done.  Equivalent to the C++ class
+ * Transliterator and its subclasses.
+ * @see Transliterator
+ * @stable ICU 2.0
+ */
+typedef void* UTransliterator;
+
+/**
+ * Direction constant indicating the direction in a transliterator,
+ * e.g., the forward or reverse rules of a RuleBasedTransliterator.
+ * Specified when a transliterator is opened.  An "A-B" transliterator
+ * transliterates A to B when operating in the forward direction, and
+ * B to A when operating in the reverse direction.
+ * @stable ICU 2.0
+ */
+typedef enum UTransDirection {
+    
+    /**
+     * UTRANS_FORWARD means from &lt;source&gt; to &lt;target&gt; for a
+     * transliterator with ID &lt;source&gt;-&lt;target&gt;.  For a transliterator
+     * opened using a rule, it means forward direction rules, e.g.,
+     * "A > B".
+     */
+    UTRANS_FORWARD,
+
+    /**
+     * UTRANS_REVERSE means from &lt;target&gt; to &lt;source&gt; for a
+     * transliterator with ID &lt;source&gt;-&lt;target&gt;.  For a transliterator
+     * opened using a rule, it means reverse direction rules, e.g.,
+     * "A < B".
+     */
+    UTRANS_REVERSE
+
+} UTransDirection;
+
+/**
+ * Position structure for utrans_transIncremental() incremental
+ * transliteration.  This structure defines two substrings of the text
+ * being transliterated.  The first region, [contextStart,
+ * contextLimit), defines what characters the transliterator will read
+ * as context.  The second region, [start, limit), defines what
+ * characters will actually be transliterated.  The second region
+ * should be a subset of the first.
+ *
+ * <p>After a transliteration operation, some of the indices in this
+ * structure will be modified.  See the field descriptions for
+ * details.
+ *
+ * <p>contextStart <= start <= limit <= contextLimit
+ *
+ * <p>Note: All index values in this structure must be at code point
+ * boundaries.  That is, none of them may occur between two code units
+ * of a surrogate pair.  If any index does split a surrogate pair,
+ * results are unspecified.
+ *
+ * @stable ICU 2.0
+ */
+typedef struct UTransPosition {
+
+    /**
+     * Beginning index, inclusive, of the context to be considered for
+     * a transliteration operation.  The transliterator will ignore
+     * anything before this index.  INPUT/OUTPUT parameter: This parameter
+     * is updated by a transliteration operation to reflect the maximum
+     * amount of antecontext needed by a transliterator.
+     * @stable ICU 2.4
+     */
+    int32_t contextStart;
+    
+    /**
+     * Ending index, exclusive, of the context to be considered for a
+     * transliteration operation.  The transliterator will ignore
+     * anything at or after this index.  INPUT/OUTPUT parameter: This
+     * parameter is updated to reflect changes in the length of the
+     * text, but points to the same logical position in the text.
+     * @stable ICU 2.4
+     */
+    int32_t contextLimit;
+    
+    /**
+     * Beginning index, inclusive, of the text to be transliteratd.
+     * INPUT/OUTPUT parameter: This parameter is advanced past
+     * characters that have already been transliterated by a
+     * transliteration operation.
+     * @stable ICU 2.4
+     */
+    int32_t start;
+    
+    /**
+     * Ending index, exclusive, of the text to be transliteratd.
+     * INPUT/OUTPUT parameter: This parameter is updated to reflect
+     * changes in the length of the text, but points to the same
+     * logical position in the text.
+     * @stable ICU 2.4
+     */
+    int32_t limit;
+
+} UTransPosition;
+
+/********************************************************************
+ * General API
+ ********************************************************************/
+
+/**
+ * Open a custom transliterator, given a custom rules string 
+ * OR 
+ * a system transliterator, given its ID.  
+ * Any non-NULL result from this function should later be closed with
+ * utrans_close().
+ *
+ * @param id a valid transliterator ID
+ * @param idLength the length of the ID string, or -1 if NUL-terminated
+ * @param dir the desired direction
+ * @param rules the transliterator rules.  See the C++ header rbt.h for
+ *              rules syntax. If NULL then a system transliterator matching
+ *              the ID is returned.
+ * @param rulesLength the length of the rules, or -1 if the rules
+ *                    are NUL-terminated.
+ * @param parseError a pointer to a UParseError struct to receive the details
+ *                   of any parsing errors. This parameter may be NULL if no
+ *                   parsing error details are desired.
+ * @param pErrorCode a pointer to the UErrorCode
+ * @return a transliterator pointer that may be passed to other
+ *         utrans_xxx() functions, or NULL if the open call fails.
+ * @stable ICU 2.8
+ */
+U_STABLE UTransliterator* U_EXPORT2
+utrans_openU(const UChar *id,
+             int32_t idLength,
+             UTransDirection dir,
+             const UChar *rules,
+             int32_t rulesLength,
+             UParseError *parseError,
+             UErrorCode *pErrorCode);
+
+/**
+ * Open an inverse of an existing transliterator.  For this to work,
+ * the inverse must be registered with the system.  For example, if
+ * the Transliterator "A-B" is opened, and then its inverse is opened,
+ * the result is the Transliterator "B-A", if such a transliterator is
+ * registered with the system.  Otherwise the result is NULL and a
+ * failing UErrorCode is set.  Any non-NULL result from this function
+ * should later be closed with utrans_close().
+ *
+ * @param trans the transliterator to open the inverse of.
+ * @param status a pointer to the UErrorCode
+ * @return a pointer to a newly-opened transliterator that is the
+ * inverse of trans, or NULL if the open call fails.
+ * @stable ICU 2.0
+ */
+U_STABLE UTransliterator* U_EXPORT2 
+utrans_openInverse(const UTransliterator* trans,
+                   UErrorCode* status);
+
+/**
+ * Create a copy of a transliterator.  Any non-NULL result from this
+ * function should later be closed with utrans_close().
+ *
+ * @param trans the transliterator to be copied.
+ * @param status a pointer to the UErrorCode
+ * @return a transliterator pointer that may be passed to other
+ * utrans_xxx() functions, or NULL if the clone call fails.
+ * @stable ICU 2.0
+ */
+U_STABLE UTransliterator* U_EXPORT2 
+utrans_clone(const UTransliterator* trans,
+             UErrorCode* status);
+
+/**
+ * Close a transliterator.  Any non-NULL pointer returned by
+ * utrans_openXxx() or utrans_clone() should eventually be closed.
+ * @param trans the transliterator to be closed.
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+utrans_close(UTransliterator* trans);
+
+/**
+ * Return the programmatic identifier for this transliterator.
+ * If this identifier is passed to utrans_openU(), it will open
+ * a transliterator equivalent to this one, if the ID has been
+ * registered.
+ *
+ * @param trans the transliterator to return the ID of.
+ * @param resultLength pointer to an output variable receiving the length
+ *        of the ID string; can be NULL
+ * @return the NUL-terminated ID string. This pointer remains
+ * valid until utrans_close() is called on this transliterator.
+ *
+ * @stable ICU 2.8
+ */
+U_STABLE const UChar * U_EXPORT2
+utrans_getUnicodeID(const UTransliterator *trans,
+                    int32_t *resultLength);
+
+/**
+ * Register an open transliterator with the system.  When
+ * utrans_open() is called with an ID string that is equal to that
+ * returned by utrans_getID(adoptedTrans,...), then
+ * utrans_clone(adoptedTrans,...) is returned.
+ *
+ * <p>NOTE: After this call the system owns the adoptedTrans and will
+ * close it.  The user must not call utrans_close() on adoptedTrans.
+ *
+ * @param adoptedTrans a transliterator, typically the result of
+ * utrans_openRules(), to be registered with the system.
+ * @param status a pointer to the UErrorCode
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+utrans_register(UTransliterator* adoptedTrans,
+                UErrorCode* status);
+
+/**
+ * Unregister a transliterator from the system.  After this call the
+ * system will no longer recognize the given ID when passed to
+ * utrans_open(). If the ID is invalid then nothing is done.
+ *
+ * @param id an ID to unregister
+ * @param idLength the length of id, or -1 if id is zero-terminated
+ * @stable ICU 2.8
+ */
+U_STABLE void U_EXPORT2
+utrans_unregisterID(const UChar* id, int32_t idLength);
+
+/**
+ * Set the filter used by a transliterator.  A filter can be used to
+ * make the transliterator pass certain characters through untouched.
+ * The filter is expressed using a UnicodeSet pattern.  If the
+ * filterPattern is NULL or the empty string, then the transliterator
+ * will be reset to use no filter.
+ *
+ * @param trans the transliterator
+ * @param filterPattern a pattern string, in the form accepted by
+ * UnicodeSet, specifying which characters to apply the
+ * transliteration to.  May be NULL or the empty string to indicate no
+ * filter.
+ * @param filterPatternLen the length of filterPattern, or -1 if
+ * filterPattern is zero-terminated
+ * @param status a pointer to the UErrorCode
+ * @see UnicodeSet
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+utrans_setFilter(UTransliterator* trans,
+                 const UChar* filterPattern,
+                 int32_t filterPatternLen,
+                 UErrorCode* status);
+
+/**
+ * Return the number of system transliterators.
+ * It is recommended to use utrans_openIDs() instead.
+ *
+ * @return the number of system transliterators.
+ * @stable ICU 2.0
+ */
+U_STABLE int32_t U_EXPORT2 
+utrans_countAvailableIDs(void);
+
+/**
+ * Return a UEnumeration for the available transliterators.
+ *
+ * @param pErrorCode Pointer to the UErrorCode in/out parameter.
+ * @return UEnumeration for the available transliterators.
+ *         Close with uenum_close().
+ *
+ * @stable ICU 2.8
+ */
+U_STABLE UEnumeration * U_EXPORT2
+utrans_openIDs(UErrorCode *pErrorCode);
+
+/********************************************************************
+ * Transliteration API
+ ********************************************************************/
+
+/**
+ * Transliterate a segment of a UReplaceable string.  The string is
+ * passed in as a UReplaceable pointer rep and a UReplaceableCallbacks
+ * function pointer struct repFunc.  Functions in the repFunc struct
+ * will be called in order to modify the rep string.
+ *
+ * @param trans the transliterator
+ * @param rep a pointer to the string.  This will be passed to the
+ * repFunc functions.
+ * @param repFunc a set of function pointers that will be used to
+ * modify the string pointed to by rep.
+ * @param start the beginning index, inclusive; <code>0 <= start <=
+ * limit</code>.
+ * @param limit pointer to the ending index, exclusive; <code>start <=
+ * limit <= repFunc->length(rep)</code>.  Upon return, *limit will
+ * contain the new limit index.  The text previously occupying
+ * <code>[start, limit)</code> has been transliterated, possibly to a
+ * string of a different length, at <code>[start,
+ * </code><em>new-limit</em><code>)</code>, where <em>new-limit</em>
+ * is the return value.
+ * @param status a pointer to the UErrorCode
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+utrans_trans(const UTransliterator* trans,
+             UReplaceable* rep,
+             UReplaceableCallbacks* repFunc,
+             int32_t start,
+             int32_t* limit,
+             UErrorCode* status);
+
+/**
+ * Transliterate the portion of the UReplaceable text buffer that can
+ * be transliterated unambiguosly.  This method is typically called
+ * after new text has been inserted, e.g. as a result of a keyboard
+ * event.  The transliterator will try to transliterate characters of
+ * <code>rep</code> between <code>index.cursor</code> and
+ * <code>index.limit</code>.  Characters before
+ * <code>index.cursor</code> will not be changed.
+ *
+ * <p>Upon return, values in <code>index</code> will be updated.
+ * <code>index.start</code> will be advanced to the first
+ * character that future calls to this method will read.
+ * <code>index.cursor</code> and <code>index.limit</code> will
+ * be adjusted to delimit the range of text that future calls to
+ * this method may change.
+ *
+ * <p>Typical usage of this method begins with an initial call
+ * with <code>index.start</code> and <code>index.limit</code>
+ * set to indicate the portion of <code>text</code> to be
+ * transliterated, and <code>index.cursor == index.start</code>.
+ * Thereafter, <code>index</code> can be used without
+ * modification in future calls, provided that all changes to
+ * <code>text</code> are made via this method.
+ *
+ * <p>This method assumes that future calls may be made that will
+ * insert new text into the buffer.  As a result, it only performs
+ * unambiguous transliterations.  After the last call to this method,
+ * there may be untransliterated text that is waiting for more input
+ * to resolve an ambiguity.  In order to perform these pending
+ * transliterations, clients should call utrans_trans() with a start
+ * of index.start and a limit of index.end after the last call to this
+ * method has been made.
+ *
+ * @param trans the transliterator
+ * @param rep a pointer to the string.  This will be passed to the
+ * repFunc functions.
+ * @param repFunc a set of function pointers that will be used to
+ * modify the string pointed to by rep.
+ * @param pos a struct containing the start and limit indices of the
+ * text to be read and the text to be transliterated
+ * @param status a pointer to the UErrorCode
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+utrans_transIncremental(const UTransliterator* trans,
+                        UReplaceable* rep,
+                        UReplaceableCallbacks* repFunc,
+                        UTransPosition* pos,
+                        UErrorCode* status);
+
+/**
+ * Transliterate a segment of a UChar* string.  The string is passed
+ * in in a UChar* buffer.  The string is modified in place.  If the
+ * result is longer than textCapacity, it is truncated.  The actual
+ * length of the result is returned in *textLength, if textLength is
+ * non-NULL. *textLength may be greater than textCapacity, but only
+ * textCapacity UChars will be written to *text, including the zero
+ * terminator.
+ *
+ * @param trans the transliterator
+ * @param text a pointer to a buffer containing the text to be
+ * transliterated on input and the result text on output.
+ * @param textLength a pointer to the length of the string in text.
+ * If the length is -1 then the string is assumed to be
+ * zero-terminated.  Upon return, the new length is stored in
+ * *textLength.  If textLength is NULL then the string is assumed to
+ * be zero-terminated.
+ * @param textCapacity a pointer to the length of the text buffer.
+ * Upon return, 
+ * @param start the beginning index, inclusive; <code>0 <= start <=
+ * limit</code>.
+ * @param limit pointer to the ending index, exclusive; <code>start <=
+ * limit <= repFunc->length(rep)</code>.  Upon return, *limit will
+ * contain the new limit index.  The text previously occupying
+ * <code>[start, limit)</code> has been transliterated, possibly to a
+ * string of a different length, at <code>[start,
+ * </code><em>new-limit</em><code>)</code>, where <em>new-limit</em>
+ * is the return value.
+ * @param status a pointer to the UErrorCode
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+utrans_transUChars(const UTransliterator* trans,
+                   UChar* text,
+                   int32_t* textLength,
+                   int32_t textCapacity,
+                   int32_t start,
+                   int32_t* limit,
+                   UErrorCode* status);
+
+/**
+ * Transliterate the portion of the UChar* text buffer that can be
+ * transliterated unambiguosly.  See utrans_transIncremental().  The
+ * string is passed in in a UChar* buffer.  The string is modified in
+ * place.  If the result is longer than textCapacity, it is truncated.
+ * The actual length of the result is returned in *textLength, if
+ * textLength is non-NULL. *textLength may be greater than
+ * textCapacity, but only textCapacity UChars will be written to
+ * *text, including the zero terminator.  See utrans_transIncremental()
+ * for usage details.
+ *
+ * @param trans the transliterator
+ * @param text a pointer to a buffer containing the text to be
+ * transliterated on input and the result text on output.
+ * @param textLength a pointer to the length of the string in text.
+ * If the length is -1 then the string is assumed to be
+ * zero-terminated.  Upon return, the new length is stored in
+ * *textLength.  If textLength is NULL then the string is assumed to
+ * be zero-terminated.
+ * @param textCapacity the length of the text buffer
+ * @param pos a struct containing the start and limit indices of the
+ * text to be read and the text to be transliterated
+ * @param status a pointer to the UErrorCode
+ * @see utrans_transIncremental
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2 
+utrans_transIncrementalUChars(const UTransliterator* trans,
+                              UChar* text,
+                              int32_t* textLength,
+                              int32_t textCapacity,
+                              UTransPosition* pos,
+                              UErrorCode* status);
+
+/* deprecated API ----------------------------------------------------------- */
+
+/* see utrans.h documentation for why these functions are deprecated */
+
+/**
+ * Deprecated, use utrans_openU() instead.
+ * Open a custom transliterator, given a custom rules string 
+ * OR 
+ * a system transliterator, given its ID.  
+ * Any non-NULL result from this function should later be closed with
+ * utrans_close().
+ *
+ * @param id a valid ID, as returned by utrans_getAvailableID()
+ * @param dir the desired direction
+ * @param rules the transliterator rules.  See the C++ header rbt.h
+ * for rules syntax. If NULL then a system transliterator matching 
+ * the ID is returned.
+ * @param rulesLength the length of the rules, or -1 if the rules
+ * are zero-terminated.
+ * @param parseError a pointer to a UParseError struct to receive the
+ * details of any parsing errors. This parameter may be NULL if no
+ * parsing error details are desired.
+ * @param status a pointer to the UErrorCode
+ * @return a transliterator pointer that may be passed to other
+ * utrans_xxx() functions, or NULL if the open call fails.
+ * @deprecated ICU 2.8 Use utrans_openU() instead, see utrans.h
+ */
+U_DEPRECATED UTransliterator* U_EXPORT2 
+utrans_open(const char* id,
+            UTransDirection dir,
+            const UChar* rules,         /* may be Null */
+            int32_t rulesLength,        /* -1 if null-terminated */ 
+            UParseError* parseError,    /* may be Null */
+            UErrorCode* status);
+
+/**
+ * Deprecated, use utrans_getUnicodeID() instead.
+ * Return the programmatic identifier for this transliterator.
+ * If this identifier is passed to utrans_open(), it will open
+ * a transliterator equivalent to this one, if the ID has been
+ * registered.
+ * @param trans the transliterator to return the ID of.
+ * @param buf the buffer in which to receive the ID.  This may be
+ * NULL, in which case no characters are copied.
+ * @param bufCapacity the capacity of the buffer.  Ignored if buf is
+ * NULL.
+ * @return the actual length of the ID, not including
+ * zero-termination.  This may be greater than bufCapacity.
+ * @deprecated ICU 2.8 Use utrans_getUnicodeID() instead, see utrans.h
+ */
+U_DEPRECATED int32_t U_EXPORT2 
+utrans_getID(const UTransliterator* trans,
+             char* buf,
+             int32_t bufCapacity);
+
+/**
+ * Deprecated, use utrans_unregisterID() instead.
+ * Unregister a transliterator from the system.  After this call the
+ * system will no longer recognize the given ID when passed to
+ * utrans_open().  If the id is invalid then nothing is done.
+ *
+ * @param id a zero-terminated ID
+ * @deprecated ICU 2.8 Use utrans_unregisterID() instead, see utrans.h
+ */
+U_DEPRECATED void U_EXPORT2 
+utrans_unregister(const char* id);
+
+/**
+ * Deprecated, use utrans_openIDs() instead.
+ * Return the ID of the index-th system transliterator.  The result
+ * is placed in the given buffer.  If the given buffer is too small,
+ * the initial substring is copied to buf.  The result in buf is
+ * always zero-terminated.
+ *
+ * @param index the number of the transliterator to return.  Must
+ * satisfy 0 <= index < utrans_countAvailableIDs().  If index is out
+ * of range then it is treated as if it were 0.
+ * @param buf the buffer in which to receive the ID.  This may be
+ * NULL, in which case no characters are copied.
+ * @param bufCapacity the capacity of the buffer.  Ignored if buf is
+ * NULL.
+ * @return the actual length of the index-th ID, not including
+ * zero-termination.  This may be greater than bufCapacity.
+ * @deprecated ICU 2.8 Use utrans_openIDs() instead, see utrans.h
+ */
+U_DEPRECATED int32_t U_EXPORT2 
+utrans_getAvailableID(int32_t index,
+                      char* buf,
+                      int32_t bufCapacity);
+
+#endif /* #if !UCONFIG_NO_TRANSLITERATION */
+
+#endif
diff --git a/CoreFoundation/icu/unicode/utypes.h b/CoreFoundation/icu/unicode/utypes.h
new file mode 100644
index 0000000..12977ed
--- /dev/null
+++ b/CoreFoundation/icu/unicode/utypes.h
@@ -0,0 +1,801 @@
+/*
+**********************************************************************
+*   Copyright (C) 1996-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+*  FILE NAME : UTYPES.H (formerly ptypes.h)
+*
+*   Date        Name        Description
+*   12/11/96    helena      Creation.
+*   02/27/97    aliu        Added typedefs for UClassID, int8, int16, int32,
+*                           uint8, uint16, and uint32.
+*   04/01/97    aliu        Added XP_CPLUSPLUS and modified to work under C as
+*                            well as C++.
+*                           Modified to use memcpy() for uprv_arrayCopy() fns.
+*   04/14/97    aliu        Added TPlatformUtilities.
+*   05/07/97    aliu        Added import/export specifiers (replacing the old
+*                           broken EXT_CLASS).  Added version number for our
+*                           code.  Cleaned up header.
+*    6/20/97    helena      Java class name change.
+*   08/11/98    stephen     UErrorCode changed from typedef to enum
+*   08/12/98    erm         Changed T_ANALYTIC_PACKAGE_VERSION to 3
+*   08/14/98    stephen     Added uprv_arrayCopy() for int8_t, int16_t, int32_t
+*   12/09/98    jfitz       Added BUFFER_OVERFLOW_ERROR (bug 1100066)
+*   04/20/99    stephen     Cleaned up & reworked for autoconf.
+*                           Renamed to utypes.h.
+*   05/05/99    stephen     Changed to use <inttypes.h>
+*   12/07/99    helena      Moved copyright notice string from ucnv_bld.h here.
+*******************************************************************************
+*/
+
+#ifndef UTYPES_H
+#define UTYPES_H
+
+
+#include "unicode/umachine.h"
+#include "unicode/utf.h"
+#include "unicode/uversion.h"
+#include "unicode/uconfig.h"
+
+#if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_DRAFT_API)
+#define U_HIDE_DRAFT_API 1
+#endif
+
+#ifdef U_HIDE_DRAFT_API
+#include "unicode/udraft.h"
+#endif
+
+#ifdef U_HIDE_DEPRECATED_API
+#include "unicode/udeprctd.h"
+#endif
+
+#ifdef U_HIDE_DEPRECATED_API
+#include "unicode/uobslete.h"
+#endif
+
+#ifdef U_HIDE_INTERNAL_API
+#include "unicode/uintrnal.h"
+#endif
+
+#ifdef U_HIDE_SYSTEM_API
+#include "unicode/usystem.h"
+#endif
+
+/*!
+ * \file
+ * \brief Basic definitions for ICU, for both C and C++ APIs
+ *
+ * This file defines basic types, constants, and enumerations directly or
+ * indirectly by including other header files, especially utf.h for the
+ * basic character and string definitions and umachine.h for consistent
+ * integer and other types.
+ */
+
+/*===========================================================================*/
+/* char Character set family                                                 */
+/*===========================================================================*/
+
+/**
+ * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.
+ * @stable ICU 2.0
+ */
+#define U_ASCII_FAMILY 0
+
+/**
+ * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.
+ * @stable ICU 2.0
+ */
+#define U_EBCDIC_FAMILY 1
+
+/**
+ * \def U_CHARSET_FAMILY
+ *
+ * <p>These definitions allow to specify the encoding of text
+ * in the char data type as defined by the platform and the compiler.
+ * It is enough to determine the code point values of "invariant characters",
+ * which are the ones shared by all encodings that are in use
+ * on a given platform.</p>
+ *
+ * <p>Those "invariant characters" should be all the uppercase and lowercase
+ * latin letters, the digits, the space, and "basic punctuation".
+ * Also, '\\n', '\\r', '\\t' should be available.</p>
+ *
+ * <p>The list of "invariant characters" is:<br>
+ * \code
+ *    A-Z  a-z  0-9  SPACE  "  %  &amp;  '  (  )  *  +  ,  -  .  /  :  ;  <  =  >  ?  _
+ * \endcode
+ * <br>
+ * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p>
+ *
+ * <p>This matches the IBM Syntactic Character Set (CS 640).</p>
+ *
+ * <p>In other words, all the graphic characters in 7-bit ASCII should
+ * be safely accessible except the following:</p>
+ *
+ * \code
+ *    '\' <backslash>
+ *    '[' <left bracket>
+ *    ']' <right bracket>
+ *    '{' <left brace>
+ *    '}' <right brace>
+ *    '^' <circumflex>
+ *    '~' <tilde>
+ *    '!' <exclamation mark>
+ *    '#' <number sign>
+ *    '|' <vertical line>
+ *    '$' <dollar sign>
+ *    '@' <commercial at>
+ *    '`' <grave accent>
+ * \endcode
+ * @stable ICU 2.0
+ */
+
+#ifndef U_CHARSET_FAMILY
+#   define U_CHARSET_FAMILY 0
+#endif
+
+/*===========================================================================*/
+/* ICUDATA naming scheme                                                     */
+/*===========================================================================*/
+
+/**
+ * \def U_ICUDATA_TYPE_LETTER
+ *
+ * This is a platform-dependent string containing one letter:
+ * - b for big-endian, ASCII-family platforms
+ * - l for little-endian, ASCII-family platforms
+ * - e for big-endian, EBCDIC-family platforms
+ * This letter is part of the common data file name.
+ * @stable ICU 2.0
+ */
+
+/**
+ * \def U_ICUDATA_TYPE_LITLETTER
+ * The non-string form of U_ICUDATA_TYPE_LETTER
+ * @stable ICU 2.0
+ */
+#if U_CHARSET_FAMILY
+#   if U_IS_BIG_ENDIAN
+   /* EBCDIC - should always be BE */
+#     define U_ICUDATA_TYPE_LETTER "e"
+#     define U_ICUDATA_TYPE_LITLETTER e
+#   else
+#     error "Don't know what to do with little endian EBCDIC!"
+#     define U_ICUDATA_TYPE_LETTER "x"
+#     define U_ICUDATA_TYPE_LITLETTER x
+#   endif
+#else
+#   if U_IS_BIG_ENDIAN
+      /* Big-endian ASCII */
+#     define U_ICUDATA_TYPE_LETTER "b"
+#     define U_ICUDATA_TYPE_LITLETTER b
+#   else
+      /* Little-endian ASCII */
+#     define U_ICUDATA_TYPE_LETTER "l"
+#     define U_ICUDATA_TYPE_LITLETTER l
+#   endif
+#endif
+
+/**
+ * A single string literal containing the icudata stub name. i.e. 'icudt18e' for
+ * ICU 1.8.x on EBCDIC, etc..
+ * @stable ICU 2.0
+ */
+#define U_ICUDATA_NAME    "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER
+
+
+/**
+ *  U_ICU_ENTRY_POINT is the name of the DLL entry point to the ICU data library.
+ *    Defined as a literal, not a string.
+ *    Tricky Preprocessor use - ## operator replaces macro paramters with the literal string
+ *                              from the corresponding macro invocation, _before_ other macro substitutions.
+ *                              Need a nested \#defines to get the actual version numbers rather than
+ *                              the literal text U_ICU_VERSION_MAJOR_NUM into the name.
+ *                              The net result will be something of the form
+ *                                  \#define U_ICU_ENTRY_POINT icudt19_dat
+ * @stable ICU 2.4
+ */
+#define U_ICUDATA_ENTRY_POINT  U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM, U_ICU_VERSION_MINOR_NUM)
+
+/**
+ * Do not use.
+ * @internal
+ */
+#define U_DEF2_ICUDATA_ENTRY_POINT(major, minor) U_DEF_ICUDATA_ENTRY_POINT(major, minor)
+/**
+ * Do not use.
+ * @internal
+ */
+#define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt##major##minor##_dat
+
+/**
+ * \def U_CALLCONV
+ * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary
+ * in callback function typedefs to make sure that the calling convention
+ * is compatible.
+ *
+ * This is only used for non-ICU-API functions.
+ * When a function is a public ICU API,
+ * you must use the U_CAPI and U_EXPORT2 qualifiers.
+ * @stable ICU 2.0
+ */
+#if defined(OS390) && (__COMPILER_VER__ < 0x41020000) && defined(XP_CPLUSPLUS)
+#    define U_CALLCONV __cdecl
+#else
+#    define U_CALLCONV U_EXPORT2
+#endif
+
+/**
+ * \def NULL
+ * Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
+ * @stable ICU 2.0
+ */
+#ifndef NULL
+#ifdef XP_CPLUSPLUS
+#define NULL    0
+#else
+#define NULL    ((void *)0)
+#endif
+#endif
+
+/*===========================================================================*/
+/* Calendar/TimeZone data types                                              */
+/*===========================================================================*/
+
+/**
+ * Date and Time data type.
+ * This is a primitive data type that holds the date and time
+ * as the number of milliseconds since 1970-jan-01, 00:00 UTC.
+ * UTC leap seconds are ignored.
+ * @stable ICU 2.0
+ */
+typedef double UDate;
+
+/** The number of milliseconds per second @stable ICU 2.0 */
+#define U_MILLIS_PER_SECOND        (1000)
+/** The number of milliseconds per minute @stable ICU 2.0 */
+#define U_MILLIS_PER_MINUTE       (60000)
+/** The number of milliseconds per hour @stable ICU 2.0 */
+#define U_MILLIS_PER_HOUR       (3600000)
+/** The number of milliseconds per day @stable ICU 2.0 */
+#define U_MILLIS_PER_DAY       (86400000)
+
+
+/*===========================================================================*/
+/* UClassID-based RTTI */
+/*===========================================================================*/
+
+/**
+ * UClassID is used to identify classes without using RTTI, since RTTI
+ * is not yet supported by all C++ compilers.  Each class hierarchy which needs
+ * to implement polymorphic clone() or operator==() defines two methods,
+ * described in detail below.  UClassID values can be compared using
+ * operator==(). Nothing else should be done with them.
+ *
+ * \par
+ * getDynamicClassID() is declared in the base class of the hierarchy as
+ * a pure virtual.  Each concrete subclass implements it in the same way:
+ *
+ * \code
+ *      class Base {
+ *      public:
+ *          virtual UClassID getDynamicClassID() const = 0;
+ *      }
+ *
+ *      class Derived {
+ *      public:
+ *          virtual UClassID getDynamicClassID() const
+ *            { return Derived::getStaticClassID(); }
+ *      }
+ * \endcode
+ *
+ * Each concrete class implements getStaticClassID() as well, which allows
+ * clients to test for a specific type.
+ *
+ * \code
+ *      class Derived {
+ *      public:
+ *          static UClassID U_EXPORT2 getStaticClassID();
+ *      private:
+ *          static char fgClassID;
+ *      }
+ *
+ *      // In Derived.cpp:
+ *      UClassID Derived::getStaticClassID()
+ *        { return (UClassID)&Derived::fgClassID; }
+ *      char Derived::fgClassID = 0; // Value is irrelevant
+ * \endcode
+ * @stable ICU 2.0
+ */
+typedef void* UClassID;
+
+/*===========================================================================*/
+/* Shared library/DLL import-export API control                              */
+/*===========================================================================*/
+
+/*
+ * Control of symbol import/export.
+ * ICU is separated into three libraries.
+ */
+
+/*
+ * \def U_COMBINED_IMPLEMENTATION
+ * Set to export library symbols from inside the ICU library
+ * when all of ICU is in a single library.
+ * This can be set as a compiler option while building ICU, and it
+ * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc.
+ * @stable ICU 2.0
+ */
+
+/**
+ * \def U_DATA_API
+ * Set to export library symbols from inside the stubdata library,
+ * and to import them from outside.
+ * @stable ICU 3.0
+ */
+
+/**
+ * \def U_COMMON_API
+ * Set to export library symbols from inside the common library,
+ * and to import them from outside.
+ * @stable ICU 2.0
+ */
+
+/**
+ * \def U_I18N_API
+ * Set to export library symbols from inside the i18n library,
+ * and to import them from outside.
+ * @stable ICU 2.0
+ */
+
+/**
+ * \def U_LAYOUT_API
+ * Set to export library symbols from inside the layout engine library,
+ * and to import them from outside.
+ * @stable ICU 2.0
+ */
+
+/**
+ * \def U_LAYOUTEX_API
+ * Set to export library symbols from inside the layout extensions library,
+ * and to import them from outside.
+ * @stable ICU 2.6
+ */
+
+/**
+ * \def U_IO_API
+ * Set to export library symbols from inside the ustdio library,
+ * and to import them from outside.
+ * @stable ICU 2.0
+ */
+
+/**
+ * \def U_TOOLUTIL_API
+ * Set to export library symbols from inside the toolutil library,
+ * and to import them from outside.
+ * @stable ICU 3.4
+ */
+
+#if defined(U_COMBINED_IMPLEMENTATION)
+#define U_DATA_API     U_EXPORT
+#define U_COMMON_API   U_EXPORT
+#define U_I18N_API     U_EXPORT
+#define U_LAYOUT_API   U_EXPORT
+#define U_LAYOUTEX_API U_EXPORT
+#define U_IO_API       U_EXPORT
+#define U_TOOLUTIL_API U_EXPORT
+#elif defined(U_STATIC_IMPLEMENTATION)
+#define U_DATA_API
+#define U_COMMON_API
+#define U_I18N_API
+#define U_LAYOUT_API
+#define U_LAYOUTEX_API
+#define U_IO_API
+#define U_TOOLUTIL_API
+#elif defined(U_COMMON_IMPLEMENTATION)
+#define U_DATA_API     U_IMPORT
+#define U_COMMON_API   U_EXPORT
+#define U_I18N_API     U_IMPORT
+#define U_LAYOUT_API   U_IMPORT
+#define U_LAYOUTEX_API U_IMPORT
+#define U_IO_API       U_IMPORT
+#define U_TOOLUTIL_API U_IMPORT
+#elif defined(U_I18N_IMPLEMENTATION)
+#define U_DATA_API     U_IMPORT
+#define U_COMMON_API   U_IMPORT
+#define U_I18N_API     U_EXPORT
+#define U_LAYOUT_API   U_IMPORT
+#define U_LAYOUTEX_API U_IMPORT
+#define U_IO_API       U_IMPORT
+#define U_TOOLUTIL_API U_IMPORT
+#elif defined(U_LAYOUT_IMPLEMENTATION)
+#define U_DATA_API     U_IMPORT
+#define U_COMMON_API   U_IMPORT
+#define U_I18N_API     U_IMPORT
+#define U_LAYOUT_API   U_EXPORT
+#define U_LAYOUTEX_API U_IMPORT
+#define U_IO_API       U_IMPORT
+#define U_TOOLUTIL_API U_IMPORT
+#elif defined(U_LAYOUTEX_IMPLEMENTATION)
+#define U_DATA_API     U_IMPORT
+#define U_COMMON_API   U_IMPORT
+#define U_I18N_API     U_IMPORT
+#define U_LAYOUT_API   U_IMPORT
+#define U_LAYOUTEX_API U_EXPORT
+#define U_IO_API       U_IMPORT
+#define U_TOOLUTIL_API U_IMPORT
+#elif defined(U_IO_IMPLEMENTATION)
+#define U_DATA_API     U_IMPORT
+#define U_COMMON_API   U_IMPORT
+#define U_I18N_API     U_IMPORT
+#define U_LAYOUT_API   U_IMPORT
+#define U_LAYOUTEX_API U_IMPORT
+#define U_IO_API       U_EXPORT
+#define U_TOOLUTIL_API U_IMPORT
+#elif defined(U_TOOLUTIL_IMPLEMENTATION)
+#define U_DATA_API     U_IMPORT
+#define U_COMMON_API   U_IMPORT
+#define U_I18N_API     U_IMPORT
+#define U_LAYOUT_API   U_IMPORT
+#define U_LAYOUTEX_API U_IMPORT
+#define U_IO_API       U_IMPORT
+#define U_TOOLUTIL_API U_EXPORT
+#else
+#define U_DATA_API     U_IMPORT
+#define U_COMMON_API   U_IMPORT
+#define U_I18N_API     U_IMPORT
+#define U_LAYOUT_API   U_IMPORT
+#define U_LAYOUTEX_API U_IMPORT
+#define U_IO_API       U_IMPORT
+#define U_TOOLUTIL_API U_IMPORT
+#endif
+
+/**
+ * \def U_STANDARD_CPP_NAMESPACE
+ * Control of C++ Namespace
+ * @stable ICU 2.0
+ */
+#ifdef __cplusplus
+#define U_STANDARD_CPP_NAMESPACE        ::
+#else
+#define U_STANDARD_CPP_NAMESPACE
+#endif
+
+
+/*===========================================================================*/
+/* Global delete operator                                                    */
+/*===========================================================================*/
+
+/*
+ * The ICU4C library must not use the global new and delete operators.
+ * These operators here are defined to enable testing for this.
+ * See Jitterbug 2581 for details of why this is necessary.
+ *
+ * Verification that ICU4C's memory usage is correct, i.e.,
+ * that global new/delete are not used:
+ *
+ * a) Check for imports of global new/delete (see uobject.cpp for details)
+ * b) Verify that new is never imported.
+ * c) Verify that delete is only imported from object code for interface/mixin classes.
+ * d) Add global delete and delete[] only for the ICU4C library itself
+ *    and define them in a way that crashes or otherwise easily shows a problem.
+ *
+ * The following implements d).
+ * The operator implementations crash; this is intentional and used for library debugging.
+ *
+ * Note: This is currently only done on Windows because
+ * some Linux/Unix compilers have problems with defining global new/delete.
+ * On Windows, U_WINDOWS is defined, and it is _MSC_VER>=1200 for MSVC 6.0 and higher.
+ */
+#if defined(XP_CPLUSPLUS) && defined(U_WINDOWS) && U_DEBUG && U_OVERRIDE_CXX_ALLOCATION && (_MSC_VER>=1200) && !defined(U_STATIC_IMPLEMENTATION) && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION))
+
+#ifndef U_HIDE_INTERNAL_API
+/**
+ * Global operator new, defined only inside ICU4C, must not be used.
+ * Crashes intentionally.
+ * @internal
+ */
+inline void *
+operator new(size_t /*size*/) {
+    char *q=NULL;
+    *q=5; /* break it */
+    return q;
+}
+
+#ifdef _Ret_bytecap_
+/* This is only needed to suppress a Visual C++ 2008 warning for operator new[]. */
+_Ret_bytecap_(_Size)
+#endif
+/**
+ * Global operator new[], defined only inside ICU4C, must not be used.
+ * Crashes intentionally.
+ * @internal
+ */
+inline void *
+operator new[](size_t /*size*/) {
+    char *q=NULL;
+    *q=5; /* break it */
+    return q;
+}
+
+/**
+ * Global operator delete, defined only inside ICU4C, must not be used.
+ * Crashes intentionally.
+ * @internal
+ */
+inline void
+operator delete(void * /*p*/) {
+    char *q=NULL;
+    *q=5; /* break it */
+}
+
+/**
+ * Global operator delete[], defined only inside ICU4C, must not be used.
+ * Crashes intentionally.
+ * @internal
+ */
+inline void
+operator delete[](void * /*p*/) {
+    char *q=NULL;
+    *q=5; /* break it */
+}
+
+#endif /* U_HIDE_INTERNAL_API */
+#endif
+
+/*===========================================================================*/
+/* UErrorCode */
+/*===========================================================================*/
+
+/**
+ * Error code to replace exception handling, so that the code is compatible with all C++ compilers,
+ * and to use the same mechanism for C and C++.
+ *
+ * \par
+ * ICU functions that take a reference (C++) or a pointer (C) to a UErrorCode
+ * first test if(U_FAILURE(errorCode)) { return immediately; }
+ * so that in a chain of such functions the first one that sets an error code
+ * causes the following ones to not perform any operations.
+ *
+ * \par
+ * Error codes should be tested using U_FAILURE() and U_SUCCESS().
+ * @stable ICU 2.0
+ */
+typedef enum UErrorCode {
+    /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird
+     * and is that way because VC++ debugger displays first encountered constant,
+     * which is not the what the code is used for
+     */
+
+    U_USING_FALLBACK_WARNING  = -128,   /**< A resource bundle lookup returned a fallback result (not an error) */
+
+    U_ERROR_WARNING_START     = -128,   /**< Start of information results (semantically successful) */
+
+    U_USING_DEFAULT_WARNING   = -127,   /**< A resource bundle lookup returned a result from the root locale (not an error) */
+
+    U_SAFECLONE_ALLOCATED_WARNING = -126, /**< A SafeClone operation required allocating memory (informational only) */
+
+    U_STATE_OLD_WARNING       = -125,   /**< ICU has to use compatibility layer to construct the service. Expect performance/memory usage degradation. Consider upgrading */
+
+    U_STRING_NOT_TERMINATED_WARNING = -124,/**< An output string could not be NUL-terminated because output length==destCapacity. */
+
+    U_SORT_KEY_TOO_SHORT_WARNING = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key */
+
+    U_AMBIGUOUS_ALIAS_WARNING = -122,   /**< This converter alias can go to different converter implementations */
+
+    U_DIFFERENT_UCA_VERSION = -121,     /**< ucol_open encountered a mismatch between UCA version and collator image version, so the collator was constructed from rules. No impact to further function */
+
+    U_ERROR_WARNING_LIMIT,              /**< This must always be the last warning value to indicate the limit for UErrorCode warnings (last warning code +1) */
+
+
+    U_ZERO_ERROR              =  0,     /**< No error, no warning. */
+
+    U_ILLEGAL_ARGUMENT_ERROR  =  1,     /**< Start of codes indicating failure */
+    U_MISSING_RESOURCE_ERROR  =  2,     /**< The requested resource cannot be found */
+    U_INVALID_FORMAT_ERROR    =  3,     /**< Data format is not what is expected */
+    U_FILE_ACCESS_ERROR       =  4,     /**< The requested file cannot be found */
+    U_INTERNAL_PROGRAM_ERROR  =  5,     /**< Indicates a bug in the library code */
+    U_MESSAGE_PARSE_ERROR     =  6,     /**< Unable to parse a message (message format) */
+    U_MEMORY_ALLOCATION_ERROR =  7,     /**< Memory allocation error */
+    U_INDEX_OUTOFBOUNDS_ERROR =  8,     /**< Trying to access the index that is out of bounds */
+    U_PARSE_ERROR             =  9,     /**< Equivalent to Java ParseException */
+    U_INVALID_CHAR_FOUND      = 10,     /**< Character conversion: Unmappable input sequence. In other APIs: Invalid character. */
+    U_TRUNCATED_CHAR_FOUND    = 11,     /**< Character conversion: Incomplete input sequence. */
+    U_ILLEGAL_CHAR_FOUND      = 12,     /**< Character conversion: Illegal input sequence/combination of input units. */
+    U_INVALID_TABLE_FORMAT    = 13,     /**< Conversion table file found, but corrupted */
+    U_INVALID_TABLE_FILE      = 14,     /**< Conversion table file not found */
+    U_BUFFER_OVERFLOW_ERROR   = 15,     /**< A result would not fit in the supplied buffer */
+    U_UNSUPPORTED_ERROR       = 16,     /**< Requested operation not supported in current context */
+    U_RESOURCE_TYPE_MISMATCH  = 17,     /**< an operation is requested over a resource that does not support it */
+    U_ILLEGAL_ESCAPE_SEQUENCE = 18,     /**< ISO-2022 illlegal escape sequence */
+    U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, /**< ISO-2022 unsupported escape sequence */
+    U_NO_SPACE_AVAILABLE      = 20,     /**< No space available for in-buffer expansion for Arabic shaping */
+    U_CE_NOT_FOUND_ERROR      = 21,     /**< Currently used only while setting variable top, but can be used generally */
+    U_PRIMARY_TOO_LONG_ERROR  = 22,     /**< User tried to set variable top to a primary that is longer than two bytes */
+    U_STATE_TOO_OLD_ERROR     = 23,     /**< ICU cannot construct a service from this state, as it is no longer supported */
+    U_TOO_MANY_ALIASES_ERROR  = 24,     /**< There are too many aliases in the path to the requested resource.
+                                             It is very possible that a circular alias definition has occured */
+    U_ENUM_OUT_OF_SYNC_ERROR  = 25,     /**< UEnumeration out of sync with underlying collection */
+    U_INVARIANT_CONVERSION_ERROR = 26,  /**< Unable to convert a UChar* string to char* with the invariant converter. */
+    U_INVALID_STATE_ERROR     = 27,     /**< Requested operation can not be completed with ICU in its current state */
+    U_COLLATOR_VERSION_MISMATCH = 28,   /**< Collator version is not compatible with the base version */
+    U_USELESS_COLLATOR_ERROR  = 29,     /**< Collator is options only and no base is specified */
+    U_NO_WRITE_PERMISSION     = 30,     /**< Attempt to modify read-only or constant data. */
+
+    U_STANDARD_ERROR_LIMIT,             /**< This must always be the last value to indicate the limit for standard errors */
+    /*
+     * the error code range 0x10000 0x10100 are reserved for Transliterator
+     */
+    U_BAD_VARIABLE_DEFINITION=0x10000,/**< Missing '$' or duplicate variable name */
+    U_PARSE_ERROR_START = 0x10000,    /**< Start of Transliterator errors */
+    U_MALFORMED_RULE,                 /**< Elements of a rule are misplaced */
+    U_MALFORMED_SET,                  /**< A UnicodeSet pattern is invalid*/
+    U_MALFORMED_SYMBOL_REFERENCE,     /**< UNUSED as of ICU 2.4 */
+    U_MALFORMED_UNICODE_ESCAPE,       /**< A Unicode escape pattern is invalid*/
+    U_MALFORMED_VARIABLE_DEFINITION,  /**< A variable definition is invalid */
+    U_MALFORMED_VARIABLE_REFERENCE,   /**< A variable reference is invalid */
+    U_MISMATCHED_SEGMENT_DELIMITERS,  /**< UNUSED as of ICU 2.4 */
+    U_MISPLACED_ANCHOR_START,         /**< A start anchor appears at an illegal position */
+    U_MISPLACED_CURSOR_OFFSET,        /**< A cursor offset occurs at an illegal position */
+    U_MISPLACED_QUANTIFIER,           /**< A quantifier appears after a segment close delimiter */
+    U_MISSING_OPERATOR,               /**< A rule contains no operator */
+    U_MISSING_SEGMENT_CLOSE,          /**< UNUSED as of ICU 2.4 */
+    U_MULTIPLE_ANTE_CONTEXTS,         /**< More than one ante context */
+    U_MULTIPLE_CURSORS,               /**< More than one cursor */
+    U_MULTIPLE_POST_CONTEXTS,         /**< More than one post context */
+    U_TRAILING_BACKSLASH,             /**< A dangling backslash */
+    U_UNDEFINED_SEGMENT_REFERENCE,    /**< A segment reference does not correspond to a defined segment */
+    U_UNDEFINED_VARIABLE,             /**< A variable reference does not correspond to a defined variable */
+    U_UNQUOTED_SPECIAL,               /**< A special character was not quoted or escaped */
+    U_UNTERMINATED_QUOTE,             /**< A closing single quote is missing */
+    U_RULE_MASK_ERROR,                /**< A rule is hidden by an earlier more general rule */
+    U_MISPLACED_COMPOUND_FILTER,      /**< A compound filter is in an invalid location */
+    U_MULTIPLE_COMPOUND_FILTERS,      /**< More than one compound filter */
+    U_INVALID_RBT_SYNTAX,             /**< A "::id" rule was passed to the RuleBasedTransliterator parser */
+    U_INVALID_PROPERTY_PATTERN,       /**< UNUSED as of ICU 2.4 */
+    U_MALFORMED_PRAGMA,               /**< A 'use' pragma is invlalid */
+    U_UNCLOSED_SEGMENT,               /**< A closing ')' is missing */
+    U_ILLEGAL_CHAR_IN_SEGMENT,        /**< UNUSED as of ICU 2.4 */
+    U_VARIABLE_RANGE_EXHAUSTED,       /**< Too many stand-ins generated for the given variable range */
+    U_VARIABLE_RANGE_OVERLAP,         /**< The variable range overlaps characters used in rules */
+    U_ILLEGAL_CHARACTER,              /**< A special character is outside its allowed context */
+    U_INTERNAL_TRANSLITERATOR_ERROR,  /**< Internal transliterator system error */
+    U_INVALID_ID,                     /**< A "::id" rule specifies an unknown transliterator */
+    U_INVALID_FUNCTION,               /**< A "&fn()" rule specifies an unknown transliterator */
+    U_PARSE_ERROR_LIMIT,              /**< The limit for Transliterator errors */
+
+    /*
+     * the error code range 0x10100 0x10200 are reserved for formatting API parsing error
+     */
+    U_UNEXPECTED_TOKEN=0x10100,       /**< Syntax error in format pattern */
+    U_FMT_PARSE_ERROR_START=0x10100,  /**< Start of format library errors */
+    U_MULTIPLE_DECIMAL_SEPARATORS,    /**< More than one decimal separator in number pattern */
+    U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, /**< Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */
+    U_MULTIPLE_EXPONENTIAL_SYMBOLS,   /**< More than one exponent symbol in number pattern */
+    U_MALFORMED_EXPONENTIAL_PATTERN,  /**< Grouping symbol in exponent pattern */
+    U_MULTIPLE_PERCENT_SYMBOLS,       /**< More than one percent symbol in number pattern */
+    U_MULTIPLE_PERMILL_SYMBOLS,       /**< More than one permill symbol in number pattern */
+    U_MULTIPLE_PAD_SPECIFIERS,        /**< More than one pad symbol in number pattern */
+    U_PATTERN_SYNTAX_ERROR,           /**< Syntax error in format pattern */
+    U_ILLEGAL_PAD_POSITION,           /**< Pad symbol misplaced in number pattern */
+    U_UNMATCHED_BRACES,               /**< Braces do not match in message pattern */
+    U_UNSUPPORTED_PROPERTY,           /**< UNUSED as of ICU 2.4 */
+    U_UNSUPPORTED_ATTRIBUTE,          /**< UNUSED as of ICU 2.4 */
+    U_ARGUMENT_TYPE_MISMATCH,         /**< Argument name and argument index mismatch in MessageFormat functions */
+    U_DUPLICATE_KEYWORD,              /**< Duplicate keyword in PluralFormat */
+    U_UNDEFINED_KEYWORD,              /**< Undefined Pluarl keyword */
+    U_DEFAULT_KEYWORD_MISSING,        /**< Missing DEFAULT rule in plural rules */
+    U_FMT_PARSE_ERROR_LIMIT,          /**< The limit for format library errors */
+
+    /*
+     * the error code range 0x10200 0x102ff are reserved for Break Iterator related error
+     */
+    U_BRK_INTERNAL_ERROR=0x10200,          /**< An internal error (bug) was detected.             */
+    U_BRK_ERROR_START=0x10200,             /**< Start of codes indicating Break Iterator failures */
+    U_BRK_HEX_DIGITS_EXPECTED,             /**< Hex digits expected as part of a escaped char in a rule. */
+    U_BRK_SEMICOLON_EXPECTED,              /**< Missing ';' at the end of a RBBI rule.            */
+    U_BRK_RULE_SYNTAX,                     /**< Syntax error in RBBI rule.                        */
+    U_BRK_UNCLOSED_SET,                    /**< UnicodeSet witing an RBBI rule missing a closing ']'.  */
+    U_BRK_ASSIGN_ERROR,                    /**< Syntax error in RBBI rule assignment statement.   */
+    U_BRK_VARIABLE_REDFINITION,            /**< RBBI rule $Variable redefined.                    */
+    U_BRK_MISMATCHED_PAREN,                /**< Mis-matched parentheses in an RBBI rule.          */
+    U_BRK_NEW_LINE_IN_QUOTED_STRING,       /**< Missing closing quote in an RBBI rule.            */
+    U_BRK_UNDEFINED_VARIABLE,              /**< Use of an undefined $Variable in an RBBI rule.    */
+    U_BRK_INIT_ERROR,                      /**< Initialization failure.  Probable missing ICU Data. */
+    U_BRK_RULE_EMPTY_SET,                  /**< Rule contains an empty Unicode Set.               */
+    U_BRK_UNRECOGNIZED_OPTION,             /**< !!option in RBBI rules not recognized.            */
+    U_BRK_MALFORMED_RULE_TAG,              /**< The {nnn} tag on a rule is mal formed             */
+    U_BRK_ERROR_LIMIT,                     /**< This must always be the last value to indicate the limit for Break Iterator failures */
+
+    /*
+     * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs
+     */
+    U_REGEX_INTERNAL_ERROR=0x10300,       /**< An internal error (bug) was detected.              */
+    U_REGEX_ERROR_START=0x10300,          /**< Start of codes indicating Regexp failures          */
+    U_REGEX_RULE_SYNTAX,                  /**< Syntax error in regexp pattern.                    */
+    U_REGEX_INVALID_STATE,                /**< RegexMatcher in invalid state for requested operation */
+    U_REGEX_BAD_ESCAPE_SEQUENCE,          /**< Unrecognized backslash escape sequence in pattern  */
+    U_REGEX_PROPERTY_SYNTAX,              /**< Incorrect Unicode property                         */
+    U_REGEX_UNIMPLEMENTED,                /**< Use of regexp feature that is not yet implemented. */
+    U_REGEX_MISMATCHED_PAREN,             /**< Incorrectly nested parentheses in regexp pattern.  */
+    U_REGEX_NUMBER_TOO_BIG,               /**< Decimal number is too large.                       */
+    U_REGEX_BAD_INTERVAL,                 /**< Error in {min,max} interval                        */
+    U_REGEX_MAX_LT_MIN,                   /**< In {min,max}, max is less than min.                */
+    U_REGEX_INVALID_BACK_REF,             /**< Back-reference to a non-existent capture group.    */
+    U_REGEX_INVALID_FLAG,                 /**< Invalid value for match mode flags.                */
+    U_REGEX_LOOK_BEHIND_LIMIT,            /**< Look-Behind pattern matches must have a bounded maximum length.    */
+    U_REGEX_SET_CONTAINS_STRING,          /**< Regexps cannot have UnicodeSets containing strings.*/
+    U_REGEX_OCTAL_TOO_BIG,                /**< Octal character constants must be <= 0377.         */
+    U_REGEX_MISSING_CLOSE_BRACKET,        /**< Missing closing bracket on a bracket expression.   */
+    U_REGEX_INVALID_RANGE,                /**< In a character range [x-y], x is greater than y.   */
+    U_REGEX_STACK_OVERFLOW,               /**< Regular expression backtrack stack overflow.       */
+    U_REGEX_TIME_OUT,                     /**< Maximum allowed match time exceeded                */
+    U_REGEX_STOPPED_BY_CALLER,            /**< Matching operation aborted by user callback fn.    */
+    U_REGEX_ERROR_LIMIT,                  /**< This must always be the last value to indicate the limit for regexp errors */
+
+    /*
+     * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes
+     */
+    U_IDNA_PROHIBITED_ERROR=0x10400,
+    U_IDNA_ERROR_START=0x10400,
+    U_IDNA_UNASSIGNED_ERROR,
+    U_IDNA_CHECK_BIDI_ERROR,
+    U_IDNA_STD3_ASCII_RULES_ERROR,
+    U_IDNA_ACE_PREFIX_ERROR,
+    U_IDNA_VERIFICATION_ERROR,
+    U_IDNA_LABEL_TOO_LONG_ERROR,
+    U_IDNA_ZERO_LENGTH_LABEL_ERROR,
+    U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR,
+    U_IDNA_ERROR_LIMIT,
+    /*
+     * Aliases for StringPrep
+     */
+    U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR,
+    U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR,
+    U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR,
+
+
+    U_ERROR_LIMIT=U_IDNA_ERROR_LIMIT      /**< This must always be the last value to indicate the limit for UErrorCode (last error code +1) */
+} UErrorCode;
+
+/* Use the following to determine if an UErrorCode represents */
+/* operational success or failure. */
+
+#ifdef XP_CPLUSPLUS
+    /**
+     * Does the error code indicate success?
+     * @stable ICU 2.0
+     */
+    static
+    inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); }
+    /**
+     * Does the error code indicate a failure?
+     * @stable ICU 2.0
+     */
+    static
+    inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); }
+#else
+    /**
+     * Does the error code indicate success?
+     * @stable ICU 2.0
+     */
+#   define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)
+    /**
+     * Does the error code indicate a failure?
+     * @stable ICU 2.0
+     */
+#   define U_FAILURE(x) ((x)>U_ZERO_ERROR)
+#endif
+
+/**
+ * Return a string for a UErrorCode value.
+ * The string will be the same as the name of the error code constant
+ * in the UErrorCode enum above.
+ * @stable ICU 2.0
+ */
+U_STABLE const char * U_EXPORT2
+u_errorName(UErrorCode code);
+
+
+#endif /* _UTYPES */
diff --git a/CoreFoundation/icu/unicode/uversion.h b/CoreFoundation/icu/unicode/uversion.h
new file mode 100644
index 0000000..bfeeedf
--- /dev/null
+++ b/CoreFoundation/icu/unicode/uversion.h
@@ -0,0 +1,275 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2000-2008, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*
+*   file name:  uversion.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   Created by: Vladimir Weinstein
+*
+*  Contains all the important version numbers for ICU. 
+*  Gets included by utypes.h and Windows .rc files
+*/
+
+/**
+ * \file
+ * \brief C API: Contains all the important version numbers for ICU. 
+ */
+/*===========================================================================*/
+/* Main ICU version information                                              */
+/*===========================================================================*/
+
+#ifndef UVERSION_H
+#define UVERSION_H
+
+/**
+ * IMPORTANT: When updating version, the following things need to be done:
+ * source/common/unicode/uversion.h - this file: update major, minor,
+ *        patchlevel, suffix, version, short version constants, namespace,
+ *                                                             and copyright
+ * source/common/common.vcproj - update 'Output file name' on the link tab so
+ *                   that it contains the new major/minor combination
+ * source/i18n/i18n.vcproj - same as for the common.vcproj
+ * source/layout/layout.vcproj - same as for the common.vcproj
+ * source/layoutex/layoutex.vcproj - same
+ * source/stubdata/stubdata.vcproj - same as for the common.vcproj
+ * source/io/io.vcproj - same as for the common.vcproj
+ * source/data/makedata.mak - change U_ICUDATA_NAME so that it contains
+ *                            the new major/minor combination
+ * source/tools/genren/genren.pl - use this script according to the README
+ *                    in that folder                                         
+ */
+
+#include "unicode/umachine.h"
+
+/** The standard copyright notice that gets compiled into each library. 
+ *  This value will change in the subsequent releases of ICU
+ *  @stable ICU 2.4
+ */
+#define U_COPYRIGHT_STRING \
+  " Copyright (C) 2008, International Business Machines Corporation and others. All Rights Reserved. "
+
+/** Maximum length of the copyright string.
+ *  @stable ICU 2.4
+ */
+#define U_COPYRIGHT_STRING_LENGTH  128
+
+/** The current ICU major version as an integer. 
+ *  This value will change in the subsequent releases of ICU
+ *  @stable ICU 2.4
+ */
+#define U_ICU_VERSION_MAJOR_NUM 4
+
+/** The current ICU minor version as an integer. 
+ *  This value will change in the subsequent releases of ICU
+ *  @stable ICU 2.6
+ */
+#define U_ICU_VERSION_MINOR_NUM 0
+
+/** The current ICU patchlevel version as an integer.  
+ *  This value will change in the subsequent releases of ICU
+ *  @stable ICU 2.4
+ */
+#define U_ICU_VERSION_PATCHLEVEL_NUM 0
+
+/** The current ICU build level version as an integer.  
+ *  This value is for use by ICU clients. It defaults to 0.
+ *  @draft ICU 4.0
+ */
+#ifndef U_ICU_VERSION_BUILDLEVEL_NUM
+#define U_ICU_VERSION_BUILDLEVEL_NUM 0
+#endif
+
+/** Glued version suffix for renamers 
+ *  This value will change in the subsequent releases of ICU
+ *  @stable ICU 2.6
+ */
+#define U_ICU_VERSION_SUFFIX _4_0
+
+/** The current ICU library version as a dotted-decimal string. The patchlevel
+ *  only appears in this string if it non-zero. 
+ *  This value will change in the subsequent releases of ICU
+ *  @stable ICU 2.4
+ */
+#define U_ICU_VERSION "4.0"
+
+/** The current ICU library major/minor version as a string without dots, for library name suffixes. 
+ *  This value will change in the subsequent releases of ICU
+ *  @stable ICU 2.6
+ */
+#define U_ICU_VERSION_SHORT "40"
+
+/** An ICU version consists of up to 4 numbers from 0..255.
+ *  @stable ICU 2.4
+ */
+#define U_MAX_VERSION_LENGTH 4
+
+/** In a string, ICU version fields are delimited by dots.
+ *  @stable ICU 2.4
+ */
+#define U_VERSION_DELIMITER '.'
+
+/** The maximum length of an ICU version string.
+ *  @stable ICU 2.4
+ */
+#define U_MAX_VERSION_STRING_LENGTH 20
+
+/** The binary form of a version on ICU APIs is an array of 4 uint8_t.
+ *  @stable ICU 2.4
+ */
+typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];
+
+/*===========================================================================*/
+/* C++ namespace if supported. Versioned unless versioning is disabled.      */
+/*===========================================================================*/
+
+/**
+ * \def U_NAMESPACE_BEGIN
+ * This is used to begin a declaration of a public ICU C++ API.
+ * If the compiler doesn't support namespaces, this does nothing.
+ * @stable ICU 2.4
+ */
+
+/**
+ * \def U_NAMESPACE_END
+ * This is used to end a declaration of a public ICU C++ API 
+ * If the compiler doesn't support namespaces, this does nothing.
+ * @stable ICU 2.4
+ */
+
+/**
+ * \def U_NAMESPACE_USE
+ * This is used to specify that the rest of the code uses the
+ * public ICU C++ API namespace.
+ * If the compiler doesn't support namespaces, this does nothing.
+ * @stable ICU 2.4
+ */
+
+/**
+ * \def U_NAMESPACE_QUALIFIER
+ * This is used to qualify that a function or class is part of
+ * the public ICU C++ API namespace.
+ * If the compiler doesn't support namespaces, this does nothing.
+ * @stable ICU 2.4
+ */
+
+/* Define namespace symbols if the compiler supports it. */
+#if U_HAVE_NAMESPACE && defined(XP_CPLUSPLUS)
+#  if U_DISABLE_RENAMING
+#       define U_ICU_NAMESPACE icu
+        namespace U_ICU_NAMESPACE { }
+#  else
+#       define U_ICU_NAMESPACE icu_4_0
+        namespace U_ICU_NAMESPACE { }
+        namespace icu = U_ICU_NAMESPACE;
+#  endif
+
+#   define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE {
+#   define U_NAMESPACE_END  }
+#   define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE;
+#   define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE::
+
+#   ifndef U_USING_ICU_NAMESPACE
+#       define U_USING_ICU_NAMESPACE 1
+#   endif
+#   if U_USING_ICU_NAMESPACE
+        U_NAMESPACE_USE
+#   endif
+#else
+#   define U_NAMESPACE_BEGIN
+#   define U_NAMESPACE_END
+#   define U_NAMESPACE_USE
+#   define U_NAMESPACE_QUALIFIER
+#endif
+
+
+/*===========================================================================*/
+/* General version helper functions. Definitions in putil.c                  */
+/*===========================================================================*/
+
+/**
+ * Parse a string with dotted-decimal version information and
+ * fill in a UVersionInfo structure with the result.
+ * Definition of this function lives in putil.c
+ *
+ * @param versionArray The destination structure for the version information.
+ * @param versionString A string with dotted-decimal version information,
+ *                      with up to four non-negative number fields with
+ *                      values of up to 255 each.
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+u_versionFromString(UVersionInfo versionArray, const char *versionString);
+
+/**
+ * Write a string with dotted-decimal version information according
+ * to the input UVersionInfo.
+ * Definition of this function lives in putil.c
+ *
+ * @param versionArray The version information to be written as a string.
+ * @param versionString A string buffer that will be filled in with
+ *                      a string corresponding to the numeric version
+ *                      information in versionArray.
+ *                      The buffer size must be at least U_MAX_VERSION_STRING_LENGTH.
+ * @stable ICU 2.4
+ */
+U_STABLE void U_EXPORT2
+u_versionToString(UVersionInfo versionArray, char *versionString);
+
+/**
+ * Gets the ICU release version.  The version array stores the version information
+ * for ICU.  For example, release "1.3.31.2" is then represented as 0x01031F02.
+ * Definition of this function lives in putil.c
+ *
+ * @param versionArray the version # information, the result will be filled in
+ * @stable ICU 2.0
+ */
+U_STABLE void U_EXPORT2
+u_getVersion(UVersionInfo versionArray);
+
+
+/*===========================================================================
+ * ICU collation framework version information                               
+ * Version info that can be obtained from a collator is affected by these    
+ * numbers in a secret and magic way. Please use collator version as whole
+ *===========================================================================
+ */
+
+/** Collation runtime version (sort key generator, strcoll). 
+ * If the version is different, sortkeys for the same string could be different 
+ * version 2 was in ICU 1.8.1. changed is: compression intervals, French secondary 
+ * compression, generating quad level always when strength is quad or more 
+ * version 4 - ICU 2.2 - tracking UCA changes, ignore completely ignorables 
+ * in contractions, ignore primary ignorables after shifted 
+ * version 5 - ICU 2.8 - changed implicit generation code
+ * version 6 - ICU 3.4 - with the UCA 4.1, Thai tag is no longer generated or used
+ * This value may change in the subsequent releases of ICU
+ * @stable ICU 2.4
+ */
+#define UCOL_RUNTIME_VERSION 6
+
+/** Builder code version. When this is different, same tailoring might result
+ * in assigning different collation elements to code points                  
+ * version 2 was in ICU 1.8.1. added support for prefixes, tweaked canonical 
+ * closure. However, the tailorings should probably get same CEs assigned    
+ * version 5 - ICU 2.2 - fixed some bugs, renamed some indirect values.      
+ * version 6 - ICU 2.8 - fixed bug in builder that allowed 0xFF in primary values
+ * version 7 - ICU 3.4 - with the UCA 4.1 Thai tag is no longer processed, complete ignorables
+ *                       now break contractions
+ * Backward compatible with the old rules. 
+ * This value may change in the subsequent releases of ICU
+ * @stable ICU 2.4
+ */
+#define UCOL_BUILDER_VERSION 7
+
+/** This is the version of the tailorings 
+ *  This value may change in the subsequent releases of ICU
+ *  @stable ICU 2.4
+ */
+#define UCOL_TAILORINGS_VERSION 1
+
+#endif
diff --git a/CoreFoundation/icu/unicode/vtzone.h b/CoreFoundation/icu/unicode/vtzone.h
new file mode 100644
index 0000000..9463f35
--- /dev/null
+++ b/CoreFoundation/icu/unicode/vtzone.h
@@ -0,0 +1,443 @@
+/*
+*******************************************************************************
+* Copyright (C) 2007-2008, International Business Machines Corporation and         *
+* others. All Rights Reserved.                                                *
+*******************************************************************************
+*/
+#ifndef VTZONE_H
+#define VTZONE_H
+
+#include "unicode/utypes.h"
+
+/**
+ * \file 
+ * \brief C++ API: RFC2445 VTIMEZONE support
+ */
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/basictz.h"
+
+U_NAMESPACE_BEGIN
+
+class VTZWriter;
+class VTZReader;
+class UVector;
+
+/**
+ * <code>VTimeZone</code> is a class implementing RFC2445 VTIMEZONE.  You can create a
+ * <code>VTimeZone</code> instance from a time zone ID supported by <code>TimeZone</code>.
+ * With the <code>VTimeZone</code> instance created from the ID, you can write out the rule
+ * in RFC2445 VTIMEZONE format.  Also, you can create a <code>VTimeZone</code> instance
+ * from RFC2445 VTIMEZONE data stream, which allows you to calculate time
+ * zone offset by the rules defined by the data.<br><br>
+ * Note: The consumer of this class reading or writing VTIMEZONE data is responsible to
+ * decode or encode Non-ASCII text.  Methods reading/writing VTIMEZONE data in this class
+ * do nothing with MIME encoding.
+ * @stable ICU 4.0
+ */
+class U_I18N_API VTimeZone : public BasicTimeZone {
+public:
+    /**
+     * Copy constructor.
+     * @param source    The <code>VTimeZone</code> object to be copied.
+     * @stable ICU 4.0
+     */
+    VTimeZone(const VTimeZone& source);
+
+    /**
+     * Destructor.
+     * @stable ICU 4.0
+     */
+    virtual ~VTimeZone();
+
+    /**
+     * Assignment operator.
+     * @param right The object to be copied.
+     * @stable ICU 4.0
+     */
+    VTimeZone& operator=(const VTimeZone& right);
+
+    /**
+     * Return true if the given <code>TimeZone</code> objects are
+     * semantically equal. Objects of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZone</code> objects are
+      *semantically equal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator==(const TimeZone& that) const;
+
+    /**
+     * Return true if the given <code>TimeZone</code> objects are
+     * semantically unequal. Objects of different subclasses are considered unequal.
+     * @param that  The object to be compared with.
+     * @return  true if the given <code>TimeZone</code> objects are
+     * semantically unequal.
+     * @stable ICU 4.0
+     */
+    virtual UBool operator!=(const TimeZone& that) const;
+
+    /**
+     * Create a <code>VTimeZone</code> instance by the time zone ID.
+     * @param ID The time zone ID, such as America/New_York
+     * @return A <code>VTimeZone</code> object initialized by the time zone ID,
+     * or NULL when the ID is unknown.
+     * @stable ICU 4.0
+     */
+    static VTimeZone* createVTimeZoneByID(const UnicodeString& ID);
+
+    /**
+     * Create a <code>VTimeZone</code> instance by RFC2445 VTIMEZONE data
+     * 
+     * @param vtzdata The string including VTIMEZONE data block
+     * @param status Output param to filled in with a success or an error.
+     * @return A <code>VTimeZone</code> initialized by the VTIMEZONE data or
+     * NULL if failed to load the rule from the VTIMEZONE data.
+     * @stable ICU 4.0
+     */
+    static VTimeZone* createVTimeZone(const UnicodeString& vtzdata, UErrorCode& status);
+
+    /**
+     * Gets the RFC2445 TZURL property value.  When a <code>VTimeZone</code> instance was
+     * created from VTIMEZONE data, the initial value is set by the TZURL property value
+     * in the data.  Otherwise, the initial value is not set.
+     * @param url Receives the RFC2445 TZURL property value.
+     * @return TRUE if TZURL attribute is available and value is set.
+     * @stable ICU 4.0
+     */
+    UBool getTZURL(UnicodeString& url) const;
+
+    /**
+     * Sets the RFC2445 TZURL property value.
+     * @param url The TZURL property value.
+     * @stable ICU 4.0
+     */
+    void setTZURL(const UnicodeString& url);
+
+    /**
+     * Gets the RFC2445 LAST-MODIFIED property value.  When a <code>VTimeZone</code> instance
+     * was created from VTIMEZONE data, the initial value is set by the LAST-MODIFIED property
+     * value in the data.  Otherwise, the initial value is not set.
+     * @param lastModified Receives the last modified date.
+     * @return TRUE if lastModified attribute is available and value is set.
+     * @stable ICU 4.0
+     */
+    UBool getLastModified(UDate& lastModified) const;
+
+    /**
+     * Sets the RFC2445 LAST-MODIFIED property value.
+     * @param lastModified The LAST-MODIFIED date.
+     * @stable ICU 4.0
+     */
+    void setLastModified(UDate lastModified);
+
+    /**
+     * Writes RFC2445 VTIMEZONE data for this time zone
+     * @param result Output param to filled in with the VTIMEZONE data.
+     * @param status Output param to filled in with a success or an error.
+     * @stable ICU 4.0
+     */
+    void write(UnicodeString& result, UErrorCode& status) const;
+
+    /**
+     * Writes RFC2445 VTIMEZONE data for this time zone applicalbe
+     * for dates after the specified start time.
+     * @param start The start date.
+     * @param result Output param to filled in with the VTIMEZONE data.
+     * @param status Output param to filled in with a success or an error.
+     * @stable ICU 4.0
+     */
+    void write(UDate start, UnicodeString& result, UErrorCode& status) /*const*/;
+
+    /**
+     * Writes RFC2445 VTIMEZONE data applicalbe for the specified date.
+     * Some common iCalendar implementations can only handle a single time
+     * zone property or a pair of standard and daylight time properties using
+     * BYDAY rule with day of week (such as BYDAY=1SUN).  This method produce
+     * the VTIMEZONE data which can be handled these implementations.  The rules
+     * produced by this method can be used only for calculating time zone offset
+     * around the specified date.
+     * @param time The date used for rule extraction.
+     * @param result Output param to filled in with the VTIMEZONE data.
+     * @param status Output param to filled in with a success or an error.
+     * @stable ICU 4.0
+     */
+    void writeSimple(UDate time, UnicodeString& result, UErrorCode& status) /*const*/;
+
+    /**
+     * Clones TimeZone objects polymorphically. Clients are responsible for deleting
+     * the TimeZone object cloned.
+     * @return   A new copy of this TimeZone object.
+     * @stable ICU 4.0
+     */
+    virtual TimeZone* clone(void) const;
+
+    /**
+     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time in this time zone, taking daylight savings time into
+     * account) as of a particular reference date.  The reference date is used to determine
+     * whether daylight savings time is in effect and needs to be figured into the offset
+     * that is returned (in other words, what is the adjusted GMT offset in this time zone
+     * at this particular date and time?).  For the time zones produced by createTimeZone(),
+     * the reference data is specified according to the Gregorian calendar, and the date
+     * and time fields are local standard time.
+     *
+     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
+     * which returns both the raw and the DST offset for a given time. This method
+     * is retained only for backward compatibility.
+     *
+     * @param era        The reference date's era
+     * @param year       The reference date's year
+     * @param month      The reference date's month (0-based; 0 is January)
+     * @param day        The reference date's day-in-month (1-based)
+     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)
+     * @param millis     The reference date's milliseconds in day, local standard time
+     * @param status     Output param to filled in with a success or an error.
+     * @return           The offset in milliseconds to add to GMT to get local time.
+     * @stable ICU 4.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
+
+    /**
+     * Gets the time zone offset, for current date, modified in case of
+     * daylight savings. This is the offset to add *to* UTC to get local time.
+     *
+     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
+     * which returns both the raw and the DST offset for a given time. This method
+     * is retained only for backward compatibility.
+     *
+     * @param era        The reference date's era
+     * @param year       The reference date's year
+     * @param month      The reference date's month (0-based; 0 is January)
+     * @param day        The reference date's day-in-month (1-based)
+     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)
+     * @param millis     The reference date's milliseconds in day, local standard time
+     * @param monthLength The length of the given month in days.
+     * @param status     Output param to filled in with a success or an error.
+     * @return           The offset in milliseconds to add to GMT to get local time.
+     * @stable ICU 4.0
+     */
+    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
+                           uint8_t dayOfWeek, int32_t millis,
+                           int32_t monthLength, UErrorCode& status) const;
+
+    /**
+     * Returns the time zone raw and GMT offset for the given moment
+     * in time.  Upon return, local-millis = GMT-millis + rawOffset +
+     * dstOffset.  All computations are performed in the proleptic
+     * Gregorian calendar.  The default implementation in the TimeZone
+     * class delegates to the 8-argument getOffset().
+     *
+     * @param date moment in time for which to return offsets, in
+     * units of milliseconds from January 1, 1970 0:00 GMT, either GMT
+     * time or local wall time, depending on `local'.
+     * @param local if true, `date' is local wall time; otherwise it
+     * is in GMT time.
+     * @param rawOffset output parameter to receive the raw offset, that
+     * is, the offset not including DST adjustments
+     * @param dstOffset output parameter to receive the DST offset,
+     * that is, the offset to be added to `rawOffset' to obtain the
+     * total offset between local and GMT time. If DST is not in
+     * effect, this value is zero; otherwise it is a positive value,
+     * typically one hour.
+     * @param ec input-output error code
+     * @stable ICU 4.0
+     */
+    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
+                           int32_t& dstOffset, UErrorCode& ec) const;
+
+    /**
+     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @param offsetMillis  The new raw GMT offset for this time zone.
+     * @stable ICU 4.0
+     */
+    virtual void setRawOffset(int32_t offsetMillis);
+
+    /**
+     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
+     * to GMT to get local time, before taking daylight savings time into account).
+     *
+     * @return   The TimeZone's raw GMT offset.
+     * @stable ICU 4.0
+     */
+    virtual int32_t getRawOffset(void) const;
+
+    /**
+     * Queries if this time zone uses daylight savings time.
+     * @return true if this time zone uses daylight savings time,
+     * false, otherwise.
+     * @stable ICU 4.0
+     */
+    virtual UBool useDaylightTime(void) const;
+
+    /**
+     * Queries if the given date is in daylight savings time in
+     * this time zone.
+     * This method is wasteful since it creates a new GregorianCalendar and
+     * deletes it each time it is called. This is a deprecated method
+     * and provided only for Java compatibility.
+     *
+     * @param date the given UDate.
+     * @param status Output param filled in with success/error code.
+     * @return true if the given date is in daylight savings time,
+     * false, otherwise.
+     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
+     */
+    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
+
+    /**
+     * Returns true if this zone has the same rule and offset as another zone.
+     * That is, if this zone differs only in ID, if at all.
+     * @param other the <code>TimeZone</code> object to be compared with
+     * @return true if the given zone is the same as this one,
+     * with the possible exception of the ID
+     * @stable ICU 4.0
+     */
+    virtual UBool hasSameRules(const TimeZone& other) const;
+
+    /**
+     * Gets the first time zone transition after the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the first transition after the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
+
+    /**
+     * Gets the most recent time zone transition before the base time.
+     * @param base      The base time.
+     * @param inclusive Whether the base time is inclusive or not.
+     * @param result    Receives the most recent transition before the base time.
+     * @return  TRUE if the transition is found.
+     * @stable ICU 4.0
+     */
+    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
+
+    /**
+     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
+     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
+     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.
+     * @param status    Receives error status code.
+     * @return The number of <code>TimeZoneRule</code>s representing time transitions.
+     * @stable ICU 4.0
+     */
+    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;
+
+    /**
+     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
+     * which represent time transitions for this time zone.  On successful return,
+     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
+     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
+     * instances up to the size specified by trscount.  The results are referencing the
+     * rule instance held by this time zone instance.  Therefore, after this time zone
+     * is destructed, they are no longer available.
+     * @param initial       Receives the initial timezone rule
+     * @param trsrules      Receives the timezone transition rules
+     * @param trscount      On input, specify the size of the array 'transitions' receiving
+     *                      the timezone transition rules.  On output, actual number of
+     *                      rules filled in the array will be set.
+     * @param status        Receives error status code.
+     * @stable ICU 4.0
+     */
+    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
+        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;
+
+private:
+    enum { DEFAULT_VTIMEZONE_LINES = 100 };
+
+    /**
+     * Default constructor.
+     */
+    VTimeZone();
+    static VTimeZone* createVTimeZone(VTZReader* reader);
+    void write(VTZWriter& writer, UErrorCode& status) const;
+    void write(UDate start, VTZWriter& writer, UErrorCode& status) /*const*/;
+    void writeSimple(UDate time, VTZWriter& writer, UErrorCode& status) /*const*/;
+    void load(VTZReader& reader, UErrorCode& status);
+    void parse(UErrorCode& status);
+
+    void writeZone(VTZWriter& w, BasicTimeZone& basictz, UVector* customProps,
+        UErrorCode& status) const;
+
+    void writeHeaders(VTZWriter& w, UErrorCode& status) const;
+    void writeFooter(VTZWriter& writer, UErrorCode& status) const;
+
+    void writeZonePropsByTime(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
+                              int32_t fromOffset, int32_t toOffset, UDate time, UBool withRDATE,
+                              UErrorCode& status) const;
+    void writeZonePropsByDOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
+                             int32_t fromOffset, int32_t toOffset,
+                             int32_t month, int32_t dayOfMonth, UDate startTime, UDate untilTime,
+                             UErrorCode& status) const;
+    void writeZonePropsByDOW(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
+                             int32_t fromOffset, int32_t toOffset,
+                             int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
+                             UDate startTime, UDate untilTime, UErrorCode& status) const;
+    void writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
+                                     int32_t fromOffset, int32_t toOffset,
+                                     int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
+                                     UDate startTime, UDate untilTime, UErrorCode& status) const;
+    void writeZonePropsByDOW_GEQ_DOM_sub(VTZWriter& writer, int32_t month, int32_t dayOfMonth,
+                                         int32_t dayOfWeek, int32_t numDays,
+                                         UDate untilTime, int32_t fromOffset, UErrorCode& status) const;
+    void writeZonePropsByDOW_LEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
+                                     int32_t fromOffset, int32_t toOffset,
+                                     int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
+                                     UDate startTime, UDate untilTime, UErrorCode& status) const;
+    void writeFinalRule(VTZWriter& writer, UBool isDst, const AnnualTimeZoneRule* rule,
+                        int32_t fromRawOffset, int32_t fromDSTSavings,
+                        UDate startTime, UErrorCode& status) const;
+
+    void beginZoneProps(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
+                        int32_t fromOffset, int32_t toOffset, UDate startTime, UErrorCode& status) const;
+    void endZoneProps(VTZWriter& writer, UBool isDst, UErrorCode& status) const;
+    void beginRRULE(VTZWriter& writer, int32_t month, UErrorCode& status) const;
+    void appendUNTIL(VTZWriter& writer, const UnicodeString& until, UErrorCode& status) const;
+
+    BasicTimeZone   *tz;
+    UVector         *vtzlines;
+    UnicodeString   tzurl;
+    UDate           lastmod;
+    UnicodeString   olsonzid;
+    UnicodeString   icutzver;
+
+public:
+    /**
+     * Return the class ID for this class. This is useful only for comparing to
+     * a return value from getDynamicClassID(). For example:
+     * <pre>
+     * .   Base* polymorphic_pointer = createPolymorphicObject();
+     * .   if (polymorphic_pointer->getDynamicClassID() ==
+     * .       erived::getStaticClassID()) ...
+     * </pre>
+     * @return          The class ID for all objects of this class.
+     * @stable ICU 4.0
+     */
+    static UClassID U_EXPORT2 getStaticClassID(void);
+
+    /**
+     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
+     * method is to implement a simple version of RTTI, since not all C++
+     * compilers support genuine RTTI. Polymorphic operator==() and clone()
+     * methods call this method.
+     *
+     * @return          The class ID for this object. All objects of a
+     *                  given class have the same class ID.  Objects of
+     *                  other classes have different class IDs.
+     * @stable ICU 4.0
+     */
+    virtual UClassID getDynamicClassID(void) const;
+};
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif // VTZONE_H
+//eof
diff --git a/CoreFoundation/include/AssertMacros.h b/CoreFoundation/include/AssertMacros.h
new file mode 100644
index 0000000..63798da
--- /dev/null
+++ b/CoreFoundation/include/AssertMacros.h
@@ -0,0 +1,1428 @@
+/*
+ * Copyright (c) 2002-2008 by 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@
+ */
+
+
+/*
+	File:       AssertMacros.h
+ 
+	Contains:   This file defines structured error handling and assertion macros for
+				programming in C. Originally used in QuickDraw GX and later enhanced.
+				These macros are used throughout Apple's software.
+	
+				New code may not want to begin adopting these macros and instead use
+				existing language functionality.
+	
+				See "Living In an Exceptional World" by Sean Parent
+				(develop, The Apple Technical Journal, Issue 11, August/September 1992)
+				<http://developer.apple.com/dev/techsupport/develop/issue11toc.shtml> or
+				<http://www.mactech.com/articles/develop/issue_11/Parent_final.html>
+				for the methodology behind these error handling and assertion macros.
+	
+	Bugs?:      For bug reports, consult the following page on
+				the World Wide Web:
+
+	 http://developer.apple.com/bugreporter/ 
+*/
+#ifndef __ASSERTMACROS__
+#define __ASSERTMACROS__
+
+/*
+ *  Macro overview:
+ *  
+ *      check(assertion)
+ *         In production builds, pre-processed away  
+ *         In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE
+ *  
+ *      verify(assertion)
+ *         In production builds, evaluates assertion and does nothing
+ *         In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE
+ *  
+ *      require(assertion, exceptionLabel)
+ *         In production builds, if the assertion expression evaluates to false, goto exceptionLabel
+ *         In debug builds, if the assertion expression evaluates to false, calls DEBUG_ASSERT_MESSAGE
+ *                          and jumps to exceptionLabel
+ *  
+ *      In addition the following suffixes are available:
+ * 
+ *         _noerr     Adds "!= 0" to assertion.  Useful for asserting and OSStatus or OSErr is noErr (zero)
+ *         _action    Adds statement to be executued if assertion fails
+ *         _quiet     Suppress call to DEBUG_ASSERT_MESSAGE
+ *         _string    Allows you to add explanitory message to DEBUG_ASSERT_MESSAGE
+ *  
+ *        For instance, require_noerr_string(resultCode, label, msg) will do nothing if 
+ *        resultCode is zero, otherwise it will call DEBUG_ASSERT_MESSAGE with msg
+ *        and jump to label.
+ *
+ *  Configuration:
+ *
+ *      By default all macros generate "production code" (i.e non-debug).  If  
+ *      DEBUG_ASSERT_PRODUCTION_CODE is defined to zero or DEBUG is defined to non-zero
+ *      while this header is included, the macros will generated debug code.
+ *
+ *      If DEBUG_ASSERT_COMPONENT_NAME_STRING is defined, all debug messages will
+ *      be prefixed with it.
+ *
+ *      By default, all messages write to stderr.  If you would like to write a custom
+ *      error message formater, defined DEBUG_ASSERT_MESSAGE to your function name.
+ *
+ *      Each individual macro will only be defined if it is not already defined, so
+ *      you can redefine their behavior singly by providing your own definition before
+ *      this file is included.
+ *
+ *      If you define __ASSERTMACROS__ before this file is included, then nothing in
+ *      this file will take effect.
+ *
+ *      Prior to Mac OS X 10.6 the macro names used in this file conflicted with some
+ *      user code, including libraries in boost and the proposed C++ standards efforts,
+ *      and there was no way for a client of this header to resolve this conflict. Because
+ *      of this, most of the macros have been changed so that they are prefixed with 
+ *      __ and contain at least one capital letter, which should alleviate the current
+ *      and future conflicts.  However, to allow current sources to continue to compile,
+ *      compatibility macros are defined at the end with the old names.  A tops script 
+ *      at the end of this file will convert all of the old macro names used in a directory
+ *      to the new names.  Clients are recommended to migrate over to these new macros as
+ *      they update their sources because a future release of Mac OS X will remove the
+ *      old macro definitions ( without the double-underscore prefix ).  Clients who
+ *      want to compile without the old macro definitions can define the macro
+ *      __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES to 0 before this file is
+ *      included.
+ */
+
+
+/*
+ *  Before including this file, #define DEBUG_ASSERT_COMPONENT_NAME_STRING to
+ *  a C-string containing the name of your client. This string will be passed to
+ *  the DEBUG_ASSERT_MESSAGE macro for inclusion in any assertion messages.
+ *
+ *  If you do not define DEBUG_ASSERT_COMPONENT_NAME_STRING, the default
+ *  DEBUG_ASSERT_COMPONENT_NAME_STRING value, an empty string, will be used by
+ *  the assertion macros.
+ */
+#ifndef DEBUG_ASSERT_COMPONENT_NAME_STRING
+    #define DEBUG_ASSERT_COMPONENT_NAME_STRING ""
+#endif
+
+
+/*
+ *  To activate the additional assertion code and messages for non-production builds,
+ *  #define DEBUG_ASSERT_PRODUCTION_CODE to zero before including this file.
+ *
+ *  If you do not define DEBUG_ASSERT_PRODUCTION_CODE, the default value 1 will be used
+ *  (production code = no assertion code and no messages).
+ */
+#ifndef DEBUG_ASSERT_PRODUCTION_CODE
+   #define DEBUG_ASSERT_PRODUCTION_CODE !DEBUG
+#endif
+
+
+/*
+ *  DEBUG_ASSERT_MESSAGE(component, assertion, label, error, file, line, errorCode)
+ *
+ *  Summary:
+ *    All assertion messages are routed through this macro. If you wish to use your
+ *    own routine to display assertion messages, you can override DEBUG_ASSERT_MESSAGE
+ *    by #defining DEBUG_ASSERT_MESSAGE before including this file.
+ *
+ *  Parameters:
+ *
+ *    componentNameString:
+ *      A pointer to a string constant containing the name of the
+ *      component this code is part of. This must be a string constant
+ *      (and not a string variable or NULL) because the preprocessor
+ *      concatenates it with other string constants.
+ *
+ *    assertionString:
+ *      A pointer to a string constant containing the assertion.
+ *      This must be a string constant (and not a string variable or
+ *      NULL) because the Preprocessor concatenates it with other
+ *      string constants.
+ *    
+ *    exceptionLabelString:
+ *      A pointer to a string containing the exceptionLabel, or NULL.
+ *    
+ *    errorString:
+ *      A pointer to the error string, or NULL. DEBUG_ASSERT_MESSAGE macros
+ *      must not attempt to concatenate this string with constant
+ *      character strings.
+ *    
+ *    fileName:
+ *      A pointer to the fileName or pathname (generated by the
+ *      preprocessor __FILE__ identifier), or NULL.
+ *    
+ *    lineNumber:
+ *      The line number in the file (generated by the preprocessor
+ *      __LINE__ identifier), or 0 (zero).
+ *    
+ *    errorCode:
+ *      A value associated with the assertion, or 0.
+ *
+ *  Here is an example of a DEBUG_ASSERT_MESSAGE macro and a routine which displays
+ *  assertion messsages:
+ *
+ *      #define DEBUG_ASSERT_COMPONENT_NAME_STRING "MyCoolProgram"
+ *
+ *      #define DEBUG_ASSERT_MESSAGE(componentNameString, assertionString,                           \
+ *                                   exceptionLabelString, errorString, fileName, lineNumber, errorCode) \
+ *              MyProgramDebugAssert(componentNameString, assertionString,                           \
+ *                                   exceptionLabelString, errorString, fileName, lineNumber, errorCode)
+ *
+ *      static void
+ *      MyProgramDebugAssert(const char *componentNameString, const char *assertionString, 
+ *                           const char *exceptionLabelString, const char *errorString, 
+ *                           const char *fileName, long lineNumber, int errorCode)
+ *      {
+ *          if ( (assertionString != NULL) && (*assertionString != '\0') )
+ *              fprintf(stderr, "Assertion failed: %s: %s\n", componentNameString, assertionString);
+ *          else
+ *              fprintf(stderr, "Check failed: %s:\n", componentNameString);
+ *          if ( exceptionLabelString != NULL )
+ *              fprintf(stderr, "    %s\n", exceptionLabelString);
+ *          if ( errorString != NULL )
+ *              fprintf(stderr, "    %s\n", errorString);
+ *          if ( fileName != NULL )
+ *              fprintf(stderr, "    file: %s\n", fileName);
+ *          if ( lineNumber != 0 )
+ *              fprintf(stderr, "    line: %ld\n", lineNumber);
+ *          if ( errorCode != 0 )
+ *              fprintf(stderr, "    error: %d\n", errorCode);
+ *      }
+ *
+ *  If you do not define DEBUG_ASSERT_MESSAGE, a simple printf to stderr will be used.
+ */
+#ifndef DEBUG_ASSERT_MESSAGE
+   #ifdef KERNEL
+      #include <libkern/libkern.h>
+      #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \
+                                  printf( "AssertMacros: %s, %s file: %s, line: %d\n", assertion, (message!=0) ? message : "", file, line);
+   #else
+      #include <stdio.h>
+      #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \
+                                  fprintf(stderr, "AssertMacros: %s, %s file: %s, line: %d\n", assertion, (message!=0) ? message : "", file, line);
+   #endif
+#endif
+
+
+
+
+
+/*
+ *  __Debug_String(message)
+ *
+ *  Summary:
+ *    Production builds: does nothing and produces no code.
+ *
+ *    Non-production builds: call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    message:
+ *      The C string to display.
+ *
+ */
+#ifndef __Debug_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Debug_String(message)
+	#else
+	   #define __Debug_String(message)                                             \
+		  do                                                                      \
+		  {                                                                       \
+			  DEBUG_ASSERT_MESSAGE(                                               \
+				  DEBUG_ASSERT_COMPONENT_NAME_STRING,                             \
+				  "",                                                             \
+				  0,                                                              \
+				  message,                                                        \
+				  __FILE__,                                                       \
+				  __LINE__,                                                       \
+				  0);                                                             \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Check(assertion)
+ *
+ *  Summary:
+ *    Production builds: does nothing and produces no code.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ */
+#ifndef __Check
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Check(assertion)
+	#else
+	   #define __Check(assertion)                                                 \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, 0, 0, __FILE__, __LINE__, 0 );                  \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nCheck
+	#define __nCheck(assertion)  __Check(!(assertion))
+#endif
+
+/*
+ *  __Check_String(assertion, message)
+ *
+ *  Summary:
+ *    Production builds: does nothing and produces no code.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Check_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Check_String(assertion, message)
+	#else
+	   #define __Check_String(assertion, message)                                 \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, 0, message, __FILE__, __LINE__, 0 );            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nCheck_String
+	#define __nCheck_String(assertion, message)  __Check_String(!(assertion), message)
+#endif
+
+/*
+ *  __Check_noErr(errorCode)
+ *
+ *  Summary:
+ *    Production builds: does nothing and produces no code.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The errorCode expression to compare with 0.
+ */
+#ifndef __Check_noErr
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Check_noErr(errorCode)
+	#else
+	   #define __Check_noErr(errorCode)                                           \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Check_noErr_String(errorCode, message)
+ *
+ *  Summary:
+ *    Production builds: check_noerr_string() does nothing and produces
+ *    no code.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The errorCode expression to compare to 0.
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Check_noErr_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Check_noErr_String(errorCode, message)
+	#else
+	   #define __Check_noErr_String(errorCode, message)                           \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Verify(assertion)
+ *
+ *  Summary:
+ *    Production builds: evaluate the assertion expression, but ignore
+ *    the result.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ */
+#ifndef __Verify
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Verify(assertion)                                                \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( !(assertion) )                                                 \
+			  {                                                                   \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Verify(assertion)                                                \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, 0, 0, __FILE__, __LINE__, 0 );                  \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nVerify
+	#define __nVerify(assertion)	__Verify(!(assertion))
+#endif
+
+/*
+ *  __Verify_String(assertion, message)
+ *
+ *  Summary:
+ *    Production builds: evaluate the assertion expression, but ignore
+ *    the result.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Verify_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Verify_String(assertion, message)                                \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( !(assertion) )                                                 \
+			  {                                                                   \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Verify_String(assertion, message)                                \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, 0, message, __FILE__, __LINE__, 0 );            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nVerify_String
+	#define __nVerify_String(assertion, message)  __Verify_String(!(assertion), message)
+#endif
+
+/*
+ *  __Verify_noErr(errorCode)
+ *
+ *  Summary:
+ *    Production builds: evaluate the errorCode expression, but ignore
+ *    the result.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ */
+#ifndef __Verify_noErr
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Verify_noErr(errorCode)                                          \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( 0 != (errorCode) )                                             \
+			  {                                                                   \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Verify_noErr(errorCode)                                          \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Verify_noErr_String(errorCode, message)
+ *
+ *  Summary:
+ *    Production builds: evaluate the errorCode expression, but ignore
+ *    the result.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Verify_noErr_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Verify_noErr_String(errorCode, message)                          \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( 0 != (errorCode) )                                             \
+			  {                                                                   \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Verify_noErr_String(errorCode, message)                          \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Verify_noErr_Action(errorCode, action)
+ *
+ *  Summary:
+ *    Production builds: if the errorCode expression does not equal 0 (noErr),
+ *    execute the action statement or compound statement (block).
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound
+ *    statement (block).
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ */
+#ifndef __Verify_noErr_Action
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Verify_noErr_Action(errorCode, action)                          \
+		  if ( 0 != (errorCode) ) {                                              \
+			  action;                                                            \
+		  }                                                                      \
+		  else do {} while (0)
+	#else
+	   #define __Verify_noErr_Action(errorCode, action)                          \
+		  long evalOnceErrorCode = (errorCode);                                  \
+		  if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) {                   \
+			  DEBUG_ASSERT_MESSAGE(                                              \
+				  DEBUG_ASSERT_COMPONENT_NAME_STRING,                            \
+				  #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, 0 );            \
+			  action;                                                            \
+		  }                                                                      \
+		  else do {} while (0)
+	#endif
+#endif
+
+/*
+ *  __Verify_Action(assertion, action)
+ *
+ *  Summary:
+ *    Production builds: if the assertion expression evaluates to false,
+ *    then execute the action statement or compound statement (block).
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound
+ *    statement (block).
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ */
+#ifndef __Verify_Action
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Verify_Action(assertion, action)                                \
+		  if ( __builtin_expect(!(assertion), 0) ) {                             \
+			action;                                                              \
+		  }                                                                      \
+		  else do {} while (0)
+	#else
+	   #define __Verify_Action(assertion, action)                                \
+		  if ( __builtin_expect(!(assertion), 0) ) {                             \
+			  DEBUG_ASSERT_MESSAGE(                                              \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                        \
+					  #assertion, 0, 0, __FILE__, __LINE__, 0 );                 \
+			  action;                                                            \
+		  }                                                                      \
+		  else do {} while (0)
+	#endif
+#endif
+
+/*
+ *  __Require(assertion, exceptionLabel)
+ *
+ *  Summary:
+ *    Production builds: if the assertion expression evaluates to false,
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    exceptionLabel:
+ *      The label.
+ */
+#ifndef __Require
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require(assertion, exceptionLabel)                               \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require(assertion, exceptionLabel)                               \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) ) {                          \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, #exceptionLabel, 0, __FILE__, __LINE__,  0);    \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nRequire
+	#define __nRequire(assertion, exceptionLabel)  __Require(!(assertion), exceptionLabel)
+#endif
+
+/*
+ *  __Require_Action(assertion, exceptionLabel, action)
+ *
+ *  Summary:
+ *    Production builds: if the assertion expression evaluates to false,
+ *    execute the action statement or compound statement (block) and then
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
+ *    statement (block), and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ */
+#ifndef __Require_Action
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require_Action(assertion, exceptionLabel, action)                \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require_Action(assertion, exceptionLabel, action)                \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, #exceptionLabel, 0,   __FILE__, __LINE__, 0);   \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nRequire_Action
+	#define __nRequire_Action(assertion, exceptionLabel, action)                  \
+	__Require_Action(!(assertion), exceptionLabel, action)
+#endif
+
+/*
+ *  __Require_Quiet(assertion, exceptionLabel)
+ *
+ *  Summary:
+ *    If the assertion expression evaluates to false, goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    exceptionLabel:
+ *      The label.
+ */
+#ifndef __Require_Quiet
+	#define __Require_Quiet(assertion, exceptionLabel)                            \
+	  do                                                                          \
+	  {                                                                           \
+		  if ( __builtin_expect(!(assertion), 0) )                                \
+		  {                                                                       \
+			  goto exceptionLabel;                                                \
+		  }                                                                       \
+	  } while ( 0 )
+#endif
+
+#ifndef __nRequire_Quiet
+	#define __nRequire_Quiet(assertion, exceptionLabel)  __Require_Quiet(!(assertion), exceptionLabel)
+#endif
+
+/*
+ *  __Require_Action_Quiet(assertion, exceptionLabel, action)
+ *
+ *  Summary:
+ *    If the assertion expression evaluates to false, execute the action
+ *    statement or compound statement (block), and goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ */
+#ifndef __Require_Action_Quiet
+	#define __Require_Action_Quiet(assertion, exceptionLabel, action)             \
+	  do                                                                          \
+	  {                                                                           \
+		  if ( __builtin_expect(!(assertion), 0) )                                \
+		  {                                                                       \
+			  {                                                                   \
+				  action;                                                         \
+			  }                                                                   \
+			  goto exceptionLabel;                                                \
+		  }                                                                       \
+	  } while ( 0 )
+#endif
+
+#ifndef __nRequire_Action_Quiet
+	#define __nRequire_Action_Quiet(assertion, exceptionLabel, action)              \
+		__Require_Action_Quiet(!(assertion), exceptionLabel, action)
+#endif
+
+/*
+ *  __Require_String(assertion, exceptionLabel, message)
+ *
+ *  Summary:
+ *    Production builds: if the assertion expression evaluates to false,
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Require_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require_String(assertion, exceptionLabel, message)               \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require_String(assertion, exceptionLabel, message)               \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, #exceptionLabel,  message,  __FILE__, __LINE__, 0); \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nRequire_String
+	#define __nRequire_String(assertion, exceptionLabel, string)                  \
+		__Require_String(!(assertion), exceptionLabel, string)
+#endif
+
+/*
+ *  __Require_Action_String(assertion, exceptionLabel, action, message)
+ *
+ *  Summary:
+ *    Production builds: if the assertion expression evaluates to false,
+ *    execute the action statement or compound statement (block), and then
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the assertion expression evaluates to false,
+ *    call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
+ *    statement (block), and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    assertion:
+ *      The assertion expression.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Require_Action_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require_Action_String(assertion, exceptionLabel, action, message)  \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require_Action_String(assertion, exceptionLabel, action, message)  \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(!(assertion), 0) )                            \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #assertion, #exceptionLabel,  message,  __FILE__,  __LINE__, 0); \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+#ifndef __nRequire_Action_String
+	#define __nRequire_Action_String(assertion, exceptionLabel, action, message)    \
+		__Require_Action_String(!(assertion), exceptionLabel, action, message)
+#endif
+
+/*
+ *  __Require_noErr(errorCode, exceptionLabel)
+ *
+ *  Summary:
+ *    Production builds: if the errorCode expression does not equal 0 (noErr),
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    exceptionLabel:
+ *      The label.
+ */
+#ifndef __Require_noErr
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require_noErr(errorCode, exceptionLabel)                         \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
+			  {                                                                   \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require_noErr(errorCode, exceptionLabel)                         \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ",  #exceptionLabel,  0,  __FILE__, __LINE__, evalOnceErrorCode); \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Require_noErr_Action(errorCode, exceptionLabel, action)
+ *
+ *  Summary:
+ *    Production builds: if the errorCode expression does not equal 0 (noErr),
+ *    execute the action statement or compound statement (block) and
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE, execute the action statement or
+ *    compound statement (block), and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ */
+#ifndef __Require_noErr_Action
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require_noErr_Action(errorCode, exceptionLabel, action)          \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
+			  {                                                                   \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require_noErr_Action(errorCode, exceptionLabel, action)          \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ", #exceptionLabel,  0,  __FILE__, __LINE__,  evalOnceErrorCode); \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Require_noErr_Quiet(errorCode, exceptionLabel)
+ *
+ *  Summary:
+ *    If the errorCode expression does not equal 0 (noErr),
+ *    goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    exceptionLabel:
+ *      The label.
+ */
+#ifndef __Require_noErr_Quiet
+	#define __Require_noErr_Quiet(errorCode, exceptionLabel)                      \
+	  do                                                                          \
+	  {                                                                           \
+		  if ( __builtin_expect(0 != (errorCode), 0) )                            \
+		  {                                                                       \
+			  goto exceptionLabel;                                                \
+		  }                                                                       \
+	  } while ( 0 )
+#endif
+
+/*
+ *  __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)
+ *
+ *  Summary:
+ *    If the errorCode expression does not equal 0 (noErr),
+ *    execute the action statement or compound statement (block) and
+ *    goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ */
+#ifndef __Require_noErr_Action_Quiet
+	#define __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)       \
+	  do                                                                          \
+	  {                                                                           \
+		  if ( __builtin_expect(0 != (errorCode), 0) )                            \
+		  {                                                                       \
+			  {                                                                   \
+				  action;                                                         \
+			  }                                                                   \
+			  goto exceptionLabel;                                                \
+		  }                                                                       \
+	  } while ( 0 )
+#endif
+
+/*
+ *  __Require_noErr_String(errorCode, exceptionLabel, message)
+ *
+ *  Summary:
+ *    Production builds: if the errorCode expression does not equal 0 (noErr),
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Require_noErr_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require_noErr_String(errorCode, exceptionLabel, message)         \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
+			  {                                                                   \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require_noErr_String(errorCode, exceptionLabel, message)         \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ",  #exceptionLabel, message, __FILE__,  __LINE__,  evalOnceErrorCode); \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Require_noErr_Action_String(errorCode, exceptionLabel, action, message)
+ *
+ *  Summary:
+ *    Production builds: if the errorCode expression does not equal 0 (noErr),
+ *    execute the action statement or compound statement (block) and
+ *    goto exceptionLabel.
+ *
+ *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
+ *    call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
+ *    statement (block), and then goto exceptionLabel.
+ *
+ *  Parameters:
+ *
+ *    errorCode:
+ *      The expression to compare to 0.
+ *
+ *    exceptionLabel:
+ *      The label.
+ *
+ *    action:
+ *      The statement or compound statement (block).
+ *
+ *    message:
+ *      The C string to display.
+ */
+#ifndef __Require_noErr_Action_String
+	#if DEBUG_ASSERT_PRODUCTION_CODE
+	   #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \
+		  do                                                                      \
+		  {                                                                       \
+			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
+			  {                                                                   \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#else
+	   #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \
+		  do                                                                      \
+		  {                                                                       \
+			  long evalOnceErrorCode = (errorCode);                               \
+			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
+			  {                                                                   \
+				  DEBUG_ASSERT_MESSAGE(                                           \
+					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
+					  #errorCode " == 0 ", #exceptionLabel, message, __FILE__, __LINE__, evalOnceErrorCode); \
+				  {                                                               \
+					  action;                                                     \
+				  }                                                               \
+				  goto exceptionLabel;                                            \
+			  }                                                                   \
+		  } while ( 0 )
+	#endif
+#endif
+
+/*
+ *  __Check_Compile_Time(expr)
+ *
+ *  Summary:
+ *    any build: if the expression is not true, generated a compile time error.
+ *
+ *  Parameters:
+ *
+ *    expr:
+ *      The compile time expression that should evaluate to non-zero.
+ *
+ *  Discussion:
+ *     This declares an array with a size that is determined by a compile-time expression.
+ *     If false, it declares a negatively sized array, which generates a compile-time error.
+ *
+ * Examples:
+ *     __Check_Compile_Time( sizeof( int ) == 4 );
+ *     __Check_Compile_Time( offsetof( MyStruct, myField ) == 4 );
+ *     __Check_Compile_Time( ( kMyBufferSize % 512 ) == 0 );
+ *
+ *  Note: This only works with compile-time expressions.
+ *  Note: This only works in places where extern declarations are allowed (e.g. global scope).
+ */
+#ifndef __Check_Compile_Time
+    #ifdef __GNUC__ 
+        #define __Check_Compile_Time( expr )    \
+            extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ] __attribute__( ( unused ) )
+    #else
+        #define __Check_Compile_Time( expr )    \
+            extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ]
+    #endif
+#endif
+
+/*
+ *	For time immemorial, Mac OS X has defined version of most of these macros without the __ prefix, which
+ *	could collide with similarly named functions or macros in user code, including new functionality in
+ *	Boost and the C++ standard library.
+ *
+ *	A future release of Mac OS X will no longer do this, and will require that clients move to the
+ *  new macros as defined above.  However, in the interim both the new and old macros will work, unless
+ *  clients define a macro __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES before this file is included
+ *  in their compilations.  Clients who do not want the older macros defined can accomplish this by adding
+ *    #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
+ *  at the top of their sources, or my adding -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 to the
+ *  gcc compilation options.
+ *
+ *  To aid users of these macros in converting their sources, the following tops script will convert usages
+ *  of the old macros into the new equivalents.  To do so, in Terminal go into the directory containing the
+ *  sources to be converted and run this command.
+ *
+    find . -name '*.[c|cc|cp|cpp|m|mm|h]' -print0 |  xargs -0 tops -verbose \
+      replace "check(<b args>)" with "__Check(<args>)" \
+      replace "check_noerr(<b args>)" with "__Check_noErr(<args>)" \
+      replace "check_noerr_string(<b args>)" with "__Check_noErr_String(<args>)" \
+      replace "check_string(<b args>)" with "__Check_String(<args>)" \
+      replace "require(<b args>)" with "__Require(<args>)" \
+      replace "require_action(<b args>)" with "__Require_Action(<args>)" \
+      replace "require_action_string(<b args>)" with "__Require_Action_String(<args>)" \
+      replace "require_noerr(<b args>)" with "__Require_noErr(<args>)" \
+      replace "require_noerr_action(<b args>)" with "__Require_noErr_Action(<args>)" \
+      replace "require_noerr_action_string(<b args>)" with "__Require_noErr_Action_String(<args>)" \
+      replace "require_noerr_string(<b args>)" with "__Require_noErr_String(<args>)" \
+      replace "require_string(<b args>)" with "__Require_String(<args>)" \
+      replace "verify(<b args>)" with "__Verify(<args>)" \
+      replace "verify_action(<b args>)" with "__Verify_Action(<args>)" \
+      replace "verify_noerr(<b args>)" with "__Verify_noErr(<args>)" \
+      replace "verify_noerr_action(<b args>)" with "__Verify_noErr_Action(<args>)" \
+      replace "verify_noerr_string(<b args>)" with "__Verify_noErr_String(<args>)" \
+      replace "verify_string(<b args>)" with "__Verify_String(<args>)" \
+      replace "ncheck(<b args>)" with "__nCheck(<args>)" \
+      replace "ncheck_string(<b args>)" with "__nCheck_String(<args>)" \
+      replace "nrequire(<b args>)" with "__nRequire(<args>)" \
+      replace "nrequire_action(<b args>)" with "__nRequire_Action(<args>)" \
+      replace "nrequire_action_quiet(<b args>)" with "__nRequire_Action_Quiet(<args>)" \
+      replace "nrequire_action_string(<b args>)" with "__nRequire_Action_String(<args>)" \
+      replace "nrequire_quiet(<b args>)" with "__nRequire_Quiet(<args>)" \
+      replace "nrequire_string(<b args>)" with "__nRequire_String(<args>)" \
+      replace "nverify(<b args>)" with "__nVerify(<args>)" \
+      replace "nverify_string(<b args>)" with "__nVerify_String(<args>)" \
+      replace "require_action_quiet(<b args>)" with "__Require_Action_Quiet(<args>)" \
+      replace "require_noerr_action_quiet(<b args>)" with "__Require_noErr_Action_Quiet(<args>)" \
+      replace "require_noerr_quiet(<b args>)" with "__Require_noErr_Quiet(<args>)" \
+      replace "require_quiet(<b args>)" with "__Require_Quiet(<args>)" \
+      replace "check_compile_time(<b args>)" with "__Check_Compile_Time(<args>)" \
+      replace "debug_string(<b args>)" with "__Debug_String(<args>)"
+ *
+ */
+
+#ifndef __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES
+	/* If we haven't set this yet, it defaults to on.  In the next release, this will default to off. */
+	#define	__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES	1
+#endif
+
+#if	__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES
+
+	#ifndef check
+	#define check(assertion)  __Check(assertion)
+	#endif
+
+	#ifndef check_noerr
+	#define check_noerr(errorCode)  __Check_noErr(errorCode)
+	#endif
+
+	#ifndef check_noerr_string
+		#define check_noerr_string(errorCode, message)  __Check_noErr_String(errorCode, message)
+	#endif
+
+	#ifndef check_string
+		#define check_string(assertion, message)  __Check_String(assertion, message)
+	#endif
+
+	#ifndef require
+		#define require(assertion, exceptionLabel)  __Require(assertion, exceptionLabel)
+	#endif
+
+	#ifndef require_action
+		#define require_action(assertion, exceptionLabel, action)  __Require_Action(assertion, exceptionLabel, action)
+	#endif
+
+	#ifndef require_action_string
+		#define require_action_string(assertion, exceptionLabel, action, message)  __Require_Action_String(assertion, exceptionLabel, action, message)
+	#endif
+
+	#ifndef require_noerr
+		#define require_noerr(errorCode, exceptionLabel)  __Require_noErr(errorCode, exceptionLabel)
+	#endif
+
+	#ifndef require_noerr_action
+		#define require_noerr_action(errorCode, exceptionLabel, action)  __Require_noErr_Action(errorCode, exceptionLabel, action)
+	#endif
+
+	#ifndef require_noerr_action_string
+		#define require_noerr_action_string(errorCode, exceptionLabel, action, message)  __Require_noErr_Action_String(errorCode, exceptionLabel, action, message)
+	#endif
+
+	#ifndef require_noerr_string
+		#define require_noerr_string(errorCode, exceptionLabel, message)  __Require_noErr_String(errorCode, exceptionLabel, message)
+	#endif
+
+	#ifndef require_string
+		#define require_string(assertion, exceptionLabel, message)  __Require_String(assertion, exceptionLabel, message)
+	#endif
+
+	#ifndef verify
+		#define verify(assertion) __Verify(assertion)
+	#endif
+
+	#ifndef verify_action
+		#define verify_action(assertion, action)  __Verify_Action(assertion, action)
+	#endif
+
+	#ifndef verify_noerr
+		#define verify_noerr(errorCode)  __Verify_noErr(errorCode)
+	#endif
+
+	#ifndef verify_noerr_action
+		#define verify_noerr_action(errorCode, action)  __Verify_noErr_Action(errorCode, action)
+	#endif
+
+	#ifndef verify_noerr_string
+		#define verify_noerr_string(errorCode, message)  __Verify_noErr_String(errorCode, message)
+	#endif
+
+	#ifndef verify_string
+		#define verify_string(assertion, message)  __Verify_String(assertion, message)
+	#endif
+
+	#ifndef ncheck
+		#define ncheck(assertion)  __nCheck(assertion)
+	#endif
+
+	#ifndef ncheck_string
+		#define ncheck_string(assertion, message)  __nCheck_String(assertion, message)
+	#endif
+
+	#ifndef nrequire
+		#define nrequire(assertion, exceptionLabel)  __nRequire(assertion, exceptionLabel)
+	#endif
+
+	#ifndef nrequire_action
+		#define nrequire_action(assertion, exceptionLabel, action)  __nRequire_Action(assertion, exceptionLabel, action)
+	#endif
+
+	#ifndef nrequire_action_quiet
+		#define nrequire_action_quiet(assertion, exceptionLabel, action)  __nRequire_Action_Quiet(assertion, exceptionLabel, action)
+	#endif
+
+	#ifndef nrequire_action_string
+		#define nrequire_action_string(assertion, exceptionLabel, action, message)  __nRequire_Action_String(assertion, exceptionLabel, action, message)
+	#endif
+
+	#ifndef nrequire_quiet
+		#define nrequire_quiet(assertion, exceptionLabel)  __nRequire_Quiet(assertion, exceptionLabel)
+	#endif
+
+	#ifndef nrequire_string
+		#define nrequire_string(assertion, exceptionLabel, string)  __nRequire_String(assertion, exceptionLabel, string)
+	#endif
+
+	#ifndef nverify
+		#define nverify(assertion)  __nVerify(assertion)
+	#endif
+
+	#ifndef nverify_string
+		#define nverify_string(assertion, message)  __nVerify_String(assertion, message)
+	#endif
+
+	#ifndef require_action_quiet
+		#define require_action_quiet(assertion, exceptionLabel, action)  __Require_Action_Quiet(assertion, exceptionLabel, action)
+	#endif
+
+	#ifndef require_noerr_action_quiet
+		#define require_noerr_action_quiet(errorCode, exceptionLabel, action)  __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)
+	#endif
+
+	#ifndef require_noerr_quiet
+		#define require_noerr_quiet(errorCode, exceptionLabel)  __Require_noErr_Quiet(errorCode, exceptionLabel)
+	#endif
+
+	#ifndef require_quiet
+		#define require_quiet(assertion, exceptionLabel)  __Require_Quiet(assertion, exceptionLabel)
+	#endif
+
+	#ifndef check_compile_time
+		#define check_compile_time( expr )  __Check_Compile_Time( expr )
+	#endif
+
+	#ifndef debug_string
+		#define debug_string(message)  __Debug_String(message)
+	#endif
+	
+#endif	/* ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES */
+
+
+#endif /* __ASSERTMACROS__ */
diff --git a/CoreFoundation/include/AvailabilityMacros.h b/CoreFoundation/include/AvailabilityMacros.h
new file mode 100644
index 0000000..f35c252
--- /dev/null
+++ b/CoreFoundation/include/AvailabilityMacros.h
@@ -0,0 +1,555 @@
+/*
+     File:       AvailabilityMacros.h
+ 
+     Copyright:  (c) 2001-2005 by Apple Computer, Inc., all rights reserved.
+
+     More Info:  See TechNote 2064
+
+     Contains:   Autoconfiguration of AVAILABLE_ macros for Mac OS X
+
+                 This header enables a developer to specify build time
+                 constraints on what Mac OS X versions the resulting
+                 application will be run.  There are two bounds a developer
+                 can specify:
+                 
+                      MAC_OS_X_VERSION_MIN_REQUIRED
+                      MAC_OS_X_VERSION_MAX_ALLOWED
+                      
+                The lower bound controls which calls to OS functions will 
+                be weak-importing (allowed to be unresolved at launch time).
+                The upper bound controls which OS functionality, if used,
+                will result in a compiler error because that functionality is
+                not available on on any OS is the specifed range.
+                
+                For example, suppose an application is compiled with:
+                
+                      MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_2
+                      MAC_OS_X_VERSION_MAX_ALLOWED  = MAC_OS_X_VERSION_10_3
+                     
+                and an OS header contains:
+                
+                     extern void funcA(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
+                     extern void funcB(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2;
+                     extern void funcC(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3;
+                     extern void funcD(void) AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER;
+                     extern void funcE(void) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;
+                     extern void funcF(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
+                     extern void funcG(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
+                     
+                     typedef long TypeA DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER;
+                     typedef long TypeB DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER;
+                     typedef long TypeC DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER;
+                     typedef long TypeD DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER;
+                     typedef long TypeE DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER;
+
+                Any application code which uses these declarations will get the following:
+                
+                                compile         link          run 
+                                -------         ------        -------
+                     funcA:     normal          normal        normal
+                     funcB:     warning         normal        normal
+                     funcC:     normal          normal        normal
+                     funcD:     normal          normal        normal
+                     funcE:     normal          normal        normal
+                     funcF:     normal          weak          on 10.3 normal, on 10.2 (&funcF == NULL)
+                     funcG:     error           error         n/a
+                     typeA:     warning
+                     typeB:     warning
+                     typeC:     warning
+                     typeD:     normal
+                     typeE:     normal
+                  
+  
+*/
+#ifndef __AVAILABILITYMACROS__
+#define __AVAILABILITYMACROS__
+
+
+/*
+ * Set up standard Mac OS X versions
+ */
+#define MAC_OS_X_VERSION_10_0 1000
+#define MAC_OS_X_VERSION_10_1 1010
+#define MAC_OS_X_VERSION_10_2 1020
+#define MAC_OS_X_VERSION_10_3 1030
+#define MAC_OS_X_VERSION_10_4 1040
+#define MAC_OS_X_VERSION_10_5 1050
+
+
+/* 
+ * If min OS not specified, assume 10.1
+ * Note: gcc driver may set _ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED_ based on MACOSX_DEPLOYMENT_TARGET environment variable
+ */
+#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
+    #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+        #define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
+    #else
+        #if __ppc64__ || __i386__ || __x86_64__ || __arm__
+            #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
+        #else
+            #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_1
+        #endif
+    #endif
+#endif
+
+/*
+ * if max OS not specified, assume largerof(10.5, min)
+ */
+#ifndef MAC_OS_X_VERSION_MAX_ALLOWED
+    #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
+        #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_MIN_REQUIRED
+    #else
+        #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_5
+    #endif
+#endif
+
+/*
+ * Error on bad values
+ */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_MIN_REQUIRED
+    #error MAC_OS_X_VERSION_MAX_ALLOWED must be >= MAC_OS_X_VERSION_MIN_REQUIRED
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_0
+    #error MAC_OS_X_VERSION_MIN_REQUIRED must be >= MAC_OS_X_VERSION_10_0
+#endif
+
+/*
+ * only certain compilers support __attribute((weak_import))__
+ */
+#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020)
+    #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
+#elif defined(__MWERKS__) && (__MWERKS__ >= 0x3205) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020)
+    #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
+#else
+    #define WEAK_IMPORT_ATTRIBUTE
+#endif
+
+/*
+ * only certain compilers support __attribute((deprecated))__
+ */
+#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
+    #define DEPRECATED_ATTRIBUTE __attribute__((deprecated))
+#else
+    #define DEPRECATED_ATTRIBUTE
+#endif
+
+/*
+ * only certain compilers support __attribute((unavailable))__
+ */
+#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
+    #define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable))
+#else
+    #define UNAVAILABLE_ATTRIBUTE
+#endif
+
+
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
+ * 
+ * Used on functions introduced in Mac OS X 10.0 
+ */
+#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED
+ * 
+ * Used on functions introduced in Mac OS X 10.0, 
+ * and deprecated in Mac OS X 10.0
+ */
+#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED    DEPRECATED_ATTRIBUTE
+
+/*
+ * DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER
+ * 
+ * Used on types deprecated in Mac OS X 10.0 
+ */
+#define DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER     DEPRECATED_ATTRIBUTE
+
+
+
+
+
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
+ * 
+ * Used on declarations introduced in Mac OS X 10.1 
+ */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_1
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER     UNAVAILABLE_ATTRIBUTE
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_1
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER     WEAK_IMPORT_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED
+ * 
+ * Used on declarations introduced in Mac OS X 10.1, 
+ * and deprecated in Mac OS X 10.1
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED    AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1
+ * 
+ * Used on declarations introduced in Mac OS X 10.0, 
+ * but later deprecated in Mac OS X 10.1
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1    AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
+#endif
+
+/*
+ * DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER
+ * 
+ * Used on types deprecated in Mac OS X 10.1 
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER    DEPRECATED_ATTRIBUTE
+#else
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER
+#endif
+
+
+
+
+
+
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
+ * 
+ * Used on declarations introduced in Mac OS X 10.2 
+ */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_2
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER     UNAVAILABLE_ATTRIBUTE
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER     WEAK_IMPORT_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED
+ * 
+ * Used on declarations introduced in Mac OS X 10.2, 
+ * and deprecated in Mac OS X 10.2
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED    AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2
+ * 
+ * Used on declarations introduced in Mac OS X 10.0, 
+ * but later deprecated in Mac OS X 10.2
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2    AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2
+ * 
+ * Used on declarations introduced in Mac OS X 10.1, 
+ * but later deprecated in Mac OS X 10.2
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2    AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
+#endif
+
+/*
+ * DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER
+ * 
+ * Used on types deprecated in Mac OS X 10.2 
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER    DEPRECATED_ATTRIBUTE
+#else
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER
+#endif
+
+
+
+
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
+ * 
+ * Used on declarations introduced in Mac OS X 10.3 
+ */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER     UNAVAILABLE_ATTRIBUTE
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER     WEAK_IMPORT_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED
+ * 
+ * Used on declarations introduced in Mac OS X 10.3, 
+ * and deprecated in Mac OS X 10.3
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED    AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3
+ * 
+ * Used on declarations introduced in Mac OS X 10.0, 
+ * but later deprecated in Mac OS X 10.3
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3    AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3
+ * 
+ * Used on declarations introduced in Mac OS X 10.1, 
+ * but later deprecated in Mac OS X 10.3
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3    AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3
+ * 
+ * Used on declarations introduced in Mac OS X 10.2, 
+ * but later deprecated in Mac OS X 10.3
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3    AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
+#endif
+
+/*
+ * DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER
+ * 
+ * Used on types deprecated in Mac OS X 10.3 
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER    DEPRECATED_ATTRIBUTE
+#else
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER
+#endif
+
+
+
+
+
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
+ * 
+ * Used on declarations introduced in Mac OS X 10.4 
+ */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
+    #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER     UNAVAILABLE_ATTRIBUTE
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
+    #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER     WEAK_IMPORT_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED
+ * 
+ * Used on declarations introduced in Mac OS X 10.4, 
+ * and deprecated in Mac OS X 10.4
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+    #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED    AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
+ * 
+ * Used on declarations introduced in Mac OS X 10.0, 
+ * but later deprecated in Mac OS X 10.4
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
+ * 
+ * Used on declarations introduced in Mac OS X 10.1, 
+ * but later deprecated in Mac OS X 10.4
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
+ * 
+ * Used on declarations introduced in Mac OS X 10.2, 
+ * but later deprecated in Mac OS X 10.4
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4
+ * 
+ * Used on declarations introduced in Mac OS X 10.3, 
+ * but later deprecated in Mac OS X 10.4
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4    AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
+#endif
+
+/*
+ * DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER
+ * 
+ * Used on types deprecated in Mac OS X 10.4 
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER    DEPRECATED_ATTRIBUTE
+#else
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER
+#endif
+
+
+
+
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
+ * 
+ * Used on declarations introduced in Mac OS X 10.5 
+ */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER     UNAVAILABLE_ATTRIBUTE
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER     WEAK_IMPORT_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED
+ * 
+ * Used on declarations introduced in Mac OS X 10.5, 
+ * and deprecated in Mac OS X 10.5
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED    AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
+ * 
+ * Used on declarations introduced in Mac OS X 10.0, 
+ * but later deprecated in Mac OS X 10.5
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
+ * 
+ * Used on declarations introduced in Mac OS X 10.1, 
+ * but later deprecated in Mac OS X 10.5
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
+ * 
+ * Used on declarations introduced in Mac OS X 10.2, 
+ * but later deprecated in Mac OS X 10.5
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
+ * 
+ * Used on declarations introduced in Mac OS X 10.3, 
+ * but later deprecated in Mac OS X 10.5
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5
+ * 
+ * Used on declarations introduced in Mac OS X 10.4, 
+ * but later deprecated in Mac OS X 10.5
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    DEPRECATED_ATTRIBUTE
+#else
+    #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5    AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
+#endif
+
+/*
+ * DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
+ * 
+ * Used on types deprecated in Mac OS X 10.5 
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER    DEPRECATED_ATTRIBUTE
+#else
+    #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
+#endif
+
+#endif  /* __AVAILABILITYMACROS__ */
+
+
diff --git a/CoreFoundation/include/Makefile.am b/CoreFoundation/include/Makefile.am
new file mode 100644
index 0000000..322ecf5
--- /dev/null
+++ b/CoreFoundation/include/Makefile.am
@@ -0,0 +1,19 @@
+all: CoreFoundation
+
+check install: all
+
+CS_includedir		= ${includedir}
+
+CS_include_HEADERS	= AssertMacros.h		\
+			  AvailabilityMacros.h		\
+			  TargetConditionals.h
+
+EXTRA_DIST		= c99/stdbool.h			\
+			  c99/stdint.h			\
+			  mach_support/bootstrap_priv.h	\
+			  mach_support/vproc_priv.h
+
+CF_SOURCE		= ${top_srcdir}
+
+CoreFoundation: | ${CF_SOURCE}
+	${LN_S} ${CF_SOURCE} $@
diff --git a/CoreFoundation/include/Makefile.in b/CoreFoundation/include/Makefile.in
new file mode 100644
index 0000000..ff3aac7
--- /dev/null
+++ b/CoreFoundation/include/Makefile.in
@@ -0,0 +1,459 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = include
+DIST_COMMON = $(CS_include_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in $(srcdir)/config.h.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(CS_includedir)"
+CS_includeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(CS_include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+CS_includedir = ${includedir}
+CS_include_HEADERS = AssertMacros.h		\
+			  AvailabilityMacros.h		\
+			  TargetConditionals.h
+
+EXTRA_DIST = c99/stdbool.h			\
+			  c99/stdint.h			\
+			  mach_support/bootstrap_priv.h	\
+			  mach_support/vproc_priv.h
+
+CF_SOURCE = ${top_srcdir}
+all: config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  include/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  include/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+config.h: stamp-h1
+	@if test ! -f $@; then \
+	  rm -f stamp-h1; \
+	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+	else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status include/config.h
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+	cd $(top_srcdir) && $(AUTOHEADER)
+	rm -f stamp-h1
+	touch $@
+
+distclean-hdr:
+	-rm -f config.h stamp-h1
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-CS_includeHEADERS: $(CS_include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(CS_includedir)" || $(MKDIR_P) "$(DESTDIR)$(CS_includedir)"
+	@list='$(CS_include_HEADERS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(CS_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(CS_includedir)/$$f'"; \
+	  $(CS_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(CS_includedir)/$$f"; \
+	done
+
+uninstall-CS_includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(CS_include_HEADERS)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(CS_includedir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(CS_includedir)/$$f"; \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS) config.h
+installdirs:
+	for dir in "$(DESTDIR)$(CS_includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-CS_includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-CS_includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool ctags distclean distclean-generic distclean-hdr \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-CS_includeHEADERS \
+	install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-CS_includeHEADERS uninstall-am
+
+all: CoreFoundation
+
+check install: all
+
+CoreFoundation: | ${CF_SOURCE}
+	${LN_S} ${CF_SOURCE} $@
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/include/TargetConditionals.h b/CoreFoundation/include/TargetConditionals.h
new file mode 100644
index 0000000..4a56a96
--- /dev/null
+++ b/CoreFoundation/include/TargetConditionals.h
@@ -0,0 +1,47 @@
+#ifndef forPublicRelease
+/*=============================================================================
+	TargetConditionals.h
+
+	$Log: TargetConditionals.h,v $
+	Revision 1.1  2006/06/07 00:51:05  seangies
+	Added windows-specific project files and code.
+	
+	Revision 1.3  2005/09/27 19:10:13  bpietsch
+	Merge  QT7Branch     (QT7Base0 -> QTMerge33_QT702_to_TOT_QT7) Shipped:   QT702GM
+	  ==>  Top Of Tree    PreMerge:   QTMerge33_QT702_to_TOT_TOT  PostMerge: QTMerge33_QT702_to_TOT
+	_______________________________________________________________________________________________
+	
+	Revision 1.2  2005/09/23 02:39:02  bpietsch
+	QT702GM to TOT merge -- files added on QT7Branch that were not added to TOT <dkudo>
+	
+	Revision 1.1.24.1  2005/08/24 21:17:22  duano
+	Add forPublicRelease conditional so we can sanitize this header for use in the Windows SDK. [4181600]
+	
+	Revision 1.1  2003/05/15 22:15:13  jsam
+	Renamed from TargetConditionals.h.  Only used on non-mac. <grc>
+	
+	Revision 1.3  2003/04/03 19:17:36  thaiwey
+	Add this for windows build after big header change.
+	
+	Revision 1.1  2002/12/02 18:30:39  gregc
+	First time.
+	
+	Note: This file exists only to serve the Windows build
+
+=============================================================================*/
+#else
+/*
+	File:		TargetConditionals.h
+
+	Copyright:	© 2002-2005 by Apple Computer, Inc., all rights reserved.
+
+	Simple redirect header to ConditionalMacros.h for use on Windows.
+*/
+#endif
+
+#if !defined(__TargetConditionals_h__)
+#define __TargetConditionals_h__
+
+#include "ConditionalMacros.h"
+
+#endif
diff --git a/CoreFoundation/include/c99/stdbool.h b/CoreFoundation/include/c99/stdbool.h
new file mode 100644
index 0000000..3b92d43
--- /dev/null
+++ b/CoreFoundation/include/c99/stdbool.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2007 Apple Inc.
+ * All rights reserved.
+ *
+ */
+
+#ifndef __STDBOOL_H__
+#define __STDBOOL_H__	1
+
+#define __bool_true_false_are_defined   1
+
+#ifndef __cplusplus
+
+#define false   0
+#define true    1
+
+#define bool    _Bool
+
+#ifndef COCOTRON
+typedef unsigned char _Bool;
+#endif
+
+#endif /* !__cplusplus */
+
+#endif
+
diff --git a/CoreFoundation/include/c99/stdint.h b/CoreFoundation/include/c99/stdint.h
new file mode 100644
index 0000000..7d0cb27
--- /dev/null
+++ b/CoreFoundation/include/c99/stdint.h
@@ -0,0 +1,186 @@
+/* ISO C9x  7.18  Integer types <stdint.h>
+ * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
+ *
+ *  THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ *  Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
+ *
+ *  This source code is offered for use in the public domain. You may
+ *  use, modify or distribute it freely.
+ *
+ *  This code is distributed in the hope that it will be useful but
+ *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ *  DISCLAMED. This includes but is not limited to warranties of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *  Date: 2000-12-02
+ */
+
+
+#ifndef _STDINT_H
+#define _STDINT_H
+
+/* 7.18.1.1  Exact-width integer types */
+typedef signed char int8_t;
+typedef unsigned char   uint8_t;
+typedef short  int16_t;
+typedef unsigned short  uint16_t;
+typedef int  int32_t;
+typedef unsigned   uint32_t;
+typedef __int64  int64_t;
+typedef unsigned __int64   uint64_t;
+
+/* 7.18.1.2  Minimum-width integer types */
+typedef signed char int_least8_t;
+typedef unsigned char   uint_least8_t;
+typedef short  int_least16_t;
+typedef unsigned short  uint_least16_t;
+typedef int  int_least32_t;
+typedef unsigned   uint_least32_t;
+typedef __int64  int_least64_t;
+typedef unsigned __int64   uint_least64_t;
+
+/*  7.18.1.3  Fastest minimum-width integer types 
+ *  Not actually guaranteed to be fastest for all purposes
+ *  Here we use the exact-width types for 8 and 16-bit ints. 
+ */
+typedef char int_fast8_t;
+typedef unsigned char uint_fast8_t;
+typedef short  int_fast16_t;
+typedef unsigned short  uint_fast16_t;
+typedef int  int_fast32_t;
+typedef unsigned  int  uint_fast32_t;
+typedef __int64  int_fast64_t;
+typedef unsigned __int64   uint_fast64_t;
+
+/* 7.18.1.4  Integer types capable of holding object pointers */
+typedef int intptr_t;
+typedef unsigned uintptr_t;
+
+/* 7.18.1.5  Greatest-width integer types */
+typedef __int64  intmax_t;
+typedef unsigned __int64   uintmax_t;
+
+/* 7.18.2  Limits of specified-width integer types */
+#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
+
+/* 7.18.2.1  Limits of exact-width integer types */
+#define INT8_MIN (-128) 
+#define INT16_MIN (-32768)
+#define INT32_MIN (-2147483647 - 1)
+#define INT64_MIN  (-9223372036854775807LL - 1)
+
+#define INT8_MAX 127
+#define INT16_MAX 32767
+#define INT32_MAX 2147483647
+#define INT64_MAX 9223372036854775807LL
+
+#define UINT8_MAX 0xff /* 255U */
+#define UINT16_MAX 0xffff /* 65535U */
+#define UINT32_MAX 0xffffffff  /* 4294967295U */
+#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
+
+/* 7.18.2.2  Limits of minimum-width integer types */
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST64_MIN INT64_MIN
+
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MAX INT64_MAX
+
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+/* 7.18.2.3  Limits of fastest minimum-width integer types */
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST64_MIN INT64_MIN
+
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MAX INT32_MAX
+#define INT_FAST64_MAX INT64_MAX
+
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+/* 7.18.2.4  Limits of integer types capable of holding
+    object pointers */ 
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+
+/* 7.18.2.5  Limits of greatest-width integer types */
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+/* 7.18.3  Limits of other integer types */
+#define PTRDIFF_MIN INT32_MIN
+#define PTRDIFF_MAX INT32_MAX
+
+#define SIG_ATOMIC_MIN INT32_MIN
+#define SIG_ATOMIC_MAX INT32_MAX
+
+//
+//	For SIZE_MAX and other basic limits.
+//
+#include <limits.h>
+//
+//	For WCHAR_MIN and WCHAR_MAX.
+//
+#include <wchar.h>
+
+/*
+ * wint_t is unsigned int in __MINGW32__,
+ * but unsigned short in MS runtime
+ */
+#define WINT_MIN 0
+#define WINT_MAX UINT32_MAX
+
+#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
+
+
+/* 7.18.4  Macros for integer constants */
+#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
+
+/* 7.18.4.1  Macros for minimum-width integer constants
+
+    Accoding to Douglas Gwyn <gwyn@arl.mil>:
+	"This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
+	9899:1999 as initially published, the expansion was required
+	to be an integer constant of precisely matching type, which
+	is impossible to accomplish for the shorter types on most
+	platforms, because C99 provides no standard way to designate
+	an integer constant with width less than that of type int.
+	TC1 changed this to require just an integer constant
+	*expression* with *promoted* type."
+
+	The trick used here is from Clive D W Feather.
+*/
+
+#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val))
+#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val))
+#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val))
+#define INT64_C(val) (INT_LEAST64_MAX-INT_LEAST64_MAX+(val))
+
+#define UINT8_C(val) (UINT_LEAST8_MAX-UINT_LEAST8_MAX+(val))
+#define UINT16_C(val) (UINT_LEAST16_MAX-UINT_LEAST16_MAX+(val))
+#define UINT32_C(val) (UINT_LEAST32_MAX-UINT_LEAST32_MAX+(val))
+#define UINT64_C(val) (UINT_LEAST64_MAX-UINT_LEAST64_MAX+(val))
+
+/* 7.18.4.2  Macros for greatest-width integer constants */
+#define INTMAX_C(val) (INTMAX_MAX-INTMAX_MAX+(val))
+#define UINTMAX_C(val) (UINTMAX_MAX-UINTMAX_MAX+(val))
+
+#endif  /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
+
+#endif
diff --git a/CoreFoundation/include/config.h.in b/CoreFoundation/include/config.h.in
new file mode 100644
index 0000000..5129c0a
--- /dev/null
+++ b/CoreFoundation/include/config.h.in
@@ -0,0 +1,573 @@
+/* include/config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if the `closedir' function returns void instead of `int'. */
+#undef CLOSEDIR_VOID
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <arpa/nameser.h> header file. */
+#undef HAVE_ARPA_NAMESER_H
+
+/* Define to 1 if you have the <assert.h> header file. */
+#undef HAVE_ASSERT_H
+
+/* Define to 1 if your system has a working `chown' function. */
+#undef HAVE_CHOWN
+
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+   */
+#undef HAVE_DECL_TZNAME
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <dns_sd.h> header file. */
+#undef HAVE_DNS_SD_H
+
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `flsl' function. */
+#undef HAVE_FLSL
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Define to 1 if you have the `getcwd' function. */
+#undef HAVE_GETCWD
+
+/* Define to 1 if you have the `getegid' function. */
+#undef HAVE_GETEGID
+
+/* Define to 1 if you have the `geteuid' function. */
+#undef HAVE_GETEUID
+
+/* Define to 1 if you have the `getgid' function. */
+#undef HAVE_GETGID
+
+/* Define to 1 if you have the `gethostname' function. */
+#undef HAVE_GETHOSTNAME
+
+/* Define to 1 if you have the `getpagesize' function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define to 1 if you have the `getpid' function. */
+#undef HAVE_GETPID
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the `getuid' function. */
+#undef HAVE_GETUID
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `dl' library (-ldl). */
+#undef HAVE_LIBDL
+
+/* Define to 1 if you have the `m' library (-lm). */
+#undef HAVE_LIBM
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+#undef HAVE_LIBRT
+
+/* Define to 1 if you have the `uuid' library (-luuid). */
+#undef HAVE_LIBUUID
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define to 1 if you have the `lstat' function. */
+#undef HAVE_LSTAT
+
+/* Define to 1 if you have the `malloc' function. */
+#undef HAVE_MALLOC
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define to 1 if you have the <malloc/malloc.h> header file. */
+#undef HAVE_MALLOC_MALLOC_H
+
+/* Define to 1 if you have the <math.h> header file. */
+#undef HAVE_MATH_H
+
+/* Define to 1 if you have the `memchr' function. */
+#undef HAVE_MEMCHR
+
+/* Define to 1 if you have the `memcmp' function. */
+#undef HAVE_MEMCMP
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `mkdir' function. */
+#undef HAVE_MKDIR
+
+/* Define to 1 if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define to 1 if you have the `munmap' function. */
+#undef HAVE_MUNMAP
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <objc/objc.h> header file. */
+#undef HAVE_OBJC_OBJC_H
+
+/* Define to 1 if you have the <objc/runtime.h> header file. */
+#undef HAVE_OBJC_RUNTIME_H
+
+/* Define to 1 if you have the <poll.h> header file. */
+#undef HAVE_POLL_H
+
+/* Define if you have POSIX threads libraries and header files. */
+#undef HAVE_PTHREAD
+
+/* Define to 1 if you have the <pwd.h> header file. */
+#undef HAVE_PWD_H
+
+/* Define to 1 if you have the `readlink' function. */
+#undef HAVE_READLINK
+
+/* Define to 1 if you have the `realloc' function. */
+#undef HAVE_REALLOC
+
+/* Define to 1 if you have the `rint' function. */
+#undef HAVE_RINT
+
+/* Define to 1 if you have the `rmdir' function. */
+#undef HAVE_RMDIR
+
+/* Define to 1 if you have the `select' function. */
+#undef HAVE_SELECT
+
+/* Define to 1 if you have the <semaphore.h> header file. */
+#undef HAVE_SEMAPHORE_H
+
+/* Define to 1 if you have the `setenv' function. */
+#undef HAVE_SETENV
+
+/* Define to 1 if you have the <setjmp.h> header file. */
+#undef HAVE_SETJMP_H
+
+/* Define to 1 if you have the <signal.h> header file. */
+#undef HAVE_SIGNAL_H
+
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
+/* Define to 1 if you have the `socket' function. */
+#undef HAVE_SOCKET
+
+/* Define to 1 if you have the `stat' function. */
+#undef HAVE_STAT
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#undef HAVE_STDARG_H
+
+/* Define to 1 if you have the <stdbool.h> header file. */
+#undef HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strncat' function. */
+#undef HAVE_STRNCAT
+
+/* Define to 1 if you have the `strncmp' function. */
+#undef HAVE_STRNCMP
+
+/* Define to 1 if you have the `strncpy' function. */
+#undef HAVE_STRNCPY
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Define to 1 if you have the `strtod' function. */
+#undef HAVE_STRTOD
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if you have the `strtoul' function. */
+#undef HAVE_STRTOUL
+
+/* Define to 1 if `tm_zone' is member of `struct tm'. */
+#undef HAVE_STRUCT_TM_TM_ZONE
+
+/* Define to 1 if you have the `symlink' function. */
+#undef HAVE_SYMLINK
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#undef HAVE_SYSLOG_H
+
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#undef HAVE_SYS_CDEFS_H
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/errno.h> header file. */
+#undef HAVE_SYS_ERRNO_H
+
+/* Define to 1 if you have the <sys/fcntl.h> header file. */
+#undef HAVE_SYS_FCNTL_H
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#undef HAVE_SYS_UIO_H
+
+/* Define to 1 if you have the <time.h> header file. */
+#undef HAVE_TIME_H
+
+/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
+   `HAVE_STRUCT_TM_TM_ZONE' instead. */
+#undef HAVE_TM_ZONE
+
+/* Define to 1 if you don't have `tm_zone' but do have the external array
+   `tzname'. */
+#undef HAVE_TZNAME
+
+/* Define to 1 if you have the <unicode/putil.h> header file. */
+#undef HAVE_UNICODE_PUTIL_H
+
+/* Define to 1 if you have the <unicode/ucal.h> header file. */
+#undef HAVE_UNICODE_UCAL_H
+
+/* Define to 1 if you have the <unicode/ucol.h> header file. */
+#undef HAVE_UNICODE_UCOL_H
+
+/* Define to 1 if you have the <unicode/ucurr.h> header file. */
+#undef HAVE_UNICODE_UCURR_H
+
+/* Define to 1 if you have the <unicode/udat.h> header file. */
+#undef HAVE_UNICODE_UDAT_H
+
+/* Define to 1 if you have the <unicode/ulocdata.h> header file. */
+#undef HAVE_UNICODE_ULOCDATA_H
+
+/* Define to 1 if you have the <unicode/uloc.h> header file. */
+#undef HAVE_UNICODE_ULOC_H
+
+/* Define to 1 if you have the <unicode/umsg.h> header file. */
+#undef HAVE_UNICODE_UMSG_H
+
+/* Define to 1 if you have the <unicode/unum.h> header file. */
+#undef HAVE_UNICODE_UNUM_H
+
+/* Define to 1 if you have the <unicode/uset.h> header file. */
+#undef HAVE_UNICODE_USET_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `ustrncasecmp' function. */
+#undef HAVE_USTRNCASECMP
+
+/* Define to 1 if you have the `ustrncmp' function. */
+#undef HAVE_USTRNCMP
+
+/* Define to 1 if you have the <uuid/uuid.h> header file. */
+#undef HAVE_UUID_UUID_H
+
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
+/* Define to 1 if you have the <xlocale.h> header file. */
+#undef HAVE_XLOCALE_H
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Define this if your target compiler supports __sync_bool_compare_and_swap
+   */
+#undef HAVE___SYNC_BOOL_COMPARE_AND_SWAP
+
+/* Define this if your target compiler supports __sync_fetch_and_add */
+#undef HAVE___SYNC_FETCH_AND_ADD
+
+/* Define this if your target compiler supports __sync_synchronize */
+#undef HAVE___SYNC_SYNCHRONIZE
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+   your system. */
+#undef PTHREAD_CREATE_JOINABLE
+
+/* Define to the type of arg 1 for `select'. */
+#undef SELECT_TYPE_ARG1
+
+/* Define to the type of args 2, 3 and 4 for `select'. */
+#undef SELECT_TYPE_ARG234
+
+/* Define to the type of arg 5 for `select'. */
+#undef SELECT_TYPE_ARG5
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Define this to the location of the default local time zone data file (e.g.
+   /etc/localtime) on the target system. */
+#undef TZDEFAULT
+
+/* Define this to the location of the time zone data files (e.g.
+   /usr/share/zoneinfo) on the target system. */
+#undef TZDIR
+
+/* Version number of package */
+#undef VERSION
+
+/* Enable BSD extensions on systems that have them.  */
+#ifndef _BSD_SOURCE
+# undef _BSD_SOURCE
+#endif
+
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT64_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT8_T
+
+/* Define to 1 if type `char' is unsigned and you are not using gcc.  */
+#ifndef __CHAR_UNSIGNED__
+# undef __CHAR_UNSIGNED__
+#endif
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef gid_t
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to the type of a signed integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int16_t
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int32_t
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int64_t
+
+/* Define to the type of a signed integer type of width exactly 8 bits if such
+   a type exists and the standard includes do not define it. */
+#undef int8_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
+/* Define to `long int' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
+/* Define to equivalent of C99 restrict keyword, or to nothing if this is not
+   supported. Do not define if restrict is supported directly. */
+#undef restrict
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef ssize_t
+
+/* Define this if the target system has strncat but not strlcat. */
+#undef strlcat
+
+/* Define this if the target system has strncpy but not strlcpy. */
+#undef strlcpy
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef uid_t
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint16_t
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint64_t
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint8_t
+
+/* Define as `fork' if `vfork' does not work. */
+#undef vfork
+
+/* Define to empty if the keyword `volatile' does not work. Warning: valid
+   code using `volatile' can become incorrect without. Disable with care. */
+#undef volatile
diff --git a/CoreFoundation/include/mach_support/bootstrap_priv.h b/CoreFoundation/include/mach_support/bootstrap_priv.h
new file mode 100644
index 0000000..2dcac7b
--- /dev/null
+++ b/CoreFoundation/include/mach_support/bootstrap_priv.h
@@ -0,0 +1,46 @@
+#ifndef _BOOTSTRAP_PRIVATE_H_
+#define _BOOTSTRAP_PRIVATE_H_
+/*
+ * Copyright (c) 2007 Apple Inc. All rights reserved.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_START@
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @APPLE_APACHE_LICENSE_HEADER_END@
+ */
+
+#include <servers/bootstrap.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+#pragma GCC visibility push(default)
+
+#define BOOTSTRAP_PER_PID_SERVICE	0x1
+#define BOOTSTRAP_ALLOW_LOOKUP		0x2
+#define BOOTSTRAP_DENY_JOB_CREATION	0x4
+
+kern_return_t bootstrap_register2(mach_port_t bp, name_t service_name, mach_port_t sp, uint64_t flags);
+
+kern_return_t bootstrap_look_up2(mach_port_t bp, name_t service_name, mach_port_t *sp, pid_t target_pid, uint64_t flags);
+
+kern_return_t bootstrap_look_up_per_user(mach_port_t bp, name_t service_name, uid_t target_user, mach_port_t *sp);
+
+kern_return_t bootstrap_set_policy(mach_port_t bp, pid_t target_pid, uint64_t flags, const char *target_service);
+
+#pragma GCC visibility pop
+
+__END_DECLS
+
+#endif
diff --git a/CoreFoundation/include/mach_support/vproc_priv.h b/CoreFoundation/include/mach_support/vproc_priv.h
new file mode 100644
index 0000000..991ceb0
--- /dev/null
+++ b/CoreFoundation/include/mach_support/vproc_priv.h
@@ -0,0 +1,82 @@
+#ifndef _VPROC_PRIVATE_H_
+#define _VPROC_PRIVATE_H_
+/*
+ * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_START@
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @APPLE_APACHE_LICENSE_HEADER_END@
+ */
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <sys/syslog.h>
+#include <sys/time.h>
+#include <stdbool.h>
+#include <launch.h>
+
+__BEGIN_DECLS
+
+#pragma GCC visibility push(default)
+
+/* DO NOT use this. This is a hack for launchctl */
+#define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C
+
+typedef enum {
+	VPROC_GSK_LAST_EXIT_STATUS = 1,
+	VPROC_GSK_GLOBAL_ON_DEMAND,
+	VPROC_GSK_MGR_UID,
+	VPROC_GSK_MGR_PID,
+	VPROC_GSK_IS_MANAGED,
+	VPROC_GSK_BASIC_KEEPALIVE,
+	VPROC_GSK_START_INTERVAL,
+	VPROC_GSK_IDLE_TIMEOUT,
+	VPROC_GSK_EXIT_TIMEOUT,
+	VPROC_GSK_ENVIRONMENT,
+	VPROC_GSK_ALLJOBS,
+	VPROC_GSK_GLOBAL_LOG_MASK,
+	VPROC_GSK_GLOBAL_UMASK,
+} vproc_gsk_t;
+
+vproc_err_t vproc_swap_integer(vproc_t vp, vproc_gsk_t key, int64_t *inval, int64_t *outval);
+vproc_err_t vproc_swap_complex(vproc_t vp, vproc_gsk_t key, launch_data_t inval, launch_data_t *outval);
+
+vproc_err_t _vproc_get_last_exit_status(int *wstatus);
+vproc_err_t _vproc_set_global_on_demand(bool val);
+
+typedef void (*_vprocmgr_log_drain_callback_t)(struct timeval *when, pid_t from_pid, pid_t about_pid, uid_t sender_uid, gid_t sender_gid, int priority, const char *from_name, const char *about_name, const char *session_name, const char *msg);
+
+vproc_err_t _vprocmgr_log_drain(vproc_t vp, pthread_mutex_t *optional_mutex_around_callback, _vprocmgr_log_drain_callback_t func);
+
+vproc_err_t _vproc_send_signal_by_label(const char *label, int sig);
+vproc_err_t _vproc_kickstart_by_label(const char *label, pid_t *out_pid, mach_port_t *out_port_name);
+vproc_err_t _vproc_wait_by_label(const char *label, int *out_wstatus);
+
+void _vproc_log(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3)));
+void _vproc_log_error(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3)));
+
+#define VPROCMGR_SESSION_LOGINWINDOW	"LoginWindow"
+#define VPROCMGR_SESSION_BACKGROUND	"Background"
+#define VPROCMGR_SESSION_AQUA		"Aqua"
+#define VPROCMGR_SESSION_STANDARDIO	"StandardIO"
+#define VPROCMGR_SESSION_SYSTEM		"System"
+
+vproc_err_t _vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type);
+
+#pragma GCC visibility pop
+
+__END_DECLS
+
+#endif
diff --git a/CoreFoundation/m4/acinclude.m4 b/CoreFoundation/m4/acinclude.m4
new file mode 100644
index 0000000..ea8717e
--- /dev/null
+++ b/CoreFoundation/m4/acinclude.m4
@@ -0,0 +1,36 @@
+# CF_BSD_SOURCE
+# --------------
+AC_DEFUN([CF_BSD_SOURCE],
+[AH_VERBATIM([_BSD_SOURCE],
+[/* Enable BSD extensions on systems that have them.  */
+#ifndef _BSD_SOURCE
+# undef _BSD_SOURCE
+#endif])dnl
+AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
+AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
+AC_DEFINE([_BSD_SOURCE])
+])
+
+# CF_REPLACE_STRLN_FUNC(SUFFIX...)
+#
+# Determine whether one or both of strl<suffix> and strn<suffix> exist
+# and then how to handle their presence or absence accordingly.
+# --------------------------------------------------------------------
+AC_DEFUN([CF_REPLACE_STRLN_FUNC],
+[
+AC_REQUIRE([AC_CHECK_FUNCS])
+AC_REQUIRE([AC_REPLACE_FUNCS])
+AC_CHECK_FUNCS([strl$1 strn$1])
+if test "x${ac_cv_func_strl$1}" = "xno"; then
+	AC_MSG_CHECKING([how to handle missing strl$1])
+	if test "x${ac_cv_func_strn$1}" = "xyes"; then
+		AC_MSG_RESULT([mapped to strn$1])
+		AC_DEFINE([strl$1],
+			  [strn$1],
+			  [Define this if the target system has strn$1 but not strl$1.])
+	else
+		AC_MSG_RESULT([using local implementation])
+		AC_REPLACE_FUNCS([strl$1])
+	fi
+fi
+])
diff --git a/CoreFoundation/macosx/CFLite.xcodeproj/project.pbxproj b/CoreFoundation/macosx/CFLite.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..cd3439e
--- /dev/null
+++ b/CoreFoundation/macosx/CFLite.xcodeproj/project.pbxproj
@@ -0,0 +1,1649 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 45;
+	objects = {
+
+/* Begin PBXAggregateTarget section */
+		84129FDA0F3A4E5400A64427 /* make_target_paths */ = {
+			isa = PBXAggregateTarget;
+			buildConfigurationList = 84129FDD0F3A4E9D00A64427 /* Build configuration list for PBXAggregateTarget "make_target_paths" */;
+			buildPhases = (
+				84129FDF0F3A4EA900A64427 /* ShellScript */,
+			);
+			dependencies = (
+			);
+			name = make_target_paths;
+			productName = make_target_paths;
+		};
+/* End PBXAggregateTarget section */
+
+/* Begin PBXBuildFile section */
+		84129F7B0F3A4C2600A64427 /* CFArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55DF0ECFAF5E003D696F /* CFArray.h */; };
+		84129F7C0F3A4C2600A64427 /* CFBag.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55E00ECFAF5E003D696F /* CFBag.h */; };
+		84129F7D0F3A4C2600A64427 /* CFBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55E10ECFAF5E003D696F /* CFBase.h */; };
+		84129F7E0F3A4C2600A64427 /* CFBinaryHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55E20ECFAF5E003D696F /* CFBinaryHeap.h */; };
+		84129F7F0F3A4C2600A64427 /* CFBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55E30ECFAF5E003D696F /* CFBitVector.h */; };
+		84129F800F3A4C2600A64427 /* CFBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55E40ECFAF5E003D696F /* CFBundle.h */; };
+		84129F810F3A4C2600A64427 /* CFByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55E80ECFAF5E003D696F /* CFByteOrder.h */; };
+		84129F820F3A4C2600A64427 /* CFCalendar.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55E90ECFAF5E003D696F /* CFCalendar.h */; };
+		84129F830F3A4C2600A64427 /* CFCharacterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55EA0ECFAF5E003D696F /* CFCharacterSet.h */; };
+		84129F840F3A4C2600A64427 /* CFData.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55EC0ECFAF5E003D696F /* CFData.h */; };
+		84129F850F3A4C2600A64427 /* CFDate.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55ED0ECFAF5E003D696F /* CFDate.h */; };
+		84129F860F3A4C2600A64427 /* CFDateFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55EE0ECFAF5E003D696F /* CFDateFormatter.h */; };
+		84129F870F3A4C2600A64427 /* CFDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55EF0ECFAF5E003D696F /* CFDictionary.h */; };
+		84129F880F3A4C2600A64427 /* CFError.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55F00ECFAF5E003D696F /* CFError.h */; };
+		84129F890F3A4C2600A64427 /* CFLocale.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55F30ECFAF5E003D696F /* CFLocale.h */; };
+		84129F8A0F3A4C2600A64427 /* CFMachPort.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55F50ECFAF5E003D696F /* CFMachPort.h */; };
+		84129F8B0F3A4C2600A64427 /* CFMessagePort.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55F60ECFAF5E003D696F /* CFMessagePort.h */; };
+		84129F8C0F3A4C2600A64427 /* CFNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55F70ECFAF5E003D696F /* CFNumber.h */; };
+		84129F8D0F3A4C2600A64427 /* CFNumberFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55F80ECFAF5E003D696F /* CFNumberFormatter.h */; };
+		84129F8E0F3A4C2600A64427 /* CFPlugIn.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55F90ECFAF5E003D696F /* CFPlugIn.h */; };
+		84129F8F0F3A4C2600A64427 /* CFPlugInCOM.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55FB0ECFAF5E003D696F /* CFPlugInCOM.h */; };
+		84129F900F3A4C2600A64427 /* CFPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55FC0ECFAF5E003D696F /* CFPreferences.h */; };
+		84129F910F3A4C2600A64427 /* CFPropertyList.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55FE0ECFAF5E003D696F /* CFPropertyList.h */; };
+		84129F920F3A4C2600A64427 /* CFRunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55FF0ECFAF5E003D696F /* CFRunLoop.h */; };
+		84129F930F3A4C2600A64427 /* CFSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B56020ECFAF5E003D696F /* CFSet.h */; };
+		84129F940F3A4C2600A64427 /* CFSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B56030ECFAF5E003D696F /* CFSocket.h */; };
+		84129F950F3A4C2600A64427 /* CFStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B56050ECFAF5E003D696F /* CFStream.h */; };
+		84129F960F3A4C2600A64427 /* CFString.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B56090ECFAF5E003D696F /* CFString.h */; };
+		84129F970F3A4C2600A64427 /* CFStringEncodingExt.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B560E0ECFAF5E003D696F /* CFStringEncodingExt.h */; };
+		84129F980F3A4C2600A64427 /* CFTimeZone.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B560F0ECFAF5E003D696F /* CFTimeZone.h */; };
+		84129F990F3A4C2600A64427 /* CFTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B56100ECFAF5E003D696F /* CFTree.h */; };
+		84129F9A0F3A4C2600A64427 /* CFURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55C80ECFAF07003D696F /* CFURL.h */; };
+		84129F9B0F3A4C2600A64427 /* CFURLAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55C90ECFAF07003D696F /* CFURLAccess.h */; };
+		84129F9C0F3A4C2600A64427 /* CFUserNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55CA0ECFAF07003D696F /* CFUserNotification.h */; };
+		84129F9D0F3A4C2600A64427 /* CFUUID.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55CB0ECFAF07003D696F /* CFUUID.h */; };
+		84129F9E0F3A4C2600A64427 /* CFXMLNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55CD0ECFAF07003D696F /* CFXMLNode.h */; };
+		84129F9F0F3A4C2600A64427 /* CFXMLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55CE0ECFAF07003D696F /* CFXMLParser.h */; };
+		84129FA00F3A4C2600A64427 /* CoreFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 848B55CF0ECFAF07003D696F /* CoreFoundation.h */; };
+		841BE8470F395D91001F2A66 /* StringExample.c in Sources */ = {isa = PBXBuildFile; fileRef = 841BE83B0F395D3E001F2A66 /* StringExample.c */; };
+		841BE9230F395FB4001F2A66 /* AllocatorExample.c in Sources */ = {isa = PBXBuildFile; fileRef = 841BE91A0F395F65001F2A66 /* AllocatorExample.c */; };
+		841BE9250F395FBE001F2A66 /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+		8448EF6C0ED2798800716715 /* CFApplicationPreferences.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55480ECFAE4D003D696F /* CFApplicationPreferences.c */; };
+		8448EF6D0ED2798800716715 /* CFArray.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55490ECFAE4D003D696F /* CFArray.c */; };
+		8448EF6E0ED2798800716715 /* CFBag.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B554A0ECFAE4D003D696F /* CFBag.c */; };
+		8448EF6F0ED2798800716715 /* CFBase.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B554B0ECFAE4D003D696F /* CFBase.c */; };
+		8448EF700ED2798800716715 /* CFBinaryHeap.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B554C0ECFAE4D003D696F /* CFBinaryHeap.c */; };
+		8448EF710ED2798800716715 /* CFBinaryPList.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B554D0ECFAE4D003D696F /* CFBinaryPList.c */; };
+		8448EF720ED2798800716715 /* CFBitVector.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B554E0ECFAE4D003D696F /* CFBitVector.c */; };
+		8448EF730ED2798800716715 /* CFBuiltinConverters.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B554F0ECFAE4D003D696F /* CFBuiltinConverters.c */; };
+		8448EF740ED2798800716715 /* CFBundle.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55500ECFAE4D003D696F /* CFBundle.c */; };
+		8448EF750ED2798800716715 /* CFBundle_Resources.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55510ECFAE4D003D696F /* CFBundle_Resources.c */; };
+		8448EF760ED2798800716715 /* CFCalendar.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55520ECFAE4D003D696F /* CFCalendar.c */; };
+		8448EF770ED2798800716715 /* CFCharacterSet.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55530ECFAE4D003D696F /* CFCharacterSet.c */; };
+		8448EF780ED2798800716715 /* CFConcreteStreams.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55540ECFAE4D003D696F /* CFConcreteStreams.c */; };
+		8448EF790ED2798800716715 /* CFData.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55550ECFAE4D003D696F /* CFData.c */; };
+		8448EF7A0ED2798800716715 /* CFDate.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55560ECFAE4D003D696F /* CFDate.c */; };
+		8448EF7B0ED2798800716715 /* CFDateFormatter.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55570ECFAE4D003D696F /* CFDateFormatter.c */; };
+		8448EF7C0ED2798800716715 /* CFDictionary.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55580ECFAE4D003D696F /* CFDictionary.c */; };
+		8448EF7D0ED2798800716715 /* CFError.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55590ECFAE4D003D696F /* CFError.c */; };
+		8448EF7E0ED2798800716715 /* CFFileUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B555A0ECFAE4D003D696F /* CFFileUtilities.c */; };
+		8448EF7F0ED2798800716715 /* CFLocale.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B555B0ECFAE4D003D696F /* CFLocale.c */; };
+		8448EF800ED2798800716715 /* CFLocaleIdentifier.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B555C0ECFAE4D003D696F /* CFLocaleIdentifier.c */; };
+		8448EF810ED2798800716715 /* CFMachPort.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B555D0ECFAE4D003D696F /* CFMachPort.c */; };
+		8448EF820ED2798800716715 /* CFMessagePort.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B555E0ECFAE4D003D696F /* CFMessagePort.c */; };
+		8448EF830ED2798800716715 /* CFNumber.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B555F0ECFAE4D003D696F /* CFNumber.c */; };
+		8448EF840ED2798800716715 /* CFNumberFormatter.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55600ECFAE4D003D696F /* CFNumberFormatter.c */; };
+		8448EF850ED2798800716715 /* CFPlatform.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55610ECFAE4D003D696F /* CFPlatform.c */; };
+		8448EF860ED2798800716715 /* CFPlugIn.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55620ECFAE4D003D696F /* CFPlugIn.c */; };
+		8448EF870ED2798800716715 /* CFPlugIn_Factory.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55630ECFAE4D003D696F /* CFPlugIn_Factory.c */; };
+		8448EF880ED2798800716715 /* CFPlugIn_Instance.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55640ECFAE4D003D696F /* CFPlugIn_Instance.c */; };
+		8448EF890ED2798800716715 /* CFPlugIn_PlugIn.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55650ECFAE4D003D696F /* CFPlugIn_PlugIn.c */; };
+		8448EF8A0ED2798800716715 /* CFPreferences.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55660ECFAE4D003D696F /* CFPreferences.c */; };
+		8448EF8B0ED2798800716715 /* CFPropertyList.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55670ECFAE4D003D696F /* CFPropertyList.c */; };
+		8448EF8C0ED2798800716715 /* CFRunLoop.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55680ECFAE4D003D696F /* CFRunLoop.c */; };
+		8448EF8D0ED2798800716715 /* CFRuntime.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55690ECFAE4D003D696F /* CFRuntime.c */; };
+		8448EF8E0ED2798800716715 /* CFSet.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B556A0ECFAE4D003D696F /* CFSet.c */; };
+		8448EF8F0ED2798800716715 /* CFSocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B556B0ECFAE4D003D696F /* CFSocket.c */; };
+		8448EF900ED2798800716715 /* CFSocketStream.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B556C0ECFAE4D003D696F /* CFSocketStream.c */; };
+		8448EF910ED2798800716715 /* CFSortFunctions.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B56440ECFAF6E003D696F /* CFSortFunctions.c */; };
+		8448EF920ED2798800716715 /* CFStorage.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B556D0ECFAE4D003D696F /* CFStorage.c */; };
+		8448EF930ED2798800716715 /* CFStream.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B556E0ECFAE4D003D696F /* CFStream.c */; };
+		8448EF940ED2798800716715 /* CFString.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B556F0ECFAE4D003D696F /* CFString.c */; };
+		8448EF950ED2798800716715 /* CFStringEncodingConverter.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55700ECFAE4D003D696F /* CFStringEncodingConverter.c */; };
+		8448EF960ED2798800716715 /* CFStringEncodings.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55710ECFAE4D003D696F /* CFStringEncodings.c */; };
+		8448EF970ED2798800716715 /* CFStringScanner.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55720ECFAE4D003D696F /* CFStringScanner.c */; };
+		8448EF980ED2798800716715 /* CFStringUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55730ECFAE4D003D696F /* CFStringUtilities.c */; };
+		8448EF990ED2798800716715 /* CFSystemDirectories.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55740ECFAE4D003D696F /* CFSystemDirectories.c */; };
+		8448EF9A0ED2798800716715 /* CFTimeZone.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55750ECFAE4D003D696F /* CFTimeZone.c */; };
+		8448EF9B0ED2798800716715 /* CFTree.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55760ECFAE4D003D696F /* CFTree.c */; };
+		8448EF9C0ED2798800716715 /* CFUniChar.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55770ECFAE4D003D696F /* CFUniChar.c */; };
+		8448EF9D0ED2798800716715 /* CFUnicodeDecomposition.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55780ECFAE4D003D696F /* CFUnicodeDecomposition.c */; };
+		8448EF9E0ED2798800716715 /* CFUnicodePrecomposition.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55790ECFAE4D003D696F /* CFUnicodePrecomposition.c */; };
+		8448EF9F0ED2798800716715 /* CFURL.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B557A0ECFAE4D003D696F /* CFURL.c */; };
+		8448EFA00ED2798800716715 /* CFURLAccess.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B557B0ECFAE4D003D696F /* CFURLAccess.c */; };
+		8448EFA10ED2798800716715 /* CFUserNotification.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B557C0ECFAE4D003D696F /* CFUserNotification.c */; };
+		8448EFA20ED2798800716715 /* CFUtilities.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B557D0ECFAE4D003D696F /* CFUtilities.c */; };
+		8448EFA30ED2798800716715 /* CFUUID.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B557E0ECFAE4D003D696F /* CFUUID.c */; };
+		8448EFA40ED2798800716715 /* CFVersion.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B557F0ECFAE4D003D696F /* CFVersion.c */; };
+		8448EFA50ED2798800716715 /* CFXMLInputStream.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55800ECFAE4D003D696F /* CFXMLInputStream.c */; };
+		8448EFA60ED2798800716715 /* CFXMLNode.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55810ECFAE4D003D696F /* CFXMLNode.c */; };
+		8448EFA70ED2798800716715 /* CFXMLParser.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55820ECFAE4D003D696F /* CFXMLParser.c */; };
+		8448EFA80ED2798800716715 /* CFXMLPreferencesDomain.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55830ECFAE4D003D696F /* CFXMLPreferencesDomain.c */; };
+		8448EFA90ED2798800716715 /* CFXMLTree.c in Sources */ = {isa = PBXBuildFile; fileRef = 848B55840ECFAE4D003D696F /* CFXMLTree.c */; };
+		844949890ED27EDF00EEB9C0 /* WritePListExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840CBF6C0ED24F4500931057 /* WritePListExample.cpp */; };
+		844949A20ED27F3100EEB9C0 /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+		844949A40ED27F8500EEB9C0 /* ReadPListExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 844949A30ED27F8500EEB9C0 /* ReadPListExample.cpp */; };
+		844F5D5A0F3FB23100239823 /* DNSServiceMetaQuery.c in Sources */ = {isa = PBXBuildFile; fileRef = 844F5D590F3FB23100239823 /* DNSServiceMetaQuery.c */; };
+		844F5D5E0F3FB24E00239823 /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+		845EDB370ED3374D0033E001 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 845EDB360ED3374D0033E001 /* Info.plist */; };
+		8466FDA90F4F42DF009FA7BA /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8466FDA80F4F42DF009FA7BA /* libobjc.dylib */; };
+		8466FDAC0F4F42F7009FA7BA /* libicucore.A.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8466FDAB0F4F42F7009FA7BA /* libicucore.A.dylib */; };
+		8481BA510F3EA6AB00BD5189 /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+		8481BA540F3EA6C800BD5189 /* DisplayURL.c in Sources */ = {isa = PBXBuildFile; fileRef = 8481BA460F3EA68A00BD5189 /* DisplayURL.c */; };
+		8481BA810F3EB2D300BD5189 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8481BA800F3EB2D300BD5189 /* CoreServices.framework */; };
+		84915D510F4B5CEA00A3C0DD /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+		84915D540F4B5D0500A3C0DD /* CFRunLoopTimerExample.c in Sources */ = {isa = PBXBuildFile; fileRef = 84915D530F4B5D0500A3C0DD /* CFRunLoopTimerExample.c */; };
+		84CD60F50F4A04530049B4EC /* SimpleWebServer.c in Sources */ = {isa = PBXBuildFile; fileRef = 84CD60D00F4A030E0049B4EC /* SimpleWebServer.c */; };
+		84DA17230EDDF47100B6A2E6 /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+		84DA17270EDDF47E00B6A2E6 /* date_test.c in Sources */ = {isa = PBXBuildFile; fileRef = 84DA170D0EDDEEEE00B6A2E6 /* date_test.c */; };
+		84DE4E550ED287D40023DFE2 /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+		84F19F470F50FAC70092A274 /* CFLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8448EF670ED2796500716715 /* CFLite.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+		84129FE00F3A4EC700A64427 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 84129FDA0F3A4E5400A64427;
+			remoteInfo = make_target_paths;
+		};
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+		840CBF6C0ED24F4500931057 /* WritePListExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WritePListExample.cpp; path = ../examples/WritePListExample/WritePListExample.cpp; sourceTree = SOURCE_ROOT; };
+		84129F440F38C0BD00A64427 /* vproc_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vproc_priv.h; path = ../include/mach_support/vproc_priv.h; sourceTree = SOURCE_ROOT; };
+		84129F460F38C0CF00A64427 /* bootstrap_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bootstrap_priv.h; path = ../include/mach_support/bootstrap_priv.h; sourceTree = SOURCE_ROOT; };
+		841BE83B0F395D3E001F2A66 /* StringExample.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = StringExample.c; path = ../examples/StringExample/StringExample.c; sourceTree = SOURCE_ROOT; };
+		841BE8400F395D5A001F2A66 /* StringExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = StringExample; sourceTree = BUILT_PRODUCTS_DIR; };
+		841BE91A0F395F65001F2A66 /* AllocatorExample.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = AllocatorExample.c; path = ../examples/Allocator/AllocatorExample.c; sourceTree = SOURCE_ROOT; };
+		841BE91F0F395F8E001F2A66 /* AllocatorExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = AllocatorExample; sourceTree = BUILT_PRODUCTS_DIR; };
+		8448EF670ED2796500716715 /* CFLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CFLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		844949820ED27E8700EEB9C0 /* WritePListExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = WritePListExample; sourceTree = BUILT_PRODUCTS_DIR; };
+		844949920ED27F1100EEB9C0 /* ReadPListExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ReadPListExample; sourceTree = BUILT_PRODUCTS_DIR; };
+		844949A30ED27F8500EEB9C0 /* ReadPListExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ReadPListExample.cpp; path = ../examples/ReadPListExample/ReadPListExample.cpp; sourceTree = SOURCE_ROOT; };
+		844F5D540F3FB1F600239823 /* DNSMetaServiceQuery */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DNSMetaServiceQuery; sourceTree = BUILT_PRODUCTS_DIR; };
+		844F5D590F3FB23100239823 /* DNSServiceMetaQuery.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = DNSServiceMetaQuery.c; path = ../examples/DNSServiceMetaQuery/DNSServiceMetaQuery.c; sourceTree = SOURCE_ROOT; };
+		845EDB360ED3374D0033E001 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Info.plist; sourceTree = SOURCE_ROOT; };
+		8466FDA80F4F42DF009FA7BA /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
+		8466FDAB0F4F42F7009FA7BA /* libicucore.A.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.A.dylib; path = /usr/lib/libicucore.A.dylib; sourceTree = "<absolute>"; };
+		8481BA460F3EA68A00BD5189 /* DisplayURL.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = DisplayURL.c; path = ../examples/DisplayURL/DisplayURL.c; sourceTree = SOURCE_ROOT; };
+		8481BA4B0F3EA69C00BD5189 /* DisplayURL */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DisplayURL; sourceTree = BUILT_PRODUCTS_DIR; };
+		8481BA800F3EB2D300BD5189 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
+		848B55480ECFAE4D003D696F /* CFApplicationPreferences.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFApplicationPreferences.c; path = ../CFApplicationPreferences.c; sourceTree = SOURCE_ROOT; };
+		848B55490ECFAE4D003D696F /* CFArray.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFArray.c; path = ../CFArray.c; sourceTree = SOURCE_ROOT; };
+		848B554A0ECFAE4D003D696F /* CFBag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBag.c; path = ../CFBag.c; sourceTree = SOURCE_ROOT; };
+		848B554B0ECFAE4D003D696F /* CFBase.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBase.c; path = ../CFBase.c; sourceTree = SOURCE_ROOT; };
+		848B554C0ECFAE4D003D696F /* CFBinaryHeap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBinaryHeap.c; path = ../CFBinaryHeap.c; sourceTree = SOURCE_ROOT; };
+		848B554D0ECFAE4D003D696F /* CFBinaryPList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBinaryPList.c; path = ../CFBinaryPList.c; sourceTree = SOURCE_ROOT; };
+		848B554E0ECFAE4D003D696F /* CFBitVector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBitVector.c; path = ../CFBitVector.c; sourceTree = SOURCE_ROOT; };
+		848B554F0ECFAE4D003D696F /* CFBuiltinConverters.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBuiltinConverters.c; path = ../CFBuiltinConverters.c; sourceTree = SOURCE_ROOT; };
+		848B55500ECFAE4D003D696F /* CFBundle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBundle.c; path = ../CFBundle.c; sourceTree = SOURCE_ROOT; };
+		848B55510ECFAE4D003D696F /* CFBundle_Resources.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFBundle_Resources.c; path = ../CFBundle_Resources.c; sourceTree = SOURCE_ROOT; };
+		848B55520ECFAE4D003D696F /* CFCalendar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFCalendar.c; path = ../CFCalendar.c; sourceTree = SOURCE_ROOT; };
+		848B55530ECFAE4D003D696F /* CFCharacterSet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFCharacterSet.c; path = ../CFCharacterSet.c; sourceTree = SOURCE_ROOT; };
+		848B55540ECFAE4D003D696F /* CFConcreteStreams.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFConcreteStreams.c; path = ../CFConcreteStreams.c; sourceTree = SOURCE_ROOT; };
+		848B55550ECFAE4D003D696F /* CFData.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFData.c; path = ../CFData.c; sourceTree = SOURCE_ROOT; };
+		848B55560ECFAE4D003D696F /* CFDate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFDate.c; path = ../CFDate.c; sourceTree = SOURCE_ROOT; };
+		848B55570ECFAE4D003D696F /* CFDateFormatter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFDateFormatter.c; path = ../CFDateFormatter.c; sourceTree = SOURCE_ROOT; };
+		848B55580ECFAE4D003D696F /* CFDictionary.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFDictionary.c; path = ../CFDictionary.c; sourceTree = SOURCE_ROOT; };
+		848B55590ECFAE4D003D696F /* CFError.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFError.c; path = ../CFError.c; sourceTree = SOURCE_ROOT; };
+		848B555A0ECFAE4D003D696F /* CFFileUtilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFFileUtilities.c; path = ../CFFileUtilities.c; sourceTree = SOURCE_ROOT; };
+		848B555B0ECFAE4D003D696F /* CFLocale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFLocale.c; path = ../CFLocale.c; sourceTree = SOURCE_ROOT; };
+		848B555C0ECFAE4D003D696F /* CFLocaleIdentifier.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFLocaleIdentifier.c; path = ../CFLocaleIdentifier.c; sourceTree = SOURCE_ROOT; };
+		848B555D0ECFAE4D003D696F /* CFMachPort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFMachPort.c; path = ../CFMachPort.c; sourceTree = SOURCE_ROOT; };
+		848B555E0ECFAE4D003D696F /* CFMessagePort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFMessagePort.c; path = ../CFMessagePort.c; sourceTree = SOURCE_ROOT; };
+		848B555F0ECFAE4D003D696F /* CFNumber.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFNumber.c; path = ../CFNumber.c; sourceTree = SOURCE_ROOT; };
+		848B55600ECFAE4D003D696F /* CFNumberFormatter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFNumberFormatter.c; path = ../CFNumberFormatter.c; sourceTree = SOURCE_ROOT; };
+		848B55610ECFAE4D003D696F /* CFPlatform.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFPlatform.c; path = ../CFPlatform.c; sourceTree = SOURCE_ROOT; };
+		848B55620ECFAE4D003D696F /* CFPlugIn.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFPlugIn.c; path = ../CFPlugIn.c; sourceTree = SOURCE_ROOT; };
+		848B55630ECFAE4D003D696F /* CFPlugIn_Factory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFPlugIn_Factory.c; path = ../CFPlugIn_Factory.c; sourceTree = SOURCE_ROOT; };
+		848B55640ECFAE4D003D696F /* CFPlugIn_Instance.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFPlugIn_Instance.c; path = ../CFPlugIn_Instance.c; sourceTree = SOURCE_ROOT; };
+		848B55650ECFAE4D003D696F /* CFPlugIn_PlugIn.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFPlugIn_PlugIn.c; path = ../CFPlugIn_PlugIn.c; sourceTree = SOURCE_ROOT; };
+		848B55660ECFAE4D003D696F /* CFPreferences.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFPreferences.c; path = ../CFPreferences.c; sourceTree = SOURCE_ROOT; };
+		848B55670ECFAE4D003D696F /* CFPropertyList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFPropertyList.c; path = ../CFPropertyList.c; sourceTree = SOURCE_ROOT; };
+		848B55680ECFAE4D003D696F /* CFRunLoop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFRunLoop.c; path = ../CFRunLoop.c; sourceTree = SOURCE_ROOT; };
+		848B55690ECFAE4D003D696F /* CFRuntime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFRuntime.c; path = ../CFRuntime.c; sourceTree = SOURCE_ROOT; };
+		848B556A0ECFAE4D003D696F /* CFSet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFSet.c; path = ../CFSet.c; sourceTree = SOURCE_ROOT; };
+		848B556B0ECFAE4D003D696F /* CFSocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFSocket.c; path = ../CFSocket.c; sourceTree = SOURCE_ROOT; };
+		848B556C0ECFAE4D003D696F /* CFSocketStream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFSocketStream.c; path = ../CFSocketStream.c; sourceTree = SOURCE_ROOT; };
+		848B556D0ECFAE4D003D696F /* CFStorage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFStorage.c; path = ../CFStorage.c; sourceTree = SOURCE_ROOT; };
+		848B556E0ECFAE4D003D696F /* CFStream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFStream.c; path = ../CFStream.c; sourceTree = SOURCE_ROOT; };
+		848B556F0ECFAE4D003D696F /* CFString.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFString.c; path = ../CFString.c; sourceTree = SOURCE_ROOT; };
+		848B55700ECFAE4D003D696F /* CFStringEncodingConverter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFStringEncodingConverter.c; path = ../CFStringEncodingConverter.c; sourceTree = SOURCE_ROOT; };
+		848B55710ECFAE4D003D696F /* CFStringEncodings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFStringEncodings.c; path = ../CFStringEncodings.c; sourceTree = SOURCE_ROOT; };
+		848B55720ECFAE4D003D696F /* CFStringScanner.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFStringScanner.c; path = ../CFStringScanner.c; sourceTree = SOURCE_ROOT; };
+		848B55730ECFAE4D003D696F /* CFStringUtilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFStringUtilities.c; path = ../CFStringUtilities.c; sourceTree = SOURCE_ROOT; };
+		848B55740ECFAE4D003D696F /* CFSystemDirectories.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFSystemDirectories.c; path = ../CFSystemDirectories.c; sourceTree = SOURCE_ROOT; };
+		848B55750ECFAE4D003D696F /* CFTimeZone.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFTimeZone.c; path = ../CFTimeZone.c; sourceTree = SOURCE_ROOT; };
+		848B55760ECFAE4D003D696F /* CFTree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFTree.c; path = ../CFTree.c; sourceTree = SOURCE_ROOT; };
+		848B55770ECFAE4D003D696F /* CFUniChar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFUniChar.c; path = ../CFUniChar.c; sourceTree = SOURCE_ROOT; };
+		848B55780ECFAE4D003D696F /* CFUnicodeDecomposition.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFUnicodeDecomposition.c; path = ../CFUnicodeDecomposition.c; sourceTree = SOURCE_ROOT; };
+		848B55790ECFAE4D003D696F /* CFUnicodePrecomposition.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFUnicodePrecomposition.c; path = ../CFUnicodePrecomposition.c; sourceTree = SOURCE_ROOT; };
+		848B557A0ECFAE4D003D696F /* CFURL.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFURL.c; path = ../CFURL.c; sourceTree = SOURCE_ROOT; };
+		848B557B0ECFAE4D003D696F /* CFURLAccess.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFURLAccess.c; path = ../CFURLAccess.c; sourceTree = SOURCE_ROOT; };
+		848B557C0ECFAE4D003D696F /* CFUserNotification.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFUserNotification.c; path = ../CFUserNotification.c; sourceTree = SOURCE_ROOT; };
+		848B557D0ECFAE4D003D696F /* CFUtilities.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFUtilities.c; path = ../CFUtilities.c; sourceTree = SOURCE_ROOT; };
+		848B557E0ECFAE4D003D696F /* CFUUID.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFUUID.c; path = ../CFUUID.c; sourceTree = SOURCE_ROOT; };
+		848B557F0ECFAE4D003D696F /* CFVersion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFVersion.c; path = ../CFVersion.c; sourceTree = SOURCE_ROOT; };
+		848B55800ECFAE4D003D696F /* CFXMLInputStream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFXMLInputStream.c; path = ../CFXMLInputStream.c; sourceTree = SOURCE_ROOT; };
+		848B55810ECFAE4D003D696F /* CFXMLNode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFXMLNode.c; path = ../CFXMLNode.c; sourceTree = SOURCE_ROOT; };
+		848B55820ECFAE4D003D696F /* CFXMLParser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFXMLParser.c; path = ../CFXMLParser.c; sourceTree = SOURCE_ROOT; };
+		848B55830ECFAE4D003D696F /* CFXMLPreferencesDomain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFXMLPreferencesDomain.c; path = ../CFXMLPreferencesDomain.c; sourceTree = SOURCE_ROOT; };
+		848B55840ECFAE4D003D696F /* CFXMLTree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFXMLTree.c; path = ../CFXMLTree.c; sourceTree = SOURCE_ROOT; };
+		848B55C40ECFAF07003D696F /* CFUniChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFUniChar.h; path = ../CFUniChar.h; sourceTree = SOURCE_ROOT; };
+		848B55C50ECFAF07003D696F /* CFUniCharPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFUniCharPriv.h; path = ../CFUniCharPriv.h; sourceTree = SOURCE_ROOT; };
+		848B55C60ECFAF07003D696F /* CFUnicodeDecomposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFUnicodeDecomposition.h; path = ../CFUnicodeDecomposition.h; sourceTree = SOURCE_ROOT; };
+		848B55C70ECFAF07003D696F /* CFUnicodePrecomposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFUnicodePrecomposition.h; path = ../CFUnicodePrecomposition.h; sourceTree = SOURCE_ROOT; };
+		848B55C80ECFAF07003D696F /* CFURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFURL.h; path = ../CFURL.h; sourceTree = SOURCE_ROOT; };
+		848B55C90ECFAF07003D696F /* CFURLAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFURLAccess.h; path = ../CFURLAccess.h; sourceTree = SOURCE_ROOT; };
+		848B55CA0ECFAF07003D696F /* CFUserNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFUserNotification.h; path = ../CFUserNotification.h; sourceTree = SOURCE_ROOT; };
+		848B55CB0ECFAF07003D696F /* CFUUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFUUID.h; path = ../CFUUID.h; sourceTree = SOURCE_ROOT; };
+		848B55CC0ECFAF07003D696F /* CFXMLInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFXMLInputStream.h; path = ../CFXMLInputStream.h; sourceTree = SOURCE_ROOT; };
+		848B55CD0ECFAF07003D696F /* CFXMLNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFXMLNode.h; path = ../CFXMLNode.h; sourceTree = SOURCE_ROOT; };
+		848B55CE0ECFAF07003D696F /* CFXMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFXMLParser.h; path = ../CFXMLParser.h; sourceTree = SOURCE_ROOT; };
+		848B55CF0ECFAF07003D696F /* CoreFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CoreFoundation.h; path = ../CoreFoundation.h; sourceTree = SOURCE_ROOT; };
+		848B55D00ECFAF07003D696F /* ForFoundationOnly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ForFoundationOnly.h; path = ../ForFoundationOnly.h; sourceTree = SOURCE_ROOT; };
+		848B55DE0ECFAF5E003D696F /* auto_stubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = auto_stubs.h; path = ../auto_stubs.h; sourceTree = SOURCE_ROOT; };
+		848B55DF0ECFAF5E003D696F /* CFArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFArray.h; path = ../CFArray.h; sourceTree = SOURCE_ROOT; };
+		848B55E00ECFAF5E003D696F /* CFBag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBag.h; path = ../CFBag.h; sourceTree = SOURCE_ROOT; };
+		848B55E10ECFAF5E003D696F /* CFBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBase.h; path = ../CFBase.h; sourceTree = SOURCE_ROOT; };
+		848B55E20ECFAF5E003D696F /* CFBinaryHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBinaryHeap.h; path = ../CFBinaryHeap.h; sourceTree = SOURCE_ROOT; };
+		848B55E30ECFAF5E003D696F /* CFBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBitVector.h; path = ../CFBitVector.h; sourceTree = SOURCE_ROOT; };
+		848B55E40ECFAF5E003D696F /* CFBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBundle.h; path = ../CFBundle.h; sourceTree = SOURCE_ROOT; };
+		848B55E50ECFAF5E003D696F /* CFBundle_BinaryTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBundle_BinaryTypes.h; path = ../CFBundle_BinaryTypes.h; sourceTree = SOURCE_ROOT; };
+		848B55E60ECFAF5E003D696F /* CFBundle_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBundle_Internal.h; path = ../CFBundle_Internal.h; sourceTree = SOURCE_ROOT; };
+		848B55E70ECFAF5E003D696F /* CFBundlePriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBundlePriv.h; path = ../CFBundlePriv.h; sourceTree = SOURCE_ROOT; };
+		848B55E80ECFAF5E003D696F /* CFByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFByteOrder.h; path = ../CFByteOrder.h; sourceTree = SOURCE_ROOT; };
+		848B55E90ECFAF5E003D696F /* CFCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCalendar.h; path = ../CFCalendar.h; sourceTree = SOURCE_ROOT; };
+		848B55EA0ECFAF5E003D696F /* CFCharacterSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCharacterSet.h; path = ../CFCharacterSet.h; sourceTree = SOURCE_ROOT; };
+		848B55EB0ECFAF5E003D696F /* CFCharacterSetPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCharacterSetPriv.h; path = ../CFCharacterSetPriv.h; sourceTree = SOURCE_ROOT; };
+		848B55EC0ECFAF5E003D696F /* CFData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFData.h; path = ../CFData.h; sourceTree = SOURCE_ROOT; };
+		848B55ED0ECFAF5E003D696F /* CFDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFDate.h; path = ../CFDate.h; sourceTree = SOURCE_ROOT; };
+		848B55EE0ECFAF5E003D696F /* CFDateFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFDateFormatter.h; path = ../CFDateFormatter.h; sourceTree = SOURCE_ROOT; };
+		848B55EF0ECFAF5E003D696F /* CFDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFDictionary.h; path = ../CFDictionary.h; sourceTree = SOURCE_ROOT; };
+		848B55F00ECFAF5E003D696F /* CFError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFError.h; path = ../CFError.h; sourceTree = SOURCE_ROOT; };
+		848B55F10ECFAF5E003D696F /* CFError_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFError_Private.h; path = ../CFError_Private.h; sourceTree = SOURCE_ROOT; };
+		848B55F20ECFAF5E003D696F /* CFInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFInternal.h; path = ../CFInternal.h; sourceTree = SOURCE_ROOT; };
+		848B55F30ECFAF5E003D696F /* CFLocale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFLocale.h; path = ../CFLocale.h; sourceTree = SOURCE_ROOT; };
+		848B55F40ECFAF5E003D696F /* CFLogUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFLogUtilities.h; path = ../CFLogUtilities.h; sourceTree = SOURCE_ROOT; };
+		848B55F50ECFAF5E003D696F /* CFMachPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFMachPort.h; path = ../CFMachPort.h; sourceTree = SOURCE_ROOT; };
+		848B55F60ECFAF5E003D696F /* CFMessagePort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFMessagePort.h; path = ../CFMessagePort.h; sourceTree = SOURCE_ROOT; };
+		848B55F70ECFAF5E003D696F /* CFNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFNumber.h; path = ../CFNumber.h; sourceTree = SOURCE_ROOT; };
+		848B55F80ECFAF5E003D696F /* CFNumberFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFNumberFormatter.h; path = ../CFNumberFormatter.h; sourceTree = SOURCE_ROOT; };
+		848B55F90ECFAF5E003D696F /* CFPlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFPlugIn.h; path = ../CFPlugIn.h; sourceTree = SOURCE_ROOT; };
+		848B55FA0ECFAF5E003D696F /* CFPlugIn_Factory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFPlugIn_Factory.h; path = ../CFPlugIn_Factory.h; sourceTree = SOURCE_ROOT; };
+		848B55FB0ECFAF5E003D696F /* CFPlugInCOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFPlugInCOM.h; path = ../CFPlugInCOM.h; sourceTree = SOURCE_ROOT; };
+		848B55FC0ECFAF5E003D696F /* CFPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFPreferences.h; path = ../CFPreferences.h; sourceTree = SOURCE_ROOT; };
+		848B55FD0ECFAF5E003D696F /* CFPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFPriv.h; path = ../CFPriv.h; sourceTree = SOURCE_ROOT; };
+		848B55FE0ECFAF5E003D696F /* CFPropertyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFPropertyList.h; path = ../CFPropertyList.h; sourceTree = SOURCE_ROOT; };
+		848B55FF0ECFAF5E003D696F /* CFRunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFRunLoop.h; path = ../CFRunLoop.h; sourceTree = SOURCE_ROOT; };
+		848B56000ECFAF5E003D696F /* CFRunLoopPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFRunLoopPriv.h; path = ../CFRunLoopPriv.h; sourceTree = SOURCE_ROOT; };
+		848B56010ECFAF5E003D696F /* CFRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFRuntime.h; path = ../CFRuntime.h; sourceTree = SOURCE_ROOT; };
+		848B56020ECFAF5E003D696F /* CFSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFSet.h; path = ../CFSet.h; sourceTree = SOURCE_ROOT; };
+		848B56030ECFAF5E003D696F /* CFSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFSocket.h; path = ../CFSocket.h; sourceTree = SOURCE_ROOT; };
+		848B56040ECFAF5E003D696F /* CFStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStorage.h; path = ../CFStorage.h; sourceTree = SOURCE_ROOT; };
+		848B56050ECFAF5E003D696F /* CFStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStream.h; path = ../CFStream.h; sourceTree = SOURCE_ROOT; };
+		848B56060ECFAF5E003D696F /* CFStreamAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStreamAbstract.h; path = ../CFStreamAbstract.h; sourceTree = SOURCE_ROOT; };
+		848B56070ECFAF5E003D696F /* CFStreamInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStreamInternal.h; path = ../CFStreamInternal.h; sourceTree = SOURCE_ROOT; };
+		848B56080ECFAF5E003D696F /* CFStreamPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStreamPriv.h; path = ../CFStreamPriv.h; sourceTree = SOURCE_ROOT; };
+		848B56090ECFAF5E003D696F /* CFString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFString.h; path = ../CFString.h; sourceTree = SOURCE_ROOT; };
+		848B560A0ECFAF5E003D696F /* CFStringDefaultEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStringDefaultEncoding.h; path = ../CFStringDefaultEncoding.h; sourceTree = SOURCE_ROOT; };
+		848B560B0ECFAF5E003D696F /* CFStringEncodingConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStringEncodingConverter.h; path = ../CFStringEncodingConverter.h; sourceTree = SOURCE_ROOT; };
+		848B560C0ECFAF5E003D696F /* CFStringEncodingConverterExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStringEncodingConverterExt.h; path = ../CFStringEncodingConverterExt.h; sourceTree = SOURCE_ROOT; };
+		848B560D0ECFAF5E003D696F /* CFStringEncodingConverterPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStringEncodingConverterPriv.h; path = ../CFStringEncodingConverterPriv.h; sourceTree = SOURCE_ROOT; };
+		848B560E0ECFAF5E003D696F /* CFStringEncodingExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStringEncodingExt.h; path = ../CFStringEncodingExt.h; sourceTree = SOURCE_ROOT; };
+		848B560F0ECFAF5E003D696F /* CFTimeZone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFTimeZone.h; path = ../CFTimeZone.h; sourceTree = SOURCE_ROOT; };
+		848B56100ECFAF5E003D696F /* CFTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFTree.h; path = ../CFTree.h; sourceTree = SOURCE_ROOT; };
+		848B56440ECFAF6E003D696F /* CFSortFunctions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFSortFunctions.c; path = ../CFSortFunctions.c; sourceTree = SOURCE_ROOT; };
+		848B56480ECFB02B003D696F /* Config_Master.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Config_Master.xcconfig; path = ../XCode_Configs/Config_Master.xcconfig; sourceTree = SOURCE_ROOT; };
+		848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = ConfigDebug.xcconfig; path = ../XCode_Configs/ConfigDebug.xcconfig; sourceTree = SOURCE_ROOT; };
+		848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = ConfigRelease.xcconfig; path = ../XCode_Configs/ConfigRelease.xcconfig; sourceTree = SOURCE_ROOT; };
+		84915D4D0F4B5CE600A3C0DD /* CFRunLoopTimerExample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CFRunLoopTimerExample; sourceTree = BUILT_PRODUCTS_DIR; };
+		84915D530F4B5D0500A3C0DD /* CFRunLoopTimerExample.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CFRunLoopTimerExample.c; path = ../examples/CFRunLoopTimerExample/CFRunLoopTimerExample.c; sourceTree = SOURCE_ROOT; };
+		84915FB70F4B893300A3C0DD /* CFLite */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = CFLite; path = build/Debug/CFLite.framework/Versions/A/CFLite; sourceTree = "<group>"; };
+		84CD60D00F4A030E0049B4EC /* SimpleWebServer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SimpleWebServer.c; path = ../examples/SimpleWebServer/SimpleWebServer.c; sourceTree = SOURCE_ROOT; };
+		84CD60DB0F4A03310049B4EC /* SimpleWebServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SimpleWebServer; sourceTree = BUILT_PRODUCTS_DIR; };
+		84DA170D0EDDEEEE00B6A2E6 /* date_test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = date_test.c; path = ../tests/date_test.c; sourceTree = SOURCE_ROOT; };
+		84DA171C0EDDF44500B6A2E6 /* Test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Test; sourceTree = BUILT_PRODUCTS_DIR; };
+		84F19F070F50F9CE0092A274 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		841BE83E0F395D5A001F2A66 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84F19F470F50FAC70092A274 /* CFLite.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		841BE91D0F395F8E001F2A66 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				841BE9250F395FBE001F2A66 /* CFLite.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		8448EF650ED2796500716715 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				8466FDA90F4F42DF009FA7BA /* libobjc.dylib in Frameworks */,
+				8466FDAC0F4F42F7009FA7BA /* libicucore.A.dylib in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		844949800ED27E8700EEB9C0 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84DE4E550ED287D40023DFE2 /* CFLite.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		844949900ED27F1100EEB9C0 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				844949A20ED27F3100EEB9C0 /* CFLite.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		844F5D520F3FB1F600239823 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				844F5D5E0F3FB24E00239823 /* CFLite.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		8481BA490F3EA69C00BD5189 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				8481BA510F3EA6AB00BD5189 /* CFLite.framework in Frameworks */,
+				8481BA810F3EB2D300BD5189 /* CoreServices.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		84915D4B0F4B5CE600A3C0DD /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84915D510F4B5CEA00A3C0DD /* CFLite.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		84CD60D90F4A03310049B4EC /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		84DA171A0EDDF44500B6A2E6 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84DA17230EDDF47100B6A2E6 /* CFLite.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		08FB7794FE84155DC02AAC07 /* CFLite */ = {
+			isa = PBXGroup;
+			children = (
+				8466FDA80F4F42DF009FA7BA /* libobjc.dylib */,
+				8466FDAB0F4F42F7009FA7BA /* libicucore.A.dylib */,
+				84915FB70F4B893300A3C0DD /* CFLite */,
+				848B56470ECFB00B003D696F /* Xcode_configs */,
+				848B55C20ECFAE55003D696F /* Headers */,
+				08FB7795FE84155DC02AAC07 /* Source */,
+				C6A0FF2B0290797F04C91782 /* Documentation */,
+				1AB674ADFE9D54B511CA2CBB /* Products */,
+				845EDB360ED3374D0033E001 /* Info.plist */,
+				84F19F070F50F9CE0092A274 /* CoreFoundation.framework */,
+			);
+			comments = "This XCode project attempts to replicate the steps performed in the BuildCFLite shell script.  For real production use, you should always use the script as it is maintained by the Apple team, and always does the right thing.  This XCode project is mainly for exploration and debugging purposes, and is sometimes out of sync with the BuildCFLite script.\n\nIf something is not working right, be sure to compare the settings in BuildCFLite and this project!";
+			name = CFLite;
+			sourceTree = "<group>";
+		};
+		08FB7795FE84155DC02AAC07 /* Source */ = {
+			isa = PBXGroup;
+			children = (
+				84DA16F50EDDE95000B6A2E6 /* Tests */,
+				84DA17160EDDEFB100B6A2E6 /* Examples */,
+				848B55C30ECFAE6B003D696F /* Private Headers */,
+				848B55480ECFAE4D003D696F /* CFApplicationPreferences.c */,
+				848B55490ECFAE4D003D696F /* CFArray.c */,
+				848B554A0ECFAE4D003D696F /* CFBag.c */,
+				848B554B0ECFAE4D003D696F /* CFBase.c */,
+				848B554C0ECFAE4D003D696F /* CFBinaryHeap.c */,
+				848B554D0ECFAE4D003D696F /* CFBinaryPList.c */,
+				848B554E0ECFAE4D003D696F /* CFBitVector.c */,
+				848B554F0ECFAE4D003D696F /* CFBuiltinConverters.c */,
+				848B55500ECFAE4D003D696F /* CFBundle.c */,
+				848B55510ECFAE4D003D696F /* CFBundle_Resources.c */,
+				848B55520ECFAE4D003D696F /* CFCalendar.c */,
+				848B55530ECFAE4D003D696F /* CFCharacterSet.c */,
+				848B55540ECFAE4D003D696F /* CFConcreteStreams.c */,
+				848B55550ECFAE4D003D696F /* CFData.c */,
+				848B55560ECFAE4D003D696F /* CFDate.c */,
+				848B55570ECFAE4D003D696F /* CFDateFormatter.c */,
+				848B55580ECFAE4D003D696F /* CFDictionary.c */,
+				848B55590ECFAE4D003D696F /* CFError.c */,
+				848B555A0ECFAE4D003D696F /* CFFileUtilities.c */,
+				848B555B0ECFAE4D003D696F /* CFLocale.c */,
+				848B555C0ECFAE4D003D696F /* CFLocaleIdentifier.c */,
+				848B555D0ECFAE4D003D696F /* CFMachPort.c */,
+				848B555E0ECFAE4D003D696F /* CFMessagePort.c */,
+				848B555F0ECFAE4D003D696F /* CFNumber.c */,
+				848B55600ECFAE4D003D696F /* CFNumberFormatter.c */,
+				848B55610ECFAE4D003D696F /* CFPlatform.c */,
+				848B55620ECFAE4D003D696F /* CFPlugIn.c */,
+				848B55630ECFAE4D003D696F /* CFPlugIn_Factory.c */,
+				848B55640ECFAE4D003D696F /* CFPlugIn_Instance.c */,
+				848B55650ECFAE4D003D696F /* CFPlugIn_PlugIn.c */,
+				848B55660ECFAE4D003D696F /* CFPreferences.c */,
+				848B55670ECFAE4D003D696F /* CFPropertyList.c */,
+				848B55680ECFAE4D003D696F /* CFRunLoop.c */,
+				848B55690ECFAE4D003D696F /* CFRuntime.c */,
+				848B556A0ECFAE4D003D696F /* CFSet.c */,
+				848B556B0ECFAE4D003D696F /* CFSocket.c */,
+				848B556C0ECFAE4D003D696F /* CFSocketStream.c */,
+				848B56440ECFAF6E003D696F /* CFSortFunctions.c */,
+				848B556D0ECFAE4D003D696F /* CFStorage.c */,
+				848B556E0ECFAE4D003D696F /* CFStream.c */,
+				848B556F0ECFAE4D003D696F /* CFString.c */,
+				848B55700ECFAE4D003D696F /* CFStringEncodingConverter.c */,
+				848B55710ECFAE4D003D696F /* CFStringEncodings.c */,
+				848B55720ECFAE4D003D696F /* CFStringScanner.c */,
+				848B55730ECFAE4D003D696F /* CFStringUtilities.c */,
+				848B55740ECFAE4D003D696F /* CFSystemDirectories.c */,
+				848B55750ECFAE4D003D696F /* CFTimeZone.c */,
+				848B55760ECFAE4D003D696F /* CFTree.c */,
+				848B55770ECFAE4D003D696F /* CFUniChar.c */,
+				848B55780ECFAE4D003D696F /* CFUnicodeDecomposition.c */,
+				848B55790ECFAE4D003D696F /* CFUnicodePrecomposition.c */,
+				848B557A0ECFAE4D003D696F /* CFURL.c */,
+				848B557B0ECFAE4D003D696F /* CFURLAccess.c */,
+				848B557C0ECFAE4D003D696F /* CFUserNotification.c */,
+				848B557D0ECFAE4D003D696F /* CFUtilities.c */,
+				848B557E0ECFAE4D003D696F /* CFUUID.c */,
+				848B557F0ECFAE4D003D696F /* CFVersion.c */,
+				848B55800ECFAE4D003D696F /* CFXMLInputStream.c */,
+				848B55810ECFAE4D003D696F /* CFXMLNode.c */,
+				848B55820ECFAE4D003D696F /* CFXMLParser.c */,
+				848B55830ECFAE4D003D696F /* CFXMLPreferencesDomain.c */,
+				848B55840ECFAE4D003D696F /* CFXMLTree.c */,
+			);
+			name = Source;
+			sourceTree = "<group>";
+		};
+		1AB674ADFE9D54B511CA2CBB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				8481BA800F3EB2D300BD5189 /* CoreServices.framework */,
+				8448EF670ED2796500716715 /* CFLite.framework */,
+				844949820ED27E8700EEB9C0 /* WritePListExample */,
+				844949920ED27F1100EEB9C0 /* ReadPListExample */,
+				84DA171C0EDDF44500B6A2E6 /* Test */,
+				841BE8400F395D5A001F2A66 /* StringExample */,
+				841BE91F0F395F8E001F2A66 /* AllocatorExample */,
+				8481BA4B0F3EA69C00BD5189 /* DisplayURL */,
+				844F5D540F3FB1F600239823 /* DNSMetaServiceQuery */,
+				84CD60DB0F4A03310049B4EC /* SimpleWebServer */,
+				84915D4D0F4B5CE600A3C0DD /* CFRunLoopTimerExample */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		84129F430F38C08F00A64427 /* mach_support */ = {
+			isa = PBXGroup;
+			children = (
+				84129F460F38C0CF00A64427 /* bootstrap_priv.h */,
+				84129F440F38C0BD00A64427 /* vproc_priv.h */,
+			);
+			name = mach_support;
+			sourceTree = "<group>";
+		};
+		848B55C20ECFAE55003D696F /* Headers */ = {
+			isa = PBXGroup;
+			children = (
+				84129F430F38C08F00A64427 /* mach_support */,
+				848B55DF0ECFAF5E003D696F /* CFArray.h */,
+				848B55E00ECFAF5E003D696F /* CFBag.h */,
+				848B55E10ECFAF5E003D696F /* CFBase.h */,
+				848B55E20ECFAF5E003D696F /* CFBinaryHeap.h */,
+				848B55E30ECFAF5E003D696F /* CFBitVector.h */,
+				848B55E40ECFAF5E003D696F /* CFBundle.h */,
+				848B55E80ECFAF5E003D696F /* CFByteOrder.h */,
+				848B55E90ECFAF5E003D696F /* CFCalendar.h */,
+				848B55EA0ECFAF5E003D696F /* CFCharacterSet.h */,
+				848B55EC0ECFAF5E003D696F /* CFData.h */,
+				848B55ED0ECFAF5E003D696F /* CFDate.h */,
+				848B55EE0ECFAF5E003D696F /* CFDateFormatter.h */,
+				848B55EF0ECFAF5E003D696F /* CFDictionary.h */,
+				848B55F00ECFAF5E003D696F /* CFError.h */,
+				848B55F30ECFAF5E003D696F /* CFLocale.h */,
+				848B55F50ECFAF5E003D696F /* CFMachPort.h */,
+				848B55F60ECFAF5E003D696F /* CFMessagePort.h */,
+				848B55F70ECFAF5E003D696F /* CFNumber.h */,
+				848B55F80ECFAF5E003D696F /* CFNumberFormatter.h */,
+				848B55F90ECFAF5E003D696F /* CFPlugIn.h */,
+				848B55FB0ECFAF5E003D696F /* CFPlugInCOM.h */,
+				848B55FC0ECFAF5E003D696F /* CFPreferences.h */,
+				848B55FE0ECFAF5E003D696F /* CFPropertyList.h */,
+				848B55FF0ECFAF5E003D696F /* CFRunLoop.h */,
+				848B56020ECFAF5E003D696F /* CFSet.h */,
+				848B56030ECFAF5E003D696F /* CFSocket.h */,
+				848B56050ECFAF5E003D696F /* CFStream.h */,
+				848B56090ECFAF5E003D696F /* CFString.h */,
+				848B560E0ECFAF5E003D696F /* CFStringEncodingExt.h */,
+				848B560F0ECFAF5E003D696F /* CFTimeZone.h */,
+				848B56100ECFAF5E003D696F /* CFTree.h */,
+				848B55C80ECFAF07003D696F /* CFURL.h */,
+				848B55C90ECFAF07003D696F /* CFURLAccess.h */,
+				848B55CA0ECFAF07003D696F /* CFUserNotification.h */,
+				848B55CB0ECFAF07003D696F /* CFUUID.h */,
+				848B55CD0ECFAF07003D696F /* CFXMLNode.h */,
+				848B55CE0ECFAF07003D696F /* CFXMLParser.h */,
+				848B55CF0ECFAF07003D696F /* CoreFoundation.h */,
+			);
+			name = Headers;
+			sourceTree = "<group>";
+		};
+		848B55C30ECFAE6B003D696F /* Private Headers */ = {
+			isa = PBXGroup;
+			children = (
+				848B55DE0ECFAF5E003D696F /* auto_stubs.h */,
+				848B55E50ECFAF5E003D696F /* CFBundle_BinaryTypes.h */,
+				848B55E60ECFAF5E003D696F /* CFBundle_Internal.h */,
+				848B55E70ECFAF5E003D696F /* CFBundlePriv.h */,
+				848B55EB0ECFAF5E003D696F /* CFCharacterSetPriv.h */,
+				848B55F10ECFAF5E003D696F /* CFError_Private.h */,
+				848B55F20ECFAF5E003D696F /* CFInternal.h */,
+				848B55F40ECFAF5E003D696F /* CFLogUtilities.h */,
+				848B55FA0ECFAF5E003D696F /* CFPlugIn_Factory.h */,
+				848B55FD0ECFAF5E003D696F /* CFPriv.h */,
+				848B56000ECFAF5E003D696F /* CFRunLoopPriv.h */,
+				848B56010ECFAF5E003D696F /* CFRuntime.h */,
+				848B56040ECFAF5E003D696F /* CFStorage.h */,
+				848B56060ECFAF5E003D696F /* CFStreamAbstract.h */,
+				848B56070ECFAF5E003D696F /* CFStreamInternal.h */,
+				848B56080ECFAF5E003D696F /* CFStreamPriv.h */,
+				848B560A0ECFAF5E003D696F /* CFStringDefaultEncoding.h */,
+				848B560B0ECFAF5E003D696F /* CFStringEncodingConverter.h */,
+				848B560C0ECFAF5E003D696F /* CFStringEncodingConverterExt.h */,
+				848B560D0ECFAF5E003D696F /* CFStringEncodingConverterPriv.h */,
+				848B55C40ECFAF07003D696F /* CFUniChar.h */,
+				848B55C50ECFAF07003D696F /* CFUniCharPriv.h */,
+				848B55C60ECFAF07003D696F /* CFUnicodeDecomposition.h */,
+				848B55C70ECFAF07003D696F /* CFUnicodePrecomposition.h */,
+				848B55CC0ECFAF07003D696F /* CFXMLInputStream.h */,
+				848B55D00ECFAF07003D696F /* ForFoundationOnly.h */,
+			);
+			name = "Private Headers";
+			sourceTree = "<group>";
+		};
+		848B56470ECFB00B003D696F /* Xcode_configs */ = {
+			isa = PBXGroup;
+			children = (
+				848B56480ECFB02B003D696F /* Config_Master.xcconfig */,
+				848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */,
+				848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */,
+			);
+			name = Xcode_configs;
+			sourceTree = "<group>";
+		};
+		84DA16F50EDDE95000B6A2E6 /* Tests */ = {
+			isa = PBXGroup;
+			children = (
+				84DA170D0EDDEEEE00B6A2E6 /* date_test.c */,
+			);
+			name = Tests;
+			sourceTree = "<group>";
+		};
+		84DA17160EDDEFB100B6A2E6 /* Examples */ = {
+			isa = PBXGroup;
+			children = (
+				84915D530F4B5D0500A3C0DD /* CFRunLoopTimerExample.c */,
+				84CD60D00F4A030E0049B4EC /* SimpleWebServer.c */,
+				844F5D590F3FB23100239823 /* DNSServiceMetaQuery.c */,
+				8481BA460F3EA68A00BD5189 /* DisplayURL.c */,
+				841BE91A0F395F65001F2A66 /* AllocatorExample.c */,
+				841BE83B0F395D3E001F2A66 /* StringExample.c */,
+				844949A30ED27F8500EEB9C0 /* ReadPListExample.cpp */,
+				840CBF6C0ED24F4500931057 /* WritePListExample.cpp */,
+			);
+			name = Examples;
+			sourceTree = "<group>";
+		};
+		C6A0FF2B0290797F04C91782 /* Documentation */ = {
+			isa = PBXGroup;
+			children = (
+			);
+			name = Documentation;
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+		8448EF620ED2796500716715 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84129F7B0F3A4C2600A64427 /* CFArray.h in Headers */,
+				84129F7C0F3A4C2600A64427 /* CFBag.h in Headers */,
+				84129F7D0F3A4C2600A64427 /* CFBase.h in Headers */,
+				84129F7E0F3A4C2600A64427 /* CFBinaryHeap.h in Headers */,
+				84129F7F0F3A4C2600A64427 /* CFBitVector.h in Headers */,
+				84129F800F3A4C2600A64427 /* CFBundle.h in Headers */,
+				84129F810F3A4C2600A64427 /* CFByteOrder.h in Headers */,
+				84129F820F3A4C2600A64427 /* CFCalendar.h in Headers */,
+				84129F830F3A4C2600A64427 /* CFCharacterSet.h in Headers */,
+				84129F840F3A4C2600A64427 /* CFData.h in Headers */,
+				84129F850F3A4C2600A64427 /* CFDate.h in Headers */,
+				84129F860F3A4C2600A64427 /* CFDateFormatter.h in Headers */,
+				84129F870F3A4C2600A64427 /* CFDictionary.h in Headers */,
+				84129F880F3A4C2600A64427 /* CFError.h in Headers */,
+				84129F890F3A4C2600A64427 /* CFLocale.h in Headers */,
+				84129F8A0F3A4C2600A64427 /* CFMachPort.h in Headers */,
+				84129F8B0F3A4C2600A64427 /* CFMessagePort.h in Headers */,
+				84129F8C0F3A4C2600A64427 /* CFNumber.h in Headers */,
+				84129F8D0F3A4C2600A64427 /* CFNumberFormatter.h in Headers */,
+				84129F8E0F3A4C2600A64427 /* CFPlugIn.h in Headers */,
+				84129F8F0F3A4C2600A64427 /* CFPlugInCOM.h in Headers */,
+				84129F900F3A4C2600A64427 /* CFPreferences.h in Headers */,
+				84129F910F3A4C2600A64427 /* CFPropertyList.h in Headers */,
+				84129F920F3A4C2600A64427 /* CFRunLoop.h in Headers */,
+				84129F930F3A4C2600A64427 /* CFSet.h in Headers */,
+				84129F940F3A4C2600A64427 /* CFSocket.h in Headers */,
+				84129F950F3A4C2600A64427 /* CFStream.h in Headers */,
+				84129F960F3A4C2600A64427 /* CFString.h in Headers */,
+				84129F970F3A4C2600A64427 /* CFStringEncodingExt.h in Headers */,
+				84129F980F3A4C2600A64427 /* CFTimeZone.h in Headers */,
+				84129F990F3A4C2600A64427 /* CFTree.h in Headers */,
+				84129F9A0F3A4C2600A64427 /* CFURL.h in Headers */,
+				84129F9B0F3A4C2600A64427 /* CFURLAccess.h in Headers */,
+				84129F9C0F3A4C2600A64427 /* CFUserNotification.h in Headers */,
+				84129F9D0F3A4C2600A64427 /* CFUUID.h in Headers */,
+				84129F9E0F3A4C2600A64427 /* CFXMLNode.h in Headers */,
+				84129F9F0F3A4C2600A64427 /* CFXMLParser.h in Headers */,
+				84129FA00F3A4C2600A64427 /* CoreFoundation.h in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+		841BE83F0F395D5A001F2A66 /* StringExample */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 841BE8440F395D8A001F2A66 /* Build configuration list for PBXNativeTarget "StringExample" */;
+			buildPhases = (
+				841BE83D0F395D5A001F2A66 /* Sources */,
+				841BE83E0F395D5A001F2A66 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = StringExample;
+			productName = StringExample;
+			productReference = 841BE8400F395D5A001F2A66 /* StringExample */;
+			productType = "com.apple.product-type.tool";
+		};
+		841BE91E0F395F8E001F2A66 /* AllocatorExample */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 841BE92A0F395FEB001F2A66 /* Build configuration list for PBXNativeTarget "AllocatorExample" */;
+			buildPhases = (
+				841BE91C0F395F8E001F2A66 /* Sources */,
+				841BE91D0F395F8E001F2A66 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = AllocatorExample;
+			productName = AllocatorExample;
+			productReference = 841BE91F0F395F8E001F2A66 /* AllocatorExample */;
+			productType = "com.apple.product-type.tool";
+		};
+		8448EF660ED2796500716715 /* CFLite */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 8448EF6B0ED2796600716715 /* Build configuration list for PBXNativeTarget "CFLite" */;
+			buildPhases = (
+				8448EF620ED2796500716715 /* Headers */,
+				8448EF630ED2796500716715 /* Resources */,
+				8448EF640ED2796500716715 /* Sources */,
+				8448EF650ED2796500716715 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				84129FE10F3A4EC700A64427 /* PBXTargetDependency */,
+			);
+			name = CFLite;
+			productName = CFLite;
+			productReference = 8448EF670ED2796500716715 /* CFLite.framework */;
+			productType = "com.apple.product-type.framework";
+		};
+		844949810ED27E8700EEB9C0 /* WritePListExample */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 844949870ED27ED400EEB9C0 /* Build configuration list for PBXNativeTarget "WritePListExample" */;
+			buildPhases = (
+				8449497F0ED27E8700EEB9C0 /* Sources */,
+				844949800ED27E8700EEB9C0 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = WritePListExample;
+			productName = WritePListExample;
+			productReference = 844949820ED27E8700EEB9C0 /* WritePListExample */;
+			productType = "com.apple.product-type.tool";
+		};
+		844949910ED27F1100EEB9C0 /* ReadPListExample */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 844949A10ED27F2800EEB9C0 /* Build configuration list for PBXNativeTarget "ReadPListExample" */;
+			buildPhases = (
+				8449498F0ED27F1100EEB9C0 /* Sources */,
+				844949900ED27F1100EEB9C0 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = ReadPListExample;
+			productName = ReadPListExample;
+			productReference = 844949920ED27F1100EEB9C0 /* ReadPListExample */;
+			productType = "com.apple.product-type.tool";
+		};
+		844F5D530F3FB1F600239823 /* DNSMetaServiceQuery */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 844F5D580F3FB22C00239823 /* Build configuration list for PBXNativeTarget "DNSMetaServiceQuery" */;
+			buildPhases = (
+				844F5D510F3FB1F600239823 /* Sources */,
+				844F5D520F3FB1F600239823 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = DNSMetaServiceQuery;
+			productName = DNSMetaServiceQuery;
+			productReference = 844F5D540F3FB1F600239823 /* DNSMetaServiceQuery */;
+			productType = "com.apple.product-type.tool";
+		};
+		8481BA4A0F3EA69C00BD5189 /* DisplayURL */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 8481BA560F3EA6E600BD5189 /* Build configuration list for PBXNativeTarget "DisplayURL" */;
+			buildPhases = (
+				8481BA480F3EA69C00BD5189 /* Sources */,
+				8481BA490F3EA69C00BD5189 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = DisplayURL;
+			productName = DisplayURL;
+			productReference = 8481BA4B0F3EA69C00BD5189 /* DisplayURL */;
+			productType = "com.apple.product-type.tool";
+		};
+		84915D4C0F4B5CE600A3C0DD /* CFRunLoopTimerExample */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 84915D550F4B5D0500A3C0DD /* Build configuration list for PBXNativeTarget "CFRunLoopTimerExample" */;
+			buildPhases = (
+				84915D4A0F4B5CE600A3C0DD /* Sources */,
+				84915D4B0F4B5CE600A3C0DD /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = CFRunLoopTimerExample;
+			productName = CFRunLoopTimerExample;
+			productReference = 84915D4D0F4B5CE600A3C0DD /* CFRunLoopTimerExample */;
+			productType = "com.apple.product-type.tool";
+		};
+		84CD60DA0F4A03310049B4EC /* SimpleWebServer */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 84CD60E00F4A037A0049B4EC /* Build configuration list for PBXNativeTarget "SimpleWebServer" */;
+			buildPhases = (
+				84CD60D80F4A03310049B4EC /* Sources */,
+				84CD60D90F4A03310049B4EC /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = SimpleWebServer;
+			productName = SimpleWebServer;
+			productReference = 84CD60DB0F4A03310049B4EC /* SimpleWebServer */;
+			productType = "com.apple.product-type.tool";
+		};
+		84DA171B0EDDF44500B6A2E6 /* Test */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 84DA17220EDDF47000B6A2E6 /* Build configuration list for PBXNativeTarget "Test" */;
+			buildPhases = (
+				84DA17190EDDF44500B6A2E6 /* Sources */,
+				84DA171A0EDDF44500B6A2E6 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = Test;
+			productName = Test;
+			productReference = 84DA171C0EDDF44500B6A2E6 /* Test */;
+			productType = "com.apple.product-type.tool";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		08FB7793FE84155DC02AAC07 /* Project object */ = {
+			isa = PBXProject;
+			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "CFLite" */;
+			compatibilityVersion = "Xcode 3.1";
+			hasScannedForEncodings = 1;
+			mainGroup = 08FB7794FE84155DC02AAC07 /* CFLite */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				8448EF660ED2796500716715 /* CFLite */,
+				844949810ED27E8700EEB9C0 /* WritePListExample */,
+				844949910ED27F1100EEB9C0 /* ReadPListExample */,
+				84DA171B0EDDF44500B6A2E6 /* Test */,
+				841BE83F0F395D5A001F2A66 /* StringExample */,
+				841BE91E0F395F8E001F2A66 /* AllocatorExample */,
+				84129FDA0F3A4E5400A64427 /* make_target_paths */,
+				8481BA4A0F3EA69C00BD5189 /* DisplayURL */,
+				844F5D530F3FB1F600239823 /* DNSMetaServiceQuery */,
+				84CD60DA0F4A03310049B4EC /* SimpleWebServer */,
+				84915D4C0F4B5CE600A3C0DD /* CFRunLoopTimerExample */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		8448EF630ED2796500716715 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				845EDB370ED3374D0033E001 /* Info.plist in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+		84129FDF0F3A4EA900A64427 /* ShellScript */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "echo ${SRCROOT}\n\nmkdir -p ${SRCROOT}/../dist\nmkdir -p ${SRCROOT}/../dist/bin\nmkdir -p ${SRCROOT}/../dist/include\nmkdir -p ${SRCROOT}/../dist/include/CoreFoundation\nmkdir -p ${SRCROOT}/../dist/lib\n\ncd ${SRCROOT}/.. && cp *.h dist/include/CoreFoundation\n";
+		};
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		841BE83D0F395D5A001F2A66 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				841BE8470F395D91001F2A66 /* StringExample.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		841BE91C0F395F8E001F2A66 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				841BE9230F395FB4001F2A66 /* AllocatorExample.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		8448EF640ED2796500716715 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				8448EF6C0ED2798800716715 /* CFApplicationPreferences.c in Sources */,
+				8448EF6D0ED2798800716715 /* CFArray.c in Sources */,
+				8448EF6E0ED2798800716715 /* CFBag.c in Sources */,
+				8448EF6F0ED2798800716715 /* CFBase.c in Sources */,
+				8448EF700ED2798800716715 /* CFBinaryHeap.c in Sources */,
+				8448EF710ED2798800716715 /* CFBinaryPList.c in Sources */,
+				8448EF720ED2798800716715 /* CFBitVector.c in Sources */,
+				8448EF730ED2798800716715 /* CFBuiltinConverters.c in Sources */,
+				8448EF740ED2798800716715 /* CFBundle.c in Sources */,
+				8448EF750ED2798800716715 /* CFBundle_Resources.c in Sources */,
+				8448EF760ED2798800716715 /* CFCalendar.c in Sources */,
+				8448EF770ED2798800716715 /* CFCharacterSet.c in Sources */,
+				8448EF780ED2798800716715 /* CFConcreteStreams.c in Sources */,
+				8448EF790ED2798800716715 /* CFData.c in Sources */,
+				8448EF7A0ED2798800716715 /* CFDate.c in Sources */,
+				8448EF7B0ED2798800716715 /* CFDateFormatter.c in Sources */,
+				8448EF7C0ED2798800716715 /* CFDictionary.c in Sources */,
+				8448EF7D0ED2798800716715 /* CFError.c in Sources */,
+				8448EF7E0ED2798800716715 /* CFFileUtilities.c in Sources */,
+				8448EF7F0ED2798800716715 /* CFLocale.c in Sources */,
+				8448EF800ED2798800716715 /* CFLocaleIdentifier.c in Sources */,
+				8448EF810ED2798800716715 /* CFMachPort.c in Sources */,
+				8448EF820ED2798800716715 /* CFMessagePort.c in Sources */,
+				8448EF830ED2798800716715 /* CFNumber.c in Sources */,
+				8448EF840ED2798800716715 /* CFNumberFormatter.c in Sources */,
+				8448EF850ED2798800716715 /* CFPlatform.c in Sources */,
+				8448EF860ED2798800716715 /* CFPlugIn.c in Sources */,
+				8448EF870ED2798800716715 /* CFPlugIn_Factory.c in Sources */,
+				8448EF880ED2798800716715 /* CFPlugIn_Instance.c in Sources */,
+				8448EF890ED2798800716715 /* CFPlugIn_PlugIn.c in Sources */,
+				8448EF8A0ED2798800716715 /* CFPreferences.c in Sources */,
+				8448EF8B0ED2798800716715 /* CFPropertyList.c in Sources */,
+				8448EF8C0ED2798800716715 /* CFRunLoop.c in Sources */,
+				8448EF8D0ED2798800716715 /* CFRuntime.c in Sources */,
+				8448EF8E0ED2798800716715 /* CFSet.c in Sources */,
+				8448EF8F0ED2798800716715 /* CFSocket.c in Sources */,
+				8448EF900ED2798800716715 /* CFSocketStream.c in Sources */,
+				8448EF910ED2798800716715 /* CFSortFunctions.c in Sources */,
+				8448EF920ED2798800716715 /* CFStorage.c in Sources */,
+				8448EF930ED2798800716715 /* CFStream.c in Sources */,
+				8448EF940ED2798800716715 /* CFString.c in Sources */,
+				8448EF950ED2798800716715 /* CFStringEncodingConverter.c in Sources */,
+				8448EF960ED2798800716715 /* CFStringEncodings.c in Sources */,
+				8448EF970ED2798800716715 /* CFStringScanner.c in Sources */,
+				8448EF980ED2798800716715 /* CFStringUtilities.c in Sources */,
+				8448EF990ED2798800716715 /* CFSystemDirectories.c in Sources */,
+				8448EF9A0ED2798800716715 /* CFTimeZone.c in Sources */,
+				8448EF9B0ED2798800716715 /* CFTree.c in Sources */,
+				8448EF9C0ED2798800716715 /* CFUniChar.c in Sources */,
+				8448EF9D0ED2798800716715 /* CFUnicodeDecomposition.c in Sources */,
+				8448EF9E0ED2798800716715 /* CFUnicodePrecomposition.c in Sources */,
+				8448EF9F0ED2798800716715 /* CFURL.c in Sources */,
+				8448EFA00ED2798800716715 /* CFURLAccess.c in Sources */,
+				8448EFA10ED2798800716715 /* CFUserNotification.c in Sources */,
+				8448EFA20ED2798800716715 /* CFUtilities.c in Sources */,
+				8448EFA30ED2798800716715 /* CFUUID.c in Sources */,
+				8448EFA40ED2798800716715 /* CFVersion.c in Sources */,
+				8448EFA50ED2798800716715 /* CFXMLInputStream.c in Sources */,
+				8448EFA60ED2798800716715 /* CFXMLNode.c in Sources */,
+				8448EFA70ED2798800716715 /* CFXMLParser.c in Sources */,
+				8448EFA80ED2798800716715 /* CFXMLPreferencesDomain.c in Sources */,
+				8448EFA90ED2798800716715 /* CFXMLTree.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		8449497F0ED27E8700EEB9C0 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				844949890ED27EDF00EEB9C0 /* WritePListExample.cpp in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		8449498F0ED27F1100EEB9C0 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				844949A40ED27F8500EEB9C0 /* ReadPListExample.cpp in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		844F5D510F3FB1F600239823 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				844F5D5A0F3FB23100239823 /* DNSServiceMetaQuery.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		8481BA480F3EA69C00BD5189 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				8481BA540F3EA6C800BD5189 /* DisplayURL.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		84915D4A0F4B5CE600A3C0DD /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84915D540F4B5D0500A3C0DD /* CFRunLoopTimerExample.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		84CD60D80F4A03310049B4EC /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84CD60F50F4A04530049B4EC /* SimpleWebServer.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		84DA17190EDDF44500B6A2E6 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				84DA17270EDDF47E00B6A2E6 /* date_test.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+		84129FE10F3A4EC700A64427 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 84129FDA0F3A4E5400A64427 /* make_target_paths */;
+			targetProxy = 84129FE00F3A4EC700A64427 /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+		1DEB91F008733DB70010E9CD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_INPUT_FILETYPE = sourcecode.c.c;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_VERSION = 4.2;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				HEADER_SEARCH_PATHS = (
+					../..,
+					../../include,
+					../../include/mach_support,
+				);
+			};
+			name = Debug;
+		};
+		1DEB91F108733DB70010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_INPUT_FILETYPE = sourcecode.c.c;
+				GCC_VERSION = 4.2;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				HEADER_SEARCH_PATHS = (
+					../..,
+					../../include,
+					../../include/mach_support,
+				);
+			};
+			name = Release;
+		};
+		84129FDB0F3A4E5500A64427 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				PRODUCT_NAME = make_target_paths;
+			};
+			name = Debug;
+		};
+		84129FDC0F3A4E5500A64427 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				PRODUCT_NAME = make_target_paths;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		841BE8420F395D5C001F2A66 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = StringExample;
+			};
+			name = Debug;
+		};
+		841BE8430F395D5C001F2A66 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = StringExample;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		841BE9210F395F90001F2A66 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = AllocatorExample;
+			};
+			name = Debug;
+		};
+		841BE9220F395F90001F2A66 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = AllocatorExample;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		8448EF690ED2796600716715 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				DYLIB_COMPATIBILITY_VERSION = 150;
+				DYLIB_CURRENT_VERSION = 476;
+				FRAMEWORK_VERSION = A;
+				GCC_ENABLE_CPP_EXCEPTIONS = NO;
+				GCC_ENABLE_CPP_RTTI = NO;
+				GCC_ENABLE_PASCAL_STRINGS = NO;
+				GCC_FAST_OBJC_DISPATCH = YES;
+				GCC_INPUT_FILETYPE = sourcecode.c.c;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PFE_FILE_C_DIALECTS = c;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_VERSION = "";
+				HEADER_SEARCH_PATHS = (
+					../icu,
+					/usr/local/include,
+					../include/mach_support,
+					../dist/include,
+				);
+				INFOPLIST_FILE = ../Info.plist;
+				INIT_ROUTINE = "___CFInitialize";
+				INSTALL_PATH = "$(HOME)/Library/Frameworks";
+				OTHER_CFLAGS = (
+					"-fconstant-cfstrings",
+					"-DVERSION=476.17",
+					"-DDEPLOYMENT_TARGET_MACOSX=1",
+					"-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5",
+					"-DU_SHOW_DRAFT_API=1",
+				);
+				OTHER_LDFLAGS = (
+					"-twolevel_namespace",
+					"-sectcreate",
+					__UNICODE,
+					__csbitmaps,
+					../CFCharacterSetBitmaps.bitmap,
+					"-sectcreate",
+					__UNICODE,
+					__properties,
+					../CFUniCharPropertyDatabase.data,
+					"-sectcreate",
+					__UNICODE,
+					__data,
+					../$UNICODE_DATA_FILE,
+					"-segprot",
+					__UNICODE,
+					r,
+					r,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = CFLite;
+			};
+			name = Debug;
+		};
+		8448EF6A0ED2796600716715 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				DYLIB_COMPATIBILITY_VERSION = 150;
+				DYLIB_CURRENT_VERSION = 476;
+				FRAMEWORK_VERSION = A;
+				GCC_ENABLE_CPP_EXCEPTIONS = NO;
+				GCC_ENABLE_CPP_RTTI = NO;
+				GCC_ENABLE_PASCAL_STRINGS = NO;
+				GCC_FAST_OBJC_DISPATCH = YES;
+				GCC_INPUT_FILETYPE = sourcecode.c.c;
+				GCC_MODEL_TUNING = G5;
+				GCC_PFE_FILE_C_DIALECTS = c;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_VERSION = "";
+				HEADER_SEARCH_PATHS = (
+					../icu,
+					/usr/local/include,
+					../include/mach_support,
+					../dist/include,
+				);
+				INFOPLIST_FILE = ../Info.plist;
+				INIT_ROUTINE = "___CFInitialize";
+				INSTALL_PATH = "$(HOME)/Library/Frameworks";
+				OTHER_CFLAGS = (
+					"-fconstant-cfstrings",
+					"-DVERSION=476.17",
+					"-DDEPLOYMENT_TARGET_MACOSX=1",
+					"-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5",
+					"-DU_SHOW_DRAFT_API=1",
+				);
+				OTHER_LDFLAGS = (
+					"-twolevel_namespace",
+					"-sectcreate",
+					__UNICODE,
+					__csbitmaps,
+					../CFCharacterSetBitmaps.bitmap,
+					"-sectcreate",
+					__UNICODE,
+					__properties,
+					../CFUniCharPropertyDatabase.data,
+					"-sectcreate",
+					__UNICODE,
+					__data,
+					../$UNICODE_DATA_FILE,
+					"-segprot",
+					__UNICODE,
+					r,
+					r,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = CFLite;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		844949840ED27E8700EEB9C0 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = WritePListExample;
+			};
+			name = Debug;
+		};
+		844949850ED27E8700EEB9C0 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = WritePListExample;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		844949940ED27F1200EEB9C0 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = ReadPListExample;
+			};
+			name = Debug;
+		};
+		844949950ED27F1200EEB9C0 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = ReadPListExample;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		844F5D560F3FB1F700239823 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = DNSMetaServiceQuery;
+			};
+			name = Debug;
+		};
+		844F5D570F3FB1F700239823 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = DNSMetaServiceQuery;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		8481BA4D0F3EA69E00BD5189 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = DisplayURL;
+			};
+			name = Debug;
+		};
+		8481BA4E0F3EA69E00BD5189 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = DisplayURL;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		84915D4F0F4B5CE600A3C0DD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = CFRunLoopTimerExample;
+			};
+			name = Debug;
+		};
+		84915D500F4B5CE600A3C0DD /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = CFRunLoopTimerExample;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		84CD60DD0F4A03320049B4EC /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/build/Debug/CFLite.framework/Versions/A\"",
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = SimpleWebServer;
+			};
+			name = Debug;
+		};
+		84CD60DE0F4A03320049B4EC /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/build/Debug/CFLite.framework/Versions/A\"",
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = SimpleWebServer;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		84DA171E0EDDF44600B6A2E6 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B56490ECFB02B003D696F /* ConfigDebug.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = Test;
+			};
+			name = Debug;
+		};
+		84DA171F0EDDF44600B6A2E6 /* Release */ = {
+			isa = XCBuildConfiguration;
+			baseConfigurationReference = 848B564A0ECFB02B003D696F /* ConfigRelease.xcconfig */;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/bin;
+				PREBINDING = NO;
+				PRODUCT_NAME = Test;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "CFLite" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1DEB91F008733DB70010E9CD /* Debug */,
+				1DEB91F108733DB70010E9CD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		84129FDD0F3A4E9D00A64427 /* Build configuration list for PBXAggregateTarget "make_target_paths" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				84129FDB0F3A4E5500A64427 /* Debug */,
+				84129FDC0F3A4E5500A64427 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		841BE8440F395D8A001F2A66 /* Build configuration list for PBXNativeTarget "StringExample" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				841BE8420F395D5C001F2A66 /* Debug */,
+				841BE8430F395D5C001F2A66 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		841BE92A0F395FEB001F2A66 /* Build configuration list for PBXNativeTarget "AllocatorExample" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				841BE9210F395F90001F2A66 /* Debug */,
+				841BE9220F395F90001F2A66 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		8448EF6B0ED2796600716715 /* Build configuration list for PBXNativeTarget "CFLite" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				8448EF690ED2796600716715 /* Debug */,
+				8448EF6A0ED2796600716715 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		844949870ED27ED400EEB9C0 /* Build configuration list for PBXNativeTarget "WritePListExample" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				844949840ED27E8700EEB9C0 /* Debug */,
+				844949850ED27E8700EEB9C0 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		844949A10ED27F2800EEB9C0 /* Build configuration list for PBXNativeTarget "ReadPListExample" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				844949940ED27F1200EEB9C0 /* Debug */,
+				844949950ED27F1200EEB9C0 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		844F5D580F3FB22C00239823 /* Build configuration list for PBXNativeTarget "DNSMetaServiceQuery" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				844F5D560F3FB1F700239823 /* Debug */,
+				844F5D570F3FB1F700239823 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		8481BA560F3EA6E600BD5189 /* Build configuration list for PBXNativeTarget "DisplayURL" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				8481BA4D0F3EA69E00BD5189 /* Debug */,
+				8481BA4E0F3EA69E00BD5189 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		84915D550F4B5D0500A3C0DD /* Build configuration list for PBXNativeTarget "CFRunLoopTimerExample" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				84915D4F0F4B5CE600A3C0DD /* Debug */,
+				84915D500F4B5CE600A3C0DD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		84CD60E00F4A037A0049B4EC /* Build configuration list for PBXNativeTarget "SimpleWebServer" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				84CD60DD0F4A03320049B4EC /* Debug */,
+				84CD60DE0F4A03320049B4EC /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		84DA17220EDDF47000B6A2E6 /* Build configuration list for PBXNativeTarget "Test" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				84DA171E0EDDF44600B6A2E6 /* Debug */,
+				84DA171F0EDDF44600B6A2E6 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
diff --git a/CoreFoundation/tests/Make_win32.bat b/CoreFoundation/tests/Make_win32.bat
new file mode 100755
index 0000000..8dd10c8
--- /dev/null
+++ b/CoreFoundation/tests/Make_win32.bat
@@ -0,0 +1,4 @@
+cl /I../dist/include /D"WIN32" /D"_WIN32_WINNT=0x0501" /D"WINVER=0x0501" date_test.c ../dist/lib/CFLite.lib

+

+xcopy date_test.exe ..\dist\bin /Y

+

diff --git a/CoreFoundation/tests/Makefile.am b/CoreFoundation/tests/Makefile.am
new file mode 100644
index 0000000..d389f4c
--- /dev/null
+++ b/CoreFoundation/tests/Makefile.am
@@ -0,0 +1,22 @@
+AM_CFLAGS		= -I${top_srcdir}/include
+
+EXTRA_DIST		= Make_win32.bat
+
+if CF_BUILD_TESTS
+check_PROGRAMS		= date_test
+endif
+
+date_test_LDADD		= ${top_builddir}/libCoreFoundation.la
+
+date_test_SOURCES	= date_test.c
+
+if CF_BUILD_TESTS
+check:
+	${LIBTOOL} --mode execute ./date_test
+
+gdb:
+	${LIBTOOL} --mode execute ${@} ./date_test
+
+valgrind:
+	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./date_test
+endif
diff --git a/CoreFoundation/tests/Makefile.in b/CoreFoundation/tests/Makefile.in
new file mode 100644
index 0000000..551ee04
--- /dev/null
+++ b/CoreFoundation/tests/Makefile.in
@@ -0,0 +1,469 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@CF_BUILD_TESTS_TRUE@check_PROGRAMS = date_test$(EXEEXT)
+subdir = tests
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am_date_test_OBJECTS = date_test.$(OBJEXT)
+date_test_OBJECTS = $(am_date_test_OBJECTS)
+date_test_DEPENDENCIES = ${top_builddir}/libCoreFoundation.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(date_test_SOURCES)
+DIST_SOURCES = $(date_test_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CF_VERSION_INFO = @CF_VERSION_INFO@
+CMP = @CMP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+ICU_CONFIG = @ICU_CONFIG@
+ICU_CPPFLAGS = @ICU_CPPFLAGS@
+ICU_LDFLAGS = @ICU_LDFLAGS@
+ICU_LIBS = @ICU_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UUID_CONFIG = @UUID_CONFIG@
+UUID_CPPFLAGS = @UUID_CPPFLAGS@
+UUID_LDFLAGS = @UUID_LDFLAGS@
+UUID_LIBS = @UUID_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -I${top_srcdir}/include
+EXTRA_DIST = Make_win32.bat
+date_test_LDADD = ${top_builddir}/libCoreFoundation.la
+date_test_SOURCES = date_test.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  tests/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+date_test$(EXEEXT): $(date_test_OBJECTS) $(date_test_DEPENDENCIES) 
+	@rm -f date_test$(EXEEXT)
+	$(LINK) $(date_test_OBJECTS) $(date_test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/date_test.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+@CF_BUILD_TESTS_TRUE@check:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ./date_test
+
+@CF_BUILD_TESTS_TRUE@gdb:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ./date_test
+
+@CF_BUILD_TESTS_TRUE@valgrind:
+@CF_BUILD_TESTS_TRUE@	${LIBTOOL} --mode execute ${@} ${VALGRINDFLAGS} ./date_test
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/CoreFoundation/tests/date_test.c b/CoreFoundation/tests/date_test.c
new file mode 100644
index 0000000..641e586
--- /dev/null
+++ b/CoreFoundation/tests/date_test.c
@@ -0,0 +1,112 @@
+/*
+ *  date_test.c
+ *  CFLite
+ *
+ *  A compilation of various examples from the "Date and Times Programming Guide for CoreFoundation".
+ *
+ *  http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFDatesAndTimes/CFDatesAndTimes.html
+ *
+ */
+
+#include <stdio.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+bool check_date_constructors ()
+{
+   CFAbsoluteTime      absTime;
+   CFDateRef           aCFDate;
+   
+   CFShow(CFSTR("Checking date constructors:"));
+
+   absTime = CFAbsoluteTimeGetCurrent();
+   aCFDate = CFDateCreate(kCFAllocatorDefault, absTime);
+   
+   CFShow(CFSTR("Absolute Time is"));
+   printf("The current absolute time is %f\n", absTime);
+   CFShow(CFSTR("Equivalent CFDate object is"));
+   CFShow(aCFDate);
+   
+   printf("\n");
+   
+   return true;
+}
+
+bool check_date_comparison ()
+{
+   CFDateRef           date1, date2;
+   
+   // Standard Core Foundation comparison result.
+   CFComparisonResult result;
+   
+   CFShow(CFSTR("Checking date comparison functions:"));
+   
+   // Create two CFDates from absolute time.
+   date1 = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent());
+   date2 = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent());
+   
+   // Pass NULL for the context param.
+   result = CFDateCompare(date1, date2, NULL);
+   
+   switch (result) {
+      case kCFCompareLessThan:
+         CFShow(CFSTR("date1 is before date2!\n"));
+         break;
+      case kCFCompareEqualTo:
+         CFShow(CFSTR("date1 is the same as date2!\n"));
+         break;
+      case kCFCompareGreaterThan:
+         CFShow(CFSTR("date1 is after date2!\n"));
+         break;
+   }
+   
+   printf("\n");
+
+   return true;
+}
+
+bool check_gregorian_dates ()
+{
+   Boolean             status;
+   CFGregorianDate     gregDate;
+   CFAbsoluteTime      absTime;
+   
+   long                weekOfYear, dayOfWeek;
+   
+   CFShow(CFSTR("Checking Gregorian date functions"));
+   
+   // Construct a Gregorian date.
+   gregDate.year = 1999;
+   gregDate.month = 11;
+   gregDate.day = 23;
+   gregDate.hour = 17;
+   gregDate.minute = 33;
+   gregDate.second = 22.7;
+   
+   // Check the validity of the date.
+   status = CFGregorianDateIsValid(gregDate, kCFGregorianAllUnits);
+   printf("Is my Gregorian date valid? %d\n", status);
+   
+   // Convert the Gregorian date to absolute time.
+   absTime = CFGregorianDateGetAbsoluteTime(gregDate, NULL);
+   printf("The Absolute Time from a Gregorian date is: %f\n", absTime);
+   
+   CFShow(CFSTR("This corresponds to the following:"));
+   weekOfYear = CFAbsoluteTimeGetWeekOfYear (absTime, NULL);
+   dayOfWeek = CFAbsoluteTimeGetDayOfWeek (absTime, NULL);
+   
+   printf("Week of the year for %d-%d-%d is %ld\n", gregDate.month, gregDate.day, gregDate.year, weekOfYear);
+   printf("Day of the week for %d-%d-%d is %ld\n", gregDate.month, gregDate.day, gregDate.year, dayOfWeek);
+
+   printf("\n");
+
+   return true;
+}
+
+int main (int argc, const char** argv)
+{
+   check_date_constructors ();
+   check_date_comparison ();
+   check_gregorian_dates ();
+   return 0;
+}
\ No newline at end of file
diff --git a/CoreFoundation/windows/CFLiteLib.vcproj b/CoreFoundation/windows/CFLiteLib.vcproj
new file mode 100644
index 0000000..91038b3
--- /dev/null
+++ b/CoreFoundation/windows/CFLiteLib.vcproj
@@ -0,0 +1,1818 @@
+<?xml version="1.0" encoding="Windows-1252"?>

+<VisualStudioProject

+	ProjectType="Visual C++"

+	Version="8.00"

+	Name="CFLite"

+	ProjectGUID="{EC99198F-4CDD-4D85-AE6F-F837FF6CC372}"

+	RootNamespace="CFLiteLib"

+	Keyword="Win32Proj"

+	>

+	<Platforms>

+		<Platform

+			Name="Win32"

+		/>

+	</Platforms>

+	<ToolFiles>

+	</ToolFiles>

+	<Configurations>

+		<Configuration

+			Name="Debug|Win32"

+			OutputDirectory="$(SolutionDir)\dist\bin"

+			IntermediateDirectory="$(ConfigurationName)"

+			ConfigurationType="2"

+			CharacterSet="1"

+			>

+			<Tool

+				Name="VCPreBuildEventTool"

+				Description="Prepare include path"

+				CommandLine="mkdir &quot;$(SolutionDir)\dist\bin&quot;&#x0D;&#x0A;mkdir &quot;$(SolutionDir)\dist\lib&quot;&#x0D;&#x0A;mkdir &quot;$(SolutionDir)\dist\include\CoreFoundation&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\*.h&quot; &quot;$(SolutionDir)\dist\include\CoreFoundation\&quot;&#x0D;&#x0A;mkdir &quot;$(SolutionDir)\dist\include\CoreFoundation\GNUCompatibility\&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\include\c99\*.h&quot; &quot;$(SolutionDir)\dist\include\&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\include\*.h&quot; &quot;$(SolutionDir)\dist\include\&quot;&#x0D;&#x0A;"

+			/>

+			<Tool

+				Name="VCCustomBuildTool"

+			/>

+			<Tool

+				Name="VCXMLDataGeneratorTool"

+			/>

+			<Tool

+				Name="VCWebServiceProxyGeneratorTool"

+			/>

+			<Tool

+				Name="VCMIDLTool"

+			/>

+			<Tool

+				Name="VCCLCompilerTool"

+				Optimization="0"

+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;;&quot;$(SolutionDir)\dist\include\CoreFoundation\GNUCompatibility&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)\icu&quot;"

+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CFLITELIB_EXPORTS;DEPLOYMENT_TARGET_WINDOWS;WIN32_LEAN_AND_MEAN;__STDC_LIMIT_MACROS;CF_BUILDING_CF;_WIN32_WINNT=0x0500;WINVER=0x0500;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"

+				MinimalRebuild="true"

+				BasicRuntimeChecks="3"

+				RuntimeLibrary="3"

+				UsePrecompiledHeader="0"

+				WarningLevel="3"

+				Detect64BitPortabilityProblems="true"

+				DebugInformationFormat="4"

+			/>

+			<Tool

+				Name="VCManagedResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCPreLinkEventTool"

+				CommandLine=""

+			/>

+			<Tool

+				Name="VCLinkerTool"

+				AdditionalDependencies="netapi32.lib ole32.lib ws2_32.lib kernel32.lib icuuc.lib icuin.lib rpcrt4.lib msvcrt.lib"

+				OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).dll"

+				LinkIncremental="2"

+				AdditionalLibraryDirectories="$(SolutionDir)\icu\lib"

+				GenerateDebugInformation="true"

+				SubSystem="2"

+				ImportLibrary="$(SolutionDir)\dist\lib\$(TargetName).lib"

+				TargetMachine="1"

+			/>

+			<Tool

+				Name="VCALinkTool"

+			/>

+			<Tool

+				Name="VCManifestTool"

+			/>

+			<Tool

+				Name="VCXDCMakeTool"

+			/>

+			<Tool

+				Name="VCBscMakeTool"

+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"

+			/>

+			<Tool

+				Name="VCFxCopTool"

+			/>

+			<Tool

+				Name="VCAppVerifierTool"

+			/>

+			<Tool

+				Name="VCWebDeploymentTool"

+			/>

+			<Tool

+				Name="VCPostBuildEventTool"

+				CommandLine="copy &quot;$(SolutionDir)\icu\bin\*.dll&quot; &quot;$(SolutionDir)\dist\bin\&quot;&#x0D;&#x0A;"

+			/>

+		</Configuration>

+		<Configuration

+			Name="Release|Win32"

+			OutputDirectory="$(SolutionDir)\dist\bin"

+			IntermediateDirectory="$(ConfigurationName)"

+			ConfigurationType="2"

+			CharacterSet="1"

+			WholeProgramOptimization="1"

+			>

+			<Tool

+				Name="VCPreBuildEventTool"

+				Description="Prepare include path"

+				CommandLine="mkdir &quot;$(SolutionDir)\dist\bin&quot;&#x0D;&#x0A;mkdir &quot;$(SolutionDir)\dist\lib&quot;&#x0D;&#x0A;mkdir &quot;$(SolutionDir)\dist\include\CoreFoundation&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\*.h&quot; &quot;$(SolutionDir)\dist\include\CoreFoundation\&quot;&#x0D;&#x0A;mkdir &quot;$(SolutionDir)\dist\include\CoreFoundation\GNUCompatibility\&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\include\c99\*.h&quot; &quot;$(SolutionDir)\dist\include\&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\include\*.h&quot; &quot;$(SolutionDir)\dist\include\&quot;&#x0D;&#x0A;"

+			/>

+			<Tool

+				Name="VCCustomBuildTool"

+			/>

+			<Tool

+				Name="VCXMLDataGeneratorTool"

+			/>

+			<Tool

+				Name="VCWebServiceProxyGeneratorTool"

+			/>

+			<Tool

+				Name="VCMIDLTool"

+			/>

+			<Tool

+				Name="VCCLCompilerTool"

+				AdditionalIncludeDirectories="&quot;$(SolutionDir)\dist\include&quot;;&quot;$(SolutionDir)\dist\include\CoreFoundation\GNUCompatibility&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)\icu&quot;"

+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CFLITELIB_EXPORTS;DEPLOYMENT_TARGET_WINDOWS;WIN32_LEAN_AND_MEAN;__STDC_LIMIT_MACROS;CF_BUILDING_CF;_WIN32_WINNT=0x0500;WINVER=0x0500;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"

+				RuntimeLibrary="2"

+				UsePrecompiledHeader="0"

+				WarningLevel="3"

+				Detect64BitPortabilityProblems="true"

+				DebugInformationFormat="3"

+			/>

+			<Tool

+				Name="VCManagedResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCResourceCompilerTool"

+			/>

+			<Tool

+				Name="VCPreLinkEventTool"

+				CommandLine=""

+			/>

+			<Tool

+				Name="VCLinkerTool"

+				AdditionalDependencies="netapi32.lib ole32.lib ws2_32.lib kernel32.lib icuuc.lib icuin.lib rpcrt4.lib msvcrt.lib"

+				LinkIncremental="1"

+				AdditionalLibraryDirectories="$(SolutionDir)\icu\lib"

+				GenerateDebugInformation="true"

+				SubSystem="2"

+				OptimizeReferences="2"

+				EnableCOMDATFolding="2"

+				ImportLibrary="$(SolutionDir)\dist\lib\$(TargetName).lib"

+				TargetMachine="1"

+			/>

+			<Tool

+				Name="VCALinkTool"

+			/>

+			<Tool

+				Name="VCManifestTool"

+			/>

+			<Tool

+				Name="VCXDCMakeTool"

+			/>

+			<Tool

+				Name="VCBscMakeTool"

+				OutputFile="$(SolutionDir)\dist\bin\$(ProjectName)_$(ConfigurationName).bsc"

+			/>

+			<Tool

+				Name="VCFxCopTool"

+			/>

+			<Tool

+				Name="VCAppVerifierTool"

+			/>

+			<Tool

+				Name="VCWebDeploymentTool"

+			/>

+			<Tool

+				Name="VCPostBuildEventTool"

+				CommandLine="copy &quot;$(SolutionDir)\icu\bin\*.dll&quot; &quot;$(SolutionDir)\dist\bin\&quot;&#x0D;&#x0A;"

+			/>

+		</Configuration>

+	</Configurations>

+	<References>

+	</References>

+	<Files>

+		<Filter

+			Name="Source Files"

+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"

+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"

+			>

+			<File

+				RelativePath="..\CFApplicationPreferences.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFArray.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBag.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBase.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBinaryHeap.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBinaryPList.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBitVector.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBuiltinConverters.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBundle.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFBundle_Resources.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFCalendar.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFCharacterSet.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFConcreteStreams.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFData.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFDate.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFDateFormatter.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFDictionary.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFError.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFFileUtilities.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFLocale.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFLocaleIdentifier.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFMachPort.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFMessagePort.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFNumber.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFNumberFormatter.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFPlatform.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFPlugIn.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFPlugIn_Factory.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFPlugIn_Instance.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFPlugIn_PlugIn.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFPreferences.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFPropertyList.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFRunLoop.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFRuntime.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFSet.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFSocket.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFSocketStream.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFSortFunctions.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFStorage.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFStream.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFString.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFStringEncodingConverter.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFStringEncodings.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFStringScanner.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFStringUtilities.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFSystemDirectories.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFTimeZone.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFTree.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFUniChar.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFUnicodeDecomposition.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFUnicodePrecomposition.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFURL.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFURLAccess.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFUserNotification.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFUtilities.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFUUID.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFVersion.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFWindowsMessageQueue.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFXMLInputStream.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFXMLNode.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFXMLParser.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFXMLPreferencesDomain.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<File

+				RelativePath="..\CFXMLTree.c"

+				>

+				<FileConfiguration

+					Name="Debug|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+				<FileConfiguration

+					Name="Release|Win32"

+					>

+					<Tool

+						Name="VCCLCompilerTool"

+						CompileAs="2"

+					/>

+				</FileConfiguration>

+			</File>

+			<Filter

+				Name="compat"

+				>

+				<File

+					RelativePath="..\compat\dirent.c"

+					>

+				</File>

+				<File

+					RelativePath="..\compat\dirent.h"

+					>

+				</File>

+				<File

+					RelativePath="..\compat\flsl.c"

+					>

+					<FileConfiguration

+						Name="Debug|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+					<FileConfiguration

+						Name="Release|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+				</File>

+				<File

+					RelativePath="..\compat\gettimeofday.c"

+					>

+					<FileConfiguration

+						Name="Debug|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+					<FileConfiguration

+						Name="Release|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+				</File>

+				<File

+					RelativePath="..\compat\strlcat.c"

+					>

+					<FileConfiguration

+						Name="Debug|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+					<FileConfiguration

+						Name="Release|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+				</File>

+				<File

+					RelativePath="..\compat\strlcpy.c"

+					>

+					<FileConfiguration

+						Name="Debug|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+					<FileConfiguration

+						Name="Release|Win32"

+						>

+						<Tool

+							Name="VCCLCompilerTool"

+							CompileAs="2"

+						/>

+					</FileConfiguration>

+				</File>

+			</Filter>

+		</Filter>

+		<Filter

+			Name="Header Files"

+			Filter="h;hpp;hxx;hm;inl;inc;xsd"

+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"

+			>

+			<File

+				RelativePath="..\auto_stubs.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFArray.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBag.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBase.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBinaryHeap.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBitVector.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBundle.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBundle_BinaryTypes.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBundle_Internal.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFBundlePriv.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFByteOrder.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFCalendar.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFCharacterSet.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFCharacterSetPriv.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFData.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFDate.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFDateFormatter.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFDictionary.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFError.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFError_Private.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFInternal.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFLocale.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFLogUtilities.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFMachPort.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFMessagePort.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFNumber.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFNumberFormatter.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFPlugIn.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFPlugIn_Factory.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFPlugInCOM.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFPreferences.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFPriv.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFPropertyList.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFRunLoop.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFRunLoopPriv.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFRuntime.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFSet.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFSocket.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStorage.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStream.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStreamAbstract.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStreamInternal.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStreamPriv.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFString.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStringDefaultEncoding.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStringEncodingConverter.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStringEncodingConverterExt.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStringEncodingConverterPriv.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFStringEncodingExt.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFTimeZone.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFTree.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFUniChar.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFUniCharPriv.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFUnicodeDecomposition.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFUnicodePrecomposition.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFURL.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFURLAccess.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFUserNotification.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFUUID.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFWindowsMessageQueue.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFXMLInputStream.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFXMLNode.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CFXMLParser.h"

+				>

+			</File>

+			<File

+				RelativePath="..\CoreFoundation.h"

+				>

+			</File>

+			<File

+				RelativePath="..\ForFoundationOnly.h"

+				>

+			</File>

+		</Filter>

+	</Files>

+	<Globals>

+	</Globals>

+</VisualStudioProject>